@mininglamp-oss/octo-runtime 1.1.9 → 1.1.11
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 +2 -2
- package/apps/cli/README.md +1 -1
- package/{node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runtime-configuration.d.ts → apps/cli/dist/adapter-configuration.d.ts} +1 -0
- package/{node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runtime-configuration.js → apps/cli/dist/adapter-configuration.js} +1 -0
- package/apps/cli/dist/adapter-configurations.d.ts +1 -1
- package/apps/cli/dist/adapter-configurations.js +1 -1
- package/apps/cli/dist/adapters.d.ts +7 -0
- package/apps/cli/dist/adapters.js +77 -0
- package/apps/cli/dist/build-info.json +2 -2
- package/apps/cli/dist/command-tree.js +2 -3
- package/apps/cli/dist/extras.js +11 -1
- package/apps/cli/dist/help.js +1 -1
- package/apps/cli/dist/index.js +18 -1
- package/apps/cli/dist/main.d.ts +2 -0
- package/apps/cli/dist/main.js +67 -34
- package/apps/cli/dist/manifest.json +0 -5
- package/apps/cli/dist/module-manifest.js +21 -3
- package/apps/cli/dist/output.d.ts +19 -1
- package/apps/cli/dist/output.js +180 -33
- package/apps/cli/dist/playboard-interrupt.d.ts +6 -0
- package/apps/cli/dist/playboard-interrupt.js +86 -0
- package/apps/cli/dist/playboard.d.ts +2 -0
- package/apps/cli/dist/playboard.js +10 -11
- package/apps/cli/dist/state.d.ts +5 -2
- package/apps/cli/dist/state.js +48 -13
- package/dist/public/codex.d.ts +1 -0
- package/dist/public/codex.js +1 -0
- package/dist/public/executor-kernel.d.ts +4 -1
- package/dist/public/executor-kernel.js +2 -1
- package/dist/public/extra.d.ts +1 -1
- package/dist/public/host.d.ts +5 -0
- package/dist/public/host.js +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.js +20 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.d.ts +6 -6
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +68 -253
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.d.ts +11 -6
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.js +198 -52
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/service.d.ts +58 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/service.js +650 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/stdin-writer.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/stdin-writer.js +15 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
- 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 +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/activity.d.ts +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/execution-scope.d.ts +25 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/reasoning.js +1 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/service-status.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/service-status.js +12 -30
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapter-configuration.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapter-configuration.js +125 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapter-configurations.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapter-configurations.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.d.ts +7 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.js +77 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/command-tree.js +2 -3
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extras.js +11 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/help.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/index.js +18 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.js +67 -34
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/manifest.json +0 -5
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/module-manifest.js +21 -3
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.d.ts +19 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +180 -33
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard-interrupt.d.ts +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard-interrupt.js +86 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.js +10 -11
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/state.d.ts +5 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/state.js +48 -13
- package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +23 -24
- package/node_modules/@mininglamp-oss/octo-runtime-client/build-info.json +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/async-question-reply.d.ts +30 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/async-question-reply.js +199 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/browser.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/browser.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/client.d.ts +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/client.js +465 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/index.d.ts +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/index.js +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/internal.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/internal.js +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/invocation-lifecycle.d.ts +59 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/invocation-lifecycle.js +287 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/notification.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/notification.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/protocol.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/protocol.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/runtime-path.d.ts +21 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/runtime-path.js +138 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/startup-catalog.d.ts +8 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/startup-catalog.js +65 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/startup-diagnostics.d.ts +82 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/startup-diagnostics.js +371 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/submission-error.d.ts +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/submission-error.js +23 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/types.d.ts +72 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/types.js +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/package.json +54 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/context-configuration-fixtures.json +1219 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/context-fixtures.json +5988 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-client.behavior.json +56 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-ipc-fixtures.json +53 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-ipc.schema.json +538 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/native-invoke-fixtures.json +116 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/protocol.schema.json +4525 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/run-protocol-fixtures.json +761 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/runtime-selection-fixtures.json +663 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/session-name-fixtures.json +191 -0
- 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 +29 -21
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +173 -14
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/async-question-reply.d.ts +1 -30
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/async-question-reply.js +2 -199
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/client.d.ts +1 -8
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/client.js +2 -444
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/endpoint.js +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/execution-source.d.ts +17 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/execution-source.js +21 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/host-run-service.d.ts +11 -9
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/host-run-service.js +14 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.d.ts +5 -7
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.js +6 -7
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-lifecycle.d.ts +1 -53
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-lifecycle.js +2 -280
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-manifest.d.ts +14 -13
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-manifest.js +84 -187
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/lifecycle.d.ts +5 -10
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/lifecycle.js +4 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runtime-home.d.ts +20 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runtime-home.js +180 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.d.ts +5 -8
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.js +75 -45
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/service.d.ts +9 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/service.js +60 -5
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-catalog.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-catalog.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-diagnostics.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-diagnostics.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-logging.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-logging.js +18 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.d.ts +1 -10
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.js +2 -23
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/types.d.ts +2 -72
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/types.js +2 -10
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +5 -12
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/extra.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/ports.d.ts +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/package.json +6 -6
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/extra.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/ports.d.ts +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/index.js +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/web/assets/{index-BVxePruX.js → index-BLMf2Etg.js} +1 -3
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/web/index.html +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/endpoint.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/endpoint.js +12 -5
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/errors.d.ts +5 -1
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/errors.js +9 -0
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/execution.d.ts +44 -0
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/execution.js +207 -0
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-config.js +23 -3
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-service.d.ts +27 -4
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-service.js +133 -25
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extras.d.ts +10 -3
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extras.js +18 -4
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/home.d.ts +5 -6
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/home.js +33 -45
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/identity.js +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/index.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/index.js +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +5 -4
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/adapter-metadata.d.ts +7 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +19 -15
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.d.ts +3 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/service-processes.d.ts +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/service-processes.js +65 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
- package/package.json +33 -29
- package/packages/octo-runtime-protocol/schema/protocol.schema.json +42 -36
- package/apps/cli/dist/worker.js +0 -18
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/app-server.d.ts +0 -63
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/app-server.js +0 -846
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/index.d.ts +0 -54
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/index.js +0 -154
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/package.json +0 -15
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/worker.js +0 -18
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/heartbeat.d.ts +0 -16
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/heartbeat.js +0 -59
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/manifest-adapters.d.ts +0 -6
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/manifest-adapters.js +0 -88
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/module-specifier.d.ts +0 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/module-specifier.js +0 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/process.d.ts +0 -42
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/process.js +0 -292
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/rpc.d.ts +0 -64
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/rpc.js +0 -674
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runner.d.ts +0 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runner.js +0 -5
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/serve.d.ts +0 -10
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/serve.js +0 -96
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/supervisor.d.ts +0 -15
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/supervisor.js +0 -279
- /package/{apps/cli/dist/worker.d.ts → node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/execution-scope.js} +0 -0
- /package/node_modules/@mininglamp-oss/{octo-runtime-cli/dist/worker.d.ts → octo-runtime-protocol/dist/adapter-metadata.js} +0 -0
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { actmodeEvidence, invocationEnvs, mapReasoningEffort } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
2
|
-
import { canonicalTerminalStatus, classifyFailure, isCodexLocalFailureReason, isStreamCapacityReason, contextHash, contextActmode, assertJsonByteLimit,
|
|
3
|
-
import {
|
|
2
|
+
import { canonicalTerminalStatus, classifyFailure, isCodexLocalFailureReason, isStreamCapacityReason, contextHash, contextActmode, assertJsonByteLimit, providerInputParts, PROVIDER_DIAGNOSTIC_MAX_BYTES, resolveStreamLimitPolicy, streamCapacityError } from "@mininglamp-oss/octo-runtime-protocol";
|
|
3
|
+
import { codexTransportError } from "./stdin-writer.js";
|
|
4
4
|
import { codexEnvironmentConfig } from "./environment.js";
|
|
5
5
|
import { CodexAsyncQuestions, asyncQuestionMetadata } from "./async-questions.js";
|
|
6
|
-
import { createProcessCleanup } from "@mininglamp-oss/octo-runtime-adapter-sdk/process-cleanup";
|
|
7
|
-
import { resolveProcessLaunch } from "@mininglamp-oss/octo-runtime-adapter-sdk/process-launch";
|
|
8
6
|
/**
|
|
9
7
|
* Codex app-server transport and event adaptation layer.
|
|
10
8
|
*
|
|
@@ -13,7 +11,7 @@ import { resolveProcessLaunch } from "@mininglamp-oss/octo-runtime-adapter-sdk/p
|
|
|
13
11
|
* initialize/thread/turn requests and must respond to approval/elicitation
|
|
14
12
|
* requests that Codex sends back. That is why this does not reuse the generic
|
|
15
13
|
* JSON CLI helper, but instead maintains a request pending map, notification
|
|
16
|
-
* parser
|
|
14
|
+
* parser and per-turn cancellation state. The service owns transport and process cleanup.
|
|
17
15
|
*
|
|
18
16
|
* This module upholds four key invariants:
|
|
19
17
|
* - the provider session becomes visible to the Core only after turn/start
|
|
@@ -21,21 +19,13 @@ import { resolveProcessLaunch } from "@mininglamp-oss/octo-runtime-adapter-sdk/p
|
|
|
21
19
|
* - each invocation publishes at most one run.* terminal;
|
|
22
20
|
* - only notifications for the current active thread are consumed, avoiding
|
|
23
21
|
* crosstalk;
|
|
24
|
-
* -
|
|
25
|
-
* close()/finally.
|
|
22
|
+
* - close()/finally releases only the current turn's RPCs and subscription.
|
|
26
23
|
*/
|
|
27
|
-
import { sanitizePublicValue, DriverQueue
|
|
24
|
+
import { sanitizePublicValue, DriverQueue } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
28
25
|
import { protocolError } from "@mininglamp-oss/octo-runtime-protocol";
|
|
29
|
-
import { spawn } from "node:child_process";
|
|
30
26
|
import { createHash } from "node:crypto";
|
|
31
|
-
import { createInterface } from "node:readline";
|
|
32
27
|
const APP_SERVER_REQUEST_TIMEOUT_MS = 30_000;
|
|
33
|
-
// R06b:EOF 宽限 250 ms + 共享 TERM/KILL 确认 600 ms,位于默认 Host 1 秒预算内。
|
|
34
|
-
const APP_SERVER_CLOSE_GRACE_MS = 250;
|
|
35
28
|
const FINALIZATION_TIMEOUT_MS = 15_000;
|
|
36
|
-
const FINALIZATION_INTERRUPT_GRACE_MS = 2_000;
|
|
37
|
-
// Keep only the tail of stderr, balancing error diagnosability against the memory ceiling of a long-lived process.
|
|
38
|
-
const STDERR_TAIL_LIMIT = 64 * 1024;
|
|
39
29
|
/** A JSON-RPC error the app-server explicitly returned, preserving method, code and raw data. */
|
|
40
30
|
export class CodexAppServerRpcError extends Error {
|
|
41
31
|
method;
|
|
@@ -72,32 +62,19 @@ export function buildCodexAppServerArgs() {
|
|
|
72
62
|
* advancement" and resume fallback; CodexAppServerClient owns wire I/O and
|
|
73
63
|
* normalizeCodexEvent handles the pure per-notification conversion.
|
|
74
64
|
*/
|
|
75
|
-
export async function* runCodexAppServerTurn({ request, spec,
|
|
65
|
+
export async function* runCodexAppServerTurn({ request, spec, channel, context, onInteractionResponder, onNativeResponder }) {
|
|
76
66
|
const requestTimeoutMs = appServerRequestTimeout(request);
|
|
77
67
|
const interactive = request.approvalMode !== "full_access";
|
|
78
|
-
|
|
68
|
+
if (!channel)
|
|
69
|
+
throw codexTransportError("CODEX_SERVICE_SCOPE_REQUIRED");
|
|
70
|
+
const client = new CodexAppServerClient(channel, requestTimeoutMs, interactive, request, context);
|
|
79
71
|
onInteractionResponder?.((response) => client.respondInteraction(response));
|
|
80
72
|
onNativeResponder?.((response) => client.respondNative(response));
|
|
81
73
|
let terminal = false;
|
|
82
74
|
let executionFailure;
|
|
83
75
|
try {
|
|
84
76
|
throwIfAborted(request.signal);
|
|
85
|
-
//
|
|
86
|
-
try {
|
|
87
|
-
await initializeClient(client);
|
|
88
|
-
}
|
|
89
|
-
catch (error) {
|
|
90
|
-
if (!isInitializeTimeout(error) || request.signal?.aborted)
|
|
91
|
-
throw error;
|
|
92
|
-
onInteractionResponder?.(undefined);
|
|
93
|
-
await client.close();
|
|
94
|
-
throwIfAborted(request.signal);
|
|
95
|
-
client = new CodexAppServerClient(spec, spawnFn, requestTimeoutMs, interactive, request, context);
|
|
96
|
-
onInteractionResponder?.((response) => client.respondInteraction(response));
|
|
97
|
-
onNativeResponder?.((response) => client.respondNative(response));
|
|
98
|
-
await initializeClient(client);
|
|
99
|
-
}
|
|
100
|
-
client.notify("initialized");
|
|
77
|
+
// 作用域已完成服务初始化;这里仅装配本轮 thread/turn,不重复握手。
|
|
101
78
|
let environmentConfig;
|
|
102
79
|
if (Object.keys(invocationEnvs(request)).length || spec.mcpServers) {
|
|
103
80
|
const result = recordValue(await client.request("config/read", { includeLayers: false, cwd: request.workdir }));
|
|
@@ -141,6 +118,8 @@ export async function* runCodexAppServerTurn({ request, spec, spawnFn = defaultS
|
|
|
141
118
|
resumed = true;
|
|
142
119
|
}
|
|
143
120
|
catch (error) {
|
|
121
|
+
if (!(error instanceof CodexAppServerRpcError))
|
|
122
|
+
throw error;
|
|
144
123
|
if (request.providerSession?.requireResume === true)
|
|
145
124
|
throw error;
|
|
146
125
|
// A failed resume does not abort this turn; record a low-cardinality reason and fall back to a fresh thread.
|
|
@@ -275,8 +254,7 @@ export async function* runCodexAppServerTurn({ request, spec, spawnFn = defaultS
|
|
|
275
254
|
}
|
|
276
255
|
if (!terminal) {
|
|
277
256
|
// Ending without a terminal in the queue is a protocol/process anomaly and must not be disguised as success.
|
|
278
|
-
|
|
279
|
-
throw new CodexAppServerProcessError(client.processErrorMessage(exit), exit);
|
|
257
|
+
throw codexTransportError("HOST_ENDED_WITHOUT_TERMINAL");
|
|
280
258
|
}
|
|
281
259
|
}
|
|
282
260
|
catch (error) {
|
|
@@ -325,46 +303,26 @@ export async function* runCodexAppServerTurn({ request, spec, spawnFn = defaultS
|
|
|
325
303
|
}
|
|
326
304
|
}
|
|
327
305
|
finally {
|
|
328
|
-
//
|
|
306
|
+
// The turn releases its subscription; only the scope closes transport and process resources.
|
|
329
307
|
onInteractionResponder?.(undefined);
|
|
330
308
|
onNativeResponder?.(undefined);
|
|
331
|
-
await closeClientAndResources(client,
|
|
309
|
+
await closeClientAndResources(client, executionFailure);
|
|
332
310
|
}
|
|
333
311
|
}
|
|
334
|
-
async function closeClientAndResources(client,
|
|
312
|
+
async function closeClientAndResources(client, executionFailure) {
|
|
335
313
|
try {
|
|
336
314
|
await client.close();
|
|
337
315
|
}
|
|
338
316
|
catch (cleanupError) {
|
|
339
317
|
// R06b:清理失败不能覆盖原始执行失败,也不能阻止调用方资源释放。
|
|
340
318
|
if (executionFailure !== undefined) {
|
|
341
|
-
const error = new AggregateError([executionFailure, cleanupError], "Codex execution and
|
|
319
|
+
const error = new AggregateError([executionFailure, cleanupError], "Codex execution and turn cleanup failed", { cause: cleanupError });
|
|
342
320
|
// Core 从顶层 code 分类;保留本地执行首因,同时用 errors/cause 暴露清理失败。
|
|
343
321
|
const code = stringErrorCode(executionFailure);
|
|
344
322
|
throw isCodexLocalFailureReason(code) ? Object.assign(error, { code }) : error;
|
|
345
323
|
}
|
|
346
324
|
throw cleanupError;
|
|
347
325
|
}
|
|
348
|
-
finally {
|
|
349
|
-
await spec.cleanup?.();
|
|
350
|
-
}
|
|
351
|
-
}
|
|
352
|
-
function initializeClient(client) {
|
|
353
|
-
return client.request("initialize", {
|
|
354
|
-
clientInfo: {
|
|
355
|
-
name: "@mininglamp-oss/octo-runtime-adapter-codex",
|
|
356
|
-
version: "0.1.0"
|
|
357
|
-
},
|
|
358
|
-
capabilities: {
|
|
359
|
-
experimentalApi: true,
|
|
360
|
-
requestAttestation: false,
|
|
361
|
-
optOutNotificationMethods: ["mcpServer/startupStatus/updated", "remoteControl/status/changed"]
|
|
362
|
-
}
|
|
363
|
-
});
|
|
364
|
-
}
|
|
365
|
-
function isInitializeTimeout(error) {
|
|
366
|
-
return (error instanceof Error &&
|
|
367
|
-
/^codex app-server initialize timed out after \d+ms$/.test(error.message));
|
|
368
326
|
}
|
|
369
327
|
function stringErrorCode(error) {
|
|
370
328
|
return error !== null &&
|
|
@@ -995,82 +953,61 @@ function boundedJson(value, depth = 0) {
|
|
|
995
953
|
.map(([key, item]) => [boundedString(key, 256), boundedJson(item, depth + 1)]));
|
|
996
954
|
}
|
|
997
955
|
/**
|
|
998
|
-
* JSON-RPC client for a single invocation
|
|
956
|
+
* JSON-RPC client for a single invocation using a channel on the shared service.
|
|
999
957
|
*
|
|
1000
958
|
* Three kinds of frame may interleave on stdout:
|
|
1001
959
|
* 1. a response carrying id + result/error, which settles a Promise in #pending;
|
|
1002
960
|
* 2. a notification with no id, which is converted and pushed into #queue;
|
|
1003
961
|
* 3. a server request carrying id + method, which the adapter must respond to.
|
|
1004
962
|
*
|
|
1005
|
-
* This class
|
|
1006
|
-
* the process and the active thread/turn state.
|
|
963
|
+
* This class owns turn state and interactions; the service owns the wire and process.
|
|
1007
964
|
*/
|
|
1008
965
|
class CodexAppServerClient {
|
|
966
|
+
channel;
|
|
1009
967
|
invocation;
|
|
1010
968
|
context;
|
|
1011
|
-
#child;
|
|
1012
|
-
#cleanupProcess;
|
|
1013
969
|
#closePromise;
|
|
1014
|
-
#reader;
|
|
1015
|
-
#removeLineGuard;
|
|
1016
970
|
#queue;
|
|
1017
971
|
#streamLimits;
|
|
1018
972
|
#normalizer;
|
|
1019
973
|
#native;
|
|
1020
974
|
#pending = new Map();
|
|
1021
|
-
#writer;
|
|
1022
975
|
#interactions = new Map();
|
|
1023
976
|
#asyncQuestions;
|
|
1024
977
|
#nativeRequestIds = new Set();
|
|
1025
978
|
#requestTimeoutMs;
|
|
1026
979
|
#interactive;
|
|
1027
980
|
#signal;
|
|
1028
|
-
#exitPromise;
|
|
1029
|
-
#resolveExit = () => undefined;
|
|
1030
|
-
#nextId = 1;
|
|
1031
981
|
#nextInteractionId = 1;
|
|
1032
|
-
#stderr = "";
|
|
1033
982
|
#closed = false;
|
|
1034
983
|
#transportFailure;
|
|
1035
984
|
#closing = false;
|
|
1036
|
-
#exited = false;
|
|
1037
985
|
#terminal = false;
|
|
1038
986
|
#activeThreadId;
|
|
1039
987
|
#activeTurnId;
|
|
1040
988
|
#lastUsage = -1;
|
|
1041
989
|
#seenItems = new Set();
|
|
1042
|
-
#abortTimer;
|
|
1043
990
|
#finalizationTimer;
|
|
1044
|
-
#finalizationGraceTimer;
|
|
1045
991
|
#finalizationTimedOut = false;
|
|
1046
|
-
#finalizationTimeoutMs = FINALIZATION_TIMEOUT_MS;
|
|
1047
992
|
#openItems = new Set();
|
|
1048
993
|
#clearFinalizationTimer() {
|
|
1049
994
|
if (this.#finalizationTimer)
|
|
1050
995
|
clearTimeout(this.#finalizationTimer);
|
|
1051
996
|
this.#finalizationTimer = undefined;
|
|
1052
997
|
}
|
|
1053
|
-
#
|
|
998
|
+
#finalizationResult() {
|
|
1054
999
|
if (this.#native)
|
|
1055
1000
|
return {
|
|
1056
1001
|
kind: "control",
|
|
1057
1002
|
control: {
|
|
1058
|
-
type: "
|
|
1059
|
-
|
|
1060
|
-
message: "CODEX_FINALIZATION_TIMEOUT"
|
|
1003
|
+
type: "state",
|
|
1004
|
+
state: "completed"
|
|
1061
1005
|
}
|
|
1062
1006
|
};
|
|
1063
1007
|
return {
|
|
1064
1008
|
protocolVersion: 2,
|
|
1065
|
-
type: "run.
|
|
1066
|
-
payload: {
|
|
1067
|
-
code: "CODEX_FINALIZATION_TIMEOUT",
|
|
1068
|
-
adapterType: "codex",
|
|
1069
|
-
message: "Codex final answer completed but the turn did not finish before the finalization deadline",
|
|
1070
|
-
timeoutStage: "rpc",
|
|
1071
|
-
timeoutReason: "rpc_timeout",
|
|
1072
|
-
timeoutMs: this.#finalizationTimeoutMs
|
|
1073
|
-
}
|
|
1009
|
+
type: "run.completed",
|
|
1010
|
+
payload: {}
|
|
1074
1011
|
};
|
|
1075
1012
|
}
|
|
1076
1013
|
#watchFinalization(method, params) {
|
|
@@ -1105,6 +1042,7 @@ class CodexAppServerClient {
|
|
|
1105
1042
|
if (item?.type !== "agentMessage" ||
|
|
1106
1043
|
item.phase !== "final_answer" ||
|
|
1107
1044
|
item.delivery === "async" ||
|
|
1045
|
+
!stringValue(item.text).trim() ||
|
|
1108
1046
|
params.threadId !== this.#activeThreadId ||
|
|
1109
1047
|
notificationTurnId(params) !== this.#activeTurnId ||
|
|
1110
1048
|
this.#openItems.size ||
|
|
@@ -1117,21 +1055,19 @@ class CodexAppServerClient {
|
|
|
1117
1055
|
const timeoutMs = typeof configured === "number" && Number.isFinite(configured) && configured > 0
|
|
1118
1056
|
? configured
|
|
1119
1057
|
: FINALIZATION_TIMEOUT_MS;
|
|
1120
|
-
this.#finalizationTimeoutMs = timeoutMs;
|
|
1121
1058
|
this.#finalizationTimer = setTimeout(() => {
|
|
1059
|
+
if (this.#terminal || this.#closed || this.#signal?.aborted)
|
|
1060
|
+
return;
|
|
1122
1061
|
this.#finalizationTimedOut = true;
|
|
1123
|
-
//
|
|
1124
|
-
this
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
this.#queue.close();
|
|
1133
|
-
}, FINALIZATION_INTERRUPT_GRACE_MS);
|
|
1134
|
-
void this.request("turn/interrupt", { threadId: this.#activeThreadId, turnId: this.#activeTurnId }, FINALIZATION_INTERRUPT_GRACE_MS).catch(() => undefined);
|
|
1062
|
+
// #307:结果在清理之前锁定;release 负责有界中断/退订,失败不得改写成功。
|
|
1063
|
+
this.context?.reportExecutionResult?.({
|
|
1064
|
+
status: "completed",
|
|
1065
|
+
basis: "final_answer_cleanup_fallback"
|
|
1066
|
+
});
|
|
1067
|
+
this.#invalidateInteractions("run_completed");
|
|
1068
|
+
this.#terminal = true;
|
|
1069
|
+
this.#queue.push(this.#finalizationResult());
|
|
1070
|
+
this.#queue.close();
|
|
1135
1071
|
}, timeoutMs);
|
|
1136
1072
|
}
|
|
1137
1073
|
/**
|
|
@@ -1158,19 +1094,11 @@ class CodexAppServerClient {
|
|
|
1158
1094
|
payload: { reason: String(this.#signal?.reason ?? "cancelled") }
|
|
1159
1095
|
});
|
|
1160
1096
|
this.#queue.close();
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
threadId: this.#activeThreadId,
|
|
1164
|
-
turnId: this.#activeTurnId
|
|
1165
|
-
}, 1_000).catch(() => undefined);
|
|
1166
|
-
}
|
|
1167
|
-
this.#abortTimer = setTimeout(() => {
|
|
1168
|
-
// 观察异步失败以免产生 unhandled rejection;close 仍等待同一 Promise 并返回失败。
|
|
1169
|
-
void this.#cleanupProcess().catch((error) => this.#handleProcessError(error));
|
|
1170
|
-
}, APP_SERVER_CLOSE_GRACE_MS);
|
|
1171
|
-
this.#abortTimer.unref?.();
|
|
1097
|
+
// release 单独发送一次中断;ACK 未知也不重发。消费者停读时仍有独立清理机会。
|
|
1098
|
+
void this.channel.close().catch((error) => this.#handleProcessError(error));
|
|
1172
1099
|
};
|
|
1173
|
-
constructor(
|
|
1100
|
+
constructor(channel, requestTimeoutMs, interactive, invocation, context) {
|
|
1101
|
+
this.channel = channel;
|
|
1174
1102
|
this.invocation = invocation;
|
|
1175
1103
|
this.context = context;
|
|
1176
1104
|
this.#streamLimits = resolveStreamLimitPolicy(context?.streamLimits);
|
|
@@ -1187,51 +1115,15 @@ class CodexAppServerClient {
|
|
|
1187
1115
|
this.#interactive = interactive;
|
|
1188
1116
|
const signal = invocation.signal;
|
|
1189
1117
|
this.#signal = signal;
|
|
1190
|
-
|
|
1191
|
-
this.#resolveExit = resolve;
|
|
1192
|
-
});
|
|
1193
|
-
this.#child = spawnFn(spec.command, spec.args, { cwd: spec.cwd, env: spec.env });
|
|
1194
|
-
this.#writer = new CodexStdinWriter(this.#child.stdin, (error) => this.#handleProcessError(error));
|
|
1195
|
-
this.#cleanupProcess = createProcessCleanup(this.#child, {
|
|
1196
|
-
// 只有 production defaultSpawn 明确拥有独立组;注入的 child 不推定拥有组。
|
|
1197
|
-
processGroup: isolatedProcessGroups.has(this.#child)
|
|
1198
|
-
});
|
|
1199
|
-
// The app-server protocol requires one JSON-RPC frame per line; readline handles chunk boundaries.
|
|
1200
|
-
const transportLimit = !this.#native && hasImageInput(invocation)
|
|
1201
|
-
? INVOKE_REQUEST_MAX_BYTES
|
|
1202
|
-
: this.#streamLimits.rawMessageMaxBytes;
|
|
1203
|
-
this.#removeLineGuard = watchLineLimit(this.#child.stdout, transportLimit, (error) => {
|
|
1204
|
-
this.#reader.close();
|
|
1205
|
-
this.#child.stdout.destroy();
|
|
1206
|
-
this.#handleProcessError(error);
|
|
1207
|
-
signalProcessTree(this.#child, "SIGTERM");
|
|
1208
|
-
});
|
|
1209
|
-
this.#reader = createInterface({ input: this.#child.stdout });
|
|
1210
|
-
this.#reader.on("line", (line) => {
|
|
1118
|
+
channel.onMessage = (message) => {
|
|
1211
1119
|
try {
|
|
1212
|
-
this.#handleLine(
|
|
1120
|
+
this.#handleLine(JSON.stringify(message));
|
|
1213
1121
|
}
|
|
1214
1122
|
catch (error) {
|
|
1215
1123
|
this.#handleProcessError(error instanceof Error ? error : new Error(String(error)), "protocol");
|
|
1216
1124
|
}
|
|
1217
|
-
}
|
|
1218
|
-
this.#
|
|
1219
|
-
this.#child.stderr.on("data", (chunk) => {
|
|
1220
|
-
this.#stderr = (this.#stderr + chunk.toString()).slice(-STDERR_TAIL_LIMIT);
|
|
1221
|
-
});
|
|
1222
|
-
// spawn error and normal/abnormal close are watched separately, but both ultimately reject pending RPCs and close the event stream.
|
|
1223
|
-
// S01(Jerry-Xin R05 同类):write 回调不能代替流 error 监听。
|
|
1224
|
-
// .octospec/tasks/pr1-yujiawei-review/assessment.md
|
|
1225
|
-
for (const source of [
|
|
1226
|
-
this.#child,
|
|
1227
|
-
this.#child.stdin,
|
|
1228
|
-
this.#child.stdout,
|
|
1229
|
-
this.#child.stderr,
|
|
1230
|
-
this.#reader
|
|
1231
|
-
]) {
|
|
1232
|
-
source.on("error", (error) => this.#handleProcessError(error));
|
|
1233
|
-
}
|
|
1234
|
-
this.#child.once("close", (code, exitSignal) => this.#handleExit({ code, signal: exitSignal }));
|
|
1125
|
+
};
|
|
1126
|
+
channel.onFailure = (error) => this.#handleProcessError(error);
|
|
1235
1127
|
if (signal?.aborted)
|
|
1236
1128
|
queueMicrotask(this.#abortListener);
|
|
1237
1129
|
else
|
|
@@ -1251,7 +1143,7 @@ class CodexAppServerClient {
|
|
|
1251
1143
|
}
|
|
1252
1144
|
/** Accept only a provider reply to a pending request in this invocation. */
|
|
1253
1145
|
async respondNative(response) {
|
|
1254
|
-
if (!this.#native || this.#closed || this.#
|
|
1146
|
+
if (!this.#native || this.#closed || this.#terminal)
|
|
1255
1147
|
throw protocolError("INTERACTION_NOT_ACTIVE");
|
|
1256
1148
|
const entry = [...this.#interactions.entries()].find(([, value]) => value.rpcId === response.requestId);
|
|
1257
1149
|
if (!entry)
|
|
@@ -1342,11 +1234,11 @@ class CodexAppServerClient {
|
|
|
1342
1234
|
/** Resume one provider reverse request after the durable Worker response reaches this invocation. */
|
|
1343
1235
|
respondInteraction(response) {
|
|
1344
1236
|
if (response.interactionId.startsWith("codex:async:")) {
|
|
1345
|
-
if (this.#native || this.#closed || this.#
|
|
1237
|
+
if (this.#native || this.#closed || this.#terminal)
|
|
1346
1238
|
return Promise.reject(protocolError("INTERACTION_NOT_ACTIVE"));
|
|
1347
1239
|
return this.#asyncQuestions.respond(response);
|
|
1348
1240
|
}
|
|
1349
|
-
if (this.#closed || this.#
|
|
1241
|
+
if (this.#closed || this.#terminal) {
|
|
1350
1242
|
return Promise.reject(new Error("codex interaction is no longer active"));
|
|
1351
1243
|
}
|
|
1352
1244
|
const pending = this.#interactions.get(response.interactionId);
|
|
@@ -1367,9 +1259,6 @@ class CodexAppServerClient {
|
|
|
1367
1259
|
}
|
|
1368
1260
|
return this.#deliverInteraction(response.interactionId, pending, { jsonrpc: "2.0", id: pending.rpcId, ...reply }, response.outcome);
|
|
1369
1261
|
}
|
|
1370
|
-
exit() {
|
|
1371
|
-
return this.#exitPromise;
|
|
1372
|
-
}
|
|
1373
1262
|
request(method, params, timeoutMs = this.#requestTimeoutMs, onWritten, requestId, accept, rejected) {
|
|
1374
1263
|
if (this.#transportFailure)
|
|
1375
1264
|
return Promise.reject(Object.assign(new Error("codex transport unavailable", { cause: this.#transportFailure }), {
|
|
@@ -1378,7 +1267,7 @@ class CodexAppServerClient {
|
|
|
1378
1267
|
? { code: stringErrorCode(this.#transportFailure) }
|
|
1379
1268
|
: {})
|
|
1380
1269
|
}));
|
|
1381
|
-
if (this.#closed
|
|
1270
|
+
if (this.#closed) {
|
|
1382
1271
|
return Promise.reject(Object.assign(new Error("codex app-server is closed"), { deliveryNotAttempted: true }));
|
|
1383
1272
|
}
|
|
1384
1273
|
const id = requestId ?? this.reserveRequestId();
|
|
@@ -1424,7 +1313,7 @@ class CodexAppServerClient {
|
|
|
1424
1313
|
}
|
|
1425
1314
|
/** Allocate the exact JSON-RPC id a subsequent request will put on the wire. */
|
|
1426
1315
|
reserveRequestId() {
|
|
1427
|
-
return this
|
|
1316
|
+
return this.channel.reserveRequestId();
|
|
1428
1317
|
}
|
|
1429
1318
|
notify(method, params) {
|
|
1430
1319
|
this.#write({
|
|
@@ -1434,46 +1323,22 @@ class CodexAppServerClient {
|
|
|
1434
1323
|
});
|
|
1435
1324
|
}
|
|
1436
1325
|
/**
|
|
1437
|
-
*
|
|
1438
|
-
* 重复 close
|
|
1439
|
-
* .octospec/tasks/pr1-yujiawei-review/second-review.md
|
|
1326
|
+
* 关闭本轮交互、RPC 与订阅;进程所有权仍留在 service。
|
|
1327
|
+
* 重复 close 共用首次释放,失败向原调用方报告,不能据此关闭共享进程。
|
|
1440
1328
|
*/
|
|
1441
1329
|
close() {
|
|
1442
1330
|
return (this.#closePromise ??= (async () => {
|
|
1443
1331
|
this.#closed = true;
|
|
1444
|
-
this.#writer.stop(protocolError("INTERACTION_NOT_ACTIVE"));
|
|
1445
1332
|
this.#clearFinalizationTimer();
|
|
1446
|
-
if (this.#finalizationGraceTimer)
|
|
1447
|
-
clearTimeout(this.#finalizationGraceTimer);
|
|
1448
1333
|
this.#closing = true;
|
|
1449
1334
|
this.#signal?.removeEventListener("abort", this.#abortListener);
|
|
1450
|
-
if (this.#abortTimer)
|
|
1451
|
-
clearTimeout(this.#abortTimer);
|
|
1452
|
-
this.#reader.close();
|
|
1453
|
-
this.#removeLineGuard();
|
|
1454
1335
|
this.#rejectPending(new Error("codex app-server closed"));
|
|
1455
1336
|
this.#invalidateInteractions("execution_lost");
|
|
1456
|
-
|
|
1457
|
-
if (!this.#exited) {
|
|
1458
|
-
this.#child.stdin.end();
|
|
1459
|
-
await waitForExit(this.#exitPromise, APP_SERVER_CLOSE_GRACE_MS);
|
|
1460
|
-
}
|
|
1461
|
-
}
|
|
1462
|
-
finally {
|
|
1463
|
-
// 即使 leader 早已退出或 EOF 已成功,仍确认后代消失并按需升级 KILL。
|
|
1464
|
-
await this.#cleanupProcess();
|
|
1465
|
-
}
|
|
1337
|
+
await this.channel.close();
|
|
1466
1338
|
})());
|
|
1467
1339
|
}
|
|
1468
1340
|
errorMessage(error) {
|
|
1469
|
-
|
|
1470
|
-
return this.#stderr.trim() ? `${raw}\n\n[codex stderr]\n${this.#stderr.trim()}` : raw;
|
|
1471
|
-
}
|
|
1472
|
-
processErrorMessage(exit) {
|
|
1473
|
-
const base = exit.signal
|
|
1474
|
-
? `codex app-server exited on ${exit.signal}`
|
|
1475
|
-
: `codex app-server exited with code ${exit.code ?? -1}`;
|
|
1476
|
-
return this.#stderr.trim() ? `${base}: ${this.#stderr.trim()}` : base;
|
|
1341
|
+
return this.channel.errorMessage(error);
|
|
1477
1342
|
}
|
|
1478
1343
|
/** Dispatch one stdout frame. Ordering of the checks matters: a response may also lack a method. */
|
|
1479
1344
|
#handleLine(line) {
|
|
@@ -1487,7 +1352,7 @@ class CodexAppServerClient {
|
|
|
1487
1352
|
});
|
|
1488
1353
|
this.#rejectPending(error);
|
|
1489
1354
|
this.#queue.fail(error);
|
|
1490
|
-
|
|
1355
|
+
this.#handleProcessError(error);
|
|
1491
1356
|
return;
|
|
1492
1357
|
}
|
|
1493
1358
|
if (!message)
|
|
@@ -1504,6 +1369,8 @@ class CodexAppServerClient {
|
|
|
1504
1369
|
this.#handleServerRequest(id, method, recordValue(message.params) ?? {}, message);
|
|
1505
1370
|
return;
|
|
1506
1371
|
}
|
|
1372
|
+
if (this.#terminal)
|
|
1373
|
+
return;
|
|
1507
1374
|
const params = recordValue(message.params) ?? {};
|
|
1508
1375
|
if (this.#native &&
|
|
1509
1376
|
((!this.#activeThreadId && method !== "thread/started") ||
|
|
@@ -1522,8 +1389,6 @@ class CodexAppServerClient {
|
|
|
1522
1389
|
this.#invalidateInteractions(recordValue(params.turn)?.status === "completed" ? "run_completed" : "run_terminal");
|
|
1523
1390
|
this.#terminal = true;
|
|
1524
1391
|
this.#clearFinalizationTimer();
|
|
1525
|
-
if (this.#finalizationGraceTimer)
|
|
1526
|
-
clearTimeout(this.#finalizationGraceTimer);
|
|
1527
1392
|
const status = recordValue(params.turn)?.status;
|
|
1528
1393
|
this.#queue.push({
|
|
1529
1394
|
kind: "control",
|
|
@@ -1546,10 +1411,8 @@ class CodexAppServerClient {
|
|
|
1546
1411
|
this.#invalidateInteractions(event.type === "run.completed" ? "run_completed" : "run_terminal");
|
|
1547
1412
|
this.#terminal = true;
|
|
1548
1413
|
this.#clearFinalizationTimer();
|
|
1549
|
-
if (this.#finalizationGraceTimer)
|
|
1550
|
-
clearTimeout(this.#finalizationGraceTimer);
|
|
1551
1414
|
this.#queue.push(this.#finalizationTimedOut && event.type !== "run.completed"
|
|
1552
|
-
? this.#
|
|
1415
|
+
? this.#finalizationResult()
|
|
1553
1416
|
: event);
|
|
1554
1417
|
this.#queue.close();
|
|
1555
1418
|
}
|
|
@@ -1613,6 +1476,12 @@ class CodexAppServerClient {
|
|
|
1613
1476
|
const pending = this.#pending.get(id);
|
|
1614
1477
|
if (!pending)
|
|
1615
1478
|
return;
|
|
1479
|
+
if (!message.error) {
|
|
1480
|
+
if (pending.method === "thread/start" || pending.method === "thread/resume")
|
|
1481
|
+
this.setActiveThread(extractThreadId(message.result));
|
|
1482
|
+
if (pending.method === "turn/start")
|
|
1483
|
+
this.setActiveTurn(extractTurnId(message.result));
|
|
1484
|
+
}
|
|
1616
1485
|
if (this.#native &&
|
|
1617
1486
|
["thread/start", "thread/resume", "turn/start", "turn/interrupt"].includes(pending.method))
|
|
1618
1487
|
this.#queue.push({ kind: "native", messageKind: "response", payload: message });
|
|
@@ -1641,7 +1510,7 @@ class CodexAppServerClient {
|
|
|
1641
1510
|
this.#rejectServerRequest(id, method);
|
|
1642
1511
|
return;
|
|
1643
1512
|
}
|
|
1644
|
-
if (this.#terminal || this.#closed
|
|
1513
|
+
if (this.#terminal || this.#closed) {
|
|
1645
1514
|
this.#write({
|
|
1646
1515
|
jsonrpc: "2.0",
|
|
1647
1516
|
id,
|
|
@@ -1798,12 +1667,12 @@ class CodexAppServerClient {
|
|
|
1798
1667
|
}
|
|
1799
1668
|
#write(message, onError, onWritten, options = {}) {
|
|
1800
1669
|
const error = this.#transportFailure ??
|
|
1801
|
-
(this.#closed
|
|
1670
|
+
(this.#closed ? codexTransportError("CODEX_TRANSPORT_FAILED") : undefined);
|
|
1802
1671
|
if (error) {
|
|
1803
1672
|
onError?.(error);
|
|
1804
1673
|
return () => { };
|
|
1805
1674
|
}
|
|
1806
|
-
return this
|
|
1675
|
+
return this.channel.write(message, onError ?? (() => { }), onWritten, {
|
|
1807
1676
|
...options,
|
|
1808
1677
|
// 普通容量拒绝可显式走普通队列;协议拒绝默认使用控制预留,批准不借用预留。
|
|
1809
1678
|
control: options.control ?? Object.hasOwn(message, "error")
|
|
@@ -1898,8 +1767,6 @@ class CodexAppServerClient {
|
|
|
1898
1767
|
!["ENOENT", "ENOTDIR", "EACCES", "EPERM"].includes(code ?? ""))
|
|
1899
1768
|
error = codexTransportError("CODEX_TRANSPORT_FAILED", error);
|
|
1900
1769
|
this.#transportFailure = error;
|
|
1901
|
-
this.#writer.stop(error);
|
|
1902
|
-
this.#reader.close();
|
|
1903
1770
|
this.#clearFinalizationTimer();
|
|
1904
1771
|
this.#rejectPending(error);
|
|
1905
1772
|
this.#invalidateInteractions("execution_lost");
|
|
@@ -1910,21 +1777,8 @@ class CodexAppServerClient {
|
|
|
1910
1777
|
});
|
|
1911
1778
|
}
|
|
1912
1779
|
}
|
|
1913
|
-
#handleExit(exit) {
|
|
1914
|
-
this.#clearFinalizationTimer();
|
|
1915
|
-
if (this.#exited)
|
|
1916
|
-
return;
|
|
1917
|
-
this.#exited = true;
|
|
1918
|
-
this.#resolveExit(exit);
|
|
1919
|
-
const error = new CodexAppServerProcessError(this.processErrorMessage(exit), exit);
|
|
1920
|
-
this.#writer.stop(error);
|
|
1921
|
-
this.#rejectPending(error);
|
|
1922
|
-
this.#invalidateInteractions("execution_lost");
|
|
1923
|
-
if (!this.#closing && !this.#terminal)
|
|
1924
|
-
this.#queue.fail(error);
|
|
1925
|
-
}
|
|
1926
1780
|
#invalidateInteractions(reasonCode) {
|
|
1927
|
-
this
|
|
1781
|
+
this.channel.cancelPending(protocolError("INTERACTION_NOT_ACTIVE"));
|
|
1928
1782
|
this.#asyncQuestions.invalidate(reasonCode);
|
|
1929
1783
|
for (const [interactionId, pending] of this.#interactions) {
|
|
1930
1784
|
clearTimeout(pending.timer);
|
|
@@ -1941,33 +1795,6 @@ class CodexAppServerClient {
|
|
|
1941
1795
|
this.#pending.clear();
|
|
1942
1796
|
}
|
|
1943
1797
|
}
|
|
1944
|
-
function defaultSpawn(command, args, options) {
|
|
1945
|
-
const launch = resolveProcessLaunch(command, args, options);
|
|
1946
|
-
const child = spawn(launch.command, [...launch.args], {
|
|
1947
|
-
cwd: options.cwd,
|
|
1948
|
-
env: options.env,
|
|
1949
|
-
stdio: ["pipe", "pipe", "pipe"],
|
|
1950
|
-
detached: process.platform !== "win32",
|
|
1951
|
-
windowsHide: process.platform === "win32"
|
|
1952
|
-
});
|
|
1953
|
-
if (process.platform !== "win32")
|
|
1954
|
-
isolatedProcessGroups.add(child);
|
|
1955
|
-
return child;
|
|
1956
|
-
}
|
|
1957
|
-
const isolatedProcessGroups = new WeakSet();
|
|
1958
|
-
function signalProcessTree(child, signal) {
|
|
1959
|
-
if (isolatedProcessGroups.has(child) && child.pid !== undefined) {
|
|
1960
|
-
try {
|
|
1961
|
-
process.kill(-child.pid, signal);
|
|
1962
|
-
return;
|
|
1963
|
-
}
|
|
1964
|
-
catch (error) {
|
|
1965
|
-
if (error.code !== "ESRCH")
|
|
1966
|
-
throw error;
|
|
1967
|
-
}
|
|
1968
|
-
}
|
|
1969
|
-
child.kill(signal);
|
|
1970
|
-
}
|
|
1971
1798
|
/** Shared params for thread/start and thread/resume; the permission policy is fixed at the thread level. */
|
|
1972
1799
|
function threadParams(request, extra, environmentConfig) {
|
|
1973
1800
|
return {
|
|
@@ -2434,15 +2261,3 @@ function stringArray(value) {
|
|
|
2434
2261
|
function rpcId(value) {
|
|
2435
2262
|
return typeof value === "string" || typeof value === "number" ? value : undefined;
|
|
2436
2263
|
}
|
|
2437
|
-
async function waitForExit(exit, timeoutMs) {
|
|
2438
|
-
let timer;
|
|
2439
|
-
return Promise.race([
|
|
2440
|
-
exit.then(() => true),
|
|
2441
|
-
new Promise((resolve) => {
|
|
2442
|
-
timer = setTimeout(() => resolve(false), timeoutMs);
|
|
2443
|
-
})
|
|
2444
|
-
]).finally(() => {
|
|
2445
|
-
if (timer)
|
|
2446
|
-
clearTimeout(timer);
|
|
2447
|
-
});
|
|
2448
|
-
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Assembly entry point for the Codex adapter.
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* app-server transport. Per-run developer instructions travel in native thread
|
|
7
|
-
* params, so app-server sees the complete state database and plugin runtime.
|
|
4
|
+
* 描述对象注册时创建独立 scope;按兼容配置选择常驻服务,再绑定本轮 channel。
|
|
5
|
+
* scope 负责最终关闭,逐轮 developer instructions 仍放在原生 thread 参数中。
|
|
8
6
|
*/
|
|
9
7
|
import { type AdapterInvocationContext, type InvokeRequest } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
10
8
|
import { type InteractionResponse, type NativeInteractionResponse } from "@mininglamp-oss/octo-runtime-protocol";
|
|
11
9
|
import { type CodexAppServerCommand, type CodexAppServerSpawn } from "./app-server.js";
|
|
10
|
+
import type { AdapterExecutionScope, AdapterOutput, RuntimeLog } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
12
11
|
export { buildCodexAppServerArgs, CodexEventNormalizer, CodexAppServerProcessError, CodexAppServerRpcError, normalizeCodexEvent, runCodexAppServerTurn, type CodexAppServerCommand, type CodexAppServerNotification, type CodexAppServerSpawn, type CodexInteractionResponder } from "./app-server.js";
|
|
13
12
|
/**
|
|
14
13
|
* Convert an Octo Runtime InvokeRequest into a launchable app-server process spec.
|
|
@@ -39,9 +38,12 @@ export declare function createCodexAdapter({ command, appServerArgs, spawnFn, en
|
|
|
39
38
|
transport: string;
|
|
40
39
|
};
|
|
41
40
|
probe: () => Promise<import("@mininglamp-oss/octo-runtime-adapter-sdk").ProbeResult>;
|
|
41
|
+
createExecutionScope: ({ log }: {
|
|
42
|
+
log: RuntimeLog;
|
|
43
|
+
}) => AdapterExecutionScope;
|
|
42
44
|
respondNative(invocationId: string, response: NativeInteractionResponse): Promise<void>;
|
|
43
45
|
respondInteraction(invocationId: string, response: InteractionResponse): Promise<void>;
|
|
44
|
-
invoke(request: InvokeRequest, context?: AdapterInvocationContext):
|
|
46
|
+
invoke(request: InvokeRequest, context?: AdapterInvocationContext): AsyncIterable<AdapterOutput>;
|
|
45
47
|
}, "metadata"> & {
|
|
46
48
|
metadata: Omit<{
|
|
47
49
|
mcp: true;
|
|
@@ -72,9 +74,12 @@ export declare const codexAdapter: Readonly<Omit<{
|
|
|
72
74
|
transport: string;
|
|
73
75
|
};
|
|
74
76
|
probe: () => Promise<import("@mininglamp-oss/octo-runtime-adapter-sdk").ProbeResult>;
|
|
77
|
+
createExecutionScope: ({ log }: {
|
|
78
|
+
log: RuntimeLog;
|
|
79
|
+
}) => AdapterExecutionScope;
|
|
75
80
|
respondNative(invocationId: string, response: NativeInteractionResponse): Promise<void>;
|
|
76
81
|
respondInteraction(invocationId: string, response: InteractionResponse): Promise<void>;
|
|
77
|
-
invoke(request: InvokeRequest, context?: AdapterInvocationContext):
|
|
82
|
+
invoke(request: InvokeRequest, context?: AdapterInvocationContext): AsyncIterable<AdapterOutput>;
|
|
78
83
|
}, "metadata"> & {
|
|
79
84
|
metadata: Omit<{
|
|
80
85
|
mcp: true;
|