Ejemplo
@agentclientprotocol/codex-acp 2.12.1
Muestra verificada para npm @agentclientprotocol/codex-acp 2.12.1. El contrato se ejecutó en node 22 · linux debian/x64 · docker y pasó.
sha256:9844925d736b34666d4a635d290d8e9666cbd1e8037769f9591344ac33df72c8
Esta red ofrece una sola cosa: una muestra que compila. La ejecutó en un sandbox y guardó el recibo firmado. No califica ni garantiza nada: si el mismo código compila donde estás no es algo que haya medido.
Cuántas claves de firma distintas presentaron un recibo de contrato aprobado. Una es solo el autor; más de una significa que alguien más también lo compiló. Una clave se genera sola y no tiene identidad registrada detrás, así que cuenta claves, no personas.
MIT-0
Evidencia de ejecución
El entorno declarado y las ejecuciones firmadas se muestran por separado, para que veas exactamente qué ejecutó esta muestra y dónde.
- Base de evidencia
- Contrato firmado aprobado
- Recibos de verificación
- 1
- Claves de firma que lo compilaron
- 1
Entorno declarado
node 22.23 linux 24 · ubuntu · glibc 2.39 x64 node 22.23 javascript npm 10
Entornos de las ejecuciones de verificación
| Entorno | Contrato | Etapas | Ejecución |
|---|---|---|---|
| node 22 · linux debian/x64 · docker ed25519:c1973797be207ac4 | PASS | compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS CONTAINER_RUN · node-typescript@1node:22@sha256:8a34c4ab3ea2… |
2026-11-27 |
Caso
HOW- Objetivo
- verify pkg:npm/%40agentclientprotocol/codex-acp@2.12.1
- Entorno
- node 22.23.2
- Creado
- 2026-11-27T22:58:01Z
Contrato
- running the codex-acp bin with --version exits 0 and prints '@agentclientprotocol/codex-acp 2.12.1'
- running 'codex-acp cli <args>' with CODEX_PATH set forwards arguments to the configured executable and exits with its status
- sending an ACP v1 JSON-RPC initialize request over stdio with a local CODEX_PATH app-server stub returns agentInfo for @agentclientprotocol/codex-acp 2.12.1, loadSession capability, and both api-key and chat-gpt authMethods by default
- setting NO_BROWSER=1 omits chat-gpt from initialize authMethods while keeping api-key
Archivos
- PROMPT.md
- csx.json
- package-lock.json
- package.json
- spec.json
- test/contract.cjs
Código fuente
Clean-room public code sample — generation instructions
Write a brand-new, minimal, self-contained code sample in this clean-room directory.
Do not copy, paraphrase, or reference any existing project source. Work only from this spec.
A csx.json manifest scaffold already exists. Do not recreate it from memory. Preserve its case.goal, packages and symbols; fill its empty case.contract with exact assertions and correct its environment, commands and verifierAdapter for the files you generate.
Goal: verify pkg:npm/%40agentclientprotocol/codex-acp@2.12.1
Kind: HOW
Use EXACTLY these public packages and versions:
- pkg:npm/%40agentclientprotocol/codex-acp@2.12.1
Constraints:
- executionContext: node
Required runtime conditions:
- ecosystem: npm
- language: javascript
- moduleSystem: cjs
- packageManager: npm@10.9.8
- runtime: node@22.23.2
Rules:
- One focused purpose; the smallest project that proves the goal.
- Include a contract test (test/contract.*) that runs OFFLINE and exits 0 exactly when the goal behavior works.
- Pin every dependency with a lockfile so resolution is reproducible.
- No secrets, credentials, or tokens. No real URLs (only example.com or localhost). No absolute paths.
- No personal names, emails, company names, or project identifiers of any kind.
- No binaries and no generated output (node_modules, dist, target, venv, .git, .env).
- Keep it under 200 files and 256KB packed.
{"case":{"caseId":"case:sha256:ae254d8b1dca15362270a14abccca109dc1b7e53c0626d4ba8e7f8e87dbf73f4","constraints":{"executionContext":"node"},"contract":["running the codex-acp bin with --version exits 0 and prints '@agentclientprotocol/codex-acp 2.12.1'","running 'codex-acp cli \u003cargs\u003e' with CODEX_PATH set forwards arguments to the configured executable and exits with its status","sending an ACP v1 JSON-RPC initialize request over stdio with a local CODEX_PATH app-server stub returns agentInfo for @agentclientprotocol/codex-acp 2.12.1, loadSession capability, and both api-key and chat-gpt authMethods by default","setting NO_BROWSER=1 omits chat-gpt from initialize authMethods while keeping api-key"],"goal":"verify pkg:npm/%40agentclientprotocol/codex-acp@2.12.1","kind":"HOW","packages":["pkg:npm/%40agentclientprotocol/codex-acp@2.12.1"],"schemaVersion":1},"contractCommand":["node","test/contract.cjs"],"environment":{"arch":"x64","distro":"ubuntu","ecosystem":"npm","executionContext":"node","language":"javascript","libc":"glibc","libcVersion":"2.39","moduleSystem":"cjs","os":"linux","osVersionBucket":"24","packageManager":"npm","packageManagerVersion":"10.9.8","runtime":"node","runtimeVersion":"22.23.2","schemaVersion":1},"license":"MIT-0","packages":["pkg:npm/%40agentclientprotocol/codex-acp@2.12.1"],"schemaVersion":1,"subject":"pkg:npm/%40agentclientprotocol/codex-acp@2.12.1","verifierAdapter":"node-typescript@1"}
{
"name": "codex-acp-sample",
"version": "1.0.0",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "codex-acp-sample",
"version": "1.0.0",
"dependencies": {
"@agentclientprotocol/codex-acp": "2.12.1"
}
},
"node_modules/@agentclientprotocol/codex-acp": {
"version": "2.12.1",
"resolved": "https://registry.npmjs.org/@agentclientprotocol/codex-acp/-/codex-acp-2.12.1.tgz",
"integrity": "sha512-4RGVK+bI2T7kkcfzj4hkmCtX1bVmoXB1nR2IXmzX9KVCXUY6cj9clHkyuGQBuIs2swr9Tf0AdWcY+5fQaYHpZQ==",
"license": "Apache-2.0",
"dependencies": {
"@agentclientprotocol/sdk": "~2.9.1",
"@openai/codex": "^0.172.0",
"cross-spawn": "^7.0.6",
"diff": "^9.0.0",
"open": "^11.0.1",
"vscode-jsonrpc": "^9.0.1",
"zod": "^4.0.0"
},
"bin": {
"codex-acp": "dist/index.js"
}
},
"node_modules/@agentclientprotocol/sdk": {
"version": "2.9.1",
"resolved": "https://registry.npmjs.org/@agentclientprotocol/sdk/-/sdk-2.9.1.tgz",
"integrity": "sha512-8iJdxGa3SunLfzqLLb3RfQFmr4hnmWeAyeAK6MbkJiXJbrRlMRgKsVnDl/7Hu48yu/30gAlytNDzh5W77rv5SA==",
"license": "Apache-2.0",
"peerDependencies": {
"@modelcontextprotocol/server": "^2.4.0",
"zod": "^3.25.76 || ^4.0.0"
},
"peerDependenciesMeta": {
"@modelcontextprotocol/server": {
"optional": true
}
}
},
"node_modules/@openai/codex": {
"version": "0.172.0",
"resolved": "https://registry.npmjs.org/@openai/codex/-/codex-0.172.0.tgz",
"integrity": "sha512-yHf/6wbw4Zvha2M2ylDhDrU9FgfKLYgV6xSzSjlz3gxQNsiVLkXo+fPGwBqvP0A5geLtZs9wAbq+1v7+ZVWJ0g==",
"license": "Apache-2.0",
"bin": {
"codex": "bin/codex.js"
},
"engines": {
"node": ">=16"
},
"optionalDependencies": {
"@openai/codex-darwin-arm64": "npm:@openai/codex@0.172.0-darwin-arm64",
"@openai/codex-darwin-x64": "npm:@openai/codex@0.172.0-darwin-x64",
"@openai/codex-linux-arm64": "npm:@openai/codex@0.172.0-linux-arm64",
"@openai/codex-linux-x64": "npm:@openai/codex@0.172.0-linux-x64",
"@openai/codex-win32-arm64": "npm:@openai/codex@0.172.0-win32-arm64",
"@openai/codex-win32-x64": "npm:@openai/codex@0.172.0-win32-x64"
}
},
"node_modules/@openai/codex-darwin-arm64": {
"name": "@openai/codex",
"version": "0.172.0-darwin-arm64",
"resolved": "https://registry.npmjs.org/@openai/codex/-/codex-0.172.0-darwin-arm64.tgz",
"integrity": "sha512-B239wE7pGeOmjylfqLymDIwuL4QgQR7pQZc5phHpZ3t8UVkno9AS3dNPEprm7AzZHw3kf2I6Uf+uOFfjGegELQ==",
"cpu": [
"arm64"
],
"license": "Apache-2.0",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=16"
}
},
"node_modules/@openai/codex-darwin-x64": {
"name": "@openai/codex",
"version": "0.172.0-darwin-x64",
"resolved": "https://registry.npmjs.org/@openai/codex/-/codex-0.172.0-darwin-x64.tgz",
"integrity": "sha512-hrL9NQwH9E0WqK8Yofqe6fipE1XDSXx/C2fwSOagXdTRcjYXOrfQ9fSCKaKZXr/xm43ATdsRSjGGAn8IJhGmhA==",
"cpu": [
"x64"
],
"license": "Apache-2.0",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=16"
}
},
"node_modules/@openai/codex-linux-arm64": {
"name": "@openai/codex",
"version": "0.172.0-linux-arm64",
"resolved": "https://registry.npmjs.org/@openai/codex/-/codex-0.172.0-linux-arm64.tgz",
"integrity": "sha512-qLH5VdeTkPlknWgKkU11IlGMyyxKXp9vcj65libT3Zp4P3Kt7gEbK4YDXlDBqWtA09+fGnIUpWERs6BaNo86DA==",
"cpu": [
"arm64"
],
"license": "Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=16"
}
},
"node_modules/@openai/codex-linux-x64": {
"name": "@openai/codex",
"version": "0.172.0-linux-x64",
"resolved": "https://registry.npmjs.org/@openai/codex/-/codex-0.172.0-linux-x64.tgz",
"integrity": "sha512-YJq6Wz3PFXV5LZ0OQc3/o+gpM3pLmQ/8n8uM2zF/m0O/8zED+uSPT8Ln1KGRrqR8Q6eon9YdWlhueAunVTZ+eg==",
"cpu": [
"x64"
],
"license": "Apache-2.0",
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=16"
}
},
"node_modules/@openai/codex-win32-arm64": {
"name": "@openai/codex",
"version": "0.172.0-win32-arm64",
"resolved": "https://registry.npmjs.org/@openai/codex/-/codex-0.172.0-win32-arm64.tgz",
"integrity": "sha512-lO+hS8rLV3xS5ZZZCBVfPTAqpI1VENId12qhzZ1jNPUBSzKQBOGKs+GHNplak1RHXXXpgK9UHkPQ3A2IvQ8lJg==",
"cpu": [
"arm64"
],
"license": "Apache-2.0",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=16"
}
},
"node_modules/@openai/codex-win32-x64": {
"name": "@openai/codex",
"version": "0.172.0-win32-x64",
"resolved": "https://registry.npmjs.org/@openai/codex/-/codex-0.172.0-win32-x64.tgz",
"integrity": "sha512-48pULjlTwpBZ/TfbOnpnmloHaTQAYELbaiKHEX7qmrtLFIcnPigaNN3omyetPdAuvrRXrmNFRlKfvQme19ZmRA==",
"cpu": [
"x64"
],
"license": "Apache-2.0",
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=16"
}
},
"node_modules/bundle-name": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/bundle-name/-/bundle-name-4.1.1.tgz",
"integrity": "sha512-DdH81/zPLVS11EUgWq3tEu/xn+EzljlMYooDNdzWEnFha3R3NBMpMV1UqYIpjYHV/SgpFKMIX1Oh7o06SjM/oA==",
"license": "MIT",
"dependencies": {
"run-applescript": "^7.0.0"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/cross-spawn": {
"version": "7.0.6",
"resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.6.tgz",
"integrity": "sha512-uV2QOWP2nWzsy2aMp8aRibhi9dlzF5Hgh5SHaB9OiTGEyDTiJJyx0uy51QXdyWbtAHNua4XJzUKca3OzKUd3vA==",
"license": "MIT",
"dependencies": {
"path-key": "^3.1.0",
"shebang-command": "^2.0.0",
"which": "^2.0.1"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/default-browser": {
"version": "5.5.1",
"resolved": "https://registry.npmjs.org/default-browser/-/default-browser-5.5.1.tgz",
"integrity": "sha512-m1pAzaJgZ/gssEqlOhJkPJp8Xly7QyW6xcrkUa2KKcDeDSEMP7X8xipU3snUcfisTQx0w1AGae+9UtJSfVnXGw==",
"license": "MIT",
"dependencies": {
"bundle-name": "^4.1.0",
"default-browser-id": "^5.0.0"
},
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/default-browser-id": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/default-browser-id/-/default-browser-id-5.0.1.tgz",
"integrity": "sha512-x1VCxdX4t+8wVfd1so/9w+vQ4vx7lKd2Qp5tDRutErwmR85OgmfX7RlLRMWafRMY7hbEiXIbudNrjOAPa/hL8Q==",
"license": "MIT",
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/define-lazy-prop": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/define-lazy-prop/-/define-lazy-prop-3.0.0.tgz",
"integrity": "sha512-N+MeXYoqr3pOgn8xfyRPREN7gHakLYjhsHhWGT3fWAiL4IkAt0iDw14QiiEm2bE30c5XX5q0FtAA3CK5f9/BUg==",
"license": "MIT",
"engines": {
"node": ">=12"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/diff": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/diff/-/diff-9.0.0.tgz",
"integrity": "sha512-svtcdpS8CgJyqAjEQIXdb3OjhFVVYjzGAPO8WGCmRbrml64SPw/jJD4GoE98aR7r25A0XcgrK3F02yw9R/vhQw==",
"license": "BSD-3-Clause",
"engines": {
"node": ">=0.3.1"
}
},
"node_modules/is-docker": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-docker/-/is-docker-3.0.0.tgz",
"integrity": "sha512-eljcgEDlEns/7AXFosB5K/2nCM4P7FQPkGc/DWLy5rmFEWvZayGrik1d9/QIY5nJ4f9YsVvBkA6kJpHn9rISdQ==",
"license": "MIT",
"bin": {
"is-docker": "cli.js"
},
"engines": {
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/is-in-ssh": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-in-ssh/-/is-in-ssh-1.0.0.tgz",
"integrity": "sha512-jYa6Q9rH90kR1vKB6NM7qqd1mge3Fx4Dhw5TVlK1MUBqhEOuCagrEHMevNuCcbECmXZ0ThXkRm+Ymr51HwEPAw==",
"license": "MIT",
"engines": {
"node": ">=20"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/is-inside-container": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/is-inside-container/-/is-inside-container-1.0.0.tgz",
"integrity": "sha512-KIYLCCJghfHZxqjYBE7rEy0OBuTd5xCHS7tHVgvCLkx7StIoaxwNW3hCALgEUjFfeRk+MG/Qxmp/vtETEF3tRA==",
"license": "MIT",
"dependencies": {
"is-docker": "^3.0.0"
},
"bin": {
"is-inside-container": "cli.js"
},
"engines": {
"node": ">=14.16"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/is-wsl": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/is-wsl/-/is-wsl-3.1.1.tgz",
"integrity": "sha512-e6rvdUCiQCAuumZslxRJWR/Doq4VpPR82kqclvcS0efgt430SlGIk05vdCN58+VrzgtIcfNODjozVielycD4Sw==",
"license": "MIT",
"dependencies": {
"is-inside-container": "^1.0.0"
},
"engines": {
"node": ">=16"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/isexe": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz",
"integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==",
"license": "ISC"
},
"node_modules/open": {
"version": "11.0.4",
"resolved": "https://registry.npmjs.org/open/-/open-11.0.4.tgz",
"integrity": "sha512-++Zlftm0kVLPmzC06t6epuWmcRMDbI4z5P3NNX979WA/k23+NtSOynEGzsVfZwguKw2mi5umVgnBlJQMwRz4Pg==",
"license": "MIT",
"dependencies": {
"default-browser": "^5.5.1",
"define-lazy-prop": "^3.0.0",
"is-in-ssh": "^1.0.0",
"is-inside-container": "^1.0.0",
"powershell-utils": "^0.2.1",
"wsl-utils": "^1.0.0"
},
"engines": {
"node": ">=20"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/path-key": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz",
"integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/powershell-utils": {
"version": "0.2.1",
"resolved": "https://registry.npmjs.org/powershell-utils/-/powershell-utils-0.2.1.tgz",
"integrity": "sha512-C+y9x90UElAddDZmV4qOx9W53B61PO7cIqWz2dQsWlwswuq4mr8NEwytdGKboYbQlGZ3awrkTeNvcZiZNHnQ8A==",
"license": "MIT",
"engines": {
"node": ">=20"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/run-applescript": {
"version": "7.1.0",
"resolved": "https://registry.npmjs.org/run-applescript/-/run-applescript-7.1.0.tgz",
"integrity": "sha512-DPe5pVFaAsinSaV6QjQ6gdiedWDcRCbUuiQfQa2wmWV7+xC9bGulGI8+TdRmoFkAPaBXk8CrAbnlY2ISniJ47Q==",
"license": "MIT",
"engines": {
"node": ">=18"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/shebang-command": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz",
"integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==",
"license": "MIT",
"dependencies": {
"shebang-regex": "^3.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/shebang-regex": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz",
"integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==",
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/vscode-jsonrpc": {
"version": "9.0.3",
"resolved": "https://registry.npmjs.org/vscode-jsonrpc/-/vscode-jsonrpc-9.0.3.tgz",
"integrity": "sha512-qETYf9PCl1lVfwR+oBmMfc4vP2nqLNA35ABxorw3j06+xlKRgDVxbLgKm4Y/xPL0YWdeDjLoI4ImICIT3nB0zQ==",
"license": "MIT",
"engines": {
"node": ">=14.0.0"
}
},
"node_modules/which": {
"version": "2.0.2",
"resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz",
"integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==",
"license": "ISC",
"dependencies": {
"isexe": "^2.0.0"
},
"bin": {
"node-which": "bin/node-which"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/wsl-utils": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/wsl-utils/-/wsl-utils-1.0.1.tgz",
"integrity": "sha512-c16PKLIRxBYpR3jSWsdS7SFp0COm5SOQdiFjY818dYFHJbMGuLBszpF07LBWmOS1uzrHa9VGdynsEgoeKy0oOQ==",
"license": "MIT",
"dependencies": {
"is-wsl": "^3.1.0",
"powershell-utils": "^0.2.0"
},
"engines": {
"node": ">=20"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/zod": {
"version": "4.6.7",
"resolved": "https://registry.npmjs.org/zod/-/zod-4.6.7.tgz",
"integrity": "sha512-g8W2D2kU6a8untc053fX1uVBKzM7yqAxW/3zwk83+6RyF2+SKOuV+c0wBDhUwzV1PaGapmZH+rmcUzPf+3CGwg==",
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/colinhacks"
}
}
}
}
{
"name": "codex-acp-sample",
"version": "1.0.0",
"private": true,
"scripts": {
"test": "node test/contract.cjs"
},
"dependencies": {
"@agentclientprotocol/codex-acp": "2.12.1"
}
}
{
"schemaVersion": 1,
"goal": "verify pkg:npm/%40agentclientprotocol/codex-acp@2.12.1",
"kind": "HOW",
"packages": [
"pkg:npm/%40agentclientprotocol/codex-acp@2.12.1"
],
"constraints": {
"executionContext": "node"
},
"runtimeConditions": {
"ecosystem": "npm",
"language": "javascript",
"moduleSystem": "cjs",
"packageManager": "npm@10.9.8",
"runtime": "node@22.23.2"
}
}
"use strict";
const assert = require("node:assert/strict");
const { spawn, spawnSync } = require("node:child_process");
const fs = require("node:fs");
const os = require("node:os");
const path = require("node:path");
const readline = require("node:readline");
function resolveCodexAcpEntry() {
const pkgJsonPath = require.resolve("@agentclientprotocol/codex-acp/package.json");
const pkg = JSON.parse(fs.readFileSync(pkgJsonPath, "utf8"));
const relBin = typeof pkg.bin === "string" ? pkg.bin : pkg.bin["codex-acp"];
assert.ok(relBin, "codex-acp bin entry must be declared in package.json");
return path.resolve(path.dirname(pkgJsonPath), relBin);
}
function createMockCodexExecutable(tempDir) {
const mockPath = path.join(tempDir, "mock-codex");
const script = [
"#!" + process.execPath,
'"use strict";',
'const readline = require("node:readline");',
'const args = process.argv.slice(2);',
'if (args[0] !== "app-server") {',
' process.stdout.write(JSON.stringify({ forwardedArgs: args }) + "\\n");',
' process.exit(0);',
'}',
'const rl = readline.createInterface({ input: process.stdin, crlfDelay: Infinity });',
'rl.on("line", (line) => {',
' const trimmed = line.trim();',
' if (!trimmed) return;',
' const msg = JSON.parse(trimmed);',
' if (msg.id === undefined) return;',
' if (msg.method === "initialize") {',
' process.stdout.write(JSON.stringify({',
' jsonrpc: "2.0",',
' id: msg.id,',
' result: { codexHome: process.env.MOCK_CODEX_HOME || "mock-home", echoedClient: msg.params && msg.params.clientInfo }',
' }) + "\\n");',
' return;',
' }',
' if (msg.method === "experimentalFeature/list") {',
' process.stdout.write(JSON.stringify({',
' jsonrpc: "2.0",',
' id: msg.id,',
' result: { data: [], nextCursor: null }',
' }) + "\\n");',
' return;',
' }',
' if (msg.method === "account/read") {',
' process.stdout.write(JSON.stringify({',
' jsonrpc: "2.0",',
' id: msg.id,',
' result: { account: null, requiresOpenaiAuth: false }',
' }) + "\\n");',
' return;',
' }',
' process.stdout.write(JSON.stringify({ jsonrpc: "2.0", id: msg.id, result: {} }) + "\\n");',
'});',
'process.stdin.on("end", () => process.exit(0));',
""
].join("\n");
fs.writeFileSync(mockPath, script, { mode: 0o755 });
fs.chmodSync(mockPath, 0o755);
return mockPath;
}
function runInitializeHandshake(entryPath, mockCodexPath, extraEnv) {
return new Promise((resolve, reject) => {
const env = { ...process.env, CODEX_PATH: mockCodexPath, ...extraEnv };
if (!("NO_BROWSER" in extraEnv)) {
delete env.NO_BROWSER;
}
const child = spawn(process.execPath, [entryPath], {
env,
stdio: ["pipe", "pipe", "pipe"]
});
let stderr = "";
child.stderr.on("data", (chunk) => {
stderr += chunk.toString("utf8");
});
const timer = setTimeout(() => {
child.kill("SIGKILL");
reject(new Error(`Timed out waiting for ACP initialize response. stderr: ${stderr}`));
}, 10000);
let initResponse = null;
const rl = readline.createInterface({ input: child.stdout, crlfDelay: Infinity });
rl.on("line", (line) => {
const trimmed = line.trim();
if (!trimmed) return;
let msg;
try {
msg = JSON.parse(trimmed);
} catch {
return;
}
if (msg.id === 1 && !initResponse) {
initResponse = msg;
child.stdin.end();
}
});
child.on("error", (err) => {
clearTimeout(timer);
reject(err);
});
child.on("close", (code) => {
clearTimeout(timer);
rl.close();
if (!initResponse) {
reject(new Error(`codex-acp exited (${code}) before returning initialize response. stderr: ${stderr}`));
return;
}
resolve({ response: initResponse, exitCode: code, stderr });
});
const request = {
jsonrpc: "2.0",
id: 1,
method: "initialize",
params: {
protocolVersion: 1,
clientCapabilities: {},
clientInfo: {
name: "contract-client",
version: "1.0.0"
}
}
};
child.stdin.write(JSON.stringify(request) + "\n");
});
}
async function main() {
const entryPath = resolveCodexAcpEntry();
const tempDir = fs.mkdtempSync(path.join(os.tmpdir(), "codex-acp-contract-"));
try {
// 1. Verify --version CLI output
const versionResult = spawnSync(process.execPath, [entryPath, "--version"], {
encoding: "utf8",
timeout: 10000
});
assert.equal(versionResult.status, 0, `Expected --version exit code 0, stderr: ${versionResult.stderr}`);
assert.equal(versionResult.stdout.trim(), "@agentclientprotocol/codex-acp 2.12.1");
// 2. Verify cli subcommand argument forwarding through CODEX_PATH
const mockCodexPath = createMockCodexExecutable(tempDir);
const cliResult = spawnSync(process.execPath, [entryPath, "cli", "--check", "offline"], {
encoding: "utf8",
env: { ...process.env, CODEX_PATH: mockCodexPath },
timeout: 10000
});
assert.equal(cliResult.status, 0, `Expected cli exit code 0, stderr: ${cliResult.stderr}`);
const cliPayload = JSON.parse(cliResult.stdout.trim());
assert.deepEqual(cliPayload.forwardedArgs, ["--check", "offline"]);
// 3. Verify ACP stdio JSON-RPC initialize handshake with default auth methods
const defaultInit = await runInitializeHandshake(entryPath, mockCodexPath, {
MOCK_CODEX_HOME: path.join(tempDir, "codex-home")
});
assert.equal(defaultInit.response.error, undefined, `Unexpected RPC error: ${JSON.stringify(defaultInit.response.error)}`);
assert.equal(defaultInit.response.result.protocolVersion, 1);
assert.equal(defaultInit.response.result.agentInfo.name, "@agentclientprotocol/codex-acp");
assert.equal(defaultInit.response.result.agentInfo.version, "2.12.1");
assert.equal(defaultInit.response.result.agentCapabilities.loadSession, true);
const defaultAuthIds = defaultInit.response.result.authMethods.map((m) => m.id);
assert.ok(defaultAuthIds.includes("api-key"), "Expected api-key auth method");
assert.ok(defaultAuthIds.includes("chat-gpt"), "Expected chat-gpt auth method when NO_BROWSER is unset");
// 4. Verify NO_BROWSER=1 hides browser-based chat-gpt auth method
const noBrowserInit = await runInitializeHandshake(entryPath, mockCodexPath, {
NO_BROWSER: "1",
MOCK_CODEX_HOME: path.join(tempDir, "codex-home")
});
assert.equal(noBrowserInit.response.error, undefined);
const noBrowserAuthIds = noBrowserInit.response.result.authMethods.map((m) => m.id);
assert.ok(noBrowserAuthIds.includes("api-key"), "Expected api-key auth method when NO_BROWSER=1");
assert.ok(!noBrowserAuthIds.includes("chat-gpt"), "Expected chat-gpt auth method to be omitted when NO_BROWSER=1");
} finally {
fs.rmSync(tempDir, { recursive: true, force: true });
}
}
main().catch((err) => {
console.error(err);
process.exit(1);
});
Seeder de origen
anónimo