Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

fix(test-types): declare the fields startMockServer actually returns

M3gA-Mind7306f3ee626e
diff --git a/scripts/mock-api-core.d.mts b/scripts/mock-api-core.d.mts
index 71fdcaebf8..dfa3abc970 100644
--- a/scripts/mock-api-core.d.mts
+++ b/scripts/mock-api-core.d.mts
@@ -47,11 +47,31 @@ export function resetMockBehavior(): void;
export function getMockServerPort(): number | null;
-/** Signature per `scripts/mock-api/server.mjs:254`: port first, options second. */
+/**
+ * Start the mock backend. Signature per `scripts/mock-api/server.mjs:254`:
+ * port first, options second.
+ *
+ * The result has two shapes and this declaration has to admit both, so the
+ * extra fields are optional rather than absent: an already-running server
+ * returns `{ port, alreadyRunning: true }` (`server.mjs:256`), while a fresh
+ * start also reports the port it was asked for and whether `retryIfInUse` had
+ * to move off it (`server.mjs:286-290`). An earlier version of this file
+ * declared only the first shape, which compiled everywhere until a test read
+ * `requestedPort` — the same failure mode the `MockRequestEntry` note above
+ * describes, in the opposite direction: a declaration NARROWER than the runtime
+ * hides fields that exist, rather than inventing ones that do not.
+ */
export function startMockServer(
port?: number,
options?: { retryIfInUse?: boolean },
-): Promise<{ port: number; alreadyRunning?: boolean }>;
+): Promise<{
+ port: number;
+ alreadyRunning?: boolean;
+ /** The port asked for, when a fresh start resolved one. */
+ requestedPort?: number;
+ /** True when `retryIfInUse` moved the server off `requestedPort`. */
+ retried?: boolean;
+}>;
export function stopMockServer(): Promise<void>;