@ai-workbench/remote-agent 0.9.0-toolbridge.34 → 0.9.0-toolbridge.36
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 +6 -5
- package/dist/acp.js +1 -1
- package/dist/claude-local.d.ts +0 -3
- package/dist/claude-local.js +3 -54
- package/dist/employee-mcp.js +2 -4
- package/dist/employee-provider.js +1 -1
- package/dist/index.js +3 -13
- package/dist/preflight-payload.js +1 -1
- package/dist/presentation.js +0 -2
- package/dist/provider.d.ts +1 -5
- package/dist/provider.js +0 -3
- package/dist/toolbridge-loop.js +1 -1
- package/dist/workspace-source.d.ts +1 -1
- package/package.json +1 -1
- package/dist/local-user-turn.d.ts +0 -24
- package/dist/local-user-turn.js +0 -103
package/README.md
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
# AI Workbench 远程助手 · @ai-workbench/remote-agent@0.9.0-toolbridge.
|
|
1
|
+
# AI Workbench 远程助手 · @ai-workbench/remote-agent@0.9.0-toolbridge.36 · 插件 → 添加插件
|
|
2
|
+
|
|
3
|
+
S7 按 owner 11-15 裁定撤除:删除 `local-user-turn` 及其轮次证明、Claude 专用接纳入口、持久输入核对、历史人类输入回退和专用字段。DSH 原生交给模型的人类输入、子任务通知、代理来信、审批续接及自动轮,统一走原生处理,不另设输入授权门;工具等待与混合插话批仍完整交付通知。L 的 0.7.17 接纳账本已在 0.7.27 删除,不恢复。新增设置、限制、错误码均为0。编排已锁定正式版本X.36/总包0.3.7;验证与历史证据见 `TESTS.md`。
|
|
4
|
+
|
|
2
5
|
|
|
3
6
|
## 办公依赖与开工计时(O1,2026-11-15)
|
|
4
7
|
|
|
@@ -10,7 +13,7 @@
|
|
|
10
13
|
|
|
11
14
|
## 含工具桥预发布线
|
|
12
15
|
|
|
13
|
-
本包为 `0.9.0-toolbridge.
|
|
16
|
+
本包为 `0.9.0-toolbridge.36`,从 `v0.9.0-toolbridge.14` 派生,使用 `host-toolbridge` 发布渠道。员工安装由连接组件提供的「AI 写作工作台(含工具桥)」总包 `@ai-workbench/workbench-toolbridge@0.3.7`,与不含工具桥的版本二选一。
|
|
14
17
|
|
|
15
18
|
本轮增加两家运行中插话(DSH 原生 nextStep),保留官方队列和原话;明确 followup 仍排下一轮。Codex 含桥组件需 `2.2.2-aw.12`,Claude 仍为官方 `0.94.0`。插件确定消息未发出时保留排队资格;送达未确认时明确报错且不重放。已注入旧正文不能撤回,编辑版下一步骤交付。
|
|
16
19
|
|
|
@@ -89,9 +92,7 @@ Codex 员工端只使用随包提供的原生组件,通道等待本次组件
|
|
|
89
92
|
|
|
90
93
|
I3(0.9.0-toolbridge.27):同一 DSH 对话的系统规则更新后,续接原 Codex native 线程并在实际模型请求应用新版规则;需要主机含桥 Codex ACP aw.15。规则未变不重复追加历史;每次恢复仍带当前配置以支持压缩重建。用量说明已由 U1(0.9.0-toolbridge.28)更正:Codex aw.15 和 Claude 0.94.0 的 ACP 回执均按本次 prompt 统计,逐轮全额结算一次,不减历史基线;旧累计快照不再参与计算。冷接回只减同一 prompt 已在 DSH 落盘的部分,可靠终态先持久化,原 broker 回收后仍可补记其未落盘用量。订阅额度卡仍读取官方额度窗口,不能由 token 数推算百分比。Claude 的规则传递保持。无新增设置、限制或错误码。
|
|
91
94
|
|
|
92
|
-
T3(0.9.0-toolbridge.
|
|
93
|
-
|
|
94
|
-
T3(0.9.0-toolbridge.33):在已连接、当前员工目录已接纳的 Codex 路径,同轮登录核验与端点准备重叠;两项均成功并再次核对目标、连接代次与物理目录后才开工,每轮核验与正常完成后结束 broker 的做法保留。当前输入已完整列出同一技能目录时,skill 工具省去重复名字数组;目录不完整或只有历史目录时保留原快照。未改变首轮工具可见性,没有新增设置、限制或错误码。本机受控时延与工具字节测量不代表远机实测速率或实际 API token 节省;DSH原生参照按编排补充引用P1首轮新对话/P2续写的既有统计,不再新测;两份均为Codex历史样本。
|
|
95
|
+
T3(0.9.0-toolbridge.33):在已连接、当前员工目录已接纳的 Codex 路径,同轮登录核验与端点准备重叠;两项均成功并再次核对目标、连接代次与物理目录后才开工,每轮核验与正常完成后结束 broker 的做法保留。当前输入已完整列出同一技能目录时,skill 工具省去重复名字数组;目录不完整或只有历史目录时保留原快照。未改变首轮工具可见性,没有新增设置、限制或错误码。本机受控时延与工具字节测量不代表远机实测速率或实际 API token 节省;DSH 原生本轮因缺独立登录未测。
|
|
95
96
|
|
|
96
97
|
B6(0.9.0-toolbridge.30,本版继承):Codex 员工执行环境接纳原生 turn/steer,含桥主机组件需 aw.16;冷恢复承接 DSH 准备阶段已固定的当前模型与推理档,不再在后置请求钩子用失败轮配置改档;历史专用元数据保留原轮模型和 native 关联。原失败冷轮可落定并按原 native 会话继续,原输入不重放。U1 的本次 prompt 用量修复来自 X.28,本版继续保留。
|
|
97
98
|
|
package/dist/acp.js
CHANGED
|
@@ -34,7 +34,7 @@ t=$(printf '%s' "$t" | z)
|
|
|
34
34
|
printf '%s\\n' "$c" | while IFS= read -r v; do v=\${v#C}; case $v in ''|*[!A-Za-z0-9._+@/\\ -]*) echo hit;; *) [ "$(printf '%s' "$v" | z)" = "$t" ] && echo hit;; esac; done | /usr/bin/grep -q hit && deny
|
|
35
35
|
exit 0`;
|
|
36
36
|
const claudeSettings = () => ({ hooks: { PreToolUse: [{ matcher: 'Agent', hooks: [{ type: 'command', command: cloudSubagentHook }] }] } });
|
|
37
|
-
function employeeClaudeOptions(routing) { return { tools: ['Agent', 'TaskStop', 'Skill'
|
|
37
|
+
function employeeClaudeOptions(routing) { return { tools: ['Agent', 'TaskStop', 'Skill'], disallowedTools: ['Read', 'Write', 'Edit', 'Glob', 'Grep', 'Bash'], toolAliases: structuredClone(routing.toolAliases), settings: claudeSettings() }; }
|
|
38
38
|
const permissionRanks = { claude: { plan: 0, default: 1, acceptEdits: 1, bypassPermissions: 2 }, codex: { 'read-only': 0, 'workspace-write': 1, agent: 1, 'agent-full-access': 2 } };
|
|
39
39
|
/** ACP v1 with explicitly negotiated SDK 2.0 lifecycle/context extensions. */
|
|
40
40
|
export class AcpSession {
|
package/dist/claude-local.d.ts
CHANGED
|
@@ -5,7 +5,6 @@ import { createEmployeeShell, type EmployeeShell } from './employee-shell.ts';
|
|
|
5
5
|
import type { EmployeeRouting } from './employee-relay.ts';
|
|
6
6
|
import { type ConnectApi, type ConnectTarget, type Project, type Runtime, type RuntimeRequest, type LocalRuntimeProvider, type ConnectionState } from './provider.ts';
|
|
7
7
|
import type { DetailChannel } from './remote-details.ts';
|
|
8
|
-
import type { LocalTurnProof } from './local-user-turn.ts';
|
|
9
8
|
import type { DetailObservation } from './conversation-details.ts';
|
|
10
9
|
interface Configuration {
|
|
11
10
|
acpMaxMessageBytes?: number;
|
|
@@ -17,8 +16,6 @@ interface Options {
|
|
|
17
16
|
getNetwork: () => EmployeeNetworkApi | undefined;
|
|
18
17
|
readWorkspace: (sessionId: string) => Promise<EmployeeWorkspace>;
|
|
19
18
|
configuration: () => Configuration;
|
|
20
|
-
readUserTurn: (request: RuntimeRequest) => Promise<LocalTurnProof>;
|
|
21
|
-
reportAdmissionFailure: (request: RuntimeRequest, code: string) => Promise<void>;
|
|
22
19
|
recordUnscoped: (request: RuntimeRequest, event: DetailObservation) => Promise<void>;
|
|
23
20
|
details: (request: RuntimeRequest, api: ConnectApi, connection: ConnectionState, target: ConnectTarget) => Promise<DetailChannel>;
|
|
24
21
|
open: (target: ConnectTarget, project: Project, request: RuntimeRequest) => Promise<Runtime>;
|
package/dist/claude-local.js
CHANGED
|
@@ -8,61 +8,15 @@ var __rewriteRelativeImportExtension = (this && this.__rewriteRelativeImportExte
|
|
|
8
8
|
};
|
|
9
9
|
import { EMPLOYEE_EXECUTION_NOTICE as NOTICE } from "./employee-presentation.js";
|
|
10
10
|
import { CloseDiagnostics, closeCode } from "./close-diagnostics.js";
|
|
11
|
-
import { isDeepStrictEqual } from 'node:util';
|
|
12
11
|
import { openEmployeeLease } from "./employee-endpoint.js";
|
|
13
12
|
import { openEmployeeMcp } from "./employee-mcp.js";
|
|
14
13
|
import { createEmployeeShell } from "./employee-shell.js";
|
|
15
|
-
import { unwrap } from "./provider.js";
|
|
16
14
|
import { sshIo } from "./broker.js";
|
|
17
15
|
import { NeedError, shellQuote } from "./remote.js";
|
|
18
|
-
import { awaitL } from "./provider.js";
|
|
19
16
|
const failure = (code) => new NeedError(code, '当前本机执行上下文无法确认,本轮已停止;没有改在主机执行。', 'L当前本地绑定、N员工端点与S同代桥');
|
|
20
17
|
/** Local source only. Host source remains with the host provider. */
|
|
21
18
|
export function createClaudeLocalProvider(options) {
|
|
22
19
|
const entries = new Map();
|
|
23
|
-
const admitted = new WeakMap();
|
|
24
|
-
const admit = async (request, api, connection, target) => {
|
|
25
|
-
if (admitted.has(request))
|
|
26
|
-
return;
|
|
27
|
-
try {
|
|
28
|
-
if (api.getContractInfo?.().workspaceLocations !== 1)
|
|
29
|
-
return;
|
|
30
|
-
const local = api;
|
|
31
|
-
if (typeof local.getWorkspaceLocationState !== 'function')
|
|
32
|
-
throw failure('EMPLOYEE_CONTEXT_UNAVAILABLE');
|
|
33
|
-
const workspace = await options.readWorkspace(request.sessionId), state = local.getWorkspaceLocationState(), matches = state.items.filter(row => row.workspaceId === workspace.workspaceId);
|
|
34
|
-
if (matches.length === 1 && matches[0].source === 'host')
|
|
35
|
-
return; // Host state/Need belongs to the host resolver, before local admission.
|
|
36
|
-
if (matches.length !== 1 || state.phase !== 'ready' || state.instanceId !== connection.instanceId || state.epoch !== connection.epoch)
|
|
37
|
-
throw failure('EMPLOYEE_CONTEXT_CHANGED');
|
|
38
|
-
const item = matches[0];
|
|
39
|
-
if (item.source !== 'local')
|
|
40
|
-
return;
|
|
41
|
-
if (item.status !== 'selected' || !item.bindingId || api.getContractInfo?.().localWorkspaceContext !== 1 || typeof local.getLocalWorkspaceContext !== 'function')
|
|
42
|
-
throw failure('EMPLOYEE_CONTEXT_UNAVAILABLE');
|
|
43
|
-
const context = unwrap(await awaitL(() => local.getLocalWorkspaceContext({ instanceId: connection.instanceId, epoch: connection.epoch, workspaceId: workspace.workspaceId, expectedBindingId: item.bindingId }), request.signal));
|
|
44
|
-
if (context.instanceId !== connection.instanceId || context.epoch !== connection.epoch || context.workspaceId !== workspace.workspaceId || context.bindingId !== item.bindingId || context.source !== 'local' || !isDeepStrictEqual(context.directory, workspace.directory))
|
|
45
|
-
throw failure('EMPLOYEE_CONTEXT_CHANGED');
|
|
46
|
-
const proof = await options.readUserTurn(request);
|
|
47
|
-
proof.assertCurrent();
|
|
48
|
-
request.signal?.throwIfAborted();
|
|
49
|
-
const now = api.getConnectionState();
|
|
50
|
-
if (options.getConnect() !== api || now.phase !== 'connected' || now.instanceId !== connection.instanceId || now.epoch !== connection.epoch)
|
|
51
|
-
throw failure('CONNECTION_LOST');
|
|
52
|
-
request.detailChannel = await options.details(request, api, connection, target);
|
|
53
|
-
admitted.set(request, { api, workspace: structuredClone(workspace), bindingId: item.bindingId, connection: structuredClone(connection) });
|
|
54
|
-
}
|
|
55
|
-
catch (error) {
|
|
56
|
-
const code = error instanceof NeedError ? error.code : 'LOCAL_ADMISSION_FAILED';
|
|
57
|
-
try {
|
|
58
|
-
await options.reportAdmissionFailure(request, code);
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
throw new NeedError(code, '本轮输入无法核对,已停止本次处理;诊断保存也未完成。', '原原因 ' + code + ';私有诊断 REMOTE_DETAIL_STORAGE_FAILED');
|
|
62
|
-
}
|
|
63
|
-
throw error;
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
20
|
const resolve = async (request, api, connection, target) => {
|
|
67
21
|
if (api.getContractInfo?.().workspaceLocations !== 1)
|
|
68
22
|
return;
|
|
@@ -75,12 +29,7 @@ export function createClaudeLocalProvider(options) {
|
|
|
75
29
|
const item = matches[0];
|
|
76
30
|
if (item.source !== 'local')
|
|
77
31
|
return;
|
|
78
|
-
if (!
|
|
79
|
-
await admit(request, api, connection, target);
|
|
80
|
-
const acceptance = admitted.get(request);
|
|
81
|
-
if (!acceptance || acceptance.api !== api || acceptance.bindingId !== item.bindingId || acceptance.connection.instanceId !== connection.instanceId || acceptance.connection.epoch !== connection.epoch || !isDeepStrictEqual(acceptance.workspace, workspace))
|
|
82
|
-
throw failure('EMPLOYEE_CONTEXT_CHANGED');
|
|
83
|
-
if (item.status !== 'selected' || !item.bindingId || local.getContractInfo().localWorkspaceContext !== 1)
|
|
32
|
+
if (item.status !== 'selected' || !item.bindingId)
|
|
84
33
|
throw failure('EMPLOYEE_CONTEXT_UNAVAILABLE');
|
|
85
34
|
if (request.cwd && request.cwd !== workspace.directory.path || request.bindingId && request.bindingId !== item.bindingId || request.workspaceId && request.workspaceId !== workspace.workspaceId)
|
|
86
35
|
throw failure('SESSION_CONTEXT_MISMATCH');
|
|
@@ -94,7 +43,8 @@ export function createClaudeLocalProvider(options) {
|
|
|
94
43
|
void entry.runtime.dispose?.({ layer: 'runtime', initiator: 'claude.next-round', reason: 'NEXT_ROUND', action: 'dispose' }).catch(() => console.warn('CLAUDE_CLEANUP_FAILED'));
|
|
95
44
|
entry = undefined;
|
|
96
45
|
}
|
|
97
|
-
const details = request
|
|
46
|
+
const details = await options.details(request, api, connection, target);
|
|
47
|
+
request.detailChannel = details;
|
|
98
48
|
const closeDiagnostics = new CloseDiagnostics(event => details.record(event));
|
|
99
49
|
closeDiagnostics.bind(event => details.record(event));
|
|
100
50
|
request.closeDiagnostics = closeDiagnostics;
|
|
@@ -189,6 +139,5 @@ export function createClaudeLocalProvider(options) {
|
|
|
189
139
|
throw error;
|
|
190
140
|
}
|
|
191
141
|
};
|
|
192
|
-
resolve.admit = admit;
|
|
193
142
|
return resolve;
|
|
194
143
|
}
|
package/dist/employee-mcp.js
CHANGED
|
@@ -8,7 +8,7 @@ import { createEmployeeTools } from "./employee-tools.js";
|
|
|
8
8
|
import { employeeRouting } from "./employee-relay.js";
|
|
9
9
|
import { NeedError } from "./remote.js";
|
|
10
10
|
const string = { type: 'string' }, integer = { type: 'integer' }, boolean = { type: 'boolean' };
|
|
11
|
-
function schema(name, properties, required) { return { name,
|
|
11
|
+
function schema(name, properties, required) { return { name, description: '在员工电脑所选工作区执行' + name + ';不在主机回退。' + (name === 'Bash' ? '输出原样保留:若stdoutEncoding或stderrEncoding为base64,对应字符串为原始字节的base64编码,按标明编码处理;退出状态独立保留。' : ''), inputSchema: { type: 'object', properties, required, additionalProperties: false } }; }
|
|
12
12
|
export const EMPLOYEE_MCP_TOOLS = [
|
|
13
13
|
schema('Read', { file_path: string, offset: integer, limit: integer, pages: string }, ['file_path']),
|
|
14
14
|
schema('Write', { file_path: string, content: string }, ['file_path', 'content']),
|
|
@@ -136,9 +136,7 @@ export async function openEmployeeMcp(options) {
|
|
|
136
136
|
const mcp = new Server({ name: 'ai-workbench-employee', version: '0.8.14' }, { capabilities: { tools: {} } }), transport = new EmployeeSocketTransport(socket, options.maxBytes, observeConnection);
|
|
137
137
|
clients.add(mcp);
|
|
138
138
|
transports.add(transport);
|
|
139
|
-
mcp.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [...EMPLOYEE_MCP_TOOLS, ...
|
|
140
|
-
// 员工执行与办公入口直接可调用;其余DSH扩展工具仍交原生搜索发现。
|
|
141
|
-
schema.name === 'skill' || schema.name === 'load_workspace_dependencies' ? { ...wire, _meta: { ...wire._meta, 'anthropic/alwaysLoad': true } } : wire)] }));
|
|
139
|
+
mcp.setRequestHandler(ListToolsRequestSchema, async () => ({ tools: [...EMPLOYEE_MCP_TOOLS, ...options.bridge?.tools ?? []] }));
|
|
142
140
|
mcp.setRequestHandler(CallToolRequestSchema, async (request, extra) => {
|
|
143
141
|
const active = options.activeSignal();
|
|
144
142
|
if (!active || active.aborted)
|
|
@@ -101,7 +101,7 @@ export function createEmployeeProvider(get, options, agent) {
|
|
|
101
101
|
try {
|
|
102
102
|
const context = request.localContext;
|
|
103
103
|
if (!context || context.instanceId !== connection.instanceId || context.epoch !== connection.epoch || context.workspaceId !== workspace.id || context.bindingId !== row.bindingId)
|
|
104
|
-
throw fail('
|
|
104
|
+
throw fail('EMPLOYEE_CONTEXT_CHANGED');
|
|
105
105
|
if (typeof api.onWorkspaceLocationState !== 'function' || typeof api.onConnectionState !== 'function')
|
|
106
106
|
throw fail('DEPENDENCY_REQUIRED');
|
|
107
107
|
const network = employee.getNetwork();
|
package/dist/index.js
CHANGED
|
@@ -31,7 +31,6 @@ import { officialEmployeeWorkspace } from "./employee-workspace.js";
|
|
|
31
31
|
import { createSessionSources } from "./session-source.js";
|
|
32
32
|
import { resolveEmployeeNative } from "./employee-native.js";
|
|
33
33
|
import { createClaudeLocalProvider } from "./claude-local.js";
|
|
34
|
-
import { readLocalUserTurn } from "./local-user-turn.js";
|
|
35
34
|
import { readEmployeeWorkspace } from "./employee-workspace.js";
|
|
36
35
|
import { createPreflightDiagnostics } from "./preflight-diagnostic.js";
|
|
37
36
|
import { installModelInputRetention, markModelPreparationFailure } from "./model-input-retention.js";
|
|
@@ -402,16 +401,7 @@ export class CodexRemoteAdapter extends LlmAdapter {
|
|
|
402
401
|
const after = options.messages.findLastIndex(message => message.role === 'assistant');
|
|
403
402
|
const tail = options.messages.slice(after + 1);
|
|
404
403
|
const humanIds = tail.flatMap(message => message.role === 'user' && message.source?.kind === 'user' && typeof message.id === 'string' ? [message.id] : []);
|
|
405
|
-
|
|
406
|
-
// human message. This is a CAS candidate only: live turn/L proof must still
|
|
407
|
-
// bind it. The actual input delta remains prepareInput's unchanged tail.
|
|
408
|
-
if (!humanIds.length && tail.some(message => message.role === 'user' && message.source?.kind === 'user-approval')) {
|
|
409
|
-
const original = options.messages.slice(0, after + 1).findLast(message => message.role === 'user' && message.source?.kind === 'user' && typeof message.id === 'string');
|
|
410
|
-
if (typeof original?.id === 'string')
|
|
411
|
-
humanIds.push(original.id);
|
|
412
|
-
}
|
|
413
|
-
request.userInputIds = Object.freeze(humanIds);
|
|
414
|
-
request.userMessageIds = request.userInputIds;
|
|
404
|
+
const currentInputs = tail.filter(message => message.role === 'user');
|
|
415
405
|
earlyStage = 'source-context';
|
|
416
406
|
await startupTiming.run('source-admission', async () => this.resolveRuntime.preflight?.(request));
|
|
417
407
|
options = { ...await this.coldRecovery?.projectCancelledInputs?.(options) ?? options, signal };
|
|
@@ -428,7 +418,7 @@ export class CodexRemoteAdapter extends LlmAdapter {
|
|
|
428
418
|
const injected = new Set(matching.filter(r => r.outcome === 'injected').map(r => { if (!previous || r.nativeSessionId !== previous.sessionId)
|
|
429
419
|
throw new NeedError('SESSION_CONTEXT_MISMATCH', '中途消息属于另一原生轮,未重复提交。', '原会话的注入回执与检查点'); return r.messageId; }));
|
|
430
420
|
const withheld = new Set([...injected, ...uncertain]);
|
|
431
|
-
if (
|
|
421
|
+
if (currentInputs.length && currentInputs.every(message => typeof message.id === 'string' && withheld.has(message.id))) {
|
|
432
422
|
if (receiptNotice) {
|
|
433
423
|
const notice = new StreamMapper();
|
|
434
424
|
yield* notice.text(receiptNotice);
|
|
@@ -889,7 +879,7 @@ export function apply(ctx, live) {
|
|
|
889
879
|
};
|
|
890
880
|
return runtime;
|
|
891
881
|
};
|
|
892
|
-
const local = agent.loginProvider === 'claude' ? createClaudeLocalProvider({ getConnect: get, getNetwork: () => ctx.get('aiWorkbenchNetwork'), readWorkspace: id => readEmployeeWorkspace(ctx, id),
|
|
882
|
+
const local = agent.loginProvider === 'claude' ? createClaudeLocalProvider({ getConnect: get, getNetwork: () => ctx.get('aiWorkbenchNetwork'), readWorkspace: id => readEmployeeWorkspace(ctx, id), recordUnscoped: (request, observation) => managerForProfile().recordLocalFailure({ sessionId: request.sessionId, provider: 'claude', code: observation.code, observation }), configuration: config, details, open }) : undefined;
|
|
893
883
|
const workspace = async (request) => {
|
|
894
884
|
const services = ctx;
|
|
895
885
|
const registry = services.get('workspaceRegistry');
|
|
@@ -4,7 +4,7 @@ export function validPreflightPayload(value) {
|
|
|
4
4
|
const p = value, keys = ['phase', 'stage', 'workspaceId', 'bindingId', 'source', 'status', 'outcome'];
|
|
5
5
|
const id = (v) => v === null || typeof v === 'string' && v.length > 0 && !/[\x00-\x1f\x7f]/.test(v);
|
|
6
6
|
return Object.keys(p).length === keys.length && keys.every(key => Object.hasOwn(p, key)) && p.phase === 'workspace-source-admission'
|
|
7
|
-
&& ['source-context', 'input-acceptance', 'login-readiness', '
|
|
7
|
+
&& ['source-context', 'input-acceptance', 'login-readiness', 'input-prepare', 'model-catalog', 'runtime-resolve'].includes(p.stage)
|
|
8
8
|
&& id(p.workspaceId) && id(p.bindingId) && [null, 'local', 'host'].includes(p.source)
|
|
9
9
|
&& [null, 'unselected', 'selected', 'legacy-confirmation-required', 'invalid'].includes(p.status)
|
|
10
10
|
&& ['confirmation-required', 'confirmed', 'declined', 'cancelled', 'failed'].includes(p.outcome);
|
package/dist/presentation.js
CHANGED
|
@@ -15,8 +15,6 @@ export function employeeFailure(code, brand = 'codex', promptDispatched = true)
|
|
|
15
15
|
WORKSPACE_SOURCE_STORAGE_FAILED: '这条会话的文件来源未能保存,本轮工作区准备失败;请恢复后在原会话重试。',
|
|
16
16
|
WORKSPACE_LOCATION_REQUIRED: '我需要你确认这个工作区使用哪一个文件夹,本轮未执行;你的原话仍保留。',
|
|
17
17
|
WORKSPACE_LOCATION_CONFLICT: '工作区来源选择已更新,本次确认不能覆盖新的选择;本轮未执行,你的原话仍保留。',
|
|
18
|
-
LOCAL_USER_TURN_CHANGED: '本次输入已变化,本轮已停止,请确认对话后重新发送。',
|
|
19
|
-
LOCAL_USER_TURN_UNCONFIRMED: '无法核对本次员工输入,本轮已停止;请在当前会话重新发送。',
|
|
20
18
|
AW_EMPLOYEE_ENVIRONMENTS_CONFIG_UNSUPPORTED: '主机环境配置会覆盖本机执行位置,本轮已停止;请联系管理员调整后在原会话重试。',
|
|
21
19
|
EMPLOYEE_CONTEXT_UNAVAILABLE: '我需要远程主机连接组件提供当前本机工作区,本轮未执行。',
|
|
22
20
|
EMPLOYEE_ENDPOINT_UNAVAILABLE: '我需要员工电脑的执行连接就绪,本轮未执行;请联系管理员检查连接组件。',
|
package/dist/provider.d.ts
CHANGED
|
@@ -91,10 +91,8 @@ export interface RuntimeRequest extends Invocation {
|
|
|
91
91
|
previousContextSha256?: string;
|
|
92
92
|
preflightFailureRecorded?: boolean;
|
|
93
93
|
recordEarlyFailure?: (error: unknown, stage: SourceAdmissionStage) => Promise<void>;
|
|
94
|
-
userInputIds?: readonly string[];
|
|
95
94
|
localContext?: Readonly<LocalWorkspaceContext>;
|
|
96
95
|
localAdmissionCheck?: () => void;
|
|
97
|
-
userMessageIds?: readonly string[];
|
|
98
96
|
detailChannel?: DetailChannel;
|
|
99
97
|
acpMaxMessageBytes?: number;
|
|
100
98
|
employeeScope?: string;
|
|
@@ -185,9 +183,7 @@ export declare function identity(t: ConnectTarget): string;
|
|
|
185
183
|
export declare function requireNativeWorkspace(api: ConnectApi): asserts api is ConnectApi & NativeWorkspaceApi;
|
|
186
184
|
/** Authorization stays in L; ensureReady only checks and records the need. */
|
|
187
185
|
export declare function offerLogin(connect: ConnectApi, request: Invocation, currentApi?: () => ConnectApi | undefined, agent?: AgentDefinition): Promise<void>;
|
|
188
|
-
export type LocalRuntimeProvider = ((request: RuntimeRequest, api: ConnectApi, connection: ConnectionState, target: ConnectTarget) => Promise<Runtime | undefined>)
|
|
189
|
-
admit?: (request: RuntimeRequest, api: ConnectApi, connection: ConnectionState, target: ConnectTarget) => Promise<void>;
|
|
190
|
-
};
|
|
186
|
+
export type LocalRuntimeProvider = ((request: RuntimeRequest, api: ConnectApi, connection: ConnectionState, target: ConnectTarget) => Promise<Runtime | undefined>);
|
|
191
187
|
export declare function sameTarget(a: ConnectTarget, b: ConnectTarget): boolean;
|
|
192
188
|
export declare function connectProvider(get: () => ConnectApi | undefined, options?: {
|
|
193
189
|
agent?: AgentDefinition;
|
package/dist/provider.js
CHANGED
|
@@ -202,12 +202,9 @@ export function connectProvider(get, options = {}) {
|
|
|
202
202
|
throw new NeedError('SESSION_CONTEXT_MISMATCH', '员工主机与原会话不一致,请新建会话', '原员工主机');
|
|
203
203
|
request.localAdmissionCheck?.();
|
|
204
204
|
admissions.set(request, { api, target, connection });
|
|
205
|
-
sourceStage = 'local-admission';
|
|
206
205
|
const locations = !host && api.getContractInfo().workspaceLocations === 1 ? api.getWorkspaceLocationState?.() : undefined;
|
|
207
206
|
if (!host && locations && (locations.phase === 'failed' || locations.phase === 'disposed') && locations.instanceId === connection.instanceId && locations.epoch === connection.epoch && locations.need)
|
|
208
207
|
throw connectNeedError(locations.need);
|
|
209
|
-
if (!host)
|
|
210
|
-
await options.local?.admit?.(request, api, connection, target);
|
|
211
208
|
if (preparation) {
|
|
212
209
|
await preparation.ready;
|
|
213
210
|
preparation.confirm(target, connection);
|
package/dist/toolbridge-loop.js
CHANGED
|
@@ -183,7 +183,7 @@ export class ToolBridgeLoop {
|
|
|
183
183
|
throw new NeedError('ABORTED', '本轮已取消,工具结果没有重放。', '确认主机取消状态');
|
|
184
184
|
if (run.latest !== options) {
|
|
185
185
|
for (const m of options.messages)
|
|
186
|
-
if (m.role === 'user' && '
|
|
186
|
+
if (m.role === 'user' && 'id' in m && typeof m.id === 'string' && !run.seen.has(m.id) && !this.isInjected?.(key, m)) {
|
|
187
187
|
run.seen.add(m.id);
|
|
188
188
|
run.deferred.push(m);
|
|
189
189
|
}
|
|
@@ -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,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
|
-
}
|