@dexto/agent-management 1.6.0 → 1.6.1

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 (46) hide show
  1. package/dist/config/config-enrichment.cjs +8 -3
  2. package/dist/config/config-enrichment.d.ts +6 -0
  3. package/dist/config/config-enrichment.d.ts.map +1 -1
  4. package/dist/config/config-enrichment.js +8 -3
  5. package/dist/preferences/loader.cjs +21 -6
  6. package/dist/preferences/loader.d.ts +4 -0
  7. package/dist/preferences/loader.d.ts.map +1 -1
  8. package/dist/preferences/loader.js +21 -6
  9. package/dist/preferences/schemas.cjs +5 -1
  10. package/dist/preferences/schemas.d.ts +32 -0
  11. package/dist/preferences/schemas.d.ts.map +1 -1
  12. package/dist/preferences/schemas.js +5 -1
  13. package/dist/registry/types.cjs +4 -0
  14. package/dist/registry/types.d.ts +8 -0
  15. package/dist/registry/types.d.ts.map +1 -1
  16. package/dist/registry/types.js +4 -0
  17. package/dist/runtime/AgentRuntime.cjs +23 -15
  18. package/dist/runtime/AgentRuntime.d.ts.map +1 -1
  19. package/dist/runtime/AgentRuntime.js +23 -15
  20. package/dist/runtime/approval-delegation.cjs +6 -3
  21. package/dist/runtime/approval-delegation.d.ts +2 -1
  22. package/dist/runtime/approval-delegation.d.ts.map +1 -1
  23. package/dist/runtime/approval-delegation.js +6 -3
  24. package/dist/runtime/schemas.cjs +1 -1
  25. package/dist/runtime/schemas.js +1 -1
  26. package/dist/runtime/types.d.ts +1 -1
  27. package/dist/runtime/types.d.ts.map +1 -1
  28. package/dist/tool-factories/agent-spawner/factory.cjs +63 -26
  29. package/dist/tool-factories/agent-spawner/factory.d.ts.map +1 -1
  30. package/dist/tool-factories/agent-spawner/factory.js +61 -24
  31. package/dist/tool-factories/agent-spawner/runtime.cjs +118 -14
  32. package/dist/tool-factories/agent-spawner/runtime.d.ts +5 -0
  33. package/dist/tool-factories/agent-spawner/runtime.d.ts.map +1 -1
  34. package/dist/tool-factories/agent-spawner/runtime.js +119 -15
  35. package/dist/tool-factories/agent-spawner/schemas.cjs +2 -2
  36. package/dist/tool-factories/agent-spawner/schemas.d.ts +1 -1
  37. package/dist/tool-factories/agent-spawner/schemas.d.ts.map +1 -1
  38. package/dist/tool-factories/agent-spawner/schemas.js +2 -2
  39. package/dist/tool-factories/agent-spawner/spawn-agent-tool.cjs +10 -1
  40. package/dist/tool-factories/agent-spawner/spawn-agent-tool.d.ts.map +1 -1
  41. package/dist/tool-factories/agent-spawner/spawn-agent-tool.js +10 -1
  42. package/dist/utils/path.cjs +10 -1
  43. package/dist/utils/path.d.ts +5 -2
  44. package/dist/utils/path.d.ts.map +1 -1
  45. package/dist/utils/path.js +10 -1
  46. package/package.json +6 -6
@@ -78,7 +78,7 @@ export interface TaskResult {
78
78
  export interface AgentRuntimeConfig {
79
79
  /** Maximum total agents managed by this runtime (default: 20) */
80
80
  maxAgents?: number;
81
- /** Default task timeout in milliseconds (default: 300000 = 5 min) */
81
+ /** Default task timeout in milliseconds (default: 300000 = 5 min, 0 = no timeout) */
82
82
  defaultTaskTimeout?: number;
83
83
  }
84
84
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/runtime/types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,0DAA0D;IAC1D,WAAW,EAAE,WAAW,CAAC;IAEzB,8EAA8E;IAC9E,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB,gEAAgE;IAChE,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB,6EAA6E;IAC7E,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,8DAA8D;IAC9D,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IA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AAS,EAAE,IAAI,CAAC;IAEhB,8CAA8C;IAC9C,SAAS,EAAE,MAAM,CAAC;IAElB,uEAAuE;IACvE,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,wBAAwB;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAEnC,kDAAkD;IAClD,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACvB,8CAA8C;IAC9C,OAAO,EAAE,OAAO,CAAC;IAEjB,oCAAoC;IACpC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,uCAAuC;IACvC,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,6CAA6C;IAC7C,OAAO,EAAE,MAAM,CAAC;IAEhB,+BAA+B;IAC/B,UAAU,CAAC,EAAE;QACT,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,KAAK,EAAE,MAAM,CAAC;KACjB,CAAC;CACL;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAC/B,iEAAiE;IACjE,SAAS,CAAC,EAAE,MAAM,CAAC;IAEnB,qFAAqF;IACrF,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IACxB,sBAAsB;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IAEf,uBAAuB;IACvB,MAAM,CAAC,EAAE,WAAW,GAAG,WAAW,EAAE,CAAC;IAErC,+BAA+B;IAC/B,SAAS,CAAC,EAAE,OAAO,CAAC;CACvB"}
@@ -22,16 +22,17 @@ __export(factory_exports, {
22
22
  });
23
23
  module.exports = __toCommonJS(factory_exports);
24
24
  var import_core = require("@dexto/core");
25
+ var import_core2 = require("@dexto/core");
25
26
  var import_orchestration = require("@dexto/orchestration");
26
27
  var import_schemas = require("./schemas.js");
27
28
  var import_runtime = require("./runtime.js");
28
29
  var import_spawn_agent_tool = require("./spawn-agent-tool.js");
29
30
  function requireAgentContext(context) {
30
31
  if (!context.agent) {
31
- throw import_core.ToolError.configInvalid("agent-spawner tools require ToolExecutionContext.agent");
32
+ throw import_core2.ToolError.configInvalid("agent-spawner tools require ToolExecutionContext.agent");
32
33
  }
33
34
  if (!context.services) {
34
- throw import_core.ToolError.configInvalid("agent-spawner tools require ToolExecutionContext.services");
35
+ throw import_core2.ToolError.configInvalid("agent-spawner tools require ToolExecutionContext.services");
35
36
  }
36
37
  return { agent: context.agent, logger: context.logger, toolServices: context.services };
37
38
  }
@@ -227,58 +228,94 @@ const agentSpawnerToolsFactory = {
227
228
  return [
228
229
  {
229
230
  id: "spawn_agent",
230
- displayName: "Agent",
231
231
  description: "Spawn a sub-agent to handle a task and return its result.",
232
232
  inputSchema: import_schemas.SpawnAgentInputSchema,
233
233
  execute: (input, context) => ensureToolsInitialized(context).spawnAgent.execute(input, context),
234
- generatePreview: async (input, context) => {
235
- const tool = ensureToolsInitialized(context).spawnAgent;
236
- if (!tool.generatePreview) {
237
- return null;
234
+ presentation: {
235
+ describeHeader: (input) => {
236
+ const agentId = typeof input.agentId === "string" ? input.agentId : void 0;
237
+ const agentLabel = agentId ? agentId.replace(/-agent$/, "") : void 0;
238
+ const title = agentLabel ? agentLabel.charAt(0).toUpperCase() + agentLabel.slice(1) : "Agent";
239
+ const task = typeof input.task === "string" ? input.task : "";
240
+ const argsText = task ? (0, import_core.truncateForHeader)(task, 120) : void 0;
241
+ return (0, import_core.createLocalToolCallHeader)({
242
+ title,
243
+ ...argsText ? { argsText } : {}
244
+ });
245
+ },
246
+ preview: async (input, context) => {
247
+ const tool = ensureToolsInitialized(context).spawnAgent;
248
+ const previewFn = tool.presentation?.preview;
249
+ if (!previewFn) {
250
+ return null;
251
+ }
252
+ return await previewFn(input, context);
238
253
  }
239
- return await tool.generatePreview(input, context);
240
254
  }
241
255
  },
242
256
  {
243
257
  id: "wait_for",
244
- displayName: "Wait",
245
258
  description: "Wait for background task(s) to complete.",
246
259
  inputSchema: import_orchestration.WaitForInputSchema,
247
260
  execute: (input, context) => ensureToolsInitialized(context).waitFor.execute(input, context),
248
- generatePreview: async (input, context) => {
249
- const tool = ensureToolsInitialized(context).waitFor;
250
- if (!tool.generatePreview) {
251
- return null;
261
+ presentation: {
262
+ describeHeader: (input) => {
263
+ const argsText = input.taskId ? (0, import_core.truncateForHeader)(input.taskId, 80) : input.taskIds && input.taskIds.length > 0 ? (0, import_core.truncateForHeader)(`${input.taskIds.length} tasks`, 80) : void 0;
264
+ return (0, import_core.createLocalToolCallHeader)({
265
+ title: "Wait",
266
+ ...argsText ? { argsText } : {}
267
+ });
268
+ },
269
+ preview: async (input, context) => {
270
+ const tool = ensureToolsInitialized(context).waitFor;
271
+ const previewFn = tool.presentation?.preview;
272
+ if (!previewFn) {
273
+ return null;
274
+ }
275
+ return await previewFn(input, context);
252
276
  }
253
- return await tool.generatePreview(input, context);
254
277
  }
255
278
  },
256
279
  {
257
280
  id: "check_task",
258
- displayName: "Check Task",
259
281
  description: "Check the status of a background task.",
260
282
  inputSchema: import_orchestration.CheckTaskInputSchema,
261
283
  execute: (input, context) => ensureToolsInitialized(context).checkTask.execute(input, context),
262
- generatePreview: async (input, context) => {
263
- const tool = ensureToolsInitialized(context).checkTask;
264
- if (!tool.generatePreview) {
265
- return null;
284
+ presentation: {
285
+ describeHeader: (input) => {
286
+ const argsText = (0, import_core.truncateForHeader)(input.taskId, 80);
287
+ return (0, import_core.createLocalToolCallHeader)({
288
+ title: "Check Task",
289
+ ...argsText ? { argsText } : {}
290
+ });
291
+ },
292
+ preview: async (input, context) => {
293
+ const tool = ensureToolsInitialized(context).checkTask;
294
+ const previewFn = tool.presentation?.preview;
295
+ if (!previewFn) {
296
+ return null;
297
+ }
298
+ return await previewFn(input, context);
266
299
  }
267
- return await tool.generatePreview(input, context);
268
300
  }
269
301
  },
270
302
  {
271
303
  id: "list_tasks",
272
- displayName: "List Tasks",
273
304
  description: "List background tasks and their statuses.",
274
305
  inputSchema: import_orchestration.ListTasksInputSchema,
275
306
  execute: (input, context) => ensureToolsInitialized(context).listTasks.execute(input, context),
276
- generatePreview: async (input, context) => {
277
- const tool = ensureToolsInitialized(context).listTasks;
278
- if (!tool.generatePreview) {
279
- return null;
307
+ presentation: {
308
+ describeHeader: () => (0, import_core.createLocalToolCallHeader)({
309
+ title: "List Tasks"
310
+ }),
311
+ preview: async (input, context) => {
312
+ const tool = ensureToolsInitialized(context).listTasks;
313
+ const previewFn = tool.presentation?.preview;
314
+ if (!previewFn) {
315
+ return null;
316
+ }
317
+ return await previewFn(input, context);
280
318
  }
281
- return await tool.generatePreview(input, context);
282
319
  }
283
320
  }
284
321
  ];
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/tool-factories/agent-spawner/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAevD,OAAO,EAGH,KAAK,kBAAkB,EAC1B,MAAM,cAAc,CAAC;AAkCtB,eAAO,MAAM,wBAAwB,EAAE,WAAW,CAAC,kBAAkB,CA8SpE,CAAC"}
1
+ {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../../src/tool-factories/agent-spawner/factory.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAiBvD,OAAO,EAGH,KAAK,kBAAkB,EAC1B,MAAM,cAAc,CAAC;AAqCtB,eAAO,MAAM,wBAAwB,EAAE,WAAW,CAAC,kBAAkB,CA8VpE,CAAC"}
@@ -1,3 +1,4 @@
1
+ import { createLocalToolCallHeader, truncateForHeader } from "@dexto/core";
1
2
  import { ToolError } from "@dexto/core";
2
3
  import {
3
4
  ConditionEngine,
@@ -217,58 +218,94 @@ const agentSpawnerToolsFactory = {
217
218
  return [
218
219
  {
219
220
  id: "spawn_agent",
220
- displayName: "Agent",
221
221
  description: "Spawn a sub-agent to handle a task and return its result.",
222
222
  inputSchema: SpawnAgentInputSchema,
223
223
  execute: (input, context) => ensureToolsInitialized(context).spawnAgent.execute(input, context),
224
- generatePreview: async (input, context) => {
225
- const tool = ensureToolsInitialized(context).spawnAgent;
226
- if (!tool.generatePreview) {
227
- return null;
224
+ presentation: {
225
+ describeHeader: (input) => {
226
+ const agentId = typeof input.agentId === "string" ? input.agentId : void 0;
227
+ const agentLabel = agentId ? agentId.replace(/-agent$/, "") : void 0;
228
+ const title = agentLabel ? agentLabel.charAt(0).toUpperCase() + agentLabel.slice(1) : "Agent";
229
+ const task = typeof input.task === "string" ? input.task : "";
230
+ const argsText = task ? truncateForHeader(task, 120) : void 0;
231
+ return createLocalToolCallHeader({
232
+ title,
233
+ ...argsText ? { argsText } : {}
234
+ });
235
+ },
236
+ preview: async (input, context) => {
237
+ const tool = ensureToolsInitialized(context).spawnAgent;
238
+ const previewFn = tool.presentation?.preview;
239
+ if (!previewFn) {
240
+ return null;
241
+ }
242
+ return await previewFn(input, context);
228
243
  }
229
- return await tool.generatePreview(input, context);
230
244
  }
231
245
  },
232
246
  {
233
247
  id: "wait_for",
234
- displayName: "Wait",
235
248
  description: "Wait for background task(s) to complete.",
236
249
  inputSchema: WaitForInputSchema,
237
250
  execute: (input, context) => ensureToolsInitialized(context).waitFor.execute(input, context),
238
- generatePreview: async (input, context) => {
239
- const tool = ensureToolsInitialized(context).waitFor;
240
- if (!tool.generatePreview) {
241
- return null;
251
+ presentation: {
252
+ describeHeader: (input) => {
253
+ const argsText = input.taskId ? truncateForHeader(input.taskId, 80) : input.taskIds && input.taskIds.length > 0 ? truncateForHeader(`${input.taskIds.length} tasks`, 80) : void 0;
254
+ return createLocalToolCallHeader({
255
+ title: "Wait",
256
+ ...argsText ? { argsText } : {}
257
+ });
258
+ },
259
+ preview: async (input, context) => {
260
+ const tool = ensureToolsInitialized(context).waitFor;
261
+ const previewFn = tool.presentation?.preview;
262
+ if (!previewFn) {
263
+ return null;
264
+ }
265
+ return await previewFn(input, context);
242
266
  }
243
- return await tool.generatePreview(input, context);
244
267
  }
245
268
  },
246
269
  {
247
270
  id: "check_task",
248
- displayName: "Check Task",
249
271
  description: "Check the status of a background task.",
250
272
  inputSchema: CheckTaskInputSchema,
251
273
  execute: (input, context) => ensureToolsInitialized(context).checkTask.execute(input, context),
252
- generatePreview: async (input, context) => {
253
- const tool = ensureToolsInitialized(context).checkTask;
254
- if (!tool.generatePreview) {
255
- return null;
274
+ presentation: {
275
+ describeHeader: (input) => {
276
+ const argsText = truncateForHeader(input.taskId, 80);
277
+ return createLocalToolCallHeader({
278
+ title: "Check Task",
279
+ ...argsText ? { argsText } : {}
280
+ });
281
+ },
282
+ preview: async (input, context) => {
283
+ const tool = ensureToolsInitialized(context).checkTask;
284
+ const previewFn = tool.presentation?.preview;
285
+ if (!previewFn) {
286
+ return null;
287
+ }
288
+ return await previewFn(input, context);
256
289
  }
257
- return await tool.generatePreview(input, context);
258
290
  }
259
291
  },
260
292
  {
261
293
  id: "list_tasks",
262
- displayName: "List Tasks",
263
294
  description: "List background tasks and their statuses.",
264
295
  inputSchema: ListTasksInputSchema,
265
296
  execute: (input, context) => ensureToolsInitialized(context).listTasks.execute(input, context),
266
- generatePreview: async (input, context) => {
267
- const tool = ensureToolsInitialized(context).listTasks;
268
- if (!tool.generatePreview) {
269
- return null;
297
+ presentation: {
298
+ describeHeader: () => createLocalToolCallHeader({
299
+ title: "List Tasks"
300
+ }),
301
+ preview: async (input, context) => {
302
+ const tool = ensureToolsInitialized(context).listTasks;
303
+ const previewFn = tool.presentation?.preview;
304
+ if (!previewFn) {
305
+ return null;
306
+ }
307
+ return await previewFn(input, context);
270
308
  }
271
- return await tool.generatePreview(input, context);
272
309
  }
273
310
  }
274
311
  ];
@@ -31,6 +31,7 @@ __export(runtime_exports, {
31
31
  AgentSpawnerRuntime: () => AgentSpawnerRuntime
32
32
  });
33
33
  module.exports = __toCommonJS(runtime_exports);
34
+ var import_crypto = require("crypto");
34
35
  var import_core = require("@dexto/core");
35
36
  var import_AgentRuntime = require("../../runtime/AgentRuntime.js");
36
37
  var import_approval_delegation = require("../../runtime/approval-delegation.js");
@@ -187,6 +188,10 @@ class AgentSpawnerRuntime {
187
188
  const tokenUsage = { input: 0, output: 0, total: 0 };
188
189
  let currentTool = "";
189
190
  const emitProgress = (tool, args) => {
191
+ const subAgentLogFilePath = this.getSubAgentLogFilePath({
192
+ runtimeAgentId: subAgentHandle.agentId,
193
+ sessionId
194
+ });
190
195
  this.parentAgent.emit("service:event", {
191
196
  service: "agent-spawner",
192
197
  event: "progress",
@@ -195,6 +200,8 @@ class AgentSpawnerRuntime {
195
200
  data: {
196
201
  task: input.task,
197
202
  agentId: input.agentId ?? "default",
203
+ runtimeAgentId: subAgentHandle.agentId,
204
+ ...subAgentLogFilePath ? { subAgentLogFilePath } : {},
198
205
  toolsCalled: toolCount,
199
206
  currentTool: tool,
200
207
  currentArgs: args,
@@ -234,6 +241,44 @@ class AgentSpawnerRuntime {
234
241
  subAgentHandle.agent.off("llm:response", responseHandler);
235
242
  };
236
243
  }
244
+ /**
245
+ * Ensure spawned agent inherits the parent's workspace context.
246
+ */
247
+ async applyParentWorkspace(agent) {
248
+ let parentWorkspace;
249
+ try {
250
+ parentWorkspace = await this.parentAgent.getWorkspace();
251
+ } catch (error) {
252
+ this.logger.warn(
253
+ `Failed to read parent workspace for sub-agent: ${error instanceof Error ? error.message : String(error)}`
254
+ );
255
+ return;
256
+ }
257
+ if (!parentWorkspace?.path) {
258
+ return;
259
+ }
260
+ try {
261
+ await agent.setWorkspace({
262
+ path: parentWorkspace.path,
263
+ ...parentWorkspace.name ? { name: parentWorkspace.name } : {}
264
+ });
265
+ } catch (error) {
266
+ this.logger.warn(
267
+ `Failed to apply parent workspace to sub-agent: ${error instanceof Error ? error.message : String(error)}`
268
+ );
269
+ }
270
+ }
271
+ getSubAgentLogFilePath(options) {
272
+ const { runtimeAgentId, sessionId } = options;
273
+ if (!sessionId) {
274
+ return null;
275
+ }
276
+ const safeSessionId = sessionId.replace(/[^a-zA-Z0-9._-]/g, "_");
277
+ return (0, import_path.getDextoPath)(
278
+ "logs",
279
+ path.join(this.parentId, `${safeSessionId}.subagent.${runtimeAgentId}.log`)
280
+ );
281
+ }
237
282
  /**
238
283
  * Check if an error is LLM-related (API errors, credit issues, model not found, etc.)
239
284
  */
@@ -255,7 +300,10 @@ class AgentSpawnerRuntime {
255
300
  let llmMode = "subagent";
256
301
  let cleanupProgressTracking;
257
302
  try {
258
- const buildOptions = {};
303
+ const buildOptions = {
304
+ // Pre-generate the runtime agentId so we can deterministically route logs.
305
+ runtimeAgentId: `agent-${(0, import_crypto.randomUUID)().slice(0, 8)}`
306
+ };
259
307
  if (input.agentId !== void 0) {
260
308
  buildOptions.agentId = input.agentId;
261
309
  }
@@ -266,6 +314,7 @@ class AgentSpawnerRuntime {
266
314
  let handle;
267
315
  try {
268
316
  handle = await this.runtime.spawnAgent({
317
+ agentId: buildOptions.runtimeAgentId,
269
318
  agentConfig: subAgentConfig,
270
319
  ephemeral: true,
271
320
  group: this.parentId,
@@ -280,6 +329,7 @@ class AgentSpawnerRuntime {
280
329
  const delegatingHandler = (0, import_approval_delegation.createDelegatingApprovalHandler)(
281
330
  this.parentAgent.services.approvalManager,
282
331
  agent.config.agentId ?? "unknown",
332
+ sessionId,
283
333
  this.logger
284
334
  );
285
335
  agent.setApprovalHandler(delegatingHandler);
@@ -287,6 +337,7 @@ class AgentSpawnerRuntime {
287
337
  }
288
338
  });
289
339
  spawnedAgentId = handle.agentId;
340
+ await this.applyParentWorkspace(handle.agent);
290
341
  } catch (spawnError) {
291
342
  const isLlmError = this.isLLMError(spawnError);
292
343
  if (isLlmError && input.agentId && llmMode === "subagent") {
@@ -298,6 +349,7 @@ class AgentSpawnerRuntime {
298
349
  buildOptions.inheritLlm = true;
299
350
  subAgentConfig = await this.buildSubAgentConfig(buildOptions, sessionId);
300
351
  handle = await this.runtime.spawnAgent({
352
+ agentId: buildOptions.runtimeAgentId,
301
353
  agentConfig: subAgentConfig,
302
354
  ephemeral: true,
303
355
  group: this.parentId,
@@ -314,6 +366,7 @@ class AgentSpawnerRuntime {
314
366
  const delegatingHandler = (0, import_approval_delegation.createDelegatingApprovalHandler)(
315
367
  this.parentAgent.services.approvalManager,
316
368
  agent.config.agentId ?? "unknown",
369
+ sessionId,
317
370
  this.logger
318
371
  );
319
372
  agent.setApprovalHandler(delegatingHandler);
@@ -321,6 +374,7 @@ class AgentSpawnerRuntime {
321
374
  }
322
375
  });
323
376
  spawnedAgentId = handle.agentId;
377
+ await this.applyParentWorkspace(handle.agent);
324
378
  } else {
325
379
  throw spawnError;
326
380
  }
@@ -328,6 +382,23 @@ class AgentSpawnerRuntime {
328
382
  this.logger.info(
329
383
  `Spawned sub-agent '${spawnedAgentId}' for task: ${input.task}${autoApprove ? " (auto-approve)" : ""}${llmMode === "parent" ? " (using parent LLM)" : ""}`
330
384
  );
385
+ const subAgentLogFilePath = this.getSubAgentLogFilePath(
386
+ sessionId ? { runtimeAgentId: buildOptions.runtimeAgentId, sessionId } : { runtimeAgentId: buildOptions.runtimeAgentId }
387
+ );
388
+ if (subAgentLogFilePath) {
389
+ this.logger.info(`Sub-agent logs: ${subAgentLogFilePath}`);
390
+ }
391
+ if (sessionId) {
392
+ const parentSession = await this.parentAgent.getSession(sessionId);
393
+ if (parentSession) {
394
+ parentSession.logger.info("Sub-agent spawned", {
395
+ runtimeAgentId: spawnedAgentId,
396
+ registryAgentId: input.agentId ?? "default",
397
+ task: input.task,
398
+ ...subAgentLogFilePath ? { subAgentLogFilePath } : {}
399
+ });
400
+ }
401
+ }
331
402
  cleanupProgressTracking = this.setupProgressTracking(
332
403
  handle,
333
404
  input,
@@ -361,6 +432,7 @@ class AgentSpawnerRuntime {
361
432
  buildOptions.inheritLlm = true;
362
433
  subAgentConfig = await this.buildSubAgentConfig(buildOptions, sessionId);
363
434
  handle = await this.runtime.spawnAgent({
435
+ agentId: buildOptions.runtimeAgentId,
364
436
  agentConfig: subAgentConfig,
365
437
  ephemeral: true,
366
438
  group: this.parentId,
@@ -377,6 +449,7 @@ class AgentSpawnerRuntime {
377
449
  const delegatingHandler = (0, import_approval_delegation.createDelegatingApprovalHandler)(
378
450
  this.parentAgent.services.approvalManager,
379
451
  agent.config.agentId ?? "unknown",
452
+ sessionId,
380
453
  this.logger
381
454
  );
382
455
  agent.setApprovalHandler(delegatingHandler);
@@ -384,6 +457,7 @@ class AgentSpawnerRuntime {
384
457
  }
385
458
  });
386
459
  spawnedAgentId = handle.agentId;
460
+ await this.applyParentWorkspace(handle.agent);
387
461
  this.logger.info(
388
462
  `Re-spawned sub-agent '${spawnedAgentId}' for task: ${input.task} (using parent LLM)`
389
463
  );
@@ -443,13 +517,49 @@ class AgentSpawnerRuntime {
443
517
  * @param sessionId - Optional session ID to get session-specific LLM config
444
518
  */
445
519
  async buildSubAgentConfig(options, sessionId) {
446
- const { agentId, inheritLlm, autoApprove } = options;
520
+ const { agentId, inheritLlm, autoApprove, runtimeAgentId } = options;
447
521
  const parentSettings = this.parentAgent.config;
448
522
  const currentParentLLM = this.parentAgent.getCurrentLLMConfig(sessionId);
449
523
  this.logger.debug(
450
524
  `[AgentSpawnerRuntime] Building sub-agent config with LLM: ${currentParentLLM.provider}/${currentParentLLM.model}` + (sessionId ? ` (sessionId: ${sessionId})` : " (no sessionId)")
451
525
  );
452
526
  const permissionsMode = autoApprove ? "auto-approve" : "manual";
527
+ const parentToolPolicies = parentSettings.permissions?.toolPolicies;
528
+ const mergeToolPolicies = (subAgentPolicies) => {
529
+ const alwaysAllow = [
530
+ ...parentToolPolicies?.alwaysAllow ?? [],
531
+ ...subAgentPolicies?.alwaysAllow ?? []
532
+ ];
533
+ const alwaysDeny = [
534
+ ...parentToolPolicies?.alwaysDeny ?? [],
535
+ ...subAgentPolicies?.alwaysDeny ?? []
536
+ ];
537
+ return {
538
+ alwaysAllow: Array.from(new Set(alwaysAllow)),
539
+ alwaysDeny: Array.from(new Set(alwaysDeny))
540
+ };
541
+ };
542
+ const inheritedLoggerConfig = await (async () => {
543
+ if (!sessionId) {
544
+ return void 0;
545
+ }
546
+ const session = await this.parentAgent.getSession(sessionId);
547
+ if (!session) {
548
+ return void 0;
549
+ }
550
+ const parentSessionLogPath = session.logger.getLogFilePath();
551
+ if (!parentSessionLogPath) {
552
+ return void 0;
553
+ }
554
+ const subAgentLogFilePath = this.getSubAgentLogFilePath({ runtimeAgentId, sessionId });
555
+ if (!subAgentLogFilePath) {
556
+ return void 0;
557
+ }
558
+ return {
559
+ level: session.logger.getLevel(),
560
+ transports: [{ type: "file", path: subAgentLogFilePath }]
561
+ };
562
+ })();
453
563
  if (agentId) {
454
564
  let configPath = null;
455
565
  try {
@@ -492,13 +602,10 @@ class AgentSpawnerRuntime {
492
602
  llm: llmConfig,
493
603
  permissions: {
494
604
  ...loadedConfig.permissions,
495
- mode: permissionsMode
605
+ mode: permissionsMode,
606
+ toolPolicies: mergeToolPolicies(loadedConfig.permissions?.toolPolicies)
496
607
  },
497
- // Suppress sub-agent console logs entirely using silent transport
498
- logger: {
499
- level: "error",
500
- transports: [{ type: "silent" }]
501
- }
608
+ ...inheritedLoggerConfig !== void 0 && { logger: inheritedLoggerConfig }
502
609
  };
503
610
  }
504
611
  this.logger.warn(
@@ -510,15 +617,12 @@ class AgentSpawnerRuntime {
510
617
  // Default system prompt for sub-agents
511
618
  systemPrompt: "You are a helpful sub-agent. Complete the task given to you efficiently and concisely.",
512
619
  permissions: {
513
- mode: permissionsMode
620
+ mode: permissionsMode,
621
+ toolPolicies: mergeToolPolicies(void 0)
514
622
  },
515
623
  // Inherit MCP servers from parent so subagent has tool access
516
624
  mcpServers: parentSettings.mcpServers ? { ...parentSettings.mcpServers } : {},
517
- // Suppress sub-agent console logs entirely using silent transport
518
- logger: {
519
- level: "error",
520
- transports: [{ type: "silent" }]
521
- }
625
+ ...inheritedLoggerConfig !== void 0 && { logger: inheritedLoggerConfig }
522
626
  };
523
627
  return config;
524
628
  }
@@ -85,6 +85,11 @@ export declare class AgentSpawnerRuntime implements TaskForker {
85
85
  * @returns Cleanup function to unsubscribe from events
86
86
  */
87
87
  private setupProgressTracking;
88
+ /**
89
+ * Ensure spawned agent inherits the parent's workspace context.
90
+ */
91
+ private applyParentWorkspace;
92
+ private getSubAgentLogFilePath;
88
93
  /**
89
94
  * Check if an error is LLM-related (API errors, credit issues, model not found, etc.)
90
95
  */
@@ -1 +1 @@
1
- {"version":3,"file":"runtime.d.ts","sourceRoot":"","sources":["../../../src/tool-factories/agent-spawner/runtime.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAMlE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,yBAAyB,CAAC;AAIlE,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnD,qBAAa,mBAAoB,YAAW,UAAU;IAClD,OAAO,CAAC,OAAO,CAAe;IAC9B,OAAO,CAAC,QAAQ,CAAS;IACzB,OAAO,CAAC,WAAW,CAAa;IAChC,OAAO,CAAC,MAAM,CAAqB;IACnC,OAAO,CAAC,MAAM,CAAS;IAEvB,OAAO,CAAC,yBAAyB;IAyBjC,OAAO,CAAC,2BAA2B;gBAYvB,WAAW,EAAE,UAAU,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,EAAE,MAAM;IAuB/E;;OAEG;IACH,OAAO,CAAC,gBAAgB;IAIxB;;OAEG;IACH,OAAO,CAAC,QAAQ;IAIhB;;;;;;;;;;;;;;OAcG;IACG,eAAe,CAAC,KAAK,EAAE;QACzB,IAAI,EAAE,MAAM,CAAC;QACb,YAAY,EAAE,MAAM,CAAC;QACrB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,WAAW,CAAC,EAAE,OAAO,CAAC;QACtB,OAAO,CAAC,EAAE,MAAM,C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