@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.
@@ -9,7 +9,7 @@ export { C as CompactorOptions, a as DefaultErrorHandler, b as DefaultRetryPolic
9
9
  export { AutoCompactionMiddleware, AutonomousRunner, AutonomousRunnerOptions, AutonomyPromptContributorOptions, DefaultSkillLoader, DoneCheckResult, DoneConditionChecker, EternalAutonomyEngine, EternalAutonomyOptions, EternalEngineState, IntelligentCompactor, IntelligentCompactorOptions, ParallelEngineState, ParallelEternalEngine, ParallelEternalOptions, SelectiveCompactor, SelectiveCompactorOptions, SkillLoaderOptions, buildGoalPreamble, makeAutonomyPromptContributor } from '../execution/index.js';
10
10
  import { P as ProviderRunner, R as RunProviderOptions } from '../provider-runner-Dlv8Fvw9.js';
11
11
  import { q as Response } from '../context-7u93AcGD.js';
12
- export { 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, n as CreateDelegateToolOptions, D as DEFAULT_DIRECTOR_PREAMBLE, q as DEFAULT_SUBAGENT_BASELINE, r as DelegateHost, s as Director, w as DirectorPromptParts, x as DirectorSessionFactory, y as DirectorSessionFactoryOptions, F as FLEET_ROSTER, z as FLEET_ROSTER_BUDGETS, J as FleetRosterBudget, K as FleetSpawnBudgetError, L as ICoordinator, M as IFleetManager, O as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, S as SECURITY_SCANNER_AGENT, V as SubagentPromptParts, W as applyRosterBudget, X as attachAutoExtend, Y as composeDirectorPrompt, Z as composeSubagentPrompt, _ as createDelegateTool, $ as getAgentDefinition, 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, af as rosterSummaryFromConfigs } from '../null-fleet-bus-CAQDGsKc.js';
12
+ export { 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, n as CreateDelegateToolOptions, D as DEFAULT_DIRECTOR_PREAMBLE, q as DEFAULT_SUBAGENT_BASELINE, r as DelegateHost, s as Director, w as DirectorPromptParts, x as DirectorSessionFactory, y as DirectorSessionFactoryOptions, F as FLEET_ROSTER, z as FLEET_ROSTER_BUDGETS, J as FleetRosterBudget, K as FleetSpawnBudgetError, L as ICoordinator, M as IFleetManager, O as NULL_FLEET_BUS, R as REFACTOR_PLANNER_AGENT, S as SECURITY_SCANNER_AGENT, V as SubagentPromptParts, W as applyRosterBudget, X as attachAutoExtend, Y as composeDirectorPrompt, Z as composeSubagentPrompt, _ as createDelegateTool, $ as getAgentDefinition, 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, af as rosterSummaryFromConfigs } from '../null-fleet-bus-DLsUjOyB.js';
13
13
  export { A as AgentBudgetTier, a as AgentCapability, b as AgentDefinition, 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, j as MultiAgentCoordinatorOptions, k as dispatchAgent, m as makeLLMClassifier, s as scoreAgents } from '../multi-agent-coordinator-DOXSgtom.js';
14
14
  export { c as BudgetExceededError, d as BudgetKind, e as BudgetLimits, j as BudgetUsage, m as SubagentBudget } from '../multi-agent-C8Z1i__e.js';
15
15
  export { A as AgentFactory, a as AgentFactoryResult, b as AgentRunnerOptions, F as FleetBus, c as FleetEvent, d as FleetHandler, e as FleetUsage, f as FleetUsageAggregator, S as SubagentUsageSnapshot, m as makeAgentSubagentRunner } from '../agent-subagent-runner-DpZTLdBe.js';
@@ -12042,6 +12042,16 @@ function makeCollabDebugTool(director) {
12042
12042
  type: "number",
12043
12043
  minimum: 1,
12044
12044
  description: "Timeout in ms. Default: 600000 (10 minutes)."
12045
+ },
12046
+ maxTargetFiles: {
12047
+ type: "number",
12048
+ minimum: 1,
12049
+ 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)."
12050
+ },
12051
+ contextWindow: {
12052
+ type: "number",
12053
+ minimum: 1,
12054
+ 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)."
12045
12055
  }
12046
12056
  },
12047
12057
  required: ["targetPaths"]
@@ -12053,7 +12063,9 @@ function makeCollabDebugTool(director) {
12053
12063
  }
12054
12064
  const options = {
12055
12065
  targetPaths: i.targetPaths,
12056
- timeoutMs: i.timeoutMs
12066
+ timeoutMs: i.timeoutMs,
12067
+ maxTargetFiles: i.maxTargetFiles,
12068
+ contextWindow: i.contextWindow
12057
12069
  };
12058
12070
  try {
12059
12071
  const report = await director.spawnCollab(options);
@@ -12236,6 +12248,7 @@ async function expandGlob(pattern) {
12236
12248
  }
12237
12249
 
12238
12250
  // src/coordination/collab-debug.ts
12251
+ var DEFAULT_MAX_TARGET_FILES = 30;
12239
12252
  var CollabSession = class extends EventEmitter {
12240
12253
  sessionId;
12241
12254
  options;
@@ -12292,9 +12305,34 @@ var CollabSession = class extends EventEmitter {
12292
12305
  getSubagentIds() {
12293
12306
  return new Map(this.subagentIds);
12294
12307
  }
12308
+ /**
12309
+ * Returns the effective file limit for this session.
12310
+ * Priority: explicit `maxTargetFiles` > dynamic from `contextWindow` > `DEFAULT_MAX_TARGET_FILES`.
12311
+ */
12312
+ effectiveFileLimit() {
12313
+ if (this.options.maxTargetFiles !== void 0) {
12314
+ return this.options.maxTargetFiles;
12315
+ }
12316
+ if (this.options.contextWindow !== void 0) {
12317
+ return Math.max(5, Math.floor(this.options.contextWindow * 0.4 / 2e3));
12318
+ }
12319
+ return DEFAULT_MAX_TARGET_FILES;
12320
+ }
12295
12321
  async buildSnapshot() {
12296
12322
  if (this.snapshot.files.length > 0) return this.snapshot;
12297
- for (const filePath of (await Promise.all(this.options.targetPaths.map((p) => expandGlob(p)))).flat()) {
12323
+ const allFiles = [];
12324
+ for (const pattern of this.options.targetPaths) {
12325
+ const expanded = await expandGlob(pattern);
12326
+ allFiles.push(...expanded);
12327
+ }
12328
+ const limit = this.effectiveFileLimit();
12329
+ if (allFiles.length > limit) {
12330
+ const hint = this.options.contextWindow ? `contextWindow=${this.options.contextWindow} \u2192 calculated limit=${limit}` : `default limit=${DEFAULT_MAX_TARGET_FILES}`;
12331
+ throw new Error(
12332
+ `[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.`
12333
+ );
12334
+ }
12335
+ for (const filePath of allFiles) {
12298
12336
  try {
12299
12337
  const content = await fsp.readFile(filePath, "utf8");
12300
12338
  const ext = filePath.split(".").pop() ?? "";
@@ -13320,6 +13358,20 @@ var Director = class _Director {
13320
13358
  );
13321
13359
  this.coordinator.setSubagentBridge(result.subagentId, subagentBridge);
13322
13360
  this.subagentBridges.set(result.subagentId, subagentBridge);
13361
+ this.fleet.emit({
13362
+ subagentId: result.subagentId,
13363
+ ts: Date.now(),
13364
+ type: "subagent.spawned",
13365
+ payload: {
13366
+ subagentId: result.subagentId,
13367
+ taskId: "",
13368
+ // taskId will be set when assign() is called
13369
+ name: config.name,
13370
+ role: config.role,
13371
+ provider: config.provider,
13372
+ model: config.model
13373
+ }
13374
+ });
13323
13375
  if (!this.fleetManager) {
13324
13376
  this.manifestEntries.set(result.subagentId, {
13325
13377
  subagentId: result.subagentId,