@excitedjs/agent-runtime-codex 0.7.0-beta.265 → 0.7.0-beta.271
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/README.md +20 -12
- package/dist/activity/cursor.d.ts +0 -1
- package/dist/activity/cursor.d.ts.map +1 -1
- package/dist/activity/cursor.js +4 -8
- package/dist/activity/cursor.js.map +1 -1
- package/dist/activity/opened-file.d.ts.map +1 -1
- package/dist/activity/opened-file.js +13 -10
- package/dist/activity/opened-file.js.map +1 -1
- package/dist/activity/path.d.ts +9 -4
- package/dist/activity/path.d.ts.map +1 -1
- package/dist/activity/path.js +56 -50
- package/dist/activity/path.js.map +1 -1
- package/dist/activity/reader.d.ts +1 -4
- package/dist/activity/reader.d.ts.map +1 -1
- package/dist/activity/reader.js +31 -57
- package/dist/activity/reader.js.map +1 -1
- package/dist/args.d.ts +10 -38
- package/dist/args.d.ts.map +1 -1
- package/dist/args.js +11 -74
- package/dist/args.js.map +1 -1
- package/dist/codex-home.d.ts +10 -15
- package/dist/codex-home.d.ts.map +1 -1
- package/dist/codex-home.js +55 -40
- package/dist/codex-home.js.map +1 -1
- package/dist/config.d.ts +3 -32
- package/dist/config.d.ts.map +1 -1
- package/dist/config.js +14 -56
- package/dist/config.js.map +1 -1
- package/dist/diagnostic.d.ts +9 -3
- package/dist/diagnostic.d.ts.map +1 -1
- package/dist/diagnostic.js +14 -10
- package/dist/diagnostic.js.map +1 -1
- package/dist/events.d.ts +18 -47
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +27 -198
- package/dist/events.js.map +1 -1
- package/dist/handshake.d.ts +1 -1
- package/dist/handshake.d.ts.map +1 -1
- package/dist/handshake.js.map +1 -1
- package/dist/index.d.ts +10 -18
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +9 -24
- package/dist/index.js.map +1 -1
- package/dist/output-schema-codec.d.ts +0 -1
- package/dist/output-schema-codec.d.ts.map +1 -1
- package/dist/output-schema-codec.js +7 -23
- package/dist/output-schema-codec.js.map +1 -1
- package/dist/paths.d.ts +11 -6
- package/dist/paths.d.ts.map +1 -1
- package/dist/paths.js +29 -18
- package/dist/paths.js.map +1 -1
- package/dist/plugin.d.ts +14 -0
- package/dist/plugin.d.ts.map +1 -0
- package/dist/plugin.js +11 -0
- package/dist/plugin.js.map +1 -0
- package/dist/provider.d.ts +8 -34
- package/dist/provider.d.ts.map +1 -1
- package/dist/provider.js +16 -57
- package/dist/provider.js.map +1 -1
- package/dist/reasoning-effort.d.ts.map +1 -1
- package/dist/reasoning-effort.js +20 -6
- package/dist/reasoning-effort.js.map +1 -1
- package/dist/rpc.d.ts.map +1 -1
- package/dist/rpc.js.map +1 -1
- package/dist/runtime-deps.d.ts +8 -18
- package/dist/runtime-deps.d.ts.map +1 -1
- package/dist/runtime.d.ts.map +1 -1
- package/dist/runtime.js +86 -48
- package/dist/runtime.js.map +1 -1
- package/dist/skill-roots.d.ts +2 -2
- package/dist/skill-roots.d.ts.map +1 -1
- package/dist/skill-roots.js +3 -5
- package/dist/skill-roots.js.map +1 -1
- package/dist/supervisor.d.ts +2 -2
- package/dist/supervisor.d.ts.map +1 -1
- package/dist/supervisor.js +1 -1
- package/dist/supervisor.js.map +1 -1
- package/dist/system-prompt.d.ts +9 -0
- package/dist/system-prompt.d.ts.map +1 -0
- package/dist/{runtime-support.js → system-prompt.js} +2 -15
- package/dist/system-prompt.js.map +1 -0
- package/dist/tool-display.d.ts.map +1 -1
- package/dist/tool-display.js +70 -19
- package/dist/tool-display.js.map +1 -1
- package/dist/turn-manager.d.ts +9 -9
- package/dist/turn-manager.d.ts.map +1 -1
- package/dist/turn-manager.js +77 -45
- package/dist/turn-manager.js.map +1 -1
- package/dist/types.d.ts +0 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/version.d.ts.map +1 -1
- package/dist/version.js.map +1 -1
- package/package.json +5 -4
- package/dist/activity/budget.d.ts +0 -8
- package/dist/activity/budget.d.ts.map +0 -1
- package/dist/activity/budget.js +0 -9
- package/dist/activity/budget.js.map +0 -1
- package/dist/activity/error.d.ts +0 -16
- package/dist/activity/error.d.ts.map +0 -1
- package/dist/activity/error.js +0 -22
- package/dist/activity/error.js.map +0 -1
- package/dist/approval.d.ts +0 -31
- package/dist/approval.d.ts.map +0 -1
- package/dist/approval.js +0 -43
- package/dist/approval.js.map +0 -1
- package/dist/provider-ref.d.ts +0 -8
- package/dist/provider-ref.d.ts.map +0 -1
- package/dist/provider-ref.js +0 -8
- package/dist/provider-ref.js.map +0 -1
- package/dist/runtime-support.d.ts +0 -20
- package/dist/runtime-support.d.ts.map +0 -1
- package/dist/runtime-support.js.map +0 -1
package/dist/codex-home.js
CHANGED
|
@@ -2,45 +2,48 @@
|
|
|
2
2
|
* Codex home/auth pre-start validation (issue #209 cleanup — relocated from
|
|
3
3
|
* Dreamux core into the owning package).
|
|
4
4
|
*
|
|
5
|
-
* This is the codex-engine readiness check: it validates that Codex
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* placement
|
|
10
|
-
*
|
|
11
|
-
*
|
|
5
|
+
* This is the codex-engine readiness check: it validates that the Codex home a
|
|
6
|
+
* runtime will actually use (its `extra_env`'s `CODEX_HOME` override, or else
|
|
7
|
+
* `~/.codex` — see `paths.ts`'s `resolveCodexHomeDir`) exists, parses its
|
|
8
|
+
* `config.toml`, carries usable auth, and that the representative app-server
|
|
9
|
+
* socket placement is sane. It is codex-specific and carries NO `~/.dreamux`
|
|
10
|
+
* knowledge — the host's socket placement arrives as a neutral sample
|
|
11
|
+
* (`socketPath`) computed from the path context's `runtimeSocketDirs()`.
|
|
12
12
|
*/
|
|
13
13
|
import { readFile } from 'node:fs/promises';
|
|
14
14
|
import { join, normalize, sep } from 'node:path';
|
|
15
15
|
import { parse as parseToml, TomlError } from 'smol-toml';
|
|
16
16
|
import { DREAMUX_UNIX_SOCKET_PATH_MAX_BYTES, pathExists, unixSocketPathFitsBudget, } from '@excitedjs/dreamux-utils';
|
|
17
|
-
import {
|
|
17
|
+
import { resolveCodexHomeDir } from './paths.js';
|
|
18
18
|
export const DISPATCHER_APP_SERVER_SOCKET_PATH_MAX_BYTES = DREAMUX_UNIX_SOCKET_PATH_MAX_BYTES;
|
|
19
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Build the doctor context for a runtime, from the same env its Codex child
|
|
21
|
+
* would actually spawn with — a per-agent `CODEX_HOME` override in
|
|
22
|
+
* `extra_env` must be reflected here too, not just in the runtime's own spawn
|
|
23
|
+
* path. Pass `paths.ts`'s `codexSpawnEnv` result, not the ambient diagnostic
|
|
24
|
+
* env.
|
|
25
|
+
*/
|
|
26
|
+
export function dispatcherCodexHomeDoctorContext(dispatcherId, env, options = {}) {
|
|
27
|
+
const codexHome = resolveCodexHomeDir(env);
|
|
20
28
|
return {
|
|
21
29
|
dispatcherId,
|
|
22
|
-
codexHome
|
|
23
|
-
configPath:
|
|
24
|
-
dispatcherCwd: options.dispatcherCwd ?? '',
|
|
30
|
+
codexHome,
|
|
31
|
+
configPath: join(codexHome, 'config.toml'),
|
|
25
32
|
socketPath: options.socketPath ?? '',
|
|
26
|
-
codexCliArgs: options.codexCliArgs ?? [],
|
|
27
33
|
};
|
|
28
34
|
}
|
|
29
|
-
export async function validateDispatcherCodexHome(input, options
|
|
30
|
-
const context =
|
|
31
|
-
? dispatcherCodexHomeDoctorContext(input, {
|
|
32
|
-
codexCliArgs: options.codexCliArgs,
|
|
33
|
-
})
|
|
34
|
-
: {
|
|
35
|
-
...input,
|
|
36
|
-
codexCliArgs: options.codexCliArgs ?? input.codexCliArgs,
|
|
37
|
-
};
|
|
35
|
+
export async function validateDispatcherCodexHome(input, options) {
|
|
36
|
+
const context = input;
|
|
38
37
|
const errors = [];
|
|
39
|
-
const env = options.env
|
|
38
|
+
const env = options.env;
|
|
39
|
+
let config = {};
|
|
40
40
|
if (await pathExists(context.configPath)) {
|
|
41
41
|
try {
|
|
42
42
|
const parsed = parseToml(await readFile(context.configPath, 'utf8'));
|
|
43
|
-
if (
|
|
43
|
+
if (isRecord(parsed)) {
|
|
44
|
+
config = parsed;
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
44
47
|
errors.push(`Codex config must be a TOML table: ${context.configPath}`);
|
|
45
48
|
}
|
|
46
49
|
}
|
|
@@ -65,7 +68,7 @@ export async function validateDispatcherCodexHome(input, options = {}) {
|
|
|
65
68
|
// The bundled dispatcher skill is no longer symlinked into the workspace
|
|
66
69
|
// (issue #209 slice 6); core injects it at runtime by role via
|
|
67
70
|
// `skills/extraRoots/set`, so the doctor no longer checks for an on-disk skill.
|
|
68
|
-
if (!(await hasAuth(context.codexHome, env))) {
|
|
71
|
+
if (!(await hasAuth(context.codexHome, config, env))) {
|
|
69
72
|
errors.push(`missing Codex auth state in ${context.codexHome} or a supported auth environment variable`);
|
|
70
73
|
}
|
|
71
74
|
return {
|
|
@@ -74,16 +77,6 @@ export async function validateDispatcherCodexHome(input, options = {}) {
|
|
|
74
77
|
context,
|
|
75
78
|
};
|
|
76
79
|
}
|
|
77
|
-
export async function assertDispatcherCodexHomeReady(context) {
|
|
78
|
-
const result = await validateDispatcherCodexHome(context);
|
|
79
|
-
if (result.ok)
|
|
80
|
-
return;
|
|
81
|
-
throw new Error(formatDispatcherCodexHomeErrors(result));
|
|
82
|
-
}
|
|
83
|
-
export function formatDispatcherCodexHomeErrors(result) {
|
|
84
|
-
const header = `dispatcher '${result.context.dispatcherId}' Codex home is not ready`;
|
|
85
|
-
return [header, ...result.errors.map((e) => `- ${e}`)].join('\n');
|
|
86
|
-
}
|
|
87
80
|
function formatTomlError(err, file) {
|
|
88
81
|
if (err instanceof TomlError) {
|
|
89
82
|
const where = typeof err.line === 'number' && typeof err.column === 'number'
|
|
@@ -94,13 +87,35 @@ function formatTomlError(err, file) {
|
|
|
94
87
|
const msg = err instanceof Error ? err.message : String(err);
|
|
95
88
|
return `Codex config parse error in ${file}: ${msg}`;
|
|
96
89
|
}
|
|
97
|
-
async function hasAuth(codexHome, env) {
|
|
90
|
+
async function hasAuth(codexHome, config, env) {
|
|
98
91
|
if (await pathExists(join(codexHome, 'auth.json')))
|
|
99
92
|
return true;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
93
|
+
if (providerCarriesAuth(config, env))
|
|
94
|
+
return true;
|
|
95
|
+
return ['OPENAI_API_KEY', 'CODEX_API_KEY', 'CODEX_ACCESS_TOKEN'].some((name) => isSet(env[name]));
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* A home whose selected `model_provider` is a `[model_providers.<id>]` table
|
|
99
|
+
* authenticates through that table: a literal `experimental_bearer_token`, or
|
|
100
|
+
* the variable its `env_key` names. Such a home has no `auth.json` and needs
|
|
101
|
+
* none of the OpenAI variables.
|
|
102
|
+
*/
|
|
103
|
+
function providerCarriesAuth(config, env) {
|
|
104
|
+
const selected = config['model_provider'];
|
|
105
|
+
const providers = config['model_providers'];
|
|
106
|
+
if (typeof selected !== 'string' || !isRecord(providers))
|
|
107
|
+
return false;
|
|
108
|
+
const provider = providers[selected];
|
|
109
|
+
if (!isRecord(provider))
|
|
110
|
+
return false;
|
|
111
|
+
const token = provider['experimental_bearer_token'];
|
|
112
|
+
if (typeof token === 'string' && token.trim() !== '')
|
|
113
|
+
return true;
|
|
114
|
+
const envKey = provider['env_key'];
|
|
115
|
+
return typeof envKey === 'string' && isSet(env[envKey]);
|
|
116
|
+
}
|
|
117
|
+
function isSet(value) {
|
|
118
|
+
return value !== undefined && value.trim() !== '';
|
|
104
119
|
}
|
|
105
120
|
function isTmpPath(path) {
|
|
106
121
|
const normalized = normalize(path);
|
package/dist/codex-home.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codex-home.js","sourceRoot":"","sources":["../src/codex-home.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAE,IAAI,EAAE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OAAO,CAAC,KAAK,CAAC,CAAC;AAC9E,CAAC"}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Builtin `builtin:codex` runtime config: schema type, defaults, reader
|
|
3
|
-
* the typed accessor.
|
|
2
|
+
* Builtin `builtin:codex` runtime config: schema type, defaults, and reader.
|
|
4
3
|
*
|
|
5
4
|
* Codex runtime config is owned by this package (the `builtin:codex` provider),
|
|
6
5
|
* not by the Dreamux host config module. It depends only on the shared neutral
|
|
7
|
-
* validation primitives (`@excitedjs/dreamux-utils`)
|
|
8
|
-
*
|
|
9
|
-
* module re-exports these so
|
|
6
|
+
* validation primitives (`@excitedjs/dreamux-utils`), never on
|
|
7
|
+
* `@excitedjs/dreamux` core. The Dreamux host config module re-exports these so
|
|
10
8
|
* the non-builtin callers (doctor, daemon, tests) keep their import paths.
|
|
11
9
|
*/
|
|
12
10
|
/**
|
|
@@ -20,18 +18,13 @@
|
|
|
20
18
|
* environment variable is a host-level override that takes precedence over it
|
|
21
19
|
* (resolved by the codex builtin's `resolveCodexBinPath`).
|
|
22
20
|
* `initialize_timeout_ms` is that dispatcher's handshake timeout.
|
|
23
|
-
* `turn_timeout_ms` is accepted and defaulted by this config reader, but the
|
|
24
|
-
* current `CodexRuntime` does not consume it. It therefore has no runtime
|
|
25
|
-
* effect; documenting that gap must not be confused with wiring a timeout.
|
|
26
21
|
*/
|
|
27
22
|
export interface DispatcherCodexConfig {
|
|
28
23
|
bin: string;
|
|
29
|
-
approval_policy: string;
|
|
30
24
|
sandbox_mode: string;
|
|
31
25
|
extra_args: string[];
|
|
32
26
|
extra_env: Record<string, string>;
|
|
33
27
|
initialize_timeout_ms: number;
|
|
34
|
-
turn_timeout_ms: number;
|
|
35
28
|
}
|
|
36
29
|
/**
|
|
37
30
|
* Default `agents[].config.bin`. The Codex binary path is
|
|
@@ -41,31 +34,9 @@ export interface DispatcherCodexConfig {
|
|
|
41
34
|
export declare const DEFAULT_CODEX_BIN = "codex";
|
|
42
35
|
/** Default `agents[].config.initialize_timeout_ms` (handshake timeout, ms). */
|
|
43
36
|
export declare const DEFAULT_INITIALIZE_TIMEOUT_MS = 10000;
|
|
44
|
-
/**
|
|
45
|
-
* Default accepted value for `agents[].config.turn_timeout_ms` (ms). The reader
|
|
46
|
-
* validates and returns it, but `CodexRuntime` currently does not consume it,
|
|
47
|
-
* so changing this value has no runtime effect.
|
|
48
|
-
*/
|
|
49
|
-
export declare const DEFAULT_CODEX_TURN_TIMEOUT_MS = 600000;
|
|
50
|
-
/** Default `agents[].config.approval_policy` when omitted. */
|
|
51
|
-
export declare const DEFAULT_APPROVAL_POLICY = "never";
|
|
52
37
|
/** Default `agents[].config.sandbox_mode` when omitted. */
|
|
53
38
|
export declare const DEFAULT_SANDBOX_MODE = "workspace-write";
|
|
54
|
-
export declare const ALLOWED_APPROVAL_POLICIES: Set<string>;
|
|
55
39
|
export declare const ALLOWED_SANDBOX_MODES: Set<string>;
|
|
56
40
|
export declare function defaultDispatcherCodexConfig(): DispatcherCodexConfig;
|
|
57
41
|
export declare function readDispatcherCodexConfig(rawCodex: Record<string, unknown>, file: string, prefix: string): DispatcherCodexConfig;
|
|
58
|
-
/**
|
|
59
|
-
* Typed accessor for a dispatcher's resolved codex runtime config. Typed
|
|
60
|
-
* structurally (not against `DispatcherConfig`) so this module never imports
|
|
61
|
-
* the host config type — a full `DispatcherConfig` still satisfies it at the
|
|
62
|
-
* call sites.
|
|
63
|
-
*/
|
|
64
|
-
export declare function dispatcherCodexConfig(dispatcher: {
|
|
65
|
-
id: string;
|
|
66
|
-
runtime: {
|
|
67
|
-
provider: string;
|
|
68
|
-
config: unknown;
|
|
69
|
-
};
|
|
70
|
-
}): DispatcherCodexConfig;
|
|
71
42
|
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAUH;;;;;;;;;;;GAWG;AACH,MAAM,WAAW,qBAAqB;IACpC,GAAG,EAAE,MAAM,CAAC;IACZ,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,qBAAqB,EAAE,MAAM,CAAC;CAC/B;AAED;;;;GAIG;AACH,eAAO,MAAM,iBAAiB,UAAU,CAAC;AAEzC,+EAA+E;AAC/E,eAAO,MAAM,6BAA6B,QAAS,CAAC;AAEpD,2DAA2D;AAC3D,eAAO,MAAM,oBAAoB,oBAAoB,CAAC;AAEtD,eAAO,MAAM,qBAAqB,aAIhC,CAAC;AAEH,wBAAgB,4BAA4B,IAAI,qBAAqB,CAQpE;AAED,wBAAgB,yBAAyB,CACvC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EACjC,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,GACb,qBAAqB,CAiDvB"}
|
package/dist/config.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Builtin `builtin:codex` runtime config: schema type, defaults, reader
|
|
3
|
-
* the typed accessor.
|
|
2
|
+
* Builtin `builtin:codex` runtime config: schema type, defaults, and reader.
|
|
4
3
|
*
|
|
5
4
|
* Codex runtime config is owned by this package (the `builtin:codex` provider),
|
|
6
5
|
* not by the Dreamux host config module. It depends only on the shared neutral
|
|
7
|
-
* validation primitives (`@excitedjs/dreamux-utils`)
|
|
8
|
-
*
|
|
9
|
-
* module re-exports these so
|
|
6
|
+
* validation primitives (`@excitedjs/dreamux-utils`), never on
|
|
7
|
+
* `@excitedjs/dreamux` core. The Dreamux host config module re-exports these so
|
|
10
8
|
* the non-builtin callers (doctor, daemon, tests) keep their import paths.
|
|
11
9
|
*/
|
|
12
|
-
import {
|
|
13
|
-
import { readOptionalString, rejectUnknownKeys, requirePositiveInt, requireStringArray, requireStringRecord, } from '@excitedjs/dreamux-utils';
|
|
10
|
+
import { readOptionalString, readPositiveInt, readStringArray, readStringRecord, RuleViolation, } from '@excitedjs/dreamux-utils';
|
|
14
11
|
/**
|
|
15
12
|
* Default `agents[].config.bin`. The Codex binary path is
|
|
16
13
|
* dispatcher-local; `CODEX_HOST_CODEX_BIN` is a host-level override above it,
|
|
@@ -19,22 +16,8 @@ import { readOptionalString, rejectUnknownKeys, requirePositiveInt, requireStrin
|
|
|
19
16
|
export const DEFAULT_CODEX_BIN = 'codex';
|
|
20
17
|
/** Default `agents[].config.initialize_timeout_ms` (handshake timeout, ms). */
|
|
21
18
|
export const DEFAULT_INITIALIZE_TIMEOUT_MS = 10_000;
|
|
22
|
-
/**
|
|
23
|
-
* Default accepted value for `agents[].config.turn_timeout_ms` (ms). The reader
|
|
24
|
-
* validates and returns it, but `CodexRuntime` currently does not consume it,
|
|
25
|
-
* so changing this value has no runtime effect.
|
|
26
|
-
*/
|
|
27
|
-
export const DEFAULT_CODEX_TURN_TIMEOUT_MS = 600_000;
|
|
28
|
-
/** Default `agents[].config.approval_policy` when omitted. */
|
|
29
|
-
export const DEFAULT_APPROVAL_POLICY = 'never';
|
|
30
19
|
/** Default `agents[].config.sandbox_mode` when omitted. */
|
|
31
20
|
export const DEFAULT_SANDBOX_MODE = 'workspace-write';
|
|
32
|
-
export const ALLOWED_APPROVAL_POLICIES = new Set([
|
|
33
|
-
'never',
|
|
34
|
-
'auto',
|
|
35
|
-
'auto-approve',
|
|
36
|
-
'on-failure',
|
|
37
|
-
]);
|
|
38
21
|
export const ALLOWED_SANDBOX_MODES = new Set([
|
|
39
22
|
'read-only',
|
|
40
23
|
'workspace-write',
|
|
@@ -43,62 +26,37 @@ export const ALLOWED_SANDBOX_MODES = new Set([
|
|
|
43
26
|
export function defaultDispatcherCodexConfig() {
|
|
44
27
|
return {
|
|
45
28
|
bin: DEFAULT_CODEX_BIN,
|
|
46
|
-
approval_policy: DEFAULT_APPROVAL_POLICY,
|
|
47
29
|
sandbox_mode: DEFAULT_SANDBOX_MODE,
|
|
48
30
|
extra_args: [],
|
|
49
31
|
extra_env: {},
|
|
50
32
|
initialize_timeout_ms: DEFAULT_INITIALIZE_TIMEOUT_MS,
|
|
51
|
-
turn_timeout_ms: DEFAULT_CODEX_TURN_TIMEOUT_MS,
|
|
52
33
|
};
|
|
53
34
|
}
|
|
54
35
|
export function readDispatcherCodexConfig(rawCodex, file, prefix) {
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
'extra_env',
|
|
61
|
-
'initialize_timeout_ms',
|
|
62
|
-
'turn_timeout_ms',
|
|
63
|
-
]), file, prefix);
|
|
36
|
+
// Unknown fields (including the retired 'approval_policy' and
|
|
37
|
+
// 'turn_timeout_ms': Codex approval policy is hard-coded to 'never', and
|
|
38
|
+
// turn_timeout_ms was accepted-and-ignored with no runtime effect) are
|
|
39
|
+
// tolerated, not rejected — the persisted-shape policy (R21) rejects only
|
|
40
|
+
// a wrong type or a missing required field.
|
|
64
41
|
// An omitted (or explicitly null) field falls back to the dispatcher-local
|
|
65
42
|
// default. Before the top-level block was removed, `null` meant "inherit the
|
|
66
43
|
// global default"; with no global, it simply means "use the built-in".
|
|
67
44
|
const defaults = defaultDispatcherCodexConfig();
|
|
68
45
|
const bin = readOptionalString(rawCodex, 'bin', file, prefix) ?? defaults.bin;
|
|
69
46
|
if (bin.trim() === '') {
|
|
70
|
-
throw new
|
|
71
|
-
}
|
|
72
|
-
const approvalPolicy = readOptionalString(rawCodex, 'approval_policy', file, prefix) ??
|
|
73
|
-
defaults.approval_policy;
|
|
74
|
-
if (!ALLOWED_APPROVAL_POLICIES.has(approvalPolicy)) {
|
|
75
|
-
throw new Error(`dreamux config error in ${file}: ${prefix}approval_policy='${approvalPolicy}' is not one of ${Array.from(ALLOWED_APPROVAL_POLICIES).join(' | ')}`);
|
|
47
|
+
throw new RuleViolation(`dreamux config error in ${file}: ${prefix}bin must be a non-empty string`);
|
|
76
48
|
}
|
|
77
49
|
const sandboxMode = readOptionalString(rawCodex, 'sandbox_mode', file, prefix) ??
|
|
78
50
|
defaults.sandbox_mode;
|
|
79
51
|
if (!ALLOWED_SANDBOX_MODES.has(sandboxMode)) {
|
|
80
|
-
throw new
|
|
52
|
+
throw new RuleViolation(`dreamux config error in ${file}: ${prefix}sandbox_mode='${sandboxMode}' is not one of ${Array.from(ALLOWED_SANDBOX_MODES).join(' | ')}`);
|
|
81
53
|
}
|
|
82
54
|
return {
|
|
83
55
|
bin,
|
|
84
|
-
approval_policy: approvalPolicy,
|
|
85
56
|
sandbox_mode: sandboxMode,
|
|
86
|
-
extra_args:
|
|
87
|
-
extra_env:
|
|
88
|
-
initialize_timeout_ms:
|
|
89
|
-
turn_timeout_ms: requirePositiveInt(rawCodex, 'turn_timeout_ms', defaults.turn_timeout_ms, file, prefix),
|
|
57
|
+
extra_args: readStringArray(rawCodex, 'extra_args', defaults.extra_args, file, prefix),
|
|
58
|
+
extra_env: readStringRecord(rawCodex, 'extra_env', defaults.extra_env, file, prefix),
|
|
59
|
+
initialize_timeout_ms: readPositiveInt(rawCodex, 'initialize_timeout_ms', defaults.initialize_timeout_ms, file, prefix),
|
|
90
60
|
};
|
|
91
61
|
}
|
|
92
|
-
/**
|
|
93
|
-
* Typed accessor for a dispatcher's resolved codex runtime config. Typed
|
|
94
|
-
* structurally (not against `DispatcherConfig`) so this module never imports
|
|
95
|
-
* the host config type — a full `DispatcherConfig` still satisfies it at the
|
|
96
|
-
* call sites.
|
|
97
|
-
*/
|
|
98
|
-
export function dispatcherCodexConfig(dispatcher) {
|
|
99
|
-
if (dispatcher.runtime.provider !== BUILTIN_CODEX_PROVIDER_REF) {
|
|
100
|
-
throw new Error(`dispatcher '${dispatcher.id}' runtime provider ${JSON.stringify(dispatcher.runtime.provider)} is not wired to Codex`);
|
|
101
|
-
}
|
|
102
|
-
return dispatcher.runtime.config;
|
|
103
|
-
}
|
|
104
62
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,eAAe,EACf,gBAAgB,EAChB,aAAa,GACd,MAAM,0BAA0B,CAAC;AAsBlC;;;;GAIG;AACH,MAAM,CAAC,MAAM,iBAAiB,GAAG,OAAO,CAAC;AAEzC,+EAA+E;AAC/E,MAAM,CAAC,MAAM,6BAA6B,GAAG,MAAM,CAAC;AAEpD,2DAA2D;AAC3D,MAAM,CAAC,MAAM,oBAAoB,GAAG,iBAAiB,CAAC;AAEtD,MAAM,CAAC,MAAM,qBAAqB,GAAG,IAAI,GAAG,CAAC;IAC3C,WAAW;IACX,iBAAiB;IACjB,oBAAoB;CACrB,CAAC,CAAC;AAEH,MAAM,UAAU,4BAA4B;IAC1C,OAAO;QACL,GAAG,EAAE,iBAAiB;QACtB,YAAY,EAAE,oBAAoB;QAClC,UAAU,EAAE,EAAE;QACd,SAAS,EAAE,EAAE;QACb,qBAAqB,EAAE,6BAA6B;KACrD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,yBAAyB,CACvC,QAAiC,EACjC,IAAY,EACZ,MAAc;IAEd,8DAA8D;IAC9D,yEAAyE;IACzE,uEAAuE;IACvE,0EAA0E;IAC1E,4CAA4C;IAC5C,2EAA2E;IAC3E,6EAA6E;IAC7E,uEAAuE;IACvE,MAAM,QAAQ,GAAG,4BAA4B,EAAE,CAAC;IAChD,MAAM,GAAG,GAAG,kBAAkB,CAAC,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,QAAQ,CAAC,GAAG,CAAC;IAC9E,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,CAAC;QACtB,MAAM,IAAI,aAAa,CACrB,2BAA2B,IAAI,KAAK,MAAM,gCAAgC,CAC3E,CAAC;IACJ,CAAC;IACD,MAAM,WAAW,GACf,kBAAkB,CAAC,QAAQ,EAAE,cAAc,EAAE,IAAI,EAAE,MAAM,CAAC;QAC1D,QAAQ,CAAC,YAAY,CAAC;IACxB,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,aAAa,CACrB,2BAA2B,IAAI,KAAK,MAAM,iBAAiB,WAAW,mBAAmB,KAAK,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CACzI,CAAC;IACJ,CAAC;IACD,OAAO;QACL,GAAG;QACH,YAAY,EAAE,WAAW;QACzB,UAAU,EAAE,eAAe,CACzB,QAAQ,EACR,YAAY,EACZ,QAAQ,CAAC,UAAU,EACnB,IAAI,EACJ,MAAM,CACP;QACD,SAAS,EAAE,gBAAgB,CACzB,QAAQ,EACR,WAAW,EACX,QAAQ,CAAC,SAAS,EAClB,IAAI,EACJ,MAAM,CACP;QACD,qBAAqB,EAAE,eAAe,CACpC,QAAQ,EACR,uBAAuB,EACvB,QAAQ,CAAC,qBAAqB,EAC9B,IAAI,EACJ,MAAM,CACP;KACF,CAAC;AACJ,CAAC"}
|
package/dist/diagnostic.d.ts
CHANGED
|
@@ -4,9 +4,15 @@
|
|
|
4
4
|
*
|
|
5
5
|
* Declares the codex bin check (deduped + executed by Dreamux core) and runs
|
|
6
6
|
* the codex-home validation plus the codex version gate (#147) itself,
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* context's
|
|
7
|
+
* against the neutral `@excitedjs/dreamux-types` diagnostic context. The
|
|
8
|
+
* codex-home check runs against the runtime's actual spawn env (the
|
|
9
|
+
* diagnostic context's own target env — the managed service's env for a
|
|
10
|
+
* managed-service check — plus this runtime's `config.extra_env`, via
|
|
11
|
+
* `paths.ts`'s `codexSpawnEnv`) rather than the terminal process running
|
|
12
|
+
* `doctor`, so a per-agent `CODEX_HOME` or auth override is validated where
|
|
13
|
+
* it actually applies. The representative app-server socket sample is
|
|
14
|
+
* derived from the neutral path context's `runtimeSocketDirs()`, so the
|
|
15
|
+
* package never names `~/.dreamux`.
|
|
10
16
|
*/
|
|
11
17
|
import type { AgentRuntimeDiagnosticCapability } from '@excitedjs/dreamux-types';
|
|
12
18
|
import { type DispatcherCodexConfig } from './config.js';
|
package/dist/diagnostic.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostic.d.ts","sourceRoot":"","sources":["../src/diagnostic.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"diagnostic.d.ts","sourceRoot":"","sources":["../src/diagnostic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,KAAK,EAEV,gCAAgC,EAIjC,MAAM,0BAA0B,CAAC;AAElC,OAAO,EAAE,KAAK,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAsCzD,eAAO,MAAM,2BAA2B,EAAE,gCAAgC,CAAC,qBAAqB,CA6C7F,CAAC"}
|
package/dist/diagnostic.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { codexArgsFromConfig, codexArgsToCli } from './args.js';
|
|
2
1
|
import { dispatcherCodexHomeDoctorContext, validateDispatcherCodexHome, } from './codex-home.js';
|
|
3
2
|
import { representativeCodexSocketPath } from './internal/socket.js';
|
|
4
3
|
import { resolveCodexBinPath } from './bin.js';
|
|
4
|
+
import { codexSpawnEnv } from './paths.js';
|
|
5
5
|
import { MIN_CODEX_VERSION, codexVersionSatisfies } from './version.js';
|
|
6
6
|
function codexBinCheckName(scope) {
|
|
7
|
-
return scope === 'managedService'
|
|
7
|
+
return scope === 'managedService'
|
|
8
|
+
? 'managed service Codex binary'
|
|
9
|
+
: 'codex binary';
|
|
8
10
|
}
|
|
9
11
|
async function checkCodexVersion(context, runner) {
|
|
10
12
|
const bin = resolveCodexBinPath(context.config.bin, context.env);
|
|
@@ -32,16 +34,18 @@ export const codexAgentRuntimeDiagnostic = {
|
|
|
32
34
|
];
|
|
33
35
|
},
|
|
34
36
|
async runDiagnostic(context, runner) {
|
|
35
|
-
const
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
const socketDirs = context.paths.runtimeSocketDirs();
|
|
38
|
+
// Validate against the env this runtime's Codex child actually spawns
|
|
39
|
+
// with (the diagnostic's target env — the managed service's own env for
|
|
40
|
+
// a managed-service check — plus this runtime's own `extra_env`), not
|
|
41
|
+
// the terminal process running `doctor`: an operator's per-agent
|
|
42
|
+
// `CODEX_HOME` or auth override in `extra_env`, or in the service's own
|
|
43
|
+
// env, must be honored here too.
|
|
44
|
+
const env = codexSpawnEnv(context.env, context.config.extra_env);
|
|
45
|
+
const homeContext = dispatcherCodexHomeDoctorContext(context.runtime_id, env, {
|
|
39
46
|
socketPath: representativeCodexSocketPath(socketDirs, context.runtime_id),
|
|
40
47
|
});
|
|
41
|
-
const home = await validateDispatcherCodexHome(homeContext, {
|
|
42
|
-
env: context.env,
|
|
43
|
-
codexCliArgs: cliArgs,
|
|
44
|
-
});
|
|
48
|
+
const home = await validateDispatcherCodexHome(homeContext, { env });
|
|
45
49
|
const errors = [...home.errors];
|
|
46
50
|
const versionError = await checkCodexVersion(context, runner);
|
|
47
51
|
if (versionError !== null)
|
package/dist/diagnostic.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostic.js","sourceRoot":"","sources":["../src/diagnostic.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"diagnostic.js","sourceRoot":"","sources":["../src/diagnostic.ts"],"names":[],"mappings":"AAyB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@@ -16,58 +16,34 @@ export interface CollectedTurn {
|
|
|
16
16
|
status: TurnStatus;
|
|
17
17
|
}
|
|
18
18
|
export interface TurnCollector {
|
|
19
|
-
|
|
19
|
+
/**
|
|
20
|
+
* Forget a turn's buffered `item/completed` items. `itemsByTurn` has no
|
|
21
|
+
* size bound of its own (unlike the terminal-id set below): every
|
|
22
|
+
* `item/completed` notification appends to it, and nothing else ever
|
|
23
|
+
* deletes an entry, so a long-lived resident collector leaks one array per
|
|
24
|
+
* native turn it has ever seen unless the caller releases each turn once
|
|
25
|
+
* it is done with it.
|
|
26
|
+
*/
|
|
20
27
|
releaseTurn(turnId: string): void;
|
|
21
28
|
dispose(): void;
|
|
22
29
|
}
|
|
23
|
-
/**
|
|
24
|
-
* One observed Codex notification, redacted to method + ids + item type — never
|
|
25
|
-
* prompt/assistant text. Emitted to {@link TurnSubscriptionOptions.onTrace} for
|
|
26
|
-
* every notification so a caller can see what Codex emitted after `turn/start`
|
|
27
|
-
* (issue #126 PR8): the dispatcher never awaits completion, so the worker is the
|
|
28
|
-
* only consumer of this stream, and an empty/abnormal trace is the diagnostic
|
|
29
|
-
* that distinguishes an environment stall (auth/network/quota) from a missed
|
|
30
|
-
* terminal event.
|
|
31
|
-
*/
|
|
32
|
-
export interface TurnTraceEvent {
|
|
33
|
-
method: string;
|
|
34
|
-
/** `params.threadId` if present, else null (reveals a field-shape mismatch). */
|
|
35
|
-
threadId: string | null;
|
|
36
|
-
turnId: string | null;
|
|
37
|
-
/** `item.type` for `item/completed`; never the item text. */
|
|
38
|
-
itemType: string | null;
|
|
39
|
-
/** Whether this notification counted toward THIS subscription's thread. */
|
|
40
|
-
matched: boolean;
|
|
41
|
-
}
|
|
42
30
|
export interface TurnSubscriptionOptions {
|
|
43
|
-
/**
|
|
44
|
-
* Accept `turn/completed` / `item/completed` even when the notification's
|
|
45
|
-
* `threadId` field does not match. A per-task worker app-server hosts exactly
|
|
46
|
-
* one thread, so any completion on its socket IS this task's completion;
|
|
47
|
-
* leniency makes the worker robust to a `threadId` field-shape drift in the
|
|
48
|
-
* Codex protocol that the strict dispatcher path never exercises. Default
|
|
49
|
-
* false preserves the strict, thread-scoped dispatcher behaviour.
|
|
50
|
-
*/
|
|
51
|
-
acceptAnyThread?: boolean;
|
|
52
|
-
/** Diagnostic hook fired for EVERY notification, before any filtering. */
|
|
53
|
-
onTrace?: (event: TurnTraceEvent) => void;
|
|
54
|
-
/** Keep listening while a resident runtime observes successive native turns. */
|
|
55
|
-
retainAfterTerminal?: boolean;
|
|
56
31
|
onTokenUsage?: (usage: ThreadTokenUsage) => void;
|
|
57
32
|
onItemStarted?: (turnId: string, item: ThreadItem) => void;
|
|
58
33
|
onItemCompleted?: (turnId: string, item: ThreadItem, occurredAt: number) => void;
|
|
59
34
|
onTerminal?: (turnId: string, terminal: CollectedTurn | Error) => void;
|
|
35
|
+
/**
|
|
36
|
+
* An `error` notification with no `turnId` — a connection-level protocol
|
|
37
|
+
* failure rather than one turn's failure. The collector stops reacting to
|
|
38
|
+
* further notifications once this fires: nothing scopes a recovery to a
|
|
39
|
+
* single turn.
|
|
40
|
+
*/
|
|
60
41
|
onUnscopedFailure?: (error: Error) => void;
|
|
61
|
-
onProtocolViolation?: (error: Error) => void;
|
|
62
42
|
}
|
|
63
43
|
/**
|
|
64
|
-
* Subscribe to turn notifications for one thread
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
* error that interrupts the turn; codex emits no `turn/completed` after it, so a
|
|
68
|
-
* resolve-only collector would hang forever) or a `turn/completed` carrying a
|
|
69
|
-
* `turn.error`. Items arriving on the parallel `item/completed` stream are
|
|
70
|
-
* buffered and merged into the resolved turn.
|
|
44
|
+
* Subscribe to turn notifications for one thread, pushing each turn's
|
|
45
|
+
* lifecycle to the given callbacks as codex reports it. Stays subscribed
|
|
46
|
+
* across successive native turns until `dispose()`.
|
|
71
47
|
*/
|
|
72
48
|
export declare function subscribeTurnCollection(client: CodexWsClient, threadId: string, options?: TurnSubscriptionOptions): TurnCollector;
|
|
73
49
|
/**
|
|
@@ -75,14 +51,9 @@ export declare function subscribeTurnCollection(client: CodexWsClient, threadId:
|
|
|
75
51
|
* This is the production Feishu inbound primitive: it intentionally does not
|
|
76
52
|
* wait for `turn/completed`.
|
|
77
53
|
*/
|
|
78
|
-
export declare function submitTurnStart(client: CodexWsClient, threadId: string, texts: string[],
|
|
54
|
+
export declare function submitTurnStart(client: CodexWsClient, threadId: string, texts: string[], outputSchema?: Record<string, unknown>, effort?: string): Promise<TurnStartResponse>;
|
|
79
55
|
/** Interrupt one running turn and resolve once Codex accepts the request. */
|
|
80
56
|
export declare function interruptTurn(client: CodexWsClient, threadId: string, turnId: string): Promise<void>;
|
|
81
|
-
/**
|
|
82
|
-
* Send a `turn/start` request and await `turn/completed`.
|
|
83
|
-
* Returns the collected turn, or throws on RPC failure.
|
|
84
|
-
*/
|
|
85
|
-
export declare function runTurn(client: CodexWsClient, threadId: string, prompt: string, cwd: string | null): Promise<CollectedTurn>;
|
|
86
57
|
/**
|
|
87
58
|
* Extract the final assistant message text from a collected turn.
|
|
88
59
|
* Returns null if the turn had no assistant message — caller decides
|
package/dist/events.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"events.d.ts","sourceRoot":"","sources":["../src/events.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAC9C,OAAO,KAAK,EAGV,UAAU,EACV,gBAAgB,EAIhB,iBAAiB,EACjB,UAAU,EAEX,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,aAAa;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,KA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