@ai-workbench/remote-agent 0.9.0-toolbridge.32 → 0.9.0-toolbridge.33
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 +8 -2
- package/dist/employee-provider.d.ts +2 -0
- package/dist/employee-provider.js +4 -4
- package/dist/employee-startup.d.ts +18 -0
- package/dist/employee-startup.js +95 -0
- package/dist/index.js +2 -0
- package/dist/provider.d.ts +1 -0
- package/dist/provider.js +63 -31
- package/dist/toolbridge-table.d.ts +1 -1
- package/dist/toolbridge-table.js +2 -2
- package/dist/toolbridge.js +20 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# AI Workbench 远程助手 · @ai-workbench/remote-agent@0.9.0-toolbridge.
|
|
1
|
+
# AI Workbench 远程助手 · @ai-workbench/remote-agent@0.9.0-toolbridge.33 · 插件 → 添加插件
|
|
2
2
|
|
|
3
3
|
## 办公依赖与开工计时(O1,2026-11-15)
|
|
4
4
|
|
|
@@ -87,4 +87,10 @@ Codex 员工端只使用随包提供的原生组件,通道等待本次组件
|
|
|
87
87
|
|
|
88
88
|
模型目录在官方启动读取时获取,并在连接变为 connected 时经官方注册刷新;官方菜单打开或重试读取缓存是 DSH 官方限制,本插件不改官方菜单或核心。真正不支持的推理档位由 DSH 预检,其英文提示保留为观察项。
|
|
89
89
|
|
|
90
|
-
I3(0.9.0-toolbridge.27):同一 DSH 对话的系统规则更新后,续接原 Codex native 线程并在实际模型请求应用新版规则;需要主机含桥 Codex ACP aw.15。规则未变不重复追加历史;每次恢复仍带当前配置以支持压缩重建。用量说明已由 U1(0.9.0-toolbridge.
|
|
90
|
+
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
|
+
|
|
92
|
+
T3(0.9.0-toolbridge.33):在已连接、当前员工目录已接纳的 Codex 路径,同轮登录核验与端点准备重叠;两项均成功并再次核对目标、连接代次与物理目录后才开工,每轮核验与正常完成后结束 broker 的做法保留。当前输入已完整列出同一技能目录时,skill 工具省去重复名字数组;目录不完整或只有历史目录时保留原快照。未改变首轮工具可见性,没有新增设置、限制或错误码。本机受控时延与工具字节测量不代表远机实测速率或实际 API token 节省;DSH 原生本轮因缺独立登录未测。
|
|
93
|
+
|
|
94
|
+
B6(0.9.0-toolbridge.30,本版继承):Codex 员工执行环境接纳原生 turn/steer,含桥主机组件需 aw.16;冷恢复承接 DSH 准备阶段已固定的当前模型与推理档,不再在后置请求钩子用失败轮配置改档;历史专用元数据保留原轮模型和 native 关联。原失败冷轮可落定并按原 native 会话继续,原输入不重放。U1 的本次 prompt 用量修复来自 X.28,本版继续保留。
|
|
95
|
+
|
|
96
|
+
本版同时继承 B6 X.32 对插话与冷恢复链十类无效状态的清理;当前步骤选择、旧 JSON 字段的读取、原轮可靠结果、取消与防重放行为保持。
|
|
@@ -4,6 +4,7 @@ import type { ConnectApi, ConnectTarget, ConnectionState, Project, Runtime, Runt
|
|
|
4
4
|
import { type BrokerIo, type SshArgv } from './broker.ts';
|
|
5
5
|
import type { DetailChannel } from './remote-details.ts';
|
|
6
6
|
import type { LocalWorkspaceContext } from '@ai-workbench/connect/api';
|
|
7
|
+
import type { EmployeeStartup } from './employee-startup.ts';
|
|
7
8
|
export interface EmployeeProviderOptions {
|
|
8
9
|
getNetwork(): NetworkApi | undefined;
|
|
9
10
|
workspace(request: RuntimeRequest): Promise<{
|
|
@@ -26,6 +27,7 @@ interface Admission {
|
|
|
26
27
|
target: ConnectTarget;
|
|
27
28
|
connection: ConnectionState;
|
|
28
29
|
request: RuntimeRequest;
|
|
30
|
+
preparation?: EmployeeStartup;
|
|
29
31
|
}
|
|
30
32
|
/** Inspect the current local workspace once at turn start, before host readiness. */
|
|
31
33
|
export declare function inspectEmployeeWorkspace(get: () => ConnectApi | undefined, employee: EmployeeProviderOptions, agent: AgentDefinition, api: ConnectApi, request: RuntimeRequest): Promise<Readonly<LocalWorkspaceContext> | undefined>;
|
|
@@ -134,13 +134,13 @@ export function createEmployeeProvider(get, options, agent) {
|
|
|
134
134
|
throw fail('EMPLOYEE_OPERATION_UNSUPPORTED');
|
|
135
135
|
if (!Number.isSafeInteger(request.acpMaxMessageBytes) || request.acpMaxMessageBytes < 1)
|
|
136
136
|
throw fail('SETTINGS_REQUIRED');
|
|
137
|
-
const prepareLocation = () => admitEmployeeLocation({ api: api, network, workspace, connection, expectedLocal: { instanceId: context.instanceId, epoch: context.epoch, workspaceId: context.workspaceId, bindingId: context.bindingId, directory: { ...context.directory } }, settingsPath: target.session.settingsPath, signal: roundSignal });
|
|
138
|
-
const resolveNative = () => employee.native();
|
|
137
|
+
const prepareLocation = () => input.preparation ? input.preparation.location(network, context) : admitEmployeeLocation({ api: api, network, workspace, connection, expectedLocal: { instanceId: context.instanceId, epoch: context.epoch, workspaceId: context.workspaceId, bindingId: context.bindingId, directory: { ...context.directory } }, settingsPath: target.session.settingsPath, signal: roundSignal });
|
|
138
|
+
const resolveNative = () => input.preparation ? input.preparation.native() : employee.native();
|
|
139
139
|
// 仅把无授权、无目标的静态包路径解析与本轮N准备重叠。两项都收敛后,
|
|
140
140
|
// 按原顺序处理错误;每轮N准备、事件撤销、执行目标绑定仍完整执行。
|
|
141
141
|
const [locationResult, nativeResult] = await Promise.allSettled([
|
|
142
|
-
request.startupTiming?.run('endpoint-prepare', prepareLocation) ?? prepareLocation(),
|
|
143
|
-
request.startupTiming?.run('native-metadata', resolveNative) ?? resolveNative(),
|
|
142
|
+
input.preparation ? prepareLocation() : request.startupTiming?.run('endpoint-prepare', prepareLocation) ?? prepareLocation(),
|
|
143
|
+
input.preparation ? resolveNative() : request.startupTiming?.run('native-metadata', resolveNative) ?? resolveNative(),
|
|
144
144
|
]);
|
|
145
145
|
if (locationResult.status === 'rejected')
|
|
146
146
|
throw locationResult.reason;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { NetworkApi } from '@ai-workbench/network/api';
|
|
2
|
+
import type { LocalWorkspaceContext } from '@ai-workbench/connect/api';
|
|
3
|
+
import type { EmployeeProviderOptions } from './employee-provider.ts';
|
|
4
|
+
import { type ConnectApi, type ConnectTarget, type ConnectionState, type RuntimeRequest } from './provider.ts';
|
|
5
|
+
import { admitEmployeeLocation } from './employee-location.ts';
|
|
6
|
+
type Location = Awaited<ReturnType<typeof admitEmployeeLocation>>;
|
|
7
|
+
/** 只拥有本次请求的等待和围栏,不拥有、关闭或缓存N的共享设备服务。 */
|
|
8
|
+
export interface EmployeeStartup {
|
|
9
|
+
ready: Promise<void>;
|
|
10
|
+
confirm(target: ConnectTarget, connection: ConnectionState): void;
|
|
11
|
+
location(network: NetworkApi, context: Readonly<LocalWorkspaceContext>): Promise<Location>;
|
|
12
|
+
native(): Promise<{
|
|
13
|
+
path: string;
|
|
14
|
+
}>;
|
|
15
|
+
cancel(): void;
|
|
16
|
+
}
|
|
17
|
+
export declare function beginEmployeeStartup(get: () => ConnectApi | undefined, employee: EmployeeProviderOptions, api: ConnectApi, request: RuntimeRequest): EmployeeStartup | undefined;
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { isDeepStrictEqual } from 'node:util';
|
|
2
|
+
import { awaitL, sameTarget, validateTarget } from "./provider.js";
|
|
3
|
+
import { admitEmployeeLocation } from "./employee-location.js";
|
|
4
|
+
import { connectNeedError } from "./connect-need.js";
|
|
5
|
+
import { NeedError } from "./remote.js";
|
|
6
|
+
const failure = (code) => new NeedError(code, '员工电脑的工作区或执行连接已变化,本轮没有继续执行。', '当前工作区绑定与员工端执行器');
|
|
7
|
+
export function beginEmployeeStartup(get, employee, api, request) {
|
|
8
|
+
const context = request.localContext ? structuredClone(request.localContext) : undefined, connection = api.getConnectionState();
|
|
9
|
+
// 只在原context已接纳且已有执行用途可信target的路径重叠;首次未连接仍按原顺序开通。
|
|
10
|
+
if (!context || connection.phase !== 'connected' || typeof api.getSshTarget !== 'function')
|
|
11
|
+
return;
|
|
12
|
+
const network = employee.getNetwork(), lifetime = new AbortController(), offs = [];
|
|
13
|
+
const signal = AbortSignal.any([lifetime.signal, ...request.signal ? [request.signal] : []]);
|
|
14
|
+
let closed = false, target, location, native;
|
|
15
|
+
const nativeMetadata = () => native ??= (request.startupTiming?.run('native-metadata', () => employee.native()) ?? Promise.resolve().then(() => employee.native()));
|
|
16
|
+
const close = () => { if (closed)
|
|
17
|
+
return; closed = true; for (const off of offs.splice(0))
|
|
18
|
+
off(); };
|
|
19
|
+
const cancel = () => { lifetime.abort(failure('ABORTED')); close(); };
|
|
20
|
+
const check = () => {
|
|
21
|
+
signal.throwIfAborted();
|
|
22
|
+
request.localAdmissionCheck?.();
|
|
23
|
+
if (get() !== api || employee.getNetwork() !== network)
|
|
24
|
+
throw failure('EMPLOYEE_CONTEXT_CHANGED');
|
|
25
|
+
const now = api.getConnectionState();
|
|
26
|
+
if (now.phase !== 'connected' || now.instanceId !== connection.instanceId || now.epoch !== connection.epoch)
|
|
27
|
+
throw failure('CONNECTION_LOST');
|
|
28
|
+
if (!network || network.getState().phase !== 'online')
|
|
29
|
+
throw failure('CONNECTION_LOST');
|
|
30
|
+
};
|
|
31
|
+
const changed = () => { try {
|
|
32
|
+
check();
|
|
33
|
+
}
|
|
34
|
+
catch (error) {
|
|
35
|
+
lifetime.abort(error);
|
|
36
|
+
close();
|
|
37
|
+
} };
|
|
38
|
+
const revokeNetwork = (event) => { if (event.kind === 'lost') {
|
|
39
|
+
lifetime.abort(failure('CONNECTION_LOST'));
|
|
40
|
+
close();
|
|
41
|
+
}
|
|
42
|
+
else
|
|
43
|
+
changed(); };
|
|
44
|
+
const aborted = () => close();
|
|
45
|
+
signal.addEventListener('abort', aborted, { once: true });
|
|
46
|
+
offs.push(() => signal.removeEventListener('abort', aborted));
|
|
47
|
+
const pending = (async () => {
|
|
48
|
+
if (typeof api.onConnectionState !== 'function' || typeof api.onWorkspaceLocationState !== 'function' || !network || typeof network.onState !== 'function' || typeof network.prepareEmployeeEndpoint !== 'function')
|
|
49
|
+
throw failure('DEPENDENCY_REQUIRED');
|
|
50
|
+
const watch = (off) => { if (closed)
|
|
51
|
+
off();
|
|
52
|
+
else
|
|
53
|
+
offs.push(off); };
|
|
54
|
+
watch(api.onConnectionState(changed));
|
|
55
|
+
watch(api.onWorkspaceLocationState(changed));
|
|
56
|
+
watch(network.onState(revokeNetwork));
|
|
57
|
+
if (network.getState().phase !== 'online')
|
|
58
|
+
throw failure('EMPLOYEE_ENDPOINT_UNAVAILABLE');
|
|
59
|
+
check();
|
|
60
|
+
const current = await awaitL(() => api.getSshTarget(), signal);
|
|
61
|
+
if (!current.ok)
|
|
62
|
+
throw connectNeedError(current.error);
|
|
63
|
+
target = structuredClone(current.value);
|
|
64
|
+
validateTarget(target);
|
|
65
|
+
check();
|
|
66
|
+
// 保留O1既有的纯静态解析重叠;实际执行与broker仍须等待两道门及静态结果。
|
|
67
|
+
void nativeMetadata().catch(() => { });
|
|
68
|
+
const prepare = () => admitEmployeeLocation({ api: api, network, workspace: { id: context.workspaceId, path: context.directory.path }, connection, expectedLocal: { instanceId: context.instanceId, epoch: context.epoch, workspaceId: context.workspaceId, bindingId: context.bindingId, directory: { ...context.directory } }, settingsPath: target.session.settingsPath, signal });
|
|
69
|
+
location = await awaitL(() => request.startupTiming?.run('endpoint-prepare', prepare) ?? prepare(), signal);
|
|
70
|
+
check();
|
|
71
|
+
})();
|
|
72
|
+
// 登录失败始终优先;端点提前失败也先被观察,不能产生未处理拒绝或抢先改变失败语义。
|
|
73
|
+
void pending.catch(() => { });
|
|
74
|
+
const confirm = (current, ready) => { check(); if (!target || !sameTarget(target, current) || ready.instanceId !== connection.instanceId || ready.epoch !== connection.epoch)
|
|
75
|
+
throw failure('EMPLOYEE_CONTEXT_CHANGED'); };
|
|
76
|
+
return { ready: pending, confirm, cancel, native: nativeMetadata, async location(currentNetwork, currentContext) {
|
|
77
|
+
await pending;
|
|
78
|
+
check();
|
|
79
|
+
if (currentNetwork !== network || !isDeepStrictEqual(currentContext, context))
|
|
80
|
+
throw failure('EMPLOYEE_CONTEXT_CHANGED');
|
|
81
|
+
// 准备完成至登录结束之间仍可能替换物理目录;只重读L的只读context,不再prepare第二次。
|
|
82
|
+
const [current, physical] = await Promise.all([
|
|
83
|
+
awaitL(() => api.getSshTarget(), signal),
|
|
84
|
+
awaitL(() => api.getLocalWorkspaceContext({ instanceId: context.instanceId, epoch: context.epoch, workspaceId: context.workspaceId, expectedBindingId: context.bindingId }), signal),
|
|
85
|
+
]);
|
|
86
|
+
check();
|
|
87
|
+
if (!current.ok)
|
|
88
|
+
throw connectNeedError(current.error);
|
|
89
|
+
if (!physical.ok)
|
|
90
|
+
throw connectNeedError(physical.error);
|
|
91
|
+
if (!target || !sameTarget(target, current.value) || !isDeepStrictEqual(physical.value, context))
|
|
92
|
+
throw failure('EMPLOYEE_CONTEXT_CHANGED');
|
|
93
|
+
return location;
|
|
94
|
+
} };
|
|
95
|
+
}
|
package/dist/index.js
CHANGED
|
@@ -761,6 +761,8 @@ export class CodexRemoteAdapter extends LlmAdapter {
|
|
|
761
761
|
throw withFirstFailureEvidence(error, runtime?.closeDiagnostics?.first?.reason, failureCode);
|
|
762
762
|
}
|
|
763
763
|
finally {
|
|
764
|
+
if (request)
|
|
765
|
+
this.resolveRuntime.releasePreparation?.(request);
|
|
764
766
|
permissionOff?.();
|
|
765
767
|
permissionOff = undefined;
|
|
766
768
|
permissionEpoch.abort();
|
package/dist/provider.d.ts
CHANGED
|
@@ -113,6 +113,7 @@ export interface RuntimeRequest extends Invocation {
|
|
|
113
113
|
}
|
|
114
114
|
export type RuntimeProvider = ((request: RuntimeRequest) => Promise<Runtime>) & {
|
|
115
115
|
preflight?: (request: RuntimeRequest) => Promise<void>;
|
|
116
|
+
releasePreparation?: (request: RuntimeRequest) => void;
|
|
116
117
|
};
|
|
117
118
|
export interface ConnectTarget {
|
|
118
119
|
host: string;
|
package/dist/provider.js
CHANGED
|
@@ -149,6 +149,16 @@ export function connectProvider(get, options = {}) {
|
|
|
149
149
|
// Cache the initialization promise so concurrent sessions share this provider's binding lifetimes.
|
|
150
150
|
let employee;
|
|
151
151
|
const admissions = new WeakMap();
|
|
152
|
+
const preparations = new WeakMap();
|
|
153
|
+
const releasePreparation = (request) => { const owned = preparations.get(request); preparations.delete(request); admissions.delete(request); owned?.restore(); owned?.preparation.cancel(); };
|
|
154
|
+
const ownPreparation = (request, preparation) => {
|
|
155
|
+
const original = request.recordEarlyFailure;
|
|
156
|
+
const wrapped = async (error, stage) => { releasePreparation(request); if (original)
|
|
157
|
+
await original(error, stage); };
|
|
158
|
+
preparations.set(request, { preparation, restore: () => { if (request.recordEarlyFailure === wrapped)
|
|
159
|
+
request.recordEarlyFailure = original; } });
|
|
160
|
+
request.recordEarlyFailure = wrapped;
|
|
161
|
+
};
|
|
152
162
|
const preflight = async (request) => {
|
|
153
163
|
request.signal?.throwIfAborted();
|
|
154
164
|
const api = get();
|
|
@@ -157,6 +167,7 @@ export function connectProvider(get, options = {}) {
|
|
|
157
167
|
requireNativeWorkspace(api);
|
|
158
168
|
requireLoginCoordinator(api);
|
|
159
169
|
let sourceStage = 'input-acceptance';
|
|
170
|
+
let preparation;
|
|
160
171
|
try {
|
|
161
172
|
request.workspaceSource = options.source ? await options.source(request, api) : request.hostSource;
|
|
162
173
|
if (!options.source && !request.workspaceSource && options.workspace && request.sessionId && api.getContractInfo().workspaceLocations === 1) {
|
|
@@ -169,6 +180,12 @@ export function connectProvider(get, options = {}) {
|
|
|
169
180
|
request.localContext = await module.inspectEmployeeWorkspace(get, options.employee, agent, api, request);
|
|
170
181
|
}
|
|
171
182
|
sourceStage = 'login-readiness';
|
|
183
|
+
if (!host && agent.loginProvider === 'codex' && options.employee && request.localContext) {
|
|
184
|
+
const module = await import("./employee-startup.js");
|
|
185
|
+
preparation = module.beginEmployeeStartup(get, options.employee, api, request);
|
|
186
|
+
if (preparation)
|
|
187
|
+
ownPreparation(request, preparation);
|
|
188
|
+
}
|
|
172
189
|
const loginReady = async () => {
|
|
173
190
|
request.localAdmissionCheck?.();
|
|
174
191
|
const before = api.getConnectionState();
|
|
@@ -191,8 +208,13 @@ export function connectProvider(get, options = {}) {
|
|
|
191
208
|
throw connectNeedError(locations.need);
|
|
192
209
|
if (!host)
|
|
193
210
|
await options.local?.admit?.(request, api, connection, target);
|
|
211
|
+
if (preparation) {
|
|
212
|
+
await preparation.ready;
|
|
213
|
+
preparation.confirm(target, connection);
|
|
214
|
+
}
|
|
194
215
|
}
|
|
195
216
|
catch (error) {
|
|
217
|
+
preparation?.cancel();
|
|
196
218
|
admissions.delete(request);
|
|
197
219
|
const record = request.recordEarlyFailure;
|
|
198
220
|
request.recordEarlyFailure = undefined;
|
|
@@ -207,41 +229,51 @@ export function connectProvider(get, options = {}) {
|
|
|
207
229
|
const admitted = admissions.get(request);
|
|
208
230
|
admissions.delete(request);
|
|
209
231
|
const { api, target, connection } = admitted;
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
232
|
+
const owned = preparations.get(request);
|
|
233
|
+
preparations.delete(request);
|
|
234
|
+
owned?.restore();
|
|
235
|
+
const preparation = owned?.preparation;
|
|
236
|
+
try {
|
|
237
|
+
if (!request.sessionId)
|
|
238
|
+
throw new NeedError('PROJECT_BINDING_REQUIRED', '我需要当前会话和已选择的工作区,请使用原生工作区入口', 'DSH会话与原生工作区');
|
|
239
|
+
const host = request.workspaceSource?.source === 'host';
|
|
240
|
+
if (!host && options.employee) {
|
|
241
|
+
employee ??= import("./employee-provider.js").then(module => module.createEmployeeProvider(get, options, agent));
|
|
242
|
+
const local = await (await employee)({ api, target, connection, request, preparation });
|
|
243
|
+
if (local) {
|
|
244
|
+
local.loginRequired = () => offerLogin(api, request, get, agent);
|
|
245
|
+
return local;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
if (!host && agent.loginProvider === 'claude' && options.local) {
|
|
249
|
+
const runtime = await options.local(request, api, connection, target);
|
|
250
|
+
if (runtime)
|
|
251
|
+
return runtime;
|
|
219
252
|
}
|
|
253
|
+
// A local source must have been handled by its employee provider above.
|
|
254
|
+
// Host execution requires an explicit host location; no name-based resolver.
|
|
255
|
+
if (!host)
|
|
256
|
+
throw new NeedError('WORKSPACE_LOCATION_REQUIRED', '请选择文件夹来源;改变来源后请新建会话。', '已选择的本机或主机文件夹');
|
|
257
|
+
const resolved = await resolveHostWorkspace(api, request, agent.loginProvider);
|
|
258
|
+
const project = resolved.project;
|
|
259
|
+
const details = await options.details?.(request, api, connection, target);
|
|
260
|
+
if (!options.open)
|
|
261
|
+
throw new NeedError('RUNTIME_REQUIRED', '我需要主机运行适配器', '主机broker适配');
|
|
262
|
+
const runtime = await options.open(resolved.target, project, { ...request, agent, bindingId: undefined, workspaceId: undefined, bindingRevision: undefined, detailChannel: details });
|
|
263
|
+
runtime.hostSource = Object.freeze({ ...request.workspaceSource });
|
|
264
|
+
runtime.hostWorkspace = Object.freeze({ cwd: project.path });
|
|
265
|
+
// The transport can outlive a turn; presentation belongs only to this invocation.
|
|
266
|
+
runtime.details = details ?? runtime.details;
|
|
267
|
+
runtime.binding = undefined;
|
|
268
|
+
runtime.connection = { ...connection };
|
|
269
|
+
runtime.loginRequired = () => offerLogin(api, request, get, agent);
|
|
270
|
+
return runtime;
|
|
220
271
|
}
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
if (runtime)
|
|
224
|
-
return runtime;
|
|
272
|
+
finally {
|
|
273
|
+
preparation?.cancel();
|
|
225
274
|
}
|
|
226
|
-
// A local source must have been handled by its employee provider above.
|
|
227
|
-
// Host execution requires an explicit host location; no name-based resolver.
|
|
228
|
-
if (!host)
|
|
229
|
-
throw new NeedError('WORKSPACE_LOCATION_REQUIRED', '请选择文件夹来源;改变来源后请新建会话。', '已选择的本机或主机文件夹');
|
|
230
|
-
const resolved = await resolveHostWorkspace(api, request, agent.loginProvider);
|
|
231
|
-
const project = resolved.project;
|
|
232
|
-
const details = await options.details?.(request, api, connection, target);
|
|
233
|
-
if (!options.open)
|
|
234
|
-
throw new NeedError('RUNTIME_REQUIRED', '我需要主机运行适配器', '主机broker适配');
|
|
235
|
-
const runtime = await options.open(resolved.target, project, { ...request, agent, bindingId: undefined, workspaceId: undefined, bindingRevision: undefined, detailChannel: details });
|
|
236
|
-
runtime.hostSource = Object.freeze({ ...request.workspaceSource });
|
|
237
|
-
runtime.hostWorkspace = Object.freeze({ cwd: project.path });
|
|
238
|
-
// The transport can outlive a turn; presentation belongs only to this invocation.
|
|
239
|
-
runtime.details = details ?? runtime.details;
|
|
240
|
-
runtime.binding = undefined;
|
|
241
|
-
runtime.connection = { ...connection };
|
|
242
|
-
runtime.loginRequired = () => offerLogin(api, request, get, agent);
|
|
243
|
-
return runtime;
|
|
244
275
|
};
|
|
245
276
|
resolve.preflight = preflight;
|
|
277
|
+
resolve.releasePreparation = releasePreparation;
|
|
246
278
|
return resolve;
|
|
247
279
|
}
|
|
@@ -8,4 +8,4 @@ export interface BridgeTool {
|
|
|
8
8
|
wire: Tool;
|
|
9
9
|
}
|
|
10
10
|
export declare function dshSkillCatalog(messages?: GenerateOptions['messages']): readonly string[] | undefined;
|
|
11
|
-
export declare function bridgeTable(tools?: readonly ToolSchema[], catalog?: readonly string[]): ReadonlyMap<string, BridgeTool>;
|
|
11
|
+
export declare function bridgeTable(tools?: readonly ToolSchema[], catalog?: readonly string[], catalogInCurrentPrompt?: boolean): ReadonlyMap<string, BridgeTool>;
|
package/dist/toolbridge-table.js
CHANGED
|
@@ -17,7 +17,7 @@ export function dshSkillCatalog(messages = []) {
|
|
|
17
17
|
return source.entries.map(entry => entry.name);
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
|
-
export function bridgeTable(tools = [], catalog) {
|
|
20
|
+
export function bridgeTable(tools = [], catalog, catalogInCurrentPrompt = false) {
|
|
21
21
|
const table = new Map(), names = new Set();
|
|
22
22
|
for (const tool of tools) {
|
|
23
23
|
if (excluded.has(tool.name))
|
|
@@ -29,7 +29,7 @@ export function bridgeTable(tools = [], catalog) {
|
|
|
29
29
|
if (table.has(alias))
|
|
30
30
|
throw new NeedError('TOOLBRIDGE_NAME_COLLISION', '工具桥名称冲突,未执行。', '唯一工具桥名称');
|
|
31
31
|
const schema = structuredClone(tool);
|
|
32
|
-
const skill = schema.name === 'skill' ? ' 这是DSH技能加载器,名字取自DSH的<available_skills>目录;主机Claude/Codex的原生技能按各自原生技能指令加载。' + (catalog === undefined ? '请以当前DSH技能目录为准。' : '本次DSH公布的目录快照:' + JSON.stringify(catalog) + ';实际可用性由DSH调用时确认。') + '技能资源按返回的<skill_resources>基址读取。' : '';
|
|
32
|
+
const skill = schema.name === 'skill' ? ' 这是DSH技能加载器,名字取自DSH的<available_skills>目录;主机Claude/Codex的原生技能按各自原生技能指令加载。' + (catalogInCurrentPrompt ? '实际可用性由DSH调用时确认。' : catalog === undefined ? '请以当前DSH技能目录为准。' : '本次DSH公布的目录快照:' + JSON.stringify(catalog) + ';实际可用性由DSH调用时确认。') + '技能资源按返回的<skill_resources>基址读取。' : '';
|
|
33
33
|
table.set(alias, { alias, schema, wire: { name: alias, description: 'DSH工具 ' + schema.name + ':' + schema.description + skill, inputSchema: structuredClone(schema.parameters) } });
|
|
34
34
|
}
|
|
35
35
|
return table;
|
package/dist/toolbridge.js
CHANGED
|
@@ -16,7 +16,26 @@ export class ToolBridge {
|
|
|
16
16
|
readImage;
|
|
17
17
|
controller = new AbortController();
|
|
18
18
|
snapshot;
|
|
19
|
-
get table() {
|
|
19
|
+
get table() {
|
|
20
|
+
if (this.snapshot)
|
|
21
|
+
return this.snapshot;
|
|
22
|
+
const messages = this.options.messages, catalog = dshSkillCatalog(messages);
|
|
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);
|
|
38
|
+
}
|
|
20
39
|
calls = new Map();
|
|
21
40
|
enabled = false;
|
|
22
41
|
ended = false;
|