@wrongstack/core 0.1.10 → 0.3.1

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 (54) hide show
  1. package/dist/{agent-bridge-6KPqsFx6.d.ts → agent-bridge-C3DUGjSb.d.ts} +1 -1
  2. package/dist/{compactor-B4mQZXf2.d.ts → compactor-BUU6Zm_3.d.ts} +1 -1
  3. package/dist/{config-BU9f_5yH.d.ts → config-CKLYPkCi.d.ts} +1 -1
  4. package/dist/{context-BmM2xGUZ.d.ts → context-IovtuTf8.d.ts} +10 -0
  5. package/dist/coordination/index.d.ts +211 -13
  6. package/dist/coordination/index.js +964 -67
  7. package/dist/coordination/index.js.map +1 -1
  8. package/dist/defaults/index.d.ts +33 -18
  9. package/dist/defaults/index.js +1273 -42
  10. package/dist/defaults/index.js.map +1 -1
  11. package/dist/{events-BMNaEFZl.d.ts → events-CNB9PALO.d.ts} +99 -1
  12. package/dist/execution/index.d.ts +12 -12
  13. package/dist/extension/index.d.ts +9 -0
  14. package/dist/extension/index.js +234 -0
  15. package/dist/extension/index.js.map +1 -0
  16. package/dist/index-BDb0cAMP.d.ts +806 -0
  17. package/dist/index.d.ts +112 -29
  18. package/dist/index.js +2036 -490
  19. package/dist/index.js.map +1 -1
  20. package/dist/infrastructure/index.d.ts +6 -6
  21. package/dist/kernel/index.d.ts +12 -9
  22. package/dist/kernel/index.js +73 -7
  23. package/dist/kernel/index.js.map +1 -1
  24. package/dist/{mcp-servers-Dzgg4x1w.d.ts → mcp-servers-DR35ojJZ.d.ts} +3 -3
  25. package/dist/models/index.d.ts +2 -2
  26. package/dist/models/index.js +24 -1
  27. package/dist/models/index.js.map +1 -1
  28. package/dist/{multi-agent-fmkRHtof.d.ts → multi-agent-B9a6sflH.d.ts} +71 -3
  29. package/dist/observability/index.d.ts +2 -2
  30. package/dist/{path-resolver-DBjaoXFq.d.ts → path-resolver-Cl_q0u-R.d.ts} +2 -2
  31. package/dist/provider-runner-BXuADQqQ.d.ts +36 -0
  32. package/dist/sdd/index.d.ts +3 -3
  33. package/dist/{secret-scrubber-CicHLN4G.d.ts → secret-scrubber-CgG2tV2B.d.ts} +1 -1
  34. package/dist/{secret-scrubber-DF88luOe.d.ts → secret-scrubber-Cuy5afaQ.d.ts} +1 -1
  35. package/dist/security/index.d.ts +20 -4
  36. package/dist/security/index.js +37 -2
  37. package/dist/security/index.js.map +1 -1
  38. package/dist/{selector-BbJqiEP4.d.ts → selector-wT2fv9Fg.d.ts} +1 -1
  39. package/dist/{session-reader-Drq8RvJu.d.ts → session-reader-CcPi4BQ8.d.ts} +1 -1
  40. package/dist/{skill-DhfSizKv.d.ts → skill-C_7znCIC.d.ts} +2 -2
  41. package/dist/storage/index.d.ts +164 -6
  42. package/dist/storage/index.js +297 -2
  43. package/dist/storage/index.js.map +1 -1
  44. package/dist/{renderer-rk_1Swwc.d.ts → system-prompt-Dk1qm8ey.d.ts} +30 -2
  45. package/dist/{tool-executor-CpuJPYm9.d.ts → tool-executor-DKu4A6nB.d.ts} +5 -5
  46. package/dist/types/index.d.ts +16 -16
  47. package/dist/types/index.js +24 -1
  48. package/dist/types/index.js.map +1 -1
  49. package/dist/utils/index.d.ts +1 -1
  50. package/dist/utils/index.js +24 -1
  51. package/dist/utils/index.js.map +1 -1
  52. package/package.json +5 -1
  53. package/dist/plugin-DJk6LL8B.d.ts +0 -434
  54. package/dist/system-prompt-BC_8ypCG.d.ts +0 -23
@@ -1,434 +0,0 @@
1
- import { u as Tool, z as ToolResultBlock, g as Provider, R as Request, j as Response, D as ToolUseBlock, a0 as Context, b as ContentBlock, T as TextBlock, a7 as RunOptions, W as WrongStackError, J as JSONSchema } from './context-BmM2xGUZ.js';
2
- import { T as Tracer } from './observability-BhnVLBLS.js';
3
- import { E as EventBus, a as EventName, L as Listener } from './events-BMNaEFZl.js';
4
- import { R as Renderer, C as Container, P as Pipeline, c as ReadonlyPipeline } from './renderer-rk_1Swwc.js';
5
- import { a as PermissionPolicy, S as SecretScrubber } from './secret-scrubber-CicHLN4G.js';
6
- import { e as ProviderConfig, C as Config } from './config-BU9f_5yH.js';
7
- import { W as WireFamily } from './models-registry-Y2xbog0E.js';
8
- import { L as Logger } from './logger-BMQgxvdy.js';
9
-
10
- declare class ToolRegistry {
11
- private readonly tools;
12
- register(tool: Tool, owner?: string): void;
13
- /**
14
- * Attempt to register a tool. Returns true if successful, false if a tool
15
- * with the same name is already registered. Useful in multi-agent or plugin
16
- * scenarios where duplicate registration may be intentional.
17
- */
18
- tryRegister(tool: Tool, owner?: string): boolean;
19
- /**
20
- * Register a tool as a default. If the tool name is already registered,
21
- * this is a no-op — the existing registration (from core or another
22
- * plugin) takes precedence. Use `override` to intentionally replace.
23
- */
24
- registerDefault(tool: Tool, owner?: string): void;
25
- unregister(name: string): boolean;
26
- /**
27
- * Override an existing tool. Throws if the tool is not already registered.
28
- * Plugins use this to replace built-in tools with custom implementations.
29
- */
30
- override(name: string, tool: Tool, owner?: string): void;
31
- get(name: string): Tool | undefined;
32
- ownerOf(name: string): string | undefined;
33
- list(): Tool[];
34
- listWithOwner(): {
35
- tool: Tool;
36
- owner: string;
37
- }[];
38
- clear(): void;
39
- }
40
-
41
- /**
42
- * Output from a single tool execution.
43
- */
44
- interface ToolExecutionOutput {
45
- result: ToolResultBlock | ToolConfirmPendingResult;
46
- tool?: Tool;
47
- durationMs: number;
48
- }
49
- /**
50
- * Result of running a batch of tools for a single agent iteration.
51
- */
52
- interface ToolBatchResult {
53
- outputs: ToolExecutionOutput[];
54
- remainingBudget: number;
55
- }
56
- type ConfirmAwaiter = (tool: Tool, input: unknown, toolUseId: string, suggestedPattern: string) => Promise<'yes' | 'no' | 'always' | 'deny'>;
57
- interface ToolExecutorOptions {
58
- permissionPolicy: PermissionPolicy;
59
- secretScrubber: SecretScrubber;
60
- renderer?: Renderer | undefined;
61
- /**
62
- * Optional event bus. When provided, the executor emits `tool.started`
63
- * before invoking each tool's `execute()`. Closes the observability gap
64
- * between "model decided to call tool" and "tool finished".
65
- */
66
- events?: EventBus | undefined;
67
- /**
68
- * Optional tracer. When provided, every tool execution opens a
69
- * `tool.<name>` span with attributes for tool name, permission decision,
70
- * input size, output size, and outcome. Spans are no-op by default.
71
- */
72
- tracer?: Tracer | undefined;
73
- /**
74
- * Async callback invoked when a tool needs user confirmation.
75
- * When omitted and confirmation is required, the executor returns a
76
- * failure result immediately (TUI path). When provided (CLI path),
77
- * the callback handles the interactive prompt and returns a decision.
78
- */
79
- confirmAwaiter?: ConfirmAwaiter | undefined;
80
- iterationTimeoutMs?: number;
81
- perIterationOutputCapBytes?: number;
82
- }
83
- /**
84
- * Result returned by executeBatch when a tool needs confirmation and
85
- * no confirmAwaiter is available. The TUI catches this and surfaces a
86
- * confirmation dialog; once resolved the tool is re-executed.
87
- * The string tag identifies it as a "pending confirm" result so callers
88
- * can distinguish it from an error without inspecting content strings.
89
- */
90
- interface ToolConfirmPendingResult {
91
- type: 'tool_confirm_pending';
92
- toolUseId: string;
93
- toolName: string;
94
- input: unknown;
95
- suggestedPattern: string;
96
- }
97
- type ToolExecutorStrategy = 'parallel' | 'sequential' | 'smart';
98
-
99
- /**
100
- * Factory for constructing a Provider instance. The `family` field
101
- * declares the wire protocol so callers can route without inspecting
102
- * the returned instance. The `type` is the registry key (e.g. a
103
- * provider's models.dev id or a user-chosen alias).
104
- */
105
- interface ProviderFactory$1 {
106
- /**
107
- * Unique identifier used as the registry key. When registered via
108
- * a plugin, this becomes `cfg.type` in `ProviderRegistry.create(cfg)`.
109
- */
110
- type: string;
111
- /**
112
- * Declares the wire protocol family so consumers can route based on
113
- * capability (e.g. which tool-format converter to use) without
114
- * instantiating the provider.
115
- */
116
- family: WireFamily;
117
- create(cfg: ProviderConfig): Provider;
118
- }
119
- declare class ProviderRegistry {
120
- private readonly factories;
121
- /**
122
- * Register a provider factory. If a factory with the same type already
123
- * exists, it is replaced. Use this for both initial registration and
124
- * runtime overrides (e.g. from plugins or CLI flags).
125
- */
126
- register(f: ProviderFactory$1): void;
127
- /**
128
- * Override an existing factory. Throws if no factory is registered
129
- * for the given type. Use this to safely replace a provider at runtime
130
- * (e.g. in tests or when a plugin provides a custom implementation).
131
- */
132
- override(type: string, f: ProviderFactory$1): void;
133
- has(type: string): boolean;
134
- create(cfg: ProviderConfig): Provider;
135
- list(): string[];
136
- }
137
-
138
- /** Default iteration cap. Use 0 or Infinity via config to disable. */
139
- declare const DEFAULT_MAX_ITERATIONS = 100;
140
- interface RunResult {
141
- status: 'done' | 'failed' | 'max_iterations' | 'aborted';
142
- /**
143
- * Set when `status === 'failed'` (always) or `'aborted'` (when the abort
144
- * carried an error context). Always a `WrongStackError` so callers can
145
- * branch on `code`, `severity`, and `recoverable` without parsing strings.
146
- * Raw throws are wrapped into an `AgentError` with code `AGENT_RUN_FAILED`
147
- * by `Agent.run` before they reach this field.
148
- */
149
- error?: WrongStackError;
150
- finalText?: string;
151
- iterations: number;
152
- }
153
- interface AgentInit {
154
- container: Container;
155
- tools: ToolRegistry;
156
- providers: ProviderRegistry;
157
- events: EventBus;
158
- pipelines: AgentPipelines;
159
- context: Context;
160
- maxIterations?: number;
161
- iterationTimeoutMs?: number;
162
- executionStrategy?: 'parallel' | 'sequential' | 'smart';
163
- perIterationOutputCapBytes?: number;
164
- /**
165
- * When true (default), the agent automatically extends its iteration
166
- * limit by 100 when hit, without asking the user. Set to false to
167
- * emit `iteration.limit_reached` and wait for a listener to grant/deny.
168
- */
169
- autoExtendLimit?: boolean;
170
- /**
171
- * Optional confirm handler. When set, the executor calls it synchronously
172
- * when a tool needs user confirmation (CLI path). When omitted, the
173
- * executor returns a `ToolConfirmPendingResult` and the agent emits
174
- * `tool.confirm_needed` for the TUI to resolve.
175
- */
176
- confirmAwaiter?: ConfirmAwaiter | undefined;
177
- /**
178
- * Optional tracer. When provided, `Agent.run` opens an `agent.run` span,
179
- * per-iteration `agent.iteration` spans, and `provider.complete` spans
180
- * inside the retry loop. Tool spans are opened by the ToolExecutor.
181
- * Default is `NoopTracer` (zero overhead).
182
- */
183
- tracer?: Tracer | undefined;
184
- }
185
- interface AgentPipelines {
186
- request: Pipeline<Request>;
187
- response: Pipeline<Response>;
188
- toolCall: Pipeline<ToolCallPipelinePayload>;
189
- userInput: Pipeline<UserInputPayload>;
190
- assistantOutput: Pipeline<TextBlock>;
191
- contextWindow: Pipeline<Context>;
192
- }
193
- interface UserInputPayload {
194
- content: ContentBlock[];
195
- /** Concatenation of text blocks — convenience for middleware that only cares about text. */
196
- text: string;
197
- ctx: Context;
198
- }
199
- type AgentInput = string | ContentBlock[];
200
- interface ToolCallPipelinePayload {
201
- toolUse: ToolUseBlock;
202
- result: ToolResultBlock;
203
- ctx: Context;
204
- /** Undefined when the model invoked a tool name we don't know. */
205
- tool?: Tool;
206
- }
207
- declare function createDefaultPipelines(): AgentPipelines;
208
- declare class Agent {
209
- readonly container: Container;
210
- readonly tools: ToolRegistry;
211
- readonly providers: ProviderRegistry;
212
- readonly events: EventBus;
213
- readonly pipelines: AgentPipelines;
214
- readonly ctx: Context;
215
- private readonly maxIterations;
216
- private readonly iterationTimeoutMs;
217
- private readonly executionStrategy;
218
- private readonly perIterationOutputCapBytes;
219
- private readonly plugins;
220
- private readonly toolExecutor;
221
- private readonly autoExtendLimit;
222
- private readonly tracer;
223
- constructor(init: AgentInit);
224
- private get logger();
225
- private get retry();
226
- private get errorHandler();
227
- private get permission();
228
- private get scrubber();
229
- private get renderer();
230
- register(tool: Tool): void;
231
- use(plugin: Plugin, api: PluginAPI): Promise<void>;
232
- run(userInput: AgentInput, opts?: RunOptions): Promise<RunResult>;
233
- private runInner;
234
- /**
235
- * Normalize user input and emit through userInput pipeline + session append.
236
- */
237
- private normalizeAndEmitUserInput;
238
- /**
239
- * Check if iteration limit has been reached and request extension if needed.
240
- * Returns the new effective limit (possibly extended) and a RunResult if
241
- * the loop should exit. Returns `{ limit }` with no result when the
242
- * iteration may proceed.
243
- */
244
- private checkIterationLimit;
245
- /**
246
- * Build request and run through request pipeline.
247
- */
248
- private buildAndRunRequestPipeline;
249
- /**
250
- * Process the provider response: run response pipeline, emit events,
251
- * update session, render text, handle abort.
252
- */
253
- private processResponse;
254
- /**
255
- * Execute tools and append tool results to context.
256
- * When a tool returns `tool_confirm_pending` (no confirmAwaiter set),
257
- * we pause and emit `tool.confirm_needed`. The run is blocked until
258
- * the event listener resolves the confirmation, then we re-run the
259
- * single tool.
260
- */
261
- private executeTools;
262
- private waitForConfirm;
263
- private executeSingleWithDecision;
264
- /**
265
- * Run context window pipeline. The pipeline may be empty, or it may contain
266
- * middleware with its own injected dependencies.
267
- */
268
- private compactContextIfNeeded;
269
- }
270
-
271
- /**
272
- * A slash command registered with the CLI or available to plugins.
273
- * Plugins receive a view of the registry via PluginAPI.slashCommands.
274
- *
275
- * Commands registered by plugins use a namespaced name: `pluginName:commandName`.
276
- * This prevents collisions with built-in commands and other plugins.
277
- */
278
- interface SlashCommand {
279
- /** Unique command name. For plugins: `pluginName:commandName`. */
280
- name: string;
281
- /** Short aliases — also prefixed automatically: `pluginName:alias`. */
282
- aliases?: string[];
283
- description: string;
284
- /**
285
- * Optional detailed help shown by `/help <name>`. Use this for usage,
286
- * arguments, examples, side-effects — anything that doesn't fit in
287
- * `description`. Renders verbatim, so format with line breaks.
288
- * If absent, `/help <name>` falls back to `description`.
289
- */
290
- help?: string;
291
- /**
292
- * Execute the command.
293
- * @param args Everything after the command name (trimmed by dispatch).
294
- * @param ctx The current agent context.
295
- * @returns `{ exit: true }` to quit the REPL. `{ message }` to print and continue.
296
- */
297
- run(args: string, ctx: Context): Promise<{
298
- exit?: boolean;
299
- message?: string;
300
- } | void>;
301
- }
302
-
303
- interface ToolRegistryView {
304
- register(t: Tool): void;
305
- unregister(name: string): void;
306
- get(name: string): Tool | undefined;
307
- list(): Tool[];
308
- }
309
- interface ProviderFactory {
310
- type: string;
311
- family: WireFamily;
312
- create(cfg: unknown): Provider;
313
- }
314
- interface ProviderRegistryView {
315
- register(f: ProviderFactory): void;
316
- create(cfg: {
317
- type: string;
318
- } & Record<string, unknown>): Provider;
319
- list(): string[];
320
- }
321
- interface MCPRegistryView {
322
- start(cfg: unknown): Promise<void>;
323
- stop(name: string): Promise<void>;
324
- restart(name: string): Promise<void>;
325
- list(): {
326
- name: string;
327
- state: string;
328
- toolCount: number;
329
- }[];
330
- }
331
- interface SlashCommandRegistryView {
332
- register(cmd: SlashCommand): void;
333
- unregister(name: string): boolean;
334
- get(name: string): SlashCommand | undefined;
335
- list(): SlashCommand[];
336
- }
337
- interface PluginPipelines {
338
- request: ReadonlyPipeline<Request>;
339
- response: ReadonlyPipeline<Response>;
340
- toolCall: ReadonlyPipeline<ToolCallPipelinePayload>;
341
- userInput: ReadonlyPipeline<{
342
- content: ContentBlock[];
343
- text: string;
344
- ctx: Context;
345
- }>;
346
- assistantOutput: ReadonlyPipeline<TextBlock>;
347
- contextWindow: ReadonlyPipeline<Context>;
348
- [k: string]: ReadonlyPipeline<any>;
349
- }
350
- interface PluginAPI {
351
- container: Container;
352
- pipelines: PluginPipelines;
353
- events: EventBus;
354
- tools: ToolRegistryView;
355
- providers: ProviderRegistryView;
356
- mcp: MCPRegistryView;
357
- slashCommands: SlashCommandRegistryView;
358
- config: Config;
359
- log: Logger;
360
- /**
361
- * Register a one-time event listener. The handler is automatically removed
362
- * after the first emission, or when the plugin is uninstalled — whichever
363
- * comes first.
364
- */
365
- onEvent<K extends EventName>(event: K, handler: Listener<K>): () => void;
366
- }
367
- /**
368
- * Capability declaration — informs the host which subsystems a plugin
369
- * intends to touch. Used for diagnostics and per-plugin enable/disable UX
370
- * (e.g. "this plugin registers tools — disable to remove them"). Not
371
- * enforced at runtime: a plugin that declares `tools: false` can still
372
- * call `api.tools.register()`, but the host can flag the discrepancy.
373
- */
374
- interface PluginCapabilities {
375
- /** Will register tools via `api.tools.register()`. */
376
- tools?: boolean;
377
- /** Will register provider factories via `api.providers.register()`. */
378
- providers?: boolean;
379
- /**
380
- * Pipelines the plugin hooks into. Use the standard names
381
- * (`request | response | toolCall | userInput | assistantOutput | contextWindow`)
382
- * or custom pipeline names exposed by other plugins.
383
- */
384
- pipelines?: string[];
385
- /** Will register slash commands via `api.slashCommands.register()`. */
386
- slashCommands?: boolean;
387
- /** Will start MCP servers via `api.mcp.start()`. */
388
- mcp?: boolean;
389
- }
390
- /**
391
- * Structured dependency declaration. The string form (`dependsOn: ['foo']`)
392
- * is shorthand for `[{ name: 'foo' }]` — both work. Use the structured form
393
- * when you need a version constraint:
394
- *
395
- * dependsOn: [{ name: 'wstack-auth', version: '^1.2.0' }]
396
- */
397
- interface PluginDependency {
398
- name: string;
399
- /** npm-style semver range. Supports `^`, `~`, exact, and unprefixed. */
400
- version?: string;
401
- }
402
- interface Plugin {
403
- name: string;
404
- version?: string;
405
- /** One-line summary for `wstack plugins list` and error messages. */
406
- description?: string;
407
- /** Semver range against the kernel API version (KERNEL_API_VERSION). */
408
- apiVersion: string;
409
- /**
410
- * Capability hints — what subsystems the plugin will register against.
411
- * Optional; provided for diagnostics and UX. The loader does not enforce
412
- * these, but mismatch is surfaced via logger at warn level.
413
- */
414
- capabilities?: PluginCapabilities;
415
- /**
416
- * JSON Schema for the options under `Config.plugins[<name>].options`.
417
- * When present, the loader validates that section before calling `setup`
418
- * and rejects the plugin with a clear error path on failure.
419
- */
420
- configSchema?: JSONSchema;
421
- /**
422
- * Mandatory plugin dependencies — loading fails if any are absent or
423
- * version-incompatible. Accepts both the legacy string-array form and
424
- * the structured form with version constraints.
425
- */
426
- dependsOn?: (string | PluginDependency)[];
427
- /** Optional plugin dependencies — silently skipped if absent. */
428
- optionalDeps?: (string | PluginDependency)[];
429
- conflictsWith?: string[];
430
- setup(api: PluginAPI): void | Promise<void>;
431
- teardown?(api: PluginAPI): void | Promise<void>;
432
- }
433
-
434
- export { Agent as A, DEFAULT_MAX_ITERATIONS as D, type MCPRegistryView as M, type Plugin as P, type RunResult as R, type SlashCommand as S, type ToolRegistryView as T, type UserInputPayload as U, type PluginAPI as a, type PluginCapabilities as b, type PluginDependency as c, type PluginPipelines as d, type ProviderFactory as e, type ProviderRegistryView as f, type SlashCommandRegistryView as g, type ToolExecutorOptions as h, type ToolExecutorStrategy as i, type ToolBatchResult as j, ToolRegistry as k, ProviderRegistry as l, type AgentInit as m, type AgentInput as n, type AgentPipelines as o, type ProviderFactory$1 as p, createDefaultPipelines as q };
@@ -1,23 +0,0 @@
1
- import { u as Tool, T as TextBlock } from './context-BmM2xGUZ.js';
2
-
3
- /** Model capabilities relevant to prompt composition. */
4
- interface ModelCapabilities {
5
- maxContextTokens: number;
6
- supportsTools: boolean;
7
- supportsVision: boolean;
8
- supportsReasoning: boolean;
9
- }
10
- interface BuildContext {
11
- cwd: string;
12
- projectRoot: string;
13
- tools: Tool[];
14
- /** Provider id (e.g. "anthropic", "minimax-coding-plan"). */
15
- provider?: string;
16
- /** Model id (e.g. "claude-sonnet-4-6", "MiniMax-M2.7"). */
17
- model?: string;
18
- }
19
- interface SystemPromptBuilder {
20
- build(ctx: BuildContext): Promise<TextBlock[]>;
21
- }
22
-
23
- export type { BuildContext as B, ModelCapabilities as M, SystemPromptBuilder as S };