@excitedjs/agent-runtime-codex 0.2.0-alpha.g0ddd418597ca
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/LICENSE +21 -0
- package/README.md +44 -0
- package/dist/approval.d.ts +30 -0
- package/dist/approval.d.ts.map +1 -0
- package/dist/approval.js +42 -0
- package/dist/approval.js.map +1 -0
- package/dist/args.d.ts +55 -0
- package/dist/args.d.ts.map +1 -0
- package/dist/args.js +113 -0
- package/dist/args.js.map +1 -0
- package/dist/bin.d.ts +14 -0
- package/dist/bin.d.ts.map +1 -0
- package/dist/bin.js +18 -0
- package/dist/bin.js.map +1 -0
- package/dist/codex-home.d.ts +42 -0
- package/dist/codex-home.d.ts.map +1 -0
- package/dist/codex-home.js +112 -0
- package/dist/codex-home.js.map +1 -0
- package/dist/config.d.ts +76 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/config.js +106 -0
- package/dist/config.js.map +1 -0
- package/dist/diagnostic.d.ts +14 -0
- package/dist/diagnostic.d.ts.map +1 -0
- package/dist/diagnostic.js +58 -0
- package/dist/diagnostic.js.map +1 -0
- package/dist/events.d.ts +88 -0
- package/dist/events.d.ts.map +1 -0
- package/dist/events.js +225 -0
- package/dist/events.js.map +1 -0
- package/dist/handshake.d.ts +44 -0
- package/dist/handshake.d.ts.map +1 -0
- package/dist/handshake.js +85 -0
- package/dist/handshake.js.map +1 -0
- package/dist/index.d.ts +22 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/internal/completion-body.d.ts +38 -0
- package/dist/internal/completion-body.d.ts.map +1 -0
- package/dist/internal/completion-body.js +62 -0
- package/dist/internal/completion-body.js.map +1 -0
- package/dist/internal/config-validate.d.ts +23 -0
- package/dist/internal/config-validate.d.ts.map +1 -0
- package/dist/internal/config-validate.js +122 -0
- package/dist/internal/config-validate.js.map +1 -0
- package/dist/internal/os.d.ts +30 -0
- package/dist/internal/os.d.ts.map +1 -0
- package/dist/internal/os.js +81 -0
- package/dist/internal/os.js.map +1 -0
- package/dist/internal/socket.d.ts +23 -0
- package/dist/internal/socket.d.ts.map +1 -0
- package/dist/internal/socket.js +74 -0
- package/dist/internal/socket.js.map +1 -0
- package/dist/internal/turn-render.d.ts +22 -0
- package/dist/internal/turn-render.d.ts.map +1 -0
- package/dist/internal/turn-render.js +40 -0
- package/dist/internal/turn-render.js.map +1 -0
- package/dist/mcp-config.d.ts +9 -0
- package/dist/mcp-config.d.ts.map +1 -0
- package/dist/mcp-config.js +21 -0
- package/dist/mcp-config.js.map +1 -0
- package/dist/paths.d.ts +7 -0
- package/dist/paths.d.ts.map +1 -0
- package/dist/paths.js +26 -0
- package/dist/paths.js.map +1 -0
- package/dist/provider-ref.d.ts +8 -0
- package/dist/provider-ref.d.ts.map +1 -0
- package/dist/provider-ref.js +8 -0
- package/dist/provider-ref.js.map +1 -0
- package/dist/provider.d.ts +71 -0
- package/dist/provider.d.ts.map +1 -0
- package/dist/provider.js +137 -0
- package/dist/provider.js.map +1 -0
- package/dist/rpc.d.ts +65 -0
- package/dist/rpc.d.ts.map +1 -0
- package/dist/rpc.js +200 -0
- package/dist/rpc.js.map +1 -0
- package/dist/runtime-support.d.ts +27 -0
- package/dist/runtime-support.d.ts.map +1 -0
- package/dist/runtime-support.js +57 -0
- package/dist/runtime-support.js.map +1 -0
- package/dist/runtime.d.ts +246 -0
- package/dist/runtime.d.ts.map +1 -0
- package/dist/runtime.js +648 -0
- package/dist/runtime.js.map +1 -0
- package/dist/supervisor.d.ts +55 -0
- package/dist/supervisor.d.ts.map +1 -0
- package/dist/supervisor.js +183 -0
- package/dist/supervisor.js.map +1 -0
- package/dist/turn-manager.d.ts +92 -0
- package/dist/turn-manager.d.ts.map +1 -0
- package/dist/turn-manager.js +271 -0
- package/dist/turn-manager.js.map +1 -0
- package/dist/types.d.ts +143 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +10 -0
- package/dist/types.js.map +1 -0
- package/dist/version.d.ts +16 -0
- package/dist/version.d.ts.map +1 -0
- package/dist/version.js +33 -0
- package/dist/version.js.map +1 -0
- package/package.json +56 -0
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { randomBytes, randomUUID } from 'node:crypto';
|
|
2
|
+
import { tmpdir } from 'node:os';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { assertUnixSocketPathBudget, unixSocketPathFitsBudget, } from '@excitedjs/dreamux-utils';
|
|
5
|
+
/**
|
|
6
|
+
* Volatile rendezvous-socket allocation for the Codex app-server (issue #182,
|
|
7
|
+
* relocated into this package by the issue #209 cleanup).
|
|
8
|
+
*
|
|
9
|
+
* A Codex socket is a pure per-start rendezvous endpoint: dreamux starts
|
|
10
|
+
* `codex app-server --listen unix://<path>` and connects with `ws+unix://<path>`
|
|
11
|
+
* immediately. Nothing resumes from a socket path, so every allocation is a
|
|
12
|
+
* fresh short random name and the path is never persisted.
|
|
13
|
+
*
|
|
14
|
+
* Dreamux core no longer hands this package a socket-allocator FUNCTION. Instead
|
|
15
|
+
* the neutral create/diagnostic context exposes the host's preference-ordered
|
|
16
|
+
* candidate directories (`AgentRuntimePathContext.runtimeSocketDirs()`), and this
|
|
17
|
+
* package owns the allocation policy: pick the first candidate whose full path
|
|
18
|
+
* fits the Unix `sun_path` budget (via `@excitedjs/dreamux-utils`), else fail
|
|
19
|
+
* loud. When the host supplies no candidate directories (the bare generic-loader
|
|
20
|
+
* / standalone path) the package falls back to its own short root.
|
|
21
|
+
*/
|
|
22
|
+
function socketName() {
|
|
23
|
+
return `${randomBytes(6).toString('base64url')}.sock`;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Standalone default for the volatile socket path, used when no host candidate
|
|
27
|
+
* directories are supplied (the bare generic-loader path or external standalone
|
|
28
|
+
* use). This is the PACKAGE's own fallback root — `$XDG_RUNTIME_DIR` when set,
|
|
29
|
+
* else the OS temp dir — deliberately NOT the Dreamux host socket contract. The
|
|
30
|
+
* path is random per call and never persisted.
|
|
31
|
+
*/
|
|
32
|
+
export function defaultVolatileSocketPath(id) {
|
|
33
|
+
const root = globalThis.process.env['XDG_RUNTIME_DIR'] ?? tmpdir();
|
|
34
|
+
return join(root, `arc-${sanitize(id)}-${randomUUID().slice(0, 8)}.sock`);
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Allocate a fresh Codex app-server socket path inside the first host candidate
|
|
38
|
+
* directory whose full path fits the socket budget. Fails loud (naming `id`)
|
|
39
|
+
* when even the last candidate is over budget. With no candidate directories it
|
|
40
|
+
* uses {@link defaultVolatileSocketPath}.
|
|
41
|
+
*/
|
|
42
|
+
export function allocateCodexSocketPath(socketDirs, id) {
|
|
43
|
+
if (socketDirs.length === 0)
|
|
44
|
+
return defaultVolatileSocketPath(id);
|
|
45
|
+
const name = socketName();
|
|
46
|
+
for (const dir of socketDirs) {
|
|
47
|
+
const path = join(dir, name);
|
|
48
|
+
if (unixSocketPathFitsBudget(path))
|
|
49
|
+
return path;
|
|
50
|
+
}
|
|
51
|
+
const fallback = socketDirs[socketDirs.length - 1];
|
|
52
|
+
return assertUnixSocketPathBudget(join(fallback, name), `dispatcher '${id}' Codex socket path`);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* A representative, NON-throwing socket sample for the doctor: the first
|
|
56
|
+
* candidate whose path fits, else the last candidate (which is then over budget,
|
|
57
|
+
* so the home doctor can REPORT it as an error rather than throwing here). With
|
|
58
|
+
* no candidate directories it uses {@link defaultVolatileSocketPath}.
|
|
59
|
+
*/
|
|
60
|
+
export function representativeCodexSocketPath(socketDirs, id) {
|
|
61
|
+
if (socketDirs.length === 0)
|
|
62
|
+
return defaultVolatileSocketPath(id);
|
|
63
|
+
const name = socketName();
|
|
64
|
+
for (const dir of socketDirs) {
|
|
65
|
+
const path = join(dir, name);
|
|
66
|
+
if (unixSocketPathFitsBudget(path))
|
|
67
|
+
return path;
|
|
68
|
+
}
|
|
69
|
+
return join(socketDirs[socketDirs.length - 1], name);
|
|
70
|
+
}
|
|
71
|
+
function sanitize(id) {
|
|
72
|
+
return id.replace(/[^A-Za-z0-9._-]/g, '_');
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=socket.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"socket.js","sourceRoot":"","sources":["../../src/internal/socket.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,SAAS,CAAC;AACjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EACL,0BAA0B,EAC1B,wBAAwB,GACzB,MAAM,0BAA0B,CAAC;AAElC;;;;;;;;;;;;;;;;GAgBG;AAEH,SAAS,UAAU;IACjB,OAAO,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,OAAO,CAAC;AACxD,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,yBAAyB,CAAC,EAAU;IAClD,MAAM,IAAI,GAAG,UAAU,CAAC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,IAAI,MAAM,EAAE,CAAC;IACnE,OAAO,IAAI,CAAC,IAAI,EAAE,OAAO,QAAQ,CAAC,EAAE,CAAC,IAAI,UAAU,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC;AAC5E,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,uBAAuB,CACrC,UAA6B,EAC7B,EAAU;IAEV,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,yBAAyB,CAAC,EAAE,CAAC,CAAC;IAClE,MAAM,IAAI,GAAG,UAAU,EAAE,CAAC;IAC1B,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC7B,IAAI,wBAAwB,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;IAClD,CAAC;IACD,MAAM,QAAQ,GAAG,UAAU,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAW,CAAC;IAC7D,OAAO,0BAA0B,CAC/B,IAAI,CAAC,QAAQ,EAAE,IAAI,CAAC,EACpB,eAAe,EAAE,qBAAqB,CACvC,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,6BAA6B,CAC3C,UAA6B,EAC7B,EAAU;IAEV,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,yBAAyB,CAAC,EAAE,CAAC,CAAC;IAClE,MAAM,IAAI,GAAG,UAAU,EAAE,CAAC;IAC1B,KAAK,MAAM,GAAG,IAAI,UAAU,EAAE,CAAC;QAC7B,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,CAAC;QAC7B,IAAI,wBAAwB,CAAC,IAAI,CAAC;YAAE,OAAO,IAAI,CAAC;IAClD,CAAC;IACD,OAAO,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAW,EAAE,IAAI,CAAC,CAAC;AACjE,CAAC;AAED,SAAS,QAAQ,CAAC,EAAU;IAC1B,OAAO,EAAE,CAAC,OAAO,CAAC,kBAAkB,EAAE,GAAG,CAAC,CAAC;AAC7C,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inbound-turn render helpers. The data shapes are published by
|
|
3
|
+
* `@excitedjs/dreamux-types`; these executable helpers render a neutral
|
|
4
|
+
* `InboundTurnInput` into Codex delivery text. Mirrors the host's neutral
|
|
5
|
+
* `agent-runtime/turn.ts` runtime helpers, vendored here so this package never
|
|
6
|
+
* imports `@excitedjs/dreamux` core.
|
|
7
|
+
*/
|
|
8
|
+
import type { InboundTurnInput } from '@excitedjs/dreamux-types';
|
|
9
|
+
export declare const DEFAULT_MESSAGE_ID_DEDUPE_WINDOW = 1024;
|
|
10
|
+
/**
|
|
11
|
+
* Wrap a channel turn body in the native `<channel source="…" …>` envelope.
|
|
12
|
+
* Only safe attribute keys (`^[a-zA-Z_][a-zA-Z0-9_]*$`) are rendered and every
|
|
13
|
+
* value is XML-escaped.
|
|
14
|
+
*/
|
|
15
|
+
export declare function renderChannelBlock(source: string, attrs: ReadonlyArray<readonly [string, string]>, body: string): string;
|
|
16
|
+
/**
|
|
17
|
+
* Render an inbound turn to delivery text. A channel-structured input (both
|
|
18
|
+
* `attrs` and `body` present) is wrapped into the `<channel>` block; a plain
|
|
19
|
+
* input (e.g. a system trigger turn) passes its `text` through unchanged.
|
|
20
|
+
*/
|
|
21
|
+
export declare function renderChannelInput(input: InboundTurnInput): string;
|
|
22
|
+
//# sourceMappingURL=turn-render.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"turn-render.d.ts","sourceRoot":"","sources":["../../src/internal/turn-render.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,eAAO,MAAM,gCAAgC,OAAO,CAAC;AAYrD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,MAAM,EACd,KAAK,EAAE,aAAa,CAAC,SAAS,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,EAC/C,IAAI,EAAE,MAAM,GACX,MAAM,CAMR;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,KAAK,EAAE,gBAAgB,GAAG,MAAM,CAKlE"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inbound-turn render helpers. The data shapes are published by
|
|
3
|
+
* `@excitedjs/dreamux-types`; these executable helpers render a neutral
|
|
4
|
+
* `InboundTurnInput` into Codex delivery text. Mirrors the host's neutral
|
|
5
|
+
* `agent-runtime/turn.ts` runtime helpers, vendored here so this package never
|
|
6
|
+
* imports `@excitedjs/dreamux` core.
|
|
7
|
+
*/
|
|
8
|
+
export const DEFAULT_MESSAGE_ID_DEDUPE_WINDOW = 1024;
|
|
9
|
+
const SAFE_CHANNEL_ATTR_KEY = /^[a-zA-Z_][a-zA-Z0-9_]*$/;
|
|
10
|
+
function escapeChannelAttr(value) {
|
|
11
|
+
return value
|
|
12
|
+
.replaceAll('&', '&')
|
|
13
|
+
.replaceAll('<', '<')
|
|
14
|
+
.replaceAll('>', '>')
|
|
15
|
+
.replaceAll('"', '"');
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Wrap a channel turn body in the native `<channel source="…" …>` envelope.
|
|
19
|
+
* Only safe attribute keys (`^[a-zA-Z_][a-zA-Z0-9_]*$`) are rendered and every
|
|
20
|
+
* value is XML-escaped.
|
|
21
|
+
*/
|
|
22
|
+
export function renderChannelBlock(source, attrs, body) {
|
|
23
|
+
const rendered = attrs
|
|
24
|
+
.filter(([key]) => SAFE_CHANNEL_ATTR_KEY.test(key))
|
|
25
|
+
.map(([key, value]) => ` ${key}="${escapeChannelAttr(value)}"`)
|
|
26
|
+
.join('');
|
|
27
|
+
return `<channel source="${escapeChannelAttr(source)}"${rendered}>\n${body}\n</channel>`;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Render an inbound turn to delivery text. A channel-structured input (both
|
|
31
|
+
* `attrs` and `body` present) is wrapped into the `<channel>` block; a plain
|
|
32
|
+
* input (e.g. a system trigger turn) passes its `text` through unchanged.
|
|
33
|
+
*/
|
|
34
|
+
export function renderChannelInput(input) {
|
|
35
|
+
if (input.attrs === undefined || input.body === undefined) {
|
|
36
|
+
return input.text;
|
|
37
|
+
}
|
|
38
|
+
return renderChannelBlock(input.source ?? 'channel', input.attrs, input.body);
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=turn-render.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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|
|
|
1
|
+
import type { AgentRuntimeMcpServer } from '@excitedjs/dreamux-types';
|
|
2
|
+
/**
|
|
3
|
+
* Render neutral MCP server descriptors into Codex `-c mcp_servers.<name>.*`
|
|
4
|
+
* config-override CLI args. Provider-neutral: it knows nothing about which
|
|
5
|
+
* channel or shim produced a descriptor — the Dreamux host decides which MCP
|
|
6
|
+
* servers a runtime gets and passes them through the create context.
|
|
7
|
+
*/
|
|
8
|
+
export declare function codexMcpServerArgs(servers: readonly AgentRuntimeMcpServer[]): string[];
|
|
9
|
+
//# sourceMappingURL=mcp-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-config.d.ts","sourceRoot":"","sources":["../src/mcp-config.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEtE;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,SAAS,qBAAqB,EAAE,GACxC,MAAM,EAAE,CAOV"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Render neutral MCP server descriptors into Codex `-c mcp_servers.<name>.*`
|
|
3
|
+
* config-override CLI args. Provider-neutral: it knows nothing about which
|
|
4
|
+
* channel or shim produced a descriptor — the Dreamux host decides which MCP
|
|
5
|
+
* servers a runtime gets and passes them through the create context.
|
|
6
|
+
*/
|
|
7
|
+
export function codexMcpServerArgs(servers) {
|
|
8
|
+
return servers.flatMap((server) => [
|
|
9
|
+
'-c',
|
|
10
|
+
`mcp_servers.${server.name}.command=${tomlString(server.command)}`,
|
|
11
|
+
'-c',
|
|
12
|
+
`mcp_servers.${server.name}.args=${tomlStringArray(server.args)}`,
|
|
13
|
+
]);
|
|
14
|
+
}
|
|
15
|
+
function tomlStringArray(values) {
|
|
16
|
+
return `[${values.map(tomlString).join(', ')}]`;
|
|
17
|
+
}
|
|
18
|
+
function tomlString(value) {
|
|
19
|
+
return JSON.stringify(value);
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=mcp-config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcp-config.js","sourceRoot":"","sources":["../src/mcp-config.ts"],"names":[],"mappings":"AAEA;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAChC,OAAyC;IAEzC,OAAO,OAAO,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;QACjC,IAAI;QACJ,eAAe,MAAM,CAAC,IAAI,YAAY,UAAU,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;QAClE,IAAI;QACJ,eAAe,MAAM,CAAC,IAAI,SAAS,eAAe,CAAC,MAAM,CAAC,IAAI,CAAC,EAAE;KAClE,CAAC,CAAC;AACL,CAAC;AAED,SAAS,eAAe,CAAC,MAAgB;IACvC,OAAO,IAAI,MAAM,CAAC,GAAG,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC;AAClD,CAAC;AAED,SAAS,UAAU,CAAC,KAAa;IAC/B,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC;AAC/B,CAAC"}
|
package/dist/paths.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** The operator's global Codex home (`~/.codex`). */
|
|
2
|
+
export declare function operatorCodexHome(): string;
|
|
3
|
+
/** A runtime's Codex home — the operator's global home (no dispatcher-private home). */
|
|
4
|
+
export declare function dispatcherCodexHome(id: string): string;
|
|
5
|
+
/** A runtime's Codex `config.toml` path, under its (operator-global) Codex home. */
|
|
6
|
+
export declare function dispatcherCodexConfigPath(id: string): string;
|
|
7
|
+
//# sourceMappingURL=paths.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAaA,qDAAqD;AACrD,wBAAgB,iBAAiB,IAAI,MAAM,CAE1C;AAED,wFAAwF;AACxF,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAGtD;AAED,oFAAoF;AACpF,wBAAgB,yBAAyB,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,CAE5D"}
|
package/dist/paths.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codex home/config paths (issue #209 cleanup — relocated from Dreamux core).
|
|
3
|
+
*
|
|
4
|
+
* These resolve Codex's OWN global home (`~/.codex`) and config file. They are
|
|
5
|
+
* codex-engine-specific and homedir-only: they carry no `~/.dreamux` knowledge,
|
|
6
|
+
* so they belong to this package, not to Dreamux core. Dreamux does NOT create a
|
|
7
|
+
* dispatcher-private `CODEX_HOME` for the MVP — every runtime follows the
|
|
8
|
+
* operator's global Codex home — so the per-runtime accessors accept an id only
|
|
9
|
+
* for call-site symmetry and ignore it.
|
|
10
|
+
*/
|
|
11
|
+
import { homedir } from 'node:os';
|
|
12
|
+
import { join } from 'node:path';
|
|
13
|
+
/** The operator's global Codex home (`~/.codex`). */
|
|
14
|
+
export function operatorCodexHome() {
|
|
15
|
+
return join(homedir(), '.codex');
|
|
16
|
+
}
|
|
17
|
+
/** A runtime's Codex home — the operator's global home (no dispatcher-private home). */
|
|
18
|
+
export function dispatcherCodexHome(id) {
|
|
19
|
+
void id;
|
|
20
|
+
return operatorCodexHome();
|
|
21
|
+
}
|
|
22
|
+
/** A runtime's Codex `config.toml` path, under its (operator-global) Codex home. */
|
|
23
|
+
export function dispatcherCodexConfigPath(id) {
|
|
24
|
+
return join(dispatcherCodexHome(id), 'config.toml');
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=paths.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,qDAAqD;AACrD,MAAM,UAAU,iBAAiB;IAC/B,OAAO,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,CAAC,CAAC;AACnC,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,mBAAmB,CAAC,EAAU;IAC5C,KAAK,EAAE,CAAC;IACR,OAAO,iBAAiB,EAAE,CAAC;AAC7B,CAAC;AAED,oFAAoF;AACpF,MAAM,UAAU,yBAAyB,CAAC,EAAU;IAClD,OAAO,IAAI,CAAC,mBAAmB,CAAC,EAAE,CAAC,EAAE,aAAa,CAAC,CAAC;AACtD,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The stable built-in provider ref this package ships behind. Dreamux core maps
|
|
3
|
+
* `builtin:codex` to `@excitedjs/agent-runtime-codex`; the ref string is the
|
|
4
|
+
* package's own public identity, so it is owned here rather than imported from
|
|
5
|
+
* core (which this package must never depend on).
|
|
6
|
+
*/
|
|
7
|
+
export declare const BUILTIN_CODEX_PROVIDER_REF = "builtin:codex";
|
|
8
|
+
//# sourceMappingURL=provider-ref.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-ref.d.ts","sourceRoot":"","sources":["../src/provider-ref.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,eAAO,MAAM,0BAA0B,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The stable built-in provider ref this package ships behind. Dreamux core maps
|
|
3
|
+
* `builtin:codex` to `@excitedjs/agent-runtime-codex`; the ref string is the
|
|
4
|
+
* package's own public identity, so it is owned here rather than imported from
|
|
5
|
+
* core (which this package must never depend on).
|
|
6
|
+
*/
|
|
7
|
+
export const BUILTIN_CODEX_PROVIDER_REF = 'builtin:codex';
|
|
8
|
+
//# sourceMappingURL=provider-ref.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider-ref.js","sourceRoot":"","sources":["../src/provider-ref.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAAG,eAAe,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { CodexWsClient } from './rpc.js';
|
|
2
|
+
import { CodexProcess, type CodexProcessOptions } from './supervisor.js';
|
|
3
|
+
import { dispatcherCodexConfig, type DispatcherCodexConfig } from './config.js';
|
|
4
|
+
import type { AgentRuntimeCapabilities, AgentRuntimeMcpServer, AgentRuntimeProvider, AgentRuntimeProviderDescriptor, AgentRuntimeProviderFactory, ProviderDescriptor, ProviderFactoryContext } from '@excitedjs/dreamux-types';
|
|
5
|
+
/**
|
|
6
|
+
* Construction options for the built-in Codex provider. The runtime's host
|
|
7
|
+
* contracts now arrive on the NEUTRAL create context, not as factory hooks:
|
|
8
|
+
* volatile socket placement comes from `context.paths.runtimeSocketDirs()` (this
|
|
9
|
+
* package owns the allocation policy), and env injection comes from
|
|
10
|
+
* `context.injectEnv`. Role-gated bundled skills arrive as neutral
|
|
11
|
+
* `skillSources`. What remains here is the `descriptor` and the test/host seams
|
|
12
|
+
* (process/WS factories, the optional Codex home pre-start check, restart
|
|
13
|
+
* backoff) that let core and tests wire behavior without changing the provider.
|
|
14
|
+
*/
|
|
15
|
+
export interface CodexAgentRuntimeProviderOptions {
|
|
16
|
+
/**
|
|
17
|
+
* The registry descriptor for `builtin:codex`. Defaults to a minimal one.
|
|
18
|
+
* Accepted wide (`ProviderDescriptor`) so a host that resolved it from its
|
|
19
|
+
* registry need not pre-narrow the kind; the factory validates it is an
|
|
20
|
+
* `agentRuntime` descriptor.
|
|
21
|
+
*/
|
|
22
|
+
descriptor?: ProviderDescriptor;
|
|
23
|
+
/** Optional Codex home/auth pre-start check, invoked with the runtime id and cwd. */
|
|
24
|
+
codexHomeDoctor?: (info: {
|
|
25
|
+
runtimeId: string;
|
|
26
|
+
cwd: string;
|
|
27
|
+
}) => void | Promise<void>;
|
|
28
|
+
codexProcessFactory?: (opts: CodexProcessOptions) => CodexProcess;
|
|
29
|
+
codexClientFactory?: (socketPath: string) => CodexWsClient;
|
|
30
|
+
restartBackoffBaseMs?: number;
|
|
31
|
+
restartBackoffMaxMs?: number;
|
|
32
|
+
}
|
|
33
|
+
export declare const CODEX_AGENT_RUNTIME_CAPABILITIES: AgentRuntimeCapabilities;
|
|
34
|
+
/**
|
|
35
|
+
* Create the built-in Codex `AgentRuntimeProvider`. It implements the neutral
|
|
36
|
+
* `@excitedjs/dreamux-types` contract: `readConfig` parses Codex runtime config,
|
|
37
|
+
* `getCapabilities` reports Codex's resume/steer/completion shape, and
|
|
38
|
+
* `createRuntime` builds a {@link CodexRuntime} from the neutral create context
|
|
39
|
+
* plus the host-supplied hooks.
|
|
40
|
+
*/
|
|
41
|
+
export declare function createCodexAgentRuntimeProvider(options?: CodexAgentRuntimeProviderOptions): AgentRuntimeProvider<DispatcherCodexConfig>;
|
|
42
|
+
/** Re-export the typed accessor for a runtime's resolved codex config. */
|
|
43
|
+
export { dispatcherCodexConfig };
|
|
44
|
+
export declare function codexRuntimeArgsForMcpServers(servers: readonly AgentRuntimeMcpServer[]): string[];
|
|
45
|
+
/**
|
|
46
|
+
* The context Dreamux core's generic provider package-loader passes to this
|
|
47
|
+
* package's factory export. A back-compat alias of the public
|
|
48
|
+
* {@link ProviderFactoryContext}, narrowed to the Agent Runtime descriptor kind
|
|
49
|
+
* so the factory assigns `descriptor` without a cast.
|
|
50
|
+
*/
|
|
51
|
+
export type CodexProviderFactoryContext = ProviderFactoryContext<AgentRuntimeProviderDescriptor>;
|
|
52
|
+
/**
|
|
53
|
+
* Default export — the factory Dreamux core's generic provider-loader selects
|
|
54
|
+
* for the `builtin:codex` ref (it imports this package and calls the default
|
|
55
|
+
* export with `{ ref, descriptor }`). It returns a provider that runs on package
|
|
56
|
+
* defaults: a standalone volatile-socket allocator and no host-injected bundled
|
|
57
|
+
* skills.
|
|
58
|
+
*
|
|
59
|
+
* The Dreamux host does NOT use this bare path in production: its launcher still
|
|
60
|
+
* drives the host-shaped create context, so it constructs the provider through
|
|
61
|
+
* its own core-owned adapter (`@excitedjs/dreamux` `builtin/codex/provider.ts`)
|
|
62
|
+
* to map that context onto the neutral one AND inject its host contracts (the
|
|
63
|
+
* shared runtime-socket root, the package-bin `PATH`, and the bundled Dreamux
|
|
64
|
+
* skills). This default export keeps the package a first-class, loadable
|
|
65
|
+
* `AgentRuntimeProvider` for the generic loader and for external embedders;
|
|
66
|
+
* converging core's launcher onto the neutral context so it can drive the loaded
|
|
67
|
+
* provider directly is later-slice work.
|
|
68
|
+
*/
|
|
69
|
+
declare const codexAgentRuntimeProviderFactory: AgentRuntimeProviderFactory<DispatcherCodexConfig>;
|
|
70
|
+
export default codexAgentRuntimeProviderFactory;
|
|
71
|
+
//# sourceMappingURL=provider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,YAAY,EACZ,KAAK,mBAAmB,EACzB,MAAM,iBAAiB,CAAC;AAKzB,OAAO,EACL,qBAAqB,EAErB,KAAK,qBAAqB,EAC3B,MAAM,aAAa,CAAC;AAMrB,OAAO,KAAK,EACV,wBAAwB,EAGxB,qBAAqB,EACrB,oBAAoB,EACpB,8BAA8B,EAC9B,2BAA2B,EAC3B,kBAAkB,EAClB,sBAAsB,EACvB,MAAM,0BAA0B,CAAC;AAElC;;;;;;;;;GASG;AACH,MAAM,WAAW,gCAAgC;IAC/C;;;;;OAKG;IACH,UAAU,CAAC,EAAE,kBAAkB,CAAC;IAChC,qFAAqF;IACrF,eAAe,CAAC,EAAE,CAAC,IAAI,EAAE;QACvB,SAAS,EAAE,MAAM,CAAC;QAClB,GAAG,EAAE,MAAM,CAAC;KACb,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC3B,mBAAmB,CAAC,EAAE,CAAC,IAAI,EAAE,mBAAmB,KAAK,YAAY,CAAC;IAClE,kBAAkB,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,KAAK,aAAa,CAAC;IAC3D,oBAAoB,CAAC,EAAE,MAAM,CAAC;IAC9B,mBAAmB,CAAC,EAAE,MAAM,CAAC;CAC9B;AAED,eAAO,MAAM,gCAAgC,EAAE,wBAe9C,CAAC;AAqBF;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAC7C,OAAO,GAAE,gCAAqC,GAC7C,oBAAoB,CAAC,qBAAqB,CAAC,CAsE7C;AAED,0EAA0E;AAC1E,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAEjC,wBAAgB,6BAA6B,CAC3C,OAAO,EAAE,SAAS,qBAAqB,EAAE,GACxC,MAAM,EAAE,CAEV;AAED;;;;;GAKG;AACH,MAAM,MAAM,2BAA2B,GACrC,sBAAsB,CAAC,8BAA8B,CAAC,CAAC;AAEzD;;;;;;;;;;;;;;;;GAgBG;AACH,QAAA,MAAM,gCAAgC,EAAE,2BAA2B,CAAC,qBAAqB,CACP,CAAC;AAEnF,eAAe,gCAAgC,CAAC"}
|
package/dist/provider.js
ADDED
|
@@ -0,0 +1,137 @@
|
|
|
1
|
+
import { codexMcpServerArgs } from './mcp-config.js';
|
|
2
|
+
import { CodexRuntime, } from './runtime.js';
|
|
3
|
+
import { dispatcherCodexConfig, readDispatcherCodexConfig, } from './config.js';
|
|
4
|
+
import { codexArgsFromConfig, codexArgsToCli } from './args.js';
|
|
5
|
+
import { BUILTIN_CODEX_PROVIDER_REF } from './provider-ref.js';
|
|
6
|
+
import { resolveCodexBinPath } from './bin.js';
|
|
7
|
+
import { codexAgentRuntimeDiagnostic } from './diagnostic.js';
|
|
8
|
+
import { allocateCodexSocketPath } from './internal/socket.js';
|
|
9
|
+
export const CODEX_AGENT_RUNTIME_CAPABILITIES = {
|
|
10
|
+
resume: { supported: true, checkpoint: 'codexThread' },
|
|
11
|
+
steer: { supported: true },
|
|
12
|
+
events: { kind: 'push' },
|
|
13
|
+
last: { supported: true },
|
|
14
|
+
context: { supported: false },
|
|
15
|
+
systemPrompt: { mode: 'replace' },
|
|
16
|
+
teammateCompletion: [
|
|
17
|
+
{
|
|
18
|
+
kind: 'codexInboxTurn',
|
|
19
|
+
description: 'inject the completion into thread history (thread/inject_items), then ' +
|
|
20
|
+
'trigger a dispatcher turn',
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
};
|
|
24
|
+
const DEFAULT_CODEX_DESCRIPTOR = {
|
|
25
|
+
id: 'codex',
|
|
26
|
+
kind: 'agentRuntime',
|
|
27
|
+
ref: { source: 'builtin', id: 'codex', raw: BUILTIN_CODEX_PROVIDER_REF },
|
|
28
|
+
};
|
|
29
|
+
/** Validate + narrow a seed descriptor to the Agent Runtime kind. */
|
|
30
|
+
function asAgentRuntimeDescriptor(descriptor) {
|
|
31
|
+
if (descriptor.kind !== 'agentRuntime') {
|
|
32
|
+
throw new Error(`@excitedjs/agent-runtime-codex: descriptor.kind must be 'agentRuntime' ` +
|
|
33
|
+
`(got ${JSON.stringify(descriptor.kind)})`);
|
|
34
|
+
}
|
|
35
|
+
return { ...descriptor, kind: descriptor.kind };
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Create the built-in Codex `AgentRuntimeProvider`. It implements the neutral
|
|
39
|
+
* `@excitedjs/dreamux-types` contract: `readConfig` parses Codex runtime config,
|
|
40
|
+
* `getCapabilities` reports Codex's resume/steer/completion shape, and
|
|
41
|
+
* `createRuntime` builds a {@link CodexRuntime} from the neutral create context
|
|
42
|
+
* plus the host-supplied hooks.
|
|
43
|
+
*/
|
|
44
|
+
export function createCodexAgentRuntimeProvider(options = {}) {
|
|
45
|
+
return {
|
|
46
|
+
ref: BUILTIN_CODEX_PROVIDER_REF,
|
|
47
|
+
descriptor: options.descriptor === undefined
|
|
48
|
+
? DEFAULT_CODEX_DESCRIPTOR
|
|
49
|
+
: asAgentRuntimeDescriptor(options.descriptor),
|
|
50
|
+
getCapabilities: () => CODEX_AGENT_RUNTIME_CAPABILITIES,
|
|
51
|
+
diagnostic: codexAgentRuntimeDiagnostic,
|
|
52
|
+
readConfig(rawConfig, context) {
|
|
53
|
+
return readDispatcherCodexConfig(rawConfig, context.file, context.prefix);
|
|
54
|
+
},
|
|
55
|
+
createRuntime(context) {
|
|
56
|
+
if (context.state === undefined) {
|
|
57
|
+
throw new Error('codex runtime requires a state sink in the create context');
|
|
58
|
+
}
|
|
59
|
+
if (context.paths === undefined) {
|
|
60
|
+
throw new Error('codex runtime requires a path context in the create context');
|
|
61
|
+
}
|
|
62
|
+
const codexConfig = context.config;
|
|
63
|
+
const codexArgs = codexArgsFromConfig(codexConfig);
|
|
64
|
+
const runtimeArgs = [
|
|
65
|
+
...codexArgsToCli(codexArgs),
|
|
66
|
+
...codexMcpServerArgs(context.mcpServers),
|
|
67
|
+
];
|
|
68
|
+
const paths = context.paths;
|
|
69
|
+
const deps = {
|
|
70
|
+
cwd: context.cwd,
|
|
71
|
+
state: context.state,
|
|
72
|
+
paths,
|
|
73
|
+
// The package owns socket allocation: pick a fresh name in the first of
|
|
74
|
+
// the host's preference-ordered candidate dirs that fits the budget.
|
|
75
|
+
allocateSocketPath: (id) => allocateCodexSocketPath(paths.runtimeSocketDirs(), id),
|
|
76
|
+
codexBinPath: resolveCodexBinPath(codexConfig.bin),
|
|
77
|
+
resolveExtraArgs: () => runtimeArgs,
|
|
78
|
+
handshakeTimeoutMs: codexConfig.initialize_timeout_ms,
|
|
79
|
+
extraEnv: codexConfig.extra_env,
|
|
80
|
+
...(context.injectEnv !== undefined
|
|
81
|
+
? { injectEnv: context.injectEnv }
|
|
82
|
+
: {}),
|
|
83
|
+
...(context.skillSources !== undefined
|
|
84
|
+
? { skillSources: context.skillSources }
|
|
85
|
+
: {}),
|
|
86
|
+
...(context.systemPromptContent !== undefined
|
|
87
|
+
? { systemPromptContent: context.systemPromptContent }
|
|
88
|
+
: {}),
|
|
89
|
+
...(context.onTurnSettled !== undefined
|
|
90
|
+
? { onTurnSettled: context.onTurnSettled }
|
|
91
|
+
: {}),
|
|
92
|
+
...(context.logger !== undefined ? { logger: context.logger } : {}),
|
|
93
|
+
...(options.codexHomeDoctor !== undefined
|
|
94
|
+
? { codexHomeDoctor: options.codexHomeDoctor }
|
|
95
|
+
: {}),
|
|
96
|
+
...(options.codexProcessFactory !== undefined
|
|
97
|
+
? { codexProcessFactory: options.codexProcessFactory }
|
|
98
|
+
: {}),
|
|
99
|
+
...(options.codexClientFactory !== undefined
|
|
100
|
+
? { codexClientFactory: options.codexClientFactory }
|
|
101
|
+
: {}),
|
|
102
|
+
...(options.restartBackoffBaseMs !== undefined
|
|
103
|
+
? { restartBackoffBaseMs: options.restartBackoffBaseMs }
|
|
104
|
+
: {}),
|
|
105
|
+
...(options.restartBackoffMaxMs !== undefined
|
|
106
|
+
? { restartBackoffMaxMs: options.restartBackoffMaxMs }
|
|
107
|
+
: {}),
|
|
108
|
+
};
|
|
109
|
+
return new CodexRuntime(context.identity, deps);
|
|
110
|
+
},
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
/** Re-export the typed accessor for a runtime's resolved codex config. */
|
|
114
|
+
export { dispatcherCodexConfig };
|
|
115
|
+
export function codexRuntimeArgsForMcpServers(servers) {
|
|
116
|
+
return codexMcpServerArgs(servers);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Default export — the factory Dreamux core's generic provider-loader selects
|
|
120
|
+
* for the `builtin:codex` ref (it imports this package and calls the default
|
|
121
|
+
* export with `{ ref, descriptor }`). It returns a provider that runs on package
|
|
122
|
+
* defaults: a standalone volatile-socket allocator and no host-injected bundled
|
|
123
|
+
* skills.
|
|
124
|
+
*
|
|
125
|
+
* The Dreamux host does NOT use this bare path in production: its launcher still
|
|
126
|
+
* drives the host-shaped create context, so it constructs the provider through
|
|
127
|
+
* its own core-owned adapter (`@excitedjs/dreamux` `builtin/codex/provider.ts`)
|
|
128
|
+
* to map that context onto the neutral one AND inject its host contracts (the
|
|
129
|
+
* shared runtime-socket root, the package-bin `PATH`, and the bundled Dreamux
|
|
130
|
+
* skills). This default export keeps the package a first-class, loadable
|
|
131
|
+
* `AgentRuntimeProvider` for the generic loader and for external embedders;
|
|
132
|
+
* converging core's launcher onto the neutral context so it can drive the loaded
|
|
133
|
+
* provider directly is later-slice work.
|
|
134
|
+
*/
|
|
135
|
+
const codexAgentRuntimeProviderFactory = (context) => createCodexAgentRuntimeProvider({ descriptor: context.descriptor });
|
|
136
|
+
export default codexAgentRuntimeProviderFactory;
|
|
137
|
+
//# sourceMappingURL=provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"provider.js","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAMrD,OAAO,EACL,YAAY,GAEb,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,qBAAqB,EACrB,yBAAyB,GAE1B,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,mBAAmB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAChE,OAAO,EAAE,0BAA0B,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,mBAAmB,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,uBAAuB,EAAE,MAAM,sBAAsB,CAAC;AA0C/D,MAAM,CAAC,MAAM,gCAAgC,GAA6B;IACxE,MAAM,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,UAAU,EAAE,aAAa,EAAE;IACtD,KAAK,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE;IAC1B,MAAM,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE;IACxB,IAAI,EAAE,EAAE,SAAS,EAAE,IA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QAClD,CAAC;KACF,CAAC;AACJ,CAAC;AAED,0EAA0E;AAC1E,OAAO,EAAE,qBAAqB,EAAE,CAAC;AAEjC,MAAM,UAAU,6BAA6B,CAC3C,OAAyC;IAEzC,OAAO,kBAAkB,CAAC,OAAO,CAAC,CAAC;AACrC,CAAC;AAWD;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,gCAAgC,GACpC,CAAC,OAAO,EAAE,EAAE,CAAC,+BAA+B,CAAC,EAAE,UAAU,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC,CAAC;AAEnF,eAAe,gCAAgC,CAAC"}
|
package/dist/rpc.d.ts
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Codex app-server WebSocket JSON-RPC client.
|
|
3
|
+
*
|
|
4
|
+
* Adapted from claudemux's `plugins/claudemux/core/src/engines/codex/rpc.ts`
|
|
5
|
+
* (excitedjs/dreamux#2 §"关键代码复用结论"). Two differences:
|
|
6
|
+
* - uses the public `ws` npm package instead of the vendored `#ws`;
|
|
7
|
+
* - replaces the `codex-protocol` import with the in-tree `./types.ts`.
|
|
8
|
+
*
|
|
9
|
+
* The wire envelope codex emits is *not* strict JSON-RPC 2.0 — the
|
|
10
|
+
* `jsonrpc` version field is omitted. Frame routing is by structural probe:
|
|
11
|
+
* - method + id + params → request
|
|
12
|
+
* - method + params → notification
|
|
13
|
+
* - id + result|error → response
|
|
14
|
+
*/
|
|
15
|
+
import type { ServerNotification, ServerRequest } from './types.js';
|
|
16
|
+
export interface CodexWsClientOptions {
|
|
17
|
+
/** Unix socket path the codex daemon listens on (production). */
|
|
18
|
+
socketPath?: string;
|
|
19
|
+
/** `ws://...` URL — used by tests pointing at an in-process WebSocket.Server. */
|
|
20
|
+
url?: string;
|
|
21
|
+
}
|
|
22
|
+
export type NotificationHandler = (notif: ServerNotification) => void;
|
|
23
|
+
export type ServerRequestHandler = (req: ServerRequest) => Promise<unknown>;
|
|
24
|
+
export type CloseHandler = (reason: Error) => void;
|
|
25
|
+
/**
|
|
26
|
+
* A long-running WebSocket connection to one codex app-server daemon.
|
|
27
|
+
* One instance per Dispatcher; lifetime matches the dispatcher runtime.
|
|
28
|
+
*/
|
|
29
|
+
export declare class CodexWsClient {
|
|
30
|
+
private readonly ws;
|
|
31
|
+
private readonly pending;
|
|
32
|
+
private readonly notifHandlers;
|
|
33
|
+
private readonly closeHandlers;
|
|
34
|
+
private serverReqHandler;
|
|
35
|
+
private nextId;
|
|
36
|
+
private readonly opened;
|
|
37
|
+
private closed;
|
|
38
|
+
private closeReason;
|
|
39
|
+
constructor(opts: CodexWsClientOptions);
|
|
40
|
+
ready(): Promise<void>;
|
|
41
|
+
onNotification(handler: NotificationHandler): void;
|
|
42
|
+
/**
|
|
43
|
+
* Install handler for server→client requests (approval, attestation, etc).
|
|
44
|
+
* The handler's return value becomes the response `result`; a throw becomes
|
|
45
|
+
* the response `error.message`.
|
|
46
|
+
*
|
|
47
|
+
* For dreamux MVP this should fail-fast on any approval request — see
|
|
48
|
+
* issue #2 §"信任模型" (approval-policy=never + fail-fast handler).
|
|
49
|
+
*/
|
|
50
|
+
setServerRequestHandler(handler: ServerRequestHandler): void;
|
|
51
|
+
onClose(handler: CloseHandler): void;
|
|
52
|
+
request<R = unknown>(method: string, params: unknown): Promise<R>;
|
|
53
|
+
/**
|
|
54
|
+
* Send a JSON-RPC notification (no `id`, no response expected). codex 0.134+
|
|
55
|
+
* uses these for the `initialized` handshake confirmation, among others.
|
|
56
|
+
*/
|
|
57
|
+
notify(method: string, params: unknown): void;
|
|
58
|
+
close(): void;
|
|
59
|
+
private onFrame;
|
|
60
|
+
private handleResponse;
|
|
61
|
+
private dispatchNotification;
|
|
62
|
+
private handleServerRequest;
|
|
63
|
+
private tearDown;
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=rpc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rpc.d.ts","sourceRoot":"","sources":["../src/rpc.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