@codeam/shared 2.60.12 → 2.60.14

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.
package/dist/index.d.mts CHANGED
@@ -131,7 +131,7 @@ declare const UNKNOWN_MODEL_PRICING: ModelPricing;
131
131
  declare function getPricing(model: string): ModelPricing;
132
132
  declare function getContextWindow(model: string | null): number;
133
133
 
134
- type AgentId = 'claude' | 'codex' | 'copilot' | 'coderabbit' | 'cursor' | 'aider' | 'gemini';
134
+ type AgentId = 'claude' | 'codex' | 'copilot' | 'coderabbit' | 'cursor' | 'aider' | 'gemini' | 'kimi';
135
135
  type AgentAuthKind = 'oauth_token' | 'api_key' | 'setup_token';
136
136
  /**
137
137
  * The agent kinds Headroom (the token-compression proxy) can actually
@@ -249,7 +249,7 @@ declare const HOUSE_AGENT_SUBTITLE = "Included \u2014 no setup";
249
249
  * endpoints and the mobile/web surfaces speak. The internal `AgentId`
250
250
  * (`'claude' | 'codex' | …`) is what the runtimes / provisioning key on.
251
251
  */
252
- type LinkedAgentId = 'claude_code' | 'codex' | 'cursor' | 'aider' | 'coderabbit' | 'gemini' | typeof HOUSE_AGENT_ID;
252
+ type LinkedAgentId = 'claude_code' | 'codex' | 'cursor' | 'aider' | 'coderabbit' | 'gemini' | 'kimi' | typeof HOUSE_AGENT_ID;
253
253
  declare const LINKED_AGENT_IDS: readonly LinkedAgentId[];
254
254
  declare function isLinkedAgentId(value: string): value is LinkedAgentId;
255
255
  /**
package/dist/index.d.ts CHANGED
@@ -131,7 +131,7 @@ declare const UNKNOWN_MODEL_PRICING: ModelPricing;
131
131
  declare function getPricing(model: string): ModelPricing;
132
132
  declare function getContextWindow(model: string | null): number;
133
133
 
134
- type AgentId = 'claude' | 'codex' | 'copilot' | 'coderabbit' | 'cursor' | 'aider' | 'gemini';
134
+ type AgentId = 'claude' | 'codex' | 'copilot' | 'coderabbit' | 'cursor' | 'aider' | 'gemini' | 'kimi';
135
135
  type AgentAuthKind = 'oauth_token' | 'api_key' | 'setup_token';
136
136
  /**
137
137
  * The agent kinds Headroom (the token-compression proxy) can actually
@@ -249,7 +249,7 @@ declare const HOUSE_AGENT_SUBTITLE = "Included \u2014 no setup";
249
249
  * endpoints and the mobile/web surfaces speak. The internal `AgentId`
250
250
  * (`'claude' | 'codex' | …`) is what the runtimes / provisioning key on.
251
251
  */
252
- type LinkedAgentId = 'claude_code' | 'codex' | 'cursor' | 'aider' | 'coderabbit' | 'gemini' | typeof HOUSE_AGENT_ID;
252
+ type LinkedAgentId = 'claude_code' | 'codex' | 'cursor' | 'aider' | 'coderabbit' | 'gemini' | 'kimi' | typeof HOUSE_AGENT_ID;
253
253
  declare const LINKED_AGENT_IDS: readonly LinkedAgentId[];
254
254
  declare function isLinkedAgentId(value: string): value is LinkedAgentId;
255
255
  /**
package/dist/index.js CHANGED
@@ -393,6 +393,23 @@ var AGENT_REGISTRY = {
393
393
  headroomWrappable: false,
394
394
  // Native ACP server: `gemini --skip-trust --acp`.
395
395
  acp: true
396
+ },
397
+ kimi: {
398
+ id: "kimi",
399
+ displayName: "Kimi Code",
400
+ binaryName: "kimi",
401
+ enabled: true,
402
+ // API key (KIMI_API_KEY, + optional KIMI_BASE_URL) is the shipping auth —
403
+ // fully documented, no reverse-engineering. OAuth `/login` (login-state at
404
+ // ~/.kimi-code/credentials/<name>.json, base https://api.kimi.com/coding/)
405
+ // is declared so it can land later without a wire change, but capturing
406
+ // that blob server-side is a separate reverse-engineering spike (phase 2).
407
+ supportedAuthKinds: ["api_key", "oauth_token"],
408
+ preferredAuthKind: "api_key",
409
+ // Moonshot's `kimi` is not listed by `headroom wrap --help` — runs native.
410
+ headroomWrappable: false,
411
+ // Native ACP server: `kimi acp` (stdio JSON-RPC, answers `initialize`).
412
+ acp: true
396
413
  }
397
414
  };
398
415
  function getEnabledAgents() {
@@ -420,6 +437,7 @@ var LINKED_AGENT_IDS = [
420
437
  "aider",
421
438
  "coderabbit",
422
439
  "gemini",
440
+ "kimi",
423
441
  HOUSE_AGENT_ID
424
442
  ];
425
443
  function isLinkedAgentId(value) {
@@ -437,6 +455,7 @@ var PUBLIC_TO_INTERNAL = {
437
455
  aider: "aider",
438
456
  coderabbit: "coderabbit",
439
457
  gemini: "gemini",
458
+ kimi: "kimi",
440
459
  // The house agent runs Claude Code under the hood (pointed at the
441
460
  // MiniMax proxy). Its internal runtime is therefore `claude`.
442
461
  [HOUSE_AGENT_ID]: "claude"
@@ -447,7 +466,8 @@ var INTERNAL_TO_PUBLIC = {
447
466
  cursor: "cursor",
448
467
  aider: "aider",
449
468
  coderabbit: "coderabbit",
450
- gemini: "gemini"
469
+ gemini: "gemini",
470
+ kimi: "kimi"
451
471
  };
452
472
  function isPublicToInternalKey(v) {
453
473
  return Object.prototype.hasOwnProperty.call(PUBLIC_TO_INTERNAL, v);
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/protocol/constants.ts","../src/protocol/renderToLines.ts","../src/protocol/remote-command.ts","../src/models/pricing.ts","../src/agents/registry.ts","../src/agents/identity.ts","../src/api-url.ts","../src/headroom/manifest.ts","../src/types/events.ts","../src/preview-prompts.ts"],"sourcesContent":["export * from './protocol/chrome-types';\nexport * from './protocol/constants';\nexport * from './protocol/renderToLines';\nexport * from './protocol/remote-command';\nexport * from './models/pricing';\nexport * from './agents';\nexport * from './types/file-change';\nexport * from './types/streaming';\nexport * from './api-url';\nexport * from './types/preview';\nexport * from './types/beads';\nexport * from './types/headroom';\nexport * from './headroom/manifest';\nexport * from './types/events';\nexport * from './preview-prompts';\n","/**\n * Shared wire / lifecycle constants. The values here are bundled\n * into the CLI + VS Code extension at build time via tsup / esbuild\n * and mirrored in `apps/jetbrains-plugin/.../protocol/Constants.kt`\n * since Kotlin can't import an npm package.\n *\n * If you change one of these values, also update the Kotlin mirror.\n */\n\n/**\n * Discriminated chunk-protocol version sent as the\n * `X-Codeam-Protocol-Version` header on every authed request. The\n * backend uses this to opt into legacy translations or to reject\n * with 426 when the client is too far behind. Bumped in lockstep\n * with chunk-shape changes (e.g. when the `chrome_steps` chunk\n * type is added).\n */\nexport const PROTOCOL_VERSION = '2.0.0' as const;\n\n/**\n * The VS Code AgentOutputMonitor's loopback HTTP server bound to\n * 127.0.0.1 on this port — the observer JS in the IDE renderer\n * uses it to round-trip captured chat content back into the\n * extension host. The port is intentionally fixed (rather than\n * `listen(0)`) so the observer script can be a static constant\n * rather than dynamically rewriting itself per session.\n *\n * Multi-window collision is solved by listen(0) per-window in the\n * monitor (see #103); this default is still the documented\n * starting port for tooling that needs to probe whether a CodeAgent\n * Mobile session is active locally.\n */\nexport const OBSERVER_BRIDGE_PORT = 47832;\n\n/**\n * Default plugin → backend heartbeat interval. User-configurable\n * via `codeagent-mobile.heartbeatIntervalMs` on VS Code and\n * `heartbeatIntervalMs` in SettingsService.kt's @State on JetBrains.\n * Mirrors the value the apps/api side uses to flip the paired\n * session to offline.\n */\nexport const HEARTBEAT_INTERVAL_MS_DEFAULT = 30_000;\n\n/**\n * SSE + polling reconnect cap. Vercel's serverless functions close\n * SSE connections after ~25 s by default; the client uses 35 s as\n * its overall socket timeout to leave a beat for graceful close.\n */\nexport const SSE_SOCKET_TIMEOUT_MS = 35_000;\n","/**\n * Render raw PTY bytes into an array of screen lines using a simplified\n * virtual terminal. Handles cursor movements (A/B/C/D/G/H), erase (J/K),\n * alternate-screen (?1049h), carriage return, and LF.\n *\n * This is the authoritative implementation used by both codeam-cli (PTY\n * output) and the VS Code extension (shell-integration output) so that\n * the mobile/web client sees identical chunks regardless of surface.\n */\nexport function renderToLines(raw: string): string[] {\n const screen: string[] = [''];\n let row = 0;\n let col = 0;\n\n function ensureRow(): void {\n while (screen.length <= row) screen.push('');\n }\n\n function writeChar(ch: string): void {\n ensureRow();\n if (col < screen[row].length) {\n screen[row] = screen[row].slice(0, col) + ch + screen[row].slice(col + 1);\n } else {\n while (screen[row].length < col) screen[row] += ' ';\n screen[row] += ch;\n }\n col++;\n }\n\n let i = 0;\n while (i < raw.length) {\n const ch = raw[i];\n\n if (ch === '\\x1B') {\n i++;\n if (i >= raw.length) break;\n\n if (raw[i] === '[') {\n i++;\n let param = '';\n while (i < raw.length && !/[@-~]/.test(raw[i])) param += raw[i++];\n const cmd = raw[i] ?? '';\n const n = parseInt(param) || 1;\n\n if (cmd === 'A') { row = Math.max(0, row - n); }\n else if (cmd === 'B') { row += n; ensureRow(); }\n else if (cmd === 'C') { col += n; }\n else if (cmd === 'D') { col = Math.max(0, col - n); }\n else if (cmd === 'G') { col = Math.max(0, n - 1); }\n else if (cmd === 'H' || cmd === 'f') {\n const p = param.split(';');\n row = Math.max(0, (parseInt(p[0] ?? '1') || 1) - 1);\n col = Math.max(0, (parseInt(p[1] ?? '1') || 1) - 1);\n ensureRow();\n } else if (cmd === 'J') {\n if (param === '2' || param === '3') {\n screen.length = 1; screen[0] = ''; row = 0; col = 0;\n } else if (param === '1') {\n for (let r = 0; r < row; r++) screen[r] = '';\n screen[row] = ' '.repeat(col) + screen[row].slice(col);\n } else {\n screen[row] = screen[row].slice(0, col);\n screen.splice(row + 1);\n }\n } else if (cmd === 'K') {\n ensureRow();\n if (param === '' || param === '0') screen[row] = screen[row].slice(0, col);\n else if (param === '1') screen[row] = ' '.repeat(col) + screen[row].slice(col);\n else if (param === '2') screen[row] = '';\n } else if (cmd === 'h' && (param === '?1049' || param === '?47')) {\n screen.length = 1; screen[0] = ''; row = 0; col = 0;\n } else if (cmd === 'l' && (param === '?1049' || param === '?47')) {\n screen.length = 1; screen[0] = ''; row = 0; col = 0;\n }\n } else if (raw[i] === ']') {\n i++;\n while (i < raw.length) {\n if (raw[i] === '\\x07') break;\n if (raw[i] === '\\x1B' && i + 1 < raw.length && raw[i + 1] === '\\\\') { i++; break; }\n i++;\n }\n }\n } else if (ch === '\\r') {\n if (i + 1 < raw.length && raw[i + 1] === '\\n') {\n row++; col = 0; ensureRow(); i++;\n } else {\n col = 0;\n }\n } else if (ch === '\\n') {\n row++; col = 0; ensureRow();\n } else if (ch >= ' ' || ch === '\\t') {\n writeChar(ch);\n }\n\n i++;\n }\n\n return screen;\n}\n","import { z } from 'zod';\n\n/**\n * The command envelope clients receive from the backend relay — both from\n * the `commands` SSE frames on `/api/commands/pending/stream` and from the\n * `GET /api/commands/pending` polling fallback. One schema, shared, so the\n * VS Code extension (and eventually the CLI) stop blind-casting\n * `Record<string, unknown>` into this shape.\n */\nexport interface RemoteCommand {\n id: string;\n sessionId: string;\n pluginId: string;\n type: string;\n payload: Record<string, unknown>;\n status: string;\n createdAt: number;\n}\n\nconst remoteCommandSchema = z.object({\n id: z.string(),\n sessionId: z.string(),\n pluginId: z.string(),\n type: z.string(),\n // The backend may omit `payload` (or send null) for payload-less commands;\n // clients have always normalized that to `{}` — keep that behavior here.\n payload: z.record(z.string(), z.unknown()).nullish(),\n status: z.string(),\n createdAt: z.number(),\n});\n\n/**\n * Validate a raw (already JSON-parsed) value into a `RemoteCommand`.\n * Returns `null` — never throws — on a malformed envelope so callers can\n * log-and-skip the single bad command without dropping the whole batch.\n */\nexport function toRemoteCommand(raw: unknown): RemoteCommand | null {\n const parsed = remoteCommandSchema.safeParse(raw);\n if (!parsed.success) return null;\n const { payload, ...rest } = parsed.data;\n return { ...rest, payload: payload ?? {} };\n}\n","export interface ModelPricing {\n input: number;\n output: number;\n cacheRead: number;\n cacheWrite: number;\n}\n\nexport const MODEL_PRICING: Record<string, ModelPricing> = {\n // ── Anthropic / Claude ────────────────────────────────────\n // The 4.x rows below cover the model ids actually emitted by the CLI\n // (apps/cli/src/agents/claude/runtime.ts listModels) and the JetBrains\n // fallback catalog (RemoteCommandRouter.kt). Prices are copied from the\n // same-family base rows (claude-opus-4 / claude-sonnet-4 /\n // claude-3-5-haiku) until distinct published rates land.\n 'claude-opus-4-7': { input: 15, output: 75, cacheRead: 1.50, cacheWrite: 18.75 },\n 'claude-opus-4-6': { input: 15, output: 75, cacheRead: 1.50, cacheWrite: 18.75 },\n 'claude-sonnet-4-6': { input: 3, output: 15, cacheRead: 0.30, cacheWrite: 3.75 },\n // Haiku-tier prices copied from claude-3-5-haiku (closest same-tier\n // sibling in this table) — previously this id matched NO row and was\n // silently billed at sonnet rates via the unknown-model fallback.\n 'claude-haiku-4-5': { input: 0.80, output: 4, cacheRead: 0.08, cacheWrite: 1 },\n 'claude-sonnet-4': { input: 3, output: 15, cacheRead: 0.30, cacheWrite: 3.75 },\n 'claude-opus-4': { input: 15, output: 75, cacheRead: 1.50, cacheWrite: 18.75 },\n 'claude-3-5-sonnet': { input: 3, output: 15, cacheRead: 0.30, cacheWrite: 3.75 },\n 'claude-3-5-haiku': { input: 0.80, output: 4, cacheRead: 0.08, cacheWrite: 1 },\n 'claude-3-haiku': { input: 0.25, output: 1.25, cacheRead: 0.03, cacheWrite: 0.30 },\n\n // ── Codex / OpenAI ────────────────────────────────────────\n // GPT-5.x rows are derived from OpenAI's published GPT-5 family rates\n // (standard tier: $1.25/1M in, $10/1M out, cached input at ~10% of input;\n // mini tier: $0.25/1M in, $2/1M out). OpenAI has no separate cache-WRITE\n // premium, so cacheWrite mirrors the input rate. Replace with the exact\n // per-version numbers from developers.openai.com/pricing when published —\n // these were the ZERO placeholders that rendered Codex sessions as $0.\n 'gpt-5.5': { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 1.25 },\n 'gpt-5.4': { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 1.25 },\n 'gpt-5.4-mini': { input: 0.25, output: 2, cacheRead: 0.025, cacheWrite: 0.25 },\n 'gpt-5.3-codex': { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 1.25 },\n 'gpt-5.2': { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 1.25 },\n 'codex-auto-review': { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 1.25 },\n};\n\nexport const MODEL_CONTEXT_WINDOW: Record<string, number> = {\n // ── Anthropic / Claude ────────────────────────────────────\n 'claude-opus-4-7': 1_000_000,\n 'claude-opus-4-6': 1_000_000,\n 'claude-sonnet-4-6': 1_000_000,\n 'claude-haiku-4-5': 200_000,\n 'claude-opus-4': 1_000_000,\n 'claude-sonnet-4': 1_000_000,\n 'claude-3-5-sonnet': 200_000,\n 'claude-3-5-haiku': 200_000,\n 'claude-3-haiku': 200_000,\n\n // ── Codex / OpenAI ────────────────────────────────────────\n 'gpt-5.5': 272_000,\n 'gpt-5.4': 272_000,\n 'gpt-5.4-mini': 272_000,\n 'gpt-5.3-codex': 272_000,\n 'gpt-5.2': 272_000,\n 'codex-auto-review': 272_000,\n};\n\nconst DEFAULT_CONTEXT_WINDOW = 200_000;\n\n/**\n * Longest-prefix lookup. The tables key by model-family prefix; a model id\n * like `claude-opus-4-7` must resolve to its own row, not be shadowed by the\n * shorter `claude-opus-4` — so the match is by prefix LENGTH, never by the\n * table's insertion order.\n */\nfunction longestPrefixMatch<T>(table: Record<string, T>, model: string): T | undefined {\n let best: T | undefined;\n let bestLen = -1;\n for (const [prefix, value] of Object.entries(table)) {\n if (prefix.length > bestLen && model.startsWith(prefix)) {\n best = value;\n bestLen = prefix.length;\n }\n }\n return best;\n}\n\n/** True when the model id resolves to a real MODEL_PRICING row (i.e. getPricing\n * will NOT be guessing via the unknown-model fallback). */\nexport function isKnownModel(model: string): boolean {\n return longestPrefixMatch(MODEL_PRICING, model) !== undefined;\n}\n\n/**\n * Flagged default for an unpriced model id. All-zero so an unknown model is\n * VISIBLY unpriced ($0) rather than silently MISPRICED at some other family's\n * rates (the old sonnet-4 fallback billed unknown ids — including a haiku id\n * that matched no row — at sonnet rates). `getPricing` returns this object for\n * unknown ids so callers that do unconditional arithmetic still work; callers\n * that must distinguish real pricing from the default check `isKnownModel`.\n */\nexport const UNKNOWN_MODEL_PRICING: ModelPricing = {\n input: 0,\n output: 0,\n cacheRead: 0,\n cacheWrite: 0,\n};\n\n/**\n * Resolve pricing by longest matching prefix. Unknown models resolve to the\n * flagged {@link UNKNOWN_MODEL_PRICING} default (all-zero, i.e. visibly\n * unpriced) instead of guessing at another model's rates. Callers that need to\n * distinguish real pricing from the default must check `isKnownModel(model)`.\n */\nexport function getPricing(model: string): ModelPricing {\n return longestPrefixMatch(MODEL_PRICING, model) ?? UNKNOWN_MODEL_PRICING;\n}\n\nexport function getContextWindow(model: string | null): number {\n if (!model) return DEFAULT_CONTEXT_WINDOW;\n return longestPrefixMatch(MODEL_CONTEXT_WINDOW, model) ?? DEFAULT_CONTEXT_WINDOW;\n}\n","import type { AgentId, AgentMetadata } from './types';\n\nexport const AGENT_REGISTRY: Record<AgentId, AgentMetadata> = {\n claude: {\n id: 'claude',\n displayName: 'Claude Code',\n binaryName: 'claude',\n enabled: true,\n // Mirrors the backend registry (codeagent-mobile\n // apps/api-v2/src/codespaces/agent.ts — authoritative for auth\n // capabilities). `setup_token` is the bare `sk-ant-oat01-…` from\n // `claude setup-token` → delivered via CLAUDE_CODE_OAUTH_TOKEN.\n supportedAuthKinds: ['setup_token', 'oauth_token', 'api_key'],\n preferredAuthKind: 'setup_token',\n headroomWrappable: true,\n headroomKind: 'claude',\n // npm adapter `@agentclientprotocol/claude-agent-acp`.\n acp: true,\n },\n codex: {\n id: 'codex',\n displayName: 'Codex CLI',\n binaryName: 'codex',\n enabled: true,\n supportedAuthKinds: ['oauth_token', 'api_key'],\n preferredAuthKind: 'oauth_token',\n headroomWrappable: true,\n headroomKind: 'codex',\n // npm adapter `@agentclientprotocol/codex-acp`.\n acp: true,\n // OAuth device-code flow; the user_code on the OpenAI page IS a real\n // human-typed code — surfaces render it (with a copy affordance).\n deviceFlow: true,\n showsUserCode: true,\n },\n copilot: {\n id: 'copilot',\n displayName: 'GitHub Copilot CLI',\n binaryName: 'gh',\n enabled: false,\n supportedAuthKinds: ['oauth_token'],\n preferredAuthKind: 'oauth_token',\n // `headroom init --global copilot` exists even though the agent is\n // still disabled here (no runtime builder yet).\n headroomWrappable: true,\n headroomKind: 'copilot',\n acp: false,\n },\n coderabbit: {\n id: 'coderabbit',\n displayName: 'CodeRabbit',\n binaryName: 'coderabbit',\n enabled: true,\n // Backend registry is authoritative: CodeRabbit links via a real\n // API key only (no OAuth flow exists in api-v2).\n supportedAuthKinds: ['api_key'],\n preferredAuthKind: 'api_key',\n headroomWrappable: false,\n // Legacy PTY runtime — no ACP adapter registered.\n acp: false,\n },\n cursor: {\n id: 'cursor',\n displayName: 'Cursor Agent',\n binaryName: 'cursor-agent',\n enabled: true,\n // Backend registry is authoritative: since the Cursor OAuth\n // device-flow shipped, new links are oauth_token only (the login\n // blob written to ~/.config/cursor/auth.json). Legacy vaulted\n // api_key rows may still exist server-side, but the link surface\n // no longer offers api_key.\n supportedAuthKinds: ['oauth_token'],\n preferredAuthKind: 'oauth_token',\n // `headroom wrap cursor` is \"manual/print-only\" (IDE settings; the\n // headless cursor-agent CLI has no base-URL override) — runs native.\n headroomWrappable: false,\n // Native ACP server: `cursor-agent acp`.\n acp: true,\n // Reverse-engineered device/poll flow; `userCode` is the secret PKCE\n // verifier echoed back on poll — NEVER human-facing.\n deviceFlow: true,\n showsUserCode: false,\n },\n aider: {\n id: 'aider',\n displayName: 'Aider',\n binaryName: 'aider',\n enabled: true,\n // Aider is OAuth-less — auth is via ANTHROPIC_API_KEY / OPENAI_API_KEY\n // / etc. env vars or `~/.aider.conf.yml`. The link flow surfaces\n // this via the existing --api-key escape hatch in commands/link.ts.\n supportedAuthKinds: ['api_key'],\n preferredAuthKind: 'api_key',\n headroomWrappable: false,\n // Legacy PTY runtime — no ACP adapter registered.\n acp: false,\n },\n gemini: {\n id: 'gemini',\n displayName: 'Gemini CLI',\n binaryName: 'gemini',\n enabled: true,\n // OAuth via `gemini auth login` (captured by `codeam link gemini`\n // from ~/.gemini/oauth_creds.json) AND GEMINI_API_KEY are both\n // accepted by the backend's GeminiProvisioningStrategy and propagated\n // into codespace deploys.\n supportedAuthKinds: ['oauth_token', 'api_key'],\n preferredAuthKind: 'oauth_token',\n // Not listed by `headroom wrap --help` — runs native.\n headroomWrappable: false,\n // Native ACP server: `gemini --skip-trust --acp`.\n acp: true,\n },\n};\n\nexport function getEnabledAgents(): AgentMetadata[] {\n return Object.values(AGENT_REGISTRY).filter(m => m.enabled);\n}\n\nexport function getAgent(id: AgentId): AgentMetadata {\n const meta = AGENT_REGISTRY[id];\n if (!meta) throw new Error(`Unknown agent id: ${id}`);\n return meta;\n}\n\nexport function isKnownAgentId(id: string): id is AgentId {\n return id in AGENT_REGISTRY;\n}\n","/**\n * Agent identity — the ONE place the public (`LinkedAgentId`) and internal\n * (`AgentId`) id spaces are declared and bridged, plus the ONE alias\n * normalizer every surface funnels through.\n *\n * Canonical values consolidated from (Phase 2, PR-1):\n * - backend `apps/api-v2/src/linked-agents/agent-map.ts`\n * (`PUBLIC_TO_INTERNAL` / `INTERNAL_TO_PUBLIC` / `LinkedAgentId`),\n * - CLI `apps/cli/src/commands/host/agent-provisioning.ts`\n * (`PUBLIC_TO_INTERNAL_AGENT`),\n * - VS Code plugin `apps/vsc-plugin/src/utils/cli-agent-id.ts`\n * (marketplace aliases + `__terminal__:` strip),\n * - CLI `apps/cli/src/commands/start/handlers.ts`\n * (the `claude_code` → `claude` normalization),\n * - mobile `apps/mobile/src/lib/agent-id-map.ts`.\n */\n\nimport type { AgentId, HeadroomKind } from './types';\nimport { AGENT_REGISTRY, isKnownAgentId } from './registry';\n\n// ─── House agent constants ───────────────────────────────────────────────────\n// Byte-identical mirrors of the backend repo's canonical\n// `codeagent-mobile/packages/shared/src/constants/house-agent.ts` (which the\n// api-v2 additionally hand-mirrors in `common/constants/house-agent.ts`).\n// PR-3 replaces those copies with re-exports of THESE.\n\n/** Sentinel id for the synthetic \"CodeAgent Cloud (incluido)\" house agent. */\nexport const HOUSE_AGENT_ID = 'house-codeagent-cloud';\n\n/** Internal provider discriminator for the house agent. */\nexport const HOUSE_AGENT_PROVIDER = 'codeagent_cloud';\n\n/** White-label display strings — never mention the backend model. */\nexport const HOUSE_AGENT_NAME = 'CodeAgent Cloud';\nexport const HOUSE_AGENT_VENDOR = 'CodeAgent';\nexport const HOUSE_AGENT_SUBTITLE = 'Included — no setup';\n\n// ─── Public (LinkedAgent) id space ───────────────────────────────────────────\n\n/**\n * Public-facing linked-agent ids — the id space the `/api/agents/...`\n * endpoints and the mobile/web surfaces speak. The internal `AgentId`\n * (`'claude' | 'codex' | …`) is what the runtimes / provisioning key on.\n */\nexport type LinkedAgentId =\n | 'claude_code'\n | 'codex'\n | 'cursor'\n | 'aider'\n | 'coderabbit'\n | 'gemini'\n | typeof HOUSE_AGENT_ID;\n\nexport const LINKED_AGENT_IDS: readonly LinkedAgentId[] = [\n 'claude_code',\n 'codex',\n 'cursor',\n 'aider',\n 'coderabbit',\n 'gemini',\n HOUSE_AGENT_ID,\n];\n\nexport function isLinkedAgentId(value: string): value is LinkedAgentId {\n return (LINKED_AGENT_IDS as readonly string[]).includes(value);\n}\n\n/**\n * Every public id → internal `AgentId`.\n *\n * ⚠️ RECONCILED ASYMMETRY — this map is the UNION of what the two sides\n * historically accepted:\n * - The backend's `agent-map.ts` accepts only the `LinkedAgentId` union\n * (incl. the house agent, whose runtime is Claude Code) — no bare\n * `claude`, no `copilot` (there is no public copilot LinkedAgentId).\n * - The CLI's self-hosted `agent-provisioning.ts` additionally accepts\n * bare `'claude'` and `'copilot'` (deploy payloads have carried\n * already-internal ids), but not the house agent.\n * Consumers that must REJECT ids outside their own historical set keep\n * their own guard on top (e.g. `isLinkedAgentId`).\n */\nexport const PUBLIC_TO_INTERNAL: Readonly<\n Record<LinkedAgentId | 'claude' | 'copilot', AgentId>\n> = {\n claude_code: 'claude',\n // CLI-side extra: self-hosted deploy payloads may carry the internal id.\n claude: 'claude',\n codex: 'codex',\n // CLI-side extra: copilot has no public LinkedAgentId (backend doesn't\n // expose it) but the self-hosted path accepts it.\n copilot: 'copilot',\n cursor: 'cursor',\n aider: 'aider',\n coderabbit: 'coderabbit',\n gemini: 'gemini',\n // The house agent runs Claude Code under the hood (pointed at the\n // MiniMax proxy). Its internal runtime is therefore `claude`.\n [HOUSE_AGENT_ID]: 'claude',\n};\n\n/**\n * Internal → public. Partial: `copilot` has no public LinkedAgentId, and\n * `claude` maps back to `claude_code` (never the house agent — that\n * direction is intentionally lossy).\n */\nexport const INTERNAL_TO_PUBLIC: Readonly<Partial<Record<AgentId, LinkedAgentId>>> = {\n claude: 'claude_code',\n codex: 'codex',\n cursor: 'cursor',\n aider: 'aider',\n coderabbit: 'coderabbit',\n gemini: 'gemini',\n};\n\nfunction isPublicToInternalKey(v: string): v is LinkedAgentId | 'claude' | 'copilot' {\n // Not Object.hasOwn — the VS Code plugin's tsconfig lib predates ES2022.\n return Object.prototype.hasOwnProperty.call(PUBLIC_TO_INTERNAL, v);\n}\n\n/** Resolve a public/linked id to the internal `AgentId`, or null. */\nexport function publicToInternal(publicId: string): AgentId | null {\n return isPublicToInternalKey(publicId) ? PUBLIC_TO_INTERNAL[publicId] : null;\n}\n\n/** Resolve an internal `AgentId` to its public `LinkedAgentId`, or null. */\nexport function internalToPublic(internal: AgentId): LinkedAgentId | null {\n return INTERNAL_TO_PUBLIC[internal] ?? null;\n}\n\n// ─── Alias normalization ─────────────────────────────────────────────────────\n\n/** Prefix IDE plugins use for terminal-hosted agent ids. */\nexport const TERMINAL_AGENT_PREFIX = '__terminal__:';\n\n/**\n * Known aliases → internal `AgentId`. Union of every alias set that used\n * to live scattered across the surfaces: the public `claude_code` id, the\n * VS Code / Open VSX marketplace extension ids, and JetBrains plugin ids.\n */\nconst AGENT_ID_ALIASES: Readonly<Record<string, AgentId>> = {\n claude_code: 'claude',\n 'claude-code': 'claude',\n 'anthropic.claude-code': 'claude',\n 'anthropics.claude': 'claude',\n 'anthropic.claude-ce': 'claude',\n 'anthropic.claude': 'claude',\n 'com.anthropic.claudecode': 'claude',\n 'com.anthropic.claude': 'claude',\n 'openai.chatgpt': 'codex',\n 'coderabbitai.coderabbit-vscode': 'coderabbit',\n};\n\n/**\n * THE agent-id normalizer. Collapses every known spelling of an agent id\n * (registry id, public `claude_code` form, marketplace extension id,\n * `__terminal__:`-prefixed plugin id — case/whitespace tolerant) onto the\n * internal `AgentId`, or `null` when unknown.\n *\n * Deliberately does NOT:\n * - gate on `enabled` (callers that need availability check the\n * registry — see the VS Code wrapper `normalizeCliAgentId`);\n * - map the house agent (that's a runtime substitution, not an alias —\n * use {@link publicToInternal});\n * - fall back to anything. Unknown in → `null` out.\n */\nexport function normalizeAgentId(raw: string): AgentId | null {\n const value = (raw ?? '').trim().toLowerCase();\n if (!value) return null;\n\n if (isKnownAgentId(value)) return value;\n\n const unprefixed = value.startsWith(TERMINAL_AGENT_PREFIX)\n ? value.slice(TERMINAL_AGENT_PREFIX.length)\n : value;\n if (isKnownAgentId(unprefixed)) return unprefixed;\n\n return AGENT_ID_ALIASES[unprefixed] ?? null;\n}\n\n// ─── Headroom kind derivation ────────────────────────────────────────────────\n\n/**\n * The `headroom init --global <kind>` subcommand for an agent id, derived\n * from the registry's `headroomKind` flags — or `null` for unknown or\n * non-wrappable agents (cursor / gemini / aider / anything else).\n *\n * ⚠️ NEVER falls back to `'claude'`. The historical CLI fallback is how\n * the 2026-06 Cursor incident happened: an unsupported agent slipped\n * through, defaulted to `claude`, and `headroom wrap claude` launched\n * Claude Code instead of the user's agent. Callers that genuinely need a\n * default (e.g. picking an init subcommand AFTER the wrappable gate has\n * already passed) apply it themselves — see the CLI's\n * `agentIdToHeadroomKind` wrapper.\n *\n * Matching mirrors the historical predicates on BOTH sides (CLI\n * `isHeadroomSupportedAgent`, api-v2 `isHeadroomWrappableAgent`):\n * case-insensitive, `_`/`-` tolerant, prefix match — so `claude_code`,\n * `Claude-Code`, `codex_cli`, `copilot-cli` all resolve.\n */\nexport function headroomKindFor(agentId: string): HeadroomKind | null {\n const normalized = (agentId ?? '').toLowerCase().replace(/[_-]/g, '');\n if (!normalized) return null;\n for (const meta of Object.values(AGENT_REGISTRY)) {\n if (meta.headroomKind !== undefined && normalized.startsWith(meta.id)) {\n return meta.headroomKind;\n }\n }\n return null;\n}\n\n/**\n * Registry-derived replacement for the two scattered predicates\n * (`isHeadroomSupportedAgent` in the CLI, `isHeadroomWrappableAgent` in\n * api-v2). Accepts both id spaces (`claude_code` and `claude`).\n */\nexport function isHeadroomWrappable(agentId: string): boolean {\n return headroomKindFor(agentId) !== null;\n}\n","/**\n * Production API base URL for all CodeAgent Mobile clients.\n *\n * History note: prod migrated from Vercel (`https://api.codeagent-mobile.com`)\n * to Cloud Run / api-v2 (`https://api.codeagent-mobile.com`) in 2026-05. The\n * Vercel deployment is now gated by Vercel deployment protection and returns\n * 403 for unauthed traffic — DO NOT fall back to it.\n *\n * Override at runtime with `CODEAM_API_URL` (full URL override) OR set\n * `CODEAM_TEST_MODE=1` to point every client request at the dev\n * preview without having to know its host.\n */\nexport const DEFAULT_API_BASE_URL = 'https://api.codeagent-mobile.com' as const;\n\n/**\n * Dev-preview API base URL. Same Cloud Run service as prod but routed\n * to the `dev` revision (auto-deploys from the `dev` branch in the\n * backend repo). Manual smoke tests + load runs land here.\n */\nexport const DEV_API_BASE_URL = 'https://dev-api.codeagent-mobile.com' as const;\n\n/**\n * Resolve the active API base URL, honoring in priority order:\n *\n * 1. Explicit `CODEAM_API_URL` env var — full URL, takes precedence.\n * 2. `CODEAM_TEST_MODE=1` shortcut — flips to [DEV_API_BASE_URL]\n * without the user having to know the dev host.\n * 3. The `DEFAULT_API_BASE_URL` constant (prod).\n *\n * Used by every CLI service that talks to the backend so one env var\n * flips heartbeats, command relay, chunk uploads, and the pairing\n * flow in lockstep — eliminates the cross-environment misroute where\n * pairing succeeds in dev (shared Redis) but the CLI keeps\n * heartbeating to prod.\n */\nexport function resolveApiBaseUrl(): string {\n // Guard against non-Node runtimes (browser bundles import this\n // module). `process` is undefined there; treat as prod default.\n // `@codeam/shared` deliberately avoids depending on `@types/node`\n // so its types stay consumable from the mobile RN bundle too, so we\n // reach for the env via a structural cast rather than NodeJS.ProcessEnv.\n const env = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process?.env;\n const explicit = env?.CODEAM_API_URL?.trim();\n if (explicit) return explicit;\n const testFlag = env?.CODEAM_TEST_MODE?.trim();\n if (testFlag === '1' || testFlag?.toLowerCase() === 'true') return DEV_API_BASE_URL;\n return DEFAULT_API_BASE_URL;\n}\n","/**\n * Headroom provisioning manifest — the SINGLE source of truth for what a\n * Headroom install consists of, rendered by every provisioning surface:\n *\n * - codespace bootstrap (bash composer in the backend repo,\n * `apps/api-v2/src/codespaces/github-ssh.service.ts` — adopts in PR-2),\n * - self-hosted deploy (TS installer, CLI `commands/host-agent.ts`\n * `setupHeadroomForSelfHosted`),\n * - on-demand local sessions (\"Session add-ons → Cost-saving\", CLI\n * `services/headroom/configure.ts`).\n *\n * Values are DATA-first (arrays/records, plus tiny pure renderers) so both\n * the TS installer and a bash composer can interpolate from them. Renderers\n * are byte-exact with the literals they replaced — guarded by\n * `packages/shared/__tests__/headroom-manifest.test.ts`.\n *\n * ⚠️ The extras matter: `[proxy,code]` pulls the ONNX compression engines\n * (Kompress + tree-sitter CodeCompressor). NEVER add `[ml]` — that's\n * multi-GB PyTorch, and a broken/cold torch wedges every prompt at\n * \"Thinking…\". The models are pre-downloaded at provision time because the\n * proxy eager-loads with `allow_download=False` and a cold cache defers the\n * ~840 MB download to the first prompt (blowing the agent's ~90 s idle\n * timeout).\n */\n\n/** Local proxy port the agent's config is routed to. */\nexport const HEADROOM_PROXY_PORT = 8787;\n\n/**\n * Env that pins the ONNX backend on the proxy process — never imports\n * torch. Spread into the proxy launch env on every surface.\n */\nexport const HEADROOM_BACKEND_ENV = {\n HEADROOM_KOMPRESS_BACKEND: 'onnx_cpu',\n} as const;\n\n/**\n * The proxy's HTTP/server companion packages, installed alongside the\n * `headroom-ai[...]` package. The COMPRESSION ENGINES come from the\n * headroom-ai extras — NOT this list.\n */\nexport const HEADROOM_PIP_COMPANIONS: readonly string[] = [\n 'fastapi',\n 'uvicorn',\n 'httpx[http2]',\n 'websockets',\n 'zstandard',\n];\n\n/** The three provisioning surfaces (see module doc). */\nexport type HeadroomSurface = 'codespace' | 'selfHosted' | 'onDemand';\n\n/**\n * pip extras per surface. `onDemand` additionally ships `image`\n * (image-compression support, added with the Session add-ons path in\n * codeam-cli@2.49.0); the older codespace/self-hosted install strings\n * remain `[proxy,code]` byte-for-byte.\n */\nexport const HEADROOM_EXTRAS_BY_SURFACE: Readonly<Record<HeadroomSurface, readonly string[]>> = {\n codespace: ['proxy', 'code'],\n selfHosted: ['proxy', 'code'],\n onDemand: ['proxy', 'code', 'image'],\n};\n\n/** `headroom-ai[<extras>]` — the pip requirement string. */\nexport function headroomPipPackage(extras: readonly string[]): string {\n return `headroom-ai[${extras.join(',')}]`;\n}\n\n/** One HuggingFace repo to pre-warm into the HF cache at provision time. */\nexport interface HeadroomModelSpec {\n repo: string;\n /** `snapshot_download(..., allow_patterns=[…])` filter. */\n allowPatterns: readonly string[];\n}\n\n/**\n * The two HF repos Kompress needs. kompress-v2-base is the ONNX model\n * (skip its .pt/.safetensors torch artifacts); ModernBERT-base is the\n * TOKENIZER ONLY (skip its model weights).\n */\nexport const HEADROOM_MODELS: readonly HeadroomModelSpec[] = [\n {\n repo: 'chopratejas/kompress-v2-base',\n allowPatterns: ['*.json', 'onnx/*.onnx', 'kompress-int8-wo.onnx'],\n },\n {\n repo: 'answerdotai/ModernBERT-base',\n allowPatterns: ['*.json', 'tokenizer*', '*.txt', 'vocab*', 'merges*'],\n },\n];\n\n/** Formatting knob so each surface can stay byte-identical to its\n * historical literal (the CLI joins patterns with `,`, the codespace\n * bash composer with `, `). */\nexport interface HeadroomPythonRenderOpts {\n /** Put a space after the commas between allow_patterns entries. */\n spaceAfterComma?: boolean;\n}\n\n/** Render one `snapshot_download(...)` python line for a model. */\nexport function headroomSnapshotDownloadLine(\n model: HeadroomModelSpec,\n opts: HeadroomPythonRenderOpts = {},\n): string {\n const sep = opts.spaceAfterComma ? ', ' : ',';\n const patterns = model.allowPatterns.map((p) => `\"${p}\"`).join(sep);\n return `snapshot_download(\"${model.repo}\", allow_patterns=[${patterns}])`;\n}\n\n/**\n * The full model pre-download python snippet (import + one\n * `snapshot_download` per model), newline-joined — what the surfaces pass\n * to `python -c` / a heredoc.\n */\nexport function headroomModelPredownloadScript(opts: HeadroomPythonRenderOpts = {}): string {\n return [\n 'from huggingface_hub import snapshot_download',\n ...HEADROOM_MODELS.map((m) => headroomSnapshotDownloadLine(m, opts)),\n ].join('\\n');\n}\n","/**\n * Canonical names of the per-user SSE bus events (`/api/users/me/stream`).\n *\n * The authoritative list is the `UserEvent` discriminated union in the\n * backend repo: codeagent-mobile/apps/api-v2/src/user-events/user-events.types.ts.\n * Every `type:` literal of that union appears here exactly once — when a new\n * variant lands on the union, add its name here (and in the backend mirror of\n * this file at codeagent-mobile/packages/shared/src/types/events.ts).\n *\n * Producers (CLI event posts, backend `userEvents.publish` calls) and\n * consumers (the `useUserEventsSSE` hooks' switch cases) should reference\n * `USER_EVENTS.*` instead of re-typing the string, so a typo becomes a\n * compile error instead of a silently dropped event.\n */\nexport const USER_EVENTS = {\n PAIRED_SESSION_STATUS: 'paired_session_status',\n PAIRED_SESSION_ADDED: 'paired_session_added',\n PAIRED_SESSION_REMOVED: 'paired_session_removed',\n PAIRED_SESSION_BRANCH_CHANGED: 'paired_session_branch_changed',\n SHARED_WITH_ME_ADDED: 'shared_with_me_added',\n SHARED_WITH_ME_REVOKED: 'shared_with_me_revoked',\n USAGE_CHANGED: 'usage_changed',\n TASK_DONE: 'task_done',\n HUNK_PENDING_REVIEW_ADDED: 'hunk_pending_review_added',\n HUNK_REVIEW_RESOLVED: 'hunk_review_resolved',\n FILE_CHANGED: 'file_changed',\n FILES_BATCH_CHANGED: 'files_batch_changed',\n AGENT_STREAMING_CHUNK: 'agent_streaming_chunk',\n AGENT_AWAITING_ANSWER: 'agent_awaiting_answer',\n AWAITING_INPUT_ADDED: 'awaiting_input_added',\n AGENT_ANSWER_RESOLVED: 'agent_answer_resolved',\n TEMPLATE_ADDED: 'template_added',\n TEMPLATE_REMOVED: 'template_removed',\n TEMPLATE_UPDATED: 'template_updated',\n AGENT_TASK_DISPATCHED: 'agent_task_dispatched',\n AGENT_TASK_COMPLETED: 'agent_task_completed',\n LINKED_AGENT_ADDED: 'linked_agent_added',\n QUOTA_REACHED: 'quota_reached',\n LINKED_AGENT_LINK_FAILED: 'linked_agent_link_failed',\n CODESPACE_AGENT_INSTALLED: 'codespace_agent_installed',\n AGENT_CREDENTIALS_REFRESHED: 'agent_credentials_refreshed',\n CREDENTIAL_INVALID: 'credential_invalid',\n CODESPACE_WAKING: 'codespace_waking',\n CODESPACE_BILLING_BLOCKED: 'codespace_billing_blocked',\n COST_SAVING_UPDATED: 'cost_saving_updated',\n COMMAND_COMPLETED: 'command_completed',\n AI_SUMMARY_PENDING: 'ai_summary_pending',\n AI_SUMMARY_READY: 'ai_summary_ready',\n AI_INSIGHT_PENDING: 'ai_insight_pending',\n AI_INSIGHT_READY: 'ai_insight_ready',\n PUSH_TOKEN_INVALIDATED: 'push_token_invalidated',\n PREVIEW_DETECTION_PENDING: 'preview_detection_pending',\n PREVIEW_DETECTION_READY: 'preview_detection_ready',\n PREVIEW_STARTING: 'preview_starting',\n PREVIEW_READY: 'preview_ready',\n PREVIEW_STOPPED: 'preview_stopped',\n PREVIEW_ERROR: 'preview_error',\n PREVIEW_PROGRESS: 'preview_progress',\n BEADS_STATE_CHANGED: 'beads_state_changed',\n BEADS_PROVISIONING: 'beads_provisioning',\n BEADS_TEAM_MEMORY_CHANGED: 'beads_team_memory_changed',\n AUDIT_EVENT_ADDED: 'audit_event_added',\n SELF_HOSTED_HOST_ADDED: 'self_hosted_host_added',\n SELF_HOSTED_HOST_STATUS: 'self_hosted_host_status',\n SELF_HOSTED_HOST_REMOVED: 'self_hosted_host_removed',\n SELF_HOSTED_HOST_TELEMETRY: 'self_hosted_host_telemetry',\n SELF_HOSTED_HOST_METRICS: 'self_hosted_host_metrics',\n SELF_HOSTED_HOST_SESSIONS: 'self_hosted_host_sessions',\n SELF_HOSTED_DEPLOY_PROGRESS: 'self_hosted_deploy_progress',\n REFERRAL_REWARD_EARNED: 'referral_reward_earned',\n HEADROOM_PROGRESS: 'headroom_progress',\n HEADROOM_STATUS: 'headroom_status',\n BEADS_STATUS: 'beads_status',\n LINKED_AGENT_HEADROOM_BUDGET_UPDATED: 'linked_agent_headroom_budget_updated',\n CLI_UPDATE_AVAILABLE: 'cli_update_available',\n AGENT_INSTALL_PROGRESS: 'agent_install_progress',\n AGENT_INSTALL_FAILED: 'agent_install_failed',\n CLI_UPDATE_PROGRESS: 'cli_update_progress',\n CLI_UPDATE_FAILED: 'cli_update_failed',\n BATON_STATE: 'baton_state',\n} as const;\n\nexport type UserEventName = (typeof USER_EVENTS)[keyof typeof USER_EVENTS];\n","/**\n * Prompt the CLI sends to the user's linked agent (Claude, Codex, …)\n * in a headless one-shot to detect how to start the project's dev\n * server. Same pattern as the AI Insights \"summary\" prompt — the\n * agent runs locally with the user's auth, has read access to the\n * project, and returns a tiny JSON blob the CLI parses.\n *\n * Kept here (in `@codeam/shared`) so the CLI build inlines the\n * exact string at compile time without runtime fetch from the backend.\n */\nexport const PREVIEW_DETECT_PROMPT = `\nAnalyze the project in the current working directory and return how to start\nits development server for in-app preview.\n\nRead package.json, Procfile, Dockerfile, docker-compose.yml, manage.py, app.json,\nmix.exs, Cargo.toml, go.mod, requirements.txt, Gemfile, and any other framework\nmarkers you find at depth <= 2.\n\nReturn ONLY a JSON object on stdout (no prose, no markdown fences):\n\n{\n \"framework\": \"<name, or 'unsupported'>\",\n \"command\": \"<executable>\",\n \"args\": [\"...\"],\n \"port\": <number>,\n \"ready_pattern\": \"<regex matching the server-ready stdout line>\",\n \"env\": { \"HOST\": \"0.0.0.0\" },\n \"setup_commands\": [{ \"cmd\": \"<executable>\", \"args\": [\"...\"] }],\n \"notes\": \"<one-line caveat or null>\"\n}\n\nRules:\n- Pick the script the developer would run locally to see the app (typically \"dev\", \"start\", \"serve\").\n- Prefer binding to 0.0.0.0 — most frameworks default to localhost which the tunnel cannot reach.\n- For Expo: framework=\"Expo\", command=\"npx\", args=[\"expo\",\"start\",\"--tunnel\"], port=8081, notes=\"Scan QR with Expo Go\".\n- If no dev server applies (CLI library, lambda, batch script): {\"framework\":\"unsupported\",\"notes\":\"<reason>\"}.\n\nCRITICAL — setup_commands:\n- DO NOT include an install command (npm install, pnpm install, yarn install,\n yarn, bun install) in setup_commands. A lockfile-aware pre-flight installer\n runs BEFORE setup_commands and picks the correct package manager from the\n lockfile present (pnpm-lock.yaml -> pnpm, yarn.lock -> yarn, bun.lockb -> bun,\n else npm). Emitting an install here either duplicates that work or, worse,\n uses the WRONG package manager on top of node_modules just populated by the\n pre-flight, which crashes (e.g. npm errors with \"Cannot read properties of\n null (reading 'matches')\" when run over pnpm's .pnpm/ layout).\n- ONLY include setup_commands for genuinely non-install work the project needs\n before its dev server can boot: prisma generate, codegen, prebuild scripts,\n database migrations against a local SQLite, etc.\n- Each setup_commands entry MUST be an object {\"cmd\": \"...\", \"args\": [\"...\"]} —\n e.g. {\"cmd\": \"npx\", \"args\": [\"prisma\", \"generate\"]}. NOT a bare string.\n- For most projects, setup_commands should be an empty array [].\n\nOUTPUT JSON ONLY. NO MARKDOWN. NO COMMENTARY.\n`.trim();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACiBO,IAAM,mBAAmB;AAezB,IAAM,uBAAuB;AAS7B,IAAM,gCAAgC;AAOtC,IAAM,wBAAwB;;;ACvC9B,SAAS,cAAc,KAAuB;AACnD,QAAM,SAAmB,CAAC,EAAE;AAC5B,MA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;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA4CnC,KAAK;","names":[]}
1
+ {"version":3,"sources":["../src/index.ts","../src/protocol/constants.ts","../src/protocol/renderToLines.ts","../src/protocol/remote-command.ts","../src/models/pricing.ts","../src/agents/registry.ts","../src/agents/identity.ts","../src/api-url.ts","../src/headroom/manifest.ts","../src/types/events.ts","../src/preview-prompts.ts"],"sourcesContent":["export * from './protocol/chrome-types';\nexport * from './protocol/constants';\nexport * from './protocol/renderToLines';\nexport * from './protocol/remote-command';\nexport * from './models/pricing';\nexport * from './agents';\nexport * from './types/file-change';\nexport * from './types/streaming';\nexport * from './api-url';\nexport * from './types/preview';\nexport * from './types/beads';\nexport * from './types/headroom';\nexport * from './headroom/manifest';\nexport * from './types/events';\nexport * from './preview-prompts';\n","/**\n * Shared wire / lifecycle constants. The values here are bundled\n * into the CLI + VS Code extension at build time via tsup / esbuild\n * and mirrored in `apps/jetbrains-plugin/.../protocol/Constants.kt`\n * since Kotlin can't import an npm package.\n *\n * If you change one of these values, also update the Kotlin mirror.\n */\n\n/**\n * Discriminated chunk-protocol version sent as the\n * `X-Codeam-Protocol-Version` header on every authed request. The\n * backend uses this to opt into legacy translations or to reject\n * with 426 when the client is too far behind. Bumped in lockstep\n * with chunk-shape changes (e.g. when the `chrome_steps` chunk\n * type is added).\n */\nexport const PROTOCOL_VERSION = '2.0.0' as const;\n\n/**\n * The VS Code AgentOutputMonitor's loopback HTTP server bound to\n * 127.0.0.1 on this port — the observer JS in the IDE renderer\n * uses it to round-trip captured chat content back into the\n * extension host. The port is intentionally fixed (rather than\n * `listen(0)`) so the observer script can be a static constant\n * rather than dynamically rewriting itself per session.\n *\n * Multi-window collision is solved by listen(0) per-window in the\n * monitor (see #103); this default is still the documented\n * starting port for tooling that needs to probe whether a CodeAgent\n * Mobile session is active locally.\n */\nexport const OBSERVER_BRIDGE_PORT = 47832;\n\n/**\n * Default plugin → backend heartbeat interval. User-configurable\n * via `codeagent-mobile.heartbeatIntervalMs` on VS Code and\n * `heartbeatIntervalMs` in SettingsService.kt's @State on JetBrains.\n * Mirrors the value the apps/api side uses to flip the paired\n * session to offline.\n */\nexport const HEARTBEAT_INTERVAL_MS_DEFAULT = 30_000;\n\n/**\n * SSE + polling reconnect cap. Vercel's serverless functions close\n * SSE connections after ~25 s by default; the client uses 35 s as\n * its overall socket timeout to leave a beat for graceful close.\n */\nexport const SSE_SOCKET_TIMEOUT_MS = 35_000;\n","/**\n * Render raw PTY bytes into an array of screen lines using a simplified\n * virtual terminal. Handles cursor movements (A/B/C/D/G/H), erase (J/K),\n * alternate-screen (?1049h), carriage return, and LF.\n *\n * This is the authoritative implementation used by both codeam-cli (PTY\n * output) and the VS Code extension (shell-integration output) so that\n * the mobile/web client sees identical chunks regardless of surface.\n */\nexport function renderToLines(raw: string): string[] {\n const screen: string[] = [''];\n let row = 0;\n let col = 0;\n\n function ensureRow(): void {\n while (screen.length <= row) screen.push('');\n }\n\n function writeChar(ch: string): void {\n ensureRow();\n if (col < screen[row].length) {\n screen[row] = screen[row].slice(0, col) + ch + screen[row].slice(col + 1);\n } else {\n while (screen[row].length < col) screen[row] += ' ';\n screen[row] += ch;\n }\n col++;\n }\n\n let i = 0;\n while (i < raw.length) {\n const ch = raw[i];\n\n if (ch === '\\x1B') {\n i++;\n if (i >= raw.length) break;\n\n if (raw[i] === '[') {\n i++;\n let param = '';\n while (i < raw.length && !/[@-~]/.test(raw[i])) param += raw[i++];\n const cmd = raw[i] ?? '';\n const n = parseInt(param) || 1;\n\n if (cmd === 'A') { row = Math.max(0, row - n); }\n else if (cmd === 'B') { row += n; ensureRow(); }\n else if (cmd === 'C') { col += n; }\n else if (cmd === 'D') { col = Math.max(0, col - n); }\n else if (cmd === 'G') { col = Math.max(0, n - 1); }\n else if (cmd === 'H' || cmd === 'f') {\n const p = param.split(';');\n row = Math.max(0, (parseInt(p[0] ?? '1') || 1) - 1);\n col = Math.max(0, (parseInt(p[1] ?? '1') || 1) - 1);\n ensureRow();\n } else if (cmd === 'J') {\n if (param === '2' || param === '3') {\n screen.length = 1; screen[0] = ''; row = 0; col = 0;\n } else if (param === '1') {\n for (let r = 0; r < row; r++) screen[r] = '';\n screen[row] = ' '.repeat(col) + screen[row].slice(col);\n } else {\n screen[row] = screen[row].slice(0, col);\n screen.splice(row + 1);\n }\n } else if (cmd === 'K') {\n ensureRow();\n if (param === '' || param === '0') screen[row] = screen[row].slice(0, col);\n else if (param === '1') screen[row] = ' '.repeat(col) + screen[row].slice(col);\n else if (param === '2') screen[row] = '';\n } else if (cmd === 'h' && (param === '?1049' || param === '?47')) {\n screen.length = 1; screen[0] = ''; row = 0; col = 0;\n } else if (cmd === 'l' && (param === '?1049' || param === '?47')) {\n screen.length = 1; screen[0] = ''; row = 0; col = 0;\n }\n } else if (raw[i] === ']') {\n i++;\n while (i < raw.length) {\n if (raw[i] === '\\x07') break;\n if (raw[i] === '\\x1B' && i + 1 < raw.length && raw[i + 1] === '\\\\') { i++; break; }\n i++;\n }\n }\n } else if (ch === '\\r') {\n if (i + 1 < raw.length && raw[i + 1] === '\\n') {\n row++; col = 0; ensureRow(); i++;\n } else {\n col = 0;\n }\n } else if (ch === '\\n') {\n row++; col = 0; ensureRow();\n } else if (ch >= ' ' || ch === '\\t') {\n writeChar(ch);\n }\n\n i++;\n }\n\n return screen;\n}\n","import { z } from 'zod';\n\n/**\n * The command envelope clients receive from the backend relay — both from\n * the `commands` SSE frames on `/api/commands/pending/stream` and from the\n * `GET /api/commands/pending` polling fallback. One schema, shared, so the\n * VS Code extension (and eventually the CLI) stop blind-casting\n * `Record<string, unknown>` into this shape.\n */\nexport interface RemoteCommand {\n id: string;\n sessionId: string;\n pluginId: string;\n type: string;\n payload: Record<string, unknown>;\n status: string;\n createdAt: number;\n}\n\nconst remoteCommandSchema = z.object({\n id: z.string(),\n sessionId: z.string(),\n pluginId: z.string(),\n type: z.string(),\n // The backend may omit `payload` (or send null) for payload-less commands;\n // clients have always normalized that to `{}` — keep that behavior here.\n payload: z.record(z.string(), z.unknown()).nullish(),\n status: z.string(),\n createdAt: z.number(),\n});\n\n/**\n * Validate a raw (already JSON-parsed) value into a `RemoteCommand`.\n * Returns `null` — never throws — on a malformed envelope so callers can\n * log-and-skip the single bad command without dropping the whole batch.\n */\nexport function toRemoteCommand(raw: unknown): RemoteCommand | null {\n const parsed = remoteCommandSchema.safeParse(raw);\n if (!parsed.success) return null;\n const { payload, ...rest } = parsed.data;\n return { ...rest, payload: payload ?? {} };\n}\n","export interface ModelPricing {\n input: number;\n output: number;\n cacheRead: number;\n cacheWrite: number;\n}\n\nexport const MODEL_PRICING: Record<string, ModelPricing> = {\n // ── Anthropic / Claude ────────────────────────────────────\n // The 4.x rows below cover the model ids actually emitted by the CLI\n // (apps/cli/src/agents/claude/runtime.ts listModels) and the JetBrains\n // fallback catalog (RemoteCommandRouter.kt). Prices are copied from the\n // same-family base rows (claude-opus-4 / claude-sonnet-4 /\n // claude-3-5-haiku) until distinct published rates land.\n 'claude-opus-4-7': { input: 15, output: 75, cacheRead: 1.50, cacheWrite: 18.75 },\n 'claude-opus-4-6': { input: 15, output: 75, cacheRead: 1.50, cacheWrite: 18.75 },\n 'claude-sonnet-4-6': { input: 3, output: 15, cacheRead: 0.30, cacheWrite: 3.75 },\n // Haiku-tier prices copied from claude-3-5-haiku (closest same-tier\n // sibling in this table) — previously this id matched NO row and was\n // silently billed at sonnet rates via the unknown-model fallback.\n 'claude-haiku-4-5': { input: 0.80, output: 4, cacheRead: 0.08, cacheWrite: 1 },\n 'claude-sonnet-4': { input: 3, output: 15, cacheRead: 0.30, cacheWrite: 3.75 },\n 'claude-opus-4': { input: 15, output: 75, cacheRead: 1.50, cacheWrite: 18.75 },\n 'claude-3-5-sonnet': { input: 3, output: 15, cacheRead: 0.30, cacheWrite: 3.75 },\n 'claude-3-5-haiku': { input: 0.80, output: 4, cacheRead: 0.08, cacheWrite: 1 },\n 'claude-3-haiku': { input: 0.25, output: 1.25, cacheRead: 0.03, cacheWrite: 0.30 },\n\n // ── Codex / OpenAI ────────────────────────────────────────\n // GPT-5.x rows are derived from OpenAI's published GPT-5 family rates\n // (standard tier: $1.25/1M in, $10/1M out, cached input at ~10% of input;\n // mini tier: $0.25/1M in, $2/1M out). OpenAI has no separate cache-WRITE\n // premium, so cacheWrite mirrors the input rate. Replace with the exact\n // per-version numbers from developers.openai.com/pricing when published —\n // these were the ZERO placeholders that rendered Codex sessions as $0.\n 'gpt-5.5': { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 1.25 },\n 'gpt-5.4': { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 1.25 },\n 'gpt-5.4-mini': { input: 0.25, output: 2, cacheRead: 0.025, cacheWrite: 0.25 },\n 'gpt-5.3-codex': { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 1.25 },\n 'gpt-5.2': { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 1.25 },\n 'codex-auto-review': { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 1.25 },\n};\n\nexport const MODEL_CONTEXT_WINDOW: Record<string, number> = {\n // ── Anthropic / Claude ────────────────────────────────────\n 'claude-opus-4-7': 1_000_000,\n 'claude-opus-4-6': 1_000_000,\n 'claude-sonnet-4-6': 1_000_000,\n 'claude-haiku-4-5': 200_000,\n 'claude-opus-4': 1_000_000,\n 'claude-sonnet-4': 1_000_000,\n 'claude-3-5-sonnet': 200_000,\n 'claude-3-5-haiku': 200_000,\n 'claude-3-haiku': 200_000,\n\n // ── Codex / OpenAI ────────────────────────────────────────\n 'gpt-5.5': 272_000,\n 'gpt-5.4': 272_000,\n 'gpt-5.4-mini': 272_000,\n 'gpt-5.3-codex': 272_000,\n 'gpt-5.2': 272_000,\n 'codex-auto-review': 272_000,\n};\n\nconst DEFAULT_CONTEXT_WINDOW = 200_000;\n\n/**\n * Longest-prefix lookup. The tables key by model-family prefix; a model id\n * like `claude-opus-4-7` must resolve to its own row, not be shadowed by the\n * shorter `claude-opus-4` — so the match is by prefix LENGTH, never by the\n * table's insertion order.\n */\nfunction longestPrefixMatch<T>(table: Record<string, T>, model: string): T | undefined {\n let best: T | undefined;\n let bestLen = -1;\n for (const [prefix, value] of Object.entries(table)) {\n if (prefix.length > bestLen && model.startsWith(prefix)) {\n best = value;\n bestLen = prefix.length;\n }\n }\n return best;\n}\n\n/** True when the model id resolves to a real MODEL_PRICING row (i.e. getPricing\n * will NOT be guessing via the unknown-model fallback). */\nexport function isKnownModel(model: string): boolean {\n return longestPrefixMatch(MODEL_PRICING, model) !== undefined;\n}\n\n/**\n * Flagged default for an unpriced model id. All-zero so an unknown model is\n * VISIBLY unpriced ($0) rather than silently MISPRICED at some other family's\n * rates (the old sonnet-4 fallback billed unknown ids — including a haiku id\n * that matched no row — at sonnet rates). `getPricing` returns this object for\n * unknown ids so callers that do unconditional arithmetic still work; callers\n * that must distinguish real pricing from the default check `isKnownModel`.\n */\nexport const UNKNOWN_MODEL_PRICING: ModelPricing = {\n input: 0,\n output: 0,\n cacheRead: 0,\n cacheWrite: 0,\n};\n\n/**\n * Resolve pricing by longest matching prefix. Unknown models resolve to the\n * flagged {@link UNKNOWN_MODEL_PRICING} default (all-zero, i.e. visibly\n * unpriced) instead of guessing at another model's rates. Callers that need to\n * distinguish real pricing from the default must check `isKnownModel(model)`.\n */\nexport function getPricing(model: string): ModelPricing {\n return longestPrefixMatch(MODEL_PRICING, model) ?? UNKNOWN_MODEL_PRICING;\n}\n\nexport function getContextWindow(model: string | null): number {\n if (!model) return DEFAULT_CONTEXT_WINDOW;\n return longestPrefixMatch(MODEL_CONTEXT_WINDOW, model) ?? DEFAULT_CONTEXT_WINDOW;\n}\n","import type { AgentId, AgentMetadata } from './types';\n\nexport const AGENT_REGISTRY: Record<AgentId, AgentMetadata> = {\n claude: {\n id: 'claude',\n displayName: 'Claude Code',\n binaryName: 'claude',\n enabled: true,\n // Mirrors the backend registry (codeagent-mobile\n // apps/api-v2/src/codespaces/agent.ts — authoritative for auth\n // capabilities). `setup_token` is the bare `sk-ant-oat01-…` from\n // `claude setup-token` → delivered via CLAUDE_CODE_OAUTH_TOKEN.\n supportedAuthKinds: ['setup_token', 'oauth_token', 'api_key'],\n preferredAuthKind: 'setup_token',\n headroomWrappable: true,\n headroomKind: 'claude',\n // npm adapter `@agentclientprotocol/claude-agent-acp`.\n acp: true,\n },\n codex: {\n id: 'codex',\n displayName: 'Codex CLI',\n binaryName: 'codex',\n enabled: true,\n supportedAuthKinds: ['oauth_token', 'api_key'],\n preferredAuthKind: 'oauth_token',\n headroomWrappable: true,\n headroomKind: 'codex',\n // npm adapter `@agentclientprotocol/codex-acp`.\n acp: true,\n // OAuth device-code flow; the user_code on the OpenAI page IS a real\n // human-typed code — surfaces render it (with a copy affordance).\n deviceFlow: true,\n showsUserCode: true,\n },\n copilot: {\n id: 'copilot',\n displayName: 'GitHub Copilot CLI',\n binaryName: 'gh',\n enabled: false,\n supportedAuthKinds: ['oauth_token'],\n preferredAuthKind: 'oauth_token',\n // `headroom init --global copilot` exists even though the agent is\n // still disabled here (no runtime builder yet).\n headroomWrappable: true,\n headroomKind: 'copilot',\n acp: false,\n },\n coderabbit: {\n id: 'coderabbit',\n displayName: 'CodeRabbit',\n binaryName: 'coderabbit',\n enabled: true,\n // Backend registry is authoritative: CodeRabbit links via a real\n // API key only (no OAuth flow exists in api-v2).\n supportedAuthKinds: ['api_key'],\n preferredAuthKind: 'api_key',\n headroomWrappable: false,\n // Legacy PTY runtime — no ACP adapter registered.\n acp: false,\n },\n cursor: {\n id: 'cursor',\n displayName: 'Cursor Agent',\n binaryName: 'cursor-agent',\n enabled: true,\n // Backend registry is authoritative: since the Cursor OAuth\n // device-flow shipped, new links are oauth_token only (the login\n // blob written to ~/.config/cursor/auth.json). Legacy vaulted\n // api_key rows may still exist server-side, but the link surface\n // no longer offers api_key.\n supportedAuthKinds: ['oauth_token'],\n preferredAuthKind: 'oauth_token',\n // `headroom wrap cursor` is \"manual/print-only\" (IDE settings; the\n // headless cursor-agent CLI has no base-URL override) — runs native.\n headroomWrappable: false,\n // Native ACP server: `cursor-agent acp`.\n acp: true,\n // Reverse-engineered device/poll flow; `userCode` is the secret PKCE\n // verifier echoed back on poll — NEVER human-facing.\n deviceFlow: true,\n showsUserCode: false,\n },\n aider: {\n id: 'aider',\n displayName: 'Aider',\n binaryName: 'aider',\n enabled: true,\n // Aider is OAuth-less — auth is via ANTHROPIC_API_KEY / OPENAI_API_KEY\n // / etc. env vars or `~/.aider.conf.yml`. The link flow surfaces\n // this via the existing --api-key escape hatch in commands/link.ts.\n supportedAuthKinds: ['api_key'],\n preferredAuthKind: 'api_key',\n headroomWrappable: false,\n // Legacy PTY runtime — no ACP adapter registered.\n acp: false,\n },\n gemini: {\n id: 'gemini',\n displayName: 'Gemini CLI',\n binaryName: 'gemini',\n enabled: true,\n // OAuth via `gemini auth login` (captured by `codeam link gemini`\n // from ~/.gemini/oauth_creds.json) AND GEMINI_API_KEY are both\n // accepted by the backend's GeminiProvisioningStrategy and propagated\n // into codespace deploys.\n supportedAuthKinds: ['oauth_token', 'api_key'],\n preferredAuthKind: 'oauth_token',\n // Not listed by `headroom wrap --help` — runs native.\n headroomWrappable: false,\n // Native ACP server: `gemini --skip-trust --acp`.\n acp: true,\n },\n kimi: {\n id: 'kimi',\n displayName: 'Kimi Code',\n binaryName: 'kimi',\n enabled: true,\n // API key (KIMI_API_KEY, + optional KIMI_BASE_URL) is the shipping auth —\n // fully documented, no reverse-engineering. OAuth `/login` (login-state at\n // ~/.kimi-code/credentials/<name>.json, base https://api.kimi.com/coding/)\n // is declared so it can land later without a wire change, but capturing\n // that blob server-side is a separate reverse-engineering spike (phase 2).\n supportedAuthKinds: ['api_key', 'oauth_token'],\n preferredAuthKind: 'api_key',\n // Moonshot's `kimi` is not listed by `headroom wrap --help` — runs native.\n headroomWrappable: false,\n // Native ACP server: `kimi acp` (stdio JSON-RPC, answers `initialize`).\n acp: true,\n },\n};\n\nexport function getEnabledAgents(): AgentMetadata[] {\n return Object.values(AGENT_REGISTRY).filter(m => m.enabled);\n}\n\nexport function getAgent(id: AgentId): AgentMetadata {\n const meta = AGENT_REGISTRY[id];\n if (!meta) throw new Error(`Unknown agent id: ${id}`);\n return meta;\n}\n\nexport function isKnownAgentId(id: string): id is AgentId {\n return id in AGENT_REGISTRY;\n}\n","/**\n * Agent identity — the ONE place the public (`LinkedAgentId`) and internal\n * (`AgentId`) id spaces are declared and bridged, plus the ONE alias\n * normalizer every surface funnels through.\n *\n * Canonical values consolidated from (Phase 2, PR-1):\n * - backend `apps/api-v2/src/linked-agents/agent-map.ts`\n * (`PUBLIC_TO_INTERNAL` / `INTERNAL_TO_PUBLIC` / `LinkedAgentId`),\n * - CLI `apps/cli/src/commands/host/agent-provisioning.ts`\n * (`PUBLIC_TO_INTERNAL_AGENT`),\n * - VS Code plugin `apps/vsc-plugin/src/utils/cli-agent-id.ts`\n * (marketplace aliases + `__terminal__:` strip),\n * - CLI `apps/cli/src/commands/start/handlers.ts`\n * (the `claude_code` → `claude` normalization),\n * - mobile `apps/mobile/src/lib/agent-id-map.ts`.\n */\n\nimport type { AgentId, HeadroomKind } from './types';\nimport { AGENT_REGISTRY, isKnownAgentId } from './registry';\n\n// ─── House agent constants ───────────────────────────────────────────────────\n// Byte-identical mirrors of the backend repo's canonical\n// `codeagent-mobile/packages/shared/src/constants/house-agent.ts` (which the\n// api-v2 additionally hand-mirrors in `common/constants/house-agent.ts`).\n// PR-3 replaces those copies with re-exports of THESE.\n\n/** Sentinel id for the synthetic \"CodeAgent Cloud (incluido)\" house agent. */\nexport const HOUSE_AGENT_ID = 'house-codeagent-cloud';\n\n/** Internal provider discriminator for the house agent. */\nexport const HOUSE_AGENT_PROVIDER = 'codeagent_cloud';\n\n/** White-label display strings — never mention the backend model. */\nexport const HOUSE_AGENT_NAME = 'CodeAgent Cloud';\nexport const HOUSE_AGENT_VENDOR = 'CodeAgent';\nexport const HOUSE_AGENT_SUBTITLE = 'Included — no setup';\n\n// ─── Public (LinkedAgent) id space ───────────────────────────────────────────\n\n/**\n * Public-facing linked-agent ids — the id space the `/api/agents/...`\n * endpoints and the mobile/web surfaces speak. The internal `AgentId`\n * (`'claude' | 'codex' | …`) is what the runtimes / provisioning key on.\n */\nexport type LinkedAgentId =\n | 'claude_code'\n | 'codex'\n | 'cursor'\n | 'aider'\n | 'coderabbit'\n | 'gemini'\n | 'kimi'\n | typeof HOUSE_AGENT_ID;\n\nexport const LINKED_AGENT_IDS: readonly LinkedAgentId[] = [\n 'claude_code',\n 'codex',\n 'cursor',\n 'aider',\n 'coderabbit',\n 'gemini',\n 'kimi',\n HOUSE_AGENT_ID,\n];\n\nexport function isLinkedAgentId(value: string): value is LinkedAgentId {\n return (LINKED_AGENT_IDS as readonly string[]).includes(value);\n}\n\n/**\n * Every public id → internal `AgentId`.\n *\n * ⚠️ RECONCILED ASYMMETRY — this map is the UNION of what the two sides\n * historically accepted:\n * - The backend's `agent-map.ts` accepts only the `LinkedAgentId` union\n * (incl. the house agent, whose runtime is Claude Code) — no bare\n * `claude`, no `copilot` (there is no public copilot LinkedAgentId).\n * - The CLI's self-hosted `agent-provisioning.ts` additionally accepts\n * bare `'claude'` and `'copilot'` (deploy payloads have carried\n * already-internal ids), but not the house agent.\n * Consumers that must REJECT ids outside their own historical set keep\n * their own guard on top (e.g. `isLinkedAgentId`).\n */\nexport const PUBLIC_TO_INTERNAL: Readonly<\n Record<LinkedAgentId | 'claude' | 'copilot', AgentId>\n> = {\n claude_code: 'claude',\n // CLI-side extra: self-hosted deploy payloads may carry the internal id.\n claude: 'claude',\n codex: 'codex',\n // CLI-side extra: copilot has no public LinkedAgentId (backend doesn't\n // expose it) but the self-hosted path accepts it.\n copilot: 'copilot',\n cursor: 'cursor',\n aider: 'aider',\n coderabbit: 'coderabbit',\n gemini: 'gemini',\n kimi: 'kimi',\n // The house agent runs Claude Code under the hood (pointed at the\n // MiniMax proxy). Its internal runtime is therefore `claude`.\n [HOUSE_AGENT_ID]: 'claude',\n};\n\n/**\n * Internal → public. Partial: `copilot` has no public LinkedAgentId, and\n * `claude` maps back to `claude_code` (never the house agent — that\n * direction is intentionally lossy).\n */\nexport const INTERNAL_TO_PUBLIC: Readonly<Partial<Record<AgentId, LinkedAgentId>>> = {\n claude: 'claude_code',\n codex: 'codex',\n cursor: 'cursor',\n aider: 'aider',\n coderabbit: 'coderabbit',\n gemini: 'gemini',\n kimi: 'kimi',\n};\n\nfunction isPublicToInternalKey(v: string): v is LinkedAgentId | 'claude' | 'copilot' {\n // Not Object.hasOwn — the VS Code plugin's tsconfig lib predates ES2022.\n return Object.prototype.hasOwnProperty.call(PUBLIC_TO_INTERNAL, v);\n}\n\n/** Resolve a public/linked id to the internal `AgentId`, or null. */\nexport function publicToInternal(publicId: string): AgentId | null {\n return isPublicToInternalKey(publicId) ? PUBLIC_TO_INTERNAL[publicId] : null;\n}\n\n/** Resolve an internal `AgentId` to its public `LinkedAgentId`, or null. */\nexport function internalToPublic(internal: AgentId): LinkedAgentId | null {\n return INTERNAL_TO_PUBLIC[internal] ?? null;\n}\n\n// ─── Alias normalization ─────────────────────────────────────────────────────\n\n/** Prefix IDE plugins use for terminal-hosted agent ids. */\nexport const TERMINAL_AGENT_PREFIX = '__terminal__:';\n\n/**\n * Known aliases → internal `AgentId`. Union of every alias set that used\n * to live scattered across the surfaces: the public `claude_code` id, the\n * VS Code / Open VSX marketplace extension ids, and JetBrains plugin ids.\n */\nconst AGENT_ID_ALIASES: Readonly<Record<string, AgentId>> = {\n claude_code: 'claude',\n 'claude-code': 'claude',\n 'anthropic.claude-code': 'claude',\n 'anthropics.claude': 'claude',\n 'anthropic.claude-ce': 'claude',\n 'anthropic.claude': 'claude',\n 'com.anthropic.claudecode': 'claude',\n 'com.anthropic.claude': 'claude',\n 'openai.chatgpt': 'codex',\n 'coderabbitai.coderabbit-vscode': 'coderabbit',\n};\n\n/**\n * THE agent-id normalizer. Collapses every known spelling of an agent id\n * (registry id, public `claude_code` form, marketplace extension id,\n * `__terminal__:`-prefixed plugin id — case/whitespace tolerant) onto the\n * internal `AgentId`, or `null` when unknown.\n *\n * Deliberately does NOT:\n * - gate on `enabled` (callers that need availability check the\n * registry — see the VS Code wrapper `normalizeCliAgentId`);\n * - map the house agent (that's a runtime substitution, not an alias —\n * use {@link publicToInternal});\n * - fall back to anything. Unknown in → `null` out.\n */\nexport function normalizeAgentId(raw: string): AgentId | null {\n const value = (raw ?? '').trim().toLowerCase();\n if (!value) return null;\n\n if (isKnownAgentId(value)) return value;\n\n const unprefixed = value.startsWith(TERMINAL_AGENT_PREFIX)\n ? value.slice(TERMINAL_AGENT_PREFIX.length)\n : value;\n if (isKnownAgentId(unprefixed)) return unprefixed;\n\n return AGENT_ID_ALIASES[unprefixed] ?? null;\n}\n\n// ─── Headroom kind derivation ────────────────────────────────────────────────\n\n/**\n * The `headroom init --global <kind>` subcommand for an agent id, derived\n * from the registry's `headroomKind` flags — or `null` for unknown or\n * non-wrappable agents (cursor / gemini / aider / anything else).\n *\n * ⚠️ NEVER falls back to `'claude'`. The historical CLI fallback is how\n * the 2026-06 Cursor incident happened: an unsupported agent slipped\n * through, defaulted to `claude`, and `headroom wrap claude` launched\n * Claude Code instead of the user's agent. Callers that genuinely need a\n * default (e.g. picking an init subcommand AFTER the wrappable gate has\n * already passed) apply it themselves — see the CLI's\n * `agentIdToHeadroomKind` wrapper.\n *\n * Matching mirrors the historical predicates on BOTH sides (CLI\n * `isHeadroomSupportedAgent`, api-v2 `isHeadroomWrappableAgent`):\n * case-insensitive, `_`/`-` tolerant, prefix match — so `claude_code`,\n * `Claude-Code`, `codex_cli`, `copilot-cli` all resolve.\n */\nexport function headroomKindFor(agentId: string): HeadroomKind | null {\n const normalized = (agentId ?? '').toLowerCase().replace(/[_-]/g, '');\n if (!normalized) return null;\n for (const meta of Object.values(AGENT_REGISTRY)) {\n if (meta.headroomKind !== undefined && normalized.startsWith(meta.id)) {\n return meta.headroomKind;\n }\n }\n return null;\n}\n\n/**\n * Registry-derived replacement for the two scattered predicates\n * (`isHeadroomSupportedAgent` in the CLI, `isHeadroomWrappableAgent` in\n * api-v2). Accepts both id spaces (`claude_code` and `claude`).\n */\nexport function isHeadroomWrappable(agentId: string): boolean {\n return headroomKindFor(agentId) !== null;\n}\n","/**\n * Production API base URL for all CodeAgent Mobile clients.\n *\n * History note: prod migrated from Vercel (`https://api.codeagent-mobile.com`)\n * to Cloud Run / api-v2 (`https://api.codeagent-mobile.com`) in 2026-05. The\n * Vercel deployment is now gated by Vercel deployment protection and returns\n * 403 for unauthed traffic — DO NOT fall back to it.\n *\n * Override at runtime with `CODEAM_API_URL` (full URL override) OR set\n * `CODEAM_TEST_MODE=1` to point every client request at the dev\n * preview without having to know its host.\n */\nexport const DEFAULT_API_BASE_URL = 'https://api.codeagent-mobile.com' as const;\n\n/**\n * Dev-preview API base URL. Same Cloud Run service as prod but routed\n * to the `dev` revision (auto-deploys from the `dev` branch in the\n * backend repo). Manual smoke tests + load runs land here.\n */\nexport const DEV_API_BASE_URL = 'https://dev-api.codeagent-mobile.com' as const;\n\n/**\n * Resolve the active API base URL, honoring in priority order:\n *\n * 1. Explicit `CODEAM_API_URL` env var — full URL, takes precedence.\n * 2. `CODEAM_TEST_MODE=1` shortcut — flips to [DEV_API_BASE_URL]\n * without the user having to know the dev host.\n * 3. The `DEFAULT_API_BASE_URL` constant (prod).\n *\n * Used by every CLI service that talks to the backend so one env var\n * flips heartbeats, command relay, chunk uploads, and the pairing\n * flow in lockstep — eliminates the cross-environment misroute where\n * pairing succeeds in dev (shared Redis) but the CLI keeps\n * heartbeating to prod.\n */\nexport function resolveApiBaseUrl(): string {\n // Guard against non-Node runtimes (browser bundles import this\n // module). `process` is undefined there; treat as prod default.\n // `@codeam/shared` deliberately avoids depending on `@types/node`\n // so its types stay consumable from the mobile RN bundle too, so we\n // reach for the env via a structural cast rather than NodeJS.ProcessEnv.\n const env = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process?.env;\n const explicit = env?.CODEAM_API_URL?.trim();\n if (explicit) return explicit;\n const testFlag = env?.CODEAM_TEST_MODE?.trim();\n if (testFlag === '1' || testFlag?.toLowerCase() === 'true') return DEV_API_BASE_URL;\n return DEFAULT_API_BASE_URL;\n}\n","/**\n * Headroom provisioning manifest — the SINGLE source of truth for what a\n * Headroom install consists of, rendered by every provisioning surface:\n *\n * - codespace bootstrap (bash composer in the backend repo,\n * `apps/api-v2/src/codespaces/github-ssh.service.ts` — adopts in PR-2),\n * - self-hosted deploy (TS installer, CLI `commands/host-agent.ts`\n * `setupHeadroomForSelfHosted`),\n * - on-demand local sessions (\"Session add-ons → Cost-saving\", CLI\n * `services/headroom/configure.ts`).\n *\n * Values are DATA-first (arrays/records, plus tiny pure renderers) so both\n * the TS installer and a bash composer can interpolate from them. Renderers\n * are byte-exact with the literals they replaced — guarded by\n * `packages/shared/__tests__/headroom-manifest.test.ts`.\n *\n * ⚠️ The extras matter: `[proxy,code]` pulls the ONNX compression engines\n * (Kompress + tree-sitter CodeCompressor). NEVER add `[ml]` — that's\n * multi-GB PyTorch, and a broken/cold torch wedges every prompt at\n * \"Thinking…\". The models are pre-downloaded at provision time because the\n * proxy eager-loads with `allow_download=False` and a cold cache defers the\n * ~840 MB download to the first prompt (blowing the agent's ~90 s idle\n * timeout).\n */\n\n/** Local proxy port the agent's config is routed to. */\nexport const HEADROOM_PROXY_PORT = 8787;\n\n/**\n * Env that pins the ONNX backend on the proxy process — never imports\n * torch. Spread into the proxy launch env on every surface.\n */\nexport const HEADROOM_BACKEND_ENV = {\n HEADROOM_KOMPRESS_BACKEND: 'onnx_cpu',\n} as const;\n\n/**\n * The proxy's HTTP/server companion packages, installed alongside the\n * `headroom-ai[...]` package. The COMPRESSION ENGINES come from the\n * headroom-ai extras — NOT this list.\n */\nexport const HEADROOM_PIP_COMPANIONS: readonly string[] = [\n 'fastapi',\n 'uvicorn',\n 'httpx[http2]',\n 'websockets',\n 'zstandard',\n];\n\n/** The three provisioning surfaces (see module doc). */\nexport type HeadroomSurface = 'codespace' | 'selfHosted' | 'onDemand';\n\n/**\n * pip extras per surface. `onDemand` additionally ships `image`\n * (image-compression support, added with the Session add-ons path in\n * codeam-cli@2.49.0); the older codespace/self-hosted install strings\n * remain `[proxy,code]` byte-for-byte.\n */\nexport const HEADROOM_EXTRAS_BY_SURFACE: Readonly<Record<HeadroomSurface, readonly string[]>> = {\n codespace: ['proxy', 'code'],\n selfHosted: ['proxy', 'code'],\n onDemand: ['proxy', 'code', 'image'],\n};\n\n/** `headroom-ai[<extras>]` — the pip requirement string. */\nexport function headroomPipPackage(extras: readonly string[]): string {\n return `headroom-ai[${extras.join(',')}]`;\n}\n\n/** One HuggingFace repo to pre-warm into the HF cache at provision time. */\nexport interface HeadroomModelSpec {\n repo: string;\n /** `snapshot_download(..., allow_patterns=[…])` filter. */\n allowPatterns: readonly string[];\n}\n\n/**\n * The two HF repos Kompress needs. kompress-v2-base is the ONNX model\n * (skip its .pt/.safetensors torch artifacts); ModernBERT-base is the\n * TOKENIZER ONLY (skip its model weights).\n */\nexport const HEADROOM_MODELS: readonly HeadroomModelSpec[] = [\n {\n repo: 'chopratejas/kompress-v2-base',\n allowPatterns: ['*.json', 'onnx/*.onnx', 'kompress-int8-wo.onnx'],\n },\n {\n repo: 'answerdotai/ModernBERT-base',\n allowPatterns: ['*.json', 'tokenizer*', '*.txt', 'vocab*', 'merges*'],\n },\n];\n\n/** Formatting knob so each surface can stay byte-identical to its\n * historical literal (the CLI joins patterns with `,`, the codespace\n * bash composer with `, `). */\nexport interface HeadroomPythonRenderOpts {\n /** Put a space after the commas between allow_patterns entries. */\n spaceAfterComma?: boolean;\n}\n\n/** Render one `snapshot_download(...)` python line for a model. */\nexport function headroomSnapshotDownloadLine(\n model: HeadroomModelSpec,\n opts: HeadroomPythonRenderOpts = {},\n): string {\n const sep = opts.spaceAfterComma ? ', ' : ',';\n const patterns = model.allowPatterns.map((p) => `\"${p}\"`).join(sep);\n return `snapshot_download(\"${model.repo}\", allow_patterns=[${patterns}])`;\n}\n\n/**\n * The full model pre-download python snippet (import + one\n * `snapshot_download` per model), newline-joined — what the surfaces pass\n * to `python -c` / a heredoc.\n */\nexport function headroomModelPredownloadScript(opts: HeadroomPythonRenderOpts = {}): string {\n return [\n 'from huggingface_hub import snapshot_download',\n ...HEADROOM_MODELS.map((m) => headroomSnapshotDownloadLine(m, opts)),\n ].join('\\n');\n}\n","/**\n * Canonical names of the per-user SSE bus events (`/api/users/me/stream`).\n *\n * The authoritative list is the `UserEvent` discriminated union in the\n * backend repo: codeagent-mobile/apps/api-v2/src/user-events/user-events.types.ts.\n * Every `type:` literal of that union appears here exactly once — when a new\n * variant lands on the union, add its name here (and in the backend mirror of\n * this file at codeagent-mobile/packages/shared/src/types/events.ts).\n *\n * Producers (CLI event posts, backend `userEvents.publish` calls) and\n * consumers (the `useUserEventsSSE` hooks' switch cases) should reference\n * `USER_EVENTS.*` instead of re-typing the string, so a typo becomes a\n * compile error instead of a silently dropped event.\n */\nexport const USER_EVENTS = {\n PAIRED_SESSION_STATUS: 'paired_session_status',\n PAIRED_SESSION_ADDED: 'paired_session_added',\n PAIRED_SESSION_REMOVED: 'paired_session_removed',\n PAIRED_SESSION_BRANCH_CHANGED: 'paired_session_branch_changed',\n SHARED_WITH_ME_ADDED: 'shared_with_me_added',\n SHARED_WITH_ME_REVOKED: 'shared_with_me_revoked',\n USAGE_CHANGED: 'usage_changed',\n TASK_DONE: 'task_done',\n HUNK_PENDING_REVIEW_ADDED: 'hunk_pending_review_added',\n HUNK_REVIEW_RESOLVED: 'hunk_review_resolved',\n FILE_CHANGED: 'file_changed',\n FILES_BATCH_CHANGED: 'files_batch_changed',\n AGENT_STREAMING_CHUNK: 'agent_streaming_chunk',\n AGENT_AWAITING_ANSWER: 'agent_awaiting_answer',\n AWAITING_INPUT_ADDED: 'awaiting_input_added',\n AGENT_ANSWER_RESOLVED: 'agent_answer_resolved',\n TEMPLATE_ADDED: 'template_added',\n TEMPLATE_REMOVED: 'template_removed',\n TEMPLATE_UPDATED: 'template_updated',\n AGENT_TASK_DISPATCHED: 'agent_task_dispatched',\n AGENT_TASK_COMPLETED: 'agent_task_completed',\n LINKED_AGENT_ADDED: 'linked_agent_added',\n QUOTA_REACHED: 'quota_reached',\n LINKED_AGENT_LINK_FAILED: 'linked_agent_link_failed',\n CODESPACE_AGENT_INSTALLED: 'codespace_agent_installed',\n AGENT_CREDENTIALS_REFRESHED: 'agent_credentials_refreshed',\n CREDENTIAL_INVALID: 'credential_invalid',\n CODESPACE_WAKING: 'codespace_waking',\n CODESPACE_BILLING_BLOCKED: 'codespace_billing_blocked',\n COST_SAVING_UPDATED: 'cost_saving_updated',\n COMMAND_COMPLETED: 'command_completed',\n AI_SUMMARY_PENDING: 'ai_summary_pending',\n AI_SUMMARY_READY: 'ai_summary_ready',\n AI_INSIGHT_PENDING: 'ai_insight_pending',\n AI_INSIGHT_READY: 'ai_insight_ready',\n PUSH_TOKEN_INVALIDATED: 'push_token_invalidated',\n PREVIEW_DETECTION_PENDING: 'preview_detection_pending',\n PREVIEW_DETECTION_READY: 'preview_detection_ready',\n PREVIEW_STARTING: 'preview_starting',\n PREVIEW_READY: 'preview_ready',\n PREVIEW_STOPPED: 'preview_stopped',\n PREVIEW_ERROR: 'preview_error',\n PREVIEW_PROGRESS: 'preview_progress',\n BEADS_STATE_CHANGED: 'beads_state_changed',\n BEADS_PROVISIONING: 'beads_provisioning',\n BEADS_TEAM_MEMORY_CHANGED: 'beads_team_memory_changed',\n AUDIT_EVENT_ADDED: 'audit_event_added',\n SELF_HOSTED_HOST_ADDED: 'self_hosted_host_added',\n SELF_HOSTED_HOST_STATUS: 'self_hosted_host_status',\n SELF_HOSTED_HOST_REMOVED: 'self_hosted_host_removed',\n SELF_HOSTED_HOST_TELEMETRY: 'self_hosted_host_telemetry',\n SELF_HOSTED_HOST_METRICS: 'self_hosted_host_metrics',\n SELF_HOSTED_HOST_SESSIONS: 'self_hosted_host_sessions',\n SELF_HOSTED_DEPLOY_PROGRESS: 'self_hosted_deploy_progress',\n REFERRAL_REWARD_EARNED: 'referral_reward_earned',\n HEADROOM_PROGRESS: 'headroom_progress',\n HEADROOM_STATUS: 'headroom_status',\n BEADS_STATUS: 'beads_status',\n LINKED_AGENT_HEADROOM_BUDGET_UPDATED: 'linked_agent_headroom_budget_updated',\n CLI_UPDATE_AVAILABLE: 'cli_update_available',\n AGENT_INSTALL_PROGRESS: 'agent_install_progress',\n AGENT_INSTALL_FAILED: 'agent_install_failed',\n CLI_UPDATE_PROGRESS: 'cli_update_progress',\n CLI_UPDATE_FAILED: 'cli_update_failed',\n BATON_STATE: 'baton_state',\n} as const;\n\nexport type UserEventName = (typeof USER_EVENTS)[keyof typeof USER_EVENTS];\n","/**\n * Prompt the CLI sends to the user's linked agent (Claude, Codex, …)\n * in a headless one-shot to detect how to start the project's dev\n * server. Same pattern as the AI Insights \"summary\" prompt — the\n * agent runs locally with the user's auth, has read access to the\n * project, and returns a tiny JSON blob the CLI parses.\n *\n * Kept here (in `@codeam/shared`) so the CLI build inlines the\n * exact string at compile time without runtime fetch from the backend.\n */\nexport const PREVIEW_DETECT_PROMPT = `\nAnalyze the project in the current working directory and return how to start\nits development server for in-app preview.\n\nRead package.json, Procfile, Dockerfile, docker-compose.yml, manage.py, app.json,\nmix.exs, Cargo.toml, go.mod, requirements.txt, Gemfile, and any other framework\nmarkers you find at depth <= 2.\n\nReturn ONLY a JSON object on stdout (no prose, no markdown fences):\n\n{\n \"framework\": \"<name, or 'unsupported'>\",\n \"command\": \"<executable>\",\n \"args\": [\"...\"],\n \"port\": <number>,\n \"ready_pattern\": \"<regex matching the server-ready stdout line>\",\n \"env\": { \"HOST\": \"0.0.0.0\" },\n \"setup_commands\": [{ \"cmd\": \"<executable>\", \"args\": [\"...\"] }],\n \"notes\": \"<one-line caveat or null>\"\n}\n\nRules:\n- Pick the script the developer would run locally to see the app (typically \"dev\", \"start\", \"serve\").\n- Prefer binding to 0.0.0.0 — most frameworks default to localhost which the tunnel cannot reach.\n- For Expo: framework=\"Expo\", command=\"npx\", args=[\"expo\",\"start\",\"--tunnel\"], port=8081, notes=\"Scan QR with Expo Go\".\n- If no dev server applies (CLI library, lambda, batch script): {\"framework\":\"unsupported\",\"notes\":\"<reason>\"}.\n\nCRITICAL — setup_commands:\n- DO NOT include an install command (npm install, pnpm install, yarn install,\n yarn, bun install) in setup_commands. A lockfile-aware pre-flight installer\n runs BEFORE setup_commands and picks the correct package manager from the\n lockfile present (pnpm-lock.yaml -> pnpm, yarn.lock -> yarn, bun.lockb -> bun,\n else npm). Emitting an install here either duplicates that work or, worse,\n uses the WRONG package manager on top of node_modules just populated by the\n pre-flight, which crashes (e.g. npm errors with \"Cannot read properties of\n null (reading 'matches')\" when run over pnpm's .pnpm/ layout).\n- ONLY include setup_commands for genuinely non-install work the project needs\n before its dev server can boot: prisma generate, codegen, prebuild scripts,\n database migrations against a local SQLite, etc.\n- Each setup_commands entry MUST be an object {\"cmd\": \"...\", \"args\": [\"...\"]} —\n e.g. {\"cmd\": \"npx\", \"args\": [\"prisma\", \"generate\"]}. NOT a bare string.\n- For most projects, setup_commands should be an empty array [].\n\nOUTPUT JSON ONLY. NO MARKDOWN. NO COMMENTARY.\n`.trim();\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACiBO,IAAM,mBAAmB;AAezB,IAAM,uBAAuB;AAS7B,IAAM,gCAAgC;AAOtC,IAAM,wBAAwB;;;ACvC9B,SAAS,cAAc,KAAuB;AACnD,QAAM,SAAmB,CAAC,EAAE;AAC5B,MAAI,MAAM;AACV,MAAI,M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B,aAAa;AACf;;;ACtEO,IAAM,wBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA4CnC,KAAK;","names":[]}
package/dist/index.mjs CHANGED
@@ -324,6 +324,23 @@ var AGENT_REGISTRY = {
324
324
  headroomWrappable: false,
325
325
  // Native ACP server: `gemini --skip-trust --acp`.
326
326
  acp: true
327
+ },
328
+ kimi: {
329
+ id: "kimi",
330
+ displayName: "Kimi Code",
331
+ binaryName: "kimi",
332
+ enabled: true,
333
+ // API key (KIMI_API_KEY, + optional KIMI_BASE_URL) is the shipping auth —
334
+ // fully documented, no reverse-engineering. OAuth `/login` (login-state at
335
+ // ~/.kimi-code/credentials/<name>.json, base https://api.kimi.com/coding/)
336
+ // is declared so it can land later without a wire change, but capturing
337
+ // that blob server-side is a separate reverse-engineering spike (phase 2).
338
+ supportedAuthKinds: ["api_key", "oauth_token"],
339
+ preferredAuthKind: "api_key",
340
+ // Moonshot's `kimi` is not listed by `headroom wrap --help` — runs native.
341
+ headroomWrappable: false,
342
+ // Native ACP server: `kimi acp` (stdio JSON-RPC, answers `initialize`).
343
+ acp: true
327
344
  }
328
345
  };
329
346
  function getEnabledAgents() {
@@ -351,6 +368,7 @@ var LINKED_AGENT_IDS = [
351
368
  "aider",
352
369
  "coderabbit",
353
370
  "gemini",
371
+ "kimi",
354
372
  HOUSE_AGENT_ID
355
373
  ];
356
374
  function isLinkedAgentId(value) {
@@ -368,6 +386,7 @@ var PUBLIC_TO_INTERNAL = {
368
386
  aider: "aider",
369
387
  coderabbit: "coderabbit",
370
388
  gemini: "gemini",
389
+ kimi: "kimi",
371
390
  // The house agent runs Claude Code under the hood (pointed at the
372
391
  // MiniMax proxy). Its internal runtime is therefore `claude`.
373
392
  [HOUSE_AGENT_ID]: "claude"
@@ -378,7 +397,8 @@ var INTERNAL_TO_PUBLIC = {
378
397
  cursor: "cursor",
379
398
  aider: "aider",
380
399
  coderabbit: "coderabbit",
381
- gemini: "gemini"
400
+ gemini: "gemini",
401
+ kimi: "kimi"
382
402
  };
383
403
  function isPublicToInternalKey(v) {
384
404
  return Object.prototype.hasOwnProperty.call(PUBLIC_TO_INTERNAL, v);
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/protocol/constants.ts","../src/protocol/renderToLines.ts","../src/protocol/remote-command.ts","../src/models/pricing.ts","../src/agents/registry.ts","../src/agents/identity.ts","../src/api-url.ts","../src/headroom/manifest.ts","../src/types/events.ts","../src/preview-prompts.ts"],"sourcesContent":["/**\n * Shared wire / lifecycle constants. The values here are bundled\n * into the CLI + VS Code extension at build time via tsup / esbuild\n * and mirrored in `apps/jetbrains-plugin/.../protocol/Constants.kt`\n * since Kotlin can't import an npm package.\n *\n * If you change one of these values, also update the Kotlin mirror.\n */\n\n/**\n * Discriminated chunk-protocol version sent as the\n * `X-Codeam-Protocol-Version` header on every authed request. The\n * backend uses this to opt into legacy translations or to reject\n * with 426 when the client is too far behind. Bumped in lockstep\n * with chunk-shape changes (e.g. when the `chrome_steps` chunk\n * type is added).\n */\nexport const PROTOCOL_VERSION = '2.0.0' as const;\n\n/**\n * The VS Code AgentOutputMonitor's loopback HTTP server bound to\n * 127.0.0.1 on this port — the observer JS in the IDE renderer\n * uses it to round-trip captured chat content back into the\n * extension host. The port is intentionally fixed (rather than\n * `listen(0)`) so the observer script can be a static constant\n * rather than dynamically rewriting itself per session.\n *\n * Multi-window collision is solved by listen(0) per-window in the\n * monitor (see #103); this default is still the documented\n * starting port for tooling that needs to probe whether a CodeAgent\n * Mobile session is active locally.\n */\nexport const OBSERVER_BRIDGE_PORT = 47832;\n\n/**\n * Default plugin → backend heartbeat interval. User-configurable\n * via `codeagent-mobile.heartbeatIntervalMs` on VS Code and\n * `heartbeatIntervalMs` in SettingsService.kt's @State on JetBrains.\n * Mirrors the value the apps/api side uses to flip the paired\n * session to offline.\n */\nexport const HEARTBEAT_INTERVAL_MS_DEFAULT = 30_000;\n\n/**\n * SSE + polling reconnect cap. Vercel's serverless functions close\n * SSE connections after ~25 s by default; the client uses 35 s as\n * its overall socket timeout to leave a beat for graceful close.\n */\nexport const SSE_SOCKET_TIMEOUT_MS = 35_000;\n","/**\n * Render raw PTY bytes into an array of screen lines using a simplified\n * virtual terminal. Handles cursor movements (A/B/C/D/G/H), erase (J/K),\n * alternate-screen (?1049h), carriage return, and LF.\n *\n * This is the authoritative implementation used by both codeam-cli (PTY\n * output) and the VS Code extension (shell-integration output) so that\n * the mobile/web client sees identical chunks regardless of surface.\n */\nexport function renderToLines(raw: string): string[] {\n const screen: string[] = [''];\n let row = 0;\n let col = 0;\n\n function ensureRow(): void {\n while (screen.length <= row) screen.push('');\n }\n\n function writeChar(ch: string): void {\n ensureRow();\n if (col < screen[row].length) {\n screen[row] = screen[row].slice(0, col) + ch + screen[row].slice(col + 1);\n } else {\n while (screen[row].length < col) screen[row] += ' ';\n screen[row] += ch;\n }\n col++;\n }\n\n let i = 0;\n while (i < raw.length) {\n const ch = raw[i];\n\n if (ch === '\\x1B') {\n i++;\n if (i >= raw.length) break;\n\n if (raw[i] === '[') {\n i++;\n let param = '';\n while (i < raw.length && !/[@-~]/.test(raw[i])) param += raw[i++];\n const cmd = raw[i] ?? '';\n const n = parseInt(param) || 1;\n\n if (cmd === 'A') { row = Math.max(0, row - n); }\n else if (cmd === 'B') { row += n; ensureRow(); }\n else if (cmd === 'C') { col += n; }\n else if (cmd === 'D') { col = Math.max(0, col - n); }\n else if (cmd === 'G') { col = Math.max(0, n - 1); }\n else if (cmd === 'H' || cmd === 'f') {\n const p = param.split(';');\n row = Math.max(0, (parseInt(p[0] ?? '1') || 1) - 1);\n col = Math.max(0, (parseInt(p[1] ?? '1') || 1) - 1);\n ensureRow();\n } else if (cmd === 'J') {\n if (param === '2' || param === '3') {\n screen.length = 1; screen[0] = ''; row = 0; col = 0;\n } else if (param === '1') {\n for (let r = 0; r < row; r++) screen[r] = '';\n screen[row] = ' '.repeat(col) + screen[row].slice(col);\n } else {\n screen[row] = screen[row].slice(0, col);\n screen.splice(row + 1);\n }\n } else if (cmd === 'K') {\n ensureRow();\n if (param === '' || param === '0') screen[row] = screen[row].slice(0, col);\n else if (param === '1') screen[row] = ' '.repeat(col) + screen[row].slice(col);\n else if (param === '2') screen[row] = '';\n } else if (cmd === 'h' && (param === '?1049' || param === '?47')) {\n screen.length = 1; screen[0] = ''; row = 0; col = 0;\n } else if (cmd === 'l' && (param === '?1049' || param === '?47')) {\n screen.length = 1; screen[0] = ''; row = 0; col = 0;\n }\n } else if (raw[i] === ']') {\n i++;\n while (i < raw.length) {\n if (raw[i] === '\\x07') break;\n if (raw[i] === '\\x1B' && i + 1 < raw.length && raw[i + 1] === '\\\\') { i++; break; }\n i++;\n }\n }\n } else if (ch === '\\r') {\n if (i + 1 < raw.length && raw[i + 1] === '\\n') {\n row++; col = 0; ensureRow(); i++;\n } else {\n col = 0;\n }\n } else if (ch === '\\n') {\n row++; col = 0; ensureRow();\n } else if (ch >= ' ' || ch === '\\t') {\n writeChar(ch);\n }\n\n i++;\n }\n\n return screen;\n}\n","import { z } from 'zod';\n\n/**\n * The command envelope clients receive from the backend relay — both from\n * the `commands` SSE frames on `/api/commands/pending/stream` and from the\n * `GET /api/commands/pending` polling fallback. One schema, shared, so the\n * VS Code extension (and eventually the CLI) stop blind-casting\n * `Record<string, unknown>` into this shape.\n */\nexport interface RemoteCommand {\n id: string;\n sessionId: string;\n pluginId: string;\n type: string;\n payload: Record<string, unknown>;\n status: string;\n createdAt: number;\n}\n\nconst remoteCommandSchema = z.object({\n id: z.string(),\n sessionId: z.string(),\n pluginId: z.string(),\n type: z.string(),\n // The backend may omit `payload` (or send null) for payload-less commands;\n // clients have always normalized that to `{}` — keep that behavior here.\n payload: z.record(z.string(), z.unknown()).nullish(),\n status: z.string(),\n createdAt: z.number(),\n});\n\n/**\n * Validate a raw (already JSON-parsed) value into a `RemoteCommand`.\n * Returns `null` — never throws — on a malformed envelope so callers can\n * log-and-skip the single bad command without dropping the whole batch.\n */\nexport function toRemoteCommand(raw: unknown): RemoteCommand | null {\n const parsed = remoteCommandSchema.safeParse(raw);\n if (!parsed.success) return null;\n const { payload, ...rest } = parsed.data;\n return { ...rest, payload: payload ?? {} };\n}\n","export interface ModelPricing {\n input: number;\n output: number;\n cacheRead: number;\n cacheWrite: number;\n}\n\nexport const MODEL_PRICING: Record<string, ModelPricing> = {\n // ── Anthropic / Claude ────────────────────────────────────\n // The 4.x rows below cover the model ids actually emitted by the CLI\n // (apps/cli/src/agents/claude/runtime.ts listModels) and the JetBrains\n // fallback catalog (RemoteCommandRouter.kt). Prices are copied from the\n // same-family base rows (claude-opus-4 / claude-sonnet-4 /\n // claude-3-5-haiku) until distinct published rates land.\n 'claude-opus-4-7': { input: 15, output: 75, cacheRead: 1.50, cacheWrite: 18.75 },\n 'claude-opus-4-6': { input: 15, output: 75, cacheRead: 1.50, cacheWrite: 18.75 },\n 'claude-sonnet-4-6': { input: 3, output: 15, cacheRead: 0.30, cacheWrite: 3.75 },\n // Haiku-tier prices copied from claude-3-5-haiku (closest same-tier\n // sibling in this table) — previously this id matched NO row and was\n // silently billed at sonnet rates via the unknown-model fallback.\n 'claude-haiku-4-5': { input: 0.80, output: 4, cacheRead: 0.08, cacheWrite: 1 },\n 'claude-sonnet-4': { input: 3, output: 15, cacheRead: 0.30, cacheWrite: 3.75 },\n 'claude-opus-4': { input: 15, output: 75, cacheRead: 1.50, cacheWrite: 18.75 },\n 'claude-3-5-sonnet': { input: 3, output: 15, cacheRead: 0.30, cacheWrite: 3.75 },\n 'claude-3-5-haiku': { input: 0.80, output: 4, cacheRead: 0.08, cacheWrite: 1 },\n 'claude-3-haiku': { input: 0.25, output: 1.25, cacheRead: 0.03, cacheWrite: 0.30 },\n\n // ── Codex / OpenAI ────────────────────────────────────────\n // GPT-5.x rows are derived from OpenAI's published GPT-5 family rates\n // (standard tier: $1.25/1M in, $10/1M out, cached input at ~10% of input;\n // mini tier: $0.25/1M in, $2/1M out). OpenAI has no separate cache-WRITE\n // premium, so cacheWrite mirrors the input rate. Replace with the exact\n // per-version numbers from developers.openai.com/pricing when published —\n // these were the ZERO placeholders that rendered Codex sessions as $0.\n 'gpt-5.5': { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 1.25 },\n 'gpt-5.4': { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 1.25 },\n 'gpt-5.4-mini': { input: 0.25, output: 2, cacheRead: 0.025, cacheWrite: 0.25 },\n 'gpt-5.3-codex': { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 1.25 },\n 'gpt-5.2': { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 1.25 },\n 'codex-auto-review': { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 1.25 },\n};\n\nexport const MODEL_CONTEXT_WINDOW: Record<string, number> = {\n // ── Anthropic / Claude ────────────────────────────────────\n 'claude-opus-4-7': 1_000_000,\n 'claude-opus-4-6': 1_000_000,\n 'claude-sonnet-4-6': 1_000_000,\n 'claude-haiku-4-5': 200_000,\n 'claude-opus-4': 1_000_000,\n 'claude-sonnet-4': 1_000_000,\n 'claude-3-5-sonnet': 200_000,\n 'claude-3-5-haiku': 200_000,\n 'claude-3-haiku': 200_000,\n\n // ── Codex / OpenAI ────────────────────────────────────────\n 'gpt-5.5': 272_000,\n 'gpt-5.4': 272_000,\n 'gpt-5.4-mini': 272_000,\n 'gpt-5.3-codex': 272_000,\n 'gpt-5.2': 272_000,\n 'codex-auto-review': 272_000,\n};\n\nconst DEFAULT_CONTEXT_WINDOW = 200_000;\n\n/**\n * Longest-prefix lookup. The tables key by model-family prefix; a model id\n * like `claude-opus-4-7` must resolve to its own row, not be shadowed by the\n * shorter `claude-opus-4` — so the match is by prefix LENGTH, never by the\n * table's insertion order.\n */\nfunction longestPrefixMatch<T>(table: Record<string, T>, model: string): T | undefined {\n let best: T | undefined;\n let bestLen = -1;\n for (const [prefix, value] of Object.entries(table)) {\n if (prefix.length > bestLen && model.startsWith(prefix)) {\n best = value;\n bestLen = prefix.length;\n }\n }\n return best;\n}\n\n/** True when the model id resolves to a real MODEL_PRICING row (i.e. getPricing\n * will NOT be guessing via the unknown-model fallback). */\nexport function isKnownModel(model: string): boolean {\n return longestPrefixMatch(MODEL_PRICING, model) !== undefined;\n}\n\n/**\n * Flagged default for an unpriced model id. All-zero so an unknown model is\n * VISIBLY unpriced ($0) rather than silently MISPRICED at some other family's\n * rates (the old sonnet-4 fallback billed unknown ids — including a haiku id\n * that matched no row — at sonnet rates). `getPricing` returns this object for\n * unknown ids so callers that do unconditional arithmetic still work; callers\n * that must distinguish real pricing from the default check `isKnownModel`.\n */\nexport const UNKNOWN_MODEL_PRICING: ModelPricing = {\n input: 0,\n output: 0,\n cacheRead: 0,\n cacheWrite: 0,\n};\n\n/**\n * Resolve pricing by longest matching prefix. Unknown models resolve to the\n * flagged {@link UNKNOWN_MODEL_PRICING} default (all-zero, i.e. visibly\n * unpriced) instead of guessing at another model's rates. Callers that need to\n * distinguish real pricing from the default must check `isKnownModel(model)`.\n */\nexport function getPricing(model: string): ModelPricing {\n return longestPrefixMatch(MODEL_PRICING, model) ?? UNKNOWN_MODEL_PRICING;\n}\n\nexport function getContextWindow(model: string | null): number {\n if (!model) return DEFAULT_CONTEXT_WINDOW;\n return longestPrefixMatch(MODEL_CONTEXT_WINDOW, model) ?? DEFAULT_CONTEXT_WINDOW;\n}\n","import type { AgentId, AgentMetadata } from './types';\n\nexport const AGENT_REGISTRY: Record<AgentId, AgentMetadata> = {\n claude: {\n id: 'claude',\n displayName: 'Claude Code',\n binaryName: 'claude',\n enabled: true,\n // Mirrors the backend registry (codeagent-mobile\n // apps/api-v2/src/codespaces/agent.ts — authoritative for auth\n // capabilities). `setup_token` is the bare `sk-ant-oat01-…` from\n // `claude setup-token` → delivered via CLAUDE_CODE_OAUTH_TOKEN.\n supportedAuthKinds: ['setup_token', 'oauth_token', 'api_key'],\n preferredAuthKind: 'setup_token',\n headroomWrappable: true,\n headroomKind: 'claude',\n // npm adapter `@agentclientprotocol/claude-agent-acp`.\n acp: true,\n },\n codex: {\n id: 'codex',\n displayName: 'Codex CLI',\n binaryName: 'codex',\n enabled: true,\n supportedAuthKinds: ['oauth_token', 'api_key'],\n preferredAuthKind: 'oauth_token',\n headroomWrappable: true,\n headroomKind: 'codex',\n // npm adapter `@agentclientprotocol/codex-acp`.\n acp: true,\n // OAuth device-code flow; the user_code on the OpenAI page IS a real\n // human-typed code — surfaces render it (with a copy affordance).\n deviceFlow: true,\n showsUserCode: true,\n },\n copilot: {\n id: 'copilot',\n displayName: 'GitHub Copilot CLI',\n binaryName: 'gh',\n enabled: false,\n supportedAuthKinds: ['oauth_token'],\n preferredAuthKind: 'oauth_token',\n // `headroom init --global copilot` exists even though the agent is\n // still disabled here (no runtime builder yet).\n headroomWrappable: true,\n headroomKind: 'copilot',\n acp: false,\n },\n coderabbit: {\n id: 'coderabbit',\n displayName: 'CodeRabbit',\n binaryName: 'coderabbit',\n enabled: true,\n // Backend registry is authoritative: CodeRabbit links via a real\n // API key only (no OAuth flow exists in api-v2).\n supportedAuthKinds: ['api_key'],\n preferredAuthKind: 'api_key',\n headroomWrappable: false,\n // Legacy PTY runtime — no ACP adapter registered.\n acp: false,\n },\n cursor: {\n id: 'cursor',\n displayName: 'Cursor Agent',\n binaryName: 'cursor-agent',\n enabled: true,\n // Backend registry is authoritative: since the Cursor OAuth\n // device-flow shipped, new links are oauth_token only (the login\n // blob written to ~/.config/cursor/auth.json). Legacy vaulted\n // api_key rows may still exist server-side, but the link surface\n // no longer offers api_key.\n supportedAuthKinds: ['oauth_token'],\n preferredAuthKind: 'oauth_token',\n // `headroom wrap cursor` is \"manual/print-only\" (IDE settings; the\n // headless cursor-agent CLI has no base-URL override) — runs native.\n headroomWrappable: false,\n // Native ACP server: `cursor-agent acp`.\n acp: true,\n // Reverse-engineered device/poll flow; `userCode` is the secret PKCE\n // verifier echoed back on poll — NEVER human-facing.\n deviceFlow: true,\n showsUserCode: false,\n },\n aider: {\n id: 'aider',\n displayName: 'Aider',\n binaryName: 'aider',\n enabled: true,\n // Aider is OAuth-less — auth is via ANTHROPIC_API_KEY / OPENAI_API_KEY\n // / etc. env vars or `~/.aider.conf.yml`. The link flow surfaces\n // this via the existing --api-key escape hatch in commands/link.ts.\n supportedAuthKinds: ['api_key'],\n preferredAuthKind: 'api_key',\n headroomWrappable: false,\n // Legacy PTY runtime — no ACP adapter registered.\n acp: false,\n },\n gemini: {\n id: 'gemini',\n displayName: 'Gemini CLI',\n binaryName: 'gemini',\n enabled: true,\n // OAuth via `gemini auth login` (captured by `codeam link gemini`\n // from ~/.gemini/oauth_creds.json) AND GEMINI_API_KEY are both\n // accepted by the backend's GeminiProvisioningStrategy and propagated\n // into codespace deploys.\n supportedAuthKinds: ['oauth_token', 'api_key'],\n preferredAuthKind: 'oauth_token',\n // Not listed by `headroom wrap --help` — runs native.\n headroomWrappable: false,\n // Native ACP server: `gemini --skip-trust --acp`.\n acp: true,\n },\n};\n\nexport function getEnabledAgents(): AgentMetadata[] {\n return Object.values(AGENT_REGISTRY).filter(m => m.enabled);\n}\n\nexport function getAgent(id: AgentId): AgentMetadata {\n const meta = AGENT_REGISTRY[id];\n if (!meta) throw new Error(`Unknown agent id: ${id}`);\n return meta;\n}\n\nexport function isKnownAgentId(id: string): id is AgentId {\n return id in AGENT_REGISTRY;\n}\n","/**\n * Agent identity — the ONE place the public (`LinkedAgentId`) and internal\n * (`AgentId`) id spaces are declared and bridged, plus the ONE alias\n * normalizer every surface funnels through.\n *\n * Canonical values consolidated from (Phase 2, PR-1):\n * - backend `apps/api-v2/src/linked-agents/agent-map.ts`\n * (`PUBLIC_TO_INTERNAL` / `INTERNAL_TO_PUBLIC` / `LinkedAgentId`),\n * - CLI `apps/cli/src/commands/host/agent-provisioning.ts`\n * (`PUBLIC_TO_INTERNAL_AGENT`),\n * - VS Code plugin `apps/vsc-plugin/src/utils/cli-agent-id.ts`\n * (marketplace aliases + `__terminal__:` strip),\n * - CLI `apps/cli/src/commands/start/handlers.ts`\n * (the `claude_code` → `claude` normalization),\n * - mobile `apps/mobile/src/lib/agent-id-map.ts`.\n */\n\nimport type { AgentId, HeadroomKind } from './types';\nimport { AGENT_REGISTRY, isKnownAgentId } from './registry';\n\n// ─── House agent constants ───────────────────────────────────────────────────\n// Byte-identical mirrors of the backend repo's canonical\n// `codeagent-mobile/packages/shared/src/constants/house-agent.ts` (which the\n// api-v2 additionally hand-mirrors in `common/constants/house-agent.ts`).\n// PR-3 replaces those copies with re-exports of THESE.\n\n/** Sentinel id for the synthetic \"CodeAgent Cloud (incluido)\" house agent. */\nexport const HOUSE_AGENT_ID = 'house-codeagent-cloud';\n\n/** Internal provider discriminator for the house agent. */\nexport const HOUSE_AGENT_PROVIDER = 'codeagent_cloud';\n\n/** White-label display strings — never mention the backend model. */\nexport const HOUSE_AGENT_NAME = 'CodeAgent Cloud';\nexport const HOUSE_AGENT_VENDOR = 'CodeAgent';\nexport const HOUSE_AGENT_SUBTITLE = 'Included — no setup';\n\n// ─── Public (LinkedAgent) id space ───────────────────────────────────────────\n\n/**\n * Public-facing linked-agent ids — the id space the `/api/agents/...`\n * endpoints and the mobile/web surfaces speak. The internal `AgentId`\n * (`'claude' | 'codex' | …`) is what the runtimes / provisioning key on.\n */\nexport type LinkedAgentId =\n | 'claude_code'\n | 'codex'\n | 'cursor'\n | 'aider'\n | 'coderabbit'\n | 'gemini'\n | typeof HOUSE_AGENT_ID;\n\nexport const LINKED_AGENT_IDS: readonly LinkedAgentId[] = [\n 'claude_code',\n 'codex',\n 'cursor',\n 'aider',\n 'coderabbit',\n 'gemini',\n HOUSE_AGENT_ID,\n];\n\nexport function isLinkedAgentId(value: string): value is LinkedAgentId {\n return (LINKED_AGENT_IDS as readonly string[]).includes(value);\n}\n\n/**\n * Every public id → internal `AgentId`.\n *\n * ⚠️ RECONCILED ASYMMETRY — this map is the UNION of what the two sides\n * historically accepted:\n * - The backend's `agent-map.ts` accepts only the `LinkedAgentId` union\n * (incl. the house agent, whose runtime is Claude Code) — no bare\n * `claude`, no `copilot` (there is no public copilot LinkedAgentId).\n * - The CLI's self-hosted `agent-provisioning.ts` additionally accepts\n * bare `'claude'` and `'copilot'` (deploy payloads have carried\n * already-internal ids), but not the house agent.\n * Consumers that must REJECT ids outside their own historical set keep\n * their own guard on top (e.g. `isLinkedAgentId`).\n */\nexport const PUBLIC_TO_INTERNAL: Readonly<\n Record<LinkedAgentId | 'claude' | 'copilot', AgentId>\n> = {\n claude_code: 'claude',\n // CLI-side extra: self-hosted deploy payloads may carry the internal id.\n claude: 'claude',\n codex: 'codex',\n // CLI-side extra: copilot has no public LinkedAgentId (backend doesn't\n // expose it) but the self-hosted path accepts it.\n copilot: 'copilot',\n cursor: 'cursor',\n aider: 'aider',\n coderabbit: 'coderabbit',\n gemini: 'gemini',\n // The house agent runs Claude Code under the hood (pointed at the\n // MiniMax proxy). Its internal runtime is therefore `claude`.\n [HOUSE_AGENT_ID]: 'claude',\n};\n\n/**\n * Internal → public. Partial: `copilot` has no public LinkedAgentId, and\n * `claude` maps back to `claude_code` (never the house agent — that\n * direction is intentionally lossy).\n */\nexport const INTERNAL_TO_PUBLIC: Readonly<Partial<Record<AgentId, LinkedAgentId>>> = {\n claude: 'claude_code',\n codex: 'codex',\n cursor: 'cursor',\n aider: 'aider',\n coderabbit: 'coderabbit',\n gemini: 'gemini',\n};\n\nfunction isPublicToInternalKey(v: string): v is LinkedAgentId | 'claude' | 'copilot' {\n // Not Object.hasOwn — the VS Code plugin's tsconfig lib predates ES2022.\n return Object.prototype.hasOwnProperty.call(PUBLIC_TO_INTERNAL, v);\n}\n\n/** Resolve a public/linked id to the internal `AgentId`, or null. */\nexport function publicToInternal(publicId: string): AgentId | null {\n return isPublicToInternalKey(publicId) ? PUBLIC_TO_INTERNAL[publicId] : null;\n}\n\n/** Resolve an internal `AgentId` to its public `LinkedAgentId`, or null. */\nexport function internalToPublic(internal: AgentId): LinkedAgentId | null {\n return INTERNAL_TO_PUBLIC[internal] ?? null;\n}\n\n// ─── Alias normalization ─────────────────────────────────────────────────────\n\n/** Prefix IDE plugins use for terminal-hosted agent ids. */\nexport const TERMINAL_AGENT_PREFIX = '__terminal__:';\n\n/**\n * Known aliases → internal `AgentId`. Union of every alias set that used\n * to live scattered across the surfaces: the public `claude_code` id, the\n * VS Code / Open VSX marketplace extension ids, and JetBrains plugin ids.\n */\nconst AGENT_ID_ALIASES: Readonly<Record<string, AgentId>> = {\n claude_code: 'claude',\n 'claude-code': 'claude',\n 'anthropic.claude-code': 'claude',\n 'anthropics.claude': 'claude',\n 'anthropic.claude-ce': 'claude',\n 'anthropic.claude': 'claude',\n 'com.anthropic.claudecode': 'claude',\n 'com.anthropic.claude': 'claude',\n 'openai.chatgpt': 'codex',\n 'coderabbitai.coderabbit-vscode': 'coderabbit',\n};\n\n/**\n * THE agent-id normalizer. Collapses every known spelling of an agent id\n * (registry id, public `claude_code` form, marketplace extension id,\n * `__terminal__:`-prefixed plugin id — case/whitespace tolerant) onto the\n * internal `AgentId`, or `null` when unknown.\n *\n * Deliberately does NOT:\n * - gate on `enabled` (callers that need availability check the\n * registry — see the VS Code wrapper `normalizeCliAgentId`);\n * - map the house agent (that's a runtime substitution, not an alias —\n * use {@link publicToInternal});\n * - fall back to anything. Unknown in → `null` out.\n */\nexport function normalizeAgentId(raw: string): AgentId | null {\n const value = (raw ?? '').trim().toLowerCase();\n if (!value) return null;\n\n if (isKnownAgentId(value)) return value;\n\n const unprefixed = value.startsWith(TERMINAL_AGENT_PREFIX)\n ? value.slice(TERMINAL_AGENT_PREFIX.length)\n : value;\n if (isKnownAgentId(unprefixed)) return unprefixed;\n\n return AGENT_ID_ALIASES[unprefixed] ?? null;\n}\n\n// ─── Headroom kind derivation ────────────────────────────────────────────────\n\n/**\n * The `headroom init --global <kind>` subcommand for an agent id, derived\n * from the registry's `headroomKind` flags — or `null` for unknown or\n * non-wrappable agents (cursor / gemini / aider / anything else).\n *\n * ⚠️ NEVER falls back to `'claude'`. The historical CLI fallback is how\n * the 2026-06 Cursor incident happened: an unsupported agent slipped\n * through, defaulted to `claude`, and `headroom wrap claude` launched\n * Claude Code instead of the user's agent. Callers that genuinely need a\n * default (e.g. picking an init subcommand AFTER the wrappable gate has\n * already passed) apply it themselves — see the CLI's\n * `agentIdToHeadroomKind` wrapper.\n *\n * Matching mirrors the historical predicates on BOTH sides (CLI\n * `isHeadroomSupportedAgent`, api-v2 `isHeadroomWrappableAgent`):\n * case-insensitive, `_`/`-` tolerant, prefix match — so `claude_code`,\n * `Claude-Code`, `codex_cli`, `copilot-cli` all resolve.\n */\nexport function headroomKindFor(agentId: string): HeadroomKind | null {\n const normalized = (agentId ?? '').toLowerCase().replace(/[_-]/g, '');\n if (!normalized) return null;\n for (const meta of Object.values(AGENT_REGISTRY)) {\n if (meta.headroomKind !== undefined && normalized.startsWith(meta.id)) {\n return meta.headroomKind;\n }\n }\n return null;\n}\n\n/**\n * Registry-derived replacement for the two scattered predicates\n * (`isHeadroomSupportedAgent` in the CLI, `isHeadroomWrappableAgent` in\n * api-v2). Accepts both id spaces (`claude_code` and `claude`).\n */\nexport function isHeadroomWrappable(agentId: string): boolean {\n return headroomKindFor(agentId) !== null;\n}\n","/**\n * Production API base URL for all CodeAgent Mobile clients.\n *\n * History note: prod migrated from Vercel (`https://api.codeagent-mobile.com`)\n * to Cloud Run / api-v2 (`https://api.codeagent-mobile.com`) in 2026-05. The\n * Vercel deployment is now gated by Vercel deployment protection and returns\n * 403 for unauthed traffic — DO NOT fall back to it.\n *\n * Override at runtime with `CODEAM_API_URL` (full URL override) OR set\n * `CODEAM_TEST_MODE=1` to point every client request at the dev\n * preview without having to know its host.\n */\nexport const DEFAULT_API_BASE_URL = 'https://api.codeagent-mobile.com' as const;\n\n/**\n * Dev-preview API base URL. Same Cloud Run service as prod but routed\n * to the `dev` revision (auto-deploys from the `dev` branch in the\n * backend repo). Manual smoke tests + load runs land here.\n */\nexport const DEV_API_BASE_URL = 'https://dev-api.codeagent-mobile.com' as const;\n\n/**\n * Resolve the active API base URL, honoring in priority order:\n *\n * 1. Explicit `CODEAM_API_URL` env var — full URL, takes precedence.\n * 2. `CODEAM_TEST_MODE=1` shortcut — flips to [DEV_API_BASE_URL]\n * without the user having to know the dev host.\n * 3. The `DEFAULT_API_BASE_URL` constant (prod).\n *\n * Used by every CLI service that talks to the backend so one env var\n * flips heartbeats, command relay, chunk uploads, and the pairing\n * flow in lockstep — eliminates the cross-environment misroute where\n * pairing succeeds in dev (shared Redis) but the CLI keeps\n * heartbeating to prod.\n */\nexport function resolveApiBaseUrl(): string {\n // Guard against non-Node runtimes (browser bundles import this\n // module). `process` is undefined there; treat as prod default.\n // `@codeam/shared` deliberately avoids depending on `@types/node`\n // so its types stay consumable from the mobile RN bundle too, so we\n // reach for the env via a structural cast rather than NodeJS.ProcessEnv.\n const env = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process?.env;\n const explicit = env?.CODEAM_API_URL?.trim();\n if (explicit) return explicit;\n const testFlag = env?.CODEAM_TEST_MODE?.trim();\n if (testFlag === '1' || testFlag?.toLowerCase() === 'true') return DEV_API_BASE_URL;\n return DEFAULT_API_BASE_URL;\n}\n","/**\n * Headroom provisioning manifest — the SINGLE source of truth for what a\n * Headroom install consists of, rendered by every provisioning surface:\n *\n * - codespace bootstrap (bash composer in the backend repo,\n * `apps/api-v2/src/codespaces/github-ssh.service.ts` — adopts in PR-2),\n * - self-hosted deploy (TS installer, CLI `commands/host-agent.ts`\n * `setupHeadroomForSelfHosted`),\n * - on-demand local sessions (\"Session add-ons → Cost-saving\", CLI\n * `services/headroom/configure.ts`).\n *\n * Values are DATA-first (arrays/records, plus tiny pure renderers) so both\n * the TS installer and a bash composer can interpolate from them. Renderers\n * are byte-exact with the literals they replaced — guarded by\n * `packages/shared/__tests__/headroom-manifest.test.ts`.\n *\n * ⚠️ The extras matter: `[proxy,code]` pulls the ONNX compression engines\n * (Kompress + tree-sitter CodeCompressor). NEVER add `[ml]` — that's\n * multi-GB PyTorch, and a broken/cold torch wedges every prompt at\n * \"Thinking…\". The models are pre-downloaded at provision time because the\n * proxy eager-loads with `allow_download=False` and a cold cache defers the\n * ~840 MB download to the first prompt (blowing the agent's ~90 s idle\n * timeout).\n */\n\n/** Local proxy port the agent's config is routed to. */\nexport const HEADROOM_PROXY_PORT = 8787;\n\n/**\n * Env that pins the ONNX backend on the proxy process — never imports\n * torch. Spread into the proxy launch env on every surface.\n */\nexport const HEADROOM_BACKEND_ENV = {\n HEADROOM_KOMPRESS_BACKEND: 'onnx_cpu',\n} as const;\n\n/**\n * The proxy's HTTP/server companion packages, installed alongside the\n * `headroom-ai[...]` package. The COMPRESSION ENGINES come from the\n * headroom-ai extras — NOT this list.\n */\nexport const HEADROOM_PIP_COMPANIONS: readonly string[] = [\n 'fastapi',\n 'uvicorn',\n 'httpx[http2]',\n 'websockets',\n 'zstandard',\n];\n\n/** The three provisioning surfaces (see module doc). */\nexport type HeadroomSurface = 'codespace' | 'selfHosted' | 'onDemand';\n\n/**\n * pip extras per surface. `onDemand` additionally ships `image`\n * (image-compression support, added with the Session add-ons path in\n * codeam-cli@2.49.0); the older codespace/self-hosted install strings\n * remain `[proxy,code]` byte-for-byte.\n */\nexport const HEADROOM_EXTRAS_BY_SURFACE: Readonly<Record<HeadroomSurface, readonly string[]>> = {\n codespace: ['proxy', 'code'],\n selfHosted: ['proxy', 'code'],\n onDemand: ['proxy', 'code', 'image'],\n};\n\n/** `headroom-ai[<extras>]` — the pip requirement string. */\nexport function headroomPipPackage(extras: readonly string[]): string {\n return `headroom-ai[${extras.join(',')}]`;\n}\n\n/** One HuggingFace repo to pre-warm into the HF cache at provision time. */\nexport interface HeadroomModelSpec {\n repo: string;\n /** `snapshot_download(..., allow_patterns=[…])` filter. */\n allowPatterns: readonly string[];\n}\n\n/**\n * The two HF repos Kompress needs. kompress-v2-base is the ONNX model\n * (skip its .pt/.safetensors torch artifacts); ModernBERT-base is the\n * TOKENIZER ONLY (skip its model weights).\n */\nexport const HEADROOM_MODELS: readonly HeadroomModelSpec[] = [\n {\n repo: 'chopratejas/kompress-v2-base',\n allowPatterns: ['*.json', 'onnx/*.onnx', 'kompress-int8-wo.onnx'],\n },\n {\n repo: 'answerdotai/ModernBERT-base',\n allowPatterns: ['*.json', 'tokenizer*', '*.txt', 'vocab*', 'merges*'],\n },\n];\n\n/** Formatting knob so each surface can stay byte-identical to its\n * historical literal (the CLI joins patterns with `,`, the codespace\n * bash composer with `, `). */\nexport interface HeadroomPythonRenderOpts {\n /** Put a space after the commas between allow_patterns entries. */\n spaceAfterComma?: boolean;\n}\n\n/** Render one `snapshot_download(...)` python line for a model. */\nexport function headroomSnapshotDownloadLine(\n model: HeadroomModelSpec,\n opts: HeadroomPythonRenderOpts = {},\n): string {\n const sep = opts.spaceAfterComma ? ', ' : ',';\n const patterns = model.allowPatterns.map((p) => `\"${p}\"`).join(sep);\n return `snapshot_download(\"${model.repo}\", allow_patterns=[${patterns}])`;\n}\n\n/**\n * The full model pre-download python snippet (import + one\n * `snapshot_download` per model), newline-joined — what the surfaces pass\n * to `python -c` / a heredoc.\n */\nexport function headroomModelPredownloadScript(opts: HeadroomPythonRenderOpts = {}): string {\n return [\n 'from huggingface_hub import snapshot_download',\n ...HEADROOM_MODELS.map((m) => headroomSnapshotDownloadLine(m, opts)),\n ].join('\\n');\n}\n","/**\n * Canonical names of the per-user SSE bus events (`/api/users/me/stream`).\n *\n * The authoritative list is the `UserEvent` discriminated union in the\n * backend repo: codeagent-mobile/apps/api-v2/src/user-events/user-events.types.ts.\n * Every `type:` literal of that union appears here exactly once — when a new\n * variant lands on the union, add its name here (and in the backend mirror of\n * this file at codeagent-mobile/packages/shared/src/types/events.ts).\n *\n * Producers (CLI event posts, backend `userEvents.publish` calls) and\n * consumers (the `useUserEventsSSE` hooks' switch cases) should reference\n * `USER_EVENTS.*` instead of re-typing the string, so a typo becomes a\n * compile error instead of a silently dropped event.\n */\nexport const USER_EVENTS = {\n PAIRED_SESSION_STATUS: 'paired_session_status',\n PAIRED_SESSION_ADDED: 'paired_session_added',\n PAIRED_SESSION_REMOVED: 'paired_session_removed',\n PAIRED_SESSION_BRANCH_CHANGED: 'paired_session_branch_changed',\n SHARED_WITH_ME_ADDED: 'shared_with_me_added',\n SHARED_WITH_ME_REVOKED: 'shared_with_me_revoked',\n USAGE_CHANGED: 'usage_changed',\n TASK_DONE: 'task_done',\n HUNK_PENDING_REVIEW_ADDED: 'hunk_pending_review_added',\n HUNK_REVIEW_RESOLVED: 'hunk_review_resolved',\n FILE_CHANGED: 'file_changed',\n FILES_BATCH_CHANGED: 'files_batch_changed',\n AGENT_STREAMING_CHUNK: 'agent_streaming_chunk',\n AGENT_AWAITING_ANSWER: 'agent_awaiting_answer',\n AWAITING_INPUT_ADDED: 'awaiting_input_added',\n AGENT_ANSWER_RESOLVED: 'agent_answer_resolved',\n TEMPLATE_ADDED: 'template_added',\n TEMPLATE_REMOVED: 'template_removed',\n TEMPLATE_UPDATED: 'template_updated',\n AGENT_TASK_DISPATCHED: 'agent_task_dispatched',\n AGENT_TASK_COMPLETED: 'agent_task_completed',\n LINKED_AGENT_ADDED: 'linked_agent_added',\n QUOTA_REACHED: 'quota_reached',\n LINKED_AGENT_LINK_FAILED: 'linked_agent_link_failed',\n CODESPACE_AGENT_INSTALLED: 'codespace_agent_installed',\n AGENT_CREDENTIALS_REFRESHED: 'agent_credentials_refreshed',\n CREDENTIAL_INVALID: 'credential_invalid',\n CODESPACE_WAKING: 'codespace_waking',\n CODESPACE_BILLING_BLOCKED: 'codespace_billing_blocked',\n COST_SAVING_UPDATED: 'cost_saving_updated',\n COMMAND_COMPLETED: 'command_completed',\n AI_SUMMARY_PENDING: 'ai_summary_pending',\n AI_SUMMARY_READY: 'ai_summary_ready',\n AI_INSIGHT_PENDING: 'ai_insight_pending',\n AI_INSIGHT_READY: 'ai_insight_ready',\n PUSH_TOKEN_INVALIDATED: 'push_token_invalidated',\n PREVIEW_DETECTION_PENDING: 'preview_detection_pending',\n PREVIEW_DETECTION_READY: 'preview_detection_ready',\n PREVIEW_STARTING: 'preview_starting',\n PREVIEW_READY: 'preview_ready',\n PREVIEW_STOPPED: 'preview_stopped',\n PREVIEW_ERROR: 'preview_error',\n PREVIEW_PROGRESS: 'preview_progress',\n BEADS_STATE_CHANGED: 'beads_state_changed',\n BEADS_PROVISIONING: 'beads_provisioning',\n BEADS_TEAM_MEMORY_CHANGED: 'beads_team_memory_changed',\n AUDIT_EVENT_ADDED: 'audit_event_added',\n SELF_HOSTED_HOST_ADDED: 'self_hosted_host_added',\n SELF_HOSTED_HOST_STATUS: 'self_hosted_host_status',\n SELF_HOSTED_HOST_REMOVED: 'self_hosted_host_removed',\n SELF_HOSTED_HOST_TELEMETRY: 'self_hosted_host_telemetry',\n SELF_HOSTED_HOST_METRICS: 'self_hosted_host_metrics',\n SELF_HOSTED_HOST_SESSIONS: 'self_hosted_host_sessions',\n SELF_HOSTED_DEPLOY_PROGRESS: 'self_hosted_deploy_progress',\n REFERRAL_REWARD_EARNED: 'referral_reward_earned',\n HEADROOM_PROGRESS: 'headroom_progress',\n HEADROOM_STATUS: 'headroom_status',\n BEADS_STATUS: 'beads_status',\n LINKED_AGENT_HEADROOM_BUDGET_UPDATED: 'linked_agent_headroom_budget_updated',\n CLI_UPDATE_AVAILABLE: 'cli_update_available',\n AGENT_INSTALL_PROGRESS: 'agent_install_progress',\n AGENT_INSTALL_FAILED: 'agent_install_failed',\n CLI_UPDATE_PROGRESS: 'cli_update_progress',\n CLI_UPDATE_FAILED: 'cli_update_failed',\n BATON_STATE: 'baton_state',\n} as const;\n\nexport type UserEventName = (typeof USER_EVENTS)[keyof typeof USER_EVENTS];\n","/**\n * Prompt the CLI sends to the user's linked agent (Claude, Codex, …)\n * in a headless one-shot to detect how to start the project's dev\n * server. Same pattern as the AI Insights \"summary\" prompt — the\n * agent runs locally with the user's auth, has read access to the\n * project, and returns a tiny JSON blob the CLI parses.\n *\n * Kept here (in `@codeam/shared`) so the CLI build inlines the\n * exact string at compile time without runtime fetch from the backend.\n */\nexport const PREVIEW_DETECT_PROMPT = `\nAnalyze the project in the current working directory and return how to start\nits development server for in-app preview.\n\nRead package.json, Procfile, Dockerfile, docker-compose.yml, manage.py, app.json,\nmix.exs, Cargo.toml, go.mod, requirements.txt, Gemfile, and any other framework\nmarkers you find at depth <= 2.\n\nReturn ONLY a JSON object on stdout (no prose, no markdown fences):\n\n{\n \"framework\": \"<name, or 'unsupported'>\",\n \"command\": \"<executable>\",\n \"args\": [\"...\"],\n \"port\": <number>,\n \"ready_pattern\": \"<regex matching the server-ready stdout line>\",\n \"env\": { \"HOST\": \"0.0.0.0\" },\n \"setup_commands\": [{ \"cmd\": \"<executable>\", \"args\": [\"...\"] }],\n \"notes\": \"<one-line caveat or null>\"\n}\n\nRules:\n- Pick the script the developer would run locally to see the app (typically \"dev\", \"start\", \"serve\").\n- Prefer binding to 0.0.0.0 — most frameworks default to localhost which the tunnel cannot reach.\n- For Expo: framework=\"Expo\", command=\"npx\", args=[\"expo\",\"start\",\"--tunnel\"], port=8081, notes=\"Scan QR with Expo Go\".\n- If no dev server applies (CLI library, lambda, batch script): {\"framework\":\"unsupported\",\"notes\":\"<reason>\"}.\n\nCRITICAL — setup_commands:\n- DO NOT include an install command (npm install, pnpm install, yarn install,\n yarn, bun install) in setup_commands. A lockfile-aware pre-flight installer\n runs BEFORE setup_commands and picks the correct package manager from the\n lockfile present (pnpm-lock.yaml -> pnpm, yarn.lock -> yarn, bun.lockb -> bun,\n else npm). Emitting an install here either duplicates that work or, worse,\n uses the WRONG package manager on top of node_modules just populated by the\n pre-flight, which crashes (e.g. npm errors with \"Cannot read properties of\n null (reading 'matches')\" when run over pnpm's .pnpm/ layout).\n- ONLY include setup_commands for genuinely non-install work the project needs\n before its dev server can boot: prisma generate, codegen, prebuild scripts,\n database migrations against a local SQLite, etc.\n- Each setup_commands entry MUST be an object {\"cmd\": \"...\", \"args\": [\"...\"]} —\n e.g. {\"cmd\": \"npx\", \"args\": [\"prisma\", \"generate\"]}. NOT a bare string.\n- For most projects, setup_commands should be an empty array [].\n\nOUTPUT JSON ONLY. NO MARKDOWN. NO COMMENTARY.\n`.trim();\n"],"mappings":";AAiBO,IAAM,mBAAmB;AAezB,IAAM,uBAAuB;AAS7B,IAAM,gCAAgC;AAOtC,IAAM,wBAAwB;;;ACvC9B,SAAS,cAAc,KAAuB;AACnD,QAAM,SAAmB,CAAC,EAAE;AAC5B,MAAI,MAAM;AACV,MAAI,MAAM;AAEV,WAAS,YAAkB;AACzB,WAAO,OAAO,UAAU,IAAK,QAAO,KAAK,EAAE;AAAA,EAC7C;AAEA,WAAS,UAAU,IAAkB;AACnC,cAAU;AACV,QAAI,MAAM,OAAO,GAAG,EAAE,QAAQ;AAC5B,aAAO,GAAG,IAAI,OAAO,GAAG,EAAE,MAAM,GAAG,GAAG,IAAI,KAAK,OAAO,GAAG,EAAE,MAAM,MAAM,CAAC;AAAA,IAC1E,OAAO;AACL,aAAO,OAAO,GAAG,EAAE,SAAS,IAAK,QAAO,GAAG,KAAK;AAChD,aAAO,GAAG,KAAK;AAAA,IACjB;AACA;AAAA,EACF;AAEA,MAAI,IAAI;AACR,SAAO,IAAI,IAAI,QAAQ;AACrB,UAAM,KAAK,IAAI,CAAC;AAEhB,QAAI,OAAO,QAAQ;AACjB;AACA,UAAI,KAAK,IAAI,OAAQ;AAErB,UAAI,IAAI,CAAC,MAAM,KAAK;AAClB;AACA,YAAI,QAAQ;AACZ,eAAO,IAAI,IAAI,UAAU,CAAC,QAAQ,KAAK,IAAI,CAAC,CAAC,EAAG,UAAS,IAAI,GAAG;AAChE,cAAM,MAAM,IAAI,CAAC,KAAK;AACtB,cAAM,IAAI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,wBAAwB;AAAA,EACxB,mBAAmB;AAAA,EACnB,iBAAiB;AAAA,EACjB,cAAc;AAAA,EACd,sCAAsC;AAAA,EACtC,sBAAsB;AAAA,EACtB,wBAAwB;AAAA,EACxB,sBAAsB;AAAA,EACtB,qBAAqB;AAAA,EACrB,mBAAmB;AAAA,EACnB,aAAa;AACf;;;ACtEO,IAAM,wBAAwB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA4CnC,KAAK;","names":[]}
1
+ {"version":3,"sources":["../src/protocol/constants.ts","../src/protocol/renderToLines.ts","../src/protocol/remote-command.ts","../src/models/pricing.ts","../src/agents/registry.ts","../src/agents/identity.ts","../src/api-url.ts","../src/headroom/manifest.ts","../src/types/events.ts","../src/preview-prompts.ts"],"sourcesContent":["/**\n * Shared wire / lifecycle constants. The values here are bundled\n * into the CLI + VS Code extension at build time via tsup / esbuild\n * and mirrored in `apps/jetbrains-plugin/.../protocol/Constants.kt`\n * since Kotlin can't import an npm package.\n *\n * If you change one of these values, also update the Kotlin mirror.\n */\n\n/**\n * Discriminated chunk-protocol version sent as the\n * `X-Codeam-Protocol-Version` header on every authed request. The\n * backend uses this to opt into legacy translations or to reject\n * with 426 when the client is too far behind. Bumped in lockstep\n * with chunk-shape changes (e.g. when the `chrome_steps` chunk\n * type is added).\n */\nexport const PROTOCOL_VERSION = '2.0.0' as const;\n\n/**\n * The VS Code AgentOutputMonitor's loopback HTTP server bound to\n * 127.0.0.1 on this port — the observer JS in the IDE renderer\n * uses it to round-trip captured chat content back into the\n * extension host. The port is intentionally fixed (rather than\n * `listen(0)`) so the observer script can be a static constant\n * rather than dynamically rewriting itself per session.\n *\n * Multi-window collision is solved by listen(0) per-window in the\n * monitor (see #103); this default is still the documented\n * starting port for tooling that needs to probe whether a CodeAgent\n * Mobile session is active locally.\n */\nexport const OBSERVER_BRIDGE_PORT = 47832;\n\n/**\n * Default plugin → backend heartbeat interval. User-configurable\n * via `codeagent-mobile.heartbeatIntervalMs` on VS Code and\n * `heartbeatIntervalMs` in SettingsService.kt's @State on JetBrains.\n * Mirrors the value the apps/api side uses to flip the paired\n * session to offline.\n */\nexport const HEARTBEAT_INTERVAL_MS_DEFAULT = 30_000;\n\n/**\n * SSE + polling reconnect cap. Vercel's serverless functions close\n * SSE connections after ~25 s by default; the client uses 35 s as\n * its overall socket timeout to leave a beat for graceful close.\n */\nexport const SSE_SOCKET_TIMEOUT_MS = 35_000;\n","/**\n * Render raw PTY bytes into an array of screen lines using a simplified\n * virtual terminal. Handles cursor movements (A/B/C/D/G/H), erase (J/K),\n * alternate-screen (?1049h), carriage return, and LF.\n *\n * This is the authoritative implementation used by both codeam-cli (PTY\n * output) and the VS Code extension (shell-integration output) so that\n * the mobile/web client sees identical chunks regardless of surface.\n */\nexport function renderToLines(raw: string): string[] {\n const screen: string[] = [''];\n let row = 0;\n let col = 0;\n\n function ensureRow(): void {\n while (screen.length <= row) screen.push('');\n }\n\n function writeChar(ch: string): void {\n ensureRow();\n if (col < screen[row].length) {\n screen[row] = screen[row].slice(0, col) + ch + screen[row].slice(col + 1);\n } else {\n while (screen[row].length < col) screen[row] += ' ';\n screen[row] += ch;\n }\n col++;\n }\n\n let i = 0;\n while (i < raw.length) {\n const ch = raw[i];\n\n if (ch === '\\x1B') {\n i++;\n if (i >= raw.length) break;\n\n if (raw[i] === '[') {\n i++;\n let param = '';\n while (i < raw.length && !/[@-~]/.test(raw[i])) param += raw[i++];\n const cmd = raw[i] ?? '';\n const n = parseInt(param) || 1;\n\n if (cmd === 'A') { row = Math.max(0, row - n); }\n else if (cmd === 'B') { row += n; ensureRow(); }\n else if (cmd === 'C') { col += n; }\n else if (cmd === 'D') { col = Math.max(0, col - n); }\n else if (cmd === 'G') { col = Math.max(0, n - 1); }\n else if (cmd === 'H' || cmd === 'f') {\n const p = param.split(';');\n row = Math.max(0, (parseInt(p[0] ?? '1') || 1) - 1);\n col = Math.max(0, (parseInt(p[1] ?? '1') || 1) - 1);\n ensureRow();\n } else if (cmd === 'J') {\n if (param === '2' || param === '3') {\n screen.length = 1; screen[0] = ''; row = 0; col = 0;\n } else if (param === '1') {\n for (let r = 0; r < row; r++) screen[r] = '';\n screen[row] = ' '.repeat(col) + screen[row].slice(col);\n } else {\n screen[row] = screen[row].slice(0, col);\n screen.splice(row + 1);\n }\n } else if (cmd === 'K') {\n ensureRow();\n if (param === '' || param === '0') screen[row] = screen[row].slice(0, col);\n else if (param === '1') screen[row] = ' '.repeat(col) + screen[row].slice(col);\n else if (param === '2') screen[row] = '';\n } else if (cmd === 'h' && (param === '?1049' || param === '?47')) {\n screen.length = 1; screen[0] = ''; row = 0; col = 0;\n } else if (cmd === 'l' && (param === '?1049' || param === '?47')) {\n screen.length = 1; screen[0] = ''; row = 0; col = 0;\n }\n } else if (raw[i] === ']') {\n i++;\n while (i < raw.length) {\n if (raw[i] === '\\x07') break;\n if (raw[i] === '\\x1B' && i + 1 < raw.length && raw[i + 1] === '\\\\') { i++; break; }\n i++;\n }\n }\n } else if (ch === '\\r') {\n if (i + 1 < raw.length && raw[i + 1] === '\\n') {\n row++; col = 0; ensureRow(); i++;\n } else {\n col = 0;\n }\n } else if (ch === '\\n') {\n row++; col = 0; ensureRow();\n } else if (ch >= ' ' || ch === '\\t') {\n writeChar(ch);\n }\n\n i++;\n }\n\n return screen;\n}\n","import { z } from 'zod';\n\n/**\n * The command envelope clients receive from the backend relay — both from\n * the `commands` SSE frames on `/api/commands/pending/stream` and from the\n * `GET /api/commands/pending` polling fallback. One schema, shared, so the\n * VS Code extension (and eventually the CLI) stop blind-casting\n * `Record<string, unknown>` into this shape.\n */\nexport interface RemoteCommand {\n id: string;\n sessionId: string;\n pluginId: string;\n type: string;\n payload: Record<string, unknown>;\n status: string;\n createdAt: number;\n}\n\nconst remoteCommandSchema = z.object({\n id: z.string(),\n sessionId: z.string(),\n pluginId: z.string(),\n type: z.string(),\n // The backend may omit `payload` (or send null) for payload-less commands;\n // clients have always normalized that to `{}` — keep that behavior here.\n payload: z.record(z.string(), z.unknown()).nullish(),\n status: z.string(),\n createdAt: z.number(),\n});\n\n/**\n * Validate a raw (already JSON-parsed) value into a `RemoteCommand`.\n * Returns `null` — never throws — on a malformed envelope so callers can\n * log-and-skip the single bad command without dropping the whole batch.\n */\nexport function toRemoteCommand(raw: unknown): RemoteCommand | null {\n const parsed = remoteCommandSchema.safeParse(raw);\n if (!parsed.success) return null;\n const { payload, ...rest } = parsed.data;\n return { ...rest, payload: payload ?? {} };\n}\n","export interface ModelPricing {\n input: number;\n output: number;\n cacheRead: number;\n cacheWrite: number;\n}\n\nexport const MODEL_PRICING: Record<string, ModelPricing> = {\n // ── Anthropic / Claude ────────────────────────────────────\n // The 4.x rows below cover the model ids actually emitted by the CLI\n // (apps/cli/src/agents/claude/runtime.ts listModels) and the JetBrains\n // fallback catalog (RemoteCommandRouter.kt). Prices are copied from the\n // same-family base rows (claude-opus-4 / claude-sonnet-4 /\n // claude-3-5-haiku) until distinct published rates land.\n 'claude-opus-4-7': { input: 15, output: 75, cacheRead: 1.50, cacheWrite: 18.75 },\n 'claude-opus-4-6': { input: 15, output: 75, cacheRead: 1.50, cacheWrite: 18.75 },\n 'claude-sonnet-4-6': { input: 3, output: 15, cacheRead: 0.30, cacheWrite: 3.75 },\n // Haiku-tier prices copied from claude-3-5-haiku (closest same-tier\n // sibling in this table) — previously this id matched NO row and was\n // silently billed at sonnet rates via the unknown-model fallback.\n 'claude-haiku-4-5': { input: 0.80, output: 4, cacheRead: 0.08, cacheWrite: 1 },\n 'claude-sonnet-4': { input: 3, output: 15, cacheRead: 0.30, cacheWrite: 3.75 },\n 'claude-opus-4': { input: 15, output: 75, cacheRead: 1.50, cacheWrite: 18.75 },\n 'claude-3-5-sonnet': { input: 3, output: 15, cacheRead: 0.30, cacheWrite: 3.75 },\n 'claude-3-5-haiku': { input: 0.80, output: 4, cacheRead: 0.08, cacheWrite: 1 },\n 'claude-3-haiku': { input: 0.25, output: 1.25, cacheRead: 0.03, cacheWrite: 0.30 },\n\n // ── Codex / OpenAI ────────────────────────────────────────\n // GPT-5.x rows are derived from OpenAI's published GPT-5 family rates\n // (standard tier: $1.25/1M in, $10/1M out, cached input at ~10% of input;\n // mini tier: $0.25/1M in, $2/1M out). OpenAI has no separate cache-WRITE\n // premium, so cacheWrite mirrors the input rate. Replace with the exact\n // per-version numbers from developers.openai.com/pricing when published —\n // these were the ZERO placeholders that rendered Codex sessions as $0.\n 'gpt-5.5': { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 1.25 },\n 'gpt-5.4': { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 1.25 },\n 'gpt-5.4-mini': { input: 0.25, output: 2, cacheRead: 0.025, cacheWrite: 0.25 },\n 'gpt-5.3-codex': { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 1.25 },\n 'gpt-5.2': { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 1.25 },\n 'codex-auto-review': { input: 1.25, output: 10, cacheRead: 0.125, cacheWrite: 1.25 },\n};\n\nexport const MODEL_CONTEXT_WINDOW: Record<string, number> = {\n // ── Anthropic / Claude ────────────────────────────────────\n 'claude-opus-4-7': 1_000_000,\n 'claude-opus-4-6': 1_000_000,\n 'claude-sonnet-4-6': 1_000_000,\n 'claude-haiku-4-5': 200_000,\n 'claude-opus-4': 1_000_000,\n 'claude-sonnet-4': 1_000_000,\n 'claude-3-5-sonnet': 200_000,\n 'claude-3-5-haiku': 200_000,\n 'claude-3-haiku': 200_000,\n\n // ── Codex / OpenAI ────────────────────────────────────────\n 'gpt-5.5': 272_000,\n 'gpt-5.4': 272_000,\n 'gpt-5.4-mini': 272_000,\n 'gpt-5.3-codex': 272_000,\n 'gpt-5.2': 272_000,\n 'codex-auto-review': 272_000,\n};\n\nconst DEFAULT_CONTEXT_WINDOW = 200_000;\n\n/**\n * Longest-prefix lookup. The tables key by model-family prefix; a model id\n * like `claude-opus-4-7` must resolve to its own row, not be shadowed by the\n * shorter `claude-opus-4` — so the match is by prefix LENGTH, never by the\n * table's insertion order.\n */\nfunction longestPrefixMatch<T>(table: Record<string, T>, model: string): T | undefined {\n let best: T | undefined;\n let bestLen = -1;\n for (const [prefix, value] of Object.entries(table)) {\n if (prefix.length > bestLen && model.startsWith(prefix)) {\n best = value;\n bestLen = prefix.length;\n }\n }\n return best;\n}\n\n/** True when the model id resolves to a real MODEL_PRICING row (i.e. getPricing\n * will NOT be guessing via the unknown-model fallback). */\nexport function isKnownModel(model: string): boolean {\n return longestPrefixMatch(MODEL_PRICING, model) !== undefined;\n}\n\n/**\n * Flagged default for an unpriced model id. All-zero so an unknown model is\n * VISIBLY unpriced ($0) rather than silently MISPRICED at some other family's\n * rates (the old sonnet-4 fallback billed unknown ids — including a haiku id\n * that matched no row — at sonnet rates). `getPricing` returns this object for\n * unknown ids so callers that do unconditional arithmetic still work; callers\n * that must distinguish real pricing from the default check `isKnownModel`.\n */\nexport const UNKNOWN_MODEL_PRICING: ModelPricing = {\n input: 0,\n output: 0,\n cacheRead: 0,\n cacheWrite: 0,\n};\n\n/**\n * Resolve pricing by longest matching prefix. Unknown models resolve to the\n * flagged {@link UNKNOWN_MODEL_PRICING} default (all-zero, i.e. visibly\n * unpriced) instead of guessing at another model's rates. Callers that need to\n * distinguish real pricing from the default must check `isKnownModel(model)`.\n */\nexport function getPricing(model: string): ModelPricing {\n return longestPrefixMatch(MODEL_PRICING, model) ?? UNKNOWN_MODEL_PRICING;\n}\n\nexport function getContextWindow(model: string | null): number {\n if (!model) return DEFAULT_CONTEXT_WINDOW;\n return longestPrefixMatch(MODEL_CONTEXT_WINDOW, model) ?? DEFAULT_CONTEXT_WINDOW;\n}\n","import type { AgentId, AgentMetadata } from './types';\n\nexport const AGENT_REGISTRY: Record<AgentId, AgentMetadata> = {\n claude: {\n id: 'claude',\n displayName: 'Claude Code',\n binaryName: 'claude',\n enabled: true,\n // Mirrors the backend registry (codeagent-mobile\n // apps/api-v2/src/codespaces/agent.ts — authoritative for auth\n // capabilities). `setup_token` is the bare `sk-ant-oat01-…` from\n // `claude setup-token` → delivered via CLAUDE_CODE_OAUTH_TOKEN.\n supportedAuthKinds: ['setup_token', 'oauth_token', 'api_key'],\n preferredAuthKind: 'setup_token',\n headroomWrappable: true,\n headroomKind: 'claude',\n // npm adapter `@agentclientprotocol/claude-agent-acp`.\n acp: true,\n },\n codex: {\n id: 'codex',\n displayName: 'Codex CLI',\n binaryName: 'codex',\n enabled: true,\n supportedAuthKinds: ['oauth_token', 'api_key'],\n preferredAuthKind: 'oauth_token',\n headroomWrappable: true,\n headroomKind: 'codex',\n // npm adapter `@agentclientprotocol/codex-acp`.\n acp: true,\n // OAuth device-code flow; the user_code on the OpenAI page IS a real\n // human-typed code — surfaces render it (with a copy affordance).\n deviceFlow: true,\n showsUserCode: true,\n },\n copilot: {\n id: 'copilot',\n displayName: 'GitHub Copilot CLI',\n binaryName: 'gh',\n enabled: false,\n supportedAuthKinds: ['oauth_token'],\n preferredAuthKind: 'oauth_token',\n // `headroom init --global copilot` exists even though the agent is\n // still disabled here (no runtime builder yet).\n headroomWrappable: true,\n headroomKind: 'copilot',\n acp: false,\n },\n coderabbit: {\n id: 'coderabbit',\n displayName: 'CodeRabbit',\n binaryName: 'coderabbit',\n enabled: true,\n // Backend registry is authoritative: CodeRabbit links via a real\n // API key only (no OAuth flow exists in api-v2).\n supportedAuthKinds: ['api_key'],\n preferredAuthKind: 'api_key',\n headroomWrappable: false,\n // Legacy PTY runtime — no ACP adapter registered.\n acp: false,\n },\n cursor: {\n id: 'cursor',\n displayName: 'Cursor Agent',\n binaryName: 'cursor-agent',\n enabled: true,\n // Backend registry is authoritative: since the Cursor OAuth\n // device-flow shipped, new links are oauth_token only (the login\n // blob written to ~/.config/cursor/auth.json). Legacy vaulted\n // api_key rows may still exist server-side, but the link surface\n // no longer offers api_key.\n supportedAuthKinds: ['oauth_token'],\n preferredAuthKind: 'oauth_token',\n // `headroom wrap cursor` is \"manual/print-only\" (IDE settings; the\n // headless cursor-agent CLI has no base-URL override) — runs native.\n headroomWrappable: false,\n // Native ACP server: `cursor-agent acp`.\n acp: true,\n // Reverse-engineered device/poll flow; `userCode` is the secret PKCE\n // verifier echoed back on poll — NEVER human-facing.\n deviceFlow: true,\n showsUserCode: false,\n },\n aider: {\n id: 'aider',\n displayName: 'Aider',\n binaryName: 'aider',\n enabled: true,\n // Aider is OAuth-less — auth is via ANTHROPIC_API_KEY / OPENAI_API_KEY\n // / etc. env vars or `~/.aider.conf.yml`. The link flow surfaces\n // this via the existing --api-key escape hatch in commands/link.ts.\n supportedAuthKinds: ['api_key'],\n preferredAuthKind: 'api_key',\n headroomWrappable: false,\n // Legacy PTY runtime — no ACP adapter registered.\n acp: false,\n },\n gemini: {\n id: 'gemini',\n displayName: 'Gemini CLI',\n binaryName: 'gemini',\n enabled: true,\n // OAuth via `gemini auth login` (captured by `codeam link gemini`\n // from ~/.gemini/oauth_creds.json) AND GEMINI_API_KEY are both\n // accepted by the backend's GeminiProvisioningStrategy and propagated\n // into codespace deploys.\n supportedAuthKinds: ['oauth_token', 'api_key'],\n preferredAuthKind: 'oauth_token',\n // Not listed by `headroom wrap --help` — runs native.\n headroomWrappable: false,\n // Native ACP server: `gemini --skip-trust --acp`.\n acp: true,\n },\n kimi: {\n id: 'kimi',\n displayName: 'Kimi Code',\n binaryName: 'kimi',\n enabled: true,\n // API key (KIMI_API_KEY, + optional KIMI_BASE_URL) is the shipping auth —\n // fully documented, no reverse-engineering. OAuth `/login` (login-state at\n // ~/.kimi-code/credentials/<name>.json, base https://api.kimi.com/coding/)\n // is declared so it can land later without a wire change, but capturing\n // that blob server-side is a separate reverse-engineering spike (phase 2).\n supportedAuthKinds: ['api_key', 'oauth_token'],\n preferredAuthKind: 'api_key',\n // Moonshot's `kimi` is not listed by `headroom wrap --help` — runs native.\n headroomWrappable: false,\n // Native ACP server: `kimi acp` (stdio JSON-RPC, answers `initialize`).\n acp: true,\n },\n};\n\nexport function getEnabledAgents(): AgentMetadata[] {\n return Object.values(AGENT_REGISTRY).filter(m => m.enabled);\n}\n\nexport function getAgent(id: AgentId): AgentMetadata {\n const meta = AGENT_REGISTRY[id];\n if (!meta) throw new Error(`Unknown agent id: ${id}`);\n return meta;\n}\n\nexport function isKnownAgentId(id: string): id is AgentId {\n return id in AGENT_REGISTRY;\n}\n","/**\n * Agent identity — the ONE place the public (`LinkedAgentId`) and internal\n * (`AgentId`) id spaces are declared and bridged, plus the ONE alias\n * normalizer every surface funnels through.\n *\n * Canonical values consolidated from (Phase 2, PR-1):\n * - backend `apps/api-v2/src/linked-agents/agent-map.ts`\n * (`PUBLIC_TO_INTERNAL` / `INTERNAL_TO_PUBLIC` / `LinkedAgentId`),\n * - CLI `apps/cli/src/commands/host/agent-provisioning.ts`\n * (`PUBLIC_TO_INTERNAL_AGENT`),\n * - VS Code plugin `apps/vsc-plugin/src/utils/cli-agent-id.ts`\n * (marketplace aliases + `__terminal__:` strip),\n * - CLI `apps/cli/src/commands/start/handlers.ts`\n * (the `claude_code` → `claude` normalization),\n * - mobile `apps/mobile/src/lib/agent-id-map.ts`.\n */\n\nimport type { AgentId, HeadroomKind } from './types';\nimport { AGENT_REGISTRY, isKnownAgentId } from './registry';\n\n// ─── House agent constants ───────────────────────────────────────────────────\n// Byte-identical mirrors of the backend repo's canonical\n// `codeagent-mobile/packages/shared/src/constants/house-agent.ts` (which the\n// api-v2 additionally hand-mirrors in `common/constants/house-agent.ts`).\n// PR-3 replaces those copies with re-exports of THESE.\n\n/** Sentinel id for the synthetic \"CodeAgent Cloud (incluido)\" house agent. */\nexport const HOUSE_AGENT_ID = 'house-codeagent-cloud';\n\n/** Internal provider discriminator for the house agent. */\nexport const HOUSE_AGENT_PROVIDER = 'codeagent_cloud';\n\n/** White-label display strings — never mention the backend model. */\nexport const HOUSE_AGENT_NAME = 'CodeAgent Cloud';\nexport const HOUSE_AGENT_VENDOR = 'CodeAgent';\nexport const HOUSE_AGENT_SUBTITLE = 'Included — no setup';\n\n// ─── Public (LinkedAgent) id space ───────────────────────────────────────────\n\n/**\n * Public-facing linked-agent ids — the id space the `/api/agents/...`\n * endpoints and the mobile/web surfaces speak. The internal `AgentId`\n * (`'claude' | 'codex' | …`) is what the runtimes / provisioning key on.\n */\nexport type LinkedAgentId =\n | 'claude_code'\n | 'codex'\n | 'cursor'\n | 'aider'\n | 'coderabbit'\n | 'gemini'\n | 'kimi'\n | typeof HOUSE_AGENT_ID;\n\nexport const LINKED_AGENT_IDS: readonly LinkedAgentId[] = [\n 'claude_code',\n 'codex',\n 'cursor',\n 'aider',\n 'coderabbit',\n 'gemini',\n 'kimi',\n HOUSE_AGENT_ID,\n];\n\nexport function isLinkedAgentId(value: string): value is LinkedAgentId {\n return (LINKED_AGENT_IDS as readonly string[]).includes(value);\n}\n\n/**\n * Every public id → internal `AgentId`.\n *\n * ⚠️ RECONCILED ASYMMETRY — this map is the UNION of what the two sides\n * historically accepted:\n * - The backend's `agent-map.ts` accepts only the `LinkedAgentId` union\n * (incl. the house agent, whose runtime is Claude Code) — no bare\n * `claude`, no `copilot` (there is no public copilot LinkedAgentId).\n * - The CLI's self-hosted `agent-provisioning.ts` additionally accepts\n * bare `'claude'` and `'copilot'` (deploy payloads have carried\n * already-internal ids), but not the house agent.\n * Consumers that must REJECT ids outside their own historical set keep\n * their own guard on top (e.g. `isLinkedAgentId`).\n */\nexport const PUBLIC_TO_INTERNAL: Readonly<\n Record<LinkedAgentId | 'claude' | 'copilot', AgentId>\n> = {\n claude_code: 'claude',\n // CLI-side extra: self-hosted deploy payloads may carry the internal id.\n claude: 'claude',\n codex: 'codex',\n // CLI-side extra: copilot has no public LinkedAgentId (backend doesn't\n // expose it) but the self-hosted path accepts it.\n copilot: 'copilot',\n cursor: 'cursor',\n aider: 'aider',\n coderabbit: 'coderabbit',\n gemini: 'gemini',\n kimi: 'kimi',\n // The house agent runs Claude Code under the hood (pointed at the\n // MiniMax proxy). Its internal runtime is therefore `claude`.\n [HOUSE_AGENT_ID]: 'claude',\n};\n\n/**\n * Internal → public. Partial: `copilot` has no public LinkedAgentId, and\n * `claude` maps back to `claude_code` (never the house agent — that\n * direction is intentionally lossy).\n */\nexport const INTERNAL_TO_PUBLIC: Readonly<Partial<Record<AgentId, LinkedAgentId>>> = {\n claude: 'claude_code',\n codex: 'codex',\n cursor: 'cursor',\n aider: 'aider',\n coderabbit: 'coderabbit',\n gemini: 'gemini',\n kimi: 'kimi',\n};\n\nfunction isPublicToInternalKey(v: string): v is LinkedAgentId | 'claude' | 'copilot' {\n // Not Object.hasOwn — the VS Code plugin's tsconfig lib predates ES2022.\n return Object.prototype.hasOwnProperty.call(PUBLIC_TO_INTERNAL, v);\n}\n\n/** Resolve a public/linked id to the internal `AgentId`, or null. */\nexport function publicToInternal(publicId: string): AgentId | null {\n return isPublicToInternalKey(publicId) ? PUBLIC_TO_INTERNAL[publicId] : null;\n}\n\n/** Resolve an internal `AgentId` to its public `LinkedAgentId`, or null. */\nexport function internalToPublic(internal: AgentId): LinkedAgentId | null {\n return INTERNAL_TO_PUBLIC[internal] ?? null;\n}\n\n// ─── Alias normalization ─────────────────────────────────────────────────────\n\n/** Prefix IDE plugins use for terminal-hosted agent ids. */\nexport const TERMINAL_AGENT_PREFIX = '__terminal__:';\n\n/**\n * Known aliases → internal `AgentId`. Union of every alias set that used\n * to live scattered across the surfaces: the public `claude_code` id, the\n * VS Code / Open VSX marketplace extension ids, and JetBrains plugin ids.\n */\nconst AGENT_ID_ALIASES: Readonly<Record<string, AgentId>> = {\n claude_code: 'claude',\n 'claude-code': 'claude',\n 'anthropic.claude-code': 'claude',\n 'anthropics.claude': 'claude',\n 'anthropic.claude-ce': 'claude',\n 'anthropic.claude': 'claude',\n 'com.anthropic.claudecode': 'claude',\n 'com.anthropic.claude': 'claude',\n 'openai.chatgpt': 'codex',\n 'coderabbitai.coderabbit-vscode': 'coderabbit',\n};\n\n/**\n * THE agent-id normalizer. Collapses every known spelling of an agent id\n * (registry id, public `claude_code` form, marketplace extension id,\n * `__terminal__:`-prefixed plugin id — case/whitespace tolerant) onto the\n * internal `AgentId`, or `null` when unknown.\n *\n * Deliberately does NOT:\n * - gate on `enabled` (callers that need availability check the\n * registry — see the VS Code wrapper `normalizeCliAgentId`);\n * - map the house agent (that's a runtime substitution, not an alias —\n * use {@link publicToInternal});\n * - fall back to anything. Unknown in → `null` out.\n */\nexport function normalizeAgentId(raw: string): AgentId | null {\n const value = (raw ?? '').trim().toLowerCase();\n if (!value) return null;\n\n if (isKnownAgentId(value)) return value;\n\n const unprefixed = value.startsWith(TERMINAL_AGENT_PREFIX)\n ? value.slice(TERMINAL_AGENT_PREFIX.length)\n : value;\n if (isKnownAgentId(unprefixed)) return unprefixed;\n\n return AGENT_ID_ALIASES[unprefixed] ?? null;\n}\n\n// ─── Headroom kind derivation ────────────────────────────────────────────────\n\n/**\n * The `headroom init --global <kind>` subcommand for an agent id, derived\n * from the registry's `headroomKind` flags — or `null` for unknown or\n * non-wrappable agents (cursor / gemini / aider / anything else).\n *\n * ⚠️ NEVER falls back to `'claude'`. The historical CLI fallback is how\n * the 2026-06 Cursor incident happened: an unsupported agent slipped\n * through, defaulted to `claude`, and `headroom wrap claude` launched\n * Claude Code instead of the user's agent. Callers that genuinely need a\n * default (e.g. picking an init subcommand AFTER the wrappable gate has\n * already passed) apply it themselves — see the CLI's\n * `agentIdToHeadroomKind` wrapper.\n *\n * Matching mirrors the historical predicates on BOTH sides (CLI\n * `isHeadroomSupportedAgent`, api-v2 `isHeadroomWrappableAgent`):\n * case-insensitive, `_`/`-` tolerant, prefix match — so `claude_code`,\n * `Claude-Code`, `codex_cli`, `copilot-cli` all resolve.\n */\nexport function headroomKindFor(agentId: string): HeadroomKind | null {\n const normalized = (agentId ?? '').toLowerCase().replace(/[_-]/g, '');\n if (!normalized) return null;\n for (const meta of Object.values(AGENT_REGISTRY)) {\n if (meta.headroomKind !== undefined && normalized.startsWith(meta.id)) {\n return meta.headroomKind;\n }\n }\n return null;\n}\n\n/**\n * Registry-derived replacement for the two scattered predicates\n * (`isHeadroomSupportedAgent` in the CLI, `isHeadroomWrappableAgent` in\n * api-v2). Accepts both id spaces (`claude_code` and `claude`).\n */\nexport function isHeadroomWrappable(agentId: string): boolean {\n return headroomKindFor(agentId) !== null;\n}\n","/**\n * Production API base URL for all CodeAgent Mobile clients.\n *\n * History note: prod migrated from Vercel (`https://api.codeagent-mobile.com`)\n * to Cloud Run / api-v2 (`https://api.codeagent-mobile.com`) in 2026-05. The\n * Vercel deployment is now gated by Vercel deployment protection and returns\n * 403 for unauthed traffic — DO NOT fall back to it.\n *\n * Override at runtime with `CODEAM_API_URL` (full URL override) OR set\n * `CODEAM_TEST_MODE=1` to point every client request at the dev\n * preview without having to know its host.\n */\nexport const DEFAULT_API_BASE_URL = 'https://api.codeagent-mobile.com' as const;\n\n/**\n * Dev-preview API base URL. Same Cloud Run service as prod but routed\n * to the `dev` revision (auto-deploys from the `dev` branch in the\n * backend repo). Manual smoke tests + load runs land here.\n */\nexport const DEV_API_BASE_URL = 'https://dev-api.codeagent-mobile.com' as const;\n\n/**\n * Resolve the active API base URL, honoring in priority order:\n *\n * 1. Explicit `CODEAM_API_URL` env var — full URL, takes precedence.\n * 2. `CODEAM_TEST_MODE=1` shortcut — flips to [DEV_API_BASE_URL]\n * without the user having to know the dev host.\n * 3. The `DEFAULT_API_BASE_URL` constant (prod).\n *\n * Used by every CLI service that talks to the backend so one env var\n * flips heartbeats, command relay, chunk uploads, and the pairing\n * flow in lockstep — eliminates the cross-environment misroute where\n * pairing succeeds in dev (shared Redis) but the CLI keeps\n * heartbeating to prod.\n */\nexport function resolveApiBaseUrl(): string {\n // Guard against non-Node runtimes (browser bundles import this\n // module). `process` is undefined there; treat as prod default.\n // `@codeam/shared` deliberately avoids depending on `@types/node`\n // so its types stay consumable from the mobile RN bundle too, so we\n // reach for the env via a structural cast rather than NodeJS.ProcessEnv.\n const env = (globalThis as { process?: { env?: Record<string, string | undefined> } }).process?.env;\n const explicit = env?.CODEAM_API_URL?.trim();\n if (explicit) return explicit;\n const testFlag = env?.CODEAM_TEST_MODE?.trim();\n if (testFlag === '1' || testFlag?.toLowerCase() === 'true') return DEV_API_BASE_URL;\n return DEFAULT_API_BASE_URL;\n}\n","/**\n * Headroom provisioning manifest — the SINGLE source of truth for what a\n * Headroom install consists of, rendered by every provisioning surface:\n *\n * - codespace bootstrap (bash composer in the backend repo,\n * `apps/api-v2/src/codespaces/github-ssh.service.ts` — adopts in PR-2),\n * - self-hosted deploy (TS installer, CLI `commands/host-agent.ts`\n * `setupHeadroomForSelfHosted`),\n * - on-demand local sessions (\"Session add-ons → Cost-saving\", CLI\n * `services/headroom/configure.ts`).\n *\n * Values are DATA-first (arrays/records, plus tiny pure renderers) so both\n * the TS installer and a bash composer can interpolate from them. Renderers\n * are byte-exact with the literals they replaced — guarded by\n * `packages/shared/__tests__/headroom-manifest.test.ts`.\n *\n * ⚠️ The extras matter: `[proxy,code]` pulls the ONNX compression engines\n * (Kompress + tree-sitter CodeCompressor). NEVER add `[ml]` — that's\n * multi-GB PyTorch, and a broken/cold torch wedges every prompt at\n * \"Thinking…\". The models are pre-downloaded at provision time because the\n * proxy eager-loads with `allow_download=False` and a cold cache defers the\n * ~840 MB download to the first prompt (blowing the agent's ~90 s idle\n * timeout).\n */\n\n/** Local proxy port the agent's config is routed to. */\nexport const HEADROOM_PROXY_PORT = 8787;\n\n/**\n * Env that pins the ONNX backend on the proxy process — never imports\n * torch. Spread into the proxy launch env on every surface.\n */\nexport const HEADROOM_BACKEND_ENV = {\n HEADROOM_KOMPRESS_BACKEND: 'onnx_cpu',\n} as const;\n\n/**\n * The proxy's HTTP/server companion packages, installed alongside the\n * `headroom-ai[...]` package. The COMPRESSION ENGINES come from the\n * headroom-ai extras — NOT this list.\n */\nexport const HEADROOM_PIP_COMPANIONS: readonly string[] = [\n 'fastapi',\n 'uvicorn',\n 'httpx[http2]',\n 'websockets',\n 'zstandard',\n];\n\n/** The three provisioning surfaces (see module doc). */\nexport type HeadroomSurface = 'codespace' | 'selfHosted' | 'onDemand';\n\n/**\n * pip extras per surface. `onDemand` additionally ships `image`\n * (image-compression support, added with the Session add-ons path in\n * codeam-cli@2.49.0); the older codespace/self-hosted install strings\n * remain `[proxy,code]` byte-for-byte.\n */\nexport const HEADROOM_EXTRAS_BY_SURFACE: Readonly<Record<HeadroomSurface, readonly string[]>> = {\n codespace: ['proxy', 'code'],\n selfHosted: ['proxy', 'code'],\n onDemand: ['proxy', 'code', 'image'],\n};\n\n/** `headroom-ai[<extras>]` — the pip requirement string. */\nexport function headroomPipPackage(extras: readonly string[]): string {\n return `headroom-ai[${extras.join(',')}]`;\n}\n\n/** One HuggingFace repo to pre-warm into the HF cache at provision time. */\nexport interface HeadroomModelSpec {\n repo: string;\n /** `snapshot_download(..., allow_patterns=[…])` filter. */\n allowPatterns: readonly string[];\n}\n\n/**\n * The two HF repos Kompress needs. kompress-v2-base is the ONNX model\n * (skip its .pt/.safetensors torch artifacts); ModernBERT-base is the\n * TOKENIZER ONLY (skip its model weights).\n */\nexport const HEADROOM_MODELS: readonly HeadroomModelSpec[] = [\n {\n repo: 'chopratejas/kompress-v2-base',\n allowPatterns: ['*.json', 'onnx/*.onnx', 'kompress-int8-wo.onnx'],\n },\n {\n repo: 'answerdotai/ModernBERT-base',\n allowPatterns: ['*.json', 'tokenizer*', '*.txt', 'vocab*', 'merges*'],\n },\n];\n\n/** Formatting knob so each surface can stay byte-identical to its\n * historical literal (the CLI joins patterns with `,`, the codespace\n * bash composer with `, `). */\nexport interface HeadroomPythonRenderOpts {\n /** Put a space after the commas between allow_patterns entries. */\n spaceAfterComma?: boolean;\n}\n\n/** Render one `snapshot_download(...)` python line for a model. */\nexport function headroomSnapshotDownloadLine(\n model: HeadroomModelSpec,\n opts: HeadroomPythonRenderOpts = {},\n): string {\n const sep = opts.spaceAfterComma ? ', ' : ',';\n const patterns = model.allowPatterns.map((p) => `\"${p}\"`).join(sep);\n return `snapshot_download(\"${model.repo}\", allow_patterns=[${patterns}])`;\n}\n\n/**\n * The full model pre-download python snippet (import + one\n * `snapshot_download` per model), newline-joined — what the surfaces pass\n * to `python -c` / a heredoc.\n */\nexport function headroomModelPredownloadScript(opts: HeadroomPythonRenderOpts = {}): string {\n return [\n 'from huggingface_hub import snapshot_download',\n ...HEADROOM_MODELS.map((m) => headroomSnapshotDownloadLine(m, opts)),\n ].join('\\n');\n}\n","/**\n * Canonical names of the per-user SSE bus events (`/api/users/me/stream`).\n *\n * The authoritative list is the `UserEvent` discriminated union in the\n * backend repo: codeagent-mobile/apps/api-v2/src/user-events/user-events.types.ts.\n * Every `type:` literal of that union appears here exactly once — when a new\n * variant lands on the union, add its name here (and in the backend mirror of\n * this file at codeagent-mobile/packages/shared/src/types/events.ts).\n *\n * Producers (CLI event posts, backend `userEvents.publish` calls) and\n * consumers (the `useUserEventsSSE` hooks' switch cases) should reference\n * `USER_EVENTS.*` instead of re-typing the string, so a typo becomes a\n * compile error instead of a silently dropped event.\n */\nexport const USER_EVENTS = {\n PAIRED_SESSION_STATUS: 'paired_session_status',\n PAIRED_SESSION_ADDED: 'paired_session_added',\n PAIRED_SESSION_REMOVED: 'paired_session_removed',\n PAIRED_SESSION_BRANCH_CHANGED: 'paired_session_branch_changed',\n SHARED_WITH_ME_ADDED: 'shared_with_me_added',\n SHARED_WITH_ME_REVOKED: 'shared_with_me_revoked',\n USAGE_CHANGED: 'usage_changed',\n TASK_DONE: 'task_done',\n HUNK_PENDING_REVIEW_ADDED: 'hunk_pending_review_added',\n HUNK_REVIEW_RESOLVED: 'hunk_review_resolved',\n FILE_CHANGED: 'file_changed',\n FILES_BATCH_CHANGED: 'files_batch_changed',\n AGENT_STREAMING_CHUNK: 'agent_streaming_chunk',\n AGENT_AWAITING_ANSWER: 'agent_awaiting_answer',\n AWAITING_INPUT_ADDED: 'awaiting_input_added',\n AGENT_ANSWER_RESOLVED: 'agent_answer_resolved',\n TEMPLATE_ADDED: 'template_added',\n TEMPLATE_REMOVED: 'template_removed',\n TEMPLATE_UPDATED: 'template_updated',\n AGENT_TASK_DISPATCHED: 'agent_task_dispatched',\n AGENT_TASK_COMPLETED: 'agent_task_completed',\n LINKED_AGENT_ADDED: 'linked_agent_added',\n QUOTA_REACHED: 'quota_reached',\n LINKED_AGENT_LINK_FAILED: 'linked_agent_link_failed',\n CODESPACE_AGENT_INSTALLED: 'codespace_agent_installed',\n AGENT_CREDENTIALS_REFRESHED: 'agent_credentials_refreshed',\n CREDENTIAL_INVALID: 'credential_invalid',\n CODESPACE_WAKING: 'codespace_waking',\n CODESPACE_BILLING_BLOCKED: 'codespace_billing_blocked',\n COST_SAVING_UPDATED: 'cost_saving_updated',\n COMMAND_COMPLETED: 'command_completed',\n AI_SUMMARY_PENDING: 'ai_summary_pending',\n AI_SUMMARY_READY: 'ai_summary_ready',\n AI_INSIGHT_PENDING: 'ai_insight_pending',\n AI_INSIGHT_READY: 'ai_insight_ready',\n PUSH_TOKEN_INVALIDATED: 'push_token_invalidated',\n PREVIEW_DETECTION_PENDING: 'preview_detection_pending',\n PREVIEW_DETECTION_READY: 'preview_detection_ready',\n PREVIEW_STARTING: 'preview_starting',\n PREVIEW_READY: 'preview_ready',\n PREVIEW_STOPPED: 'preview_stopped',\n PREVIEW_ERROR: 'preview_error',\n PREVIEW_PROGRESS: 'preview_progress',\n BEADS_STATE_CHANGED: 'beads_state_changed',\n BEADS_PROVISIONING: 'beads_provisioning',\n BEADS_TEAM_MEMORY_CHANGED: 'beads_team_memory_changed',\n AUDIT_EVENT_ADDED: 'audit_event_added',\n SELF_HOSTED_HOST_ADDED: 'self_hosted_host_added',\n SELF_HOSTED_HOST_STATUS: 'self_hosted_host_status',\n SELF_HOSTED_HOST_REMOVED: 'self_hosted_host_removed',\n SELF_HOSTED_HOST_TELEMETRY: 'self_hosted_host_telemetry',\n SELF_HOSTED_HOST_METRICS: 'self_hosted_host_metrics',\n SELF_HOSTED_HOST_SESSIONS: 'self_hosted_host_sessions',\n SELF_HOSTED_DEPLOY_PROGRESS: 'self_hosted_deploy_progress',\n REFERRAL_REWARD_EARNED: 'referral_reward_earned',\n HEADROOM_PROGRESS: 'headroom_progress',\n HEADROOM_STATUS: 'headroom_status',\n BEADS_STATUS: 'beads_status',\n LINKED_AGENT_HEADROOM_BUDGET_UPDATED: 'linked_agent_headroom_budget_updated',\n CLI_UPDATE_AVAILABLE: 'cli_update_available',\n AGENT_INSTALL_PROGRESS: 'agent_install_progress',\n AGENT_INSTALL_FAILED: 'agent_install_failed',\n CLI_UPDATE_PROGRESS: 'cli_update_progress',\n CLI_UPDATE_FAILED: 'cli_update_failed',\n BATON_STATE: 'baton_state',\n} as const;\n\nexport type UserEventName = (typeof USER_EVENTS)[keyof typeof USER_EVENTS];\n","/**\n * Prompt the CLI sends to the user's linked agent (Claude, Codex, …)\n * in a headless one-shot to detect how to start the project's dev\n * server. Same pattern as the AI Insights \"summary\" prompt — the\n * agent runs locally with the user's auth, has read access to the\n * project, and returns a tiny JSON blob the CLI parses.\n *\n * Kept here (in `@codeam/shared`) so the CLI build inlines the\n * exact string at compile time without runtime fetch from the backend.\n */\nexport const PREVIEW_DETECT_PROMPT = `\nAnalyze the project in the current working directory and return how to start\nits development server for in-app preview.\n\nRead package.json, Procfile, Dockerfile, docker-compose.yml, manage.py, app.json,\nmix.exs, Cargo.toml, go.mod, requirements.txt, Gemfile, and any other framework\nmarkers you find at depth <= 2.\n\nReturn ONLY a JSON object on stdout (no prose, no markdown fences):\n\n{\n \"framework\": \"<name, or 'unsupported'>\",\n \"command\": \"<executable>\",\n \"args\": [\"...\"],\n \"port\": <number>,\n \"ready_pattern\": \"<regex matching the server-ready stdout line>\",\n \"env\": { \"HOST\": \"0.0.0.0\" },\n \"setup_commands\": [{ \"cmd\": \"<executable>\", \"args\": [\"...\"] }],\n \"notes\": \"<one-line caveat or null>\"\n}\n\nRules:\n- Pick the script the developer would run locally to see the app (typically \"dev\", \"start\", \"serve\").\n- Prefer binding to 0.0.0.0 — most frameworks default to localhost which the tunnel cannot reach.\n- For Expo: framework=\"Expo\", command=\"npx\", args=[\"expo\",\"start\",\"--tunnel\"], port=8081, notes=\"Scan QR with Expo Go\".\n- If no dev server applies (CLI library, lambda, batch script): {\"framework\":\"unsupported\",\"notes\":\"<reason>\"}.\n\nCRITICAL — setup_commands:\n- DO NOT include an install command (npm install, pnpm install, yarn install,\n yarn, bun install) in setup_commands. A lockfile-aware pre-flight installer\n runs BEFORE setup_commands and picks the correct package manager from the\n lockfile present (pnpm-lock.yaml -> pnpm, yarn.lock -> yarn, bun.lockb -> bun,\n else npm). Emitting an install here either duplicates that work or, worse,\n uses the WRONG package manager on top of node_modules just populated by the\n pre-flight, which crashes (e.g. npm errors with \"Cannot read properties of\n null (reading 'matches')\" when run over pnpm's .pnpm/ layout).\n- ONLY include setup_commands for genuinely non-install work the project needs\n before its dev server can boot: prisma generate, codegen, prebuild scripts,\n database migrations against a local SQLite, etc.\n- Each setup_commands entry MUST be an object {\"cmd\": \"...\", \"args\": [\"...\"]} —\n e.g. {\"cmd\": \"npx\", \"args\": [\"prisma\", \"generate\"]}. NOT a bare string.\n- For most projects, setup_commands should be an empty array [].\n\nOUTPUT JSON ONLY. NO MARKDOWN. NO COMMENTARY.\n`.trim();\n"],"mappings":";AAiBO,IAAM,mBAAmB;AAezB,IAAM,uBAAuB;AAS7B,IAAM,gCAAgC;AAOtC,IAAM,wBAAwB;;;ACvC9B,SAAS,cAAc,KAAuB;AACnD,QAAM,SAAmB,CAAC,EAAE;AAC5B,MAAI,MAAM;AACV,MAAI,MAAM;AAEV,WAAS,YAAkB;AACzB,WAAO,OAAO,UAAU,IAAK,QAAO,KAAK,EAAE;AAAA,EAC7C;AAEA,WAAS,UAA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AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EA4CnC,KAAK;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codeam/shared",
3
- "version": "2.60.12",
3
+ "version": "2.60.14",
4
4
  "description": "CodeAgent Mobile wire-protocol contract: chunk-protocol renderer, RemoteCommand envelope, SSE event names, model pricing tables, and cross-repo wire types shared by codeam-cli, the VS Code extension, and the backend.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",