@mininglamp-oss/octo-runtime 1.1.8 → 1.1.10
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 +3 -1
- package/{node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runtime-configuration.d.ts → apps/cli/dist/adapter-configuration.d.ts} +1 -0
- package/{node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runtime-configuration.js → apps/cli/dist/adapter-configuration.js} +1 -0
- package/apps/cli/dist/adapter-configurations.d.ts +1 -1
- package/apps/cli/dist/adapter-configurations.js +1 -1
- package/apps/cli/dist/adapters.d.ts +7 -0
- package/apps/cli/dist/adapters.js +51 -0
- package/apps/cli/dist/build-info.json +2 -2
- package/apps/cli/dist/command-tree.js +3 -1
- package/apps/cli/dist/help.js +1 -1
- package/apps/cli/dist/index.js +4 -0
- package/apps/cli/dist/main.d.ts +2 -0
- package/apps/cli/dist/main.js +10 -12
- package/apps/cli/dist/manifest.json +0 -5
- package/apps/cli/dist/output.js +7 -9
- package/apps/cli/dist/playboard-interrupt.d.ts +6 -0
- package/apps/cli/dist/playboard-interrupt.js +86 -0
- package/apps/cli/dist/playboard.d.ts +2 -0
- package/apps/cli/dist/playboard.js +20 -12
- package/dist/public/executor-kernel.d.ts +2 -3
- package/dist/public/executor-kernel.js +1 -2
- package/dist/public/protocol.d.ts +1 -1
- package/dist/public/protocol.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
- 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 +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/app-server.js +200 -106
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/async-questions.d.ts +27 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/async-questions.js +205 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/stdin-writer.d.ts +30 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/dist/stdin-writer.js +223 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-V5W6ZTYC.js → chunk-FGFEM7JP.js} +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-CFKMMCO6.js → chunk-R3PDZLX5.js} +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/{chunk-LO34KB7D.js → chunk-TSRZVLIG.js} +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/dist/dsh-sdk-NOTICE.txt +2 -2
- 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.js +5 -5
- 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/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/dist/gateway.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/gateway.js +57 -13
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.d.ts +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/dist/index.js +4 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
- 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/approval.js +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/reasoning.js +1 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/service-status.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/service-status.js +12 -30
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapter-configuration.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapter-configuration.js +125 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapter-configurations.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapter-configurations.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.d.ts +7 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/adapters.js +51 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/command-tree.js +3 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/help.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/index.js +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/main.js +10 -12
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/manifest.json +0 -5
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +7 -9
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard-interrupt.d.ts +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard-interrupt.js +86 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.js +20 -12
- package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +23 -24
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/launchd.d.ts +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/dist/launchd.js +12 -11
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/experience.js +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.d.ts +8 -7
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +33 -11
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/invoke-input.js +9 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/watchdog.js +6 -3
- 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 +30 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/async-question-reply.js +199 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/client.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/client.js +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/execution-source.d.ts +17 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/execution-source.js +21 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/host-run-service.d.ts +9 -9
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/host-run-service.js +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.d.ts +2 -6
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.js +3 -6
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-manifest.d.ts +14 -13
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/invocation-manifest.js +84 -187
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.d.ts +5 -8
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.js +77 -53
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/service.d.ts +5 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/service.js +15 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +4 -12
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/im-channel.js +6 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/contracts.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/task.js +14 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.js +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/interaction-card.js +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/session-command.d.ts +9 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/session-command.js +71 -0
- 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/application/im-channel.js +14 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/web/assets/{index-B127MhT-.js → index-BLMf2Etg.js} +2 -4
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/web/index.html +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/context-loader.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/browser.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/browser.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/context.js +4 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/failure.js +63 -12
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/generated/protocol-types.d.ts +110 -20
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.d.ts +7 -4
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/index.js +28 -6
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/invoke-input.js +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/questions.d.ts +9 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/questions.js +84 -0
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/dist/run-protocol.js +11 -5
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
- package/package.json +26 -28
- package/packages/octo-runtime-protocol/schema/protocol.schema.json +157 -41
- package/apps/cli/dist/worker.d.ts +0 -1
- package/apps/cli/dist/worker.js +0 -18
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/app-server.d.ts +0 -63
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/app-server.js +0 -846
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/index.d.ts +0 -54
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/dist/index.js +0 -154
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/package.json +0 -15
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/worker.d.ts +0 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/worker.js +0 -18
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/heartbeat.d.ts +0 -16
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/heartbeat.js +0 -59
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/manifest-adapters.d.ts +0 -6
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/manifest-adapters.js +0 -88
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/module-specifier.d.ts +0 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/module-specifier.js +0 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/process.d.ts +0 -42
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/process.js +0 -292
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/rpc.d.ts +0 -62
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/rpc.js +0 -661
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runner.d.ts +0 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/runner.js +0 -5
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/serve.d.ts +0 -10
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/serve.js +0 -96
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/supervisor.d.ts +0 -15
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/supervisor.js +0 -279
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-adapter-mcode",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.
|
|
12
|
+
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.10"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { RuntimeLog } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
1
2
|
export interface OpenClawDeviceIdentity {
|
|
2
3
|
deviceId: string;
|
|
3
4
|
publicKey: string;
|
|
@@ -9,6 +10,8 @@ export interface OpenClawGatewayOptions {
|
|
|
9
10
|
device: OpenClawDeviceIdentity;
|
|
10
11
|
connectTimeoutMs?: number;
|
|
11
12
|
requestTimeoutMs?: number;
|
|
13
|
+
/** 元数据诊断 sink;缺省写 stderr,不写 worker 的 stdout RPC 通道。 */
|
|
14
|
+
log?: RuntimeLog;
|
|
12
15
|
}
|
|
13
16
|
export interface OpenClawGatewayEvent {
|
|
14
17
|
event: string;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { createHash, generateKeyPairSync, randomUUID, sign } from "node:crypto";
|
|
2
|
+
import { writeSync } from "node:fs";
|
|
2
3
|
import WebSocket from "ws";
|
|
3
4
|
import { isGatewayRunPending } from "./compatibility.js";
|
|
4
5
|
const PROTOCOL_VERSION = 4;
|
|
@@ -93,7 +94,7 @@ export class OpenClawGatewayClient {
|
|
|
93
94
|
#socket;
|
|
94
95
|
#hello;
|
|
95
96
|
#connectPromise;
|
|
96
|
-
#
|
|
97
|
+
#invalidFrameCount = 0;
|
|
97
98
|
constructor(options) {
|
|
98
99
|
this.#options = options;
|
|
99
100
|
}
|
|
@@ -110,13 +111,12 @@ export class OpenClawGatewayClient {
|
|
|
110
111
|
}
|
|
111
112
|
async #open() {
|
|
112
113
|
const requestId = `req_${randomUUID().replaceAll("-", "")}`;
|
|
113
|
-
this.#connectionRequestId = requestId;
|
|
114
114
|
const socket = new WebSocket(this.#options.url, {
|
|
115
115
|
headers: { [REQUEST_ID_HEADER]: requestId },
|
|
116
116
|
maxPayload: 25 * 1024 * 1024
|
|
117
117
|
});
|
|
118
118
|
this.#socket = socket;
|
|
119
|
-
socket.on("message", (data) => this.#onMessage(
|
|
119
|
+
socket.on("message", (data) => this.#onMessage(data));
|
|
120
120
|
socket.on("close", (code, reason) => this.#failPending(withRequestId(new Error(`OpenClaw Gateway closed (${code}): ${reason.toString()}`), requestId)));
|
|
121
121
|
socket.on("error", (error) => this.#failPending(withRequestId(error, requestId)));
|
|
122
122
|
const timeoutMs = this.#options.connectTimeoutMs ?? 10_000;
|
|
@@ -270,26 +270,70 @@ export class OpenClawGatewayClient {
|
|
|
270
270
|
timer.unref?.();
|
|
271
271
|
});
|
|
272
272
|
}
|
|
273
|
-
|
|
274
|
-
|
|
273
|
+
/** 跳过坏消息不改变连接、pending 或原期限;仅诊断采样,不能当作执行进度。 */
|
|
274
|
+
#ignoreFrame(reason) {
|
|
275
|
+
if (this.#invalidFrameCount === Number.MAX_SAFE_INTEGER)
|
|
276
|
+
return;
|
|
277
|
+
const count = ++this.#invalidFrameCount;
|
|
278
|
+
if (count > 10 && count % 100 !== 0)
|
|
279
|
+
return;
|
|
280
|
+
const data = { adapter_type: "openclaw", reason_code: reason, frame_count: count };
|
|
281
|
+
try {
|
|
282
|
+
if (this.#options.log) {
|
|
283
|
+
const result = this.#options.log("warn", "openclaw.gateway.invalid_frame", data);
|
|
284
|
+
// void sink 也可由 async 函数实现;只观察拒绝,不等待、不重试日志。
|
|
285
|
+
if (result && typeof result.then === "function")
|
|
286
|
+
void Promise.resolve(result).catch(() => undefined);
|
|
287
|
+
}
|
|
288
|
+
else {
|
|
289
|
+
// 固定、小于 512 字节的元数据;同步写避免后台排队,EPIPE 等仅丢失本条诊断。
|
|
290
|
+
writeSync(2, `${JSON.stringify({ level: "warn", event: "openclaw.gateway.invalid_frame", ...data })}\n`);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
catch {
|
|
294
|
+
/* 日志失败不影响本消息的跳过,更不能打断下一条合法消息。 */
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
#onMessage(data) {
|
|
298
|
+
let text;
|
|
299
|
+
try {
|
|
300
|
+
text = messageText(data);
|
|
301
|
+
}
|
|
302
|
+
catch {
|
|
303
|
+
this.#ignoreFrame("invalid_message");
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
let value;
|
|
275
307
|
try {
|
|
276
|
-
|
|
308
|
+
value = JSON.parse(text);
|
|
277
309
|
}
|
|
278
310
|
catch {
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
311
|
+
this.#ignoreFrame("invalid_json");
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
const frame = record(value);
|
|
315
|
+
if (!frame || typeof frame.type !== "string") {
|
|
316
|
+
this.#ignoreFrame("invalid_shape");
|
|
284
317
|
return;
|
|
285
318
|
}
|
|
286
|
-
|
|
319
|
+
// 只验证路由字段,扩展字段与 payload 保持原生合同;业务回调不在解析 catch 内。
|
|
320
|
+
if (frame.type === "event") {
|
|
321
|
+
if (typeof frame.event !== "string" || !frame.event) {
|
|
322
|
+
this.#ignoreFrame("invalid_event");
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
287
325
|
for (const listener of this.#listeners)
|
|
288
326
|
listener({ event: frame.event, payload: frame.payload });
|
|
289
327
|
return;
|
|
290
328
|
}
|
|
291
|
-
if (frame.type !== "res"
|
|
329
|
+
if (frame.type !== "res") {
|
|
330
|
+
this.#ignoreFrame("unknown_type");
|
|
292
331
|
return;
|
|
332
|
+
}
|
|
333
|
+
if (typeof frame.id !== "string" || !frame.id || typeof frame.ok !== "boolean") {
|
|
334
|
+
this.#ignoreFrame("invalid_response");
|
|
335
|
+
return;
|
|
336
|
+
}
|
|
293
337
|
const pending = this.#pending.get(frame.id);
|
|
294
338
|
if (!pending)
|
|
295
339
|
return;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type AdapterInvocationContext, type AdapterProbeOptions, type CanonicalEvent, type InvokeRequest } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
1
|
+
import { type AdapterInvocationContext, type AdapterProbeOptions, type CanonicalEvent, type InvokeRequest, type RuntimeLog } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
2
2
|
import { type InteractionResponse } from "@mininglamp-oss/octo-runtime-protocol";
|
|
3
3
|
import { type OpenClawGatewayEvent, type OpenClawGatewayOptions } from "./gateway.js";
|
|
4
4
|
type JsonRecord = Record<string, unknown>;
|
|
@@ -33,8 +33,9 @@ export interface OpenClawGatewayClientLike {
|
|
|
33
33
|
close(): Promise<void>;
|
|
34
34
|
}
|
|
35
35
|
type GatewayClientFactory = (options: OpenClawGatewayOptions) => OpenClawGatewayClientLike;
|
|
36
|
-
export declare function createOpenClawAdapter({ clientFactory }?: {
|
|
36
|
+
export declare function createOpenClawAdapter({ clientFactory, log }?: {
|
|
37
37
|
clientFactory?: GatewayClientFactory;
|
|
38
|
+
log?: RuntimeLog;
|
|
38
39
|
}): Readonly<Omit<{
|
|
39
40
|
metadata: {
|
|
40
41
|
type: string;
|
|
@@ -1185,12 +1185,12 @@ async function* invokeOpenClawGateway(req, invocation, context, clientFactory, p
|
|
|
1185
1185
|
await stop(!terminal);
|
|
1186
1186
|
}
|
|
1187
1187
|
}
|
|
1188
|
-
export function createOpenClawAdapter({ clientFactory = (options) => new OpenClawGatewayClient(options) } = {}) {
|
|
1188
|
+
export function createOpenClawAdapter({ clientFactory = (options) => new OpenClawGatewayClient(options), log } = {}) {
|
|
1189
1189
|
const responders = new Map();
|
|
1190
1190
|
const probeGateway = async (options) => {
|
|
1191
1191
|
let client;
|
|
1192
1192
|
try {
|
|
1193
|
-
client = clientFactory(await resolveOpenClawGateway(options?.providerOptions));
|
|
1193
|
+
client = clientFactory({ ...(await resolveOpenClawGateway(options?.providerOptions)), log });
|
|
1194
1194
|
resolveGatewayContract(await client.connect());
|
|
1195
1195
|
await client.request("agents.list", {});
|
|
1196
1196
|
return { available: true, command: "openclaw-gateway" };
|
|
@@ -1240,6 +1240,8 @@ export function createOpenClawAdapter({ clientFactory = (options) => new OpenCla
|
|
|
1240
1240
|
}
|
|
1241
1241
|
};
|
|
1242
1242
|
const invocation = buildOpenClawGatewayInvocation(req);
|
|
1243
|
+
// 本轮及其对账/取消恢复连接共用本轮 sink;probe 则只使用工厂 sink。
|
|
1244
|
+
invocation.gateway.log = context?.log ?? log;
|
|
1243
1245
|
const bridge = new AcpApprovalBridge(req, 600_000, {
|
|
1244
1246
|
providerDecisions: true,
|
|
1245
1247
|
providerManagedExpiry: true
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-adapter-openclaw",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
9
|
-
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.
|
|
8
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.10",
|
|
9
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.10",
|
|
10
10
|
"ws": "8.22.0"
|
|
11
11
|
},
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-adapter-opencode",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
9
|
-
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.
|
|
10
|
-
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.
|
|
8
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.10",
|
|
9
|
+
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.10",
|
|
10
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.10"
|
|
11
11
|
},
|
|
12
12
|
"types": "./dist/index.d.ts",
|
|
13
13
|
"files": [
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-adapter-qodercli",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.
|
|
12
|
+
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.10"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-adapter-qoderclicn",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
@@ -9,6 +9,6 @@
|
|
|
9
9
|
"dist"
|
|
10
10
|
],
|
|
11
11
|
"dependencies": {
|
|
12
|
-
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.
|
|
12
|
+
"@mininglamp-oss/octo-runtime-adapter-acp": "1.1.10"
|
|
13
13
|
}
|
|
14
14
|
}
|
|
@@ -112,6 +112,8 @@ export class AcpApprovalBridge {
|
|
|
112
112
|
payload: {
|
|
113
113
|
interactionId,
|
|
114
114
|
kind: "approval",
|
|
115
|
+
// 自动响应仍须等待 responseWritten 确认;此字段只说明回答的所有者。
|
|
116
|
+
responseRequired: !automatic,
|
|
115
117
|
executionInstanceId: this.request.invocationId,
|
|
116
118
|
expiresAt: new Date(expiresAt).toISOString(),
|
|
117
119
|
request: {
|
|
@@ -28,8 +28,7 @@ export const DEFAULT_REASONING_LEVEL_MAPS = Object.freeze({
|
|
|
28
28
|
"kimi-code": null,
|
|
29
29
|
mcode: null,
|
|
30
30
|
qodercli: null,
|
|
31
|
-
qoderclicn: null
|
|
32
|
-
"zcode-gui": null
|
|
31
|
+
qoderclicn: null
|
|
33
32
|
});
|
|
34
33
|
export function reasoningLevelMap(adapterType) {
|
|
35
34
|
return Object.hasOwn(DEFAULT_REASONING_LEVEL_MAPS, adapterType)
|
|
@@ -14,7 +14,7 @@ export interface KernelStatusRecord {
|
|
|
14
14
|
event: string;
|
|
15
15
|
data: Record<string, string | number>;
|
|
16
16
|
}
|
|
17
|
-
/** Kernel
|
|
17
|
+
/** Kernel 原生生命周期诊断白名单;读盘时也重建,绝不包含执行正文或原始异常。 */
|
|
18
18
|
export declare function kernelStatusRecord(level: RuntimeLogLevel, event: string, data?: Readonly<Record<string, unknown>>, time?: string): KernelStatusRecord | undefined;
|
|
19
19
|
/** Rebuild status records from a separate allowlist, including when reading persisted files. */
|
|
20
20
|
export declare function extraStatusRecord(extra: string, level: RuntimeLogLevel, event: string, data?: Readonly<Record<string, unknown>>, time?: string): ExtraStatusRecord | undefined;
|
|
@@ -1,41 +1,23 @@
|
|
|
1
|
-
/** Kernel
|
|
1
|
+
/** Kernel 原生生命周期诊断白名单;读盘时也重建,绝不包含执行正文或原始异常。 */
|
|
2
2
|
export function kernelStatusRecord(level, event, data, time = new Date().toISOString()) {
|
|
3
3
|
if (!["info", "warn", "error"].includes(level) ||
|
|
4
4
|
![
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
"
|
|
9
|
-
"
|
|
5
|
+
"kernel.ready",
|
|
6
|
+
"kernel.closing",
|
|
7
|
+
"kernel.execution_drained",
|
|
8
|
+
"kernel.cleanup_incomplete",
|
|
9
|
+
"kernel.start_failed"
|
|
10
10
|
].includes(event) ||
|
|
11
11
|
!/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(time) ||
|
|
12
12
|
!Number.isFinite(Date.parse(time)))
|
|
13
13
|
return;
|
|
14
14
|
const safe = {};
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
: key === "signal"
|
|
22
|
-
? /^SIG[A-Z0-9]+$/.test(value)
|
|
23
|
-
: key === "trigger"
|
|
24
|
-
? ["exit", "error", "heartbeat", "ipc"].includes(value)
|
|
25
|
-
: key === "stage"
|
|
26
|
-
? ["cleanup", "manifest", "starting", "backoff"].includes(value)
|
|
27
|
-
: /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}\.\d{3}Z$/.test(value) &&
|
|
28
|
-
Number.isFinite(Date.parse(value));
|
|
29
|
-
if (valid)
|
|
30
|
-
safe[key] = value;
|
|
31
|
-
}
|
|
32
|
-
for (const key of ["pid", "generation", "attempt", "delay_ms", "exit_code"]) {
|
|
33
|
-
const value = data?.[key];
|
|
34
|
-
if (typeof value === "number" &&
|
|
35
|
-
Number.isSafeInteger(value) &&
|
|
36
|
-
(key === "exit_code" || value >= 0))
|
|
37
|
-
safe[key] = value;
|
|
38
|
-
}
|
|
15
|
+
const code = data?.code;
|
|
16
|
+
if (typeof code === "string" && /^[A-Z][A-Z0-9_]{0,95}$/.test(code))
|
|
17
|
+
safe.code = code;
|
|
18
|
+
const pid = data?.pid;
|
|
19
|
+
if (typeof pid === "number" && Number.isSafeInteger(pid) && pid >= 0)
|
|
20
|
+
safe.pid = pid;
|
|
39
21
|
return Object.freeze({ time, level, source: "kernel", event, data: Object.freeze(safe) });
|
|
40
22
|
}
|
|
41
23
|
const events = new Set([
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-adapter-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.10",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"./module-manifest": "./dist/module-manifest.js"
|
|
11
11
|
},
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
13
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.10",
|
|
14
14
|
"import-meta-resolve": "4.2.0"
|
|
15
15
|
},
|
|
16
16
|
"types": "./dist/index.d.ts",
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { AdapterProbeOptions } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
2
|
+
/** CLI 读取 profile 配置和凭据引用,返回配置值;Kernel 不读取这些文件或路径。 */
|
|
3
|
+
export declare function readAdapterConfigurations(profileRoot: string, adaptersValue: unknown): Record<string, AdapterProbeOptions>;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { readFileSync, realpathSync } from "node:fs";
|
|
2
|
+
import { isAbsolute, join, relative, resolve } from "node:path";
|
|
3
|
+
import { resolveStreamLimitPolicy } from "@mininglamp-oss/octo-runtime-protocol";
|
|
4
|
+
/** CLI 读取 profile 配置和凭据引用,返回配置值;Kernel 不读取这些文件或路径。 */
|
|
5
|
+
export function readAdapterConfigurations(profileRoot, adaptersValue) {
|
|
6
|
+
const adapters = objectValue(adaptersValue);
|
|
7
|
+
const connections = { openclaw: { providerOptions: { OPENCLAW_RUNTIME_ROOT: profileRoot } } };
|
|
8
|
+
if (!adapters)
|
|
9
|
+
return connections;
|
|
10
|
+
if (adapters.openclaw !== undefined)
|
|
11
|
+
throw new Error("OpenClaw uses adapters/openclaw/connection.json; remove the obsolete external binding and configure this Runtime connection");
|
|
12
|
+
return {
|
|
13
|
+
...connections,
|
|
14
|
+
...Object.fromEntries(Object.entries(adapters).map(([adapterType, value]) => {
|
|
15
|
+
if (!/^[a-z0-9][a-z0-9-]{0,127}$/.test(adapterType)) {
|
|
16
|
+
throw new Error(`managed adapter type is invalid: ${adapterType}`);
|
|
17
|
+
}
|
|
18
|
+
const adapter = objectValue(value);
|
|
19
|
+
const execution = objectValue(adapter?.execution);
|
|
20
|
+
if (!execution)
|
|
21
|
+
throw new Error(`managed ${adapterType} adapter execution manifest is missing`);
|
|
22
|
+
const publicOptions = stringRecord(execution.provider_options, `${adapterType} provider_options`);
|
|
23
|
+
assertNoCredentialLikeOptions(publicOptions, adapterType);
|
|
24
|
+
const credentialRef = optionalString(execution.credential_ref);
|
|
25
|
+
const credentialOptions = credentialRef
|
|
26
|
+
? readCredentialOptions(profileRoot, credentialRef, adapterType)
|
|
27
|
+
: {};
|
|
28
|
+
if (Object.hasOwn(execution, "managed_workspace"))
|
|
29
|
+
throw new TypeError("LOCAL_PLUGIN_CONFIGURATION_REQUIRED");
|
|
30
|
+
return [
|
|
31
|
+
adapterType,
|
|
32
|
+
{
|
|
33
|
+
providerOptions: { ...publicOptions, ...credentialOptions },
|
|
34
|
+
...(execution.stream_limits === undefined
|
|
35
|
+
? {}
|
|
36
|
+
: { streamLimits: readStreamLimits(execution.stream_limits, adapterType) })
|
|
37
|
+
}
|
|
38
|
+
];
|
|
39
|
+
}))
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
const STREAM_LIMIT_FIELDS = {
|
|
43
|
+
raw_message_max_bytes: "rawMessageMaxBytes",
|
|
44
|
+
adapter_queue_item_max_bytes: "adapterQueueItemMaxBytes",
|
|
45
|
+
adapter_queue_max_bytes: "adapterQueueMaxBytes",
|
|
46
|
+
adapter_queue_max_items: "adapterQueueMaxItems",
|
|
47
|
+
host_frame_max_bytes: "hostFrameMaxBytes",
|
|
48
|
+
rpc_queue_max_bytes: "rpcQueueMaxBytes",
|
|
49
|
+
rpc_queue_max_items: "rpcQueueMaxItems",
|
|
50
|
+
replay_run_max_bytes: "replayRunMaxBytes",
|
|
51
|
+
replay_run_max_items: "replayRunMaxItems",
|
|
52
|
+
replay_global_max_bytes: "replayGlobalMaxBytes"
|
|
53
|
+
};
|
|
54
|
+
function readStreamLimits(value, adapterType) {
|
|
55
|
+
const record = objectValue(value);
|
|
56
|
+
if (!record)
|
|
57
|
+
throw new TypeError(`managed ${adapterType} stream_limits must be an object`);
|
|
58
|
+
const overrides = {};
|
|
59
|
+
for (const [key, entry] of Object.entries(record)) {
|
|
60
|
+
const field = STREAM_LIMIT_FIELDS[key];
|
|
61
|
+
if (!field)
|
|
62
|
+
throw new TypeError(`managed ${adapterType} stream_limits.${key} is unknown`);
|
|
63
|
+
if (!Number.isSafeInteger(entry) || entry < 1)
|
|
64
|
+
throw new TypeError(`managed ${adapterType} stream_limits.${key} must be a positive integer`);
|
|
65
|
+
overrides[field] = entry;
|
|
66
|
+
}
|
|
67
|
+
return { ...resolveStreamLimitPolicy(overrides) };
|
|
68
|
+
}
|
|
69
|
+
function readCredentialOptions(profileRoot, credentialRef, adapterType) {
|
|
70
|
+
const credentialsRoot = realpathSync(join(profileRoot, "credentials"));
|
|
71
|
+
const credentialPath = realpathSync(resolve(profileRoot, credentialRef));
|
|
72
|
+
const relativeCredential = relative(credentialsRoot, credentialPath);
|
|
73
|
+
if (relativeCredential.startsWith("..") || isAbsolute(relativeCredential)) {
|
|
74
|
+
throw new Error(`managed ${adapterType} credential_ref resolves outside the profile credentials directory`);
|
|
75
|
+
}
|
|
76
|
+
const credential = readJsonRequired(credentialPath);
|
|
77
|
+
if (credential.schema_version !== 1)
|
|
78
|
+
throw new Error(`managed ${adapterType} credential is invalid`);
|
|
79
|
+
return stringRecord(credential.provider_options, `${adapterType} credential provider_options`);
|
|
80
|
+
}
|
|
81
|
+
function stringRecord(value, name) {
|
|
82
|
+
const record = objectValue(value);
|
|
83
|
+
if (!record)
|
|
84
|
+
throw new Error(`managed ${name} is required`);
|
|
85
|
+
return Object.fromEntries(Object.entries(record).map(([key, entry]) => [key, requiredString(entry, `${name}.${key}`)]));
|
|
86
|
+
}
|
|
87
|
+
function assertNoCredentialLikeOptions(options, adapterType) {
|
|
88
|
+
for (const key of Object.keys(options)) {
|
|
89
|
+
if (/(?:TOKEN|SECRET|PASSWORD|PRIVATE_KEY|CREDENTIAL)/i.test(key)) {
|
|
90
|
+
throw new Error(`managed ${adapterType} public provider_options contains credential-like key ${key}`);
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function readJsonOptional(path) {
|
|
95
|
+
try {
|
|
96
|
+
return JSON.parse(readFileSync(path, "utf8"));
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
if (isNodeError(error, "ENOENT"))
|
|
100
|
+
return undefined;
|
|
101
|
+
throw new Error(`cannot read managed config ${path}`, { cause: error });
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
function readJsonRequired(path) {
|
|
105
|
+
const value = readJsonOptional(path);
|
|
106
|
+
if (!value)
|
|
107
|
+
throw new Error(`managed setup file is missing: ${path}`);
|
|
108
|
+
return value;
|
|
109
|
+
}
|
|
110
|
+
function requiredString(value, name) {
|
|
111
|
+
if (typeof value !== "string" || !value.trim())
|
|
112
|
+
throw new Error(`managed ${name} is required`);
|
|
113
|
+
return value.trim();
|
|
114
|
+
}
|
|
115
|
+
function optionalString(value) {
|
|
116
|
+
return typeof value === "string" && value.trim() ? value.trim() : undefined;
|
|
117
|
+
}
|
|
118
|
+
function objectValue(value) {
|
|
119
|
+
return value !== null && typeof value === "object" && !Array.isArray(value)
|
|
120
|
+
? value
|
|
121
|
+
: undefined;
|
|
122
|
+
}
|
|
123
|
+
function isNodeError(error, code) {
|
|
124
|
+
return (error instanceof Error && "code" in error && error.code === code);
|
|
125
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
+
import { readAdapterConfigurations } from "./adapter-configuration.js";
|
|
1
2
|
import type { ModuleManifest } from "@mininglamp-oss/octo-runtime-adapter-sdk/module-manifest";
|
|
2
|
-
import { readAdapterConfigurations } from "@mininglamp-oss/octo-runtime-executor-kernel";
|
|
3
3
|
/** CLI 宿主在创建 Kernel 前补齐 npm DSH 入口;探测与调用共享快照,显式配置始终优先。 */
|
|
4
4
|
export declare function readCliAdapterConfigurations(profileRoot: string, adapters: unknown, manifest: ModuleManifest, env?: NodeJS.ProcessEnv): Promise<ReturnType<typeof readAdapterConfigurations>>;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
+
import { readAdapterConfigurations } from "./adapter-configuration.js";
|
|
1
2
|
import { constants } from "node:fs";
|
|
2
3
|
import { access, lstat, readFile, realpath, stat } from "node:fs/promises";
|
|
3
4
|
import { delimiter, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
|
|
4
5
|
import { processEnvironmentValue } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
5
|
-
import { readAdapterConfigurations } from "@mininglamp-oss/octo-runtime-executor-kernel";
|
|
6
6
|
/** CLI 宿主在创建 Kernel 前补齐 npm DSH 入口;探测与调用共享快照,显式配置始终优先。 */
|
|
7
7
|
export async function readCliAdapterConfigurations(profileRoot, adapters, manifest, env = process.env) {
|
|
8
8
|
const configurations = readAdapterConfigurations(profileRoot, adapters);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { type AdapterModuleEntry } from "@mininglamp-oss/octo-runtime-adapter-sdk/module-manifest";
|
|
2
|
+
import type { HostedAdapter } from "@mininglamp-oss/octo-runtime-executor-kernel";
|
|
3
|
+
/** CLI 只加载所选模块并构造实例;Kernel 不接触清单、模块路径或产品准备。 */
|
|
4
|
+
export declare function loadCliAdapters(entries: readonly AdapterModuleEntry[], options?: {
|
|
5
|
+
profileRoot: string;
|
|
6
|
+
syncOpenClawTools: boolean;
|
|
7
|
+
}): Promise<HostedAdapter[]>;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { resolveModuleSpecifier } from "@mininglamp-oss/octo-runtime-adapter-sdk/module-manifest";
|
|
2
|
+
import { readExtraDirectory } from "@mininglamp-oss/octo-runtime-host-sdk";
|
|
3
|
+
import { dirname, join } from "node:path";
|
|
4
|
+
/** CLI 只加载所选模块并构造实例;Kernel 不接触清单、模块路径或产品准备。 */
|
|
5
|
+
export async function loadCliAdapters(entries, options) {
|
|
6
|
+
const adapters = [];
|
|
7
|
+
for (const entry of entries) {
|
|
8
|
+
const specifier = resolveModuleSpecifier(entry.module, entry.sourceManifest);
|
|
9
|
+
const loaded = await import(specifier);
|
|
10
|
+
const exports = asRecord(loaded, `adapter module ${entry.module}`);
|
|
11
|
+
const exported = exports[entry.export];
|
|
12
|
+
if (exported === undefined)
|
|
13
|
+
throw new Error(`missing export ${entry.export} from ${entry.module}`);
|
|
14
|
+
// 动态模块先校验工厂与 Adapter 形状,再交给唯一 Core 注册;不提前探测未选模块。
|
|
15
|
+
const instance = entry.factory ? callFactory(exported, entry) : exported;
|
|
16
|
+
if (!isHostedAdapter(instance))
|
|
17
|
+
throw new TypeError(`${entry.module}#${entry.export} is not an Octo Runtime adapter`);
|
|
18
|
+
if (entry.type && instance.metadata.type !== entry.type)
|
|
19
|
+
throw new Error(`manifest type ${entry.type} does not match adapter ${instance.metadata.type}`);
|
|
20
|
+
adapters.push(instance);
|
|
21
|
+
}
|
|
22
|
+
if (options && adapters.some((adapter) => adapter.metadata.type === "openclaw")) {
|
|
23
|
+
const { initializeCliOpenClaw, syncCliOpenClawToolEnvironment } = await import("./openclaw.js");
|
|
24
|
+
await initializeCliOpenClaw(options.profileRoot);
|
|
25
|
+
if (options.syncOpenClawTools)
|
|
26
|
+
await syncCliOpenClawToolEnvironment(options.profileRoot, await readExtraDirectory(join(dirname(options.profileRoot), "extras")));
|
|
27
|
+
}
|
|
28
|
+
return adapters;
|
|
29
|
+
}
|
|
30
|
+
function callFactory(value, entry) {
|
|
31
|
+
if (typeof value !== "function")
|
|
32
|
+
throw new TypeError(`${entry.module}#${entry.export} is marked as a factory but is not callable`);
|
|
33
|
+
return value(entry.options);
|
|
34
|
+
}
|
|
35
|
+
function isHostedAdapter(value) {
|
|
36
|
+
if (!isRecord(value) || !isRecord(value.metadata))
|
|
37
|
+
return false;
|
|
38
|
+
return (typeof value.metadata.type === "string" &&
|
|
39
|
+
Array.isArray(value.metadata.agentSources) &&
|
|
40
|
+
value.metadata.agentSources.length > 0 &&
|
|
41
|
+
value.metadata.agentSources.every((source) => source === "preset" || source === "provisioned") &&
|
|
42
|
+
typeof value.invoke === "function");
|
|
43
|
+
}
|
|
44
|
+
function asRecord(value, label) {
|
|
45
|
+
if (!isRecord(value))
|
|
46
|
+
throw new TypeError(`${label} must be an object`);
|
|
47
|
+
return value;
|
|
48
|
+
}
|
|
49
|
+
function isRecord(value) {
|
|
50
|
+
return value !== null && typeof value === "object" && !Array.isArray(value);
|
|
51
|
+
}
|
|
@@ -230,7 +230,9 @@ export async function parseCliCommand(raw, dependencies) {
|
|
|
230
230
|
}
|
|
231
231
|
entries.push(metadata ?? { name, module: "", sourceManifest: "" });
|
|
232
232
|
}
|
|
233
|
-
const root = command("octo-runtime", "Manage the local Octo Agent runtime and independent services
|
|
233
|
+
const root = command("octo-runtime", "Manage the local Octo Agent runtime and independent services.\n\n" +
|
|
234
|
+
"Octo Runtime by Mininglamp Technology\n" +
|
|
235
|
+
"Open source on GitHub: https://github.com/Mininglamp-OSS/octo-runtime");
|
|
234
236
|
addHostOptions(root, args, !isExtra || (offline && !["extraset", "extraget"].includes(operands[1])));
|
|
235
237
|
option(root, "-v, --version", "Print version and build information", args);
|
|
236
238
|
// 旧服务参数可位于组件之前;根仅隐藏解析,所属动作仍在本层帮助展示。
|
|
@@ -44,7 +44,7 @@ export const lifecycleCommands = new Map([
|
|
|
44
44
|
export const rootCommands = new Map([
|
|
45
45
|
["adapter", "List and probe execution adapters"],
|
|
46
46
|
["doctor", "Diagnose the local runtime"],
|
|
47
|
-
["executor-kernel", "Manage
|
|
47
|
+
["executor-kernel", "Manage native Agent execution and local RPC"],
|
|
48
48
|
["extraget", "Read a complete service configuration (advanced)"],
|
|
49
49
|
["extraset", "Replace a complete service configuration from JSON (advanced)"],
|
|
50
50
|
["help", "Help about any command"],
|
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { runCli } from "./main.js";
|
|
3
|
+
import { installPlayboardInterrupt } from "./playboard-interrupt.js";
|
|
3
4
|
let componentRun = false;
|
|
4
5
|
try {
|
|
5
6
|
process.exitCode = await runCli(process.argv.slice(2), {
|
|
7
|
+
onPlayboardRun: () => {
|
|
8
|
+
installPlayboardInterrupt();
|
|
9
|
+
},
|
|
6
10
|
onComponentRun: () => {
|
|
7
11
|
componentRun = true;
|
|
8
12
|
}
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { type ServiceControlOptions } from "./service-control.js";
|
|
2
2
|
export interface CliDependencies extends ServiceControlOptions {
|
|
3
|
+
/** 参数确认后通知可执行入口接管 Playboard 信号;可导入调用方默认保留协作取消。 */
|
|
4
|
+
onPlayboardRun?: () => void;
|
|
3
5
|
env?: NodeJS.ProcessEnv;
|
|
4
6
|
input?: NodeJS.ReadableStream;
|
|
5
7
|
output?: (line: string) => void;
|