@ai-workbench/remote-agent 0.9.0-toolbridge.35 → 0.9.0-toolbridge.37-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -7
- package/dist/acp.d.ts +4 -3
- package/dist/acp.js +6 -8
- package/dist/claude-local.d.ts +0 -3
- package/dist/claude-local.js +5 -56
- package/dist/cold-protocol.d.ts +1 -0
- package/dist/cold-protocol.js +14 -7
- package/dist/cold-recovery.d.ts +1 -0
- package/dist/cold-recovery.js +2 -2
- package/dist/cold-store.d.ts +0 -1
- package/dist/custom-instructions.d.ts +6 -0
- package/dist/custom-instructions.js +21 -0
- package/dist/employee-mcp.js +3 -5
- package/dist/employee-native.d.ts +2 -2
- package/dist/employee-native.js +1 -1
- package/dist/employee-provider.js +2 -2
- package/dist/employee-relay.js +1 -1
- package/dist/employee-tools.js +1 -1
- package/dist/index.d.ts +0 -2
- package/dist/index.js +34 -74
- package/dist/input.d.ts +2 -9
- package/dist/input.js +13 -62
- package/dist/native-content-transport.d.ts +42 -0
- package/dist/native-content-transport.js +83 -0
- package/dist/native-content.d.ts +67 -0
- package/dist/native-content.js +294 -0
- package/dist/preflight-payload.js +1 -1
- package/dist/presentation.js +0 -2
- package/dist/provider.d.ts +5 -7
- package/dist/provider.js +0 -3
- package/dist/toolbridge-loop.js +1 -1
- package/dist/toolbridge-table.d.ts +5 -3
- package/dist/toolbridge-table.js +6 -15
- package/dist/toolbridge.js +21 -32
- package/dist/workspace-source.d.ts +1 -1
- package/package.json +7 -5
- package/dist/local-user-turn.d.ts +0 -24
- package/dist/local-user-turn.js +0 -103
package/dist/toolbridge.js
CHANGED
|
@@ -4,7 +4,7 @@ import { mkdtemp, lstat, rm } from 'node:fs/promises';
|
|
|
4
4
|
import { Server } from '@modelcontextprotocol/sdk/server/index.js';
|
|
5
5
|
import { ListToolsRequestSchema, CallToolRequestSchema } from '@modelcontextprotocol/sdk/types.js';
|
|
6
6
|
import { EmployeeSocketTransport } from "./employee-mcp.js";
|
|
7
|
-
import { bridgeTable,
|
|
7
|
+
import { bridgeTable, essentialBridgeTool } from "./toolbridge-table.js";
|
|
8
8
|
import { NeedError } from "./remote.js";
|
|
9
9
|
export const TOOLBRIDGE_TIMEOUT_SECONDS = 1800;
|
|
10
10
|
export const TOOLBRIDGE_NOTICE = '含工具桥:本机文件夹的扩展工具(含DSH子代理、workflow和后台任务工具)由DSH执行并按当前权限审批;文件和命令保持原执行方式。工具表在新一轮主机连接时更新。';
|
|
@@ -19,22 +19,7 @@ export class ToolBridge {
|
|
|
19
19
|
get table() {
|
|
20
20
|
if (this.snapshot)
|
|
21
21
|
return this.snapshot;
|
|
22
|
-
|
|
23
|
-
// prepareInput只转发最后assistant之后的user内容;历史目录不能代替当前prompt。
|
|
24
|
-
// 正文不含目录全部名字时仍保留原schema快照,避免分支/切模型时丢发现入口。
|
|
25
|
-
const current = messages.slice(messages.findLastIndex(message => message.role === 'assistant') + 1);
|
|
26
|
-
const forwarded = catalog !== undefined && catalog.length > 0 && current.some(message => {
|
|
27
|
-
const names = dshSkillCatalog([message]);
|
|
28
|
-
if (names === undefined || JSON.stringify(names) !== JSON.stringify(catalog))
|
|
29
|
-
return false;
|
|
30
|
-
const text = message.content.filter(block => block.type === 'text').map(block => block.text).join('\n');
|
|
31
|
-
// 只认官方目录中明确声明的完整名字;子串命中不能证明office也已随office-xlsx送达。
|
|
32
|
-
// 未识别的格式继续携带原名字快照,不推测目录内容。
|
|
33
|
-
const declared = new Set([...text.matchAll(/<available_skills>([\s\S]*?)<\/available_skills>/g)]
|
|
34
|
-
.flatMap(section => [...section[1].matchAll(/^[ \t]*-[ \t]+`([^`\r\n]+)`[ \t]*:/gm)].map(item => item[1])));
|
|
35
|
-
return catalog.every(name => declared.has(name));
|
|
36
|
-
});
|
|
37
|
-
return this.snapshot = bridgeTable(this.options.tools, catalog, forwarded);
|
|
22
|
+
return this.snapshot = bridgeTable(this.options.tools);
|
|
38
23
|
}
|
|
39
24
|
calls = new Map();
|
|
40
25
|
enabled = false;
|
|
@@ -62,11 +47,12 @@ export class ToolBridge {
|
|
|
62
47
|
enable(record) { if (!this.table.size)
|
|
63
48
|
return; this.enabled = true; this.record = record; record({ kind: 'session', severity: 'info', code: 'TOOLBRIDGE_SELECTED', summary: TOOLBRIDGE_NOTICE, payload: { toolCount: this.table.size, toolTimeoutSec: TOOLBRIDGE_TIMEOUT_SECONDS, timeoutSource: 'owner-2026-10-26', snapshot: 'native-session-open', excluded: 'official-file-command-terminal-run_code' } }); }
|
|
64
49
|
get tools() { return [...this.table.values()].map(t => t.wire); }
|
|
65
|
-
isBridge(name) { return typeof name === 'string' && this.table.has(name.replace(/^
|
|
50
|
+
isBridge(name) { return typeof name === 'string' && this.table.has(name.replace(/^mcp__(?:employee|dsh)__/, '')); }
|
|
66
51
|
async call(alias, args, signal) {
|
|
52
|
+
alias = alias.replace(/^mcp__(?:employee|dsh)__/, '');
|
|
67
53
|
const tool = this.table.get(alias);
|
|
68
54
|
if (!this.enabled || this.ended || this.localTurnEnded || !this.active || this.active.aborted || !tool || signal.aborted)
|
|
69
|
-
return errorResult(
|
|
55
|
+
return errorResult(JSON.stringify({ code: -32603 }));
|
|
70
56
|
const id = ('awb-' + randomUUID());
|
|
71
57
|
const abort = () => this.abandon('MCP_REQUEST_CANCELLED');
|
|
72
58
|
const pending = { block: { type: 'tool-call', id, name: tool.schema.name, arguments: JSON.stringify(args) }, alias, reply: Promise.withResolvers(), exported: false, settled: false, off: () => signal.removeEventListener('abort', abort) };
|
|
@@ -101,7 +87,7 @@ export class ToolBridge {
|
|
|
101
87
|
if (this.localTurnEnded)
|
|
102
88
|
for (const p of this.calls.values())
|
|
103
89
|
if (!p.exported && !p.settled) {
|
|
104
|
-
batch.push({ pending: p, result: errorResult(
|
|
90
|
+
batch.push({ pending: p, result: errorResult(JSON.stringify({ code: -32603 })) });
|
|
105
91
|
this.record({ kind: 'tool', severity: 'info', code: 'TOOLBRIDGE_CONCLUDED_UNDISPATCHED', summary: 'DSH工具结束了本轮,尚未交给DSH的调用没有执行。', payload: { callId: p.block.id } });
|
|
106
92
|
}
|
|
107
93
|
const ready = batch.filter(row => !row.pending.settled);
|
|
@@ -122,7 +108,7 @@ export class ToolBridge {
|
|
|
122
108
|
}
|
|
123
109
|
if (block.type === 'image') {
|
|
124
110
|
if (block.offloaded)
|
|
125
|
-
return errorResult(
|
|
111
|
+
return errorResult(JSON.stringify({ code: -32603 }));
|
|
126
112
|
if (!this.readImage)
|
|
127
113
|
throw new NeedError('ATTACHMENT_REQUIRED', '我需要官方附件组件读取工具返回的图片。', 'attachments.readImage');
|
|
128
114
|
const image = await this.readImage(block.attachment, signal);
|
|
@@ -132,7 +118,7 @@ export class ToolBridge {
|
|
|
132
118
|
content.push({ type: 'image', mimeType: image.ref.mediaType, data: Buffer.from(image.data).toString('base64') });
|
|
133
119
|
continue;
|
|
134
120
|
}
|
|
135
|
-
return errorResult(
|
|
121
|
+
return errorResult(JSON.stringify({ code: -32603, data: { type: block.type } }));
|
|
136
122
|
}
|
|
137
123
|
return { content, isError: !!message.isError };
|
|
138
124
|
}
|
|
@@ -151,7 +137,7 @@ export class ToolBridge {
|
|
|
151
137
|
const u = update;
|
|
152
138
|
const raw = u.rawInput;
|
|
153
139
|
const name = u.name ?? u._meta?.claudeCode?.toolName;
|
|
154
|
-
if (this.isBridge(name) || raw?.server
|
|
140
|
+
if (this.isBridge(name) || ['employee', 'dsh'].includes(raw?.server) && this.isBridge(raw.tool) || this.isBridge(u.title))
|
|
155
141
|
this.nativeBridgeIds.add(u.toolCallId);
|
|
156
142
|
if ((u.status === 'completed' || u.status === 'failed') && this.nativeBridgeIds.has(u.toolCallId))
|
|
157
143
|
this.nativeTerminated.add(u.toolCallId);
|
|
@@ -184,7 +170,7 @@ export class ToolBridge {
|
|
|
184
170
|
if (!p.settled) {
|
|
185
171
|
p.settled = true;
|
|
186
172
|
p.off();
|
|
187
|
-
p.reply.resolve(errorResult(
|
|
173
|
+
p.reply.resolve(errorResult(JSON.stringify({ code: -32603 })));
|
|
188
174
|
}
|
|
189
175
|
this.changed();
|
|
190
176
|
}
|
|
@@ -194,28 +180,31 @@ export async function openToolBridgeMcp(bridge, maxBytes) {
|
|
|
194
180
|
const root = await mkdtemp('/private/tmp/aw-tb-'), socketPath = root + '/mcp';
|
|
195
181
|
const clients = new Set();
|
|
196
182
|
let closed = false;
|
|
197
|
-
const
|
|
183
|
+
const listeners = ['employee', 'dsh'].map(group => createServer(socket => {
|
|
198
184
|
if (closed) {
|
|
199
185
|
socket.destroy();
|
|
200
186
|
return;
|
|
201
187
|
}
|
|
202
188
|
const server = new Server({ name: 'ai-workbench-toolbridge', version: '0.9.0' }, { capabilities: { tools: {} } });
|
|
203
189
|
clients.add(server);
|
|
204
|
-
|
|
205
|
-
server.setRequestHandler(
|
|
190
|
+
const belongs = (name) => essentialBridgeTool(name) === (group === 'employee');
|
|
191
|
+
server.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: bridge.tools.filter(tool => belongs(tool.name)) }));
|
|
192
|
+
server.setRequestHandler(CallToolRequestSchema, (r, extra) => belongs(r.params.name) ? bridge.call(r.params.name, r.params.arguments ?? {}, extra.signal) : Promise.resolve(errorResult(JSON.stringify({ code: -32601 }))));
|
|
206
193
|
server.onclose = () => clients.delete(server);
|
|
207
194
|
server.onerror = () => bridge.abandon('MCP_TRANSPORT_FAILED');
|
|
208
195
|
void server.connect(new EmployeeSocketTransport(socket, maxBytes)).catch(() => { socket.destroy(); bridge.abandon('MCP_CONNECT_FAILED'); });
|
|
209
|
-
});
|
|
196
|
+
}));
|
|
210
197
|
const close = async () => { if (closed)
|
|
211
|
-
return; closed = true; bridge.close(); await Promise.allSettled([...clients].map(c => c.close()));
|
|
212
|
-
|
|
198
|
+
return; closed = true; bridge.close(); await Promise.allSettled([...clients].map(c => c.close())); for (const listener of listeners)
|
|
199
|
+
if (listener.listening)
|
|
200
|
+
await new Promise(r => listener.close(() => r())); await rm(root, { recursive: true }); };
|
|
213
201
|
try {
|
|
214
202
|
const stat = await lstat(root);
|
|
215
203
|
if (stat.uid !== process.getuid?.() || (stat.mode & 0o077) !== 0)
|
|
216
204
|
throw Error('TOOLBRIDGE_PRIVATE_DIRECTORY_REQUIRED');
|
|
217
|
-
|
|
218
|
-
|
|
205
|
+
for (const [index, listener] of listeners.entries())
|
|
206
|
+
await new Promise((yes, no) => { listener.once('error', no); listener.listen(socketPath + index, () => { listener.removeListener('error', no); yes(); }); });
|
|
207
|
+
return { mcpServers: ['employee', 'dsh'].map((name, index) => ({ name, command: '/usr/bin/nc', args: ['-U', socketPath + index], env: [] })), close };
|
|
219
208
|
}
|
|
220
209
|
catch (error) {
|
|
221
210
|
await close();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export type SourceAdmissionStage = 'source-context' | 'input-acceptance' | 'login-readiness' | '
|
|
1
|
+
export type SourceAdmissionStage = 'source-context' | 'input-acceptance' | 'login-readiness' | 'input-prepare' | 'model-catalog' | 'runtime-resolve';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ai-workbench/remote-agent",
|
|
3
|
-
"version": "0.9.0-toolbridge.
|
|
3
|
+
"version": "0.9.0-toolbridge.37-rc.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"test": "npm run build && node --test --test-concurrency=1 lib/test/*.test.js",
|
|
24
24
|
"typecheck": "node node_modules/typescript/bin/tsc --noEmit",
|
|
25
|
-
"build": "node node_modules/typescript/bin/tsc && node node_modules/typescript/bin/tsc -p tsconfig.build.json && node tools/build-client.mjs",
|
|
25
|
+
"build": "node tools/clean-build.mjs && node node_modules/typescript/bin/tsc && node node_modules/typescript/bin/tsc -p tsconfig.build.json && node tools/build-client.mjs",
|
|
26
26
|
"probe:host": "node tools/probe-host.ts",
|
|
27
27
|
"pack:artifact": "node tools/pack-artifact.mjs"
|
|
28
28
|
},
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"dependencies": {
|
|
34
34
|
"@agentclientprotocol/sdk": "2.0.0",
|
|
35
35
|
"@modelcontextprotocol/sdk": "1.32.1",
|
|
36
|
-
"@openai/codex": "0.
|
|
36
|
+
"@openai/codex": "0.162.0",
|
|
37
37
|
"zod": "4.6.7"
|
|
38
38
|
},
|
|
39
39
|
"devDependencies": {
|
|
@@ -71,7 +71,8 @@
|
|
|
71
71
|
"react": "18.3.1",
|
|
72
72
|
"react-dom": "18.3.1",
|
|
73
73
|
"typescript": "5.9.3",
|
|
74
|
-
"zustand": "4.4.7"
|
|
74
|
+
"zustand": "4.4.7",
|
|
75
|
+
"@deepseek-ai/dsh-scope": "0.2.0-rc.2"
|
|
75
76
|
},
|
|
76
77
|
"peerDependencies": {
|
|
77
78
|
"@ai-workbench/connect": "~0.7.37",
|
|
@@ -85,7 +86,8 @@
|
|
|
85
86
|
"@deepseek-ai/dsh-storage-domain": ">=0.2.0-rc.2 <0.3.0-0",
|
|
86
87
|
"@deepseek-ai/dsh-typert-protocol": ">=0.2.0-rc.2 <0.3.0-0",
|
|
87
88
|
"@deepseek-ai/dsh-user-approval": ">=0.2.0-rc.2 <0.3.0-0",
|
|
88
|
-
"@deepseek-ai/schemastery": "^3.18.4"
|
|
89
|
+
"@deepseek-ai/schemastery": "^3.18.4",
|
|
90
|
+
"@deepseek-ai/dsh-scope": ">=0.2.0-rc.2 <0.3.0-0"
|
|
89
91
|
},
|
|
90
92
|
"dsh": {
|
|
91
93
|
"bundle": {
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import type { RuntimeRequest } from './provider.ts';
|
|
2
|
-
import type { Context } from '@deepseek-ai/cordis';
|
|
3
|
-
export interface LocalTurnProof {
|
|
4
|
-
expectedUserTurn: {
|
|
5
|
-
turn: number;
|
|
6
|
-
userMessageId: string;
|
|
7
|
-
};
|
|
8
|
-
startSequence: number;
|
|
9
|
-
userMessageSequence: number;
|
|
10
|
-
assertCurrent(): void;
|
|
11
|
-
}
|
|
12
|
-
/** CAS expectation only. L independently establishes live human-turn/brand evidence. */
|
|
13
|
-
export declare function readLocalUserTurn(ctx: Context, request: {
|
|
14
|
-
sessionId: string;
|
|
15
|
-
route: string;
|
|
16
|
-
userMessageIds: readonly string[];
|
|
17
|
-
}): Promise<LocalTurnProof>;
|
|
18
|
-
/** Only metadata observed live since this plugin mounted; never seed or persisted tails. */
|
|
19
|
-
export declare function createLocalUserTurnObserver(ctx: Pick<Context, 'get' | 'on'>): {
|
|
20
|
-
current(request: Pick<RuntimeRequest, "sessionId" | "userInputIds">): {
|
|
21
|
-
turn: number;
|
|
22
|
-
userMessageId: string;
|
|
23
|
-
};
|
|
24
|
-
};
|
package/dist/local-user-turn.js
DELETED
|
@@ -1,103 +0,0 @@
|
|
|
1
|
-
import { SessionId } from '@deepseek-ai/dsh-session';
|
|
2
|
-
import { sameStoredSessionHeader } from "./session-header.js";
|
|
3
|
-
import { isDeepStrictEqual } from 'node:util';
|
|
4
|
-
import { NeedError } from "./remote.js";
|
|
5
|
-
const failure = (code = 'REMOTE_DETAIL_SCOPE_INVALID') => new NeedError(code, '本轮输入无法核对,已停止本次处理。', '官方当前员工输入与所选远程品牌');
|
|
6
|
-
/** CAS expectation only. L independently establishes live human-turn/brand evidence. */
|
|
7
|
-
export async function readLocalUserTurn(ctx, request) {
|
|
8
|
-
request = structuredClone(request);
|
|
9
|
-
const id = SessionId(request.sessionId), sessions = ctx.get('sessions'), session = sessions?.get(id);
|
|
10
|
-
const persistence = ctx.get('sessionPersistence');
|
|
11
|
-
if (!session || typeof sessions?.flush !== 'function' || !persistence?.identity || typeof persistence.open !== 'function' || !request.userMessageIds.length)
|
|
12
|
-
throw failure();
|
|
13
|
-
const watermark = session.seq, header = structuredClone(session.header), persistenceIdentity = persistence.identity;
|
|
14
|
-
const assertCurrent = () => { if (ctx.get('sessions')?.get(id) !== session || ctx.get('sessionPersistence')?.identity !== persistenceIdentity || session.seq !== watermark || !isDeepStrictEqual(session.header, header))
|
|
15
|
-
throw failure('LOCAL_USER_TURN_CHANGED'); };
|
|
16
|
-
assertCurrent();
|
|
17
|
-
if (!await sessions.flush(session))
|
|
18
|
-
throw failure();
|
|
19
|
-
assertCurrent();
|
|
20
|
-
const handle = await persistence.open(id, 'read');
|
|
21
|
-
let proof, firstFailure;
|
|
22
|
-
try {
|
|
23
|
-
assertCurrent();
|
|
24
|
-
if (handle.id !== id || handle.access !== 'read' || !sameStoredSessionHeader(handle.header, header) || handle.inheritedEventCount !== session.inheritedEventCount)
|
|
25
|
-
throw failure();
|
|
26
|
-
const { events } = await handle.read();
|
|
27
|
-
assertCurrent();
|
|
28
|
-
if (!Array.isArray(events) || events.length !== watermark)
|
|
29
|
-
throw failure();
|
|
30
|
-
let turn, step, input, route, routeContext;
|
|
31
|
-
for (let i = 0; i < events.length; i++) {
|
|
32
|
-
const e = events[i];
|
|
33
|
-
if (e.seq !== i)
|
|
34
|
-
throw failure();
|
|
35
|
-
if (e.type === 'turn/start') {
|
|
36
|
-
turn = e;
|
|
37
|
-
step = undefined;
|
|
38
|
-
input = undefined;
|
|
39
|
-
}
|
|
40
|
-
else if (e.type === 'turn/end') {
|
|
41
|
-
turn = undefined;
|
|
42
|
-
step = undefined;
|
|
43
|
-
input = undefined;
|
|
44
|
-
}
|
|
45
|
-
// Human proof belongs to the native turn; approval continuations add a new
|
|
46
|
-
// step without re-emitting that human message. An active own step is still
|
|
47
|
-
// required, and turn/start/end above permanently clear the previous input.
|
|
48
|
-
else if (e.type === 'step/start')
|
|
49
|
-
step = e;
|
|
50
|
-
else if (e.type === 'step/end')
|
|
51
|
-
step = undefined;
|
|
52
|
-
else if (e.type === 'user/message' && step && e.data.source.kind === 'user')
|
|
53
|
-
input = e;
|
|
54
|
-
else if (e.type === 'request/header')
|
|
55
|
-
route = e.data.header.config.provider;
|
|
56
|
-
else if (e.type === 'request/context')
|
|
57
|
-
routeContext = e.data.provider;
|
|
58
|
-
}
|
|
59
|
-
if (!turn || !step || step.data.turn !== turn.data.turn || !input || route !== request.route || routeContext !== undefined && routeContext !== request.route || !session.isOwnSeq(turn.seq) || !session.isOwnSeq(step.seq) || !session.isOwnSeq(input.seq) || !request.userMessageIds.includes(input.data.id))
|
|
60
|
-
throw failure();
|
|
61
|
-
proof = { expectedUserTurn: { turn: turn.data.turn, userMessageId: input.data.id }, startSequence: turn.seq, userMessageSequence: input.seq };
|
|
62
|
-
}
|
|
63
|
-
catch (error) {
|
|
64
|
-
firstFailure = error;
|
|
65
|
-
}
|
|
66
|
-
try {
|
|
67
|
-
await handle.close();
|
|
68
|
-
}
|
|
69
|
-
catch (error) {
|
|
70
|
-
if (firstFailure instanceof NeedError)
|
|
71
|
-
throw Object.assign(new NeedError(firstFailure.code, firstFailure.message, firstFailure.requires + ';持久句柄关闭失败'), { cause: new AggregateError([firstFailure, error], 'LOCAL_TURN_READ_AND_CLOSE_FAILED') });
|
|
72
|
-
if (firstFailure !== undefined)
|
|
73
|
-
throw new AggregateError([firstFailure, error], 'LOCAL_TURN_READ_AND_CLOSE_FAILED');
|
|
74
|
-
throw error;
|
|
75
|
-
}
|
|
76
|
-
if (firstFailure !== undefined)
|
|
77
|
-
throw firstFailure;
|
|
78
|
-
assertCurrent();
|
|
79
|
-
return { ...proof, assertCurrent };
|
|
80
|
-
}
|
|
81
|
-
/** Only metadata observed live since this plugin mounted; never seed or persisted tails. */
|
|
82
|
-
export function createLocalUserTurnObserver(ctx) {
|
|
83
|
-
const current = new WeakMap();
|
|
84
|
-
ctx.on('session/event', (session, event) => {
|
|
85
|
-
if (event.type === 'turn/start')
|
|
86
|
-
current.set(session, { turn: event.data.turn });
|
|
87
|
-
else if (event.type === 'turn/end')
|
|
88
|
-
current.delete(session);
|
|
89
|
-
else if (event.type === 'user/message' && event.data.source.kind === 'user') {
|
|
90
|
-
const turn = current.get(session);
|
|
91
|
-
if (turn)
|
|
92
|
-
turn.userMessageId = event.data.id;
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
ctx.on('session/disposed', session => current.delete(session));
|
|
96
|
-
return { current(request) {
|
|
97
|
-
const session = request.sessionId ? ctx.get('sessions')?.get(SessionId(request.sessionId)) : undefined;
|
|
98
|
-
const metadata = session ? current.get(session) : undefined;
|
|
99
|
-
if (!metadata || !Number.isSafeInteger(metadata.turn) || metadata.turn < 0 || !metadata.userMessageId || !request.userInputIds?.includes(metadata.userMessageId))
|
|
100
|
-
throw new NeedError('LOCAL_USER_TURN_UNCONFIRMED', '无法核对本次员工输入,本轮已停止。', '本插件启用后观察到的官方真实员工输入');
|
|
101
|
-
return { turn: metadata.turn, userMessageId: metadata.userMessageId };
|
|
102
|
-
} };
|
|
103
|
-
}
|