@ai-workbench/remote-agent 0.9.0-toolbridge.30 → 0.9.0-toolbridge.32

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 CHANGED
@@ -1,4 +1,4 @@
1
- # AI Workbench 远程助手 · @ai-workbench/remote-agent@0.9.0-toolbridge.30 · 插件 → 添加插件
1
+ # AI Workbench 远程助手 · @ai-workbench/remote-agent@0.9.0-toolbridge.32 · 插件 → 添加插件
2
2
 
3
3
  ## 办公依赖与开工计时(O1,2026-11-15)
4
4
 
@@ -87,4 +87,4 @@ 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.30)更正:Codex aw.15 和 Claude 0.94.0 的 ACP 回执均按本次 prompt 统计,逐轮全额结算一次,不减历史基线;旧累计快照不再参与计算。冷接回只减同一 prompt 已在 DSH 落盘的部分,可靠终态先持久化,原 broker 回收后仍可补记其未落盘用量。订阅额度卡仍读取官方额度窗口,不能由 token 数推算百分比。Claude 的规则传递保持。无新增设置、限制或错误码。
90
+ I3(0.9.0-toolbridge.27):同一 DSH 对话的系统规则更新后,续接原 Codex native 线程并在实际模型请求应用新版规则;需要主机含桥 Codex ACP aw.15。规则未变不重复追加历史;每次恢复仍带当前配置以支持压缩重建。用量说明已由 U1(0.9.0-toolbridge.32)更正:Codex aw.15 和 Claude 0.94.0 的 ACP 回执均按本次 prompt 统计,逐轮全额结算一次,不减历史基线;旧累计快照不再参与计算。冷接回只减同一 prompt 已在 DSH 落盘的部分,可靠终态先持久化,原 broker 回收后仍可补记其未落盘用量。订阅额度卡仍读取官方额度窗口,不能由 token 数推算百分比。Claude 的规则传递保持。无新增设置、限制或错误码。
package/dist/acp.d.ts CHANGED
@@ -77,16 +77,11 @@ export declare class AcpSession {
77
77
  private method?;
78
78
  private ready;
79
79
  private closeRequested;
80
- private updating;
81
- private cwd?;
82
80
  private codexNewSessionOnly;
83
- private creatingReplacement;
84
81
  private employeeMeta?;
85
- private employeeRouting?;
86
82
  private employeeNegotiated;
87
83
  private configuration?;
88
84
  private configRevision;
89
- private selected?;
90
85
  private selecting;
91
86
  private pendingConfigurations;
92
87
  private dispatchedPrompts;
package/dist/acp.js CHANGED
@@ -54,16 +54,11 @@ export class AcpSession {
54
54
  method;
55
55
  ready = false;
56
56
  closeRequested = false;
57
- updating = false;
58
- cwd;
59
57
  codexNewSessionOnly = false;
60
- creatingReplacement = false;
61
58
  employeeMeta;
62
- employeeRouting;
63
59
  employeeNegotiated = false;
64
60
  configuration;
65
61
  configRevision = 0;
66
- selected;
67
62
  selecting = false;
68
63
  pendingConfigurations = new Map();
69
64
  dispatchedPrompts = 0;
@@ -106,7 +101,6 @@ export class AcpSession {
106
101
  }
107
102
  pendingConfiguration(sessionId, options) { const pending = this.pendingConfigurations.get(sessionId) ?? []; pending.push(options); this.pendingConfigurations.set(sessionId, pending); }
108
103
  resetConfiguration(clearRoles = true) {
109
- this.selected = undefined;
110
104
  if (this.configuration) {
111
105
  try {
112
106
  this.configuration.invalidate(clearRoles);
@@ -138,11 +132,10 @@ export class AcpSession {
138
132
  async selectModel(model, effort, signal) {
139
133
  if (!this.ready || !this.sessionId)
140
134
  throw new ModelConfigurationError('远端会话尚未建立');
141
- if (this.busy || this.updating || this.selecting)
135
+ if (this.busy || this.selecting)
142
136
  throw new ModelConfigurationError('上一项会话操作尚未完成');
143
137
  signal?.throwIfAborted();
144
138
  this.selecting = true;
145
- this.selected = { model, ...(effort === undefined ? {} : { effort }) };
146
139
  this.turnSignal = signal;
147
140
  try {
148
141
  if (!this.configuration)
@@ -305,12 +298,6 @@ export class AcpSession {
305
298
  const app = acp.client({ name: '@ai-workbench/remote-agent' })
306
299
  .onNotification(acp.methods.client.session.update, ({ params: incoming }) => {
307
300
  const { notification, sequence } = this.hooks.broker?.stripOutputOrigin(incoming) ?? { notification: incoming, sequence: undefined };
308
- if (this.creatingReplacement) {
309
- if (notification.sessionId !== this.sessionId && notification.update.sessionUpdate === 'config_option_update')
310
- this.pendingConfiguration(notification.sessionId, notification.update.configOptions);
311
- this.detail({ kind: 'session', severity: 'info', code: 'ACP_IDLE_UPDATE', summary: '新会话建立期间的轨迹,未作为正文处理', method: 'session/update', payload: notification });
312
- return;
313
- }
314
301
  if (this.sessionId && notification.sessionId !== this.sessionId) {
315
302
  this.detail({ kind: 'session', severity: 'warning', code: 'ACP_FOREIGN_SESSION_UPDATE', summary: '收到不属于当前远端会话的通知,未作为正文处理', method: 'session/update', payload: notification });
316
303
  return;
@@ -541,7 +528,7 @@ export class AcpSession {
541
528
  throw new NeedError('PROMPT_CONTENT_UNSUPPORTED', `远端未声明此输入内容能力:${block.type};本轮未发送`, '对应内容类型的公开 ACP 输入能力');
542
529
  }
543
530
  setHooks(hooks) {
544
- if (this.busy || this.updating || this.selecting)
531
+ if (this.busy || this.selecting)
545
532
  throw new NeedError('TURN_BUSY', '上一轮或配置更新结束前不能更换会话钩子', '上一轮结束');
546
533
  this.hooks = hooks;
547
534
  this.employeeNoticeNames.clear();
@@ -583,7 +570,6 @@ export class AcpSession {
583
570
  if (prompt)
584
571
  this.validatePrompt(prompt);
585
572
  const routing = context?.employeeRouting ? structuredClone(context.employeeRouting) : undefined;
586
- this.employeeRouting = routing;
587
573
  const claudeCode = routing ? { options: employeeClaudeOptions(routing) } : this.codexNewSessionOnly ? undefined : { options: { settings: claudeSettings() } };
588
574
  const params = { cwd, mcpServers: context?.toolBridgeServers ? structuredClone(context.toolBridgeServers) : routing ? structuredClone(routing.mcpServers) : [], ...((claudeCode || this.employeeMeta || initialModel) ? { _meta: { ...(initialModel ? { awInitialModel: { version: 1, model: initialModel } } : {}), ...(this.employeeMeta ? { awEmployeeExecution: this.employeeMeta } : {}), ...(claudeCode ? { claudeCode } : {}) } } : {}), ...((systemPrompt !== undefined || context?.systemPromptChanged || nativeContext) && !(resumeId && this.codexNewSessionOnly && !context?.systemPromptChanged && !nativeContext) ? { systemPrompt: { mode: 'append', content: [{ type: 'text', text: systemPrompt ?? '' }] } } : {}) };
589
575
  const configRevision = this.resetConfiguration();
@@ -637,7 +623,6 @@ export class AcpSession {
637
623
  this.confirmBridgeStartupFailure();
638
624
  await this.hooks.sessionOwnership?.bind(this.sessionId, signal);
639
625
  this.ready = true;
640
- this.cwd = cwd;
641
626
  return this.sessionId;
642
627
  }
643
628
  catch (error) {
@@ -656,7 +641,7 @@ export class AcpSession {
656
641
  async prompt(input, signal) {
657
642
  if (!this.ready || !this.sessionId)
658
643
  throw new NeedError('SESSION_REQUIRED', '我需要先建立远端会话', 'ACP 会话');
659
- if (this.busy || this.updating || this.selecting)
644
+ if (this.busy || this.selecting)
660
645
  throw new NeedError('TURN_BUSY', '此远端会话正在处理上一轮或更新配置', '上一轮结束');
661
646
  signal?.throwIfAborted();
662
647
  const prompt = typeof input === 'string' ? [{ type: 'text', text: input }] : input;
@@ -115,7 +115,7 @@ export async function* recoverColdProtocol(record, store, prefix, options) {
115
115
  broker = new BrokerTransport({ maxFrameBytes: options.maxFrameBytes, controlMaxBytes: record.controlMaxBytes, leased: true, inputProtocolVersion: 2, messageInput: true, recoverDisconnect: true, instanceId: record.instanceId, initialSequence: record.outputStart, restoreInput: { sequence: record.inputSequence, pending: record.pending }, beforeMessage, afterMessage, attach: (after = 0) => options.io.attach(command(['attach', record.brokerId, '--after', String(after), '--framed', '--leased', '--input-protocol', '2', '--message-input', '--if-instance', record.instanceId, '--cold-round', record.id, '--prompt-id', record.promptId, ...owner])) });
116
116
  const raw = acp.ndJsonStream(broker.writable, broker.readable, { maxMessageBytes: options.maxMessageBytes }), reader = raw.readable.getReader(), writer = raw.writable.getWriter();
117
117
  const mapper = new StreamMapper(), output = new StreamMapper(), trim = new Prefix(prefix);
118
- let terminal = false, replayed = false, delivered = false;
118
+ let replayed = false, delivered = false;
119
119
  const pendingRequests = new Map();
120
120
  let outboundTail = Promise.resolve();
121
121
  const enqueue = (work) => { outboundTail = outboundTail.then(work); void outboundTail.catch(error => broker.fail(error instanceof NeedError ? error : coldNeed())); };
@@ -329,7 +329,6 @@ export async function* recoverColdProtocol(record, store, prefix, options) {
329
329
  throw readFailure;
330
330
  if (options.cancelOnly)
331
331
  return;
332
- terminal = true;
333
332
  await store.update(record.sessionId, record.provider, record.id, row => { row.terminal = { kind: m.error ? 'error' : 'result', value: m.error ?? m.result }; row.phase = 'terminal'; row.terminalAfter = broker.lastSequence; });
334
333
  if (m.error) {
335
334
  trim.finish();
@@ -369,8 +368,7 @@ export async function* recoverColdProtocol(record, store, prefix, options) {
369
368
  return;
370
369
  }
371
370
  }
372
- if (!terminal)
373
- throw coldNeed('CONNECTION_LOST');
371
+ throw coldNeed('CONNECTION_LOST');
374
372
  }
375
373
  finally {
376
374
  options.signal?.removeEventListener('abort', cancel);
@@ -359,12 +359,12 @@ export class ColdRecovery {
359
359
  * step's choice; it neither selects nor advertises capabilities for a new model. */
360
360
  recoveryModel(provider, model, signal) {
361
361
  for (const step of this.steps.values())
362
- if (step.signal === signal && step.row.provider === provider && (step.selection?.model ?? step.row.meta?.model) === model) {
363
- const effort = step.selection?.reasoningEffort;
362
+ if (step.signal === signal && step.row.provider === provider && step.selection.model === model) {
363
+ const effort = step.selection.reasoningEffort;
364
364
  return { provider, id: model, name: '接回原轮结果', ...(effort === undefined ? {} : { reasoning: { efforts: [{ id: ReasoningEffortId(effort), name: effort }] } }) };
365
365
  }
366
366
  }
367
- canRecover(options) { return !options.purpose && [...this.steps].some(([agent, step]) => agent.session.id === options.sessionId && step.row.provider === options.provider && (step.selection?.model ?? step.row.meta?.model) === options.model && step.signal === options.signal && (!step.signal.aborted || step.signal.reason?.kind === 'user') && options.messages.some(m => m.id === step.markerId && recoveryMarker(m) === step.row.id)); }
367
+ canRecover(options) { return !options.purpose && [...this.steps].some(([agent, step]) => agent.session.id === options.sessionId && step.row.provider === options.provider && step.selection.model === options.model && step.signal === options.signal && (!step.signal.aborted || step.signal.reason?.kind === 'user') && options.messages.some(m => m.id === step.markerId && recoveryMarker(m) === step.row.id)); }
368
368
  async connection(signal, binding) {
369
369
  for (;;) {
370
370
  signal?.throwIfAborted();
@@ -42,12 +42,10 @@ export interface ColdRound {
42
42
  revision: number;
43
43
  };
44
44
  hostSource?: unknown;
45
- contextSha256: string; /** 只读旧版字段;不再作为跨轮基线。 */
46
- baseline?: unknown;
45
+ contextSha256: string;
47
46
  modelConfiguration?: unknown;
48
47
  header: unknown;
49
- model: string; /** 只读旧版字段;不再覆盖DSH已冻结的本步配置。 */
50
- callConfig?: import('@deepseek-ai/dsh-llm').LlmCallConfig;
48
+ model: string;
51
49
  prelude?: string;
52
50
  inputDigests?: Record<string, string>;
53
51
  localDirectory?: {
@@ -69,7 +67,6 @@ export interface ColdRound {
69
67
  inputNotDelivered: true;
70
68
  receipt: unknown;
71
69
  };
72
- /** 只读旧版字段;不再参与恢复结算。 */ finalUsage?: unknown;
73
70
  errorDelivery?: {
74
71
  markerId: string;
75
72
  code: string;
package/dist/index.js CHANGED
@@ -360,13 +360,11 @@ export class CodexRemoteAdapter extends LlmAdapter {
360
360
  let session;
361
361
  let live;
362
362
  let succeeded = false;
363
- let remoteAttempted = false;
364
363
  let promptBaseline = 0;
365
364
  let failureCode;
366
365
  let activeMapper;
367
366
  let selected;
368
367
  let modelConfiguration;
369
- let turnFailure;
370
368
  let coldPrelude = '';
371
369
  let employeeNoticeShown = false;
372
370
  let permissionOff;
@@ -376,9 +374,8 @@ export class CodexRemoteAdapter extends LlmAdapter {
376
374
  for (const entry of information.splice(0))
377
375
  runtime.details.record(entry); };
378
376
  const config = this.config();
379
- const mode = 'session';
380
377
  const startupTiming = new StartupTiming(this.preflightDiagnostics ? event => { void this.preflightDiagnostics.record(request, this.agent.loginProvider, event); } : undefined), endStartup = startupTiming.start('startup');
381
- request = { sessionId: options.sessionId, mode: mode ?? 'session', signal, toolBridge: bridge, startupTiming };
378
+ request = { sessionId: options.sessionId, mode: 'session', signal, toolBridge: bridge, startupTiming };
382
379
  const observeAbort = (source, initiator, reason) => { if (!source)
383
380
  return; const record = () => { (request?.closeDiagnostics ?? runtime?.closeDiagnostics)?.record({ layer: 'adapter', initiator, reason, action: 'abort', changes: [{ field: 'adapter.turn-aborted', before: false, after: source.aborted }] }); }; source.addEventListener('abort', record, { once: true }); abortOffs.push(() => source.removeEventListener('abort', record)); };
384
381
  observeAbort(original.signal, 'signal.caller', 'CALLER_ABORTED');
@@ -400,8 +397,7 @@ export class CodexRemoteAdapter extends LlmAdapter {
400
397
  if (employeeNoticeShown && key)
401
398
  this.employeeNoticeSessions.add(key);
402
399
  live = undefined;
403
- const configuration = JSON.stringify([config.acpMaxMessageBytes, config.brokerMaxFrameBytes, config.brokerControlMaxBytes, config.employeeShellKillGraceMs]);
404
- Object.assign(request, { acpMaxMessageBytes: config.acpMaxMessageBytes, resumeSessionId: previous?.sessionId, sessionId: options.sessionId, mode, hostSource: previous?.hostSource, cwd: previous?.cwd, identity: previous?.identity, bindingId: previous?.bindingId, workspaceId: previous?.workspaceId, agent: this.agent, signal, brokerSettings: Object.freeze({ brokerMaxFrameBytes: config.brokerMaxFrameBytes, brokerControlMaxBytes: config.brokerControlMaxBytes }) });
400
+ Object.assign(request, { acpMaxMessageBytes: config.acpMaxMessageBytes, resumeSessionId: previous?.sessionId, sessionId: options.sessionId, mode: 'session', hostSource: previous?.hostSource, cwd: previous?.cwd, identity: previous?.identity, bindingId: previous?.bindingId, workspaceId: previous?.workspaceId, agent: this.agent, signal, brokerSettings: Object.freeze({ brokerMaxFrameBytes: config.brokerMaxFrameBytes, brokerControlMaxBytes: config.brokerControlMaxBytes }) });
405
401
  request.previousContextSha256 = previous?.contextSha256;
406
402
  const after = options.messages.findLastIndex(message => message.role === 'assistant');
407
403
  const tail = options.messages.slice(after + 1);
@@ -453,7 +449,7 @@ export class CodexRemoteAdapter extends LlmAdapter {
453
449
  // New Codex transport scopes are independent of the native context digest.
454
450
  if (contextChanged)
455
451
  request.contextSha256 = undefined;
456
- if (mode === 'session' && Buffer.byteLength(JSON.stringify({ prompt: input.prompt, systemPrompt: input.systemPrompt }), 'utf8') > config.acpMaxMessageBytes)
452
+ if (Buffer.byteLength(JSON.stringify({ prompt: input.prompt, systemPrompt: input.systemPrompt }), 'utf8') > config.acpMaxMessageBytes)
457
453
  throw new NeedError('ACP_MESSAGE_TOO_LARGE', '本轮输入超过已设置的会话消息容量,未截断或发送', '管理员调整acpMaxMessageBytes');
458
454
  selected = this.modelPresentation.find(options.model) ?? { id: options.model, value: options.model, name: options.model, resolvedModel: null, reasoning: { options: [], defaultValue: null, defaultKnown: false }, source: null };
459
455
  let modelSignal = signal;
@@ -473,7 +469,7 @@ export class CodexRemoteAdapter extends LlmAdapter {
473
469
  if (previous && !runtime.hostSource && (previous.identity !== runtime.identity || previous.cwd !== runtime.cwd || previous.bindingId && previous.bindingId !== runtime.binding?.bindingId || previous.workspaceId && previous.workspaceId !== runtime.binding?.workspaceId))
474
470
  throw new NeedError('SESSION_CONTEXT_MISMATCH', '原会话的员工主机或工作区已改变,请新建会话', '原会话的可信目标和工作区');
475
471
  input = await prepareContinuation({ ...options, messages: projected.messages.slice(checkpointIndex + 1) }, input, this.readImage, { maxBytes: config.acpMaxMessageBytes, host: runtime.hostWorkspace });
476
- if (runtime.hostWorkspace && mode === 'session' && Buffer.byteLength(JSON.stringify({ prompt: input.prompt, systemPrompt: input.systemPrompt }), 'utf8') > config.acpMaxMessageBytes)
472
+ if (runtime.hostWorkspace && Buffer.byteLength(JSON.stringify({ prompt: input.prompt, systemPrompt: input.systemPrompt }), 'utf8') > config.acpMaxMessageBytes)
477
473
  throw new NeedError('ACP_MESSAGE_TOO_LARGE', '本轮输入超过已设置的会话消息容量,未截断或发送', '管理员调整acpMaxMessageBytes');
478
474
  const details = runtime.details ?? await createRemoteDetails({ warn: line => console.warn(line) }).open({ sessionId: options.sessionId ?? 'unscoped', provider: this.agent.loginProvider, identity: runtime.identity, connection: runtime.connection });
479
475
  startupTiming.bind(event => details.record(event));
@@ -513,7 +509,7 @@ export class CodexRemoteAdapter extends LlmAdapter {
513
509
  }
514
510
  yield* mapper.flush();
515
511
  }
516
- if (mode === 'session') {
512
+ { // 仅支持ACP会话模式;保留此块的局部变量作用域。
517
513
  if (!runtime.acpTransport)
518
514
  throw new NeedError('DEPENDENCY_REQUIRED', '我需要该员工主机上的ACP通道', 'S提供的ACP命令与aw-session');
519
515
  const queue = [];
@@ -581,7 +577,7 @@ export class CodexRemoteAdapter extends LlmAdapter {
581
577
  }), onDetail: detail => details.record(detail) };
582
578
  const transport = runtime.acpTransport instanceof acp.AgentApp || runtime.acpTransport instanceof unstable.AgentApp ? runtime.acpTransport : acp.ndJsonStream(runtime.acpTransport.writable, runtime.acpTransport.readable, { maxMessageBytes: config.acpMaxMessageBytes });
583
579
  session = new AcpSession(transport, hooks);
584
- live = { session, runtime, configuration, contextSha256, options, acceptingSteer: true, turnId: randomUUID(), steerIds: new Map(), steerTail: Promise.resolve(), maxBytes: config.acpMaxMessageBytes, notice: renderNotice };
580
+ live = { session, runtime, options, acceptingSteer: true, turnId: randomUUID(), steerIds: new Map(), steerTail: Promise.resolve(), maxBytes: config.acpMaxMessageBytes, notice: renderNotice };
585
581
  if (key)
586
582
  this.sessions.set(key, live);
587
583
  promptBaseline = session.promptDispatchCount;
@@ -627,7 +623,6 @@ export class CodexRemoteAdapter extends LlmAdapter {
627
623
  }
628
624
  };
629
625
  const task = (async () => {
630
- remoteAttempted = true;
631
626
  try {
632
627
  await session.start(runtime.execution?.hostCwd ?? runtime.cwd, previous?.sessionId, modelSignal, { systemPrompt: input.systemPrompt, systemPromptChanged: contextChanged, ...(bridgeMcp ? { toolBridgeServers: bridgeMcp.mcpServers } : {}), ...(runtime.execution ? { employeeRouting: runtime.execution.routing } : {}), ...(codex ? { codexNewSessionOnly: true, initialModel: selected.value } : {}), ...(runtime.employeeExecutionMeta ? { employeeExecution: runtime.employeeExecutionMeta } : {}) }, input.prompt);
633
628
  }
@@ -753,7 +748,6 @@ export class CodexRemoteAdapter extends LlmAdapter {
753
748
  onPromptDispatched();
754
749
  if (bridge?.unsettled && !signal.aborted)
755
750
  bridge.abandon('HOST_PROMPT_FAILED');
756
- turnFailure = error;
757
751
  runtime?.closeDiagnostics?.record({ layer: 'adapter', initiator: 'adapter.turn-failure', reason: closeCode(error, signal.aborted ? 'ABORTED' : 'TURN_FAILED'), action: 'failure' });
758
752
  recordInformation();
759
753
  failureCode = error instanceof NeedError || error instanceof ModelConfigurationError ? error.code : error instanceof LlmError ? error.code : 'TURN_PREPARATION_FAILED';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-workbench/remote-agent",
3
- "version": "0.9.0-toolbridge.30",
3
+ "version": "0.9.0-toolbridge.32",
4
4
  "type": "module",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",