@mininglamp-oss/octo-runtime 1.1.12 → 1.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/apps/cli/dist/adapters.d.ts +19 -1
- package/apps/cli/dist/adapters.js +154 -28
- package/apps/cli/dist/build-info.json +2 -2
- package/apps/cli/dist/codex.d.ts +5 -0
- package/apps/cli/dist/codex.js +36 -0
- package/apps/cli/dist/kernel.d.ts +4 -0
- package/apps/cli/dist/kernel.js +84 -0
- package/apps/cli/dist/main.js +8 -7
- package/apps/cli/dist/manifest.json +33 -22
- package/apps/cli/dist/output.d.ts +1 -0
- package/apps/cli/dist/output.js +8 -4
- package/apps/cli/dist/playboard.js +21 -12
- package/apps/cli/dist/provider-launch.d.ts +28 -0
- package/apps/cli/dist/provider-launch.js +52 -0
- package/apps/cli/dist/providers.d.ts +182 -0
- package/apps/cli/dist/providers.js +34 -0
- package/dist/public/adapter-sdk.d.ts +2 -0
- package/dist/public/adapter-sdk.js +2 -0
- package/dist/public/protocol.d.ts +2 -2
- package/dist/public/protocol.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-acp-client/dist/index.js +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.d.ts +26 -10
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.js +44 -53
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/dist/index.d.ts +10 -35
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/dist/index.js +21 -29
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/agent-env.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/agent-env.js +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/index.d.ts +14 -68
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/index.js +77 -61
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.d.ts +19 -31
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.js +28 -18
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/agent-env.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/agent-env.js +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.d.ts +6 -5
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +55 -54
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/engine.d.ts +54 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/engine.js +147 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/environment.js +4 -8
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.d.ts +20 -92
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.js +103 -217
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/mcp.d.ts +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/mcp.js +4 -11
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/service.d.ts +9 -5
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/service.js +77 -81
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-SMTJTIN7.js → chunk-AE3OJBDS.js} +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-H3S6WM37.js → chunk-NGR74QLF.js} +0 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-RISQ6NGV.js → chunk-XIUZ6GXG.js} +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.d.ts +0 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.d.ts +6 -8
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.js +16 -21
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/launch.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/trajectory.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/adapter.d.ts +14 -16
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/adapter.js +29 -46
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/agent-env.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/agent-env.js +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/client.js +4 -7
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/index.d.ts +13 -21
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/index.js +47 -36
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/dist/index.d.ts +24 -8
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/dist/index.js +14 -7
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/dist/index.d.ts +24 -8
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/dist/index.js +13 -6
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/dist/index.d.ts +24 -8
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/dist/index.js +14 -7
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.d.ts +7 -7
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.js +28 -31
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.d.ts +16 -25
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.js +113 -179
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/dist/index.d.ts +24 -8
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/dist/index.js +14 -6
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/dist/index.d.ts +24 -8
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/dist/index.js +14 -6
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/activity.d.ts +5 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/agent-env.d.ts +48 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/agent-env.js +234 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/approval.js +7 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/environment.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/execution-scope.d.ts +5 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +25 -14
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.js +112 -59
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/mcp.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/process-launch.d.ts +11 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/process-launch.js +89 -8
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/provider-launch.d.ts +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/provider-launch.js +25 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/public-display.js +10 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.d.ts +19 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.js +154 -28
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/codex.d.ts +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/codex.js +36 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/kernel.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/kernel.js +84 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.js +8 -7
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/manifest.json +33 -22
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +8 -4
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.js +21 -12
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/provider-launch.d.ts +28 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/provider-launch.js +52 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/providers.d.ts +182 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/providers.js +34 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +20 -20
- package/node_modules/@mininglamp-oss/octo-runtime-client/build-info.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/client.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-client/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-ipc.schema.json +3 -104
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/protocol.schema.json +166 -1870
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.d.ts +0 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +122 -65
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/invoke-input.d.ts +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/invoke-input.js +13 -85
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-output-silence.d.ts +21 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-output-silence.js +176 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.d.ts +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.js +8 -4
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.d.ts +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.js +17 -20
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/adapter-metadata.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/browser.d.ts +0 -2
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/browser.js +0 -2
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-catalog.d.ts +0 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-catalog.js +3 -9
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-configuration.js +1 -8
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.d.ts +1 -5
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.js +3 -292
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/experience.js +7 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.js +18 -13
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +90 -608
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.js +32 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.d.ts +7 -18
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +34 -189
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.d.ts +11 -22
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.js +38 -78
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/multimodal.js +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.d.ts +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.js +5 -40
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/service-processes.js +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
- package/package.json +34 -37
- package/packages/octo-runtime-protocol/schema/kernel-ipc.schema.json +3 -104
- package/packages/octo-runtime-protocol/schema/protocol.schema.json +166 -1870
- package/dist/public/codex.d.ts +0 -1
- package/dist/public/codex.js +0 -1
- package/dist/public/dsh.d.ts +0 -2
- package/dist/public/dsh.js +0 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/actmode.d.ts +0 -5
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/actmode.js +0 -8
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/context-configuration-fixtures.json +0 -1219
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/context-fixtures.json +0 -5988
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-client.behavior.json +0 -56
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/native-invoke-fixtures.json +0 -116
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/run-protocol-fixtures.json +0 -761
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/runtime-selection-fixtures.json +0 -663
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/session-name-fixtures.json +0 -191
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/context.d.ts +0 -12
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/context.js +0 -89
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/execution-preparation.d.ts +0 -33
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/execution-preparation.js +0 -93
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/actmode.d.ts +0 -4
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/actmode.js +0 -36
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/execution-plan.d.ts +0 -3
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/execution-plan.js +0 -80
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/model-context.d.ts +0 -3
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/model-context.js +0 -9
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/runtime-selection.d.ts +0 -3
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/runtime-selection.js +0 -68
- /package/node_modules/@mininglamp-oss/octo-runtime-client/{schema → fixtures}/kernel-ipc-fixtures.json +0 -0
- /package/packages/octo-runtime-protocol/{schema → test/fixtures}/kernel-ipc-fixtures.json +0 -0
|
@@ -0,0 +1,147 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { isAbsolute } from "node:path";
|
|
3
|
+
import { invocationEnvironment, invocationEnvs, invocationProviderOptions, invocationWorkdir, mergeProcessEnvironment, processEnvironmentValue, probeCommand, snapshotProviderLaunch } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
4
|
+
import { hasImageInput, resolveStreamLimitPolicy } from "@mininglamp-oss/octo-runtime-protocol";
|
|
5
|
+
import { buildCodexAppServerArgs } from "./app-server.js";
|
|
6
|
+
import { codexMcpConfig } from "./mcp.js";
|
|
7
|
+
import { CodexService } from "./service.js";
|
|
8
|
+
/** Home 由宿主提供和准备;库不选择、创建或修改持久目录。 */
|
|
9
|
+
export function assertCodexHome(home) {
|
|
10
|
+
if (typeof home !== "string" || !isAbsolute(home) || home.includes("\0"))
|
|
11
|
+
throw new TypeError("CODEX_HOME_REQUIRED");
|
|
12
|
+
}
|
|
13
|
+
/** 本轮不能通过环境覆盖宿主已绑定的 Home。 */
|
|
14
|
+
export function assertCodexInvocationHome(request, home) {
|
|
15
|
+
const override = processEnvironmentValue(invocationEnvs(request), "CODEX_HOME");
|
|
16
|
+
if (override !== undefined && override !== home)
|
|
17
|
+
throw new Error("CODEX_HOME_CONFLICT");
|
|
18
|
+
}
|
|
19
|
+
/** 构造命令不启动进程;显式环境必须含 Home,不回退 ~/.codex。 */
|
|
20
|
+
export function buildCodexCommand(req, command, appServerArgs = buildCodexAppServerArgs(), env = {}) {
|
|
21
|
+
const home = processEnvironmentValue(env, "CODEX_HOME");
|
|
22
|
+
assertCodexHome(home);
|
|
23
|
+
assertCodexInvocationHome(req, home);
|
|
24
|
+
const runEnv = invocationEnvironment(req, { CODEX_HOME: home }, env);
|
|
25
|
+
const mcp = codexMcpConfig(req, runEnv);
|
|
26
|
+
return {
|
|
27
|
+
command,
|
|
28
|
+
args: [...appServerArgs, ...nativeCapacityOverrides(req)],
|
|
29
|
+
cwd: invocationWorkdir(req),
|
|
30
|
+
env: mergeProcessEnvironment(runEnv, mcp.env),
|
|
31
|
+
...(Object.keys(mcp.servers).length ? { mcpServers: mcp.servers } : {}),
|
|
32
|
+
cleanup: () => undefined
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
/** 宿主显式拥有唯一 app-server;本轮配置只进入 thread,不参与进程选择。 */
|
|
36
|
+
export function createManagedCodexEngine({ codexHome, command, commandArgsPrefix = [], appServerArgs = buildCodexAppServerArgs(), spawnFn, env = {} }) {
|
|
37
|
+
assertCodexHome(codexHome);
|
|
38
|
+
const launch = snapshotProviderLaunch({ command, args: commandArgsPrefix, env });
|
|
39
|
+
const inherited = mergeProcessEnvironment(launch.env, { CODEX_HOME: codexHome });
|
|
40
|
+
const scopeId = randomUUID();
|
|
41
|
+
// server 启动继承宿主目录;CODEX_HOME 仅是数据目录,本轮 cwd 只经 thread/turn RPC 传入。
|
|
42
|
+
const spec = {
|
|
43
|
+
command: launch.command,
|
|
44
|
+
args: [...launch.args, ...appServerArgs],
|
|
45
|
+
env: inherited,
|
|
46
|
+
cleanup: () => undefined
|
|
47
|
+
};
|
|
48
|
+
let service;
|
|
49
|
+
let closing = false;
|
|
50
|
+
let close;
|
|
51
|
+
const unresolved = new Set();
|
|
52
|
+
const failed = new Set();
|
|
53
|
+
return {
|
|
54
|
+
provider: {
|
|
55
|
+
codexHome,
|
|
56
|
+
probe: () => probeCommand(launch.command, { args: launch.args, env: inherited }),
|
|
57
|
+
async acquire(request, context) {
|
|
58
|
+
if (closing)
|
|
59
|
+
throw new Error("CODEX_SERVICE_CLOSED");
|
|
60
|
+
assertCodexInvocationHome(request, codexHome);
|
|
61
|
+
if (invocationProviderOptions(request, "codex").codexServiceRevision !== undefined)
|
|
62
|
+
throw new Error("CODEX_SERVICE_REVISION_UNSUPPORTED");
|
|
63
|
+
const runEnv = invocationEnvironment(request, {}, inherited);
|
|
64
|
+
const rawMessageMaxBytes = resolveStreamLimitPolicy(context?.streamLimits).rawMessageMaxBytes;
|
|
65
|
+
const mcp = codexMcpConfig(request, runEnv);
|
|
66
|
+
const config = codexCapacityConfig(request);
|
|
67
|
+
service ??= new CodexService(scopeId, spec, spawnFn);
|
|
68
|
+
const channel = await service.acquire(request.signal, context?.protocolMode !== "native" && hasImageInput(request), rawMessageMaxBytes);
|
|
69
|
+
return {
|
|
70
|
+
channel,
|
|
71
|
+
configuration: {
|
|
72
|
+
...(Object.keys(mcp.servers).length ? { mcpServers: mcp.servers } : {}),
|
|
73
|
+
...(Object.keys(config).length ? { config } : {})
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
processes: () => (service ? [service.snapshot()] : []),
|
|
79
|
+
beginShutdown() {
|
|
80
|
+
closing = true;
|
|
81
|
+
service?.stopRecovery();
|
|
82
|
+
},
|
|
83
|
+
async close({ deadline }) {
|
|
84
|
+
if (!Number.isFinite(deadline))
|
|
85
|
+
throw new TypeError("CLEANUP_DEADLINE_INVALID");
|
|
86
|
+
closing = true;
|
|
87
|
+
if (!close) {
|
|
88
|
+
if (service)
|
|
89
|
+
unresolved.add(service.id);
|
|
90
|
+
close = Promise.all((service ? [service] : []).map(async (service) => {
|
|
91
|
+
try {
|
|
92
|
+
await service.close();
|
|
93
|
+
unresolved.delete(service.id);
|
|
94
|
+
}
|
|
95
|
+
catch {
|
|
96
|
+
failed.add(service.id);
|
|
97
|
+
}
|
|
98
|
+
})).then(() => { });
|
|
99
|
+
}
|
|
100
|
+
let timer;
|
|
101
|
+
try {
|
|
102
|
+
await Promise.race([
|
|
103
|
+
close,
|
|
104
|
+
new Promise((done) => {
|
|
105
|
+
timer = setTimeout(done, Math.max(0, deadline - performance.now()));
|
|
106
|
+
})
|
|
107
|
+
]);
|
|
108
|
+
}
|
|
109
|
+
finally {
|
|
110
|
+
clearTimeout(timer);
|
|
111
|
+
}
|
|
112
|
+
return {
|
|
113
|
+
complete: unresolved.size === 0,
|
|
114
|
+
unresolvedServiceIds: [...unresolved],
|
|
115
|
+
failedCleanupServiceIds: [...failed]
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
/** 宿主已确认的容量映射为原生参数,不重发已接受的 turn。 */
|
|
121
|
+
function nativeCapacityOverrides(request) {
|
|
122
|
+
return Object.entries(codexCapacityConfig(request)).flatMap(([key, value]) => [
|
|
123
|
+
"-c",
|
|
124
|
+
`${key}=${value}`
|
|
125
|
+
]);
|
|
126
|
+
}
|
|
127
|
+
/** 容量属于本轮 thread 配置,不改变共享服务的 argv。 */
|
|
128
|
+
function codexCapacityConfig(request) {
|
|
129
|
+
const value = request.runMetadata?.contextCapacity;
|
|
130
|
+
if (!value)
|
|
131
|
+
return {};
|
|
132
|
+
const window = value.contextWindow;
|
|
133
|
+
const reserve = value.outputReserveTokens;
|
|
134
|
+
if (value.management !== "provider_native" ||
|
|
135
|
+
typeof window !== "number" ||
|
|
136
|
+
!Number.isSafeInteger(window) ||
|
|
137
|
+
window < 1024 ||
|
|
138
|
+
typeof reserve !== "number" ||
|
|
139
|
+
!Number.isSafeInteger(reserve) ||
|
|
140
|
+
reserve < 0 ||
|
|
141
|
+
reserve >= window)
|
|
142
|
+
throw new TypeError("CONTEXT_CAPACITY_UNAVAILABLE");
|
|
143
|
+
return {
|
|
144
|
+
model_context_window: window,
|
|
145
|
+
model_auto_compact_token_limit: window - reserve
|
|
146
|
+
};
|
|
147
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { invocationEnvs } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
1
|
+
import { invocationEnvs, mergeProcessEnvironment } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
2
2
|
/** Per-thread overrides; the provider's effective configuration stays on disk unchanged. */
|
|
3
3
|
export function codexEnvironmentConfig(request, config) {
|
|
4
4
|
const envs = invocationEnvs(request);
|
|
@@ -7,7 +7,7 @@ export function codexEnvironmentConfig(request, config) {
|
|
|
7
7
|
return {};
|
|
8
8
|
const shell = record(config.shell_environment_policy);
|
|
9
9
|
const overrides = {
|
|
10
|
-
"shell_environment_policy.set":
|
|
10
|
+
"shell_environment_policy.set": mergeProcessEnvironment(record(shell.set), envs)
|
|
11
11
|
};
|
|
12
12
|
if (Array.isArray(shell.include_only) && shell.include_only.length) {
|
|
13
13
|
overrides["shell_environment_policy.include_only"] = [
|
|
@@ -21,15 +21,11 @@ export function codexEnvironmentConfig(request, config) {
|
|
|
21
21
|
server.enabled === false ||
|
|
22
22
|
server.experimental_environment === "remote")
|
|
23
23
|
continue;
|
|
24
|
-
//
|
|
25
|
-
// Existing per-server env overrides retain their provider-native precedence.
|
|
24
|
+
// 共享 app-server 环境固定;逐线程传实际值,MCP 自有 env 继续具有原生优先级。
|
|
26
25
|
Object.defineProperty(servers, name, {
|
|
27
26
|
enumerable: true,
|
|
28
27
|
value: {
|
|
29
|
-
|
|
30
|
-
...(Array.isArray(server.env_vars) ? server.env_vars : []),
|
|
31
|
-
...keys
|
|
32
|
-
]
|
|
28
|
+
env: mergeProcessEnvironment(envs, record(server.env))
|
|
33
29
|
}
|
|
34
30
|
});
|
|
35
31
|
}
|
|
@@ -1,99 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
import { type AdapterInvocationContext, type InvokeRequest } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
8
|
-
import { type InteractionResponse, type NativeInteractionResponse } from "@mininglamp-oss/octo-runtime-protocol";
|
|
9
|
-
import { type CodexAppServerCommand, type CodexAppServerSpawn } from "./app-server.js";
|
|
10
|
-
import type { AdapterExecutionScope, AdapterOutput, RuntimeLog } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
1
|
+
import type { AdapterMetadata } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
2
|
+
export declare const codexMetadata: AdapterMetadata;
|
|
3
|
+
import { type AdapterExecutionScope, type AdapterInvocationContext, type AdapterOutput, type InvokeRequest } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
4
|
+
import type { InteractionResponse, NativeInteractionResponse } from "@mininglamp-oss/octo-runtime-protocol";
|
|
5
|
+
import { type CodexEngineProvider } from "./engine.js";
|
|
6
|
+
export * from "./engine.js";
|
|
11
7
|
export { buildCodexAppServerArgs, CodexEventNormalizer, CodexAppServerProcessError, CodexAppServerRpcError, normalizeCodexEvent, runCodexAppServerTurn, type CodexAppServerCommand, type CodexAppServerNotification, type CodexAppServerSpawn, type CodexInteractionResponder } from "./app-server.js";
|
|
12
8
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
* turn/start. The parent process environment is inherited whole and only
|
|
17
|
-
* The complete real CODEX_HOME is reused. Per-run instructions are sent through
|
|
18
|
-
* thread/start or thread/resume `developerInstructions`, never written to the
|
|
19
|
-
* user's config.toml.
|
|
9
|
+
* 宿主先构造 Codex 访问依赖,再注册 Adapter;注册只创建本地调用 scope。
|
|
10
|
+
* scope 释放自身 lease 和路由,永不关闭 Engine;宿主最终关闭其 owner。
|
|
11
|
+
* 这是 Codex 专用签名,不限制其他 Adapter 的类、工厂、闭包及任意依赖参数。
|
|
20
12
|
*/
|
|
21
|
-
export declare function
|
|
22
|
-
|
|
23
|
-
command?: string;
|
|
24
|
-
appServerArgs?: string[];
|
|
25
|
-
spawnFn?: CodexAppServerSpawn;
|
|
26
|
-
env?: NodeJS.ProcessEnv;
|
|
13
|
+
export declare function createCodexAdapter({ engine }: {
|
|
14
|
+
engine: CodexEngineProvider;
|
|
27
15
|
}): Readonly<Omit<{
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
processModel: string;
|
|
38
|
-
transport: string;
|
|
39
|
-
};
|
|
40
|
-
probe: () => Promise<import("@mininglamp-oss/octo-runtime-adapter-sdk").ProbeResult>;
|
|
41
|
-
createExecutionScope: ({ log }: {
|
|
42
|
-
log: RuntimeLog;
|
|
43
|
-
}) => AdapterExecutionScope;
|
|
44
|
-
respondNative(invocationId: string, response: NativeInteractionResponse): Promise<void>;
|
|
45
|
-
respondInteraction(invocationId: string, response: InteractionResponse): Promise<void>;
|
|
46
|
-
invoke(request: InvokeRequest, context?: AdapterInvocationContext): AsyncIterable<AdapterOutput>;
|
|
47
|
-
}, "metadata"> & {
|
|
48
|
-
metadata: Omit<{
|
|
49
|
-
mcp: true;
|
|
50
|
-
protocolSupport: {
|
|
51
|
-
protocol: string;
|
|
52
|
-
modes: ["native", "canonical"];
|
|
53
|
-
nativeMethods: string[];
|
|
54
|
-
};
|
|
55
|
-
type: string;
|
|
56
|
-
agentSources: "provisioned"[];
|
|
57
|
-
processModel: string;
|
|
58
|
-
transport: string;
|
|
59
|
-
}, "protocolSupport"> & {
|
|
60
|
-
protocolSupport: import("@mininglamp-oss/octo-runtime-protocol").AdapterProtocolSupport;
|
|
61
|
-
};
|
|
62
|
-
}>;
|
|
63
|
-
export declare const codexAdapter: Readonly<Omit<{
|
|
64
|
-
metadata: {
|
|
65
|
-
mcp: true;
|
|
66
|
-
protocolSupport: {
|
|
67
|
-
protocol: string;
|
|
68
|
-
modes: ["native", "canonical"];
|
|
69
|
-
nativeMethods: string[];
|
|
70
|
-
};
|
|
71
|
-
type: string;
|
|
72
|
-
agentSources: "provisioned"[];
|
|
73
|
-
processModel: string;
|
|
74
|
-
transport: string;
|
|
75
|
-
};
|
|
76
|
-
probe: () => Promise<import("@mininglamp-oss/octo-runtime-adapter-sdk").ProbeResult>;
|
|
77
|
-
createExecutionScope: ({ log }: {
|
|
78
|
-
log: RuntimeLog;
|
|
79
|
-
}) => AdapterExecutionScope;
|
|
80
|
-
respondNative(invocationId: string, response: NativeInteractionResponse): Promise<void>;
|
|
81
|
-
respondInteraction(invocationId: string, response: InteractionResponse): Promise<void>;
|
|
82
|
-
invoke(request: InvokeRequest, context?: AdapterInvocationContext): AsyncIterable<AdapterOutput>;
|
|
83
|
-
}, "metadata"> & {
|
|
84
|
-
metadata: Omit<{
|
|
85
|
-
mcp: true;
|
|
86
|
-
protocolSupport: {
|
|
87
|
-
protocol: string;
|
|
88
|
-
modes: ["native", "canonical"];
|
|
89
|
-
nativeMethods: string[];
|
|
90
|
-
};
|
|
91
|
-
type: string;
|
|
92
|
-
agentSources: "provisioned"[];
|
|
93
|
-
processModel: string;
|
|
94
|
-
transport: string;
|
|
95
|
-
}, "protocolSupport"> & {
|
|
16
|
+
createExecutionScope: () => AdapterExecutionScope;
|
|
17
|
+
respondNative(_id: string, _response: NativeInteractionResponse): Promise<void>;
|
|
18
|
+
respondInteraction(_id: string, _response: InteractionResponse): Promise<void>;
|
|
19
|
+
invoke(_request: InvokeRequest, _context?: AdapterInvocationContext): AsyncIterable<AdapterOutput>;
|
|
20
|
+
probe?: (() => Promise<import("@mininglamp-oss/octo-runtime-adapter-sdk").ProbeResult>) | undefined;
|
|
21
|
+
metadata: AdapterMetadata;
|
|
22
|
+
}, "metadata" | "defaultAgentEnv"> & {
|
|
23
|
+
readonly defaultAgentEnv: import("@mininglamp-oss/octo-runtime-protocol").AgentEnv;
|
|
24
|
+
metadata: Omit<AdapterMetadata, "protocolSupport"> & {
|
|
96
25
|
protocolSupport: import("@mininglamp-oss/octo-runtime-protocol").AdapterProtocolSupport;
|
|
97
26
|
};
|
|
98
27
|
}>;
|
|
99
|
-
export default codexAdapter;
|