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

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.
Files changed (53) hide show
  1. package/README.md +32 -7
  2. package/dist/acp.d.ts +23 -3
  3. package/dist/acp.js +106 -21
  4. package/dist/broker-runtime.d.ts +2 -0
  5. package/dist/broker-runtime.js +60 -3
  6. package/dist/broker.d.ts +56 -1
  7. package/dist/broker.js +310 -11
  8. package/dist/claude-local.js +26 -5
  9. package/dist/client.js +1 -1
  10. package/dist/close-diagnostics.d.ts +1 -1
  11. package/dist/close-diagnostics.js +1 -1
  12. package/dist/cold-protocol.d.ts +17 -0
  13. package/dist/cold-protocol.js +399 -0
  14. package/dist/cold-recovery.d.ts +62 -0
  15. package/dist/cold-recovery.js +595 -0
  16. package/dist/cold-store.d.ts +99 -0
  17. package/dist/cold-store.js +29 -0
  18. package/dist/conversation-details.js +21 -8
  19. package/dist/employee-endpoint.js +15 -1
  20. package/dist/employee-mcp.js +1 -1
  21. package/dist/employee-native.js +7 -1
  22. package/dist/employee-provider.js +46 -11
  23. package/dist/employee-relay.js +148 -1
  24. package/dist/employee-shell.d.ts +2 -0
  25. package/dist/employee-shell.js +22 -19
  26. package/dist/employee-tools.js +2 -2
  27. package/dist/employee-workspace.d.ts +20 -4
  28. package/dist/employee-workspace.js +26 -5
  29. package/dist/index.d.ts +12 -3
  30. package/dist/index.js +221 -51
  31. package/dist/input.js +4 -1
  32. package/dist/live-steering.d.ts +46 -0
  33. package/dist/live-steering.js +45 -0
  34. package/dist/mapping.d.ts +4 -24
  35. package/dist/mapping.js +11 -65
  36. package/dist/model-catalog.d.ts +2 -0
  37. package/dist/model-catalog.js +5 -1
  38. package/dist/preflight-diagnostic.js +1 -1
  39. package/dist/presentation.js +1 -0
  40. package/dist/provider.d.ts +15 -0
  41. package/dist/provider.js +3 -2
  42. package/dist/rpc-namespace.js +16 -2
  43. package/dist/session-source.d.ts +3 -1
  44. package/dist/session-source.js +2 -1
  45. package/dist/startup-timing.d.ts +14 -0
  46. package/dist/startup-timing.js +34 -0
  47. package/dist/toolbridge-loop.d.ts +3 -2
  48. package/dist/toolbridge-loop.js +4 -2
  49. package/dist/toolbridge-table.d.ts +4 -3
  50. package/dist/toolbridge-table.js +14 -5
  51. package/dist/toolbridge.d.ts +1 -1
  52. package/dist/toolbridge.js +4 -4
  53. package/package.json +23 -16
@@ -94,7 +94,7 @@ export function createEmployeeTools(options) {
94
94
  throw failure('EMPLOYEE_OUTPUT_TOO_LARGE'); };
95
95
  async function run(command, args, signal, detail, timeout) {
96
96
  signal.throwIfAborted();
97
- const diagnostics = options.closeDiagnostics?.child(detail);
97
+ const diagnostics = options.closeDiagnostics?.child(detail, true);
98
98
  const operation = new Promise((yes, no) => {
99
99
  const child = spawn(command, args, { cwd: options.cwd, env: process.env, stdio: ['pipe', 'pipe', 'pipe'] });
100
100
  child.stdin.end();
@@ -118,7 +118,7 @@ export function createEmployeeTools(options) {
118
118
  } if (signal.aborted)
119
119
  aborted(); });
120
120
  child.on('error', e => { diagnostics?.record({ layer: 'executor', initiator: 'tools.process-error', reason: e.code === 'ENOENT' ? 'EMPLOYEE_COMMAND_UNAVAILABLE' : 'EMPLOYEE_PROCESS_FAILED', action: 'failure' }); failed ??= failure(e.code === 'ENOENT' ? 'EMPLOYEE_COMMAND_UNAVAILABLE' : 'EMPLOYEE_PROCESS_FAILED'); });
121
- child.on('close', (exitCode, exitSignal) => { diagnostics?.record({ layer: 'executor', initiator: 'tools.process-close', reason: failed?.code ?? 'PROCESS_EXIT', action: 'exit', exitCode, signal: exitSignal }); signal.removeEventListener('abort', aborted); if (killTimer)
121
+ child.on('close', (exitCode, exitSignal) => { diagnostics?.record({ layer: 'executor', initiator: 'tools.process-close', reason: failed?.code ?? 'PROCESS_EXIT', ...!failed && !exitSignal && exitCode !== null ? { operation: 'completed' } : {}, action: 'exit', exitCode, signal: exitSignal }); signal.removeEventListener('abort', aborted); if (killTimer)
122
122
  clearTimeout(killTimer); if (timeoutTimer)
123
123
  clearTimeout(timeoutTimer); failed ? no(failed) : yes({ stdout: Buffer.concat(stdout).toString('utf8'), stderr: Buffer.concat(stderr).toString('utf8'), exitCode, signal: exitSignal }); });
124
124
  signal.addEventListener('abort', aborted, { once: true });
@@ -4,6 +4,25 @@ interface Services {
4
4
  get(name: string): unknown;
5
5
  inject: Context['inject'];
6
6
  }
7
+ interface LiveSessions {
8
+ get(id: string): {
9
+ header: {
10
+ id: string;
11
+ cwd?: string;
12
+ parentSession?: string;
13
+ };
14
+ } | undefined;
15
+ }
16
+ /**
17
+ * DSH subagent/workflow child sessions are never workspaceRegistry members; they work in the
18
+ * workspace of their nearest registered ancestor along the live parentSession chain. The
19
+ * child's own header.cwd still has to equal that workspace path at each caller.
20
+ */
21
+ export declare function registeredSessionId(sessionId: string, registry: {
22
+ list(): readonly {
23
+ sessionIds: readonly string[];
24
+ }[];
25
+ }, sessions: LiveSessions | undefined): string;
7
26
  /** Session headers do not have workspaceId. Resolve only the official registry relationship. */
8
27
  export declare function readEmployeeWorkspace(ctx: Services, sessionId: string): Promise<EmployeeWorkspace>;
9
28
  interface RegisteredWorkspace {
@@ -16,10 +35,7 @@ interface OfficialRegistry {
16
35
  get(id: string): RegisteredWorkspace | undefined;
17
36
  }
18
37
  /** Same official membership/header boundary as L. No basename or first-workspace inference. */
19
- export declare function officialEmployeeWorkspace(sessionId: string, registry: OfficialRegistry | undefined, header: {
20
- id: string;
21
- cwd?: string;
22
- } | undefined): {
38
+ export declare function officialEmployeeWorkspace(sessionId: string, registry: OfficialRegistry | undefined, sessions: LiveSessions | undefined): {
23
39
  id: string;
24
40
  path: string;
25
41
  };
@@ -1,6 +1,24 @@
1
1
  import { lstat, realpath } from 'node:fs/promises';
2
2
  import { isAbsolute } from 'node:path';
3
3
  import { NeedError } from "./remote.js";
4
+ /**
5
+ * DSH subagent/workflow child sessions are never workspaceRegistry members; they work in the
6
+ * workspace of their nearest registered ancestor along the live parentSession chain. The
7
+ * child's own header.cwd still has to equal that workspace path at each caller.
8
+ */
9
+ export function registeredSessionId(sessionId, registry, sessions) {
10
+ const member = (id) => registry.list().some(row => Array.isArray(row.sessionIds) && row.sessionIds.includes(id));
11
+ const seen = new Set();
12
+ let id = sessionId;
13
+ while (!member(id)) {
14
+ seen.add(id);
15
+ const parent = sessions?.get(id)?.header.parentSession;
16
+ if (!parent || seen.has(parent) || !sessions?.get(parent))
17
+ return sessionId;
18
+ id = parent;
19
+ }
20
+ return id;
21
+ }
4
22
  const invalid = () => new NeedError('EMPLOYEE_WORKSPACE_INVALID', '无法核对当前会话的本机文件夹,本轮未执行。', '官方工作区唯一会话关系与当前原生cwd');
5
23
  /** Session headers do not have workspaceId. Resolve only the official registry relationship. */
6
24
  export async function readEmployeeWorkspace(ctx, sessionId) {
@@ -32,11 +50,12 @@ async function readWorkspace(ctx, sessionId, fence) {
32
50
  // Service proxies are caller-scoped; injection owns the lifecycle fence.
33
51
  if (!currentRegistry || ctx.get('sessions')?.get(sessionId) !== live)
34
52
  throw invalid();
35
- const matches = currentRegistry.list().filter(row => Array.isArray(row.sessionIds) && row.sessionIds.includes(sessionId));
53
+ const member = registeredSessionId(sessionId, currentRegistry, sessions);
54
+ const matches = currentRegistry.list().filter(row => Array.isArray(row.sessionIds) && row.sessionIds.includes(member));
36
55
  if (matches.length !== 1)
37
56
  throw invalid();
38
57
  const row = matches[0], entry = currentRegistry.get(row.id), header = sessions.get(sessionId)?.header;
39
- if (!entry || row.id !== entry.id || row.path !== entry.path || !entry.sessionIds.includes(sessionId) || !isAbsolute(row.path) || !header || header.id !== sessionId || !isAbsolute(header.cwd))
58
+ if (!entry || row.id !== entry.id || row.path !== entry.path || !entry.sessionIds.includes(member) || !isAbsolute(row.path) || !header || header.id !== sessionId || !isAbsolute(header.cwd))
40
59
  throw invalid();
41
60
  return { workspaceId: row.id, path: row.path, cwd: header.cwd };
42
61
  };
@@ -47,15 +66,17 @@ async function readWorkspace(ctx, sessionId, fence) {
47
66
  return { workspaceId: first.workspaceId, directory: { path, device: info.dev, inode: info.ino } };
48
67
  }
49
68
  /** Same official membership/header boundary as L. No basename or first-workspace inference. */
50
- export function officialEmployeeWorkspace(sessionId, registry, header) {
69
+ export function officialEmployeeWorkspace(sessionId, registry, sessions) {
51
70
  const fail = () => new NeedError('EMPLOYEE_WORKSPACE_UNAVAILABLE', '无法确认这次会话的本机工作区,本轮没有执行;请从原生工作区打开会话。', '官方workspaceRegistry成员关系与会话header.cwd');
71
+ const header = sessionId ? sessions?.get(sessionId)?.header : undefined;
52
72
  if (!sessionId || !registry || !header || header.id !== sessionId || typeof header.cwd !== 'string')
53
73
  throw fail();
54
- const matches = registry.list().filter(w => Array.isArray(w.sessionIds) && w.sessionIds.includes(sessionId));
74
+ const member = registeredSessionId(sessionId, registry, sessions);
75
+ const matches = registry.list().filter(w => Array.isArray(w.sessionIds) && w.sessionIds.includes(member));
55
76
  if (matches.length !== 1)
56
77
  throw fail();
57
78
  const item = matches[0], current = registry.get(item.id);
58
- if (!current || current.id !== item.id || current.path !== item.path || !current.sessionIds.includes(sessionId) || !item.path.startsWith('/') || item.path.includes('\0') || header.cwd !== item.path)
79
+ if (!current || current.id !== item.id || current.path !== item.path || !current.sessionIds.includes(member) || !item.path.startsWith('/') || item.path.includes('\0') || header.cwd !== item.path)
59
80
  throw fail();
60
81
  return { id: item.id, path: item.path };
61
82
  }
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import { ColdRecovery } from './cold-recovery.ts';
2
+ import { type SteeringReceipts } from './live-steering.ts';
1
3
  import type { Context } from '@deepseek-ai/cordis';
2
4
  import Schema from '@deepseek-ai/schemastery';
3
5
  import { LlmAdapter, type GenerateOptions, type StreamChunk, type LlmResolvedModelInfo } from '@deepseek-ai/dsh-llm';
@@ -15,7 +17,7 @@ export declare const settingsNamespace = "ai-workbench-codex";
15
17
  export declare const inject: string[];
16
18
  /** Owner-approved defaults; administrators may override through the existing settings. */
17
19
  export declare const DEFAULT_CONFIG: Readonly<{
18
- readonly acpMaxMessageBytes: 4194304;
20
+ readonly acpMaxMessageBytes: 512000000;
19
21
  readonly brokerMaxFrameBytes: 2097152;
20
22
  readonly brokerControlMaxBytes: 1048576;
21
23
  readonly employeeShellKillGraceMs: 1000;
@@ -57,9 +59,12 @@ export declare class CodexRemoteAdapter extends LlmAdapter {
57
59
  private readonly directory?;
58
60
  private readonly preflightDiagnostics?;
59
61
  private readonly permissions?;
62
+ private readonly steeringReceipts?;
63
+ private readonly coldRecovery?;
60
64
  private bridgeLoop;
61
65
  private config;
62
66
  private sessions;
67
+ private injectedInputs;
63
68
  private turns;
64
69
  private lifetime;
65
70
  private shuttingDown;
@@ -67,11 +72,13 @@ export declare class CodexRemoteAdapter extends LlmAdapter {
67
72
  private modelPresentation;
68
73
  private employeeNoticeSessions;
69
74
  private pendingEmployeeNotices;
70
- constructor(config: PluginConfig | (() => PluginConfig), resolveRuntime: RuntimeProvider, approve?: InvocationApproval | undefined, providerName?: () => string, agent?: AgentDefinition, readImage?: ImageReader | undefined, reportLoginFailure?: LoginFailureReporter | undefined, directory?: ModelDirectory | undefined, preflightDiagnostics?: PreflightDiagnostics | undefined, permissions?: PermissionSource | undefined, bridgeStopped?: (sessionId: string, notice: string) => void);
75
+ constructor(config: PluginConfig | (() => PluginConfig), resolveRuntime: RuntimeProvider, approve?: InvocationApproval | undefined, providerName?: () => string, agent?: AgentDefinition, readImage?: ImageReader | undefined, reportLoginFailure?: LoginFailureReporter | undefined, directory?: ModelDirectory | undefined, preflightDiagnostics?: PreflightDiagnostics | undefined, permissions?: PermissionSource | undefined, bridgeStopped?: (sessionId: string, notice: string) => void, steeringReceipts?: SteeringReceipts | undefined, coldRecovery?: ColdRecovery | undefined);
71
76
  providerInfo(provider: string): {
72
77
  id: string;
73
78
  name: string;
74
79
  };
80
+ canSteer(sessionId: string): boolean;
81
+ steer(sessionId: string, message: import('@deepseek-ai/dsh-llm').UserMessage, isCurrent?: () => boolean): Promise<void>;
75
82
  private catalog;
76
83
  listModels(provider: string): Promise<(LlmResolvedModelInfo & {
77
84
  catalog: HostModel;
@@ -101,7 +108,7 @@ export declare class CodexRemoteAdapter extends LlmAdapter {
101
108
  /** One official registration owns both routes, preserving opaque replay ownership. */
102
109
  export declare class RemoteAgentsAdapter extends LlmAdapter {
103
110
  private adapters;
104
- constructor(config: () => PluginConfig, makeRuntime: (agent: AgentDefinition) => RuntimeProvider, approve: InvocationApproval, nameFor: (agent: AgentDefinition) => string, readImage?: ImageReader, reportLoginFailure?: LoginFailureReporter, directory?: ModelDirectory, preflightDiagnostics?: PreflightDiagnostics, permissions?: PermissionSource, bridgeStopped?: (sessionId: string, notice: string) => void);
111
+ constructor(config: () => PluginConfig, makeRuntime: (agent: AgentDefinition) => RuntimeProvider, approve: InvocationApproval, nameFor: (agent: AgentDefinition) => string, readImage?: ImageReader, reportLoginFailure?: LoginFailureReporter, directory?: ModelDirectory, preflightDiagnostics?: PreflightDiagnostics, permissions?: PermissionSource, bridgeStopped?: (sessionId: string, notice: string) => void, steeringReceipts?: SteeringReceipts, coldRecovery?: ColdRecovery);
105
112
  private adapter;
106
113
  providerInfo(provider: string): {
107
114
  id: string;
@@ -124,6 +131,8 @@ export declare class RemoteAgentsAdapter extends LlmAdapter {
124
131
  jitterRatio: number;
125
132
  };
126
133
  stream(options: GenerateOptions): AsyncGenerator<StreamChunk, any, any>;
134
+ canSteer(provider: string, sessionId: string): boolean;
135
+ steer(provider: string, sessionId: string, message: import('@deepseek-ai/dsh-llm').UserMessage, isCurrent?: () => boolean): Promise<void>;
127
136
  completeDshTurn(sessionId: string, messages: GenerateOptions['messages']): Promise<void>;
128
137
  disposeSession(sessionId: string): Promise<void>;
129
138
  detachSession(sessionId: string): Promise<void>;