@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,292 +0,0 @@
|
|
|
1
|
-
import { createProcessCleanup } from "@mininglamp-oss/octo-runtime-adapter-sdk/process-cleanup";
|
|
2
|
-
import { execFile, spawn } from "node:child_process";
|
|
3
|
-
import { setTimeout as delay } from "node:timers/promises";
|
|
4
|
-
import { WorkerRpcClient } from "./rpc.js";
|
|
5
|
-
/** 保留失败进程的回收入口;只有重新确认回收成功后,监督器才允许创建替代 worker。 */
|
|
6
|
-
export class WorkerCleanupError extends AggregateError {
|
|
7
|
-
retryCleanup;
|
|
8
|
-
pid;
|
|
9
|
-
code;
|
|
10
|
-
constructor(errors, retryCleanup, pid) {
|
|
11
|
-
super(errors, "WORKER_CLEANUP_INCOMPLETE", { cause: errors.at(-1) });
|
|
12
|
-
this.retryCleanup = retryCleanup;
|
|
13
|
-
this.pid = pid;
|
|
14
|
-
const cause = errors.at(-1);
|
|
15
|
-
const code = cause instanceof Error && "code" in cause ? cause.code : undefined;
|
|
16
|
-
this.code =
|
|
17
|
-
typeof code === "string" && /^[A-Z][A-Z0-9_]{0,95}$/.test(code)
|
|
18
|
-
? code
|
|
19
|
-
: "WORKER_CLEANUP_INCOMPLETE";
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
/** 每轮失败后允许重新观测;成功后永不再次向旧 PGID 发信号,避免历史身份被复用。 */
|
|
23
|
-
function workerCleanup(child) {
|
|
24
|
-
let complete = false;
|
|
25
|
-
let pending;
|
|
26
|
-
let failure;
|
|
27
|
-
return () => {
|
|
28
|
-
if (complete)
|
|
29
|
-
return Promise.resolve();
|
|
30
|
-
if (pending)
|
|
31
|
-
return pending;
|
|
32
|
-
// Windows 已观察到树回收失败后,leader 消失也不能抹去未知后代的事实。
|
|
33
|
-
if (process.platform === "win32" &&
|
|
34
|
-
failure &&
|
|
35
|
-
(child.exitCode !== null || child.signalCode !== null))
|
|
36
|
-
return Promise.reject(failure);
|
|
37
|
-
// leader 已退出后,同号 PID 若重新出现就不能再向旧 PGID 发信号。
|
|
38
|
-
// 只在原 PID 仍不存在时确认所属剩余进程组,不扫描或回收其他应用。
|
|
39
|
-
if (process.platform !== "win32" &&
|
|
40
|
-
child.pid !== undefined &&
|
|
41
|
-
(child.exitCode !== null || child.signalCode !== null)) {
|
|
42
|
-
try {
|
|
43
|
-
process.kill(child.pid, 0);
|
|
44
|
-
return Promise.reject(Object.assign(new Error("WORKER_PROCESS_IDENTITY_CONFLICT"), {
|
|
45
|
-
code: "WORKER_PROCESS_IDENTITY_CONFLICT"
|
|
46
|
-
}));
|
|
47
|
-
}
|
|
48
|
-
catch (error) {
|
|
49
|
-
if (error.code !== "ESRCH")
|
|
50
|
-
return Promise.reject(error instanceof Error ? error : new Error("WORKER_IDENTITY_UNKNOWN"));
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
pending = createProcessCleanup(child, {
|
|
54
|
-
processGroup: process.platform !== "win32",
|
|
55
|
-
processTree: true
|
|
56
|
-
})()
|
|
57
|
-
.then(() => {
|
|
58
|
-
complete = true;
|
|
59
|
-
})
|
|
60
|
-
.catch((error) => {
|
|
61
|
-
failure = error instanceof Error ? error : new Error("WORKER_CLEANUP_INCOMPLETE");
|
|
62
|
-
throw error;
|
|
63
|
-
})
|
|
64
|
-
.finally(() => {
|
|
65
|
-
pending = undefined;
|
|
66
|
-
});
|
|
67
|
-
return pending;
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
// Reserve more time for tree cleanup until the worker confirms it has started shutdown.
|
|
71
|
-
// A cooperating worker can use its existing 2.5 s shutdown + 1 s logging bounds.
|
|
72
|
-
const WINDOWS_CLOSE_GRACE_MS = 4_000;
|
|
73
|
-
const WINDOWS_TREE_CLEANUP_RESERVE_MS = 1_900;
|
|
74
|
-
const WINDOWS_COOPERATIVE_CLEANUP_RESERVE_MS = 1_000;
|
|
75
|
-
const closeOptions = new WeakMap();
|
|
76
|
-
/** Kernel 内部传递关闭预算;公开 WorkerProcess.close() 仍然无参数。故障恢复不等待日志排空。 */
|
|
77
|
-
export function closeWorker(worker, until, immediate = false) {
|
|
78
|
-
closeOptions.set(worker, { until, immediate });
|
|
79
|
-
return worker.close();
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* 启动 Node worker,以首次 list RPC 成功作为就绪确认,再返回客户端与进程所有权。
|
|
83
|
-
* 入口/manifest/环境错误在启动阶段携带有界 stderr 抛出;失败路径仍须回收已创建的进程。
|
|
84
|
-
* owner 必须等待 close;清理失败不能当作可安全启动替代 worker 的普通启动错误。
|
|
85
|
-
*/
|
|
86
|
-
export async function spawnWorker({ entrypoint, manifest, adapterModules, env = process.env, signal, onSpawn, readyTimeoutMs = 15_000 }) {
|
|
87
|
-
if (signal?.aborted)
|
|
88
|
-
throw new Error("adapter-host spawn cancelled");
|
|
89
|
-
if (manifest && adapterModules !== undefined)
|
|
90
|
-
throw new TypeError("manifest and adapterModules are mutually exclusive");
|
|
91
|
-
if (!Number.isFinite(readyTimeoutMs) || readyTimeoutMs < 1) {
|
|
92
|
-
throw new Error("adapter-host readyTimeoutMs must be positive");
|
|
93
|
-
}
|
|
94
|
-
// 快照通过已有 Node IPC 发送,不占命令行/环境长度,不落盘;永不序列化模块实例。
|
|
95
|
-
const child = spawn(process.execPath, [
|
|
96
|
-
entrypoint,
|
|
97
|
-
...(manifest ? ["--manifest", manifest] : []),
|
|
98
|
-
...(adapterModules === undefined ? [] : ["--adapters-from-ipc"])
|
|
99
|
-
], {
|
|
100
|
-
argv0: "octo-runtime-executor-kernel",
|
|
101
|
-
env,
|
|
102
|
-
stdio: ["pipe", "pipe", "pipe", "ipc"],
|
|
103
|
-
detached: process.platform !== "win32"
|
|
104
|
-
});
|
|
105
|
-
const cleanup = workerCleanup(child);
|
|
106
|
-
let stderr = "";
|
|
107
|
-
child.stderr.setEncoding("utf8");
|
|
108
|
-
child.stderr.on("data", (value) => {
|
|
109
|
-
// Keep only the tail so a chatty child cannot grow this buffer unbounded.
|
|
110
|
-
stderr = (stderr + value.toString()).slice(-8192);
|
|
111
|
-
});
|
|
112
|
-
const client = new WorkerRpcClient({
|
|
113
|
-
input: child.stdout,
|
|
114
|
-
output: child.stdin
|
|
115
|
-
});
|
|
116
|
-
// S05:spawn error 必须在 readiness 阶段归属本次启动,不能终止宿主。
|
|
117
|
-
// .octospec/tasks/pr1-yujiawei-review/assessment.md
|
|
118
|
-
child.on("error", (error) => client.close(error));
|
|
119
|
-
let adapters;
|
|
120
|
-
try {
|
|
121
|
-
// 先登记进程所有权;快照发送也可能因子进程未读取 IPC 而阻塞,须纳入就绪预算。
|
|
122
|
-
await onSpawn?.(child);
|
|
123
|
-
const initialize = async () => {
|
|
124
|
-
if (adapterModules !== undefined)
|
|
125
|
-
await new Promise((resolve, reject) => {
|
|
126
|
-
child.send({ type: "kernel.adapters", adapters: adapterModules }, (error) => error ? reject(error) : resolve());
|
|
127
|
-
});
|
|
128
|
-
return client.list();
|
|
129
|
-
};
|
|
130
|
-
adapters = await waitForReady(initialize(), readyTimeoutMs, signal);
|
|
131
|
-
}
|
|
132
|
-
catch (error) {
|
|
133
|
-
client.close(error instanceof Error ? error : new Error(errorMessage(error)));
|
|
134
|
-
try {
|
|
135
|
-
await cleanup();
|
|
136
|
-
}
|
|
137
|
-
catch (cleanupError) {
|
|
138
|
-
throw new WorkerCleanupError([error, cleanupError], async () => cleanup(), child.pid);
|
|
139
|
-
}
|
|
140
|
-
throw new Error(`${errorMessage(error)}${stderr ? `: ${stderr}` : ""}`, { cause: error });
|
|
141
|
-
}
|
|
142
|
-
let closing;
|
|
143
|
-
const worker = {
|
|
144
|
-
client,
|
|
145
|
-
child,
|
|
146
|
-
adapters,
|
|
147
|
-
// 关闭 RPC 后等待正常收尾与平台清理;POSIX 不以 leader exit 结束进程组回收。
|
|
148
|
-
// Windows 排空后须保留 leader 到 taskkill;宽限内提前退出不能当作树已清空。
|
|
149
|
-
close() {
|
|
150
|
-
if (closing)
|
|
151
|
-
return closing;
|
|
152
|
-
const { until = Date.now() + 5000, immediate = false } = closeOptions.get(worker) ?? {};
|
|
153
|
-
client.close();
|
|
154
|
-
// Windows 的 kill(SIGTERM) 是强制终止;先用 EOF 触发现有子进程收尾。
|
|
155
|
-
// S02:POSIX 仍回收整个所属进程组,不能只因 leader 退出而跳过 cleanup。
|
|
156
|
-
return (closing = (async () => {
|
|
157
|
-
const drained = process.platform === "win32" && !immediate
|
|
158
|
-
? await endWindowsWorkerInput(child, until)
|
|
159
|
-
: undefined;
|
|
160
|
-
try {
|
|
161
|
-
// 启动回滚与 POSIX 保留共享清理;Windows 正常关闭须验证本次 taskkill 的结果。
|
|
162
|
-
// leader 在通知后退出时,不能再用它的退出状态掩盖 taskkill 未能找到树的错误。
|
|
163
|
-
if (process.platform === "win32" && drained !== "skipped")
|
|
164
|
-
await cleanupWindowsWorker(child, until);
|
|
165
|
-
else
|
|
166
|
-
await cleanup();
|
|
167
|
-
// Reaping the OS tree does not erase an observed Adapter cleanup failure.
|
|
168
|
-
if (drained === "incomplete")
|
|
169
|
-
throw Object.assign(new Error("EXECUTOR_CLEANUP_INCOMPLETE"), {
|
|
170
|
-
code: "EXECUTOR_CLEANUP_INCOMPLETE"
|
|
171
|
-
});
|
|
172
|
-
}
|
|
173
|
-
catch (error) {
|
|
174
|
-
// 普通 close 仍共享首次结果;恢复专用入口重新执行 OS 确认,不复用 rejected Promise。
|
|
175
|
-
throw new WorkerCleanupError([error], async (retryUntil) => {
|
|
176
|
-
if (drained === "incomplete")
|
|
177
|
-
throw error;
|
|
178
|
-
if (process.platform === "win32" && drained !== "skipped")
|
|
179
|
-
await cleanupWindowsWorker(child, retryUntil);
|
|
180
|
-
else
|
|
181
|
-
await cleanup();
|
|
182
|
-
closing = Promise.resolve();
|
|
183
|
-
}, child.pid);
|
|
184
|
-
}
|
|
185
|
-
finally {
|
|
186
|
-
if (process.platform === "win32") {
|
|
187
|
-
// 正常收尾或 fallback 结束后释放本层管道;回收失败仍向调用方传播。
|
|
188
|
-
child.stdin.destroy();
|
|
189
|
-
child.stdout.destroy();
|
|
190
|
-
child.stderr.destroy();
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
})());
|
|
194
|
-
},
|
|
195
|
-
stderr: () => stderr
|
|
196
|
-
};
|
|
197
|
-
return worker;
|
|
198
|
-
}
|
|
199
|
-
/** 只回收本次 worker 的树。命令和退出确认共用截止时间,任何命令错误都保留为回收失败。 */
|
|
200
|
-
async function cleanupWindowsWorker(child, until) {
|
|
201
|
-
const incomplete = (cause) => Object.assign(new Error("PROCESS_TREE_CLEANUP_INCOMPLETE", { cause }), {
|
|
202
|
-
code: "PROCESS_TREE_CLEANUP_INCOMPLETE"
|
|
203
|
-
});
|
|
204
|
-
if (child.pid === undefined || child.exitCode !== null || child.signalCode !== null)
|
|
205
|
-
throw incomplete();
|
|
206
|
-
const remaining = until - Date.now();
|
|
207
|
-
if (remaining <= 0)
|
|
208
|
-
throw incomplete();
|
|
209
|
-
await new Promise((resolve, reject) => {
|
|
210
|
-
execFile("taskkill", ["/PID", String(child.pid), "/T", "/F"], { windowsHide: true, timeout: remaining }, (error) => (error ? reject(incomplete(error)) : resolve()));
|
|
211
|
-
});
|
|
212
|
-
const confirmUntil = Math.min(until, Date.now() + 200);
|
|
213
|
-
while (child.exitCode === null && child.signalCode === null) {
|
|
214
|
-
const left = confirmUntil - Date.now();
|
|
215
|
-
if (left <= 0)
|
|
216
|
-
throw Object.assign(new Error("PROCESS_CLEANUP_TIMEOUT"), {
|
|
217
|
-
code: "PROCESS_CLEANUP_TIMEOUT"
|
|
218
|
-
});
|
|
219
|
-
await delay(Math.min(10, left));
|
|
220
|
-
}
|
|
221
|
-
}
|
|
222
|
-
/** 私有正常关闭阶段:EOF 触发排空,IPC 只确认排空结果,实际进程树仍由 cleanup 回收。 */
|
|
223
|
-
function endWindowsWorkerInput(child, until) {
|
|
224
|
-
if (child.exitCode !== null || child.signalCode !== null || child.stdin.destroyed)
|
|
225
|
-
return Promise.resolve("skipped");
|
|
226
|
-
return new Promise((resolve) => {
|
|
227
|
-
const graceUntil = Math.min(Date.now() + WINDOWS_CLOSE_GRACE_MS, until - WINDOWS_COOPERATIVE_CLEANUP_RESERVE_MS);
|
|
228
|
-
let settled = false;
|
|
229
|
-
const finish = (result) => {
|
|
230
|
-
if (settled)
|
|
231
|
-
return;
|
|
232
|
-
settled = true;
|
|
233
|
-
clearTimeout(timer);
|
|
234
|
-
child.off("close", fallback);
|
|
235
|
-
child.off("error", fallback);
|
|
236
|
-
child.stdin.off("error", fallback);
|
|
237
|
-
child.off("message", onMessage);
|
|
238
|
-
resolve(result);
|
|
239
|
-
};
|
|
240
|
-
const fallback = () => finish("fallback");
|
|
241
|
-
const onMessage = (message) => {
|
|
242
|
-
if (!message || typeof message !== "object" || !("type" in message))
|
|
243
|
-
return;
|
|
244
|
-
if (message.type === "worker.stopping") {
|
|
245
|
-
// This is progress, not cleanup success. Repeated messages never extend the deadline.
|
|
246
|
-
clearTimeout(timer);
|
|
247
|
-
timer = setTimeout(fallback, Math.max(0, graceUntil - Date.now()));
|
|
248
|
-
return;
|
|
249
|
-
}
|
|
250
|
-
if (message.type === "worker.drained" &&
|
|
251
|
-
"cleanup" in message &&
|
|
252
|
-
(message.cleanup === "complete" || message.cleanup === "incomplete"))
|
|
253
|
-
finish(message.cleanup);
|
|
254
|
-
};
|
|
255
|
-
let timer = setTimeout(fallback, Math.max(0, Math.min(graceUntil, until - WINDOWS_TREE_CLEANUP_RESERVE_MS) - Date.now()));
|
|
256
|
-
// 先监听再发送 EOF;worker 排空后仍存活,输出在通知/超时前持续消费。
|
|
257
|
-
child.once("close", fallback);
|
|
258
|
-
child.once("error", fallback);
|
|
259
|
-
child.stdin.once("error", fallback);
|
|
260
|
-
child.on("message", onMessage);
|
|
261
|
-
try {
|
|
262
|
-
child.stdin.end();
|
|
263
|
-
}
|
|
264
|
-
catch {
|
|
265
|
-
// EPIPE 等故障不新增公开错误合同;真正的回收失败仍由 cleanup 抛出。
|
|
266
|
-
fallback();
|
|
267
|
-
}
|
|
268
|
-
});
|
|
269
|
-
}
|
|
270
|
-
function waitForReady(operation, timeoutMs, signal) {
|
|
271
|
-
return new Promise((resolve, reject) => {
|
|
272
|
-
let settled = false;
|
|
273
|
-
const finish = (callback) => {
|
|
274
|
-
if (settled)
|
|
275
|
-
return;
|
|
276
|
-
settled = true;
|
|
277
|
-
clearTimeout(timer);
|
|
278
|
-
signal?.removeEventListener("abort", onAbort);
|
|
279
|
-
callback();
|
|
280
|
-
};
|
|
281
|
-
const onAbort = () => finish(() => reject(new Error("adapter-host spawn cancelled")));
|
|
282
|
-
const timer = setTimeout(() => finish(() => reject(new Error(`adapter-host readiness timed out after ${timeoutMs}ms`))), timeoutMs);
|
|
283
|
-
signal?.addEventListener("abort", onAbort, { once: true });
|
|
284
|
-
operation.then((value) => finish(() => resolve(value)), (error) => finish(() => reject(error instanceof Error ? error : new Error(errorMessage(error)))));
|
|
285
|
-
// 即使 onSpawn 期间已取消,也必须观察已创建的 RPC,避免回滚触发未处理拒绝。
|
|
286
|
-
if (signal?.aborted)
|
|
287
|
-
onAbort();
|
|
288
|
-
});
|
|
289
|
-
}
|
|
290
|
-
function errorMessage(error) {
|
|
291
|
-
return error instanceof Error ? error.message : String(error);
|
|
292
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import type { Readable, Writable } from "node:stream";
|
|
2
|
-
import { type RuntimeLog, type AdapterProbeOptions } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
3
|
-
import { type InputFrames, type InvokeInput, type InvokeEnvironment, type InputInvoke, type HostFrame, type NativeInteractionResponse, type InteractionResponse } from "@mininglamp-oss/octo-runtime-protocol";
|
|
4
|
-
import type { AgentExecutor, HostedAdapterMetadata } from "@mininglamp-oss/octo-runtime-executor-core";
|
|
5
|
-
type JsonRecord = Record<string, unknown>;
|
|
6
|
-
export type RpcTraceDirection = "send" | "receive";
|
|
7
|
-
export type RpcTrace = (direction: RpcTraceDirection, frame: string) => void;
|
|
8
|
-
/** Kernel 到 worker 的内部执行合同;取消回执 cancelled 由外层 RPC 映射为 accepted,均不表示终态。 */
|
|
9
|
-
export interface WorkerRpc {
|
|
10
|
-
list(configurations?: Record<string, AdapterProbeOptions>): Promise<HostedAdapterMetadata[]>;
|
|
11
|
-
probe(adapterType: string, options?: AdapterProbeOptions): Promise<unknown>;
|
|
12
|
-
cancel(invocationId: string, reason?: string): Promise<{
|
|
13
|
-
cancelled: boolean;
|
|
14
|
-
}>;
|
|
15
|
-
respondInteraction(invocationId: string, response: InteractionResponse): Promise<void>;
|
|
16
|
-
respondNative(invocationId: string, response: NativeInteractionResponse): Promise<void>;
|
|
17
|
-
invoke: InputInvoke;
|
|
18
|
-
invokeFrames: InputFrames;
|
|
19
|
-
}
|
|
20
|
-
/**
|
|
21
|
-
* 在 worker 中将唯一 AgentExecutor 暴露为 stdio NDJSON JSON-RPC 服务。
|
|
22
|
-
* 普通方法是一问一答;invoke 先返回接纳凭据,再发送通知流,不与 Kernel 对外 socket 协议混用。
|
|
23
|
-
*/
|
|
24
|
-
export declare class WorkerRpcServer {
|
|
25
|
-
#private;
|
|
26
|
-
constructor({ host, output, trace, log }: {
|
|
27
|
-
host: AgentExecutor;
|
|
28
|
-
output: Writable;
|
|
29
|
-
trace?: RpcTrace;
|
|
30
|
-
log?: RuntimeLog;
|
|
31
|
-
});
|
|
32
|
-
/** Start consuming the input stream; each line must be one complete JSON-RPC object. */
|
|
33
|
-
listen(input: Readable): void;
|
|
34
|
-
}
|
|
35
|
-
/**
|
|
36
|
-
* Kernel 持有的 worker RPC 客户端,将按身份校验的通知还原为有界异步流。
|
|
37
|
-
* 这里只管理逻辑请求与流;进程存活、心跳和回收由 WorkerSupervisor/WorkerProcess 负责。
|
|
38
|
-
*/
|
|
39
|
-
export declare class WorkerRpcClient implements WorkerRpc {
|
|
40
|
-
#private;
|
|
41
|
-
readonly invoke: InputInvoke;
|
|
42
|
-
constructor({ input, output, trace, maximumInputBytes }: {
|
|
43
|
-
input: Readable;
|
|
44
|
-
output: Writable;
|
|
45
|
-
trace?: RpcTrace;
|
|
46
|
-
maximumInputBytes?: number;
|
|
47
|
-
});
|
|
48
|
-
/** Send an ordinary JSON-RPC request and await the matching response by random ID. */
|
|
49
|
-
request<T = unknown>(method: string, params?: JsonRecord, signal?: AbortSignal): Promise<T>;
|
|
50
|
-
/** 用同一故障结束所有逻辑请求/流;不终止进程,owner 仍须调用 WorkerProcess.close。 */
|
|
51
|
-
close(error?: Error): void;
|
|
52
|
-
list(configurations?: Record<string, AdapterProbeOptions>): Promise<HostedAdapterMetadata[]>;
|
|
53
|
-
probe(adapterType: string, options?: AdapterProbeOptions): Promise<unknown>;
|
|
54
|
-
cancel(invocationId: string, reason?: string): Promise<{
|
|
55
|
-
cancelled: boolean;
|
|
56
|
-
}>;
|
|
57
|
-
respondInteraction(invocationId: string, response: InteractionResponse): Promise<void>;
|
|
58
|
-
respondNative(invocationId: string, response: NativeInteractionResponse): Promise<void>;
|
|
59
|
-
/** Await the invoke ACK first, then keep yielding this invocation's event notifications until done. */
|
|
60
|
-
invokeFrames(input: InvokeInput, environment?: InvokeEnvironment): AsyncGenerator<HostFrame>;
|
|
61
|
-
}
|
|
62
|
-
/** Kernel 配置与 worker 探测共用的配置形态校验;不修改调用方对象。 */
|
|
63
|
-
export declare function probeOptions(value: unknown): AdapterProbeOptions | undefined;
|
|
64
|
-
export {};
|