@mininglamp-oss/octo-runtime 1.1.7 → 1.1.9
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/apps/cli/README.md +3 -1
- package/apps/cli/dist/build-info.json +2 -2
- package/apps/cli/dist/command-tree.js +3 -1
- package/apps/cli/dist/output.js +5 -2
- package/apps/cli/dist/playboard.js +11 -2
- package/dist/public/executor-kernel.d.ts +2 -2
- package/dist/public/executor-kernel.js +1 -1
- 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/index.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.js +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/public-display.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/public-display.js +22 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/runtime-log.js +20 -0
- package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/service-status.js +14 -1
- 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/command-tree.js +3 -1
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/output.js +5 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/playboard.js +11 -2
- package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +24 -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 +5 -4
- package/node_modules/@mininglamp-oss/octo-runtime-executor-core/dist/index.js +7 -4
- 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/host-run-service.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.d.ts +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/index.js +1 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/rpc.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/rpc.js +16 -3
- package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/server.js +36 -19
- 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 +27 -35
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/contracts.d.ts +5 -4
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/dispatcher.d.ts +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/dispatcher.js +29 -6
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/identity.d.ts +1 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/identity.js +2 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/send-error.d.ts +6 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/send-error.js +10 -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/card-session.d.ts +3 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/card-session.js +54 -10
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.d.ts +4 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.js +77 -109
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connector.d.ts +3 -5
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connector.js +27 -40
- 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/reasoning-frame.js +42 -7
- 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/dist/transport/wukong.d.ts +1 -12
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.js +6 -126
- 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-CXTvRGim.js → index-BVxePruX.js} +11 -10
- 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 -5
- 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 +27 -27
- package/packages/octo-runtime-protocol/schema/protocol.schema.json +156 -4
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/text-send.d.ts +0 -19
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/text-send.js +0 -86
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/presentation/delivery-notice.d.ts +0 -5
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/presentation/delivery-notice.js +0 -35
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
function exactCommand(text) {
|
|
2
|
+
const command = text.trim();
|
|
3
|
+
return command === "/reset" || command === "/new" || command === "/stop" ? command : null;
|
|
4
|
+
}
|
|
5
|
+
function splitsSurrogate(text, offset) {
|
|
6
|
+
const before = text.charCodeAt(offset - 1), after = text.charCodeAt(offset);
|
|
7
|
+
return before >= 0xd800 && before <= 0xdbff && after >= 0xdc00 && after <= 0xdfff;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* 在 Gateway 已完成消息准入后解析当前纯文本;不改变原文,不从名称补造授权。
|
|
11
|
+
* 只有剥离原生提及前缀后的完整输入才是控制命令,含 /stop 的语义文本仍交给 AgentRun。
|
|
12
|
+
*/
|
|
13
|
+
export function sessionCommand(message, botId) {
|
|
14
|
+
if (![2, 5].includes(message.channelType) || message.payload.type !== 1)
|
|
15
|
+
return null;
|
|
16
|
+
const text = message.payload.content, raw = message.payload.mention;
|
|
17
|
+
if (typeof text !== "string" || !raw || typeof raw !== "object" || Array.isArray(raw))
|
|
18
|
+
return null;
|
|
19
|
+
const mention = raw;
|
|
20
|
+
const flag = (value) => value === 1 || value === true;
|
|
21
|
+
// ais 会把 Bot UID 展开到 uids;广播与直接点名混合也不能操作会话。
|
|
22
|
+
if ([mention.all, mention.ais, mention.humans].some(flag) || !Array.isArray(mention.uids))
|
|
23
|
+
return null;
|
|
24
|
+
const uids = new Set(mention.uids);
|
|
25
|
+
if (!uids.has(botId))
|
|
26
|
+
return null;
|
|
27
|
+
if (mention.entities === undefined)
|
|
28
|
+
return exactCommand(text);
|
|
29
|
+
if (!Array.isArray(mention.entities))
|
|
30
|
+
return null;
|
|
31
|
+
if (!mention.entities.length)
|
|
32
|
+
return exactCommand(text);
|
|
33
|
+
const entities = [];
|
|
34
|
+
for (const rawEntity of mention.entities) {
|
|
35
|
+
if (!rawEntity || typeof rawEntity !== "object" || Array.isArray(rawEntity))
|
|
36
|
+
return null;
|
|
37
|
+
const entity = rawEntity;
|
|
38
|
+
const { uid, offset, length } = entity;
|
|
39
|
+
if (typeof uid !== "string" ||
|
|
40
|
+
!uid ||
|
|
41
|
+
!uids.has(uid) ||
|
|
42
|
+
typeof offset !== "number" ||
|
|
43
|
+
!Number.isSafeInteger(offset) ||
|
|
44
|
+
offset < 0 ||
|
|
45
|
+
typeof length !== "number" ||
|
|
46
|
+
!Number.isSafeInteger(length) ||
|
|
47
|
+
length <= 1 ||
|
|
48
|
+
offset + length > text.length ||
|
|
49
|
+
splitsSurrogate(text, offset) ||
|
|
50
|
+
splitsSurrogate(text, offset + length) ||
|
|
51
|
+
text[offset] !== "@" ||
|
|
52
|
+
!text.slice(offset + 1, offset + length).trim())
|
|
53
|
+
return null;
|
|
54
|
+
entities.push({ uid, offset, length });
|
|
55
|
+
}
|
|
56
|
+
entities.sort((left, right) => left.offset - right.offset);
|
|
57
|
+
let end = 0;
|
|
58
|
+
for (const entity of entities) {
|
|
59
|
+
if (entity.offset < end)
|
|
60
|
+
return null;
|
|
61
|
+
end = entity.offset + entity.length;
|
|
62
|
+
}
|
|
63
|
+
let cursor = 0, directlyMentioned = false;
|
|
64
|
+
for (const entity of entities) {
|
|
65
|
+
if (text.slice(cursor, entity.offset).trim())
|
|
66
|
+
break;
|
|
67
|
+
cursor = entity.offset + entity.length;
|
|
68
|
+
directlyMentioned ||= entity.uid === botId;
|
|
69
|
+
}
|
|
70
|
+
return directlyMentioned ? exactCommand(text.slice(cursor)) : null;
|
|
71
|
+
}
|
package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { ImTextMention } from "./mentions.js";
|
|
2
1
|
export interface ImMessage {
|
|
3
2
|
messageId: string;
|
|
4
3
|
messageSeq: number;
|
|
@@ -30,7 +29,6 @@ export declare class WukongConnection {
|
|
|
30
29
|
clientMsgNo: string;
|
|
31
30
|
spaceId?: unknown;
|
|
32
31
|
}) => void) | undefined;
|
|
33
|
-
readonly onDelivered?: ((clientMsgNo: string) => void) | undefined;
|
|
34
32
|
constructor(onMessage: (message: ImMessage) => void, onDisconnect?: (error: Error) => void, onPosition?: ((position: {
|
|
35
33
|
channelId: string;
|
|
36
34
|
channelType: number;
|
|
@@ -39,17 +37,8 @@ export declare class WukongConnection {
|
|
|
39
37
|
messageId: string;
|
|
40
38
|
clientMsgNo: string;
|
|
41
39
|
spaceId?: unknown;
|
|
42
|
-
}) => void) | undefined
|
|
40
|
+
}) => void) | undefined);
|
|
43
41
|
get connected(): boolean;
|
|
44
42
|
connect(registration: BotRegistration): Promise<void>;
|
|
45
|
-
sendText(channelId: string, channelType: number, text: string, clientMsgNo?: string, spaceId?: string, mention?: ImTextMention, signal?: AbortSignal, onPosition?: (sequence: number) => void): Promise<string>;
|
|
46
|
-
/** 原生文件消息复用文本的加密、稳定编号、ACK/迟到确认和取消窗口;不使用互动卡服务。 */
|
|
47
|
-
sendFile(channelId: string, channelType: number, file: {
|
|
48
|
-
url: string;
|
|
49
|
-
name: string;
|
|
50
|
-
size: number;
|
|
51
|
-
extension: string;
|
|
52
|
-
}, clientMsgNo: string, spaceId?: string, signal?: AbortSignal, onPosition?: (sequence: number) => void): Promise<string>;
|
|
53
|
-
isDelivered(clientMsgNo: string): boolean;
|
|
54
43
|
close(): Promise<void>;
|
|
55
44
|
}
|
package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* WuKong
|
|
3
|
-
*
|
|
2
|
+
* WuKong 接收传输:负责 Bot 注册、加密握手、入站消息、接收 ACK 及 PING/PONG。
|
|
3
|
+
* 业务消息统一由上层通过 REST 发送;本层不持有结果投递、发送重试或迟到确认状态。
|
|
4
4
|
*/
|
|
5
5
|
import { createCipheriv, createDecipheriv, createHash, createPublicKey, diffieHellman, generateKeyPairSync, randomUUID } from "node:crypto";
|
|
6
6
|
import WebSocket from "ws";
|
|
7
|
-
import { ImSendError, ImTextSend } from "../delivery/text-send.js";
|
|
8
7
|
import { isRulesNotification } from "./normalize.js";
|
|
9
8
|
import { trimTrailingSlashes } from "./api/url.js";
|
|
10
9
|
import { connectionFetch, connectionJson, httpConnectionFailure, ImConnectionError, wukongConnectionFailure } from "./connection-error.js";
|
|
@@ -66,10 +65,6 @@ class Writer {
|
|
|
66
65
|
this.chunks.push(h, b);
|
|
67
66
|
return this;
|
|
68
67
|
}
|
|
69
|
-
bytes(b) {
|
|
70
|
-
this.chunks.push(b);
|
|
71
|
-
return this;
|
|
72
|
-
}
|
|
73
68
|
finish() {
|
|
74
69
|
return Buffer.concat(this.chunks);
|
|
75
70
|
}
|
|
@@ -120,28 +115,20 @@ export class WukongConnection {
|
|
|
120
115
|
onMessage;
|
|
121
116
|
onDisconnect;
|
|
122
117
|
onPosition;
|
|
123
|
-
onDelivered;
|
|
124
118
|
#socket;
|
|
125
119
|
#closing;
|
|
126
120
|
#key;
|
|
127
121
|
#iv;
|
|
128
122
|
#version = 0;
|
|
129
123
|
#buffer = Buffer.alloc(0);
|
|
130
|
-
#seq = 0;
|
|
131
124
|
#heartbeat;
|
|
132
125
|
#awaitingPong = false;
|
|
133
126
|
#closed = false;
|
|
134
127
|
#ready = false;
|
|
135
|
-
|
|
136
|
-
#active = new Set();
|
|
137
|
-
#confirmed = new Set();
|
|
138
|
-
#retained = new Map();
|
|
139
|
-
#abort = new AbortController();
|
|
140
|
-
constructor(onMessage, onDisconnect = () => { }, onPosition, onDelivered) {
|
|
128
|
+
constructor(onMessage, onDisconnect = () => { }, onPosition) {
|
|
141
129
|
this.onMessage = onMessage;
|
|
142
130
|
this.onDisconnect = onDisconnect;
|
|
143
131
|
this.onPosition = onPosition;
|
|
144
|
-
this.onDelivered = onDelivered;
|
|
145
132
|
}
|
|
146
133
|
get connected() {
|
|
147
134
|
return this.#ready && this.#socket?.readyState === WebSocket.OPEN;
|
|
@@ -189,12 +176,6 @@ export class WukongConnection {
|
|
|
189
176
|
clearTimeout(timeout);
|
|
190
177
|
if (this.#heartbeat)
|
|
191
178
|
clearInterval(this.#heartbeat);
|
|
192
|
-
for (const pending of [...this.#active])
|
|
193
|
-
pending.disconnected();
|
|
194
|
-
this.#sends.clear();
|
|
195
|
-
for (const timer of this.#retained.values())
|
|
196
|
-
clearTimeout(timer);
|
|
197
|
-
this.#retained.clear();
|
|
198
179
|
const error = failure ?? new ImConnectionError("IM_DISCONNECTED", true);
|
|
199
180
|
if (!ready)
|
|
200
181
|
reject(error);
|
|
@@ -268,7 +249,8 @@ export class WukongConnection {
|
|
|
268
249
|
this.#ready = true;
|
|
269
250
|
clearTimeout(timeout);
|
|
270
251
|
// 切网不一定触发 TCP close,必须主动确认这条连接的双向协议链路。
|
|
271
|
-
// 每
|
|
252
|
+
// 每 10 秒 PING,下一次检查仍无 PONG 即关闭;推送或服务端 PING 不能续命。
|
|
253
|
+
// 此探测只恢复入站连接,不取消已受理任务,也不阻塞其 REST 投递。
|
|
272
254
|
// 单连接最多一个在途探测,回调延迟时不补发积压 PING;close 负责通知上层重连。
|
|
273
255
|
this.#heartbeat = setInterval(() => {
|
|
274
256
|
if (this.#awaitingPong) {
|
|
@@ -281,7 +263,7 @@ export class WukongConnection {
|
|
|
281
263
|
this.#awaitingPong = true;
|
|
282
264
|
socket.send(Buffer.from([7 << 4]));
|
|
283
265
|
}
|
|
284
|
-
},
|
|
266
|
+
}, 10_000);
|
|
285
267
|
this.#heartbeat.unref();
|
|
286
268
|
resolve();
|
|
287
269
|
}
|
|
@@ -293,24 +275,6 @@ export class WukongConnection {
|
|
|
293
275
|
throw new Error("IM_HANDSHAKE_REQUIRED");
|
|
294
276
|
else if (kind === 5)
|
|
295
277
|
this.#receive(reader, registration.robot_id);
|
|
296
|
-
else if (kind === 4) {
|
|
297
|
-
const id = reader.u64().toString();
|
|
298
|
-
const seq = reader.u32();
|
|
299
|
-
const messageSeq = reader.u32();
|
|
300
|
-
const reason = reader.byte();
|
|
301
|
-
const pending = this.#sends.get(seq);
|
|
302
|
-
if (pending) {
|
|
303
|
-
if (reason === 1) {
|
|
304
|
-
pending.onPosition?.(messageSeq);
|
|
305
|
-
this.#confirmed.add(pending.key);
|
|
306
|
-
if (this.#confirmed.size > 512)
|
|
307
|
-
this.#confirmed.delete(this.#confirmed.values().next().value);
|
|
308
|
-
this.onDelivered?.(pending.key);
|
|
309
|
-
this.#forget(pending.operation);
|
|
310
|
-
}
|
|
311
|
-
pending.operation.ack(id, reason);
|
|
312
|
-
}
|
|
313
|
-
}
|
|
314
278
|
}
|
|
315
279
|
}
|
|
316
280
|
catch (error) {
|
|
@@ -350,13 +314,6 @@ export class WukongConnection {
|
|
|
350
314
|
const payload = JSON.parse(plain.toString());
|
|
351
315
|
if (!payload || typeof payload !== "object" || Array.isArray(payload))
|
|
352
316
|
throw new Error("IM_PAYLOAD_INVALID");
|
|
353
|
-
if (fromUid === ownUid) {
|
|
354
|
-
const pending = [...this.#sends.values()].find((entry) => entry.key === clientNo &&
|
|
355
|
-
entry.channelId === channelId &&
|
|
356
|
-
entry.channelType === channelType &&
|
|
357
|
-
(!payload.space_id || payload.space_id === entry.spaceId));
|
|
358
|
-
pending?.onPosition?.(messageSeq);
|
|
359
|
-
}
|
|
360
317
|
this.onPosition?.({
|
|
361
318
|
channelId,
|
|
362
319
|
channelType,
|
|
@@ -380,87 +337,10 @@ export class WukongConnection {
|
|
|
380
337
|
// 此 ACK 仅确认 IM 消息已接收,不代表 AgentRun 已执行完成。
|
|
381
338
|
this.#socket?.send(frame(6, new Writer().u64(messageId).u32(messageSeq).finish()));
|
|
382
339
|
}
|
|
383
|
-
sendText(channelId, channelType, text, clientMsgNo = randomUUID(), spaceId, mention, signal, onPosition) {
|
|
384
|
-
return this.#sendPayload(channelId, channelType, { type: 1, content: text, ...(mention ? { mention } : {}) }, clientMsgNo, spaceId, signal, onPosition);
|
|
385
|
-
}
|
|
386
|
-
/** 原生文件消息复用文本的加密、稳定编号、ACK/迟到确认和取消窗口;不使用互动卡服务。 */
|
|
387
|
-
sendFile(channelId, channelType, file, clientMsgNo, spaceId, signal, onPosition) {
|
|
388
|
-
return this.#sendPayload(channelId, channelType, { type: 8, url: file.url, name: file.name, size: file.size, extension: file.extension }, clientMsgNo, spaceId, signal, onPosition);
|
|
389
|
-
}
|
|
390
|
-
#sendPayload(channelId, channelType, payload, clientMsgNo, spaceId, signal, onPosition) {
|
|
391
|
-
if (this.#socket?.readyState !== WebSocket.OPEN || !this.#key)
|
|
392
|
-
return Promise.reject(new ImSendError("IM_NOT_READY", "failed"));
|
|
393
|
-
const serialized = JSON.stringify({ ...payload, ...(spaceId ? { space_id: spaceId } : {}) });
|
|
394
|
-
if (Buffer.byteLength(serialized) > 256 * 1024 ||
|
|
395
|
-
this.#active.size >= 64 ||
|
|
396
|
-
this.#socket.bufferedAmount > LIMIT)
|
|
397
|
-
return Promise.reject(new ImSendError("IM_SEND_CAPACITY_EXHAUSTED", "failed"));
|
|
398
|
-
const encrypted = this.#encrypt(serialized);
|
|
399
|
-
const operation = new ImTextSend(() => {
|
|
400
|
-
if (!this.connected)
|
|
401
|
-
throw new ImSendError("IM_NOT_READY", "failed");
|
|
402
|
-
if (this.#socket.bufferedAmount > LIMIT)
|
|
403
|
-
throw new ImSendError("IM_SEND_CAPACITY_EXHAUSTED", "failed");
|
|
404
|
-
const seq = ++this.#seq;
|
|
405
|
-
const body = new Writer()
|
|
406
|
-
.byte(0)
|
|
407
|
-
.u32(seq)
|
|
408
|
-
.string(clientMsgNo)
|
|
409
|
-
.string(channelId)
|
|
410
|
-
.byte(channelType);
|
|
411
|
-
if (this.#version >= 3)
|
|
412
|
-
body.u32(0);
|
|
413
|
-
body
|
|
414
|
-
.string(md5(this.#encrypt(`${seq}${clientMsgNo}${channelId}${channelType}${encrypted}`)))
|
|
415
|
-
.bytes(Buffer.from(encrypted));
|
|
416
|
-
this.#sends.set(seq, {
|
|
417
|
-
operation,
|
|
418
|
-
key: clientMsgNo,
|
|
419
|
-
channelId,
|
|
420
|
-
channelType,
|
|
421
|
-
spaceId,
|
|
422
|
-
onPosition
|
|
423
|
-
});
|
|
424
|
-
this.#socket.send(frame(3, body.finish(), 2), (error) => {
|
|
425
|
-
if (error)
|
|
426
|
-
operation.disconnected();
|
|
427
|
-
});
|
|
428
|
-
}, (state) => {
|
|
429
|
-
this.#active.delete(operation);
|
|
430
|
-
if (state === "unknown" && !this.#closed) {
|
|
431
|
-
// 留出 REST 降级窗口关联迟到 ACK;映射与计时器均有界。
|
|
432
|
-
while (this.#retained.size >= 64)
|
|
433
|
-
this.#forget(this.#retained.keys().next().value);
|
|
434
|
-
const timer = setTimeout(() => this.#forget(operation), 30_000);
|
|
435
|
-
timer.unref();
|
|
436
|
-
this.#retained.set(operation, timer);
|
|
437
|
-
}
|
|
438
|
-
else
|
|
439
|
-
this.#forget(operation);
|
|
440
|
-
}, signal ? AbortSignal.any([this.#abort.signal, signal]) : this.#abort.signal);
|
|
441
|
-
this.#active.add(operation);
|
|
442
|
-
operation.start();
|
|
443
|
-
return operation.result;
|
|
444
|
-
}
|
|
445
|
-
isDelivered(clientMsgNo) {
|
|
446
|
-
return this.#confirmed.has(clientMsgNo);
|
|
447
|
-
}
|
|
448
|
-
#forget(operation) {
|
|
449
|
-
clearTimeout(this.#retained.get(operation));
|
|
450
|
-
this.#retained.delete(operation);
|
|
451
|
-
for (const [seq, pending] of this.#sends)
|
|
452
|
-
if (pending.operation === operation)
|
|
453
|
-
this.#sends.delete(seq);
|
|
454
|
-
}
|
|
455
340
|
close() {
|
|
456
341
|
if (this.#closing)
|
|
457
342
|
return this.#closing;
|
|
458
343
|
this.#closed = true;
|
|
459
|
-
this.#abort.abort();
|
|
460
|
-
for (const timer of this.#retained.values())
|
|
461
|
-
clearTimeout(timer);
|
|
462
|
-
this.#retained.clear();
|
|
463
|
-
this.#sends.clear();
|
|
464
344
|
this.#ready = false;
|
|
465
345
|
if (this.#heartbeat)
|
|
466
346
|
clearInterval(this.#heartbeat);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-extra-channel-gateway",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -22,11 +22,11 @@
|
|
|
22
22
|
"docs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@mininglamp-oss/octo-runtime-executor-kernel": "1.1.
|
|
26
|
-
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.
|
|
27
|
-
"@mininglamp-oss/octo-runtime-executor-core": "1.1.
|
|
28
|
-
"@mininglamp-oss/octo-runtime-host-sdk": "1.1.
|
|
29
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
25
|
+
"@mininglamp-oss/octo-runtime-executor-kernel": "1.1.9",
|
|
26
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.9",
|
|
27
|
+
"@mininglamp-oss/octo-runtime-executor-core": "1.1.9",
|
|
28
|
+
"@mininglamp-oss/octo-runtime-host-sdk": "1.1.9",
|
|
29
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.9",
|
|
30
30
|
"mdast-util-from-markdown": "2.1.0",
|
|
31
31
|
"ws": "8.22.0"
|
|
32
32
|
}
|
package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/application/im-channel.js
CHANGED
|
@@ -433,6 +433,7 @@ export class ImRuntime {
|
|
|
433
433
|
if (!entry ||
|
|
434
434
|
entry.key !== key ||
|
|
435
435
|
entry.senderId !== message.senderId ||
|
|
436
|
+
entry.request.expiresAt === undefined ||
|
|
436
437
|
!Number.isFinite(Date.parse(entry.request.expiresAt)) ||
|
|
437
438
|
Date.parse(entry.request.expiresAt) <= Date.now()) {
|
|
438
439
|
await this.#reply(message, "该交互已失效或不属于当前会话。", `interaction:${message.messageId}`);
|
|
@@ -531,6 +532,7 @@ export class ImRuntime {
|
|
|
531
532
|
let presentationFailed = false;
|
|
532
533
|
let executionStarted = false;
|
|
533
534
|
let localFailure;
|
|
535
|
+
const ignoredAsyncQuestions = new Set();
|
|
534
536
|
try {
|
|
535
537
|
presentation = message.beginPresentation?.(request.runId, (code) => this.#diagnostic(code, request.runId), controls);
|
|
536
538
|
presentation?.update(projector.snapshot());
|
|
@@ -541,6 +543,18 @@ export class ImRuntime {
|
|
|
541
543
|
})) {
|
|
542
544
|
if (this.#closed || this.#signal.aborted)
|
|
543
545
|
break;
|
|
546
|
+
// 企微尚未接入异步表单;在登记、提示和状态投影前成对过滤,正文继续正常交付。
|
|
547
|
+
// resolved 不带 delivery,须用本轮 requested 的身份识别,避免覆盖同步交互的等待状态。
|
|
548
|
+
if (event.type === "interaction.requested" && event.payload.delivery === "async") {
|
|
549
|
+
if (ignoredAsyncQuestions.size >= 64 &&
|
|
550
|
+
!ignoredAsyncQuestions.has(event.payload.interactionId))
|
|
551
|
+
throw new Error("IM_INTERACTION_CAPACITY_EXHAUSTED");
|
|
552
|
+
ignoredAsyncQuestions.add(event.payload.interactionId);
|
|
553
|
+
continue;
|
|
554
|
+
}
|
|
555
|
+
if (event.type === "interaction.resolved" &&
|
|
556
|
+
ignoredAsyncQuestions.delete(event.payload.interactionId))
|
|
557
|
+
continue;
|
|
544
558
|
if (event.type === "session.update" && session.id === request.sessionId) {
|
|
545
559
|
session.providerSession = event.payload.providerSession;
|
|
546
560
|
this.#saveBinding(key, session);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-extra-channel-wecom",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -22,10 +22,10 @@
|
|
|
22
22
|
"docs"
|
|
23
23
|
],
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@mininglamp-oss/octo-runtime-host-sdk": "1.1.
|
|
26
|
-
"@mininglamp-oss/octo-runtime-executor-core": "1.1.
|
|
27
|
-
"@mininglamp-oss/octo-runtime-executor-kernel": "1.1.
|
|
25
|
+
"@mininglamp-oss/octo-runtime-host-sdk": "1.1.9",
|
|
26
|
+
"@mininglamp-oss/octo-runtime-executor-core": "1.1.9",
|
|
27
|
+
"@mininglamp-oss/octo-runtime-executor-kernel": "1.1.9",
|
|
28
28
|
"ws": "8.22.0",
|
|
29
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
29
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.9"
|
|
30
30
|
}
|
|
31
31
|
}
|