@atlasharness/atlascode 0.1.65 → 0.1.66

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/cli.js +61 -6
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -37092,7 +37092,7 @@ function formatAgentLine(agent) {
37092
37092
  function getPrompt(agents) {
37093
37093
  const list = agents.length > 0 ? agents.map(formatAgentLine).join(`
37094
37094
  `) : "- general-purpose: General-purpose agent for researching and executing multi-step tasks.";
37095
- return "Launch a subagent to run a self-contained task in an isolated context. " + "Provide a short description (3-5 words) and a fully self-contained prompt " + "(the subagent cannot see this conversation). " + "Be cost-aware about delegating: prefer to do the work inline in this " + "conversation for a small task with a known, bounded target (a single-file " + "edit, a quick lookup, a change you can finish without broad exploration) — " + "spawning a subagent has overhead. Delegate when the task is genuinely " + "parallelizable or would otherwise flood this context with material you do " + "not need to keep (a broad multi-file search, an isolated multi-step " + "implementation, or independent work that can run alongside your own). Keep " + "each delegated brief narrow and evidence-focused: name the exact goal, the " + "files or area, and the expected deliverable rather than a broad " + '"figure this out." Because the subagent cannot see this conversation, its ' + "prompt must be fully self-contained — state every constraint, file, and " + "reporting requirement it needs. " + "Set run_in_background to true to launch a subagent that runs while you " + "continue working in this conversation; you will receive a task-notification " + "when it completes. Use this only for genuinely parallel work, not to defer " + "a result you need before you can proceed. " + `Available agent types and the tools they have access to:
37095
+ return "Launch a subagent to run a self-contained task in an isolated context. " + "Provide a short description (3-5 words) and a fully self-contained prompt " + "(the subagent cannot see this conversation). " + "Be cost-aware about delegating: prefer to do the work inline in this " + "conversation for a small task with a known, bounded target (a single-file " + "edit, a quick lookup, a change you can finish without broad exploration) — " + "spawning a subagent has overhead. Delegate when the task is genuinely " + "parallelizable or would otherwise flood this context with material you do " + "not need to keep (a broad multi-file search, an isolated multi-step " + "implementation, or independent work that can run alongside your own). Keep " + "each delegated brief narrow and evidence-focused: name the exact goal, the " + "files or area, and the expected deliverable rather than a broad " + '"figure this out." Because the subagent cannot see this conversation, its ' + "prompt must be fully self-contained — state every constraint, file, and " + "reporting requirement it needs. " + "Subagents run in the background by default; you will receive a " + "task-notification when one completes — do not poll or sleep waiting for " + "it. Set run_in_background to false only when you need the result before " + "you can proceed. Use background for genuinely parallel work, not to defer " + "a result you need immediately. " + `Available agent types and the tools they have access to:
37096
37096
  ${list}
37097
37097
  ` + `The ${AGENT_TOOL_NAME} tool runs the subagent and returns its final result ` + "when it completes; act on that result once it is returned. " + "Do not predict or assume what the subagent will find — wait for its " + "returned result and act on what it actually reports.";
37098
37098
  }
@@ -37204,8 +37204,44 @@ var init_runAgent = __esm(() => {
37204
37204
  init_localAgentTask();
37205
37205
  });
37206
37206
 
37207
+ // src/engine/tools/agent/backgroundTracker.ts
37208
+ function trackBackgroundAgent(p) {
37209
+ const handled = p.then(() => {}, () => {});
37210
+ pendingBackgroundAgents.add(handled);
37211
+ handled.finally(() => {
37212
+ pendingBackgroundAgents.delete(handled);
37213
+ });
37214
+ }
37215
+ function hasPendingBackgroundAgents() {
37216
+ return pendingBackgroundAgents.size > 0;
37217
+ }
37218
+ async function drainPendingBackgroundAgents(signal) {
37219
+ if (pendingBackgroundAgents.size === 0)
37220
+ return;
37221
+ const promises = Array.from(pendingBackgroundAgents);
37222
+ if (signal?.aborted)
37223
+ return;
37224
+ await Promise.allSettled(promises);
37225
+ }
37226
+ function resetBackgroundAgentTracker() {
37227
+ pendingBackgroundAgents.clear();
37228
+ }
37229
+ var pendingBackgroundAgents;
37230
+ var init_backgroundTracker = __esm(() => {
37231
+ pendingBackgroundAgents = new Set;
37232
+ });
37233
+
37207
37234
  // src/engine/tools/agent/AgentTool.ts
37208
37235
  import { randomUUID as randomUUID5 } from "crypto";
37236
+ function isAgentBackgroundByDefault() {
37237
+ return !isEnvTruthy(process.env.ATLAS_AGENT_DEFAULT_FOREGROUND);
37238
+ }
37239
+ function shouldRunInBackground(runInBg) {
37240
+ if (isAgentBackgroundByDefault()) {
37241
+ return runInBg !== false;
37242
+ }
37243
+ return !!runInBg;
37244
+ }
37209
37245
  function resolveAgentDefinition(subagentType, agents) {
37210
37246
  if (!subagentType)
37211
37247
  return GENERAL_PURPOSE_AGENT;
@@ -37229,6 +37265,8 @@ var init_AgentTool = __esm(() => {
37229
37265
  init_coordinator();
37230
37266
  init_task2();
37231
37267
  init_localAgentTask();
37268
+ init_shared();
37269
+ init_backgroundTracker();
37232
37270
  AGENT_TOOL_INPUT_SCHEMA = {
37233
37271
  type: "object",
37234
37272
  properties: {
@@ -37311,9 +37349,9 @@ var init_AgentTool = __esm(() => {
37311
37349
  const allowFanOut = isCoordinatorMode() && childSpawnDepth < MAX_WORKER_SPAWN_DEPTH;
37312
37350
  const resolvedTools = resolveAgentTools(agentDefinition, availableTools, allowFanOut).resolvedTools;
37313
37351
  const agentId = "agent-" + randomUUID5();
37314
- if (input.run_in_background) {
37352
+ if (shouldRunInBackground(input.run_in_background)) {
37315
37353
  const outputFile = getTaskOutputPath(agentId);
37316
- runAsyncAgentLifecycle({
37354
+ const bgPromise = runAsyncAgentLifecycle({
37317
37355
  agentDefinition,
37318
37356
  prompt: input.prompt,
37319
37357
  tools: resolvedTools,
@@ -37333,6 +37371,7 @@ var init_AgentTool = __esm(() => {
37333
37371
  error: err instanceof Error ? err.message : String(err)
37334
37372
  });
37335
37373
  });
37374
+ trackBackgroundAgent(bgPromise);
37336
37375
  return {
37337
37376
  data: {
37338
37377
  status: "async_launched",
@@ -51681,6 +51720,7 @@ var init_agent = __esm(() => {
51681
51720
  init_forkSubagent();
51682
51721
  init_agentToolUtils();
51683
51722
  init_prompt();
51723
+ init_backgroundTracker();
51684
51724
  });
51685
51725
 
51686
51726
  // src/engine/tools/bash/bashPrompt.ts
@@ -86946,6 +86986,7 @@ async function runHeadless(inputPrompt, options) {
86946
86986
  }
86947
86987
  cronScheduler.stop();
86948
86988
  await drainToOutput();
86989
+ await drainPendingBackgroundAgents(abortController.signal);
86949
86990
  } catch (error) {
86950
86991
  cronScheduler.stop();
86951
86992
  logForDebugging2(headlessErrorLine(error), { level: "error" });
@@ -180344,6 +180385,7 @@ __export(exports_engineCompat, {
180344
180385
  dequeueAllMatching: () => dequeueAllMatching,
180345
180386
  dequeuePendingNotification: () => dequeuePendingNotification,
180346
180387
  doesMessageExistInSession: () => doesMessageExistInSession,
180388
+ drainPendingBackgroundAgents: () => drainPendingBackgroundAgents,
180347
180389
  drainPendingMessages: () => drainPendingMessages,
180348
180390
  drainSdkEvents: () => drainSdkEvents,
180349
180391
  emitTaskTerminatedSdk: () => emitTaskTerminatedSdk,
@@ -180511,6 +180553,7 @@ __export(exports_engineCompat, {
180511
180553
  hasForegroundTasks: () => hasForegroundTasks,
180512
180554
  hasMetInitializationThreshold: () => hasMetInitializationThreshold,
180513
180555
  hasMetUpdateThreshold: () => hasMetUpdateThreshold,
180556
+ hasPendingBackgroundAgents: () => hasPendingBackgroundAgents,
180514
180557
  hasPendingNotifications: () => hasPendingNotifications,
180515
180558
  hasSessionMessagesCache: () => hasSessionMessagesCache,
180516
180559
  hasWorkingInProcessTeammates: () => hasWorkingInProcessTeammates,
@@ -180693,6 +180736,7 @@ __export(exports_engineCompat, {
180693
180736
  renderableSearchText: () => renderableSearchText,
180694
180737
  reportAutoCompactCircuitFailures: () => reportAutoCompactCircuitFailures,
180695
180738
  resetAutoCompactCircuitForTesting: () => resetAutoCompactCircuitForTesting,
180739
+ resetBackgroundAgentTracker: () => resetBackgroundAgentTracker,
180696
180740
  resetBuiltinCommandNamesSourceForTesting: () => resetBuiltinCommandNamesSourceForTesting,
180697
180741
  resetCheckInState: () => resetCheckInState,
180698
180742
  resetCommandQueue: () => resetCommandQueue,
@@ -180801,6 +180845,7 @@ __export(exports_engineCompat, {
180801
180845
  tokenCountWithEstimation: () => tokenCountWithEstimation,
180802
180846
  toolResultSearchText: () => toolResultSearchText,
180803
180847
  toolUseSearchText: () => toolUseSearchText,
180848
+ trackBackgroundAgent: () => trackBackgroundAgent,
180804
180849
  truncateHeadForPTLRetry: () => truncateHeadForPTLRetry,
180805
180850
  tryAcquireSchedulerLock: () => tryAcquireSchedulerLock,
180806
180851
  tryReactiveCompact: () => tryReactiveCompact,
@@ -276301,8 +276346,8 @@ ${whenNotToUseSection}
276301
276346
  Usage notes:
276302
276347
  - Always include a short description (3-5 words) summarizing what the agent will do${concurrencyNote}
276303
276348
  - When the agent is done, it will return a single message back to you. The result returned by the agent is not visible to the user. To show the user the result, you should send a text message back to the user with a concise summary of the result.${!isEnvTruthy2(process.env.ATLAS_DISABLE_BACKGROUND_TASKS) && !isInProcessTeammate3() && !forkEnabled ? `
276304
- - You can optionally run agents in the background using the run_in_background parameter. When an agent runs in the background, you will be automatically notified when it completes — do NOT sleep, poll, or proactively check on its progress. Continue with other work or respond to the user instead.
276305
- - **Foreground vs background**: Use foreground (default) when you need the agent's results before you can proceed — e.g., research agents whose findings inform your next steps. Use background when you have genuinely independent work to do in parallel.` : ""}
276349
+ - Agents run in the background by default. When an agent runs in the background, you will be automatically notified when it completes — do NOT sleep, poll, or proactively check on its progress. Continue with other work or respond to the user instead.
276350
+ - **Foreground vs background**: Agents run in the background by default. Use foreground (set run_in_background to false) when you need the agent's results before you can proceed — e.g., research agents whose findings inform your next steps. Use background when you have genuinely independent work to do in parallel.` : ""}
276306
276351
  - To continue a previously spawned agent, use ${SEND_MESSAGE_TOOL_NAME3} with the agent's ID or name as the \`to\` field. The agent resumes with its full context preserved. ${forkEnabled ? "Each fresh Agent invocation with a subagent_type starts without context — provide a complete task description." : "Each Agent invocation starts fresh — provide a complete task description."}
276307
276352
  - The agent's outputs should generally be trusted
276308
276353
  - Clearly tell the agent whether you expect it to write code or just to do research (search, file reads, web fetches, etc.)${forkEnabled ? "" : ", since it is not aware of the user's intent"}
@@ -276327,6 +276372,15 @@ var init_prompt13 = __esm(() => {
276327
276372
  });
276328
276373
 
276329
276374
  // src/tui/tools/AgentTool/AgentTool.ts
276375
+ function isAgentBackgroundByDefault2() {
276376
+ return !isEnvTruthy2(process.env.ATLAS_AGENT_DEFAULT_FOREGROUND);
276377
+ }
276378
+ function shouldRunInBackground2(runInBg) {
276379
+ if (isAgentBackgroundByDefault2()) {
276380
+ return runInBg !== false;
276381
+ }
276382
+ return !!runInBg;
276383
+ }
276330
276384
  function resolveAgentDefinition2(subagentType, agents) {
276331
276385
  if (!subagentType)
276332
276386
  return GENERAL_PURPOSE_AGENT2;
@@ -276359,6 +276413,7 @@ var init_AgentTool2 = __esm(() => {
276359
276413
  init_prompt13();
276360
276414
  init_runAgent2();
276361
276415
  init_UI9();
276416
+ init_envUtils2();
276362
276417
  inputSchema13 = lazySchema2(() => object({
276363
276418
  description: string2().describe("A short (3-5 word) description of the task"),
276364
276419
  prompt: string2().describe("The task for the agent to perform"),
@@ -276428,7 +276483,7 @@ var init_AgentTool2 = __esm(() => {
276428
276483
  },
276429
276484
  async call(args, context, canUseTool, parentMessage, onProgress) {
276430
276485
  const agents = getBuiltInAgents2();
276431
- const isAsync = !!args.run_in_background;
276486
+ const isAsync = shouldRunInBackground2(args.run_in_background);
276432
276487
  const agentId = createAgentId(args.description);
276433
276488
  const parentModel = context && context.options && (context.options.mainLoopModel || context.options.model) || "small";
276434
276489
  logForDebugging3("[AGENT] launching agent, type=" + (args.subagent_type ?? (isForkSubagentEnabled2() ? "fork" : "general-purpose")));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlasharness/atlascode",
3
- "version": "0.1.65",
3
+ "version": "0.1.66",
4
4
  "description": "AtlasCode \u2014 Coding Agent for the domestic computing ecosystem (Ascend NPU + domestic LLM backends)",
5
5
  "bin": {
6
6
  "atlas": "dist/cli.js",