OpenAI's Codex Security CLI and TypeScript SDK for finding, validating, and fixing security vulnerabilities. npm: https://www.npmjs.com/package/@openai/codex-security
TypeScript ai-securityapplication-securityclicode-scanningcodexcodex-securitycybersecuritydevsecopsnodejsnpmopenaisdksecuritytypescriptvulnerability-scanning
test(mcp): share worker-launch and tool-request setup (#1357)
mldangelo-oai39f041ab7818
diff --git a/plugins/codex-security/mcp-app/tests/test_deep_scan_executor.ts b/plugins/codex-security/mcp-app/tests/test_deep_scan_executor.tsindex d568af3c2..e2b5d74bd 100644--- a/plugins/codex-security/mcp-app/tests/test_deep_scan_executor.ts+++ b/plugins/codex-security/mcp-app/tests/test_deep_scan_executor.ts@@ -25,6 +25,7 @@ import { importModule } from "./import-module.ts";import type {CodexWorkerDiagnostic,+ CodexWorkerRequest,DeepScanWorkerKind,} from "../src/deep-scan/types.js";@@ -388,15 +389,7 @@ async function testWindowsLongExecutableLaunches() {(await snapshotWorkerEnvironment()).CODEX_CLI_PATH,configured,);- const result = await new CodexSdkWorkerExecutor({- parentSandbox: trustedParentSandbox,- }).run({- kind: "discovery",- promptPath,- workingDirectory,- subagents: 0,- signal: new AbortController().signal,- });+ const result = await runWorker(promptPath, workingDirectory);assert.equal(result.threadId, "fixture-thread-id");const invocation = await readJson(fixture.markerPath);assert.deepEqual(invocation.argv.slice(0, 2), [@@ -777,15 +770,7 @@ async function testWorkerLaunchesWithoutGlobalCodex() {await mkdir(workingDirectory);await writeFile(promptPath, "fixture nested worker without global codex\n");- const result = await new CodexSdkWorkerExecutor({- parentSandbox: trustedParentSandbox,- }).run({- kind: "discovery",- promptPath,- workingDirectory,- subagents: 0,- signal: new AbortController().signal,- });+ const result = await runWorker(promptPath, workingDirectory);assert.equal(result.threadId, "fixture-thread-id");const invocation = await readJson(fixture.markerPath);@@ -855,15 +840,7 @@ async function testPreflightBindsExecutableAndHomeBeforeChangingCwd() {if (configured === undefined) delete process.env.CODEX_CLI_PATH;else process.env.CODEX_CLI_PATH = configured;assert.equal(resolveCodexPath(), expectedExecutable);- const result = await new CodexSdkWorkerExecutor({- parentSandbox: trustedParentSandbox,- }).run({- kind: "discovery",- promptPath,- workingDirectory,- subagents: 0,- signal: new AbortController().signal,- });+ const result = await runWorker(promptPath, workingDirectory);assert.equal(result.threadId, "fixture-thread-id");const preflight = await readJson(fixture.preflightMarkerPath);@@ -900,14 +877,12 @@ async function testSdkInvocationAndThreadCapture() {model: "gpt-5.6-luna",reasoningEffort: "xhigh",parentSandbox: trustedParentSandboxWithDenials,- }).run({- kind: "discovery",- promptPath,- workingDirectory,- subagents: 3,- signal: new AbortController().signal,- onThreadStarted: onThreadId,- });+ }).run(+ workerRequest(promptPath, workingDirectory, {+ subagents: 3,+ onThreadStarted: onThreadId,+ }),+ );assert.equal(result.threadId, "fixture-thread-id");const callbackThreadId = onThreadId.mock.calls.at(-1)?.arguments[0];assert.equal(callbackThreadId, "fixture-thread-id");@@ -1052,14 +1027,9 @@ async function testOpenAiCredentialsReachWorker() {});for (const kind of ["discovery", "dedup"] as const) {for (const resumeThreadId of [undefined, "fixture-resume"]) {- await executor.run({- kind,- promptPath,- workingDirectory: fixture.root,- subagents: 0,- resumeThreadId,- signal: new AbortController().signal,- });+ await executor.run(+ workerRequest(promptPath, fixture.root, { kind, resumeThreadId }),+ );const preflight = await readJson(fixture.preflightMarkerPath);const invocation = await readJson(fixture.markerPath);assert.equal(preflight.codexHome, fixture.root);@@ -1252,26 +1222,24 @@ env_key = "SYNTHETIC_GATEWAY_KEY"`,} else {process.env.SYNTHETIC_GATEWAY_KEY = providerKeys[index];}- return executor.run({- kind,- promptPath,- workingDirectory: fixture.root,- subagents: 0,- resumeThreadId,- artifactContext: {- root: fixture.root,- layout: kind === "dedup" ? "reducer" : "worker",- ...(kind === "dedup"- ? {- deepReducer: {- scanRoot: fixture.root,- claimedWorkers: [],- },- }- : {}),- },- signal: new AbortController().signal,- });+ return executor.run(+ workerRequest(promptPath, fixture.root, {+ kind,+ resumeThreadId,+ artifactContext: {+ root: fixture.root,+ layout: kind === "dedup" ? "reducer" : "worker",+ ...(kind === "dedup"+ ? {+ deepReducer: {+ scanRoot: fixture.root,+ claimedWorkers: [],+ },+ }+ : {}),+ },+ }),+ );}),);const workerLaunches = launches.filter(@@ -1488,14 +1456,9 @@ async function testWorkerCyberAccessSettings() {cases.map((testCase) => {// Each scan captures its own config before its asynchronous launch.process.env.CODEX_SECURITY_CONFIG_PATH = testCase.configPath;- return testCase.executor!.run({- kind,- resumeThreadId,- promptPath,- workingDirectory: fixture.root,- subagents: 0,- signal: new AbortController().signal,- });+ return testCase.executor!.run(+ workerRequest(promptPath, fixture.root, { kind, resumeThreadId }),+ );}),);const workerLaunches = launches.filter(@@ -1594,14 +1557,9 @@ async function testBedrockCredentialsReachWorker() {});for (const kind of ["discovery", "dedup"] as const) {for (const resumeThreadId of [undefined, "fixture-bedrock-resume"]) {- const result = await executor.run({- kind,- promptPath,- workingDirectory,- subagents: 0,- resumeThreadId,- signal: new AbortController().signal,- });+ const result = await executor.run(+ workerRequest(promptPath, workingDirectory, { kind, resumeThreadId }),+ );assert.equal(result.threadId, resumeThreadId ?? "fixture-thread-id");const invocation = await readJson(fixture.markerPath);assert.deepEqual(invocation.bedrockAuthentication, awsEnvironment);@@ -1630,13 +1588,7 @@ async function testZeroSubagentsPreservesHostRestrictions() {const result = await new CodexSdkWorkerExecutor({model,parentSandbox: trustedParentSandbox,- }).run({- kind: "discovery",- promptPath,- workingDirectory,- subagents: 0,- signal: new AbortController().signal,- });+ }).run(workerRequest(promptPath, workingDirectory));assert.equal(result.threadId, "fixture-thread-id");const invocation = await readJson(fixture.markerPath);assertFlagPair(invocation.argv, "--model", model);@@ -1656,14 +1608,11 @@ async function testArtifactServerUsesExtendedStartupTimeout() {repoRoot: fixture.root,scanId: "fixture-scan-id",},- }).run({- kind: "discovery",- promptPath,- workingDirectory,- subagents: 0,- signal: new AbortController().signal,- artifactContext: { root: workingDirectory, layout: "worker" },- });+ }).run(+ workerRequest(promptPath, workingDirectory, {+ artifactContext: { root: workingDirectory, layout: "worker" },+ }),+ );assert.equal(result.threadId, "fixture-thread-id");const invocation = await readJson(fixture.markerPath);assertConfigOverrides(invocation.argv, {@@ -1681,15 +1630,13 @@ async function testSdkResumesExistingThread() {model: "gpt-5.6-sol",reasoningEffort: "ultra",parentSandbox: trustedParentSandbox,- }).run({- kind: "discovery",- promptPath,- workingDirectory,- subagents: 3,- signal: new AbortController().signal,- resumeThreadId: "fixture-existing-thread",- continuationPrompt: "continue the existing worker\n",- });+ }).run(+ workerRequest(promptPath, workingDirectory, {+ subagents: 3,+ resumeThreadId: "fixture-existing-thread",+ continuationPrompt: "continue the existing worker\n",+ }),+ );assert.equal(result.threadId, "fixture-existing-thread");const invocation = await readJson(fixture.markerPath);const resumeIndex = invocation.argv.indexOf("resume");@@ -1706,14 +1653,8 @@ async function testSdkResumesExistingThread() {async function testRetryNotificationDoesNotInterruptTurn() {return withWorkerFixture(async (fixture, promptPath, workingDirectory) => {await writeFile(promptPath, "RETRYABLE_STREAM_ERROR\n");- const result = await new CodexSdkWorkerExecutor({- parentSandbox: trustedParentSandbox,- }).run({- kind: "discovery",- promptPath,- workingDirectory,+ const result = await runWorker(promptPath, workingDirectory, {subagents: 3,- signal: new AbortController().signal,});assert.equal(result.threadId, "fixture-thread-id");const invocation = await readJson(fixture.markerPath);@@ -1870,14 +1811,8 @@ async function testCodeModeFrameDiagnosticSurvivesSuccessfulTurn() {promptPath,`IPC_DIAGNOSTIC_EVENT\n${JSON.stringify(event)}\n`,);- const result = await new CodexSdkWorkerExecutor({- parentSandbox: trustedParentSandbox,- }).run({+ const result = await runWorker(promptPath, workingDirectory, {kind: "dedup",- promptPath,- workingDirectory,- subagents: 0,- signal: new AbortController().signal,});assert.equal(result.threadId, "fixture-thread-id");assert.deepEqual(result.diagnostics, [@@ -2038,14 +1973,7 @@ async function testMalformedCommandEventsRemainRetryable() {);const onThreadId = mock.fn();await assert.rejects(- new CodexSdkWorkerExecutor({- parentSandbox: trustedParentSandbox,- }).run({- kind: "discovery",- promptPath,- workingDirectory,- subagents: 0,- signal: new AbortController().signal,+ runWorker(promptPath, workingDirectory, {onThreadStarted: onThreadId,}),(error: NodeJS.ErrnoException & { cause?: NodeJS.ErrnoException }) =>@@ -2097,13 +2025,12 @@ async function testMissingParentSandboxFailsBeforeWorkerLaunch() {process.env.CODEX_CLI_PATH = fixture.executablePath;try {await assert.rejects(- new CodexSdkWorkerExecutor().run({- kind: "discovery",- promptPath: path.join(fixture.root, "missing-prompt.md"),- workingDirectory: path.join(fixture.root, "artifacts"),- subagents: 0,- signal: new AbortController().signal,- }),+ new CodexSdkWorkerExecutor().run(+ workerRequest(+ path.join(fixture.root, "missing-prompt.md"),+ path.join(fixture.root, "artifacts"),+ ),+ ),(error: NodeJS.ErrnoException & { cause?: NodeJS.ErrnoException }) =>error?.name === "DeepScanNonRetryableError" &&/verified parent sandbox metadata/i.test(error.message),@@ -2124,15 +2051,7 @@ async function testDisallowedWorkerProfileFailsBeforeWorkerLaunch() {await writeFile(promptPath, "fixture blocked worker prompt\n");await assert.rejects(- new CodexSdkWorkerExecutor({- parentSandbox: trustedParentSandbox,- }).run({- kind: "discovery",- promptPath,- workingDirectory,- subagents: 0,- signal: new AbortController().signal,- }),+ runWorker(promptPath, workingDirectory),(error: NodeJS.ErrnoException & { cause?: NodeJS.ErrnoException }) =>error?.name === "DeepScanNonRetryableError" &&error.message.includes("codex_security_deep_scan_worker") &&@@ -2160,15 +2079,7 @@ async function testRuntimePermissionProfileFallbackStopsAndDiscards() {await writeFile(promptPath, `${marker}\n`);await assert.rejects(- new CodexSdkWorkerExecutor({- parentSandbox: trustedParentSandbox,- }).run({- kind: "discovery",- promptPath,- workingDirectory,- subagents: 0,- signal: new AbortController().signal,- }),+ runWorker(promptPath, workingDirectory),(error: NodeJS.ErrnoException & { cause?: NodeJS.ErrnoException }) =>error?.name === "DeepScanNonRetryableError" &&error.message.includes("worker was stopped") &&@@ -2181,6 +2092,31 @@ async function testRuntimePermissionProfileFallbackStopsAndDiscards() {}}+function runWorker(+ promptPath: string,+ workingDirectory: string,+ options: Partial<CodexWorkerRequest> = {},+) {+ return new CodexSdkWorkerExecutor({+ parentSandbox: trustedParentSandbox,+ }).run(workerRequest(promptPath, workingDirectory, options));+}++function workerRequest(+ promptPath: string,+ workingDirectory: string,+ options: Partial<CodexWorkerRequest> = {},+): CodexWorkerRequest {+ return {+ kind: "discovery",+ promptPath,+ workingDirectory,+ subagents: 0,+ signal: new AbortController().signal,+ ...options,+ };+}+async function runFixtureWorker(prompt: string,kind: DeepScanWorkerKind = "discovery",@@ -2188,15 +2124,7 @@ async function runFixtureWorker() {return withWorkerFixture(async (fixture, promptPath, workingDirectory) => {await writeFile(promptPath, `${prompt}\n`);- return await new CodexSdkWorkerExecutor({- parentSandbox: trustedParentSandbox,- }).run({- kind,- promptPath,- workingDirectory,- subagents,- signal: new AbortController().signal,- });+ return await runWorker(promptPath, workingDirectory, { kind, subagents });});}diff --git a/plugins/codex-security/mcp-app/tests/test_mcp_app_smoke.ts b/plugins/codex-security/mcp-app/tests/test_mcp_app_smoke.tsindex de8d4ac06..1619bc954 100644--- a/plugins/codex-security/mcp-app/tests/test_mcp_app_smoke.ts+++ b/plugins/codex-security/mcp-app/tests/test_mcp_app_smoke.ts@@ -236,6 +236,16 @@ function startTestServer({}throw new Error(`Timed out waiting for ${description}`);},+ initialize(name: string, capabilities: Record<string, unknown> = {}) {+ return this.requestAndWait(1, "initialize", {+ protocolVersion: "2025-11-25",+ capabilities,+ clientInfo: { name, version: "0.1.0" },+ });+ },+ callTool(id: number, params: Record<string, unknown>) {+ return this.requestAndWait(id, "tools/call", params);+ },async requestAndWait(id: number, method: string, params = {}) {writeMessage(childProcess, { jsonrpc: "2.0", id, method, params });const started = Date.now();@@ -322,14 +332,7 @@ async function assertBundledNodeLauncher() {});try {assertNoError(- await bundledNodeServer.requestAndWait(1, "initialize", {- protocolVersion: "2025-11-25",- capabilities: {},- clientInfo: {- name: "codex-security-bundled-node-smoke",- version: "0.1.0",- },- }),+ await bundledNodeServer.initialize("codex-security-bundled-node-smoke"),);assertNoError(await bundledNodeServer.requestAndWait(2, "tools/list"));if (!windows) {@@ -357,16 +360,11 @@ async function assertMissingPythonError() {});try {assertNoError(- await missingPythonServer.requestAndWait(1, "initialize", {- protocolVersion: "2025-11-25",- capabilities: {},- clientInfo: {- name: "codex-security-missing-python-smoke",- version: "0.1.0",- },- }),+ await missingPythonServer.initialize(+ "codex-security-missing-python-smoke",+ ),);- const response = await missingPythonServer.requestAndWait(2, "tools/call", {+ const response = await missingPythonServer.callTool(2, {name: "inspect_codex_security_target",arguments: { targetPath: target },});@@ -399,17 +397,8 @@ async function assertWorkbenchStdinFailureDoesNotCrashServer() {env: { CODEX_SECURITY_STATE_DIR: stateDir, PYTHON: helper },});try {- assertNoError(- await server.requestAndWait(1, "initialize", {- protocolVersion: "2025-11-25",- capabilities: {},- clientInfo: {- name: "codex-security-early-exit-smoke",- version: "0.1.0",- },- }),- );- const response = await server.requestAndWait(2, "tools/call", {+ assertNoError(await server.initialize("codex-security-early-exit-smoke"));+ const response = await server.callTool(2, {name: "update_codex_security_scan_context",arguments: {scanId: randomUUID(),@@ -432,16 +421,11 @@ async function assertUnavailableUserInputFallback() {});try {assertNoError(- await noElicitationServer.requestAndWait(1, "initialize", {- protocolVersion: "2025-11-25",- capabilities: {},- clientInfo: {- name: "codex-security-no-elicitation-smoke",- version: "0.1.0",- },- }),+ await noElicitationServer.initialize(+ "codex-security-no-elicitation-smoke",+ ),);- const response = await noElicitationServer.requestAndWait(2, "tools/call", {+ const response = await noElicitationServer.callTool(2, {name: "request_codex_security_user_input",arguments: {questions: [@@ -470,14 +454,8 @@ async function assertWorkspaceWorksWithoutUiCapability() {env: { CODEX_SECURITY_STATE_DIR: nonUiStateDir },});try {- assertNoError(- await nonUiServer.requestAndWait(1, "initialize", {- protocolVersion: "2025-11-25",- capabilities: {},- clientInfo: { name: "codex-security-non-ui-smoke", version: "0.1.0" },- }),- );- const response = await nonUiServer.requestAndWait(2, "tools/call", {+ assertNoError(await nonUiServer.initialize("codex-security-non-ui-smoke"));+ const response = await nonUiServer.callTool(2, {name: "open_codex_security_workspace",arguments: { targetPath: target, mode: "standard", scope: "." },_meta: { "openai/threadId": "fixture-non-ui-thread" },@@ -515,13 +493,9 @@ async function assertHeadlessStandardScanWorksWithoutUiCapability() {assert.ok(headlessContext.length > 1_000_000);try {assertNoError(- await headlessServer.requestAndWait(1, "initialize", {- protocolVersion: "2025-11-25",- capabilities: {},- clientInfo: { name: "codex-security-headless-smoke", version: "0.1.0" },- }),+ await headlessServer.initialize("codex-security-headless-smoke"),);- const withoutOwner = await headlessServer.requestAndWait(2, "tools/call", {+ const withoutOwner = await headlessServer.callTool(2, {name: "start_codex_security_standard_scan",arguments: { targetPath: target },});@@ -531,7 +505,7 @@ async function assertHeadlessStandardScanWorksWithoutUiCapability() {/owning Codex thread context/,);- const started = await headlessServer.requestAndWait(3, "tools/call", {+ const started = await headlessServer.callTool(3, {name: "start_codex_security_standard_scan",arguments: {targetPath: target,@@ -563,7 +537,7 @@ async function assertHeadlessStandardScanWorksWithoutUiCapability() {assert.equal(result.scan.userContext, headlessContext);assert.equal(result.workspace.userContext, headlessContext);- const joined = await headlessServer.requestAndWait(4, "tools/call", {+ const joined = await headlessServer.callTool(4, {name: "start_codex_security_standard_scan",arguments: {targetPath: target,@@ -579,7 +553,7 @@ async function assertHeadlessStandardScanWorksWithoutUiCapability() {result.handoffClaimToken,);- const wrongThread = await headlessServer.requestAndWait(6, "tools/call", {+ const wrongThread = await headlessServer.callTool(6, {name: "list_codex_security_review_items",arguments: { scanId: result.scanId },_meta: { "openai/threadId": "fixture-headless-other-thread" },@@ -590,25 +564,21 @@ async function assertHeadlessStandardScanWorksWithoutUiCapability() {/current continuation claim/,);- const standardInventory = await headlessServer.requestAndWait(- 7,- "tools/call",- {- name: "list_codex_security_review_items",- arguments: {- scanId: result.scanId,- handoffClaimToken: result.handoffClaimToken,- },- _meta: { "openai/threadId": "fixture-headless-delegated-thread" },+ const standardInventory = await headlessServer.callTool(7, {+ name: "list_codex_security_review_items",+ arguments: {+ scanId: result.scanId,+ handoffClaimToken: result.handoffClaimToken,},- );+ _meta: { "openai/threadId": "fixture-headless-delegated-thread" },+ });assert.equal(standardInventory.result.isError, true);assert.match(standardInventory.result.content[0].text,/only available for Deep or diff scans/,);- const progressed = await headlessServer.requestAndWait(8, "tools/call", {+ const progressed = await headlessServer.callTool(8, {name: "update_codex_security_scan_progress",arguments: {scanId: result.scanId,@@ -619,7 +589,7 @@ async function assertHeadlessStandardScanWorksWithoutUiCapability() {});assertNoError(progressed);- const advanced = await headlessServer.requestAndWait(81, "tools/call", {+ const advanced = await headlessServer.callTool(81, {name: "update_codex_security_scan_progress",arguments: {scanId: result.scanId,@@ -629,18 +599,14 @@ async function assertHeadlessStandardScanWorksWithoutUiCapability() {_meta: { "openai/threadId": ownerThread },});assertNoError(advanced);- const rejoinedAfterPreflight = await headlessServer.requestAndWait(- 82,- "tools/call",- {- name: "start_codex_security_standard_scan",- arguments: {- targetPath: target,- userContext: headlessContext,- },- _meta: { "openai/threadId": ownerThread },+ const rejoinedAfterPreflight = await headlessServer.callTool(82, {+ name: "start_codex_security_standard_scan",+ arguments: {+ targetPath: target,+ userContext: headlessContext,},- );+ _meta: { "openai/threadId": ownerThread },+ });assertNoError(rejoinedAfterPreflight);assert.equal(rejoinedAfterPreflight.result.structuredContent.startDisposition,@@ -656,7 +622,7 @@ async function assertHeadlessStandardScanWorksWithoutUiCapability() {result.scanId,result.scan.contract.target.requiredSnapshotDigest,);- const completed = await headlessServer.requestAndWait(9, "tools/call", {+ const completed = await headlessServer.callTool(9, {name: "complete_codex_security_scan",arguments: {scanId: result.scanId,@@ -697,14 +663,7 @@ async function assertDeepScanPersistsRetryableWorkerStartupError() {});try {assertNoError(- await deepServer.requestAndWait(1, "initialize", {- protocolVersion: "2025-11-25",- capabilities: {},- clientInfo: {- name: "codex-security-deep-inventory-smoke",- version: "0.1.0",- },- }),+ await deepServer.initialize("codex-security-deep-inventory-smoke"),);deepServer.sendRequest(2, "tools/call", {@@ -723,7 +682,7 @@ async function assertDeepScanPersistsRetryableWorkerStartupError() {Date.now() - pollingStarted < 30_000;requestId++) {- const listed = await deepServer.requestAndWait(requestId, "tools/call", {+ const listed = await deepServer.callTool(requestId, {name: "list_codex_security_scans",arguments: {},});@@ -764,7 +723,7 @@ async function assertDeepScanPersistsRetryableWorkerStartupError() {);assert.equal(startupErrorWorker.status, "running");- const canceled = await deepServer.requestAndWait(3, "tools/call", {+ const canceled = await deepServer.callTool(3, {name: "cancel_codex_security_scan",arguments: { scanId: scan.scanId },_meta: { "openai/threadId": "fixture-deep-inventory-thread" },@@ -798,18 +757,14 @@ with sqlite3.connect(sys.argv[1]) as connection:publicationFailure,scan.scanId,]);- const canceledWithPublicationFailure = await deepServer.requestAndWait(- 4,- "tools/call",- {- name: "start_codex_security_deep_scan",- arguments: { scanId: scan.scanId },- _meta: {- "openai/threadId": "fixture-deep-inventory-thread",- "codex/sandbox-state-meta": parentSandboxState,- },+ const canceledWithPublicationFailure = await deepServer.callTool(4, {+ name: "start_codex_security_deep_scan",+ arguments: { scanId: scan.scanId },+ _meta: {+ "openai/threadId": "fixture-deep-inventory-thread",+ "codex/sandbox-state-meta": parentSandboxState,},- );+ });const publicationFailureText = canceledWithPublicationFailure.result.content.map((item: { text: string }) => item.text).join(" ");@@ -835,14 +790,10 @@ async function assertUserInputFailureLogging() {});try {assertNoError(- await failingElicitationServer.requestAndWait(1, "initialize", {- protocolVersion: "2025-11-25",- capabilities: { elicitation: { form: {} } },- clientInfo: {- name: "codex-security-failing-elicitation-smoke",- version: "0.1.0",- },- }),+ await failingElicitationServer.initialize(+ "codex-security-failing-elicitation-smoke",+ { elicitation: { form: {} } },+ ),);failingElicitationServer.sendRequest(2, "tools/call", {name: "request_codex_security_user_input",@@ -923,14 +874,9 @@ async function assertBundledPythonRuntime() {});try {assertNoError(- await bundledPythonServer.requestAndWait(1, "initialize", {- protocolVersion: "2025-11-25",- capabilities: {},- clientInfo: {- name: "codex-security-bundled-python-smoke",- version: "0.1.0",- },- }),+ await bundledPythonServer.initialize(+ "codex-security-bundled-python-smoke",+ ),);// Codex can install the primary runtime after the MCP server has started.// Creating this wrapper after initialization verifies call-time discovery.@@ -944,7 +890,7 @@ exec "$CODEX_SECURITY_TEST_SYSTEM_PYTHON" "$@"{ mode: 0o755 },);assertNoError(- await bundledPythonServer.requestAndWait(2, "tools/call", {+ await bundledPythonServer.callTool(2, {name: "inspect_codex_security_target",arguments: { targetPath: target },}),@@ -1036,12 +982,8 @@ async function writeCompletedContract(}try {- const initialized = await requestAndWait(1, "initialize", {- protocolVersion: "2025-11-25",- capabilities: {- elicitation: { form: {} },- },- clientInfo: { name: "codex-security-smoke", version: "0.1.0" },+ const initialized = await testServer.initialize("codex-security-smoke", {+ elicitation: { form: {} },});assertNoError(initialized);assert.equal(initialized.result.capabilities.resources, undefined);@@ -1088,7 +1030,7 @@ try {/Skip it for Amazon Bedrock scans/,);- const unknownTrustedAccess = await requestAndWait(9601, "tools/call", {+ const unknownTrustedAccess = await testServer.callTool(9601, {name: "get_codex_security_daybreak_access",arguments: {},});@@ -1137,7 +1079,7 @@ try {checkedAt: "2026-07-13T12:00:00.000Z",stale: false,};- const hostedTrustedAccess = await requestAndWait(9602, "tools/call", {+ const hostedTrustedAccess = await testServer.callTool(9602, {name: "get_codex_security_daybreak_access",arguments: {},_meta: {@@ -1172,7 +1114,7 @@ try {{ level: "government", source: "project" },];for (const [index, invalidGrant] of invalidGrantPairs.entries()) {- const response = await requestAndWait(9620 + index, "tools/call", {+ const response = await testServer.callTool(9620 + index, {name: "get_codex_security_daybreak_access",arguments: {},_meta: {@@ -1193,7 +1135,7 @@ try {assert.deepEqual(response.result.structuredContent.programs, []);}- const staleGrantedAccess = await requestAndWait(9626, "tools/call", {+ const staleGrantedAccess = await testServer.callTool(9626, {name: "get_codex_security_daybreak_access",arguments: {},_meta: {@@ -1219,7 +1161,7 @@ try {/protected results may not be displayable/,);- const untrustedReplay = await requestAndWait(9603, "tools/call", {+ const untrustedReplay = await testServer.callTool(9603, {name: "get_codex_security_daybreak_access",arguments: {},_meta: { threadId: "fixture-trusted-access-thread" },@@ -1236,7 +1178,7 @@ try {stale: false,enrollmentUrl: "https://chatgpt.com/cyber",};- const refreshedTrustedAccess = await requestAndWait(9604, "tools/call", {+ const refreshedTrustedAccess = await testServer.callTool(9604, {name: "get_codex_security_daybreak_access",arguments: {},_meta: {@@ -1272,7 +1214,7 @@ try {/does not determine Amazon Bedrock model access/,);- const timestampedTrustedAccess = await requestAndWait(9608, "tools/call", {+ const timestampedTrustedAccess = await testServer.callTool(9608, {name: "get_codex_security_daybreak_access",arguments: {},_meta: {@@ -1304,7 +1246,7 @@ try {),);- const unownedTrustedAccess = await requestAndWait(9605, "tools/call", {+ const unownedTrustedAccess = await testServer.callTool(9605, {name: "get_codex_security_daybreak_access",arguments: {},_meta: {@@ -1320,7 +1262,7 @@ try {assertNoError(unownedTrustedAccess);assert.equal(unownedTrustedAccess.result.structuredContent.status, "unknown");- const malformedTrustedAccess = await requestAndWait(9606, "tools/call", {+ const malformedTrustedAccess = await testServer.callTool(9606, {name: "get_codex_security_daybreak_access",arguments: {},_meta: {@@ -1342,7 +1284,7 @@ try {"unknown",);- const argumentTrustedAccess = await requestAndWait(9607, "tools/call", {+ const argumentTrustedAccess = await testServer.callTool(9607, {name: "get_codex_security_daybreak_access",arguments: {"openai/entitlementContext": {@@ -1356,7 +1298,7 @@ try {});assert.equal(argumentTrustedAccess.result.isError, true);- const replayedTrustedAccess = await requestAndWait(9609, "tools/call", {+ const replayedTrustedAccess = await testServer.callTool(9609, {name: "get_codex_security_daybreak_access",arguments: {},_meta: { threadId: "fixture-trusted-access-thread" },@@ -1367,7 +1309,7 @@ try {"unknown",);- const spoofedThreadTrustedAccess = await requestAndWait(9610, "tools/call", {+ const spoofedThreadTrustedAccess = await testServer.callTool(9610, {name: "get_codex_security_daybreak_access",arguments: {},_meta: {@@ -1386,22 +1328,18 @@ try {spoofedThreadTrustedAccess.result.structuredContent,grantedDaybreakAccess,);- const canonicalThreadTrustedAccess = await requestAndWait(- 9611,- "tools/call",- {- name: "get_codex_security_daybreak_access",- arguments: {},- _meta: { threadId: "fixture-trusted-access-owner" },- },- );+ const canonicalThreadTrustedAccess = await testServer.callTool(9611, {+ name: "get_codex_security_daybreak_access",+ arguments: {},+ _meta: { threadId: "fixture-trusted-access-owner" },+ });assertNoError(canonicalThreadTrustedAccess);assert.equal(canonicalThreadTrustedAccess.result.structuredContent.status,"unknown",);- const isolatedHostedTrustedAccess = await requestAndWait(9612, "tools/call", {+ const isolatedHostedTrustedAccess = await testServer.callTool(9612, {name: "get_codex_security_daybreak_access",arguments: {},_meta: {@@ -1419,7 +1357,7 @@ try {isolatedHostedTrustedAccess.result.structuredContent,grantedDaybreakAccess,);- const isolatedOtherTrustedAccess = await requestAndWait(9613, "tools/call", {+ const isolatedOtherTrustedAccess = await testServer.callTool(9613, {name: "get_codex_security_daybreak_access",arguments: {},_meta: { threadId: "fixture-isolated-trusted-access-other" },@@ -1627,7 +1565,7 @@ try {preflight_action: "Leave paused",},});- const invalidUserInput = await requestAndWait(9001, "tools/call", {+ const invalidUserInput = await testServer.callTool(9001, {name: "request_codex_security_user_input",arguments: {questions: [@@ -2011,7 +1949,7 @@ try {]);assert.deepEqual(exportFindings._meta.ui.visibility, ["app"]);assert.deepEqual(listFindings._meta.ui.visibility, ["app"]);- const missingDeepIdentity = await requestAndWait(9100, "tools/call", {+ const missingDeepIdentity = await testServer.callTool(9100, {name: "start_codex_security_deep_scan",arguments: {},_meta: { "openai/threadId": "fixture-thread" },@@ -2021,7 +1959,7 @@ try {missingDeepIdentity.result.content[0].text,/exactly one Deep Scan identity/,);- const mixedDeepIdentity = await requestAndWait(9101, "tools/call", {+ const mixedDeepIdentity = await testServer.callTool(9101, {name: "start_codex_security_deep_scan",arguments: { scanId: randomUUID(), targetPath: target },_meta: { "openai/threadId": "fixture-thread" },@@ -2031,7 +1969,7 @@ try {mixedDeepIdentity.result.content[0].text,/exactly one Deep Scan identity/,);- const invalidDeepScope = await requestAndWait(9102, "tools/call", {+ const invalidDeepScope = await testServer.callTool(9102, {name: "start_codex_security_deep_scan",arguments: { targetPath: target, scope: "src" },_meta: { "openai/threadId": "fixture-thread" },@@ -2041,7 +1979,7 @@ try {invalidDeepScope.result.content[0].text,/requires the whole target/,);- const missingDeepThread = await requestAndWait(9103, "tools/call", {+ const missingDeepThread = await testServer.callTool(9103, {name: "start_codex_security_deep_scan",arguments: { targetPath: target },});@@ -2050,7 +1988,7 @@ try {missingDeepThread.result.content[0].text,/owning Codex thread context/,);- const missingPersistedDeepScan = await requestAndWait(9104, "tools/call", {+ const missingPersistedDeepScan = await testServer.callTool(9104, {name: "start_codex_security_deep_scan",arguments: { scanId: randomUUID() },_meta: {@@ -2093,7 +2031,7 @@ try {const urlContext ="Deployment details came from https://example.test/internal.";- const urlContextAccepted = await requestAndWait(1290, "tools/call", {+ const urlContextAccepted = await testServer.callTool(1290, {name: "open_codex_security_workspace",arguments: {targetPath: target,@@ -2107,7 +2045,7 @@ try {urlContext,);- const opened = await requestAndWait(4, "tools/call", {+ const opened = await testServer.callTool(4, {name: "open_codex_security_workspace",arguments: {targetPath: target,@@ -2130,7 +2068,7 @@ try {reviewChangesSupported: false,});- const sameThreadReopen = await requestAndWait(1162, "tools/call", {+ const sameThreadReopen = await testServer.callTool(1162, {name: "open_codex_security_workspace",arguments: { sessionId: workspace.id },_meta: { "openai/threadId": "fixture-thread" },@@ -2141,7 +2079,7 @@ try {workspace.id,);- const otherThreadOpened = await requestAndWait(1163, "tools/call", {+ const otherThreadOpened = await testServer.callTool(1163, {name: "open_codex_security_workspace",arguments: { targetPath: replacementTarget },_meta: { "openai/threadId": "fixture-other-thread" },@@ -2156,7 +2094,7 @@ try {await realpath(replacementTarget),);- const crossThreadReopen = await requestAndWait(1164, "tools/call", {+ const crossThreadReopen = await testServer.callTool(1164, {name: "open_codex_security_workspace",arguments: { sessionId: workspace.id },_meta: { "openai/threadId": "fixture-other-thread" },@@ -2167,7 +2105,7 @@ try {/workspace not found in this thread/,);- const metadataFreeReopen = await requestAndWait(1165, "tools/call", {+ const metadataFreeReopen = await testServer.callTool(1165, {name: "open_codex_security_workspace",arguments: { sessionId: workspace.id },});@@ -2177,7 +2115,7 @@ try {/thread metadata is required/i,);- const metadataFreeCreate = await requestAndWait(1166, "tools/call", {+ const metadataFreeCreate = await testServer.callTool(1166, {name: "open_codex_security_workspace",arguments: { targetPath: target },});@@ -2187,7 +2125,7 @@ try {/^[0-9a-f-]{36}$/,);- const savedOtherWorkspace = await requestAndWait(2020, "tools/call", {+ const savedOtherWorkspace = await testServer.callTool(2020, {name: "submit_codex_security_setup",arguments: {sessionId: otherThreadOpened.result.structuredContent.workspace.id,@@ -2203,7 +2141,7 @@ try {reason: "Smoke-test cancellation",});await new Promise((resolve) => setTimeout(resolve, 100));- const otherStarted = await requestAndWait(2023, "tools/call", {+ const otherStarted = await testServer.callTool(2023, {name: "start_codex_security_scan",arguments: {sessionId: otherThreadOpened.result.structuredContent.workspace.id,@@ -2211,7 +2149,7 @@ try {});assertNoError(otherStarted);- const absoluteScopeOpened = await requestAndWait(150, "tools/call", {+ const absoluteScopeOpened = await testServer.callTool(150, {name: "open_codex_security_workspace",arguments: { targetPath: target, scope: target, mode: "standard" },_meta: { "openai/threadId": "fixture-aux-thread" },@@ -2222,14 +2160,14 @@ try {".",);- const invalidReopen = await requestAndWait(151, "tools/call", {+ const invalidReopen = await testServer.callTool(151, {name: "open_codex_security_workspace",arguments: { sessionId: workspace.id, scope: "." },});assert.equal(invalidReopen.result.isError, true);assert.match(invalidReopen.result.content[0].text, /sessionId only reopens/);- const deepOpened = await requestAndWait(44, "tools/call", {+ const deepOpened = await testServer.callTool(44, {name: "open_codex_security_workspace",arguments: { targetPath: target, scope: ".", mode: "deep" },_meta: { "openai/threadId": "fixture-aux-thread" },@@ -2238,7 +2176,7 @@ try {assert.equal(deepOpened.result.structuredContent.workspace.mode, "deep");assert.equal(deepOpened.result.structuredContent.workspace.scope, ".");- const diffOpened = await requestAndWait(45, "tools/call", {+ const diffOpened = await testServer.callTool(45, {name: "open_codex_security_workspace",arguments: {targetPath: gitTarget,@@ -2264,7 +2202,7 @@ try {true,);- const inferredDiffOpened = await requestAndWait(152, "tools/call", {+ const inferredDiffOpened = await testServer.callTool(152, {name: "open_codex_security_workspace",arguments: {targetPath: gitTarget,@@ -2279,7 +2217,7 @@ try {"diff",);- const contradictoryDiffOpened = await requestAndWait(153, "tools/call", {+ const contradictoryDiffOpened = await testServer.callTool(153, {name: "open_codex_security_workspace",arguments: {targetPath: gitTarget,@@ -2294,7 +2232,7 @@ try {/requires mode 'diff'/,);- const scopedDeepOpened = await requestAndWait(154, "tools/call", {+ const scopedDeepOpened = await testServer.callTool(154, {name: "open_codex_security_workspace",arguments: { targetPath: target, scope: "src", mode: "deep" },});@@ -2306,7 +2244,7 @@ try {const nestedGitTarget = path.join(gitTarget, "nested");await mkdir(nestedGitTarget);- const nestedDiffOpened = await requestAndWait(155, "tools/call", {+ const nestedDiffOpened = await testServer.callTool(155, {name: "open_codex_security_workspace",arguments: {targetPath: nestedGitTarget,@@ -2331,7 +2269,7 @@ try {false,);- const inspectedSetup = await requestAndWait(46, "tools/call", {+ const inspectedSetup = await testServer.callTool(46, {name: "inspect_codex_security_setup",arguments: {targetPath: gitTarget,@@ -2354,7 +2292,7 @@ try {"update fixture",);- const inspectedCommitOpened = await requestAndWait(2200, "tools/call", {+ const inspectedCommitOpened = await testServer.callTool(2200, {name: "open_codex_security_workspace",arguments: {targetPath: gitTarget,@@ -2367,7 +2305,7 @@ try {});assertNoError(inspectedCommitOpened);- const inspectedCommitSaved = await requestAndWait(2201, "tools/call", {+ const inspectedCommitSaved = await testServer.callTool(2201, {name: "submit_codex_security_setup",arguments: {sessionId: inspectedCommitOpened.result.structuredContent.workspace.id,@@ -2384,7 +2322,7 @@ try {inspectedCommitTarget,);- const invalidOpened = await requestAndWait(47, "tools/call", {+ const invalidOpened = await testServer.callTool(47, {name: "open_codex_security_workspace",arguments: {targetPath: path.join(target, "missing"),@@ -2403,7 +2341,7 @@ try {undefined,);- const inspected = await requestAndWait(40, "tools/call", {+ const inspected = await testServer.callTool(40, {name: "inspect_codex_security_target",arguments: { targetPath: target },});@@ -2422,7 +2360,7 @@ try {false,);- const saved = await requestAndWait(5, "tools/call", {+ const saved = await testServer.callTool(5, {name: "submit_codex_security_setup",arguments: {sessionId: workspace.id,@@ -2437,7 +2375,7 @@ try {const savedWorkspace = saved.result.structuredContent.workspace;assert.equal(savedWorkspace.setup.submitted, true);assert.equal(savedWorkspace.userContext, "Pay attention to the HTTP API.");- const started = await requestAndWait(6, "tools/call", {+ const started = await testServer.callTool(6, {name: "start_codex_security_scan",arguments: {model: "gpt-5.6-sol",@@ -2485,7 +2423,7 @@ try {);const handoffClaimToken = randomUUID();- const claimedHandoff = await requestAndWait(2002, "tools/call", {+ const claimedHandoff = await testServer.callTool(2002, {name: "claim_codex_security_scan_handoff_delivery",arguments: { claimToken: handoffClaimToken, scanId },});@@ -2494,7 +2432,7 @@ try {claimedHandoff.result.structuredContent.workspace.results.handoffClaimToken,handoffClaimToken,);- const attachedHandoff = await requestAndWait(20021, "tools/call", {+ const attachedHandoff = await testServer.callTool(20021, {name: "attach_codex_security_scan_continuation_thread",arguments: {claimToken: handoffClaimToken,@@ -2503,7 +2441,7 @@ try {},});assertNoError(attachedHandoff);- const threadOwnedScan = await requestAndWait(2202, "tools/call", {+ const threadOwnedScan = await testServer.callTool(2202, {name: "get_codex_security_scan",arguments: { scanId },});@@ -2513,7 +2451,7 @@ try {"fixture-thread",);- const wrongThreadDelivery = await requestAndWait(2009, "tools/call", {+ const wrongThreadDelivery = await testServer.callTool(2009, {name: "get_codex_security_scan_context",arguments: { handoffClaimToken, scanId },_meta: { "openai/threadId": "fixture-other-thread" },@@ -2524,7 +2462,7 @@ try {/owning Codex thread/,);- const missingClaimToken = await requestAndWait(2005, "tools/call", {+ const missingClaimToken = await testServer.callTool(2005, {name: "get_codex_security_scan_context",arguments: { scanId },_meta: { "openai/threadId": "fixture-thread" },@@ -2535,7 +2473,7 @@ try {/Pass the handoffClaimToken/,);- const delivered = await requestAndWait(2003, "tools/call", {+ const delivered = await testServer.callTool(2003, {name: "get_codex_security_scan_context",arguments: { handoffClaimToken, scanId },_meta: { "openai/threadId": "fixture-thread" },@@ -2553,7 +2491,7 @@ try {delivered.result.structuredContent.workspace.results.handoffClaimToken,undefined,);- const reopenedWorkspace = await requestAndWait(2203, "tools/call", {+ const reopenedWorkspace = await testServer.callTool(2203, {name: "open_codex_security_workspace",arguments: { sessionId: workspace.id },_meta: { "openai/threadId": "fixture-thread" },@@ -2565,7 +2503,7 @@ try {undefined,);- const supersededClaim = await requestAndWait(2006, "tools/call", {+ const supersededClaim = await testServer.callTool(2006, {name: "get_codex_security_scan_context",arguments: { handoffClaimToken: randomUUID(), scanId },_meta: { "openai/threadId": "fixture-thread" },@@ -2576,7 +2514,7 @@ try {/owned by another continuation/,);- const deliveredWithoutToken = await requestAndWait(2007, "tools/call", {+ const deliveredWithoutToken = await testServer.callTool(2007, {name: "get_codex_security_scan_context",arguments: { scanId },_meta: { "openai/threadId": "fixture-thread" },@@ -2584,7 +2522,7 @@ try {assertNoError(deliveredWithoutToken);const longUserContext = "Prioritize tenant isolation. ".repeat(120).trim();- const updatedContext = await requestAndWait(92010, "tools/call", {+ const updatedContext = await testServer.callTool(92010, {name: "update_codex_security_scan_context",arguments: { handoffClaimToken, scanId, userContext: longUserContext },_meta: { "openai/threadId": "fixture-thread" },@@ -2600,7 +2538,7 @@ try {);const appUserContext = "Focus on account recovery. ".repeat(120).trim();- const appUpdatedContext = await requestAndWait(92011, "tools/call", {+ const appUpdatedContext = await testServer.callTool(92011, {name: "update_codex_security_scan_context_from_app",arguments: { scanId, userContext: appUserContext },});@@ -2611,7 +2549,7 @@ try {);const urlContextUpdate = "Read https://example.test/context.";- const updatedContextUrl = await requestAndWait(92012, "tools/call", {+ const updatedContextUrl = await testServer.callTool(92012, {name: "update_codex_security_scan_context",arguments: {handoffClaimToken,@@ -2630,7 +2568,7 @@ try {urlContextUpdate,);- const conflictingPreflightCounts = await requestAndWait(90161, "tools/call", {+ const conflictingPreflightCounts = await testServer.callTool(90161, {name: "update_codex_security_scan_progress",arguments: {scanId,@@ -2672,26 +2610,22 @@ try {status: "pass",},];- const incompletePreflightProgress = await requestAndWait(- 90162,- "tools/call",- {- name: "update_codex_security_scan_progress",- arguments: {- scanId,- handoffClaimToken,- preflightChecks: [- {- capability: "usable_worker_slots_6",- reason: "The runtime did not report worker capacity.",- severity: "block",- status: "unknown",- },- ...successfulPreflightChecks,- ],- },+ const incompletePreflightProgress = await testServer.callTool(90162, {+ name: "update_codex_security_scan_progress",+ arguments: {+ scanId,+ handoffClaimToken,+ preflightChecks: [+ {+ capability: "usable_worker_slots_6",+ reason: "The runtime did not report worker capacity.",+ severity: "block",+ status: "unknown",+ },+ ...successfulPreflightChecks,+ ],},- );+ });assertNoError(incompletePreflightProgress);assert.equal(incompletePreflightProgress.result.structuredContent.scan.progress@@ -2704,7 +2638,7 @@ try {{ completed: 3, total: 4 },);- const blockedPreflightProgress = await requestAndWait(90163, "tools/call", {+ const blockedPreflightProgress = await testServer.callTool(90163, {name: "update_codex_security_scan_progress",arguments: {scanId,@@ -2732,7 +2666,7 @@ try {{ completed: 4, total: 4 },);- const readyPreflightProgress = await requestAndWait(90164, "tools/call", {+ const readyPreflightProgress = await testServer.callTool(90164, {name: "update_codex_security_scan_progress",_meta: {"openai/threadId": "fixture-thread",@@ -2780,7 +2714,7 @@ try {);const nextPhaseUserContext = "Prioritize password-reset token validation.";- const updatedPhaseContext = await requestAndWait(92013, "tools/call", {+ const updatedPhaseContext = await testServer.callTool(92013, {name: "update_codex_security_scan_context",arguments: {handoffClaimToken,@@ -2791,7 +2725,7 @@ try {});assertNoError(updatedPhaseContext);- const updated = await requestAndWait(8, "tools/call", {+ const updated = await testServer.callTool(8, {name: "update_codex_security_scan_progress",arguments: {scanId,@@ -2838,7 +2772,7 @@ try {await writeCompletedContract(initializedScanDir, scanId, snapshotDigest);await writeFile(path.join(target, "src/a.py"), "changed\n");- const completed = await requestAndWait(802, "tools/call", {+ const completed = await testServer.callTool(802, {name: "complete_codex_security_scan",arguments: { handoffClaimToken, scanId },});@@ -2856,7 +2790,7 @@ try {completed.result.structuredContent.workspace.results.progress.status,"complete",);- const refreshed = await requestAndWait(10, "tools/call", {+ const refreshed = await testServer.callTool(10, {name: "get_codex_security_scan",arguments: { scanId },});@@ -2883,7 +2817,7 @@ try {const occurrenceId = results.findings[0].occurrenceId;const remediationRequestId = randomUUID();- const closedFinding = await requestAndWait(60, "tools/call", {+ const closedFinding = await testServer.callTool(60, {name: "set_codex_security_finding_triage",arguments: {occurrenceId,@@ -2903,7 +2837,7 @@ try {);const generationActionToken = randomUUID();- const rejectedClosedPatch = await requestAndWait(159, "tools/call", {+ const rejectedClosedPatch = await testServer.callTool(159, {name: "request_codex_security_finding_remediation",arguments: {actionToken: generationActionToken,@@ -2916,7 +2850,7 @@ try {rejectedClosedPatch.result.content[0].text,/Reopen this finding/,);- const reopenedFinding = await requestAndWait(160, "tools/call", {+ const reopenedFinding = await testServer.callTool(160, {name: "set_codex_security_finding_triage",arguments: { occurrenceId, status: "open" },});@@ -2924,7 +2858,7 @@ try {const canceledRequestId = randomUUID();const canceledActionToken = randomUUID();- const requestedThenCanceledPatch = await requestAndWait(500, "tools/call", {+ const requestedThenCanceledPatch = await testServer.callTool(500, {name: "request_codex_security_finding_remediation",arguments: {actionToken: canceledActionToken,@@ -2933,7 +2867,7 @@ try {},});assertNoError(requestedThenCanceledPatch);- const canceledPatch = await requestAndWait(501, "tools/call", {+ const canceledPatch = await testServer.callTool(501, {name: "cancel_codex_security_finding_remediation_request",arguments: {actionToken: canceledActionToken,@@ -2949,7 +2883,7 @@ try {},);- const requestedPatch = await requestAndWait(61, "tools/call", {+ const requestedPatch = await testServer.callTool(61, {name: "request_codex_security_finding_remediation",arguments: {actionToken: generationActionToken,@@ -2963,7 +2897,7 @@ try {.state,"requested",);- const rejectedPendingClose = await requestAndWait(161, "tools/call", {+ const rejectedPendingClose = await testServer.callTool(161, {name: "set_codex_security_finding_triage",arguments: { occurrenceId, status: "closed", closeReason: "already_fixed" },});@@ -2983,7 +2917,7 @@ try {path.join(initializedScanDir, "remediation.patch"),remediationPatch,);- const generatedPatch = await requestAndWait(62, "tools/call", {+ const generatedPatch = await testServer.callTool(62, {name: "set_codex_security_finding_remediation",arguments: {actionToken: generationActionToken,@@ -3009,7 +2943,7 @@ try {);const applyActionToken = randomUUID();- const requestedApply = await requestAndWait(65, "tools/call", {+ const requestedApply = await testServer.callTool(65, {name: "request_codex_security_finding_remediation_action",arguments: {action: "apply",@@ -3030,7 +2964,7 @@ try {.version,3,);- const markedApplyDelivered = await requestAndWait(166, "tools/call", {+ const markedApplyDelivered = await testServer.callTool(166, {name: "mark_codex_security_finding_remediation_delivered",arguments: {actionToken: applyActionToken,@@ -3051,7 +2985,7 @@ try {},);- const appliedPatch = await requestAndWait(66, "tools/call", {+ const appliedPatch = await testServer.callTool(66, {name: "set_codex_security_finding_remediation",arguments: {actionToken: applyActionToken,@@ -3070,7 +3004,7 @@ try {);const verifyActionToken = randomUUID();- const requestedVerify = await requestAndWait(168, "tools/call", {+ const requestedVerify = await testServer.callTool(168, {name: "request_codex_security_finding_remediation_action",arguments: {action: "verify",@@ -3092,7 +3026,7 @@ try {5,);- const verifyingPatch = await requestAndWait(169, "tools/call", {+ const verifyingPatch = await testServer.callTool(169, {name: "set_codex_security_finding_remediation",arguments: {actionToken: verifyActionToken,@@ -3115,7 +3049,7 @@ try {"verify",);- const verifiedPatch = await requestAndWait(170, "tools/call", {+ const verifiedPatch = await testServer.callTool(170, {name: "set_codex_security_finding_remediation",arguments: {actionToken: verifyActionToken,@@ -3144,7 +3078,7 @@ try {"Focused remediation checks passed.",);- const findingsPage = await requestAndWait(67, "tools/call", {+ const findingsPage = await testServer.callTool(67, {name: "list_codex_security_findings",arguments: { scanId, offset: 0, limit: 1 },});@@ -3158,7 +3092,7 @@ try {1,);assert.equal(findingsPage.result.structuredContent.findingsPage.total, 2);- const filteredFindingsPage = await requestAndWait(94001, "tools/call", {+ const filteredFindingsPage = await testServer.callTool(94001, {name: "list_codex_security_findings",arguments: {scanId,@@ -3180,7 +3114,7 @@ try {1,);- const csvExport = await requestAndWait(63, "tools/call", {+ const csvExport = await testServer.callTool(63, {name: "export_codex_security_findings",arguments: { scanId, format: "csv" },});@@ -3194,7 +3128,7 @@ try {/occurrence_id,finding_id,title/,);- const sarifExport = await requestAndWait(64, "tools/call", {+ const sarifExport = await testServer.callTool(64, {name: "export_codex_security_findings",arguments: { scanId, format: "sarif" },});@@ -3204,14 +3138,14 @@ try {path.join(initializedScanDir, "exports", "results.sarif"),);- const restarted = await requestAndWait(171, "tools/call", {+ const restarted = await testServer.callTool(171, {name: "start_codex_security_scan",arguments: { sessionId: workspace.id },});assertNoError(restarted);const canceledScanId =restarted.result.structuredContent.workspace.results.scanId;- const unclaimedContext = await requestAndWait(2010, "tools/call", {+ const unclaimedContext = await testServer.callTool(2010, {name: "get_codex_security_scan_context",arguments: { scanId: canceledScanId },_meta: { "openai/threadId": "fixture-thread" },@@ -3225,7 +3159,7 @@ try {unclaimedContext.result.content[0].text,/Claim the pending Codex Security scan handoff/,);- const rejectedWrongThreadCancel = await requestAndWait(1169, "tools/call", {+ const rejectedWrongThreadCancel = await testServer.callTool(1169, {name: "cancel_codex_security_scan",arguments: { scanId: canceledScanId },_meta: { "openai/threadId": "fixture-other-thread" },@@ -3235,7 +3169,7 @@ try {rejectedWrongThreadCancel.result.content[0].text,/owning Codex thread/,);- const rejectedMissingThreadCancel = await requestAndWait(1170, "tools/call", {+ const rejectedMissingThreadCancel = await testServer.callTool(1170, {name: "cancel_codex_security_scan",arguments: { scanId: canceledScanId },});@@ -3244,13 +3178,13 @@ try {rejectedMissingThreadCancel.result.content[0].text,/continuation thread.*Codex Security workbench/,);- const canceledFromNativeRoute = await requestAndWait(2210, "tools/call", {+ const canceledFromNativeRoute = await testServer.callTool(2210, {name: "cancel_codex_security_scan_from_app",arguments: { scanId: canceledScanId },});assertNoError(canceledFromNativeRoute);- const canceled = await requestAndWait(172, "tools/call", {+ const canceled = await testServer.callTool(172, {name: "cancel_codex_security_scan",arguments: { scanId: canceledScanId },_meta: { "openai/threadId": "fixture-thread" },@@ -3265,7 +3199,7 @@ try {"string",);- const rejectedCanceledProgress = await requestAndWait(173, "tools/call", {+ const rejectedCanceledProgress = await testServer.callTool(173, {name: "update_codex_security_scan_progress",arguments: { scanId: canceledScanId, phase: "discovery" },});@@ -3275,7 +3209,7 @@ try {/Only a running scan/,);- const fallbackStarted = await requestAndWait(2011, "tools/call", {+ const fallbackStarted = await testServer.callTool(2011, {name: "start_codex_security_scan",arguments: { sessionId: workspace.id },});@@ -3283,7 +3217,7 @@ try {const fallbackScanId =fallbackStarted.result.structuredContent.workspace.results.scanId;const fallbackClaimToken = `recovery_${randomUUID()}`;- const fallbackClaimed = await requestAndWait(2012, "tools/call", {+ const fallbackClaimed = await testServer.callTool(2012, {name: "claim_codex_security_scan_handoff_delivery",arguments: {claimToken: fallbackClaimToken,@@ -3297,7 +3231,7 @@ try {.handoffClaimToken,fallbackClaimToken,);- const fallbackAttached = await requestAndWait(2017, "tools/call", {+ const fallbackAttached = await testServer.callTool(2017, {name: "attach_codex_security_scan_continuation_thread",arguments: {claimToken: fallbackClaimToken,@@ -3311,7 +3245,7 @@ try {.continuationThreadId,"fixture-recovery-thread",);- const wrongRecoveryContext = await requestAndWait(20171, "tools/call", {+ const wrongRecoveryContext = await testServer.callTool(20171, {name: "get_codex_security_scan_context",arguments: {handoffClaimToken: `recovery_${randomUUID()}`,@@ -3324,7 +3258,7 @@ try {wrongRecoveryContext.result.content[0].text,/handoff delivery could not be recorded|owned by another continuation/i,);- const fallbackContext = await requestAndWait(2013, "tools/call", {+ const fallbackContext = await testServer.callTool(2013, {name: "get_codex_security_scan_context",arguments: {handoffClaimToken: fallbackClaimToken,@@ -3345,7 +3279,7 @@ try {.handoffClaimToken,undefined,);- const recoveredThreadContext = await requestAndWait(20172, "tools/call", {+ const recoveredThreadContext = await testServer.callTool(20172, {name: "get_codex_security_scan_context",arguments: {handoffClaimToken: fallbackClaimToken,@@ -3371,7 +3305,7 @@ try {.handoffClaimToken,undefined,);- const fallbackAppAcknowledgement = await requestAndWait(2014, "tools/call", {+ const fallbackAppAcknowledgement = await testServer.callTool(2014, {name: "mark_codex_security_scan_handoff_delivered",arguments: { claimToken: fallbackClaimToken, scanId: fallbackScanId },});@@ -3392,7 +3326,7 @@ with sqlite3.connect(sys.argv[1]) as connection:rotatedFallbackClaimToken,fallbackScanId,]);- const staleRecoveryContext = await requestAndWait(20173, "tools/call", {+ const staleRecoveryContext = await testServer.callTool(20173, {name: "get_codex_security_scan_context",arguments: {handoffClaimToken: fallbackClaimToken,@@ -3405,7 +3339,7 @@ with sqlite3.connect(sys.argv[1]) as connection:staleRecoveryContext.result.content[0].text,/handoff delivery could not be recorded|owned by another continuation/i,);- const scanList = await requestAndWait(2212, "tools/call", {+ const scanList = await testServer.callTool(2212, {name: "list_codex_security_scans",arguments: {},});@@ -3417,7 +3351,7 @@ with sqlite3.connect(sys.argv[1]) as connection:assert.equal(listedFallback.progress.status, "running");assert.equal("artifacts" in listedFallback, false);assert.equal("findings" in listedFallback, false);- const globalFindings = await requestAndWait(2213, "tools/call", {+ const globalFindings = await testServer.callTool(2213, {name: "list_codex_security_global_findings",arguments: { limit: 1 },});@@ -3432,7 +3366,7 @@ with sqlite3.connect(sys.argv[1]) as connection:assert.equal(indexedFinding.status, "open");assert.equal(indexedFinding.occurrenceCount, 1);assert.match(indexedFinding.targetId, /^target_sha256_[0-9a-f]{64}$/);- const globalFindingsNext = await requestAndWait(2215, "tools/call", {+ const globalFindingsNext = await testServer.callTool(2215, {name: "list_codex_security_global_findings",arguments: { limit: 20, offset: 1 },});@@ -3441,7 +3375,7 @@ with sqlite3.connect(sys.argv[1]) as connection:assert.equal(globalFindingsNext.result.structuredContent.limit, 20);assert.equal(globalFindingsNext.result.structuredContent.offset, 1);assert.equal(globalFindingsNext.result.structuredContent.nextOffset, null);- const filteredGlobalFindings = await requestAndWait(94002, "tools/call", {+ const filteredGlobalFindings = await testServer.callTool(94002, {name: "list_codex_security_global_findings",arguments: {limit: 1,@@ -3462,7 +3396,7 @@ with sqlite3.connect(sys.argv[1]) as connection:filteredGlobalFindings.result.structuredContent.nextOffset,null,);- const repositories = await requestAndWait(2214, "tools/call", {+ const repositories = await testServer.callTool(2214, {name: "list_codex_security_repositories",arguments: {},});@@ -3482,7 +3416,7 @@ with sqlite3.connect(sys.argv[1]) as connection:scan.targetId === indexedFinding.targetId,).length,);- const filteredScans = await requestAndWait(94003, "tools/call", {+ const filteredScans = await testServer.callTool(94003, {name: "list_codex_security_scans",arguments: {limit: 1,@@ -3498,7 +3432,7 @@ with sqlite3.connect(sys.argv[1]) as connection:fallbackScanId,);assert.equal(filteredScans.result.structuredContent.limit, 1);- const filteredRepositories = await requestAndWait(94004, "tools/call", {+ const filteredRepositories = await testServer.callTool(94004, {name: "list_codex_security_repositories",arguments: {limit: 1,@@ -3514,7 +3448,7 @@ with sqlite3.connect(sys.argv[1]) as connection:),[indexedFinding.targetId],);- const rotatedAttached = await requestAndWait(2030, "tools/call", {+ const rotatedAttached = await testServer.callTool(2030, {name: "attach_codex_security_scan_continuation_thread",arguments: {claimToken: rotatedFallbackClaimToken,@@ -3523,7 +3457,7 @@ with sqlite3.connect(sys.argv[1]) as connection:},});assertNoError(rotatedAttached);- const observedRotatedScan = await requestAndWait(2031, "tools/call", {+ const observedRotatedScan = await testServer.callTool(2031, {name: "get_codex_security_scan",arguments: { scanId: fallbackScanId },});@@ -3545,7 +3479,7 @@ with sqlite3.connect(sys.argv[1]) as connection:},]) {for (const staleClaimToken of [undefined, fallbackClaimToken]) {- const rejected = await requestAndWait(rejectedRequestId++, "tools/call", {+ const rejected = await testServer.callTool(rejectedRequestId++, {name: operation.name,arguments: {...operation.arguments,@@ -3562,7 +3496,7 @@ with sqlite3.connect(sys.argv[1]) as connection:);}}- const rotatedProgress = await requestAndWait(2038, "tools/call", {+ const rotatedProgress = await testServer.callTool(2038, {name: "update_codex_security_scan_progress",arguments: {handoffClaimToken: rotatedFallbackClaimToken,@@ -3571,7 +3505,7 @@ with sqlite3.connect(sys.argv[1]) as connection:},});assertNoError(rotatedProgress);- const rotatedFailure = await requestAndWait(2039, "tools/call", {+ const rotatedFailure = await testServer.callTool(2039, {name: "fail_codex_security_scan",arguments: {handoffClaimToken: rotatedFallbackClaimToken,@@ -3584,7 +3518,7 @@ with sqlite3.connect(sys.argv[1]) as connection:rotatedFailure.result.structuredContent.scan.progress.status,"failed",);- const unavailableRecovery = await requestAndWait(2040, "tools/call", {+ const unavailableRecovery = await testServer.callTool(2040, {name: "recover_codex_security_scan_results",arguments: { scanId: fallbackScanId },});@@ -3594,14 +3528,14 @@ with sqlite3.connect(sys.argv[1]) as connection:/No saved stopped-scan results were available to recover/,);- const silentRefresh = await requestAndWait(11, "tools/call", {+ const silentRefresh = await testServer.callTool(11, {name: "open_codex_security_workspace",arguments: { sessionId: workspace.id },_meta: { "openai/threadId": "fixture-thread" },});assertNoError(silentRefresh);- const replacementWorkspaceResponse = await requestAndWait(42, "tools/call", {+ const replacementWorkspaceResponse = await testServer.callTool(42, {name: "open_codex_security_workspace",arguments: { targetPath: target, targetTitle: "Old target title" },_meta: { "openai/threadId": "fixture-aux-thread" },@@ -3609,7 +3543,7 @@ with sqlite3.connect(sys.argv[1]) as connection:assertNoError(replacementWorkspaceResponse);const replacementWorkspace =replacementWorkspaceResponse.result.structuredContent.workspace;- const replacementSaved = await requestAndWait(43, "tools/call", {+ const replacementSaved = await testServer.callTool(43, {name: "submit_codex_security_setup",arguments: {sessionId: replacementWorkspace.id,@@ -3624,7 +3558,7 @@ with sqlite3.connect(sys.argv[1]) as connection:path.basename(replacementTarget),);- const nativeSetupOpen = await requestAndWait(9226, "tools/call", {+ const nativeSetupOpen = await testServer.callTool(9226, {name: "open_codex_security_workspace",arguments: {targetPath: target,@@ -3643,7 +3577,7 @@ with sqlite3.connect(sys.argv[1]) as connection:undefined,);- const invalidScanStarted = await requestAndWait(9401, "tools/call", {+ const invalidScanStarted = await testServer.callTool(9401, {name: "start_codex_security_scan",arguments: { sessionId: workspace.id },});@@ -3651,12 +3585,12 @@ with sqlite3.connect(sys.argv[1]) as connection:const invalidScanId =invalidScanStarted.result.structuredContent.workspace.results.scanId;const invalidScanClaimToken = randomUUID();- const invalidScanClaimed = await requestAndWait(9402, "tools/call", {+ const invalidScanClaimed = await testServer.callTool(9402, {name: "claim_codex_security_scan_handoff_delivery",arguments: { claimToken: invalidScanClaimToken, scanId: invalidScanId },});assertNoError(invalidScanClaimed);- const prematureCompletion = await requestAndWait(9403, "tools/call", {+ const prematureCompletion = await testServer.callTool(9403, {name: "complete_codex_security_scan",arguments: {handoffClaimToken: invalidScanClaimToken,@@ -3668,7 +3602,7 @@ with sqlite3.connect(sys.argv[1]) as connection:prematureCompletion.result.content[0].text,/scan-manifest\.json/,);- const resumableScan = await requestAndWait(9404, "tools/call", {+ const resumableScan = await testServer.callTool(9404, {name: "get_codex_security_scan",arguments: { scanId: invalidScanId },});