@wrongstack/core 0.63.4 → 0.66.13

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.
Files changed (57) hide show
  1. package/dist/{agent-bridge-B5rxWrg3.d.ts → agent-bridge-D-j6OOBT.d.ts} +1 -1
  2. package/dist/agent-subagent-runner-DRZ9-NnR.d.ts +1042 -0
  3. package/dist/{compactor-0vjZ8KTk.d.ts → compactor-D_ExJajC.d.ts} +1 -1
  4. package/dist/{config-BdDuaZmB.d.ts → config--86aHSln.d.ts} +1 -1
  5. package/dist/{context-iFMEO2rN.d.ts → context-y87Jc5ei.d.ts} +3 -3
  6. package/dist/coordination/index.d.ts +12 -12
  7. package/dist/coordination/index.js +87 -69
  8. package/dist/coordination/index.js.map +1 -1
  9. package/dist/defaults/index.d.ts +22 -22
  10. package/dist/defaults/index.js +113 -84
  11. package/dist/defaults/index.js.map +1 -1
  12. package/dist/{events-k8CHjcrN.d.ts → events-CIplI98R.d.ts} +1 -1
  13. package/dist/execution/index.d.ts +16 -385
  14. package/dist/execution/index.js +59 -51
  15. package/dist/execution/index.js.map +1 -1
  16. package/dist/extension/index.d.ts +6 -6
  17. package/dist/goal-store-C7jcumEh.d.ts +96 -0
  18. package/dist/{index-Bc6BiP5q.d.ts → index-DKUvyTvV.d.ts} +28 -442
  19. package/dist/{index-CWdW_CJt.d.ts → index-b5uhfTSl.d.ts} +8 -8
  20. package/dist/index.d.ts +34 -32
  21. package/dist/index.js +647 -677
  22. package/dist/index.js.map +1 -1
  23. package/dist/infrastructure/index.d.ts +6 -6
  24. package/dist/kernel/index.d.ts +9 -9
  25. package/dist/{mcp-servers-CwqQDMYy.d.ts → mcp-servers-DwoNBf6r.d.ts} +3 -3
  26. package/dist/models/index.d.ts +2 -2
  27. package/dist/{multi-agent-coordinator-CNUJYq7U.d.ts → multi-agent-coordinator-CWnH-CiX.d.ts} +10 -2
  28. package/dist/{null-fleet-bus-DRoJ0uOY.d.ts → null-fleet-bus-VApKRxcp.d.ts} +6 -7
  29. package/dist/observability/index.d.ts +2 -2
  30. package/dist/parallel-eternal-engine-0UwotoSx.d.ts +483 -0
  31. package/dist/{path-resolver-C5sPVne8.d.ts → path-resolver-DVkEcIw8.d.ts} +2 -2
  32. package/dist/{permission-Ld-i5ugf.d.ts → permission-C1A5whY5.d.ts} +5 -1
  33. package/dist/{permission-policy-CL-mPufp.d.ts → permission-policy-B2dK-T5N.d.ts} +19 -5
  34. package/dist/{plan-templates-ThBHOjaM.d.ts → plan-templates-Bprrzhbu.d.ts} +4 -4
  35. package/dist/{provider-runner-DJQa211J.d.ts → provider-runner-mXvXGSIw.d.ts} +3 -3
  36. package/dist/{retry-policy-BfBScewS.d.ts → retry-policy-CG3qvH_e.d.ts} +1 -1
  37. package/dist/sdd/index.d.ts +8 -8
  38. package/dist/sdd/index.js +58 -51
  39. package/dist/sdd/index.js.map +1 -1
  40. package/dist/security/index.d.ts +3 -3
  41. package/dist/security/index.js +31 -22
  42. package/dist/security/index.js.map +1 -1
  43. package/dist/{selector-DxhW7ML3.d.ts → selector-RvBR_YRW.d.ts} +1 -1
  44. package/dist/session-event-bridge-CDHxcmQU.d.ts +93 -0
  45. package/dist/{session-reader-q2ThszgG.d.ts → session-reader-BIpwM60D.d.ts} +1 -1
  46. package/dist/storage/index.d.ts +7 -6
  47. package/dist/{system-prompt-7LHyBbIf.d.ts → system-prompt-b61lOd49.d.ts} +2 -2
  48. package/dist/types/index.d.ts +23 -14
  49. package/dist/types/index.js.map +1 -1
  50. package/dist/utils/index.d.ts +2 -2
  51. package/dist/utils/index.js.map +1 -1
  52. package/package.json +1 -1
  53. package/skills/multi-agent/SKILL.md +0 -2
  54. package/dist/agent-subagent-runner-Zc3f37Sg.d.ts +0 -182
  55. package/dist/goal-store-iHltMi5n.d.ts +0 -188
  56. package/dist/multi-agent-SASYOrWA.d.ts +0 -554
  57. package/dist/tool-executor-CIjpGaRA.d.ts +0 -111
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wrongstack/core",
3
- "version": "0.63.4",
3
+ "version": "0.66.13",
4
4
  "license": "MIT",
5
5
  "description": "WrongStack core: kernel, types, defaults, and shared utilities for the WrongStack CLI agent.",
6
6
  "repository": {
@@ -166,8 +166,6 @@ The session throws a clear error if the resolved file count exceeds the effectiv
166
166
  // ✅ Good — single package, limited files
167
167
  collab_debug(["packages/core/src/agents/**/*.ts"])
168
168
 
169
- // ✅ Dynamic — limit computed from contextWindow
170
- collab_debug({
171
169
  // ✅ Explicit — override limit directly
172
170
  collab_debug({
173
171
  targetPaths: ["packages/core/src/**/*.ts"],
@@ -1,182 +0,0 @@
1
- import { c as Agent, f as AgentInput } from './index-Bc6BiP5q.js';
2
- import { E as EventBus } from './events-k8CHjcrN.js';
3
- import { n as SubagentConfig, v as TaskSpec, t as SubagentRunner } from './multi-agent-SASYOrWA.js';
4
-
5
- /**
6
- * Single fleet-wide event with subagent attribution. Whatever a child
7
- * agent emits on its own EventBus gets re-published here, prefixed with
8
- * `subagentId` so a single subscriber can multiplex across the fleet.
9
- *
10
- * The director uses `FleetBus.filter('tool.executed', …)` to see every
11
- * tool call across the fleet; the TUI uses
12
- * `FleetBus.subscribe(id, handler)` to render a per-subagent panel.
13
- */
14
- interface FleetEvent {
15
- subagentId: string;
16
- taskId?: string;
17
- ts: number;
18
- type: string;
19
- payload: unknown;
20
- }
21
- type FleetHandler = (event: FleetEvent) => void;
22
- /**
23
- * Fan-in for per-subagent EventBuses. Each subagent's bus is plugged in
24
- * via `attach()`; the FleetBus re-emits every event with subagent
25
- * attribution. Detachment is automatic via the returned disposer — call
26
- * it when a subagent terminates so we don't leak listeners.
27
- *
28
- * The bus exposes two subscription modes: by `subagentId` (everything
29
- * from one child) and by `type` (one event-type across the fleet). They
30
- * compose — if you need a per-subagent + per-type slice, subscribe by
31
- * type and filter on `event.subagentId` in your handler.
32
- */
33
- declare class FleetBus {
34
- private readonly byId;
35
- private readonly byType;
36
- private readonly any;
37
- /**
38
- * Hook a subagent's EventBus into the fleet. Uses `onAny()` (an alias for
39
- * `onPattern('*')`) to forward all events with subagent attribution, so
40
- * new kernel event types are automatically forwarded without any manual
41
- * registration. `subagent.*` events are excluded because they originate
42
- * from MultiAgentHost on the parent bus, not the subagent's own bus.
43
- *
44
- * Returns a disposer that detaches every subscription; call on
45
- * subagent teardown so the listeners don't outlive the run.
46
- */
47
- attach(subagentId: string, bus: EventBus, taskId?: string): () => void;
48
- /** Subscribe to every event from one subagent. */
49
- subscribe(subagentId: string, handler: FleetHandler): () => void;
50
- /** Subscribe to one event type across all subagents. */
51
- filter(type: string, handler: FleetHandler): () => void;
52
- /** Subscribe to literally everything. The fleet roll-up uses this. */
53
- onAny(handler: FleetHandler): () => void;
54
- emit(event: FleetEvent): void;
55
- }
56
- /**
57
- * Roll-up of token usage + cost across an entire director run. The
58
- * director's `fleet_status` tool returns this so the model can reason
59
- * about budget in its next turn ("the researcher already burned $0.40,
60
- * lean on summaries for the next task").
61
- */
62
- interface FleetUsage {
63
- total: {
64
- input: number;
65
- output: number;
66
- cacheRead: number;
67
- cacheWrite: number;
68
- cost: number;
69
- };
70
- perSubagent: Record<string, SubagentUsageSnapshot>;
71
- }
72
- interface SubagentUsageSnapshot {
73
- subagentId: string;
74
- provider?: string;
75
- model?: string;
76
- input: number;
77
- output: number;
78
- cacheRead: number;
79
- cacheWrite: number;
80
- cost: number;
81
- toolCalls: number;
82
- iterations: number;
83
- startedAt: number;
84
- lastEventAt: number;
85
- }
86
- /**
87
- * Aggregates provider.response + tool.executed events from the FleetBus
88
- * into a live `FleetUsage` snapshot. Costs are computed by the caller
89
- * via a `priceLookup(subagentId)` so we don't bake provider-pricing
90
- * coupling into core; the CLI/tests supply a function that resolves
91
- * each subagent's per-token rates from the models registry.
92
- */
93
- declare class FleetUsageAggregator {
94
- private readonly priceLookup?;
95
- private readonly metaLookup?;
96
- private readonly perSubagent;
97
- private readonly total;
98
- private readonly unsub;
99
- constructor(bus: FleetBus, priceLookup?: ((subagentId: string, provider?: string, model?: string) => {
100
- input?: number;
101
- output?: number;
102
- cacheRead?: number;
103
- cacheWrite?: number;
104
- } | undefined) | undefined, metaLookup?: ((subagentId: string) => {
105
- provider?: string;
106
- model?: string;
107
- } | undefined) | undefined);
108
- /**
109
- * Remove a terminated subagent's data from the aggregator and subtract its
110
- * contribution from the running totals. Call this when a subagent is removed
111
- * from the fleet so the aggregator doesn't accumulate unbounded data for
112
- * entities that will never emit events again.
113
- */
114
- removeSubagent(subagentId: string): void;
115
- /** Disposes all fleet-bus subscriptions. Call when the aggregator is no longer needed. */
116
- dispose(): void;
117
- /** Live snapshot — safe to call from a tool's execute() body. */
118
- snapshot(): FleetUsage;
119
- private ensure;
120
- private onProviderResponse;
121
- private onToolExecuted;
122
- private onIterationStarted;
123
- }
124
-
125
- /**
126
- * Caller-supplied factory that builds an isolated `Agent` for a subagent.
127
- * The factory MUST construct a fresh `Context` per call — sharing context
128
- * between subagents defeats isolation. Each Agent should also use either
129
- * its own `EventBus` or a forwarded view, so per-subagent metrics can be
130
- * attributed correctly.
131
- */
132
- type AgentFactory = (config: SubagentConfig) => Promise<AgentFactoryResult>;
133
- interface AgentFactoryResult {
134
- agent: Agent;
135
- /** Event bus the factory wired to this agent — required for budget hookup. */
136
- events: EventBus;
137
- /**
138
- * Optional cleanup hook invoked in the runner's `finally` block once
139
- * the task ends (success, failure, abort — same exit path). Factories
140
- * that own resources scoped to a single task (per-subagent JSONL
141
- * writers, transient providers, throwaway containers) implement this
142
- * to close them deterministically instead of relying on GC. Errors
143
- * thrown here are swallowed so a flaky cleanup can't mask the task's
144
- * real result.
145
- */
146
- dispose?: () => Promise<void> | void;
147
- }
148
- interface AgentRunnerOptions {
149
- factory: AgentFactory;
150
- /**
151
- * Format a TaskSpec into the user input the agent will receive. Defaults
152
- * to `task.description ?? ''`. Override when subagents expect structured
153
- * input (e.g. JSON contracts, role-prefixed prompts).
154
- */
155
- formatTaskInput?: (task: TaskSpec, config: SubagentConfig) => AgentInput;
156
- /**
157
- * When set, the runner attaches the subagent's EventBus to this FleetBus
158
- * on task start and detaches it when the task finishes. This is the
159
- * injection seam that lets the TUI fleet panel observe subagent activity
160
- * live — without it, FleetBus stays empty.
161
- */
162
- fleetBus?: FleetBus;
163
- }
164
- /**
165
- * Builds a `SubagentRunner` that drives a real `Agent` per task while honoring
166
- * the coordinator's budget and abort signal. This is the production adapter —
167
- * the coordinator's `runner` option in CLI/TUI assemblies points here.
168
- *
169
- * Lifecycle per task:
170
- * 1. factory(config) → fresh Agent + EventBus.
171
- * 2. Subscribe to events to feed the budget (tool calls, token usage).
172
- * 3. Call agent.run(input, { signal }) — the coordinator's signal cancels.
173
- * 4. Map RunResult.status onto a `SubagentRunOutcome` or throw on failure.
174
- * 5. Unsubscribe and let the factory's resources be GC'd.
175
- *
176
- * The budget is checked synchronously from event handlers — a runaway agent
177
- * that crosses its tool-call limit triggers `BudgetExceededError`, which the
178
- * coordinator surfaces as `status: 'failed'` on the task result.
179
- */
180
- declare function makeAgentSubagentRunner(opts: AgentRunnerOptions): SubagentRunner;
181
-
182
- export { type AgentFactory as A, FleetBus as F, type SubagentUsageSnapshot as S, type AgentFactoryResult as a, type AgentRunnerOptions as b, type FleetEvent as c, type FleetHandler as d, type FleetUsage as e, FleetUsageAggregator as f, makeAgentSubagentRunner as m };
@@ -1,188 +0,0 @@
1
- import { w as SessionEvent, B as SessionWriter } from './context-iFMEO2rN.js';
2
-
3
- type AuditLevel = 'minimal' | 'standard' | 'full';
4
- /**
5
- * Configuration for sampling high-volume events inside the bridge.
6
- * This allows callers (CLI, TUI, WebUI, plugins) to tune how aggressively
7
- * noisy events like tool progress are persisted.
8
- */
9
- interface ToolProgressSamplingOptions {
10
- /**
11
- * How often to persist 'log' and 'partial_output' progress events.
12
- * - 1 = every message (no sampling)
13
- * - 8 = keep the first message + every 8th after that (default)
14
- */
15
- sampleRate?: number;
16
- }
17
- interface SessionSamplingOptions {
18
- /** Controls sampling behavior for `tool_progress` events (only relevant at auditLevel 'full'). */
19
- toolProgress?: ToolProgressSamplingOptions;
20
- }
21
- interface SessionEventBridgeOptions {
22
- /** Sampling rules for high-volume audit events. */
23
- sampling?: SessionSamplingOptions;
24
- }
25
- /**
26
- * Small, safe helper that wraps a SessionWriter and enforces the
27
- * configured auditLevel.
28
- *
29
- * All appends are best-effort. Failures are swallowed (with optional
30
- * diagnostics) so they never crash the agent loop.
31
- */
32
- interface SessionEventBridge {
33
- /** Append an event if allowed by the current audit level. */
34
- append(event: SessionEvent): Promise<void>;
35
- /** Current audit level this bridge was created with. */
36
- readonly level: AuditLevel;
37
- /** Returns true if an event of this type should be written at the current level. */
38
- allows(type: SessionEvent['type']): boolean;
39
- }
40
- /** Core events that are always written regardless of auditLevel. */
41
- declare const CORE_RECONSTRUCT_EVENTS: Set<"error" | "tool_use" | "tool_result" | "session_start" | "session_resumed" | "user_input" | "llm_request" | "llm_response" | "compaction" | "session_end" | "mode_changed" | "task_created" | "task_updated" | "task_completed" | "task_failed" | "agent_spawned" | "agent_stopped" | "agent_error" | "spec_parsed" | "spec_analyzed" | "skill_activated" | "skill_deactivated" | "tool_call_start" | "tool_call_end" | "tool_progress" | "message_truncated" | "provider_retry" | "provider_error" | "checkpoint" | "file_snapshot" | "rewound" | "in_flight_start" | "in_flight_end">;
42
- /**
43
- * Events that are considered "standard" audit detail.
44
- * These are lightweight and high-value for forensics.
45
- */
46
- declare const STANDARD_AUDIT_EVENTS: Set<"error" | "tool_use" | "tool_result" | "session_start" | "session_resumed" | "user_input" | "llm_request" | "llm_response" | "compaction" | "session_end" | "mode_changed" | "task_created" | "task_updated" | "task_completed" | "task_failed" | "agent_spawned" | "agent_stopped" | "agent_error" | "spec_parsed" | "spec_analyzed" | "skill_activated" | "skill_deactivated" | "tool_call_start" | "tool_call_end" | "tool_progress" | "message_truncated" | "provider_retry" | "provider_error" | "checkpoint" | "file_snapshot" | "rewound" | "in_flight_start" | "in_flight_end">;
47
- /**
48
- * Create a safe, audit-level-aware bridge around a SessionWriter.
49
- *
50
- * The bridge can also apply sampling for high-volume events (e.g. `tool_progress`)
51
- * when `auditLevel` is set to `'full'`.
52
- *
53
- * @example
54
- * const bridge = createSessionEventBridge(sessionWriter, 'full', {
55
- * sampling: {
56
- * toolProgress: { sampleRate: 5 } // more aggressive sampling
57
- * }
58
- * });
59
- */
60
- declare function createSessionEventBridge(writer: SessionWriter | undefined | null, level?: AuditLevel, options?: SessionEventBridgeOptions): SessionEventBridge;
61
-
62
- /**
63
- * Safely extract the auditLevel from a (possibly partial) Config object.
64
- * Falls back to 'standard' if not present or invalid.
65
- */
66
- declare function resolveAuditLevel(cfg?: {
67
- session?: {
68
- auditLevel?: AuditLevel;
69
- };
70
- } | null): AuditLevel;
71
- /**
72
- * Fully resolves the session logging configuration with sensible defaults.
73
- * This is the recommended way for the CLI / TUI / WebUI to read session config.
74
- */
75
- declare function resolveSessionLoggingConfig(cfg?: {
76
- session?: {
77
- auditLevel?: AuditLevel;
78
- sampling?: {
79
- toolProgress?: {
80
- sampleRate?: number;
81
- };
82
- };
83
- };
84
- } | null): {
85
- auditLevel: AuditLevel;
86
- sampling: {
87
- toolProgress: {
88
- sampleRate: number;
89
- };
90
- };
91
- };
92
-
93
- /**
94
- * Long-running autonomous mission. A goal survives across sessions and
95
- * drives the EternalAutonomyEngine — every iteration of the engine
96
- * consults the goal to choose what to do next.
97
- *
98
- * Storage: `~/.wrongstack/projects/<hash>/goal.json`. Persistent and
99
- * project-scoped on purpose: the goal belongs to the codebase, not the
100
- * REPL session.
101
- */
102
- interface JournalEntry {
103
- /** ISO timestamp of the iteration. */
104
- at: string;
105
- /** Sequential iteration counter (1-based, monotonically increasing). */
106
- iteration: number;
107
- /** Source that produced the action ('todo' | 'git' | 'brainstorm' | 'resume' | 'manual' | 'parallel'). */
108
- source: 'todo' | 'git' | 'brainstorm' | 'resume' | 'manual' | 'parallel';
109
- /** Short one-line description of what the iteration set out to do. */
110
- task: string;
111
- /** Outcome status. */
112
- status: 'success' | 'failure' | 'aborted' | 'skipped';
113
- /** Optional free-form note (error message, summary, etc.). */
114
- note?: string;
115
- /** Optional token usage delta for this iteration. */
116
- tokens?: {
117
- input: number;
118
- output: number;
119
- };
120
- /** Optional USD cost delta for this iteration (provider-estimated). */
121
- costUsd?: number;
122
- }
123
- interface GoalFile {
124
- version: 1;
125
- /** The mission statement. */
126
- goal: string;
127
- /** When the goal was first set or last replaced. */
128
- setAt: string;
129
- /** Updated on every iteration completion. */
130
- lastActivityAt: string;
131
- /** Total iterations the engine has run against this goal (cumulative). */
132
- iterations: number;
133
- /** Engine lifecycle state — 'running' means another process owns this goal. */
134
- engineState: 'idle' | 'running' | 'stopped';
135
- /**
136
- * Mission-level lifecycle. `active` is the default; `completed` is set
137
- * when the engine detects `[GOAL_COMPLETE]` in a successful iteration's
138
- * final text AND a verification pass agrees; `abandoned` is set by the
139
- * user (e.g. `/goal abandon`) or when the engine exceeds a configured
140
- * failure ceiling. Once not `active`, the engine refuses to run further
141
- * iterations against this goal — protects against accidental restarts
142
- * burning through API quota after the work is done.
143
- *
144
- * Optional for backward compatibility — pre-existing `goal.json` files
145
- * without this field load as `active`.
146
- */
147
- goalState?: 'active' | 'paused' | 'completed' | 'abandoned';
148
- /**
149
- * Per-todo attempt counter. Keyed by TodoItem id. Used by the engine
150
- * to skip a todo that has failed N times rather than spinning on it
151
- * forever. Persisted so attempt counts survive restarts (`/autonomy
152
- * stop` + resume should not reset progress against a stuck task).
153
- */
154
- todoAttempts?: Record<string, number>;
155
- /** Bounded ring buffer of recent iterations (newest last). */
156
- journal: JournalEntry[];
157
- }
158
- /** Cap on persisted journal entries — older entries are evicted FIFO. */
159
- declare const MAX_JOURNAL_ENTRIES = 500;
160
- /**
161
- * Resolve the goal file path for a given project root.
162
- * Exposed so the engine and CLI use one canonical path.
163
- * Uses `~/.wrongstack/projects/<hash>/goal.json` .<hash>/`.
164
- */
165
- declare function goalFilePath(projectRoot: string): string;
166
- declare function loadGoal(filePath: string): Promise<GoalFile | null>;
167
- declare function saveGoal(filePath: string, goal: GoalFile): Promise<void>;
168
- declare function emptyGoal(goal: string): GoalFile;
169
- /**
170
- * Append a journal entry, bumping iteration counters and trimming the
171
- * ring buffer. Returns a new GoalFile — does not mutate the argument.
172
- */
173
- declare function appendJournal(goal: GoalFile, entry: Omit<JournalEntry, 'iteration' | 'at'>): GoalFile;
174
- /**
175
- * Aggregate cumulative cost + tokens across all journal entries. Entries
176
- * without telemetry are skipped (legacy entries from before the field
177
- * was added still load cleanly).
178
- */
179
- declare function summarizeUsage(goal: GoalFile): {
180
- totalCostUsd: number;
181
- totalInputTokens: number;
182
- totalOutputTokens: number;
183
- iterationsWithUsage: number;
184
- };
185
- /** Format the goal + recent journal as a human-readable status block. */
186
- declare function formatGoal(goal: GoalFile, journalLimit?: number): string;
187
-
188
- export { type AuditLevel as A, CORE_RECONSTRUCT_EVENTS as C, type GoalFile as G, type JournalEntry as J, MAX_JOURNAL_ENTRIES as M, STANDARD_AUDIT_EVENTS as S, type ToolProgressSamplingOptions as T, type SessionEventBridge as a, type SessionEventBridgeOptions as b, type SessionSamplingOptions as c, appendJournal as d, createSessionEventBridge as e, emptyGoal as f, formatGoal as g, goalFilePath as h, resolveSessionLoggingConfig as i, summarizeUsage as j, loadGoal as l, resolveAuditLevel as r, saveGoal as s };