omnius 1.0.381 → 1.0.383

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/index.js CHANGED
@@ -4820,6 +4820,17 @@ var init_shell = __esm({
4820
4820
  return lines.join("\n");
4821
4821
  }
4822
4822
  async finalizeResult(command, timeout2, start2, result) {
4823
+ const reportedExitCode = this.reportedExitCodeFromOutput(`${result.output ?? ""}
4824
+ ${result.llmContent ?? ""}`);
4825
+ if (result.success && reportedExitCode !== null && reportedExitCode !== 0) {
4826
+ const error = `Command reported non-zero exit marker ${reportedExitCode} despite wrapper exit 0.`;
4827
+ result = {
4828
+ ...result,
4829
+ success: false,
4830
+ error,
4831
+ llmContent: this.markTranscriptFailure(result.llmContent ?? result.output ?? "", reportedExitCode, error)
4832
+ };
4833
+ }
4823
4834
  if (this.isBenignPipePreviewSigpipe(command, result)) {
4824
4835
  const note = "[NOTE — preview pipe closed after producing output]\nA downstream preview command such as `head`/`tail`/`sed -n` closed the pipe early, producing SIGPIPE exit 141 upstream. Captured output is usable as a preview; rerun without the preview pipe if the full output is needed.";
4825
4836
  const output = result.output ? `${result.output}
@@ -4901,6 +4912,32 @@ ${elevatedResult.stderr}` : ""),
4901
4912
  }
4902
4913
  return result;
4903
4914
  }
4915
+ reportedExitCodeFromOutput(text2) {
4916
+ const matches = text2.matchAll(/(?:^|\n)\s*(?:__)?EXIT_CODE\s*=\s*(\d+)\s*(?:\n|$)/g);
4917
+ let found = null;
4918
+ for (const match of matches) {
4919
+ const value2 = Number(match[1]);
4920
+ if (Number.isInteger(value2))
4921
+ found = value2;
4922
+ }
4923
+ return found;
4924
+ }
4925
+ markTranscriptFailure(text2, exitCode, error) {
4926
+ if (!text2)
4927
+ return error;
4928
+ let next = text2;
4929
+ next = next.replace(/status: success/g, "status: failure");
4930
+ next = next.replace(/exit_code: 0/g, `exit_code: ${exitCode}`);
4931
+ if (!next.includes(`exit_code: ${exitCode}`)) {
4932
+ next = `${next}
4933
+ exit_code: ${exitCode}`;
4934
+ }
4935
+ if (!next.includes(error)) {
4936
+ next = `${next}
4937
+ error: ${error}`;
4938
+ }
4939
+ return next;
4940
+ }
4904
4941
  isBenignPipePreviewSigpipe(command, result) {
4905
4942
  if (result.success !== false)
4906
4943
  return false;
@@ -20357,18 +20394,18 @@ function detectStage(metrics2) {
20357
20394
  return "specialization";
20358
20395
  return "exploration";
20359
20396
  }
20360
- function thresholdsForStage(stage) {
20361
- return { ...STAGE_THRESHOLDS[stage] };
20397
+ function thresholdsForStage(stage2) {
20398
+ return { ...STAGE_THRESHOLDS[stage2] };
20362
20399
  }
20363
- function characteristicsForStage(stage) {
20364
- return { ...STAGE_CHARACTERISTICS[stage] };
20400
+ function characteristicsForStage(stage2) {
20401
+ return { ...STAGE_CHARACTERISTICS[stage2] };
20365
20402
  }
20366
20403
  function report(metrics2) {
20367
- const stage = detectStage(metrics2);
20368
- const thresholds = thresholdsForStage(stage);
20369
- const characteristics = characteristicsForStage(stage);
20370
- const nextStage = computeNextStage(stage, metrics2);
20371
- return { stage, metrics: metrics2, thresholds, characteristics, nextStage };
20404
+ const stage2 = detectStage(metrics2);
20405
+ const thresholds = thresholdsForStage(stage2);
20406
+ const characteristics = characteristicsForStage(stage2);
20407
+ const nextStage = computeNextStage(stage2, metrics2);
20408
+ return { stage: stage2, metrics: metrics2, thresholds, characteristics, nextStage };
20372
20409
  }
20373
20410
  function computeNextStage(current, m2) {
20374
20411
  const next = current === "exploration" ? "specialization" : current === "specialization" ? "integration" : current === "integration" ? "wisdom" : null;
@@ -21815,11 +21852,11 @@ var init_memoryStageContext = __esm({
21815
21852
  current;
21816
21853
  onStageChange;
21817
21854
  constructor(options2 = {}) {
21818
- const stage = options2.initialStage ?? "exploration";
21855
+ const stage2 = options2.initialStage ?? "exploration";
21819
21856
  this.current = {
21820
- stage,
21821
- thresholds: thresholdsForStage(stage),
21822
- characteristics: characteristicsForStage(stage),
21857
+ stage: stage2,
21858
+ thresholds: thresholdsForStage(stage2),
21859
+ characteristics: characteristicsForStage(stage2),
21823
21860
  computedAt: Date.now()
21824
21861
  };
21825
21862
  this.onStageChange = options2.onStageChange;
@@ -274668,12 +274705,12 @@ function parseStructuredProgress(text2) {
274668
274705
  const parsed = JSON.parse(trimmed);
274669
274706
  if (parsed["omnius_progress"] !== true)
274670
274707
  return null;
274671
- const stage = String(parsed["stage"] ?? "process");
274708
+ const stage2 = String(parsed["stage"] ?? "process");
274672
274709
  const message2 = String(parsed["message"] ?? "").trim();
274673
274710
  const percent = typeof parsed["percent"] === "number" ? parsed["percent"] : void 0;
274674
274711
  if (!message2)
274675
274712
  return null;
274676
- return { stage, message: message2, percent };
274713
+ return { stage: stage2, message: message2, percent };
274677
274714
  } catch {
274678
274715
  return null;
274679
274716
  }
@@ -277260,12 +277297,12 @@ async function runProcess3(command, args, options2) {
277260
277297
  }, 5e3);
277261
277298
  sigkillTimer.unref();
277262
277299
  };
277263
- const abortWithMessage = (message2, stage) => {
277300
+ const abortWithMessage = (message2, stage2) => {
277264
277301
  stderr += stderr.endsWith("\n") || stderr.length === 0 ? `${message2}
277265
277302
  ` : `
277266
277303
  ${message2}
277267
277304
  `;
277268
- options2.onProgress?.({ stage, message: message2, elapsedMs: Date.now() - startedAt2 });
277305
+ options2.onProgress?.({ stage: stage2, message: message2, elapsedMs: Date.now() - startedAt2 });
277269
277306
  terminateChild();
277270
277307
  finish({ code: 124, stdout, stderr }, { preserveSigkillTimer: true });
277271
277308
  };
@@ -281041,12 +281078,12 @@ function parseStructuredProgress2(text2) {
281041
281078
  const parsed = JSON.parse(trimmed);
281042
281079
  if (parsed["omnius_progress"] !== true)
281043
281080
  return null;
281044
- const stage = String(parsed["stage"] ?? "process");
281081
+ const stage2 = String(parsed["stage"] ?? "process");
281045
281082
  const message2 = String(parsed["message"] ?? "").trim();
281046
281083
  const percent = typeof parsed["percent"] === "number" ? parsed["percent"] : void 0;
281047
281084
  if (!message2)
281048
281085
  return null;
281049
- return { stage, message: message2, percent };
281086
+ return { stage: stage2, message: message2, percent };
281050
281087
  } catch {
281051
281088
  return null;
281052
281089
  }
@@ -284867,9 +284904,9 @@ No artifact created: provide prompt and/or input_image for ${kindLabel(kind)} ge
284867
284904
  brokerDecision
284868
284905
  };
284869
284906
  }
284870
- emit(start2, stage, message2, percent) {
284907
+ emit(start2, stage2, message2, percent) {
284871
284908
  this.progressCallback?.({
284872
- stage,
284909
+ stage: stage2,
284873
284910
  message: message2,
284874
284911
  percent,
284875
284912
  elapsedMs: performance.now() - start2
@@ -549127,7 +549164,7 @@ var init_agent_tool = __esm({
549127
549164
  _idCounter = 0;
549128
549165
  AgentTool = class {
549129
549166
  name = "agent";
549130
- description = "Spawn a sub-agent to handle a task autonomously. Sub-agents have their own context window and tool set, controlled by the agent type.\n\nAgent types:\n- general: Full tool access (minus agent spawning). For complex multi-step tasks.\n- explore: Read-only. Fast codebase search and analysis.\n- plan: Read-only. Returns structured implementation plans.\n- coordinator: Orchestrates teams of agents. Cannot edit files directly.\n\nUse run_in_background=true for parallel work. Check results via task_status/task_output.";
549167
+ description = "Spawn a sub-agent to handle a task autonomously. Sub-agents have their own context window and tool set, controlled by the agent type.\n\nAgent types:\n- general: Full tool access (minus agent spawning). For complex multi-step tasks.\n- explore: Read-only. Fast codebase search and analysis.\n- plan: Read-only. Returns structured implementation plans.\n- coordinator: Orchestrates teams of agents. Cannot edit files directly.\n\nDeployment patterns: optional named orchestration contracts such as sequential_pipeline, parallel_analysis, scatter_gather, maker_checker, debate_review, specialist_committee, hierarchical_crew, blackboard, task_swarm, and dynamic_task_ledger. Use them only when specialization, context isolation, parallelism, critique, or dynamic decomposition is structurally needed.\n\nUse run_in_background=true for parallel work. Check results via task_status/task_output.";
549131
549168
  parameters = {
549132
549169
  type: "object",
549133
549170
  properties: {
@@ -549140,6 +549177,14 @@ var init_agent_tool = __esm({
549140
549177
  enum: ["general", "explore", "plan", "coordinator"],
549141
549178
  description: "Agent type determining tool access and behavior (default: general)"
549142
549179
  },
549180
+ deployment_pattern: {
549181
+ type: "string",
549182
+ description: "Optional named sub-agent deployment pattern. Examples: single_worker, sequential_pipeline, parallel_analysis, scatter_gather, orchestrator_workers, maker_checker, debate_review, specialist_committee, hierarchical_crew, blackboard, task_swarm, dynamic_task_ledger. Multi-stage patterns auto-select coordinator when subagent_type is omitted."
549183
+ },
549184
+ pattern: {
549185
+ type: "string",
549186
+ description: "Compatibility alias for deployment_pattern. Prefer deployment_pattern."
549187
+ },
549143
549188
  run_in_background: {
549144
549189
  type: "boolean",
549145
549190
  description: "Run asynchronously, return task ID immediately (default: false)"
@@ -549184,7 +549229,8 @@ var init_agent_tool = __esm({
549184
549229
  async execute(args) {
549185
549230
  const start2 = performance.now();
549186
549231
  const prompt = String(args["prompt"] ?? "");
549187
- const subagentType = String(args["subagent_type"] ?? "general");
549232
+ const rawPattern = String(args["deployment_pattern"] ?? args["pattern"] ?? "").trim();
549233
+ let subagentType = String(args["subagent_type"] ?? "general");
549188
549234
  const runInBackground = Boolean(args["run_in_background"] ?? false);
549189
549235
  const modelOverride = args["model"] ? String(args["model"]) : void 0;
549190
549236
  const isolation = args["isolation"] ? String(args["isolation"]) : void 0;
@@ -549202,6 +549248,19 @@ var init_agent_tool = __esm({
549202
549248
  durationMs: performance.now() - start2
549203
549249
  };
549204
549250
  }
549251
+ const deploymentPattern = rawPattern ? this.callbacks.resolveDeploymentPattern?.(rawPattern, prompt) : void 0;
549252
+ if (rawPattern && !deploymentPattern) {
549253
+ const available = this.callbacks.listDeploymentPatterns?.().join(", ") || "(pattern registry unavailable)";
549254
+ return {
549255
+ success: false,
549256
+ output: "",
549257
+ error: `Unknown deployment pattern: ${rawPattern}. Available: ${available}`,
549258
+ durationMs: performance.now() - start2
549259
+ };
549260
+ }
549261
+ if (deploymentPattern?.coordinatorRequired && args["subagent_type"] === void 0) {
549262
+ subagentType = "coordinator";
549263
+ }
549205
549264
  const resolved = this.callbacks.resolveType(subagentType);
549206
549265
  if (!resolved) {
549207
549266
  const available = this.callbacks.listTypes().join(", ");
@@ -549260,11 +549319,15 @@ var init_agent_tool = __esm({
549260
549319
  }
549261
549320
  }
549262
549321
  const composedPrompt = (() => {
549263
- if (preloadedFiles.length === 0 && constraints.length === 0)
549322
+ if (preloadedFiles.length === 0 && constraints.length === 0 && !deploymentPattern)
549264
549323
  return prompt;
549265
549324
  const lines = [];
549266
549325
  lines.push("[Sub-Agent Handoff — parent has provided this scoped context]");
549267
549326
  lines.push("");
549327
+ if (deploymentPattern) {
549328
+ lines.push(deploymentPattern.instructions);
549329
+ lines.push("");
549330
+ }
549268
549331
  if (preloadedFiles.length > 0) {
549269
549332
  lines.push("## Pre-loaded files");
549270
549333
  lines.push("These files have already been read for you. Reference them directly without calling file_read.");
@@ -549319,6 +549382,7 @@ var init_agent_tool = __esm({
549319
549382
  systemPromptAddition: resolved.systemPromptAddition,
549320
549383
  relevantFiles: preloadedFiles,
549321
549384
  constraints,
549385
+ deploymentPattern: deploymentPattern?.pattern,
549322
549386
  subAgentMode: true
549323
549387
  }).then((result) => {
549324
549388
  this.callbacks?.onViewStatus?.(agentId, result.completed ? "completed" : "failed");
@@ -549349,6 +549413,7 @@ var init_agent_tool = __esm({
549349
549413
  systemPromptAddition: resolved.systemPromptAddition,
549350
549414
  relevantFiles: preloadedFiles,
549351
549415
  constraints,
549416
+ deploymentPattern: deploymentPattern?.pattern,
549352
549417
  subAgentMode: true
549353
549418
  });
549354
549419
  if (result.completed) {
@@ -566361,17 +566426,58 @@ function retentionStrength(note, now2 = Date.now()) {
566361
566426
  const retention = Math.exp(-ageH / Math.max(1, stability));
566362
566427
  return Math.min(1, Math.max(note.importance / 10 * 0.2, retention));
566363
566428
  }
566429
+ function hashFeature(s2) {
566430
+ let h = 2166136261;
566431
+ for (let i2 = 0; i2 < s2.length; i2++) {
566432
+ h ^= s2.charCodeAt(i2);
566433
+ h = Math.imul(h, 16777619);
566434
+ }
566435
+ return h >>> 0;
566436
+ }
566437
+ function textFeatures(text2) {
566438
+ const tokens = text2.toLowerCase().split(/[^\p{L}\p{N}_./-]+/u).map((t2) => t2.trim()).filter(Boolean);
566439
+ const features = [...tokens];
566440
+ for (let i2 = 0; i2 < tokens.length - 1; i2++) {
566441
+ features.push(`${tokens[i2]} ${tokens[i2 + 1]}`);
566442
+ }
566443
+ return features;
566444
+ }
566445
+ function textToHashEmbedding(text2, dimensions = DEFAULT_HASH_DIMS) {
566446
+ const dim = Math.max(8, Math.floor(dimensions));
566447
+ const vec = new Array(dim).fill(0);
566448
+ for (const feature of textFeatures(text2)) {
566449
+ const h = hashFeature(feature);
566450
+ const idx = h % dim;
566451
+ const sign2 = (h & 2147483648) === 0 ? 1 : -1;
566452
+ vec[idx] += sign2;
566453
+ }
566454
+ const norm = Math.sqrt(vec.reduce((sum, v) => sum + v * v, 0));
566455
+ if (!norm)
566456
+ return vec;
566457
+ return vec.map((v) => Math.round(v / norm * 1e6) / 1e6);
566458
+ }
566459
+ function relevanceScore(note, queryEmbedding) {
566460
+ if (!queryEmbedding)
566461
+ return 0.5;
566462
+ if (!note.embedding || note.embedding.length !== queryEmbedding.length)
566463
+ return 0;
566464
+ return Math.max(0, cosine3(note.embedding, queryEmbedding));
566465
+ }
566364
566466
  function scoreNote(note, opts = {}) {
566365
566467
  const now2 = opts.now ?? Date.now();
566366
566468
  const w = opts.weights ?? DEFAULT_WEIGHTS;
566367
566469
  const recency = retentionStrength(note, now2);
566368
566470
  const importance = Math.min(1, Math.max(0, note.importance / 10));
566369
- const relevance = opts.queryEmbedding && note.embedding ? Math.max(0, cosine3(note.embedding, opts.queryEmbedding)) : 0.5;
566471
+ const relevance = opts.queryEmbedding ? relevanceScore(note, opts.queryEmbedding) : 0.5;
566370
566472
  const total = w.recency * recency + w.importance * importance + w.relevance * relevance;
566371
566473
  return Math.round(total / (w.recency + w.importance + w.relevance) * 1e4) / 1e4;
566372
566474
  }
566373
566475
  function selectTopNotes(notes, k, opts) {
566374
- return [...notes].map((n2) => ({ n: n2, s: scoreNote(n2, opts) })).sort((a2, b) => b.s - a2.s).slice(0, Math.max(0, k)).map((x) => x.n);
566476
+ return [...notes].map((n2) => ({
566477
+ n: n2,
566478
+ s: scoreNote(n2, opts),
566479
+ r: relevanceScore(n2, opts?.queryEmbedding)
566480
+ })).filter(({ r: r2 }) => !opts?.queryEmbedding || opts.minRelevance === void 0 || r2 >= opts.minRelevance).sort((a2, b) => b.s - a2.s).slice(0, Math.max(0, k)).map((x) => x.n);
566375
566481
  }
566376
566482
  function findDuplicateGroups(notes, simThreshold = 0.92) {
566377
566483
  const groups = [];
@@ -566438,7 +566544,7 @@ function planConsolidation(notes, opts = {}) {
566438
566544
  }
566439
566545
  return { keep, prune, merge: merge2, distill };
566440
566546
  }
566441
- var HOUR, ImportanceBudget, DEFAULT_WEIGHTS;
566547
+ var HOUR, ImportanceBudget, DEFAULT_WEIGHTS, DEFAULT_HASH_DIMS;
566442
566548
  var init_memory_consolidation = __esm({
566443
566549
  "packages/orchestrator/dist/memory-consolidation.js"() {
566444
566550
  "use strict";
@@ -566465,6 +566571,7 @@ var init_memory_consolidation = __esm({
566465
566571
  }
566466
566572
  };
566467
566573
  DEFAULT_WEIGHTS = { recency: 1, importance: 1, relevance: 1 };
566574
+ DEFAULT_HASH_DIMS = 256;
566468
566575
  }
566469
566576
  });
566470
566577
 
@@ -566508,6 +566615,10 @@ function noteAfterTask(args) {
566508
566615
  createdAt: now2,
566509
566616
  lastAccessedMs: now2,
566510
566617
  accessCount: 0,
566618
+ embedding: textToHashEmbedding(`${args.summary || ""}
566619
+ ${(args.keywords ?? []).join(" ")}`),
566620
+ sourceSurface: args.sourceSurface,
566621
+ sourceKey: args.sourceKey,
566511
566622
  version: 1
566512
566623
  });
566513
566624
  const budget = new ImportanceBudget(THRESHOLD);
@@ -566555,11 +566666,28 @@ function noteAfterTask(args) {
566555
566666
  save2(store2);
566556
566667
  return result;
566557
566668
  }
566558
- function recallTopNotes(k = 5) {
566669
+ function ensureNoteEmbeddings(store2) {
566670
+ let changed = false;
566671
+ for (const note of store2.notes) {
566672
+ if (!Array.isArray(note.embedding) || note.embedding.length === 0) {
566673
+ note.embedding = textToHashEmbedding(`${note.content || ""}
566674
+ ${(note.keywords ?? []).join(" ")}`);
566675
+ changed = true;
566676
+ }
566677
+ }
566678
+ return changed;
566679
+ }
566680
+ function recallTopNotes(k = 5, opts = {}) {
566559
566681
  const store2 = load2();
566560
566682
  if (!store2.notes.length)
566561
566683
  return [];
566562
- const top = selectTopNotes(store2.notes, k);
566684
+ const changed = ensureNoteEmbeddings(store2);
566685
+ const queryEmbedding = opts.query ? textToHashEmbedding(opts.query) : void 0;
566686
+ const top = selectTopNotes(store2.notes, k, {
566687
+ queryEmbedding,
566688
+ minRelevance: queryEmbedding ? opts.minRelevance ?? 0.18 : void 0,
566689
+ weights: queryEmbedding ? { recency: 0.5, importance: 0.75, relevance: 2 } : void 0
566690
+ });
566563
566691
  const now2 = Date.now();
566564
566692
  const ids = new Set(top.map((n2) => n2.id));
566565
566693
  for (const n2 of store2.notes)
@@ -566567,11 +566695,12 @@ function recallTopNotes(k = 5) {
566567
566695
  n2.accessCount += 1;
566568
566696
  n2.lastAccessedMs = now2;
566569
566697
  }
566570
- save2(store2);
566698
+ if (changed || ids.size > 0)
566699
+ save2(store2);
566571
566700
  return top;
566572
566701
  }
566573
- function recallNotesBlock(k = 5) {
566574
- const top = recallTopNotes(k);
566702
+ function recallNotesBlock(k = 5, opts = {}) {
566703
+ const top = recallTopNotes(k, opts);
566575
566704
  if (!top.length)
566576
566705
  return "";
566577
566706
  const lines = top.map((n2) => `- (${n2.tier === "semantic" ? "learned" : "recent"}, imp ${n2.importance}) ${n2.content}`);
@@ -569258,6 +569387,8 @@ function violatesDirective(directive, input) {
569258
569387
  if (input.toolName === "task_complete") {
569259
569388
  return directive.state === "terminal_incomplete";
569260
569389
  }
569390
+ if (input.toolName === "ask_user")
569391
+ return false;
569261
569392
  const family = actionFamily(input.toolName, input.args);
569262
569393
  if (directive.forbiddenActionFamilies.includes(family))
569263
569394
  return true;
@@ -569267,20 +569398,41 @@ function violatesDirective(directive, input) {
569267
569398
  case "update_todos":
569268
569399
  return input.toolName !== "todo_write";
569269
569400
  case "read_authoritative_target":
569270
- return input.toolName !== "file_read";
569401
+ return !isEvidenceGatheringTool(input.toolName);
569271
569402
  case "run_verification":
569272
569403
  return input.toolName !== "shell";
569273
569404
  case "report_blocked":
569274
569405
  case "report_incomplete":
569275
- return input.toolName !== "task_complete";
569406
+ return !isReportTool(input.toolName);
569276
569407
  case "edit_different_target":
569277
- return input.toolName === "shell" || input.isReadLike || directive.forbiddenActionFamilies.includes(family);
569408
+ return !isEditTool(input.toolName) && !isEvidenceGatheringTool(input.toolName);
569278
569409
  case "use_cached_evidence":
569279
569410
  return directive.forbiddenActionFamilies.includes(family);
569280
569411
  default:
569281
569412
  return false;
569282
569413
  }
569283
569414
  }
569415
+ function isEvidenceGatheringTool(toolName) {
569416
+ return [
569417
+ "file_read",
569418
+ "grep_search",
569419
+ "find_files",
569420
+ "list_directory",
569421
+ "log_explore",
569422
+ "todo_write"
569423
+ ].includes(toolName);
569424
+ }
569425
+ function isEditTool(toolName) {
569426
+ return [
569427
+ "file_write",
569428
+ "file_edit",
569429
+ "file_patch",
569430
+ "batch_edit"
569431
+ ].includes(toolName);
569432
+ }
569433
+ function isReportTool(toolName) {
569434
+ return toolName === "task_complete" || toolName === "ask_user";
569435
+ }
569284
569436
  function actionFamily(toolName, args) {
569285
569437
  const target = args?.["path"] ?? args?.["file"] ?? args?.["filePath"] ?? args?.["file_path"] ?? args?.["command"] ?? args?.["cmd"] ?? "";
569286
569438
  return `${toolName}:${normalizeTarget(String(target ?? "")) || "no-target"}`;
@@ -569313,6 +569465,7 @@ var init_focusSupervisor = __esm({
569313
569465
  lastReason = "";
569314
569466
  lastContext = null;
569315
569467
  failureFamilies = /* @__PURE__ */ new Map();
569468
+ ignoredDirectiveStreak = 0;
569316
569469
  constructor(options2 = {}) {
569317
569470
  this.mode = options2.mode ?? "auto";
569318
569471
  this.modelTier = options2.modelTier ?? "large";
@@ -569361,13 +569514,15 @@ var init_focusSupervisor = __esm({
569361
569514
  const prior = this.directive;
569362
569515
  if (prior && violatesDirective(prior, input)) {
569363
569516
  prior.ignoredCount++;
569517
+ this.ignoredDirectiveStreak++;
569364
569518
  const strict = this.shouldStrictlyIntervene(input.context);
569365
569519
  if (strict && prior.ignoredCount >= 1) {
569520
+ const ignoredManyTimes = this.ignoredDirectiveStreak >= 3;
569366
569521
  const directive = this.setDirective({
569367
569522
  turn: input.turn,
569368
- state: "single_next_action",
569369
- reason: `model ignored prior directive ${prior.id}: ${prior.reason}`,
569370
- requiredNextAction: prior.requiredNextAction,
569523
+ state: ignoredManyTimes ? "verify_or_block" : "single_next_action",
569524
+ reason: ignoredManyTimes ? `model ignored ${this.ignoredDirectiveStreak} focus directives; report incomplete or ask for help instead of trying another variant` : `model ignored prior directive ${prior.id}; ${prior.reason}`,
569525
+ requiredNextAction: ignoredManyTimes ? "report_incomplete" : prior.requiredNextAction,
569371
569526
  forbiddenActionFamilies: unique2([
569372
569527
  ...prior.forbiddenActionFamilies,
569373
569528
  family
@@ -569403,7 +569558,7 @@ var init_focusSupervisor = __esm({
569403
569558
  turn: input.turn,
569404
569559
  state,
569405
569560
  reason: input.cachedResultFailed ? `cached failed ${input.toolName} evidence already exists` : `duplicate ${input.toolName} call has cached evidence`,
569406
- requiredNextAction: input.cachedResultFailed ? "edit_different_target" : "use_cached_evidence",
569561
+ requiredNextAction: input.cachedResultFailed ? "read_authoritative_target" : "use_cached_evidence",
569407
569562
  forbiddenActionFamilies: [family]
569408
569563
  });
569409
569564
  if (strict && !advisoryOnly && (input.cachedResultFailed || duplicateHitCount >= hitLimit)) {
@@ -569429,6 +569584,8 @@ var init_focusSupervisor = __esm({
569429
569584
  }
569430
569585
  this.lastDecision = "pass";
569431
569586
  this.lastReason = "";
569587
+ if (!this.directive)
569588
+ this.ignoredDirectiveStreak = 0;
569432
569589
  return this.pass();
569433
569590
  }
569434
569591
  observeToolResult(input) {
@@ -569550,6 +569707,7 @@ var init_focusSupervisor = __esm({
569550
569707
  this.lastReason = reason;
569551
569708
  this.directive = null;
569552
569709
  this.state = "observe";
569710
+ this.ignoredDirectiveStreak = 0;
569553
569711
  }
569554
569712
  pass() {
569555
569713
  return { kind: "pass", state: this.state, ...this.directive ? { directive: this.directive } : {} };
@@ -572867,11 +573025,11 @@ ${parts.join("\n")}
572867
573025
  }
572868
573026
  return "unknown";
572869
573027
  }
572870
- _recordContextWindowDump(stage, request, turn, attempt) {
573028
+ _recordContextWindowDump(stage2, request, turn, attempt) {
572871
573029
  const agentType = this.options.artifactMode === "internal" ? "internal" : this.options.subAgent || this.options.recursionDepth > 0 ? "sub-agent" : "main";
572872
573030
  const record = recordContextWindowDump({
572873
573031
  source: "agenticRunner",
572874
- stage,
573032
+ stage: stage2,
572875
573033
  agentType,
572876
573034
  sessionId: this._sessionId,
572877
573035
  runId: this._sessionId,
@@ -578443,7 +578601,7 @@ ${_fanout}`;
578443
578601
  } catch {
578444
578602
  }
578445
578603
  try {
578446
- const _notes = recallNotesBlock(5);
578604
+ const _notes = recallNotesBlock(5, { query: persistentTaskGoal });
578447
578605
  if (_notes)
578448
578606
  systemPrompt = `${systemPrompt}
578449
578607
 
@@ -578453,21 +578611,11 @@ ${_notes}`;
578453
578611
  try {
578454
578612
  if (!this.options.subAgent) {
578455
578613
  const _imp = Math.min(9, Math.max(3, 3 + Math.floor((persistentTaskGoal.length || 0) / 250)));
578456
- const _kw = String(persistentTaskGoal || "").toLowerCase().match(/[a-z][a-z0-9_-]{3,}/g)?.filter((w) => ![
578457
- "this",
578458
- "that",
578459
- "with",
578460
- "from",
578461
- "into",
578462
- "your",
578463
- "have",
578464
- "will",
578465
- "please"
578466
- ].includes(w)).slice(0, 6) ?? [];
578467
578614
  noteAfterTask({
578468
578615
  summary: `Task: ${persistentTaskGoal.slice(0, 200)}`,
578469
578616
  importance: _imp,
578470
- keywords: _kw
578617
+ sourceSurface: this._inferSurface(),
578618
+ sourceKey: this.options.stateDir ?? this.authoritativeWorkingDirectory()
578471
578619
  });
578472
578620
  }
578473
578621
  } catch {
@@ -592874,6 +593022,565 @@ var init_agent_types = __esm({
592874
593022
  }
592875
593023
  });
592876
593024
 
593025
+ // packages/orchestrator/dist/agent-patterns.js
593026
+ function stage(input) {
593027
+ return { required: true, ...input };
593028
+ }
593029
+ function buildDeploymentPatternInstructions(def, stages, task) {
593030
+ const lines = [
593031
+ "[Sub-Agent Deployment Pattern]",
593032
+ `pattern: ${def.pattern}`,
593033
+ `topology: ${def.topology}`,
593034
+ `task: ${task}`,
593035
+ `coordinator_required: ${def.coordinatorRequired}`,
593036
+ `max_agents: ${def.maxAgents}`,
593037
+ "",
593038
+ "Use this pattern only because the task needs specialization, isolation, parallelism, critique, or dynamic decomposition.",
593039
+ def.systemPromptAddition,
593040
+ "",
593041
+ "Stages:"
593042
+ ];
593043
+ for (const s2 of stages) {
593044
+ lines.push(`${s2.order}. ${s2.id} — ${s2.label}`, ` agent_type: ${s2.agentType}`, ` mode: ${s2.mode}${s2.parallelGroup ? ` (${s2.parallelGroup})` : ""}`, ` purpose: ${s2.purpose}`);
593045
+ if (s2.dependsOn?.length)
593046
+ lines.push(` depends_on: ${s2.dependsOn.join(", ")}`);
593047
+ lines.push(" output_contract:");
593048
+ for (const item of s2.outputContract)
593049
+ lines.push(` - ${item}`);
593050
+ }
593051
+ lines.push("", "Coordinator contract:", "- Keep worker prompts narrow and self-contained.", "- Run independent stages in parallel only when their write sets do not overlap.", "- Validate each handoff before starting dependent stages.", "- Preserve dissent, failures, and unresolved blockers in the final synthesis.", "- Complete only with evidence from worker outputs and verification.");
593052
+ return lines.join("\n");
593053
+ }
593054
+ function getAgentDeploymentPatternRegistry() {
593055
+ return _patternRegistry;
593056
+ }
593057
+ function registerAgentDeploymentPattern(def) {
593058
+ _patternRegistry.register(def);
593059
+ }
593060
+ function getAgentDeploymentPattern(pattern) {
593061
+ return _patternRegistry.get(pattern);
593062
+ }
593063
+ function planAgentDeploymentPattern(pattern, task) {
593064
+ return _patternRegistry.plan(pattern, task);
593065
+ }
593066
+ function buildAgentDeploymentPatternSummary() {
593067
+ return _patternRegistry.buildPatternSummary();
593068
+ }
593069
+ var BUILT_INS, AgentDeploymentPatternRegistry, _patternRegistry;
593070
+ var init_agent_patterns = __esm({
593071
+ "packages/orchestrator/dist/agent-patterns.js"() {
593072
+ "use strict";
593073
+ init_agent_types();
593074
+ BUILT_INS = [
593075
+ {
593076
+ pattern: "single_worker",
593077
+ aliases: ["single", "direct_worker"],
593078
+ description: "One bounded worker owns the delegated task.",
593079
+ topology: "single",
593080
+ useWhen: ["The task is narrow enough for one context window."],
593081
+ avoidWhen: ["Independent critique, parallel search, or separate permissions are required."],
593082
+ coordinatorRequired: false,
593083
+ maxAgents: 1,
593084
+ systemPromptAddition: "Use the least autonomous design: one focused worker, scoped evidence, then task_complete.",
593085
+ stages: [
593086
+ stage({
593087
+ id: "worker",
593088
+ label: "Focused worker",
593089
+ agentType: "general",
593090
+ purpose: "Complete the delegated task inside one scoped context.",
593091
+ order: 1,
593092
+ mode: "sequential",
593093
+ outputContract: ["Summary of changes or findings", "Verification evidence", "Open blockers"]
593094
+ })
593095
+ ]
593096
+ },
593097
+ {
593098
+ pattern: "sequential_pipeline",
593099
+ aliases: ["pipeline", "planner_executor_reporter"],
593100
+ description: "Fixed-order handoff where each stage validates and passes compact output forward.",
593101
+ topology: "sequential",
593102
+ useWhen: ["The workflow order is known and each handoff can be validated."],
593103
+ avoidWhen: ["Stages are independent and should run in parallel."],
593104
+ coordinatorRequired: true,
593105
+ maxAgents: 3,
593106
+ systemPromptAddition: "Run a fixed sequence. Do not skip handoff validation between stages.",
593107
+ stages: [
593108
+ stage({
593109
+ id: "plan",
593110
+ label: "Planner",
593111
+ agentType: "plan",
593112
+ purpose: "Produce a compact implementation or investigation plan.",
593113
+ order: 1,
593114
+ mode: "sequential",
593115
+ outputContract: ["Concrete steps", "Files or systems to inspect", "Verification plan"]
593116
+ }),
593117
+ stage({
593118
+ id: "execute",
593119
+ label: "Executor",
593120
+ agentType: "general",
593121
+ purpose: "Execute the approved plan.",
593122
+ order: 2,
593123
+ mode: "sequential",
593124
+ dependsOn: ["plan"],
593125
+ outputContract: ["Work performed", "Files modified", "Commands/tests run"]
593126
+ }),
593127
+ stage({
593128
+ id: "report",
593129
+ label: "Reporter",
593130
+ agentType: "explore",
593131
+ purpose: "Check resulting evidence and summarize final state.",
593132
+ order: 3,
593133
+ mode: "review",
593134
+ dependsOn: ["execute"],
593135
+ outputContract: ["Evidence-backed result", "Residual risks", "Suggested next steps"]
593136
+ })
593137
+ ]
593138
+ },
593139
+ {
593140
+ pattern: "parallel_analysis",
593141
+ aliases: ["concurrent_analysis", "sectioning"],
593142
+ description: "Run independent specialists in parallel and aggregate disagreements explicitly.",
593143
+ topology: "parallel",
593144
+ useWhen: ["Independent perspectives or code regions can be analyzed separately."],
593145
+ avoidWhen: ["Workers must mutate the same files without a merge owner."],
593146
+ coordinatorRequired: true,
593147
+ maxAgents: 5,
593148
+ systemPromptAddition: "Launch independent read-only or scoped workers in parallel, then aggregate explicitly.",
593149
+ stages: [
593150
+ stage({
593151
+ id: "explorer_a",
593152
+ label: "Explorer A",
593153
+ agentType: "explore",
593154
+ purpose: "Inspect the first region or perspective.",
593155
+ order: 1,
593156
+ mode: "parallel",
593157
+ parallelGroup: "analysis",
593158
+ outputContract: ["Findings", "Source paths", "Confidence"]
593159
+ }),
593160
+ stage({
593161
+ id: "explorer_b",
593162
+ label: "Explorer B",
593163
+ agentType: "explore",
593164
+ purpose: "Inspect the second region or perspective.",
593165
+ order: 1,
593166
+ mode: "parallel",
593167
+ parallelGroup: "analysis",
593168
+ outputContract: ["Findings", "Source paths", "Confidence"]
593169
+ }),
593170
+ stage({
593171
+ id: "aggregate",
593172
+ label: "Aggregator",
593173
+ agentType: "plan",
593174
+ purpose: "Merge findings, preserve disagreements, and recommend next action.",
593175
+ order: 2,
593176
+ mode: "aggregate",
593177
+ dependsOn: ["explorer_a", "explorer_b"],
593178
+ outputContract: ["Merged conclusion", "Disagreements", "Evidence list"]
593179
+ })
593180
+ ]
593181
+ },
593182
+ {
593183
+ pattern: "scatter_gather",
593184
+ aliases: ["map_reduce", "fanout_reduce"],
593185
+ description: "Fan out over many files/regions, then reduce into one compact result.",
593186
+ topology: "scatter_gather",
593187
+ useWhen: ["The input corpus is too large for one context window."],
593188
+ avoidWhen: ["Only one or two files are relevant."],
593189
+ coordinatorRequired: true,
593190
+ maxAgents: 8,
593191
+ systemPromptAddition: "Partition by source/region, require provenance from every mapper, then reduce deterministically.",
593192
+ stages: [
593193
+ stage({
593194
+ id: "map",
593195
+ label: "Mapper workers",
593196
+ agentType: "explore",
593197
+ purpose: "Process assigned partitions independently.",
593198
+ order: 1,
593199
+ mode: "parallel",
593200
+ parallelGroup: "map",
593201
+ outputContract: ["Partition id", "Relevant paths", "Distilled findings"]
593202
+ }),
593203
+ stage({
593204
+ id: "reduce",
593205
+ label: "Reducer",
593206
+ agentType: "plan",
593207
+ purpose: "Dedupe and synthesize mapper outputs.",
593208
+ order: 2,
593209
+ mode: "aggregate",
593210
+ dependsOn: ["map"],
593211
+ outputContract: ["Deduped paths", "Synthesis", "Empty partitions"]
593212
+ })
593213
+ ]
593214
+ },
593215
+ {
593216
+ pattern: "orchestrator_workers",
593217
+ aliases: ["manager_workers", "manager_agents_as_tools"],
593218
+ description: "A coordinator decomposes unknown subtasks and owns final synthesis.",
593219
+ topology: "orchestrator_workers",
593220
+ useWhen: ["Subtasks are not fully known upfront."],
593221
+ avoidWhen: ["The task can be expressed as a fixed sequence."],
593222
+ coordinatorRequired: true,
593223
+ maxAgents: 6,
593224
+ systemPromptAddition: "The coordinator owns decomposition, worker scope, progress ledger, and final synthesis.",
593225
+ stages: [
593226
+ stage({
593227
+ id: "coordinate",
593228
+ label: "Coordinator",
593229
+ agentType: "coordinator",
593230
+ purpose: "Maintain task ledger and dispatch narrow workers.",
593231
+ order: 1,
593232
+ mode: "coordinate",
593233
+ outputContract: ["Task ledger", "Worker assignments", "Completion criteria"]
593234
+ }),
593235
+ stage({
593236
+ id: "workers",
593237
+ label: "Workers",
593238
+ agentType: "general",
593239
+ purpose: "Execute scoped subtasks assigned by the coordinator.",
593240
+ order: 2,
593241
+ mode: "parallel",
593242
+ dependsOn: ["coordinate"],
593243
+ outputContract: ["Scoped result", "Files touched", "Verification evidence"]
593244
+ })
593245
+ ]
593246
+ },
593247
+ {
593248
+ pattern: "maker_checker",
593249
+ aliases: ["make_check", "generator_reviewer"],
593250
+ description: "One worker produces, an independent checker validates before completion.",
593251
+ topology: "maker_checker",
593252
+ useWhen: ["Quality, policy, or correctness needs an independent review."],
593253
+ avoidWhen: ["There is no clear checkable output."],
593254
+ coordinatorRequired: true,
593255
+ maxAgents: 2,
593256
+ systemPromptAddition: "Keep maker and checker independent. Prefer deterministic tests over model judgment when available.",
593257
+ stages: [
593258
+ stage({
593259
+ id: "maker",
593260
+ label: "Maker",
593261
+ agentType: "general",
593262
+ purpose: "Implement or draft the requested artifact.",
593263
+ order: 1,
593264
+ mode: "sequential",
593265
+ outputContract: ["Produced artifact", "Implementation notes", "Verification run"]
593266
+ }),
593267
+ stage({
593268
+ id: "checker",
593269
+ label: "Checker",
593270
+ agentType: "explore",
593271
+ purpose: "Validate the maker output without sharing the maker prompt as hidden state.",
593272
+ order: 2,
593273
+ mode: "review",
593274
+ dependsOn: ["maker"],
593275
+ outputContract: ["Pass/fail", "Findings with evidence", "Required fixes"]
593276
+ })
593277
+ ]
593278
+ },
593279
+ {
593280
+ pattern: "debate_review",
593281
+ aliases: ["adversarial_review", "debate"],
593282
+ description: "Assign competing positions, then synthesize with evidence.",
593283
+ topology: "debate",
593284
+ useWhen: ["The decision is ambiguous or confirmation bias is likely."],
593285
+ avoidWhen: ["The task is a straightforward implementation with objective tests."],
593286
+ coordinatorRequired: true,
593287
+ maxAgents: 4,
593288
+ systemPromptAddition: "Assign explicit positions, require evidence for claims, then synthesize neutrally.",
593289
+ stages: [
593290
+ stage({
593291
+ id: "pro",
593292
+ label: "Pro advocate",
593293
+ agentType: "plan",
593294
+ purpose: "Argue for the proposed approach using evidence.",
593295
+ order: 1,
593296
+ mode: "parallel",
593297
+ parallelGroup: "debate",
593298
+ outputContract: ["Argument", "Evidence", "Assumptions"]
593299
+ }),
593300
+ stage({
593301
+ id: "con",
593302
+ label: "Risk advocate",
593303
+ agentType: "plan",
593304
+ purpose: "Argue against the proposed approach and surface risks.",
593305
+ order: 1,
593306
+ mode: "parallel",
593307
+ parallelGroup: "debate",
593308
+ outputContract: ["Counterargument", "Evidence", "Risks"]
593309
+ }),
593310
+ stage({
593311
+ id: "synthesis",
593312
+ label: "Neutral synthesizer",
593313
+ agentType: "plan",
593314
+ purpose: "Resolve the debate and state the decision criteria.",
593315
+ order: 2,
593316
+ mode: "aggregate",
593317
+ dependsOn: ["pro", "con"],
593318
+ outputContract: ["Decision", "Tradeoffs", "Dissent preserved"]
593319
+ })
593320
+ ]
593321
+ },
593322
+ {
593323
+ pattern: "specialist_committee",
593324
+ aliases: ["committee", "aggregator"],
593325
+ description: "Domain specialists produce findings; an aggregator preserves evidence and dissent.",
593326
+ topology: "committee",
593327
+ useWhen: ["The problem spans multiple domains or risk lenses."],
593328
+ avoidWhen: ["The domain is singular and objective tests are available."],
593329
+ coordinatorRequired: true,
593330
+ maxAgents: 6,
593331
+ systemPromptAddition: "Specialists must state assumptions, evidence, uncertainty, and dissent.",
593332
+ stages: [
593333
+ stage({
593334
+ id: "technical",
593335
+ label: "Technical specialist",
593336
+ agentType: "general",
593337
+ purpose: "Assess implementation feasibility and constraints.",
593338
+ order: 1,
593339
+ mode: "parallel",
593340
+ parallelGroup: "committee",
593341
+ outputContract: ["Technical findings", "Evidence", "Uncertainty"]
593342
+ }),
593343
+ stage({
593344
+ id: "risk",
593345
+ label: "Risk specialist",
593346
+ agentType: "explore",
593347
+ purpose: "Assess safety, operational, or regression risks.",
593348
+ order: 1,
593349
+ mode: "parallel",
593350
+ parallelGroup: "committee",
593351
+ outputContract: ["Risks", "Evidence", "Mitigations"]
593352
+ }),
593353
+ stage({
593354
+ id: "aggregate",
593355
+ label: "Aggregator",
593356
+ agentType: "plan",
593357
+ purpose: "Synthesize specialist findings and preserve disagreements.",
593358
+ order: 2,
593359
+ mode: "aggregate",
593360
+ dependsOn: ["technical", "risk"],
593361
+ outputContract: ["Synthesis", "Dissent", "Recommendation"]
593362
+ })
593363
+ ]
593364
+ },
593365
+ {
593366
+ pattern: "hierarchical_crew",
593367
+ aliases: ["crew", "multi_team"],
593368
+ description: "A coordinator manages subcrews for large multi-domain work.",
593369
+ topology: "hierarchical",
593370
+ useWhen: ["The task is large, multi-domain, and decomposable."],
593371
+ avoidWhen: ["A flat worker set is enough."],
593372
+ coordinatorRequired: true,
593373
+ maxAgents: 10,
593374
+ systemPromptAddition: "Define hierarchy, responsibilities, checkpoints, and stop conditions before spawning subcrews.",
593375
+ stages: [
593376
+ stage({
593377
+ id: "lead",
593378
+ label: "Crew lead",
593379
+ agentType: "coordinator",
593380
+ purpose: "Own hierarchy, checkpoints, and final integration.",
593381
+ order: 1,
593382
+ mode: "coordinate",
593383
+ outputContract: ["Hierarchy", "Responsibilities", "Checkpoints"]
593384
+ }),
593385
+ stage({
593386
+ id: "subcrews",
593387
+ label: "Subcrew workers",
593388
+ agentType: "general",
593389
+ purpose: "Execute scoped domain work under the lead.",
593390
+ order: 2,
593391
+ mode: "parallel",
593392
+ dependsOn: ["lead"],
593393
+ outputContract: ["Domain result", "Verification", "Blockers"]
593394
+ })
593395
+ ]
593396
+ },
593397
+ {
593398
+ pattern: "blackboard",
593399
+ aliases: ["shared_workspace"],
593400
+ description: "Workers coordinate through a structured shared artifact.",
593401
+ topology: "blackboard",
593402
+ useWhen: ["Multiple agents must update a common evolving state."],
593403
+ avoidWhen: ["Workers can return independent final outputs without coordination."],
593404
+ coordinatorRequired: true,
593405
+ maxAgents: 6,
593406
+ systemPromptAddition: "Use a structured blackboard with author, timestamp, source, confidence, and conflict fields.",
593407
+ stages: [
593408
+ stage({
593409
+ id: "board_init",
593410
+ label: "Board initializer",
593411
+ agentType: "plan",
593412
+ purpose: "Create the shared artifact schema and initial task lanes.",
593413
+ order: 1,
593414
+ mode: "sequential",
593415
+ outputContract: ["Board schema", "Task lanes", "Conflict policy"]
593416
+ }),
593417
+ stage({
593418
+ id: "contributors",
593419
+ label: "Contributors",
593420
+ agentType: "general",
593421
+ purpose: "Write structured entries to the board without conflicting writes.",
593422
+ order: 2,
593423
+ mode: "parallel",
593424
+ dependsOn: ["board_init"],
593425
+ outputContract: ["Board entries", "Sources", "Confidence"]
593426
+ })
593427
+ ]
593428
+ },
593429
+ {
593430
+ pattern: "task_swarm",
593431
+ aliases: ["swarm"],
593432
+ description: "Many small stateless workers process granular queued tasks.",
593433
+ topology: "swarm",
593434
+ useWhen: ["The workload is large, partitionable, and homogeneous."],
593435
+ avoidWhen: ["Workers need shared mutable state or nuanced coordination."],
593436
+ coordinatorRequired: true,
593437
+ maxAgents: 12,
593438
+ systemPromptAddition: "Keep swarm workers stateless, cap fan-out, aggregate deterministically, and monitor cost.",
593439
+ stages: [
593440
+ stage({
593441
+ id: "queue",
593442
+ label: "Queue planner",
593443
+ agentType: "plan",
593444
+ purpose: "Partition work into small independent units.",
593445
+ order: 1,
593446
+ mode: "sequential",
593447
+ outputContract: ["Queue entries", "Unit success criteria", "Fan-out cap"]
593448
+ }),
593449
+ stage({
593450
+ id: "workers",
593451
+ label: "Swarm workers",
593452
+ agentType: "explore",
593453
+ purpose: "Process assigned units independently.",
593454
+ order: 2,
593455
+ mode: "parallel",
593456
+ dependsOn: ["queue"],
593457
+ outputContract: ["Unit id", "Result", "Failure reason"]
593458
+ })
593459
+ ]
593460
+ },
593461
+ {
593462
+ pattern: "dynamic_task_ledger",
593463
+ aliases: ["magentic", "dynamic_ledger", "replan_ledger"],
593464
+ description: "Maintain a visible task ledger while planning, executing, observing, and replanning.",
593465
+ topology: "dynamic_ledger",
593466
+ useWhen: ["The solution path is unknown and must adapt to observations."],
593467
+ avoidWhen: ["A fixed pipeline or one worker can solve the task."],
593468
+ coordinatorRequired: true,
593469
+ maxAgents: 8,
593470
+ systemPromptAddition: "Maintain a visible task/progress ledger with success criteria, completed work, blockers, and replan reasons.",
593471
+ stages: [
593472
+ stage({
593473
+ id: "ledger",
593474
+ label: "Ledger coordinator",
593475
+ agentType: "coordinator",
593476
+ purpose: "Maintain task decomposition and reconfigure subtasks as evidence arrives.",
593477
+ order: 1,
593478
+ mode: "coordinate",
593479
+ outputContract: ["Current ledger", "Success criteria", "Replan reasons"]
593480
+ }),
593481
+ stage({
593482
+ id: "workers",
593483
+ label: "Adaptive workers",
593484
+ agentType: "general",
593485
+ purpose: "Execute current ledger items and return evidence.",
593486
+ order: 2,
593487
+ mode: "parallel",
593488
+ dependsOn: ["ledger"],
593489
+ outputContract: ["Ledger item id", "Evidence", "Blockers"]
593490
+ }),
593491
+ stage({
593492
+ id: "verify",
593493
+ label: "Verifier",
593494
+ agentType: "explore",
593495
+ purpose: "Verify completed ledger items before final synthesis.",
593496
+ order: 3,
593497
+ mode: "review",
593498
+ dependsOn: ["workers"],
593499
+ outputContract: ["Verified items", "Rejected claims", "Remaining work"]
593500
+ })
593501
+ ]
593502
+ }
593503
+ ];
593504
+ AgentDeploymentPatternRegistry = class {
593505
+ patterns = /* @__PURE__ */ new Map();
593506
+ aliases = /* @__PURE__ */ new Map();
593507
+ constructor() {
593508
+ for (const def of BUILT_INS)
593509
+ this.register(def);
593510
+ }
593511
+ register(def) {
593512
+ this.validate(def);
593513
+ this.patterns.set(def.pattern, def);
593514
+ this.aliases.set(def.pattern, def.pattern);
593515
+ for (const alias of def.aliases ?? [])
593516
+ this.aliases.set(alias, def.pattern);
593517
+ }
593518
+ get(pattern) {
593519
+ const canonical = this.aliases.get(pattern) ?? pattern;
593520
+ return this.patterns.get(canonical);
593521
+ }
593522
+ listPatterns() {
593523
+ return Array.from(this.patterns.keys());
593524
+ }
593525
+ listDefinitions() {
593526
+ return Array.from(this.patterns.values());
593527
+ }
593528
+ plan(pattern, task) {
593529
+ const def = this.get(pattern);
593530
+ if (!def)
593531
+ return void 0;
593532
+ const typeRegistry = getAgentTypeRegistry();
593533
+ const stages = def.stages.slice().sort((a2, b) => a2.order - b.order || a2.id.localeCompare(b.id)).map((s2) => ({
593534
+ ...s2,
593535
+ agentTypeDescription: typeRegistry.get(s2.agentType)?.description ?? "Unknown agent type"
593536
+ }));
593537
+ return {
593538
+ pattern: def.pattern,
593539
+ topology: def.topology,
593540
+ description: def.description,
593541
+ coordinatorRequired: def.coordinatorRequired,
593542
+ task,
593543
+ stages,
593544
+ instructions: buildDeploymentPatternInstructions(def, stages, task)
593545
+ };
593546
+ }
593547
+ buildPatternSummary() {
593548
+ const lines = ["Available sub-agent deployment patterns:"];
593549
+ for (const def of this.patterns.values()) {
593550
+ lines.push(`- ${def.pattern} (${def.topology}): ${def.description} Use when: ${def.useWhen[0] ?? "structurally justified"}`);
593551
+ }
593552
+ return lines.join("\n");
593553
+ }
593554
+ validate(def) {
593555
+ if (!def.pattern.trim())
593556
+ throw new Error("pattern id is required");
593557
+ if (!def.stages.length)
593558
+ throw new Error(`pattern ${def.pattern} must define at least one stage`);
593559
+ const typeRegistry = getAgentTypeRegistry();
593560
+ const ids = /* @__PURE__ */ new Set();
593561
+ for (const s2 of def.stages) {
593562
+ if (!s2.id.trim())
593563
+ throw new Error(`pattern ${def.pattern} has a stage without id`);
593564
+ if (ids.has(s2.id))
593565
+ throw new Error(`pattern ${def.pattern} repeats stage id ${s2.id}`);
593566
+ ids.add(s2.id);
593567
+ if (!typeRegistry.get(s2.agentType)) {
593568
+ throw new Error(`pattern ${def.pattern} references unknown agent type ${s2.agentType}`);
593569
+ }
593570
+ for (const dep of s2.dependsOn ?? []) {
593571
+ if (!def.stages.some((candidate) => candidate.id === dep)) {
593572
+ throw new Error(`pattern ${def.pattern} stage ${s2.id} depends on unknown stage ${dep}`);
593573
+ }
593574
+ }
593575
+ }
593576
+ if (def.maxAgents < 1)
593577
+ throw new Error(`pattern ${def.pattern} maxAgents must be positive`);
593578
+ }
593579
+ };
593580
+ _patternRegistry = new AgentDeploymentPatternRegistry();
593581
+ }
593582
+ });
593583
+
592877
593584
  // packages/orchestrator/dist/agent-task.js
592878
593585
  function isTerminalTaskStatus(status) {
592879
593586
  return status === "completed" || status === "failed" || status === "killed";
@@ -596125,6 +596832,7 @@ var init_conversational_scrutiny = __esm({
596125
596832
  var dist_exports3 = {};
596126
596833
  __export(dist_exports3, {
596127
596834
  AGENT_DISALLOWED_TOOLS: () => AGENT_DISALLOWED_TOOLS,
596835
+ AgentDeploymentPatternRegistry: () => AgentDeploymentPatternRegistry,
596128
596836
  AgentLoop: () => AgentLoop,
596129
596837
  AgentTaskManager: () => AgentTaskManager,
596130
596838
  AgentTypeRegistry: () => AgentTypeRegistry,
@@ -596180,6 +596888,7 @@ __export(dist_exports3, {
596180
596888
  arcSummary: () => arcSummary,
596181
596889
  auditCompletionClaims: () => auditCompletionClaims,
596182
596890
  auditPerceptionClaims: () => auditPerceptionClaims,
596891
+ buildAgentDeploymentPatternSummary: () => buildAgentDeploymentPatternSummary,
596183
596892
  buildAgentNotification: () => buildAgentNotification,
596184
596893
  buildAgentTypeSummary: () => buildAgentTypeSummary,
596185
596894
  buildCompletionScenarioDecomposition: () => buildCompletionScenarioDecomposition,
@@ -596259,6 +596968,8 @@ __export(dist_exports3, {
596259
596968
  generateUserTestingResult: () => generateUserTestingResult,
596260
596969
  generateUserTestingValidatorSkill: () => generateUserTestingValidatorSkill,
596261
596970
  generateWorkerSkillTemplate: () => generateWorkerSkillTemplate,
596971
+ getAgentDeploymentPattern: () => getAgentDeploymentPattern,
596972
+ getAgentDeploymentPatternRegistry: () => getAgentDeploymentPatternRegistry,
596262
596973
  getAgentType: () => getAgentType,
596263
596974
  getAgentTypeRegistry: () => getAgentTypeRegistry,
596264
596975
  getAllDefaultPricing: () => getAllDefaultPricing,
@@ -596311,6 +597022,7 @@ __export(dist_exports3, {
596311
597022
  parseTextToolCalls: () => parseTextToolCalls,
596312
597023
  partitionToolCalls: () => partitionToolCalls,
596313
597024
  persistAgentTaskSidecar: () => persistAgentTaskSidecar,
597025
+ planAgentDeploymentPattern: () => planAgentDeploymentPattern,
596314
597026
  planConsolidation: () => planConsolidation,
596315
597027
  preprocessContextReferences: () => preprocessContextReferences,
596316
597028
  pressureCheck: () => pressureCheck,
@@ -596338,6 +597050,7 @@ __export(dist_exports3, {
596338
597050
  recordToolDecision: () => recordToolDecision,
596339
597051
  recordToolEvidence: () => recordToolEvidence,
596340
597052
  recordToolExecution: () => recordToolExecution,
597053
+ registerAgentDeploymentPattern: () => registerAgentDeploymentPattern,
596341
597054
  registerAgentType: () => registerAgentType,
596342
597055
  registerCommand: () => registerCommand,
596343
597056
  registerHookHandler: () => registerHookHandler,
@@ -596432,6 +597145,7 @@ var init_dist8 = __esm({
596432
597145
  init_stability_tracker();
596433
597146
  init_render_decision();
596434
597147
  init_agent_types();
597148
+ init_agent_patterns();
596435
597149
  init_agent_task();
596436
597150
  init_task_recovery();
596437
597151
  init_coordinator();
@@ -596570,7 +597284,7 @@ function generationKindForToolName(toolName) {
596570
597284
  function formatGenerativeProgress(kind, event, options2 = {}) {
596571
597285
  const width = Math.max(8, Math.min(32, options2.width ?? (options2.surface === "telegram" ? 12 : 20)));
596572
597286
  const label = kindLabel2(kind);
596573
- const stage = stageLabel(event.stage);
597287
+ const stage2 = stageLabel(event.stage);
596574
597288
  const pct = finitePercent(event.percent);
596575
597289
  const bytes = formatProgressBytes(event);
596576
597290
  const elapsed = formatElapsed(event.elapsedMs);
@@ -596578,17 +597292,17 @@ function formatGenerativeProgress(kind, event, options2 = {}) {
596578
597292
  if (typeof pct === "number") {
596579
597293
  const filled = Math.max(0, Math.min(width, Math.round(pct / 100 * width)));
596580
597294
  const bar = `${"#".repeat(filled)}${"-".repeat(width - filled)}`;
596581
- return `${label} ${stage}: [${bar}] ${pct}% ${message2}${bytes}${elapsed}`;
597295
+ return `${label} ${stage2}: [${bar}] ${pct}% ${message2}${bytes}${elapsed}`;
596582
597296
  }
596583
- return `${label} ${stage}: ${message2}${bytes}${elapsed}`;
597297
+ return `${label} ${stage2}: ${message2}${bytes}${elapsed}`;
596584
597298
  }
596585
597299
  function kindLabel2(kind) {
596586
597300
  if (kind === "tts") return "TTS";
596587
597301
  if (kind === "model") return "3D/CAD";
596588
597302
  return kind.slice(0, 1).toUpperCase() + kind.slice(1);
596589
597303
  }
596590
- function stageLabel(stage) {
596591
- const normalized = String(stage || "process").trim().toLowerCase();
597304
+ function stageLabel(stage2) {
597305
+ const normalized = String(stage2 || "process").trim().toLowerCase();
596592
597306
  if (normalized === "setup") return "setup";
596593
597307
  if (normalized === "download") return "download";
596594
597308
  if (normalized === "load") return "load";
@@ -658420,23 +659134,23 @@ ${sections.join("\n\n")}`;
658420
659134
  function adaptTool3(tool) {
658421
659135
  return adaptExecutionTool(tool);
658422
659136
  }
658423
- function buildDreamPrompt(mode, stage, cycleNum, totalCycles, previousFindings, dreamsDir) {
659137
+ function buildDreamPrompt(mode, stage2, cycleNum, totalCycles, previousFindings, dreamsDir) {
658424
659138
  const modeDesc = mode === "lucid" ? "LUCID DREAM MODE: You have full implementation capability. After ideation, you will implement, test, and evaluate changes." : mode === "deep" ? "DEEP DREAM MODE: Explore deeply with multiple expansion/contraction cycles. All proposals go in .omnius/dreams/." : "DREAM MODE: Creative exploration only. All output must be written to .omnius/dreams/ directory using file_write.";
658425
659139
  const stageInstruction = {
658426
659140
  "NREM-1": `LIGHT SCAN (Stage 1/${SLEEP_STAGES.length}): Do a quick scan of the codebase structure. Identify the main files, architecture patterns, and surface-level observations. Note areas that catch your attention. Write a brief scan report.`,
658427
659141
  "NREM-2": `PATTERN DETECTION (Stage 2/${SLEEP_STAGES.length}): Look deeper at the patterns you noticed. Identify: technical debt, missing tests, code duplication, potential optimizations, missing features, security concerns, DX improvements. Categorize findings by priority.`,
658428
659142
  "NREM-3": `DEEP CONSOLIDATION (Stage 3/${SLEEP_STAGES.length}): Synthesize your findings into concrete, actionable proposals. For each proposal, write: (1) problem statement, (2) proposed solution with implementation plan, (3) estimated effort, (4) expected impact. Create clean entrypoint files.`,
658429
659143
  "REM": `CREATIVE EXPANSION (Stage 4/${SLEEP_STAGES.length}): Think boldly and creatively. What novel features could transform this project? Cross-domain inspiration? Unconventional approaches? Generate at least 3 wild ideas alongside 3 practical innovations. Write detailed vision documents.`
658430
- }[stage.name];
659144
+ }[stage2.name];
658431
659145
  return loadPrompt3("tui/dream-stages.md", {
658432
659146
  modeDesc,
658433
659147
  cycleNum: String(cycleNum),
658434
659148
  totalCycles: String(totalCycles),
658435
- stageName: stage.name,
658436
- stageLabel: stage.label,
658437
- stageDescription: stage.description,
659149
+ stageName: stage2.name,
659150
+ stageLabel: stage2.label,
659151
+ stageDescription: stage2.description,
658438
659152
  stageInstruction: stageInstruction || "",
658439
- stageNameLower: stage.name.toLowerCase(),
659153
+ stageNameLower: stage2.name.toLowerCase(),
658440
659154
  previousFindings: previousFindings ? `PREVIOUS FINDINGS FROM EARLIER STAGES:
658441
659155
  ${previousFindings}
658442
659156
  ` : ""
@@ -658477,9 +659191,9 @@ function renderDreamStage(name10, label, description) {
658477
659191
  `);
658478
659192
  });
658479
659193
  }
658480
- function renderDreamStageComplete(stage, durationMs) {
659194
+ function renderDreamStageComplete(stage2, durationMs) {
658481
659195
  const secs = (durationMs / 1e3).toFixed(1);
658482
- dreamWrite(() => process.stdout.write(` ${c3.green("✔")} ${stage} complete ${c3.dim(`(${secs}s)`)}
659196
+ dreamWrite(() => process.stdout.write(` ${c3.green("✔")} ${stage2} complete ${c3.dim(`(${secs}s)`)}
658483
659197
  `));
658484
659198
  }
658485
659199
  function renderDreamContraction(cycle) {
@@ -658826,12 +659540,12 @@ var init_dream_engine = __esm({
658826
659540
  let previousFindings = "";
658827
659541
  const cycleResults = [];
658828
659542
  const modelTier2 = getModelTier(this.config.model);
658829
- for (const stage of SLEEP_STAGES) {
659543
+ for (const stage2 of SLEEP_STAGES) {
658830
659544
  if (this.abortController.signal.aborted) break;
658831
- renderDreamStage(stage.name, stage.label, stage.description);
659545
+ renderDreamStage(stage2.name, stage2.label, stage2.description);
658832
659546
  const startMs = Date.now();
658833
659547
  let result;
658834
- if (stage.name === "REM" && modelTier2 === "large" && detectSystemSpecs().gpuVramGB > 0) {
659548
+ if (stage2.name === "REM" && modelTier2 === "large" && detectSystemSpecs().gpuVramGB > 0) {
658835
659549
  renderInfo("REM: Autoresearch swarm — 5-agent GPU experiment loop (Researcher + Monitor + Evaluator + Critic + Flow Maintainer)");
658836
659550
  const swarmResult = await this.runAutoresearchSwarm(
658837
659551
  cycle,
@@ -658839,7 +659553,7 @@ var init_dream_engine = __esm({
658839
659553
  onEvent
658840
659554
  );
658841
659555
  result = { summary: swarmResult.summary, turns: 0, toolCalls: 0 };
658842
- } else if (stage.name === "REM" && modelTier2 === "large") {
659556
+ } else if (stage2.name === "REM" && modelTier2 === "large") {
658843
659557
  renderInfo("REM: Multi-agent creative mode — parallel Visionary + Pragmatist + Cross-Pollinator");
658844
659558
  const remResult = await this.runMultiAgentREM(
658845
659559
  cycle,
@@ -658852,7 +659566,7 @@ var init_dream_engine = __esm({
658852
659566
  } else {
658853
659567
  const prompt = buildDreamPrompt(
658854
659568
  mode,
658855
- stage,
659569
+ stage2,
658856
659570
  cycle,
658857
659571
  totalCycles,
658858
659572
  previousFindings,
@@ -658867,7 +659581,7 @@ var init_dream_engine = __esm({
658867
659581
  const durationMs = Date.now() - startMs;
658868
659582
  const cycleResult = {
658869
659583
  cycle,
658870
- stage: stage.name,
659584
+ stage: stage2.name,
658871
659585
  ideas: [],
658872
659586
  proposals: [],
658873
659587
  filesGenerated: [],
@@ -658875,12 +659589,12 @@ var init_dream_engine = __esm({
658875
659589
  };
658876
659590
  previousFindings += `
658877
659591
 
658878
- ### ${stage.label} findings:
659592
+ ### ${stage2.label} findings:
658879
659593
  ${result.summary}`;
658880
659594
  cycleResult.ideas.push(result.summary);
658881
659595
  cycleResults.push(cycleResult);
658882
659596
  this.state.results.push(cycleResult);
658883
- renderDreamStageComplete(stage.name, durationMs);
659597
+ renderDreamStageComplete(stage2.name, durationMs);
658884
659598
  }
658885
659599
  if (mode !== "default" || cycle === totalCycles) {
658886
659600
  renderDreamContraction(cycle);
@@ -666733,19 +667447,19 @@ function deriveVisualEvidencePlan(request) {
666733
667447
  }
666734
667448
  async function executeVisualEvidencePlan(resolution, plan, executor) {
666735
667449
  const stages = [];
666736
- for (const stage of plan.stages) {
667450
+ for (const stage2 of plan.stages) {
666737
667451
  const start2 = Date.now();
666738
667452
  try {
666739
- const result = await executor(stage.kind, resolution.path, "auto");
666740
- stages.push({ ...stage, completed: true, output: result.output, durationMs: result.durationMs });
667453
+ const result = await executor(stage2.kind, resolution.path, "auto");
667454
+ stages.push({ ...stage2, completed: true, output: result.output, durationMs: result.durationMs });
666741
667455
  } catch (err) {
666742
667456
  stages.push({
666743
- ...stage,
667457
+ ...stage2,
666744
667458
  completed: false,
666745
667459
  error: err instanceof Error ? err.message : String(err),
666746
667460
  durationMs: Date.now() - start2
666747
667461
  });
666748
- if (stage.required) break;
667462
+ if (stage2.required) break;
666749
667463
  }
666750
667464
  }
666751
667465
  const succeeded = stages.filter((s2) => s2.completed);
@@ -678111,13 +678825,13 @@ ${TELEGRAM_PUBLIC_ORCHESTRATOR_CONTRACT}`
678111
678825
  if (!html) return;
678112
678826
  const state = stateFor(toolName);
678113
678827
  const now2 = Date.now();
678114
- const stage = String(event.stage || "process");
678828
+ const stage2 = String(event.stage || "process");
678115
678829
  const percent = typeof event.percent === "number" && Number.isFinite(event.percent) ? Math.round(event.percent) : void 0;
678116
- const terminalStage = stage === "save" || stage === "thumbnail" || stage === "hf_token_required";
678117
- const shouldRender = state.lastRenderedAt === 0 || stage !== state.lastStage || typeof percent === "number" && (state.lastPercent === void 0 || Math.abs(percent - state.lastPercent) >= 5) || now2 - state.lastRenderedAt >= 3500 || terminalStage;
678830
+ const terminalStage = stage2 === "save" || stage2 === "thumbnail" || stage2 === "hf_token_required";
678831
+ const shouldRender = state.lastRenderedAt === 0 || stage2 !== state.lastStage || typeof percent === "number" && (state.lastPercent === void 0 || Math.abs(percent - state.lastPercent) >= 5) || now2 - state.lastRenderedAt >= 3500 || terminalStage;
678118
678832
  if (!shouldRender) return;
678119
678833
  state.lastRenderedAt = now2;
678120
- state.lastStage = stage;
678834
+ state.lastStage = stage2;
678121
678835
  state.lastPercent = percent;
678122
678836
  enqueue(state, html);
678123
678837
  },
@@ -690225,7 +690939,7 @@ async function tunnelViaTor(req3) {
690225
690939
  function openSocks5(targetHost, targetPort, timeoutMs) {
690226
690940
  return new Promise((resolve74, reject) => {
690227
690941
  const sock = createConnection3({ host: DEFAULT_SOCKS_HOST, port: DEFAULT_SOCKS_PORT });
690228
- let stage = "greet";
690942
+ let stage2 = "greet";
690229
690943
  const timer = setTimeout(() => {
690230
690944
  try {
690231
690945
  sock.destroy(new Error(`Tor SOCKS5 timeout (${timeoutMs}ms)`));
@@ -690241,7 +690955,7 @@ function openSocks5(targetHost, targetPort, timeoutMs) {
690241
690955
  sock.write(Buffer.from([5, 1, 0]));
690242
690956
  });
690243
690957
  sock.on("data", (chunk) => {
690244
- if (stage === "greet") {
690958
+ if (stage2 === "greet") {
690245
690959
  if (chunk.length < 2 || chunk[0] !== 5 || chunk[1] !== 0) {
690246
690960
  clearTimeout(timer);
690247
690961
  reject(new Error("Tor SOCKS5: greeting rejected (auth required?)"));
@@ -690261,10 +690975,10 @@ function openSocks5(targetHost, targetPort, timeoutMs) {
690261
690975
  hostBuf.copy(buf, 5);
690262
690976
  buf.writeUInt16BE(targetPort, 5 + hostBuf.length);
690263
690977
  sock.write(buf);
690264
- stage = "connect";
690978
+ stage2 = "connect";
690265
690979
  return;
690266
690980
  }
690267
- if (stage === "connect") {
690981
+ if (stage2 === "connect") {
690268
690982
  if (chunk.length < 2 || chunk[0] !== 5) {
690269
690983
  clearTimeout(timer);
690270
690984
  reject(new Error("Tor SOCKS5: malformed CONNECT reply"));
@@ -690285,7 +690999,7 @@ function openSocks5(targetHost, targetPort, timeoutMs) {
690285
690999
  return;
690286
691000
  }
690287
691001
  clearTimeout(timer);
690288
- stage = "ready";
691002
+ stage2 = "ready";
690289
691003
  resolve74(sock);
690290
691004
  }
690291
691005
  });
@@ -717076,6 +717790,7 @@ Bypass for special cases: set env OMNIUS_DISABLE_TASK_COMPLETE_BUILD_GUARD=1 (no
717076
717790
  }
717077
717791
  function wireAgentToolMinimal(tool, config, repoRoot) {
717078
717792
  const typeRegistry = getAgentTypeRegistry();
717793
+ const patternRegistry = getAgentDeploymentPatternRegistry();
717079
717794
  const allToolNames = [
717080
717795
  "file_read",
717081
717796
  "file_write",
@@ -717109,6 +717824,27 @@ function wireAgentToolMinimal(tool, config, repoRoot) {
717109
717824
  };
717110
717825
  },
717111
717826
  listTypes: () => typeRegistry.listTypes(),
717827
+ resolveDeploymentPattern: (patternName, task) => {
717828
+ const plan = patternRegistry.plan(patternName, task);
717829
+ if (!plan) return void 0;
717830
+ return {
717831
+ pattern: plan.pattern,
717832
+ topology: plan.topology,
717833
+ description: plan.description,
717834
+ coordinatorRequired: plan.coordinatorRequired,
717835
+ instructions: plan.instructions,
717836
+ stages: plan.stages.map((stage2) => ({
717837
+ id: stage2.id,
717838
+ label: stage2.label,
717839
+ agentType: stage2.agentType,
717840
+ mode: stage2.mode,
717841
+ order: stage2.order,
717842
+ ...stage2.parallelGroup ? { parallelGroup: stage2.parallelGroup } : {},
717843
+ ...stage2.dependsOn ? { dependsOn: stage2.dependsOn } : {}
717844
+ }))
717845
+ };
717846
+ },
717847
+ listDeploymentPatterns: () => patternRegistry.listPatterns(),
717112
717848
  spawnInProcess: async (opts) => {
717113
717849
  let backend;
717114
717850
  if (config.backendType === "nexus") {
@@ -721177,6 +721913,7 @@ Review its full output via sub_agent(action='output', id='${id}')`
721177
721913
  };
721178
721914
  _wireAgentToolCallbacks = (tool) => {
721179
721915
  const typeRegistry = getAgentTypeRegistry();
721916
+ const patternRegistry = getAgentDeploymentPatternRegistry();
721180
721917
  const allToolNames = [
721181
721918
  "file_read",
721182
721919
  "file_write",
@@ -721216,6 +721953,27 @@ Review its full output via sub_agent(action='output', id='${id}')`
721216
721953
  };
721217
721954
  },
721218
721955
  listTypes: () => typeRegistry.listTypes(),
721956
+ resolveDeploymentPattern: (patternName, task) => {
721957
+ const plan = patternRegistry.plan(patternName, task);
721958
+ if (!plan) return void 0;
721959
+ return {
721960
+ pattern: plan.pattern,
721961
+ topology: plan.topology,
721962
+ description: plan.description,
721963
+ coordinatorRequired: plan.coordinatorRequired,
721964
+ instructions: plan.instructions,
721965
+ stages: plan.stages.map((stage2) => ({
721966
+ id: stage2.id,
721967
+ label: stage2.label,
721968
+ agentType: stage2.agentType,
721969
+ mode: stage2.mode,
721970
+ order: stage2.order,
721971
+ ...stage2.parallelGroup ? { parallelGroup: stage2.parallelGroup } : {},
721972
+ ...stage2.dependsOn ? { dependsOn: stage2.dependsOn } : {}
721973
+ }))
721974
+ };
721975
+ },
721976
+ listDeploymentPatterns: () => patternRegistry.listPatterns(),
721219
721977
  spawnInProcess: async (opts) => {
721220
721978
  let backend;
721221
721979
  if (config.backendType === "nexus") {