@agentproto/adapter-claude-code-cloud 0.0.0-stage → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/sessions-api.ts","../src/cli.ts","../src/repo-source.ts","../src/acp-server.ts"],"names":["execFileAsync","promisify","execFile"],"mappings":";;;;;;;;;;;;;;;;AAuBA,IAAM,aAAA,GAAgB,UAAU,QAAQ,CAAA;AAiBxC,IAAM,gBAAA,GAAmB,yBAAA;AAOlB,SAAS,wBAAA,CACd,IAAA,GAOI,EAAC,EACa;AAClB,EAAA,MAAM,YAAA,GACJ,IAAA,CAAK,YAAA,KACJ,OAAO,KAAa,IAAA,KAAmB;AACtC,IAAA,MAAM,EAAE,MAAA,EAAO,GAAI,MAAM,aAAA,CAAc,KAAK,IAAA,EAAM;AAAA;AAAA;AAAA,MAGhD,WAAW,CAAA,IAAK;AAAA,KACjB,CAAA;AACD,IAAA,OAAO,EAAE,MAAA,EAAO;AAAA,EAClB,CAAA,CAAA;AACF,EAAA,MAAM,mBACJ,IAAA,CAAK,gBAAA,KACJ,CAAC,IAAA,KAAiB,QAAA,CAAS,MAAM,MAAM,CAAA,CAAA;AAC1C,EAAA,MAAM,IAAA,GAAO,KAAK,OAAA,IAAW,OAAA;AAE7B,EAAA,IAAI,MAAA,GAAiC,IAAA;AAErC,EAAA,OAAO;AAAA,IACL,MAAM,GAAA,GAAgC;AACpC,MAAA,IAAI,QAAQ,OAAO,MAAA;AACnB,MAAA,MAAM,EAAE,MAAA,EAAO,GAAI,MAAM,aAAa,UAAA,EAAY;AAAA,QAChD,uBAAA;AAAA,QACA,IAAA;AAAA,QACA,gBAAA;AAAA,QACA;AAAA,OACD,CAAA;AACD,MAAA,MAAM,QAAA,GAAW,IAAA,CAAK,KAAA,CAAM,MAAM,CAAA;AAGlC,MAAA,MAAM,WAAA,GAAc,SAAS,aAAA,EAAe,WAAA;AAC5C,MA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O,IAAI,mBAAA;AAAA,IACT,CAAA,IAAA,KAAQ,IAAI,mBAAA,CAAoB,IAAA,EAAM,IAAI,CAAA;AAAA,IAC1C;AAAA,GACF;AACF;AAGO,SAAS,IAAA,GAAa;AAC3B,EAAA,eAAA,EAAgB;AAClB","file":"chunk-KA4G4O2X.mjs","sourcesContent":["/**\n * Thin client for the undocumented Claude Code cloud sessions API\n * (AIP-66 Appendix A). Base https://api.anthropic.com; requests carry\n * `Authorization: Bearer <claude.ai OAuth access token>`,\n * `anthropic-version: 2023-06-01` and `x-organization-uuid`.\n *\n * The credential is the user's claude.ai login, owned by the claude CLI\n * (AIP-66 §8): this module never logs it, never persists it, and never\n * writes it anywhere — it lives only in request headers for the lifetime\n * of a call. On 401 the credential source is re-read exactly once (the\n * token may have been refreshed since process start), then the call fails\n * with a message that tells the user how to log in.\n *\n * All network access goes through an injectable `fetch` so tests can drive\n * the client from fixtures — no live Anthropic call is ever made from here.\n */\n\nimport { execFile } from \"node:child_process\"\nimport { readFile } from \"node:fs/promises\"\nimport { homedir } from \"node:os\"\nimport { join } from \"node:path\"\nimport { promisify } from \"node:util\"\n\nconst execFileAsync = promisify(execFile)\n\n/** A claude.ai OAuth credential. `accessToken` is the bearer the API wants;\n * `orgUuid` is the `x-organization-uuid` header (from `~/.claude.json`'s\n * `.oauthAccount.organizationUuid`). NEVER logged or persisted. */\nexport interface CloudCredential {\n accessToken: string\n orgUuid?: string\n}\n\n/** Where the host reads the vendor login from (AIP-66 §8). Implementations\n * must not cache a token across an explicit invalidate() — a 401 re-read\n * has to be able to observe a refreshed login. */\nexport interface CredentialSource {\n get(): Promise<CloudCredential>\n}\n\nconst KEYCHAIN_SERVICE = \"Claude Code-credentials\"\n\n/** macOS keychain credential: `security find-generic-password -s \"Claude\n * Code-credentials\" -w` returns JSON whose `.claudeAiOauth.accessToken` is\n * the bearer; the org uuid comes from `~/.claude.json`. `execFile` and the\n * file reader are injectable for tests; the token never leaves this module\n * except as a request header. */\nexport function keychainCredentialSource(\n deps: {\n execFileImpl?: (\n cmd: string,\n args: string[],\n ) => Promise<{ stdout: string }>\n readFileSyncImpl?: (path: string) => Promise<string>\n homedir?: () => string\n } = {},\n): CredentialSource {\n const execFileImpl =\n deps.execFileImpl ??\n (async (cmd: string, args: string[]) => {\n const { stdout } = await execFileAsync(cmd, args, {\n // `security` writes the secret to stdout only; maxBuffer covers a\n // long JSON blob. Never `echo` it anywhere else.\n maxBuffer: 1 << 20,\n })\n return { stdout }\n })\n const readFileSyncImpl =\n deps.readFileSyncImpl ??\n ((path: string) => readFile(path, \"utf8\"))\n const home = deps.homedir ?? homedir\n\n let cached: CloudCredential | null = null\n\n return {\n async get(): Promise<CloudCredential> {\n if (cached) return cached\n const { stdout } = await execFileImpl(\"security\", [\n \"find-generic-password\",\n \"-s\",\n KEYCHAIN_SERVICE,\n \"-w\",\n ])\n const keychain = JSON.parse(stdout) as {\n claudeAiOauth?: { accessToken?: string }\n }\n const accessToken = keychain.claudeAiOauth?.accessToken\n if (!accessToken) {\n throw new Error(\n \"claude code cloud: no claudeAiOauth.accessToken in the Claude Code \" +\n \"keychain entry — run `claude auth login`\",\n )\n }\n let orgUuid: string | undefined\n try {\n const rc = JSON.parse(\n await readFileSyncImpl(join(home(), \".claude.json\")),\n ) as { oauthAccount?: { organizationUuid?: string } }\n orgUuid = rc.oauthAccount?.organizationUuid\n } catch {\n // org header is best-effort; some CLI versions work without it.\n }\n cached = { accessToken, ...(orgUuid ? { orgUuid } : {}) }\n return cached\n },\n }\n}\n\n/** Env credential for hosts/tests that inject the login themselves:\n * CLAUDE_CLOUD_OAUTH_TOKEN (+ optional CLAUDE_CLOUD_ORG_UUID). */\nexport function envCredentialSource(\n env: Record<string, string | undefined> = process.env,\n): CredentialSource {\n return {\n async get(): Promise<CloudCredential> {\n const accessToken = env.CLAUDE_CLOUD_OAUTH_TOKEN\n if (!accessToken) {\n throw new Error(\n \"claude code cloud: CLAUDE_CLOUD_OAUTH_TOKEN is not set — run \" +\n \"`claude auth login` and use the keychain credential source, or \" +\n \"inject the token\",\n )\n }\n const orgUuid = env.CLAUDE_CLOUD_ORG_UUID\n return { accessToken, ...(orgUuid ? { orgUuid } : {}) }\n },\n }\n}\n\n// ── wire shapes (observed 2026-10-14, CLI 2.1.296–2.1.299) ──────────────────\n\n/** One entry of GET /v1/code/sessions/{id}/events (newest first). The\n * `payload` is the Claude Code stream-json SDK message for `user` /\n * `assistant` / `result` events. */\nexport interface CloudSessionEvent {\n created_at: string\n event_id: string\n event_type: string\n payload: unknown\n}\n\nexport interface CloudEventsPage {\n data: CloudSessionEvent[]\n /** Pass back as `cursor` on the next poll to resume after this page. */\n resume_cursor?: string\n}\n\n/** GET /v1/code/sessions/{id} — wrapped in `response_shape`. */\nexport interface CloudSessionState {\n id: string\n title: string\n status: string\n status_bucket?: string\n worker_status?: string\n connection_status?: string\n last_event_at?: string\n session_url?: string\n post_turn_summary?: string\n [key: string]: unknown\n}\n\nexport interface CloudGetSessionResponse {\n response_shape: CloudSessionState\n [key: string]: unknown\n}\n\n/** One entry of GET /v1/code/sessions — id is spelled `cse_<suffix>`, the\n * same suffix the CLI's `session_<suffix>` carries. */\nexport interface CloudSessionSummary {\n id: string\n title: string\n status: \"active\" | \"archived\" | string\n environment_kind?: \"anthropic_cloud\" | \"bridge\" | string\n config?: { model?: string; origin?: string; [key: string]: unknown }\n created_at?: string\n [key: string]: unknown\n}\n\nexport interface CloudListSessionsResponse {\n data: CloudSessionSummary[]\n resume_token?: string\n}\n\n/**\n * Normalize a session id to the API's own `cse_<suffix>` spelling. Accepts\n * `session_<suffix>` (what the CLI prints and `--cloud` takes) and\n * `cse_<suffix>` (what the API listing returns); rejects anything else so a\n * malformed id can never be interpolated into a request path.\n */\nexport function normalizeSessionId(id: string): string {\n const trimmed = id.trim()\n if (trimmed.startsWith(\"session_\")) return `cse_${trimmed.slice(\"session_\".length)}`\n if (trimmed.startsWith(\"cse_\")) return trimmed\n throw new Error(\n `claude code cloud: unrecognized session id ${JSON.stringify(id)} — ` +\n \"expected session_<id> or cse_<id>\",\n )\n}\n\n/** Normalize to the CLI's own `session_<suffix>` spelling (for `--cloud`,\n * `--teleport`). Same acceptance set as {@link normalizeSessionId}. */\nexport function toCliSessionId(id: string): string {\n const normalized = normalizeSessionId(id)\n return `session_${normalized.slice(\"cse_\".length)}`\n}\n\nexport interface SessionsApiOptions {\n /** Credential source; re-read once on a 401, then the call fails. */\n credentials: CredentialSource\n /** Injectable fetch — tests pass a fixture router; default is globalThis.fetch. */\n fetchImpl?: typeof fetch\n /** Override for proxies/mirrors; default https://api.anthropic.com. */\n baseUrl?: string\n}\n\nconst UNAUTHORIZED_HINT = \"run `claude auth login`\"\n\nexport class SessionsApi {\n readonly #credentials: CredentialSource\n readonly #fetch: typeof fetch\n readonly #baseUrl: string\n #credential: CloudCredential | null = null\n\n constructor(options: SessionsApiOptions) {\n this.#credentials = options.credentials\n this.#fetch = options.fetchImpl ?? globalThis.fetch.bind(globalThis)\n this.#baseUrl = (options.baseUrl ?? \"https://api.anthropic.com\").replace(/\\/$/, \"\")\n }\n\n /** GET /v1/code/sessions/{id} */\n async getSession(id: string): Promise<CloudGetSessionResponse> {\n return this.#request<CloudGetSessionResponse>(\n \"GET\",\n `/v1/code/sessions/${normalizeSessionId(id)}`,\n )\n }\n\n /**\n * GET /v1/code/sessions/{id}/events — newest first. Pass the previous\n * page's `resume_cursor` as `cursor` to resume after it.\n */\n async listEvents(\n id: string,\n opts: { cursor?: string; limit?: number } = {},\n ): Promise<CloudEventsPage> {\n const params = new URLSearchParams()\n if (opts.cursor) params.set(\"cursor\", opts.cursor)\n if (opts.limit !== undefined) params.set(\"limit\", String(opts.limit))\n const qs = params.toString()\n return this.#request<CloudEventsPage>(\n \"GET\",\n `/v1/code/sessions/${normalizeSessionId(id)}/events${qs ? `?${qs}` : \"\"}`,\n )\n }\n\n /** GET /v1/code/sessions?limit=N */\n async listSessions(\n opts: { limit?: number } = {},\n ): Promise<CloudListSessionsResponse> {\n const qs = opts.limit !== undefined ? `?limit=${opts.limit}` : \"\"\n return this.#request<CloudListSessionsResponse>(\n \"GET\",\n `/v1/code/sessions${qs}`,\n )\n }\n\n async #credentialNow(): Promise<CloudCredential> {\n if (!this.#credential) this.#credential = await this.#credentials.get()\n return this.#credential\n }\n\n async #request<T>(method: string, path: string, retriedAuth = false): Promise<T> {\n const credential = await this.#credentialNow()\n const headers: Record<string, string> = {\n authorization: `Bearer ${credential.accessToken}`,\n \"anthropic-version\": \"2023-06-01\",\n \"content-type\": \"application/json\",\n ...(credential.orgUuid ? { \"x-organization-uuid\": credential.orgUuid } : {}),\n }\n const res = await this.#fetch(`${this.#baseUrl}${path}`, { method, headers })\n if (res.status === 401 && !retriedAuth) {\n // The token may have been refreshed since we read it — re-read the\n // source exactly once, then fail closed with the login hint.\n this.#credential = null\n return this.#request<T>(method, path, true)\n }\n if (res.status === 401) {\n throw new Error(`claude code cloud: unauthorized (401) — ${UNAUTHORIZED_HINT}`)\n }\n if (!res.ok) {\n throw new Error(\n `claude code cloud: ${method} ${path} failed: HTTP ${res.status}`,\n )\n }\n return (await res.json()) as T\n }\n}\n","/**\n * The vendor-client surface (AIP-66 Appendix A): start a Claude Code cloud\n * session under a PTY, send follow-ups headlessly, and preflight the\n * claude.ai login. The CLI is the only supported way to CREATE and PROMPT a\n * cloud session — the sessions API (sessions-api.ts) is observe-only.\n *\n * Every child process runs with ANTHROPIC_API_KEY and the Claude Code\n * gateway/redirect toggles deleted from its env (AIP-66 §8): a leftover\n * toggle or API key would make the CLI authenticate a different way and\n * refuse (or worse, re-route) the cloud call. The token the CLI reads from\n * the user's own login is never touched, logged or persisted here.\n *\n * The binary runner is injectable so tests can drive every path — auth\n * preflight, trust prompt, output parsing — from fixtures without a live\n * claude CLI or a real PTY.\n */\n\nimport { spawn } from \"node:child_process\"\nimport { ANTHROPIC_CORE_SCRUB_ENV } from \"@agentproto/provider-presets\"\nimport { toCliSessionId } from \"./sessions-api.js\"\n\n// Cloud-provider redirect toggles scrubbed alongside ANTHROPIC_API_KEY —\n// byte-for-byte the same set the claude-code adapter scrubs for gateway\n// modes (adapters/claude-code/src/index.ts): a leftover Bedrock/Vertex/…\n// toggle in the child env would override the claude.ai login path. The\n// core ANTHROPIC_API_KEY entry comes from @agentproto/provider-presets, the\n// single source of truth for that fact.\nconst CLAUDE_CODE_CLOUD_TOGGLES: readonly string[] = [\n \"CLAUDE_CODE_USE_BEDROCK\",\n \"CLAUDE_CODE_USE_VERTEX\",\n \"CLAUDE_CODE_USE_FOUNDRY\",\n \"CLAUDE_CODE_USE_ANTHROPIC_AWS\",\n \"CLAUDE_CODE_USE_MANTLE\",\n \"CLAUDE_CODE_USE_GATEWAY\",\n]\n\n/** Env keys deleted from every claude child this adapter spawns (AIP-66 §8). */\nexport const CLAUDE_CODE_GATEWAY_ENV_UNSET: readonly string[] = [\n ...ANTHROPIC_CORE_SCRUB_ENV,\n ...CLAUDE_CODE_CLOUD_TOGGLES,\n]\n\n/** Copy `base` with every {@link CLAUDE_CODE_GATEWAY_ENV_UNSET} key deleted. */\nexport function cloudChildEnv(\n base: Record<string, string | undefined> = process.env,\n): Record<string, string> {\n const out: Record<string, string> = {}\n const drop = new Set(CLAUDE_CODE_GATEWAY_ENV_UNSET)\n for (const [key, value] of Object.entries(base)) {\n if (value === undefined || drop.has(key)) continue\n out[key] = value\n }\n return out\n}\n\n// ── injectable runner ───────────────────────────────────────────────────────\n\nexport interface RunResult {\n code: number\n stdout: string\n stderr: string\n}\n\nexport interface RunOpts {\n cwd: string\n env: Record<string, string>\n timeoutMs?: number\n /** \"ignore\" detaches stdin so a non-interactive call can never TTY-block. */\n stdin?: \"ignore\"\n}\n\nexport interface PtyHandle {\n write(data: string): void\n result: Promise<{ code: number; output: string }>\n}\n\nexport interface PtyRunOpts extends RunOpts {\n onData?: (chunk: string) => void\n}\n\n/** What {@link startCloudSession} / {@link sendPrompt} drive. Tests inject a\n * fake; production uses {@link defaultCloudCliRunner}. */\nexport interface CloudCliRunner {\n run(cmd: string, args: string[], opts: RunOpts): Promise<RunResult>\n runPty(cmd: string, args: string[], opts: PtyRunOpts): PtyHandle\n}\n\nconst DEFAULT_RUN_TIMEOUT_MS = 60_000\n\n/** Real runner: child_process for headless calls, node-pty (optional dep)\n * for the TTY-required `claude --cloud` start. */\nexport function defaultCloudCliRunner(): CloudCliRunner {\n return {\n run(cmd, args, opts) {\n return new Promise<RunResult>((resolve, reject) => {\n const child = spawn(cmd, args, {\n cwd: opts.cwd,\n env: opts.env,\n stdio: [opts.stdin === \"ignore\" ? \"ignore\" : \"inherit\", \"pipe\", \"pipe\"],\n })\n let stdout = \"\"\n let stderr = \"\"\n const timer = setTimeout(() => {\n child.kill(\"SIGKILL\")\n reject(\n new Error(\n `claude code cloud: \\`${cmd} ${args.join(\" \")}\\` timed out after ` +\n `${opts.timeoutMs ?? DEFAULT_RUN_TIMEOUT_MS}ms`,\n ),\n )\n }, opts.timeoutMs ?? DEFAULT_RUN_TIMEOUT_MS)\n timer.unref?.()\n child.stdout?.on(\"data\", (d: Buffer) => (stdout += d.toString()))\n child.stderr?.on(\"data\", (d: Buffer) => (stderr += d.toString()))\n child.on(\"error\", (err) => {\n clearTimeout(timer)\n reject(err)\n })\n child.on(\"close\", (code) => {\n clearTimeout(timer)\n resolve({ code: code ?? -1, stdout, stderr })\n })\n })\n },\n runPty(cmd, args, opts) {\n let resolveResult: (v: { code: number; output: string }) => void\n let rejectResult: (err: unknown) => void\n const result = new Promise<{ code: number; output: string }>((res, rej) => {\n resolveResult = res\n rejectResult = rej\n })\n let proc: import(\"node-pty\").IPty | null = null\n const pendingWrites: string[] = []\n // node-pty is an optional native dep (same policy as @agentproto/cli):\n // load it lazily and fail with an actionable message when absent.\n void import(\"node-pty\")\n .then(mod => {\n // node-pty is CJS — `import()` wraps it under `.default`.\n const pty = (mod as { default?: { spawn: typeof import(\"node-pty\").spawn } }).default ?? (mod as unknown as { spawn: typeof import(\"node-pty\").spawn })\n if (typeof pty.spawn !== \"function\") throw new Error(\"node-pty has no spawn\")\n const p = pty.spawn(cmd, args, {\n name: \"xterm-256color\",\n cols: 120,\n rows: 40,\n cwd: opts.cwd,\n env: opts.env,\n })\n proc = p\n for (const data of pendingWrites) p.write(data)\n pendingWrites.length = 0\n let output = \"\"\n let answeredTrustPrompt = false\n p.onData((chunk: string) => {\n output += chunk\n opts.onData?.(chunk)\n // First run in a folder shows a trust prompt whose DEFAULT\n // highlighted option is \"No, exit\" — Down + Enter picks\n // \"Yes, I trust this folder\". Answer at most once.\n if (!answeredTrustPrompt && /Yes, I trust this folder/.test(output)) {\n answeredTrustPrompt = true\n p.write(\"\\x1b[B\\r\")\n }\n })\n const timer = setTimeout(() => {\n try {\n p.kill(\"SIGKILL\")\n } catch {\n // already dead\n }\n rejectResult(\n new Error(\n `claude code cloud: \\`${cmd} ${args.join(\" \")}\\` timed out after ` +\n `${opts.timeoutMs ?? 120_000}ms under the PTY`,\n ),\n )\n }, opts.timeoutMs ?? 120_000)\n timer.unref?.()\n p.onExit(({ exitCode }: { exitCode: number }) => {\n clearTimeout(timer)\n resolveResult({ code: exitCode, output })\n })\n })\n .catch(err => {\n rejectResult(\n new Error(\n `claude code cloud: \\`claude --cloud\\` needs a real PTY and ` +\n `node-pty is not available (${err instanceof Error ? err.message : String(err)}) — ` +\n `install it (npm i node-pty) to use managed cloud sessions`,\n ),\n )\n })\n return {\n write: (data: string) => {\n if (proc) proc.write(data)\n else pendingWrites.push(data)\n },\n result,\n }\n },\n }\n}\n\n// ── auth preflight ──────────────────────────────────────────────────────────\n\nexport interface AuthStatus {\n loggedIn: boolean\n authMethod?: string\n}\n\n/** Parse `claude auth status` JSON output. */\nexport function parseAuthStatus(stdout: string): AuthStatus {\n const trimmed = stdout.trim()\n const start = trimmed.indexOf(\"{\")\n const end = trimmed.lastIndexOf(\"}\")\n if (start === -1 || end === -1 || end < start) {\n throw new Error(\n \"claude code cloud: could not parse `claude auth status` output — \" +\n \"run `claude auth login`\",\n )\n }\n const parsed = JSON.parse(trimmed.slice(start, end + 1)) as {\n loggedIn?: boolean\n authMethod?: string\n }\n return { loggedIn: parsed.loggedIn === true, authMethod: parsed.authMethod }\n}\n\n/**\n * Refuse the spawn before any side effect when the claude CLI is missing,\n * not logged in, or authenticated by API key — cloud sessions require a\n * claude.ai sign-in (verified live: an ANTHROPIC_API_KEY env makes the CLI\n * refuse with \"Cloud sessions need a claude.ai sign-in\").\n */\nexport async function preflightAuth(\n runner: CloudCliRunner,\n opts: { cwd: string; env: Record<string, string> },\n): Promise<AuthStatus> {\n let result: RunResult\n try {\n result = await runner.run(\"claude\", [\"auth\", \"status\"], {\n cwd: opts.cwd,\n env: opts.env,\n timeoutMs: 15_000,\n stdin: \"ignore\",\n })\n } catch (err) {\n throw new Error(\n `claude code cloud: could not run \\`claude auth status\\` — is the ` +\n `claude CLI installed and on PATH? (${err instanceof Error ? err.message : String(err)})`,\n )\n }\n if (result.code !== 0 && !result.stdout.trim()) {\n throw new Error(\n \"claude code cloud: `claude auth status` failed — the claude CLI is \" +\n \"not usable; run `claude auth login`\",\n )\n }\n const status = parseAuthStatus(result.stdout)\n if (!status.loggedIn) {\n throw new Error(\n \"claude code cloud: not logged in — cloud sessions need a claude.ai \" +\n \"sign-in; run `claude auth login`\",\n )\n }\n if (status.authMethod === \"api_key\") {\n throw new Error(\n \"claude code cloud: authenticated by API key — cloud sessions need a \" +\n \"claude.ai sign-in; run `claude auth login`\",\n )\n }\n return status\n}\n\n// ── start / send ────────────────────────────────────────────────────────────\n\nexport interface StartedCloudSession {\n /** CLI-spelled id (`session_<id>`), ready for `--cloud` / `--teleport`. */\n sessionId: string\n url: string\n title?: string\n}\n\n/** Parse the `claude --cloud` start transcript: the id from the \"Resume\n * with:\" line (falling back to the View URL's path), the URL, and the\n * session title. Returns null when no session id can be found. */\nexport function parseCloudStartOutput(\n output: string,\n): StartedCloudSession | null {\n let sessionId: string | undefined\n let url: string | undefined\n let title: string | undefined\n\n const resume = output.match(/Resume with:\\s*claude\\s+--teleport\\s+(session_[A-Za-z0-9_-]+)/)\n if (resume?.[1]) sessionId = resume[1]\n\n const view = output.match(/View:\\s*(https?:\\/\\/\\S+)/)\n if (view?.[1]) {\n url = view[1]\n if (!sessionId) {\n const fromUrl = url.match(/\\/session_([A-Za-z0-9_-]+)/)\n if (fromUrl?.[1]) sessionId = `session_${fromUrl[1]}`\n }\n }\n\n const created = output.match(/Created cloud session:\\s*(.+)/)\n if (created?.[1]) title = created[1].trim()\n\n if (!sessionId) return null\n return {\n sessionId,\n url: url ?? `https://claude.ai/code/${sessionId}`,\n ...(title ? { title } : {}),\n }\n}\n\nexport interface StartCloudSessionOpts {\n runner?: CloudCliRunner\n env?: Record<string, string | undefined>\n cwd: string\n /** Hard cap on the interactive start (PTY) — default 120s. */\n timeoutMs?: number\n /** Skip the auth preflight (tests only; production always preflights). */\n skipPreflight?: boolean\n}\n\n/**\n * Start a cloud session: `claude --cloud \"<prompt>\"` under a PTY (the CLI\n * requires a TTY here), answering the first-run folder-trust prompt, then\n * parse the printed session id / URL and exit. The vendor runs the first\n * turn; observe it via the sessions API.\n */\nexport async function startCloudSession(\n prompt: string,\n opts: StartCloudSessionOpts,\n): Promise<StartedCloudSession> {\n const runner = opts.runner ?? defaultCloudCliRunner()\n const env = cloudChildEnv(opts.env ?? process.env)\n if (!opts.skipPreflight) await preflightAuth(runner, { cwd: opts.cwd, env })\n\n const pty = runner.runPty(\"claude\", [\"--cloud\", prompt], {\n cwd: opts.cwd,\n env,\n timeoutMs: opts.timeoutMs ?? 120_000,\n })\n const { code, output } = await pty.result\n if (code !== 0) {\n throw new Error(\n `claude code cloud: \\`claude --cloud\\` exited ${code}: ` +\n `${output.trim().split(\"\\n\").slice(-5).join(\"\\n\").trim()}`,\n )\n }\n const started = parseCloudStartOutput(output)\n if (!started) {\n throw new Error(\n \"claude code cloud: could not parse a cloud session id from \" +\n \"`claude --cloud` output\",\n )\n }\n return started\n}\n\nexport interface SendPromptOpts {\n runner?: CloudCliRunner\n env?: Record<string, string | undefined>\n cwd: string\n timeoutMs?: number\n skipPreflight?: boolean\n}\n\n/**\n * Send a follow-up turn: `claude -p \"<text>\" --cloud <session id>` with\n * stdin detached (no TTY). Send-only by design — the CLI prints \"Sent to\n * cloud session.\" and never the reply; the reply is observed via the\n * sessions API. Accepts `session_`/`cse_` ids.\n */\nexport async function sendPrompt(\n sessionId: string,\n text: string,\n opts: SendPromptOpts,\n): Promise<{ stdout: string }> {\n const runner = opts.runner ?? defaultCloudCliRunner()\n const env = cloudChildEnv(opts.env ?? process.env)\n if (!opts.skipPreflight) await preflightAuth(runner, { cwd: opts.cwd, env })\n\n const result = await runner.run(\n \"claude\",\n [\"-p\", text, \"--cloud\", toCliSessionId(sessionId)],\n {\n cwd: opts.cwd,\n env,\n stdin: \"ignore\",\n timeoutMs: opts.timeoutMs ?? 60_000,\n },\n )\n if (result.code !== 0) {\n throw new Error(\n `claude code cloud: \\`claude -p --cloud\\` exited ${result.code}: ` +\n `${(result.stderr || result.stdout).trim().split(\"\\n\").slice(-5).join(\"\\n\").trim()}`,\n )\n }\n return { stdout: result.stdout }\n}\n","/**\n * AIP-66 §3 (repo source): a managed cloud agent runs on a git remote and\n * ref — never on an uploaded working tree. The host MUST refuse the spawn\n * when `cwd` is not a git checkout with a remote, when the working tree is\n * dirty, or when HEAD is not reachable from the remote.\n *\n * Pure git-invocation logic with an injectable runner so tests can drive\n * every refusal from fixtures (no real repo required).\n */\n\nimport { execFile } from \"node:child_process\"\nimport { promisify } from \"node:util\"\n\nconst execFileAsync = promisify(execFile)\n\n/** Runs `git <args…>` in `cwd`; resolves with the exit code + streams. */\nexport type GitRunner = (\n args: string[],\n cwd: string,\n) => Promise<{ code: number; stdout: string; stderr: string }>\n\nexport const defaultGitRunner: GitRunner = async (args, cwd) => {\n try {\n const { stdout, stderr } = await execFileAsync(\"git\", args, { cwd })\n return { code: 0, stdout, stderr }\n } catch (err) {\n const e = err as { code?: number; stdout?: string; stderr?: string }\n return {\n code: typeof e.code === \"number\" ? e.code : 1,\n stdout: e.stdout ?? \"\",\n stderr: e.stderr ?? \"\",\n }\n }\n}\n\n/**\n * Refuse (throw) unless `cwd` is a clean git checkout whose HEAD is\n * contained in some `origin/*` ref. Each error names the failed condition —\n * the ACP server surfaces it as the `session/new` failure.\n */\nexport async function validateRepoSource(\n cwd: string,\n git: GitRunner = defaultGitRunner,\n): Promise<void> {\n const inside = await git([\"rev-parse\", \"--is-inside-work-tree\"], cwd)\n if (inside.code !== 0 || inside.stdout.trim() !== \"true\") {\n throw new Error(\n `claude code cloud: ${cwd} is not a git checkout — managed cloud ` +\n \"agents run on a git remote and ref (AIP-66 §3)\",\n )\n }\n\n const status = await git([\"status\", \"--porcelain\"], cwd)\n if (status.code !== 0) {\n throw new Error(\n `claude code cloud: could not read the working tree status in ${cwd} ` +\n `(${status.stderr.trim() || `git status exited ${status.code}`})`,\n )\n }\n if (status.stdout.trim().length > 0) {\n throw new Error(\n `claude code cloud: the working tree in ${cwd} is dirty — commit or ` +\n \"stash first; the vendor refuses to upload uncommitted files \" +\n \"(AIP-66 §3)\",\n )\n }\n\n const remote = await git([\"remote\", \"get-url\", \"origin\"], cwd)\n if (remote.code !== 0 || !remote.stdout.trim()) {\n throw new Error(\n `claude code cloud: ${cwd} has no origin remote — a managed cloud ` +\n \"agent runs on the repo's remote, not a local path (AIP-66 §3)\",\n )\n }\n\n const head = await git([\"rev-parse\", \"HEAD\"], cwd)\n if (head.code !== 0 || !head.stdout.trim()) {\n throw new Error(\n `claude code cloud: could not resolve HEAD in ${cwd} (${head.stderr.trim() || `git rev-parse HEAD exited ${head.code}`})`,\n )\n }\n\n // HEAD must be contained in some origin/* ref — i.e. pushed. An unpushed\n // commit (or a local-only branch) is refused; the vendor can only check\n // out what the remote actually has.\n const contains = await git([\"branch\", \"-r\", \"--contains\", \"HEAD\"], cwd)\n if (contains.code !== 0 || !contains.stdout.trim()) {\n throw new Error(\n `claude code cloud: HEAD in ${cwd} is not reachable from origin — ` +\n \"push the commit before starting a cloud session (AIP-66 §3)\",\n )\n }\n}\n","/**\n * The AIP-44 ACP server for Claude Code cloud sessions (AIP-66). This is\n * the binary the daemon spawns (`bin/claude-code-cloud-acp.mjs` → dist):\n * the vendor owns the machine and the harness, so this server does not run\n * any agent — it relays.\n *\n * - `session/new` validates the cwd as a pushed, clean git checkout\n * (AIP-66 §3) BEFORE any vendor side effect.\n * - first `session/prompt` → `claude --cloud \"<prompt>\"` (start), later\n * ones → `claude -p … --cloud <id>` (send-only).\n * - the turn is then observed via the sessions API: events are mapped\n * with @agentproto/adapter-claude-sdk's stream-json → ACP mappers\n * (the payloads ARE Claude Code stream-json SDK messages — reused, not\n * forked), and ONLY the vendor's own `result` event ends the prompt\n * (AIP-66 §6: never a timer, never silence). Transient read failures\n * (HTTP 5xx, network) are retried with backoff before the prompt fails.\n * - `result` carries `total_cost_usd` + `usage` → an ACP `usage_update`\n * (AIP-66 §7); a result without usage emits none — unmeasured, never\n * zero.\n * - `session/cancel` is unsupported: the vendor exposes no interrupt\n * verb, and AIP-66 §6 says a host without one reports it unsupported.\n */\n\nimport { Readable, Writable } from \"node:stream\"\nimport {\n AgentSideConnection,\n ndJsonStream,\n PROTOCOL_VERSION,\n type Agent,\n type CancelNotification,\n type InitializeRequest,\n type InitializeResponse,\n type NewSessionRequest,\n type NewSessionResponse,\n type PromptRequest,\n type PromptResponse,\n type SetSessionConfigOptionRequest,\n type SetSessionConfigOptionResponse,\n type SetSessionModeRequest,\n type SetSessionModeResponse,\n type SessionNotification,\n type SessionUpdate,\n type StopReason,\n} from \"@agentclientprotocol/sdk\"\nimport { promptText, sdkMessageToUpdates } from \"@agentproto/adapter-claude-sdk\"\nimport {\n defaultCloudCliRunner,\n sendPrompt as defaultSendPrompt,\n startCloudSession as defaultStartCloudSession,\n type StartedCloudSession,\n} from \"./cli.js\"\nimport {\n SessionsApi,\n keychainCredentialSource,\n type CloudEventsPage,\n type CredentialSource,\n} from \"./sessions-api.js\"\nimport { validateRepoSource } from \"./repo-source.js\"\n\n/**\n * The wire shape the cloud events API serves as `event.payload`: a Claude\n * Code stream-json SDK message. Derived from `sdkMessageToUpdates`'s\n * parameter so this package does not need a direct dependency on\n * `@anthropic-ai/claude-agent-sdk` (which would otherwise be a transitive\n * dep of `adapter-claude-sdk` and could break under strict pnpm or leak\n * into the emitted d.ts).\n */\ntype SDKMessage = Parameters<typeof sdkMessageToUpdates>[0]\n\n/** Poll cadence: 2s, backing off to 10s while the turn is still running. */\nexport const POLL_INITIAL_MS = 2_000\nexport const POLL_MAX_MS = 10_000\n\n/**\n * Budget of consecutive transient `listEvents` failures before the turn's\n * observation fails: the first four are retried with the poll backoff, the\n * fifth consecutive one fails the turn. The bound decides only when READING\n * events becomes impossible — a turn still ENDS solely on a vendor `result`\n * event (AIP-66 §6).\n */\nexport const MAX_LIST_EVENTS_FAILURES = 5\n\n/** Node/network error codes a transient fetch failure can surface (walked\n * down the `cause` chain — undici wraps them under \"fetch failed\"). */\nconst NETWORK_ERROR_CODES =\n /^(ECONNABORTED|ECONNREFUSED|ECONNRESET|EHOSTUNREACH|ENETUNREACH|EAI_AGAIN|ENOTFOUND|EPIPE|ETIMEDOUT|UND_ERR)/\n\n/**\n * Worth retrying: an HTTP 5xx from the vendor API, or a network-level\n * failure. 4xx (auth, not-found, bad request) and payload/parse errors are\n * NOT transient — retrying them would just stall the turn.\n */\nexport function isTransientListEventsError(err: unknown): boolean {\n if (!(err instanceof Error)) return false\n if (/\\bHTTP 5\\d\\d\\b/.test(err.message)) return true\n if (/fetch failed|network error|socket hang up/i.test(err.message)) return true\n let cause: unknown = err\n for (let depth = 0; depth < 4 && cause; depth += 1) {\n const code = (cause as { code?: unknown }).code\n if (typeof code === \"string\" && NETWORK_ERROR_CODES.test(code)) return true\n cause = (cause as { cause?: unknown }).cause\n }\n return false\n}\n\n/** Read the ACP prompt's text content blocks. */\nexport { promptText }\n\n/** The observe surface the turn loop needs — satisfied by {@link SessionsApi}. */\nexport interface CloudEventsClient {\n listEvents(\n id: string,\n opts?: { cursor?: string; limit?: number },\n ): Promise<CloudEventsPage>\n}\n\n/** The start/send surface — satisfied by cli.ts's functions. */\nexport interface CloudCliDeps {\n startCloudSession(\n prompt: string,\n opts: { cwd: string },\n ): Promise<StartedCloudSession>\n sendPrompt(\n sessionId: string,\n text: string,\n opts: { cwd: string },\n ): Promise<{ stdout: string }>\n}\n\nexport interface ClaudeCloudAcpDeps {\n /** Events client. Default: real {@link SessionsApi} on the keychain login. */\n api?: CloudEventsClient\n /** Vendor CLI. Default: cli.ts's start/send against the real runner. */\n cli?: CloudCliDeps\n /** Repo-source validator (AIP-66 §3). Default: real git invocations. */\n validateRepo?: (cwd: string) => Promise<void>\n sleep?: (ms: number) => Promise<void>\n pollInitialMs?: number\n pollMaxMs?: number\n}\n\ninterface CloudSessionState {\n readonly id: string\n readonly cwd: string\n /** Vendor session id (`session_…`), set by the first prompt's start. */\n vendorSessionId: string | null\n vendorUrl: string | null\n /** Events page cursor across polls; null until the API hands one back. */\n pollCursor: string | null\n /** Event ids already projected this turn (and previous turns) — the\n * newest-first first page overlaps turns, so dedup is mandatory. Bounded:\n * ids are remembered in projection order (oldest first) and the OLDEST\n * are evicted past {@link SEEN_EVENT_IDS_LIMIT}, so the set cannot grow\n * for the life of the session. */\n readonly seenEventIds: Set<string>\n promptInFlight: boolean\n}\n\n/**\n * Cap on remembered event ids per session. Dedup spans turns (an old\n * `result` must not end a new turn), but the session may live indefinitely —\n * so the set is bounded, evicting in insertion order: those ids were\n * projected on the earliest polls, behind the pagination cursor the API\n * serves forward from.\n */\nexport const SEEN_EVENT_IDS_LIMIT = 500\n\n/** Record a projected event id, evicting the oldest past the cap. */\nfunction rememberSeenEventId(session: CloudSessionState, id: string): void {\n const seen = session.seenEventIds\n seen.add(id)\n while (seen.size > SEEN_EVENT_IDS_LIMIT) {\n const oldest = seen.values().next()\n if (oldest.done) break\n seen.delete(oldest.value)\n }\n}\n\nfunction defaultSleep(ms: number): Promise<void> {\n return new Promise(resolve => {\n const timer = setTimeout(resolve, ms)\n timer.unref?.()\n })\n}\n\nfunction defaultDeps(): Required<\n Pick<ClaudeCloudAcpDeps, \"api\" | \"cli\" | \"validateRepo\">\n> {\n const runner = defaultCloudCliRunner()\n const credentials: CredentialSource = keychainCredentialSource()\n return {\n api: new SessionsApi({ credentials }),\n cli: {\n startCloudSession: (prompt, opts) =>\n defaultStartCloudSession(prompt, {\n cwd: opts.cwd,\n runner,\n env: process.env,\n }),\n sendPrompt: (id, text, opts) =>\n defaultSendPrompt(id, text, {\n cwd: opts.cwd,\n runner,\n env: process.env,\n }),\n },\n validateRepo: (cwd: string) => validateRepoSource(cwd),\n }\n}\n\n/** Map a `result` event's payload to ACP updates. AIP-66 §7: usage is\n * reported only when the vendor's event carries it; absent usage is\n * UNMEASURED — never a fabricated zero. The shared mapper handles the\n * shape; we normalize the two fields it reads defensively (`modelUsage`,\n * `usage`). */\nexport function resultEventUpdates(payload: unknown): SessionUpdate[] {\n const p = (payload ?? {}) as {\n usage?: unknown\n total_cost_usd?: unknown\n modelUsage?: unknown\n }\n const hasUsage = p.usage != null || typeof p.total_cost_usd === \"number\"\n if (!hasUsage) return []\n const normalized = {\n ...p,\n type: \"result\",\n modelUsage: p.modelUsage ?? {},\n usage: p.usage ?? { input_tokens: 0, output_tokens: 0 },\n }\n return sdkMessageToUpdates(normalized as unknown as SDKMessage).filter(\n u => u.sessionUpdate === \"usage_update\",\n )\n}\n\n/** Stop reason from the `result` payload: an error (or any non-success\n * subtype) stops as `refusal` — ACP has no dedicated error stop. */\nexport function resultStopReason(payload: unknown): StopReason {\n const p = (payload ?? {}) as { is_error?: boolean; subtype?: string }\n if (p.is_error === true) return \"refusal\"\n if (p.subtype !== undefined && p.subtype !== \"success\") return \"refusal\"\n return \"end_turn\"\n}\n\nfunction errorResultText(payload: unknown): string | null {\n const p = (payload ?? {}) as { result?: unknown }\n if (typeof p.result === \"string\" && p.result.trim()) return p.result\n return null\n}\n\nexport class ClaudeCloudAcpAgent implements Agent {\n readonly #conn: AgentSideConnection\n readonly #api: CloudEventsClient\n readonly #cli: CloudCliDeps\n readonly #validateRepo: (cwd: string) => Promise<void>\n readonly #sleep: (ms: number) => Promise<void>\n readonly #pollInitialMs: number\n readonly #pollMaxMs: number\n readonly #sessions = new Map<string, CloudSessionState>()\n\n constructor(conn: AgentSideConnection, deps: ClaudeCloudAcpDeps = {}) {\n // Defaults are lazy: the real SessionsApi/keychain/runner only touch\n // the system when a turn actually runs — safe to construct always.\n const defaults = defaultDeps()\n this.#conn = conn\n this.#api = deps.api ?? defaults.api\n this.#cli = deps.cli ?? defaults.cli\n this.#validateRepo = deps.validateRepo ?? defaults.validateRepo\n this.#sleep = deps.sleep ?? defaultSleep\n this.#pollInitialMs = deps.pollInitialMs ?? POLL_INITIAL_MS\n this.#pollMaxMs = deps.pollMaxMs ?? POLL_MAX_MS\n }\n\n async initialize(_params: InitializeRequest): Promise<InitializeResponse> {\n return {\n protocolVersion: PROTOCOL_VERSION,\n agentCapabilities: {\n // Sessions live in the vendor's cloud; re-attach is via the vendor\n // id, not an ACP session/load replay (AIP-66 §5).\n loadSession: false,\n },\n }\n }\n\n async authenticate(): Promise<void> {\n // Auth is the user's claude.ai login, owned by the claude CLI —\n // preflighted per turn (see cli.ts). No ACP handshake.\n }\n\n async newSession(params: NewSessionRequest): Promise<NewSessionResponse> {\n // AIP-66 §4: mcpServers has no meaning for a vendor-owned harness —\n // refuse rather than silently drop (the host-level gate refuses the\n // whole spawn field set; this is the relay's own fail-closed backstop).\n if (params.mcpServers && params.mcpServers.length > 0) {\n throw new Error(\n \"claude code cloud: mcpServers is not supported for managed cloud \" +\n \"agents (AIP-66 §4) — the vendor owns the harness\",\n )\n }\n // AIP-66 §3 — refuse BEFORE any vendor side effect.\n await this.#validateRepo(params.cwd)\n const id = crypto.randomUUID()\n this.#sessions.set(id, {\n id,\n cwd: params.cwd,\n vendorSessionId: null,\n vendorUrl: null,\n pollCursor: null,\n seenEventIds: new Set(),\n promptInFlight: false,\n })\n return { sessionId: id }\n }\n\n async prompt(params: PromptRequest): Promise<PromptResponse> {\n const session = this.#sessions.get(params.sessionId)\n if (!session) throw new Error(`unknown session ${params.sessionId}`)\n if (session.promptInFlight) {\n // session/cancel is unsupported (no vendor interrupt verb), so a\n // second concurrent turn cannot be honoured honestly.\n throw new Error(\n \"claude code cloud: a turn is already in flight — session/cancel is \" +\n \"unsupported (AIP-66 §6)\",\n )\n }\n session.promptInFlight = true\n try {\n const text = promptText(params)\n if (!session.vendorSessionId) {\n const started = await this.#cli.startCloudSession(text, {\n cwd: session.cwd,\n })\n session.vendorSessionId = started.sessionId\n session.vendorUrl = started.url\n // Surface the session URL (AIP-66 security considerations: the user\n // must be able to inspect what the vendor is running).\n await this.#conn.sessionUpdate({\n sessionId: session.id,\n update: {\n sessionUpdate: \"agent_message_chunk\",\n content: {\n type: \"text\",\n text: `[claude-code-cloud] ${started.title ? `${started.title} — ` : \"\"}${started.url}`,\n },\n },\n })\n } else {\n await this.#cli.sendPrompt(session.vendorSessionId, text, {\n cwd: session.cwd,\n })\n }\n return await this.#observeTurn(session)\n } finally {\n session.promptInFlight = false\n }\n }\n\n /** Read events until a NEW `result` event ends the turn (AIP-66 §6). */\n async #observeTurn(session: CloudSessionState): Promise<PromptResponse> {\n const vendorId = session.vendorSessionId\n if (!vendorId) throw new Error(\"claude code cloud: no vendor session\")\n let delay = this.#pollInitialMs\n let failures = 0\n for (;;) {\n let page: CloudEventsPage\n try {\n page = await this.#api.listEvents(\n vendorId,\n session.pollCursor ? { cursor: session.pollCursor } : {},\n )\n } catch (err) {\n // A transient read failure (HTTP 5xx, network) says nothing about the\n // turn — retry with the poll backoff, up to MAX_LIST_EVENTS_FAILURES\n // consecutive failures. Non-transient errors and an exhausted budget\n // fail the prompt; only a vendor `result` ever ENDS the turn.\n if (\n !isTransientListEventsError(err) ||\n failures + 1 >= MAX_LIST_EVENTS_FAILURES\n ) {\n throw err\n }\n failures += 1\n await this.#sleep(delay)\n delay = Math.min(delay * 2, this.#pollMaxMs)\n continue\n }\n failures = 0\n if (page.resume_cursor) session.pollCursor = page.resume_cursor\n const fresh = (page.data ?? [])\n .filter(event => !session.seenEventIds.has(event.event_id))\n .sort((a, b) => {\n if (a.created_at !== b.created_at) {\n return a.created_at < b.created_at ? -1 : 1\n }\n return a.event_id < b.event_id ? -1 : 1\n })\n let stopReason: StopReason | null = null\n for (const event of fresh) {\n rememberSeenEventId(session, event.event_id)\n if (event.event_type === \"result\") {\n if (resultStopReason(event.payload) === \"refusal\") {\n const errText = errorResultText(event.payload)\n if (errText) {\n await this.#send(session.id, {\n sessionUpdate: \"agent_message_chunk\",\n content: { type: \"text\", text: errText },\n })\n }\n }\n for (const update of resultEventUpdates(event.payload)) {\n await this.#send(session.id, update)\n }\n stopReason = resultStopReason(event.payload)\n } else if (event.event_type === \"user\") {\n // Follow-up turns: the vendor echoes the user's own prompt back as\n // a `user` event — the host already rendered that prompt, so it is\n // NEVER replayed as a chunk. Only `tool_result` blocks project\n // (tool_call_update); every other user payload is dropped here.\n for (const update of sdkMessageToUpdates(\n event.payload as unknown as SDKMessage,\n )) {\n if (update.sessionUpdate === \"agent_message_chunk\") continue\n await this.#send(session.id, update)\n }\n } else if (event.event_type === \"assistant\") {\n // Payloads ARE stream-json SDK messages — reuse the claude-sdk\n // adapter's mappers (assistant text → agent_message_chunk,\n // tool_use → tool_call).\n for (const update of sdkMessageToUpdates(\n event.payload as unknown as SDKMessage,\n )) {\n await this.#send(session.id, update)\n }\n }\n // system / env_manager_log / rate_limit_event / … carry no ACP\n // projection; they still consume a seen-id above.\n }\n if (stopReason) return { stopReason }\n await this.#sleep(delay)\n delay = Math.min(delay * 2, this.#pollMaxMs)\n }\n }\n\n async #send(sessionId: string, update: SessionUpdate): Promise<void> {\n await this.#conn.sessionUpdate({ sessionId, update } as SessionNotification)\n }\n\n /** Unsupported: the vendor exposes no interrupt verb (AIP-66 §6). Throwing\n * reports it — the in-flight poll loop is NOT aborted (we cannot stop the\n * cloud turn; lying \"cancelled\" would violate §6's end-on-vendor-event\n * rule). */\n async cancel(_params: CancelNotification): Promise<void> {\n throw new Error(\n \"claude code cloud: session/cancel is unsupported — the vendor \" +\n \"exposes no interrupt verb for cloud sessions (AIP-66 §6)\",\n )\n }\n\n /** No runtime-configurable options (no model menu — the vendor picks the\n * model). Empty set so a host that tries to set one doesn't error. */\n async setSessionConfigOption(\n _params: SetSessionConfigOptionRequest,\n ): Promise<SetSessionConfigOptionResponse> {\n return { configOptions: [] }\n }\n\n /** No agent-specific modes; accept and ignore. */\n async setSessionMode(\n _params: SetSessionModeRequest,\n ): Promise<SetSessionModeResponse> {\n return {}\n }\n}\n\n/** Boot the ACP server over stdio — what bin/claude-code-cloud-acp.mjs runs. */\nexport function runAcpOverStdio(deps: ClaudeCloudAcpDeps = {}): AgentSideConnection {\n const toClient = Writable.toWeb(process.stdout) as WritableStream<Uint8Array>\n const fromClient = Readable.toWeb(\n process.stdin,\n ) as unknown as ReadableStream<Uint8Array>\n const stream = ndJsonStream(toClient, fromClient)\n return new AgentSideConnection(\n conn => new ClaudeCloudAcpAgent(conn, deps),\n stream,\n )\n}\n\n/** Entry point for bin/claude-code-cloud-acp.mjs. */\nexport function main(): void {\n runAcpOverStdio()\n}\n"]}
@@ -0,0 +1,374 @@
1
+ import { AgentCliHandle, AgentCliRuntime } from '@agentproto/driver-agent-cli';
2
+ export { AgentCliHandle, AgentCliRuntime } from '@agentproto/driver-agent-cli';
3
+ import { Agent, AgentSideConnection, InitializeRequest, InitializeResponse, NewSessionRequest, NewSessionResponse, PromptRequest, PromptResponse, CancelNotification, SetSessionConfigOptionRequest, SetSessionConfigOptionResponse, SetSessionModeRequest, SetSessionModeResponse, SessionUpdate, StopReason } from '@agentclientprotocol/sdk';
4
+
5
+ /**
6
+ * The vendor-client surface (AIP-66 Appendix A): start a Claude Code cloud
7
+ * session under a PTY, send follow-ups headlessly, and preflight the
8
+ * claude.ai login. The CLI is the only supported way to CREATE and PROMPT a
9
+ * cloud session — the sessions API (sessions-api.ts) is observe-only.
10
+ *
11
+ * Every child process runs with ANTHROPIC_API_KEY and the Claude Code
12
+ * gateway/redirect toggles deleted from its env (AIP-66 §8): a leftover
13
+ * toggle or API key would make the CLI authenticate a different way and
14
+ * refuse (or worse, re-route) the cloud call. The token the CLI reads from
15
+ * the user's own login is never touched, logged or persisted here.
16
+ *
17
+ * The binary runner is injectable so tests can drive every path — auth
18
+ * preflight, trust prompt, output parsing — from fixtures without a live
19
+ * claude CLI or a real PTY.
20
+ */
21
+ /** Env keys deleted from every claude child this adapter spawns (AIP-66 §8). */
22
+ declare const CLAUDE_CODE_GATEWAY_ENV_UNSET: readonly string[];
23
+ /** Copy `base` with every {@link CLAUDE_CODE_GATEWAY_ENV_UNSET} key deleted. */
24
+ declare function cloudChildEnv(base?: Record<string, string | undefined>): Record<string, string>;
25
+ interface RunResult {
26
+ code: number;
27
+ stdout: string;
28
+ stderr: string;
29
+ }
30
+ interface RunOpts {
31
+ cwd: string;
32
+ env: Record<string, string>;
33
+ timeoutMs?: number;
34
+ /** "ignore" detaches stdin so a non-interactive call can never TTY-block. */
35
+ stdin?: "ignore";
36
+ }
37
+ interface PtyHandle {
38
+ write(data: string): void;
39
+ result: Promise<{
40
+ code: number;
41
+ output: string;
42
+ }>;
43
+ }
44
+ interface PtyRunOpts extends RunOpts {
45
+ onData?: (chunk: string) => void;
46
+ }
47
+ /** What {@link startCloudSession} / {@link sendPrompt} drive. Tests inject a
48
+ * fake; production uses {@link defaultCloudCliRunner}. */
49
+ interface CloudCliRunner {
50
+ run(cmd: string, args: string[], opts: RunOpts): Promise<RunResult>;
51
+ runPty(cmd: string, args: string[], opts: PtyRunOpts): PtyHandle;
52
+ }
53
+ /** Real runner: child_process for headless calls, node-pty (optional dep)
54
+ * for the TTY-required `claude --cloud` start. */
55
+ declare function defaultCloudCliRunner(): CloudCliRunner;
56
+ interface AuthStatus {
57
+ loggedIn: boolean;
58
+ authMethod?: string;
59
+ }
60
+ /** Parse `claude auth status` JSON output. */
61
+ declare function parseAuthStatus(stdout: string): AuthStatus;
62
+ /**
63
+ * Refuse the spawn before any side effect when the claude CLI is missing,
64
+ * not logged in, or authenticated by API key — cloud sessions require a
65
+ * claude.ai sign-in (verified live: an ANTHROPIC_API_KEY env makes the CLI
66
+ * refuse with "Cloud sessions need a claude.ai sign-in").
67
+ */
68
+ declare function preflightAuth(runner: CloudCliRunner, opts: {
69
+ cwd: string;
70
+ env: Record<string, string>;
71
+ }): Promise<AuthStatus>;
72
+ interface StartedCloudSession {
73
+ /** CLI-spelled id (`session_<id>`), ready for `--cloud` / `--teleport`. */
74
+ sessionId: string;
75
+ url: string;
76
+ title?: string;
77
+ }
78
+ /** Parse the `claude --cloud` start transcript: the id from the "Resume
79
+ * with:" line (falling back to the View URL's path), the URL, and the
80
+ * session title. Returns null when no session id can be found. */
81
+ declare function parseCloudStartOutput(output: string): StartedCloudSession | null;
82
+ interface StartCloudSessionOpts {
83
+ runner?: CloudCliRunner;
84
+ env?: Record<string, string | undefined>;
85
+ cwd: string;
86
+ /** Hard cap on the interactive start (PTY) — default 120s. */
87
+ timeoutMs?: number;
88
+ /** Skip the auth preflight (tests only; production always preflights). */
89
+ skipPreflight?: boolean;
90
+ }
91
+ /**
92
+ * Start a cloud session: `claude --cloud "<prompt>"` under a PTY (the CLI
93
+ * requires a TTY here), answering the first-run folder-trust prompt, then
94
+ * parse the printed session id / URL and exit. The vendor runs the first
95
+ * turn; observe it via the sessions API.
96
+ */
97
+ declare function startCloudSession(prompt: string, opts: StartCloudSessionOpts): Promise<StartedCloudSession>;
98
+ interface SendPromptOpts {
99
+ runner?: CloudCliRunner;
100
+ env?: Record<string, string | undefined>;
101
+ cwd: string;
102
+ timeoutMs?: number;
103
+ skipPreflight?: boolean;
104
+ }
105
+ /**
106
+ * Send a follow-up turn: `claude -p "<text>" --cloud <session id>` with
107
+ * stdin detached (no TTY). Send-only by design — the CLI prints "Sent to
108
+ * cloud session." and never the reply; the reply is observed via the
109
+ * sessions API. Accepts `session_`/`cse_` ids.
110
+ */
111
+ declare function sendPrompt(sessionId: string, text: string, opts: SendPromptOpts): Promise<{
112
+ stdout: string;
113
+ }>;
114
+
115
+ /**
116
+ * Thin client for the undocumented Claude Code cloud sessions API
117
+ * (AIP-66 Appendix A). Base https://api.anthropic.com; requests carry
118
+ * `Authorization: Bearer <claude.ai OAuth access token>`,
119
+ * `anthropic-version: 2023-06-01` and `x-organization-uuid`.
120
+ *
121
+ * The credential is the user's claude.ai login, owned by the claude CLI
122
+ * (AIP-66 §8): this module never logs it, never persists it, and never
123
+ * writes it anywhere — it lives only in request headers for the lifetime
124
+ * of a call. On 401 the credential source is re-read exactly once (the
125
+ * token may have been refreshed since process start), then the call fails
126
+ * with a message that tells the user how to log in.
127
+ *
128
+ * All network access goes through an injectable `fetch` so tests can drive
129
+ * the client from fixtures — no live Anthropic call is ever made from here.
130
+ */
131
+ /** A claude.ai OAuth credential. `accessToken` is the bearer the API wants;
132
+ * `orgUuid` is the `x-organization-uuid` header (from `~/.claude.json`'s
133
+ * `.oauthAccount.organizationUuid`). NEVER logged or persisted. */
134
+ interface CloudCredential {
135
+ accessToken: string;
136
+ orgUuid?: string;
137
+ }
138
+ /** Where the host reads the vendor login from (AIP-66 §8). Implementations
139
+ * must not cache a token across an explicit invalidate() — a 401 re-read
140
+ * has to be able to observe a refreshed login. */
141
+ interface CredentialSource {
142
+ get(): Promise<CloudCredential>;
143
+ }
144
+ /** macOS keychain credential: `security find-generic-password -s "Claude
145
+ * Code-credentials" -w` returns JSON whose `.claudeAiOauth.accessToken` is
146
+ * the bearer; the org uuid comes from `~/.claude.json`. `execFile` and the
147
+ * file reader are injectable for tests; the token never leaves this module
148
+ * except as a request header. */
149
+ declare function keychainCredentialSource(deps?: {
150
+ execFileImpl?: (cmd: string, args: string[]) => Promise<{
151
+ stdout: string;
152
+ }>;
153
+ readFileSyncImpl?: (path: string) => Promise<string>;
154
+ homedir?: () => string;
155
+ }): CredentialSource;
156
+ /** Env credential for hosts/tests that inject the login themselves:
157
+ * CLAUDE_CLOUD_OAUTH_TOKEN (+ optional CLAUDE_CLOUD_ORG_UUID). */
158
+ declare function envCredentialSource(env?: Record<string, string | undefined>): CredentialSource;
159
+ /** One entry of GET /v1/code/sessions/{id}/events (newest first). The
160
+ * `payload` is the Claude Code stream-json SDK message for `user` /
161
+ * `assistant` / `result` events. */
162
+ interface CloudSessionEvent {
163
+ created_at: string;
164
+ event_id: string;
165
+ event_type: string;
166
+ payload: unknown;
167
+ }
168
+ interface CloudEventsPage {
169
+ data: CloudSessionEvent[];
170
+ /** Pass back as `cursor` on the next poll to resume after this page. */
171
+ resume_cursor?: string;
172
+ }
173
+ /** GET /v1/code/sessions/{id} — wrapped in `response_shape`. */
174
+ interface CloudSessionState {
175
+ id: string;
176
+ title: string;
177
+ status: string;
178
+ status_bucket?: string;
179
+ worker_status?: string;
180
+ connection_status?: string;
181
+ last_event_at?: string;
182
+ session_url?: string;
183
+ post_turn_summary?: string;
184
+ [key: string]: unknown;
185
+ }
186
+ interface CloudGetSessionResponse {
187
+ response_shape: CloudSessionState;
188
+ [key: string]: unknown;
189
+ }
190
+ /** One entry of GET /v1/code/sessions — id is spelled `cse_<suffix>`, the
191
+ * same suffix the CLI's `session_<suffix>` carries. */
192
+ interface CloudSessionSummary {
193
+ id: string;
194
+ title: string;
195
+ status: "active" | "archived" | string;
196
+ environment_kind?: "anthropic_cloud" | "bridge" | string;
197
+ config?: {
198
+ model?: string;
199
+ origin?: string;
200
+ [key: string]: unknown;
201
+ };
202
+ created_at?: string;
203
+ [key: string]: unknown;
204
+ }
205
+ interface CloudListSessionsResponse {
206
+ data: CloudSessionSummary[];
207
+ resume_token?: string;
208
+ }
209
+ /**
210
+ * Normalize a session id to the API's own `cse_<suffix>` spelling. Accepts
211
+ * `session_<suffix>` (what the CLI prints and `--cloud` takes) and
212
+ * `cse_<suffix>` (what the API listing returns); rejects anything else so a
213
+ * malformed id can never be interpolated into a request path.
214
+ */
215
+ declare function normalizeSessionId(id: string): string;
216
+ /** Normalize to the CLI's own `session_<suffix>` spelling (for `--cloud`,
217
+ * `--teleport`). Same acceptance set as {@link normalizeSessionId}. */
218
+ declare function toCliSessionId(id: string): string;
219
+ interface SessionsApiOptions {
220
+ /** Credential source; re-read once on a 401, then the call fails. */
221
+ credentials: CredentialSource;
222
+ /** Injectable fetch — tests pass a fixture router; default is globalThis.fetch. */
223
+ fetchImpl?: typeof fetch;
224
+ /** Override for proxies/mirrors; default https://api.anthropic.com. */
225
+ baseUrl?: string;
226
+ }
227
+ declare class SessionsApi {
228
+ #private;
229
+ constructor(options: SessionsApiOptions);
230
+ /** GET /v1/code/sessions/{id} */
231
+ getSession(id: string): Promise<CloudGetSessionResponse>;
232
+ /**
233
+ * GET /v1/code/sessions/{id}/events — newest first. Pass the previous
234
+ * page's `resume_cursor` as `cursor` to resume after it.
235
+ */
236
+ listEvents(id: string, opts?: {
237
+ cursor?: string;
238
+ limit?: number;
239
+ }): Promise<CloudEventsPage>;
240
+ /** GET /v1/code/sessions?limit=N */
241
+ listSessions(opts?: {
242
+ limit?: number;
243
+ }): Promise<CloudListSessionsResponse>;
244
+ }
245
+
246
+ /**
247
+ * The AIP-44 ACP server for Claude Code cloud sessions (AIP-66). This is
248
+ * the binary the daemon spawns (`bin/claude-code-cloud-acp.mjs` → dist):
249
+ * the vendor owns the machine and the harness, so this server does not run
250
+ * any agent — it relays.
251
+ *
252
+ * - `session/new` validates the cwd as a pushed, clean git checkout
253
+ * (AIP-66 §3) BEFORE any vendor side effect.
254
+ * - first `session/prompt` → `claude --cloud "<prompt>"` (start), later
255
+ * ones → `claude -p … --cloud <id>` (send-only).
256
+ * - the turn is then observed via the sessions API: events are mapped
257
+ * with @agentproto/adapter-claude-sdk's stream-json → ACP mappers
258
+ * (the payloads ARE Claude Code stream-json SDK messages — reused, not
259
+ * forked), and ONLY the vendor's own `result` event ends the prompt
260
+ * (AIP-66 §6: never a timer, never silence). Transient read failures
261
+ * (HTTP 5xx, network) are retried with backoff before the prompt fails.
262
+ * - `result` carries `total_cost_usd` + `usage` → an ACP `usage_update`
263
+ * (AIP-66 §7); a result without usage emits none — unmeasured, never
264
+ * zero.
265
+ * - `session/cancel` is unsupported: the vendor exposes no interrupt
266
+ * verb, and AIP-66 §6 says a host without one reports it unsupported.
267
+ */
268
+
269
+ /** Poll cadence: 2s, backing off to 10s while the turn is still running. */
270
+ declare const POLL_INITIAL_MS = 2000;
271
+ declare const POLL_MAX_MS = 10000;
272
+ /** The observe surface the turn loop needs — satisfied by {@link SessionsApi}. */
273
+ interface CloudEventsClient {
274
+ listEvents(id: string, opts?: {
275
+ cursor?: string;
276
+ limit?: number;
277
+ }): Promise<CloudEventsPage>;
278
+ }
279
+ /** The start/send surface — satisfied by cli.ts's functions. */
280
+ interface CloudCliDeps {
281
+ startCloudSession(prompt: string, opts: {
282
+ cwd: string;
283
+ }): Promise<StartedCloudSession>;
284
+ sendPrompt(sessionId: string, text: string, opts: {
285
+ cwd: string;
286
+ }): Promise<{
287
+ stdout: string;
288
+ }>;
289
+ }
290
+ interface ClaudeCloudAcpDeps {
291
+ /** Events client. Default: real {@link SessionsApi} on the keychain login. */
292
+ api?: CloudEventsClient;
293
+ /** Vendor CLI. Default: cli.ts's start/send against the real runner. */
294
+ cli?: CloudCliDeps;
295
+ /** Repo-source validator (AIP-66 §3). Default: real git invocations. */
296
+ validateRepo?: (cwd: string) => Promise<void>;
297
+ sleep?: (ms: number) => Promise<void>;
298
+ pollInitialMs?: number;
299
+ pollMaxMs?: number;
300
+ }
301
+ /** Map a `result` event's payload to ACP updates. AIP-66 §7: usage is
302
+ * reported only when the vendor's event carries it; absent usage is
303
+ * UNMEASURED — never a fabricated zero. The shared mapper handles the
304
+ * shape; we normalize the two fields it reads defensively (`modelUsage`,
305
+ * `usage`). */
306
+ declare function resultEventUpdates(payload: unknown): SessionUpdate[];
307
+ /** Stop reason from the `result` payload: an error (or any non-success
308
+ * subtype) stops as `refusal` — ACP has no dedicated error stop. */
309
+ declare function resultStopReason(payload: unknown): StopReason;
310
+ declare class ClaudeCloudAcpAgent implements Agent {
311
+ #private;
312
+ constructor(conn: AgentSideConnection, deps?: ClaudeCloudAcpDeps);
313
+ initialize(_params: InitializeRequest): Promise<InitializeResponse>;
314
+ authenticate(): Promise<void>;
315
+ newSession(params: NewSessionRequest): Promise<NewSessionResponse>;
316
+ prompt(params: PromptRequest): Promise<PromptResponse>;
317
+ /** Unsupported: the vendor exposes no interrupt verb (AIP-66 §6). Throwing
318
+ * reports it — the in-flight poll loop is NOT aborted (we cannot stop the
319
+ * cloud turn; lying "cancelled" would violate §6's end-on-vendor-event
320
+ * rule). */
321
+ cancel(_params: CancelNotification): Promise<void>;
322
+ /** No runtime-configurable options (no model menu — the vendor picks the
323
+ * model). Empty set so a host that tries to set one doesn't error. */
324
+ setSessionConfigOption(_params: SetSessionConfigOptionRequest): Promise<SetSessionConfigOptionResponse>;
325
+ /** No agent-specific modes; accept and ignore. */
326
+ setSessionMode(_params: SetSessionModeRequest): Promise<SetSessionModeResponse>;
327
+ }
328
+ /** Boot the ACP server over stdio — what bin/claude-code-cloud-acp.mjs runs. */
329
+ declare function runAcpOverStdio(deps?: ClaudeCloudAcpDeps): AgentSideConnection;
330
+
331
+ /**
332
+ * AIP-66 §3 (repo source): a managed cloud agent runs on a git remote and
333
+ * ref — never on an uploaded working tree. The host MUST refuse the spawn
334
+ * when `cwd` is not a git checkout with a remote, when the working tree is
335
+ * dirty, or when HEAD is not reachable from the remote.
336
+ *
337
+ * Pure git-invocation logic with an injectable runner so tests can drive
338
+ * every refusal from fixtures (no real repo required).
339
+ */
340
+ /** Runs `git <args…>` in `cwd`; resolves with the exit code + streams. */
341
+ type GitRunner = (args: string[], cwd: string) => Promise<{
342
+ code: number;
343
+ stdout: string;
344
+ stderr: string;
345
+ }>;
346
+ declare const defaultGitRunner: GitRunner;
347
+ /**
348
+ * Refuse (throw) unless `cwd` is a clean git checkout whose HEAD is
349
+ * contained in some `origin/*` ref. Each error names the failed condition —
350
+ * the ACP server surfaces it as the `session/new` failure.
351
+ */
352
+ declare function validateRepoSource(cwd: string, git?: GitRunner): Promise<void>;
353
+
354
+ /**
355
+ * @agentproto/adapter-claude-code-cloud — AIP-66 managed cloud agent adapter
356
+ * for Anthropic Claude Code cloud sessions.
357
+ *
358
+ * Unlike `@agentproto/adapter-claude-code` (local harness, host machine),
359
+ * this adapter relays a session the VENDOR hosts end to end: the vendor
360
+ * boots the machine, runs Claude Code in it, and exposes the session
361
+ * through `claude --cloud` / `claude -p --cloud` plus the undocumented
362
+ * Claude Code sessions API. No agentproto daemon runs inside; the host
363
+ * controls neither the machine nor the harness — so this manifest is
364
+ * deliberately smaller and refuses the spawn fields that could never take
365
+ * effect (AIP-66 §4).
366
+ *
367
+ * import { claudeCodeCloud } from "@agentproto/adapter-claude-code-cloud"
368
+ */
369
+
370
+ declare const CLOUD_REFUSED_SPAWN_FIELDS: readonly ["sandbox", "worktree", "commandSandbox", "mcpServers", "daemonMount", "bundles", "browser", "appServe", "inference"];
371
+ declare const claudeCodeCloud: AgentCliHandle;
372
+ declare function claudeCodeCloudRuntime(): AgentCliRuntime;
373
+
374
+ export { type AuthStatus, CLAUDE_CODE_GATEWAY_ENV_UNSET, CLOUD_REFUSED_SPAWN_FIELDS, ClaudeCloudAcpAgent, type ClaudeCloudAcpDeps, type CloudCliDeps, type CloudCliRunner, type CloudCredential, type CloudEventsClient, type CloudEventsPage, type CloudGetSessionResponse, type CloudSessionEvent, type CloudSessionState, type CloudSessionSummary, type CredentialSource, type GitRunner, POLL_INITIAL_MS, POLL_MAX_MS, type RunOpts, type RunResult, SessionsApi, type SessionsApiOptions, type StartedCloudSession, claudeCodeCloud, claudeCodeCloudRuntime, cloudChildEnv, defaultCloudCliRunner, defaultGitRunner, envCredentialSource, keychainCredentialSource, normalizeSessionId, parseAuthStatus, parseCloudStartOutput, preflightAuth, resultEventUpdates, resultStopReason, runAcpOverStdio, sendPrompt, startCloudSession, toCliSessionId, validateRepoSource };