@mininglamp-oss/octo-runtime 1.1.4 → 1.1.5
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 +61 -37
- package/apps/cli/README.md +58 -22
- package/apps/cli/dist/build-info.json +2 -2
- package/apps/cli/dist/cli-entrypoint.d.ts +2 -0
- package/apps/cli/dist/cli-entrypoint.js +16 -0
- package/apps/cli/dist/command-tree.d.ts +20 -0
- package/apps/cli/dist/command-tree.js +402 -0
- package/apps/cli/dist/extra-command-config.d.ts +4 -0
- package/apps/cli/dist/extra-command-config.js +50 -0
- package/apps/cli/dist/extra-commands.d.ts +15 -0
- package/apps/cli/dist/extra-commands.js +275 -0
- package/apps/cli/dist/extras.js +14 -2
- package/apps/cli/dist/global-extras.d.ts +16 -0
- package/apps/cli/dist/global-extras.js +201 -0
- package/apps/cli/dist/help.d.ts +4 -1
- package/apps/cli/dist/help.js +31 -79
- package/apps/cli/dist/main.d.ts +2 -0
- package/apps/cli/dist/main.js +27 -63
- package/apps/cli/dist/manifest.json +48 -3
- package/apps/cli/dist/module-manifest.d.ts +1 -1
- package/apps/cli/dist/module-manifest.js +3 -2
- package/apps/cli/dist/output.js +13 -2
- package/apps/cli/dist/service-control.js +2 -2
- package/apps/cli/dist/state.js +48 -19
- package/dist/public/channel-gateway-commands.d.ts +1 -0
- package/dist/public/channel-gateway-commands.js +1 -0
- package/dist/public/channel-wecom-commands.d.ts +1 -0
- package/dist/public/channel-wecom-commands.js +1 -0
- package/dist/public/extra.d.ts +1 -0
- package/dist/public/extra.js +1 -0
- package/dist/public/host.d.ts +2 -4
- package/dist/public/host.js +1 -2
- package/dist/public/webui-commands.d.ts +1 -0
- package/dist/public/webui-commands.js +1 -0
- 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/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/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/module-manifest.d.ts +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/module-manifest.js +16 -4
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/cli-entrypoint.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/cli-entrypoint.js +16 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/command-tree.d.ts +20 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/command-tree.js +402 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extra-command-config.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extra-command-config.js +50 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extra-commands.d.ts +15 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extra-commands.js +275 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/extras.js +14 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/global-extras.d.ts +16 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/global-extras.js +201 -0
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/help.d.ts +4 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/help.js +31 -79
- 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 +27 -63
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/manifest.json +48 -3
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/module-manifest.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/module-manifest.js +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +13 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/service-control.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/state.js +48 -19
- package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +25 -24
- package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +4 -4
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/im-channel.js +3 -3
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/commands.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/commands.js +124 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/auth.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/auth.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connection-error.d.ts +7 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connection-error.js +44 -3
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.js +8 -5
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/package.json +10 -6
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/commands.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/commands.js +128 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/package.json +9 -5
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/commands.d.ts +3 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/commands.js +51 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/package.json +7 -3
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-commands.d.ts +70 -0
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/extra-commands.js +16 -0
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/index.d.ts +1 -3
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/index.js +1 -2
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +8 -4
- package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
- package/node_modules/commander/LICENSE +22 -0
- package/node_modules/commander/Readme.md +1172 -0
- package/node_modules/commander/index.js +21 -0
- package/node_modules/commander/lib/argument.js +147 -0
- package/node_modules/commander/lib/command.js +2790 -0
- package/node_modules/commander/lib/error.js +36 -0
- package/node_modules/commander/lib/help.js +731 -0
- package/node_modules/commander/lib/option.js +377 -0
- package/node_modules/commander/lib/suggestSimilar.js +99 -0
- package/node_modules/commander/package-support.json +19 -0
- package/node_modules/commander/package.json +64 -0
- package/node_modules/commander/typings/index.d.ts +1113 -0
- package/package.json +41 -27
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/launch.d.ts +0 -15
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/launch.js +0 -22
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/native.d.ts +0 -16
- package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/dist/native.js +0 -160
package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/auth.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { connectionFetch, connectionJson, httpConnectionFailure } from "./connection-error.js";
|
|
2
2
|
import { trimTrailingSlashes } from "./api/url.js";
|
|
3
|
-
/**
|
|
3
|
+
/** 建联前用调用方提供的 Bot 凭据解析身份与租户;取消由调用方持有,不跟随重定向转发凭据。 */
|
|
4
4
|
export async function verifyBotIdentity(apiUrl, token, signal) {
|
|
5
5
|
const response = await connectionFetch(`${trimTrailingSlashes(apiUrl)}/v1/auth/verify-bot`, {
|
|
6
6
|
method: "POST",
|
|
7
|
-
redirect: "
|
|
7
|
+
redirect: "manual",
|
|
8
8
|
signal: AbortSignal.any([signal, AbortSignal.timeout(15_000)]),
|
|
9
9
|
headers: { "Content-Type": "application/json" },
|
|
10
10
|
body: JSON.stringify({ bot_token: token })
|
|
@@ -4,6 +4,13 @@ export declare class ImConnectionError extends Error {
|
|
|
4
4
|
readonly retryAfterMs: number;
|
|
5
5
|
constructor(code: string, retryable: boolean, retryAfterMs?: number);
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* 保留 WuKong 原因码,区分连接中断与明确拒绝;不把服务端主动断开等同于凭据失效。
|
|
9
|
+
* DISCONNECT 与失败 CONNACK 均默认允许重新鉴权建联,覆盖滚动更新、节点迁移和新增码。
|
|
10
|
+
* 只有机器可读的明确认证、权限或协议拒绝才永久失败,不由原因文案猜测所有权。
|
|
11
|
+
*/
|
|
12
|
+
export declare function wukongConnectionFailure(phase: "CONNECT_REJECTED" | "SERVER_DISCONNECTED", reason: number): ImConnectionError;
|
|
13
|
+
/** 将连接依赖的异常归一为脱敏恢复事实;显式分类优先,调用方据此安排回收后的重试。 */
|
|
7
14
|
export declare function connectionFailure(error: unknown): ImConnectionError;
|
|
8
15
|
export declare function connectionFetch(url: string, init: RequestInit, phase: "AUTH" | "REGISTER"): Promise<Response>;
|
|
9
16
|
export declare function httpConnectionFailure(response: Response, phase: "AUTH" | "REGISTER"): Promise<ImConnectionError>;
|
|
@@ -8,13 +8,49 @@ export class ImConnectionError extends Error {
|
|
|
8
8
|
this.retryAfterMs = retryAfterMs;
|
|
9
9
|
}
|
|
10
10
|
}
|
|
11
|
+
/**
|
|
12
|
+
* 保留 WuKong 原因码,区分连接中断与明确拒绝;不把服务端主动断开等同于凭据失效。
|
|
13
|
+
* DISCONNECT 与失败 CONNACK 均默认允许重新鉴权建联,覆盖滚动更新、节点迁移和新增码。
|
|
14
|
+
* 只有机器可读的明确认证、权限或协议拒绝才永久失败,不由原因文案猜测所有权。
|
|
15
|
+
*/
|
|
16
|
+
export function wukongConnectionFailure(phase, reason) {
|
|
17
|
+
// 认证、黑/白名单、封禁、禁止发送及明确协议/密钥错误,不靠重新连接消除。
|
|
18
|
+
const terminal = [2, 4, 8, 9, 11, 13, 19, 20, 21, 23, 27].includes(reason);
|
|
19
|
+
return new ImConnectionError(`IM_${phase}_${reason}`, !terminal);
|
|
20
|
+
}
|
|
21
|
+
/** 将连接依赖的异常归一为脱敏恢复事实;显式分类优先,调用方据此安排回收后的重试。 */
|
|
11
22
|
export function connectionFailure(error) {
|
|
12
23
|
if (error instanceof ImConnectionError)
|
|
13
24
|
return error;
|
|
14
25
|
const code = error instanceof Error && /^IM_[A-Z0-9_]+$/.test(error.message)
|
|
15
26
|
? error.message
|
|
16
27
|
: "IM_CONNECTION_FAILED";
|
|
17
|
-
|
|
28
|
+
// 未分类异常可能来自宿主凭据服务或连接依赖,不能单凭缺少类型就永久停止恢复。
|
|
29
|
+
// 本地已确认的身份、配置、协议及资源所有权错误仍须修正后才能重新连接。
|
|
30
|
+
const terminal = [
|
|
31
|
+
"IM_CREDENTIALS_REQUIRED",
|
|
32
|
+
"IM_BOT_TOKEN_INVALID",
|
|
33
|
+
"IM_BOT_IDENTITY_MISMATCH",
|
|
34
|
+
"IM_TENANT_NOT_ACTIVE",
|
|
35
|
+
"IM_AUTH_IDENTITY_INVALID",
|
|
36
|
+
"IM_REGISTRATION_INVALID",
|
|
37
|
+
"IM_WS_URL_INVALID",
|
|
38
|
+
"IM_WS_TLS_REQUIRED",
|
|
39
|
+
"IM_ALREADY_CONNECTED",
|
|
40
|
+
"IM_DISPOSE_FAILED",
|
|
41
|
+
"IM_TRANSPORT_DISPOSE_FAILED",
|
|
42
|
+
"IM_FIELD_TOO_LARGE",
|
|
43
|
+
"IM_FRAME_TRUNCATED",
|
|
44
|
+
"IM_BINARY_REQUIRED",
|
|
45
|
+
"IM_FRAME_TOO_LARGE",
|
|
46
|
+
"IM_LENGTH_INVALID",
|
|
47
|
+
"IM_KEY_INVALID",
|
|
48
|
+
"IM_HANDSHAKE_REQUIRED",
|
|
49
|
+
"IM_PROTOCOL_ERROR",
|
|
50
|
+
"IM_MESSAGE_KEY_INVALID",
|
|
51
|
+
"IM_PAYLOAD_INVALID"
|
|
52
|
+
].includes(code);
|
|
53
|
+
return new ImConnectionError(code, !terminal);
|
|
18
54
|
}
|
|
19
55
|
export async function connectionFetch(url, init, phase) {
|
|
20
56
|
try {
|
|
@@ -35,8 +71,13 @@ export async function httpConnectionFailure(response, phase) {
|
|
|
35
71
|
const date = retryAfter ? Date.parse(retryAfter) : NaN;
|
|
36
72
|
const retryAfterMs = Math.max(0, seconds !== undefined ? seconds * 1000 : date - Date.now());
|
|
37
73
|
await response.body?.cancel();
|
|
38
|
-
//
|
|
39
|
-
|
|
74
|
+
// 仅明确认证、资源/请求或协议错误停止;服务超时、冲突、限流及未知服务故障默认重试。
|
|
75
|
+
// 禁止重定向仍是接入约束,不能自动把凭据带到另一个地址。
|
|
76
|
+
const terminal = response.status < 400 ||
|
|
77
|
+
[
|
|
78
|
+
400, 401, 403, 404, 405, 407, 410, 411, 413, 414, 415, 416, 417, 422, 426, 428, 431, 451
|
|
79
|
+
].includes(response.status);
|
|
80
|
+
return new ImConnectionError(`IM_${phase}_HTTP_${response.status}`, !terminal, Number.isFinite(retryAfterMs) ? retryAfterMs : 0);
|
|
40
81
|
}
|
|
41
82
|
export async function connectionJson(response, phase, invalidCode) {
|
|
42
83
|
try {
|
package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.js
CHANGED
|
@@ -6,13 +6,14 @@ import { createCipheriv, createDecipheriv, createHash, createPublicKey, diffieHe
|
|
|
6
6
|
import WebSocket from "ws";
|
|
7
7
|
import { ImSendError, ImTextSend } from "../delivery/text-send.js";
|
|
8
8
|
import { isRulesNotification } from "./normalize.js";
|
|
9
|
-
import { connectionFetch, connectionJson, httpConnectionFailure, ImConnectionError } from "./connection-error.js";
|
|
9
|
+
import { connectionFetch, connectionJson, httpConnectionFailure, ImConnectionError, wukongConnectionFailure } from "./connection-error.js";
|
|
10
10
|
const LIMIT = 1 << 20;
|
|
11
11
|
const md5 = (value) => createHash("md5").update(value).digest("hex");
|
|
12
12
|
export async function registerBot(apiUrl, token, signal) {
|
|
13
13
|
const response = await connectionFetch(`${apiUrl.replace(/\/$/, "")}/v1/bot/register`, {
|
|
14
14
|
method: "POST",
|
|
15
|
-
|
|
15
|
+
// 返回重定向状态供统一分类,不跟随到新地址,也不将其折叠成网络暂态。
|
|
16
|
+
redirect: "manual",
|
|
16
17
|
signal: signal
|
|
17
18
|
? AbortSignal.any([signal, AbortSignal.timeout(15_000)])
|
|
18
19
|
: AbortSignal.timeout(15_000),
|
|
@@ -243,7 +244,7 @@ export class WukongConnection {
|
|
|
243
244
|
reader.u64();
|
|
244
245
|
const reason = reader.byte();
|
|
245
246
|
if (reason !== 1)
|
|
246
|
-
throw
|
|
247
|
+
throw wukongConnectionFailure("CONNECT_REJECTED", reason);
|
|
247
248
|
const remoteKey = reader.string();
|
|
248
249
|
const salt = reader.string();
|
|
249
250
|
if (this.#version >= 4)
|
|
@@ -273,6 +274,10 @@ export class WukongConnection {
|
|
|
273
274
|
this.#heartbeat.unref();
|
|
274
275
|
resolve();
|
|
275
276
|
}
|
|
277
|
+
else if (kind === 9) {
|
|
278
|
+
// 滚动更新也可能在 CONNACK 前关闭连接;先按断开原因分类,不能误报握手协议错误。
|
|
279
|
+
throw wukongConnectionFailure("SERVER_DISCONNECTED", reader.byte());
|
|
280
|
+
}
|
|
276
281
|
else if (!ready)
|
|
277
282
|
throw new Error("IM_HANDSHAKE_REQUIRED");
|
|
278
283
|
else if (kind === 5)
|
|
@@ -294,8 +299,6 @@ export class WukongConnection {
|
|
|
294
299
|
pending.operation.ack(id, reason);
|
|
295
300
|
}
|
|
296
301
|
}
|
|
297
|
-
else if (kind === 9)
|
|
298
|
-
throw new ImConnectionError(`IM_SERVER_DISCONNECTED_${reader.byte()}`, false);
|
|
299
302
|
}
|
|
300
303
|
}
|
|
301
304
|
catch (error) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-extra-channel-gateway",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
".": {
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
10
|
"import": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./commands": {
|
|
13
|
+
"types": "./dist/commands.d.ts",
|
|
14
|
+
"import": "./dist/commands.js"
|
|
11
15
|
}
|
|
12
16
|
},
|
|
13
17
|
"types": "./dist/index.d.ts",
|
|
@@ -18,11 +22,11 @@
|
|
|
18
22
|
"docs"
|
|
19
23
|
],
|
|
20
24
|
"dependencies": {
|
|
21
|
-
"@mininglamp-oss/octo-runtime-executor-kernel": "1.1.
|
|
22
|
-
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.
|
|
23
|
-
"@mininglamp-oss/octo-runtime-executor-core": "1.1.
|
|
24
|
-
"@mininglamp-oss/octo-runtime-host-sdk": "1.1.
|
|
25
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
25
|
+
"@mininglamp-oss/octo-runtime-executor-kernel": "1.1.5",
|
|
26
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.5",
|
|
27
|
+
"@mininglamp-oss/octo-runtime-executor-core": "1.1.5",
|
|
28
|
+
"@mininglamp-oss/octo-runtime-host-sdk": "1.1.5",
|
|
29
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.5",
|
|
26
30
|
"mdast-util-from-markdown": "2.1.0",
|
|
27
31
|
"ws": "8.22.0"
|
|
28
32
|
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { ExtraCommandError, savedConfigResult } from "@mininglamp-oss/octo-runtime-host-sdk/extra-commands";
|
|
2
|
+
import { validateImBots } from "./lifecycle/configuration.js";
|
|
3
|
+
/** 离线业务校验复用运行时 Bot 合同;不认证、不构造 manager 或服务。 */
|
|
4
|
+
function validate(config) {
|
|
5
|
+
try {
|
|
6
|
+
validateImBots(config.bots ?? []);
|
|
7
|
+
const spaces = config.authorized_space_ids;
|
|
8
|
+
if (spaces !== undefined &&
|
|
9
|
+
(!Array.isArray(spaces) || spaces.some((id) => typeof id !== "string" || !id.trim())))
|
|
10
|
+
throw new Error("IM_AUTHORIZED_SPACES_INVALID");
|
|
11
|
+
const settings = config.context_loading;
|
|
12
|
+
if (settings !== undefined) {
|
|
13
|
+
if (!settings ||
|
|
14
|
+
typeof settings !== "object" ||
|
|
15
|
+
Array.isArray(settings) ||
|
|
16
|
+
Object.keys(settings).some((key) => !["timeout_ms", "max_in_flight"].includes(key)))
|
|
17
|
+
throw new Error("IM_CONTEXT_LOADING_CONFIG_INVALID");
|
|
18
|
+
for (const [key, max] of [
|
|
19
|
+
["timeout_ms", 30000],
|
|
20
|
+
["max_in_flight", 32]
|
|
21
|
+
]) {
|
|
22
|
+
const value = settings[key];
|
|
23
|
+
if (value !== undefined &&
|
|
24
|
+
(typeof value !== "number" || !Number.isInteger(value) || value < 1 || value > max))
|
|
25
|
+
throw new Error("IM_CONTEXT_LOADING_CONFIG_INVALID");
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
const hints = {
|
|
31
|
+
IM_BOT_ID_REQUIRED: "Provide a non-empty --bot_id (JSON: bots[].bot_id).",
|
|
32
|
+
IM_ADAPTER_REQUIRED: "Each Bot requires an adapter object; configure maps --adapter_type/--workdir to it.",
|
|
33
|
+
IM_WORKDIR_ABSOLUTE_REQUIRED: "Provide an absolute --workdir for a local adapter.",
|
|
34
|
+
IM_OPENCLAW_WORKDIR_UNSUPPORTED: "OpenClaw uses its own workspace; remove config.bots[].adapter.workdir using extraset.",
|
|
35
|
+
IM_PROVIDER_AGENT_ID_UNSUPPORTED: "--provider_agent_id is supported only by OpenClaw.",
|
|
36
|
+
IM_API_URL_INVALID: "Use a valid endpoint URL without credentials, query or fragment; insecure URLs are loopback-only.",
|
|
37
|
+
IM_BOT_DUPLICATED: "Duplicate Bot identity in bots; keep one entry per endpoint and bot_id.",
|
|
38
|
+
IM_CONFIG_LIST_REQUIRED: "bots must be an array within this Extra's Bot limit.",
|
|
39
|
+
IM_AUTHORIZED_SPACES_INVALID: "authorized_space_ids must contain non-empty strings.",
|
|
40
|
+
IM_CONTEXT_LOADING_CONFIG_INVALID: "context_loading accepts timeout_ms (1..30000) and max_in_flight (1..32)."
|
|
41
|
+
};
|
|
42
|
+
const code = error instanceof Error && Object.hasOwn(hints, error.message)
|
|
43
|
+
? error.message
|
|
44
|
+
: "EXTRA_CONFIG_INVALID";
|
|
45
|
+
throw new ExtraCommandError(code, hints[code] ??
|
|
46
|
+
"Invalid Bot configuration. Check configure --help and this Extra's configuration schema.");
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/** 单 Bot 配置命令按 bot_id upsert;省略字段保留,重复调用不会追加相同 Bot。 */
|
|
50
|
+
const extension = {
|
|
51
|
+
apiVersion: 1,
|
|
52
|
+
commands: [
|
|
53
|
+
{
|
|
54
|
+
name: "configure",
|
|
55
|
+
description: "Add or update one Bot by bot_id; saves config only",
|
|
56
|
+
options: [
|
|
57
|
+
{ name: "bot_id", type: "string", required: true, description: "Platform Bot ID" },
|
|
58
|
+
{
|
|
59
|
+
name: "ws_url",
|
|
60
|
+
type: "string",
|
|
61
|
+
description: "WeCom WebSocket URL; preserved on update, official endpoint for new Bots"
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "adapter_type",
|
|
65
|
+
type: "string",
|
|
66
|
+
description: "Execution adapter type (adapter.adapter_type)"
|
|
67
|
+
},
|
|
68
|
+
{ name: "workdir", type: "string", description: "Absolute local execution directory" },
|
|
69
|
+
{ name: "model", type: "string", description: "Provider model ID" },
|
|
70
|
+
{
|
|
71
|
+
name: "effort",
|
|
72
|
+
type: "string",
|
|
73
|
+
description: "Reasoning effort: low, medium, high, xhigh"
|
|
74
|
+
},
|
|
75
|
+
{ name: "provider_agent_id", type: "string", description: "Existing OpenClaw Agent ID" },
|
|
76
|
+
{
|
|
77
|
+
name: "app_secret",
|
|
78
|
+
type: "string",
|
|
79
|
+
description: "Raw credential (bots[].app_secret); omitted values are preserved"
|
|
80
|
+
}
|
|
81
|
+
],
|
|
82
|
+
examples: [
|
|
83
|
+
"octo-runtime channel-wecom configure --bot_id assistant --adapter_type codex --workdir /absolute/workspace --app_secret EXAMPLE_CREDENTIAL"
|
|
84
|
+
],
|
|
85
|
+
async run(context, input) {
|
|
86
|
+
const snapshot = await context.readConfig();
|
|
87
|
+
validate(snapshot.config);
|
|
88
|
+
const bots = snapshot.config.bots ?? [];
|
|
89
|
+
validateImBots(bots);
|
|
90
|
+
// configure 用 bot_id 定位,更新 endpoint 不产生第二个 Bot。
|
|
91
|
+
// 旧 extraset 跨 endpoint 的同 ID 保留首项省略字段并合并;省略 ws_url 不重置已有地址。
|
|
92
|
+
const position = bots.findIndex((bot) => bot.bot_id === input.options.bot_id);
|
|
93
|
+
const old = position < 0 ? undefined : bots[position];
|
|
94
|
+
const identityFields = {
|
|
95
|
+
bot_id: input.options.bot_id,
|
|
96
|
+
ws_url: input.options.ws_url ?? old?.ws_url ?? "wss://openws.work.weixin.qq.com"
|
|
97
|
+
};
|
|
98
|
+
const adapter = { ...old?.adapter };
|
|
99
|
+
for (const field of ["adapter_type", "workdir", "model", "effort", "provider_agent_id"]) {
|
|
100
|
+
const value = input.options[field];
|
|
101
|
+
if (typeof value === "string")
|
|
102
|
+
adapter[field] = value;
|
|
103
|
+
}
|
|
104
|
+
if (adapter.effort !== undefined &&
|
|
105
|
+
(typeof adapter.effort !== "string" ||
|
|
106
|
+
!["low", "medium", "high", "xhigh"].includes(adapter.effort)))
|
|
107
|
+
throw new ExtraCommandError("EXTRA_CONFIG_INVALID", "--effort must be low, medium, high or xhigh.");
|
|
108
|
+
const bot = { ...old, ...identityFields, adapter };
|
|
109
|
+
const credential = input.options.app_secret;
|
|
110
|
+
if (typeof credential === "string") {
|
|
111
|
+
if (!credential.trim())
|
|
112
|
+
throw new ExtraCommandError("EXTRA_CONFIG_INVALID", "--app_secret must not be blank.");
|
|
113
|
+
// 与 extraset 的业务字段同名;保存传入原文,省略时保留已有凭据。
|
|
114
|
+
bot.app_secret = credential;
|
|
115
|
+
}
|
|
116
|
+
const nextBots = bots.filter((bot, index) => index === position || bot.bot_id !== identityFields.bot_id);
|
|
117
|
+
if (position < 0)
|
|
118
|
+
nextBots.push(bot);
|
|
119
|
+
else
|
|
120
|
+
nextBots[position] = bot;
|
|
121
|
+
const config = { ...snapshot.config, bots: nextBots };
|
|
122
|
+
validate(config);
|
|
123
|
+
return savedConfigResult(await context.saveConfig(config, snapshot.revision));
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
]
|
|
127
|
+
};
|
|
128
|
+
export default extension;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-extra-channel-wecom",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -8,6 +8,10 @@
|
|
|
8
8
|
".": {
|
|
9
9
|
"types": "./dist/index.d.ts",
|
|
10
10
|
"import": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./commands": {
|
|
13
|
+
"types": "./dist/commands.d.ts",
|
|
14
|
+
"import": "./dist/commands.js"
|
|
11
15
|
}
|
|
12
16
|
},
|
|
13
17
|
"types": "./dist/index.d.ts",
|
|
@@ -18,10 +22,10 @@
|
|
|
18
22
|
"docs"
|
|
19
23
|
],
|
|
20
24
|
"dependencies": {
|
|
21
|
-
"@mininglamp-oss/octo-runtime-host-sdk": "1.1.
|
|
22
|
-
"@mininglamp-oss/octo-runtime-executor-core": "1.1.
|
|
23
|
-
"@mininglamp-oss/octo-runtime-executor-kernel": "1.1.
|
|
25
|
+
"@mininglamp-oss/octo-runtime-host-sdk": "1.1.5",
|
|
26
|
+
"@mininglamp-oss/octo-runtime-executor-core": "1.1.5",
|
|
27
|
+
"@mininglamp-oss/octo-runtime-executor-kernel": "1.1.5",
|
|
24
28
|
"ws": "8.22.0",
|
|
25
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
29
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.5"
|
|
26
30
|
}
|
|
27
31
|
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { isAbsolute, join } from "node:path";
|
|
2
|
+
import { assertContextEnvelope } from "@mininglamp-oss/octo-runtime-protocol";
|
|
3
|
+
import { ExtraCommandError, savedConfigResult } from "@mininglamp-oss/octo-runtime-host-sdk/extra-commands";
|
|
4
|
+
/** WebUI 在一个 Home 内只有 webui 这份配置;端口不是实例 ID,不创建多实例列表。 */
|
|
5
|
+
function validate(config) {
|
|
6
|
+
const port = config.port ?? 13888;
|
|
7
|
+
if (typeof port !== "number" || !Number.isInteger(port) || port < 1 || port > 65535)
|
|
8
|
+
throw new ExtraCommandError("WEBUI_PORT_INVALID", "--port must be an integer from 1 to 65535.");
|
|
9
|
+
if (typeof config.sessionStorePath !== "string" || !isAbsolute(config.sessionStorePath))
|
|
10
|
+
throw new ExtraCommandError("WEBUI_STORE_PATH_REQUIRED", "config.sessionStorePath must refer to an absolute session JSON file path.");
|
|
11
|
+
if (config.defaultProjectPath !== undefined && typeof config.defaultProjectPath !== "string")
|
|
12
|
+
throw new ExtraCommandError("WEBUI_PROJECT_PATH_INVALID", "defaultProjectPath must be a string.");
|
|
13
|
+
if (config.context !== undefined) {
|
|
14
|
+
try {
|
|
15
|
+
assertContextEnvelope(config.context);
|
|
16
|
+
}
|
|
17
|
+
catch {
|
|
18
|
+
throw new ExtraCommandError("WEBUI_CONTEXT_INVALID", "context must follow the Context v3 contract.");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
const extension = {
|
|
23
|
+
apiVersion: 1,
|
|
24
|
+
commands: [
|
|
25
|
+
{
|
|
26
|
+
name: "configure",
|
|
27
|
+
description: "Update the single WebUI configuration; saves only, restart to apply",
|
|
28
|
+
options: [
|
|
29
|
+
{ name: "port", type: "string", description: "Loopback HTTP port (default 13888)" }
|
|
30
|
+
],
|
|
31
|
+
examples: ["octo-runtime webui configure --port 13888"],
|
|
32
|
+
async run(context, input) {
|
|
33
|
+
const snapshot = await context.readConfig();
|
|
34
|
+
const config = { ...snapshot.config };
|
|
35
|
+
// 简化入口只暴露端口;首次会话存储从宿主 Home 推导,已有路径和项目配置保持。
|
|
36
|
+
// 高级 extraset 仍按完整声明的 JSON 合同替换,不改存储字段名或隐式迁移数据。
|
|
37
|
+
if (config.sessionStorePath === undefined)
|
|
38
|
+
config.sessionStorePath = join(context.home, "extras", context.name, "sessions.json");
|
|
39
|
+
const port = input.options.port;
|
|
40
|
+
if (typeof port === "string") {
|
|
41
|
+
if (!/^[0-9]+$/.test(port))
|
|
42
|
+
throw new ExtraCommandError("WEBUI_PORT_INVALID", "--port must be an integer from 1 to 65535.");
|
|
43
|
+
config.port = Number(port);
|
|
44
|
+
}
|
|
45
|
+
validate(config);
|
|
46
|
+
return savedConfigResult(await context.saveConfig(config, snapshot.revision));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
]
|
|
50
|
+
};
|
|
51
|
+
export default extension;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-extra-webui",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Local Runtime workbench with canonical SSE presentation",
|
|
@@ -10,7 +10,11 @@
|
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
11
11
|
"import": "./dist/index.js"
|
|
12
12
|
},
|
|
13
|
-
"./config-schema.json": "./config-schema.json"
|
|
13
|
+
"./config-schema.json": "./config-schema.json",
|
|
14
|
+
"./commands": {
|
|
15
|
+
"types": "./dist/commands.d.ts",
|
|
16
|
+
"import": "./dist/commands.js"
|
|
17
|
+
}
|
|
14
18
|
},
|
|
15
19
|
"files": [
|
|
16
20
|
"dist",
|
|
@@ -19,6 +23,6 @@
|
|
|
19
23
|
"porting-map.md"
|
|
20
24
|
],
|
|
21
25
|
"dependencies": {
|
|
22
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
26
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.5"
|
|
23
27
|
}
|
|
24
28
|
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { JsonObject, JsonValue } from "./extras.js";
|
|
2
|
+
/** Extra 自有命令的版本化声明;导入模块只声明命令,不初始化服务或访问业务后端。 */
|
|
3
|
+
export interface ExtraCommandExtension {
|
|
4
|
+
apiVersion: 1;
|
|
5
|
+
commands: readonly ExtraCommand[];
|
|
6
|
+
}
|
|
7
|
+
export interface ExtraCommandOption {
|
|
8
|
+
name: string;
|
|
9
|
+
description: string;
|
|
10
|
+
type: "string" | "boolean";
|
|
11
|
+
required?: boolean;
|
|
12
|
+
}
|
|
13
|
+
export interface ExtraCommand {
|
|
14
|
+
name: string;
|
|
15
|
+
description: string;
|
|
16
|
+
options?: readonly ExtraCommandOption[];
|
|
17
|
+
/** 按顺序消费位置参数;不声明就拒绝额外参数,-- 后的文本仍按此声明校验。 */
|
|
18
|
+
arguments?: readonly {
|
|
19
|
+
name: string;
|
|
20
|
+
required?: boolean;
|
|
21
|
+
}[];
|
|
22
|
+
examples?: readonly string[];
|
|
23
|
+
commands?: readonly ExtraCommand[];
|
|
24
|
+
run?: (context: ExtraCommandContext, input: ExtraCommandInput) => Promise<ExtraCommandResult | void>;
|
|
25
|
+
}
|
|
26
|
+
export interface ExtraCommandInput {
|
|
27
|
+
options: Readonly<Record<string, string | boolean>>;
|
|
28
|
+
arguments: readonly string[];
|
|
29
|
+
}
|
|
30
|
+
export interface ExtraCommandResult {
|
|
31
|
+
/** 可选的普通终端安全提示;--json 时输出 value,不从业务 JSON 字段猜测格式。 */
|
|
32
|
+
message?: string;
|
|
33
|
+
value?: JsonValue;
|
|
34
|
+
exitCode?: number;
|
|
35
|
+
}
|
|
36
|
+
export interface ExtraConfigSnapshot {
|
|
37
|
+
config: JsonObject;
|
|
38
|
+
/** 宿主生成的不透明修订,用于保存时检查整份声明是否发生并发变化。 */
|
|
39
|
+
revision: string;
|
|
40
|
+
}
|
|
41
|
+
export interface ExtraConfigSaved {
|
|
42
|
+
saved: true;
|
|
43
|
+
name: string;
|
|
44
|
+
file: string;
|
|
45
|
+
reload_required: true;
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* CLI 拥有 Home、IO 与取消信号;业务实现先读快照、在锁外完成交互/校验,再保存。
|
|
49
|
+
* saveConfig 只写当前 Extra 的 config,保留宿主字段;冲突须重新读取,不能盲目重试。
|
|
50
|
+
* output/prompt 的文本由插件负责脱敏;凭据输入方式归 Extra 决定,不使用会回显的 prompt。
|
|
51
|
+
*/
|
|
52
|
+
export interface ExtraCommandContext {
|
|
53
|
+
readonly home: string;
|
|
54
|
+
readonly name: string;
|
|
55
|
+
readonly signal: AbortSignal;
|
|
56
|
+
readonly interactive: boolean;
|
|
57
|
+
readConfig(): Promise<ExtraConfigSnapshot>;
|
|
58
|
+
saveConfig(config: JsonObject, revision: string): Promise<ExtraConfigSaved>;
|
|
59
|
+
readStdin(): Promise<string>;
|
|
60
|
+
output(text: string): void;
|
|
61
|
+
prompt(question: string): Promise<string>;
|
|
62
|
+
}
|
|
63
|
+
/** 可公开的固定诊断;不得把凭据、用户输入或后端错误正文拼入 code/message。 */
|
|
64
|
+
export declare class ExtraCommandError extends Error {
|
|
65
|
+
readonly code: string;
|
|
66
|
+
constructor(code: string, message: string);
|
|
67
|
+
}
|
|
68
|
+
export type { JsonObject, JsonValue } from "./extras.js";
|
|
69
|
+
/** 将宿主保存回执转换为明确的文本/JSON 输出;业务对象不参与回执识别。 */
|
|
70
|
+
export declare function savedConfigResult(saved: ExtraConfigSaved): ExtraCommandResult;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/** 可公开的固定诊断;不得把凭据、用户输入或后端错误正文拼入 code/message。 */
|
|
2
|
+
export class ExtraCommandError extends Error {
|
|
3
|
+
code;
|
|
4
|
+
constructor(code, message) {
|
|
5
|
+
super(message);
|
|
6
|
+
this.code = code;
|
|
7
|
+
this.name = "ExtraCommandError";
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
/** 将宿主保存回执转换为明确的文本/JSON 输出;业务对象不参与回执识别。 */
|
|
11
|
+
export function savedConfigResult(saved) {
|
|
12
|
+
return {
|
|
13
|
+
value: { ...saved },
|
|
14
|
+
message: `${saved.name}: configuration saved. Restart this Extra to apply it.\nConfig file: ${saved.file}`
|
|
15
|
+
};
|
|
16
|
+
}
|
|
@@ -7,6 +7,4 @@ export * from "./extra-service.js";
|
|
|
7
7
|
export * from "./endpoint.js";
|
|
8
8
|
export * from "./home.js";
|
|
9
9
|
export * from "./identity.js";
|
|
10
|
-
export * from "./
|
|
11
|
-
export type { CleanupResult } from "./launch.js";
|
|
12
|
-
export { ComponentStartError } from "./launch.js";
|
|
10
|
+
export * from "./extra-commands.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-host-sdk",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.5",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -16,12 +16,16 @@
|
|
|
16
16
|
".": {
|
|
17
17
|
"types": "./dist/index.d.ts",
|
|
18
18
|
"import": "./dist/index.js"
|
|
19
|
+
},
|
|
20
|
+
"./extra-commands": {
|
|
21
|
+
"types": "./dist/extra-commands.d.ts",
|
|
22
|
+
"import": "./dist/extra-commands.js"
|
|
19
23
|
}
|
|
20
24
|
},
|
|
21
25
|
"dependencies": {
|
|
22
|
-
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.
|
|
23
|
-
"@mininglamp-oss/octo-runtime-executor-kernel": "1.1.
|
|
24
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
26
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.5",
|
|
27
|
+
"@mininglamp-oss/octo-runtime-executor-kernel": "1.1.5",
|
|
28
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.5"
|
|
25
29
|
},
|
|
26
30
|
"types": "./dist/index.d.ts",
|
|
27
31
|
"files": [
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2011 TJ Holowaychuk <tj@vision-media.ca>
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
|
+
a copy of this software and associated documentation files (the
|
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
|
11
|
+
the following conditions:
|
|
12
|
+
|
|
13
|
+
The above copyright notice and this permission notice shall be
|
|
14
|
+
included in all copies or substantial portions of the Software.
|
|
15
|
+
|
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|