@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
|
@@ -15,7 +15,6 @@ import { MODEL_WAIT_TIMEOUT_MESSAGE } from "../execution/model-wait.js";
|
|
|
15
15
|
import { ImDeliveryIdentity } from "../delivery/identity.js";
|
|
16
16
|
import { ImDeliveryDispatcher } from "../delivery/dispatcher.js";
|
|
17
17
|
import { ImRunProjector } from "../presentation/run-projector.js";
|
|
18
|
-
import { deliveryNotice } from "../presentation/delivery-notice.js";
|
|
19
18
|
import { MemoryImSessionStore } from "./session-store.js";
|
|
20
19
|
import { addRulesRecovery, selectRulesContext } from "./rules-context.js";
|
|
21
20
|
import { planStableContext } from "./stable-context.js";
|
|
@@ -65,7 +64,7 @@ export class ImRuntime {
|
|
|
65
64
|
#delivery;
|
|
66
65
|
#cardDelivery;
|
|
67
66
|
#deliveryIdentity;
|
|
68
|
-
//
|
|
67
|
+
// 仅保存已核验 Bot/空间的凭据;候选值核验期间 REST 继续使用旧值,不等待 WS。
|
|
69
68
|
#restToken;
|
|
70
69
|
#sessions = new Map();
|
|
71
70
|
#sessionStore;
|
|
@@ -201,7 +200,6 @@ export class ImRuntime {
|
|
|
201
200
|
? this.dependencies.credentials(config, signal)
|
|
202
201
|
: Promise.resolve(config.bf_token));
|
|
203
202
|
signal.throwIfAborted();
|
|
204
|
-
this.#restToken = token?.trim();
|
|
205
203
|
return token;
|
|
206
204
|
};
|
|
207
205
|
const connector = new GatewayTransport(this.config, credentials, {
|
|
@@ -210,6 +208,11 @@ export class ImRuntime {
|
|
|
210
208
|
if (connector === this.#connector && !signal.aborted)
|
|
211
209
|
this.#observePosition(position);
|
|
212
210
|
},
|
|
211
|
+
onTaskPosition: (position) => {
|
|
212
|
+
// 原任务目标身份生成 key;重连中 current connector 可能尚未核验空间。
|
|
213
|
+
if (!this.#signal.aborted)
|
|
214
|
+
this.#observePosition(position, this.#key(position, connector.identity));
|
|
215
|
+
},
|
|
213
216
|
onRulesChanged: (change) => {
|
|
214
217
|
if (connector !== this.#connector || signal.aborted)
|
|
215
218
|
return;
|
|
@@ -237,8 +240,9 @@ export class ImRuntime {
|
|
|
237
240
|
dispatcher: this.#cardDelivery,
|
|
238
241
|
identity: this.#deliveryIdentity,
|
|
239
242
|
token: () => this.#restToken,
|
|
240
|
-
|
|
241
|
-
|
|
243
|
+
acceptToken: (token) => {
|
|
244
|
+
this.#restToken = token;
|
|
245
|
+
}
|
|
242
246
|
});
|
|
243
247
|
this.#connector = connector;
|
|
244
248
|
try {
|
|
@@ -373,9 +377,9 @@ export class ImRuntime {
|
|
|
373
377
|
this.#drainErrors.push(new Error(code));
|
|
374
378
|
this.#diagnostic(code, runId);
|
|
375
379
|
}
|
|
376
|
-
#key(message) {
|
|
380
|
+
#key(message, identity = this.#connector.identity) {
|
|
377
381
|
return [
|
|
378
|
-
|
|
382
|
+
identity,
|
|
379
383
|
imBotIdentity(this.config),
|
|
380
384
|
this.config.adapter.adapter_type ?? "",
|
|
381
385
|
message.conversationKind,
|
|
@@ -384,10 +388,9 @@ export class ImRuntime {
|
|
|
384
388
|
.map(encodeURIComponent)
|
|
385
389
|
.join("/");
|
|
386
390
|
}
|
|
387
|
-
#observePosition(position) {
|
|
391
|
+
#observePosition(position, key = this.#key(position)) {
|
|
388
392
|
if (this.#closed || !validMessageSeq(position.messageSeq))
|
|
389
393
|
return;
|
|
390
|
-
const key = this.#key(position);
|
|
391
394
|
try {
|
|
392
395
|
const binding = this.#sessionStore.read(key);
|
|
393
396
|
if (!binding?.id || !this.#sessionStore.patchGap)
|
|
@@ -488,6 +491,8 @@ export class ImRuntime {
|
|
|
488
491
|
}
|
|
489
492
|
this.#seen.set(dedupe, now + 120_000);
|
|
490
493
|
const command = message.text.trim();
|
|
494
|
+
// null 表示 Gateway 已拒绝控制授权;不能用 ?? 回退原文,避免广播裸命令绕过。
|
|
495
|
+
const sessionControl = message.sessionControl === undefined ? command : message.sessionControl;
|
|
491
496
|
if (/^\/(approve|decline|respond)\s/.test(command)) {
|
|
492
497
|
void this.#respond(message, key).catch(() => this.#diagnostic("IM_INTERACTION_RESPONSE_FAILED"));
|
|
493
498
|
return;
|
|
@@ -506,7 +511,7 @@ export class ImRuntime {
|
|
|
506
511
|
return;
|
|
507
512
|
}
|
|
508
513
|
try {
|
|
509
|
-
if (
|
|
514
|
+
if (sessionControl === "/reset" || sessionControl === "/new") {
|
|
510
515
|
try {
|
|
511
516
|
const binding = this.#sessionStore.reset(key, message.messageId);
|
|
512
517
|
this.#finalDeliveries.get(key)?.abort();
|
|
@@ -529,7 +534,7 @@ export class ImRuntime {
|
|
|
529
534
|
}
|
|
530
535
|
return;
|
|
531
536
|
}
|
|
532
|
-
if (
|
|
537
|
+
if (sessionControl === "/stop" || command === "/cancel") {
|
|
533
538
|
// 控制命令绕过普通消息队列,否则 stop 会排在待取消的长任务之后。
|
|
534
539
|
const preparation = this.#preparing.get(key);
|
|
535
540
|
preparation?.abort();
|
|
@@ -792,36 +797,21 @@ export class ImRuntime {
|
|
|
792
797
|
this.#failureNotifications.set(failure.diagnosticId, notification);
|
|
793
798
|
return notification;
|
|
794
799
|
}
|
|
795
|
-
async #reply(message, text, effectKey, requireDelivered = false, final = false,
|
|
800
|
+
async #reply(message, text, effectKey, requireDelivered = false, final = false, finalOptions, runId) {
|
|
796
801
|
if (this.#closed || this.#signal.aborted || !this.#delivery)
|
|
797
802
|
return;
|
|
798
803
|
const receipt = await this.#delivery.deliver(effectKey, () => final && message.replyFinal
|
|
799
804
|
? message.replyFinal(text, effectKey, finalOptions)
|
|
800
|
-
: message.reply(text, effectKey, finalOptions), {
|
|
805
|
+
: message.reply(text, effectKey, finalOptions), {
|
|
806
|
+
obsolete: finalOptions ? () => finalOptions.obsolete() : undefined,
|
|
807
|
+
...(finalOptions ? { attempts: 4 } : {})
|
|
808
|
+
});
|
|
801
809
|
if (finalOptions?.obsolete())
|
|
802
810
|
return;
|
|
803
811
|
if (receipt.state !== "delivered") {
|
|
804
812
|
if (this.#draining)
|
|
805
813
|
this.#drainErrors.push(new Error(receipt.code ?? "IM_DELIVERY_FAILED"));
|
|
806
|
-
this.#diagnostic(receipt.code ?? "IM_DELIVERY_FAILED");
|
|
807
|
-
if (allowUnknownNotice &&
|
|
808
|
-
receipt.state === "unknown" &&
|
|
809
|
-
message.replyDeliveryUnknown &&
|
|
810
|
-
!this.#closed &&
|
|
811
|
-
!this.#signal.aborted) {
|
|
812
|
-
const notice = deliveryNotice();
|
|
813
|
-
// 未知通知仍属于原轮最终投递;stop/reset 必须取消在途请求并阻止后续重试。
|
|
814
|
-
// 迟到 ACK 与代次过期共用发送边界检查,不能因 REST 独立于 WS 而脱离任务期限。
|
|
815
|
-
const noticeSignal = finalOptions
|
|
816
|
-
? AbortSignal.any([this.#signal, finalOptions.signal])
|
|
817
|
-
: this.#signal;
|
|
818
|
-
const obsolete = () => noticeSignal.aborted ||
|
|
819
|
-
Boolean(finalOptions?.obsolete()) ||
|
|
820
|
-
Boolean(message.isReplyDelivered?.(effectKey));
|
|
821
|
-
const result = await this.#delivery.deliver(`delivery-unknown:${effectKey}`, () => message.replyDeliveryUnknown(notice, `delivery-unknown:${effectKey}`, effectKey, noticeSignal, obsolete), { obsolete });
|
|
822
|
-
if (result.state !== "delivered" && !obsolete())
|
|
823
|
-
this.#diagnostic("IM_DELIVERY_NOTICE_FAILED");
|
|
824
|
-
}
|
|
814
|
+
this.#diagnostic(receipt.code ?? "IM_DELIVERY_FAILED", runId);
|
|
825
815
|
if (requireDelivered)
|
|
826
816
|
throw new Error(receipt.code ?? "IM_DELIVERY_FAILED");
|
|
827
817
|
}
|
|
@@ -834,6 +824,7 @@ export class ImRuntime {
|
|
|
834
824
|
if (!entry ||
|
|
835
825
|
entry.key !== key ||
|
|
836
826
|
entry.senderId !== message.senderId ||
|
|
827
|
+
entry.request.expiresAt === undefined ||
|
|
837
828
|
!Number.isFinite(Date.parse(entry.request.expiresAt)) ||
|
|
838
829
|
Date.parse(entry.request.expiresAt) <= Date.now()) {
|
|
839
830
|
await this.#reply(message, "该交互已失效或不属于当前会话。", `interaction:${message.messageId}`);
|
|
@@ -868,6 +859,7 @@ export class ImRuntime {
|
|
|
868
859
|
entry.key !== key ||
|
|
869
860
|
entry.senderId !== senderId ||
|
|
870
861
|
this.#sessionStore.read(key)?.id !== entry.sessionId ||
|
|
862
|
+
entry.request.expiresAt === undefined ||
|
|
871
863
|
!Number.isFinite(Date.parse(entry.request.expiresAt)) ||
|
|
872
864
|
Date.parse(entry.request.expiresAt) <= Date.now())
|
|
873
865
|
throw Error("IM_INTERACTION_STALE");
|
|
@@ -1133,7 +1125,7 @@ export class ImRuntime {
|
|
|
1133
1125
|
};
|
|
1134
1126
|
try {
|
|
1135
1127
|
try {
|
|
1136
|
-
presentation = message.beginPresentation?.(rootRunId, (code) => this.#diagnostic(code, rootRunId), controls);
|
|
1128
|
+
presentation = message.beginPresentation?.(rootRunId, (code, data) => this.#diagnostic(code, rootRunId, data), controls);
|
|
1137
1129
|
presentation?.update(snapshot());
|
|
1138
1130
|
session.activeInvocationId = request.invocationId;
|
|
1139
1131
|
executionStarted = true;
|
|
@@ -1386,11 +1378,11 @@ export class ImRuntime {
|
|
|
1386
1378
|
providerSessionId: session.providerSession.sessionId
|
|
1387
1379
|
});
|
|
1388
1380
|
// 最终文本拥有独立投递身份,即使进度卡投递失败,也必须尝试回复用户。
|
|
1389
|
-
await this.#reply(message, text, `final:${rootRunId}`, false, allowMention,
|
|
1381
|
+
await this.#reply(message, text, `final:${rootRunId}`, false, allowMention, {
|
|
1390
1382
|
artifacts: prepared.artifacts,
|
|
1391
1383
|
signal: deliverySignal,
|
|
1392
1384
|
obsolete: () => deliverySignal.aborted || (allowMention && obsolete())
|
|
1393
|
-
});
|
|
1385
|
+
}, rootRunId);
|
|
1394
1386
|
}
|
|
1395
1387
|
finally {
|
|
1396
1388
|
if (this.#finalDeliveries.get(key) === delivery)
|
|
@@ -91,14 +91,13 @@ export interface ImInboundMessage {
|
|
|
91
91
|
conversationId: string;
|
|
92
92
|
conversationKind: "direct" | "group" | "thread";
|
|
93
93
|
text: string;
|
|
94
|
+
/** Gateway 群/话题已核验的完整控制命令;null 禁止正文回退,省略沿用 DM/内部调用行为。 */
|
|
95
|
+
sessionControl?: "/reset" | "/new" | "/stop" | null;
|
|
94
96
|
buildInputs?(signal: AbortSignal): Promise<ModelInputPart[]>;
|
|
95
97
|
/** 终态提示也携带该轮投递期限;普通控制回复可省略,不进行产物准备。 */
|
|
96
98
|
reply(text: string, effectKey?: string, options?: Pick<ImFinalReplyOptions, "signal" | "obsolete">): Promise<void>;
|
|
97
99
|
replyFinal?(text: string, effectKey: string, options?: ImFinalReplyOptions): Promise<void>;
|
|
98
100
|
replyFailure?(event: CanonicalEvent, effectKey: string, options?: Pick<ImFinalReplyOptions, "signal" | "obsolete">): Promise<void>;
|
|
99
|
-
/** 原轮未知通知继承最终投递取消及过期判断,在实际 REST 发送前再次检查。 */
|
|
100
|
-
replyDeliveryUnknown?(event: CanonicalEvent, effectKey: string, replyEffectKey: string, signal: AbortSignal, obsolete?: () => boolean): Promise<void>;
|
|
101
|
-
isReplyDelivered?(effectKey: string): boolean;
|
|
102
101
|
buildContext(signal: AbortSignal, options?: {
|
|
103
102
|
initialSession: boolean;
|
|
104
103
|
configuredItems?: readonly ContextItem[];
|
|
@@ -107,7 +106,7 @@ export interface ImInboundMessage {
|
|
|
107
106
|
}): Promise<ContextEnvelope>;
|
|
108
107
|
executionEnvironment?(): InvokeEnvironment;
|
|
109
108
|
runMetadata?: Record<string, unknown>;
|
|
110
|
-
beginPresentation?(runId: string, onDiagnostic: (code: string) => void, controls: ImRunControls): ImPresentation;
|
|
109
|
+
beginPresentation?(runId: string, onDiagnostic: (code: string, data?: Record<string, unknown>) => void, controls: ImRunControls): ImPresentation;
|
|
111
110
|
}
|
|
112
111
|
export interface ImPresentation {
|
|
113
112
|
interaction?(request: InteractionRequestedPayload): Promise<boolean>;
|
|
@@ -135,6 +134,8 @@ export interface ChannelCallbacks {
|
|
|
135
134
|
shortId?: string;
|
|
136
135
|
}): void;
|
|
137
136
|
onPosition?(position: ImPositionObservation): void;
|
|
137
|
+
/** 已受理任务的 REST 回执位置,归 Bot/任务所有,不要求接收 WS 仍在线。 */
|
|
138
|
+
onTaskPosition?(position: ImPositionObservation): void;
|
|
138
139
|
authorizeSpace?: (spaceId: string) => void;
|
|
139
140
|
onMessage(message: ImInboundMessage): void;
|
|
140
141
|
onDisconnect(code: string, retryable?: boolean): void;
|
|
@@ -11,6 +11,10 @@ export declare class ImDeliveryDispatcher {
|
|
|
11
11
|
get receiptCount(): number;
|
|
12
12
|
deliver(effectKey: string, operation: () => Promise<string | void>, options?: {
|
|
13
13
|
transient?: boolean;
|
|
14
|
+
/** 仅当前 finalMsg/卡片 finish 显式指定剩余尝试数,包含首发,最多四次。 */
|
|
15
|
+
attempts?: 1 | 2 | 3 | 4;
|
|
14
16
|
obsolete?: () => boolean;
|
|
17
|
+
cardOperation?: "send" | "edit";
|
|
18
|
+
onDiagnostic?: (code: string, data?: Record<string, unknown>) => void;
|
|
15
19
|
}): Promise<ImDeliveryReceipt>;
|
|
16
20
|
}
|
package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/dispatcher.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { sanitizeDiagnosticBody } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
1
2
|
import { OctoApiError } from "../transport/api/errors.js";
|
|
2
|
-
import { ImSendError } from "./
|
|
3
|
+
import { ImSendError } from "./send-error.js";
|
|
3
4
|
export class ImDeliveryDispatcher {
|
|
4
5
|
signal;
|
|
5
6
|
#receipts = new Map();
|
|
@@ -14,7 +15,7 @@ export class ImDeliveryDispatcher {
|
|
|
14
15
|
const previous = this.#receipts.get(effectKey);
|
|
15
16
|
if (previous?.state === "delivered")
|
|
16
17
|
return { ...previous };
|
|
17
|
-
const attempts = options.transient ? 1 : 3;
|
|
18
|
+
const attempts = options.transient ? 1 : (options.attempts ?? 3);
|
|
18
19
|
let receipt = { effectKey, state: "pending" };
|
|
19
20
|
this.#record(receipt);
|
|
20
21
|
for (let attempt = 0; attempt < attempts && !this.signal.aborted; attempt++) {
|
|
@@ -36,12 +37,27 @@ export class ImDeliveryDispatcher {
|
|
|
36
37
|
code: error instanceof ImSendError
|
|
37
38
|
? error.code
|
|
38
39
|
: status
|
|
39
|
-
?
|
|
40
|
+
? options.cardOperation
|
|
41
|
+
? `IM_CARD_${options.cardOperation.toUpperCase()}_${status}`
|
|
42
|
+
: `IM_HTTP_${status}`
|
|
40
43
|
: "IM_DELIVERY_UNKNOWN"
|
|
41
44
|
};
|
|
42
45
|
this.#record(receipt);
|
|
43
|
-
//
|
|
44
|
-
|
|
46
|
+
// HTTP 状态只描述本次投递,不代表业务永久失败;诊断先脱敏再限长,不记录请求正文。
|
|
47
|
+
try {
|
|
48
|
+
options.onDiagnostic?.(receipt.code, options.cardOperation && error instanceof OctoApiError
|
|
49
|
+
? {
|
|
50
|
+
path: error.path.split(/[?#]/, 1)[0],
|
|
51
|
+
http_status: error.status,
|
|
52
|
+
response_body: sanitizeDiagnosticBody(error.body)
|
|
53
|
+
}
|
|
54
|
+
: undefined);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
/* 诊断回调失败不得改变投递结果或触发额外发送。 */
|
|
58
|
+
}
|
|
59
|
+
// 仅本轮 REST 收尾可重试未知响应;明确取消/拒绝立即结束,不另开确认窗口。
|
|
60
|
+
if (error instanceof ImSendError && !(options.attempts && error.state === "unknown"))
|
|
45
61
|
break;
|
|
46
62
|
if (status && status !== 429 && status < 500)
|
|
47
63
|
break;
|
|
@@ -73,8 +89,15 @@ export class ImDeliveryDispatcher {
|
|
|
73
89
|
}
|
|
74
90
|
}
|
|
75
91
|
}
|
|
76
|
-
if (receipt.state === "pending")
|
|
92
|
+
if (receipt.state === "pending") {
|
|
77
93
|
receipt = { effectKey, state: "failed", code: "IM_DELIVERY_CANCELLED" };
|
|
94
|
+
try {
|
|
95
|
+
options.onDiagnostic?.(receipt.code);
|
|
96
|
+
}
|
|
97
|
+
catch {
|
|
98
|
+
/* 取消诊断同样不能阻断清理。 */
|
|
99
|
+
}
|
|
100
|
+
}
|
|
78
101
|
this.#record(receipt);
|
|
79
102
|
return receipt;
|
|
80
103
|
}
|
package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/delivery/identity.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ImSendError } from "./
|
|
2
|
-
/** 一次已核验目标身份的投递权限及有界
|
|
1
|
+
import { ImSendError } from "./send-error.js";
|
|
2
|
+
/** 一次已核验目标身份的投递权限及有界 REST 回执缓存;更新 token 或重建 WS 不取消。 */
|
|
3
3
|
export class ImDeliveryScope {
|
|
4
4
|
#abort = new AbortController();
|
|
5
5
|
#confirmed = new Set();
|
package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/task.js
CHANGED
|
@@ -244,6 +244,7 @@ export class ImTask {
|
|
|
244
244
|
this.attempts.push(attempt);
|
|
245
245
|
let terminal;
|
|
246
246
|
let completion = "unresolved";
|
|
247
|
+
const ignoredAsyncQuestions = new Set();
|
|
247
248
|
try {
|
|
248
249
|
for await (const event of this.kernel.invoke(request, {
|
|
249
250
|
...this.environment,
|
|
@@ -251,6 +252,19 @@ export class ImTask {
|
|
|
251
252
|
})) {
|
|
252
253
|
if (terminal)
|
|
253
254
|
throw new Error("IM_FRAME_AFTER_TERMINAL");
|
|
255
|
+
// Gateway 尚不接入异步表单;成对忽略交互事件,避免暂停等待钟或改变卡片状态。
|
|
256
|
+
// 消息正文仍正常投影,原流继续消费;已出现交互的尝试仍禁止自动重放。
|
|
257
|
+
if (event.type === "interaction.requested" && event.payload.delivery === "async") {
|
|
258
|
+
this.#replaySafe = false;
|
|
259
|
+
if (ignoredAsyncQuestions.size >= 64 &&
|
|
260
|
+
!ignoredAsyncQuestions.has(event.payload.interactionId))
|
|
261
|
+
throw new Error("IM_INTERACTION_CAPACITY_EXHAUSTED");
|
|
262
|
+
ignoredAsyncQuestions.add(event.payload.interactionId);
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
if (event.type === "interaction.resolved" &&
|
|
266
|
+
ignoredAsyncQuestions.delete(event.payload.interactionId))
|
|
267
|
+
continue;
|
|
254
268
|
this.#observe(event);
|
|
255
269
|
if (event.type === "session.update")
|
|
256
270
|
request = {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* 单 Run 卡片会话:首次创建、后续编辑同一消息,并用序号和终态屏障收敛状态。
|
|
3
|
-
*
|
|
3
|
+
* 终态展示被拒绝时有界降级到精简帧;确认投递后 finish 正常返回,仍失败则保留诊断。
|
|
4
|
+
* 最终文本由执行编排独立投递;服务端回执不代表客户端已经渲染。
|
|
4
5
|
*/
|
|
5
6
|
import type { ImAddress } from "../contracts.js";
|
|
6
7
|
import type { OctoConnector } from "./connector.js";
|
|
@@ -12,7 +13,7 @@ export declare class CardSession {
|
|
|
12
13
|
readonly delivery: ImDeliveryDispatcher;
|
|
13
14
|
readonly address: ImAddress;
|
|
14
15
|
readonly effectKey: string;
|
|
15
|
-
constructor(connector: OctoConnector, delivery: ImDeliveryDispatcher, address: ImAddress, runId: string, stopTyping: () => void, onDiagnostic: (code: string) => void);
|
|
16
|
+
constructor(connector: OctoConnector, delivery: ImDeliveryDispatcher, address: ImAddress, runId: string, stopTyping: () => void, onDiagnostic: (code: string, data?: Record<string, unknown>) => void);
|
|
16
17
|
update(snapshot: RunPresentation): void;
|
|
17
18
|
finish(): Promise<void>;
|
|
18
19
|
/** 所有者完成 finish 后释放调度/回调;保留 messageId 供已有卡片按钮关联使用。 */
|
|
@@ -57,21 +57,65 @@ export class CardSession {
|
|
|
57
57
|
// 模板查询期间可能已收到终态;旧快照必须在出站前再次检查。
|
|
58
58
|
if (!this.#scheduler || (this.#scheduler.terminal && !settled))
|
|
59
59
|
return;
|
|
60
|
-
|
|
61
|
-
const
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
60
|
+
// 同一 finish 的原帧与精简帧共用四次预算,切换展示内容不能重开重试窗口。
|
|
61
|
+
const budget = { remaining: settled ? 4 : 1 };
|
|
62
|
+
let receipt = await this.#deliver(frame, template, settled, budget);
|
|
63
|
+
// 400 不是业务终态。只在明确拒收后替换展示内容再投一次,不重放未知投递或另起可见卡片。
|
|
64
|
+
if (settled &&
|
|
65
|
+
budget.remaining > 0 &&
|
|
66
|
+
receipt.state === "failed" &&
|
|
67
|
+
(receipt.code === "IM_CARD_SEND_400" || receipt.code === "IM_CARD_EDIT_400")) {
|
|
68
|
+
const compact = {
|
|
69
|
+
reasoningId: frame.reasoningId,
|
|
70
|
+
state: frame.state,
|
|
71
|
+
title: "执行结果",
|
|
72
|
+
statusLabel: frame.statusLabel,
|
|
73
|
+
statusTone: frame.statusTone,
|
|
74
|
+
traceExpanded: false,
|
|
75
|
+
traceCollapsed: true,
|
|
76
|
+
collapsedSummary: frame.statusLabel + " · 过程详情暂不可用,请查看最终回复或运行记录。",
|
|
77
|
+
phases: [
|
|
78
|
+
{
|
|
79
|
+
thought: "过程详情暂不可用,请查看最终回复或运行记录。",
|
|
80
|
+
actions: [
|
|
81
|
+
{
|
|
82
|
+
tool: "任务状态",
|
|
83
|
+
detail: frame.statusLabel,
|
|
84
|
+
statusGlyph: "●",
|
|
85
|
+
statusTone: "Accent"
|
|
86
|
+
}
|
|
87
|
+
]
|
|
88
|
+
}
|
|
89
|
+
],
|
|
90
|
+
...(frame.state === "error"
|
|
91
|
+
? { errorTitle: "执行失败", errorMessage: "请查看最终回复或运行记录。" }
|
|
92
|
+
: {})
|
|
93
|
+
};
|
|
94
|
+
receipt = await this.#deliver(compact, template, settled, budget);
|
|
95
|
+
if (receipt.state === "delivered")
|
|
96
|
+
this.#onDiagnostic?.("IM_CARD_TERMINAL_DEGRADED");
|
|
97
|
+
}
|
|
65
98
|
if (receipt.state === "delivered") {
|
|
66
99
|
// 后续更新绑定第一次成功发送的消息,不另起卡片;可见卡片接替 typing 提示。
|
|
67
100
|
this.#messageId = receipt.messageId;
|
|
68
101
|
this.#stopTyping?.();
|
|
69
102
|
}
|
|
70
|
-
else
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
103
|
+
else if (settled)
|
|
104
|
+
this.#terminalFailed = true;
|
|
105
|
+
}
|
|
106
|
+
/** 沿同一卡片串行发送;降级帧也使用新序号和独立回执,保留取消与旧帧屏障。 */
|
|
107
|
+
#deliver(frame, template, settled, budget) {
|
|
108
|
+
const seq = ++this.#seq;
|
|
109
|
+
return this.delivery.deliver(`${this.effectKey}:${seq}`, () => {
|
|
110
|
+
budget.remaining--;
|
|
111
|
+
return this.connector.card(this.address, template, frame, this.effectKey, this.#messageId, seq, !settled);
|
|
112
|
+
}, {
|
|
113
|
+
transient: !settled,
|
|
114
|
+
...(settled ? { attempts: budget.remaining } : {}),
|
|
115
|
+
obsolete: () => !this.#scheduler || (this.#scheduler.terminal && !settled),
|
|
116
|
+
cardOperation: this.#messageId ? "edit" : "send",
|
|
117
|
+
onDiagnostic: (code, data) => this.#onDiagnostic?.(code, data)
|
|
118
|
+
});
|
|
75
119
|
}
|
|
76
120
|
async finish() {
|
|
77
121
|
this.#stopTyping?.();
|
package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.d.ts
CHANGED
|
@@ -13,7 +13,8 @@ export declare class GatewayTransport {
|
|
|
13
13
|
dispatcher: ImDeliveryDispatcher;
|
|
14
14
|
identity: ImDeliveryIdentity;
|
|
15
15
|
token?: () => string | undefined;
|
|
16
|
-
|
|
16
|
+
/** 身份及空间准入后同步发布凭据;候选值不得提前供旧任务读取。 */
|
|
17
|
+
acceptToken?: (token: string) => void;
|
|
17
18
|
} | undefined;
|
|
18
19
|
identity: string;
|
|
19
20
|
readonly botId: string;
|
|
@@ -57,7 +58,8 @@ export declare class GatewayTransport {
|
|
|
57
58
|
dispatcher: ImDeliveryDispatcher;
|
|
58
59
|
identity: ImDeliveryIdentity;
|
|
59
60
|
token?: () => string | undefined;
|
|
60
|
-
|
|
61
|
+
/** 身份及空间准入后同步发布凭据;候选值不得提前供旧任务读取。 */
|
|
62
|
+
acceptToken?: (token: string) => void;
|
|
61
63
|
} | undefined);
|
|
62
64
|
get status(): {
|
|
63
65
|
connected: boolean;
|