@wrongstack/core 0.31.1 → 0.32.0

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,4 +1,4 @@
1
- export { A as ACP_AGENTS, a as AGENTS_BY_PHASE, b as AGENT_CATALOG, c as ALL_AGENT_DEFINITIONS, d as ALL_FLEET_AGENTS, e as AUDIT_LOG_AGENT, f as AutoExtendCeiling, g as AutoExtendPolicy, B as BUG_HUNTER_AGENT, h as BugFinding, C as CollabBudgetConfig, i as CollabBudgetOverrides, j as CollabBudgetWarningPayload, k as CollabDebugReport, l as CollabSession, m as CollabSessionOptions, n as CreateDelegateToolOptions, o as CriticConcern, p as CriticEvaluation, D as DEFAULT_DIRECTOR_PREAMBLE, q as DEFAULT_SUBAGENT_BASELINE, r as DelegateHost, s as Director, t as DirectorAlert, u as DirectorAlertLevel, v as DirectorCancelCollabPayload, w as DirectorPromptParts, x as DirectorSessionFactory, y as DirectorSessionFactoryOptions, F as FLEET_ROSTER, z as FLEET_ROSTER_BUDGETS, E as FLEET_ROSTER_WITHACP, G as FleetCostCapError, H as FleetManager, I as FleetManagerOptions, J as FleetRosterBudget, K as FleetSpawnBudgetError, L as ICoordinator, M as IFleetManager, N as LargeAnswerStore, O as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, P as RefactorPhase, Q as RefactorPlan, S as SECURITY_SCANNER_AGENT, T as SharedFileEntry, U as SharedFileSnapshot, V as SubagentPromptParts, W as applyRosterBudget, X as attachAutoExtend, Y as composeDirectorPrompt, Z as composeSubagentPrompt, _ as createDelegateTool, $ as getAgentDefinition, a0 as makeAskResultTool, a1 as makeAskTool, a2 as makeAssignTool, a3 as makeAwaitTasksTool, a4 as makeCollabDebugTool, a5 as makeDirectorSessionFactory, a6 as makeFleetEmitTool, a7 as makeFleetHealthTool, a8 as makeFleetSessionTool, a9 as makeFleetStatusTool, aa as makeFleetUsageTool, ab as makeRollUpTool, ac as makeSpawnTool, ad as makeTerminateTool, ae as makeWorkCompleteTool, af as rosterSummaryFromConfigs } from '../null-fleet-bus-CAQDGsKc.js';
1
+ export { A as ACP_AGENTS, a as AGENTS_BY_PHASE, b as AGENT_CATALOG, c as ALL_AGENT_DEFINITIONS, d as ALL_FLEET_AGENTS, e as AUDIT_LOG_AGENT, f as AutoExtendCeiling, g as AutoExtendPolicy, B as BUG_HUNTER_AGENT, h as BugFinding, C as CollabBudgetConfig, i as CollabBudgetOverrides, j as CollabBudgetWarningPayload, k as CollabDebugReport, l as CollabSession, m as CollabSessionOptions, n as CreateDelegateToolOptions, o as CriticConcern, p as CriticEvaluation, D as DEFAULT_DIRECTOR_PREAMBLE, q as DEFAULT_SUBAGENT_BASELINE, r as DelegateHost, s as Director, t as DirectorAlert, u as DirectorAlertLevel, v as DirectorCancelCollabPayload, w as DirectorPromptParts, x as DirectorSessionFactory, y as DirectorSessionFactoryOptions, F as FLEET_ROSTER, z as FLEET_ROSTER_BUDGETS, E as FLEET_ROSTER_WITHACP, G as FleetCostCapError, H as FleetManager, I as FleetManagerOptions, J as FleetRosterBudget, K as FleetSpawnBudgetError, L as ICoordinator, M as IFleetManager, N as LargeAnswerStore, O as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, P as RefactorPhase, Q as RefactorPlan, S as SECURITY_SCANNER_AGENT, T as SharedFileEntry, U as SharedFileSnapshot, V as SubagentPromptParts, W as applyRosterBudget, X as attachAutoExtend, Y as composeDirectorPrompt, Z as composeSubagentPrompt, _ as createDelegateTool, $ as getAgentDefinition, a0 as makeAskResultTool, a1 as makeAskTool, a2 as makeAssignTool, a3 as makeAwaitTasksTool, a4 as makeCollabDebugTool, a5 as makeDirectorSessionFactory, a6 as makeFleetEmitTool, a7 as makeFleetHealthTool, a8 as makeFleetSessionTool, a9 as makeFleetStatusTool, aa as makeFleetUsageTool, ab as makeRollUpTool, ac as makeSpawnTool, ad as makeTerminateTool, ae as makeWorkCompleteTool, af as rosterSummaryFromConfigs } from '../null-fleet-bus-DLsUjOyB.js';
2
2
  import { b as AgentDefinition } from '../multi-agent-coordinator-DOXSgtom.js';
3
3
  export { T as AGENT_TOOL_PRESETS, A as AgentBudgetTier, a as AgentCapability, c as AgentPhase, D as DEFAULT_DISPATCH_ROLE, d as DefaultMultiAgentCoordinator, e as DispatchCandidate, f as DispatchClassifier, g as DispatchMethod, h as DispatchOptions, i as DispatchResult, H as HEAVY_BUDGET, L as LIGHT_BUDGET, M as MEDIUM_BUDGET, j as MultiAgentCoordinatorOptions, k as dispatchAgent, m as makeLLMClassifier, s as scoreAgents } from '../multi-agent-coordinator-DOXSgtom.js';
4
4
  export { c as BudgetExceededError, d as BudgetKind, e as BudgetLimits, f as BudgetNegotiationMode, g as BudgetThresholdDecision, h as BudgetThresholdHandler, i as BudgetThresholdSignal, j as BudgetUsage, m as SubagentBudget } from '../multi-agent-C8Z1i__e.js';
@@ -4973,6 +4973,16 @@ function makeCollabDebugTool(director) {
4973
4973
  type: "number",
4974
4974
  minimum: 1,
4975
4975
  description: "Timeout in ms. Default: 600000 (10 minutes)."
4976
+ },
4977
+ maxTargetFiles: {
4978
+ type: "number",
4979
+ minimum: 1,
4980
+ description: "Maximum number of files to include in the snapshot. If not set, the limit is computed dynamically from contextWindow or falls back to the default (30)."
4981
+ },
4982
+ contextWindow: {
4983
+ type: "number",
4984
+ minimum: 1,
4985
+ description: "Context window size (tokens) of the model. When provided and maxTargetFiles is not set, the file limit is computed dynamically as floor((contextWindow * 0.4) / 2000)."
4976
4986
  }
4977
4987
  },
4978
4988
  required: ["targetPaths"]
@@ -4984,7 +4994,9 @@ function makeCollabDebugTool(director) {
4984
4994
  }
4985
4995
  const options = {
4986
4996
  targetPaths: i.targetPaths,
4987
- timeoutMs: i.timeoutMs
4997
+ timeoutMs: i.timeoutMs,
4998
+ maxTargetFiles: i.maxTargetFiles,
4999
+ contextWindow: i.contextWindow
4988
5000
  };
4989
5001
  try {
4990
5002
  const report = await director.spawnCollab(options);
@@ -5167,6 +5179,7 @@ async function expandGlob(pattern) {
5167
5179
  }
5168
5180
 
5169
5181
  // src/coordination/collab-debug.ts
5182
+ var DEFAULT_MAX_TARGET_FILES = 30;
5170
5183
  var DirectorAlertLevel = /* @__PURE__ */ ((DirectorAlertLevel2) => {
5171
5184
  DirectorAlertLevel2["WARNING"] = "warning";
5172
5185
  DirectorAlertLevel2["CRITICAL"] = "critical";
@@ -5229,9 +5242,34 @@ var CollabSession = class extends EventEmitter {
5229
5242
  getSubagentIds() {
5230
5243
  return new Map(this.subagentIds);
5231
5244
  }
5245
+ /**
5246
+ * Returns the effective file limit for this session.
5247
+ * Priority: explicit `maxTargetFiles` > dynamic from `contextWindow` > `DEFAULT_MAX_TARGET_FILES`.
5248
+ */
5249
+ effectiveFileLimit() {
5250
+ if (this.options.maxTargetFiles !== void 0) {
5251
+ return this.options.maxTargetFiles;
5252
+ }
5253
+ if (this.options.contextWindow !== void 0) {
5254
+ return Math.max(5, Math.floor(this.options.contextWindow * 0.4 / 2e3));
5255
+ }
5256
+ return DEFAULT_MAX_TARGET_FILES;
5257
+ }
5232
5258
  async buildSnapshot() {
5233
5259
  if (this.snapshot.files.length > 0) return this.snapshot;
5234
- for (const filePath of (await Promise.all(this.options.targetPaths.map((p) => expandGlob(p)))).flat()) {
5260
+ const allFiles = [];
5261
+ for (const pattern of this.options.targetPaths) {
5262
+ const expanded = await expandGlob(pattern);
5263
+ allFiles.push(...expanded);
5264
+ }
5265
+ const limit = this.effectiveFileLimit();
5266
+ if (allFiles.length > limit) {
5267
+ const hint = this.options.contextWindow ? `contextWindow=${this.options.contextWindow} \u2192 calculated limit=${limit}` : `default limit=${DEFAULT_MAX_TARGET_FILES}`;
5268
+ throw new Error(
5269
+ `[collab_debug] Target has ${allFiles.length} files, which exceeds the limit (${hint}). Narrow the target or pass maxTargetFiles / contextWindow to override. For large codebases, run package-by-package or module-by-module sessions instead of targeting the entire repo.`
5270
+ );
5271
+ }
5272
+ for (const filePath of allFiles) {
5235
5273
  try {
5236
5274
  const content = await fsp6.readFile(filePath, "utf8");
5237
5275
  const ext = filePath.split(".").pop() ?? "";
@@ -6257,6 +6295,20 @@ var Director = class _Director {
6257
6295
  );
6258
6296
  this.coordinator.setSubagentBridge(result.subagentId, subagentBridge);
6259
6297
  this.subagentBridges.set(result.subagentId, subagentBridge);
6298
+ this.fleet.emit({
6299
+ subagentId: result.subagentId,
6300
+ ts: Date.now(),
6301
+ type: "subagent.spawned",
6302
+ payload: {
6303
+ subagentId: result.subagentId,
6304
+ taskId: "",
6305
+ // taskId will be set when assign() is called
6306
+ name: config.name,
6307
+ role: config.role,
6308
+ provider: config.provider,
6309
+ model: config.model
6310
+ }
6311
+ });
6260
6312
  if (!this.fleetManager) {
6261
6313
  this.manifestEntries.set(result.subagentId, {
6262
6314
  subagentId: result.subagentId,