@dimi-agent/cli 0.5.3 → 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.
- package/dist/main.mjs +119 -130
- package/package.json +11 -4
- package/dist/dimi_bridge.node +0 -0
package/dist/main.mjs
CHANGED
|
@@ -99274,18 +99274,34 @@ var init_loginShellPath = __esmMin((() => {
|
|
|
99274
99274
|
* live in `dimi-wire` (Rust) and `@dimi-agent/transcript` (zod) and are
|
|
99275
99275
|
* cross-checked by the differential test suite.
|
|
99276
99276
|
*/
|
|
99277
|
+
function loadPlatformSubpackage() {
|
|
99278
|
+
try {
|
|
99279
|
+
return nodeRequire$4(PLATFORM_SUBPACKAGE);
|
|
99280
|
+
} catch {
|
|
99281
|
+
return null;
|
|
99282
|
+
}
|
|
99283
|
+
}
|
|
99277
99284
|
/**
|
|
99278
|
-
* Loads the native binding, building nothing.
|
|
99279
|
-
*
|
|
99285
|
+
* Loads the native binding, building nothing. Resolution order:
|
|
99286
|
+
* 1. `dist/dimi_bridge.node` next to the package — the dev / workspace
|
|
99287
|
+
* layout (local cargo builds always win).
|
|
99288
|
+
* 2. the npm platform subpackage (`@dimi-agent/dimi-native-<platform>-<arch>`)
|
|
99289
|
+
* — npm installs >=0.5.4; the SEA binary's module hook redirects the same
|
|
99290
|
+
* specifier into the embedded native-asset cache.
|
|
99291
|
+
* Throws with a pointer to the build command when neither exists.
|
|
99280
99292
|
*/
|
|
99281
99293
|
function loadNative() {
|
|
99282
99294
|
if (binding) return binding;
|
|
99283
99295
|
try {
|
|
99284
|
-
binding =
|
|
99285
|
-
|
|
99286
|
-
|
|
99296
|
+
binding = nodeRequire$4("../dist/dimi_bridge.node");
|
|
99297
|
+
return binding;
|
|
99298
|
+
} catch {}
|
|
99299
|
+
const platformBinding = loadPlatformSubpackage();
|
|
99300
|
+
if (platformBinding !== null) {
|
|
99301
|
+
binding = platformBinding;
|
|
99302
|
+
return binding;
|
|
99287
99303
|
}
|
|
99288
|
-
|
|
99304
|
+
throw new Error("dimi-native: native binding not found; run `pnpm --filter @dimi-agent/dimi-native run build:native`");
|
|
99289
99305
|
}
|
|
99290
99306
|
/** Full cold rebuild: wire records JSON array → snapshot JSON. */
|
|
99291
99307
|
function coldRebuild(recordsJson) {
|
|
@@ -99321,9 +99337,10 @@ function rustHostEnvironmentProbe() {
|
|
|
99321
99337
|
function rustTerminalSpawn(options) {
|
|
99322
99338
|
return loadNative().RustTerminal.spawn(options);
|
|
99323
99339
|
}
|
|
99324
|
-
var
|
|
99340
|
+
var nodeRequire$4, binding, PLATFORM_SUBPACKAGE, RustAgentTranscript, RustFileSystem;
|
|
99325
99341
|
var init_src$7 = __esmMin((() => {
|
|
99326
|
-
|
|
99342
|
+
nodeRequire$4 = createRequire(import.meta.url);
|
|
99343
|
+
PLATFORM_SUBPACKAGE = `@dimi-agent/dimi-native-${process.platform}-${process.arch}`;
|
|
99327
99344
|
RustAgentTranscript = class {
|
|
99328
99345
|
#inner;
|
|
99329
99346
|
constructor(agentId) {
|
|
@@ -99601,7 +99618,6 @@ function toRustOptions$1(options) {
|
|
|
99601
99618
|
}
|
|
99602
99619
|
var ERRNO_PREFIX, RustHostFileSystem;
|
|
99603
99620
|
var init_rustHostFileSystemService = __esmMin((() => {
|
|
99604
|
-
init_scope();
|
|
99605
99621
|
init_src$7();
|
|
99606
99622
|
init_hostFileSystem();
|
|
99607
99623
|
init_hostFsErrors();
|
|
@@ -119569,22 +119585,6 @@ function wrapSubagentModelError(error, boundModel, callerModelAlias) {
|
|
|
119569
119585
|
}
|
|
119570
119586
|
});
|
|
119571
119587
|
}
|
|
119572
|
-
/** Human-readable duration for the subagent timeout message. */
|
|
119573
|
-
function formatSubagentTimeoutDescription(ms) {
|
|
119574
|
-
if (ms % (3600 * 1e3) === 0) {
|
|
119575
|
-
const h = ms / (3600 * 1e3);
|
|
119576
|
-
return `${h} hour${h === 1 ? "" : "s"}`;
|
|
119577
|
-
}
|
|
119578
|
-
if (ms % (60 * 1e3) === 0) {
|
|
119579
|
-
const m = ms / (60 * 1e3);
|
|
119580
|
-
return `${m} minute${m === 1 ? "" : "s"}`;
|
|
119581
|
-
}
|
|
119582
|
-
if (ms % 1e3 === 0) {
|
|
119583
|
-
const s = ms / 1e3;
|
|
119584
|
-
return `${s} second${s === 1 ? "" : "s"}`;
|
|
119585
|
-
}
|
|
119586
|
-
return `${ms} ms`;
|
|
119587
|
-
}
|
|
119588
119588
|
var SUBAGENT_SECTION, SubagentConfigSchema, DEFAULT_SUBAGENT_TIMEOUT_MS, SUBAGENT_TIMEOUT_ENV, subagentEnvBindings, stripSubagentEnv;
|
|
119589
119589
|
var init_configSection$7 = __esmMin((() => {
|
|
119590
119590
|
init_zod$1();
|
|
@@ -138766,7 +138766,15 @@ var init_subagent = __esmMin((() => {
|
|
|
138766
138766
|
async function runAgentTurn(target, request, options) {
|
|
138767
138767
|
options.signal.throwIfAborted();
|
|
138768
138768
|
const promptService = target.accessor.get(IAgentPromptService);
|
|
138769
|
-
const turn = request.kind === "prompt" ? await (await promptService.
|
|
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: {
|
|
138770
138778
|
role: "user",
|
|
138771
138779
|
content: [{
|
|
138772
138780
|
type: "text",
|
|
@@ -138774,7 +138782,7 @@ async function runAgentTurn(target, request, options) {
|
|
|
138774
138782
|
}],
|
|
138775
138783
|
toolCalls: [],
|
|
138776
138784
|
origin: AGENT_RUN_PROMPT_ORIGIN
|
|
138777
|
-
} })).launched : await promptService.retry();
|
|
138785
|
+
} }))).launched : await promptService.retry();
|
|
138778
138786
|
if (turn === void 0) throw new Error("Agent turn could not be started");
|
|
138779
138787
|
if (options.onReady !== void 0) turn.ready.then(() => options.onReady?.()).catch(() => {});
|
|
138780
138788
|
const completion = awaitRun(target, turn, options);
|
|
@@ -138948,7 +138956,8 @@ var init_subagentService = __esmMin((() => {
|
|
|
138948
138956
|
return runAgentTurn(handle, request, {
|
|
138949
138957
|
summaryPolicy: opts.summaryPolicy ?? this.summaryPolicyFor(handle),
|
|
138950
138958
|
signal: opts.signal,
|
|
138951
|
-
onReady: opts.onReady
|
|
138959
|
+
onReady: opts.onReady,
|
|
138960
|
+
steer: opts.steer
|
|
138952
138961
|
});
|
|
138953
138962
|
}
|
|
138954
138963
|
notifyAgentTaskStopped(context) {
|
|
@@ -139220,7 +139229,7 @@ var init_mirrorAgentRun = __esmMin((() => {
|
|
|
139220
139229
|
init_eventBus();
|
|
139221
139230
|
init_agentLifecycle();
|
|
139222
139231
|
init_subagent();
|
|
139223
|
-
})), DEFAULT_PROFILE_NAME, SubagentToolInputSchema,
|
|
139232
|
+
})), DEFAULT_PROFILE_NAME, SubagentToolInputSchema, RESUME_WITH_TYPE_UNAVAILABLE, USER_INTERRUPTED_SUBAGENT_MESSAGE, SUBAGENT_STOPPED_MESSAGE, ISubagentTool;
|
|
139224
139233
|
var init_agent$2 = __esmMin((() => {
|
|
139225
139234
|
init_zod$1();
|
|
139226
139235
|
init_instantiation();
|
|
@@ -139237,8 +139246,7 @@ var init_agent$2 = __esmMin((() => {
|
|
|
139237
139246
|
prompt: string$2().describe("Full task prompt for the subagent"),
|
|
139238
139247
|
description: string$2().describe("Short task description (3-5 words) for UI display"),
|
|
139239
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."),
|
|
139240
|
-
resume: string$2().optional().describe("
|
|
139241
|
-
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."),
|
|
139242
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.")
|
|
139243
139251
|
}));
|
|
139244
139252
|
object({
|
|
@@ -139250,7 +139258,6 @@ var init_agent$2 = __esmMin((() => {
|
|
|
139250
139258
|
cache_write: number$2().int().nonnegative().optional()
|
|
139251
139259
|
}).describe("Cumulative token usage")
|
|
139252
139260
|
});
|
|
139253
|
-
BACKGROUND_AGENT_UNAVAILABLE = "Background agent execution is not available for this agent because TaskList, TaskOutput, and TaskStop are not enabled.";
|
|
139254
139261
|
RESUME_WITH_TYPE_UNAVAILABLE = "Cannot set subagent_type when resuming an existing agent. Resume by agent id only.";
|
|
139255
139262
|
USER_INTERRUPTED_SUBAGENT_MESSAGE = "The subagent was stopped before it finished by user.";
|
|
139256
139263
|
SUBAGENT_STOPPED_MESSAGE = "The subagent was stopped before it finished.";
|
|
@@ -139296,22 +139303,10 @@ function firstNonEmpty(...values) {
|
|
|
139296
139303
|
}
|
|
139297
139304
|
var init_subagentMetadata = __esmMin((() => {}));
|
|
139298
139305
|
//#endregion
|
|
139299
|
-
//#region ../../packages/agent-core-v2/src/agent/tools/agent/agent-background-disabled.md?raw
|
|
139300
|
-
var agent_background_disabled_default;
|
|
139301
|
-
var init_agent_background_disabled = __esmMin((() => {
|
|
139302
|
-
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.";
|
|
139303
|
-
}));
|
|
139304
|
-
//#endregion
|
|
139305
|
-
//#region ../../packages/agent-core-v2/src/agent/tools/agent/agent-background-enabled.md?raw
|
|
139306
|
-
var agent_background_enabled_default;
|
|
139307
|
-
var init_agent_background_enabled = __esmMin((() => {
|
|
139308
|
-
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";
|
|
139309
|
-
}));
|
|
139310
|
-
//#endregion
|
|
139311
139306
|
//#region ../../packages/agent-core-v2/src/agent/tools/agent/agent.md?raw
|
|
139312
139307
|
var agent_default;
|
|
139313
139308
|
var init_agent$1 = __esmMin((() => {
|
|
139314
|
-
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";
|
|
139315
139310
|
}));
|
|
139316
139311
|
//#endregion
|
|
139317
139312
|
//#region ../../packages/agent-core-v2/src/agent/tools/agent/agentTool.ts
|
|
@@ -139335,7 +139330,7 @@ function buildProfileDescriptions(profiles, tools, isToolActive$1, showModelPref
|
|
|
139335
139330
|
return `${headerLines}\n Tools: ${activeTools.join(", ")}`;
|
|
139336
139331
|
}).join("\n");
|
|
139337
139332
|
}
|
|
139338
|
-
function
|
|
139333
|
+
function formatAsyncAgentResult(taskId, handle, description) {
|
|
139339
139334
|
return [
|
|
139340
139335
|
`task_id: ${taskId}`,
|
|
139341
139336
|
"status: running",
|
|
@@ -139345,31 +139340,11 @@ function formatBackgroundAgentResult(taskId, handle, description, allowBackgroun
|
|
|
139345
139340
|
"",
|
|
139346
139341
|
`description: ${description}`,
|
|
139347
139342
|
"",
|
|
139348
|
-
|
|
139349
|
-
`
|
|
139350
|
-
|
|
139351
|
-
}
|
|
139352
|
-
function formatForegroundAgentSuccess(handle, result) {
|
|
139353
|
-
return [
|
|
139354
|
-
`agent_id: ${handle.agentId}`,
|
|
139355
|
-
`actual_subagent_type: ${handle.profileName}`,
|
|
139356
|
-
"status: completed",
|
|
139357
|
-
"",
|
|
139358
|
-
"[summary]",
|
|
139359
|
-
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.`
|
|
139360
139346
|
].join("\n");
|
|
139361
139347
|
}
|
|
139362
|
-
function formatForegroundAgentFailure(handle, message, timedOut) {
|
|
139363
|
-
const lines = [
|
|
139364
|
-
`agent_id: ${handle.agentId}`,
|
|
139365
|
-
`actual_subagent_type: ${handle.profileName}`,
|
|
139366
|
-
"status: failed",
|
|
139367
|
-
"",
|
|
139368
|
-
`subagent error: ${message}`
|
|
139369
|
-
];
|
|
139370
|
-
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.`);
|
|
139371
|
-
return lines.join("\n");
|
|
139372
|
-
}
|
|
139373
139348
|
function launchErrorMessage(error, signal) {
|
|
139374
139349
|
if (isUserCancellation(signal.reason)) return USER_INTERRUPTED_SUBAGENT_MESSAGE;
|
|
139375
139350
|
if (isAbortError$1(error)) return formatSubagentStoppedMessage(errorMessage$4(signal.reason));
|
|
@@ -139397,7 +139372,6 @@ var init_agentTool = __esmMin((() => {
|
|
|
139397
139372
|
init_toolPolicy();
|
|
139398
139373
|
init_permissionMode();
|
|
139399
139374
|
init_scopeContext();
|
|
139400
|
-
init_loop();
|
|
139401
139375
|
init_userTool();
|
|
139402
139376
|
init_toolContract();
|
|
139403
139377
|
init_toolContribution();
|
|
@@ -139421,8 +139395,6 @@ var init_agentTool = __esmMin((() => {
|
|
|
139421
139395
|
init_flag$2();
|
|
139422
139396
|
init_agent$2();
|
|
139423
139397
|
init_subagent_task();
|
|
139424
|
-
init_agent_background_disabled();
|
|
139425
|
-
init_agent_background_enabled();
|
|
139426
139398
|
init_agent$1();
|
|
139427
139399
|
init_decorateParam();
|
|
139428
139400
|
init_decorate();
|
|
@@ -139445,7 +139417,6 @@ var init_agentTool = __esmMin((() => {
|
|
|
139445
139417
|
name = "Agent";
|
|
139446
139418
|
parameters = toInputJsonSchema(SubagentToolInputSchema);
|
|
139447
139419
|
callerAgentId;
|
|
139448
|
-
canRunInBackground;
|
|
139449
139420
|
constructor(lifecycle, subagents, catalog, scopeContext, tasks, profile, toolPolicy, toolRegistry, workspace, processRunner, sessionMetadata, log, permissionMode, config, flags, modelCatalog) {
|
|
139450
139421
|
this.lifecycle = lifecycle;
|
|
139451
139422
|
this.subagents = subagents;
|
|
@@ -139463,10 +139434,9 @@ var init_agentTool = __esmMin((() => {
|
|
|
139463
139434
|
this.flags = flags;
|
|
139464
139435
|
this.modelCatalog = modelCatalog;
|
|
139465
139436
|
this.callerAgentId = scopeContext.agentId;
|
|
139466
|
-
this.canRunInBackground = () => this.toolPolicy.isToolActive("TaskList") && this.toolPolicy.isToolActive("TaskOutput") && this.toolPolicy.isToolActive("TaskStop");
|
|
139467
139437
|
}
|
|
139468
139438
|
get description() {
|
|
139469
|
-
let description =
|
|
139439
|
+
let description = agent_default;
|
|
139470
139440
|
const allowlist = subagentAllowlistFor(this.catalog, this.profile.data());
|
|
139471
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));
|
|
139472
139442
|
if (typeLines) description += `\n\nAvailable agent types (pass via subagent_type):\n${typeLines}`;
|
|
@@ -139492,13 +139462,13 @@ var init_agentTool = __esmMin((() => {
|
|
|
139492
139462
|
};
|
|
139493
139463
|
const profileNameForDisplay = resumeAgentId !== void 0 && resumeAgentId.length > 0 ? this.resumeProfileName(resumeAgentId) ?? "subagent" : requestedProfileName ?? "coder";
|
|
139494
139464
|
return {
|
|
139495
|
-
description:
|
|
139465
|
+
description: `Launching ${profileNameForDisplay} agent: ${args.description}`,
|
|
139496
139466
|
accesses: ToolAccesses.none(),
|
|
139497
139467
|
display: {
|
|
139498
139468
|
kind: "agent_call",
|
|
139499
139469
|
agent_name: profileNameForDisplay,
|
|
139500
139470
|
prompt: args.prompt,
|
|
139501
|
-
background:
|
|
139471
|
+
background: false
|
|
139502
139472
|
},
|
|
139503
139473
|
approvalRule: this.name,
|
|
139504
139474
|
matchesRule: (ruleArgs) => matchesGlobRuleSubject(ruleArgs, profileNameForDisplay),
|
|
@@ -139521,7 +139491,7 @@ var init_agentTool = __esmMin((() => {
|
|
|
139521
139491
|
if (isResume) {
|
|
139522
139492
|
const target = this.lifecycle.get(resumeAgentId);
|
|
139523
139493
|
if (target === void 0) throw new Error(`Agent instance "${resumeAgentId}" does not exist`);
|
|
139524
|
-
await this.
|
|
139494
|
+
await this.ensureOwnedSubagent(resumeAgentId);
|
|
139525
139495
|
agentId = target.id;
|
|
139526
139496
|
profileName = target.accessor.get(IAgentProfileService).data().profileName ?? "subagent";
|
|
139527
139497
|
} else {
|
|
@@ -139562,17 +139532,19 @@ var init_agentTool = __esmMin((() => {
|
|
|
139562
139532
|
log: this.log
|
|
139563
139533
|
});
|
|
139564
139534
|
}
|
|
139565
|
-
const runInBackground = args.run_in_background === true;
|
|
139566
139535
|
emitAgentRunSpawned(requester, agentId, {
|
|
139567
139536
|
profileName,
|
|
139568
139537
|
parentToolCallId: toolCallId,
|
|
139569
139538
|
description: args.description,
|
|
139570
|
-
runInBackground
|
|
139539
|
+
runInBackground: false
|
|
139571
139540
|
});
|
|
139572
139541
|
const mirrored = mirrorAgentRun(requester, await this.subagents.run(agentId, {
|
|
139573
139542
|
kind: "prompt",
|
|
139574
139543
|
prompt: promptText
|
|
139575
|
-
}, {
|
|
139544
|
+
}, {
|
|
139545
|
+
signal: controller.signal,
|
|
139546
|
+
steer: isResume
|
|
139547
|
+
}), {
|
|
139576
139548
|
profileName,
|
|
139577
139549
|
prompt: promptText,
|
|
139578
139550
|
signal: controller.signal,
|
|
@@ -139589,16 +139561,14 @@ var init_agentTool = __esmMin((() => {
|
|
|
139589
139561
|
}))
|
|
139590
139562
|
};
|
|
139591
139563
|
}
|
|
139592
|
-
async
|
|
139564
|
+
async ensureOwnedSubagent(agentId) {
|
|
139593
139565
|
const meta = (await this.sessionMetadata.read()).agents?.[agentId];
|
|
139594
139566
|
if (!isSubagentMeta(meta)) throw new Error(`Agent instance "${agentId}" is not a subagent`);
|
|
139595
139567
|
if (subagentParentAgentId(meta) !== this.callerAgentId) throw new Error(`Agent instance "${agentId}" does not belong to this parent agent`);
|
|
139596
|
-
if (target.accessor.get(IAgentLoopService).status().state === "running") throw new Error(`Agent instance "${agentId}" is already running and cannot run concurrently`);
|
|
139597
139568
|
}
|
|
139598
139569
|
async execution(args, { toolCallId, signal }) {
|
|
139599
139570
|
try {
|
|
139600
139571
|
signal.throwIfAborted();
|
|
139601
|
-
const runInBackground = args.run_in_background === true;
|
|
139602
139572
|
const requestedProfileName = args.subagent_type?.length ? args.subagent_type : void 0;
|
|
139603
139573
|
const resumeAgentId = args.resume?.trim();
|
|
139604
139574
|
const isResume = resumeAgentId !== void 0 && resumeAgentId.length > 0;
|
|
@@ -139606,17 +139576,12 @@ var init_agentTool = __esmMin((() => {
|
|
|
139606
139576
|
output: RESUME_WITH_TYPE_UNAVAILABLE,
|
|
139607
139577
|
isError: true
|
|
139608
139578
|
};
|
|
139609
|
-
const allowBackground = this.canRunInBackground();
|
|
139610
|
-
if (runInBackground && !allowBackground) return {
|
|
139611
|
-
output: BACKGROUND_AGENT_UNAVAILABLE,
|
|
139612
|
-
isError: true
|
|
139613
|
-
};
|
|
139614
139579
|
const timeoutMs = resolveSubagentTimeoutMs(this.config);
|
|
139615
139580
|
const controller = new AbortController();
|
|
139616
139581
|
const abortBeforeRegister = () => {
|
|
139617
139582
|
controller.abort(signal.reason);
|
|
139618
139583
|
};
|
|
139619
|
-
|
|
139584
|
+
signal.addEventListener("abort", abortBeforeRegister, { once: true });
|
|
139620
139585
|
let handle;
|
|
139621
139586
|
try {
|
|
139622
139587
|
handle = await this.launch(args, toolCallId, controller);
|
|
@@ -139624,7 +139589,6 @@ var init_agentTool = __esmMin((() => {
|
|
|
139624
139589
|
signal.removeEventListener("abort", abortBeforeRegister);
|
|
139625
139590
|
this.log.warn("subagent launch failed", {
|
|
139626
139591
|
toolCallId,
|
|
139627
|
-
runInBackground,
|
|
139628
139592
|
operation: isResume ? "resume" : "spawn",
|
|
139629
139593
|
subagentType: requestedProfileName ?? "coder",
|
|
139630
139594
|
resumeAgentId: isResume ? resumeAgentId : void 0,
|
|
@@ -139635,9 +139599,9 @@ var init_agentTool = __esmMin((() => {
|
|
|
139635
139599
|
let taskId;
|
|
139636
139600
|
try {
|
|
139637
139601
|
const registerOptions = {
|
|
139638
|
-
detached:
|
|
139602
|
+
detached: true,
|
|
139639
139603
|
timeoutMs,
|
|
139640
|
-
signal:
|
|
139604
|
+
signal: void 0
|
|
139641
139605
|
};
|
|
139642
139606
|
taskId = this.tasks.registerTask(new SubagentTask(handle, args.description, controller), registerOptions);
|
|
139643
139607
|
signal.removeEventListener("abort", abortBeforeRegister);
|
|
@@ -139645,7 +139609,7 @@ var init_agentTool = __esmMin((() => {
|
|
|
139645
139609
|
controller.abort();
|
|
139646
139610
|
handle.completion.catch(() => {});
|
|
139647
139611
|
signal.removeEventListener("abort", abortBeforeRegister);
|
|
139648
|
-
this.log?.warn("
|
|
139612
|
+
this.log?.warn("subagent task registration failed", {
|
|
139649
139613
|
toolCallId,
|
|
139650
139614
|
agentId: handle.agentId,
|
|
139651
139615
|
subagentType: handle.profileName,
|
|
@@ -139657,9 +139621,7 @@ var init_agentTool = __esmMin((() => {
|
|
|
139657
139621
|
isError: true
|
|
139658
139622
|
};
|
|
139659
139623
|
}
|
|
139660
|
-
|
|
139661
|
-
if (await this.tasks.waitForForegroundRelease(taskId) === "detached") return { output: formatBackgroundAgentResult(taskId, handle, args.description, allowBackground) };
|
|
139662
|
-
return await this.formatForegroundResult(taskId, handle, timeoutMs);
|
|
139624
|
+
return { output: formatAsyncAgentResult(taskId, handle, args.description) };
|
|
139663
139625
|
} catch (error) {
|
|
139664
139626
|
return {
|
|
139665
139627
|
output: `subagent error: ${launchErrorMessage(error, signal)}`,
|
|
@@ -139667,15 +139629,6 @@ var init_agentTool = __esmMin((() => {
|
|
|
139667
139629
|
};
|
|
139668
139630
|
}
|
|
139669
139631
|
}
|
|
139670
|
-
async formatForegroundResult(taskId, handle, timeoutMs) {
|
|
139671
|
-
const info = this.tasks.getTask(taskId);
|
|
139672
|
-
if (info?.status === "completed") return { output: formatForegroundAgentSuccess(handle, await this.tasks.readOutput(taskId)) };
|
|
139673
|
-
const timedOut = info?.status === "timed_out";
|
|
139674
|
-
return {
|
|
139675
|
-
output: formatForegroundAgentFailure(handle, timedOut ? `Agent timed out after ${formatSubagentTimeoutDescription(timeoutMs)}.` : formatSubagentStoppedMessage(info?.stopReason), timedOut),
|
|
139676
|
-
isError: true
|
|
139677
|
-
};
|
|
139678
|
-
}
|
|
139679
139632
|
};
|
|
139680
139633
|
SubagentTool = __decorate$1([
|
|
139681
139634
|
__decorateParam(0, IAgentLifecycleService),
|
|
@@ -214606,7 +214559,6 @@ var init_sessionSwarmService = __esmMin((() => {
|
|
|
214606
214559
|
init_abort();
|
|
214607
214560
|
init_profile();
|
|
214608
214561
|
init_permissionMode();
|
|
214609
|
-
init_loop();
|
|
214610
214562
|
init_userTool();
|
|
214611
214563
|
init_eventBus();
|
|
214612
214564
|
init_sessionAgentProfileCatalog();
|
|
@@ -214735,7 +214687,6 @@ var init_sessionSwarmService = __esmMin((() => {
|
|
|
214735
214687
|
await this.requireOwnedSubagent(callerAgentId, agentId);
|
|
214736
214688
|
const caller = this.requireHandle(callerAgentId, "Caller agent");
|
|
214737
214689
|
const child = this.requireHandle(agentId, "Agent instance");
|
|
214738
|
-
this.requireIdleSubagent(agentId, child);
|
|
214739
214690
|
const profileName = child.accessor.get(IAgentProfileService).data().profileName ?? RESUMED_PROFILE_FALLBACK;
|
|
214740
214691
|
if (!retryTurn) emitAgentRunSpawned(caller, agentId, {
|
|
214741
214692
|
profileName,
|
|
@@ -214749,15 +214700,16 @@ var init_sessionSwarmService = __esmMin((() => {
|
|
|
214749
214700
|
kind: "prompt",
|
|
214750
214701
|
prompt: options.prompt
|
|
214751
214702
|
};
|
|
214752
|
-
return this.observe(caller, child.id, profileName, request, options);
|
|
214703
|
+
return this.observe(caller, child.id, profileName, request, options, !retryTurn);
|
|
214753
214704
|
}
|
|
214754
|
-
async observe(caller, agentId, profileName, request, options) {
|
|
214705
|
+
async observe(caller, agentId, profileName, request, options, steer = false) {
|
|
214755
214706
|
return {
|
|
214756
214707
|
agentId,
|
|
214757
214708
|
profileName,
|
|
214758
214709
|
completion: mirrorAgentRun(caller, await this.subagents.run(agentId, request, {
|
|
214759
214710
|
signal: options.signal,
|
|
214760
|
-
onReady: options.onReady
|
|
214711
|
+
onReady: options.onReady,
|
|
214712
|
+
steer
|
|
214761
214713
|
}), {
|
|
214762
214714
|
profileName,
|
|
214763
214715
|
prompt: request.kind === "prompt" ? request.prompt : void 0,
|
|
@@ -214774,9 +214726,6 @@ var init_sessionSwarmService = __esmMin((() => {
|
|
|
214774
214726
|
if (handle === void 0) throw new Error(`${label} "${agentId}" does not exist`);
|
|
214775
214727
|
return handle;
|
|
214776
214728
|
}
|
|
214777
|
-
requireIdleSubagent(agentId, child) {
|
|
214778
|
-
if (child.accessor.get(IAgentLoopService).status().state === "running") throw new Error(`Agent instance "${agentId}" is already running and cannot run concurrently`);
|
|
214779
|
-
}
|
|
214780
214729
|
async requireOwnedSubagent(callerAgentId, agentId) {
|
|
214781
214730
|
const meta = await this.agentMeta(agentId);
|
|
214782
214731
|
if (!isSubagentMeta(meta)) throw new Error(`Agent instance "${agentId}" is not a subagent`);
|
|
@@ -393981,6 +393930,20 @@ var init_upgrade = __esmMin((() => {
|
|
|
393981
393930
|
}));
|
|
393982
393931
|
//#endregion
|
|
393983
393932
|
//#region src/native/module-hook.ts
|
|
393933
|
+
/**
|
|
393934
|
+
* The cached dimi_bridge.node for the requested binding subpackage, or null
|
|
393935
|
+
* when the package resolves normally (dev / npm installs — the real package
|
|
393936
|
+
* wins) or the native-asset tree has no such package.
|
|
393937
|
+
*/
|
|
393938
|
+
function dimiNativeBindingPath(request) {
|
|
393939
|
+
try {
|
|
393940
|
+
nodeRequire.resolve(request);
|
|
393941
|
+
return null;
|
|
393942
|
+
} catch {}
|
|
393943
|
+
const pkgRoot = getNativePackageRoot(request);
|
|
393944
|
+
if (pkgRoot === null) return null;
|
|
393945
|
+
return join(pkgRoot, "dimi_bridge.node");
|
|
393946
|
+
}
|
|
393984
393947
|
function installNativeModuleHook() {
|
|
393985
393948
|
if (installed) return;
|
|
393986
393949
|
installed = true;
|
|
@@ -393988,28 +393951,38 @@ function installNativeModuleHook() {
|
|
|
393988
393951
|
const originalLoad = moduleBuiltin._load;
|
|
393989
393952
|
if (originalLoad === void 0) return;
|
|
393990
393953
|
moduleBuiltin._load = function loadWithNativeAssets(request, parent, isMain) {
|
|
393991
|
-
if (typeof request === "string"
|
|
393992
|
-
|
|
393993
|
-
|
|
393994
|
-
|
|
393995
|
-
|
|
393996
|
-
|
|
393997
|
-
|
|
393954
|
+
if (typeof request === "string") {
|
|
393955
|
+
if (PI_TUI_NATIVE_PATTERN.test(request) && !existsSync(request)) {
|
|
393956
|
+
const pkgRoot = getNativePackageRoot("@dimi-agent/pi-tui");
|
|
393957
|
+
if (pkgRoot !== null) {
|
|
393958
|
+
const match = request.match(PI_TUI_NATIVE_PATTERN);
|
|
393959
|
+
if (match !== null) {
|
|
393960
|
+
const redirected = join(pkgRoot, match[0]);
|
|
393961
|
+
return originalLoad.call(this, redirected, parent, isMain);
|
|
393962
|
+
}
|
|
393998
393963
|
}
|
|
393964
|
+
} else if (DIMI_NATIVE_SUBPACKAGE.test(request)) {
|
|
393965
|
+
const redirected = dimiNativeBindingPath(request);
|
|
393966
|
+
if (redirected !== null) return originalLoad.call(this, redirected, parent, isMain);
|
|
393999
393967
|
}
|
|
394000
393968
|
}
|
|
394001
393969
|
return originalLoad.call(this, request, parent, isMain);
|
|
394002
393970
|
};
|
|
394003
393971
|
}
|
|
394004
|
-
var nodeRequire, installed, PI_TUI_NATIVE_PATTERN;
|
|
393972
|
+
var nodeRequire, installed, PI_TUI_NATIVE_PATTERN, DIMI_NATIVE_SUBPACKAGE;
|
|
394005
393973
|
var init_module_hook = __esmMin((() => {
|
|
394006
393974
|
init_native_assets();
|
|
394007
393975
|
nodeRequire = createRequire(import.meta.url);
|
|
394008
393976
|
installed = false;
|
|
394009
393977
|
PI_TUI_NATIVE_PATTERN = /native[\\/](?:win32|darwin)[\\/]prebuilds[\\/].+\.node$/;
|
|
393978
|
+
DIMI_NATIVE_SUBPACKAGE = /^@dimi-agent\/dimi-native-(?:darwin|linux|win32)-(?:arm64|x64)$/;
|
|
394010
393979
|
}));
|
|
394011
393980
|
//#endregion
|
|
394012
393981
|
//#region src/native/smoke.ts
|
|
393982
|
+
function smokeDimiNativeLoad() {
|
|
393983
|
+
const info = createRequire(import.meta.url)(dimiNativePackage)?.RustHostEnvironment?.probe?.();
|
|
393984
|
+
if (typeof info !== "object" || info === null || typeof info.osKind !== "string") throw new Error("dimi-native binding loaded but probe() returned an unexpected shape");
|
|
393985
|
+
}
|
|
394013
393986
|
function smokePiTuiNativeLoad() {
|
|
394014
393987
|
const platform = process.platform;
|
|
394015
393988
|
const arch = process.arch;
|
|
@@ -394027,6 +394000,7 @@ function runNativeAssetSmokeIfRequested() {
|
|
|
394027
394000
|
if (manifest === null) throw new Error("Native asset manifest is not available.");
|
|
394028
394001
|
for (const packageName of smokePackages) if (getNativePackageRoot(packageName, { manifest }) === null) throw new Error(`Native package is not available: ${packageName}`);
|
|
394029
394002
|
smokePiTuiNativeLoad();
|
|
394003
|
+
smokeDimiNativeLoad();
|
|
394030
394004
|
process.stdout.write(`Native asset smoke passed: ${manifest.target}\n`);
|
|
394031
394005
|
process.exit(0);
|
|
394032
394006
|
} catch (error) {
|
|
@@ -394035,10 +394009,15 @@ function runNativeAssetSmokeIfRequested() {
|
|
|
394035
394009
|
process.exit(1);
|
|
394036
394010
|
}
|
|
394037
394011
|
}
|
|
394038
|
-
var smokePackages;
|
|
394012
|
+
var dimiNativePackage, smokePackages;
|
|
394039
394013
|
var init_smoke = __esmMin((() => {
|
|
394040
394014
|
init_native_assets();
|
|
394041
|
-
|
|
394015
|
+
dimiNativePackage = `@dimi-agent/dimi-native-${process.platform}-${process.arch}`;
|
|
394016
|
+
smokePackages = [
|
|
394017
|
+
"@mariozechner/clipboard",
|
|
394018
|
+
"@dimi-agent/pi-tui",
|
|
394019
|
+
dimiNativePackage
|
|
394020
|
+
];
|
|
394042
394021
|
}));
|
|
394043
394022
|
//#endregion
|
|
394044
394023
|
//#region src/main-app.ts
|
|
@@ -394186,16 +394165,26 @@ if (process.env["DIMI_LEGACY"] !== "1" && !nativeBindingAvailable()) {
|
|
|
394186
394165
|
process.env["DIMI_LEGACY"] = "1";
|
|
394187
394166
|
process.stderr.write("dimi: native runtime unavailable (dimi_bridge.node not found); falling back to the legacy TypeScript backend. Reinstall or run \"dimi upgrade\" to get the Rust runtime.\n");
|
|
394188
394167
|
}
|
|
394189
|
-
|
|
394168
|
+
Promise.resolve().then(() => (init_main_app(), main_app_exports)).catch((error) => {
|
|
394169
|
+
process.stderr.write(`dimi: failed to start: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
394170
|
+
process.exit(1);
|
|
394171
|
+
});
|
|
394190
394172
|
/** Locate the napi binding without loading it. */
|
|
394191
394173
|
function nativeBindingAvailable() {
|
|
394192
|
-
const
|
|
394193
|
-
|
|
394174
|
+
const nodeRequire = createRequire(import.meta.url);
|
|
394175
|
+
try {
|
|
394176
|
+
const sea = nodeRequire("node:sea");
|
|
394177
|
+
if (typeof sea?.isSea === "function" && sea.isSea()) return true;
|
|
394178
|
+
} catch {}
|
|
394179
|
+
if (existsSync(resolve(dirname(fileURLToPath(import.meta.url)), "../dist/dimi_bridge.node"))) return true;
|
|
394194
394180
|
try {
|
|
394195
|
-
|
|
394196
|
-
|
|
394181
|
+
nodeRequire.resolve(`@dimi-agent/dimi-native-${process.platform}-${process.arch}`);
|
|
394182
|
+
return true;
|
|
394183
|
+
} catch {}
|
|
394184
|
+
try {
|
|
394185
|
+
if (existsSync(resolve(dirname(nodeRequire.resolve("@dimi-agent/dimi-native/package.json")), "dist/dimi_bridge.node"))) return true;
|
|
394197
394186
|
} catch {}
|
|
394198
|
-
return
|
|
394187
|
+
return false;
|
|
394199
394188
|
}
|
|
394200
394189
|
//#endregion
|
|
394201
394190
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dimi-agent/cli",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.5",
|
|
4
4
|
"description": "The Starting Point for Next-Gen Agents",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
},
|
|
28
28
|
"files": [
|
|
29
29
|
"dist",
|
|
30
|
+
"!dist/dimi_bridge.node",
|
|
30
31
|
"dist-web",
|
|
31
32
|
"native",
|
|
32
33
|
"README.md"
|
|
@@ -59,10 +60,10 @@
|
|
|
59
60
|
"tsx": "^4.21.0",
|
|
60
61
|
"yazl": "^3.3.1",
|
|
61
62
|
"zod": "^4.3.6",
|
|
62
|
-
"@dimi-agent/agent-core-v2": "^0.1.0",
|
|
63
|
-
"@dimi-agent/dimi-sdk": "^0.2.0",
|
|
64
63
|
"@dimi-agent/dimi-oauth": "^0.1.0",
|
|
64
|
+
"@dimi-agent/dimi-sdk": "^0.2.0",
|
|
65
65
|
"@dimi-agent/dimi-telemetry": "^0.1.0",
|
|
66
|
+
"@dimi-agent/agent-core-v2": "^0.1.0",
|
|
66
67
|
"@dimi-agent/dimi-web": "^0.1.0",
|
|
67
68
|
"@dimi-agent/pi-tui": "^0.1.0",
|
|
68
69
|
"@dimi-agent/remote": "^0.1.0",
|
|
@@ -70,7 +71,13 @@
|
|
|
70
71
|
},
|
|
71
72
|
"optionalDependencies": {
|
|
72
73
|
"@mariozechner/clipboard": "^0.3.9",
|
|
73
|
-
"node-pty": "^1.1.0"
|
|
74
|
+
"node-pty": "^1.1.0",
|
|
75
|
+
"@dimi-agent/dimi-native-darwin-arm64": ">=0.5.3 <1",
|
|
76
|
+
"@dimi-agent/dimi-native-darwin-x64": ">=0.5.3 <1",
|
|
77
|
+
"@dimi-agent/dimi-native-linux-x64": ">=0.5.3 <1",
|
|
78
|
+
"@dimi-agent/dimi-native-linux-arm64": ">=0.5.3 <1",
|
|
79
|
+
"@dimi-agent/dimi-native-win32-x64": ">=0.5.3 <1",
|
|
80
|
+
"@dimi-agent/dimi-native-win32-arm64": ">=0.5.3 <1"
|
|
74
81
|
},
|
|
75
82
|
"engines": {
|
|
76
83
|
"node": ">=22.19.0"
|
package/dist/dimi_bridge.node
DELETED
|
Binary file
|