@mininglamp-oss/octo-runtime 1.1.10 → 1.1.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/apps/cli/README.md +1 -1
- package/apps/cli/dist/adapters.js +40 -14
- package/apps/cli/dist/build-info.json +2 -2
- package/apps/cli/dist/command-tree.js +2 -3
- package/apps/cli/dist/extras.js +11 -1
- package/apps/cli/dist/index.js +14 -1
- package/apps/cli/dist/main.js +58 -23
- package/apps/cli/dist/module-manifest.js +21 -3
- package/apps/cli/dist/output.d.ts +19 -1
- package/apps/cli/dist/output.js +179 -27
- package/apps/cli/dist/playboard.js +2 -2
- package/apps/cli/dist/state.d.ts +5 -2
- package/apps/cli/dist/state.js +48 -13
- package/dist/public/codex.d.ts +1 -0
- package/dist/public/codex.js +1 -0
- package/dist/public/executor-kernel.d.ts +4 -0
- package/dist/public/executor-kernel.js +2 -0
- package/dist/public/extra.d.ts +1 -1
- package/dist/public/host.d.ts +5 -0
- package/dist/public/host.js +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/dist/index.js +20 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.d.ts +6 -6
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +68 -253
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.d.ts +11 -6
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/index.js +198 -52
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/service.d.ts +58 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/service.js +650 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/stdin-writer.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/stdin-writer.js +15 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/dist/index.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/activity.d.ts +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/execution-scope.d.ts +25 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/execution-scope.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.js +40 -14
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/command-tree.js +2 -3
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extras.js +11 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/index.js +14 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.js +58 -23
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/module-manifest.js +21 -3
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.d.ts +19 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +179 -27
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/state.d.ts +5 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/state.js +48 -13
- package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +23 -23
- package/node_modules/@mininglamp-oss/octo-runtime-client/build-info.json +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/async-question-reply.d.ts +30 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/async-question-reply.js +199 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/browser.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/browser.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/client.d.ts +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/client.js +465 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/index.d.ts +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/index.js +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/internal.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/internal.js +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/invocation-lifecycle.d.ts +59 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/invocation-lifecycle.js +287 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/notification.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/notification.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/protocol.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/protocol.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/runtime-path.d.ts +21 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/runtime-path.js +138 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/startup-catalog.d.ts +8 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/startup-catalog.js +65 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/startup-diagnostics.d.ts +82 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/startup-diagnostics.js +371 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/submission-error.d.ts +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/submission-error.js +23 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/types.d.ts +72 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/dist/types.js +10 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/package.json +54 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/context-configuration-fixtures.json +1219 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/context-fixtures.json +5988 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-client.behavior.json +56 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-ipc-fixtures.json +53 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/kernel-ipc.schema.json +538 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/native-invoke-fixtures.json +116 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/protocol.schema.json +4525 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/run-protocol-fixtures.json +761 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/runtime-selection-fixtures.json +663 -0
- package/node_modules/@mininglamp-oss/octo-runtime-client/schema/session-name-fixtures.json +191 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.d.ts +26 -18
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +151 -11
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/async-question-reply.d.ts +1 -30
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/async-question-reply.js +2 -199
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/client.d.ts +1 -10
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/client.js +2 -446
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/endpoint.js +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/host-run-service.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/host-run-service.js +13 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.d.ts +4 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.js +4 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-lifecycle.d.ts +1 -53
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-lifecycle.js +2 -280
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/lifecycle.d.ts +5 -10
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/lifecycle.js +4 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runtime-home.d.ts +20 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runtime-home.js +180 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.js +31 -8
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/service.d.ts +5 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/service.js +48 -5
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-catalog.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-catalog.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-diagnostics.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-diagnostics.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-logging.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/startup-logging.js +18 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.d.ts +1 -10
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/submission-error.js +2 -23
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/types.d.ts +2 -72
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/types.js +2 -10
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +5 -4
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/extra.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/ports.d.ts +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/package.json +6 -6
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/extra.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/ports.d.ts +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/index.js +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/endpoint.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/endpoint.js +12 -5
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/errors.d.ts +5 -1
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/errors.js +9 -0
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/execution.d.ts +44 -0
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/execution.js +207 -0
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-config.js +23 -3
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-service.d.ts +27 -4
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-service.js +133 -25
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extras.d.ts +10 -3
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extras.js +18 -4
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/home.d.ts +5 -6
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/home.js +33 -45
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/identity.js +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/index.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/index.js +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +5 -4
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/adapter-metadata.d.ts +7 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/adapter-metadata.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +19 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.d.ts +3 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/service-processes.d.ts +5 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/service-processes.js +65 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
- package/package.json +33 -27
- package/packages/octo-runtime-protocol/schema/protocol.schema.json +42 -0
|
@@ -2,12 +2,17 @@ import { createHash, randomUUID } from "node:crypto";
|
|
|
2
2
|
import { access, chmod, link, mkdir, open, readFile, rename, rm, rmdir } from "node:fs/promises";
|
|
3
3
|
import { homedir } from "node:os";
|
|
4
4
|
import { basename, dirname, join, resolve } from "node:path";
|
|
5
|
-
import { componentEndpoint } from "@mininglamp-oss/octo-runtime-host-sdk";
|
|
5
|
+
import { componentEndpoint, normalizeRuntimeHome, assertRuntimePath, runtimePathFailure, validateRuntimeHome } from "@mininglamp-oss/octo-runtime-host-sdk";
|
|
6
|
+
import { withStartupContext } from "@mininglamp-oss/octo-runtime-executor-kernel";
|
|
6
7
|
const PROFILE_NAME = /^[A-Za-z0-9][A-Za-z0-9._-]{0,127}$/;
|
|
7
8
|
const RESERVED_PROFILE_NAMES = new Set([
|
|
8
9
|
"config.json",
|
|
9
10
|
"credentials",
|
|
10
11
|
"extras",
|
|
12
|
+
"executor-kernel.sock",
|
|
13
|
+
"executor-kernel.sock.owner",
|
|
14
|
+
"executor-kernel.sock.owner.recovery",
|
|
15
|
+
"executor-kernel.sock.runs",
|
|
11
16
|
"identity",
|
|
12
17
|
"machine.json",
|
|
13
18
|
"logs",
|
|
@@ -18,20 +23,43 @@ const RESERVED_PROFILE_NAMES = new Set([
|
|
|
18
23
|
"sockets",
|
|
19
24
|
"state.db"
|
|
20
25
|
]);
|
|
21
|
-
export function defaultRuntimeHome(env = process.env
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
export function defaultRuntimeHome(env = process.env) {
|
|
27
|
+
return normalizeRuntimeHome(join(env.HOME?.trim() || homedir(), ".octo-runtime"));
|
|
28
|
+
}
|
|
29
|
+
/** CLI 明确接受相对 --home 并转为绝对路径;不展开 ~,空值必须失败。 */
|
|
30
|
+
export function selectRuntimeHome(input, env, platform = process.platform) {
|
|
31
|
+
if (input === undefined)
|
|
32
|
+
return normalizeRuntimeHome(defaultRuntimeHome(env), platform);
|
|
33
|
+
if (typeof input !== "string" || !input.trim() || input.startsWith("~"))
|
|
34
|
+
return normalizeRuntimeHome(input, platform);
|
|
35
|
+
return normalizeRuntimeHome(resolve(input), platform);
|
|
36
|
+
}
|
|
37
|
+
/** 根目录只由 CLI 准备;先检查完整预算,创建失败保留原 path/errno,不换根。 */
|
|
38
|
+
export async function prepareRuntimeHome(home) {
|
|
39
|
+
const selected = normalizeRuntimeHome(home);
|
|
40
|
+
componentEndpoint(selected);
|
|
41
|
+
assertRuntimePath(join(selected, "run", `kernel-invocations.json.acknowledged.${"0".repeat(36)}.json`), "kernel-state");
|
|
42
|
+
try {
|
|
43
|
+
await mkdir(selected, { recursive: true, mode: 0o700 });
|
|
28
44
|
}
|
|
29
|
-
|
|
45
|
+
catch (error) {
|
|
46
|
+
if (isNodeError(error, "EEXIST"))
|
|
47
|
+
validateRuntimeHome(selected);
|
|
48
|
+
throw runtimePathFailure(error, selected, "home", "mkdir");
|
|
49
|
+
}
|
|
50
|
+
validateRuntimeHome(selected);
|
|
30
51
|
}
|
|
31
52
|
export function runtimePaths(home, profile, platform = process.platform) {
|
|
32
53
|
assertProfileName(profile);
|
|
33
|
-
const absoluteHome =
|
|
54
|
+
const absoluteHome = normalizeRuntimeHome(home, platform);
|
|
34
55
|
const profileRoot = join(absoluteHome, profile);
|
|
56
|
+
// CLI 的身份/锁原子写另有后缀,不可只检查 Home 或 hash pipe 的短地址。
|
|
57
|
+
for (const path of [
|
|
58
|
+
join(profileRoot, "credentials", `runtime-token.json.${"0".repeat(10)}.${"0".repeat(36)}.tmp`),
|
|
59
|
+
join(absoluteHome, "run", `kernel-invocations.json.acknowledged.${"0".repeat(36)}.json`),
|
|
60
|
+
join(absoluteHome, "run", `.reclaim-${"0".repeat(64)}.${"0".repeat(10)}.${"0".repeat(36)}.tmp`)
|
|
61
|
+
])
|
|
62
|
+
assertRuntimePath(path, "cli-state", platform);
|
|
35
63
|
return {
|
|
36
64
|
home: absoluteHome,
|
|
37
65
|
rootConfig: join(absoluteHome, "config.json"),
|
|
@@ -43,7 +71,6 @@ export function runtimePaths(home, profile, platform = process.platform) {
|
|
|
43
71
|
openclawRoot: join(profileRoot, "adapters", "openclaw"),
|
|
44
72
|
setupLock: join(absoluteHome, "run", "setup.lock"),
|
|
45
73
|
pid: join(absoluteHome, "run", "executor-kernel.pid"),
|
|
46
|
-
socket: componentEndpoint(absoluteHome, "executor-kernel", platform),
|
|
47
74
|
logs: join(absoluteHome, "logs")
|
|
48
75
|
};
|
|
49
76
|
}
|
|
@@ -141,8 +168,16 @@ export async function readJsonFile(path) {
|
|
|
141
168
|
if (isNodeError(error, "ENOENT"))
|
|
142
169
|
return undefined;
|
|
143
170
|
if (error instanceof SyntaxError)
|
|
144
|
-
throw new Error(`invalid JSON file: ${path}`, { cause: error })
|
|
145
|
-
|
|
171
|
+
throw withStartupContext(new Error(`invalid JSON file: ${path}`, { cause: error }), {
|
|
172
|
+
component: "cli",
|
|
173
|
+
phase: "created",
|
|
174
|
+
context: { path, resource: "configuration", operation: "read-json" }
|
|
175
|
+
}, "LOCAL_STATE_INVALID");
|
|
176
|
+
throw withStartupContext(error, {
|
|
177
|
+
component: "cli",
|
|
178
|
+
phase: "created",
|
|
179
|
+
context: { path, resource: "configuration", operation: "read" }
|
|
180
|
+
});
|
|
146
181
|
}
|
|
147
182
|
}
|
|
148
183
|
export async function writeJsonAtomic(path, value) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-cli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.11",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -9,28 +9,28 @@
|
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
10
|
"dependencies": {
|
|
11
11
|
"commander": "15.0.0",
|
|
12
|
-
"@mininglamp-oss/octo-runtime-adapter-dsh": "1.1.
|
|
13
|
-
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.
|
|
12
|
+
"@mininglamp-oss/octo-runtime-adapter-dsh": "1.1.11",
|
|
13
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.11",
|
|
14
14
|
"json5": "2.2.3",
|
|
15
|
-
"@mininglamp-oss/octo-runtime-extra-channel-gateway": "1.1.
|
|
16
|
-
"@mininglamp-oss/octo-runtime-host-sdk": "1.1.
|
|
17
|
-
"@mininglamp-oss/octo-runtime-adapter-openclaw": "1.1.
|
|
18
|
-
"@mininglamp-oss/octo-runtime-cross-service": "1.1.
|
|
19
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
20
|
-
"@mininglamp-oss/octo-runtime-executor-kernel": "1.1.
|
|
21
|
-
"@mininglamp-oss/octo-runtime-executor-core": "1.1.
|
|
22
|
-
"@mininglamp-oss/octo-runtime-adapter-antigravity": "1.1.
|
|
23
|
-
"@mininglamp-oss/octo-runtime-adapter-claude-code": "1.1.
|
|
24
|
-
"@mininglamp-oss/octo-runtime-adapter-codebuddy": "1.1.
|
|
25
|
-
"@mininglamp-oss/octo-runtime-adapter-codex": "1.1.
|
|
26
|
-
"@mininglamp-oss/octo-runtime-adapter-hermes": "1.1.
|
|
27
|
-
"@mininglamp-oss/octo-runtime-adapter-grok-build": "1.1.
|
|
28
|
-
"@mininglamp-oss/octo-runtime-adapter-kimi-code": "1.1.
|
|
29
|
-
"@mininglamp-oss/octo-runtime-adapter-mcode": "1.1.
|
|
30
|
-
"@mininglamp-oss/octo-runtime-adapter-opencode": "1.1.
|
|
31
|
-
"@mininglamp-oss/octo-runtime-adapter-qodercli": "1.1.
|
|
32
|
-
"@mininglamp-oss/octo-runtime-adapter-qoderclicn": "1.1.
|
|
33
|
-
"@mininglamp-oss/octo-runtime-extra-channel-wecom": "1.1.
|
|
34
|
-
"@mininglamp-oss/octo-runtime-extra-webui": "1.1.
|
|
15
|
+
"@mininglamp-oss/octo-runtime-extra-channel-gateway": "1.1.11",
|
|
16
|
+
"@mininglamp-oss/octo-runtime-host-sdk": "1.1.11",
|
|
17
|
+
"@mininglamp-oss/octo-runtime-adapter-openclaw": "1.1.11",
|
|
18
|
+
"@mininglamp-oss/octo-runtime-cross-service": "1.1.11",
|
|
19
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.11",
|
|
20
|
+
"@mininglamp-oss/octo-runtime-executor-kernel": "1.1.11",
|
|
21
|
+
"@mininglamp-oss/octo-runtime-executor-core": "1.1.11",
|
|
22
|
+
"@mininglamp-oss/octo-runtime-adapter-antigravity": "1.1.11",
|
|
23
|
+
"@mininglamp-oss/octo-runtime-adapter-claude-code": "1.1.11",
|
|
24
|
+
"@mininglamp-oss/octo-runtime-adapter-codebuddy": "1.1.11",
|
|
25
|
+
"@mininglamp-oss/octo-runtime-adapter-codex": "1.1.11",
|
|
26
|
+
"@mininglamp-oss/octo-runtime-adapter-hermes": "1.1.11",
|
|
27
|
+
"@mininglamp-oss/octo-runtime-adapter-grok-build": "1.1.11",
|
|
28
|
+
"@mininglamp-oss/octo-runtime-adapter-kimi-code": "1.1.11",
|
|
29
|
+
"@mininglamp-oss/octo-runtime-adapter-mcode": "1.1.11",
|
|
30
|
+
"@mininglamp-oss/octo-runtime-adapter-opencode": "1.1.11",
|
|
31
|
+
"@mininglamp-oss/octo-runtime-adapter-qodercli": "1.1.11",
|
|
32
|
+
"@mininglamp-oss/octo-runtime-adapter-qoderclicn": "1.1.11",
|
|
33
|
+
"@mininglamp-oss/octo-runtime-extra-channel-wecom": "1.1.11",
|
|
34
|
+
"@mininglamp-oss/octo-runtime-extra-webui": "1.1.11"
|
|
35
35
|
}
|
|
36
36
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type AsyncQuestionReplySnapshot, type CanonicalEvent, type HostFrame, type InvokeEnvironment, type InvokeInput } from "@mininglamp-oss/octo-runtime-protocol";
|
|
2
|
+
import { type KernelClient } from "./types.js";
|
|
3
|
+
export type AsyncQuestionReplyResult = {
|
|
4
|
+
route: "steer";
|
|
5
|
+
acceptance: "provider_accepted";
|
|
6
|
+
} | {
|
|
7
|
+
route: "new_run";
|
|
8
|
+
input: InvokeInput;
|
|
9
|
+
events: AsyncGenerator<CanonicalEvent>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* 宿主持有的一份旁路问题控制者,不拥有 Kernel 或数据库。
|
|
13
|
+
* 活动时 steer,确认正常完成后复用 invoke;宿主须串行管理同会话、
|
|
14
|
+
* 保存提交状态并消费新 Run 尾流。新流返回不代表 Provider 接纳。
|
|
15
|
+
*/
|
|
16
|
+
export declare class AsyncQuestionReply {
|
|
17
|
+
#private;
|
|
18
|
+
readonly client: KernelClient;
|
|
19
|
+
readonly continuation: () => InvokeInput;
|
|
20
|
+
readonly environment?: InvokeEnvironment | undefined;
|
|
21
|
+
constructor(client: KernelClient, snapshot: AsyncQuestionReplySnapshot, continuation: () => InvokeInput, environment?: InvokeEnvironment | undefined);
|
|
22
|
+
/** 独立 JSON 副本供宿主保存;恢复 submitting/unknown 不会再次投递。 */
|
|
23
|
+
snapshot(): AsyncQuestionReplySnapshot;
|
|
24
|
+
/** 只接受原源流事实;消息 final 或查不到 Run 不能证明正常完成。 */
|
|
25
|
+
observe(frame: HostFrame): void;
|
|
26
|
+
/** 关闭旁路,不中断模型;原活动交互同步关闭,未知响应不重试。 */
|
|
27
|
+
cancel(): Promise<void>;
|
|
28
|
+
/** 整批一次。steer 等待 Provider ACK;new_run 必须消费返回流,沿原 invoke 管理执行。 */
|
|
29
|
+
respond(value: unknown): Promise<AsyncQuestionReplyResult>;
|
|
30
|
+
}
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { assertCanonicalEvent, assertHostFrame, assertHostFrameIdentity, assertHostRunReceipt, assertInvokeInput, assertJsonValue, assertQuestionRequest, assertQuestionResponse, questionAnswerText } from "@mininglamp-oss/octo-runtime-protocol";
|
|
3
|
+
import { KernelError } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* 宿主持有的一份旁路问题控制者,不拥有 Kernel 或数据库。
|
|
6
|
+
* 活动时 steer,确认正常完成后复用 invoke;宿主须串行管理同会话、
|
|
7
|
+
* 保存提交状态并消费新 Run 尾流。新流返回不代表 Provider 接纳。
|
|
8
|
+
*/
|
|
9
|
+
export class AsyncQuestionReply {
|
|
10
|
+
client;
|
|
11
|
+
continuation;
|
|
12
|
+
environment;
|
|
13
|
+
#snapshot;
|
|
14
|
+
constructor(client, snapshot, continuation, environment) {
|
|
15
|
+
this.client = client;
|
|
16
|
+
this.continuation = continuation;
|
|
17
|
+
this.environment = environment;
|
|
18
|
+
assertJsonValue(snapshot);
|
|
19
|
+
if (snapshot.schema !== "octo.async-question-reply/v1" ||
|
|
20
|
+
!["pending", "submitting", "answered", "cancelled", "invalidated", "unknown"].includes(snapshot.phase) ||
|
|
21
|
+
typeof snapshot.completed !== "boolean" ||
|
|
22
|
+
snapshot.ref.protocol_mode !== "canonical" ||
|
|
23
|
+
snapshot.ref.protocol !== "codex.app-server" ||
|
|
24
|
+
snapshot.question.delivery !== "async" ||
|
|
25
|
+
snapshot.question.kind !== "question" ||
|
|
26
|
+
snapshot.question.executionInstanceId !== snapshot.ref.invocation_id ||
|
|
27
|
+
!snapshot.providerSession.sessionId ||
|
|
28
|
+
snapshot.providerSession.resumable === false)
|
|
29
|
+
throw new KernelError("INVALID_ASYNC_QUESTION_SNAPSHOT");
|
|
30
|
+
const { kernel_instance_id, ...receipt } = snapshot.ref;
|
|
31
|
+
if (!kernel_instance_id)
|
|
32
|
+
throw new KernelError("INVALID_ASYNC_QUESTION_SNAPSHOT");
|
|
33
|
+
assertHostRunReceipt(receipt);
|
|
34
|
+
assertCanonicalEvent({
|
|
35
|
+
protocolVersion: 2,
|
|
36
|
+
type: "interaction.requested",
|
|
37
|
+
payload: snapshot.question
|
|
38
|
+
});
|
|
39
|
+
assertQuestionRequest(snapshot.question.request);
|
|
40
|
+
this.#snapshot = structuredClone(snapshot);
|
|
41
|
+
}
|
|
42
|
+
/** 独立 JSON 副本供宿主保存;恢复 submitting/unknown 不会再次投递。 */
|
|
43
|
+
snapshot() {
|
|
44
|
+
return structuredClone(this.#snapshot);
|
|
45
|
+
}
|
|
46
|
+
/** 只接受原源流事实;消息 final 或查不到 Run 不能证明正常完成。 */
|
|
47
|
+
observe(frame) {
|
|
48
|
+
assertHostFrame(frame);
|
|
49
|
+
const { kernel_instance_id: _instance, ...receipt } = this.#snapshot.ref;
|
|
50
|
+
void _instance;
|
|
51
|
+
assertHostFrameIdentity(frame, receipt);
|
|
52
|
+
if (frame.kind === "control" && frame.control.type === "state") {
|
|
53
|
+
if (frame.control.state === "completed")
|
|
54
|
+
this.#snapshot.completed = true;
|
|
55
|
+
else if (["failed", "cancelled", "lost"].includes(frame.control.state))
|
|
56
|
+
this.#snapshot.phase = "invalidated";
|
|
57
|
+
}
|
|
58
|
+
if (frame.kind === "canonical" &&
|
|
59
|
+
frame.event.type === "interaction.resolved" &&
|
|
60
|
+
frame.event.payload.interactionId === this.#snapshot.question.interactionId) {
|
|
61
|
+
const payload = frame.event.payload;
|
|
62
|
+
this.#snapshot.phase =
|
|
63
|
+
payload.reasonCode === "provider_accepted"
|
|
64
|
+
? "answered"
|
|
65
|
+
: payload.reasonCode === "submission_outcome_unknown"
|
|
66
|
+
? "unknown"
|
|
67
|
+
: "invalidated";
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** 关闭旁路,不中断模型;原活动交互同步关闭,未知响应不重试。 */
|
|
71
|
+
async cancel() {
|
|
72
|
+
this.#assertPending();
|
|
73
|
+
this.#snapshot.phase = "cancelled";
|
|
74
|
+
if (!this.#snapshot.completed) {
|
|
75
|
+
try {
|
|
76
|
+
await this.client.respond(this.#snapshot.ref, {
|
|
77
|
+
interactionId: this.#snapshot.question.interactionId,
|
|
78
|
+
outcome: "cancelled"
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
if (!(error instanceof KernelError) || error.code !== "INTERACTION_NOT_ACTIVE")
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/** 整批一次。steer 等待 Provider ACK;new_run 必须消费返回流,沿原 invoke 管理执行。 */
|
|
88
|
+
async respond(value) {
|
|
89
|
+
this.#assertPending();
|
|
90
|
+
const original = this.#snapshot;
|
|
91
|
+
assertQuestionRequest(original.question.request);
|
|
92
|
+
const answer = structuredClone(value);
|
|
93
|
+
assertQuestionResponse(answer);
|
|
94
|
+
const text = questionAnswerText(original.question.request, answer);
|
|
95
|
+
const next = structuredClone(this.continuation());
|
|
96
|
+
assertInvokeInput(next);
|
|
97
|
+
// 现有会话由宿主显式提供,旧题不能跨 reset 或 Provider binding 改投。
|
|
98
|
+
if (next.sessionId !== original.ref.agent_session_id ||
|
|
99
|
+
(next.sessionGeneration ?? 0) !== original.ref.session_generation ||
|
|
100
|
+
next.providerSession?.sessionId !== original.providerSession.sessionId ||
|
|
101
|
+
next.providerSession?.resumable === false ||
|
|
102
|
+
next.providerEpoch !== original.providerEpoch)
|
|
103
|
+
throw new KernelError("ASYNC_QUESTION_SESSION_STALE");
|
|
104
|
+
original.phase = "submitting";
|
|
105
|
+
let attempted = false;
|
|
106
|
+
try {
|
|
107
|
+
if (!original.completed) {
|
|
108
|
+
const current = await this.client.get(original.ref, original.ref.kernel_instance_id);
|
|
109
|
+
if (current.terminal)
|
|
110
|
+
this.observe(current.terminal);
|
|
111
|
+
if (this.snapshot().phase === "invalidated")
|
|
112
|
+
throw new KernelError("INTERACTION_NOT_ACTIVE");
|
|
113
|
+
}
|
|
114
|
+
if (!original.completed) {
|
|
115
|
+
attempted = true;
|
|
116
|
+
try {
|
|
117
|
+
this.#assertNotExpired();
|
|
118
|
+
await this.client.respond(original.ref, {
|
|
119
|
+
interactionId: original.question.interactionId,
|
|
120
|
+
outcome: "answered",
|
|
121
|
+
value: answer
|
|
122
|
+
});
|
|
123
|
+
original.phase = "answered";
|
|
124
|
+
return { route: "steer", acceptance: "provider_accepted" };
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
if (!(error instanceof KernelError) ||
|
|
128
|
+
!["INTERACTION_NOT_ACTIVE", "ASYNC_ANSWER_REJECTED"].includes(error.code))
|
|
129
|
+
throw error;
|
|
130
|
+
// 仅明确未接纳才可在正常终态之后续跑;ACK 丢失和写后失联绝不进入此分支。
|
|
131
|
+
attempted = false;
|
|
132
|
+
const current = await this.client.get(original.ref, original.ref.kernel_instance_id);
|
|
133
|
+
if (current.terminal)
|
|
134
|
+
this.observe(current.terminal);
|
|
135
|
+
if (!original.completed) {
|
|
136
|
+
original.phase = "invalidated";
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const input = {
|
|
142
|
+
...next,
|
|
143
|
+
runId: randomUUID(),
|
|
144
|
+
invocationId: randomUUID(),
|
|
145
|
+
protocol_mode: "canonical",
|
|
146
|
+
continuityMode: "continue",
|
|
147
|
+
inputs: [{ type: "text", text }],
|
|
148
|
+
prompt: text,
|
|
149
|
+
modelInput: text,
|
|
150
|
+
providerSession: { ...original.providerSession, requireResume: true },
|
|
151
|
+
freshFallbackModelInput: text,
|
|
152
|
+
freshFallbackModelInputParts: [{ type: "text", text }]
|
|
153
|
+
};
|
|
154
|
+
const client = this.client, environment = this.environment;
|
|
155
|
+
const beforeInvoke = () => {
|
|
156
|
+
this.#assertNotExpired();
|
|
157
|
+
const currentInput = this.continuation();
|
|
158
|
+
if (currentInput.sessionId !== input.sessionId ||
|
|
159
|
+
(currentInput.sessionGeneration ?? 0) !== original.ref.session_generation ||
|
|
160
|
+
currentInput.providerSession?.sessionId !== original.providerSession.sessionId ||
|
|
161
|
+
currentInput.providerEpoch !== original.providerEpoch)
|
|
162
|
+
throw new KernelError("ASYNC_QUESTION_SESSION_STALE");
|
|
163
|
+
};
|
|
164
|
+
const events = (async function* () {
|
|
165
|
+
try {
|
|
166
|
+
beforeInvoke();
|
|
167
|
+
for await (const event of client.invoke(input, environment)) {
|
|
168
|
+
if (event.type === "session.update" &&
|
|
169
|
+
event.payload.providerSession?.sessionId === original.providerSession.sessionId &&
|
|
170
|
+
event.payload.providerSession.resumeOutcome === "resumed")
|
|
171
|
+
original.phase = "answered";
|
|
172
|
+
yield event;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
finally {
|
|
176
|
+
if (original.phase === "submitting")
|
|
177
|
+
original.phase = "unknown";
|
|
178
|
+
}
|
|
179
|
+
})();
|
|
180
|
+
return { route: "new_run", input: structuredClone(input), events };
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
if (original.phase === "submitting")
|
|
184
|
+
original.phase = attempted ? "unknown" : "pending";
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
#assertPending() {
|
|
189
|
+
const snapshot = this.#snapshot;
|
|
190
|
+
if (snapshot.phase !== "pending")
|
|
191
|
+
throw new KernelError("INTERACTION_NOT_ACTIVE");
|
|
192
|
+
this.#assertNotExpired();
|
|
193
|
+
}
|
|
194
|
+
#assertNotExpired() {
|
|
195
|
+
const expiresAt = this.#snapshot.question.expiresAt;
|
|
196
|
+
if (expiresAt !== undefined && Date.parse(expiresAt) <= Date.now())
|
|
197
|
+
throw new KernelError("INTERACTION_NOT_ACTIVE");
|
|
198
|
+
}
|
|
199
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@mininglamp-oss/octo-runtime-protocol/browser";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "@mininglamp-oss/octo-runtime-protocol/browser";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type KernelClient } from "./types.js";
|
|
2
|
+
/**
|
|
3
|
+
* 连接本机 socket/Windows Pipe,返回不拥有 Kernel 进程的客户端。
|
|
4
|
+
* 独立应用显式连接已有服务;原生 SDK 服务宿主使用 kernel.client。
|
|
5
|
+
* Kernel/Extra 服务内部也复用本函数构造 RPC 客户端,不要求 SDK 调用方额外 attach。
|
|
6
|
+
* invoke 提供登记、取消和尾流观察;关闭连接或迭代器不会隐式取消已接纳 Run。
|
|
7
|
+
*/
|
|
8
|
+
export declare function attachKernel(options: {
|
|
9
|
+
endpoint: string;
|
|
10
|
+
}): KernelClient;
|