@tokenfactory/acc-runner 0.40.2 → 0.40.3
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/engines/chat-stream.d.ts +31 -0
- package/dist/engines/chat-stream.d.ts.map +1 -0
- package/dist/engines/chat-stream.js +56 -0
- package/dist/engines/chat-stream.js.map +1 -0
- package/dist/engines/claude-code-chat.d.ts +2 -5
- package/dist/engines/claude-code-chat.d.ts.map +1 -1
- package/dist/engines/claude-code-chat.js +3 -48
- package/dist/engines/claude-code-chat.js.map +1 -1
- package/dist/engines/codex-chat.d.ts +86 -0
- package/dist/engines/codex-chat.d.ts.map +1 -0
- package/dist/engines/codex-chat.js +290 -0
- package/dist/engines/codex-chat.js.map +1 -0
- package/dist/engines/registry.d.ts.map +1 -1
- package/dist/engines/registry.js +8 -2
- package/dist/engines/registry.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CC-4A (CODEX-ADAPTER): the engine-agnostic headless-streaming driver shared by
|
|
3
|
+
* every chat-lane adapter (claude-code-chat, codex-chat, …).
|
|
4
|
+
*
|
|
5
|
+
* Extracted from the CC-1C claude reference adapter so a second provider does
|
|
6
|
+
* not re-implement — and subtly diverge on — the delta-sequencing contract the
|
|
7
|
+
* conformance suite pins: monotonic 0-based `seq`, EXACTLY ONE terminal `done`
|
|
8
|
+
* frame, and a synthetic terminal frame when the child ends without emitting a
|
|
9
|
+
* result event (crash / abort / silent exit). The ONLY per-engine variation is
|
|
10
|
+
* the JSONL line parser, injected as `parseLine`.
|
|
11
|
+
*/
|
|
12
|
+
import type { ExecaChildProcess } from "execa";
|
|
13
|
+
import type { EngineStreamChunk } from "./types.js";
|
|
14
|
+
/** One parsed stream event: the text to surface (may be "") and whether the turn is terminal. */
|
|
15
|
+
export interface ParsedChatStreamEvent {
|
|
16
|
+
text: string;
|
|
17
|
+
done: boolean;
|
|
18
|
+
}
|
|
19
|
+
/** Parse one raw JSONL stdout line into a stream event, or null to skip it. */
|
|
20
|
+
export type ChatStreamLineParser = (line: string) => ParsedChatStreamEvent | null;
|
|
21
|
+
/**
|
|
22
|
+
* Drive one headless streaming turn: pipe `prompt` on stdin, parse the child's
|
|
23
|
+
* stdout JSONL line-by-line with `parseLine`, and yield the resulting deltas.
|
|
24
|
+
*
|
|
25
|
+
* The terminal `result` event carries the full text; it is only surfaced as a
|
|
26
|
+
* delta when nothing streamed (an engine that emits no incremental assistant
|
|
27
|
+
* events). A turn that ends WITHOUT a terminal event still yields a final
|
|
28
|
+
* `{ done: true }` so the consumer's gap/done detection always fires.
|
|
29
|
+
*/
|
|
30
|
+
export declare function streamChatTurn(child: ExecaChildProcess, prompt: string, parseLine: ChatStreamLineParser): AsyncIterable<EngineStreamChunk>;
|
|
31
|
+
//# sourceMappingURL=chat-stream.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-stream.d.ts","sourceRoot":"","sources":["../../src/engines/chat-stream.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AAC/C,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAEpD,iGAAiG;AACjG,MAAM,WAAW,qBAAqB;IACpC,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,OAAO,CAAC;CACf;AAED,+EAA+E;AAC/E,MAAM,MAAM,oBAAoB,GAAG,CAAC,IAAI,EAAE,MAAM,KAAK,qBAAqB,GAAG,IAAI,CAAC;AAElF;;;;;;;;GAQG;AACH,wBAAuB,cAAc,CACnC,KAAK,EAAE,iBAAiB,EACxB,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,oBAAoB,GAC9B,aAAa,CAAC,iBAAiB,CAAC,CA6ClC"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Drive one headless streaming turn: pipe `prompt` on stdin, parse the child's
|
|
3
|
+
* stdout JSONL line-by-line with `parseLine`, and yield the resulting deltas.
|
|
4
|
+
*
|
|
5
|
+
* The terminal `result` event carries the full text; it is only surfaced as a
|
|
6
|
+
* delta when nothing streamed (an engine that emits no incremental assistant
|
|
7
|
+
* events). A turn that ends WITHOUT a terminal event still yields a final
|
|
8
|
+
* `{ done: true }` so the consumer's gap/done detection always fires.
|
|
9
|
+
*/
|
|
10
|
+
export async function* streamChatTurn(child, prompt, parseLine) {
|
|
11
|
+
if (child.stdin) {
|
|
12
|
+
child.stdin.write(prompt);
|
|
13
|
+
child.stdin.end();
|
|
14
|
+
}
|
|
15
|
+
let seq = 0;
|
|
16
|
+
let sawText = false;
|
|
17
|
+
let doneEmitted = false;
|
|
18
|
+
let buf = "";
|
|
19
|
+
const emit = function* (ev) {
|
|
20
|
+
if (ev.done) {
|
|
21
|
+
yield { seq: seq++, delta: sawText ? "" : ev.text, done: true };
|
|
22
|
+
doneEmitted = true;
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
sawText = true;
|
|
26
|
+
yield { seq: seq++, delta: ev.text, done: false };
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const stdout = child.stdout;
|
|
30
|
+
if (stdout) {
|
|
31
|
+
for await (const raw of stdout) {
|
|
32
|
+
buf += typeof raw === "string" ? raw : raw.toString("utf8");
|
|
33
|
+
let nl;
|
|
34
|
+
while ((nl = buf.indexOf("\n")) !== -1) {
|
|
35
|
+
const line = buf.slice(0, nl);
|
|
36
|
+
buf = buf.slice(nl + 1);
|
|
37
|
+
const ev = parseLine(line);
|
|
38
|
+
if (ev)
|
|
39
|
+
yield* emit(ev);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (buf.trim()) {
|
|
43
|
+
const ev = parseLine(buf);
|
|
44
|
+
if (ev)
|
|
45
|
+
yield* emit(ev);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
// Await the child so an abort/SIGTERM is observed and the process is reaped.
|
|
49
|
+
// reject:false → resolves even on a non-zero exit; we never throw here.
|
|
50
|
+
await child.catch(() => undefined);
|
|
51
|
+
// A process that ended without a terminal event still owes the consumer a
|
|
52
|
+
// terminal frame so its gap/done detection fires.
|
|
53
|
+
if (!doneEmitted)
|
|
54
|
+
yield { seq: seq++, delta: "", done: true };
|
|
55
|
+
}
|
|
56
|
+
//# sourceMappingURL=chat-stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chat-stream.js","sourceRoot":"","sources":["../../src/engines/chat-stream.ts"],"names":[],"mappings":"AAuBA;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,SAAS,CAAC,CAAC,cAAc,CACnC,KAAwB,EACxB,MAAc,EACd,SAA+B;IAE/B,IAAI,KAAK,CAAC,KAAK,EAAE,CAAC;QAChB,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAC1B,KAAK,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;IACpB,CAAC;IACD,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,IAAI,WAAW,GAAG,KAAK,CAAC;IACxB,IAAI,GAAG,GAAG,EAAE,CAAC;IAEb,MAAM,IAAI,GAAG,QAAQ,CAAC,EAAE,EAAyB;QAC/C,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC;YACZ,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;YAChE,WAAW,GAAG,IAAI,CAAC;QACrB,CAAC;aAAM,CAAC;YACN,OAAO,GAAG,IAAI,CAAC;YACf,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE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-1,5 +1,6 @@
|
|
|
1
1
|
import { type ExecaChildProcess } from "execa";
|
|
2
2
|
import { type AnthropicAuthMode } from "../provider-auth.js";
|
|
3
|
+
import { type ParsedChatStreamEvent } from "./chat-stream.js";
|
|
3
4
|
import type { AccMcpToolBusFence, ConformantAgentEngine, EngineCapabilityMatrix, EngineStreamTurnOptions, RunnerCapacityClass } from "./types.js";
|
|
4
5
|
/**
|
|
5
6
|
* Native (built-in) claude tools disabled for a chat-lane turn. The tool bus is
|
|
@@ -45,11 +46,7 @@ export declare function buildChatArgs(opts?: {
|
|
|
45
46
|
* token. Never mutates `base`.
|
|
46
47
|
*/
|
|
47
48
|
export declare function chatEnv(opts: EngineStreamTurnOptions): NodeJS.ProcessEnv;
|
|
48
|
-
|
|
49
|
-
export interface ParsedChatStreamEvent {
|
|
50
|
-
text: string;
|
|
51
|
-
done: boolean;
|
|
52
|
-
}
|
|
49
|
+
export type { ParsedChatStreamEvent };
|
|
53
50
|
/**
|
|
54
51
|
* TOLERANT parse of one line of claude's `--output-format=stream-json` output
|
|
55
52
|
* (the v0.44 codex tolerant-parser lesson: a point-release event-shape drift
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-code-chat.d.ts","sourceRoot":"","sources":["../../src/engines/claude-code-chat.ts"],"names":[],"mappings":"AAiCA,OAAO,EAAS,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAIL,KAAK,iBAAiB,EACvB,MAAM,qBAAqB,CAAC;AAG7B,OAAO,KAAK,EACV,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EAItB,uBAAuB,EACvB,mBAAmB,EACpB,MAAM,YAAY,CAAC;AAIpB;;;;;;;;GAQG;AACH,eAAO,MAAM,qBAAqB,EAAE,SAAS,MAAM,EAgBlD,CAAC;AAEF,mGAAmG;AACnG,eAAO,MAAM,4BAA4B,6BAA6B,CAAC;AAEvE;;;;;GAKG;AACH,wBAAgB,iBAAiB,IAAI,kBAAk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,EAAE,MAAM,GAAG,qBAAqB,GAAG,IAAI,CAoB9E;AASD;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,mBAAmB,CAO1F;AA4CD,8EAA8E;AAC9E,eAAO,MAAM,6BAA6B,EAAE,sBAO3C,CAAC;AAEF,MAAM,WAAW,kBAAkB;IACjC,uEAAuE;IACvE,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,uBAAuB,KAAK,iBAAiB,CAAC;IACjE,oEAAoE;IACpE,WAAW,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,CAAC,UAAU,KAAK,iBAAiB,CAAC;IAC5D,2IAA2I;IAC3I,qBAAqB,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/C,uGAAuG;IACvG,cAAc,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;IACxC,sFAAsF;IACtF,WAAW,CAAC,EAAE,MAAM;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;CACtD;AAYD;;;;;;GAMG;AACH,wBAAgB,0BAA0B,CAAC,IAAI,GAAE,kBAAuB,GAAG,qBAAqB,CAU/F;AAED,6DAA6D;AAC7D,eAAO,MAAM,oBAAoB,EAAE,qBAAoD,CAAC"}
|
|
@@ -35,6 +35,7 @@ import { execa } from "execa";
|
|
|
35
35
|
import { resolveAuthMode, describeAuthMode, withAnthropicAuth, } from "../provider-auth.js";
|
|
36
36
|
import { ACC_MCP_KEY } from "../mcp-spawn.js";
|
|
37
37
|
import { claudeCodeEngine } from "./claude-code.js";
|
|
38
|
+
import { streamChatTurn } from "./chat-stream.js";
|
|
38
39
|
const BINARY = "claude";
|
|
39
40
|
/**
|
|
40
41
|
* Native (built-in) claude tools disabled for a chat-lane turn. The tool bus is
|
|
@@ -190,54 +191,8 @@ export function parseChatStreamLine(line) {
|
|
|
190
191
|
}
|
|
191
192
|
return null;
|
|
192
193
|
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
if (child.stdin) {
|
|
196
|
-
child.stdin.write(opts.prompt);
|
|
197
|
-
child.stdin.end();
|
|
198
|
-
}
|
|
199
|
-
let seq = 0;
|
|
200
|
-
let sawText = false;
|
|
201
|
-
let doneEmitted = false;
|
|
202
|
-
let buf = "";
|
|
203
|
-
const emit = function* (ev) {
|
|
204
|
-
if (ev.done) {
|
|
205
|
-
// The terminal `result` carries the full text; only surface it as a delta
|
|
206
|
-
// when nothing was streamed (older claude that emits no `assistant` events).
|
|
207
|
-
yield { seq: seq++, delta: sawText ? "" : ev.text, done: true };
|
|
208
|
-
doneEmitted = true;
|
|
209
|
-
}
|
|
210
|
-
else {
|
|
211
|
-
sawText = true;
|
|
212
|
-
yield { seq: seq++, delta: ev.text, done: false };
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
const stdout = child.stdout;
|
|
216
|
-
if (stdout) {
|
|
217
|
-
for await (const raw of stdout) {
|
|
218
|
-
buf += typeof raw === "string" ? raw : raw.toString("utf8");
|
|
219
|
-
let nl;
|
|
220
|
-
while ((nl = buf.indexOf("\n")) !== -1) {
|
|
221
|
-
const line = buf.slice(0, nl);
|
|
222
|
-
buf = buf.slice(nl + 1);
|
|
223
|
-
const ev = parseChatStreamLine(line);
|
|
224
|
-
if (ev)
|
|
225
|
-
yield* emit(ev);
|
|
226
|
-
}
|
|
227
|
-
}
|
|
228
|
-
if (buf.trim()) {
|
|
229
|
-
const ev = parseChatStreamLine(buf);
|
|
230
|
-
if (ev)
|
|
231
|
-
yield* emit(ev);
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
// Await the child so an abort/SIGTERM is observed and the process is reaped.
|
|
235
|
-
// reject:false → resolves even on a non-zero exit; we never throw here.
|
|
236
|
-
await child.catch(() => undefined);
|
|
237
|
-
// A process that ended without a `result` event (crash, abort, silent exit)
|
|
238
|
-
// still owes the consumer a terminal frame so its gap/done detection fires.
|
|
239
|
-
if (!doneEmitted)
|
|
240
|
-
yield { seq: seq++, delta: "", done: true };
|
|
194
|
+
function streamTurnImpl(deps, opts) {
|
|
195
|
+
return streamChatTurn(deps.spawnChat(opts), opts.prompt, parseChatStreamLine);
|
|
241
196
|
}
|
|
242
197
|
/**
|
|
243
198
|
* Pure host-load → capacity-class mapping (extracted so it is unit-testable
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"claude-code-chat.js","sourceRoot":"","sources":["../../src/engines/claude-code-chat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,KAAK,EAA0B,MAAM,OAAO,CAAC;AACtD,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,iBAAiB,GAElB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"claude-code-chat.js","sourceRoot":"","sources":["../../src/engines/claude-code-chat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EAAE,MAAM,SAAS,CAAC;AACzB,OAAO,EAAE,KAAK,EAA0B,MAAM,OAAO,CAAC;AACtD,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,iBAAiB,GAElB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,cAAc,EAA8B,MAAM,kBAAkB,CAAC;AAY9E,MAAM,MAAM,GAAG,QAAQ,CAAC;AAExB;;;;;;;;GAQG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAAsB;IACtD,M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,8EAA8E;AAC9E,MAAM,CAAC,MAAM,6BAA6B,GAA2B;IACnE,iBAAiB,EAAE,IAAI;IACvB,aAAa,EAAE,IAAI;IACnB,QAAQ,EAAE,IAAI;IACd,QAAQ,EAAE,IAAI;IACd,UAAU,EAAE,IAAI;IAChB,IAAI,EAAE,MAAM;CACb,CAAC;AAiBF,MAAM,YAAY,GAAqB;IACrC,SAAS;IACT,WAAW,EAAE,eAAe;IAC5B,qBAAqB,EAAE,KAAK,IAAI,EAAE,CAAC,IAAI;IACvC,cAAc,EAAE,qBAAqB;IACrC,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,MAAM,EAAE,CAAC;CAC9E,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,0BAA0B,CAAC,OAA2B,EAAE;IACtE,MAAM,CAAC,GAAqB,EAAE,GAAG,YAAY,EAAE,GAAG,IAAI,EAAE,CAAC;IACzD,OAAO;QACL,GAAG,gBAAgB;QACnB,YAAY,EAAE,6BAA6B;QAC3C,UAAU,EAAE,CAAC,IAA6B,EAAE,EAAE,CAAC,cAAc,CAAC,CAAC,EAAE,IAAI,CAAC;QACtE,iBAAiB;QACjB,eAAe,EAAE,GAAG,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC;QAC7C,gBAAgB,EAAE,GAAG,EAAE,CAAC,oBAAoB,CAAC,CAAC,CAAC;KAChD,CAAC;AACJ,CAAC;AAED,6DAA6D;AAC7D,MAAM,CAAC,MAAM,oBAAoB,GAA0B,0BAA0B,EAAE,CAAC"}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { type ExecaChildProcess } from "execa";
|
|
2
|
+
import { type CodexAuthMode } from "../provider-auth.js";
|
|
3
|
+
import { type ParsedChatStreamEvent } from "./chat-stream.js";
|
|
4
|
+
import type { AccMcpToolBusFence, ConformantAgentEngine, EngineCapabilityMatrix, EngineStreamTurnOptions } from "./types.js";
|
|
5
|
+
/**
|
|
6
|
+
* Native (built-in) codex tools disabled for a chat-lane turn. The tool bus is
|
|
7
|
+
* fenced to acc-mcp only, so none of codex's shell / patch / web / file tools
|
|
8
|
+
* may run — the hardening test asserts every one is disabled via its
|
|
9
|
+
* `-c tools.<name>=false` override. Defence-in-depth on top of the
|
|
10
|
+
* "only MCP tools" override: even a codex build that treats a built-in as
|
|
11
|
+
* implicitly-enabled still cannot mutate the repo or reach outside acc-mcp.
|
|
12
|
+
*/
|
|
13
|
+
export declare const NATIVE_TOOLS_DISABLED_CODEX: readonly string[];
|
|
14
|
+
/** Codex config override that pins the session to MCP tools only. */
|
|
15
|
+
export declare const CODEX_MCP_ONLY_OVERRIDE = "experimental_use_only_mcp_tools=true";
|
|
16
|
+
/**
|
|
17
|
+
* The tool-bus fence: acc-mcp only. `enforced` is always true for this adapter
|
|
18
|
+
* (the chat lane never runs unfenced), and `allowedServers` is exactly the
|
|
19
|
+
* acc-mcp server id (`ACC_MCP_KEY`, shared with mcp-spawn.ts so the whitelisted
|
|
20
|
+
* server matches the one the runner writes into the codex MCP config).
|
|
21
|
+
*/
|
|
22
|
+
export declare function accMcpToolBusOnly(): AccMcpToolBusFence;
|
|
23
|
+
/**
|
|
24
|
+
* Build the argv for a headless streaming codex chat turn. Fences the tool bus
|
|
25
|
+
* to acc-mcp only and disables every native tool, all through codex's generic
|
|
26
|
+
* `-c key=value` config-override mechanism so the fence survives a point-release
|
|
27
|
+
* flag rename:
|
|
28
|
+
* exec --json → headless structured event stream
|
|
29
|
+
* --dangerously-bypass-approvals-and-sandbox → non-interactive; the fence, not
|
|
30
|
+
* an approval prompt, is the boundary (mirrors the batch lane rationale).
|
|
31
|
+
* -c tools.<native>=false → defence-in-depth block-list
|
|
32
|
+
* -c experimental_use_only_mcp_tools=true → ONLY MCP (acc-mcp) tools may run
|
|
33
|
+
* `--model` is forwarded only when the turn pins a non-blank model.
|
|
34
|
+
*/
|
|
35
|
+
export declare function buildCodexChatArgs(opts?: {
|
|
36
|
+
modelId?: string | null;
|
|
37
|
+
}): string[];
|
|
38
|
+
/**
|
|
39
|
+
* Augment the base environment for a codex chat turn: resolve the first-attempt
|
|
40
|
+
* auth channel (subscription vs api-key) via the shared `withOpenAiAuth` (so chat
|
|
41
|
+
* authenticates identically to the batch lane) and, when present, surface the
|
|
42
|
+
* per-turn delegation token so the acc-mcp bus acts with the narrowly-scoped
|
|
43
|
+
* companion delegation rather than the runner token. Never mutates `base`.
|
|
44
|
+
*/
|
|
45
|
+
export declare function codexChatEnv(opts: EngineStreamTurnOptions): NodeJS.ProcessEnv;
|
|
46
|
+
/**
|
|
47
|
+
* TOLERANT parse of one line of a codex chat stream into a stream event. Reads
|
|
48
|
+
* TWO shapes so one conformance suite drives both adapters:
|
|
49
|
+
* - claude-style stream-json (`type:"assistant"` blocks / `type:"result"`) —
|
|
50
|
+
* the shape the engine-agnostic conformance suite replays;
|
|
51
|
+
* - codex-native `exec --json` events (`item.completed` → `agent_message`,
|
|
52
|
+
* `turn.completed`, older `{msg:{…}}` / `{response:{…}}` envelopes).
|
|
53
|
+
* Returns `{text,done:false}` for a delta, `{text,done:true}` for the terminal
|
|
54
|
+
* event, or null for a non-JSON / keep-alive / uninteresting line.
|
|
55
|
+
*/
|
|
56
|
+
export declare function parseCodexChatStreamLine(line: string): ParsedChatStreamEvent | null;
|
|
57
|
+
/** Static capability declaration for the codex chat adapter. */
|
|
58
|
+
export declare const CODEX_CHAT_CAPABILITIES: EngineCapabilityMatrix;
|
|
59
|
+
export interface CodexChatDeps {
|
|
60
|
+
/** Spawn the chat child (default: real `codex exec --json` stream spawn). */
|
|
61
|
+
spawnChat?: (opts: EngineStreamTurnOptions) => ExecaChildProcess;
|
|
62
|
+
/** Resolve the first-attempt codex auth mode (default: `resolveCodexSpawnMode`). */
|
|
63
|
+
resolveSpawnMode?: (env: NodeJS.ProcessEnv) => CodexAuthMode;
|
|
64
|
+
/** Whether an OPENAI_API_KEY is present for the api-key channel (default: env read). */
|
|
65
|
+
hasApiKey?: (env: NodeJS.ProcessEnv) => boolean;
|
|
66
|
+
/** Whether a usable ChatGPT login session exists (default: optimistic true; a stale one surfaces as auth_expired at turn time). */
|
|
67
|
+
hasSubscriptionSession?: () => Promise<boolean>;
|
|
68
|
+
/** Whether the host holds a repo-write grant → full vs draft-only tier (default: `gh auth status`). */
|
|
69
|
+
repoWriteProbe?: () => Promise<boolean>;
|
|
70
|
+
/** Sample host load for capacity classification (default: `os.loadavg`/`os.cpus`). */
|
|
71
|
+
loadSampler?: () => {
|
|
72
|
+
load1: number;
|
|
73
|
+
cores: number;
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Build a chat-conformant codex engine. Composes the FROZEN batch `codexEngine`
|
|
78
|
+
* (id/binary/authMode/buildArgs/env/spawn/parseResult/classifyFailure/
|
|
79
|
+
* healthProbe are inherited verbatim — the batch lanes are untouched) and adds
|
|
80
|
+
* the chat-lane conformance surface. All side effects are injectable so the
|
|
81
|
+
* conformance suite runs deterministically without a real `codex` binary.
|
|
82
|
+
*/
|
|
83
|
+
export declare function createCodexChatEngine(deps?: CodexChatDeps): ConformantAgentEngine;
|
|
84
|
+
/** The wired default chat-conformant codex adapter. */
|
|
85
|
+
export declare const codexChatEngine: ConformantAgentEngine;
|
|
86
|
+
//# sourceMappingURL=codex-chat.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-chat.d.ts","sourceRoot":"","sources":["../../src/engines/codex-chat.ts"],"names":[],"mappings":"AAwCA,OAAO,EAAS,KAAK,iBAAiB,EAAE,MAAM,OAAO,CAAC;AACtD,OAAO,EAIL,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAC;AAO7B,OAAO,EAAkB,KAAK,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AAC9E,OAAO,KAAK,EACV,kBAAkB,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tD;AAaD;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,IAAI,GAAE,aAAkB,GAAG,qBAAqB,CAWrF;AAED,uDAAuD;AACvD,eAAO,MAAM,eAAe,EAAE,qBAA+C,CAAC"}
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* CC-4A (CODEX-ADAPTER): the chat-hardened `codex` adapter on the CC-0A engine
|
|
3
|
+
* conformance interface (`ConformantAgentEngine`, engines/types.ts) — the first
|
|
4
|
+
* NON-Anthropic engine to reach the chat conformance floor.
|
|
5
|
+
*
|
|
6
|
+
* The batch task/review lanes drive codex via the plain `AgentEngine`
|
|
7
|
+
* (`codexEngine` in codex.ts) — that export is UNCHANGED. This module layers the
|
|
8
|
+
* strictly-larger chat-lane obligations on top of it, exactly as
|
|
9
|
+
* `claude-code-chat.ts` does for claude:
|
|
10
|
+
*
|
|
11
|
+
* 1. Headless streaming turn — `streamTurn()` spawns `codex exec --json`, pipes
|
|
12
|
+
* the operator prompt on stdin, and yields incremental `EngineStreamChunk`s
|
|
13
|
+
* through the shared `streamChatTurn` driver (identical delta-sequencing
|
|
14
|
+
* contract as the reference adapter). `parseCodexChatStreamLine` is TOLERANT
|
|
15
|
+
* (the v0.44 lesson): it reads BOTH codex's native `--json` event shapes and
|
|
16
|
+
* the claude-style stream-json shape the engine-agnostic conformance suite
|
|
17
|
+
* replays, so one suite runs both adapters.
|
|
18
|
+
* 2. acc-mcp as the ONLY tool bus — `accMcpToolBusOnly()` is the declarative
|
|
19
|
+
* fence and `buildCodexChatArgs()` enforces it: every native codex tool
|
|
20
|
+
* (shell / apply_patch / web_search / file IO) is disabled via a
|
|
21
|
+
* `-c tools.<name>=false` override AND only MCP tools may run
|
|
22
|
+
* (`experimental_use_only_mcp_tools=true`). The runner writes a codex config
|
|
23
|
+
* listing ONLY the acc-mcp server (the codex analog of the `.mcp.json`
|
|
24
|
+
* mcp-spawn writes for claude), so no native tool can escape the fence.
|
|
25
|
+
* 3. Credential-tier probe — `credentialProbe()` resolves the OpenAI/Codex auth
|
|
26
|
+
* channel (api-key OR ChatGPT subscription) and the highest tier it
|
|
27
|
+
* authorises (`full` with a repo-write grant, else `draft-only`;
|
|
28
|
+
* `unavailable` with no model credential). Never echoes key material.
|
|
29
|
+
* 4. Capacity classifier — `classifyCapacity()` reuses the shared host-load
|
|
30
|
+
* bucketer so codex reports the same `idle | light | saturated | overloaded`
|
|
31
|
+
* classes the scheduler routes on.
|
|
32
|
+
* 5. Declared capability matrix — `capabilities`, read by the scheduler via the
|
|
33
|
+
* registry to route turns.
|
|
34
|
+
*
|
|
35
|
+
* Every side-effecting probe (spawn, auth resolution, repo-write check, load
|
|
36
|
+
* sample) is injectable via `createCodexChatEngine(deps)` so the conformance
|
|
37
|
+
* suite exercises the LOGIC deterministically without a real `codex` binary.
|
|
38
|
+
* `codexChatEngine` is the wired default built from the production deps.
|
|
39
|
+
*/
|
|
40
|
+
import os from "node:os";
|
|
41
|
+
import { execa } from "execa";
|
|
42
|
+
import { openaiApiKey, describeCodexAuthMode, withOpenAiAuth, } from "../provider-auth.js";
|
|
43
|
+
import { ACC_MCP_KEY } from "../mcp-spawn.js";
|
|
44
|
+
import { codexEngine, resolveCodexSpawnMode } from "./codex.js";
|
|
45
|
+
import { classifyCapacityFromLoad, ACC_MCP_DELEGATION_TOKEN_ENV, } from "./claude-code-chat.js";
|
|
46
|
+
import { streamChatTurn } from "./chat-stream.js";
|
|
47
|
+
const BINARY = "codex";
|
|
48
|
+
/**
|
|
49
|
+
* Native (built-in) codex tools disabled for a chat-lane turn. The tool bus is
|
|
50
|
+
* fenced to acc-mcp only, so none of codex's shell / patch / web / file tools
|
|
51
|
+
* may run — the hardening test asserts every one is disabled via its
|
|
52
|
+
* `-c tools.<name>=false` override. Defence-in-depth on top of the
|
|
53
|
+
* "only MCP tools" override: even a codex build that treats a built-in as
|
|
54
|
+
* implicitly-enabled still cannot mutate the repo or reach outside acc-mcp.
|
|
55
|
+
*/
|
|
56
|
+
export const NATIVE_TOOLS_DISABLED_CODEX = [
|
|
57
|
+
"shell",
|
|
58
|
+
"apply_patch",
|
|
59
|
+
"web_search",
|
|
60
|
+
"read_file",
|
|
61
|
+
"write_file",
|
|
62
|
+
"view_image",
|
|
63
|
+
];
|
|
64
|
+
/** Codex config override that pins the session to MCP tools only. */
|
|
65
|
+
export const CODEX_MCP_ONLY_OVERRIDE = "experimental_use_only_mcp_tools=true";
|
|
66
|
+
/**
|
|
67
|
+
* The tool-bus fence: acc-mcp only. `enforced` is always true for this adapter
|
|
68
|
+
* (the chat lane never runs unfenced), and `allowedServers` is exactly the
|
|
69
|
+
* acc-mcp server id (`ACC_MCP_KEY`, shared with mcp-spawn.ts so the whitelisted
|
|
70
|
+
* server matches the one the runner writes into the codex MCP config).
|
|
71
|
+
*/
|
|
72
|
+
export function accMcpToolBusOnly() {
|
|
73
|
+
return { enforced: true, allowedServers: [ACC_MCP_KEY] };
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Build the argv for a headless streaming codex chat turn. Fences the tool bus
|
|
77
|
+
* to acc-mcp only and disables every native tool, all through codex's generic
|
|
78
|
+
* `-c key=value` config-override mechanism so the fence survives a point-release
|
|
79
|
+
* flag rename:
|
|
80
|
+
* exec --json → headless structured event stream
|
|
81
|
+
* --dangerously-bypass-approvals-and-sandbox → non-interactive; the fence, not
|
|
82
|
+
* an approval prompt, is the boundary (mirrors the batch lane rationale).
|
|
83
|
+
* -c tools.<native>=false → defence-in-depth block-list
|
|
84
|
+
* -c experimental_use_only_mcp_tools=true → ONLY MCP (acc-mcp) tools may run
|
|
85
|
+
* `--model` is forwarded only when the turn pins a non-blank model.
|
|
86
|
+
*/
|
|
87
|
+
export function buildCodexChatArgs(opts = {}) {
|
|
88
|
+
const args = ["exec", "--json", "--dangerously-bypass-approvals-and-sandbox"];
|
|
89
|
+
for (const tool of NATIVE_TOOLS_DISABLED_CODEX) {
|
|
90
|
+
args.push("-c", `tools.${tool}=false`);
|
|
91
|
+
}
|
|
92
|
+
args.push("-c", CODEX_MCP_ONLY_OVERRIDE);
|
|
93
|
+
const trimmed = (opts.modelId ?? "").trim();
|
|
94
|
+
if (trimmed)
|
|
95
|
+
args.push("--model", trimmed);
|
|
96
|
+
return args;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Augment the base environment for a codex chat turn: resolve the first-attempt
|
|
100
|
+
* auth channel (subscription vs api-key) via the shared `withOpenAiAuth` (so chat
|
|
101
|
+
* authenticates identically to the batch lane) and, when present, surface the
|
|
102
|
+
* per-turn delegation token so the acc-mcp bus acts with the narrowly-scoped
|
|
103
|
+
* companion delegation rather than the runner token. Never mutates `base`.
|
|
104
|
+
*/
|
|
105
|
+
export function codexChatEnv(opts) {
|
|
106
|
+
const base = opts.baseEnv ?? process.env;
|
|
107
|
+
const next = { ...withOpenAiAuth(resolveCodexSpawnMode(base), base) };
|
|
108
|
+
const token = (opts.delegationToken ?? "").trim();
|
|
109
|
+
if (token)
|
|
110
|
+
next[ACC_MCP_DELEGATION_TOKEN_ENV] = token;
|
|
111
|
+
return next;
|
|
112
|
+
}
|
|
113
|
+
function spawnCodexChat(opts) {
|
|
114
|
+
return execa(BINARY, buildCodexChatArgs({ modelId: opts.modelId }), {
|
|
115
|
+
...(opts.cwd !== undefined ? { cwd: opts.cwd } : {}),
|
|
116
|
+
...(opts.signal ? { signal: opts.signal } : {}),
|
|
117
|
+
stdin: "pipe",
|
|
118
|
+
stdout: "pipe",
|
|
119
|
+
stderr: "pipe",
|
|
120
|
+
reject: false,
|
|
121
|
+
env: codexChatEnv(opts),
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
function asRecord(v) {
|
|
125
|
+
return typeof v === "object" && v !== null ? v : null;
|
|
126
|
+
}
|
|
127
|
+
/** First non-empty string among the given candidate text keys. */
|
|
128
|
+
function pickText(obj) {
|
|
129
|
+
for (const k of ["text", "message", "content", "output_text", "delta"]) {
|
|
130
|
+
const v = obj[k];
|
|
131
|
+
if (typeof v === "string" && v.length > 0)
|
|
132
|
+
return v;
|
|
133
|
+
}
|
|
134
|
+
return null;
|
|
135
|
+
}
|
|
136
|
+
/** Concatenated text from a claude-style assistant message's content blocks. */
|
|
137
|
+
function extractAssistantText(message) {
|
|
138
|
+
const m = asRecord(message);
|
|
139
|
+
if (!m)
|
|
140
|
+
return "";
|
|
141
|
+
const content = m.content;
|
|
142
|
+
if (typeof content === "string")
|
|
143
|
+
return content;
|
|
144
|
+
if (!Array.isArray(content))
|
|
145
|
+
return "";
|
|
146
|
+
let out = "";
|
|
147
|
+
for (const block of content) {
|
|
148
|
+
const b = asRecord(block);
|
|
149
|
+
if (b && b.type === "text" && typeof b.text === "string")
|
|
150
|
+
out += b.text;
|
|
151
|
+
}
|
|
152
|
+
return out;
|
|
153
|
+
}
|
|
154
|
+
// Codex-native event `type`s (top-level or nested under item/msg) that carry an
|
|
155
|
+
// assistant message delta vs that terminate the turn. Kept permissive so a
|
|
156
|
+
// point-release rename degrades gracefully (the shared driver always emits a
|
|
157
|
+
// terminal frame even if none of these match).
|
|
158
|
+
const CODEX_MESSAGE_TYPES = new Set(["agent_message", "assistant_message", "message", "assistant"]);
|
|
159
|
+
const CODEX_DONE_TYPES = new Set([
|
|
160
|
+
"result",
|
|
161
|
+
"task_complete",
|
|
162
|
+
"turn.completed",
|
|
163
|
+
"turn_complete",
|
|
164
|
+
"response.completed",
|
|
165
|
+
]);
|
|
166
|
+
/**
|
|
167
|
+
* TOLERANT parse of one line of a codex chat stream into a stream event. Reads
|
|
168
|
+
* TWO shapes so one conformance suite drives both adapters:
|
|
169
|
+
* - claude-style stream-json (`type:"assistant"` blocks / `type:"result"`) —
|
|
170
|
+
* the shape the engine-agnostic conformance suite replays;
|
|
171
|
+
* - codex-native `exec --json` events (`item.completed` → `agent_message`,
|
|
172
|
+
* `turn.completed`, older `{msg:{…}}` / `{response:{…}}` envelopes).
|
|
173
|
+
* Returns `{text,done:false}` for a delta, `{text,done:true}` for the terminal
|
|
174
|
+
* event, or null for a non-JSON / keep-alive / uninteresting line.
|
|
175
|
+
*/
|
|
176
|
+
export function parseCodexChatStreamLine(line) {
|
|
177
|
+
const s = line.trim();
|
|
178
|
+
if (!s.startsWith("{"))
|
|
179
|
+
return null;
|
|
180
|
+
let parsed;
|
|
181
|
+
try {
|
|
182
|
+
parsed = JSON.parse(s);
|
|
183
|
+
}
|
|
184
|
+
catch {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
const rec = asRecord(parsed);
|
|
188
|
+
if (!rec)
|
|
189
|
+
return null;
|
|
190
|
+
// claude-style stream-json (also what the conformance suite emits).
|
|
191
|
+
if (rec.type === "assistant") {
|
|
192
|
+
const text = extractAssistantText(rec.message);
|
|
193
|
+
return text ? { text, done: false } : null;
|
|
194
|
+
}
|
|
195
|
+
if (rec.type === "result") {
|
|
196
|
+
return { text: typeof rec.result === "string" ? rec.result : "", done: true };
|
|
197
|
+
}
|
|
198
|
+
// codex-native event stream.
|
|
199
|
+
const type = typeof rec.type === "string" ? rec.type : "";
|
|
200
|
+
const nested = asRecord(rec.item) ?? asRecord(rec.msg) ?? asRecord(rec.response);
|
|
201
|
+
const nestedType = nested && typeof nested.type === "string" ? nested.type : "";
|
|
202
|
+
const isMessage = CODEX_MESSAGE_TYPES.has(type) || CODEX_MESSAGE_TYPES.has(nestedType);
|
|
203
|
+
if (isMessage) {
|
|
204
|
+
const text = (nested ? pickText(nested) : null) ?? pickText(rec);
|
|
205
|
+
if (text)
|
|
206
|
+
return { text, done: false };
|
|
207
|
+
}
|
|
208
|
+
if (CODEX_DONE_TYPES.has(type) || CODEX_DONE_TYPES.has(nestedType)) {
|
|
209
|
+
const text = pickText(rec) ?? (nested ? pickText(nested) : null) ?? "";
|
|
210
|
+
return { text, done: true };
|
|
211
|
+
}
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Default repo-write probe: `gh auth status` exit 0 (same contract as the claude
|
|
216
|
+
* adapter). A companion that can push / open a PR authorises the `full` tier;
|
|
217
|
+
* one that only holds a model credential is `draft-only`. Never throws.
|
|
218
|
+
*/
|
|
219
|
+
async function defaultRepoWriteProbe() {
|
|
220
|
+
try {
|
|
221
|
+
const res = await execa("gh", ["auth", "status"], { reject: false, timeout: 5_000, env: process.env });
|
|
222
|
+
return res.exitCode === 0;
|
|
223
|
+
}
|
|
224
|
+
catch {
|
|
225
|
+
return false;
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
async function credentialProbeImpl(deps) {
|
|
229
|
+
const channel = codexEngine.authMode; // "api-key-or-subscription"
|
|
230
|
+
const mode = deps.resolveSpawnMode(process.env);
|
|
231
|
+
const hasModelCreds = mode === "api-key" ? deps.hasApiKey(process.env) : await deps.hasSubscriptionSession();
|
|
232
|
+
if (!hasModelCreds) {
|
|
233
|
+
return {
|
|
234
|
+
ok: false,
|
|
235
|
+
channel,
|
|
236
|
+
tier: "unavailable",
|
|
237
|
+
detail: "no OpenAI credential resolved (set OPENAI_API_KEY for the api-key channel or run `codex login` for a ChatGPT subscription)",
|
|
238
|
+
};
|
|
239
|
+
}
|
|
240
|
+
const repoWrite = await deps.repoWriteProbe();
|
|
241
|
+
const tier = repoWrite ? "full" : "draft-only";
|
|
242
|
+
return {
|
|
243
|
+
ok: true,
|
|
244
|
+
channel,
|
|
245
|
+
tier,
|
|
246
|
+
detail: `${describeCodexAuthMode(mode)}; repo-write ${repoWrite ? "granted (full tier)" : "absent (draft-only tier)"}`,
|
|
247
|
+
};
|
|
248
|
+
}
|
|
249
|
+
async function classifyCapacityImpl(deps) {
|
|
250
|
+
const { load1, cores } = deps.loadSampler();
|
|
251
|
+
return classifyCapacityFromLoad(load1, cores);
|
|
252
|
+
}
|
|
253
|
+
/** Static capability declaration for the codex chat adapter. */
|
|
254
|
+
export const CODEX_CHAT_CAPABILITIES = {
|
|
255
|
+
headlessStreaming: true,
|
|
256
|
+
accMcpToolBus: true,
|
|
257
|
+
chatLane: true,
|
|
258
|
+
taskLane: true,
|
|
259
|
+
reviewLane: true,
|
|
260
|
+
tier: "full",
|
|
261
|
+
};
|
|
262
|
+
const DEFAULT_DEPS = {
|
|
263
|
+
spawnChat: spawnCodexChat,
|
|
264
|
+
resolveSpawnMode: resolveCodexSpawnMode,
|
|
265
|
+
hasApiKey: (env) => openaiApiKey(env).length > 0,
|
|
266
|
+
hasSubscriptionSession: async () => true,
|
|
267
|
+
repoWriteProbe: defaultRepoWriteProbe,
|
|
268
|
+
loadSampler: () => ({ load1: os.loadavg()[0] ?? 0, cores: os.cpus().length }),
|
|
269
|
+
};
|
|
270
|
+
/**
|
|
271
|
+
* Build a chat-conformant codex engine. Composes the FROZEN batch `codexEngine`
|
|
272
|
+
* (id/binary/authMode/buildArgs/env/spawn/parseResult/classifyFailure/
|
|
273
|
+
* healthProbe are inherited verbatim — the batch lanes are untouched) and adds
|
|
274
|
+
* the chat-lane conformance surface. All side effects are injectable so the
|
|
275
|
+
* conformance suite runs deterministically without a real `codex` binary.
|
|
276
|
+
*/
|
|
277
|
+
export function createCodexChatEngine(deps = {}) {
|
|
278
|
+
const d = { ...DEFAULT_DEPS, ...deps };
|
|
279
|
+
return {
|
|
280
|
+
...codexEngine,
|
|
281
|
+
capabilities: CODEX_CHAT_CAPABILITIES,
|
|
282
|
+
streamTurn: (opts) => streamChatTurn(d.spawnChat(opts), opts.prompt, parseCodexChatStreamLine),
|
|
283
|
+
accMcpToolBusOnly,
|
|
284
|
+
credentialProbe: () => credentialProbeImpl(d),
|
|
285
|
+
classifyCapacity: () => classifyCapacityImpl(d),
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
/** The wired default chat-conformant codex adapter. */
|
|
289
|
+
export const codexChatEngine = createCodexChatEngine();
|
|
290
|
+
//# sourceMappingURL=codex-chat.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"codex-chat.js","sourceRoot":"","sources":["../../src/engines/codex-chat.ts"],"names":[],"mappings":"AAAA;;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,qBAAqB,EAAE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/engines/registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../src/engines/registry.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,WAAW,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAS7F,iEAAiE;AACjE,eAAO,MAAM,iBAAiB,QAAsB,CAAC;AAErD;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,WAAW,CAOzD;AAED,wBAAgB,SAAS,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAE7C;AAED,wBAAgB,SAAS,IAAI,MAAM,EAAE,CAEpC;AAsBD,uCAAuC;AACvC,eAAO,MAAM,sBAAsB,QAA0B,CAAC;AAE9D;;;GAGG;AACH,wBAAgB,aAAa,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,qBAAqB,CASvE;AAED,wBAAgB,aAAa,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAEjD;AAED,wBAAgB,aAAa,IAAI,MAAM,EAAE,CAExC;AAED;;;GAGG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,IAAI,qBAAqB,CAUvF;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,sBAAsB,GAAG,IAAI,CAIpF"}
|
package/dist/engines/registry.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { claudeCodeEngine } from "./claude-code.js";
|
|
2
2
|
import { claudeCodeChatEngine } from "./claude-code-chat.js";
|
|
3
|
+
import { codexChatEngine } from "./codex-chat.js";
|
|
3
4
|
const ENGINES = {
|
|
4
5
|
[claudeCodeEngine.id]: claudeCodeEngine,
|
|
5
6
|
};
|
|
@@ -31,11 +32,16 @@ export function engineIds() {
|
|
|
31
32
|
* acc-mcp fence + credential-tier probe + capacity classifier + capability
|
|
32
33
|
* matrix). Registered separately from the batch `ENGINES` map so the batch
|
|
33
34
|
* task/review dispatch stays byte-identical — a chat-capable build is opt-in per
|
|
34
|
-
* engine, exactly as the interface header describes.
|
|
35
|
-
*
|
|
35
|
+
* engine, exactly as the interface header describes.
|
|
36
|
+
*
|
|
37
|
+
* CC-4A (CODEX-ADAPTER): the codex chat adapter is the second registered
|
|
38
|
+
* conformant engine. Registration is the ONLY orchestration touch-point — the
|
|
39
|
+
* scheduler resolves it through `getChatEngine`/`engineCapabilities` with zero
|
|
40
|
+
* dispatch-layer changes (the §6 provider-independence proof, part 1).
|
|
36
41
|
* ================================================================== */
|
|
37
42
|
const CHAT_ENGINES = {
|
|
38
43
|
[claudeCodeChatEngine.id]: claudeCodeChatEngine,
|
|
44
|
+
[codexChatEngine.id]: codexChatEngine,
|
|
39
45
|
};
|
|
40
46
|
/** The default chat-lane engine id. */
|
|
41
47
|
export const DEFAULT_CHAT_ENGINE_ID = claudeCodeChatEngine.id;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/engines/registry.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"registry.js","sourceRoot":"","sources":["../../src/engines/registry.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC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