@mininglamp-oss/octo-runtime 1.1.8 → 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/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 +6 -2
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/contracts.d.ts +2 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/execution/task.js +14 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.js +4 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/interaction-card.js +2 -1
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/session-command.d.ts +9 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/session-command.js +71 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/package.json +6 -6
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/dist/application/im-channel.js +14 -0
- package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-wecom/package.json +5 -5
- package/node_modules/@mininglamp-oss/octo-runtime-extra-webui/dist/web/assets/{index-B127MhT-.js → index-BVxePruX.js} +1 -1
- 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
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { isTerminal } from "@mininglamp-oss/octo-runtime-protocol";
|
|
1
|
+
import { isTerminal, DEFAULT_RUN_TIMEOUT_MS } from "@mininglamp-oss/octo-runtime-protocol";
|
|
2
2
|
import { performance } from "node:perf_hooks";
|
|
3
3
|
export const DEFAULT_RUNTIME_LIMITS = {
|
|
4
4
|
firstFrameTimeoutMs: 60_000,
|
|
@@ -6,7 +6,7 @@ export const DEFAULT_RUNTIME_LIMITS = {
|
|
|
6
6
|
modelIdleWarningMs: 120_000,
|
|
7
7
|
modelIdlePolicy: "enforce",
|
|
8
8
|
toolTimeoutMs: 600_000,
|
|
9
|
-
runTimeoutMs:
|
|
9
|
+
runTimeoutMs: DEFAULT_RUN_TIMEOUT_MS,
|
|
10
10
|
cancelGraceMs: 1_000,
|
|
11
11
|
enforcement: "enforce"
|
|
12
12
|
};
|
|
@@ -162,7 +162,10 @@ export class InvocationWatchdog {
|
|
|
162
162
|
toolChanged = this.#tools.delete(id);
|
|
163
163
|
this.#finishSubjectActivities("tool", id);
|
|
164
164
|
}
|
|
165
|
-
|
|
165
|
+
// 非阻塞问题不授予等待豁免;原模型/工具仍按真实进度计时。
|
|
166
|
+
if (event.type === "interaction.requested" &&
|
|
167
|
+
event.payload.delivery !== "async" &&
|
|
168
|
+
typeof event.payload.interactionId === "string") {
|
|
166
169
|
this.#interaction(event.payload.interactionId, true);
|
|
167
170
|
}
|
|
168
171
|
if (event.type === "interaction.resolved" && typeof event.payload.interactionId === "string") {
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-executor-core",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": "./dist/index.js",
|
|
7
7
|
"dependencies": {
|
|
8
|
-
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.
|
|
9
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
8
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.9",
|
|
9
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.9"
|
|
10
10
|
},
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
12
|
"files": [
|
package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/async-question-reply.d.ts
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type AsyncQuestionReplySnapshot, type CanonicalEvent, type HostFrame, type InvokeEnvironment, type InvokeInput } from "@mininglamp-oss/octo-runtime-protocol";
|
|
2
|
+
import { type KernelClient } from "./types.js";
|
|
3
|
+
export type AsyncQuestionReplyResult = {
|
|
4
|
+
route: "steer";
|
|
5
|
+
acceptance: "provider_accepted";
|
|
6
|
+
} | {
|
|
7
|
+
route: "new_run";
|
|
8
|
+
input: InvokeInput;
|
|
9
|
+
events: AsyncGenerator<CanonicalEvent>;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* 宿主持有的一份旁路问题控制者,不拥有 Kernel 或数据库。
|
|
13
|
+
* 活动时 steer,确认正常完成后复用 invoke;宿主须串行管理同会话、
|
|
14
|
+
* 保存提交状态并消费新 Run 尾流。新流返回不代表 Provider 接纳。
|
|
15
|
+
*/
|
|
16
|
+
export declare class AsyncQuestionReply {
|
|
17
|
+
#private;
|
|
18
|
+
readonly client: KernelClient;
|
|
19
|
+
readonly continuation: () => InvokeInput;
|
|
20
|
+
readonly environment?: InvokeEnvironment | undefined;
|
|
21
|
+
constructor(client: KernelClient, snapshot: AsyncQuestionReplySnapshot, continuation: () => InvokeInput, environment?: InvokeEnvironment | undefined);
|
|
22
|
+
/** 独立 JSON 副本供宿主保存;恢复 submitting/unknown 不会再次投递。 */
|
|
23
|
+
snapshot(): AsyncQuestionReplySnapshot;
|
|
24
|
+
/** 只接受原源流事实;消息 final 或查不到 Run 不能证明正常完成。 */
|
|
25
|
+
observe(frame: HostFrame): void;
|
|
26
|
+
/** 关闭旁路,不中断模型;原活动交互同步关闭,未知响应不重试。 */
|
|
27
|
+
cancel(): Promise<void>;
|
|
28
|
+
/** 整批一次。steer 等待 Provider ACK;new_run 必须消费返回流,沿原 invoke 管理执行。 */
|
|
29
|
+
respond(value: unknown): Promise<AsyncQuestionReplyResult>;
|
|
30
|
+
}
|
package/node_modules/@mininglamp-oss/octo-runtime-executor-kernel/dist/async-question-reply.js
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { randomUUID } from "node:crypto";
|
|
2
|
+
import { assertCanonicalEvent, assertHostFrame, assertHostFrameIdentity, assertHostRunReceipt, assertInvokeInput, assertJsonValue, assertQuestionRequest, assertQuestionResponse, questionAnswerText } from "@mininglamp-oss/octo-runtime-protocol";
|
|
3
|
+
import { KernelError } from "./types.js";
|
|
4
|
+
/**
|
|
5
|
+
* 宿主持有的一份旁路问题控制者,不拥有 Kernel 或数据库。
|
|
6
|
+
* 活动时 steer,确认正常完成后复用 invoke;宿主须串行管理同会话、
|
|
7
|
+
* 保存提交状态并消费新 Run 尾流。新流返回不代表 Provider 接纳。
|
|
8
|
+
*/
|
|
9
|
+
export class AsyncQuestionReply {
|
|
10
|
+
client;
|
|
11
|
+
continuation;
|
|
12
|
+
environment;
|
|
13
|
+
#snapshot;
|
|
14
|
+
constructor(client, snapshot, continuation, environment) {
|
|
15
|
+
this.client = client;
|
|
16
|
+
this.continuation = continuation;
|
|
17
|
+
this.environment = environment;
|
|
18
|
+
assertJsonValue(snapshot);
|
|
19
|
+
if (snapshot.schema !== "octo.async-question-reply/v1" ||
|
|
20
|
+
!["pending", "submitting", "answered", "cancelled", "invalidated", "unknown"].includes(snapshot.phase) ||
|
|
21
|
+
typeof snapshot.completed !== "boolean" ||
|
|
22
|
+
snapshot.ref.protocol_mode !== "canonical" ||
|
|
23
|
+
snapshot.ref.protocol !== "codex.app-server" ||
|
|
24
|
+
snapshot.question.delivery !== "async" ||
|
|
25
|
+
snapshot.question.kind !== "question" ||
|
|
26
|
+
snapshot.question.executionInstanceId !== snapshot.ref.invocation_id ||
|
|
27
|
+
!snapshot.providerSession.sessionId ||
|
|
28
|
+
snapshot.providerSession.resumable === false)
|
|
29
|
+
throw new KernelError("INVALID_ASYNC_QUESTION_SNAPSHOT");
|
|
30
|
+
const { kernel_instance_id, ...receipt } = snapshot.ref;
|
|
31
|
+
if (!kernel_instance_id)
|
|
32
|
+
throw new KernelError("INVALID_ASYNC_QUESTION_SNAPSHOT");
|
|
33
|
+
assertHostRunReceipt(receipt);
|
|
34
|
+
assertCanonicalEvent({
|
|
35
|
+
protocolVersion: 2,
|
|
36
|
+
type: "interaction.requested",
|
|
37
|
+
payload: snapshot.question
|
|
38
|
+
});
|
|
39
|
+
assertQuestionRequest(snapshot.question.request);
|
|
40
|
+
this.#snapshot = structuredClone(snapshot);
|
|
41
|
+
}
|
|
42
|
+
/** 独立 JSON 副本供宿主保存;恢复 submitting/unknown 不会再次投递。 */
|
|
43
|
+
snapshot() {
|
|
44
|
+
return structuredClone(this.#snapshot);
|
|
45
|
+
}
|
|
46
|
+
/** 只接受原源流事实;消息 final 或查不到 Run 不能证明正常完成。 */
|
|
47
|
+
observe(frame) {
|
|
48
|
+
assertHostFrame(frame);
|
|
49
|
+
const { kernel_instance_id: _instance, ...receipt } = this.#snapshot.ref;
|
|
50
|
+
void _instance;
|
|
51
|
+
assertHostFrameIdentity(frame, receipt);
|
|
52
|
+
if (frame.kind === "control" && frame.control.type === "state") {
|
|
53
|
+
if (frame.control.state === "completed")
|
|
54
|
+
this.#snapshot.completed = true;
|
|
55
|
+
else if (["failed", "cancelled", "lost"].includes(frame.control.state))
|
|
56
|
+
this.#snapshot.phase = "invalidated";
|
|
57
|
+
}
|
|
58
|
+
if (frame.kind === "canonical" &&
|
|
59
|
+
frame.event.type === "interaction.resolved" &&
|
|
60
|
+
frame.event.payload.interactionId === this.#snapshot.question.interactionId) {
|
|
61
|
+
const payload = frame.event.payload;
|
|
62
|
+
this.#snapshot.phase =
|
|
63
|
+
payload.reasonCode === "provider_accepted"
|
|
64
|
+
? "answered"
|
|
65
|
+
: payload.reasonCode === "submission_outcome_unknown"
|
|
66
|
+
? "unknown"
|
|
67
|
+
: "invalidated";
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/** 关闭旁路,不中断模型;原活动交互同步关闭,未知响应不重试。 */
|
|
71
|
+
async cancel() {
|
|
72
|
+
this.#assertPending();
|
|
73
|
+
this.#snapshot.phase = "cancelled";
|
|
74
|
+
if (!this.#snapshot.completed) {
|
|
75
|
+
try {
|
|
76
|
+
await this.client.respond(this.#snapshot.ref, {
|
|
77
|
+
interactionId: this.#snapshot.question.interactionId,
|
|
78
|
+
outcome: "cancelled"
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
catch (error) {
|
|
82
|
+
if (!(error instanceof KernelError) || error.code !== "INTERACTION_NOT_ACTIVE")
|
|
83
|
+
throw error;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/** 整批一次。steer 等待 Provider ACK;new_run 必须消费返回流,沿原 invoke 管理执行。 */
|
|
88
|
+
async respond(value) {
|
|
89
|
+
this.#assertPending();
|
|
90
|
+
const original = this.#snapshot;
|
|
91
|
+
assertQuestionRequest(original.question.request);
|
|
92
|
+
const answer = structuredClone(value);
|
|
93
|
+
assertQuestionResponse(answer);
|
|
94
|
+
const text = questionAnswerText(original.question.request, answer);
|
|
95
|
+
const next = structuredClone(this.continuation());
|
|
96
|
+
assertInvokeInput(next);
|
|
97
|
+
// 现有会话由宿主显式提供,旧题不能跨 reset 或 Provider binding 改投。
|
|
98
|
+
if (next.sessionId !== original.ref.agent_session_id ||
|
|
99
|
+
(next.sessionGeneration ?? 0) !== original.ref.session_generation ||
|
|
100
|
+
next.providerSession?.sessionId !== original.providerSession.sessionId ||
|
|
101
|
+
next.providerSession?.resumable === false ||
|
|
102
|
+
next.providerEpoch !== original.providerEpoch)
|
|
103
|
+
throw new KernelError("ASYNC_QUESTION_SESSION_STALE");
|
|
104
|
+
original.phase = "submitting";
|
|
105
|
+
let attempted = false;
|
|
106
|
+
try {
|
|
107
|
+
if (!original.completed) {
|
|
108
|
+
const current = await this.client.get(original.ref, original.ref.kernel_instance_id);
|
|
109
|
+
if (current.terminal)
|
|
110
|
+
this.observe(current.terminal);
|
|
111
|
+
if (this.snapshot().phase === "invalidated")
|
|
112
|
+
throw new KernelError("INTERACTION_NOT_ACTIVE");
|
|
113
|
+
}
|
|
114
|
+
if (!original.completed) {
|
|
115
|
+
attempted = true;
|
|
116
|
+
try {
|
|
117
|
+
this.#assertNotExpired();
|
|
118
|
+
await this.client.respond(original.ref, {
|
|
119
|
+
interactionId: original.question.interactionId,
|
|
120
|
+
outcome: "answered",
|
|
121
|
+
value: answer
|
|
122
|
+
});
|
|
123
|
+
original.phase = "answered";
|
|
124
|
+
return { route: "steer", acceptance: "provider_accepted" };
|
|
125
|
+
}
|
|
126
|
+
catch (error) {
|
|
127
|
+
if (!(error instanceof KernelError) ||
|
|
128
|
+
!["INTERACTION_NOT_ACTIVE", "ASYNC_ANSWER_REJECTED"].includes(error.code))
|
|
129
|
+
throw error;
|
|
130
|
+
// 仅明确未接纳才可在正常终态之后续跑;ACK 丢失和写后失联绝不进入此分支。
|
|
131
|
+
attempted = false;
|
|
132
|
+
const current = await this.client.get(original.ref, original.ref.kernel_instance_id);
|
|
133
|
+
if (current.terminal)
|
|
134
|
+
this.observe(current.terminal);
|
|
135
|
+
if (!original.completed) {
|
|
136
|
+
original.phase = "invalidated";
|
|
137
|
+
throw error;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const input = {
|
|
142
|
+
...next,
|
|
143
|
+
runId: randomUUID(),
|
|
144
|
+
invocationId: randomUUID(),
|
|
145
|
+
protocol_mode: "canonical",
|
|
146
|
+
continuityMode: "continue",
|
|
147
|
+
inputs: [{ type: "text", text }],
|
|
148
|
+
prompt: text,
|
|
149
|
+
modelInput: text,
|
|
150
|
+
providerSession: { ...original.providerSession, requireResume: true },
|
|
151
|
+
freshFallbackModelInput: text,
|
|
152
|
+
freshFallbackModelInputParts: [{ type: "text", text }]
|
|
153
|
+
};
|
|
154
|
+
const client = this.client, environment = this.environment;
|
|
155
|
+
const beforeInvoke = () => {
|
|
156
|
+
this.#assertNotExpired();
|
|
157
|
+
const currentInput = this.continuation();
|
|
158
|
+
if (currentInput.sessionId !== input.sessionId ||
|
|
159
|
+
(currentInput.sessionGeneration ?? 0) !== original.ref.session_generation ||
|
|
160
|
+
currentInput.providerSession?.sessionId !== original.providerSession.sessionId ||
|
|
161
|
+
currentInput.providerEpoch !== original.providerEpoch)
|
|
162
|
+
throw new KernelError("ASYNC_QUESTION_SESSION_STALE");
|
|
163
|
+
};
|
|
164
|
+
const events = (async function* () {
|
|
165
|
+
try {
|
|
166
|
+
beforeInvoke();
|
|
167
|
+
for await (const event of client.invoke(input, environment)) {
|
|
168
|
+
if (event.type === "session.update" &&
|
|
169
|
+
event.payload.providerSession?.sessionId === original.providerSession.sessionId &&
|
|
170
|
+
event.payload.providerSession.resumeOutcome === "resumed")
|
|
171
|
+
original.phase = "answered";
|
|
172
|
+
yield event;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
finally {
|
|
176
|
+
if (original.phase === "submitting")
|
|
177
|
+
original.phase = "unknown";
|
|
178
|
+
}
|
|
179
|
+
})();
|
|
180
|
+
return { route: "new_run", input: structuredClone(input), events };
|
|
181
|
+
}
|
|
182
|
+
catch (error) {
|
|
183
|
+
if (original.phase === "submitting")
|
|
184
|
+
original.phase = attempted ? "unknown" : "pending";
|
|
185
|
+
throw error;
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
#assertPending() {
|
|
189
|
+
const snapshot = this.#snapshot;
|
|
190
|
+
if (snapshot.phase !== "pending")
|
|
191
|
+
throw new KernelError("INTERACTION_NOT_ACTIVE");
|
|
192
|
+
this.#assertNotExpired();
|
|
193
|
+
}
|
|
194
|
+
#assertNotExpired() {
|
|
195
|
+
const expiresAt = this.#snapshot.question.expiresAt;
|
|
196
|
+
if (expiresAt !== undefined && Date.parse(expiresAt) <= Date.now())
|
|
197
|
+
throw new KernelError("INTERACTION_NOT_ACTIVE");
|
|
198
|
+
}
|
|
199
|
+
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createInputInvoke, assertInvokeRequestSize, identifyInvokeInput, assertHostFrameIdentity, isHostTerminal, isStreamCapacityReason, resolveStreamLimitPolicy, streamCapacityError } from "@mininglamp-oss/octo-runtime-protocol";
|
|
1
|
+
import { createInputInvoke, assertInvokeRequestSize, identifyInvokeInput, assertHostFrameIdentity, isHostTerminal, isStreamCapacityReason, resolveStreamLimitPolicy, streamCapacityError, protocolError } from "@mininglamp-oss/octo-runtime-protocol";
|
|
2
2
|
const TTL = 120_000;
|
|
3
3
|
/**
|
|
4
4
|
* Kernel 内唯一的 Run 事件源:从 worker 消费一次,按原 stream/seq 有界缓存供多个订阅观察。
|
|
@@ -261,7 +261,7 @@ export class HostRunService {
|
|
|
261
261
|
respond(runId, response) {
|
|
262
262
|
const run = this.#get(runId);
|
|
263
263
|
if (run.terminal)
|
|
264
|
-
throw
|
|
264
|
+
throw protocolError("INTERACTION_NOT_ACTIVE", "INTERACTION_EXPIRED");
|
|
265
265
|
return this.respondInteraction(run.invocationId, response);
|
|
266
266
|
}
|
|
267
267
|
respondNativeRun(runId, response) {
|
|
@@ -3,6 +3,7 @@ export { HostRunService } from "./host-run-service.js";
|
|
|
3
3
|
export { createKernelService, type KernelService, type KernelServiceOptions, type KernelServiceStatus } from "./service.js";
|
|
4
4
|
export * from "./lifecycle.js";
|
|
5
5
|
export { attachKernel } from "./client.js";
|
|
6
|
+
export { AsyncQuestionReply, type AsyncQuestionReplyResult } from "./async-question-reply.js";
|
|
6
7
|
export { isInvocationNotSubmitted } from "./submission-error.js";
|
|
7
8
|
export * from "./types.js";
|
|
8
9
|
export { InvocationManifest, acknowledgeOrphanCleanup, inspectOrphanCleanup, processStartIdentity, reapOrphanedInvocationManifest } from "./invocation-manifest.js";
|
|
@@ -4,6 +4,7 @@ export { HostRunService } from "./host-run-service.js";
|
|
|
4
4
|
export { createKernelService } from "./service.js";
|
|
5
5
|
export * from "./lifecycle.js";
|
|
6
6
|
export { attachKernel } from "./client.js";
|
|
7
|
+
export { AsyncQuestionReply } from "./async-question-reply.js";
|
|
7
8
|
export { isInvocationNotSubmitted } from "./submission-error.js";
|
|
8
9
|
export * from "./types.js";
|
|
9
10
|
export { InvocationManifest, acknowledgeOrphanCleanup, inspectOrphanCleanup, processStartIdentity, reapOrphanedInvocationManifest } from "./invocation-manifest.js";
|
|
@@ -59,4 +59,6 @@ export declare class WorkerRpcClient implements WorkerRpc {
|
|
|
59
59
|
/** Await the invoke ACK first, then keep yielding this invocation's event notifications until done. */
|
|
60
60
|
invokeFrames(input: InvokeInput, environment?: InvokeEnvironment): AsyncGenerator<HostFrame>;
|
|
61
61
|
}
|
|
62
|
+
/** Kernel 配置与 worker 探测共用的配置形态校验;不修改调用方对象。 */
|
|
63
|
+
export declare function probeOptions(value: unknown): AdapterProbeOptions | undefined;
|
|
62
64
|
export {};
|
|
@@ -272,7 +272,15 @@ export class WorkerRpcServer {
|
|
|
272
272
|
code: errorCode(error),
|
|
273
273
|
message: errorMessage(error),
|
|
274
274
|
...(isRecord(error) && typeof error.code === "string"
|
|
275
|
-
? {
|
|
275
|
+
? {
|
|
276
|
+
data: {
|
|
277
|
+
code: error.code,
|
|
278
|
+
...(error.code === "ASYNC_ANSWER_REJECTED" &&
|
|
279
|
+
Number.isSafeInteger(error.providerRpcCode)
|
|
280
|
+
? { providerRpcCode: error.providerRpcCode }
|
|
281
|
+
: {})
|
|
282
|
+
}
|
|
283
|
+
}
|
|
276
284
|
: {})
|
|
277
285
|
}
|
|
278
286
|
});
|
|
@@ -433,7 +441,11 @@ export class WorkerRpcClient {
|
|
|
433
441
|
this.#pending.delete(message.id);
|
|
434
442
|
if (message.error)
|
|
435
443
|
pending.reject(Object.assign(new Error(message.error.message), {
|
|
436
|
-
code: message.error.data?.code ?? message.error.code
|
|
444
|
+
code: message.error.data?.code ?? message.error.code,
|
|
445
|
+
...(message.error.data?.code === "ASYNC_ANSWER_REJECTED" &&
|
|
446
|
+
Number.isSafeInteger(message.error.data.providerRpcCode)
|
|
447
|
+
? { providerRpcCode: message.error.data.providerRpcCode }
|
|
448
|
+
: {})
|
|
437
449
|
}));
|
|
438
450
|
else
|
|
439
451
|
pending.resolve(message.result);
|
|
@@ -633,7 +645,8 @@ function traceFrame(message, raw) {
|
|
|
633
645
|
bytes: Buffer.byteLength(raw)
|
|
634
646
|
});
|
|
635
647
|
}
|
|
636
|
-
|
|
648
|
+
/** Kernel 配置与 worker 探测共用的配置形态校验;不修改调用方对象。 */
|
|
649
|
+
export function probeOptions(value) {
|
|
637
650
|
if (value === undefined)
|
|
638
651
|
return undefined;
|
|
639
652
|
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
@@ -3,9 +3,10 @@ import { randomUUID } from "node:crypto";
|
|
|
3
3
|
import { chmod, mkdir, rm } from "node:fs/promises";
|
|
4
4
|
import { dirname, join } from "node:path";
|
|
5
5
|
import { readBoundedLines, RuntimeLogging, assertRuntimeLogging } from "@mininglamp-oss/octo-runtime-adapter-sdk";
|
|
6
|
-
import { assertHostRunReceipt, createInputInvoke, contextItem, INVOKE_REQUEST_MAX_BYTES, HOST_RPC_MAX_LINE_BYTES } from "@mininglamp-oss/octo-runtime-protocol";
|
|
6
|
+
import { assertHostRunReceipt, createInputInvoke, contextItem, INVOKE_REQUEST_MAX_BYTES, HOST_RPC_MAX_LINE_BYTES, resolveStreamLimitPolicy } from "@mininglamp-oss/octo-runtime-protocol";
|
|
7
7
|
import { HostRunService } from "./host-run-service.js";
|
|
8
8
|
import { WorkerSupervisor } from "./supervisor.js";
|
|
9
|
+
import { probeOptions } from "./rpc.js";
|
|
9
10
|
import { acquireEndpoint } from "./endpoint.js";
|
|
10
11
|
import { InvocationManifest } from "./invocation-manifest.js";
|
|
11
12
|
import { readModuleManifest, resolveAdapterModules } from "@mininglamp-oss/octo-runtime-adapter-sdk/module-manifest";
|
|
@@ -83,9 +84,15 @@ export async function startKernelServer(options, signal) {
|
|
|
83
84
|
const logging = new RuntimeLogging(options.logging);
|
|
84
85
|
let manifest;
|
|
85
86
|
const worker = new WorkerSupervisor({ entrypoint: options.workerEntrypoint, adapterModules, env: options.env }, (pid) => manifest?.setWorker(pid, options.workerEntrypoint) ?? Promise.resolve(), logging.kernel);
|
|
87
|
+
// 每轮只读取一次宿主配置;复制后冻结自有快照,不冻结宿主持有的原对象。
|
|
86
88
|
const configure = (input) => {
|
|
87
89
|
const type = contextItem(input.contexts, "octo.execution", "adapter")?.payload.type;
|
|
88
|
-
|
|
90
|
+
const config = probeOptions((options.configurations?.(typeof input.runMetadata?.runtimeId === "string" ? input.runMetadata.runtimeId : undefined) ?? options.adapterConfigurations)?.[typeof type === "string" ? type : "codex"]);
|
|
91
|
+
return (config &&
|
|
92
|
+
Object.freeze({
|
|
93
|
+
providerOptions: config.providerOptions && Object.freeze({ ...config.providerOptions }),
|
|
94
|
+
streamLimits: resolveStreamLimitPolicy(config.streamLimits)
|
|
95
|
+
}));
|
|
89
96
|
};
|
|
90
97
|
const transport = {
|
|
91
98
|
list: (configs) => worker.client.list(configs ?? options.configurations?.() ?? options.adapterConfigurations),
|
|
@@ -94,23 +101,9 @@ export async function startKernelServer(options, signal) {
|
|
|
94
101
|
respondInteraction: (id, response) => worker.client.respondInteraction(id, response),
|
|
95
102
|
respondNative: (id, response) => worker.client.respondNative(id, response),
|
|
96
103
|
invoke: createInputInvoke((input, environment) => transport.invokeFrames(input, environment)),
|
|
97
|
-
|
|
98
|
-
const config = configure(input);
|
|
99
|
-
yield* worker.client.invokeFrames(config
|
|
100
|
-
? {
|
|
101
|
-
...input,
|
|
102
|
-
agentConfig: {
|
|
103
|
-
...input.agentConfig,
|
|
104
|
-
providerOptions: {
|
|
105
|
-
...input.agentConfig?.providerOptions,
|
|
106
|
-
...config.providerOptions
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
: input, environment);
|
|
111
|
-
}
|
|
104
|
+
invokeFrames: (input, environment) => worker.client.invokeFrames(input, environment)
|
|
112
105
|
};
|
|
113
|
-
const runs = new HostRunService(transport
|
|
106
|
+
const runs = new HostRunService(transport);
|
|
114
107
|
const sockets = new Set();
|
|
115
108
|
let closing;
|
|
116
109
|
let listening = false;
|
|
@@ -194,7 +187,23 @@ export async function startKernelServer(options, signal) {
|
|
|
194
187
|
throw new KernelError(worker.status.state === "exhausted"
|
|
195
188
|
? "WORKER_RESTART_EXHAUSTED"
|
|
196
189
|
: "KERNEL_UNAVAILABLE", { invocation_not_submitted: true });
|
|
197
|
-
const
|
|
190
|
+
const input = params.input;
|
|
191
|
+
const config = configure(input);
|
|
192
|
+
// 选项先合并再进入 HostRunService 的整请求预算检查;策略沿同一调用传给 worker 和重放窗口。
|
|
193
|
+
const configuredInput = config
|
|
194
|
+
? {
|
|
195
|
+
...input,
|
|
196
|
+
agentConfig: {
|
|
197
|
+
...input.agentConfig,
|
|
198
|
+
providerOptions: {
|
|
199
|
+
...input.agentConfig?.providerOptions,
|
|
200
|
+
...config.providerOptions
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
: input;
|
|
205
|
+
const receipt = await runs.submit(configuredInput, {
|
|
206
|
+
streamLimits: config?.streamLimits,
|
|
198
207
|
executionEnvOverrides: params.executionEnvOverrides
|
|
199
208
|
});
|
|
200
209
|
result = { kernel_instance_id: instance, receipt };
|
|
@@ -300,6 +309,12 @@ export async function startKernelServer(options, signal) {
|
|
|
300
309
|
message: "Kernel request failed",
|
|
301
310
|
data: {
|
|
302
311
|
code,
|
|
312
|
+
// worker RPC 已还原 camelCase 属性;此处转换为公开 socket 协议字段,client 保留整个 data。
|
|
313
|
+
...(code === "ASYNC_ANSWER_REJECTED" &&
|
|
314
|
+
record(error) &&
|
|
315
|
+
Number.isSafeInteger(error.providerRpcCode)
|
|
316
|
+
? { provider_rpc_code: error.providerRpcCode }
|
|
317
|
+
: {}),
|
|
303
318
|
...(error instanceof KernelError &&
|
|
304
319
|
error.data?.invocation_not_submitted === true
|
|
305
320
|
? { invocation_not_submitted: true, kernel_instance_id: instance }
|
|
@@ -418,6 +433,8 @@ function record(value) {
|
|
|
418
433
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
419
434
|
}
|
|
420
435
|
function safeCode(error) {
|
|
436
|
+
if (record(error) && typeof error.code === "string" && /^[A-Z][A-Z0-9_]{1,80}$/.test(error.code))
|
|
437
|
+
return error.code;
|
|
421
438
|
return error instanceof Error && /^[A-Z][A-Z0-9_]{1,80}$/.test(error.message)
|
|
422
439
|
? error.message
|
|
423
440
|
: "KERNEL_REQUEST_FAILED";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mininglamp-oss/octo-runtime-executor-kernel",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.9",
|
|
4
4
|
"private": true,
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -18,9 +18,9 @@
|
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
"dependencies": {
|
|
21
|
-
"@mininglamp-oss/octo-runtime-executor-core": "1.1.
|
|
22
|
-
"@mininglamp-oss/octo-runtime-protocol": "1.1.
|
|
23
|
-
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.
|
|
21
|
+
"@mininglamp-oss/octo-runtime-executor-core": "1.1.9",
|
|
22
|
+
"@mininglamp-oss/octo-runtime-protocol": "1.1.9",
|
|
23
|
+
"@mininglamp-oss/octo-runtime-adapter-sdk": "1.1.9"
|
|
24
24
|
},
|
|
25
25
|
"types": "./dist/index.d.ts",
|
|
26
26
|
"files": [
|
|
@@ -491,6 +491,8 @@ export class ImRuntime {
|
|
|
491
491
|
}
|
|
492
492
|
this.#seen.set(dedupe, now + 120_000);
|
|
493
493
|
const command = message.text.trim();
|
|
494
|
+
// null 表示 Gateway 已拒绝控制授权;不能用 ?? 回退原文,避免广播裸命令绕过。
|
|
495
|
+
const sessionControl = message.sessionControl === undefined ? command : message.sessionControl;
|
|
494
496
|
if (/^\/(approve|decline|respond)\s/.test(command)) {
|
|
495
497
|
void this.#respond(message, key).catch(() => this.#diagnostic("IM_INTERACTION_RESPONSE_FAILED"));
|
|
496
498
|
return;
|
|
@@ -509,7 +511,7 @@ export class ImRuntime {
|
|
|
509
511
|
return;
|
|
510
512
|
}
|
|
511
513
|
try {
|
|
512
|
-
if (
|
|
514
|
+
if (sessionControl === "/reset" || sessionControl === "/new") {
|
|
513
515
|
try {
|
|
514
516
|
const binding = this.#sessionStore.reset(key, message.messageId);
|
|
515
517
|
this.#finalDeliveries.get(key)?.abort();
|
|
@@ -532,7 +534,7 @@ export class ImRuntime {
|
|
|
532
534
|
}
|
|
533
535
|
return;
|
|
534
536
|
}
|
|
535
|
-
if (
|
|
537
|
+
if (sessionControl === "/stop" || command === "/cancel") {
|
|
536
538
|
// 控制命令绕过普通消息队列,否则 stop 会排在待取消的长任务之后。
|
|
537
539
|
const preparation = this.#preparing.get(key);
|
|
538
540
|
preparation?.abort();
|
|
@@ -822,6 +824,7 @@ export class ImRuntime {
|
|
|
822
824
|
if (!entry ||
|
|
823
825
|
entry.key !== key ||
|
|
824
826
|
entry.senderId !== message.senderId ||
|
|
827
|
+
entry.request.expiresAt === undefined ||
|
|
825
828
|
!Number.isFinite(Date.parse(entry.request.expiresAt)) ||
|
|
826
829
|
Date.parse(entry.request.expiresAt) <= Date.now()) {
|
|
827
830
|
await this.#reply(message, "该交互已失效或不属于当前会话。", `interaction:${message.messageId}`);
|
|
@@ -856,6 +859,7 @@ export class ImRuntime {
|
|
|
856
859
|
entry.key !== key ||
|
|
857
860
|
entry.senderId !== senderId ||
|
|
858
861
|
this.#sessionStore.read(key)?.id !== entry.sessionId ||
|
|
862
|
+
entry.request.expiresAt === undefined ||
|
|
859
863
|
!Number.isFinite(Date.parse(entry.request.expiresAt)) ||
|
|
860
864
|
Date.parse(entry.request.expiresAt) <= Date.now())
|
|
861
865
|
throw Error("IM_INTERACTION_STALE");
|
|
@@ -91,6 +91,8 @@ 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>;
|
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 = {
|
package/node_modules/@mininglamp-oss/octo-runtime-extra-channel-gateway/dist/transport/channel.js
CHANGED
|
@@ -8,6 +8,7 @@ import { imBotIdentity } from "../lifecycle/configuration.js";
|
|
|
8
8
|
import { verifyBotIdentity } from "./auth.js";
|
|
9
9
|
import { registerBot, WukongConnection } from "./wukong.js";
|
|
10
10
|
import { acceptsImMessage, groupScope, isRulesNotification, rulesChange } from "./normalize.js";
|
|
11
|
+
import { sessionCommand } from "./session-command.js";
|
|
11
12
|
import { build_im_contexts } from "./contexts.js";
|
|
12
13
|
import { OctoConnector, stableEffectKey } from "./connector.js";
|
|
13
14
|
import { CardSession } from "./card-session.js";
|
|
@@ -186,6 +187,9 @@ export class GatewayTransport {
|
|
|
186
187
|
};
|
|
187
188
|
this.callbacks.onMessage({
|
|
188
189
|
messageId: message.messageId,
|
|
190
|
+
...(message.channelType === 2 || message.channelType === 5
|
|
191
|
+
? { sessionControl: sessionCommand(message, this.botId) }
|
|
192
|
+
: {}),
|
|
189
193
|
...(message.channelType === 2 || message.channelType === 5
|
|
190
194
|
? {
|
|
191
195
|
position: { messageSeq: message.messageSeq },
|
|
@@ -76,7 +76,8 @@ export function interactionCard(request, settled) {
|
|
|
76
76
|
};
|
|
77
77
|
}
|
|
78
78
|
export function interactionAnswer(request, action) {
|
|
79
|
-
if (
|
|
79
|
+
if (request.expiresAt === undefined ||
|
|
80
|
+
!Number.isFinite(Date.parse(request.expiresAt)) ||
|
|
80
81
|
Date.parse(request.expiresAt) <= Date.now())
|
|
81
82
|
throw Error("IM_INTERACTION_EXPIRED");
|
|
82
83
|
const outcome = action.actionId.slice("interaction_".length);
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { ImInboundMessage } from "../contracts.js";
|
|
2
|
+
import type { ImMessage } from "./wukong.js";
|
|
3
|
+
type SessionCommand = NonNullable<ImInboundMessage["sessionControl"]>;
|
|
4
|
+
/**
|
|
5
|
+
* 在 Gateway 已完成消息准入后解析当前纯文本;不改变原文,不从名称补造授权。
|
|
6
|
+
* 只有剥离原生提及前缀后的完整输入才是控制命令,含 /stop 的语义文本仍交给 AgentRun。
|
|
7
|
+
*/
|
|
8
|
+
export declare function sessionCommand(message: ImMessage, botId: string): SessionCommand | null;
|
|
9
|
+
export {};
|