@warlock.js/ai-cli 5.31.0 → 5.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/cjs/index.cjs +38 -46
- package/cjs/index.cjs.map +1 -1
- package/esm/adapters/aider.d.mts +4 -4
- package/esm/adapters/aider.d.mts.map +1 -1
- package/esm/adapters/amp.d.mts +2 -2
- package/esm/adapters/amp.d.mts.map +1 -1
- package/esm/adapters/antigravity.d.mts +3 -3
- package/esm/adapters/antigravity.d.mts.map +1 -1
- package/esm/adapters/claude-code.d.mts +2 -2
- package/esm/adapters/claude-code.d.mts.map +1 -1
- package/esm/adapters/claude-stream.d.mts +3 -3
- package/esm/adapters/claude-stream.d.mts.map +1 -1
- package/esm/adapters/codex.d.mts +3 -3
- package/esm/adapters/codex.d.mts.map +1 -1
- package/esm/adapters/codex.mjs +10 -8
- package/esm/adapters/codex.mjs.map +1 -1
- package/esm/adapters/copilot.d.mts +3 -3
- package/esm/adapters/copilot.d.mts.map +1 -1
- package/esm/adapters/copilot.mjs +5 -7
- package/esm/adapters/copilot.mjs.map +1 -1
- package/esm/adapters/cursor.d.mts +3 -3
- package/esm/adapters/cursor.d.mts.map +1 -1
- package/esm/adapters/droid.d.mts +3 -3
- package/esm/adapters/droid.d.mts.map +1 -1
- package/esm/adapters/grok.d.mts +3 -3
- package/esm/adapters/grok.d.mts.map +1 -1
- package/esm/adapters/grok.mjs +6 -8
- package/esm/adapters/grok.mjs.map +1 -1
- package/esm/adapters/index.d.mts +2 -1
- package/esm/adapters/index.mjs +1 -1
- package/esm/adapters/kimi.d.mts +3 -3
- package/esm/adapters/kimi.d.mts.map +1 -1
- package/esm/adapters/mistral-vibe.d.mts +3 -3
- package/esm/adapters/mistral-vibe.d.mts.map +1 -1
- package/esm/adapters/mistral-vibe.mjs +5 -7
- package/esm/adapters/mistral-vibe.mjs.map +1 -1
- package/esm/adapters/opencode.d.mts +3 -3
- package/esm/adapters/opencode.d.mts.map +1 -1
- package/esm/adapters/qwen-code.d.mts +2 -2
- package/esm/adapters/qwen-code.d.mts.map +1 -1
- package/esm/adapters/reasonix.d.mts +3 -3
- package/esm/adapters/reasonix.d.mts.map +1 -1
- package/esm/adapters/reasonix.mjs +6 -8
- package/esm/adapters/reasonix.mjs.map +1 -1
- package/esm/adapters/shared.d.mts +19 -16
- package/esm/adapters/shared.d.mts.map +1 -1
- package/esm/cli-agent.d.mts +9 -8
- package/esm/cli-agent.d.mts.map +1 -1
- package/esm/cli.d.mts +11 -8
- package/esm/cli.d.mts.map +1 -1
- package/esm/contracts/adapter.contract.d.mts +52 -31
- package/esm/contracts/adapter.contract.d.mts.map +1 -1
- package/esm/contracts/events.type.d.mts +36 -24
- package/esm/contracts/events.type.d.mts.map +1 -1
- package/esm/contracts/index.d.mts +2 -1
- package/esm/contracts/mcp.type.d.mts +4 -5
- package/esm/contracts/mcp.type.d.mts.map +1 -1
- package/esm/contracts/options.type.d.mts +56 -31
- package/esm/contracts/options.type.d.mts.map +1 -1
- package/esm/errors.d.mts +11 -9
- package/esm/errors.d.mts.map +1 -1
- package/esm/index.d.mts +2 -0
- package/esm/model/cli-model.d.mts +8 -7
- package/esm/model/cli-model.d.mts.map +1 -1
- package/esm/probe/probe.d.mts +4 -4
- package/esm/probe/probe.d.mts.map +1 -1
- package/esm/probe/probe.mjs +2 -2
- package/esm/probe/probe.mjs.map +1 -1
- package/esm/session/aggregate.mjs +2 -4
- package/esm/session/aggregate.mjs.map +1 -1
- package/esm/session/environment.mjs +1 -1
- package/esm/spawn/invocation.d.mts +6 -7
- package/esm/spawn/invocation.d.mts.map +1 -1
- package/esm/spawn/invocation.mjs +3 -3
- package/esm/spawn/invocation.mjs.map +1 -1
- package/esm/spawn/resolve-command.d.mts +12 -10
- package/esm/spawn/resolve-command.d.mts.map +1 -1
- package/esm/stream/json-lines.d.mts +10 -10
- package/esm/stream/json-lines.d.mts.map +1 -1
- package/esm/stream/line-splitter.mjs +2 -2
- package/esm/stream/line-splitter.mjs.map +1 -1
- package/esm/utils/toml.d.mts +3 -4
- package/esm/utils/toml.d.mts.map +1 -1
- package/package.json +2 -2
package/esm/adapters/aider.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CliAdapter, CliLaunchContext, CliStreamParser } from "../contracts/adapter.contract.mjs";
|
|
2
|
+
import "../contracts/index.mjs";
|
|
2
3
|
//#region ../../packages/ai-cli/src/adapters/aider.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* Aider (`aider`, PyPI `aider-chat`).
|
|
@@ -31,11 +32,10 @@ import { CliAdapter, CliLaunchContext, CliStreamParser } from "../contracts/adap
|
|
|
31
32
|
* (`OPENAI_API_KEY`, `ANTHROPIC_API_KEY`, …) via `env`. Always pass
|
|
32
33
|
* `model` — without one Aider may start an interactive OAuth flow.
|
|
33
34
|
*/
|
|
34
|
-
declare const aiderAdapter: CliAdapter;
|
|
35
|
+
export declare const aiderAdapter: CliAdapter;
|
|
35
36
|
/** `2.4k` → 2400, `12k` → 12000, `61` → 61. */
|
|
36
|
-
declare function parseAiderCount(value: string | undefined): number | undefined;
|
|
37
|
+
export declare function parseAiderCount(value: string | undefined): number | undefined;
|
|
37
38
|
/** Parser for Aider's plain-text stdout (plus its analytics log). */
|
|
38
|
-
declare function createAiderParser(context?: CliLaunchContext): CliStreamParser;
|
|
39
|
+
export declare function createAiderParser(context?: CliLaunchContext): CliStreamParser;
|
|
39
40
|
//#endregion
|
|
40
|
-
export { aiderAdapter, createAiderParser, parseAiderCount };
|
|
41
41
|
//# sourceMappingURL=aider.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"aider.d.mts","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/aider.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"aider.d.mts","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/aider.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA8Ca,cAAc;;wBAkGX,gBAAgB;;wBA8EhB,kBAAkB,UAAU,mBAAmB"}
|
package/esm/adapters/amp.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CliAdapter } from "../contracts/adapter.contract.mjs";
|
|
2
|
+
import "../contracts/index.mjs";
|
|
2
3
|
//#region ../../packages/ai-cli/src/adapters/amp.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* Amp (`amp`, npm `@ampcode/cli`; `@sourcegraph/amp` is a shim to it).
|
|
@@ -27,7 +28,6 @@ import { CliAdapter } from "../contracts/adapter.contract.mjs";
|
|
|
27
28
|
* - Home: Amp follows XDG (`$XDG_CONFIG_HOME/amp/settings.json`); auth
|
|
28
29
|
* `AMP_API_KEY`; update checks off with `AMP_SKIP_UPDATE_CHECK=1`.
|
|
29
30
|
*/
|
|
30
|
-
declare const ampAdapter: CliAdapter;
|
|
31
|
+
export declare const ampAdapter: CliAdapter;
|
|
31
32
|
//#endregion
|
|
32
|
-
export { ampAdapter };
|
|
33
33
|
//# sourceMappingURL=amp.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"amp.d.mts","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/amp.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"amp.d.mts","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/amp.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAgCa,YAAY"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CliAdapter, CliStreamParser } from "../contracts/adapter.contract.mjs";
|
|
2
|
+
import "../contracts/index.mjs";
|
|
2
3
|
//#region ../../packages/ai-cli/src/adapters/antigravity.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* Google Antigravity CLI (`agy`), installed by the
|
|
@@ -29,9 +30,8 @@ import { CliAdapter, CliStreamParser } from "../contracts/adapter.contract.mjs";
|
|
|
29
30
|
* `$HOME/.gemini/antigravity-cli/settings.json`; the adapter writes that
|
|
30
31
|
* file when `apiKey` is set on a private home.
|
|
31
32
|
*/
|
|
32
|
-
declare const antigravityAdapter: CliAdapter;
|
|
33
|
+
export declare const antigravityAdapter: CliAdapter;
|
|
33
34
|
/** Parser for `agy -p … --output-format stream-json`. */
|
|
34
|
-
declare function createAntigravityParser(): CliStreamParser;
|
|
35
|
+
export declare function createAntigravityParser(): CliStreamParser;
|
|
35
36
|
//#endregion
|
|
36
|
-
export { antigravityAdapter, createAntigravityParser };
|
|
37
37
|
//# sourceMappingURL=antigravity.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"antigravity.d.mts","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/antigravity.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"antigravity.d.mts","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/antigravity.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA8Ca,oBAAoB;;wBA6HjB,2BAA2B"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CliAdapter } from "../contracts/adapter.contract.mjs";
|
|
2
|
+
import "../contracts/index.mjs";
|
|
2
3
|
//#region ../../packages/ai-cli/src/adapters/claude-code.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* Claude Code (`claude`, npm `@anthropic-ai/claude-code`).
|
|
@@ -24,7 +25,6 @@ import { CliAdapter } from "../contracts/adapter.contract.mjs";
|
|
|
24
25
|
* - Home: `CLAUDE_CONFIG_DIR`; auth `ANTHROPIC_API_KEY` (or a home you
|
|
25
26
|
* logged in to); auto-update off with `DISABLE_AUTOUPDATER=1`.
|
|
26
27
|
*/
|
|
27
|
-
declare const claudeCodeAdapter: CliAdapter;
|
|
28
|
+
export declare const claudeCodeAdapter: CliAdapter;
|
|
28
29
|
//#endregion
|
|
29
|
-
export { claudeCodeAdapter };
|
|
30
30
|
//# sourceMappingURL=claude-code.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-code.d.mts","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/claude-code.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"claude-code.d.mts","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/claude-code.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;qBA6Ba,mBAAmB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CliStreamParser } from "../contracts/adapter.contract.mjs";
|
|
2
|
+
import "../contracts/index.mjs";
|
|
2
3
|
//#region ../../packages/ai-cli/src/adapters/claude-stream.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* How a Claude-style stream reports input tokens.
|
|
@@ -6,7 +7,7 @@ import { CliStreamParser } from "../contracts/adapter.contract.mjs";
|
|
|
6
7
|
* - `anthropic` — `input_tokens` excludes cache reads/writes (Claude Code).
|
|
7
8
|
* - `inclusive` — `input_tokens` already includes cached tokens (Qwen Code).
|
|
8
9
|
*/
|
|
9
|
-
type ClaudeStreamUsage = "anthropic" | "inclusive";
|
|
10
|
+
export type ClaudeStreamUsage = "anthropic" | "inclusive";
|
|
10
11
|
/**
|
|
11
12
|
* Parser for the Claude Code `stream-json` format, which several CLIs
|
|
12
13
|
* reproduce (Qwen Code, Grok Build's `streaming-messages-json`):
|
|
@@ -23,10 +24,9 @@ type ClaudeStreamUsage = "anthropic" | "inclusive";
|
|
|
23
24
|
* Sub-agent traffic (`parent_tool_use_id` set) is reported like the main
|
|
24
25
|
* thread's, so its tool calls stay visible.
|
|
25
26
|
*/
|
|
26
|
-
declare function createClaudeStreamParser(options?: {
|
|
27
|
+
export declare function createClaudeStreamParser(options?: {
|
|
27
28
|
usage?: ClaudeStreamUsage;
|
|
28
29
|
vendor?: string;
|
|
29
30
|
}): CliStreamParser;
|
|
30
31
|
//#endregion
|
|
31
|
-
export { ClaudeStreamUsage, createClaudeStreamParser };
|
|
32
32
|
//# sourceMappingURL=claude-stream.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-stream.d.mts","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/claude-stream.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"claude-stream.d.mts","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/claude-stream.ts"],"mappings":";;;;;;;;;YAmBY;;;;;;;;;;;;;;;;;wBAoCI,yBACd;EAAW,QAAQ;EAAmB;IACrC"}
|
package/esm/adapters/codex.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CliAdapter, CliStreamParser } from "../contracts/adapter.contract.mjs";
|
|
2
|
+
import "../contracts/index.mjs";
|
|
2
3
|
//#region ../../packages/ai-cli/src/adapters/codex.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* OpenAI Codex CLI (`codex`, npm `@openai/codex`).
|
|
@@ -29,9 +30,8 @@ import { CliAdapter, CliStreamParser } from "../contracts/adapter.contract.mjs";
|
|
|
29
30
|
* process environment, named through `env_vars` / `env_http_headers`.
|
|
30
31
|
* - Home `CODEX_HOME`; auth `CODEX_API_KEY`.
|
|
31
32
|
*/
|
|
32
|
-
declare const codexAdapter: CliAdapter;
|
|
33
|
+
export declare const codexAdapter: CliAdapter;
|
|
33
34
|
/** Parser for `codex exec --json`. */
|
|
34
|
-
declare function createCodexParser(): CliStreamParser;
|
|
35
|
+
export declare function createCodexParser(): CliStreamParser;
|
|
35
36
|
//#endregion
|
|
36
|
-
export { codexAdapter, createCodexParser };
|
|
37
37
|
//# sourceMappingURL=codex.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex.d.mts","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/codex.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"codex.d.mts","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/codex.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA+Ca,cAAc;;wBA0OX,qBAAqB"}
|
package/esm/adapters/codex.mjs
CHANGED
|
@@ -93,13 +93,15 @@ const codexAdapter = {
|
|
|
93
93
|
args.push("--dangerously-bypass-approvals-and-sandbox");
|
|
94
94
|
requires.push("--dangerously-bypass-approvals-and-sandbox");
|
|
95
95
|
}
|
|
96
|
-
if (context.mcp !== void 0)
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
96
|
+
if (context.mcp !== void 0) {
|
|
97
|
+
if (context.home !== void 0 && context.homeIsPrivate) files.push({
|
|
98
|
+
path: path.join(context.home, "config.toml"),
|
|
99
|
+
content: toToml({ mcp_servers: codexMcpTable(context.mcp) })
|
|
100
|
+
});
|
|
101
|
+
else {
|
|
102
|
+
args.push(...codexMcpOverrides(context.mcp, env));
|
|
103
|
+
requires.push("--config");
|
|
104
|
+
}
|
|
103
105
|
}
|
|
104
106
|
if (context.home !== void 0) env.CODEX_HOME = context.home;
|
|
105
107
|
const prompt = context.transport === "argv" ? argvPrompt(context.prompt) : "-";
|
|
@@ -168,7 +170,7 @@ function codexMcpOverrides(servers, env) {
|
|
|
168
170
|
}
|
|
169
171
|
return overrides;
|
|
170
172
|
}
|
|
171
|
-
const TOOL_ITEMS = new Set([
|
|
173
|
+
const TOOL_ITEMS = /* @__PURE__ */ new Set([
|
|
172
174
|
"command_execution",
|
|
173
175
|
"file_change",
|
|
174
176
|
"mcp_tool_call",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex.mjs","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/codex.ts"],"sourcesContent":["import path from \"node:path\";\nimport type {\n CliAdapter,\n CliLaunchFile,\n CliMcpServers,\n CliParsedEvent,\n CliStreamParser,\n} from \"../contracts\";\nimport {\n jsonLinesParser,\n numberField,\n outputText,\n recordField,\n stringField,\n} from \"../stream/json-lines\";\nimport { type TomlTable, tomlKey, toToml } from \"../utils/toml\";\nimport { argvPrompt, mapEffort, unsupportedOption, usageOf } from \"./shared\";\n\n/**\n * OpenAI Codex CLI (`codex`, npm `@openai/codex`).\n *\n * Verified against the real `codex exec --help` / `codex exec resume\n * --help` of 0.163.0, the source at tag `rust-v0.163.0` (`exec_events.rs`,\n * the JSONL event processor, `cli.rs`) and the docs (non-interactive mode,\n * config reference), 2026-10-17.\n *\n * - Headless: `codex exec --json --skip-git-repo-check <prompt>` (`-` reads\n * the prompt from stdin); resume is `codex exec resume … <thread_id>\n * <prompt>`.\n * - Stream: `thread.started` (`thread_id`), `item.started`/`item.completed`\n * with `item.type` `agent_message`, `reasoning`, `command_execution`,\n * `file_change`, `mcp_tool_call`, `web_search`, `error`; `turn.completed`\n * with the thread's cumulative `usage` (`input_tokens` includes\n * `cached_input_tokens`); `turn.failed` and `error` on failure. No text\n * deltas and no cost field.\n * - Permissions: exec never asks (approval policy \"never\"); `standard` keeps\n * Codex's default **read-only** sandbox — allow edits with\n * `args: [\"-c\", \"sandbox_mode=workspace-write\"]`. Bypass is\n * `--dangerously-bypass-approvals-and-sandbox`.\n * - Effort: `-c model_reasoning_effort=<level>`.\n * - MCP: no flag. With a private home the servers go into\n * `$CODEX_HOME/config.toml` (0600). With a caller-owned or inherited home\n * they are passed as `-c mcp_servers.<name>.…` overrides that carry only\n * the command, args and URL; secret `env` values and headers travel in the\n * process environment, named through `env_vars` / `env_http_headers`.\n * - Home `CODEX_HOME`; auth `CODEX_API_KEY`.\n */\nexport const codexAdapter: CliAdapter = {\n name: \"codex\",\n title: \"Codex CLI\",\n command: \"codex\",\n apiKeyEnv: [\"CODEX_API_KEY\"],\n homeEnv: [\"CODEX_HOME\"],\n transports: [\"argv\", \"stdin\"],\n effort: true,\n mcp: true,\n probe: {\n help: [\n [\"exec\", \"--help\"],\n [\"exec\", \"resume\", \"--help\"],\n ],\n version: [\"--version\"],\n },\n verification: {\n version: \"0.163.0\",\n verifiedBy: \"help\",\n sources: [\n \"https://developers.openai.com/codex/noninteractive\",\n \"https://developers.openai.com/codex/config-reference\",\n \"https://github.com/openai/codex/blob/rust-v0.163.0/codex-rs/exec/src/exec_events.rs\",\n ],\n checkedAt: \"2026-10-17\",\n },\n plan(context) {\n const args = [\"exec\"];\n const requires = [\"exec\", \"--json\", \"--skip-git-repo-check\"];\n const files: CliLaunchFile[] = [];\n const env: Record<string, string> = {};\n\n if (context.resume !== undefined) {\n args.push(\"resume\");\n requires.push(\"resume\");\n }\n\n args.push(\"--json\", \"--skip-git-repo-check\", \"-c\", \"check_for_update_on_startup=false\");\n\n if (context.model !== undefined) {\n args.push(\"--model\", context.model);\n requires.push(\"--model\");\n }\n\n if (context.effort !== undefined) {\n const effort = mapEffort(context.effort, {\n low: \"low\",\n medium: \"medium\",\n high: \"high\",\n xhigh: \"xhigh\",\n max: \"max\",\n });\n\n args.push(\"-c\", `model_reasoning_effort=${effort}`);\n requires.push(\"--config\");\n }\n\n if (context.permission === \"bypass\") {\n args.push(\"--dangerously-bypass-approvals-and-sandbox\");\n requires.push(\"--dangerously-bypass-approvals-and-sandbox\");\n }\n\n if (context.mcp !== undefined) {\n if (context.home !== undefined && context.homeIsPrivate) {\n files.push({\n path: path.join(context.home, \"config.toml\"),\n content: toToml({ mcp_servers: codexMcpTable(context.mcp) }),\n });\n } else {\n args.push(...codexMcpOverrides(context.mcp, env));\n requires.push(\"--config\");\n }\n }\n\n if (context.home !== undefined) {\n env.CODEX_HOME = context.home;\n }\n\n const prompt = context.transport === \"argv\" ? argvPrompt(context.prompt) : \"-\";\n\n return {\n args,\n tail: context.resume !== undefined ? [context.resume, prompt] : [prompt],\n stdin: context.transport === \"stdin\" ? context.prompt : undefined,\n env,\n files,\n requires,\n };\n },\n parser: createCodexParser,\n};\n\n/** `[mcp_servers.<name>]` tables for a private `config.toml`. */\nfunction codexMcpTable(servers: CliMcpServers): TomlTable {\n const table: TomlTable = {};\n\n for (const [name, server] of Object.entries(servers)) {\n if (server.type === \"sse\") {\n throw unsupportedOption(\n codexAdapter,\n `MCP server \"${name}\" uses SSE; Codex supports stdio and streamable HTTP.`,\n );\n }\n\n table[name] =\n server.type === \"stdio\"\n ? { command: server.command, args: server.args ?? [], env: server.env }\n : { url: server.url, http_headers: server.headers };\n }\n\n return table;\n}\n\n/** A TOML string for a `-c key=value` override. */\nfunction tomlString(value: string): string {\n return JSON.stringify(value);\n}\n\n/**\n * `-c` overrides that carry no secret: env values and header values are put\n * in `env` (the Codex process environment) and only their names go to argv.\n */\nfunction codexMcpOverrides(servers: CliMcpServers, env: Record<string, string>): string[] {\n const overrides: string[] = [];\n const claim = (name: string, value: string): void => {\n if (env[name] !== undefined && env[name] !== value) {\n throw unsupportedOption(\n codexAdapter,\n `two MCP servers set ${name} to different values; with a shared home they share one environment.`,\n );\n }\n\n env[name] = value;\n };\n\n for (const [name, server] of Object.entries(servers)) {\n const prefix = `mcp_servers.${tomlKey(name)}`;\n\n if (server.type === \"sse\") {\n throw unsupportedOption(\n codexAdapter,\n `MCP server \"${name}\" uses SSE; Codex supports stdio and streamable HTTP.`,\n );\n }\n\n if (server.type === \"stdio\") {\n overrides.push(\"-c\", `${prefix}.command=${tomlString(server.command)}`);\n overrides.push(\"-c\", `${prefix}.args=[${(server.args ?? []).map(tomlString).join(\",\")}]`);\n\n const names = Object.keys(server.env ?? {});\n\n for (const [key, value] of Object.entries(server.env ?? {})) {\n claim(key, value);\n }\n\n if (names.length > 0) {\n overrides.push(\"-c\", `${prefix}.env_vars=[${names.map(tomlString).join(\",\")}]`);\n }\n\n continue;\n }\n\n overrides.push(\"-c\", `${prefix}.url=${tomlString(server.url)}`);\n\n const headers = Object.entries(server.headers ?? {});\n\n if (headers.length > 0) {\n const mapping = headers.map(([header, value], index) => {\n const variable = `WARLOCK_MCP_${name.replace(/\\W/g, \"_\").toUpperCase()}_HEADER_${index}`;\n\n claim(variable, value);\n\n return `${tomlString(header)}=${tomlString(variable)}`;\n });\n\n overrides.push(\"-c\", `${prefix}.env_http_headers={${mapping.join(\",\")}}`);\n }\n }\n\n return overrides;\n}\n\nconst TOOL_ITEMS = new Set([\n \"command_execution\",\n \"file_change\",\n \"mcp_tool_call\",\n \"web_search\",\n \"collab_tool_call\",\n]);\n\nfunction toolCall(item: Record<string, unknown>): { name: string; input: unknown } {\n switch (stringField(item, \"type\")) {\n case \"command_execution\":\n return { name: \"shell\", input: { command: item.command } };\n case \"file_change\":\n return { name: \"apply_patch\", input: { changes: item.changes } };\n case \"mcp_tool_call\":\n return {\n name: `${stringField(item, \"server\") ?? \"mcp\"}.${stringField(item, \"tool\") ?? \"tool\"}`,\n input: item.arguments,\n };\n case \"web_search\":\n return { name: \"web_search\", input: { query: item.query } };\n default:\n return { name: stringField(item, \"type\") ?? \"tool\", input: item };\n }\n}\n\nfunction toolResult(item: Record<string, unknown>): { output: string; isError: boolean } {\n const status = stringField(item, \"status\");\n const failed = status === \"failed\" || status === \"declined\";\n\n switch (stringField(item, \"type\")) {\n case \"command_execution\": {\n const exitCode = numberField(item, \"exit_code\");\n\n return {\n output: stringField(item, \"aggregated_output\") ?? \"\",\n isError: failed || (exitCode !== undefined && exitCode !== 0),\n };\n }\n case \"mcp_tool_call\": {\n const error = stringField(recordField(item, \"error\"), \"message\");\n\n return error !== undefined\n ? { output: error, isError: true }\n : { output: outputText(recordField(item, \"result\")?.content), isError: failed };\n }\n default:\n return { output: outputText(item.changes ?? item.result ?? \"\"), isError: failed };\n }\n}\n\n/** Parser for `codex exec --json`. */\nexport function createCodexParser(): CliStreamParser {\n const announced = new Set<string>();\n\n return jsonLinesParser((record): CliParsedEvent[] => {\n const type = stringField(record, \"type\");\n const item = recordField(record, \"item\");\n const itemType = stringField(item, \"type\");\n const id = stringField(item, \"id\") ?? \"\";\n\n if (type === \"thread.started\") {\n return [\n { type: \"session.started\", sessionRef: stringField(record, \"thread_id\"), raw: record },\n ];\n }\n\n if (\n type === \"item.started\" &&\n item !== undefined &&\n itemType !== undefined &&\n TOOL_ITEMS.has(itemType)\n ) {\n announced.add(id);\n\n return [{ type: \"tool.call\", id, ...toolCall(item), raw: record }];\n }\n\n if (type === \"item.completed\" && item !== undefined) {\n if (itemType === \"agent_message\") {\n const text = stringField(item, \"text\") ?? \"\";\n\n return text.length > 0 ? [{ type: \"message\", text, delta: false, raw: record }] : [];\n }\n\n if (itemType === \"error\") {\n return [{ type: \"error\", message: stringField(item, \"message\") ?? \"error\", raw: record }];\n }\n\n if (itemType !== undefined && TOOL_ITEMS.has(itemType)) {\n const events: CliParsedEvent[] = [];\n\n if (!announced.has(id)) {\n events.push({ type: \"tool.call\", id, ...toolCall(item), raw: record });\n }\n\n events.push({ type: \"tool.result\", id, ...toolResult(item), raw: record });\n\n return events;\n }\n\n return [];\n }\n\n if (type === \"turn.completed\") {\n const usage = recordField(record, \"usage\");\n\n if (usage === undefined) {\n return [];\n }\n\n const cached = numberField(usage, \"cached_input_tokens\");\n const written = numberField(usage, \"cache_write_input_tokens\");\n\n return [\n {\n type: \"usage\",\n cumulative: true,\n usage: usageOf({\n input: numberField(usage, \"input_tokens\"),\n output: numberField(usage, \"output_tokens\"),\n cachedTokens: cached !== undefined && cached > 0 ? cached : undefined,\n cacheWriteTokens: written !== undefined && written > 0 ? written : undefined,\n reasoningTokens: numberField(usage, \"reasoning_output_tokens\") || undefined,\n }),\n raw: record,\n },\n ];\n }\n\n if (type === \"turn.failed\") {\n return [\n {\n type: \"error\",\n message: stringField(recordField(record, \"error\"), \"message\") ?? \"Codex turn failed\",\n fatal: true,\n raw: record,\n },\n ];\n }\n\n if (type === \"error\") {\n return [\n {\n type: \"error\",\n message: stringField(record, \"message\") ?? \"Codex error\",\n fatal: true,\n raw: record,\n },\n ];\n }\n\n return [];\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAa,eAA2B;CACtC,MAAM;CACN,OAAO;CACP,SAAS;CACT,WAAW,CAAC,eAAe;CAC3B,SAAS,CAAC,YAAY;CACtB,YAAY,CAAC,QA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N,SAAS,YAAY,YAAY,QAAQ,OAAO,GAAG,SAAS,KAAK;GACjE,OAAO;GACP,KAAK;EACP,CACF;EAGF,IAAI,SAAS,SACX,OAAO,CACL;GACE,MAAM;GACN,SAAS,YAAY,QAAQ,SAAS,KAAK;GAC3C,OAAO;GACP,KAAK;EACP,CACF;EAGF,OAAO,CAAC;CACV,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"codex.mjs","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/codex.ts"],"sourcesContent":["import path from \"node:path\";\nimport type {\n CliAdapter,\n CliLaunchFile,\n CliMcpServers,\n CliParsedEvent,\n CliStreamParser,\n} from \"../contracts\";\nimport {\n jsonLinesParser,\n numberField,\n outputText,\n recordField,\n stringField,\n} from \"../stream/json-lines\";\nimport { type TomlTable, tomlKey, toToml } from \"../utils/toml\";\nimport { argvPrompt, mapEffort, unsupportedOption, usageOf } from \"./shared\";\n\n/**\n * OpenAI Codex CLI (`codex`, npm `@openai/codex`).\n *\n * Verified against the real `codex exec --help` / `codex exec resume\n * --help` of 0.163.0, the source at tag `rust-v0.163.0` (`exec_events.rs`,\n * the JSONL event processor, `cli.rs`) and the docs (non-interactive mode,\n * config reference), 2026-10-17.\n *\n * - Headless: `codex exec --json --skip-git-repo-check <prompt>` (`-` reads\n * the prompt from stdin); resume is `codex exec resume … <thread_id>\n * <prompt>`.\n * - Stream: `thread.started` (`thread_id`), `item.started`/`item.completed`\n * with `item.type` `agent_message`, `reasoning`, `command_execution`,\n * `file_change`, `mcp_tool_call`, `web_search`, `error`; `turn.completed`\n * with the thread's cumulative `usage` (`input_tokens` includes\n * `cached_input_tokens`); `turn.failed` and `error` on failure. No text\n * deltas and no cost field.\n * - Permissions: exec never asks (approval policy \"never\"); `standard` keeps\n * Codex's default **read-only** sandbox — allow edits with\n * `args: [\"-c\", \"sandbox_mode=workspace-write\"]`. Bypass is\n * `--dangerously-bypass-approvals-and-sandbox`.\n * - Effort: `-c model_reasoning_effort=<level>`.\n * - MCP: no flag. With a private home the servers go into\n * `$CODEX_HOME/config.toml` (0600). With a caller-owned or inherited home\n * they are passed as `-c mcp_servers.<name>.…` overrides that carry only\n * the command, args and URL; secret `env` values and headers travel in the\n * process environment, named through `env_vars` / `env_http_headers`.\n * - Home `CODEX_HOME`; auth `CODEX_API_KEY`.\n */\nexport const codexAdapter: CliAdapter = {\n name: \"codex\",\n title: \"Codex CLI\",\n command: \"codex\",\n apiKeyEnv: [\"CODEX_API_KEY\"],\n homeEnv: [\"CODEX_HOME\"],\n transports: [\"argv\", \"stdin\"],\n effort: true,\n mcp: true,\n probe: {\n help: [\n [\"exec\", \"--help\"],\n [\"exec\", \"resume\", \"--help\"],\n ],\n version: [\"--version\"],\n },\n verification: {\n version: \"0.163.0\",\n verifiedBy: \"help\",\n sources: [\n \"https://developers.openai.com/codex/noninteractive\",\n \"https://developers.openai.com/codex/config-reference\",\n \"https://github.com/openai/codex/blob/rust-v0.163.0/codex-rs/exec/src/exec_events.rs\",\n ],\n checkedAt: \"2026-10-17\",\n },\n plan(context) {\n const args = [\"exec\"];\n const requires = [\"exec\", \"--json\", \"--skip-git-repo-check\"];\n const files: CliLaunchFile[] = [];\n const env: Record<string, string> = {};\n\n if (context.resume !== undefined) {\n args.push(\"resume\");\n requires.push(\"resume\");\n }\n\n args.push(\"--json\", \"--skip-git-repo-check\", \"-c\", \"check_for_update_on_startup=false\");\n\n if (context.model !== undefined) {\n args.push(\"--model\", context.model);\n requires.push(\"--model\");\n }\n\n if (context.effort !== undefined) {\n const effort = mapEffort(context.effort, {\n low: \"low\",\n medium: \"medium\",\n high: \"high\",\n xhigh: \"xhigh\",\n max: \"max\",\n });\n\n args.push(\"-c\", `model_reasoning_effort=${effort}`);\n requires.push(\"--config\");\n }\n\n if (context.permission === \"bypass\") {\n args.push(\"--dangerously-bypass-approvals-and-sandbox\");\n requires.push(\"--dangerously-bypass-approvals-and-sandbox\");\n }\n\n if (context.mcp !== undefined) {\n if (context.home !== undefined && context.homeIsPrivate) {\n files.push({\n path: path.join(context.home, \"config.toml\"),\n content: toToml({ mcp_servers: codexMcpTable(context.mcp) }),\n });\n } else {\n args.push(...codexMcpOverrides(context.mcp, env));\n requires.push(\"--config\");\n }\n }\n\n if (context.home !== undefined) {\n env.CODEX_HOME = context.home;\n }\n\n const prompt = context.transport === \"argv\" ? argvPrompt(context.prompt) : \"-\";\n\n return {\n args,\n tail: context.resume !== undefined ? [context.resume, prompt] : [prompt],\n stdin: context.transport === \"stdin\" ? context.prompt : undefined,\n env,\n files,\n requires,\n };\n },\n parser: createCodexParser,\n};\n\n/** `[mcp_servers.<name>]` tables for a private `config.toml`. */\nfunction codexMcpTable(servers: CliMcpServers): TomlTable {\n const table: TomlTable = {};\n\n for (const [name, server] of Object.entries(servers)) {\n if (server.type === \"sse\") {\n throw unsupportedOption(\n codexAdapter,\n `MCP server \"${name}\" uses SSE; Codex supports stdio and streamable HTTP.`,\n );\n }\n\n table[name] =\n server.type === \"stdio\"\n ? { command: server.command, args: server.args ?? [], env: server.env }\n : { url: server.url, http_headers: server.headers };\n }\n\n return table;\n}\n\n/** A TOML string for a `-c key=value` override. */\nfunction tomlString(value: string): string {\n return JSON.stringify(value);\n}\n\n/**\n * `-c` overrides that carry no secret: env values and header values are put\n * in `env` (the Codex process environment) and only their names go to argv.\n */\nfunction codexMcpOverrides(servers: CliMcpServers, env: Record<string, string>): string[] {\n const overrides: string[] = [];\n const claim = (name: string, value: string): void => {\n if (env[name] !== undefined && env[name] !== value) {\n throw unsupportedOption(\n codexAdapter,\n `two MCP servers set ${name} to different values; with a shared home they share one environment.`,\n );\n }\n\n env[name] = value;\n };\n\n for (const [name, server] of Object.entries(servers)) {\n const prefix = `mcp_servers.${tomlKey(name)}`;\n\n if (server.type === \"sse\") {\n throw unsupportedOption(\n codexAdapter,\n `MCP server \"${name}\" uses SSE; Codex supports stdio and streamable HTTP.`,\n );\n }\n\n if (server.type === \"stdio\") {\n overrides.push(\"-c\", `${prefix}.command=${tomlString(server.command)}`);\n overrides.push(\"-c\", `${prefix}.args=[${(server.args ?? []).map(tomlString).join(\",\")}]`);\n\n const names = Object.keys(server.env ?? {});\n\n for (const [key, value] of Object.entries(server.env ?? {})) {\n claim(key, value);\n }\n\n if (names.length > 0) {\n overrides.push(\"-c\", `${prefix}.env_vars=[${names.map(tomlString).join(\",\")}]`);\n }\n\n continue;\n }\n\n overrides.push(\"-c\", `${prefix}.url=${tomlString(server.url)}`);\n\n const headers = Object.entries(server.headers ?? {});\n\n if (headers.length > 0) {\n const mapping = headers.map(([header, value], index) => {\n const variable = `WARLOCK_MCP_${name.replace(/\\W/g, \"_\").toUpperCase()}_HEADER_${index}`;\n\n claim(variable, value);\n\n return `${tomlString(header)}=${tomlString(variable)}`;\n });\n\n overrides.push(\"-c\", `${prefix}.env_http_headers={${mapping.join(\",\")}}`);\n }\n }\n\n return overrides;\n}\n\nconst TOOL_ITEMS = new Set([\n \"command_execution\",\n \"file_change\",\n \"mcp_tool_call\",\n \"web_search\",\n \"collab_tool_call\",\n]);\n\nfunction toolCall(item: Record<string, unknown>): { name: string; input: unknown } {\n switch (stringField(item, \"type\")) {\n case \"command_execution\":\n return { name: \"shell\", input: { command: item.command } };\n case \"file_change\":\n return { name: \"apply_patch\", input: { changes: item.changes } };\n case \"mcp_tool_call\":\n return {\n name: `${stringField(item, \"server\") ?? \"mcp\"}.${stringField(item, \"tool\") ?? \"tool\"}`,\n input: item.arguments,\n };\n case \"web_search\":\n return { name: \"web_search\", input: { query: item.query } };\n default:\n return { name: stringField(item, \"type\") ?? \"tool\", input: item };\n }\n}\n\nfunction toolResult(item: Record<string, unknown>): { output: string; isError: boolean } {\n const status = stringField(item, \"status\");\n const failed = status === \"failed\" || status === \"declined\";\n\n switch (stringField(item, \"type\")) {\n case \"command_execution\": {\n const exitCode = numberField(item, \"exit_code\");\n\n return {\n output: stringField(item, \"aggregated_output\") ?? \"\",\n isError: failed || (exitCode !== undefined && exitCode !== 0),\n };\n }\n case \"mcp_tool_call\": {\n const error = stringField(recordField(item, \"error\"), \"message\");\n\n return error !== undefined\n ? { output: error, isError: true }\n : { output: outputText(recordField(item, \"result\")?.content), isError: failed };\n }\n default:\n return { output: outputText(item.changes ?? item.result ?? \"\"), isError: failed };\n }\n}\n\n/** Parser for `codex exec --json`. */\nexport function createCodexParser(): CliStreamParser {\n const announced = new Set<string>();\n\n return jsonLinesParser((record): CliParsedEvent[] => {\n const type = stringField(record, \"type\");\n const item = recordField(record, \"item\");\n const itemType = stringField(item, \"type\");\n const id = stringField(item, \"id\") ?? \"\";\n\n if (type === \"thread.started\") {\n return [\n { type: \"session.started\", sessionRef: stringField(record, \"thread_id\"), raw: record },\n ];\n }\n\n if (\n type === \"item.started\" &&\n item !== undefined &&\n itemType !== undefined &&\n TOOL_ITEMS.has(itemType)\n ) {\n announced.add(id);\n\n return [{ type: \"tool.call\", id, ...toolCall(item), raw: record }];\n }\n\n if (type === \"item.completed\" && item !== undefined) {\n if (itemType === \"agent_message\") {\n const text = stringField(item, \"text\") ?? \"\";\n\n return text.length > 0 ? [{ type: \"message\", text, delta: false, raw: record }] : [];\n }\n\n if (itemType === \"error\") {\n return [{ type: \"error\", message: stringField(item, \"message\") ?? \"error\", raw: record }];\n }\n\n if (itemType !== undefined && TOOL_ITEMS.has(itemType)) {\n const events: CliParsedEvent[] = [];\n\n if (!announced.has(id)) {\n events.push({ type: \"tool.call\", id, ...toolCall(item), raw: record });\n }\n\n events.push({ type: \"tool.result\", id, ...toolResult(item), raw: record });\n\n return events;\n }\n\n return [];\n }\n\n if (type === \"turn.completed\") {\n const usage = recordField(record, \"usage\");\n\n if (usage === undefined) {\n return [];\n }\n\n const cached = numberField(usage, \"cached_input_tokens\");\n const written = numberField(usage, \"cache_write_input_tokens\");\n\n return [\n {\n type: \"usage\",\n cumulative: true,\n usage: usageOf({\n input: numberField(usage, \"input_tokens\"),\n output: numberField(usage, \"output_tokens\"),\n cachedTokens: cached !== undefined && cached > 0 ? cached : undefined,\n cacheWriteTokens: written !== undefined && written > 0 ? written : undefined,\n reasoningTokens: numberField(usage, \"reasoning_output_tokens\") || undefined,\n }),\n raw: record,\n },\n ];\n }\n\n if (type === \"turn.failed\") {\n return [\n {\n type: \"error\",\n message: stringField(recordField(record, \"error\"), \"message\") ?? \"Codex turn failed\",\n fatal: true,\n raw: record,\n },\n ];\n }\n\n if (type === \"error\") {\n return [\n {\n type: \"error\",\n message: stringField(record, \"message\") ?? \"Codex error\",\n fatal: true,\n raw: record,\n },\n ];\n }\n\n return [];\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+CA,MAAa,eAA2B;CACtC,MAAM;CACN,OAAO;CACP,SAAS;CACT,WAAW,CAAC,eAAe;CAC3B,SAAS,CAAC,YAAY;CACtB,YAAY,CAAC,QAAQ,OAAO;CAC5B,QAAQ;CACR,KAAK;CACL,OAAO;EACL,MAAM,CACJ,CAAC,QAAQ,QAAQ,GACjB;GAAC;GAAQ;GAAU;EAAQ,CAC7B;EACA,SAAS,CAAC,WAAW;CACvB;CACA,cAAc;EACZ,SAAS;EACT,YAAY;EACZ,SAAS;GACP;GACA;GACA;EACF;EACA,WAAW;CACb;CACA,KAAK,SAAS;EACZ,MAAM,OAAO,CAAC,MAAM;EACpB,MAAM,WAAW;GAAC;GAAQ;GAAU;EAAuB;EAC3D,MAAM,QAAyB,CAAC;EAChC,MAAM,MAA8B,CAAC;EAErC,IAAI,QAAQ,WAAW,QAAW;GAChC,KAAK,KAAK,QAAQ;GAClB,SAAS,KAAK,QAAQ;EACxB;EAEA,KAAK,KAAK,UAAU,yBAAyB,MAAM,mCAAmC;EAEtF,IAAI,QAAQ,UAAU,QAAW;GAC/B,KAAK,KAAK,WAAW,QAAQ,KAAK;GAClC,SAAS,KAAK,SAAS;EACzB;EAEA,IAAI,QAAQ,WAAW,QAAW;GAChC,MAAM,SAAS,UAAU,QAAQ,QAAQ;IACvC,KAAK;IACL,QAAQ;IACR,MAAM;IACN,OAAO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EACV;EAEA,IAAI,SAAS,kBAAkB;GAC7B,MAAM,QAAQ,YAAY,QAAQ,OAAO;GAEzC,IAAI,UAAU,QACZ,OAAO,CAAC;GAGV,MAAM,SAAS,YAAY,OAAO,qBAAqB;GACvD,MAAM,UAAU,YAAY,OAAO,0BAA0B;GAE7D,OAAO,CACL;IACE,MAAM;IACN,YAAY;IACZ,OAAO,QAAQ;KACb,OAAO,YAAY,OAAO,cAAc;KACxC,QAAQ,YAAY,OAAO,eAAe;KAC1C,cAAc,WAAW,UAAa,SAAS,IAAI,SAAS;KAC5D,kBAAkB,YAAY,UAAa,UAAU,IAAI,UAAU;KACnE,iBAAiB,YAAY,OAAO,yBAAyB,KAAK;IACpE,CAAC;IACD,KAAK;GACP,CACF;EACF;EAEA,IAAI,SAAS,eACX,OAAO,CACL;GACE,MAAM;GACN,SAAS,YAAY,YAAY,QAAQ,OAAO,GAAG,SAAS,KAAK;GACjE,OAAO;GACP,KAAK;EACP,CACF;EAGF,IAAI,SAAS,SACX,OAAO,CACL;GACE,MAAM;GACN,SAAS,YAAY,QAAQ,SAAS,KAAK;GAC3C,OAAO;GACP,KAAK;EACP,CACF;EAGF,OAAO,CAAC;CACV,CAAC;AACH"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CliAdapter, CliLaunchContext, CliStreamParser } from "../contracts/adapter.contract.mjs";
|
|
2
|
+
import "../contracts/index.mjs";
|
|
2
3
|
//#region ../../packages/ai-cli/src/adapters/copilot.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* GitHub Copilot CLI (`copilot`, npm `@github/copilot`).
|
|
@@ -27,9 +28,8 @@ import { CliAdapter, CliLaunchContext, CliStreamParser } from "../contracts/adap
|
|
|
27
28
|
* - Home `COPILOT_HOME`; auth `COPILOT_GITHUB_TOKEN`. Resume with
|
|
28
29
|
* `--session-id <id>`.
|
|
29
30
|
*/
|
|
30
|
-
declare const copilotAdapter: CliAdapter;
|
|
31
|
+
export declare const copilotAdapter: CliAdapter;
|
|
31
32
|
/** Parser for `copilot -p … --output-format json` (plus its usage file). */
|
|
32
|
-
declare function createCopilotParser(context?: CliLaunchContext): CliStreamParser;
|
|
33
|
+
export declare function createCopilotParser(context?: CliLaunchContext): CliStreamParser;
|
|
33
34
|
//#endregion
|
|
34
|
-
export { copilotAdapter, createCopilotParser };
|
|
35
35
|
//# sourceMappingURL=copilot.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copilot.d.mts","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/copilot.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"copilot.d.mts","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/copilot.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBAkDa,gBAAgB;;wBA2Ib,oBAAoB,UAAU,mBAAmB"}
|
package/esm/adapters/copilot.mjs
CHANGED
|
@@ -222,13 +222,11 @@ function createCopilotParser(context) {
|
|
|
222
222
|
case "result":
|
|
223
223
|
sessionRef = stringField(record, "sessionId") ?? sessionRef;
|
|
224
224
|
break;
|
|
225
|
-
case "error":
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
});
|
|
231
|
-
break;
|
|
225
|
+
case "error": events.push({
|
|
226
|
+
type: "error",
|
|
227
|
+
message: stringField(record, "message") ?? "error",
|
|
228
|
+
raw: record
|
|
229
|
+
});
|
|
232
230
|
}
|
|
233
231
|
return events;
|
|
234
232
|
}, () => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"copilot.mjs","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/copilot.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type {\n CliAdapter,\n CliLaunchContext,\n CliLaunchFile,\n CliParsedEvent,\n CliStreamParser,\n} from \"../contracts\";\nimport {\n asRecord,\n jsonLinesParser,\n numberField,\n outputText,\n parseJsonLine,\n recordField,\n stringField,\n} from \"../stream/json-lines\";\nimport { argvPrompt, jsonFile, mcpServersJson, usageOf } from \"./shared\";\n\n/** Usage file (inside the run directory) Copilot writes on exit. */\nconst USAGE_FILE = \"copilot-usage.json\";\n\n/**\n * GitHub Copilot CLI (`copilot`, npm `@github/copilot`).\n *\n * Verified against the real `copilot --help` of 1.0.98, the JSONL writer in\n * the shipped CLI, the event types of `@github/copilot-sdk` 1.0.22 and the\n * docs (`docs.github.com/copilot/how-tos/copilot-cli/…`, programmatic and\n * command references), 2026-10-17.\n *\n * - Headless: `copilot -p <prompt> --output-format json --stream on`\n * (piped stdin is the prompt when `-p` is absent). Stream lines are\n * session events `{type,data,id,timestamp}`: `assistant.message_delta`\n * (`deltaContent`), `assistant.message` (`content`),\n * `tool.execution_start` (`toolCallId`, `toolName`, `arguments`),\n * `tool.execution_complete` (`success`, `result.content`,\n * `error.message`), `session.error`, and a final CLI-built `result`\n * (`sessionId`, `exitCode`, premium-request usage).\n * - Tokens are not in the stream; the adapter passes `--usage-output-file`\n * and reads `modelMetrics.*.usage` from it when the stream ends. Billing\n * is in premium requests, so no USD cost is reported.\n * - Permissions: unapproved tool requests are auto-denied in `-p` mode;\n * bypass is `--allow-all` (tools, paths and URLs). `--no-ask-user` and\n * `--no-auto-update` are always passed.\n * - MCP: `--additional-mcp-config @<file>` (`mcpServers`, `type`\n * `local`/`http`/`sse`, `tools: [\"*\"]`), written to the run directory.\n * - Home `COPILOT_HOME`; auth `COPILOT_GITHUB_TOKEN`. Resume with\n * `--session-id <id>`.\n */\nexport const copilotAdapter: CliAdapter = {\n name: \"copilot\",\n title: \"Copilot CLI\",\n command: \"copilot\",\n apiKeyEnv: [\"COPILOT_GITHUB_TOKEN\"],\n homeEnv: [\"COPILOT_HOME\"],\n transports: [\"argv\", \"stdin\"],\n effort: true,\n mcp: true,\n probe: { help: [[\"--help\"]], version: [\"--version\"] },\n verification: {\n version: \"1.0.98\",\n verifiedBy: \"help\",\n sources: [\n \"https://docs.github.com/en/copilot/how-tos/copilot-cli/automate-copilot-cli/run-cli-programmatically\",\n \"https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-command-reference\",\n \"https://www.npmjs.com/package/@github/copilot\",\n ],\n checkedAt: \"2026-10-17\",\n },\n plan(context) {\n const args = [\n \"--output-format\",\n \"json\",\n \"--stream\",\n \"on\",\n \"--no-ask-user\",\n \"--no-auto-update\",\n \"--usage-output-file\",\n path.join(context.runDir, USAGE_FILE),\n ];\n const requires = [\n \"--output-format\",\n \"--stream\",\n \"--no-ask-user\",\n \"--no-auto-update\",\n \"--usage-output-file\",\n ];\n const files: CliLaunchFile[] = [];\n\n if (context.model !== undefined) {\n args.push(\"--model\", context.model);\n requires.push(\"--model\");\n }\n\n if (context.effort !== undefined) {\n // Copilot accepts the framework scale verbatim: none … max.\n args.push(\"--reasoning-effort\", context.effort);\n requires.push(\"--reasoning-effort\");\n }\n\n if (context.resume !== undefined) {\n args.push(\"--session-id\", context.resume);\n requires.push(\"--session-id\");\n }\n\n if (context.permission === \"bypass\") {\n args.push(\"--allow-all\");\n requires.push(\"--allow-all\");\n }\n\n if (context.mcp !== undefined) {\n const file = path.join(context.runDir, \"copilot-mcp.json\");\n const servers = mcpServersJson(context.mcp, { typeField: true, extra: { tools: [\"*\"] } });\n\n for (const server of Object.values(servers)) {\n if (server.type === \"stdio\") {\n server.type = \"local\";\n }\n }\n\n files.push({ path: file, content: jsonFile({ mcpServers: servers }) });\n args.push(\"--additional-mcp-config\", `@${file}`);\n requires.push(\"--additional-mcp-config\");\n }\n\n return {\n args,\n tail: context.transport === \"argv\" ? [\"-p\", argvPrompt(context.prompt)] : [],\n stdin: context.transport === \"stdin\" ? context.prompt : undefined,\n env: context.home !== undefined ? { COPILOT_HOME: context.home } : undefined,\n files,\n requires: context.transport === \"argv\" ? [...requires, \"-p\"] : requires,\n };\n },\n parser: createCopilotParser,\n};\n\n/** Token usage summed over `modelMetrics` of the usage file. */\nfunction usageFileEvent(context: CliLaunchContext | undefined): CliParsedEvent | undefined {\n if (context === undefined) {\n return undefined;\n }\n\n let report: Record<string, unknown> | undefined;\n\n try {\n report = parseJsonLine(readFileSync(path.join(context.runDir, USAGE_FILE), \"utf8\"));\n } catch {\n return undefined;\n }\n\n const metrics = recordField(report, \"modelMetrics\");\n\n if (metrics === undefined) {\n return undefined;\n }\n\n let input = 0;\n let output = 0;\n let cached = 0;\n let written = 0;\n let reasoning = 0;\n\n for (const value of Object.values(metrics)) {\n const usage = recordField(asRecord(value), \"usage\");\n\n input += numberField(usage, \"inputTokens\") ?? 0;\n output += numberField(usage, \"outputTokens\") ?? 0;\n cached += numberField(usage, \"cacheReadTokens\") ?? 0;\n written += numberField(usage, \"cacheWriteTokens\") ?? 0;\n reasoning += numberField(usage, \"reasoningTokens\") ?? 0;\n }\n\n return {\n type: \"usage\",\n cumulative: true,\n usage: usageOf({\n input,\n output,\n cachedTokens: cached > 0 ? cached : undefined,\n cacheWriteTokens: written > 0 ? written : undefined,\n reasoningTokens: reasoning > 0 ? reasoning : undefined,\n }),\n raw: report,\n };\n}\n\n/** Parser for `copilot -p … --output-format json` (plus its usage file). */\nexport function createCopilotParser(context?: CliLaunchContext): CliStreamParser {\n let started = false;\n let sessionRef: string | undefined;\n\n const parser = jsonLinesParser(\n (record): CliParsedEvent[] => {\n const events: CliParsedEvent[] = [];\n const type = stringField(record, \"type\");\n const data = recordField(record, \"data\");\n\n if (!started) {\n started = true;\n events.push({\n type: \"session.started\",\n sessionRef: stringField(data, \"sessionId\"),\n raw: record,\n });\n }\n\n switch (type) {\n case \"assistant.message_delta\": {\n const text = stringField(data, \"deltaContent\") ?? \"\";\n\n if (text.length > 0) {\n events.push({ type: \"message\", text, delta: true, raw: record });\n }\n break;\n }\n case \"assistant.message\": {\n const text = stringField(data, \"content\") ?? \"\";\n\n if (text.length > 0) {\n events.push({ type: \"message\", text, delta: false, raw: record });\n }\n break;\n }\n case \"tool.execution_start\":\n events.push({\n type: \"tool.call\",\n id: stringField(data, \"toolCallId\") ?? \"\",\n name: stringField(data, \"toolName\") ?? \"\",\n input: data?.arguments,\n raw: record,\n });\n break;\n case \"tool.execution_complete\": {\n const success = data?.success === true;\n\n events.push({\n type: \"tool.result\",\n id: stringField(data, \"toolCallId\") ?? \"\",\n output: success\n ? outputText(recordField(data, \"result\")?.content)\n : (stringField(recordField(data, \"error\"), \"message\") ?? \"tool failed\"),\n isError: !success,\n raw: record,\n });\n break;\n }\n case \"session.error\":\n events.push({\n type: \"error\",\n message: stringField(data, \"message\") ?? \"Copilot session error\",\n fatal: true,\n raw: record,\n });\n break;\n case \"result\":\n sessionRef = stringField(record, \"sessionId\") ?? sessionRef;\n break;\n case \"error\":\n events.push({\n type: \"error\",\n message: stringField(record, \"message\") ?? \"error\",\n raw: record,\n });\n break;\n }\n\n return events;\n },\n () => {\n const usage = usageFileEvent(context);\n\n return usage !== undefined ? [usage] : [];\n },\n );\n\n return { ...parser, sessionRef: () => sessionRef };\n}\n"],"mappings":";;;;;;;AAqBA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BnB,MAAa,iBAA6B;CACxC,MAAM;CACN,OAAO;CACP,SAAS;CACT,WAAW,CAAC,sBAAsB;CAClC,SAAS,CAAC,cAAc;CACxB,YAAY,CAAC,QAAQ,OAAO;CAC5B,QAAQ;CACR,KAAK;CACL,OAAO;EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC;EAAG,SAAS,CAAC,WAAW;CAAE;CACpD,cAAc;EACZ,SAAS;EACT,YAAY;EACZ,SAAS;GACP;GACA;GACA;EACF;EACA,WAAW;CACb;CACA,KAAK,SAAS;EACZ,MAAM,OAAO;GACX;GACA;GACA;GACA;GACA;GACA;GACA;GACA,KAAK,KAAK,QAAQ,QAAQ,UAAU;EACtC;EACA,MAAM,WAAW;GACf;GACA;GACA;GACA;GACA;EACF;EACA,MAAM,QAAyB,CAAC;EAEhC,IAAI,QAAQ,UAAU,QAAW;GAC/B,KAAK,KAAK,WAAW,QAAQ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SAAS,GAChB,OAAO,KAAK;MAAE,MAAM;MAAW;MAAM,OAAO;MAAO,KAAK;KAAO,CAAC;KAElE;IACF;IACA,KAAK;KACH,OAAO,KAAK;MACV,MAAM;MACN,IAAI,YAAY,MAAM,YAAY,KAAK;MACvC,MAAM,YAAY,MAAM,UAAU,KAAK;MACvC,OAAO,MAAM;MACb,KAAK;KACP,CAAC;KACD;IACF,KAAK,2BAA2B;KAC9B,MAAM,UAAU,MAAM,YAAY;KAElC,OAAO,KAAK;MACV,MAAM;MACN,IAAI,YAAY,MAAM,YAAY,KAAK;MACvC,QAAQ,UACJ,WAAW,YAAY,MAAM,QAAQ,CAAC,EAAE,OAAO,IAC9C,YAAY,YAAY,MAAM,OAAO,GAAG,SAAS,KAAK;MAC3D,SAAS,CAAC;MACV,KAAK;KACP,CAAC;KACD;IACF;IACA,KAAK;KACH,OAAO,KAAK;MACV,MAAM;MACN,SAAS,YAAY,MAAM,SAAS,KAAK;MACzC,OAAO;MACP,KAAK;KACP,CAAC;KACD;IACF,KAAK;KACH,aAAa,YAAY,QAAQ,WAAW,KAAK;KACjD;IACF,KAAK;KACH,OAAO,KAAK;MACV,MAAM;MACN,SAAS,YAAY,QAAQ,SAAS,KAAK;MAC3C,KAAK;KACP,CAAC;KACD;GACJ;GAEA,OAAO;EACT,SACM;GACJ,MAAM,QAAQ,eAAe,OAAO;GAEpC,OAAO,UAAU,SAAY,CAAC,KAAK,IAAI,CAAC;EAC1C,CAGe;EAAG,kBAAkB;CAAW;AACnD"}
|
|
1
|
+
{"version":3,"file":"copilot.mjs","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/copilot.ts"],"sourcesContent":["import { readFileSync } from \"node:fs\";\nimport path from \"node:path\";\nimport type {\n CliAdapter,\n CliLaunchContext,\n CliLaunchFile,\n CliParsedEvent,\n CliStreamParser,\n} from \"../contracts\";\nimport {\n asRecord,\n jsonLinesParser,\n numberField,\n outputText,\n parseJsonLine,\n recordField,\n stringField,\n} from \"../stream/json-lines\";\nimport { argvPrompt, jsonFile, mcpServersJson, usageOf } from \"./shared\";\n\n/** Usage file (inside the run directory) Copilot writes on exit. */\nconst USAGE_FILE = \"copilot-usage.json\";\n\n/**\n * GitHub Copilot CLI (`copilot`, npm `@github/copilot`).\n *\n * Verified against the real `copilot --help` of 1.0.98, the JSONL writer in\n * the shipped CLI, the event types of `@github/copilot-sdk` 1.0.22 and the\n * docs (`docs.github.com/copilot/how-tos/copilot-cli/…`, programmatic and\n * command references), 2026-10-17.\n *\n * - Headless: `copilot -p <prompt> --output-format json --stream on`\n * (piped stdin is the prompt when `-p` is absent). Stream lines are\n * session events `{type,data,id,timestamp}`: `assistant.message_delta`\n * (`deltaContent`), `assistant.message` (`content`),\n * `tool.execution_start` (`toolCallId`, `toolName`, `arguments`),\n * `tool.execution_complete` (`success`, `result.content`,\n * `error.message`), `session.error`, and a final CLI-built `result`\n * (`sessionId`, `exitCode`, premium-request usage).\n * - Tokens are not in the stream; the adapter passes `--usage-output-file`\n * and reads `modelMetrics.*.usage` from it when the stream ends. Billing\n * is in premium requests, so no USD cost is reported.\n * - Permissions: unapproved tool requests are auto-denied in `-p` mode;\n * bypass is `--allow-all` (tools, paths and URLs). `--no-ask-user` and\n * `--no-auto-update` are always passed.\n * - MCP: `--additional-mcp-config @<file>` (`mcpServers`, `type`\n * `local`/`http`/`sse`, `tools: [\"*\"]`), written to the run directory.\n * - Home `COPILOT_HOME`; auth `COPILOT_GITHUB_TOKEN`. Resume with\n * `--session-id <id>`.\n */\nexport const copilotAdapter: CliAdapter = {\n name: \"copilot\",\n title: \"Copilot CLI\",\n command: \"copilot\",\n apiKeyEnv: [\"COPILOT_GITHUB_TOKEN\"],\n homeEnv: [\"COPILOT_HOME\"],\n transports: [\"argv\", \"stdin\"],\n effort: true,\n mcp: true,\n probe: { help: [[\"--help\"]], version: [\"--version\"] },\n verification: {\n version: \"1.0.98\",\n verifiedBy: \"help\",\n sources: [\n \"https://docs.github.com/en/copilot/how-tos/copilot-cli/automate-copilot-cli/run-cli-programmatically\",\n \"https://docs.github.com/en/copilot/reference/copilot-cli-reference/cli-command-reference\",\n \"https://www.npmjs.com/package/@github/copilot\",\n ],\n checkedAt: \"2026-10-17\",\n },\n plan(context) {\n const args = [\n \"--output-format\",\n \"json\",\n \"--stream\",\n \"on\",\n \"--no-ask-user\",\n \"--no-auto-update\",\n \"--usage-output-file\",\n path.join(context.runDir, USAGE_FILE),\n ];\n const requires = [\n \"--output-format\",\n \"--stream\",\n \"--no-ask-user\",\n \"--no-auto-update\",\n \"--usage-output-file\",\n ];\n const files: CliLaunchFile[] = [];\n\n if (context.model !== undefined) {\n args.push(\"--model\", context.model);\n requires.push(\"--model\");\n }\n\n if (context.effort !== undefined) {\n // Copilot accepts the framework scale verbatim: none … max.\n args.push(\"--reasoning-effort\", context.effort);\n requires.push(\"--reasoning-effort\");\n }\n\n if (context.resume !== undefined) {\n args.push(\"--session-id\", context.resume);\n requires.push(\"--session-id\");\n }\n\n if (context.permission === \"bypass\") {\n args.push(\"--allow-all\");\n requires.push(\"--allow-all\");\n }\n\n if (context.mcp !== undefined) {\n const file = path.join(context.runDir, \"copilot-mcp.json\");\n const servers = mcpServersJson(context.mcp, { typeField: true, extra: { tools: [\"*\"] } });\n\n for (const server of Object.values(servers)) {\n if (server.type === \"stdio\") {\n server.type = \"local\";\n }\n }\n\n files.push({ path: file, content: jsonFile({ mcpServers: servers }) });\n args.push(\"--additional-mcp-config\", `@${file}`);\n requires.push(\"--additional-mcp-config\");\n }\n\n return {\n args,\n tail: context.transport === \"argv\" ? [\"-p\", argvPrompt(context.prompt)] : [],\n stdin: context.transport === \"stdin\" ? context.prompt : undefined,\n env: context.home !== undefined ? { COPILOT_HOME: context.home } : undefined,\n files,\n requires: context.transport === \"argv\" ? [...requires, \"-p\"] : requires,\n };\n },\n parser: createCopilotParser,\n};\n\n/** Token usage summed over `modelMetrics` of the usage file. */\nfunction usageFileEvent(context: CliLaunchContext | undefined): CliParsedEvent | undefined {\n if (context === undefined) {\n return undefined;\n }\n\n let report: Record<string, unknown> | undefined;\n\n try {\n report = parseJsonLine(readFileSync(path.join(context.runDir, USAGE_FILE), \"utf8\"));\n } catch {\n return undefined;\n }\n\n const metrics = recordField(report, \"modelMetrics\");\n\n if (metrics === undefined) {\n return undefined;\n }\n\n let input = 0;\n let output = 0;\n let cached = 0;\n let written = 0;\n let reasoning = 0;\n\n for (const value of Object.values(metrics)) {\n const usage = recordField(asRecord(value), \"usage\");\n\n input += numberField(usage, \"inputTokens\") ?? 0;\n output += numberField(usage, \"outputTokens\") ?? 0;\n cached += numberField(usage, \"cacheReadTokens\") ?? 0;\n written += numberField(usage, \"cacheWriteTokens\") ?? 0;\n reasoning += numberField(usage, \"reasoningTokens\") ?? 0;\n }\n\n return {\n type: \"usage\",\n cumulative: true,\n usage: usageOf({\n input,\n output,\n cachedTokens: cached > 0 ? cached : undefined,\n cacheWriteTokens: written > 0 ? written : undefined,\n reasoningTokens: reasoning > 0 ? reasoning : undefined,\n }),\n raw: report,\n };\n}\n\n/** Parser for `copilot -p … --output-format json` (plus its usage file). */\nexport function createCopilotParser(context?: CliLaunchContext): CliStreamParser {\n let started = false;\n let sessionRef: string | undefined;\n\n const parser = jsonLinesParser(\n (record): CliParsedEvent[] => {\n const events: CliParsedEvent[] = [];\n const type = stringField(record, \"type\");\n const data = recordField(record, \"data\");\n\n if (!started) {\n started = true;\n events.push({\n type: \"session.started\",\n sessionRef: stringField(data, \"sessionId\"),\n raw: record,\n });\n }\n\n switch (type) {\n case \"assistant.message_delta\": {\n const text = stringField(data, \"deltaContent\") ?? \"\";\n\n if (text.length > 0) {\n events.push({ type: \"message\", text, delta: true, raw: record });\n }\n break;\n }\n case \"assistant.message\": {\n const text = stringField(data, \"content\") ?? \"\";\n\n if (text.length > 0) {\n events.push({ type: \"message\", text, delta: false, raw: record });\n }\n break;\n }\n case \"tool.execution_start\":\n events.push({\n type: \"tool.call\",\n id: stringField(data, \"toolCallId\") ?? \"\",\n name: stringField(data, \"toolName\") ?? \"\",\n input: data?.arguments,\n raw: record,\n });\n break;\n case \"tool.execution_complete\": {\n const success = data?.success === true;\n\n events.push({\n type: \"tool.result\",\n id: stringField(data, \"toolCallId\") ?? \"\",\n output: success\n ? outputText(recordField(data, \"result\")?.content)\n : (stringField(recordField(data, \"error\"), \"message\") ?? \"tool failed\"),\n isError: !success,\n raw: record,\n });\n break;\n }\n case \"session.error\":\n events.push({\n type: \"error\",\n message: stringField(data, \"message\") ?? \"Copilot session error\",\n fatal: true,\n raw: record,\n });\n break;\n case \"result\":\n sessionRef = stringField(record, \"sessionId\") ?? sessionRef;\n break;\n case \"error\":\n events.push({\n type: \"error\",\n message: stringField(record, \"message\") ?? \"error\",\n raw: record,\n });\n break;\n }\n\n return events;\n },\n () => {\n const usage = usageFileEvent(context);\n\n return usage !== undefined ? [usage] : [];\n },\n );\n\n return { ...parser, sessionRef: () => sessionRef };\n}\n"],"mappings":";;;;;;;AAqBA,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BnB,MAAa,iBAA6B;CACxC,MAAM;CACN,OAAO;CACP,SAAS;CACT,WAAW,CAAC,sBAAsB;CAClC,SAAS,CAAC,cAAc;CACxB,YAAY,CAAC,QAAQ,OAAO;CAC5B,QAAQ;CACR,KAAK;CACL,OAAO;EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC;EAAG,SAAS,CAAC,WAAW;CAAE;CACpD,cAAc;EACZ,SAAS;EACT,YAAY;EACZ,SAAS;GACP;GACA;GACA;EACF;EACA,WAAW;CACb;CACA,KAAK,SAAS;EACZ,MAAM,OAAO;GACX;GACA;GACA;GACA;GACA;GACA;GACA;GACA,KAAK,KAAK,QAAQ,QAAQ,UAAU;EACtC;EACA,MAAM,WAAW;GACf;GACA;GACA;GACA;GACA;EACF;EACA,MAAM,QAAyB,CAAC;EAEhC,IAAI,QAAQ,UAAU,QAAW;GAC/B,KAAK,KAAK,WAAW,QAAQ,KAAK;GAClC,SAAS,KA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;MAAE,MAAM;MAAW;MAAM,OAAO;MAAO,KAAK;KAAO,CAAC;KAElE;IACF;IACA,KAAK;KACH,OAAO,KAAK;MACV,MAAM;MACN,IAAI,YAAY,MAAM,YAAY,KAAK;MACvC,MAAM,YAAY,MAAM,UAAU,KAAK;MACvC,OAAO,MAAM;MACb,KAAK;KACP,CAAC;KACD;IACF,KAAK,2BAA2B;KAC9B,MAAM,UAAU,MAAM,YAAY;KAElC,OAAO,KAAK;MACV,MAAM;MACN,IAAI,YAAY,MAAM,YAAY,KAAK;MACvC,QAAQ,UACJ,WAAW,YAAY,MAAM,QAAQ,CAAC,EAAE,OAAO,IAC9C,YAAY,YAAY,MAAM,OAAO,GAAG,SAAS,KAAK;MAC3D,SAAS,CAAC;MACV,KAAK;KACP,CAAC;KACD;IACF;IACA,KAAK;KACH,OAAO,KAAK;MACV,MAAM;MACN,SAAS,YAAY,MAAM,SAAS,KAAK;MACzC,OAAO;MACP,KAAK;KACP,CAAC;KACD;IACF,KAAK;KACH,aAAa,YAAY,QAAQ,WAAW,KAAK;KACjD;IACF,KAAK,SACH,OAAO,KAAK;KACV,MAAM;KACN,SAAS,YAAY,QAAQ,SAAS,KAAK;KAC3C,KAAK;IACP,CAAC;GAEL;GAEA,OAAO;EACT,SACM;GACJ,MAAM,QAAQ,eAAe,OAAO;GAEpC,OAAO,UAAU,SAAY,CAAC,KAAK,IAAI,CAAC;EAC1C,CAGe;EAAG,kBAAkB;CAAW;AACnD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CliAdapter, CliStreamParser } from "../contracts/adapter.contract.mjs";
|
|
2
|
+
import "../contracts/index.mjs";
|
|
2
3
|
//#region ../../packages/ai-cli/src/adapters/cursor.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* Cursor CLI (`cursor-agent`, also installed as `agent`), installed by the
|
|
@@ -27,9 +28,8 @@ import { CliAdapter, CliStreamParser } from "../contracts/adapter.contract.mjs";
|
|
|
27
28
|
* - Home: `HOME`/`USERPROFILE`, `CURSOR_CONFIG_DIR` and `CURSOR_DATA_DIR`
|
|
28
29
|
* are pointed into it. Auth: `CURSOR_API_KEY`.
|
|
29
30
|
*/
|
|
30
|
-
declare const cursorAdapter: CliAdapter;
|
|
31
|
+
export declare const cursorAdapter: CliAdapter;
|
|
31
32
|
/** Parser for `cursor-agent -p --output-format stream-json`. */
|
|
32
|
-
declare function createCursorParser(): CliStreamParser;
|
|
33
|
+
export declare function createCursorParser(): CliStreamParser;
|
|
33
34
|
//#endregion
|
|
34
|
-
export { createCursorParser, cursorAdapter };
|
|
35
35
|
//# sourceMappingURL=cursor.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cursor.d.mts","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/cursor.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"cursor.d.mts","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/cursor.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA+Ca,eAAe;;wBA2FZ,sBAAsB"}
|
package/esm/adapters/droid.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CliAdapter, CliStreamParser } from "../contracts/adapter.contract.mjs";
|
|
2
|
+
import "../contracts/index.mjs";
|
|
2
3
|
//#region ../../packages/ai-cli/src/adapters/droid.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* Factory Droid (`droid`, npm `droid` / `@factory/cli`).
|
|
@@ -24,9 +25,8 @@ import { CliAdapter, CliStreamParser } from "../contracts/adapter.contract.mjs";
|
|
|
24
25
|
* with `droid mcp list`), so per-run MCP needs a private home.
|
|
25
26
|
* - Auth: `FACTORY_API_KEY`.
|
|
26
27
|
*/
|
|
27
|
-
declare const droidAdapter: CliAdapter;
|
|
28
|
+
export declare const droidAdapter: CliAdapter;
|
|
28
29
|
/** Parser for `droid exec -o stream-json`. */
|
|
29
|
-
declare function createDroidParser(): CliStreamParser;
|
|
30
|
+
export declare function createDroidParser(): CliStreamParser;
|
|
30
31
|
//#endregion
|
|
31
|
-
export { createDroidParser, droidAdapter };
|
|
32
32
|
//# sourceMappingURL=droid.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"droid.d.mts","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/droid.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"droid.d.mts","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/droid.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;qBAoCa,cAAc;;wBAiFX,qBAAqB"}
|
package/esm/adapters/grok.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CliAdapter, CliStreamParser } from "../contracts/adapter.contract.mjs";
|
|
2
|
+
import "../contracts/index.mjs";
|
|
2
3
|
//#region ../../packages/ai-cli/src/adapters/grok.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* Grok Build (`grok`) — xAI's official coding-agent CLI, installed by the
|
|
@@ -24,9 +25,8 @@ import { CliAdapter, CliStreamParser } from "../contracts/adapter.contract.mjs";
|
|
|
24
25
|
* - Auth: `XAI_API_KEY`. Update checks are disabled with
|
|
25
26
|
* `GROK_DISABLE_AUTOUPDATER=1`.
|
|
26
27
|
*/
|
|
27
|
-
declare const grokAdapter: CliAdapter;
|
|
28
|
+
export declare const grokAdapter: CliAdapter;
|
|
28
29
|
/** Parser for `grok -p … --output-format streaming-json`. */
|
|
29
|
-
declare function createGrokParser(): CliStreamParser;
|
|
30
|
+
export declare function createGrokParser(): CliStreamParser;
|
|
30
31
|
//#endregion
|
|
31
|
-
export { createGrokParser, grokAdapter };
|
|
32
32
|
//# sourceMappingURL=grok.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grok.d.mts","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/grok.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"grok.d.mts","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/grok.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;qBAgDa,aAAa;;wBAsGV,oBAAoB"}
|
package/esm/adapters/grok.mjs
CHANGED
|
@@ -179,14 +179,12 @@ function createGrokParser() {
|
|
|
179
179
|
});
|
|
180
180
|
break;
|
|
181
181
|
}
|
|
182
|
-
case "error":
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
});
|
|
189
|
-
break;
|
|
182
|
+
case "error": events.push({
|
|
183
|
+
type: "error",
|
|
184
|
+
message: stringField(record, "message") ?? "Grok Build reported an error",
|
|
185
|
+
fatal: true,
|
|
186
|
+
raw: record
|
|
187
|
+
});
|
|
190
188
|
}
|
|
191
189
|
return events;
|
|
192
190
|
}),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"grok.mjs","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/grok.ts"],"sourcesContent":["import path from \"node:path\";\nimport type {\n CliAdapter,\n CliLaunchFile,\n CliMcpServers,\n CliParsedEvent,\n CliStreamParser,\n} from \"../contracts\";\nimport {\n jsonLinesParser,\n numberField,\n outputText,\n recordField,\n stringField,\n} from \"../stream/json-lines\";\nimport { type TomlTable, toToml } from \"../utils/toml\";\nimport {\n anthropicUsage,\n argvPrompt,\n promptFile,\n requirePrivateHome,\n unsupportedOption,\n} from \"./shared\";\n\n/**\n * Grok Build (`grok`) — xAI's official coding-agent CLI, installed by the\n * `x.ai/cli/install.sh` script (no npm package).\n *\n * Verified against the docs and source only (the binary is distributed by\n * a curl installer, which was not run): the repo user guide\n * `crates/codegen/xai-grok-pager/docs/user-guide/{14-headless-mode,\n * 07-mcp-servers,05-configuration,22-permissions-and-safety}.md`, the clap\n * definitions in `xai-grok-pager/src/app/cli.rs` and the headless reducer\n * `headless/reducer/acp.rs`, at source version 1.0.45; latest stable 1.0.62\n * (2026-10-17). The capability probe checks every flag against the\n * installed binary's `--help` before the first run.\n *\n * - Headless: `grok -p <prompt>` or `--prompt-file <path>`; piped stdin is\n * not read. `--output-format streaming-json` prints `type`-tagged lines:\n * `text`, `thought`, `tool_call`, `tool_call_update`, `usage` (per model\n * response, `input_tokens` uncached) and a final `end` (session id, totals,\n * `total_cost_usd`); failures print `{\"type\":\"error\",\"message\"}`.\n * - Permissions: headless mode answers every approval request with\n * \"cancelled\" (auto-deny); bypass is `--always-approve`.\n * - MCP: no flag; `[mcp_servers.<name>]` in `$GROK_HOME/config.toml`.\n * - Auth: `XAI_API_KEY`. Update checks are disabled with\n * `GROK_DISABLE_AUTOUPDATER=1`.\n */\nexport const grokAdapter: CliAdapter = {\n name: \"grok\",\n title: \"Grok Build\",\n command: \"grok\",\n apiKeyEnv: [\"XAI_API_KEY\"],\n homeEnv: [\"GROK_HOME\"],\n transports: [\"argv\", \"file\"],\n effort: true,\n mcp: true,\n probe: { help: [[\"--help\"]], version: [\"--version\"] },\n verification: {\n version: \"1.0.62\",\n verifiedBy: \"docs\",\n sources: [\n \"https://docs.x.ai/build/cli/headless-scripting\",\n \"https://github.com/xai-org/grok-build/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/14-headless-mode.md\",\n \"https://github.com/xai-org/grok-build/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/07-mcp-servers.md\",\n ],\n checkedAt: \"2026-10-17\",\n },\n plan(context) {\n const args = [\"--output-format\", \"streaming-json\"];\n const requires = [\"--output-format\", \"streaming-json\"];\n const files: CliLaunchFile[] = [];\n let tail: string[];\n\n if (context.model !== undefined) {\n args.push(\"--model\", context.model);\n requires.push(\"--model\");\n }\n\n if (context.effort !== undefined) {\n // Grok accepts the framework scale verbatim (none … max, model-dependent).\n args.push(\"--reasoning-effort\", context.effort);\n requires.push(\"--reasoning-effort\");\n }\n\n if (context.resume !== undefined) {\n args.push(\"--resume\", context.resume);\n requires.push(\"--resume\");\n }\n\n if (context.permission === \"bypass\") {\n args.push(\"--always-approve\");\n requires.push(\"--always-approve\");\n }\n\n if (context.mcp !== undefined) {\n const home = requirePrivateHome(context, grokAdapter, \"MCP servers\");\n\n files.push({\n path: path.join(home, \"config.toml\"),\n content: toToml({ mcp_servers: grokMcp(context.mcp) }),\n });\n }\n\n if (context.transport === \"file\") {\n const prompt = promptFile(context);\n\n files.push(prompt);\n tail = [\"--prompt-file\", prompt.path];\n requires.push(\"--prompt-file\");\n } else {\n tail = [\"-p\", argvPrompt(context.prompt)];\n requires.push(\"-p\");\n }\n\n return {\n args,\n tail,\n env: {\n ...(context.home !== undefined ? { GROK_HOME: context.home } : {}),\n GROK_DISABLE_AUTOUPDATER: \"1\",\n },\n files,\n requires,\n };\n },\n parser: createGrokParser,\n};\n\nfunction grokMcp(servers: CliMcpServers): TomlTable {\n const table: TomlTable = {};\n\n for (const [name, server] of Object.entries(servers)) {\n if (server.type === \"sse\") {\n throw unsupportedOption(\n grokAdapter,\n `MCP server \"${name}\" uses SSE; Grok Build supports stdio and HTTP servers.`,\n );\n }\n\n table[name] =\n server.type === \"stdio\"\n ? { command: server.command, args: server.args ?? [], env: server.env }\n : { url: server.url, headers: server.headers };\n }\n\n return table;\n}\n\n/** Parser for `grok -p … --output-format streaming-json`. */\nexport function createGrokParser(): CliStreamParser {\n let started = false;\n let sessionRef: string | undefined;\n\n const parser = jsonLinesParser((record): CliParsedEvent[] => {\n const events: CliParsedEvent[] = [];\n\n if (!started) {\n started = true;\n events.push({ type: \"session.started\" });\n }\n\n switch (stringField(record, \"type\")) {\n case \"text\": {\n const text = stringField(record, \"data\") ?? \"\";\n\n if (text.length > 0) {\n events.push({ type: \"message\", text, delta: true, raw: record });\n }\n break;\n }\n case \"tool_call\":\n events.push({\n type: \"tool.call\",\n id: stringField(record, \"toolCallId\") ?? \"\",\n name: stringField(record, \"toolName\") ?? stringField(record, \"title\") ?? \"\",\n input: record.rawInput,\n raw: record,\n });\n break;\n case \"tool_call_update\": {\n const status = stringField(record, \"status\");\n\n if (status === \"completed\" || status === \"failed\") {\n events.push({\n type: \"tool.result\",\n id: stringField(record, \"toolCallId\") ?? \"\",\n output: outputText(record.rawOutput ?? record.content),\n isError: status === \"failed\",\n raw: record,\n });\n }\n break;\n }\n case \"usage\": {\n const usage = anthropicUsage(recordField(record, \"usage\"));\n\n if (usage !== undefined) {\n events.push({ type: \"usage\", usage, cumulative: false, raw: record });\n }\n break;\n }\n case \"end\": {\n sessionRef = stringField(record, \"sessionId\") ?? sessionRef;\n\n const usage = anthropicUsage(\n recordField(record, \"usage\"),\n numberField(record, \"total_cost_usd\"),\n );\n\n if (usage !== undefined) {\n events.push({ type: \"usage\", usage, cumulative: true, raw: record });\n }\n break;\n }\n case \"error\":\n events.push({\n type: \"error\",\n message: stringField(record, \"message\") ?? \"Grok Build reported an error\",\n fatal: true,\n raw: record,\n });\n break;\n }\n\n return events;\n });\n\n return { ...parser, sessionRef: () => sessionRef };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAa,cAA0B;CACrC,MAAM;CACN,OAAO;CACP,SAAS;CACT,WAAW,CAAC,aAAa;CACzB,SAAS,CAAC,WAAW;CACrB,YAAY,CAAC,QAAQ,MAAM;CAC3B,QAAQ;CACR,KAAK;CACL,OAAO;EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC;EAAG,SAAS,CAAC,WAAW;CAAE;CACpD,cAAc;EACZ,SAAS;EACT,YAAY;EACZ,SAAS;GACP;GACA;GACA;EACF;EACA,WAAW;CACb;CACA,KAAK,SAAS;EACZ,MAAM,OAAO,CAAC,mBAAmB,gBAAgB;EACjD,MAAM,WAAW,CAAC,mBAAmB,gBAAgB;EACrD,MAAM,QAAyB,CAAC;EAChC,IAAI;EAEJ,IAAI,QAAQ,UAAU,QAAW;GAC/B,KAAK,KAAK,WAAW,QAAQ,KAAK;GAClC,SAAS,KAAK,SAAS;EACzB;EAEA,IAAI,QAAQ,WAAW,QAAW;GAEhC,KAAK,KAAK,sBAAsB,QAAQ,MAAM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KACH,OAAO,KAAK;MACV,MAAM;MACN,SAAS,YAAY,QAAQ,SAAS,KAAK;MAC3C,OAAO;MACP,KAAK;KACP,CAAC;KACD;GACJ;GAEA,OAAO;EACT,CAEiB;EAAG,kBAAkB;CAAW;AACnD"}
|
|
1
|
+
{"version":3,"file":"grok.mjs","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/grok.ts"],"sourcesContent":["import path from \"node:path\";\nimport type {\n CliAdapter,\n CliLaunchFile,\n CliMcpServers,\n CliParsedEvent,\n CliStreamParser,\n} from \"../contracts\";\nimport {\n jsonLinesParser,\n numberField,\n outputText,\n recordField,\n stringField,\n} from \"../stream/json-lines\";\nimport { type TomlTable, toToml } from \"../utils/toml\";\nimport {\n anthropicUsage,\n argvPrompt,\n promptFile,\n requirePrivateHome,\n unsupportedOption,\n} from \"./shared\";\n\n/**\n * Grok Build (`grok`) — xAI's official coding-agent CLI, installed by the\n * `x.ai/cli/install.sh` script (no npm package).\n *\n * Verified against the docs and source only (the binary is distributed by\n * a curl installer, which was not run): the repo user guide\n * `crates/codegen/xai-grok-pager/docs/user-guide/{14-headless-mode,\n * 07-mcp-servers,05-configuration,22-permissions-and-safety}.md`, the clap\n * definitions in `xai-grok-pager/src/app/cli.rs` and the headless reducer\n * `headless/reducer/acp.rs`, at source version 1.0.45; latest stable 1.0.62\n * (2026-10-17). The capability probe checks every flag against the\n * installed binary's `--help` before the first run.\n *\n * - Headless: `grok -p <prompt>` or `--prompt-file <path>`; piped stdin is\n * not read. `--output-format streaming-json` prints `type`-tagged lines:\n * `text`, `thought`, `tool_call`, `tool_call_update`, `usage` (per model\n * response, `input_tokens` uncached) and a final `end` (session id, totals,\n * `total_cost_usd`); failures print `{\"type\":\"error\",\"message\"}`.\n * - Permissions: headless mode answers every approval request with\n * \"cancelled\" (auto-deny); bypass is `--always-approve`.\n * - MCP: no flag; `[mcp_servers.<name>]` in `$GROK_HOME/config.toml`.\n * - Auth: `XAI_API_KEY`. Update checks are disabled with\n * `GROK_DISABLE_AUTOUPDATER=1`.\n */\nexport const grokAdapter: CliAdapter = {\n name: \"grok\",\n title: \"Grok Build\",\n command: \"grok\",\n apiKeyEnv: [\"XAI_API_KEY\"],\n homeEnv: [\"GROK_HOME\"],\n transports: [\"argv\", \"file\"],\n effort: true,\n mcp: true,\n probe: { help: [[\"--help\"]], version: [\"--version\"] },\n verification: {\n version: \"1.0.62\",\n verifiedBy: \"docs\",\n sources: [\n \"https://docs.x.ai/build/cli/headless-scripting\",\n \"https://github.com/xai-org/grok-build/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/14-headless-mode.md\",\n \"https://github.com/xai-org/grok-build/blob/main/crates/codegen/xai-grok-pager/docs/user-guide/07-mcp-servers.md\",\n ],\n checkedAt: \"2026-10-17\",\n },\n plan(context) {\n const args = [\"--output-format\", \"streaming-json\"];\n const requires = [\"--output-format\", \"streaming-json\"];\n const files: CliLaunchFile[] = [];\n let tail: string[];\n\n if (context.model !== undefined) {\n args.push(\"--model\", context.model);\n requires.push(\"--model\");\n }\n\n if (context.effort !== undefined) {\n // Grok accepts the framework scale verbatim (none … max, model-dependent).\n args.push(\"--reasoning-effort\", context.effort);\n requires.push(\"--reasoning-effort\");\n }\n\n if (context.resume !== undefined) {\n args.push(\"--resume\", context.resume);\n requires.push(\"--resume\");\n }\n\n if (context.permission === \"bypass\") {\n args.push(\"--always-approve\");\n requires.push(\"--always-approve\");\n }\n\n if (context.mcp !== undefined) {\n const home = requirePrivateHome(context, grokAdapter, \"MCP servers\");\n\n files.push({\n path: path.join(home, \"config.toml\"),\n content: toToml({ mcp_servers: grokMcp(context.mcp) }),\n });\n }\n\n if (context.transport === \"file\") {\n const prompt = promptFile(context);\n\n files.push(prompt);\n tail = [\"--prompt-file\", prompt.path];\n requires.push(\"--prompt-file\");\n } else {\n tail = [\"-p\", argvPrompt(context.prompt)];\n requires.push(\"-p\");\n }\n\n return {\n args,\n tail,\n env: {\n ...(context.home !== undefined ? { GROK_HOME: context.home } : {}),\n GROK_DISABLE_AUTOUPDATER: \"1\",\n },\n files,\n requires,\n };\n },\n parser: createGrokParser,\n};\n\nfunction grokMcp(servers: CliMcpServers): TomlTable {\n const table: TomlTable = {};\n\n for (const [name, server] of Object.entries(servers)) {\n if (server.type === \"sse\") {\n throw unsupportedOption(\n grokAdapter,\n `MCP server \"${name}\" uses SSE; Grok Build supports stdio and HTTP servers.`,\n );\n }\n\n table[name] =\n server.type === \"stdio\"\n ? { command: server.command, args: server.args ?? [], env: server.env }\n : { url: server.url, headers: server.headers };\n }\n\n return table;\n}\n\n/** Parser for `grok -p … --output-format streaming-json`. */\nexport function createGrokParser(): CliStreamParser {\n let started = false;\n let sessionRef: string | undefined;\n\n const parser = jsonLinesParser((record): CliParsedEvent[] => {\n const events: CliParsedEvent[] = [];\n\n if (!started) {\n started = true;\n events.push({ type: \"session.started\" });\n }\n\n switch (stringField(record, \"type\")) {\n case \"text\": {\n const text = stringField(record, \"data\") ?? \"\";\n\n if (text.length > 0) {\n events.push({ type: \"message\", text, delta: true, raw: record });\n }\n break;\n }\n case \"tool_call\":\n events.push({\n type: \"tool.call\",\n id: stringField(record, \"toolCallId\") ?? \"\",\n name: stringField(record, \"toolName\") ?? stringField(record, \"title\") ?? \"\",\n input: record.rawInput,\n raw: record,\n });\n break;\n case \"tool_call_update\": {\n const status = stringField(record, \"status\");\n\n if (status === \"completed\" || status === \"failed\") {\n events.push({\n type: \"tool.result\",\n id: stringField(record, \"toolCallId\") ?? \"\",\n output: outputText(record.rawOutput ?? record.content),\n isError: status === \"failed\",\n raw: record,\n });\n }\n break;\n }\n case \"usage\": {\n const usage = anthropicUsage(recordField(record, \"usage\"));\n\n if (usage !== undefined) {\n events.push({ type: \"usage\", usage, cumulative: false, raw: record });\n }\n break;\n }\n case \"end\": {\n sessionRef = stringField(record, \"sessionId\") ?? sessionRef;\n\n const usage = anthropicUsage(\n recordField(record, \"usage\"),\n numberField(record, \"total_cost_usd\"),\n );\n\n if (usage !== undefined) {\n events.push({ type: \"usage\", usage, cumulative: true, raw: record });\n }\n break;\n }\n case \"error\":\n events.push({\n type: \"error\",\n message: stringField(record, \"message\") ?? \"Grok Build reported an error\",\n fatal: true,\n raw: record,\n });\n break;\n }\n\n return events;\n });\n\n return { ...parser, sessionRef: () => sessionRef };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgDA,MAAa,cAA0B;CACrC,MAAM;CACN,OAAO;CACP,SAAS;CACT,WAAW,CAAC,aAAa;CACzB,SAAS,CAAC,WAAW;CACrB,YAAY,CAAC,QAAQ,MAAM;CAC3B,QAAQ;CACR,KAAK;CACL,OAAO;EAAE,MAAM,CAAC,CAAC,QAAQ,CAAC;EAAG,SAAS,CAAC,WAAW;CAAE;CACpD,cAAc;EACZ,SAAS;EACT,YAAY;EACZ,SAAS;GACP;GACA;GACA;EACF;EACA,WAAW;CACb;CACA,KAAK,SAAS;EACZ,MAAM,OAAO,CAAC,mBAAmB,gBAAgB;EACjD,MAAM,WAAW,CAAC,mBAAmB,gBAAgB;EACrD,MAAM,QAAyB,CAAC;EAChC,IAAI;EAEJ,IAAI,QAAQ,UAAU,QAAW;GAC/B,KAAK,KAAK,WAAW,QAAQ,KAAK;GAClC,SAAS,KAAK,SAAS;EACzB;EAEA,IAAI,QAAQ,WAAW,QAAW;GAEhC,KAAK,KAAK,sBAAsB,QAAQ,MAAM;GAC9C,SAAS,KAAK,oBAAoB;EACpC;EAEA,IAAI,QAAQ,WAAW,QAAW;GAChC,KAAK,KAAK,YAAY,QAAQ,MAAM;GACpC,SAAS,KAAK,UAAU;EAC1B;EAEA,IAAI,QAAQ,eAAe,UAAU;GACnC,KAAK,KAAK,kBAAkB;GAC5B,SAAS,KAAK,kBAAkB;EAClC;EAEA,IAAI,QAAQ,QAAQ,QAAW;GAC7B,MAAM,OAAO,mBAAmB,SAAS,aAAa,aAAa;GAEnE,MAAM,KAAK;IACT,MAAM,KAAK,KAAK,MAAM,aAAa;IACnC,SAAS,OAAO,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jE;IACF;IACA,KAAK;KACH,OAAO,KAAK;MACV,MAAM;MACN,IAAI,YAAY,QAAQ,YAAY,KAAK;MACzC,MAAM,YAAY,QAAQ,UAAU,KAAK,YAAY,QAAQ,OAAO,KAAK;MACzE,OAAO,OAAO;MACd,KAAK;KACP,CAAC;KACD;IACF,KAAK,oBAAoB;KACvB,MAAM,SAAS,YAAY,QAAQ,QAAQ;KAE3C,IAAI,WAAW,eAAe,WAAW,UACvC,OAAO,KAAK;MACV,MAAM;MACN,IAAI,YAAY,QAAQ,YAAY,KAAK;MACzC,QAAQ,WAAW,OAAO,aAAa,OAAO,OAAO;MACrD,SAAS,WAAW;MACpB,KAAK;KACP,CAAC;KAEH;IACF;IACA,KAAK,SAAS;KACZ,MAAM,QAAQ,eAAe,YAAY,QAAQ,OAAO,CAAC;KAEzD,IAAI,UAAU,QACZ,OAAO,KAAK;MAAE,MAAM;MAAS;MAAO,YAAY;MAAO,KAAK;KAAO,CAAC;KAEtE;IACF;IACA,KAAK,OAAO;KACV,aAAa,YAAY,QAAQ,WAAW,KAAK;KAEjD,MAAM,QAAQ,eACZ,YAAY,QAAQ,OAAO,GAC3B,YAAY,QAAQ,gBAAgB,CACtC;KAEA,IAAI,UAAU,QACZ,OAAO,KAAK;MAAE,MAAM;MAAS;MAAO,YAAY;MAAM,KAAK;KAAO,CAAC;KAErE;IACF;IACA,KAAK,SACH,OAAO,KAAK;KACV,MAAM;KACN,SAAS,YAAY,QAAQ,SAAS,KAAK;KAC3C,OAAO;KACP,KAAK;IACP,CAAC;GAEL;GAEA,OAAO;EACT,CAEiB;EAAG,kBAAkB;CAAW;AACnD"}
|
package/esm/adapters/index.d.mts
CHANGED
|
@@ -13,4 +13,5 @@ import { createVibeParser, mistralVibeAdapter } from "./mistral-vibe.mjs";
|
|
|
13
13
|
import { createOpencodeParser, opencodeAdapter } from "./opencode.mjs";
|
|
14
14
|
import { qwenCodeAdapter } from "./qwen-code.mjs";
|
|
15
15
|
import { createReasonixParser, reasonixAdapter } from "./reasonix.mjs";
|
|
16
|
-
import { anthropicUsage, argvPrompt, dotenvFile, jsonFile, mapEffort, mcpServersJson, parseArguments, promptFile, requirePrivateHome, unsupportedOption, usageOf } from "./shared.mjs";
|
|
16
|
+
import { anthropicUsage, argvPrompt, dotenvFile, jsonFile, mapEffort, mcpServersJson, parseArguments, promptFile, requirePrivateHome, unsupportedOption, usageOf } from "./shared.mjs";
|
|
17
|
+
export { type ClaudeStreamUsage, aiderAdapter, ampAdapter, anthropicUsage, antigravityAdapter, argvPrompt, claudeCodeAdapter, codexAdapter, copilotAdapter, createAiderParser, createAntigravityParser, createClaudeStreamParser, createCodexParser, createCopilotParser, createCursorParser, createDroidParser, createGrokParser, createKimiParser, createOpencodeParser, createReasonixParser, createVibeParser, cursorAdapter, dotenvFile, droidAdapter, grokAdapter, jsonFile, kimiAdapter, mapEffort, mcpServersJson, mistralVibeAdapter, opencodeAdapter, parseAiderCount, parseArguments, promptFile, qwenCodeAdapter, reasonixAdapter, requirePrivateHome, unsupportedOption, usageOf };
|
package/esm/adapters/index.mjs
CHANGED
|
@@ -15,4 +15,4 @@ import { createOpencodeParser, opencodeAdapter } from "./opencode.mjs";
|
|
|
15
15
|
import { qwenCodeAdapter } from "./qwen-code.mjs";
|
|
16
16
|
import { createReasonixParser, reasonixAdapter } from "./reasonix.mjs";
|
|
17
17
|
|
|
18
|
-
export {
|
|
18
|
+
export { aiderAdapter, ampAdapter, anthropicUsage, antigravityAdapter, argvPrompt, claudeCodeAdapter, codexAdapter, copilotAdapter, createAiderParser, createAntigravityParser, createClaudeStreamParser, createCodexParser, createCopilotParser, createCursorParser, createDroidParser, createGrokParser, createKimiParser, createOpencodeParser, createReasonixParser, createVibeParser, cursorAdapter, dotenvFile, droidAdapter, grokAdapter, jsonFile, kimiAdapter, mapEffort, mcpServersJson, mistralVibeAdapter, opencodeAdapter, parseAiderCount, parseArguments, promptFile, qwenCodeAdapter, reasonixAdapter, requirePrivateHome, unsupportedOption, usageOf };
|
package/esm/adapters/kimi.d.mts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CliAdapter, CliStreamParser } from "../contracts/adapter.contract.mjs";
|
|
2
|
+
import "../contracts/index.mjs";
|
|
2
3
|
//#region ../../packages/ai-cli/src/adapters/kimi.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* Kimi Code CLI (`kimi`, npm `@moonshot-ai/kimi-code`) — Moonshot AI's
|
|
@@ -26,9 +27,8 @@ import { CliAdapter, CliStreamParser } from "../contracts/adapter.contract.mjs";
|
|
|
26
27
|
* key set `KIMI_MODEL_NAME` (and optionally `KIMI_MODEL_PROVIDER_TYPE`,
|
|
27
28
|
* `KIMI_MODEL_BASE_URL`) in `env`; `apiKey` becomes `KIMI_MODEL_API_KEY`.
|
|
28
29
|
*/
|
|
29
|
-
declare const kimiAdapter: CliAdapter;
|
|
30
|
+
export declare const kimiAdapter: CliAdapter;
|
|
30
31
|
/** Parser for `kimi -p … --output-format stream-json`. */
|
|
31
|
-
declare function createKimiParser(): CliStreamParser;
|
|
32
|
+
export declare function createKimiParser(): CliStreamParser;
|
|
32
33
|
//#endregion
|
|
33
|
-
export { createKimiParser, kimiAdapter };
|
|
34
34
|
//# sourceMappingURL=kimi.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"kimi.d.mts","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/kimi.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"kimi.d.mts","names":[],"sources":["../../../../../../../../packages/ai-cli/src/adapters/kimi.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;qBA4Ca,aAAa;;wBAkFV,oBAAoB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CliAdapter, CliLaunchContext, CliStreamParser } from "../contracts/adapter.contract.mjs";
|
|
2
|
+
import "../contracts/index.mjs";
|
|
2
3
|
//#region ../../packages/ai-cli/src/adapters/mistral-vibe.d.ts
|
|
3
4
|
/**
|
|
4
5
|
* Mistral Vibe (`vibe`, PyPI `mistral-vibe`).
|
|
@@ -24,9 +25,8 @@ import { CliAdapter, CliLaunchContext, CliStreamParser } from "../contracts/adap
|
|
|
24
25
|
* - MCP: `[[mcp_servers]]` in `$VIBE_HOME/config.toml` (private home).
|
|
25
26
|
* - Auth: `MISTRAL_API_KEY`; home `VIBE_HOME`.
|
|
26
27
|
*/
|
|
27
|
-
declare const mistralVibeAdapter: CliAdapter;
|
|
28
|
+
export declare const mistralVibeAdapter: CliAdapter;
|
|
28
29
|
/** Parser for `vibe -p … --output streaming` (plus the run's `export.json`). */
|
|
29
|
-
declare function createVibeParser(context?: CliLaunchContext): CliStreamParser;
|
|
30
|
+
export declare function createVibeParser(context?: CliLaunchContext): CliStreamParser;
|
|
30
31
|
//#endregion
|
|
31
|
-
export { createVibeParser, mistralVibeAdapter };
|
|
32
32
|
//# sourceMappingURL=mistral-vibe.d.mts.map
|