@elizaos/plugin-agent-orchestrator 0.3.0 → 0.3.2

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 (79) hide show
  1. package/dist/index.js +58 -37
  2. package/dist/index.js.map +9 -9
  3. package/package.json +1 -1
  4. package/dist/actions/coding-task-handlers.d.ts +0 -44
  5. package/dist/actions/coding-task-handlers.d.ts.map +0 -1
  6. package/dist/actions/coding-task-helpers.d.ts +0 -27
  7. package/dist/actions/coding-task-helpers.d.ts.map +0 -1
  8. package/dist/actions/finalize-workspace.d.ts +0 -11
  9. package/dist/actions/finalize-workspace.d.ts.map +0 -1
  10. package/dist/actions/list-agents.d.ts +0 -11
  11. package/dist/actions/list-agents.d.ts.map +0 -1
  12. package/dist/actions/manage-issues.d.ts +0 -11
  13. package/dist/actions/manage-issues.d.ts.map +0 -1
  14. package/dist/actions/provision-workspace.d.ts +0 -11
  15. package/dist/actions/provision-workspace.d.ts.map +0 -1
  16. package/dist/actions/send-to-agent.d.ts +0 -11
  17. package/dist/actions/send-to-agent.d.ts.map +0 -1
  18. package/dist/actions/spawn-agent.d.ts +0 -11
  19. package/dist/actions/spawn-agent.d.ts.map +0 -1
  20. package/dist/actions/start-coding-task.d.ts +0 -17
  21. package/dist/actions/start-coding-task.d.ts.map +0 -1
  22. package/dist/actions/stop-agent.d.ts +0 -11
  23. package/dist/actions/stop-agent.d.ts.map +0 -1
  24. package/dist/api/agent-routes.d.ts +0 -18
  25. package/dist/api/agent-routes.d.ts.map +0 -1
  26. package/dist/api/coordinator-routes.d.ts +0 -22
  27. package/dist/api/coordinator-routes.d.ts.map +0 -1
  28. package/dist/api/issue-routes.d.ts +0 -17
  29. package/dist/api/issue-routes.d.ts.map +0 -1
  30. package/dist/api/routes.d.ts +0 -36
  31. package/dist/api/routes.d.ts.map +0 -1
  32. package/dist/api/workspace-routes.d.ts +0 -17
  33. package/dist/api/workspace-routes.d.ts.map +0 -1
  34. package/dist/index.d.ts +0 -33
  35. package/dist/index.d.ts.map +0 -1
  36. package/dist/providers/action-examples.d.ts +0 -13
  37. package/dist/providers/action-examples.d.ts.map +0 -1
  38. package/dist/providers/active-workspace-context.d.ts +0 -13
  39. package/dist/providers/active-workspace-context.d.ts.map +0 -1
  40. package/dist/services/agent-metrics.d.ts +0 -28
  41. package/dist/services/agent-metrics.d.ts.map +0 -1
  42. package/dist/services/agent-selection.d.ts +0 -53
  43. package/dist/services/agent-selection.d.ts.map +0 -1
  44. package/dist/services/ansi-utils.d.ts +0 -48
  45. package/dist/services/ansi-utils.d.ts.map +0 -1
  46. package/dist/services/pty-auto-response.d.ts +0 -30
  47. package/dist/services/pty-auto-response.d.ts.map +0 -1
  48. package/dist/services/pty-init.d.ts +0 -45
  49. package/dist/services/pty-init.d.ts.map +0 -1
  50. package/dist/services/pty-service.d.ts +0 -92
  51. package/dist/services/pty-service.d.ts.map +0 -1
  52. package/dist/services/pty-session-io.d.ts +0 -46
  53. package/dist/services/pty-session-io.d.ts.map +0 -1
  54. package/dist/services/pty-spawn.d.ts +0 -50
  55. package/dist/services/pty-spawn.d.ts.map +0 -1
  56. package/dist/services/pty-types.d.ts +0 -80
  57. package/dist/services/pty-types.d.ts.map +0 -1
  58. package/dist/services/stall-classifier.d.ts +0 -44
  59. package/dist/services/stall-classifier.d.ts.map +0 -1
  60. package/dist/services/swarm-coordinator-prompts.d.ts +0 -75
  61. package/dist/services/swarm-coordinator-prompts.d.ts.map +0 -1
  62. package/dist/services/swarm-coordinator.d.ts +0 -196
  63. package/dist/services/swarm-coordinator.d.ts.map +0 -1
  64. package/dist/services/swarm-decision-loop.d.ts +0 -44
  65. package/dist/services/swarm-decision-loop.d.ts.map +0 -1
  66. package/dist/services/swarm-event-triage.d.ts +0 -49
  67. package/dist/services/swarm-event-triage.d.ts.map +0 -1
  68. package/dist/services/swarm-idle-watchdog.d.ts +0 -22
  69. package/dist/services/swarm-idle-watchdog.d.ts.map +0 -1
  70. package/dist/services/workspace-git-ops.d.ts +0 -28
  71. package/dist/services/workspace-git-ops.d.ts.map +0 -1
  72. package/dist/services/workspace-github.d.ts +0 -58
  73. package/dist/services/workspace-github.d.ts.map +0 -1
  74. package/dist/services/workspace-lifecycle.d.ts +0 -18
  75. package/dist/services/workspace-lifecycle.d.ts.map +0 -1
  76. package/dist/services/workspace-service.d.ts +0 -84
  77. package/dist/services/workspace-service.d.ts.map +0 -1
  78. package/dist/services/workspace-types.d.ts +0 -81
  79. package/dist/services/workspace-types.d.ts.map +0 -1
package/dist/index.js CHANGED
@@ -115,7 +115,7 @@ function buildTurnCompletePrompt(taskCtx, turnOutput, decisionHistory) {
115
115
  ` + `Guidelines:\n` + `- BEFORE choosing "complete", enumerate each objective from the original task and verify ` + `evidence in the output. If ANY objective lacks evidence, use "respond" with the missing work.\n` + `- A PR being created does NOT mean the task is done \u2014 check that the PR covers ALL requested changes.
116
116
  ` + `- If the task mentions multiple features/fixes, verify EACH one is addressed, not just the first.\n` + `- If the agent only analyzed code or read files, it hasn't done the actual work yet \u2014 send a follow-up.
117
117
  ` + `- If the agent wrote code but didn't test it and testing seems appropriate, ask it to run tests.\n` + `- If the output shows errors or failed tests, send a follow-up to fix them.\n` + `- IMPORTANT: If the working directory is a git repository clone (not a scratch dir), the agent ` + `MUST commit its changes, push them, and create a pull request before the task can be "complete". ` + `If the output only shows code edits with no git commit or PR, respond with "Now commit your changes, push, and create a pull request".\n` + `- IMPORTANT: Creating a PR is NOT the final step. If this is the turn where the PR was created ` + `(i.e. "Created pull request" or a PR URL appears for the FIRST time and no previous decision ` + `already sent a review follow-up), respond with "Review your PR, run each test plan item to verify ` + `it works, update the PR to check off each item, then confirm all items pass".\n` + `- If a previous decision ALREADY sent a review/verification follow-up (check the decision history), ` + `and the agent has now responded with its review results, you MAY mark "complete" if the agent ` + `indicates the work is done (e.g. "Done", "verified", "all checks pass", "Here's what I did", ` + `or a clear summary of completed work). Do NOT require exact phrases \u2014 use judgment.
118
- ` + `- Keep follow-up instructions concise and specific.\n` + `- Default to "respond" \u2014 only use "complete" when you're certain ALL work is done.
118
+ ` + `- Keep follow-up instructions concise and specific.\n` + `- When asking agents to verify work, prefer CLI tools (gh, curl, cat, git diff, etc.) over ` + `browser automation. Browser tools may not be available in headless environments and can cause delays.\n` + `- Default to "respond" \u2014 only use "complete" when you're certain ALL work is done.
119
119
 
120
120
  ` + `Respond with ONLY a JSON object:\n` + `{"action": "respond|complete|escalate|ignore", "response": "...", "useKeys": false, "keys": [], "reasoning": "..."}`;
121
121
  }
@@ -135,7 +135,7 @@ function buildTurnCompleteEventMessage(taskCtx, turnOutput, decisionHistory) {
135
135
  ` + `- "escalate" \u2014 something looks wrong, ask the user
136
136
  ` + `- "ignore" \u2014 should not normally be used here
137
137
 
138
- ` + `Guidelines:\n` + `- Verify evidence for EVERY objective before using "complete".\n` + `- If code was written but not committed/pushed/PR'd, respond with next step.\n` + `- If a PR was just created, respond to review & verify test plan items.\n` + `- Default to "respond" \u2014 only "complete" when certain ALL work is done.
138
+ ` + `Guidelines:\n` + `- Verify evidence for EVERY objective before using "complete".\n` + `- If code was written but not committed/pushed/PR'd, respond with next step.\n` + `- If a PR was just created, respond to review & verify test plan items.\n` + `- When asking agents to verify work, prefer CLI tools (gh, curl, cat, etc.) over browser automation.\n` + `- Default to "respond" \u2014 only "complete" when certain ALL work is done.
139
139
 
140
140
  ` + `Include a JSON action block at the end of your response:\n` + "```json\n" + `{"action": "respond|complete|escalate|ignore", "response": "...", "useKeys": false, "keys": [], "reasoning": "..."}\n` + "```";
141
141
  }
@@ -425,7 +425,7 @@ async function executeDecision(ctx, sessionId, decision) {
425
425
  } catch {
426
426
  }
427
427
  ctx.sendChatMessage(summary ? `Finished "${taskCtx?.label ?? sessionId}".\n\n${summary}` : `Finished "${taskCtx?.label ?? sessionId}".`, "coding-agent");
428
- ctx.ptyService.stopSession(sessionId).catch((err) => {
428
+ ctx.ptyService.stopSession(sessionId, true).catch((err) => {
429
429
  ctx.log(`Failed to stop session after LLM-detected completion: ${err}`);
430
430
  });
431
431
  checkAllTasksComplete(ctx);
@@ -469,7 +469,7 @@ async function handleBlocked(ctx, sessionId, taskCtx, data) {
469
469
  });
470
470
  ctx.sendChatMessage(`[${taskCtx.label}] WARNING: Auto-approved access to path outside workspace (${taskCtx.workdir}). ` + `Prompt: "${promptText.slice(0, 150)}". Stopping session for safety.`, "coding-agent");
471
471
  taskCtx.status = "error";
472
- ctx.ptyService?.stopSession(sessionId).catch((err) => {
472
+ ctx.ptyService?.stopSession(sessionId, true).catch((err) => {
473
473
  ctx.log(`Failed to stop session after out-of-scope auto-approval: ${err}`);
474
474
  });
475
475
  return;
@@ -1980,6 +1980,14 @@ isBun,
1980
1980
  PTYManager,
1981
1981
  ShellAdapter
1982
1982
  } from "pty-manager";
1983
+ function forwardReadyAsTaskComplete(ctx, session) {
1984
+ if (!ctx.hasActiveTask?.(session.id) || !ctx.hasTaskActivity?.(session.id)) {
1985
+ return;
1986
+ }
1987
+ const response = ctx.taskResponseMarkers.has(session.id) ? captureTaskResponse(session.id, ctx.sessionOutputBuffers, ctx.taskResponseMarkers) : "";
1988
+ ctx.log(`session_ready for active task ${session.id} \u2014 forwarding as task_complete (stall classifier path, response: ${response.length} chars)`);
1989
+ ctx.emitEvent(session.id, "task_complete", { session, response });
1990
+ }
1983
1991
  async function initializePTYManager(ctx) {
1984
1992
  const usingBunWorker = isBun();
1985
1993
  if (usingBunWorker) {
@@ -1996,11 +2004,7 @@ async function initializePTYManager(ctx) {
1996
2004
  bunManager.on("session_ready", (session) => {
1997
2005
  ctx.log(`session_ready event received for ${session.id} (type: ${session.type}, status: ${session.status})`);
1998
2006
  ctx.emitEvent(session.id, "ready", { session });
1999
- if (ctx.hasActiveTask?.(session.id) && ctx.taskResponseMarkers.has(session.id)) {
2000
- const response = captureTaskResponse(session.id, ctx.sessionOutputBuffers, ctx.taskResponseMarkers);
2001
- ctx.log(`session_ready for active task ${session.id} \u2014 forwarding as task_complete (stall classifier path)`);
2002
- ctx.emitEvent(session.id, "task_complete", { session, response });
2003
- }
2007
+ forwardReadyAsTaskComplete(ctx, session);
2004
2008
  });
2005
2009
  bunManager.on("session_exit", (id, code) => {
2006
2010
  ctx.emitEvent(id, "stopped", { reason: `exit code ${code}` });
@@ -2079,11 +2083,7 @@ async function initializePTYManager(ctx) {
2079
2083
  }
2080
2084
  nodeManager.on("session_ready", (session) => {
2081
2085
  ctx.emitEvent(session.id, "ready", { session });
2082
- if (ctx.hasActiveTask?.(session.id) && ctx.taskResponseMarkers.has(session.id)) {
2083
- const response = captureTaskResponse(session.id, ctx.sessionOutputBuffers, ctx.taskResponseMarkers);
2084
- ctx.log(`session_ready for active task ${session.id} \u2014 forwarding as task_complete (stall classifier path)`);
2085
- ctx.emitEvent(session.id, "task_complete", { session, response });
2086
- }
2086
+ forwardReadyAsTaskComplete(ctx, session);
2087
2087
  });
2088
2088
  nodeManager.on("blocking_prompt", (session, promptInfo, autoResponded) => {
2089
2089
  ctx.emitEvent(session.id, "blocked", { promptInfo, autoResponded });
@@ -2151,26 +2151,40 @@ async function sendKeysToSession(ctx, sessionId, keys) {
2151
2151
  ptySession.sendKeys(keys);
2152
2152
  }
2153
2153
  }
2154
- async function stopSession(ctx, sessionId, sessionMetadata, sessionWorkdirs, log) {
2155
- const session = ctx.manager.get(sessionId);
2156
- if (!session) {
2157
- throw new Error(`Session ${sessionId} not found`);
2158
- }
2159
- if (ctx.usingBunWorker) {
2160
- await ctx.manager.kill(sessionId);
2161
- } else {
2162
- await ctx.manager.stop(sessionId);
2163
- }
2164
- const unsubscribe = ctx.outputUnsubscribers.get(sessionId);
2165
- if (unsubscribe) {
2166
- unsubscribe();
2154
+ async function stopSession(ctx, sessionId, sessionMetadata, sessionWorkdirs, log, force = false) {
2155
+ try {
2156
+ const session = ctx.manager.get(sessionId);
2157
+ if (!session) {
2158
+ throw new Error(`Session ${sessionId} not found`);
2159
+ }
2160
+ if (ctx.usingBunWorker) {
2161
+ if (force) {
2162
+ await ctx.manager.kill(sessionId, "SIGKILL");
2163
+ } else {
2164
+ await ctx.manager.kill(sessionId);
2165
+ }
2166
+ } else {
2167
+ if (force) {
2168
+ await ctx.manager.stop(sessionId, { force: true });
2169
+ } else {
2170
+ await ctx.manager.stop(sessionId);
2171
+ }
2172
+ }
2173
+ } finally {
2174
+ try {
2175
+ const unsubscribe = ctx.outputUnsubscribers.get(sessionId);
2176
+ if (unsubscribe) {
2177
+ unsubscribe();
2178
+ }
2179
+ } catch {
2180
+ }
2167
2181
  ctx.outputUnsubscribers.delete(sessionId);
2182
+ sessionMetadata.delete(sessionId);
2183
+ sessionWorkdirs.delete(sessionId);
2184
+ ctx.sessionOutputBuffers.delete(sessionId);
2185
+ ctx.taskResponseMarkers.delete(sessionId);
2186
+ log(`Stopped session ${sessionId}`);
2168
2187
  }
2169
- sessionMetadata.delete(sessionId);
2170
- sessionWorkdirs.delete(sessionId);
2171
- ctx.sessionOutputBuffers.delete(sessionId);
2172
- ctx.taskResponseMarkers.delete(sessionId);
2173
- log(`Stopped session ${sessionId}`);
2174
2188
  }
2175
2189
  function subscribeToOutput(ctx, sessionId, callback) {
2176
2190
  if (ctx.usingBunWorker) {
@@ -2579,7 +2593,7 @@ async function scanIdleSessions(ctx) {
2579
2593
  ctx.sendChatMessage(`[${taskCtx.label}] Session stopped \u2014 idle for ${idleMinutes} minutes with no progress.`, "coding-agent");
2580
2594
  if (ctx.ptyService) {
2581
2595
  try {
2582
- await ctx.ptyService.stopSession(taskCtx.sessionId);
2596
+ await ctx.ptyService.stopSession(taskCtx.sessionId, true);
2583
2597
  } catch (err) {
2584
2598
  ctx.log(`Idle watchdog: failed to stop session ${taskCtx.sessionId}: ${err}`);
2585
2599
  taskCtx.status = "error";
@@ -3193,6 +3207,13 @@ class PTYService {
3193
3207
  return false;
3194
3208
  const taskCtx = coordinator.getTaskContext(sessionId);
3195
3209
  return taskCtx?.status === "active";
3210
+ },
3211
+ hasTaskActivity: (sessionId) => {
3212
+ const coordinator = this.coordinator;
3213
+ if (!coordinator)
3214
+ return false;
3215
+ const taskCtx = coordinator.getTaskContext(sessionId);
3216
+ return (taskCtx?.decisions.length ?? 0) > 0;
3196
3217
  }
3197
3218
  });
3198
3219
  this.manager = result.manager;
@@ -3361,10 +3382,10 @@ class PTYService {
3361
3382
  throw new Error("PTYService not initialized");
3362
3383
  return sendKeysToSession(this.ioContext(), sessionId, keys);
3363
3384
  }
3364
- async stopSession(sessionId) {
3385
+ async stopSession(sessionId, force = false) {
3365
3386
  if (!this.manager)
3366
3387
  throw new Error("PTYService not initialized");
3367
- return stopSession(this.ioContext(), sessionId, this.sessionMetadata, this.sessionWorkdirs, (msg) => this.log(msg));
3388
+ return stopSession(this.ioContext(), sessionId, this.sessionMetadata, this.sessionWorkdirs, (msg) => this.log(msg), force);
3368
3389
  }
3369
3390
  get defaultApprovalPreset() {
3370
3391
  const fromEnv = this.runtime.getSetting("PARALLAX_DEFAULT_APPROVAL_PRESET");
@@ -3834,7 +3855,7 @@ function registerSessionEvents(ptyService, runtime, sessionId, label, scratchDir
3834
3855
  text: preview ? `Agent "${label}" completed the task.\n\n${preview}` : `Agent "${label}" completed the task.`
3835
3856
  });
3836
3857
  }
3837
- ptyService.stopSession(sessionId).catch((err) => {
3858
+ ptyService.stopSession(sessionId, true).catch((err) => {
3838
3859
  logger4.warn(`[START_CODING_TASK] Failed to stop session for "${label}" after task complete: ${err}`);
3839
3860
  });
3840
3861
  }
@@ -6059,5 +6080,5 @@ export {
6059
6080
  CodingWorkspaceService
6060
6081
  };
6061
6082
 
6062
- //# debugId=0100F6538A0A9D6264756E2164756E21
6083
+ //# debugId=BA5A6C5F800D868764756E2164756E21
6063
6084
  //# sourceMappingURL=index.js.map