@mininglamp-oss/octo-runtime 1.1.12 → 1.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/apps/cli/dist/adapters.d.ts +19 -1
- package/apps/cli/dist/adapters.js +154 -28
- package/apps/cli/dist/build-info.json +2 -2
- package/apps/cli/dist/codex.d.ts +5 -0
- package/apps/cli/dist/codex.js +36 -0
- package/apps/cli/dist/kernel.d.ts +4 -0
- package/apps/cli/dist/kernel.js +84 -0
- package/apps/cli/dist/main.js +8 -7
- package/apps/cli/dist/manifest.json +33 -22
- package/apps/cli/dist/output.d.ts +1 -0
- package/apps/cli/dist/output.js +8 -4
- package/apps/cli/dist/playboard.js +21 -12
- package/apps/cli/dist/provider-launch.d.ts +28 -0
- package/apps/cli/dist/provider-launch.js +52 -0
- package/apps/cli/dist/providers.d.ts +182 -0
- package/apps/cli/dist/providers.js +34 -0
- package/dist/public/adapter-sdk.d.ts +2 -0
- package/dist/public/adapter-sdk.js +2 -0
- package/dist/public/protocol.d.ts +2 -2
- package/dist/public/protocol.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-acp-client/dist/index.js +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.d.ts +26 -10
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.js +44 -53
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/dist/index.d.ts +10 -35
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/dist/index.js +21 -29
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/agent-env.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/agent-env.js +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/index.d.ts +14 -68
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/dist/index.js +77 -61
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.d.ts +19 -31
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/dist/index.js +28 -18
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/agent-env.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/agent-env.js +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.d.ts +6 -5
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +55 -54
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/engine.d.ts +54 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/engine.js +147 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/environment.js +4 -8
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.d.ts +20 -92
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.js +103 -217
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/mcp.d.ts +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/mcp.js +4 -11
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/service.d.ts +9 -5
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/service.js +77 -81
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-SMTJTIN7.js → chunk-AE3OJBDS.js} +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-H3S6WM37.js → chunk-NGR74QLF.js} +0 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-RISQ6NGV.js → chunk-XIUZ6GXG.js} +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.d.ts +0 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/errors.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.d.ts +6 -8
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/index.js +16 -21
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/launch.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/trajectory.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/adapter.d.ts +14 -16
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/adapter.js +29 -46
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/agent-env.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/agent-env.js +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/client.js +4 -7
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/index.d.ts +13 -21
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/dist/index.js +47 -36
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/dist/index.d.ts +24 -8
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/dist/index.js +14 -7
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/dist/index.d.ts +24 -8
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/dist/index.js +13 -6
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/dist/index.d.ts +24 -8
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/dist/index.js +14 -7
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.d.ts +7 -7
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.js +28 -31
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.d.ts +16 -25
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.js +113 -179
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/dist/index.d.ts +24 -8
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/dist/index.js +14 -6
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/dist/index.d.ts +24 -8
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/dist/index.js +14 -6
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/activity.d.ts +5 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/agent-env.d.ts +48 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/agent-env.js +234 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/approval.js +7 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/environment.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/execution-scope.d.ts +5 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +25 -14
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.js +112 -59
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/mcp.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/process-launch.d.ts +11 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/process-launch.js +89 -8
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/provider-launch.d.ts +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/provider-launch.js +25 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/public-display.js +10 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.d.ts +19 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.js +154 -28
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/codex.d.ts +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/codex.js +36 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/kernel.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/kernel.js +84 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.js +8 -7
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/manifest.json +33 -22
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +8 -4
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.js +21 -12
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/provider-launch.d.ts +28 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/provider-launch.js +52 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/providers.d.ts +182 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/providers.js +34 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +20 -20
- package/node_modules/@mininglamp-oss/octo-runtime-client/build-info.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/client.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-client/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-ipc.schema.json +3 -104
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/protocol.schema.json +166 -1870
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.d.ts +0 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +122 -65
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/invoke-input.d.ts +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/invoke-input.js +13 -85
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-output-silence.d.ts +21 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/model-output-silence.js +176 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.d.ts +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.js +8 -4
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.d.ts +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.js +17 -20
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/adapter-metadata.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/browser.d.ts +0 -2
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/browser.js +0 -2
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-catalog.d.ts +0 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-catalog.js +3 -9
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context-configuration.js +1 -8
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.d.ts +1 -5
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.js +3 -292
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/experience.js +7 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.js +18 -13
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +90 -608
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.js +32 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.d.ts +7 -18
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +34 -189
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.d.ts +11 -22
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.js +38 -78
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/multimodal.js +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.d.ts +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.js +5 -40
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/service-processes.js +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
- package/package.json +34 -37
- package/packages/octo-runtime-protocol/schema/kernel-ipc.schema.json +3 -104
- package/packages/octo-runtime-protocol/schema/protocol.schema.json +166 -1870
- package/dist/public/codex.d.ts +0 -1
- package/dist/public/codex.js +0 -1
- package/dist/public/dsh.d.ts +0 -2
- package/dist/public/dsh.js +0 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/actmode.d.ts +0 -5
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/actmode.js +0 -8
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/context-configuration-fixtures.json +0 -1219
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/context-fixtures.json +0 -5988
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-client.behavior.json +0 -56
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/native-invoke-fixtures.json +0 -116
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/run-protocol-fixtures.json +0 -761
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/runtime-selection-fixtures.json +0 -663
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/session-name-fixtures.json +0 -191
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/context.d.ts +0 -12
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/context.js +0 -89
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/execution-preparation.d.ts +0 -33
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/execution-preparation.js +0 -93
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/actmode.d.ts +0 -4
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/actmode.js +0 -36
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/execution-plan.d.ts +0 -3
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/execution-plan.js +0 -80
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/model-context.d.ts +0 -3
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/model-context.js +0 -9
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/runtime-selection.d.ts +0 -3
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/runtime-selection.js +0 -68
- /package/node_modules/@mininglamp-oss/octo-runtime-client/{schema → fixtures}/kernel-ipc-fixtures.json +0 -0
- /package/packages/octo-runtime-protocol/{schema → test/fixtures}/kernel-ipc-fixtures.json +0 -0
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type AdapterMetadata } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
2
|
+
/** CLI 明确选择安装;配置形状错误阻止装配,缺安装只影响对应 Adapter。 */
|
|
3
|
+
export declare function cliProviderLaunch(options: Record<string, unknown>, env: NodeJS.ProcessEnv, defaultCommand: string): {
|
|
4
|
+
launch: Required<import("@mininglamp-oss/octo-runtime-adapter-sdk").ProviderLaunch>;
|
|
5
|
+
command?: undefined;
|
|
6
|
+
reason?: undefined;
|
|
7
|
+
} | {
|
|
8
|
+
command: string;
|
|
9
|
+
reason: string;
|
|
10
|
+
launch?: undefined;
|
|
11
|
+
};
|
|
12
|
+
/** 复用模块静态声明及既有 probe;没有依赖时不构造假 command、不延迟发现安装。 */
|
|
13
|
+
export declare function unavailableCliAdapter(metadata: AdapterMetadata, reason: string, command: string): Readonly<Omit<{
|
|
14
|
+
metadata: AdapterMetadata;
|
|
15
|
+
probe: () => Promise<{
|
|
16
|
+
available: false;
|
|
17
|
+
command: string;
|
|
18
|
+
reason: string;
|
|
19
|
+
}>;
|
|
20
|
+
respondInteraction: () => Promise<void>;
|
|
21
|
+
respondNative: () => Promise<void>;
|
|
22
|
+
invoke(request: import("@mininglamp-oss/octo-runtime-protocol").InvokeRequest, context: import("@mininglamp-oss/octo-runtime-adapter-sdk").AdapterInvocationContext | undefined): AsyncGenerator<never, void, unknown>;
|
|
23
|
+
}, "metadata" | "defaultAgentEnv"> & {
|
|
24
|
+
readonly defaultAgentEnv: import("@mininglamp-oss/octo-runtime-protocol").AgentEnv;
|
|
25
|
+
metadata: Omit<AdapterMetadata, "protocolSupport"> & {
|
|
26
|
+
protocolSupport: import("@mininglamp-oss/octo-runtime-protocol").AdapterProtocolSupport;
|
|
27
|
+
};
|
|
28
|
+
}>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { defineAdapter, runAdapterPreparation } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
2
|
+
import { resolveHostProviderLaunch } from "@mininglamp-oss/octo-runtime-adapter-sdk/process-launch";
|
|
3
|
+
/** CLI 明确选择安装;配置形状错误阻止装配,缺安装只影响对应 Adapter。 */
|
|
4
|
+
export function cliProviderLaunch(options, env, defaultCommand) {
|
|
5
|
+
if ((options.command !== undefined &&
|
|
6
|
+
(typeof options.command !== "string" ||
|
|
7
|
+
!options.command ||
|
|
8
|
+
options.command.includes("\0"))) ||
|
|
9
|
+
(options.commandArgsPrefix !== undefined &&
|
|
10
|
+
(!Array.isArray(options.commandArgsPrefix) ||
|
|
11
|
+
options.commandArgsPrefix.some((arg) => typeof arg !== "string" || arg.includes("\0")))))
|
|
12
|
+
throw new TypeError("PROVIDER_LAUNCH_INVALID");
|
|
13
|
+
try {
|
|
14
|
+
return {
|
|
15
|
+
launch: resolveHostProviderLaunch(options.command ?? defaultCommand, {
|
|
16
|
+
env,
|
|
17
|
+
cwd: process.cwd(),
|
|
18
|
+
args: options.commandArgsPrefix
|
|
19
|
+
})
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
const code = error.code;
|
|
24
|
+
if (code === "ENOENT" || code === "ENOTDIR" || code === "EACCES" || code === "EPERM")
|
|
25
|
+
return {
|
|
26
|
+
command: typeof error.path === "string"
|
|
27
|
+
? error.path
|
|
28
|
+
: (options.command ?? defaultCommand),
|
|
29
|
+
reason: code === "EACCES" || code === "EPERM" ? "permission_denied" : "command_not_found"
|
|
30
|
+
};
|
|
31
|
+
throw error;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
/** 复用模块静态声明及既有 probe;没有依赖时不构造假 command、不延迟发现安装。 */
|
|
35
|
+
export function unavailableCliAdapter(metadata, reason, command) {
|
|
36
|
+
const failure = Object.assign(new Error(`${reason}: ${command}`), {
|
|
37
|
+
code: reason === "permission_denied" ? "EACCES" : "ENOENT"
|
|
38
|
+
});
|
|
39
|
+
return defineAdapter({
|
|
40
|
+
metadata,
|
|
41
|
+
probe: () => Promise.resolve({ available: false, command, reason }),
|
|
42
|
+
respondInteraction: () => Promise.reject(new Error("INTERACTION_NOT_ACTIVE")),
|
|
43
|
+
respondNative: () => Promise.reject(new Error("INTERACTION_NOT_ACTIVE")),
|
|
44
|
+
async *invoke(request, context) {
|
|
45
|
+
await runAdapterPreparation(context, () => {
|
|
46
|
+
request.signal?.throwIfAborted();
|
|
47
|
+
throw failure;
|
|
48
|
+
});
|
|
49
|
+
yield* [];
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { type AdapterMetadata } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
2
|
+
import type { HostedAdapter } from "@mininglamp-oss/octo-runtime-executor-kernel";
|
|
3
|
+
export declare const createCliOpenCodeAdapter: (options: Record<string, unknown>, context: {
|
|
4
|
+
env: NodeJS.ProcessEnv;
|
|
5
|
+
}) => HostedAdapter | Readonly<Omit<{
|
|
6
|
+
metadata: AdapterMetadata;
|
|
7
|
+
probe: () => Promise<{
|
|
8
|
+
available: false;
|
|
9
|
+
command: string;
|
|
10
|
+
reason: string;
|
|
11
|
+
}>;
|
|
12
|
+
respondInteraction: () => Promise<void>;
|
|
13
|
+
respondNative: () => Promise<void>;
|
|
14
|
+
invoke(request: import("@mininglamp-oss/octo-runtime-protocol").InvokeRequest, context: import("@mininglamp-oss/octo-runtime-adapter-sdk").AdapterInvocationContext | undefined): AsyncGenerator<never, void, unknown>;
|
|
15
|
+
}, "metadata" | "defaultAgentEnv"> & {
|
|
16
|
+
readonly defaultAgentEnv: import("@mininglamp-oss/octo-runtime-protocol").AgentEnv;
|
|
17
|
+
metadata: Omit<AdapterMetadata, "protocolSupport"> & {
|
|
18
|
+
protocolSupport: import("@mininglamp-oss/octo-runtime-protocol").AdapterProtocolSupport;
|
|
19
|
+
};
|
|
20
|
+
}>;
|
|
21
|
+
export declare const createCliClaudeCodeAdapter: (options: Record<string, unknown>, context: {
|
|
22
|
+
env: NodeJS.ProcessEnv;
|
|
23
|
+
}) => HostedAdapter | Readonly<Omit<{
|
|
24
|
+
metadata: AdapterMetadata;
|
|
25
|
+
probe: () => Promise<{
|
|
26
|
+
available: false;
|
|
27
|
+
command: string;
|
|
28
|
+
reason: string;
|
|
29
|
+
}>;
|
|
30
|
+
respondInteraction: () => Promise<void>;
|
|
31
|
+
respondNative: () => Promise<void>;
|
|
32
|
+
invoke(request: import("@mininglamp-oss/octo-runtime-protocol").InvokeRequest, context: import("@mininglamp-oss/octo-runtime-adapter-sdk").AdapterInvocationContext | undefined): AsyncGenerator<never, void, unknown>;
|
|
33
|
+
}, "metadata" | "defaultAgentEnv"> & {
|
|
34
|
+
readonly defaultAgentEnv: import("@mininglamp-oss/octo-runtime-protocol").AgentEnv;
|
|
35
|
+
metadata: Omit<AdapterMetadata, "protocolSupport"> & {
|
|
36
|
+
protocolSupport: import("@mininglamp-oss/octo-runtime-protocol").AdapterProtocolSupport;
|
|
37
|
+
};
|
|
38
|
+
}>;
|
|
39
|
+
export declare const createCliCodeBuddyAdapter: (options: Record<string, unknown>, context: {
|
|
40
|
+
env: NodeJS.ProcessEnv;
|
|
41
|
+
}) => HostedAdapter | Readonly<Omit<{
|
|
42
|
+
metadata: AdapterMetadata;
|
|
43
|
+
probe: () => Promise<{
|
|
44
|
+
available: false;
|
|
45
|
+
command: string;
|
|
46
|
+
reason: string;
|
|
47
|
+
}>;
|
|
48
|
+
respondInteraction: () => Promise<void>;
|
|
49
|
+
respondNative: () => Promise<void>;
|
|
50
|
+
invoke(request: import("@mininglamp-oss/octo-runtime-protocol").InvokeRequest, context: import("@mininglamp-oss/octo-runtime-adapter-sdk").AdapterInvocationContext | undefined): AsyncGenerator<never, void, unknown>;
|
|
51
|
+
}, "metadata" | "defaultAgentEnv"> & {
|
|
52
|
+
readonly defaultAgentEnv: import("@mininglamp-oss/octo-runtime-protocol").AgentEnv;
|
|
53
|
+
metadata: Omit<AdapterMetadata, "protocolSupport"> & {
|
|
54
|
+
protocolSupport: import("@mininglamp-oss/octo-runtime-protocol").AdapterProtocolSupport;
|
|
55
|
+
};
|
|
56
|
+
}>;
|
|
57
|
+
export declare const createCliAntigravityAdapter: (options: Record<string, unknown>, context: {
|
|
58
|
+
env: NodeJS.ProcessEnv;
|
|
59
|
+
}) => HostedAdapter | Readonly<Omit<{
|
|
60
|
+
metadata: AdapterMetadata;
|
|
61
|
+
probe: () => Promise<{
|
|
62
|
+
available: false;
|
|
63
|
+
command: string;
|
|
64
|
+
reason: string;
|
|
65
|
+
}>;
|
|
66
|
+
respondInteraction: () => Promise<void>;
|
|
67
|
+
respondNative: () => Promise<void>;
|
|
68
|
+
invoke(request: import("@mininglamp-oss/octo-runtime-protocol").InvokeRequest, context: import("@mininglamp-oss/octo-runtime-adapter-sdk").AdapterInvocationContext | undefined): AsyncGenerator<never, void, unknown>;
|
|
69
|
+
}, "metadata" | "defaultAgentEnv"> & {
|
|
70
|
+
readonly defaultAgentEnv: import("@mininglamp-oss/octo-runtime-protocol").AgentEnv;
|
|
71
|
+
metadata: Omit<AdapterMetadata, "protocolSupport"> & {
|
|
72
|
+
protocolSupport: import("@mininglamp-oss/octo-runtime-protocol").AdapterProtocolSupport;
|
|
73
|
+
};
|
|
74
|
+
}>;
|
|
75
|
+
export declare const createCliGrokBuildAdapter: (options: Record<string, unknown>, context: {
|
|
76
|
+
env: NodeJS.ProcessEnv;
|
|
77
|
+
}) => HostedAdapter | Readonly<Omit<{
|
|
78
|
+
metadata: AdapterMetadata;
|
|
79
|
+
probe: () => Promise<{
|
|
80
|
+
available: false;
|
|
81
|
+
command: string;
|
|
82
|
+
reason: string;
|
|
83
|
+
}>;
|
|
84
|
+
respondInteraction: () => Promise<void>;
|
|
85
|
+
respondNative: () => Promise<void>;
|
|
86
|
+
invoke(request: import("@mininglamp-oss/octo-runtime-protocol").InvokeRequest, context: import("@mininglamp-oss/octo-runtime-adapter-sdk").AdapterInvocationContext | undefined): AsyncGenerator<never, void, unknown>;
|
|
87
|
+
}, "metadata" | "defaultAgentEnv"> & {
|
|
88
|
+
readonly defaultAgentEnv: import("@mininglamp-oss/octo-runtime-protocol").AgentEnv;
|
|
89
|
+
metadata: Omit<AdapterMetadata, "protocolSupport"> & {
|
|
90
|
+
protocolSupport: import("@mininglamp-oss/octo-runtime-protocol").AdapterProtocolSupport;
|
|
91
|
+
};
|
|
92
|
+
}>;
|
|
93
|
+
export declare const createCliHermesAdapter: (options: Record<string, unknown>, context: {
|
|
94
|
+
env: NodeJS.ProcessEnv;
|
|
95
|
+
}) => HostedAdapter | Readonly<Omit<{
|
|
96
|
+
metadata: AdapterMetadata;
|
|
97
|
+
probe: () => Promise<{
|
|
98
|
+
available: false;
|
|
99
|
+
command: string;
|
|
100
|
+
reason: string;
|
|
101
|
+
}>;
|
|
102
|
+
respondInteraction: () => Promise<void>;
|
|
103
|
+
respondNative: () => Promise<void>;
|
|
104
|
+
invoke(request: import("@mininglamp-oss/octo-runtime-protocol").InvokeRequest, context: import("@mininglamp-oss/octo-runtime-adapter-sdk").AdapterInvocationContext | undefined): AsyncGenerator<never, void, unknown>;
|
|
105
|
+
}, "metadata" | "defaultAgentEnv"> & {
|
|
106
|
+
readonly defaultAgentEnv: import("@mininglamp-oss/octo-runtime-protocol").AgentEnv;
|
|
107
|
+
metadata: Omit<AdapterMetadata, "protocolSupport"> & {
|
|
108
|
+
protocolSupport: import("@mininglamp-oss/octo-runtime-protocol").AdapterProtocolSupport;
|
|
109
|
+
};
|
|
110
|
+
}>;
|
|
111
|
+
export declare const createCliKimiCodeAdapter: (options: Record<string, unknown>, context: {
|
|
112
|
+
env: NodeJS.ProcessEnv;
|
|
113
|
+
}) => HostedAdapter | Readonly<Omit<{
|
|
114
|
+
metadata: AdapterMetadata;
|
|
115
|
+
probe: () => Promise<{
|
|
116
|
+
available: false;
|
|
117
|
+
command: string;
|
|
118
|
+
reason: string;
|
|
119
|
+
}>;
|
|
120
|
+
respondInteraction: () => Promise<void>;
|
|
121
|
+
respondNative: () => Promise<void>;
|
|
122
|
+
invoke(request: import("@mininglamp-oss/octo-runtime-protocol").InvokeRequest, context: import("@mininglamp-oss/octo-runtime-adapter-sdk").AdapterInvocationContext | undefined): AsyncGenerator<never, void, unknown>;
|
|
123
|
+
}, "metadata" | "defaultAgentEnv"> & {
|
|
124
|
+
readonly defaultAgentEnv: import("@mininglamp-oss/octo-runtime-protocol").AgentEnv;
|
|
125
|
+
metadata: Omit<AdapterMetadata, "protocolSupport"> & {
|
|
126
|
+
protocolSupport: import("@mininglamp-oss/octo-runtime-protocol").AdapterProtocolSupport;
|
|
127
|
+
};
|
|
128
|
+
}>;
|
|
129
|
+
export declare const createCliMcodeAdapter: (options: Record<string, unknown>, context: {
|
|
130
|
+
env: NodeJS.ProcessEnv;
|
|
131
|
+
}) => HostedAdapter | Readonly<Omit<{
|
|
132
|
+
metadata: AdapterMetadata;
|
|
133
|
+
probe: () => Promise<{
|
|
134
|
+
available: false;
|
|
135
|
+
command: string;
|
|
136
|
+
reason: string;
|
|
137
|
+
}>;
|
|
138
|
+
respondInteraction: () => Promise<void>;
|
|
139
|
+
respondNative: () => Promise<void>;
|
|
140
|
+
invoke(request: import("@mininglamp-oss/octo-runtime-protocol").InvokeRequest, context: import("@mininglamp-oss/octo-runtime-adapter-sdk").AdapterInvocationContext | undefined): AsyncGenerator<never, void, unknown>;
|
|
141
|
+
}, "metadata" | "defaultAgentEnv"> & {
|
|
142
|
+
readonly defaultAgentEnv: import("@mininglamp-oss/octo-runtime-protocol").AgentEnv;
|
|
143
|
+
metadata: Omit<AdapterMetadata, "protocolSupport"> & {
|
|
144
|
+
protocolSupport: import("@mininglamp-oss/octo-runtime-protocol").AdapterProtocolSupport;
|
|
145
|
+
};
|
|
146
|
+
}>;
|
|
147
|
+
export declare const createCliQoderCliAdapter: (options: Record<string, unknown>, context: {
|
|
148
|
+
env: NodeJS.ProcessEnv;
|
|
149
|
+
}) => HostedAdapter | Readonly<Omit<{
|
|
150
|
+
metadata: AdapterMetadata;
|
|
151
|
+
probe: () => Promise<{
|
|
152
|
+
available: false;
|
|
153
|
+
command: string;
|
|
154
|
+
reason: string;
|
|
155
|
+
}>;
|
|
156
|
+
respondInteraction: () => Promise<void>;
|
|
157
|
+
respondNative: () => Promise<void>;
|
|
158
|
+
invoke(request: import("@mininglamp-oss/octo-runtime-protocol").InvokeRequest, context: import("@mininglamp-oss/octo-runtime-adapter-sdk").AdapterInvocationContext | undefined): AsyncGenerator<never, void, unknown>;
|
|
159
|
+
}, "metadata" | "defaultAgentEnv"> & {
|
|
160
|
+
readonly defaultAgentEnv: import("@mininglamp-oss/octo-runtime-protocol").AgentEnv;
|
|
161
|
+
metadata: Omit<AdapterMetadata, "protocolSupport"> & {
|
|
162
|
+
protocolSupport: import("@mininglamp-oss/octo-runtime-protocol").AdapterProtocolSupport;
|
|
163
|
+
};
|
|
164
|
+
}>;
|
|
165
|
+
export declare const createCliQoderCliCnAdapter: (options: Record<string, unknown>, context: {
|
|
166
|
+
env: NodeJS.ProcessEnv;
|
|
167
|
+
}) => HostedAdapter | Readonly<Omit<{
|
|
168
|
+
metadata: AdapterMetadata;
|
|
169
|
+
probe: () => Promise<{
|
|
170
|
+
available: false;
|
|
171
|
+
command: string;
|
|
172
|
+
reason: string;
|
|
173
|
+
}>;
|
|
174
|
+
respondInteraction: () => Promise<void>;
|
|
175
|
+
respondNative: () => Promise<void>;
|
|
176
|
+
invoke(request: import("@mininglamp-oss/octo-runtime-protocol").InvokeRequest, context: import("@mininglamp-oss/octo-runtime-adapter-sdk").AdapterInvocationContext | undefined): AsyncGenerator<never, void, unknown>;
|
|
177
|
+
}, "metadata" | "defaultAgentEnv"> & {
|
|
178
|
+
readonly defaultAgentEnv: import("@mininglamp-oss/octo-runtime-protocol").AgentEnv;
|
|
179
|
+
metadata: Omit<AdapterMetadata, "protocolSupport"> & {
|
|
180
|
+
protocolSupport: import("@mininglamp-oss/octo-runtime-protocol").AdapterProtocolSupport;
|
|
181
|
+
};
|
|
182
|
+
}>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createOpenCodeAdapter, openCodeMetadata } from "@mininglamp-oss/octo-runtime-adapter-opencode";
|
|
2
|
+
import { createClaudeCodeAdapter, claudeCodeMetadata } from "@mininglamp-oss/octo-runtime-adapter-claude-code";
|
|
3
|
+
import { createCodeBuddyAdapter, codeBuddyMetadata } from "@mininglamp-oss/octo-runtime-adapter-codebuddy";
|
|
4
|
+
import { createAntigravityAdapter, antigravityMetadata } from "@mininglamp-oss/octo-runtime-adapter-antigravity";
|
|
5
|
+
import { createGrokBuildAdapter, grokBuildMetadata } from "@mininglamp-oss/octo-runtime-adapter-grok-build";
|
|
6
|
+
import { createHermesAdapter, hermesMetadata } from "@mininglamp-oss/octo-runtime-adapter-hermes";
|
|
7
|
+
import { createKimiCodeAdapter, kimiCodeMetadata } from "@mininglamp-oss/octo-runtime-adapter-kimi-code";
|
|
8
|
+
import { createMcodeAdapter, mcodeMetadata } from "@mininglamp-oss/octo-runtime-adapter-mcode";
|
|
9
|
+
import { createQoderCliAdapter, qoderCliMetadata } from "@mininglamp-oss/octo-runtime-adapter-qodercli";
|
|
10
|
+
import { createQoderCliCnAdapter, qoderCliCnMetadata } from "@mininglamp-oss/octo-runtime-adapter-qoderclicn";
|
|
11
|
+
import { cliProviderLaunch, unavailableCliAdapter } from "./provider-launch.js";
|
|
12
|
+
/** 仅 CLI 的装配便利层;不约束 SDK 构造形式,也不在 Kernel 内注册执行依赖。 */
|
|
13
|
+
function cliFactory(metadata, command, construct) {
|
|
14
|
+
return (options, context) => {
|
|
15
|
+
const selected = cliProviderLaunch(options, context.env, command);
|
|
16
|
+
if (!selected.launch)
|
|
17
|
+
return unavailableCliAdapter(metadata, selected.reason, selected.command);
|
|
18
|
+
return construct({
|
|
19
|
+
command: selected.launch.command,
|
|
20
|
+
commandArgsPrefix: [...selected.launch.args],
|
|
21
|
+
env: selected.launch.env
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export const createCliOpenCodeAdapter = cliFactory(openCodeMetadata, "opencode", createOpenCodeAdapter);
|
|
26
|
+
export const createCliClaudeCodeAdapter = cliFactory(claudeCodeMetadata, "claude", createClaudeCodeAdapter);
|
|
27
|
+
export const createCliCodeBuddyAdapter = cliFactory(codeBuddyMetadata, "codebuddy", createCodeBuddyAdapter);
|
|
28
|
+
export const createCliAntigravityAdapter = cliFactory(antigravityMetadata, "agy", createAntigravityAdapter);
|
|
29
|
+
export const createCliGrokBuildAdapter = cliFactory(grokBuildMetadata, "grok", createGrokBuildAdapter);
|
|
30
|
+
export const createCliHermesAdapter = cliFactory(hermesMetadata, "hermes", createHermesAdapter);
|
|
31
|
+
export const createCliKimiCodeAdapter = cliFactory(kimiCodeMetadata, "kimi", createKimiCodeAdapter);
|
|
32
|
+
export const createCliMcodeAdapter = cliFactory(mcodeMetadata, "mcode", createMcodeAdapter);
|
|
33
|
+
export const createCliQoderCliAdapter = cliFactory(qoderCliMetadata, "qodercli", createQoderCliAdapter);
|
|
34
|
+
export const createCliQoderCliCnAdapter = cliFactory(qoderCliCnMetadata, "qoderclicn", createQoderCliCnAdapter);
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export type * from "@mininglamp-oss/octo-runtime-protocol";
|
|
2
|
-
export type { CanonicalEventWire,
|
|
3
|
-
export { InvokeInput, assertInvokeInput, CONTEXT_SCHEMA, CONTEXT_MAX_BYTES, CONTEXT_MAX_ITEMS, RUNTIME_RUN_CONTRACT, PROTOCOL_VERSION, APPROVAL_MODES, CANONICAL_EVENT_TYPES, TERMINAL_EVENT_TYPES, INTERACTION_RESPONSE_OUTCOMES, IMAGE_INPUT_LIMITS, IMAGE_INPUT_MIME_TYPES, assertContextEnvelope, assertModelInputParts, assertRuntimeLimits, assertCanonicalEvent, assertApprovalRequest, assertAsyncQuestions, assertQuestionRequest, assertQuestionResponse, questionAnswerText, assertInteractionResponse, assertNativeInteractionResponse, assertHostRunReceipt, assertHostControl, assertHostFrame, assertHostFrameIdentity, assertFailureEnvelope, isTerminal, isHostTerminal, canonicalEvents, contextItem, contextHash, messageExposure, isFailureEnvelope, failureMessage } from "@mininglamp-oss/octo-runtime-protocol";
|
|
2
|
+
export type { CanonicalEventWire, ContextMcpPayload, ContextModelSelectionPayload, PersistentContextEnvelope } from "@mininglamp-oss/octo-runtime-protocol/browser";
|
|
3
|
+
export { InvokeInput, assertInvokeInput, CONTEXT_SCHEMA, CONTEXT_MAX_BYTES, CONTEXT_MAX_ITEMS, RUNTIME_RUN_CONTRACT, PROTOCOL_VERSION, KERNEL_IPC_VERSION, APPROVAL_MODES, CANONICAL_EVENT_TYPES, TERMINAL_EVENT_TYPES, INTERACTION_RESPONSE_OUTCOMES, IMAGE_INPUT_LIMITS, IMAGE_INPUT_MIME_TYPES, assertContextEnvelope, assertModelInputParts, assertRuntimeLimits, assertCanonicalEvent, assertApprovalRequest, assertAsyncQuestions, assertQuestionRequest, assertQuestionResponse, questionAnswerText, assertInteractionResponse, assertNativeInteractionResponse, assertHostRunReceipt, assertHostControl, assertHostFrame, assertHostFrameIdentity, assertFailureEnvelope, isTerminal, isHostTerminal, canonicalEvents, contextItem, contextHash, messageExposure, isFailureEnvelope, failureMessage } from "@mininglamp-oss/octo-runtime-protocol";
|
package/dist/public/protocol.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { InvokeInput, assertInvokeInput, CONTEXT_SCHEMA, CONTEXT_MAX_BYTES, CONTEXT_MAX_ITEMS, RUNTIME_RUN_CONTRACT, PROTOCOL_VERSION, APPROVAL_MODES, CANONICAL_EVENT_TYPES, TERMINAL_EVENT_TYPES, INTERACTION_RESPONSE_OUTCOMES, IMAGE_INPUT_LIMITS, IMAGE_INPUT_MIME_TYPES, assertContextEnvelope, assertModelInputParts, assertRuntimeLimits, assertCanonicalEvent, assertApprovalRequest, assertAsyncQuestions, assertQuestionRequest, assertQuestionResponse, questionAnswerText, assertInteractionResponse, assertNativeInteractionResponse, assertHostRunReceipt, assertHostControl, assertHostFrame, assertHostFrameIdentity, assertFailureEnvelope, isTerminal, isHostTerminal, canonicalEvents, contextItem, contextHash, messageExposure, isFailureEnvelope, failureMessage } from "@mininglamp-oss/octo-runtime-protocol";
|
|
1
|
+
export { InvokeInput, assertInvokeInput, CONTEXT_SCHEMA, CONTEXT_MAX_BYTES, CONTEXT_MAX_ITEMS, RUNTIME_RUN_CONTRACT, PROTOCOL_VERSION, KERNEL_IPC_VERSION, APPROVAL_MODES, CANONICAL_EVENT_TYPES, TERMINAL_EVENT_TYPES, INTERACTION_RESPONSE_OUTCOMES, IMAGE_INPUT_LIMITS, IMAGE_INPUT_MIME_TYPES, assertContextEnvelope, assertModelInputParts, assertRuntimeLimits, assertCanonicalEvent, assertApprovalRequest, assertAsyncQuestions, assertQuestionRequest, assertQuestionResponse, questionAnswerText, assertInteractionResponse, assertNativeInteractionResponse, assertHostRunReceipt, assertHostControl, assertHostFrame, assertHostFrameIdentity, assertFailureEnvelope, isTerminal, isHostTerminal, canonicalEvents, contextItem, contextHash, messageExposure, isFailureEnvelope, failureMessage } from "@mininglamp-oss/octo-runtime-protocol";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { DriverQueue, watchLineLimit, mergeProcessEnvironment } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
2
2
|
import { INVOKE_REQUEST_MAX_BYTES, resolveStreamLimitPolicy } from "@mininglamp-oss/octo-runtime-protocol";
|
|
3
3
|
import { createProcessCleanup } from "@mininglamp-oss/octo-runtime-adapter-sdk/process-cleanup";
|
|
4
|
-
import {
|
|
4
|
+
import { assertProviderCommand } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
5
5
|
import { spawn } from "node:child_process";
|
|
6
6
|
import { createInterface } from "node:readline";
|
|
7
7
|
/** Build the exact params serialized by `session/new`. */
|
|
@@ -325,9 +325,9 @@ export class AcpClient {
|
|
|
325
325
|
*/
|
|
326
326
|
export function spawnAcpClient(options) {
|
|
327
327
|
const { command, args = [], cwd, env, signal, permissionHandler, onPermissionResponseWritten, onPermissionResponseFailed, streamLimits } = options;
|
|
328
|
-
|
|
329
|
-
const
|
|
330
|
-
const child = spawn(
|
|
328
|
+
assertProviderCommand(command);
|
|
329
|
+
const processEnv = mergeProcessEnvironment(env ?? {});
|
|
330
|
+
const child = spawn(command, args, {
|
|
331
331
|
cwd,
|
|
332
332
|
env: processEnv,
|
|
333
333
|
stdio: ["pipe", "pipe", "pipe"],
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-acp-client",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.14",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.
|
|
13
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
12
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.14",
|
|
13
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.14"
|
|
14
14
|
}
|
|
15
15
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawnAcpClient, type AcpUpdate } from "@mininglamp-oss/octo-runtime-acp-client";
|
|
2
|
-
import { type AdapterInvocationContext, type CanonicalEvent, type InvokeRequest } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
2
|
+
import { type ProbeResult, type AdapterMetadata, type AdapterInvocationContext, type CanonicalEvent, type InvokeRequest } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
3
3
|
import { type InteractionResponse } from "@mininglamp-oss/octo-runtime-protocol";
|
|
4
4
|
type JsonRecord = Record<string, unknown>;
|
|
5
5
|
/** 调用已失败但 ACP 传输已成功关闭;清理异常不包装成此类型。 */
|
|
@@ -7,6 +7,7 @@ export declare class AcpInvocationError extends Error {
|
|
|
7
7
|
constructor(cause: unknown);
|
|
8
8
|
}
|
|
9
9
|
export interface AcpAdapterDefinition {
|
|
10
|
+
metadata?: AdapterMetadata;
|
|
10
11
|
type: string;
|
|
11
12
|
provider: string;
|
|
12
13
|
command: string;
|
|
@@ -33,35 +34,50 @@ export interface AcpModelSelectionRequest {
|
|
|
33
34
|
params: JsonRecord;
|
|
34
35
|
}
|
|
35
36
|
/** 只使用 Provider 发布的模式 ID;不从产品名称、审批档位或正文猜测。 */
|
|
36
|
-
export declare function
|
|
37
|
+
export declare function acpModeSelectionRequest(session: JsonRecord, sessionId: string, requested: string): {
|
|
37
38
|
method: "session/set_config_option" | "session/set_mode";
|
|
38
39
|
params: JsonRecord;
|
|
39
|
-
effective: "default" | "plan";
|
|
40
40
|
nativeMode: string;
|
|
41
41
|
unchanged: boolean;
|
|
42
42
|
};
|
|
43
43
|
/** Resolve the model-selection RPC advertised by an ACP session response. */
|
|
44
44
|
export declare function acpModelSelectionRequest(session: JsonRecord, sessionId: string, requestedModel: string): AcpModelSelectionRequest | undefined;
|
|
45
45
|
export declare function normalizeAcpUpdate(update: StandardAcpUpdate, provider: string): CanonicalEvent[];
|
|
46
|
-
export declare function createAcpAdapter(definition: AcpAdapterDefinition, { acpClientFactory, command }?: {
|
|
46
|
+
export declare function createAcpAdapter(definition: AcpAdapterDefinition, { acpClientFactory, command, commandArgsPrefix, env, probe }?: {
|
|
47
47
|
acpClientFactory?: typeof spawnAcpClient;
|
|
48
48
|
command?: string;
|
|
49
|
+
commandArgsPrefix?: readonly string[];
|
|
50
|
+
env?: NodeJS.ProcessEnv;
|
|
51
|
+
probe?: () => Promise<ProbeResult>;
|
|
49
52
|
}): Readonly<Omit<{
|
|
50
53
|
metadata: {
|
|
51
|
-
mcp
|
|
54
|
+
mcp?: boolean;
|
|
55
|
+
workspace?: boolean;
|
|
56
|
+
protocolSupport?: import("@mininglamp-oss/octo-runtime-protocol").AdapterProtocolSupport;
|
|
52
57
|
type: string;
|
|
53
|
-
|
|
58
|
+
processModel?: string;
|
|
59
|
+
transport?: string;
|
|
54
60
|
};
|
|
55
|
-
probe: () => Promise<
|
|
61
|
+
probe: (() => Promise<ProbeResult>) | (() => Promise<{
|
|
62
|
+
available: false;
|
|
63
|
+
command: string;
|
|
64
|
+
reason: string;
|
|
65
|
+
}>);
|
|
56
66
|
respondInteraction(invocationId: string, response: InteractionResponse): Promise<void>;
|
|
57
67
|
invoke(request: InvokeRequest, context?: AdapterInvocationContext): AsyncGenerator<CanonicalEvent>;
|
|
58
|
-
}, "metadata"> & {
|
|
68
|
+
}, "metadata" | "defaultAgentEnv"> & {
|
|
69
|
+
readonly defaultAgentEnv: import("@mininglamp-oss/octo-runtime-protocol").AgentEnv;
|
|
59
70
|
metadata: Omit<{
|
|
60
|
-
mcp
|
|
71
|
+
mcp?: boolean;
|
|
72
|
+
workspace?: boolean;
|
|
73
|
+
protocolSupport?: import("@mininglamp-oss/octo-runtime-protocol").AdapterProtocolSupport;
|
|
61
74
|
type: string;
|
|
62
|
-
|
|
75
|
+
processModel?: string;
|
|
76
|
+
transport?: string;
|
|
63
77
|
}, "protocolSupport"> & {
|
|
64
78
|
protocolSupport: import("@mininglamp-oss/octo-runtime-protocol").AdapterProtocolSupport;
|
|
65
79
|
};
|
|
66
80
|
}>;
|
|
81
|
+
/** ACP 包私有约定;派生 Adapter 以自己的类型命名空间选取原生 modeId。 */
|
|
82
|
+
export declare function acpModeId(request: InvokeRequest, type: string): string | undefined;
|
|
67
83
|
export {};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { agentEnvItem, invocationModel, invocationApprovalMode, invocationWorkdir } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
1
2
|
import { acpLoadSessionParams, acpNewSessionParams, acpPromptParams, spawnAcpClient } from "@mininglamp-oss/octo-runtime-acp-client";
|
|
2
|
-
import {
|
|
3
|
-
import { canonicalTerminalStatus,
|
|
3
|
+
import { AcpApprovalBridge, AcpTurnNormalizer, acpToolTerminalStatus, defineAdapter, invocationEnvironment, invocationMcpServers, assertMcpOptions, normalizeAcpToolUpdate, probeCommand, snapshotProviderLaunch } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
4
|
+
import { canonicalTerminalStatus, providerInputParts } from "@mininglamp-oss/octo-runtime-protocol";
|
|
4
5
|
/** 调用已失败但 ACP 传输已成功关闭;清理异常不包装成此类型。 */
|
|
5
6
|
export class AcpInvocationError extends Error {
|
|
6
7
|
constructor(cause) {
|
|
@@ -9,7 +10,7 @@ export class AcpInvocationError extends Error {
|
|
|
9
10
|
}
|
|
10
11
|
}
|
|
11
12
|
/** 只使用 Provider 发布的模式 ID;不从产品名称、审批档位或正文猜测。 */
|
|
12
|
-
export function
|
|
13
|
+
export function acpModeSelectionRequest(session, sessionId, requested) {
|
|
13
14
|
const option = arrayField(session, "configOptions")
|
|
14
15
|
.map(recordValue)
|
|
15
16
|
.find((value) => stringField(value, "category") === "mode" || stringField(value, "id") === "mode");
|
|
@@ -22,21 +23,17 @@ export function acpActmodeSelectionRequest(session, sessionId, requested) {
|
|
|
22
23
|
})
|
|
23
24
|
.map((value) => stringField(value, "value"))
|
|
24
25
|
: arrayField(modes, "availableModes").map((value) => stringField(recordValue(value), "id"));
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const nativeMode = requested === "plan" && available.includes("plan") ? "plan" : ordinary;
|
|
31
|
-
if (!nativeMode)
|
|
32
|
-
throw new Error("ACTMODE_UNSUPPORTED: ACP did not advertise an applicable mode");
|
|
26
|
+
if (!requested.trim() || !available.includes(requested))
|
|
27
|
+
throw new Error("ACP_MODE_UNSUPPORTED: Provider did not advertise the requested mode ID");
|
|
28
|
+
if (option && !stringField(option, "id"))
|
|
29
|
+
throw new Error("ACP_MODE_INVALID: mode config option has no ID");
|
|
30
|
+
const nativeMode = requested;
|
|
33
31
|
return {
|
|
34
32
|
method: option ? "session/set_config_option" : "session/set_mode",
|
|
35
33
|
params: option
|
|
36
34
|
? { sessionId, configId: stringField(option, "id"), value: nativeMode }
|
|
37
35
|
: { sessionId, modeId: nativeMode },
|
|
38
36
|
nativeMode,
|
|
39
|
-
effective: nativeMode === "plan" ? "plan" : "default",
|
|
40
37
|
unchanged: (option ? stringField(option, "currentValue") : stringField(modes, "currentModeId")) ===
|
|
41
38
|
nativeMode
|
|
42
39
|
};
|
|
@@ -147,15 +144,20 @@ export function normalizeAcpUpdate(update, provider) {
|
|
|
147
144
|
}
|
|
148
145
|
return [];
|
|
149
146
|
}
|
|
150
|
-
export function createAcpAdapter(definition, { acpClientFactory = spawnAcpClient, command = definition.command } = {}) {
|
|
147
|
+
export function createAcpAdapter(definition, { acpClientFactory = spawnAcpClient, command = definition.command, commandArgsPrefix = [], env = {}, probe } = {}) {
|
|
148
|
+
const launch = acpClientFactory === spawnAcpClient
|
|
149
|
+
? snapshotProviderLaunch({ command, args: commandArgsPrefix, env })
|
|
150
|
+
: { command, args: [...commandArgsPrefix], env: { ...env } };
|
|
151
151
|
const responders = new Map();
|
|
152
|
+
// 私有条目按最终注册身份读取;宿主可复用传输定义并覆盖 metadata.type。
|
|
153
|
+
// 固定构造时的 metadata,避免调用方后来修改定义对象改变本包读取的命名空间。
|
|
154
|
+
const metadata = { ...(definition.metadata ?? { mcp: true, type: definition.type }) };
|
|
152
155
|
return defineAdapter({
|
|
153
|
-
metadata
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
probe: () => probeCommand(command),
|
|
156
|
+
metadata,
|
|
157
|
+
probe: probe ??
|
|
158
|
+
(acpClientFactory === spawnAcpClient
|
|
159
|
+
? () => probeCommand(launch.command, { args: launch.args, env: launch.env })
|
|
160
|
+
: () => Promise.resolve({ available: false, command, reason: "probe_missing" })),
|
|
159
161
|
async respondInteraction(invocationId, response) {
|
|
160
162
|
const bridge = responders.get(invocationId);
|
|
161
163
|
if (!bridge)
|
|
@@ -163,7 +165,8 @@ export function createAcpAdapter(definition, { acpClientFactory = spawnAcpClient
|
|
|
163
165
|
await bridge.respond(response);
|
|
164
166
|
},
|
|
165
167
|
async *invoke(request, context) {
|
|
166
|
-
if (request
|
|
168
|
+
if (invocationApprovalMode(request) !== "ask" &&
|
|
169
|
+
invocationApprovalMode(request) !== "full_access")
|
|
167
170
|
throw new Error("APPROVAL_MODE_UNSUPPORTED: this ACP adapter has no assisted policy");
|
|
168
171
|
if (responders.has(request.invocationId))
|
|
169
172
|
throw new Error("INVOCATION_ALREADY_ACTIVE");
|
|
@@ -182,7 +185,7 @@ export function createAcpAdapter(definition, { acpClientFactory = spawnAcpClient
|
|
|
182
185
|
const args = typeof definition.args === "function"
|
|
183
186
|
? definition.args(request)
|
|
184
187
|
: (definition.args ?? ["acp"]);
|
|
185
|
-
const runEnv = invocationEnvironment(request, definition.env?.(request));
|
|
188
|
+
const runEnv = invocationEnvironment(request, definition.env?.(request), launch.env);
|
|
186
189
|
const mcp = invocationMcpServers(request, runEnv);
|
|
187
190
|
assertMcpOptions(mcp, definition.type, []);
|
|
188
191
|
const servers = Object.entries(mcp).map(([name, server]) => server.type === "stdio"
|
|
@@ -199,10 +202,10 @@ export function createAcpAdapter(definition, { acpClientFactory = spawnAcpClient
|
|
|
199
202
|
headers: Object.entries(server.headers ?? {}).map(([name, value]) => ({ name, value }))
|
|
200
203
|
});
|
|
201
204
|
const client = acpClientFactory({
|
|
202
|
-
command,
|
|
203
|
-
args: [...args],
|
|
205
|
+
command: launch.command,
|
|
206
|
+
args: [...launch.args, ...args],
|
|
204
207
|
env: runEnv,
|
|
205
|
-
cwd: request
|
|
208
|
+
cwd: invocationWorkdir(request),
|
|
206
209
|
permissionHandler: (params) => bridge.requestPermission(params),
|
|
207
210
|
onPermissionResponseWritten: (params) => bridge.responseWritten(params),
|
|
208
211
|
onPermissionResponseFailed: (params, error) => bridge.responseFailed(params, error),
|
|
@@ -245,8 +248,8 @@ export function createAcpAdapter(definition, { acpClientFactory = spawnAcpClient
|
|
|
245
248
|
let resumeFallback;
|
|
246
249
|
let sessionMethod = requestedSessionId ? "session/load" : "session/new";
|
|
247
250
|
let sessionParams = requestedSessionId
|
|
248
|
-
? acpLoadSessionParams(requestedSessionId, { cwd: request
|
|
249
|
-
: acpNewSessionParams({ cwd: request
|
|
251
|
+
? acpLoadSessionParams(requestedSessionId, { cwd: invocationWorkdir(request) })
|
|
252
|
+
: acpNewSessionParams({ cwd: invocationWorkdir(request) });
|
|
250
253
|
sessionParams.mcpServers = servers;
|
|
251
254
|
let sessionRequestId = client.reserveRequestId();
|
|
252
255
|
let sessionResult = {};
|
|
@@ -265,7 +268,7 @@ export function createAcpAdapter(definition, { acpClientFactory = spawnAcpClient
|
|
|
265
268
|
if (missingLoadedSession) {
|
|
266
269
|
resumeFallback = "session_load_not_found";
|
|
267
270
|
sessionMethod = "session/new";
|
|
268
|
-
sessionParams = acpNewSessionParams({ cwd: request
|
|
271
|
+
sessionParams = acpNewSessionParams({ cwd: invocationWorkdir(request) });
|
|
269
272
|
sessionParams.mcpServers = servers;
|
|
270
273
|
sessionRequestId = client.reserveRequestId();
|
|
271
274
|
result = await client.request(sessionMethod, sessionParams, {
|
|
@@ -289,7 +292,7 @@ export function createAcpAdapter(definition, { acpClientFactory = spawnAcpClient
|
|
|
289
292
|
payload: {
|
|
290
293
|
noticeId: `${request.invocationId}:session-name`,
|
|
291
294
|
code: "provider_diagnostic",
|
|
292
|
-
severity: "
|
|
295
|
+
severity: "warning",
|
|
293
296
|
params: {
|
|
294
297
|
adapter: definition.type,
|
|
295
298
|
diagnosticId: "session-name-unsupported",
|
|
@@ -298,22 +301,13 @@ export function createAcpAdapter(definition, { acpClientFactory = spawnAcpClient
|
|
|
298
301
|
}
|
|
299
302
|
}
|
|
300
303
|
};
|
|
301
|
-
const requestedMode =
|
|
304
|
+
const requestedMode = acpModeId(request, metadata.type);
|
|
302
305
|
if (requestedMode !== undefined) {
|
|
303
|
-
const selection =
|
|
306
|
+
const selection = acpModeSelectionRequest(sessionResult, sessionId, requestedMode);
|
|
304
307
|
if (!selection.unchanged)
|
|
305
308
|
await client.request(selection.method, selection.params);
|
|
306
|
-
yield actmodeEvidence({
|
|
307
|
-
requested: requestedMode,
|
|
308
|
-
effective: selection.effective,
|
|
309
|
-
nativeMode: selection.nativeMode,
|
|
310
|
-
status: selection.effective === requestedMode ? "applied" : "fallback",
|
|
311
|
-
...(selection.effective !== requestedMode
|
|
312
|
-
? { reason: "provider_unsupported" }
|
|
313
|
-
: {})
|
|
314
|
-
});
|
|
315
309
|
}
|
|
316
|
-
const requestedModel = nonEmptyString(request
|
|
310
|
+
const requestedModel = nonEmptyString(invocationModel(request));
|
|
317
311
|
if (requestedModel) {
|
|
318
312
|
const selection = acpModelSelectionRequest(sessionResult, sessionId, requestedModel);
|
|
319
313
|
if (selection) {
|
|
@@ -349,19 +343,7 @@ export function createAcpAdapter(definition, { acpClientFactory = spawnAcpClient
|
|
|
349
343
|
};
|
|
350
344
|
const input = providerInputParts(request, resumeFallback !== undefined);
|
|
351
345
|
// Preserve the legacy text call while mixed prompts retain every block's position.
|
|
352
|
-
const prompt = input.length === 1 && input[0]?.type === "text"
|
|
353
|
-
? `${input[0].text}${initialControlInstructions(request, !requestedSessionId || resumeFallback !== undefined) ? `\n\n${initialControlInstructions(request, !requestedSessionId || resumeFallback !== undefined)}` : ""}`
|
|
354
|
-
: [
|
|
355
|
-
...input,
|
|
356
|
-
...(initialControlInstructions(request, !requestedSessionId || resumeFallback !== undefined)
|
|
357
|
-
? [
|
|
358
|
-
{
|
|
359
|
-
type: "text",
|
|
360
|
-
text: initialControlInstructions(request, !requestedSessionId || resumeFallback !== undefined)
|
|
361
|
-
}
|
|
362
|
-
]
|
|
363
|
-
: [])
|
|
364
|
-
];
|
|
346
|
+
const prompt = input.length === 1 && input[0]?.type === "text" ? input[0].text : input;
|
|
365
347
|
const promptParams = acpPromptParams(sessionId, prompt);
|
|
366
348
|
const promptRequestId = client.reserveRequestId();
|
|
367
349
|
let stopReason;
|
|
@@ -554,3 +536,12 @@ function nonEmptyString(value) {
|
|
|
554
536
|
function stringField(value, key) {
|
|
555
537
|
return typeof value[key] === "string" ? value[key] : undefined;
|
|
556
538
|
}
|
|
539
|
+
/** ACP 包私有约定;派生 Adapter 以自己的类型命名空间选取原生 modeId。 */
|
|
540
|
+
export function acpModeId(request, type) {
|
|
541
|
+
const value = agentEnvItem(request.agentEnv, `adapter.${type}`, "options")?.modeId;
|
|
542
|
+
if (value === undefined)
|
|
543
|
+
return undefined;
|
|
544
|
+
if (typeof value !== "string" || !value.trim())
|
|
545
|
+
throw new TypeError("ADAPTER_OPTION_INVALID: modeId");
|
|
546
|
+
return value;
|
|
547
|
+
}
|