@wrongstack/core 0.1.8 → 0.1.9

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.
@@ -1062,6 +1062,55 @@ interface DirectorOptions {
1062
1062
  * `DEFAULT_SUBAGENT_BASELINE`). Pass an empty string to suppress.
1063
1063
  */
1064
1064
  subagentBaseline?: string;
1065
+ /**
1066
+ * Absolute path to a directory the fleet can use as a shared scratchpad
1067
+ * (read + write by every subagent). When set, the director creates it on
1068
+ * construction and `subagentSystemPrompt()` automatically injects a
1069
+ * "Shared notes" block telling subagents where to drop their findings.
1070
+ * This is the cheap fleet-coordination channel — agents don't need each
1071
+ * other's transcripts, just each other's conclusions.
1072
+ *
1073
+ * Convention: under a fleet run rooted at `<sessionsRoot>/<runId>/`,
1074
+ * pass `<sessionsRoot>/<runId>/shared/` here.
1075
+ */
1076
+ sharedScratchpadPath?: string;
1077
+ /**
1078
+ * Maximum number of spawns this director can perform across its
1079
+ * lifetime. Default: unlimited. Acts as a hard fleet-wide cost cap —
1080
+ * a runaway leader that keeps spawning workers gets cut off cleanly
1081
+ * instead of burning provider tokens until the user kills the
1082
+ * process. The N+1-th spawn call rejects with a `DirectorBudgetError`.
1083
+ */
1084
+ maxSpawns?: number;
1085
+ /**
1086
+ * Maximum nesting depth for spawns. The director constructed by the
1087
+ * user is at depth `spawnDepth` (default 0); any subagent that itself
1088
+ * acts as a director would construct its own `Director` with
1089
+ * `spawnDepth: parent.spawnDepth + 1`. When `spawnDepth >= maxSpawnDepth`,
1090
+ * `spawn()` rejects. Default: 2 (root director can spawn workers; a
1091
+ * worker that becomes a sub-director cannot itself spawn further).
1092
+ * This stops infinite recursive director chains from a hostile or
1093
+ * confused prompt.
1094
+ */
1095
+ maxSpawnDepth?: number;
1096
+ /**
1097
+ * Current spawn-chain depth for this director instance. Defaults to 0.
1098
+ * A nested director should pass `parent.spawnDepth + 1`. Together with
1099
+ * `maxSpawnDepth` this bounds the chain.
1100
+ */
1101
+ spawnDepth?: number;
1102
+ }
1103
+ /**
1104
+ * Thrown by `Director.spawn()` when a configured spawn cap (`maxSpawns`,
1105
+ * `maxSpawnDepth`) is hit. Distinct error class so callers — including
1106
+ * the `spawn_subagent` tool surface — can recognize the budget case and
1107
+ * report it cleanly instead of treating it like an unexpected failure.
1108
+ */
1109
+ declare class DirectorBudgetError extends Error {
1110
+ readonly kind: 'max_spawns' | 'max_spawn_depth';
1111
+ readonly limit: number;
1112
+ readonly observed: number;
1113
+ constructor(kind: 'max_spawns' | 'max_spawn_depth', limit: number, observed: number);
1065
1114
  }
1066
1115
  declare class Director {
1067
1116
  readonly id: string;
@@ -1097,6 +1146,19 @@ declare class Director {
1097
1146
  private readonly roster?;
1098
1147
  private readonly directorPreamble;
1099
1148
  private readonly subagentBaseline;
1149
+ /** Absolute path to the fleet's shared scratchpad directory, or null
1150
+ * when none was configured. Exposed as a readonly getter for callers
1151
+ * that need to surface the path to the user (e.g. the CLI logging
1152
+ * the location after `--director` boots). */
1153
+ readonly sharedScratchpadPath: string | null;
1154
+ /** Spawn cap (lifetime total). Infinity means unlimited. */
1155
+ readonly maxSpawns: number;
1156
+ /** Nesting cap. The N-th director in a chain has `spawnDepth = N-1`. */
1157
+ readonly maxSpawnDepth: number;
1158
+ /** This director's position in a director chain. Root director = 0. */
1159
+ readonly spawnDepth: number;
1160
+ /** Live spawn counter for `maxSpawns` enforcement. */
1161
+ private spawnCount;
1100
1162
  constructor(opts: DirectorOptions);
1101
1163
  /**
1102
1164
  * Spawn a subagent. Identical to the coordinator's `spawn()` but
@@ -1360,6 +1422,16 @@ interface SubagentPromptParts {
1360
1422
  * but exposed here in case the factory wants it duplicated in the
1361
1423
  * system prompt for reinforcement. */
1362
1424
  task?: string;
1425
+ /**
1426
+ * Absolute path to a shared scratchpad directory the whole fleet can
1427
+ * read/write. When set, the composer adds a "Shared notes" block that
1428
+ * tells the subagent where to drop findings and where to look for
1429
+ * sibling output. This is the cheap fleet-coordination channel —
1430
+ * agents don't need each other's transcripts, just each other's
1431
+ * conclusions. Falls between `task` and `override` so the override
1432
+ * can still narrow or replace it.
1433
+ */
1434
+ sharedScratchpad?: string;
1363
1435
  /** Final per-spawn override from `SubagentConfig.systemPromptOverride`.
1364
1436
  * Added last so it wins on conflict — that's by design: the spawn site
1365
1437
  * knows the most about what this specific subagent should do. */
@@ -1398,6 +1470,37 @@ declare function rosterSummaryFromConfigs(roster: Record<string, {
1398
1470
  role?: string;
1399
1471
  }>): string;
1400
1472
 
1473
+ /**
1474
+ * Pre-built subagent role configurations for the WrongStack fleet.
1475
+ * These can be passed to `MultiAgentHost.spawn()` or used as templates
1476
+ * for the director's roster.
1477
+ */
1478
+
1479
+ /**
1480
+ * Audit Log Agent — analyzes session logs, event streams, and traces.
1481
+ * Use for: post-mortems, trend analysis, operational insights.
1482
+ */
1483
+ declare const AUDIT_LOG_AGENT: SubagentConfig;
1484
+ /**
1485
+ * Bug Hunter Agent — systematic bug and code smell detection.
1486
+ * Use for: pre-refactoring health checks, code review, regression prevention.
1487
+ */
1488
+ declare const BUG_HUNTER_AGENT: SubagentConfig;
1489
+ /**
1490
+ * Refactor Planner Agent — structured refactoring planning.
1491
+ * Use for: large rewrites, technical debt reduction, architecture improvements.
1492
+ */
1493
+ declare const REFACTOR_PLANNER_AGENT: SubagentConfig;
1494
+ /**
1495
+ * Security Scanner Agent — vulnerability and secret detection.
1496
+ * Use for: CI checks, pre-release audits, dependency vulnerability scanning.
1497
+ */
1498
+ declare const SECURITY_SCANNER_AGENT: SubagentConfig;
1499
+ /** All pre-built agents in a map for easy lookup by role. */
1500
+ declare const FLEET_ROSTER: Record<string, SubagentConfig>;
1501
+ /** Quick-access list for spawning all at once. */
1502
+ declare const ALL_FLEET_AGENTS: SubagentConfig[];
1503
+
1401
1504
  type AutonomousResult = RunResult & {
1402
1505
  toolCalls: number;
1403
1506
  reason?: string;
@@ -2203,4 +2306,4 @@ declare const sentinelServer: () => MCPServerConfig;
2203
2306
  /** Everything bundled — full set of built-in servers. Useful for `wstack mcp add --all`. */
2204
2307
  declare const allServers: () => Record<string, MCPServerConfig>;
2205
2308
 
2206
- export { type AbandonedSession, type AgentFactory, type AgentFactoryResult, type AgentRunnerOptions, type AttachmentStoreOptions, AutoCompactionMiddleware, AutonomousRunner, type AutonomousRunnerOptions, type CompactorOptions, type ConfigLoaderOptions, type ConfigMigration, ConfigMigrationError, type ConfigSource, type ContextManagerAction, type ContextManagerInput, type ContextManagerResult, type ContextManagerToolOptions, DEFAULT_CONFIG_MIGRATIONS, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_SUBAGENT_BASELINE, DefaultAttachmentStore, DefaultConfigLoader, DefaultConfigStore, DefaultErrorHandler, DefaultHealthRegistry, DefaultLogger, type DefaultLoggerOptions, DefaultMemoryStore, DefaultModeStore, DefaultModelsRegistry, type DefaultModelsRegistryOptions, DefaultMultiAgentCoordinator, DefaultPathResolver, DefaultPermissionPolicy, DefaultRetryPolicy, DefaultSecretScrubber, DefaultSecretVault, DefaultSessionReader, DefaultSessionStore, DefaultSkillLoader, DefaultTaskStore, DefaultTokenCounter, Director, type DirectorPromptParts, type DirectorSessionFactory, type DirectorSessionFactoryOptions, type DoneCheckResult, DoneConditionChecker, FleetBus, type FleetEvent, type FleetHandler, type FleetUsage, FleetUsageAggregator, type GeneratedTask, HybridCompactor, InMemoryAgentBridge, InMemoryBridgeTransport, InMemoryMetricsSink, IntelligentCompactor, type IntelligentCompactorOptions, LLMSelector, type LLMSelectorOptions, type MemoryStoreOptions, type MetricsServerHandle, type MetricsServerOptions, type MigrationContext, type MigrationResult, type ModeLoaderOptions, type MultiAgentCoordinatorOptions, NoopMetricsSink, NoopTracer, OTelTracer, type OtlpMetricsExporterHandle, type OtlpMetricsExporterOptions, type OtlpTraceExporterHandle, type OtlpTraceExporterOptions, PROMETHEUS_CONTENT_TYPE, type PermissionPolicyOptions, type PersistedQueueItem, QueueStore, RecoveryLock, type RecoveryLockOptions, type SecretVaultOptions, SelectiveCompactor, type SelectiveCompactorOptions, type SessionStoreOptions, type SkillLoaderOptions, SpecDrivenDev, type SpecDrivenDevOptions, SpecParser, type SubagentPromptParts, type SubagentUsageSnapshot, TaskFlow, type TaskFlowEventMap, type TaskFlowEventName, type TaskFlowExecutionContext, type TaskFlowOptions, type TaskFlowPhase, TaskGenerator, type TaskGeneratorOptions, type TaskStore, TaskTracker, type TaskTrackerOptions, type TaskTransition, ToolExecutor, allServers, awsServer, blockServer, braveSearchServer, buildOtlpMetricsRequest, buildOtlpTracesRequest, classifyFamily, composeDirectorPrompt, composeSubagentPrompt, context7Server, contextManagerTool, createContextManagerTool, createMessage, decryptConfigSecrets, encryptConfigSecrets, everArtServer, filesystemServer, githubServer, googleMapsServer, loadProjectModes, loadUserModes, makeAgentSubagentRunner, makeDirectorSessionFactory, migratePlaintextSecrets, renderPrometheus, rewriteConfigEncrypted, rosterSummaryFromConfigs, runConfigMigrations, sentinelServer, slackServer, startMetricsServer, startOtlpMetricsExporter, startOtlpTraceExporter, wireMetricsToEvents };
2309
+ export { ALL_FLEET_AGENTS, AUDIT_LOG_AGENT, type AbandonedSession, type AgentFactory, type AgentFactoryResult, type AgentRunnerOptions, type AttachmentStoreOptions, AutoCompactionMiddleware, AutonomousRunner, type AutonomousRunnerOptions, BUG_HUNTER_AGENT, type CompactorOptions, type ConfigLoaderOptions, type ConfigMigration, ConfigMigrationError, type ConfigSource, type ContextManagerAction, type ContextManagerInput, type ContextManagerResult, type ContextManagerToolOptions, DEFAULT_CONFIG_MIGRATIONS, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_SUBAGENT_BASELINE, DefaultAttachmentStore, DefaultConfigLoader, DefaultConfigStore, DefaultErrorHandler, DefaultHealthRegistry, DefaultLogger, type DefaultLoggerOptions, DefaultMemoryStore, DefaultModeStore, DefaultModelsRegistry, type DefaultModelsRegistryOptions, DefaultMultiAgentCoordinator, DefaultPathResolver, DefaultPermissionPolicy, DefaultRetryPolicy, DefaultSecretScrubber, DefaultSecretVault, DefaultSessionReader, DefaultSessionStore, DefaultSkillLoader, DefaultTaskStore, DefaultTokenCounter, Director, DirectorBudgetError, type DirectorPromptParts, type DirectorSessionFactory, type DirectorSessionFactoryOptions, type DoneCheckResult, DoneConditionChecker, FLEET_ROSTER, FleetBus, type FleetEvent, type FleetHandler, type FleetUsage, FleetUsageAggregator, type GeneratedTask, HybridCompactor, InMemoryAgentBridge, InMemoryBridgeTransport, InMemoryMetricsSink, IntelligentCompactor, type IntelligentCompactorOptions, LLMSelector, type LLMSelectorOptions, type MemoryStoreOptions, type MetricsServerHandle, type MetricsServerOptions, type MigrationContext, type MigrationResult, type ModeLoaderOptions, type MultiAgentCoordinatorOptions, NoopMetricsSink, NoopTracer, OTelTracer, type OtlpMetricsExporterHandle, type OtlpMetricsExporterOptions, type OtlpTraceExporterHandle, type OtlpTraceExporterOptions, PROMETHEUS_CONTENT_TYPE, type PermissionPolicyOptions, type PersistedQueueItem, QueueStore, REFACTOR_PLANNER_AGENT, RecoveryLock, type RecoveryLockOptions, SECURITY_SCANNER_AGENT, type SecretVaultOptions, SelectiveCompactor, type SelectiveCompactorOptions, type SessionStoreOptions, type SkillLoaderOptions, SpecDrivenDev, type SpecDrivenDevOptions, SpecParser, type SubagentPromptParts, type SubagentUsageSnapshot, TaskFlow, type TaskFlowEventMap, type TaskFlowEventName, type TaskFlowExecutionContext, type TaskFlowOptions, type TaskFlowPhase, TaskGenerator, type TaskGeneratorOptions, type TaskStore, TaskTracker, type TaskTrackerOptions, type TaskTransition, ToolExecutor, allServers, awsServer, blockServer, braveSearchServer, buildOtlpMetricsRequest, buildOtlpTracesRequest, classifyFamily, composeDirectorPrompt, composeSubagentPrompt, context7Server, contextManagerTool, createContextManagerTool, createMessage, decryptConfigSecrets, encryptConfigSecrets, everArtServer, filesystemServer, githubServer, googleMapsServer, loadProjectModes, loadUserModes, makeAgentSubagentRunner, makeDirectorSessionFactory, migratePlaintextSecrets, renderPrometheus, rewriteConfigEncrypted, rosterSummaryFromConfigs, runConfigMigrations, sentinelServer, slackServer, startMetricsServer, startOtlpMetricsExporter, startOtlpTraceExporter, wireMetricsToEvents };
@@ -4083,6 +4083,15 @@ ${parts.role.trim()}`);
4083
4083
  sections.push(`Task:
4084
4084
  ${parts.task.trim()}`);
4085
4085
  }
4086
+ if (parts.sharedScratchpad && parts.sharedScratchpad.trim().length > 0) {
4087
+ sections.push(
4088
+ `Shared notes:
4089
+ A scratchpad shared with the rest of the fleet is mounted at \`${parts.sharedScratchpad.trim()}\`.
4090
+ - Write your final findings as markdown files there (e.g. \`findings.md\`, \`security.md\`).
4091
+ - Before starting, list the directory and read any sibling files relevant to your task \u2014 they may already contain context you can build on.
4092
+ - Use stable filenames (one file per concern); overwrite instead of appending so the Director sees the latest state.`
4093
+ );
4094
+ }
4086
4095
  if (parts.override && parts.override.trim().length > 0) {
4087
4096
  sections.push(parts.override.trim());
4088
4097
  }
@@ -4100,6 +4109,20 @@ function rosterSummaryFromConfigs(roster) {
4100
4109
  }
4101
4110
 
4102
4111
  // src/defaults/director.ts
4112
+ var DirectorBudgetError = class extends Error {
4113
+ kind;
4114
+ limit;
4115
+ observed;
4116
+ constructor(kind, limit, observed) {
4117
+ super(
4118
+ kind === "max_spawns" ? `Director spawn budget exceeded: tried to spawn #${observed} but maxSpawns is ${limit}` : `Director spawn depth budget exceeded: this director is at depth ${observed} and maxSpawnDepth is ${limit}`
4119
+ );
4120
+ this.name = "DirectorBudgetError";
4121
+ this.kind = kind;
4122
+ this.limit = limit;
4123
+ this.observed = observed;
4124
+ }
4125
+ };
4103
4126
  var Director = class {
4104
4127
  id;
4105
4128
  fleet;
@@ -4134,12 +4157,32 @@ var Director = class {
4134
4157
  roster;
4135
4158
  directorPreamble;
4136
4159
  subagentBaseline;
4160
+ /** Absolute path to the fleet's shared scratchpad directory, or null
4161
+ * when none was configured. Exposed as a readonly getter for callers
4162
+ * that need to surface the path to the user (e.g. the CLI logging
4163
+ * the location after `--director` boots). */
4164
+ sharedScratchpadPath;
4165
+ /** Spawn cap (lifetime total). Infinity means unlimited. */
4166
+ maxSpawns;
4167
+ /** Nesting cap. The N-th director in a chain has `spawnDepth = N-1`. */
4168
+ maxSpawnDepth;
4169
+ /** This director's position in a director chain. Root director = 0. */
4170
+ spawnDepth;
4171
+ /** Live spawn counter for `maxSpawns` enforcement. */
4172
+ spawnCount = 0;
4137
4173
  constructor(opts) {
4138
4174
  this.id = opts.config.coordinatorId || randomUUID();
4139
4175
  this.manifestPath = opts.manifestPath;
4140
4176
  this.roster = opts.roster;
4141
4177
  this.directorPreamble = opts.directorPreamble ?? DEFAULT_DIRECTOR_PREAMBLE;
4142
4178
  this.subagentBaseline = opts.subagentBaseline ?? DEFAULT_SUBAGENT_BASELINE;
4179
+ this.sharedScratchpadPath = opts.sharedScratchpadPath ?? null;
4180
+ this.maxSpawns = opts.maxSpawns ?? Infinity;
4181
+ this.maxSpawnDepth = opts.maxSpawnDepth ?? 2;
4182
+ this.spawnDepth = opts.spawnDepth ?? 0;
4183
+ if (this.sharedScratchpadPath) {
4184
+ void fsp.mkdir(this.sharedScratchpadPath, { recursive: true }).catch(() => void 0);
4185
+ }
4143
4186
  this.transport = new InMemoryBridgeTransport();
4144
4187
  this.bridge = new InMemoryAgentBridge(
4145
4188
  { agentId: this.id, coordinatorId: this.id },
@@ -4175,6 +4218,13 @@ var Director = class {
4175
4218
  * it the `cost` column in `usage.snapshot()` stays at 0.
4176
4219
  */
4177
4220
  async spawn(config, priceLookup) {
4221
+ if (this.spawnDepth >= this.maxSpawnDepth) {
4222
+ throw new DirectorBudgetError("max_spawn_depth", this.maxSpawnDepth, this.spawnDepth);
4223
+ }
4224
+ if (this.spawnCount >= this.maxSpawns) {
4225
+ throw new DirectorBudgetError("max_spawns", this.maxSpawns, this.spawnCount + 1);
4226
+ }
4227
+ this.spawnCount += 1;
4178
4228
  const result = await this.coordinator.spawn(config);
4179
4229
  this.subagentMeta.set(result.subagentId, {
4180
4230
  provider: config.provider,
@@ -4427,6 +4477,7 @@ var Director = class {
4427
4477
  baseline: this.subagentBaseline,
4428
4478
  role: config.prompt,
4429
4479
  task: taskBrief,
4480
+ sharedScratchpad: this.sharedScratchpadPath ?? void 0,
4430
4481
  override: config.systemPromptOverride
4431
4482
  });
4432
4483
  }
@@ -4496,8 +4547,15 @@ function makeSpawnTool(director, roster) {
4496
4547
  if (typeof i.maxIterations === "number") cfg.maxIterations = i.maxIterations;
4497
4548
  if (typeof i.maxToolCalls === "number") cfg.maxToolCalls = i.maxToolCalls;
4498
4549
  if (typeof i.maxCostUsd === "number") cfg.maxCostUsd = i.maxCostUsd;
4499
- const subagentId = await director.spawn(cfg);
4500
- return { subagentId, provider: cfg.provider, model: cfg.model, name: cfg.name };
4550
+ try {
4551
+ const subagentId = await director.spawn(cfg);
4552
+ return { subagentId, provider: cfg.provider, model: cfg.model, name: cfg.name };
4553
+ } catch (err) {
4554
+ if (err instanceof DirectorBudgetError) {
4555
+ return { error: err.message, kind: err.kind, limit: err.limit, observed: err.observed };
4556
+ }
4557
+ return { error: err instanceof Error ? err.message : String(err) };
4558
+ }
4501
4559
  }
4502
4560
  };
4503
4561
  }
@@ -4688,6 +4746,184 @@ function makeDirectorSessionFactory(opts) {
4688
4746
  };
4689
4747
  }
4690
4748
 
4749
+ // src/defaults/agents/fleet.ts
4750
+ var AUDIT_LOG_AGENT = {
4751
+ id: "audit-log",
4752
+ name: "Audit Log",
4753
+ role: "audit-log",
4754
+ prompt: `You are the Audit Log agent. Your job is to analyze structured JSONL
4755
+ session logs and produce actionable markdown reports.
4756
+
4757
+ Scope:
4758
+ - Parse session logs (iteration counts, tool calls, errors, usage)
4759
+ - Detect repeated failure patterns across multiple runs
4760
+ - Identify tool usage anomalies (over-use, failures, unexpected chains)
4761
+ - Track token consumption trends
4762
+ - Generate structured audit reports with severity ratings
4763
+
4764
+ Input format you accept:
4765
+ { "task": "analyze | report | trends", "sessionPath": "<path>", "focus": "errors | tools | usage | all" }
4766
+
4767
+ Output: Markdown audit report with sections:
4768
+ - ## Summary (totals, error rate)
4769
+ - ## Top Errors (count + context)
4770
+ - ## Tool Usage (table with calls, failures, avg duration)
4771
+ - ## Anomalies (pattern \u2192 severity)
4772
+
4773
+ Working rules:
4774
+ - Never fabricate numbers \u2014 read the actual logs first
4775
+ - Always include file:line references for errors
4776
+ - If sessionPath is missing, ask the director to provide it
4777
+ - Report confidence level: high (>90% accuracy), medium, low`,
4778
+ maxIterations: 50,
4779
+ maxToolCalls: 200,
4780
+ timeoutMs: 12e4
4781
+ };
4782
+ var BUG_HUNTER_AGENT = {
4783
+ id: "bug-hunter",
4784
+ name: "Bug Hunter",
4785
+ role: "bug-hunter",
4786
+ prompt: `You are the Bug Hunter agent. Your job is to systematically scan
4787
+ source code for bugs, anti-patterns, and code smells using pattern matching
4788
+ and heuristics. Output a prioritized hit list with file:line references.
4789
+
4790
+ Scope:
4791
+ - Detect common bug patterns (uncaught errors, resource leaks, race conditions)
4792
+ - Identify anti-patterns (callback hell, God objects, circular deps)
4793
+ - Find TypeScript-specific issues (unsafe any, missing null checks, branded types)
4794
+ - Flag security-sensitive constructs (eval, innerHTML, hardcoded secrets)
4795
+ - Rank findings: critical > high > medium > low
4796
+
4797
+ Input format you accept:
4798
+ { "task": "scan | hunt | check", "paths": ["src/**/*.ts"], "focus": "bugs | patterns | security | all", "severityThreshold": "medium" }
4799
+
4800
+ Output: Markdown bug hunt report:
4801
+ - ## Critical (must fix first)
4802
+ - ## High (should fix)
4803
+ - ## Medium
4804
+ - ## Low (consider)
4805
+ Each entry: **[TYPE]** \`file:line\` \u2014 description + suggested fix
4806
+
4807
+ Bug pattern reference you know:
4808
+ | Pattern | Regex hint | Severity |
4809
+ |---------|------------|----------|
4810
+ | Uncaught promise | /.then\\(.*\\)/ without catch | high |
4811
+ | Event leak | on\\( without off/removeListener | high |
4812
+ | Hardcoded secret | [a-zA-Z0-9/_-]{20,} in config files | critical |
4813
+ | unsafe any | : any\\b or <any> | medium |
4814
+ | innerHTML | innerHTML\\s*= | high |
4815
+
4816
+ Working rules:
4817
+ - Never scan node_modules \u2014 it's noise
4818
+ - Always include file:line for every finding
4819
+ - If >30% of findings are false positives, note the confidence level
4820
+ - Ask director for clarification if paths are ambiguous`,
4821
+ maxIterations: 80,
4822
+ maxToolCalls: 300,
4823
+ timeoutMs: 18e4
4824
+ };
4825
+ var REFACTOR_PLANNER_AGENT = {
4826
+ id: "refactor-planner",
4827
+ name: "Refactor Planner",
4828
+ role: "refactor-planner",
4829
+ prompt: `You are the Refactor Planner agent. Your job is to analyze code
4830
+ structure and produce a concrete, phased refactoring plan with risk
4831
+ assessment, dependency ordering, and rollback strategy.
4832
+
4833
+ Scope:
4834
+ - Map module-level dependencies (import graph)
4835
+ - Identify coupling hotspots (high fan-in/out modules)
4836
+ - Assess refactoring risk by complexity and test coverage
4837
+ - Generate phased plans with checkpoint milestones
4838
+ - Produce diff-friendly task lists (one task = one concern)
4839
+
4840
+ Input format you accept:
4841
+ { "task": "plan | assess | roadmap", "target": "src/core", "constraint": "no-breaking-changes | minimal-downtime | full-rewrite", "focus": "architecture | performance | maintainability" }
4842
+
4843
+ Output: Markdown refactor plan:
4844
+ - ## Phase 1: Low Risk / High Payoff (do first)
4845
+ Table: | # | Task | Module | Risk | Est. Time |
4846
+ - ## Phase 2: Medium Risk
4847
+ - ## Phase 3: High Risk (requires full regression)
4848
+ - ## Dependency Graph (abbreviated ASCII)
4849
+ - ## Rollback Strategy
4850
+ - ## Exit Criteria (checkbox list)
4851
+
4852
+ Risk scoring criteria:
4853
+ | Factor | Low | Medium | High |
4854
+ |--------|-----|--------|------|
4855
+ | Cyclomatic complexity | <10 | 10-20 | >20 |
4856
+ | Test coverage | >80% | 50-80% | <50% |
4857
+ | Fan-out (imports) | <5 | 5-15 | >15 |
4858
+
4859
+ Working rules:
4860
+ - Always include rollback strategy \u2014 every refactor can fail
4861
+ - Merge tasks that take <1h into a single phase
4862
+ - Respect team constraints (reviewer availability, parallelization)
4863
+ - Never plan without analyzing the actual code first`,
4864
+ maxIterations: 60,
4865
+ maxToolCalls: 250,
4866
+ timeoutMs: 15e4
4867
+ };
4868
+ var SECURITY_SCANNER_AGENT = {
4869
+ id: "security-scanner",
4870
+ name: "Security Scanner",
4871
+ role: "security-scanner",
4872
+ prompt: `You are the Security Scanner agent. Your job is to scan code,
4873
+ configs, and dependencies for security issues from hardcoded secrets to
4874
+ supply chain risks.
4875
+
4876
+ Scope:
4877
+ - Detect hardcoded secrets: API keys, tokens, passwords, private keys
4878
+ - Find injection vectors: eval, innerHTML, SQL concat, shell injection
4879
+ - Identify insecure patterns: weak crypto, hardcoded IVs, disabled TLS
4880
+ - Scan dependencies for known CVEs (via npm/pnpm audit)
4881
+ - Flag supply chain risks: postinstall hooks, unverified scripts, .npmrc
4882
+
4883
+ Input format you accept:
4884
+ { "task": "scan | audit | secrets | dependencies", "paths": ["src", "config"], "depth": "quick | normal | deep" }
4885
+
4886
+ Output: Markdown security report:
4887
+ - ## CRITICAL: Secrets Found (with code snippets)
4888
+ - ## HIGH: Injection Vectors
4889
+ - ## MEDIUM: Insecure Patterns
4890
+ - ## Dependency Issues (CVE list)
4891
+ - ## Summary table (severity \u2192 count)
4892
+ - ## Remediation Checklist (with checkboxes)
4893
+
4894
+ Secret patterns you detect:
4895
+ | Pattern | Example | Severity |
4896
+ |---------|---------|----------|
4897
+ | AWS Access Key | AKIAIOSFODNN7EXAMPLE | critical |
4898
+ | AWS Secret Key | [a-zA-Z0-9/+=]{40} base64 | critical |
4899
+ | GitHub Token | ghp_[a-zA-Z0-9]{36} | critical |
4900
+ | Private Key PEM | -----BEGIN.*PRIVATE KEY----- | critical |
4901
+ | JWT | eyJ[a-zA-Z0-9_-]+ | high |
4902
+
4903
+ Injection patterns:
4904
+ | Construct | Safe alternative |
4905
+ |-----------|-----------------|
4906
+ | eval(str) | new Function() or parse |
4907
+ | innerHTML = x | textContent or sanitize |
4908
+ | exec(\`cmd \${x}\`) | execFile with args array |
4909
+
4910
+ Working rules:
4911
+ - Never scan node_modules \u2014 use npm audit instead
4912
+ - Always provide remediation steps, not just findings
4913
+ - Verify regex-based secrets before flagging (false positive risk)
4914
+ - When in doubt, flag as medium rather than ignoring potential issues`,
4915
+ maxIterations: 70,
4916
+ maxToolCalls: 280,
4917
+ timeoutMs: 16e4
4918
+ };
4919
+ var FLEET_ROSTER = {
4920
+ "audit-log": AUDIT_LOG_AGENT,
4921
+ "bug-hunter": BUG_HUNTER_AGENT,
4922
+ "refactor-planner": REFACTOR_PLANNER_AGENT,
4923
+ "security-scanner": SECURITY_SCANNER_AGENT
4924
+ };
4925
+ var ALL_FLEET_AGENTS = Object.values(FLEET_ROSTER);
4926
+
4691
4927
  // src/defaults/autonomous-runner.ts
4692
4928
  var DoneConditionChecker = class {
4693
4929
  constructor(condition) {
@@ -7253,6 +7489,6 @@ var allServers = () => ({
7253
7489
  sentinel: { ...sentinelServer(), enabled: false }
7254
7490
  });
7255
7491
 
7256
- export { AutoCompactionMiddleware, AutonomousRunner, BudgetExceededError, ConfigMigrationError, DEFAULT_CONFIG_MIGRATIONS, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_SUBAGENT_BASELINE, DefaultAttachmentStore, DefaultConfigLoader, DefaultConfigStore, DefaultErrorHandler, DefaultHealthRegistry, DefaultLogger, DefaultMemoryStore, DefaultModeStore, DefaultModelsRegistry, DefaultMultiAgentCoordinator, DefaultPathResolver, DefaultPermissionPolicy, DefaultRetryPolicy, DefaultSecretScrubber, DefaultSecretVault, DefaultSessionReader, DefaultSessionStore, DefaultSkillLoader, DefaultTaskStore, DefaultTokenCounter, Director, DoneConditionChecker, FleetBus, FleetUsageAggregator, HybridCompactor, InMemoryAgentBridge, InMemoryBridgeTransport, InMemoryMetricsSink, IntelligentCompactor, LLMSelector, NoopMetricsSink, NoopTracer, OTelTracer, PROMETHEUS_CONTENT_TYPE, QueueStore, RecoveryLock, SelectiveCompactor, SpecDrivenDev, SpecParser, SubagentBudget, TaskFlow, TaskGenerator, TaskTracker, ToolExecutor, allServers, awsServer, blockServer, braveSearchServer, buildOtlpMetricsRequest, buildOtlpTracesRequest, classifyFamily, composeDirectorPrompt, composeSubagentPrompt, context7Server, contextManagerTool, createContextManagerTool, createMessage, decryptConfigSecrets, encryptConfigSecrets, everArtServer, filesystemServer, githubServer, googleMapsServer, loadProjectModes, loadUserModes, makeAgentSubagentRunner, makeDirectorSessionFactory, migratePlaintextSecrets, renderPrometheus, rewriteConfigEncrypted, rosterSummaryFromConfigs, runConfigMigrations, sentinelServer, slackServer, startMetricsServer, startOtlpMetricsExporter, startOtlpTraceExporter, wireMetricsToEvents };
7492
+ export { ALL_FLEET_AGENTS, AUDIT_LOG_AGENT, AutoCompactionMiddleware, AutonomousRunner, BUG_HUNTER_AGENT, BudgetExceededError, ConfigMigrationError, DEFAULT_CONFIG_MIGRATIONS, DEFAULT_DIRECTOR_PREAMBLE, DEFAULT_SUBAGENT_BASELINE, DefaultAttachmentStore, DefaultConfigLoader, DefaultConfigStore, DefaultErrorHandler, DefaultHealthRegistry, DefaultLogger, DefaultMemoryStore, DefaultModeStore, DefaultModelsRegistry, DefaultMultiAgentCoordinator, DefaultPathResolver, DefaultPermissionPolicy, DefaultRetryPolicy, DefaultSecretScrubber, DefaultSecretVault, DefaultSessionReader, DefaultSessionStore, DefaultSkillLoader, DefaultTaskStore, DefaultTokenCounter, Director, DirectorBudgetError, DoneConditionChecker, FLEET_ROSTER, FleetBus, FleetUsageAggregator, HybridCompactor, InMemoryAgentBridge, InMemoryBridgeTransport, InMemoryMetricsSink, IntelligentCompactor, LLMSelector, NoopMetricsSink, NoopTracer, OTelTracer, PROMETHEUS_CONTENT_TYPE, QueueStore, REFACTOR_PLANNER_AGENT, RecoveryLock, SECURITY_SCANNER_AGENT, SelectiveCompactor, SpecDrivenDev, SpecParser, SubagentBudget, TaskFlow, TaskGenerator, TaskTracker, ToolExecutor, allServers, awsServer, blockServer, braveSearchServer, buildOtlpMetricsRequest, buildOtlpTracesRequest, classifyFamily, composeDirectorPrompt, composeSubagentPrompt, context7Server, contextManagerTool, createContextManagerTool, createMessage, decryptConfigSecrets, encryptConfigSecrets, everArtServer, filesystemServer, githubServer, googleMapsServer, loadProjectModes, loadUserModes, makeAgentSubagentRunner, makeDirectorSessionFactory, migratePlaintextSecrets, renderPrometheus, rewriteConfigEncrypted, rosterSummaryFromConfigs, runConfigMigrations, sentinelServer, slackServer, startMetricsServer, startOtlpMetricsExporter, startOtlpTraceExporter, wireMetricsToEvents };
7257
7493
  //# sourceMappingURL=index.js.map
7258
7494
  //# sourceMappingURL=index.js.map