@elizaos/plugin-agent-orchestrator 0.3.17 → 0.3.19

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.
@@ -1,8 +1,8 @@
1
1
  /**
2
2
  * Handler logic for the START_CODING_TASK action.
3
3
  *
4
- * - handleMultiAgent() -- Multi-agent mode (pipe-delimited `agents` param)
5
- * - handleSingleAgent() -- Single-agent mode (standard handler path)
4
+ * handleMultiAgent() handles both multi-agent and single-agent modes.
5
+ * A single-agent call is just a length-1 agent spec.
6
6
  *
7
7
  * @module actions/coding-task-handlers
8
8
  */
@@ -37,10 +37,4 @@ export interface CodingTaskContext {
37
37
  * workspace clone (or scratch directory).
38
38
  */
39
39
  export declare function handleMultiAgent(ctx: CodingTaskContext, agentsParam: string): Promise<ActionResult | undefined>;
40
- /**
41
- * Single-agent mode handler.
42
- *
43
- * Provisions a workspace (clone or scratch) and spawns a single coding agent.
44
- */
45
- export declare function handleSingleAgent(ctx: CodingTaskContext, task: string | undefined): Promise<ActionResult | undefined>;
46
40
  //# sourceMappingURL=coding-task-handlers.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"coding-task-handlers.d.ts","sourceRoot":"","sources":["../../src/actions/coding-task-handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,aAAa,EAElB,KAAK,MAAM,EAEX,KAAK,KAAK,EACX,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,gBAAgB,EAAkB,MAAM,uBAAuB,CAAC;AAC9E,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAE7D,OAAO,EACL,KAAK,eAAe,EAKrB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC/E,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAgI7E,0EAA0E;AAC1E,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,aAAa,CAAC;IACvB,UAAU,EAAE,UAAU,CAAC;IACvB,SAAS,EAAE,sBAAsB,GAAG,SAAS,CAAC;IAC9C,WAAW,EAAE,gBAAgB,CAAC;IAC9B,iBAAiB,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,SAAS,CAAC;IACtD,QAAQ,EAAE,eAAe,GAAG,SAAS,CAAC;IACtC,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,KAAK,GAAG,SAAS,CAAC;IACzB,IAAI,EAAE,MAAM,GAAG,SAAS,CAAC;IACzB,gBAAgB,EAAE,eAAe,CAAC;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,sBAAsB,EAAE,sBAAsB,CAAC;IAC/C,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;IAClC,cAAc,EAAE,MAAM,GAAG,SAAS,CAAC;IACnC,aAAa,EAAE,MAAM,GAAG,SAAS,CAAC;CACnC;AAED;;;;;GAKG;AACH,wBAAsB,gBAAgB,CACpC,GAAG,EAAE,iBAAiB,EACtB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CAyRnC;AAED;;;;GAIG;AACH,wBAAsB,iBAAiB,CACrC,GAAG,EAAE,iBAAiB,EACtB,IAAI,EAAE,MAAM,GAAG,SAAS,GACvB,OAAO,CAAC,YAAY,GAAG,SAAS,CAAC,CAgNnC"}
1
+ {"version":3,"file":"coding-task-handlers.d.ts","sourceRoot":"","sources":["../../src/actions/coding-task-handlers.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EACL,KAAK,YAAY,EACjB,KAAK,eAAe,EACpB,KAAK,aAAa,EAElB,KAAK,MAAM,EAEX,KAAK,KAAK,EACX,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EAAE,gBAAgB,EAAkB,MAAM,uBAAuB,CAAC;AAC9E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}
1
+ {"version":3,"file":"spawn-agent.d.ts","sourceRoot":"","sources":["../../src/actions/spawn-agent.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EACL,KAAK,MAAM,EAQZ,MAAM,eAAe,CAAC;AAavB,eAAO,MAAM,gBAAgB,EAAE,MA+U9B,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"start-coding-task.d.ts","sourceRoot":"","sources":["../../src/actions/start-coding-task.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EACV,MAAM,EAOP,MAAM,eAAe,CAAC;AAYvB,eAAO,MAAM,qBAAqB,EAAE,MAgPnC,CAAC"}
1
+ {"version":3,"file":"start-coding-task.d.ts","sourceRoot":"","sources":["../../src/actions/start-coding-task.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AAEH,OAAO,KAAK,EACV,MAAM,EAOP,MAAM,eAAe,CAAC;AAWvB,eAAO,MAAM,qBAAqB,EAAE,MAkPnC,CAAC"}
package/dist/index.js CHANGED
@@ -3400,6 +3400,7 @@ async function handleIdleCheck(ctx, taskCtx, idleMinutes) {
3400
3400
  var UNREGISTERED_BUFFER_MS = 2000;
3401
3401
  var IDLE_SCAN_INTERVAL_MS = 60 * 1000;
3402
3402
  var PAUSE_TIMEOUT_MS = 30000;
3403
+ var MAX_PRE_BRIDGE_BUFFER = 100;
3403
3404
  var STOPPED_RECOVERY_WINDOW_MS = 90000;
3404
3405
 
3405
3406
  class SwarmCoordinator {
@@ -3428,6 +3429,7 @@ class SwarmCoordinator {
3428
3429
  _swarmContext = "";
3429
3430
  swarmCompleteNotified = false;
3430
3431
  pauseBuffer = [];
3432
+ preBridgeBroadcastBuffer = [];
3431
3433
  pauseTimeout = null;
3432
3434
  constructor(runtime) {
3433
3435
  this.runtime = runtime;
@@ -3438,7 +3440,15 @@ class SwarmCoordinator {
3438
3440
  }
3439
3441
  setWsBroadcast(cb) {
3440
3442
  this.wsBroadcast = cb;
3441
- this.log("WS broadcast callback wired");
3443
+ if (this.preBridgeBroadcastBuffer.length > 0) {
3444
+ this.log(`WS broadcast callback wired — replaying ${this.preBridgeBroadcastBuffer.length} buffered event(s)`);
3445
+ for (const event of this.preBridgeBroadcastBuffer) {
3446
+ cb(event);
3447
+ }
3448
+ this.preBridgeBroadcastBuffer.length = 0;
3449
+ } else {
3450
+ this.log("WS broadcast callback wired");
3451
+ }
3442
3452
  }
3443
3453
  setSwarmCompleteCallback(cb) {
3444
3454
  this.swarmCompleteCb = cb;
@@ -3517,6 +3527,7 @@ class SwarmCoordinator {
3517
3527
  this.pauseTimeout = null;
3518
3528
  }
3519
3529
  this.pauseBuffer = [];
3530
+ this.preBridgeBroadcastBuffer.length = 0;
3520
3531
  this.log("SwarmCoordinator stopped");
3521
3532
  }
3522
3533
  get isPaused() {
@@ -3527,7 +3538,12 @@ class SwarmCoordinator {
3527
3538
  return;
3528
3539
  this._paused = true;
3529
3540
  this.log("Coordinator paused — buffering LLM decisions until user message is processed");
3530
- this.broadcast({ type: "coordinator_paused", sessionId: "", timestamp: Date.now(), data: {} });
3541
+ this.broadcast({
3542
+ type: "coordinator_paused",
3543
+ sessionId: "",
3544
+ timestamp: Date.now(),
3545
+ data: {}
3546
+ });
3531
3547
  this.pauseTimeout = setTimeout(() => {
3532
3548
  if (this._paused) {
3533
3549
  this.log("Coordinator auto-resuming after timeout");
@@ -3544,7 +3560,12 @@ class SwarmCoordinator {
3544
3560
  this.pauseTimeout = null;
3545
3561
  }
3546
3562
  this.log(`Coordinator resumed — replaying ${this.pauseBuffer.length} buffered events`);
3547
- this.broadcast({ type: "coordinator_resumed", sessionId: "", timestamp: Date.now(), data: {} });
3563
+ this.broadcast({
3564
+ type: "coordinator_resumed",
3565
+ sessionId: "",
3566
+ timestamp: Date.now(),
3567
+ data: {}
3568
+ });
3548
3569
  const buffered = [...this.pauseBuffer];
3549
3570
  this.pauseBuffer = [];
3550
3571
  for (const entry of buffered) {
@@ -3646,7 +3667,11 @@ class SwarmCoordinator {
3646
3667
  for (const d of dead) {
3647
3668
  this.sseClients.delete(d);
3648
3669
  }
3649
- this.wsBroadcast?.(event);
3670
+ if (this.wsBroadcast) {
3671
+ this.wsBroadcast(event);
3672
+ } else if (this.preBridgeBroadcastBuffer.length < MAX_PRE_BRIDGE_BUFFER) {
3673
+ this.preBridgeBroadcastBuffer.push(event);
3674
+ }
3650
3675
  }
3651
3676
  writeSseEvent(res, event) {
3652
3677
  try {
@@ -5165,7 +5190,8 @@ ${taskList}
5165
5190
  try {
5166
5191
  const result = await withTrajectoryContext(runtime, { source: "orchestrator", decisionType: "swarm-context-generation" }, () => runtime.useModel(ModelType5.TEXT_SMALL, {
5167
5192
  prompt,
5168
- temperature: 0.3
5193
+ temperature: 0.3,
5194
+ stream: false
5169
5195
  }));
5170
5196
  return result?.trim() || "";
5171
5197
  } catch (err) {
@@ -5192,12 +5218,7 @@ async function handleMultiAgent(ctx, agentsParam) {
5192
5218
  } = ctx;
5193
5219
  const agentSpecs = agentsParam.split("|").map((s) => s.trim()).filter(Boolean);
5194
5220
  if (agentSpecs.length === 0) {
5195
- if (callback) {
5196
- await callback({
5197
- text: "No agent tasks provided in agents parameter."
5198
- });
5199
- }
5200
- return { success: false, error: "EMPTY_AGENTS_PARAM" };
5221
+ agentSpecs.push("");
5201
5222
  }
5202
5223
  if (agentSpecs.length > MAX_CONCURRENT_AGENTS) {
5203
5224
  if (callback) {
@@ -5372,169 +5393,6 @@ ${swarmContext}
5372
5393
  data: { agents: results }
5373
5394
  };
5374
5395
  }
5375
- async function handleSingleAgent(ctx, task) {
5376
- logger6.debug(`[START_CODING_TASK] handleSingleAgent called, agentType=${ctx.defaultAgentType}, task=${task ? "yes" : "none"}, repo=${ctx.repo ?? "none"}`);
5377
- const {
5378
- runtime,
5379
- ptyService,
5380
- wsService,
5381
- credentials,
5382
- customCredentials,
5383
- callback,
5384
- message,
5385
- state,
5386
- repo,
5387
- defaultAgentType: agentType,
5388
- rawAgentType,
5389
- memoryContent,
5390
- approvalPreset,
5391
- explicitLabel
5392
- } = ctx;
5393
- const label = explicitLabel || generateLabel(repo, task);
5394
- let workdir;
5395
- let workspaceId;
5396
- let branch;
5397
- if (repo) {
5398
- if (!wsService) {
5399
- if (callback) {
5400
- await callback({
5401
- text: "Workspace Service is not available. Cannot clone repository."
5402
- });
5403
- }
5404
- return { success: false, error: "WORKSPACE_SERVICE_UNAVAILABLE" };
5405
- }
5406
- try {
5407
- if (callback) {
5408
- await callback({ text: `Cloning ${repo}...` });
5409
- }
5410
- const workspace = await wsService.provisionWorkspace({ repo });
5411
- workdir = workspace.path;
5412
- workspaceId = workspace.id;
5413
- branch = workspace.branch;
5414
- wsService.setLabel(workspace.id, label);
5415
- if (state) {
5416
- state.codingWorkspace = {
5417
- id: workspace.id,
5418
- path: workspace.path,
5419
- branch: workspace.branch,
5420
- isWorktree: workspace.isWorktree,
5421
- label
5422
- };
5423
- }
5424
- } catch (error) {
5425
- const errorMessage = error instanceof Error ? error.message : String(error);
5426
- if (callback) {
5427
- await callback({
5428
- text: `Failed to clone repository: ${errorMessage}`
5429
- });
5430
- }
5431
- return { success: false, error: errorMessage };
5432
- }
5433
- } else {
5434
- workdir = createScratchDir();
5435
- }
5436
- logger6.debug(`[START_CODING_TASK] Spawning ${agentType} agent, task: ${task ? `"${task.slice(0, 80)}..."` : "(none)"}, workdir: ${workdir}`);
5437
- try {
5438
- if (agentType !== "shell" && agentType !== "pi") {
5439
- const [preflight] = await ptyService.checkAvailableAgents([
5440
- agentType
5441
- ]);
5442
- if (preflight && !preflight.installed) {
5443
- logger6.warn(`[START_CODING_TASK] ${preflight.adapter} CLI not installed`);
5444
- if (callback) {
5445
- await callback({
5446
- text: `${preflight.adapter} CLI is not installed.
5447
- Install with: ${preflight.installCommand}
5448
- Docs: ${preflight.docsUrl}`
5449
- });
5450
- }
5451
- return { success: false, error: "AGENT_NOT_INSTALLED" };
5452
- }
5453
- logger6.debug(`[START_CODING_TASK] Preflight OK: ${preflight?.adapter} installed`);
5454
- }
5455
- const piRequested = isPiAgentType(rawAgentType);
5456
- const initialTask = piRequested ? toPiCommand(task) : task;
5457
- const displayType = piRequested ? "pi" : agentType;
5458
- const pastExperience = await queryPastExperience(runtime, {
5459
- taskDescription: task,
5460
- lookbackHours: 48,
5461
- maxEntries: 6,
5462
- repo
5463
- });
5464
- const pastExperienceBlock = formatPastExperience(pastExperience);
5465
- const agentMemory = [memoryContent, pastExperienceBlock].filter(Boolean).join(`
5466
-
5467
- `) || undefined;
5468
- const coordinator = getCoordinator(runtime);
5469
- logger6.debug(`[START_CODING_TASK] Calling spawnSession (${agentType}, coordinator=${!!coordinator})`);
5470
- const session = await ptyService.spawnSession({
5471
- name: `coding-${Date.now()}`,
5472
- agentType,
5473
- workdir,
5474
- initialTask,
5475
- memoryContent: agentMemory,
5476
- credentials,
5477
- approvalPreset: approvalPreset ?? ptyService.defaultApprovalPreset,
5478
- customCredentials,
5479
- ...coordinator ? { skipAdapterAutoResponse: true } : {},
5480
- metadata: {
5481
- requestedType: rawAgentType,
5482
- messageId: message.id,
5483
- userId: message.userId,
5484
- workspaceId,
5485
- label
5486
- }
5487
- });
5488
- logger6.debug(`[START_CODING_TASK] Session spawned: ${session.id} (${session.status})`);
5489
- const isScratchWorkspace = !repo;
5490
- const scratchDir = isScratchWorkspace ? workdir : null;
5491
- registerSessionEvents(ptyService, runtime, session.id, label, scratchDir, callback, !!coordinator);
5492
- if (coordinator && task) {
5493
- coordinator.registerTask(session.id, {
5494
- agentType,
5495
- label,
5496
- originalTask: task,
5497
- workdir,
5498
- repo
5499
- });
5500
- }
5501
- if (state) {
5502
- state.codingSession = {
5503
- id: session.id,
5504
- agentType: session.agentType,
5505
- workdir: session.workdir,
5506
- status: session.status
5507
- };
5508
- }
5509
- const summary = repo ? `Cloned ${repo} and started ${displayType} agent as "${label}"${task ? ` with task: "${task}"` : ""}` : `Started ${displayType} agent as "${label}" in scratch workspace${task ? ` with task: "${task}"` : ""}`;
5510
- if (callback) {
5511
- await callback({ text: `${summary}
5512
- Session ID: ${session.id}` });
5513
- }
5514
- return {
5515
- success: true,
5516
- text: summary,
5517
- data: {
5518
- sessionId: session.id,
5519
- agentType: displayType,
5520
- workdir: session.workdir,
5521
- workspaceId,
5522
- branch,
5523
- label,
5524
- status: session.status
5525
- }
5526
- };
5527
- } catch (error) {
5528
- const errorMessage = error instanceof Error ? error.message : String(error);
5529
- logger6.error("[START_CODING_TASK] Failed to spawn agent:", errorMessage);
5530
- if (callback) {
5531
- await callback({
5532
- text: `Failed to start coding agent: ${errorMessage}`
5533
- });
5534
- }
5535
- return { success: false, error: errorMessage };
5536
- }
5537
- }
5538
5396
 
5539
5397
  // src/actions/start-coding-task.ts
5540
5398
  var startCodingTaskAction = {
@@ -5654,7 +5512,8 @@ var startCodingTaskAction = {
5654
5512
  return handleMultiAgent(ctx, agentsParam);
5655
5513
  }
5656
5514
  const task = params?.task ?? content.task;
5657
- return handleSingleAgent(ctx, task);
5515
+ const singleAgentSpec = task || "";
5516
+ return handleMultiAgent(ctx, singleAgentSpec);
5658
5517
  },
5659
5518
  parameters: [
5660
5519
  {
@@ -7935,5 +7794,5 @@ export {
7935
7794
  CodingWorkspaceService
7936
7795
  };
7937
7796
 
7938
- //# debugId=9A77138F9177BAEA64756E2164756E21
7797
+ //# debugId=62DE82DAFB3D448A64756E2164756E21
7939
7798
  //# sourceMappingURL=index.js.map