@mininglamp-oss/octo-runtime 1.1.7 → 1.1.8

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.
Files changed (58) hide show
  1. package/apps/cli/dist/build-info.json +2 -2
  2. package/node_modules/@mininglamp-oss/octo-runtime-acp-client/package.json +3 -3
  3. package/node_modules/@mininglamp-oss/octo-runtime-adapter-acp/package.json +4 -4
  4. package/node_modules/@mininglamp-oss/octo-runtime-adapter-antigravity/package.json +3 -3
  5. package/node_modules/@mininglamp-oss/octo-runtime-adapter-claude-code/package.json +3 -3
  6. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codebuddy/package.json +4 -4
  7. package/node_modules/@mininglamp-oss/octo-runtime-adapter-codex/package.json +3 -3
  8. package/node_modules/@mininglamp-oss/octo-runtime-adapter-dsh/package.json +3 -3
  9. package/node_modules/@mininglamp-oss/octo-runtime-adapter-grok-build/package.json +5 -5
  10. package/node_modules/@mininglamp-oss/octo-runtime-adapter-hermes/package.json +2 -2
  11. package/node_modules/@mininglamp-oss/octo-runtime-adapter-kimi-code/package.json +2 -2
  12. package/node_modules/@mininglamp-oss/octo-runtime-adapter-mcode/package.json +2 -2
  13. package/node_modules/@mininglamp-oss/octo-runtime-adapter-openclaw/package.json +3 -3
  14. package/node_modules/@mininglamp-oss/octo-runtime-adapter-opencode/package.json +4 -4
  15. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qodercli/package.json +2 -2
  16. package/node_modules/@mininglamp-oss/octo-runtime-adapter-qoderclicn/package.json +2 -2
  17. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.d.ts +1 -1
  18. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/index.js +1 -1
  19. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/public-display.d.ts +2 -0
  20. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/public-display.js +22 -0
  21. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/runtime-log.js +20 -0
  22. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/dist/service-status.js +14 -1
  23. package/node_modules/@mininglamp-oss/octo-runtime-adapter-sdk/package.json +2 -2
  24. package/node_modules/@mininglamp-oss/octo-runtime-adapter-zcode-gui/package.json +3 -3
  25. package/node_modules/@mininglamp-oss/octo-runtime-cli/dist/build-info.json +2 -2
  26. package/node_modules/@mininglamp-oss/octo-runtime-cli/package.json +24 -24
  27. package/node_modules/@mininglamp-oss/octo-runtime-cross-service/package.json +1 -1
  28. package/node_modules/@mininglamp-oss/octo-runtime-executor-core/package.json +3 -3
  29. package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/package.json +4 -4
  30. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/application/im-channel.js +21 -33
  31. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/contracts.d.ts +3 -4
  32. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/dispatcher.d.ts +4 -0
  33. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/dispatcher.js +29 -6
  34. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/identity.d.ts +1 -1
  35. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/identity.js +2 -2
  36. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/send-error.d.ts +6 -0
  37. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/send-error.js +10 -0
  38. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/card-session.d.ts +3 -2
  39. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/card-session.js +54 -10
  40. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.d.ts +4 -2
  41. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.js +73 -109
  42. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connector.d.ts +3 -5
  43. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/connector.js +27 -40
  44. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/reasoning-frame.js +42 -7
  45. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.d.ts +1 -12
  46. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/wukong.js +6 -126
  47. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/package.json +6 -6
  48. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/package.json +5 -5
  49. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/web/assets/{index-CXTvRGim.js → index-B127MhT-.js} +10 -9
  50. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/web/index.html +1 -1
  51. package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/package.json +2 -2
  52. package/node_modules/@mininglamp-oss/octo-runtime-host-sdk/package.json +4 -4
  53. package/node_modules/@mininglamp-oss/octo-runtime-protocol/package.json +1 -1
  54. package/package.json +27 -27
  55. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/text-send.d.ts +0 -19
  56. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/text-send.js +0 -86
  57. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/presentation/delivery-notice.d.ts +0 -5
  58. package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/presentation/delivery-notice.js +0 -35
@@ -1,10 +1,9 @@
1
1
  /**
2
- * WuKong 传输:负责 Bot 注册、加密握手、二进制帧编解码和收发确认。
3
- * 保留原通道的协议兼容性;授权、Context 和执行策略由上层处理。
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
- #sends = new Map();
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
- // 每 5 秒 PING,下一次检查仍无 PONG 即关闭;推送或服务端 PING 不能续命。
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
- }, 5_000);
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.7",
3
+ "version": "1.1.8",
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.7",
26
- "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.7",
27
- "@mininglamp-oss/octo-runtime-executor-core": "1.1.7",
28
- "@mininglamp-oss/octo-runtime-host-sdk": "1.1.7",
29
- "@mininglamp-oss/octo-runtime-protocol": "1.1.7",
25
+ "@mininglamp-oss/octo-runtime-executor-kernel": "1.1.8",
26
+ "@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.8",
27
+ "@mininglamp-oss/octo-runtime-executor-core": "1.1.8",
28
+ "@mininglamp-oss/octo-runtime-host-sdk": "1.1.8",
29
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.8",
30
30
  "mdast-util-from-markdown": "2.1.0",
31
31
  "ws": "8.22.0"
32
32
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mininglamp-oss/octo-runtime-extra-channel-wecom",
3
- "version": "1.1.7",
3
+ "version": "1.1.8",
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.7",
26
- "@mininglamp-oss/octo-runtime-executor-core": "1.1.7",
27
- "@mininglamp-oss/octo-runtime-executor-kernel": "1.1.7",
25
+ "@mininglamp-oss/octo-runtime-host-sdk": "1.1.8",
26
+ "@mininglamp-oss/octo-runtime-executor-core": "1.1.8",
27
+ "@mininglamp-oss/octo-runtime-executor-kernel": "1.1.8",
28
28
  "ws": "8.22.0",
29
- "@mininglamp-oss/octo-runtime-protocol": "1.1.7"
29
+ "@mininglamp-oss/octo-runtime-protocol": "1.1.8"
30
30
  }
31
31
  }