@wrongstack/core 0.1.8 → 0.1.10
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.
- package/dist/agent-bridge-6KPqsFx6.d.ts +33 -0
- package/dist/compactor-B4mQZXf2.d.ts +17 -0
- package/dist/config-BU9f_5yH.d.ts +193 -0
- package/dist/{provider-txgB0Oq9.d.ts → context-BmM2xGUZ.d.ts} +532 -472
- package/dist/coordination/index.d.ts +694 -0
- package/dist/coordination/index.js +1995 -0
- package/dist/coordination/index.js.map +1 -0
- package/dist/defaults/index.d.ts +34 -2206
- package/dist/defaults/index.js +4116 -3790
- package/dist/defaults/index.js.map +1 -1
- package/dist/events-BMNaEFZl.d.ts +218 -0
- package/dist/execution/index.d.ts +260 -0
- package/dist/execution/index.js +1625 -0
- package/dist/execution/index.js.map +1 -0
- package/dist/index.d.ts +50 -12
- package/dist/index.js +6669 -5909
- package/dist/index.js.map +1 -1
- package/dist/infrastructure/index.d.ts +10 -0
- package/dist/infrastructure/index.js +575 -0
- package/dist/infrastructure/index.js.map +1 -0
- package/dist/input-reader-E-ffP2ee.d.ts +12 -0
- package/dist/kernel/index.d.ts +15 -4
- package/dist/kernel/index.js.map +1 -1
- package/dist/logger-BH6AE0W9.d.ts +24 -0
- package/dist/logger-BMQgxvdy.d.ts +12 -0
- package/dist/mcp-servers-Dzgg4x1w.d.ts +100 -0
- package/dist/memory-CEXuo7sz.d.ts +16 -0
- package/dist/mode-CV077NjV.d.ts +27 -0
- package/dist/models/index.d.ts +60 -0
- package/dist/models/index.js +621 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models-registry-DqzwpBQy.d.ts +46 -0
- package/dist/models-registry-Y2xbog0E.d.ts +95 -0
- package/dist/multi-agent-fmkRHtof.d.ts +283 -0
- package/dist/observability/index.d.ts +353 -0
- package/dist/observability/index.js +691 -0
- package/dist/observability/index.js.map +1 -0
- package/dist/observability-BhnVLBLS.d.ts +67 -0
- package/dist/path-resolver-CPRj4bFY.d.ts +10 -0
- package/dist/path-resolver-DBjaoXFq.d.ts +54 -0
- package/dist/plugin-DJk6LL8B.d.ts +434 -0
- package/dist/renderer-rk_1Swwc.d.ts +158 -0
- package/dist/sdd/index.d.ts +206 -0
- package/dist/sdd/index.js +864 -0
- package/dist/sdd/index.js.map +1 -0
- package/dist/secret-scrubber-CicHLN4G.d.ts +31 -0
- package/dist/secret-scrubber-DF88luOe.d.ts +54 -0
- package/dist/secret-vault-DoISxaKO.d.ts +19 -0
- package/dist/security/index.d.ts +30 -0
- package/dist/security/index.js +524 -0
- package/dist/security/index.js.map +1 -0
- package/dist/selector-BbJqiEP4.d.ts +51 -0
- package/dist/session-reader-Drq8RvJu.d.ts +150 -0
- package/dist/skill-DhfSizKv.d.ts +72 -0
- package/dist/storage/index.d.ts +382 -0
- package/dist/storage/index.js +1530 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/{system-prompt-vAB0F54-.d.ts → system-prompt-BC_8ypCG.d.ts} +1 -1
- package/dist/task-graph-BITvWt4t.d.ts +160 -0
- package/dist/tool-executor-CpuJPYm9.d.ts +97 -0
- package/dist/types/index.d.ts +26 -4
- package/dist/types/index.js +1787 -4
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +49 -2
- package/dist/utils/index.js +100 -2
- package/dist/utils/index.js.map +1 -1
- package/package.json +34 -2
- package/skills/audit-log/SKILL.md +67 -0
- package/skills/bug-hunter/SKILL.md +87 -0
- package/skills/refactor-planner/SKILL.md +94 -0
- package/skills/security-scanner/SKILL.md +117 -0
- package/dist/mode-Pjt5vMS6.d.ts +0 -815
- package/dist/session-reader-9sOTgmeC.d.ts +0 -1087
|
@@ -1,1087 +0,0 @@
|
|
|
1
|
-
import { c as ContentBlock, a0 as Context, v as Tool, B as ToolResultBlock, F as ToolUseBlock, h as Provider, R as Request, k as Response, T as TextBlock, a5 as RunOptions, W as WrongStackError, J as JSONSchema, U as Usage, n as SessionEvent, o as SessionMetadata, p as SessionStore } from './provider-txgB0Oq9.js';
|
|
2
|
-
import { t as PermissionPolicy, S as SecretScrubber, y as Renderer, O as EventBus, W as WireFamily, x as ProviderConfig, N as Container, a2 as Pipeline, a5 as ReadonlyPipeline, b as Config, g as Logger, Q as EventName, U as Listener } from './mode-Pjt5vMS6.js';
|
|
3
|
-
|
|
4
|
-
type AttachmentKind = 'text' | 'image' | 'file';
|
|
5
|
-
interface AttachmentMeta {
|
|
6
|
-
/** Display label for the placeholder e.g. "123 lines" or "PNG 412 KB". */
|
|
7
|
-
label?: string;
|
|
8
|
-
/** Original filename if known. */
|
|
9
|
-
filename?: string;
|
|
10
|
-
/** MIME type if known. Required for images. */
|
|
11
|
-
mediaType?: string;
|
|
12
|
-
}
|
|
13
|
-
interface Attachment {
|
|
14
|
-
readonly id: string;
|
|
15
|
-
readonly kind: AttachmentKind;
|
|
16
|
-
readonly meta: AttachmentMeta;
|
|
17
|
-
/** In-memory payload. For images this is base64; for text/file it's the raw text. */
|
|
18
|
-
readonly data?: string;
|
|
19
|
-
/** Disk location if spooled. Mutually exclusive with `data` for large payloads. */
|
|
20
|
-
readonly path?: string;
|
|
21
|
-
readonly bytes: number;
|
|
22
|
-
readonly createdAt: string;
|
|
23
|
-
}
|
|
24
|
-
interface AttachmentRef {
|
|
25
|
-
readonly id: string;
|
|
26
|
-
readonly kind: AttachmentKind;
|
|
27
|
-
/** Index for display, e.g. `#1`. Stable for the lifetime of a session. */
|
|
28
|
-
readonly seq: number;
|
|
29
|
-
readonly meta: AttachmentMeta;
|
|
30
|
-
}
|
|
31
|
-
interface AddAttachmentInput {
|
|
32
|
-
kind: AttachmentKind;
|
|
33
|
-
data: string;
|
|
34
|
-
meta?: AttachmentMeta;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Session-scoped store for content that is too big to inline in display
|
|
38
|
-
* but must be sent to the model as a real ContentBlock. The input layer
|
|
39
|
-
* (CLI/TUI) puts pasted text, dropped files, and pasted images here, gets
|
|
40
|
-
* back a stable AttachmentRef, and shows a placeholder like `[pasted #1]`
|
|
41
|
-
* to the user. At submit time, `expand()` swaps placeholders for the real
|
|
42
|
-
* payload as ContentBlock[].
|
|
43
|
-
*/
|
|
44
|
-
interface AttachmentStore {
|
|
45
|
-
add(input: AddAttachmentInput): Promise<AttachmentRef>;
|
|
46
|
-
get(id: string): Promise<Attachment | undefined>;
|
|
47
|
-
list(): AttachmentRef[];
|
|
48
|
-
/**
|
|
49
|
-
* Replace all known placeholder tokens in `text` (e.g. `[pasted #1]`,
|
|
50
|
-
* `[image #2]`) with the corresponding ContentBlock(s) and return the
|
|
51
|
-
* mixed array. Unknown placeholders are left as plain text.
|
|
52
|
-
*/
|
|
53
|
-
expand(text: string): Promise<ContentBlock[]>;
|
|
54
|
-
clear(): Promise<void>;
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
/**
|
|
58
|
-
* SecretVault encrypts secrets-at-rest in config files. The wire format is
|
|
59
|
-
* `enc:v1:<base64-iv>:<base64-tag>:<base64-ciphertext>`. Plaintext strings
|
|
60
|
-
* (those that do not match this prefix) are passed through unchanged so that
|
|
61
|
-
* existing configs and env-var-derived values keep working.
|
|
62
|
-
*
|
|
63
|
-
* The vault is intentionally NOT designed to defeat a determined local
|
|
64
|
-
* attacker who can read both the config file and the key file — that level
|
|
65
|
-
* of secrecy needs the OS keychain. The goal is to keep keys from being
|
|
66
|
-
* visible in screen shares, accidental log captures, and `cat config.json`
|
|
67
|
-
* over someone's shoulder.
|
|
68
|
-
*/
|
|
69
|
-
interface SecretVault {
|
|
70
|
-
encrypt(plaintext: string): string;
|
|
71
|
-
decrypt(value: string): string;
|
|
72
|
-
isEncrypted(value: string): boolean;
|
|
73
|
-
}
|
|
74
|
-
declare const ENCRYPTED_PREFIX = "enc:v1:";
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* A slash command registered with the CLI or available to plugins.
|
|
78
|
-
* Plugins receive a view of the registry via PluginAPI.slashCommands.
|
|
79
|
-
*
|
|
80
|
-
* Commands registered by plugins use a namespaced name: `pluginName:commandName`.
|
|
81
|
-
* This prevents collisions with built-in commands and other plugins.
|
|
82
|
-
*/
|
|
83
|
-
interface SlashCommand {
|
|
84
|
-
/** Unique command name. For plugins: `pluginName:commandName`. */
|
|
85
|
-
name: string;
|
|
86
|
-
/** Short aliases — also prefixed automatically: `pluginName:alias`. */
|
|
87
|
-
aliases?: string[];
|
|
88
|
-
description: string;
|
|
89
|
-
/**
|
|
90
|
-
* Optional detailed help shown by `/help <name>`. Use this for usage,
|
|
91
|
-
* arguments, examples, side-effects — anything that doesn't fit in
|
|
92
|
-
* `description`. Renders verbatim, so format with line breaks.
|
|
93
|
-
* If absent, `/help <name>` falls back to `description`.
|
|
94
|
-
*/
|
|
95
|
-
help?: string;
|
|
96
|
-
/**
|
|
97
|
-
* Execute the command.
|
|
98
|
-
* @param args Everything after the command name (trimmed by dispatch).
|
|
99
|
-
* @param ctx The current agent context.
|
|
100
|
-
* @returns `{ exit: true }` to quit the REPL. `{ message }` to print and continue.
|
|
101
|
-
*/
|
|
102
|
-
run(args: string, ctx: Context): Promise<{
|
|
103
|
-
exit?: boolean;
|
|
104
|
-
message?: string;
|
|
105
|
-
} | void>;
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
declare class ToolRegistry {
|
|
109
|
-
private readonly tools;
|
|
110
|
-
register(tool: Tool, owner?: string): void;
|
|
111
|
-
/**
|
|
112
|
-
* Attempt to register a tool. Returns true if successful, false if a tool
|
|
113
|
-
* with the same name is already registered. Useful in multi-agent or plugin
|
|
114
|
-
* scenarios where duplicate registration may be intentional.
|
|
115
|
-
*/
|
|
116
|
-
tryRegister(tool: Tool, owner?: string): boolean;
|
|
117
|
-
/**
|
|
118
|
-
* Register a tool as a default. If the tool name is already registered,
|
|
119
|
-
* this is a no-op — the existing registration (from core or another
|
|
120
|
-
* plugin) takes precedence. Use `override` to intentionally replace.
|
|
121
|
-
*/
|
|
122
|
-
registerDefault(tool: Tool, owner?: string): void;
|
|
123
|
-
unregister(name: string): boolean;
|
|
124
|
-
/**
|
|
125
|
-
* Override an existing tool. Throws if the tool is not already registered.
|
|
126
|
-
* Plugins use this to replace built-in tools with custom implementations.
|
|
127
|
-
*/
|
|
128
|
-
override(name: string, tool: Tool, owner?: string): void;
|
|
129
|
-
get(name: string): Tool | undefined;
|
|
130
|
-
ownerOf(name: string): string | undefined;
|
|
131
|
-
list(): Tool[];
|
|
132
|
-
listWithOwner(): {
|
|
133
|
-
tool: Tool;
|
|
134
|
-
owner: string;
|
|
135
|
-
}[];
|
|
136
|
-
clear(): void;
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Observability primitives — metrics, tracing, health. Implementations live in
|
|
141
|
-
* `defaults/observability/`. Consumers depend on these interfaces so a noop
|
|
142
|
-
* sink can be swapped for an OTel/Prometheus adapter without touching call
|
|
143
|
-
* sites.
|
|
144
|
-
*/
|
|
145
|
-
type MetricLabels = Record<string, string>;
|
|
146
|
-
interface MetricsSink {
|
|
147
|
-
/** Monotonically-increasing counter (e.g. total tool calls). */
|
|
148
|
-
counter(name: string, value?: number, labels?: MetricLabels): void;
|
|
149
|
-
/** Latency / size distribution (e.g. tool duration). */
|
|
150
|
-
histogram(name: string, value: number, labels?: MetricLabels): void;
|
|
151
|
-
/** Current value (e.g. active subagents, pending tasks). */
|
|
152
|
-
gauge(name: string, value: number, labels?: MetricLabels): void;
|
|
153
|
-
/** Point-in-time export — for /metrics scrape, debug dumps, tests. */
|
|
154
|
-
snapshot(): MetricsSnapshot;
|
|
155
|
-
/** Reset all metrics. Useful for tests; production code should rarely use. */
|
|
156
|
-
reset(): void;
|
|
157
|
-
}
|
|
158
|
-
interface MetricSeries {
|
|
159
|
-
name: string;
|
|
160
|
-
type: 'counter' | 'histogram' | 'gauge';
|
|
161
|
-
labels: MetricLabels;
|
|
162
|
-
/** Counter/gauge: latest value. Histogram: count, sum, min, max, p50, p95, p99. */
|
|
163
|
-
values: Record<string, number>;
|
|
164
|
-
}
|
|
165
|
-
interface MetricsSnapshot {
|
|
166
|
-
timestamp: number;
|
|
167
|
-
series: MetricSeries[];
|
|
168
|
-
}
|
|
169
|
-
type HealthStatus = 'healthy' | 'degraded' | 'unhealthy';
|
|
170
|
-
interface HealthCheckResult {
|
|
171
|
-
status: HealthStatus;
|
|
172
|
-
detail?: string;
|
|
173
|
-
/** Optional structured data (e.g. latency, version) for dashboards. */
|
|
174
|
-
data?: Record<string, unknown>;
|
|
175
|
-
}
|
|
176
|
-
interface HealthCheck {
|
|
177
|
-
readonly name: string;
|
|
178
|
-
check(): Promise<HealthCheckResult>;
|
|
179
|
-
}
|
|
180
|
-
interface AggregateHealth {
|
|
181
|
-
status: HealthStatus;
|
|
182
|
-
timestamp: number;
|
|
183
|
-
checks: (HealthCheckResult & {
|
|
184
|
-
name: string;
|
|
185
|
-
})[];
|
|
186
|
-
}
|
|
187
|
-
interface HealthRegistry {
|
|
188
|
-
register(check: HealthCheck): void;
|
|
189
|
-
unregister(name: string): void;
|
|
190
|
-
run(): Promise<AggregateHealth>;
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* Minimal OTel-compatible Span. The default implementation is a noop; wire an
|
|
194
|
-
* OpenTelemetry adapter in production to get distributed tracing for free.
|
|
195
|
-
*/
|
|
196
|
-
interface Span {
|
|
197
|
-
setAttribute(key: string, value: string | number | boolean): void;
|
|
198
|
-
recordError(err: Error): void;
|
|
199
|
-
end(): void;
|
|
200
|
-
}
|
|
201
|
-
interface Tracer {
|
|
202
|
-
startSpan(name: string, attrs?: Record<string, string | number | boolean>): Span;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Input for a single tool execution, scoped to a single iteration's budget.
|
|
207
|
-
*/
|
|
208
|
-
interface ToolExecution {
|
|
209
|
-
toolUse: ToolUseBlock;
|
|
210
|
-
result: ToolResultBlock;
|
|
211
|
-
/** True if the tool was not found in the registry. */
|
|
212
|
-
unknownTool?: boolean;
|
|
213
|
-
/** True if the tool execution threw an exception. */
|
|
214
|
-
threw?: boolean;
|
|
215
|
-
}
|
|
216
|
-
/**
|
|
217
|
-
* Output from a single tool execution.
|
|
218
|
-
*/
|
|
219
|
-
interface ToolExecutionOutput {
|
|
220
|
-
result: ToolResultBlock | ToolConfirmPendingResult;
|
|
221
|
-
tool?: Tool;
|
|
222
|
-
durationMs: number;
|
|
223
|
-
}
|
|
224
|
-
/**
|
|
225
|
-
* Result of running a batch of tools for a single agent iteration.
|
|
226
|
-
*/
|
|
227
|
-
interface ToolBatchResult {
|
|
228
|
-
outputs: ToolExecutionOutput[];
|
|
229
|
-
remainingBudget: number;
|
|
230
|
-
}
|
|
231
|
-
type ConfirmAwaiter = (tool: Tool, input: unknown, toolUseId: string, suggestedPattern: string) => Promise<'yes' | 'no' | 'always' | 'deny'>;
|
|
232
|
-
interface ToolExecutorOptions {
|
|
233
|
-
permissionPolicy: PermissionPolicy;
|
|
234
|
-
secretScrubber: SecretScrubber;
|
|
235
|
-
renderer?: Renderer | undefined;
|
|
236
|
-
/**
|
|
237
|
-
* Optional event bus. When provided, the executor emits `tool.started`
|
|
238
|
-
* before invoking each tool's `execute()`. Closes the observability gap
|
|
239
|
-
* between "model decided to call tool" and "tool finished".
|
|
240
|
-
*/
|
|
241
|
-
events?: EventBus | undefined;
|
|
242
|
-
/**
|
|
243
|
-
* Optional tracer. When provided, every tool execution opens a
|
|
244
|
-
* `tool.<name>` span with attributes for tool name, permission decision,
|
|
245
|
-
* input size, output size, and outcome. Spans are no-op by default.
|
|
246
|
-
*/
|
|
247
|
-
tracer?: Tracer | undefined;
|
|
248
|
-
/**
|
|
249
|
-
* Async callback invoked when a tool needs user confirmation.
|
|
250
|
-
* When omitted and confirmation is required, the executor returns a
|
|
251
|
-
* failure result immediately (TUI path). When provided (CLI path),
|
|
252
|
-
* the callback handles the interactive prompt and returns a decision.
|
|
253
|
-
*/
|
|
254
|
-
confirmAwaiter?: ConfirmAwaiter | undefined;
|
|
255
|
-
iterationTimeoutMs?: number;
|
|
256
|
-
perIterationOutputCapBytes?: number;
|
|
257
|
-
}
|
|
258
|
-
interface ToolExecutorInit {
|
|
259
|
-
registry: ToolRegistry;
|
|
260
|
-
options: ToolExecutorOptions;
|
|
261
|
-
}
|
|
262
|
-
/**
|
|
263
|
-
* Result returned by executeBatch when a tool needs confirmation and
|
|
264
|
-
* no confirmAwaiter is available. The TUI catches this and surfaces a
|
|
265
|
-
* confirmation dialog; once resolved the tool is re-executed.
|
|
266
|
-
* The string tag identifies it as a "pending confirm" result so callers
|
|
267
|
-
* can distinguish it from an error without inspecting content strings.
|
|
268
|
-
*/
|
|
269
|
-
interface ToolConfirmPendingResult {
|
|
270
|
-
type: 'tool_confirm_pending';
|
|
271
|
-
toolUseId: string;
|
|
272
|
-
toolName: string;
|
|
273
|
-
input: unknown;
|
|
274
|
-
suggestedPattern: string;
|
|
275
|
-
}
|
|
276
|
-
type ToolExecutorStrategy = 'parallel' | 'sequential' | 'smart';
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Factory for constructing a Provider instance. The `family` field
|
|
280
|
-
* declares the wire protocol so callers can route without inspecting
|
|
281
|
-
* the returned instance. The `type` is the registry key (e.g. a
|
|
282
|
-
* provider's models.dev id or a user-chosen alias).
|
|
283
|
-
*/
|
|
284
|
-
interface ProviderFactory$1 {
|
|
285
|
-
/**
|
|
286
|
-
* Unique identifier used as the registry key. When registered via
|
|
287
|
-
* a plugin, this becomes `cfg.type` in `ProviderRegistry.create(cfg)`.
|
|
288
|
-
*/
|
|
289
|
-
type: string;
|
|
290
|
-
/**
|
|
291
|
-
* Declares the wire protocol family so consumers can route based on
|
|
292
|
-
* capability (e.g. which tool-format converter to use) without
|
|
293
|
-
* instantiating the provider.
|
|
294
|
-
*/
|
|
295
|
-
family: WireFamily;
|
|
296
|
-
create(cfg: ProviderConfig): Provider;
|
|
297
|
-
}
|
|
298
|
-
declare class ProviderRegistry {
|
|
299
|
-
private readonly factories;
|
|
300
|
-
/**
|
|
301
|
-
* Register a provider factory. If a factory with the same type already
|
|
302
|
-
* exists, it is replaced. Use this for both initial registration and
|
|
303
|
-
* runtime overrides (e.g. from plugins or CLI flags).
|
|
304
|
-
*/
|
|
305
|
-
register(f: ProviderFactory$1): void;
|
|
306
|
-
/**
|
|
307
|
-
* Override an existing factory. Throws if no factory is registered
|
|
308
|
-
* for the given type. Use this to safely replace a provider at runtime
|
|
309
|
-
* (e.g. in tests or when a plugin provides a custom implementation).
|
|
310
|
-
*/
|
|
311
|
-
override(type: string, f: ProviderFactory$1): void;
|
|
312
|
-
has(type: string): boolean;
|
|
313
|
-
create(cfg: ProviderConfig): Provider;
|
|
314
|
-
list(): string[];
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
/** Default iteration cap. Use 0 or Infinity via config to disable. */
|
|
318
|
-
declare const DEFAULT_MAX_ITERATIONS = 100;
|
|
319
|
-
interface RunResult {
|
|
320
|
-
status: 'done' | 'failed' | 'max_iterations' | 'aborted';
|
|
321
|
-
/**
|
|
322
|
-
* Set when `status === 'failed'` (always) or `'aborted'` (when the abort
|
|
323
|
-
* carried an error context). Always a `WrongStackError` so callers can
|
|
324
|
-
* branch on `code`, `severity`, and `recoverable` without parsing strings.
|
|
325
|
-
* Raw throws are wrapped into an `AgentError` with code `AGENT_RUN_FAILED`
|
|
326
|
-
* by `Agent.run` before they reach this field.
|
|
327
|
-
*/
|
|
328
|
-
error?: WrongStackError;
|
|
329
|
-
finalText?: string;
|
|
330
|
-
iterations: number;
|
|
331
|
-
}
|
|
332
|
-
interface AgentInit {
|
|
333
|
-
container: Container;
|
|
334
|
-
tools: ToolRegistry;
|
|
335
|
-
providers: ProviderRegistry;
|
|
336
|
-
events: EventBus;
|
|
337
|
-
pipelines: AgentPipelines;
|
|
338
|
-
context: Context;
|
|
339
|
-
maxIterations?: number;
|
|
340
|
-
iterationTimeoutMs?: number;
|
|
341
|
-
executionStrategy?: 'parallel' | 'sequential' | 'smart';
|
|
342
|
-
perIterationOutputCapBytes?: number;
|
|
343
|
-
/**
|
|
344
|
-
* When true (default), the agent automatically extends its iteration
|
|
345
|
-
* limit by 100 when hit, without asking the user. Set to false to
|
|
346
|
-
* emit `iteration.limit_reached` and wait for a listener to grant/deny.
|
|
347
|
-
*/
|
|
348
|
-
autoExtendLimit?: boolean;
|
|
349
|
-
/**
|
|
350
|
-
* Optional confirm handler. When set, the executor calls it synchronously
|
|
351
|
-
* when a tool needs user confirmation (CLI path). When omitted, the
|
|
352
|
-
* executor returns a `ToolConfirmPendingResult` and the agent emits
|
|
353
|
-
* `tool.confirm_needed` for the TUI to resolve.
|
|
354
|
-
*/
|
|
355
|
-
confirmAwaiter?: ConfirmAwaiter | undefined;
|
|
356
|
-
/**
|
|
357
|
-
* Optional tracer. When provided, `Agent.run` opens an `agent.run` span,
|
|
358
|
-
* per-iteration `agent.iteration` spans, and `provider.complete` spans
|
|
359
|
-
* inside the retry loop. Tool spans are opened by the ToolExecutor.
|
|
360
|
-
* Default is `NoopTracer` (zero overhead).
|
|
361
|
-
*/
|
|
362
|
-
tracer?: Tracer | undefined;
|
|
363
|
-
}
|
|
364
|
-
interface AgentPipelines {
|
|
365
|
-
request: Pipeline<Request>;
|
|
366
|
-
response: Pipeline<Response>;
|
|
367
|
-
toolCall: Pipeline<ToolCallPipelinePayload>;
|
|
368
|
-
userInput: Pipeline<UserInputPayload>;
|
|
369
|
-
assistantOutput: Pipeline<TextBlock>;
|
|
370
|
-
contextWindow: Pipeline<Context>;
|
|
371
|
-
}
|
|
372
|
-
interface UserInputPayload {
|
|
373
|
-
content: ContentBlock[];
|
|
374
|
-
/** Concatenation of text blocks — convenience for middleware that only cares about text. */
|
|
375
|
-
text: string;
|
|
376
|
-
ctx: Context;
|
|
377
|
-
}
|
|
378
|
-
type AgentInput = string | ContentBlock[];
|
|
379
|
-
interface ToolCallPipelinePayload {
|
|
380
|
-
toolUse: ToolUseBlock;
|
|
381
|
-
result: ToolResultBlock;
|
|
382
|
-
ctx: Context;
|
|
383
|
-
/** Undefined when the model invoked a tool name we don't know. */
|
|
384
|
-
tool?: Tool;
|
|
385
|
-
}
|
|
386
|
-
declare function createDefaultPipelines(): AgentPipelines;
|
|
387
|
-
declare class Agent {
|
|
388
|
-
readonly container: Container;
|
|
389
|
-
readonly tools: ToolRegistry;
|
|
390
|
-
readonly providers: ProviderRegistry;
|
|
391
|
-
readonly events: EventBus;
|
|
392
|
-
readonly pipelines: AgentPipelines;
|
|
393
|
-
readonly ctx: Context;
|
|
394
|
-
private readonly maxIterations;
|
|
395
|
-
private readonly iterationTimeoutMs;
|
|
396
|
-
private readonly executionStrategy;
|
|
397
|
-
private readonly perIterationOutputCapBytes;
|
|
398
|
-
private readonly plugins;
|
|
399
|
-
private readonly toolExecutor;
|
|
400
|
-
private readonly autoExtendLimit;
|
|
401
|
-
private readonly tracer;
|
|
402
|
-
constructor(init: AgentInit);
|
|
403
|
-
private get logger();
|
|
404
|
-
private get retry();
|
|
405
|
-
private get errorHandler();
|
|
406
|
-
private get permission();
|
|
407
|
-
private get scrubber();
|
|
408
|
-
private get renderer();
|
|
409
|
-
register(tool: Tool): void;
|
|
410
|
-
use(plugin: Plugin, api: PluginAPI): Promise<void>;
|
|
411
|
-
run(userInput: AgentInput, opts?: RunOptions): Promise<RunResult>;
|
|
412
|
-
private runInner;
|
|
413
|
-
/**
|
|
414
|
-
* Normalize user input and emit through userInput pipeline + session append.
|
|
415
|
-
*/
|
|
416
|
-
private normalizeAndEmitUserInput;
|
|
417
|
-
/**
|
|
418
|
-
* Check if iteration limit has been reached and request extension if needed.
|
|
419
|
-
* Returns the new effective limit (possibly extended) and a RunResult if
|
|
420
|
-
* the loop should exit. Returns `{ limit }` with no result when the
|
|
421
|
-
* iteration may proceed.
|
|
422
|
-
*/
|
|
423
|
-
private checkIterationLimit;
|
|
424
|
-
/**
|
|
425
|
-
* Build request and run through request pipeline.
|
|
426
|
-
*/
|
|
427
|
-
private buildAndRunRequestPipeline;
|
|
428
|
-
/**
|
|
429
|
-
* Process the provider response: run response pipeline, emit events,
|
|
430
|
-
* update session, render text, handle abort.
|
|
431
|
-
*/
|
|
432
|
-
private processResponse;
|
|
433
|
-
/**
|
|
434
|
-
* Execute tools and append tool results to context.
|
|
435
|
-
* When a tool returns `tool_confirm_pending` (no confirmAwaiter set),
|
|
436
|
-
* we pause and emit `tool.confirm_needed`. The run is blocked until
|
|
437
|
-
* the event listener resolves the confirmation, then we re-run the
|
|
438
|
-
* single tool.
|
|
439
|
-
*/
|
|
440
|
-
private executeTools;
|
|
441
|
-
private waitForConfirm;
|
|
442
|
-
private executeSingleWithDecision;
|
|
443
|
-
/**
|
|
444
|
-
* Run context window pipeline. The pipeline may be empty, or it may contain
|
|
445
|
-
* middleware with its own injected dependencies.
|
|
446
|
-
*/
|
|
447
|
-
private compactContextIfNeeded;
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
interface ToolRegistryView {
|
|
451
|
-
register(t: Tool): void;
|
|
452
|
-
unregister(name: string): void;
|
|
453
|
-
get(name: string): Tool | undefined;
|
|
454
|
-
list(): Tool[];
|
|
455
|
-
}
|
|
456
|
-
interface ProviderFactory {
|
|
457
|
-
type: string;
|
|
458
|
-
family: WireFamily;
|
|
459
|
-
create(cfg: unknown): Provider;
|
|
460
|
-
}
|
|
461
|
-
interface ProviderRegistryView {
|
|
462
|
-
register(f: ProviderFactory): void;
|
|
463
|
-
create(cfg: {
|
|
464
|
-
type: string;
|
|
465
|
-
} & Record<string, unknown>): Provider;
|
|
466
|
-
list(): string[];
|
|
467
|
-
}
|
|
468
|
-
interface MCPRegistryView {
|
|
469
|
-
start(cfg: unknown): Promise<void>;
|
|
470
|
-
stop(name: string): Promise<void>;
|
|
471
|
-
restart(name: string): Promise<void>;
|
|
472
|
-
list(): {
|
|
473
|
-
name: string;
|
|
474
|
-
state: string;
|
|
475
|
-
toolCount: number;
|
|
476
|
-
}[];
|
|
477
|
-
}
|
|
478
|
-
interface SlashCommandRegistryView {
|
|
479
|
-
register(cmd: SlashCommand): void;
|
|
480
|
-
unregister(name: string): boolean;
|
|
481
|
-
get(name: string): SlashCommand | undefined;
|
|
482
|
-
list(): SlashCommand[];
|
|
483
|
-
}
|
|
484
|
-
interface PluginPipelines {
|
|
485
|
-
request: ReadonlyPipeline<Request>;
|
|
486
|
-
response: ReadonlyPipeline<Response>;
|
|
487
|
-
toolCall: ReadonlyPipeline<ToolCallPipelinePayload>;
|
|
488
|
-
userInput: ReadonlyPipeline<{
|
|
489
|
-
content: ContentBlock[];
|
|
490
|
-
text: string;
|
|
491
|
-
ctx: Context;
|
|
492
|
-
}>;
|
|
493
|
-
assistantOutput: ReadonlyPipeline<TextBlock>;
|
|
494
|
-
contextWindow: ReadonlyPipeline<Context>;
|
|
495
|
-
[k: string]: ReadonlyPipeline<any>;
|
|
496
|
-
}
|
|
497
|
-
interface PluginAPI {
|
|
498
|
-
container: Container;
|
|
499
|
-
pipelines: PluginPipelines;
|
|
500
|
-
events: EventBus;
|
|
501
|
-
tools: ToolRegistryView;
|
|
502
|
-
providers: ProviderRegistryView;
|
|
503
|
-
mcp: MCPRegistryView;
|
|
504
|
-
slashCommands: SlashCommandRegistryView;
|
|
505
|
-
config: Config;
|
|
506
|
-
log: Logger;
|
|
507
|
-
/**
|
|
508
|
-
* Register a one-time event listener. The handler is automatically removed
|
|
509
|
-
* after the first emission, or when the plugin is uninstalled — whichever
|
|
510
|
-
* comes first.
|
|
511
|
-
*/
|
|
512
|
-
onEvent<K extends EventName>(event: K, handler: Listener<K>): () => void;
|
|
513
|
-
}
|
|
514
|
-
/**
|
|
515
|
-
* Capability declaration — informs the host which subsystems a plugin
|
|
516
|
-
* intends to touch. Used for diagnostics and per-plugin enable/disable UX
|
|
517
|
-
* (e.g. "this plugin registers tools — disable to remove them"). Not
|
|
518
|
-
* enforced at runtime: a plugin that declares `tools: false` can still
|
|
519
|
-
* call `api.tools.register()`, but the host can flag the discrepancy.
|
|
520
|
-
*/
|
|
521
|
-
interface PluginCapabilities {
|
|
522
|
-
/** Will register tools via `api.tools.register()`. */
|
|
523
|
-
tools?: boolean;
|
|
524
|
-
/** Will register provider factories via `api.providers.register()`. */
|
|
525
|
-
providers?: boolean;
|
|
526
|
-
/**
|
|
527
|
-
* Pipelines the plugin hooks into. Use the standard names
|
|
528
|
-
* (`request | response | toolCall | userInput | assistantOutput | contextWindow`)
|
|
529
|
-
* or custom pipeline names exposed by other plugins.
|
|
530
|
-
*/
|
|
531
|
-
pipelines?: string[];
|
|
532
|
-
/** Will register slash commands via `api.slashCommands.register()`. */
|
|
533
|
-
slashCommands?: boolean;
|
|
534
|
-
/** Will start MCP servers via `api.mcp.start()`. */
|
|
535
|
-
mcp?: boolean;
|
|
536
|
-
}
|
|
537
|
-
/**
|
|
538
|
-
* Structured dependency declaration. The string form (`dependsOn: ['foo']`)
|
|
539
|
-
* is shorthand for `[{ name: 'foo' }]` — both work. Use the structured form
|
|
540
|
-
* when you need a version constraint:
|
|
541
|
-
*
|
|
542
|
-
* dependsOn: [{ name: 'wstack-auth', version: '^1.2.0' }]
|
|
543
|
-
*/
|
|
544
|
-
interface PluginDependency {
|
|
545
|
-
name: string;
|
|
546
|
-
/** npm-style semver range. Supports `^`, `~`, exact, and unprefixed. */
|
|
547
|
-
version?: string;
|
|
548
|
-
}
|
|
549
|
-
interface Plugin {
|
|
550
|
-
name: string;
|
|
551
|
-
version?: string;
|
|
552
|
-
/** One-line summary for `wstack plugins list` and error messages. */
|
|
553
|
-
description?: string;
|
|
554
|
-
/** Semver range against the kernel API version (KERNEL_API_VERSION). */
|
|
555
|
-
apiVersion: string;
|
|
556
|
-
/**
|
|
557
|
-
* Capability hints — what subsystems the plugin will register against.
|
|
558
|
-
* Optional; provided for diagnostics and UX. The loader does not enforce
|
|
559
|
-
* these, but mismatch is surfaced via logger at warn level.
|
|
560
|
-
*/
|
|
561
|
-
capabilities?: PluginCapabilities;
|
|
562
|
-
/**
|
|
563
|
-
* JSON Schema for the options under `Config.plugins[<name>].options`.
|
|
564
|
-
* When present, the loader validates that section before calling `setup`
|
|
565
|
-
* and rejects the plugin with a clear error path on failure.
|
|
566
|
-
*/
|
|
567
|
-
configSchema?: JSONSchema;
|
|
568
|
-
/**
|
|
569
|
-
* Mandatory plugin dependencies — loading fails if any are absent or
|
|
570
|
-
* version-incompatible. Accepts both the legacy string-array form and
|
|
571
|
-
* the structured form with version constraints.
|
|
572
|
-
*/
|
|
573
|
-
dependsOn?: (string | PluginDependency)[];
|
|
574
|
-
/** Optional plugin dependencies — silently skipped if absent. */
|
|
575
|
-
optionalDeps?: (string | PluginDependency)[];
|
|
576
|
-
conflictsWith?: string[];
|
|
577
|
-
setup(api: PluginAPI): void | Promise<void>;
|
|
578
|
-
teardown?(api: PluginAPI): void | Promise<void>;
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
type BridgeMessageType = 'task' | 'result' | 'progress' | 'error' | 'heartbeat' | 'stop' | 'delegate';
|
|
582
|
-
interface BridgeMessage<T = unknown> {
|
|
583
|
-
id: string;
|
|
584
|
-
type: BridgeMessageType;
|
|
585
|
-
from: string;
|
|
586
|
-
to?: string;
|
|
587
|
-
payload: T;
|
|
588
|
-
timestamp: number;
|
|
589
|
-
priority?: 'low' | 'normal' | 'high' | 'critical';
|
|
590
|
-
}
|
|
591
|
-
interface AgentBridgeConfig {
|
|
592
|
-
agentId: string;
|
|
593
|
-
coordinatorId: string;
|
|
594
|
-
timeoutMs?: number;
|
|
595
|
-
bufferSize?: number;
|
|
596
|
-
}
|
|
597
|
-
interface AgentBridge {
|
|
598
|
-
readonly agentId: string;
|
|
599
|
-
readonly coordinatorId: string;
|
|
600
|
-
send(msg: BridgeMessage): Promise<void>;
|
|
601
|
-
broadcast(msg: BridgeMessage): Promise<void>;
|
|
602
|
-
subscribe(handler: (msg: BridgeMessage) => void | Promise<void>): () => void;
|
|
603
|
-
request<T>(msg: BridgeMessage, timeoutMs?: number): Promise<BridgeMessage<T>>;
|
|
604
|
-
stop(): Promise<void>;
|
|
605
|
-
}
|
|
606
|
-
interface BridgeTransport {
|
|
607
|
-
send(msg: BridgeMessage, to: string): Promise<void>;
|
|
608
|
-
subscribe(agentId: string, handler: (msg: BridgeMessage) => void | Promise<void>): () => void;
|
|
609
|
-
close(agentId: string): Promise<void>;
|
|
610
|
-
}
|
|
611
|
-
|
|
612
|
-
type BudgetKind = 'tool_calls' | 'iterations' | 'tokens' | 'timeout' | 'cost';
|
|
613
|
-
declare class BudgetExceededError extends Error {
|
|
614
|
-
readonly kind: BudgetKind;
|
|
615
|
-
readonly limit: number;
|
|
616
|
-
readonly observed: number;
|
|
617
|
-
constructor(kind: BudgetKind, limit: number, observed: number);
|
|
618
|
-
}
|
|
619
|
-
interface BudgetLimits {
|
|
620
|
-
maxIterations?: number;
|
|
621
|
-
maxToolCalls?: number;
|
|
622
|
-
maxTokens?: number;
|
|
623
|
-
/** Estimated USD cost ceiling. */
|
|
624
|
-
maxCostUsd?: number;
|
|
625
|
-
/** Wall-clock timeout from start() to checkTimeout(). */
|
|
626
|
-
timeoutMs?: number;
|
|
627
|
-
}
|
|
628
|
-
interface BudgetUsage {
|
|
629
|
-
iterations: number;
|
|
630
|
-
toolCalls: number;
|
|
631
|
-
tokens: {
|
|
632
|
-
input: number;
|
|
633
|
-
output: number;
|
|
634
|
-
total: number;
|
|
635
|
-
};
|
|
636
|
-
costUsd: number;
|
|
637
|
-
elapsedMs: number;
|
|
638
|
-
}
|
|
639
|
-
/**
|
|
640
|
-
* Per-subagent budget enforcement. Each subagent gets its own instance so a
|
|
641
|
-
* runaway agent can't drain the cost ceiling of its siblings. All record/check
|
|
642
|
-
* methods are O(1) and safe to call from hot paths.
|
|
643
|
-
*
|
|
644
|
-
* Behavior: `record*` methods throw `BudgetExceededError` synchronously the
|
|
645
|
-
* moment a limit is crossed. The caller (runner/coordinator) catches this and
|
|
646
|
-
* marks the task as 'failed' with the budget kind, so the operator can see
|
|
647
|
-
* exactly which ceiling tripped.
|
|
648
|
-
*/
|
|
649
|
-
declare class SubagentBudget {
|
|
650
|
-
readonly limits: Readonly<BudgetLimits>;
|
|
651
|
-
private iterations;
|
|
652
|
-
private toolCalls;
|
|
653
|
-
private tokenInput;
|
|
654
|
-
private tokenOutput;
|
|
655
|
-
private costUsd;
|
|
656
|
-
private startTime;
|
|
657
|
-
constructor(limits?: BudgetLimits);
|
|
658
|
-
start(): void;
|
|
659
|
-
recordIteration(): void;
|
|
660
|
-
recordToolCall(): void;
|
|
661
|
-
recordUsage(usage: Usage, costUsd?: number): void;
|
|
662
|
-
/**
|
|
663
|
-
* Throws if the wall-clock budget is exhausted. Call this from the iteration
|
|
664
|
-
* loop so a hung tool can't keep a subagent running past its deadline.
|
|
665
|
-
*/
|
|
666
|
-
checkTimeout(): void;
|
|
667
|
-
/** Returns true if a timeout has occurred without throwing. Useful for races. */
|
|
668
|
-
isTimedOut(): boolean;
|
|
669
|
-
usage(): BudgetUsage;
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
interface SubagentConfig {
|
|
673
|
-
id?: string;
|
|
674
|
-
name: string;
|
|
675
|
-
role?: string;
|
|
676
|
-
prompt?: string;
|
|
677
|
-
maxIterations?: number;
|
|
678
|
-
maxToolCalls?: number;
|
|
679
|
-
maxTokens?: number;
|
|
680
|
-
maxCostUsd?: number;
|
|
681
|
-
timeoutMs?: number;
|
|
682
|
-
tools?: string[];
|
|
683
|
-
model?: string;
|
|
684
|
-
priority?: number;
|
|
685
|
-
/**
|
|
686
|
-
* Provider registry id (e.g. `'anthropic'`, `'openai'`, `'google'`).
|
|
687
|
-
* Allows a director to mix providers across siblings — one subagent on
|
|
688
|
-
* Sonnet, another on GPT-5, another on Haiku. Falls back to the
|
|
689
|
-
* factory's default provider when omitted, which is the legacy
|
|
690
|
-
* single-provider behavior.
|
|
691
|
-
*/
|
|
692
|
-
provider?: string;
|
|
693
|
-
/**
|
|
694
|
-
* Per-subagent session JSONL path. When omitted the orchestrator-
|
|
695
|
-
* supplied factory derives a path under `<sessionRoot>/<runId>/`.
|
|
696
|
-
* Override to redirect the transcript elsewhere (long-term storage,
|
|
697
|
-
* a different filesystem, etc.).
|
|
698
|
-
*/
|
|
699
|
-
sessionPath?: string;
|
|
700
|
-
/**
|
|
701
|
-
* Additional text appended to the role's base system prompt. Does not
|
|
702
|
-
* replace it. Useful for last-mile guidance like "you may only call
|
|
703
|
-
* read tools, never write" or "respond in JSON only".
|
|
704
|
-
*/
|
|
705
|
-
systemPromptOverride?: string;
|
|
706
|
-
/**
|
|
707
|
-
* Routing for streaming output. `'director'` (default) forwards
|
|
708
|
-
* text/tool events to the parent's FleetBus so the director can read
|
|
709
|
-
* the subagent's stream. `'silent'` keeps everything subagent-local;
|
|
710
|
-
* the director only sees the final task result. `'user'` forwards
|
|
711
|
-
* direct to the user-facing renderer (gate this behind an explicit
|
|
712
|
-
* config flag — it can confuse the chat surface).
|
|
713
|
-
*/
|
|
714
|
-
textStream?: 'director' | 'silent' | 'user';
|
|
715
|
-
toolStream?: 'director' | 'silent' | 'user';
|
|
716
|
-
}
|
|
717
|
-
interface TaskResult<T = unknown> {
|
|
718
|
-
subagentId: string;
|
|
719
|
-
taskId: string;
|
|
720
|
-
status: 'success' | 'failed' | 'timeout' | 'stopped';
|
|
721
|
-
result?: T;
|
|
722
|
-
error?: string;
|
|
723
|
-
iterations: number;
|
|
724
|
-
toolCalls: number;
|
|
725
|
-
durationMs: number;
|
|
726
|
-
}
|
|
727
|
-
interface TaskSpec {
|
|
728
|
-
id: string;
|
|
729
|
-
description: string;
|
|
730
|
-
subagentId?: string;
|
|
731
|
-
priority?: number;
|
|
732
|
-
maxToolCalls?: number;
|
|
733
|
-
timeoutMs?: number;
|
|
734
|
-
context?: Record<string, unknown>;
|
|
735
|
-
}
|
|
736
|
-
interface DoneCondition {
|
|
737
|
-
type: 'iterations' | 'tool_calls' | 'output_match' | 'custom' | 'all_tasks_done';
|
|
738
|
-
maxIterations?: number;
|
|
739
|
-
maxToolCalls?: number;
|
|
740
|
-
pattern?: string;
|
|
741
|
-
predicate?: string;
|
|
742
|
-
}
|
|
743
|
-
interface MultiAgentConfig {
|
|
744
|
-
coordinatorId: string;
|
|
745
|
-
leaderSystemPrompt?: string;
|
|
746
|
-
subagents?: SubagentConfig[];
|
|
747
|
-
maxConcurrent?: number;
|
|
748
|
-
doneCondition: DoneCondition;
|
|
749
|
-
timeoutMs?: number;
|
|
750
|
-
/**
|
|
751
|
-
* Optional default budget applied to every spawned subagent. Per-subagent
|
|
752
|
-
* fields in `SubagentConfig` override these. Coordinator enforces them by
|
|
753
|
-
* constructing a `SubagentBudget` per spawn — see `SubagentRunContext.budget`.
|
|
754
|
-
*/
|
|
755
|
-
defaultBudget?: {
|
|
756
|
-
maxIterations?: number;
|
|
757
|
-
maxToolCalls?: number;
|
|
758
|
-
maxTokens?: number;
|
|
759
|
-
maxCostUsd?: number;
|
|
760
|
-
timeoutMs?: number;
|
|
761
|
-
};
|
|
762
|
-
}
|
|
763
|
-
interface SpawnResult {
|
|
764
|
-
subagentId: string;
|
|
765
|
-
agentId: string;
|
|
766
|
-
}
|
|
767
|
-
interface TaskDelegation {
|
|
768
|
-
task: TaskSpec;
|
|
769
|
-
subagentId: string;
|
|
770
|
-
}
|
|
771
|
-
interface CoordinatorEvents {
|
|
772
|
-
'task.assigned': {
|
|
773
|
-
task: TaskSpec;
|
|
774
|
-
subagentId: string;
|
|
775
|
-
};
|
|
776
|
-
'task.completed': {
|
|
777
|
-
task: TaskSpec;
|
|
778
|
-
result: TaskResult;
|
|
779
|
-
};
|
|
780
|
-
'subagent.started': {
|
|
781
|
-
subagent: SubagentConfig;
|
|
782
|
-
};
|
|
783
|
-
'subagent.stopped': {
|
|
784
|
-
subagentId: string;
|
|
785
|
-
reason: string;
|
|
786
|
-
};
|
|
787
|
-
'done': {
|
|
788
|
-
results: TaskResult[];
|
|
789
|
-
totalIterations: number;
|
|
790
|
-
};
|
|
791
|
-
}
|
|
792
|
-
interface MultiAgentCoordinator {
|
|
793
|
-
readonly coordinatorId: string;
|
|
794
|
-
readonly config: MultiAgentConfig;
|
|
795
|
-
spawn(subagent: SubagentConfig): Promise<SpawnResult>;
|
|
796
|
-
assign(task: TaskSpec): Promise<void>;
|
|
797
|
-
delegate(to: string, msg: BridgeMessage): Promise<void>;
|
|
798
|
-
stop(subagentId: string): Promise<void>;
|
|
799
|
-
stopAll(): Promise<void>;
|
|
800
|
-
getStatus(): CoordinatorStatus;
|
|
801
|
-
}
|
|
802
|
-
/**
|
|
803
|
-
* Caller-supplied runner that actually executes a task. The coordinator
|
|
804
|
-
* provides isolated state (own budget, own AbortSignal, own bridge handle)
|
|
805
|
-
* and enforces concurrency limits — the runner just runs the task and reports
|
|
806
|
-
* the outcome. This is the injection seam that decouples the coordinator
|
|
807
|
-
* from `Agent` so it can be tested with mocks and reused for non-Agent
|
|
808
|
-
* subagents (workers, MCP-driven subagents, etc.).
|
|
809
|
-
*/
|
|
810
|
-
type SubagentRunner = (task: TaskSpec, ctx: SubagentRunContext) => Promise<SubagentRunOutcome>;
|
|
811
|
-
interface SubagentRunContext {
|
|
812
|
-
subagentId: string;
|
|
813
|
-
config: SubagentConfig;
|
|
814
|
-
budget: SubagentBudget;
|
|
815
|
-
signal: AbortSignal;
|
|
816
|
-
/** Null until `setSubagentBridge` is called for this subagent. */
|
|
817
|
-
bridge: AgentBridge | null;
|
|
818
|
-
}
|
|
819
|
-
interface SubagentRunOutcome {
|
|
820
|
-
result?: unknown;
|
|
821
|
-
iterations: number;
|
|
822
|
-
toolCalls: number;
|
|
823
|
-
}
|
|
824
|
-
interface CoordinatorStatus {
|
|
825
|
-
coordinatorId: string;
|
|
826
|
-
subagents: {
|
|
827
|
-
id: string;
|
|
828
|
-
name: string;
|
|
829
|
-
status: 'running' | 'idle' | 'stopped' | 'error';
|
|
830
|
-
currentTask?: string;
|
|
831
|
-
}[];
|
|
832
|
-
pendingTasks: number;
|
|
833
|
-
completedTasks: number;
|
|
834
|
-
totalIterations: number;
|
|
835
|
-
done: boolean;
|
|
836
|
-
}
|
|
837
|
-
interface SubagentContext {
|
|
838
|
-
subagentId: string;
|
|
839
|
-
tasks: TaskSpec[];
|
|
840
|
-
/**
|
|
841
|
-
* Two-phase initialization: `spawn()` creates the subagent before the
|
|
842
|
-
* bridge is wired (`setSubagentBridge()`), so `parentBridge` is nullable
|
|
843
|
-
* by design. Readers must `hasParentBridge()`-guard or null-check before
|
|
844
|
-
* use; the prior `null as unknown as AgentBridge` cast was a type lie
|
|
845
|
-
* that hid this from the compiler.
|
|
846
|
-
*/
|
|
847
|
-
parentBridge: AgentBridge | null;
|
|
848
|
-
doneCondition: DoneCondition;
|
|
849
|
-
maxConcurrent: number;
|
|
850
|
-
}
|
|
851
|
-
|
|
852
|
-
type SpecStatus = 'draft' | 'review' | 'approved' | 'implemented' | 'deprecated';
|
|
853
|
-
type SpecSectionType = 'overview' | 'requirements' | 'architecture' | 'api' | 'data' | 'security' | 'acceptance';
|
|
854
|
-
interface SpecSection {
|
|
855
|
-
type: SpecSectionType;
|
|
856
|
-
title: string;
|
|
857
|
-
content: string;
|
|
858
|
-
level: number;
|
|
859
|
-
children?: SpecSection[];
|
|
860
|
-
}
|
|
861
|
-
interface SpecRequirement {
|
|
862
|
-
id: string;
|
|
863
|
-
type: 'functional' | 'non-functional' | 'security' | 'performance' | 'ux';
|
|
864
|
-
priority: 'critical' | 'high' | 'medium' | 'low';
|
|
865
|
-
description: string;
|
|
866
|
-
acceptanceCriteria: string[];
|
|
867
|
-
blockedBy?: string[];
|
|
868
|
-
implements?: string[];
|
|
869
|
-
}
|
|
870
|
-
interface SpecApiEndpoint {
|
|
871
|
-
method: 'GET' | 'POST' | 'PUT' | 'DELETE' | 'PATCH';
|
|
872
|
-
path: string;
|
|
873
|
-
description: string;
|
|
874
|
-
request?: Record<string, unknown>;
|
|
875
|
-
response?: Record<string, unknown>;
|
|
876
|
-
auth?: boolean;
|
|
877
|
-
}
|
|
878
|
-
interface Specification {
|
|
879
|
-
id: string;
|
|
880
|
-
title: string;
|
|
881
|
-
version: string;
|
|
882
|
-
status: SpecStatus;
|
|
883
|
-
overview: string;
|
|
884
|
-
sections: SpecSection[];
|
|
885
|
-
requirements: SpecRequirement[];
|
|
886
|
-
apiEndpoints?: SpecApiEndpoint[];
|
|
887
|
-
dependencies?: string[];
|
|
888
|
-
createdAt: number;
|
|
889
|
-
updatedAt: number;
|
|
890
|
-
metadata?: Record<string, unknown>;
|
|
891
|
-
}
|
|
892
|
-
interface SpecAnalysis {
|
|
893
|
-
specId: string;
|
|
894
|
-
completeness: number;
|
|
895
|
-
coverage: {
|
|
896
|
-
requirements: number;
|
|
897
|
-
apiEndpoints: number;
|
|
898
|
-
edgeCases: number;
|
|
899
|
-
errorHandling: number;
|
|
900
|
-
};
|
|
901
|
-
gaps: string[];
|
|
902
|
-
risks: {
|
|
903
|
-
requirement: string;
|
|
904
|
-
risk: string;
|
|
905
|
-
severity: 'high' | 'medium' | 'low';
|
|
906
|
-
}[];
|
|
907
|
-
suggestions: string[];
|
|
908
|
-
}
|
|
909
|
-
interface SpecValidationResult {
|
|
910
|
-
valid: boolean;
|
|
911
|
-
errors: {
|
|
912
|
-
path: string;
|
|
913
|
-
message: string;
|
|
914
|
-
}[];
|
|
915
|
-
warnings: {
|
|
916
|
-
path: string;
|
|
917
|
-
message: string;
|
|
918
|
-
}[];
|
|
919
|
-
}
|
|
920
|
-
interface SpecTemplate {
|
|
921
|
-
id: string;
|
|
922
|
-
name: string;
|
|
923
|
-
description: string;
|
|
924
|
-
sections: Omit<SpecSection, 'content'>[];
|
|
925
|
-
defaultRequirements: Omit<SpecRequirement, 'id' | 'description'>[];
|
|
926
|
-
}
|
|
927
|
-
declare const DEFAULT_SPEC_TEMPLATE: SpecTemplate;
|
|
928
|
-
|
|
929
|
-
type TaskStatus = 'pending' | 'in_progress' | 'blocked' | 'failed' | 'review' | 'completed';
|
|
930
|
-
type TaskPriority = 'critical' | 'high' | 'medium' | 'low';
|
|
931
|
-
type TaskType = 'feature' | 'bugfix' | 'refactor' | 'docs' | 'test' | 'chore';
|
|
932
|
-
interface TaskNode {
|
|
933
|
-
id: string;
|
|
934
|
-
title: string;
|
|
935
|
-
description: string;
|
|
936
|
-
type: TaskType;
|
|
937
|
-
priority: TaskPriority;
|
|
938
|
-
status: TaskStatus;
|
|
939
|
-
assignee?: string;
|
|
940
|
-
estimateHours?: number;
|
|
941
|
-
actualHours?: number;
|
|
942
|
-
tags?: string[];
|
|
943
|
-
specRequirementId?: string;
|
|
944
|
-
parentId?: string;
|
|
945
|
-
children?: string[];
|
|
946
|
-
createdAt: number;
|
|
947
|
-
updatedAt: number;
|
|
948
|
-
completedAt?: number;
|
|
949
|
-
metadata?: Record<string, unknown>;
|
|
950
|
-
}
|
|
951
|
-
interface TaskEdge {
|
|
952
|
-
id: string;
|
|
953
|
-
from: string;
|
|
954
|
-
to: string;
|
|
955
|
-
type: 'blocks' | 'depends_on' | 'relates_to' | 'implements';
|
|
956
|
-
weight?: number;
|
|
957
|
-
}
|
|
958
|
-
interface TaskGraph {
|
|
959
|
-
id: string;
|
|
960
|
-
specId: string;
|
|
961
|
-
title: string;
|
|
962
|
-
nodes: Map<string, TaskNode>;
|
|
963
|
-
edges: TaskEdge[];
|
|
964
|
-
rootNodes: string[];
|
|
965
|
-
createdAt: number;
|
|
966
|
-
updatedAt: number;
|
|
967
|
-
}
|
|
968
|
-
interface TaskDependency {
|
|
969
|
-
taskId: string;
|
|
970
|
-
blockedBy: string[];
|
|
971
|
-
blocking: string[];
|
|
972
|
-
}
|
|
973
|
-
interface TaskAssignment {
|
|
974
|
-
taskId: string;
|
|
975
|
-
assignee: string;
|
|
976
|
-
assignedAt: number;
|
|
977
|
-
}
|
|
978
|
-
interface TaskProgress {
|
|
979
|
-
total: number;
|
|
980
|
-
pending: number;
|
|
981
|
-
inProgress: number;
|
|
982
|
-
blocked: number;
|
|
983
|
-
failed: number;
|
|
984
|
-
review: number;
|
|
985
|
-
completed: number;
|
|
986
|
-
percentComplete: number;
|
|
987
|
-
estimatedHours: number;
|
|
988
|
-
actualHours: number;
|
|
989
|
-
}
|
|
990
|
-
interface TaskFilter {
|
|
991
|
-
status?: TaskStatus[];
|
|
992
|
-
priority?: TaskPriority[];
|
|
993
|
-
type?: TaskType[];
|
|
994
|
-
assignee?: string[];
|
|
995
|
-
tags?: string[];
|
|
996
|
-
specRequirementId?: string;
|
|
997
|
-
}
|
|
998
|
-
interface TaskSort {
|
|
999
|
-
field: 'priority' | 'createdAt' | 'updatedAt' | 'status';
|
|
1000
|
-
direction: 'asc' | 'desc';
|
|
1001
|
-
}
|
|
1002
|
-
interface CriticalPathResult {
|
|
1003
|
-
taskIds: string[];
|
|
1004
|
-
totalEstimateHours: number;
|
|
1005
|
-
bottleneckTasks: string[];
|
|
1006
|
-
}
|
|
1007
|
-
declare function computeTaskProgress(graph: TaskGraph): TaskProgress;
|
|
1008
|
-
declare function findCriticalPath(graph: TaskGraph): CriticalPathResult;
|
|
1009
|
-
declare function topologicalSort(graph: TaskGraph): string[];
|
|
1010
|
-
|
|
1011
|
-
/**
|
|
1012
|
-
* L2-A: SessionReader — query, replay, search, export over a `SessionStore`.
|
|
1013
|
-
*
|
|
1014
|
-
* Keeps a clean read-only interface (no `append`, no `delete`) so analytics
|
|
1015
|
-
* code can be wired against a store without granting it the writer surface.
|
|
1016
|
-
*/
|
|
1017
|
-
type SessionEventType = SessionEvent['type'];
|
|
1018
|
-
interface SessionQuery {
|
|
1019
|
-
/** Filter by start timestamp (ISO). Sessions started before this are excluded. */
|
|
1020
|
-
since?: string;
|
|
1021
|
-
/** Filter by start timestamp (ISO). Sessions started after this are excluded. */
|
|
1022
|
-
until?: string;
|
|
1023
|
-
/** Substring match against title (case-insensitive). */
|
|
1024
|
-
titleContains?: string;
|
|
1025
|
-
/** Filter by provider id. */
|
|
1026
|
-
provider?: string;
|
|
1027
|
-
/** Filter by model id. */
|
|
1028
|
-
model?: string;
|
|
1029
|
-
/** Minimum total tokens (input+output) to keep. */
|
|
1030
|
-
minTokens?: number;
|
|
1031
|
-
/** Limit result count. Defaults to no limit. */
|
|
1032
|
-
limit?: number;
|
|
1033
|
-
}
|
|
1034
|
-
interface SessionSearchHit {
|
|
1035
|
-
sessionId: string;
|
|
1036
|
-
eventIndex: number;
|
|
1037
|
-
ts: string;
|
|
1038
|
-
type: SessionEventType;
|
|
1039
|
-
/** Short snippet of the matched text — null for events without text content. */
|
|
1040
|
-
snippet: string | null;
|
|
1041
|
-
}
|
|
1042
|
-
interface SessionSearchQuery {
|
|
1043
|
-
/** Plain text or regex pattern. */
|
|
1044
|
-
query: string;
|
|
1045
|
-
/** Treat `query` as a regex. Defaults to false (literal substring). */
|
|
1046
|
-
regex?: boolean;
|
|
1047
|
-
/** Case-insensitive match. Defaults to true. */
|
|
1048
|
-
caseInsensitive?: boolean;
|
|
1049
|
-
/** Limit only to these event types. Defaults to all event types. */
|
|
1050
|
-
types?: SessionEventType[];
|
|
1051
|
-
/** Limit hit count. Defaults to 100. */
|
|
1052
|
-
limit?: number;
|
|
1053
|
-
}
|
|
1054
|
-
interface SessionExportOptions {
|
|
1055
|
-
/** "markdown" produces a human-readable chat log; "json" passes through raw events. */
|
|
1056
|
-
format: 'markdown' | 'json' | 'text';
|
|
1057
|
-
/** Include tool_use/tool_result blocks. Defaults to true. */
|
|
1058
|
-
includeTools?: boolean;
|
|
1059
|
-
/** Include system/diagnostic events (errors, compaction). Defaults to true. */
|
|
1060
|
-
includeDiagnostics?: boolean;
|
|
1061
|
-
}
|
|
1062
|
-
interface SessionSummaryLite {
|
|
1063
|
-
id: string;
|
|
1064
|
-
title: string;
|
|
1065
|
-
startedAt: string;
|
|
1066
|
-
endedAt?: string;
|
|
1067
|
-
provider: string;
|
|
1068
|
-
model: string;
|
|
1069
|
-
tokenTotal: number;
|
|
1070
|
-
}
|
|
1071
|
-
interface SessionReader {
|
|
1072
|
-
/** List sessions matching the query. Uses the underlying store's summary cache. */
|
|
1073
|
-
query(q?: SessionQuery): Promise<SessionSummaryLite[]>;
|
|
1074
|
-
/** Yield events for `sessionId` in chronological order. */
|
|
1075
|
-
replay(sessionId: string): AsyncIterable<SessionEvent>;
|
|
1076
|
-
/** Full-text/regex search across one or all sessions. */
|
|
1077
|
-
search(q: SessionSearchQuery, sessionId?: string): Promise<SessionSearchHit[]>;
|
|
1078
|
-
/** Render a session for human or downstream-tool consumption. */
|
|
1079
|
-
export(sessionId: string, opts: SessionExportOptions): Promise<string>;
|
|
1080
|
-
/** Read the metadata header without loading the full event stream. */
|
|
1081
|
-
metadata(sessionId: string): Promise<SessionMetadata>;
|
|
1082
|
-
}
|
|
1083
|
-
interface DefaultSessionReaderOptions {
|
|
1084
|
-
store: SessionStore;
|
|
1085
|
-
}
|
|
1086
|
-
|
|
1087
|
-
export { type SpecSection as $, type AddAttachmentInput as A, type BridgeMessage as B, type ConfirmAwaiter as C, DEFAULT_SPEC_TEMPLATE as D, ENCRYPTED_PREFIX as E, type PluginDependency as F, type PluginPipelines as G, type HealthCheck as H, type ProviderFactory as I, type ProviderRegistryView as J, type SessionEventType as K, type SessionExportOptions as L, type MCPRegistryView as M, type SessionQuery as N, type SessionReader as O, type Plugin as P, type SessionSearchHit as Q, type SessionSearchQuery as R, type SecretVault as S, type SessionSummaryLite as T, type SlashCommand as U, type SlashCommandRegistryView as V, type Span as W, type SpawnResult as X, type SpecAnalysis as Y, type SpecApiEndpoint as Z, type SpecRequirement as _, type AgentBridge as a, type SpecSectionType as a0, type SpecStatus as a1, type SpecTemplate as a2, type SpecValidationResult as a3, type Specification as a4, type SubagentConfig as a5, type SubagentContext as a6, type SubagentRunContext as a7, type SubagentRunOutcome as a8, type SubagentRunner as a9, ToolRegistry as aA, ProviderRegistry as aB, Agent as aC, type AgentInit as aD, type AgentInput as aE, type AgentPipelines as aF, BudgetExceededError as aG, type BudgetKind as aH, type BudgetLimits as aI, type BudgetUsage as aJ, DEFAULT_MAX_ITERATIONS as aK, type ProviderFactory$1 as aL, type RunResult as aM, SubagentBudget as aN, type UserInputPayload as aO, createDefaultPipelines as aP, type TaskAssignment as aa, type TaskDelegation as ab, type TaskDependency as ac, type TaskEdge as ad, type TaskFilter as ae, type TaskGraph as af, type TaskNode as ag, type TaskPriority as ah, type TaskProgress as ai, type TaskResult as aj, type TaskSort as ak, type TaskSpec as al, type TaskStatus as am, type TaskType as an, type ToolBatchResult as ao, type ToolConfirmPendingResult as ap, type ToolExecution as aq, type ToolExecutionOutput as ar, type ToolExecutorInit as as, type ToolExecutorOptions as at, type ToolExecutorStrategy as au, type ToolRegistryView as av, type Tracer as aw, computeTaskProgress as ax, findCriticalPath as ay, topologicalSort as az, type AgentBridgeConfig as b, type AggregateHealth as c, type Attachment as d, type AttachmentKind as e, type AttachmentMeta as f, type AttachmentRef as g, type AttachmentStore as h, type BridgeMessageType as i, type BridgeTransport as j, type CoordinatorEvents as k, type CoordinatorStatus as l, type CriticalPathResult as m, type DefaultSessionReaderOptions as n, type DoneCondition as o, type HealthCheckResult as p, type HealthRegistry as q, type HealthStatus as r, type MetricLabels as s, type MetricSeries as t, type MetricsSink as u, type MetricsSnapshot as v, type MultiAgentConfig as w, type MultiAgentCoordinator as x, type PluginAPI as y, type PluginCapabilities as z };
|