@wrongstack/core 0.3.3 → 0.3.4

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,9 +1,9 @@
1
- export { A as AfterIterationHook, p as AfterRunHook, q as AfterToolExecutionHook, s as AgentExtension, B as BeforeIterationHook, w as BeforeRunHook, x as BeforeToolExecutionHook, E as ExtensionRegistry, O as OnErrorHook, G as ProviderRunnerFn, z as ProviderRunnerWrapper } from '../index-hWNybrNZ.js';
1
+ export { A as AfterIterationHook, p as AfterRunHook, q as AfterToolExecutionHook, s as AgentExtension, B as BeforeIterationHook, w as BeforeRunHook, x as BeforeToolExecutionHook, E as ExtensionRegistry, O as OnErrorHook, G as ProviderRunnerFn, z as ProviderRunnerWrapper } from '../index-DedY4Euf.js';
2
2
  import '../context-IovtuTf8.js';
3
3
  import '../logger-BMQgxvdy.js';
4
4
  import '../system-prompt-Dk1qm8ey.js';
5
5
  import '../observability-BhnVLBLS.js';
6
6
  import '../events-BHIQs4o1.js';
7
7
  import '../secret-scrubber-CgG2tV2B.js';
8
- import '../config-D2qvAxVd.js';
8
+ import '../config-DgE3JslD.js';
9
9
  import '../models-registry-Y2xbog0E.js';
@@ -4,7 +4,7 @@ import { R as Renderer, B as BuildContext, C as Container, P as Pipeline, e as R
4
4
  import { T as Tracer } from './observability-BhnVLBLS.js';
5
5
  import { E as EventBus, a as EventName, L as Listener } from './events-BHIQs4o1.js';
6
6
  import { a as PermissionPolicy, S as SecretScrubber } from './secret-scrubber-CgG2tV2B.js';
7
- import { l as ProviderConfig, a as Config } from './config-D2qvAxVd.js';
7
+ import { l as ProviderConfig, a as Config } from './config-DgE3JslD.js';
8
8
  import { W as WireFamily } from './models-registry-Y2xbog0E.js';
9
9
 
10
10
  /**
@@ -566,6 +566,12 @@ interface SlashCommand {
566
566
  /** Short aliases — also prefixed automatically: `pluginName:alias`. */
567
567
  aliases?: string[];
568
568
  description: string;
569
+ /**
570
+ * Optional compact argument hint for interactive menus. This is not parsed
571
+ * by the registry; it only helps TUI/REPL surfaces show the expected shape,
572
+ * for example `[list|install <alias>|disable <name>]`.
573
+ */
574
+ argsHint?: string;
569
575
  /**
570
576
  * Optional detailed help shown by `/help <name>`. Use this for usage,
571
577
  * arguments, examples, side-effects — anything that doesn't fit in
package/dist/index.d.ts CHANGED
@@ -6,8 +6,8 @@ export { RunController, RunControllerOptions, TOKENS } from './kernel/index.js';
6
6
  import { b as ContentBlock, T as TextBlock, a0 as Context } from './context-IovtuTf8.js';
7
7
  export { A as AgentError, C as Capabilities, a as ConfigError, a3 as ContextInit, a4 as ConversationState, E as ErrorCode, c as ErrorSeverity, d as ErrorSubsystem, I as ImageBlock, J as JSONSchema, M as Message, e as MessageRole, P as Permission, f as PluginError, g as Provider, h as ProviderError, i as ProviderErrorBody, a5 as ReadonlyConversationState, R as Request, j as Response, k as ResumedSession, a6 as RunEnv, a7 as RunOptions, S as SessionData, l as SessionError, m as SessionEvent, n as SessionMetadata, o as SessionStore, p as SessionSummary, q as SessionWriter, a8 as StateChange, a9 as StateChangeHandler, r as StopReason, s as StreamEvent, t as ThinkingBlock, aa as TodoItem, a1 as TokenCounter, u as Tool, v as ToolCallContext, w as ToolError, x as ToolFinalEvent, y as ToolProgressEvent, z as ToolResultBlock, B as ToolStreamEvent, D as ToolUseBlock, U as Usage, W as WrongStackError, F as asBlocks, G as asText, ab as extractRunEnv, H as isAgentError, K as isConfigError, L as isImageBlock, N as isPluginError, O as isSessionError, Q as isTextBlock, V as isThinkingBlock, X as isToolError, Y as isToolResultBlock, Z as isToolUseBlock, _ as isWrongStackError, $ as toWrongStackError, ac as wrapAsState } from './context-IovtuTf8.js';
8
8
  export { P as ProviderRunner, R as RunProviderOptions } from './provider-runner-B39miKRw.js';
9
- import { a as Config } from './config-D2qvAxVd.js';
10
- export { C as CONTEXT_WINDOW_MODES, b as ConfigLoader, c as ConfigStore, d as ContextConfig, e as ContextWindowAggressiveOn, f as ContextWindowConfigLike, g as ContextWindowMode, h as ContextWindowModeId, i as ContextWindowPolicy, j as ContextWindowThresholds, D as DEFAULT_CONTEXT_WINDOW_MODE_ID, F as FeaturesConfig, L as LogConfig, M as MCPServerConfig, P as PluginConfig, k as ProviderApiKey, l as ProviderConfig, T as ToolsConfig, m as formatContextWindowModeList, n as getContextWindowMode, o as isContextWindowModeId, p as listContextWindowModes, r as resolveContextWindowPolicy } from './config-D2qvAxVd.js';
9
+ import { a as Config } from './config-DgE3JslD.js';
10
+ export { C as CONTEXT_WINDOW_MODES, b as ConfigLoader, c as ConfigStore, d as ContextConfig, e as ContextWindowAggressiveOn, f as ContextWindowConfigLike, g as ContextWindowMode, h as ContextWindowModeId, i as ContextWindowPolicy, j as ContextWindowThresholds, D as DEFAULT_CONTEXT_WINDOW_MODE_ID, F as FeaturesConfig, L as LogConfig, M as MCPServerConfig, P as PluginConfig, k as ProviderApiKey, l as ProviderConfig, T as ToolsConfig, m as formatContextWindowModeList, n as getContextWindowMode, o as isContextWindowModeId, p as listContextWindowModes, r as resolveContextWindowPolicy } from './config-DgE3JslD.js';
11
11
  export { C as CompactReport, a as Compactor } from './compactor-DpJBI1YH.js';
12
12
  export { P as PermissionDecision, a as PermissionPolicy, T as TrustPolicy } from './secret-scrubber-CgG2tV2B.js';
13
13
  import { e as AttachmentStore, d as AttachmentRef, A as AddAttachmentInput } from './session-reader-CcPi4BQ8.js';
@@ -17,12 +17,12 @@ export { D as DefaultLogger, a as DefaultLoggerOptions } from './logger-BH6AE0W9
17
17
  export { D as DefaultPathResolver, a as DefaultTokenCounter } from './path-resolver--59rCou3.js';
18
18
  import { b as MemoryStore } from './memory-CEXuo7sz.js';
19
19
  export { M as MemoryEntry, a as MemoryScope } from './memory-CEXuo7sz.js';
20
- export { C as CompactorOptions, D as DEFAULT_RECOVERY_STRATEGIES, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, R as RecoveryStrategy, T as ToolExecutor, c as buildRecoveryStrategies } from './tool-executor-HsBLGRaA.js';
20
+ export { C as CompactorOptions, D as DEFAULT_RECOVERY_STRATEGIES, a as DefaultErrorHandler, b as DefaultRetryPolicy, H as HybridCompactor, R as RecoveryStrategy, T as ToolExecutor, c as buildRecoveryStrategies } from './tool-executor-DY0iSXYf.js';
21
21
  import { a as SkillLoader } from './skill-C_7znCIC.js';
22
22
  export { S as SkillEntry, b as SkillManifest } from './skill-C_7znCIC.js';
23
23
  export { I as InputReader, P as PromptOption } from './input-reader-E-ffP2ee.js';
24
- import { j as SystemPromptContributor, h as SlashCommand, b as PluginAPI, e as PluginPipelines, T as ToolRegistryView, g as ProviderRegistryView, M as MCPRegistryView, i as SlashCommandRegistryView, E as ExtensionRegistry, S as SessionWriterView, a as MetricsSinkView, n as ToolRegistry, o as ProviderRegistry, P as Plugin } from './index-hWNybrNZ.js';
25
- export { A as AfterIterationHook, p as AfterRunHook, q as AfterToolExecutionHook, r as Agent, s as AgentExtension, t as AgentInit, u as AgentInput, v as AgentPipelines, B as BeforeIterationHook, w as BeforeRunHook, x as BeforeToolExecutionHook, D as DEFAULT_MAX_ITERATIONS, O as OnErrorHook, c as PluginCapabilities, d as PluginDependency, y as ProviderFactory, z as ProviderRunnerWrapper, R as RunResult, C as ToolWrapper, U as UserInputPayload, F as createDefaultPipelines } from './index-hWNybrNZ.js';
24
+ import { j as SystemPromptContributor, h as SlashCommand, b as PluginAPI, e as PluginPipelines, T as ToolRegistryView, g as ProviderRegistryView, M as MCPRegistryView, i as SlashCommandRegistryView, E as ExtensionRegistry, S as SessionWriterView, a as MetricsSinkView, n as ToolRegistry, o as ProviderRegistry, P as Plugin } from './index-DedY4Euf.js';
25
+ export { A as AfterIterationHook, p as AfterRunHook, q as AfterToolExecutionHook, r as Agent, s as AgentExtension, t as AgentInit, u as AgentInput, v as AgentPipelines, B as BeforeIterationHook, w as BeforeRunHook, x as BeforeToolExecutionHook, D as DEFAULT_MAX_ITERATIONS, O as OnErrorHook, c as PluginCapabilities, d as PluginDependency, y as ProviderFactory, z as ProviderRunnerWrapper, R as RunResult, C as ToolWrapper, U as UserInputPayload, F as createDefaultPipelines } from './index-DedY4Euf.js';
26
26
  export { D as DefaultModelsRegistry, a as DefaultModelsRegistryOptions, c as classifyFamily } from './models-registry-DqzwpBQy.js';
27
27
  import { c as ModeStore } from './mode-CV077NjV.js';
28
28
  export { D as DEFAULT_MODES, M as Mode, a as ModeConfig, b as ModeManifest } from './mode-CV077NjV.js';
@@ -30,7 +30,7 @@ export { I as InMemoryAgentBridge, a as InMemoryBridgeTransport, c as createMess
30
30
  export { n as BudgetExceededError, o as BudgetKind, p as BudgetLimits, q as BudgetUsage, C as CoordinatorEvents, a as CoordinatorStatus, D as DoneCondition, M as MultiAgentConfig, b as MultiAgentCoordinator, S as SpawnResult, r as SubagentBudget, c as SubagentConfig, d as SubagentContext, e as SubagentError, f as SubagentErrorKind, g as SubagentRunContext, h as SubagentRunOutcome, i as SubagentRunner, T as TaskDelegation, j as TaskResult, k as TaskSpec } from './multi-agent-B9a6sflH.js';
31
31
  export { C as CriticalPathResult, D as DEFAULT_SPEC_TEMPLATE, S as SpecAnalysis, a as SpecApiEndpoint, b as SpecRequirement, c as SpecSection, d as SpecSectionType, e as SpecStatus, f as SpecTemplate, g as SpecValidationResult, h as Specification, T as TaskAssignment, i as TaskDependency, j as TaskEdge, k as TaskFilter, l as TaskGraph, m as TaskNode, n as TaskPriority, o as TaskProgress, p as TaskSort, q as TaskStatus, r as TaskType, s as computeTaskProgress, t as findCriticalPath, u as topologicalSort } from './task-graph-BITvWt4t.js';
32
32
  export { A as AggregateHealth, H as HealthCheck, a as HealthCheckResult, b as HealthRegistry, c as HealthStatus, M as MetricLabels, d as MetricSeries, e as MetricsSink, f as MetricsSnapshot, S as Span, T as Tracer } from './observability-BhnVLBLS.js';
33
- export { AtomicWriteOptions, BuildChildEnvOptions, MessageRepairReport, MessageRepairResult, NewlineStyle, SafeParseResult, ToolOutputSerializerOptions, UnifiedDiffOptions, ValidationError, ValidationResult, atomicWrite, buildChildEnv, color, compileGlob, createToolOutputSerializer, detectNewlineStyle, ensureDir, estimateTextTokens, estimateToolInputTokens, estimateToolResultTokens, formatTodosList, matchAny, matchGlob, normalizeToLf, repairToolUseAdjacency, safeParse, safeStringify, sanitizeJsonString, stripAnsi, toStyle, unifiedDiff, validateAgainstSchema } from './utils/index.js';
33
+ export { AtomicWriteOptions, BuildChildEnvOptions, CompileFail, CompileResult, MessageRepairReport, MessageRepairResult, NewlineStyle, SafeParseResult, ToolOutputSerializerOptions, UnifiedDiffOptions, ValidationError, ValidationResult, atomicWrite, buildChildEnv, color, compileGlob, compileUserRegex, createToolOutputSerializer, detectNewlineStyle, ensureDir, estimateTextTokens, estimateToolInputTokens, estimateToolResultTokens, formatTodosList, matchAny, matchGlob, normalizeToLf, repairToolUseAdjacency, safeParse, safeStringify, sanitizeJsonString, stripAnsi, toStyle, unifiedDiff, validateAgainstSchema } from './utils/index.js';
34
34
  export { W as WstackPathOptions, a as WstackPaths, p as projectHash, r as resolveWstackPaths } from './wstack-paths-BGu2INTm.js';
35
35
  export { AbandonedSession, AttachmentStoreOptions, ConfigLoaderOptions, ConfigMigration, ConfigMigrationError, ConfigSource, DEFAULT_CONFIG_MIGRATIONS, DefaultAttachmentStore, DefaultConfigLoader, DefaultConfigStore, DefaultMemoryStore, DefaultSessionStore, DirectorStateCheckpoint, DirectorStateSnapshot, DirectorSubagentState, DirectorTaskState, MemoryStoreOptions, MigrationContext, MigrationResult, PersistedQueueItem, PlanFile, PlanItem, QueueStore, RecoveryLock, RecoveryLockOptions, SessionAnalyzer, SessionStoreOptions, TodosCheckpointFile, addPlanItem, attachPlanCheckpoint, attachTodosCheckpoint, clearPlan, emptyPlan, formatPlan, loadDirectorState, loadPlan, loadTodosCheckpoint, removePlanItem, runConfigMigrations, savePlan, saveTodosCheckpoint, setPlanItemStatus } from './storage/index.js';
36
36
  export { AutoApprovePermissionPolicy, DefaultPermissionPolicy, PermissionPolicyOptions } from './security/index.js';
@@ -40,7 +40,7 @@ export { ALL_FLEET_AGENTS, AUDIT_LOG_AGENT, AgentFactory, AgentFactoryResult, Ag
40
40
  export { DefaultModeStore, LLMSelector, LLMSelectorOptions, ModeLoaderOptions, loadProjectModes, loadUserModes } from './models/index.js';
41
41
  export { DefaultTaskStore, GeneratedTask, SpecDrivenDev, SpecDrivenDevOptions, SpecParser, TaskFlow, TaskFlowEventMap, TaskFlowEventName, TaskFlowExecutionContext, TaskFlowOptions, TaskFlowPhase, TaskGenerator, TaskGeneratorOptions, TaskStore, TaskTracker, TaskTrackerOptions, TaskTransition } from './sdd/index.js';
42
42
  export { DefaultHealthRegistry, InMemoryMetricsSink, MetricsServerHandle, MetricsServerOptions, NoopMetricsSink, NoopTracer, OTelTracer, OtlpMetricsExporterHandle, OtlpMetricsExporterOptions, OtlpTraceExporterHandle, OtlpTraceExporterOptions, PROMETHEUS_CONTENT_TYPE, buildOtlpMetricsRequest, buildOtlpTracesRequest, renderPrometheus, startMetricsServer, startOtlpMetricsExporter, startOtlpTraceExporter, wireMetricsToEvents } from './observability/index.js';
43
- export { C as ContextManagerAction, a as ContextManagerInput, b as ContextManagerResult, c as ContextManagerToolOptions, d as allServers, e as awsServer, f as blockServer, g as braveSearchServer, h as context7Server, i as contextManagerTool, j as createContextManagerTool, k as everArtServer, l as filesystemServer, m as githubServer, n as googleMapsServer, o as miniMaxVisionServer, s as sentinelServer, p as slackServer, z as zaiVisionServer } from './mcp-servers-C2OopXOn.js';
43
+ export { C as ContextManagerAction, a as ContextManagerInput, b as ContextManagerResult, c as ContextManagerToolOptions, d as allServers, e as awsServer, f as blockServer, g as braveSearchServer, h as context7Server, i as contextManagerTool, j as createContextManagerTool, k as everArtServer, l as filesystemServer, m as githubServer, n as googleMapsServer, o as miniMaxVisionServer, s as sentinelServer, p as slackServer, z as zaiVisionServer } from './mcp-servers-zGiC1lQc.js';
44
44
  import { L as Logger } from './logger-BMQgxvdy.js';
45
45
  export { a as LogLevel } from './logger-BMQgxvdy.js';
46
46
  export { a as ModelsDevPayload, c as ModelsDevProvider, M as ModelsRegistry, b as ResolvedModel, R as ResolvedProvider, W as WireFamily } from './models-registry-Y2xbog0E.js';
package/dist/index.js CHANGED
@@ -806,7 +806,7 @@ function walk(node, vault, transform) {
806
806
  if (Array.isArray(node)) {
807
807
  return node.map((item) => walk(item, vault, transform));
808
808
  }
809
- const out = {};
809
+ const out = /* @__PURE__ */ Object.create(null);
810
810
  for (const [k, v] of Object.entries(node)) {
811
811
  if (typeof v === "string" && isSecretField(k)) {
812
812
  out[k] = transform(v, k);
@@ -1770,6 +1770,7 @@ var FAMILY_BY_NPM = {
1770
1770
  "@ai-sdk/xai": "openai-compatible",
1771
1771
  "@ai-sdk/cerebras": "openai-compatible",
1772
1772
  "@ai-sdk/togetherai": "openai-compatible",
1773
+ "@ai-sdk/mistral": "openai-compatible",
1773
1774
  "@ai-sdk/perplexity": "openai-compatible",
1774
1775
  "@ai-sdk/deepinfra": "openai-compatible",
1775
1776
  "@openrouter/ai-sdk-provider": "openai-compatible",
@@ -2692,6 +2693,42 @@ var ToolExecutor = class {
2692
2693
  }
2693
2694
  };
2694
2695
 
2696
+ // src/utils/regex-guard.ts
2697
+ var MAX_PATTERN_LEN = 512;
2698
+ var DANGEROUS_PATTERNS = [
2699
+ /(\([^)]*[+*][^)]*\))[+*]/,
2700
+ // (a+)+, (.*)+, etc
2701
+ /(\(\?:[^)]*[+*][^)]*\))[+*]/
2702
+ // same, with non-capturing group
2703
+ ];
2704
+ function compileUserRegex(pattern, flags) {
2705
+ if (typeof pattern !== "string") {
2706
+ return { ok: false, reason: "pattern must be a string" };
2707
+ }
2708
+ if (pattern.length === 0) {
2709
+ return { ok: false, reason: "pattern is empty" };
2710
+ }
2711
+ if (pattern.length > MAX_PATTERN_LEN) {
2712
+ return { ok: false, reason: `pattern exceeds ${MAX_PATTERN_LEN} characters` };
2713
+ }
2714
+ for (const rx of DANGEROUS_PATTERNS) {
2715
+ if (rx.test(pattern)) {
2716
+ return {
2717
+ ok: false,
2718
+ reason: "pattern looks vulnerable to catastrophic backtracking \u2014 rewrite without nested quantifiers"
2719
+ };
2720
+ }
2721
+ }
2722
+ try {
2723
+ return { ok: true, regex: new RegExp(pattern, flags) };
2724
+ } catch (err) {
2725
+ return {
2726
+ ok: false,
2727
+ reason: err instanceof Error ? err.message : "invalid regex"
2728
+ };
2729
+ }
2730
+ }
2731
+
2695
2732
  // src/storage/session-reader.ts
2696
2733
  var DefaultSessionReader = class {
2697
2734
  store;
@@ -2786,7 +2823,11 @@ function buildMatcher(q) {
2786
2823
  const ci = q.caseInsensitive ?? true;
2787
2824
  if (q.regex) {
2788
2825
  const flags = ci ? "i" : "";
2789
- const re = new RegExp(q.query, flags);
2826
+ const compiled = compileUserRegex(q.query, flags);
2827
+ if (!compiled.ok) {
2828
+ throw new Error(`Invalid search regex "${q.query}": ${compiled.reason}`);
2829
+ }
2830
+ const re = compiled.regex;
2790
2831
  return (text) => {
2791
2832
  const m = re.exec(text);
2792
2833
  return m ? { start: m.index, end: m.index + m[0].length } : null;
@@ -3079,7 +3120,11 @@ function getCachedGlob(pattern) {
3079
3120
  COMPILED_GLOB_CACHE.set(pattern, re);
3080
3121
  return re;
3081
3122
  }
3123
+ var MAX_GLOB_PATTERN_LEN = 1024;
3082
3124
  function compileGlob(pattern) {
3125
+ if (pattern.length > MAX_GLOB_PATTERN_LEN) {
3126
+ throw new Error(`Glob pattern exceeds ${MAX_GLOB_PATTERN_LEN} characters`);
3127
+ }
3083
3128
  let i = 0;
3084
3129
  let re = "^";
3085
3130
  while (i < pattern.length) {
@@ -6224,7 +6269,15 @@ var AutoCompactionMiddleware = class {
6224
6269
  var DoneConditionChecker = class {
6225
6270
  constructor(condition) {
6226
6271
  this.condition = condition;
6227
- this.compiledRegex = condition.type === "output_match" && condition.pattern ? new RegExp(condition.pattern) : null;
6272
+ if (condition.type === "output_match" && condition.pattern) {
6273
+ const result = compileUserRegex(condition.pattern, "");
6274
+ this.compiledRegex = result.ok ? result.regex : null;
6275
+ if (!result.ok) {
6276
+ console.warn(`[DoneConditionChecker] Invalid regex pattern "${condition.pattern}": ${result.reason}`);
6277
+ }
6278
+ } else {
6279
+ this.compiledRegex = null;
6280
+ }
6228
6281
  }
6229
6282
  condition;
6230
6283
  compiledRegex;
@@ -6842,8 +6895,8 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
6842
6895
  // --- internal dispatching ---------------------------------------------
6843
6896
  tryDispatchNext() {
6844
6897
  while (this.canDispatch()) {
6845
- const subagentId = this.findIdleSubagent();
6846
- if (!subagentId) {
6898
+ const dispatchable = this.takeNextDispatchableTask();
6899
+ if (!dispatchable) {
6847
6900
  if (this.pendingTasks.length > 0 && !this.hasLiveSubagent()) {
6848
6901
  this.drainPendingAsAborted(
6849
6902
  "No live subagent available \u2014 all stopped or mid-termination"
@@ -6851,8 +6904,7 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
6851
6904
  }
6852
6905
  return;
6853
6906
  }
6854
- const task = this.pendingTasks.shift();
6855
- if (!task) return;
6907
+ const { subagentId, task } = dispatchable;
6856
6908
  this.runDispatched(subagentId, task).catch((err) => {
6857
6909
  this.recordCompletion({
6858
6910
  subagentId,
@@ -6870,12 +6922,26 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
6870
6922
  const max = this.config.maxConcurrent ?? 4;
6871
6923
  return this.inFlight < max && this.pendingTasks.length > 0;
6872
6924
  }
6925
+ takeNextDispatchableTask() {
6926
+ for (let i = 0; i < this.pendingTasks.length; i++) {
6927
+ const task = this.pendingTasks[i];
6928
+ const subagentId = task.subagentId ? this.isIdleSubagent(task.subagentId) ? task.subagentId : null : this.findIdleSubagent();
6929
+ if (!subagentId) continue;
6930
+ this.pendingTasks.splice(i, 1);
6931
+ return { subagentId, task };
6932
+ }
6933
+ return null;
6934
+ }
6873
6935
  findIdleSubagent() {
6874
6936
  for (const [id, s] of this.subagents) {
6875
6937
  if (s.status === "idle" && !this.terminating.has(id)) return id;
6876
6938
  }
6877
6939
  return null;
6878
6940
  }
6941
+ isIdleSubagent(id) {
6942
+ const subagent = this.subagents.get(id);
6943
+ return !!subagent && subagent.status === "idle" && !this.terminating.has(id);
6944
+ }
6879
6945
  /**
6880
6946
  * Returns true iff at least one spawned subagent could still
6881
6947
  * process a task. A "live" subagent is one that is not stopped
@@ -7060,10 +7126,11 @@ var DefaultMultiAgentCoordinator = class extends EventEmitter {
7060
7126
  };
7061
7127
  function classifySubagentError(err, hints = {}) {
7062
7128
  const cause = err instanceof Error ? { name: err.name, message: err.message, stack: err.stack } : void 0;
7063
- const baseMessage = err instanceof Error ? err.message : String(err);
7064
7129
  if (err instanceof ProviderError) {
7065
- return providerErrorToSubagentError(err, baseMessage, cause);
7130
+ const baseMessage2 = err.describe();
7131
+ return providerErrorToSubagentError(err, baseMessage2, cause);
7066
7132
  }
7133
+ const baseMessage = err instanceof Error ? err.message : String(err);
7067
7134
  if (err instanceof BudgetExceededError) {
7068
7135
  const map = {
7069
7136
  iterations: "budget_iterations",
@@ -7180,7 +7247,7 @@ function makeSpawnTool(director, roster) {
7180
7247
  if (role && !base) {
7181
7248
  return { error: `unknown role "${role}". roster has: ${roster ? Object.keys(roster).join(", ") : "(empty)"}` };
7182
7249
  }
7183
- const cfg = { ...base ?? { name: i.name ?? "subagent" } };
7250
+ const cfg = base ? instantiateRosterConfig(role, base) : { name: i.name ?? "subagent" };
7184
7251
  if (typeof i.name === "string") cfg.name = i.name;
7185
7252
  if (typeof i.provider === "string") cfg.provider = i.provider;
7186
7253
  if (typeof i.model === "string") cfg.model = i.model;
@@ -7200,6 +7267,14 @@ function makeSpawnTool(director, roster) {
7200
7267
  }
7201
7268
  };
7202
7269
  }
7270
+ function instantiateRosterConfig(role, base) {
7271
+ return {
7272
+ ...base,
7273
+ // Roster entries are templates. A director may spawn several
7274
+ // workers with the same role, so never reuse the template id.
7275
+ id: `${role}-${randomUUID().slice(0, 8)}`
7276
+ };
7277
+ }
7203
7278
  function makeAssignTool(director) {
7204
7279
  const inputSchema = {
7205
7280
  type: "object",
@@ -7961,7 +8036,7 @@ function createDelegateTool(opts) {
7961
8036
  error: `Unknown role "${i.role}". Available: ${rosterIds.join(", ") || "(no roster configured)"}.`
7962
8037
  };
7963
8038
  }
7964
- cfg = { ...base };
8039
+ cfg = instantiateRosterConfig2(i.role, base);
7965
8040
  if (i.systemPromptOverride) cfg.systemPromptOverride = i.systemPromptOverride;
7966
8041
  if (i.provider) cfg.provider = i.provider;
7967
8042
  if (i.model) cfg.model = i.model;
@@ -8047,6 +8122,14 @@ function createDelegateTool(opts) {
8047
8122
  }
8048
8123
  };
8049
8124
  }
8125
+ function instantiateRosterConfig2(role, base) {
8126
+ return {
8127
+ ...base,
8128
+ // Roster entries are templates. Give each spawn a fresh id so
8129
+ // parallel or repeated delegates can use the same role safely.
8130
+ id: `${role}-${randomUUID().slice(0, 8)}`
8131
+ };
8132
+ }
8050
8133
  function hintForKind(kind, retryable, backoffMs) {
8051
8134
  if (!kind) return void 0;
8052
8135
  switch (kind) {
@@ -12535,6 +12618,6 @@ function wrapApiForCapabilityCheck(plugin, api, log, enforce = false) {
12535
12618
  });
12536
12619
  }
12537
12620
 
12538
- export { ALL_FLEET_AGENTS, AUDIT_LOG_AGENT, Agent, AgentError, AutoApprovePermissionPolicy, AutoCompactionMiddleware, AutonomousRunner, BUG_HUNTER_AGENT, BudgetExceededError, CONTEXT_WINDOW_MODES, ConfigError, ConfigMigrationError, Container, Context, ConversationState, DEFAULT_CONFIG_MIGRATIONS, DEFAULT_CONTEXT_WINDOW_MODE_ID, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_MAX_ITERATIONS, DEFAULT_MODES, DEFAULT_RECOVERY_STRATEGIES, DEFAULT_SPEC_TEMPLATE, DEFAULT_SUBAGENT_BASELINE, DefaultAttachmentStore, DefaultConfigLoader, DefaultConfigStore, DefaultErrorHandler, DefaultHealthRegistry, DefaultLogger, DefaultMemoryStore, DefaultModeStore, DefaultModelsRegistry, DefaultMultiAgentCoordinator, DefaultPathResolver, DefaultPermissionPolicy, DefaultPluginAPI, DefaultProviderRunner, DefaultRetryPolicy, DefaultSecretScrubber, DefaultSecretVault, DefaultSessionReader, DefaultSessionStore, DefaultSkillLoader, DefaultSystemPromptBuilder, DefaultTaskStore, DefaultTokenCounter, Director, DirectorBudgetError, DirectorStateCheckpoint, DoneConditionChecker, EventBus, ExtensionRegistry, FLEET_ROSTER, FleetBus, FleetUsageAggregator, HybridCompactor, InMemoryAgentBridge, InMemoryBridgeTransport, InMemoryMetricsSink, InputBuilder, IntelligentCompactor, KERNEL_API_VERSION, LAYER_1_IDENTITY, LLMSelector, NoopMetricsSink, NoopTracer, OTelTracer, PROMETHEUS_CONTENT_TYPE, Pipeline, PluginError, ProviderError, ProviderRegistry, QueueStore, REFACTOR_PLANNER_AGENT, RecoveryLock, RunController, SECURITY_SCANNER_AGENT, SelectiveCompactor, SessionAnalyzer, SessionError, SlashCommandRegistry, SpecDrivenDev, SpecParser, SubagentBudget, TOKENS, TaskFlow, TaskGenerator, TaskTracker, ToolError, ToolExecutor, ToolRegistry, WrongStackError, addPlanItem, allServers, asBlocks, asText, atomicWrite, attachPlanCheckpoint, attachTodosCheckpoint, awsServer, blockServer, braveSearchServer, buildChildEnv, buildOtlpMetricsRequest, buildOtlpTracesRequest, buildRecoveryStrategies, classifyFamily, clearPlan, color, compileGlob, composeDirectorPrompt, composeSubagentPrompt, computeTaskProgress, context7Server, contextManagerTool, createContextManagerTool, createDefaultPipelines, createDelegateTool, createMessage, createToolOutputSerializer, decryptConfigSecrets, detectNewlineStyle, emptyPlan, encryptConfigSecrets, ensureDir, estimateTextTokens, estimateToolInputTokens, estimateToolResultTokens, everArtServer, extractRunEnv, filesystemServer, findCriticalPath, formatContextWindowModeList, formatPlan, formatTodosList, getContextWindowMode, githubServer, googleMapsServer, isAgentError, isConfigError, isContextWindowModeId, isImageBlock, isPluginError, isSessionError, isTextBlock, isThinkingBlock, isToolError, isToolResultBlock, isToolUseBlock, isWrongStackError, listContextWindowModes, loadDirectorState, loadPlan, loadPlugins, loadProjectModes, loadTodosCheckpoint, loadUserModes, makeAgentSubagentRunner, makeDirectorSessionFactory, matchAny, matchGlob, migratePlaintextSecrets, miniMaxVisionServer, normalizeToLf, projectHash, removePlanItem, renderPrometheus, repairToolUseAdjacency, resolveContextWindowPolicy, resolveWstackPaths, rewriteConfigEncrypted, rosterSummaryFromConfigs, runConfigMigrations, safeParse, safeStringify, sanitizeJsonString, savePlan, saveTodosCheckpoint, sentinelServer, setPlanItemStatus, slackServer, startMetricsServer, startOtlpMetricsExporter, startOtlpTraceExporter, stripAnsi, toStyle, toWrongStackError, topologicalSort, unifiedDiff, unloadPlugins, validateAgainstSchema, wireMetricsToEvents, wrapAsState, zaiVisionServer };
12621
+ export { ALL_FLEET_AGENTS, AUDIT_LOG_AGENT, Agent, AgentError, AutoApprovePermissionPolicy, AutoCompactionMiddleware, AutonomousRunner, BUG_HUNTER_AGENT, BudgetExceededError, CONTEXT_WINDOW_MODES, ConfigError, ConfigMigrationError, Container, Context, ConversationState, DEFAULT_CONFIG_MIGRATIONS, DEFAULT_CONTEXT_WINDOW_MODE_ID, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_MAX_ITERATIONS, DEFAULT_MODES, DEFAULT_RECOVERY_STRATEGIES, DEFAULT_SPEC_TEMPLATE, DEFAULT_SUBAGENT_BASELINE, DefaultAttachmentStore, DefaultConfigLoader, DefaultConfigStore, DefaultErrorHandler, DefaultHealthRegistry, DefaultLogger, DefaultMemoryStore, DefaultModeStore, DefaultModelsRegistry, DefaultMultiAgentCoordinator, DefaultPathResolver, DefaultPermissionPolicy, DefaultPluginAPI, DefaultProviderRunner, DefaultRetryPolicy, DefaultSecretScrubber, DefaultSecretVault, DefaultSessionReader, DefaultSessionStore, DefaultSkillLoader, DefaultSystemPromptBuilder, DefaultTaskStore, DefaultTokenCounter, Director, DirectorBudgetError, DirectorStateCheckpoint, DoneConditionChecker, EventBus, ExtensionRegistry, FLEET_ROSTER, FleetBus, FleetUsageAggregator, HybridCompactor, InMemoryAgentBridge, InMemoryBridgeTransport, InMemoryMetricsSink, InputBuilder, IntelligentCompactor, KERNEL_API_VERSION, LAYER_1_IDENTITY, LLMSelector, NoopMetricsSink, NoopTracer, OTelTracer, PROMETHEUS_CONTENT_TYPE, Pipeline, PluginError, ProviderError, ProviderRegistry, QueueStore, REFACTOR_PLANNER_AGENT, RecoveryLock, RunController, SECURITY_SCANNER_AGENT, SelectiveCompactor, SessionAnalyzer, SessionError, SlashCommandRegistry, SpecDrivenDev, SpecParser, SubagentBudget, TOKENS, TaskFlow, TaskGenerator, TaskTracker, ToolError, ToolExecutor, ToolRegistry, WrongStackError, addPlanItem, allServers, asBlocks, asText, atomicWrite, attachPlanCheckpoint, attachTodosCheckpoint, awsServer, blockServer, braveSearchServer, buildChildEnv, buildOtlpMetricsRequest, buildOtlpTracesRequest, buildRecoveryStrategies, classifyFamily, clearPlan, color, compileGlob, compileUserRegex, composeDirectorPrompt, composeSubagentPrompt, computeTaskProgress, context7Server, contextManagerTool, createContextManagerTool, createDefaultPipelines, createDelegateTool, createMessage, createToolOutputSerializer, decryptConfigSecrets, detectNewlineStyle, emptyPlan, encryptConfigSecrets, ensureDir, estimateTextTokens, estimateToolInputTokens, estimateToolResultTokens, everArtServer, extractRunEnv, filesystemServer, findCriticalPath, formatContextWindowModeList, formatPlan, formatTodosList, getContextWindowMode, githubServer, googleMapsServer, isAgentError, isConfigError, isContextWindowModeId, isImageBlock, isPluginError, isSessionError, isTextBlock, isThinkingBlock, isToolError, isToolResultBlock, isToolUseBlock, isWrongStackError, listContextWindowModes, loadDirectorState, loadPlan, loadPlugins, loadProjectModes, loadTodosCheckpoint, loadUserModes, makeAgentSubagentRunner, makeDirectorSessionFactory, matchAny, matchGlob, migratePlaintextSecrets, miniMaxVisionServer, normalizeToLf, projectHash, removePlanItem, renderPrometheus, repairToolUseAdjacency, resolveContextWindowPolicy, resolveWstackPaths, rewriteConfigEncrypted, rosterSummaryFromConfigs, runConfigMigrations, safeParse, safeStringify, sanitizeJsonString, savePlan, saveTodosCheckpoint, sentinelServer, setPlanItemStatus, slackServer, startMetricsServer, startOtlpMetricsExporter, startOtlpTraceExporter, stripAnsi, toStyle, toWrongStackError, topologicalSort, unifiedDiff, unloadPlugins, validateAgainstSchema, wireMetricsToEvents, wrapAsState, zaiVisionServer };
12539
12622
  //# sourceMappingURL=index.js.map
12540
12623
  //# sourceMappingURL=index.js.map