@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
package/README.md
CHANGED
|
@@ -20,7 +20,7 @@ octo-runtime logs --lines 200 --follow
|
|
|
20
20
|
|
|
21
21
|
Applications consuming an existing Kernel install `@mininglamp-oss/octo-runtime-client` and call `attachKernel({endpoint})`. Protocol types and helpers come from `/protocol`. Owners drain their accepted invocations and finish business delivery before closing their client; closing a connection does not stop the Kernel.
|
|
22
22
|
|
|
23
|
-
|
|
23
|
+
Native applications owning an execution service integrate Kernel/Core, shared helpers and selected Adapters from source workspace, then construct `createKernelService({home, endpoint, adapters})`. Declare only the Adapter dependencies that the product needs; the CLI package exposes no Adapter aggregate entries. See [SDK integration](docs/en/getting-started/sdk.md). Explicit direct Core remains an advanced choice with host-owned lifecycle.
|
|
24
24
|
|
|
25
25
|
## Channel Gateway
|
|
26
26
|
|
|
@@ -1,7 +1,25 @@
|
|
|
1
1
|
import { type AdapterModuleEntry } from "@mininglamp-oss/octo-runtime-adapter-sdk/module-manifest";
|
|
2
2
|
import type { HostedAdapter } from "@mininglamp-oss/octo-runtime-executor-kernel";
|
|
3
|
+
import { type ServiceCleanupResult } from "@mininglamp-oss/octo-runtime-executor-kernel";
|
|
4
|
+
import type { AdapterScopeCleanup, ServiceProcessSnapshot } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
5
|
+
/** CLI 默认每种 Harness 一个自有实例;工厂不按调用分池,SDK 自管装配不受此约定限制。 */
|
|
6
|
+
export interface CliAdapterResource {
|
|
7
|
+
adapter: HostedAdapter;
|
|
8
|
+
processes?(): readonly ServiceProcessSnapshot[];
|
|
9
|
+
beginShutdown?(): void;
|
|
10
|
+
close(deadline: number): Promise<AdapterScopeCleanup>;
|
|
11
|
+
}
|
|
12
|
+
export interface CliAdapters {
|
|
13
|
+
adapters: HostedAdapter[];
|
|
14
|
+
processes(): readonly ServiceProcessSnapshot[];
|
|
15
|
+
beginShutdown(): void;
|
|
16
|
+
close(deadline: number): Promise<AdapterScopeCleanup>;
|
|
17
|
+
}
|
|
3
18
|
/** CLI 只加载所选模块并构造实例;Kernel 不接触清单、模块路径或产品准备。 */
|
|
4
19
|
export declare function loadCliAdapters(entries: readonly AdapterModuleEntry[], options?: {
|
|
5
20
|
profileRoot: string;
|
|
6
21
|
syncOpenClawTools: boolean;
|
|
7
|
-
|
|
22
|
+
env?: NodeJS.ProcessEnv;
|
|
23
|
+
}): Promise<CliAdapters>;
|
|
24
|
+
/** 将宿主资源清理事实投影到既有启动诊断;主失败与 pending/failed 资源分别保留。 */
|
|
25
|
+
export declare function cliCleanupResult(cleanup: AdapterScopeCleanup): ServiceCleanupResult;
|
|
@@ -1,41 +1,166 @@
|
|
|
1
1
|
import { resolveModuleSpecifier } from "@mininglamp-oss/octo-runtime-adapter-sdk/module-manifest";
|
|
2
|
-
import { withStartupContext } from "@mininglamp-oss/octo-runtime-executor-kernel";
|
|
2
|
+
import { withStartupContext, ServiceInitializationError } from "@mininglamp-oss/octo-runtime-executor-kernel";
|
|
3
3
|
/** CLI 只加载所选模块并构造实例;Kernel 不接触清单、模块路径或产品准备。 */
|
|
4
4
|
export async function loadCliAdapters(entries, options) {
|
|
5
5
|
const adapters = [];
|
|
6
|
+
const resources = [];
|
|
7
|
+
const pending = new Map();
|
|
8
|
+
const completed = new Map();
|
|
9
|
+
const types = new Set();
|
|
10
|
+
const assembly = {
|
|
11
|
+
adapters,
|
|
12
|
+
processes: () => resources.flatMap((r) => [...(r.processes?.() ?? [])]),
|
|
13
|
+
beginShutdown() {
|
|
14
|
+
const errors = [];
|
|
15
|
+
for (const resource of resources) {
|
|
16
|
+
try {
|
|
17
|
+
resource.beginShutdown?.();
|
|
18
|
+
}
|
|
19
|
+
catch (error) {
|
|
20
|
+
errors.push(error);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
if (errors.length)
|
|
24
|
+
throw new AggregateError(errors, "CLI_ENGINE_SHUTDOWN_FAILED");
|
|
25
|
+
},
|
|
26
|
+
async close(deadline) {
|
|
27
|
+
if (!Number.isFinite(deadline))
|
|
28
|
+
throw new TypeError("CLEANUP_DEADLINE_INVALID");
|
|
29
|
+
// 按构造逆序释放依赖;每个 disposer 只启动一次,到期仍尝试其余独立资源。
|
|
30
|
+
for (const [index, resource] of [...resources.entries()].reverse()) {
|
|
31
|
+
if (!pending.has(resource)) {
|
|
32
|
+
pending.set(resource, Promise.resolve()
|
|
33
|
+
.then(() => resource.close(deadline))
|
|
34
|
+
.then((result) => {
|
|
35
|
+
// JS 工厂可能违反类型合同;坏结果也必须成为清理失败,不能打断其他 disposer。
|
|
36
|
+
if (!isScopeCleanup(result))
|
|
37
|
+
throw new TypeError("CLI_RESOURCE_CLEANUP_INVALID");
|
|
38
|
+
completed.set(resource, !result.complete && !result.unresolvedServiceIds.length
|
|
39
|
+
? { ...result, unresolvedServiceIds: [`cli-adapter-${index}`] }
|
|
40
|
+
: result);
|
|
41
|
+
})
|
|
42
|
+
.catch(() => {
|
|
43
|
+
completed.set(resource, {
|
|
44
|
+
complete: false,
|
|
45
|
+
unresolvedServiceIds: [`cli-adapter-${index}`],
|
|
46
|
+
failedCleanupServiceIds: [`cli-adapter-${index}`]
|
|
47
|
+
});
|
|
48
|
+
}));
|
|
49
|
+
}
|
|
50
|
+
let timer;
|
|
51
|
+
if (performance.now() >= deadline) {
|
|
52
|
+
await Promise.resolve();
|
|
53
|
+
continue;
|
|
54
|
+
}
|
|
55
|
+
try {
|
|
56
|
+
await Promise.race([
|
|
57
|
+
pending.get(resource),
|
|
58
|
+
new Promise((done) => {
|
|
59
|
+
timer = setTimeout(done, Math.max(0, deadline - performance.now()));
|
|
60
|
+
})
|
|
61
|
+
]);
|
|
62
|
+
}
|
|
63
|
+
finally {
|
|
64
|
+
clearTimeout(timer);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
const results = resources.map((resource, index) => completed.get(resource) ?? {
|
|
68
|
+
complete: false,
|
|
69
|
+
unresolvedServiceIds: [`cli-adapter-${index}`],
|
|
70
|
+
failedCleanupServiceIds: []
|
|
71
|
+
});
|
|
72
|
+
return {
|
|
73
|
+
complete: results.every((r) => r.complete && !r.unresolvedServiceIds.length && !r.failedCleanupServiceIds.length),
|
|
74
|
+
unresolvedServiceIds: results.flatMap((r) => [...r.unresolvedServiceIds]),
|
|
75
|
+
failedCleanupServiceIds: results.flatMap((r) => [...r.failedCleanupServiceIds])
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
};
|
|
6
79
|
// 解析也在诊断边界内;仍先解析整个所选集合,再导入/构造,保持 CLI 原顺序。
|
|
80
|
+
const declaredTypes = new Set();
|
|
7
81
|
const selected = entries.map((entry) => {
|
|
8
82
|
try {
|
|
83
|
+
// 已声明类型在任何工厂运行前拒绝重复,避免先创建第二个受管 Harness。
|
|
84
|
+
if (entry.type) {
|
|
85
|
+
if (declaredTypes.has(entry.type))
|
|
86
|
+
throw new Error(`CLI_HARNESS_TYPE_DUPLICATE: ${entry.type}`);
|
|
87
|
+
declaredTypes.add(entry.type);
|
|
88
|
+
}
|
|
9
89
|
return { entry, specifier: resolveModuleSpecifier(entry.module, entry.sourceManifest) };
|
|
10
90
|
}
|
|
11
91
|
catch (error) {
|
|
12
92
|
throw adapterStartupFailure(error, entry);
|
|
13
93
|
}
|
|
14
94
|
});
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
95
|
+
try {
|
|
96
|
+
for (const { entry, specifier } of selected) {
|
|
97
|
+
try {
|
|
98
|
+
const loaded = await import(specifier);
|
|
99
|
+
const exports = asRecord(loaded, `adapter module ${entry.module}`);
|
|
100
|
+
const exported = exports[entry.export];
|
|
101
|
+
if (exported === undefined)
|
|
102
|
+
throw new Error(`missing export ${entry.export} from ${entry.module}`);
|
|
103
|
+
// 动态模块先校验工厂与 Adapter 形状,再交给唯一 Core 注册;不提前探测未选模块。
|
|
104
|
+
const constructed = entry.factory
|
|
105
|
+
? await callFactory(exported, entry, options?.env ?? process.env)
|
|
106
|
+
: exported;
|
|
107
|
+
const resource = isRecord(constructed) &&
|
|
108
|
+
typeof constructed.close === "function" &&
|
|
109
|
+
"adapter" in constructed
|
|
110
|
+
? constructed
|
|
111
|
+
: undefined;
|
|
112
|
+
if (resource)
|
|
113
|
+
resources.push(resource);
|
|
114
|
+
const instance = resource ? resource.adapter : constructed;
|
|
115
|
+
if (!isHostedAdapter(instance))
|
|
116
|
+
throw new TypeError(`${entry.module}#${entry.export} is not an Octo Runtime adapter`);
|
|
117
|
+
if (entry.type && instance.metadata.type !== entry.type)
|
|
118
|
+
throw new Error(`manifest type ${entry.type} does not match adapter ${instance.metadata.type}`);
|
|
119
|
+
if (types.has(instance.metadata.type))
|
|
120
|
+
throw new Error(`CLI_HARNESS_TYPE_DUPLICATE: ${instance.metadata.type}`);
|
|
121
|
+
types.add(instance.metadata.type);
|
|
122
|
+
adapters.push(instance);
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
throw adapterStartupFailure(error, entry);
|
|
126
|
+
}
|
|
29
127
|
}
|
|
30
|
-
|
|
31
|
-
|
|
128
|
+
if (options && adapters.some((adapter) => adapter.metadata.type === "openclaw")) {
|
|
129
|
+
const { initializeCliOpenClaw } = await import("./openclaw.js");
|
|
130
|
+
await initializeCliOpenClaw(options.profileRoot);
|
|
32
131
|
}
|
|
132
|
+
return assembly;
|
|
33
133
|
}
|
|
34
|
-
|
|
35
|
-
const
|
|
36
|
-
|
|
134
|
+
catch (error) {
|
|
135
|
+
const cleanup = await assembly.close(performance.now() + 2500);
|
|
136
|
+
if (!cleanup.complete)
|
|
137
|
+
throw new ServiceInitializationError(error, cliCleanupResult(cleanup), {
|
|
138
|
+
component: "cli",
|
|
139
|
+
phase: "created"
|
|
140
|
+
});
|
|
141
|
+
throw error;
|
|
37
142
|
}
|
|
38
|
-
|
|
143
|
+
}
|
|
144
|
+
/** 将宿主资源清理事实投影到既有启动诊断;主失败与 pending/failed 资源分别保留。 */
|
|
145
|
+
export function cliCleanupResult(cleanup) {
|
|
146
|
+
const complete = cleanup.complete &&
|
|
147
|
+
!cleanup.unresolvedServiceIds.length &&
|
|
148
|
+
!cleanup.failedCleanupServiceIds.length;
|
|
149
|
+
return {
|
|
150
|
+
complete,
|
|
151
|
+
errors: complete
|
|
152
|
+
? []
|
|
153
|
+
: [
|
|
154
|
+
{ resource: "engines", code: "ENGINE_CLEANUP_INCOMPLETE" },
|
|
155
|
+
...cleanup.failedCleanupServiceIds.map((resource) => ({
|
|
156
|
+
resource,
|
|
157
|
+
code: "ENGINE_CLEANUP_FAILED"
|
|
158
|
+
}))
|
|
159
|
+
],
|
|
160
|
+
pendingResources: [
|
|
161
|
+
...new Set([...cleanup.unresolvedServiceIds, ...cleanup.failedCleanupServiceIds])
|
|
162
|
+
]
|
|
163
|
+
};
|
|
39
164
|
}
|
|
40
165
|
function adapterStartupFailure(error, entry) {
|
|
41
166
|
return withStartupContext(error, {
|
|
@@ -49,19 +174,20 @@ function adapterStartupFailure(error, entry) {
|
|
|
49
174
|
}
|
|
50
175
|
});
|
|
51
176
|
}
|
|
52
|
-
function callFactory(value, entry) {
|
|
177
|
+
function callFactory(value, entry, env) {
|
|
53
178
|
if (typeof value !== "function")
|
|
54
179
|
throw new TypeError(`${entry.module}#${entry.export} is marked as a factory but is not callable`);
|
|
55
|
-
return value(entry.options);
|
|
180
|
+
return value(entry.options, { env });
|
|
56
181
|
}
|
|
57
182
|
function isHostedAdapter(value) {
|
|
58
183
|
if (!isRecord(value) || !isRecord(value.metadata))
|
|
59
184
|
return false;
|
|
60
|
-
return
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
185
|
+
return typeof value.metadata.type === "string" && typeof value.invoke === "function";
|
|
186
|
+
}
|
|
187
|
+
function isScopeCleanup(value) {
|
|
188
|
+
if (!isRecord(value) || typeof value.complete !== "boolean")
|
|
189
|
+
return false;
|
|
190
|
+
return [value.unresolvedServiceIds, value.failedCleanupServiceIds].every((ids) => Array.isArray(ids) && ids.every((id) => typeof id === "string"));
|
|
65
191
|
}
|
|
66
192
|
function asRecord(value, label) {
|
|
67
193
|
if (!isRecord(value))
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { homedir } from "node:os";
|
|
2
|
+
import { join } from "node:path";
|
|
3
|
+
import { createCodexAdapter, codexMetadata, createManagedCodexEngine } from "@mininglamp-oss/octo-runtime-adapter-codex";
|
|
4
|
+
import { processEnvironmentValue } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
5
|
+
import { cliProviderLaunch, unavailableCliAdapter } from "./provider-launch.js";
|
|
6
|
+
/** CLI 在实际服务进程选择默认 Home 并持有 owner;库和 Adapter 不决定目录生命周期。 */
|
|
7
|
+
export function createCliCodexAdapter(options, context) {
|
|
8
|
+
const codexHome = options.codexHome ??
|
|
9
|
+
processEnvironmentValue(context.env, "CODEX_HOME") ??
|
|
10
|
+
join(homedir(), ".codex");
|
|
11
|
+
if (typeof codexHome !== "string" ||
|
|
12
|
+
(options.command !== undefined && typeof options.command !== "string") ||
|
|
13
|
+
(options.appServerArgs !== undefined &&
|
|
14
|
+
(!Array.isArray(options.appServerArgs) ||
|
|
15
|
+
!options.appServerArgs.every((v) => typeof v === "string"))))
|
|
16
|
+
throw new TypeError("CODEX_CONFIGURATION_INVALID");
|
|
17
|
+
const selected = cliProviderLaunch(options, context.env, "codex");
|
|
18
|
+
if (!selected.launch)
|
|
19
|
+
return {
|
|
20
|
+
adapter: unavailableCliAdapter(codexMetadata, selected.reason, selected.command),
|
|
21
|
+
close: () => Promise.resolve({ complete: true, unresolvedServiceIds: [], failedCleanupServiceIds: [] })
|
|
22
|
+
};
|
|
23
|
+
const owner = createManagedCodexEngine({
|
|
24
|
+
codexHome,
|
|
25
|
+
env: selected.launch.env,
|
|
26
|
+
command: selected.launch.command,
|
|
27
|
+
commandArgsPrefix: selected.launch.args,
|
|
28
|
+
appServerArgs: options.appServerArgs
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
adapter: createCodexAdapter({ engine: owner.provider }),
|
|
32
|
+
processes: () => owner.processes(),
|
|
33
|
+
beginShutdown: () => owner.beginShutdown(),
|
|
34
|
+
close: (deadline) => owner.close({ deadline })
|
|
35
|
+
};
|
|
36
|
+
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type KernelService, type KernelServiceOptions } from "@mininglamp-oss/octo-runtime-executor-kernel";
|
|
2
|
+
import { type CliAdapters } from "./adapters.js";
|
|
3
|
+
/** CLI 显式拥有装配资源;Kernel 只关闭自身调用,最后由此宿主关闭 Engine owner。 */
|
|
4
|
+
export declare function createCliKernelService(options: Omit<KernelServiceOptions, "adapters">, assembly: CliAdapters): Promise<KernelService>;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { createKernelService, ServiceInitializationError } from "@mininglamp-oss/octo-runtime-executor-kernel";
|
|
2
|
+
import { cliCleanupResult } from "./adapters.js";
|
|
3
|
+
/** CLI 显式拥有装配资源;Kernel 只关闭自身调用,最后由此宿主关闭 Engine owner。 */
|
|
4
|
+
export async function createCliKernelService(options, assembly) {
|
|
5
|
+
let kernel;
|
|
6
|
+
try {
|
|
7
|
+
kernel = createKernelService({
|
|
8
|
+
...options,
|
|
9
|
+
adapters: assembly.adapters,
|
|
10
|
+
serviceProcesses: () => assembly.processes(),
|
|
11
|
+
async finalizeHostResources(deadline) {
|
|
12
|
+
const cleanup = await assembly.close(deadline);
|
|
13
|
+
if (!cleanup.complete)
|
|
14
|
+
throw new Error("ENGINE_CLEANUP_INCOMPLETE", { cause: cleanup });
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
catch (error) {
|
|
19
|
+
const result = await assembly.close(performance.now() + 2500);
|
|
20
|
+
if (!result.complete)
|
|
21
|
+
throw new ServiceInitializationError(error, cliCleanupResult(result), {
|
|
22
|
+
component: "cli",
|
|
23
|
+
phase: "created"
|
|
24
|
+
});
|
|
25
|
+
throw error;
|
|
26
|
+
}
|
|
27
|
+
let closing;
|
|
28
|
+
let finish;
|
|
29
|
+
const closed = new Promise((resolve) => {
|
|
30
|
+
finish = resolve;
|
|
31
|
+
});
|
|
32
|
+
const close = () => (closing ??= (async () => {
|
|
33
|
+
const deadline = performance.now() + 5000;
|
|
34
|
+
const errors = [];
|
|
35
|
+
const pendingResources = [];
|
|
36
|
+
let cleanupError;
|
|
37
|
+
try {
|
|
38
|
+
assembly.beginShutdown();
|
|
39
|
+
}
|
|
40
|
+
catch {
|
|
41
|
+
errors.push({ resource: "engines", code: "ENGINE_SHUTDOWN_FAILED" });
|
|
42
|
+
}
|
|
43
|
+
try {
|
|
44
|
+
const result = await kernel.close();
|
|
45
|
+
errors.push(...result.errors);
|
|
46
|
+
pendingResources.push(...result.pendingResources);
|
|
47
|
+
if (!result.complete && !result.errors.length)
|
|
48
|
+
errors.push({ resource: "kernel", code: "KERNEL_CLEANUP_INCOMPLETE" });
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
cleanupError = error;
|
|
52
|
+
errors.push({ resource: "kernel", code: "KERNEL_CLEANUP_INCOMPLETE" });
|
|
53
|
+
}
|
|
54
|
+
const engines = await assembly.close(deadline);
|
|
55
|
+
const engineCleanup = cliCleanupResult(engines);
|
|
56
|
+
errors.push(...engineCleanup.errors);
|
|
57
|
+
pendingResources.push(...engineCleanup.pendingResources);
|
|
58
|
+
const result = { complete: !errors.length, errors, pendingResources };
|
|
59
|
+
finish(result);
|
|
60
|
+
if (cleanupError)
|
|
61
|
+
throw cleanupError instanceof Error
|
|
62
|
+
? cleanupError
|
|
63
|
+
: new Error("KERNEL_CLEANUP_INCOMPLETE", { cause: cleanupError });
|
|
64
|
+
return result;
|
|
65
|
+
})());
|
|
66
|
+
void kernel.closed.then(() => close()).catch(() => { });
|
|
67
|
+
// initialize 自身失败也走统一 disposer;保留主原因和所有独立清理事实。
|
|
68
|
+
return {
|
|
69
|
+
get client() {
|
|
70
|
+
return kernel.client;
|
|
71
|
+
},
|
|
72
|
+
async initialize(options) {
|
|
73
|
+
try {
|
|
74
|
+
await kernel.initialize(options);
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
throw new ServiceInitializationError(error, await close().catch(() => closed));
|
|
78
|
+
}
|
|
79
|
+
},
|
|
80
|
+
status: () => kernel.status(),
|
|
81
|
+
close,
|
|
82
|
+
closed
|
|
83
|
+
};
|
|
84
|
+
}
|
package/apps/cli/dist/main.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { loadCliAdapters } from "./adapters.js";
|
|
2
|
+
import { createCliKernelService } from "./kernel.js";
|
|
2
3
|
import { once } from "node:events";
|
|
3
4
|
import { join, resolve } from "node:path";
|
|
4
|
-
import { attachKernel, acknowledgeOrphanCleanup, inspectOrphanCleanup,
|
|
5
|
+
import { attachKernel, acknowledgeOrphanCleanup, inspectOrphanCleanup, safeStartupValue } from "@mininglamp-oss/octo-runtime-executor-kernel";
|
|
5
6
|
import { componentEndpoint, validateRuntimeHome, RuntimeHomeError } from "@mininglamp-oss/octo-runtime-host-sdk";
|
|
6
7
|
import { cliVersionInfo, lifecycleCommands } from "./help.js";
|
|
7
8
|
import { parseCliCommand } from "./command-tree.js";
|
|
@@ -230,17 +231,17 @@ export async function runCli(args, dependencies = {}) {
|
|
|
230
231
|
let handle;
|
|
231
232
|
{
|
|
232
233
|
const config = await readJsonFile(paths.profileConfig);
|
|
233
|
-
handle =
|
|
234
|
+
handle = await createCliKernelService({
|
|
234
235
|
home,
|
|
235
236
|
logging: { directory: join(home, "logs") },
|
|
236
237
|
endpoint: kernelEndpoint(),
|
|
237
238
|
stateDirectory: kernelStateDirectory,
|
|
238
|
-
adapters: await loadCliAdapters(manifest.adapters, {
|
|
239
|
-
profileRoot: paths.profileRoot,
|
|
240
|
-
syncOpenClawTools: true
|
|
241
|
-
}),
|
|
242
239
|
adapterConfigurations: await readCliAdapterConfigurations(paths.profileRoot, config?.adapters, manifest, dependencies.env ?? process.env)
|
|
243
|
-
}
|
|
240
|
+
}, await loadCliAdapters(manifest.adapters, {
|
|
241
|
+
profileRoot: paths.profileRoot,
|
|
242
|
+
syncOpenClawTools: true,
|
|
243
|
+
env: dependencies.env ?? process.env
|
|
244
|
+
}));
|
|
244
245
|
}
|
|
245
246
|
return await runForegroundService(handle, () => publish({ component, state: "ready" }, `${component}: ready`), async (error) => {
|
|
246
247
|
try {
|
|
@@ -8,43 +8,51 @@
|
|
|
8
8
|
},
|
|
9
9
|
{
|
|
10
10
|
"type": "codex",
|
|
11
|
-
"module": "
|
|
12
|
-
"export": "
|
|
11
|
+
"module": "./codex.js",
|
|
12
|
+
"export": "createCliCodexAdapter",
|
|
13
|
+
"factory": true
|
|
13
14
|
},
|
|
14
15
|
{
|
|
15
16
|
"type": "claude-code",
|
|
16
|
-
"module": "
|
|
17
|
-
"export": "
|
|
17
|
+
"module": "./providers.js",
|
|
18
|
+
"export": "createCliClaudeCodeAdapter",
|
|
19
|
+
"factory": true
|
|
18
20
|
},
|
|
19
21
|
{
|
|
20
22
|
"type": "codebuddy",
|
|
21
|
-
"module": "
|
|
22
|
-
"export": "
|
|
23
|
+
"module": "./providers.js",
|
|
24
|
+
"export": "createCliCodeBuddyAdapter",
|
|
25
|
+
"factory": true
|
|
23
26
|
},
|
|
24
27
|
{
|
|
25
28
|
"type": "grok-build",
|
|
26
|
-
"module": "
|
|
27
|
-
"export": "
|
|
29
|
+
"module": "./providers.js",
|
|
30
|
+
"export": "createCliGrokBuildAdapter",
|
|
31
|
+
"factory": true
|
|
28
32
|
},
|
|
29
33
|
{
|
|
30
34
|
"type": "hermes",
|
|
31
|
-
"module": "
|
|
32
|
-
"export": "
|
|
35
|
+
"module": "./providers.js",
|
|
36
|
+
"export": "createCliHermesAdapter",
|
|
37
|
+
"factory": true
|
|
33
38
|
},
|
|
34
39
|
{
|
|
35
40
|
"type": "kimi-code",
|
|
36
|
-
"module": "
|
|
37
|
-
"export": "
|
|
41
|
+
"module": "./providers.js",
|
|
42
|
+
"export": "createCliKimiCodeAdapter",
|
|
43
|
+
"factory": true
|
|
38
44
|
},
|
|
39
45
|
{
|
|
40
46
|
"type": "mcode",
|
|
41
|
-
"module": "
|
|
42
|
-
"export": "
|
|
47
|
+
"module": "./providers.js",
|
|
48
|
+
"export": "createCliMcodeAdapter",
|
|
49
|
+
"factory": true
|
|
43
50
|
},
|
|
44
51
|
{
|
|
45
52
|
"type": "opencode",
|
|
46
|
-
"module": "
|
|
47
|
-
"export": "
|
|
53
|
+
"module": "./providers.js",
|
|
54
|
+
"export": "createCliOpenCodeAdapter",
|
|
55
|
+
"factory": true
|
|
48
56
|
},
|
|
49
57
|
{
|
|
50
58
|
"type": "openclaw",
|
|
@@ -53,18 +61,21 @@
|
|
|
53
61
|
},
|
|
54
62
|
{
|
|
55
63
|
"type": "qodercli",
|
|
56
|
-
"module": "
|
|
57
|
-
"export": "
|
|
64
|
+
"module": "./providers.js",
|
|
65
|
+
"export": "createCliQoderCliAdapter",
|
|
66
|
+
"factory": true
|
|
58
67
|
},
|
|
59
68
|
{
|
|
60
69
|
"type": "qoderclicn",
|
|
61
|
-
"module": "
|
|
62
|
-
"export": "
|
|
70
|
+
"module": "./providers.js",
|
|
71
|
+
"export": "createCliQoderCliCnAdapter",
|
|
72
|
+
"factory": true
|
|
63
73
|
},
|
|
64
74
|
{
|
|
65
75
|
"type": "antigravity",
|
|
66
|
-
"module": "
|
|
67
|
-
"export": "
|
|
76
|
+
"module": "./providers.js",
|
|
77
|
+
"export": "createCliAntigravityAdapter",
|
|
78
|
+
"factory": true
|
|
68
79
|
}
|
|
69
80
|
]
|
|
70
81
|
}
|
|
@@ -12,6 +12,7 @@ export interface ResidentProcessView {
|
|
|
12
12
|
observation: string;
|
|
13
13
|
service_id?: string;
|
|
14
14
|
incarnation?: number;
|
|
15
|
+
ownership?: string;
|
|
15
16
|
}
|
|
16
17
|
/** doctor 仅投影已取得的常驻快照;同 PID 合并角色,层级表示所有权而非猜测 OS PPID。 */
|
|
17
18
|
export declare function residentProcesses(snapshots: Record<string, ComponentSnapshot>): ResidentProcessView[];
|
package/apps/cli/dist/output.js
CHANGED
|
@@ -28,7 +28,7 @@ export function residentProcesses(snapshots) {
|
|
|
28
28
|
const managedPid = pid(snapshot.service.pid);
|
|
29
29
|
add({
|
|
30
30
|
...(actualPid || managedPid ? { pid: actualPid ?? managedPid } : {}),
|
|
31
|
-
roles:
|
|
31
|
+
roles: name === "executor-kernel" ? ["CLI Host", "Kernel"] : [name],
|
|
32
32
|
state: actualPid ? "running" : snapshot.service.state,
|
|
33
33
|
observation: actualPid ? "alive" : "unknown"
|
|
34
34
|
});
|
|
@@ -43,7 +43,8 @@ export function residentProcesses(snapshots) {
|
|
|
43
43
|
state: text(service.state),
|
|
44
44
|
observation: text(service.observation),
|
|
45
45
|
service_id: text(service.service_id),
|
|
46
|
-
incarnation: typeof service.incarnation === "number" ? service.incarnation : undefined
|
|
46
|
+
incarnation: typeof service.incarnation === "number" ? service.incarnation : undefined,
|
|
47
|
+
ownership: typeof service.ownership === "string" ? text(service.ownership) : undefined
|
|
47
48
|
});
|
|
48
49
|
}
|
|
49
50
|
}
|
|
@@ -52,9 +53,12 @@ export function residentProcesses(snapshots) {
|
|
|
52
53
|
export function formatResidentProcesses(processes) {
|
|
53
54
|
const lines = ["Resident processes (ownership):"];
|
|
54
55
|
for (const entry of processes.filter((value) => !value.owner_pid)) {
|
|
55
|
-
|
|
56
|
+
const embeddedKernel = entry.roles.includes("CLI Host") && entry.roles.includes("Kernel");
|
|
57
|
+
lines.push(` ${entry.roles.filter((role) => !embeddedKernel || role !== "Kernel").join(", ")} PID ${entry.pid ?? "unknown"} ${entry.state} (${entry.observation})`);
|
|
58
|
+
if (embeddedKernel)
|
|
59
|
+
lines.push(` +-- Kernel in-process (shared PID ${entry.pid ?? "unknown"})`);
|
|
56
60
|
for (const child of processes.filter((value) => entry.pid && value.owner_pid === entry.pid))
|
|
57
|
-
lines.push(` +-- ${child.roles.join(", ")} PID ${child.pid ?? "-"} ${child.state} (${child.observation}) incarnation ${child.incarnation ?? "-"} service ${child.service_id ?? "-"}`);
|
|
61
|
+
lines.push(` +-- ${child.roles.join(", ")} PID ${child.pid ?? "-"} ${child.state} (${child.observation}) ${child.ownership ?? "unknown"} incarnation ${child.incarnation ?? "-"} service ${child.service_id ?? "-"}`);
|
|
58
62
|
}
|
|
59
63
|
for (const entry of processes.filter((value) => value.owner_pid && !processes.some((parent) => parent.pid === value.owner_pid)))
|
|
60
64
|
lines.push(` ${entry.roles.join(", ")} PID ${entry.pid ?? "-"} ${entry.state} (${entry.observation}) owner PID ${entry.owner_pid}`);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { loadCliAdapters } from "./adapters.js";
|
|
2
|
+
import { createCliKernelService } from "./kernel.js";
|
|
2
3
|
import { defaultRuntimeHome, runtimePaths, readJsonFile } from "./state.js";
|
|
3
4
|
import { loadCliManifest } from "./module-manifest.js";
|
|
4
5
|
import { readCliAdapterConfigurations } from "./adapter-configurations.js";
|
|
5
|
-
import { createKernelService } from "@mininglamp-oss/octo-runtime-executor-kernel";
|
|
6
6
|
import { componentEndpoint } from "@mininglamp-oss/octo-runtime-host-sdk";
|
|
7
7
|
import { mkdtemp, rm } from "node:fs/promises";
|
|
8
8
|
import { tmpdir } from "node:os";
|
|
@@ -44,12 +44,21 @@ export async function runPlayboard(options) {
|
|
|
44
44
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
45
45
|
throw new TypeError("playboard stdin must contain one JSON input object");
|
|
46
46
|
const input = identifyInvokeInput(InvokeInput.check(value));
|
|
47
|
-
// full_access 是本 CLI
|
|
47
|
+
// full_access 是本 CLI 宿主的缺省策略;显式策略(包括非法值)保留给 Adapter 校验,
|
|
48
48
|
// 不覆盖 Context,也不改变 SDK 的 ask 默认值。
|
|
49
|
-
if (!
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
if (!(Array.isArray(input.agentEnv?.items) &&
|
|
50
|
+
input.agentEnv.items.some((item) => item?.namespace === "octo.security" && item.name === "approval_policy")))
|
|
51
|
+
input.agentEnv = {
|
|
52
|
+
...input.agentEnv,
|
|
53
|
+
items: [
|
|
54
|
+
...input.agentEnv.items,
|
|
55
|
+
{
|
|
56
|
+
namespace: "octo.security",
|
|
57
|
+
name: "approval_policy",
|
|
58
|
+
payload: { mode: "full_access" }
|
|
59
|
+
}
|
|
60
|
+
]
|
|
61
|
+
};
|
|
53
62
|
const profile = options.profile ?? "default";
|
|
54
63
|
const home = options.home ?? defaultRuntimeHome(options.env);
|
|
55
64
|
runtimePaths(home, profile); // Validate the selected profile before starting resources.
|
|
@@ -87,15 +96,15 @@ export async function runPlayboard(options) {
|
|
|
87
96
|
const paths = runtimePaths(home, profile);
|
|
88
97
|
const manifest = await loadCliManifest(home, options.manifest);
|
|
89
98
|
const configuration = await readJsonFile(paths.profileConfig);
|
|
90
|
-
kernel =
|
|
99
|
+
kernel = await createCliKernelService({
|
|
91
100
|
home: temporary,
|
|
92
101
|
endpoint: process.platform === "win32" ? componentEndpoint(temporary) : join(temporary, "k.sock"),
|
|
93
|
-
adapters: await loadCliAdapters(manifest.adapters, {
|
|
94
|
-
profileRoot: paths.profileRoot,
|
|
95
|
-
syncOpenClawTools: false
|
|
96
|
-
}),
|
|
97
102
|
adapterConfigurations: await readCliAdapterConfigurations(paths.profileRoot, configuration?.adapters, manifest, options.env ?? process.env)
|
|
98
|
-
}
|
|
103
|
+
}, await loadCliAdapters(manifest.adapters, {
|
|
104
|
+
profileRoot: paths.profileRoot,
|
|
105
|
+
syncOpenClawTools: false,
|
|
106
|
+
env: options.env ?? process.env
|
|
107
|
+
}));
|
|
99
108
|
await kernel.initialize({ signal: controller.signal });
|
|
100
109
|
let exitCode = 1;
|
|
101
110
|
const { inputs: parts, sessionId, providerSession, agentEnv, ...content } = input;
|