@dimi-agent/cli 0.5.4 → 0.5.5

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 (2) hide show
  1. package/dist/main.mjs +38 -105
  2. package/package.json +4 -4
package/dist/main.mjs CHANGED
@@ -119585,22 +119585,6 @@ function wrapSubagentModelError(error, boundModel, callerModelAlias) {
119585
119585
  }
119586
119586
  });
119587
119587
  }
119588
- /** Human-readable duration for the subagent timeout message. */
119589
- function formatSubagentTimeoutDescription(ms) {
119590
- if (ms % (3600 * 1e3) === 0) {
119591
- const h = ms / (3600 * 1e3);
119592
- return `${h} hour${h === 1 ? "" : "s"}`;
119593
- }
119594
- if (ms % (60 * 1e3) === 0) {
119595
- const m = ms / (60 * 1e3);
119596
- return `${m} minute${m === 1 ? "" : "s"}`;
119597
- }
119598
- if (ms % 1e3 === 0) {
119599
- const s = ms / 1e3;
119600
- return `${s} second${s === 1 ? "" : "s"}`;
119601
- }
119602
- return `${ms} ms`;
119603
- }
119604
119588
  var SUBAGENT_SECTION, SubagentConfigSchema, DEFAULT_SUBAGENT_TIMEOUT_MS, SUBAGENT_TIMEOUT_ENV, subagentEnvBindings, stripSubagentEnv;
119605
119589
  var init_configSection$7 = __esmMin((() => {
119606
119590
  init_zod$1();
@@ -138782,7 +138766,15 @@ var init_subagent = __esmMin((() => {
138782
138766
  async function runAgentTurn(target, request, options) {
138783
138767
  options.signal.throwIfAborted();
138784
138768
  const promptService = target.accessor.get(IAgentPromptService);
138785
- const turn = request.kind === "prompt" ? await (await promptService.enqueue({ message: {
138769
+ const turn = request.kind === "prompt" ? await (await (options.steer === true ? promptService.enqueueOrSteer({ message: {
138770
+ role: "user",
138771
+ content: [{
138772
+ type: "text",
138773
+ text: request.prompt
138774
+ }],
138775
+ toolCalls: [],
138776
+ origin: AGENT_RUN_PROMPT_ORIGIN
138777
+ } }) : promptService.enqueue({ message: {
138786
138778
  role: "user",
138787
138779
  content: [{
138788
138780
  type: "text",
@@ -138790,7 +138782,7 @@ async function runAgentTurn(target, request, options) {
138790
138782
  }],
138791
138783
  toolCalls: [],
138792
138784
  origin: AGENT_RUN_PROMPT_ORIGIN
138793
- } })).launched : await promptService.retry();
138785
+ } }))).launched : await promptService.retry();
138794
138786
  if (turn === void 0) throw new Error("Agent turn could not be started");
138795
138787
  if (options.onReady !== void 0) turn.ready.then(() => options.onReady?.()).catch(() => {});
138796
138788
  const completion = awaitRun(target, turn, options);
@@ -138964,7 +138956,8 @@ var init_subagentService = __esmMin((() => {
138964
138956
  return runAgentTurn(handle, request, {
138965
138957
  summaryPolicy: opts.summaryPolicy ?? this.summaryPolicyFor(handle),
138966
138958
  signal: opts.signal,
138967
- onReady: opts.onReady
138959
+ onReady: opts.onReady,
138960
+ steer: opts.steer
138968
138961
  });
138969
138962
  }
138970
138963
  notifyAgentTaskStopped(context) {
@@ -139236,7 +139229,7 @@ var init_mirrorAgentRun = __esmMin((() => {
139236
139229
  init_eventBus();
139237
139230
  init_agentLifecycle();
139238
139231
  init_subagent();
139239
- })), DEFAULT_PROFILE_NAME, SubagentToolInputSchema, BACKGROUND_AGENT_UNAVAILABLE, RESUME_WITH_TYPE_UNAVAILABLE, USER_INTERRUPTED_SUBAGENT_MESSAGE, SUBAGENT_STOPPED_MESSAGE, ISubagentTool;
139232
+ })), DEFAULT_PROFILE_NAME, SubagentToolInputSchema, RESUME_WITH_TYPE_UNAVAILABLE, USER_INTERRUPTED_SUBAGENT_MESSAGE, SUBAGENT_STOPPED_MESSAGE, ISubagentTool;
139240
139233
  var init_agent$2 = __esmMin((() => {
139241
139234
  init_zod$1();
139242
139235
  init_instantiation();
@@ -139253,8 +139246,7 @@ var init_agent$2 = __esmMin((() => {
139253
139246
  prompt: string$2().describe("Full task prompt for the subagent"),
139254
139247
  description: string$2().describe("Short task description (3-5 words) for UI display"),
139255
139248
  subagent_type: string$2().optional().describe("One of the available agent types (see \"Available agent types\" in this tool description). Defaults to \"coder\" when omitted."),
139256
- resume: string$2().optional().describe("Optional agent ID to resume instead of creating a new instance. When set, do not also pass subagent_type — the resumed agent keeps its own type, and supplying both is rejected."),
139257
- run_in_background: boolean$2().optional().describe("If true, return immediately without waiting for completion. Prefer false unless the task can run independently and there is a clear benefit to not waiting."),
139249
+ resume: string$2().optional().describe("Agent ID to message or continue instead of creating a new instance. Messaging an existing subagent works exactly like a human steering the agent: if it is still running, the prompt is injected into its current turn immediately; if it is idle, it starts a normal turn. When set, do not also pass subagent_type — the resumed agent keeps its own type, and supplying both is rejected."),
139258
139250
  model: _enum(["secondary", "primary"]).optional().describe("Which model to run the subagent on: \"secondary\" = the configured secondary model; \"primary\" = the main model you are running on (for hard, quality-sensitive tasks). This explicit choice overrides the selected agent type's model_preference; without either, secondary is the default when configured. Only effective when a secondary model is configured; otherwise the subagent inherits your model. Ignored when resuming — resumed subagents keep their own model.")
139259
139251
  }));
139260
139252
  object({
@@ -139266,7 +139258,6 @@ var init_agent$2 = __esmMin((() => {
139266
139258
  cache_write: number$2().int().nonnegative().optional()
139267
139259
  }).describe("Cumulative token usage")
139268
139260
  });
139269
- BACKGROUND_AGENT_UNAVAILABLE = "Background agent execution is not available for this agent because TaskList, TaskOutput, and TaskStop are not enabled.";
139270
139261
  RESUME_WITH_TYPE_UNAVAILABLE = "Cannot set subagent_type when resuming an existing agent. Resume by agent id only.";
139271
139262
  USER_INTERRUPTED_SUBAGENT_MESSAGE = "The subagent was stopped before it finished by user.";
139272
139263
  SUBAGENT_STOPPED_MESSAGE = "The subagent was stopped before it finished.";
@@ -139312,22 +139303,10 @@ function firstNonEmpty(...values) {
139312
139303
  }
139313
139304
  var init_subagentMetadata = __esmMin((() => {}));
139314
139305
  //#endregion
139315
- //#region ../../packages/agent-core-v2/src/agent/tools/agent/agent-background-disabled.md?raw
139316
- var agent_background_disabled_default;
139317
- var init_agent_background_disabled = __esmMin((() => {
139318
- agent_background_disabled_default = "Background agent execution is disabled for this agent. Do not set `run_in_background=true` — any call that sets it is rejected before the subagent launches. Run every subagent in the foreground and wait for its result.";
139319
- }));
139320
- //#endregion
139321
- //#region ../../packages/agent-core-v2/src/agent/tools/agent/agent-background-enabled.md?raw
139322
- var agent_background_enabled_default;
139323
- var init_agent_background_enabled = __esmMin((() => {
139324
- agent_background_enabled_default = "When `run_in_background=true`, the subagent runs detached from this turn. The completion arrives in a later turn as a synthetic user-role message containing its result — you do not need to poll, sleep, or check on its progress. Continue with other work or respond to the user. Never fabricate or predict what the result will say.\n\nDefault to a foreground subagent (omit `run_in_background`) when your next step needs its result — foreground hands the result straight back. Reach for `run_in_background=true` only when you have other work to do while it runs and do not need its result to proceed. Never launch in the background and then immediately wait on it (by polling `TaskOutput`, sleeping, or otherwise): that just blocks the turn for no benefit — run it in the foreground instead.\n";
139325
- }));
139326
- //#endregion
139327
139306
  //#region ../../packages/agent-core-v2/src/agent/tools/agent/agent.md?raw
139328
139307
  var agent_default;
139329
139308
  var init_agent$1 = __esmMin((() => {
139330
- agent_default = "Launch a subagent to handle a task. The subagent runs as a same-process loop instance with its own context and wire file. Delegating also keeps the bulk of intermediate file contents out of your own context — you get a conclusion back instead of a pile of dumps.\n\nWriting the prompt:\n- The subagent starts with zero context — it has not seen this conversation. Brief it like a colleague who just walked into the room: state the goal, list what you already know, hand over the specifics.\n- Lookups (read this file, run that test): put the exact path or command in the prompt. The subagent should not have to search for things you already know.\n- Investigations (figure out X, find why Y): give the question, not prescribed steps — fixed steps become dead weight when the premise is wrong.\n- Do not delegate understanding. If the task hinges on a file path or line number, find it yourself first and write it into the prompt.\n\nUsage notes:\n- When the task continues earlier work a subagent already did, prefer resuming that agent (pass its `resume` id) over spawning a fresh instance — the resumed agent keeps its prior context.\n- A subagent's result is only visible to you, not to the user. When the user needs to see what a subagent produced, summarize the relevant parts yourself in your own reply.\n- Subagents use a fixed 2-hour timeout. If one times out, resume the same agent instead of starting over.\n\nWhen NOT to use Agent: skip delegation for trivial work you can do directly — reading a file whose path you already know, searching a small known set of files, or any task that takes only a step or two. Delegation has a context-handoff cost; it pays off only when the task is substantial enough to outweigh it.\n\nOnce a subagent is running, leave that scope to it: do not redo its searches or reads in parallel, and do not abandon it midway and finish the job manually. Both undo the context savings the delegation was meant to buy.\n";
139309
+ agent_default = "Launch a subagent to handle a task. The subagent runs as a same-process loop instance with its own context and wire file. Delegating also keeps the bulk of intermediate file contents out of your own context — you get a conclusion back instead of a pile of dumps.\n\nThe subagent is **fully asynchronous**: this tool returns immediately with the subagent's `agent_id` and a `task_id` — it never blocks your turn. Do the rest of your work while it runs; its result arrives on its own as a completion notification with the final summary. You do not need to poll, sleep, or check on it — and never fabricate or predict what the result will say.\n\nWhen you genuinely have nothing else to do and want to see how it is going:\n\n- Call `AgentOutput(agent_id=\"...\")` to read its recent rendered output (assistant text, thinking, tool calls, progress) — the same view a human sees in the TUI.\n- If it is still working, call `WaitFor` with a reasonable `timeout_seconds` instead of polling `AgentOutput` in a loop; the wait wakes you on the completion notification or the timeout, then check again with `AgentOutput`.\n\nWriting the prompt:\n- The subagent starts with zero context — it has not seen this conversation. Brief it like a colleague who just walked into the room: state the goal, list what you already know, hand over the specifics.\n- Lookups (read this file, run that test): put the exact path or command in the prompt. The subagent should not have to search for things you already know.\n- Investigations (figure out X, find why Y): give the question, not prescribed steps — fixed steps become dead weight when the premise is wrong.\n- Do not delegate understanding. If the task hinges on a file path or line number, find it yourself first and write it into the prompt.\n\nUsage notes:\n- When the task continues earlier work a subagent already did, prefer resuming that agent (pass its `resume` id) over spawning a fresh instance — the resumed agent keeps its prior context. `resume` works exactly like a human steering the agent: while the subagent is still running, your prompt is injected into its current turn immediately; when it is idle, it starts a normal turn. Use it to redirect, follow up, or send it new information.\n- A subagent's result is only visible to you, not to the user. When the user needs to see what a subagent produced, summarize the relevant parts yourself in your own reply.\n- Subagents use a fixed 2-hour timeout. If one times out, resume the same agent instead of starting over.\n\nWhen NOT to use Agent: skip delegation for trivial work you can do directly — reading a file whose path you already know, searching a small known set of files, or any task that takes only a step or two. Delegation has a context-handoff cost; it pays off only when the task is substantial enough to outweigh it.\n\nOnce a subagent is running, leave that scope to it: do not redo its searches or reads in parallel, and do not abandon it midway and finish the job manually. Both undo the context savings the delegation was meant to buy.\n";
139331
139310
  }));
139332
139311
  //#endregion
139333
139312
  //#region ../../packages/agent-core-v2/src/agent/tools/agent/agentTool.ts
@@ -139351,7 +139330,7 @@ function buildProfileDescriptions(profiles, tools, isToolActive$1, showModelPref
139351
139330
  return `${headerLines}\n Tools: ${activeTools.join(", ")}`;
139352
139331
  }).join("\n");
139353
139332
  }
139354
- function formatBackgroundAgentResult(taskId, handle, description, allowBackground) {
139333
+ function formatAsyncAgentResult(taskId, handle, description) {
139355
139334
  return [
139356
139335
  `task_id: ${taskId}`,
139357
139336
  "status: running",
@@ -139361,31 +139340,11 @@ function formatBackgroundAgentResult(taskId, handle, description, allowBackgroun
139361
139340
  "",
139362
139341
  `description: ${description}`,
139363
139342
  "",
139364
- allowBackground ? `next_step: The completion arrives automatically in a later turn do NOT wait, poll, or call TaskOutput on it; continue with other work or hand back to the user. (If you have nothing to do until it finishes, run such tasks in the foreground next time.)` : "next_step: The completion arrives automatically in a later turn.",
139365
- `resume_hint: To continue or recover this same subagent later, call Agent(resume="${handle.agentId}", prompt="..."). The parameter is agent_id ("${handle.agentId}"), NOT task_id ("${taskId}") or source_id from a later <notification>. Recovery cases: a later <notification type="task.lost" | "task.failed" | "task.killed"> for this subagent its conversation history is preserved across session restarts and resume will pick it up.`
139366
- ].join("\n");
139367
- }
139368
- function formatForegroundAgentSuccess(handle, result) {
139369
- return [
139370
- `agent_id: ${handle.agentId}`,
139371
- `actual_subagent_type: ${handle.profileName}`,
139372
- "status: completed",
139373
- "",
139374
- "[summary]",
139375
- result
139343
+ "next_step: The subagent runs fully asynchronously — continue with other work. Its final result arrives later as a completion notification.",
139344
+ `progress_hint: To check on it, call AgentOutput(agent_id="${handle.agentId}") to read its recent output (assistant text, thinking, tool calls). If you have nothing else to do, call WaitFor with a reasonable timeout_seconds instead of polling, then check again with AgentOutput.`,
139345
+ `resume_hint: To continue, redirect, or send this subagent a message — like a human steering the agent — call Agent(resume="${handle.agentId}", prompt="..."). While it is still running the prompt is injected into its current turn immediately; when idle it starts a normal turn. The parameter is agent_id ("${handle.agentId}"), NOT task_id ("${taskId}") or source_id from a later <notification>. Recovery cases: a later <notification type="task.lost" | "task.failed" | "task.killed"> for this subagent — its conversation history is preserved across session restarts and resume will pick it up.`
139376
139346
  ].join("\n");
139377
139347
  }
139378
- function formatForegroundAgentFailure(handle, message, timedOut) {
139379
- const lines = [
139380
- `agent_id: ${handle.agentId}`,
139381
- `actual_subagent_type: ${handle.profileName}`,
139382
- "status: failed",
139383
- "",
139384
- `subagent error: ${message}`
139385
- ];
139386
- if (timedOut) lines.push(`resume_hint: Continue with Agent(resume="${handle.agentId}", prompt="continue"). Use agent_id only; do not set subagent_type. The subagent retains its prior context; redo any unfinished tool call if its result was lost.`);
139387
- return lines.join("\n");
139388
- }
139389
139348
  function launchErrorMessage(error, signal) {
139390
139349
  if (isUserCancellation(signal.reason)) return USER_INTERRUPTED_SUBAGENT_MESSAGE;
139391
139350
  if (isAbortError$1(error)) return formatSubagentStoppedMessage(errorMessage$4(signal.reason));
@@ -139413,7 +139372,6 @@ var init_agentTool = __esmMin((() => {
139413
139372
  init_toolPolicy();
139414
139373
  init_permissionMode();
139415
139374
  init_scopeContext();
139416
- init_loop();
139417
139375
  init_userTool();
139418
139376
  init_toolContract();
139419
139377
  init_toolContribution();
@@ -139437,8 +139395,6 @@ var init_agentTool = __esmMin((() => {
139437
139395
  init_flag$2();
139438
139396
  init_agent$2();
139439
139397
  init_subagent_task();
139440
- init_agent_background_disabled();
139441
- init_agent_background_enabled();
139442
139398
  init_agent$1();
139443
139399
  init_decorateParam();
139444
139400
  init_decorate();
@@ -139461,7 +139417,6 @@ var init_agentTool = __esmMin((() => {
139461
139417
  name = "Agent";
139462
139418
  parameters = toInputJsonSchema(SubagentToolInputSchema);
139463
139419
  callerAgentId;
139464
- canRunInBackground;
139465
139420
  constructor(lifecycle, subagents, catalog, scopeContext, tasks, profile, toolPolicy, toolRegistry, workspace, processRunner, sessionMetadata, log, permissionMode, config, flags, modelCatalog) {
139466
139421
  this.lifecycle = lifecycle;
139467
139422
  this.subagents = subagents;
@@ -139479,10 +139434,9 @@ var init_agentTool = __esmMin((() => {
139479
139434
  this.flags = flags;
139480
139435
  this.modelCatalog = modelCatalog;
139481
139436
  this.callerAgentId = scopeContext.agentId;
139482
- this.canRunInBackground = () => this.toolPolicy.isToolActive("TaskList") && this.toolPolicy.isToolActive("TaskOutput") && this.toolPolicy.isToolActive("TaskStop");
139483
139437
  }
139484
139438
  get description() {
139485
- let description = `${agent_default}\n\n${this.canRunInBackground() ? agent_background_enabled_default : agent_background_disabled_default}`;
139439
+ let description = agent_default;
139486
139440
  const allowlist = subagentAllowlistFor(this.catalog, this.profile.data());
139487
139441
  const typeLines = buildProfileDescriptions(allowlist === void 0 ? this.catalog.list() : this.catalog.list().filter((profile) => allowlist.includes(profile.name)), this.knownToolReferences(), (profile, name, source) => this.toolPolicy.isToolActiveForProfile(profile, name, source), this.flags.enabled(SECONDARY_MODEL_FLAG_ID), this.flags.enabled(BACKGROUND_BASH_STDIN_FLAG_ID));
139488
139442
  if (typeLines) description += `\n\nAvailable agent types (pass via subagent_type):\n${typeLines}`;
@@ -139508,13 +139462,13 @@ var init_agentTool = __esmMin((() => {
139508
139462
  };
139509
139463
  const profileNameForDisplay = resumeAgentId !== void 0 && resumeAgentId.length > 0 ? this.resumeProfileName(resumeAgentId) ?? "subagent" : requestedProfileName ?? "coder";
139510
139464
  return {
139511
- description: `${args.run_in_background === true ? "Launching background" : "Launching"} ${profileNameForDisplay} agent: ${args.description}`,
139465
+ description: `Launching ${profileNameForDisplay} agent: ${args.description}`,
139512
139466
  accesses: ToolAccesses.none(),
139513
139467
  display: {
139514
139468
  kind: "agent_call",
139515
139469
  agent_name: profileNameForDisplay,
139516
139470
  prompt: args.prompt,
139517
- background: args.run_in_background
139471
+ background: false
139518
139472
  },
139519
139473
  approvalRule: this.name,
139520
139474
  matchesRule: (ruleArgs) => matchesGlobRuleSubject(ruleArgs, profileNameForDisplay),
@@ -139537,7 +139491,7 @@ var init_agentTool = __esmMin((() => {
139537
139491
  if (isResume) {
139538
139492
  const target = this.lifecycle.get(resumeAgentId);
139539
139493
  if (target === void 0) throw new Error(`Agent instance "${resumeAgentId}" does not exist`);
139540
- await this.ensureOwnedIdleSubagent(resumeAgentId, target);
139494
+ await this.ensureOwnedSubagent(resumeAgentId);
139541
139495
  agentId = target.id;
139542
139496
  profileName = target.accessor.get(IAgentProfileService).data().profileName ?? "subagent";
139543
139497
  } else {
@@ -139578,17 +139532,19 @@ var init_agentTool = __esmMin((() => {
139578
139532
  log: this.log
139579
139533
  });
139580
139534
  }
139581
- const runInBackground = args.run_in_background === true;
139582
139535
  emitAgentRunSpawned(requester, agentId, {
139583
139536
  profileName,
139584
139537
  parentToolCallId: toolCallId,
139585
139538
  description: args.description,
139586
- runInBackground
139539
+ runInBackground: false
139587
139540
  });
139588
139541
  const mirrored = mirrorAgentRun(requester, await this.subagents.run(agentId, {
139589
139542
  kind: "prompt",
139590
139543
  prompt: promptText
139591
- }, { signal: controller.signal }), {
139544
+ }, {
139545
+ signal: controller.signal,
139546
+ steer: isResume
139547
+ }), {
139592
139548
  profileName,
139593
139549
  prompt: promptText,
139594
139550
  signal: controller.signal,
@@ -139605,16 +139561,14 @@ var init_agentTool = __esmMin((() => {
139605
139561
  }))
139606
139562
  };
139607
139563
  }
139608
- async ensureOwnedIdleSubagent(agentId, target) {
139564
+ async ensureOwnedSubagent(agentId) {
139609
139565
  const meta = (await this.sessionMetadata.read()).agents?.[agentId];
139610
139566
  if (!isSubagentMeta(meta)) throw new Error(`Agent instance "${agentId}" is not a subagent`);
139611
139567
  if (subagentParentAgentId(meta) !== this.callerAgentId) throw new Error(`Agent instance "${agentId}" does not belong to this parent agent`);
139612
- if (target.accessor.get(IAgentLoopService).status().state === "running") throw new Error(`Agent instance "${agentId}" is already running and cannot run concurrently`);
139613
139568
  }
139614
139569
  async execution(args, { toolCallId, signal }) {
139615
139570
  try {
139616
139571
  signal.throwIfAborted();
139617
- const runInBackground = args.run_in_background === true;
139618
139572
  const requestedProfileName = args.subagent_type?.length ? args.subagent_type : void 0;
139619
139573
  const resumeAgentId = args.resume?.trim();
139620
139574
  const isResume = resumeAgentId !== void 0 && resumeAgentId.length > 0;
@@ -139622,17 +139576,12 @@ var init_agentTool = __esmMin((() => {
139622
139576
  output: RESUME_WITH_TYPE_UNAVAILABLE,
139623
139577
  isError: true
139624
139578
  };
139625
- const allowBackground = this.canRunInBackground();
139626
- if (runInBackground && !allowBackground) return {
139627
- output: BACKGROUND_AGENT_UNAVAILABLE,
139628
- isError: true
139629
- };
139630
139579
  const timeoutMs = resolveSubagentTimeoutMs(this.config);
139631
139580
  const controller = new AbortController();
139632
139581
  const abortBeforeRegister = () => {
139633
139582
  controller.abort(signal.reason);
139634
139583
  };
139635
- if (!runInBackground) signal.addEventListener("abort", abortBeforeRegister, { once: true });
139584
+ signal.addEventListener("abort", abortBeforeRegister, { once: true });
139636
139585
  let handle;
139637
139586
  try {
139638
139587
  handle = await this.launch(args, toolCallId, controller);
@@ -139640,7 +139589,6 @@ var init_agentTool = __esmMin((() => {
139640
139589
  signal.removeEventListener("abort", abortBeforeRegister);
139641
139590
  this.log.warn("subagent launch failed", {
139642
139591
  toolCallId,
139643
- runInBackground,
139644
139592
  operation: isResume ? "resume" : "spawn",
139645
139593
  subagentType: requestedProfileName ?? "coder",
139646
139594
  resumeAgentId: isResume ? resumeAgentId : void 0,
@@ -139651,9 +139599,9 @@ var init_agentTool = __esmMin((() => {
139651
139599
  let taskId;
139652
139600
  try {
139653
139601
  const registerOptions = {
139654
- detached: runInBackground,
139602
+ detached: true,
139655
139603
  timeoutMs,
139656
- signal: runInBackground ? void 0 : signal
139604
+ signal: void 0
139657
139605
  };
139658
139606
  taskId = this.tasks.registerTask(new SubagentTask(handle, args.description, controller), registerOptions);
139659
139607
  signal.removeEventListener("abort", abortBeforeRegister);
@@ -139661,7 +139609,7 @@ var init_agentTool = __esmMin((() => {
139661
139609
  controller.abort();
139662
139610
  handle.completion.catch(() => {});
139663
139611
  signal.removeEventListener("abort", abortBeforeRegister);
139664
- this.log?.warn("background agent task registration failed", {
139612
+ this.log?.warn("subagent task registration failed", {
139665
139613
  toolCallId,
139666
139614
  agentId: handle.agentId,
139667
139615
  subagentType: handle.profileName,
@@ -139673,9 +139621,7 @@ var init_agentTool = __esmMin((() => {
139673
139621
  isError: true
139674
139622
  };
139675
139623
  }
139676
- if (runInBackground) return { output: formatBackgroundAgentResult(taskId, handle, args.description, allowBackground) };
139677
- if (await this.tasks.waitForForegroundRelease(taskId) === "detached") return { output: formatBackgroundAgentResult(taskId, handle, args.description, allowBackground) };
139678
- return await this.formatForegroundResult(taskId, handle, timeoutMs);
139624
+ return { output: formatAsyncAgentResult(taskId, handle, args.description) };
139679
139625
  } catch (error) {
139680
139626
  return {
139681
139627
  output: `subagent error: ${launchErrorMessage(error, signal)}`,
@@ -139683,15 +139629,6 @@ var init_agentTool = __esmMin((() => {
139683
139629
  };
139684
139630
  }
139685
139631
  }
139686
- async formatForegroundResult(taskId, handle, timeoutMs) {
139687
- const info = this.tasks.getTask(taskId);
139688
- if (info?.status === "completed") return { output: formatForegroundAgentSuccess(handle, await this.tasks.readOutput(taskId)) };
139689
- const timedOut = info?.status === "timed_out";
139690
- return {
139691
- output: formatForegroundAgentFailure(handle, timedOut ? `Agent timed out after ${formatSubagentTimeoutDescription(timeoutMs)}.` : formatSubagentStoppedMessage(info?.stopReason), timedOut),
139692
- isError: true
139693
- };
139694
- }
139695
139632
  };
139696
139633
  SubagentTool = __decorate$1([
139697
139634
  __decorateParam(0, IAgentLifecycleService),
@@ -214622,7 +214559,6 @@ var init_sessionSwarmService = __esmMin((() => {
214622
214559
  init_abort();
214623
214560
  init_profile();
214624
214561
  init_permissionMode();
214625
- init_loop();
214626
214562
  init_userTool();
214627
214563
  init_eventBus();
214628
214564
  init_sessionAgentProfileCatalog();
@@ -214751,7 +214687,6 @@ var init_sessionSwarmService = __esmMin((() => {
214751
214687
  await this.requireOwnedSubagent(callerAgentId, agentId);
214752
214688
  const caller = this.requireHandle(callerAgentId, "Caller agent");
214753
214689
  const child = this.requireHandle(agentId, "Agent instance");
214754
- this.requireIdleSubagent(agentId, child);
214755
214690
  const profileName = child.accessor.get(IAgentProfileService).data().profileName ?? RESUMED_PROFILE_FALLBACK;
214756
214691
  if (!retryTurn) emitAgentRunSpawned(caller, agentId, {
214757
214692
  profileName,
@@ -214765,15 +214700,16 @@ var init_sessionSwarmService = __esmMin((() => {
214765
214700
  kind: "prompt",
214766
214701
  prompt: options.prompt
214767
214702
  };
214768
- return this.observe(caller, child.id, profileName, request, options);
214703
+ return this.observe(caller, child.id, profileName, request, options, !retryTurn);
214769
214704
  }
214770
- async observe(caller, agentId, profileName, request, options) {
214705
+ async observe(caller, agentId, profileName, request, options, steer = false) {
214771
214706
  return {
214772
214707
  agentId,
214773
214708
  profileName,
214774
214709
  completion: mirrorAgentRun(caller, await this.subagents.run(agentId, request, {
214775
214710
  signal: options.signal,
214776
- onReady: options.onReady
214711
+ onReady: options.onReady,
214712
+ steer
214777
214713
  }), {
214778
214714
  profileName,
214779
214715
  prompt: request.kind === "prompt" ? request.prompt : void 0,
@@ -214790,9 +214726,6 @@ var init_sessionSwarmService = __esmMin((() => {
214790
214726
  if (handle === void 0) throw new Error(`${label} "${agentId}" does not exist`);
214791
214727
  return handle;
214792
214728
  }
214793
- requireIdleSubagent(agentId, child) {
214794
- if (child.accessor.get(IAgentLoopService).status().state === "running") throw new Error(`Agent instance "${agentId}" is already running and cannot run concurrently`);
214795
- }
214796
214729
  async requireOwnedSubagent(callerAgentId, agentId) {
214797
214730
  const meta = await this.agentMeta(agentId);
214798
214731
  if (!isSubagentMeta(meta)) throw new Error(`Agent instance "${agentId}" is not a subagent`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dimi-agent/cli",
3
- "version": "0.5.4",
3
+ "version": "0.5.5",
4
4
  "description": "The Starting Point for Next-Gen Agents",
5
5
  "keywords": [
6
6
  "agent",
@@ -60,14 +60,14 @@
60
60
  "tsx": "^4.21.0",
61
61
  "yazl": "^3.3.1",
62
62
  "zod": "^4.3.6",
63
- "@dimi-agent/agent-core-v2": "^0.1.0",
64
63
  "@dimi-agent/dimi-oauth": "^0.1.0",
65
64
  "@dimi-agent/dimi-sdk": "^0.2.0",
66
65
  "@dimi-agent/dimi-telemetry": "^0.1.0",
66
+ "@dimi-agent/agent-core-v2": "^0.1.0",
67
67
  "@dimi-agent/dimi-web": "^0.1.0",
68
- "@dimi-agent/kap-server": "^0.1.0",
68
+ "@dimi-agent/pi-tui": "^0.1.0",
69
69
  "@dimi-agent/remote": "^0.1.0",
70
- "@dimi-agent/pi-tui": "^0.1.0"
70
+ "@dimi-agent/kap-server": "^0.1.0"
71
71
  },
72
72
  "optionalDependencies": {
73
73
  "@mariozechner/clipboard": "^0.3.9",