@wrongstack/core 0.1.1 → 0.1.3
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/defaults/index.d.ts +738 -138
- package/dist/defaults/index.js +2507 -975
- package/dist/defaults/index.js.map +1 -1
- package/dist/index.d.ts +28 -9
- package/dist/index.js +3272 -1058
- package/dist/index.js.map +1 -1
- package/dist/kernel/index.d.ts +5 -3
- package/dist/kernel/index.js +89 -11
- package/dist/kernel/index.js.map +1 -1
- package/dist/provider-DovtyuM8.d.ts +813 -0
- package/dist/{secret-scrubber-Dax_Ou_o.d.ts → secret-scrubber-qU3AwEiI.d.ts} +126 -457
- package/dist/{tool-executor-DjnMELMV.d.ts → session-reader-DR4u3bu9.d.ts} +445 -59
- package/dist/{system-prompt-BG3nks8P.d.ts → system-prompt--mzZnenv.d.ts} +1 -1
- package/dist/types/index.d.ts +4 -3
- package/dist/types/index.js +153 -5
- package/dist/types/index.js.map +1 -1
- package/dist/utils/index.d.ts +42 -1
- package/dist/utils/index.js +122 -3
- package/dist/utils/index.js.map +1 -1
- package/package.json +5 -4
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { U as Usage, a0 as Context, z as ToolProgressEvent, v as Tool, P as Permission, T as TextBlock, c as ContentBlock, k as Response, i as ProviderError } from './provider-DovtyuM8.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Container — dependency injection with explicit bind / override / decorate.
|
|
3
5
|
*
|
|
@@ -60,6 +62,22 @@ declare class Container {
|
|
|
60
62
|
*/
|
|
61
63
|
type NextFn<T> = (value: T) => Promise<T>;
|
|
62
64
|
type MiddlewareHandler<T> = (value: T, next: NextFn<T>) => Promise<T>;
|
|
65
|
+
/**
|
|
66
|
+
* Called when a middleware crashes (throws or rejects). Used by the
|
|
67
|
+
* Pipeline's error boundary to log the offender without aborting the run.
|
|
68
|
+
*
|
|
69
|
+
* Return `'rethrow'` to propagate the error (default for core middleware),
|
|
70
|
+
* or `'swallow'` to skip past the crashing middleware and continue with the
|
|
71
|
+
* value the previous one produced. Plugin middleware should usually be
|
|
72
|
+
* swallowed so one bad plugin can't kill an agent run.
|
|
73
|
+
*/
|
|
74
|
+
type PipelineErrorPolicy = 'rethrow' | 'swallow';
|
|
75
|
+
interface PipelineErrorEvent {
|
|
76
|
+
middleware: string;
|
|
77
|
+
owner?: string;
|
|
78
|
+
err: unknown;
|
|
79
|
+
}
|
|
80
|
+
type PipelineErrorHandler = (ev: PipelineErrorEvent) => PipelineErrorPolicy | Promise<PipelineErrorPolicy>;
|
|
63
81
|
interface Middleware<T> {
|
|
64
82
|
name: string;
|
|
65
83
|
handler: MiddlewareHandler<T>;
|
|
@@ -80,6 +98,17 @@ interface ReadonlyPipeline<T> {
|
|
|
80
98
|
}
|
|
81
99
|
declare class Pipeline<T> {
|
|
82
100
|
private readonly chain;
|
|
101
|
+
private errorHandler?;
|
|
102
|
+
/**
|
|
103
|
+
* Install an error boundary. When a middleware throws or rejects, the
|
|
104
|
+
* handler is called and decides whether to swallow (continue with the
|
|
105
|
+
* pre-handler value) or rethrow. Without a handler, errors propagate.
|
|
106
|
+
*
|
|
107
|
+
* Wire one per pipeline at boot — the host CLI typically installs a
|
|
108
|
+
* single boundary that logs to the operational log and emits a
|
|
109
|
+
* `pipeline.error` event for /diag.
|
|
110
|
+
*/
|
|
111
|
+
setErrorHandler(handler: PipelineErrorHandler | undefined): this;
|
|
83
112
|
use(mw: Middleware<T> | Middleware<unknown>): this;
|
|
84
113
|
prepend(mw: Middleware<T>): this;
|
|
85
114
|
/**
|
|
@@ -113,462 +142,6 @@ declare class Pipeline<T> {
|
|
|
113
142
|
private ensureUnique;
|
|
114
143
|
}
|
|
115
144
|
|
|
116
|
-
interface TextBlock {
|
|
117
|
-
type: 'text';
|
|
118
|
-
text: string;
|
|
119
|
-
cache_control?: {
|
|
120
|
-
type: 'ephemeral';
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
interface ToolUseBlock {
|
|
124
|
-
type: 'tool_use';
|
|
125
|
-
id: string;
|
|
126
|
-
name: string;
|
|
127
|
-
input: Record<string, unknown>;
|
|
128
|
-
}
|
|
129
|
-
interface ToolResultBlock {
|
|
130
|
-
type: 'tool_result';
|
|
131
|
-
tool_use_id: string;
|
|
132
|
-
/**
|
|
133
|
-
* The original tool name. Useful for providers like Google Gemini that
|
|
134
|
-
* need the tool name in `functionResponse.name` — the tool_use_id is
|
|
135
|
-
* only a session-local identifier and is not stable across replays.
|
|
136
|
-
* Always set by ToolExecutor; may be absent on manually-constructed blocks.
|
|
137
|
-
*/
|
|
138
|
-
name?: string;
|
|
139
|
-
content: string;
|
|
140
|
-
is_error?: boolean;
|
|
141
|
-
}
|
|
142
|
-
interface ImageBlock {
|
|
143
|
-
type: 'image';
|
|
144
|
-
source: {
|
|
145
|
-
type: 'base64' | 'url';
|
|
146
|
-
media_type?: string;
|
|
147
|
-
data?: string;
|
|
148
|
-
url?: string;
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
type ContentBlock = TextBlock | ToolUseBlock | ToolResultBlock | ImageBlock;
|
|
152
|
-
declare function isTextBlock(b: ContentBlock): b is TextBlock;
|
|
153
|
-
declare function isToolUseBlock(b: ContentBlock): b is ToolUseBlock;
|
|
154
|
-
declare function isToolResultBlock(b: ContentBlock): b is ToolResultBlock;
|
|
155
|
-
declare function isImageBlock(b: ContentBlock): b is ImageBlock;
|
|
156
|
-
|
|
157
|
-
type MessageRole = 'user' | 'assistant' | 'system';
|
|
158
|
-
interface Message {
|
|
159
|
-
role: MessageRole;
|
|
160
|
-
content: string | ContentBlock[];
|
|
161
|
-
}
|
|
162
|
-
declare function asBlocks(content: string | ContentBlock[]): ContentBlock[];
|
|
163
|
-
declare function asText(content: string | ContentBlock[]): string;
|
|
164
|
-
|
|
165
|
-
interface SessionMetadata {
|
|
166
|
-
id: string;
|
|
167
|
-
title?: string;
|
|
168
|
-
model?: string;
|
|
169
|
-
provider?: string;
|
|
170
|
-
startedAt: string;
|
|
171
|
-
endedAt?: string;
|
|
172
|
-
}
|
|
173
|
-
type SessionEvent = {
|
|
174
|
-
type: 'session_start';
|
|
175
|
-
ts: string;
|
|
176
|
-
id: string;
|
|
177
|
-
model: string;
|
|
178
|
-
provider: string;
|
|
179
|
-
} | {
|
|
180
|
-
type: 'session_resumed';
|
|
181
|
-
ts: string;
|
|
182
|
-
id: string;
|
|
183
|
-
model: string;
|
|
184
|
-
provider: string;
|
|
185
|
-
} | {
|
|
186
|
-
type: 'user_input';
|
|
187
|
-
ts: string;
|
|
188
|
-
content: string | ContentBlock[];
|
|
189
|
-
} | {
|
|
190
|
-
type: 'llm_request';
|
|
191
|
-
ts: string;
|
|
192
|
-
model: string;
|
|
193
|
-
messageCount: number;
|
|
194
|
-
} | {
|
|
195
|
-
type: 'llm_response';
|
|
196
|
-
ts: string;
|
|
197
|
-
content: ContentBlock[];
|
|
198
|
-
stopReason: string;
|
|
199
|
-
usage: Usage;
|
|
200
|
-
} | {
|
|
201
|
-
type: 'tool_use';
|
|
202
|
-
ts: string;
|
|
203
|
-
name: string;
|
|
204
|
-
id: string;
|
|
205
|
-
input: unknown;
|
|
206
|
-
} | {
|
|
207
|
-
type: 'tool_result';
|
|
208
|
-
ts: string;
|
|
209
|
-
id: string;
|
|
210
|
-
content: unknown;
|
|
211
|
-
isError: boolean;
|
|
212
|
-
} | {
|
|
213
|
-
type: 'compaction';
|
|
214
|
-
ts: string;
|
|
215
|
-
before: number;
|
|
216
|
-
after: number;
|
|
217
|
-
} | {
|
|
218
|
-
type: 'error';
|
|
219
|
-
ts: string;
|
|
220
|
-
message: string;
|
|
221
|
-
phase: string;
|
|
222
|
-
} | {
|
|
223
|
-
type: 'session_end';
|
|
224
|
-
ts: string;
|
|
225
|
-
usage: Usage;
|
|
226
|
-
} | {
|
|
227
|
-
type: 'mode_changed';
|
|
228
|
-
ts: string;
|
|
229
|
-
from: string;
|
|
230
|
-
to: string;
|
|
231
|
-
} | {
|
|
232
|
-
type: 'task_created';
|
|
233
|
-
ts: string;
|
|
234
|
-
taskId: string;
|
|
235
|
-
title: string;
|
|
236
|
-
} | {
|
|
237
|
-
type: 'task_updated';
|
|
238
|
-
ts: string;
|
|
239
|
-
taskId: string;
|
|
240
|
-
status: string;
|
|
241
|
-
} | {
|
|
242
|
-
type: 'task_completed';
|
|
243
|
-
ts: string;
|
|
244
|
-
taskId: string;
|
|
245
|
-
title: string;
|
|
246
|
-
} | {
|
|
247
|
-
type: 'task_failed';
|
|
248
|
-
ts: string;
|
|
249
|
-
taskId: string;
|
|
250
|
-
title: string;
|
|
251
|
-
error: string;
|
|
252
|
-
} | {
|
|
253
|
-
type: 'agent_spawned';
|
|
254
|
-
ts: string;
|
|
255
|
-
agentId: string;
|
|
256
|
-
role: string;
|
|
257
|
-
} | {
|
|
258
|
-
type: 'agent_stopped';
|
|
259
|
-
ts: string;
|
|
260
|
-
agentId: string;
|
|
261
|
-
} | {
|
|
262
|
-
type: 'agent_error';
|
|
263
|
-
ts: string;
|
|
264
|
-
agentId: string;
|
|
265
|
-
error: string;
|
|
266
|
-
} | {
|
|
267
|
-
type: 'spec_parsed';
|
|
268
|
-
ts: string;
|
|
269
|
-
specId: string;
|
|
270
|
-
title: string;
|
|
271
|
-
completeness: number;
|
|
272
|
-
} | {
|
|
273
|
-
type: 'spec_analyzed';
|
|
274
|
-
ts: string;
|
|
275
|
-
specId: string;
|
|
276
|
-
gaps: string[];
|
|
277
|
-
} | {
|
|
278
|
-
type: 'skill_activated';
|
|
279
|
-
ts: string;
|
|
280
|
-
skillName: string;
|
|
281
|
-
} | {
|
|
282
|
-
type: 'skill_deactivated';
|
|
283
|
-
ts: string;
|
|
284
|
-
skillName: string;
|
|
285
|
-
} | {
|
|
286
|
-
type: 'tool_call_start';
|
|
287
|
-
ts: string;
|
|
288
|
-
name: string;
|
|
289
|
-
id: string;
|
|
290
|
-
input: unknown;
|
|
291
|
-
} | {
|
|
292
|
-
type: 'tool_call_end';
|
|
293
|
-
ts: string;
|
|
294
|
-
name: string;
|
|
295
|
-
id: string;
|
|
296
|
-
durationMs: number;
|
|
297
|
-
outputSize: number;
|
|
298
|
-
} | {
|
|
299
|
-
type: 'message_truncated';
|
|
300
|
-
ts: string;
|
|
301
|
-
before: number;
|
|
302
|
-
after: number;
|
|
303
|
-
};
|
|
304
|
-
interface SessionSummary {
|
|
305
|
-
id: string;
|
|
306
|
-
title: string;
|
|
307
|
-
startedAt: string;
|
|
308
|
-
model: string;
|
|
309
|
-
provider: string;
|
|
310
|
-
tokenTotal: number;
|
|
311
|
-
}
|
|
312
|
-
interface SessionData {
|
|
313
|
-
metadata: SessionMetadata;
|
|
314
|
-
events: SessionEvent[];
|
|
315
|
-
messages: Message[];
|
|
316
|
-
usage: Usage;
|
|
317
|
-
}
|
|
318
|
-
interface ResumedSession {
|
|
319
|
-
writer: SessionWriter;
|
|
320
|
-
data: SessionData;
|
|
321
|
-
}
|
|
322
|
-
interface SessionStore {
|
|
323
|
-
create(meta: Omit<SessionMetadata, 'startedAt'>): Promise<SessionWriter>;
|
|
324
|
-
load(id: string): Promise<SessionData>;
|
|
325
|
-
/**
|
|
326
|
-
* Open an existing session for append, returning both a writer that
|
|
327
|
-
* continues writing to the same JSONL file and the replayed state
|
|
328
|
-
* (messages + usage) so the caller can hydrate a Context. A
|
|
329
|
-
* `session_resumed` marker is appended for audit.
|
|
330
|
-
*/
|
|
331
|
-
resume(id: string): Promise<ResumedSession>;
|
|
332
|
-
list(limit?: number): Promise<SessionSummary[]>;
|
|
333
|
-
delete(id: string): Promise<void>;
|
|
334
|
-
}
|
|
335
|
-
interface SessionWriter {
|
|
336
|
-
readonly id: string;
|
|
337
|
-
append(event: SessionEvent): Promise<void>;
|
|
338
|
-
close(): Promise<void>;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
interface CacheStats {
|
|
342
|
-
/** Tokens served from cache (cheaper). */
|
|
343
|
-
readTokens: number;
|
|
344
|
-
/** Tokens written into the cache (more expensive than input on first hit). */
|
|
345
|
-
writeTokens: number;
|
|
346
|
-
/** Hit ratio: cacheRead / (cacheRead + input). 0 when nothing cached. */
|
|
347
|
-
hitRatio: number;
|
|
348
|
-
}
|
|
349
|
-
interface TokenCounter {
|
|
350
|
-
account(usage: Usage, model?: string): void;
|
|
351
|
-
total(): Usage;
|
|
352
|
-
estimateCost(): {
|
|
353
|
-
input: number;
|
|
354
|
-
output: number;
|
|
355
|
-
total: number;
|
|
356
|
-
currency: 'USD';
|
|
357
|
-
};
|
|
358
|
-
cacheStats(): CacheStats;
|
|
359
|
-
reset(): void;
|
|
360
|
-
}
|
|
361
|
-
|
|
362
|
-
interface TodoItem {
|
|
363
|
-
id: string;
|
|
364
|
-
content: string;
|
|
365
|
-
status: 'pending' | 'in_progress' | 'completed';
|
|
366
|
-
activeForm?: string;
|
|
367
|
-
}
|
|
368
|
-
interface RunOptions {
|
|
369
|
-
signal?: AbortSignal;
|
|
370
|
-
model?: string;
|
|
371
|
-
executionStrategy?: 'parallel' | 'sequential' | 'smart';
|
|
372
|
-
maxIterations?: number;
|
|
373
|
-
}
|
|
374
|
-
interface ContextInit {
|
|
375
|
-
systemPrompt: TextBlock[];
|
|
376
|
-
provider: Provider;
|
|
377
|
-
session: SessionWriter;
|
|
378
|
-
signal: AbortSignal;
|
|
379
|
-
tokenCounter: TokenCounter;
|
|
380
|
-
cwd: string;
|
|
381
|
-
projectRoot: string;
|
|
382
|
-
model: string;
|
|
383
|
-
tools?: Tool[];
|
|
384
|
-
}
|
|
385
|
-
declare class Context {
|
|
386
|
-
messages: Message[];
|
|
387
|
-
todos: TodoItem[];
|
|
388
|
-
readFiles: Set<string>;
|
|
389
|
-
fileMtimes: Map<string, number>;
|
|
390
|
-
systemPrompt: TextBlock[];
|
|
391
|
-
provider: Provider;
|
|
392
|
-
session: SessionWriter;
|
|
393
|
-
signal: AbortSignal;
|
|
394
|
-
tokenCounter: TokenCounter;
|
|
395
|
-
cwd: string;
|
|
396
|
-
projectRoot: string;
|
|
397
|
-
model: string;
|
|
398
|
-
tools: Tool[];
|
|
399
|
-
meta: Record<string, unknown>;
|
|
400
|
-
constructor(init: ContextInit);
|
|
401
|
-
/**
|
|
402
|
-
* Register a teardown hook tied to the current run's abort signal. The
|
|
403
|
-
* hook fires when the run aborts OR ends normally — Agent.run wires
|
|
404
|
-
* this through a RunController. When no run is active the hook fires
|
|
405
|
-
* immediately so callers don't leak resources.
|
|
406
|
-
*/
|
|
407
|
-
private abortHooks;
|
|
408
|
-
registerAbortHook(fn: () => void | Promise<void>): () => void;
|
|
409
|
-
drainAbortHooks(): Promise<void>;
|
|
410
|
-
recordRead(absPath: string, mtimeMs: number): void;
|
|
411
|
-
hasRead(absPath: string): boolean;
|
|
412
|
-
lastReadMtime(absPath: string): number | undefined;
|
|
413
|
-
usage(): Usage;
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
type Permission = 'auto' | 'confirm' | 'deny';
|
|
417
|
-
interface JSONSchema {
|
|
418
|
-
type?: string;
|
|
419
|
-
properties?: Record<string, JSONSchema>;
|
|
420
|
-
required?: string[];
|
|
421
|
-
items?: JSONSchema;
|
|
422
|
-
enum?: unknown[];
|
|
423
|
-
description?: string;
|
|
424
|
-
[k: string]: unknown;
|
|
425
|
-
}
|
|
426
|
-
interface Tool<I = unknown, O = unknown> {
|
|
427
|
-
name: string;
|
|
428
|
-
description: string;
|
|
429
|
-
usageHint?: string;
|
|
430
|
-
inputSchema: JSONSchema;
|
|
431
|
-
permission: Permission;
|
|
432
|
-
mutating: boolean;
|
|
433
|
-
maxOutputBytes?: number;
|
|
434
|
-
timeoutMs?: number;
|
|
435
|
-
execute(input: I, ctx: Context, opts: {
|
|
436
|
-
signal: AbortSignal;
|
|
437
|
-
}): Promise<O>;
|
|
438
|
-
}
|
|
439
|
-
interface ToolCallContext {
|
|
440
|
-
tool: Tool;
|
|
441
|
-
input: unknown;
|
|
442
|
-
callId: string;
|
|
443
|
-
ctx: Context;
|
|
444
|
-
signal: AbortSignal;
|
|
445
|
-
}
|
|
446
|
-
|
|
447
|
-
interface Usage {
|
|
448
|
-
input: number;
|
|
449
|
-
output: number;
|
|
450
|
-
cacheRead?: number;
|
|
451
|
-
cacheWrite?: number;
|
|
452
|
-
}
|
|
453
|
-
interface Capabilities {
|
|
454
|
-
tools: boolean;
|
|
455
|
-
parallelTools: boolean;
|
|
456
|
-
vision: boolean;
|
|
457
|
-
streaming: boolean;
|
|
458
|
-
promptCache: boolean;
|
|
459
|
-
systemPrompt: boolean;
|
|
460
|
-
jsonMode: boolean;
|
|
461
|
-
maxContext: number;
|
|
462
|
-
cacheControl: 'native' | 'auto' | 'none';
|
|
463
|
-
}
|
|
464
|
-
interface Request {
|
|
465
|
-
model: string;
|
|
466
|
-
system?: TextBlock[];
|
|
467
|
-
messages: Message[];
|
|
468
|
-
tools?: Tool[];
|
|
469
|
-
maxTokens: number;
|
|
470
|
-
temperature?: number;
|
|
471
|
-
topP?: number;
|
|
472
|
-
stopSequences?: string[];
|
|
473
|
-
toolChoice?: 'auto' | 'required' | 'none' | {
|
|
474
|
-
type: 'tool';
|
|
475
|
-
name: string;
|
|
476
|
-
};
|
|
477
|
-
}
|
|
478
|
-
type StopReason = 'end_turn' | 'tool_use' | 'max_tokens' | 'stop_sequence' | 'refusal';
|
|
479
|
-
interface Response {
|
|
480
|
-
content: ContentBlock[];
|
|
481
|
-
stopReason: StopReason;
|
|
482
|
-
usage: Usage;
|
|
483
|
-
model: string;
|
|
484
|
-
}
|
|
485
|
-
type StreamEvent = {
|
|
486
|
-
type: 'message_start';
|
|
487
|
-
model: string;
|
|
488
|
-
} | {
|
|
489
|
-
type: 'content_block_start';
|
|
490
|
-
kind: 'text' | 'tool_use';
|
|
491
|
-
id?: string;
|
|
492
|
-
name?: string;
|
|
493
|
-
} | {
|
|
494
|
-
type: 'content_block_stop';
|
|
495
|
-
index: number;
|
|
496
|
-
} | {
|
|
497
|
-
type: 'text_delta';
|
|
498
|
-
text: string;
|
|
499
|
-
} | {
|
|
500
|
-
type: 'tool_use_start';
|
|
501
|
-
id: string;
|
|
502
|
-
name: string;
|
|
503
|
-
} | {
|
|
504
|
-
type: 'tool_use_input_delta';
|
|
505
|
-
id: string;
|
|
506
|
-
partial: string;
|
|
507
|
-
} | {
|
|
508
|
-
type: 'tool_use_stop';
|
|
509
|
-
id: string;
|
|
510
|
-
input: unknown;
|
|
511
|
-
} | {
|
|
512
|
-
type: 'message_stop';
|
|
513
|
-
stopReason: StopReason;
|
|
514
|
-
usage: Usage;
|
|
515
|
-
};
|
|
516
|
-
interface Provider {
|
|
517
|
-
readonly id: string;
|
|
518
|
-
readonly capabilities: Capabilities;
|
|
519
|
-
/** Canonical streaming entry point. `complete()` defaults to a wrapper that
|
|
520
|
-
* aggregates this stream — providers may override for non-streaming wires. */
|
|
521
|
-
stream(req: Request, opts: {
|
|
522
|
-
signal: AbortSignal;
|
|
523
|
-
}): AsyncIterable<StreamEvent>;
|
|
524
|
-
complete(req: Request, opts: {
|
|
525
|
-
signal: AbortSignal;
|
|
526
|
-
}): Promise<Response>;
|
|
527
|
-
}
|
|
528
|
-
/**
|
|
529
|
-
* Structured body parsed from a provider's HTTP error response. Populated
|
|
530
|
-
* best-effort: providers return JSON shaped differently (Anthropic uses
|
|
531
|
-
* `{error: {type, message}}`, OpenAI uses `{error: {message, code}}`,
|
|
532
|
-
* Google uses `{error: {status, message}}`), so the fields here are the
|
|
533
|
-
* intersection that's usable for rendering and routing.
|
|
534
|
-
*/
|
|
535
|
-
interface ProviderErrorBody {
|
|
536
|
-
/** Provider-specific kind, e.g. "overloaded_error", "rate_limit_error", "invalid_request_error". */
|
|
537
|
-
type?: string;
|
|
538
|
-
/** Human-readable explanation from the provider. */
|
|
539
|
-
message?: string;
|
|
540
|
-
/** Provider request id, when present in the body or headers. */
|
|
541
|
-
requestId?: string;
|
|
542
|
-
/** Parsed Retry-After header (or equivalent body hint) in milliseconds. */
|
|
543
|
-
retryAfterMs?: number;
|
|
544
|
-
/** The raw response body (truncated), kept for debugging. */
|
|
545
|
-
raw?: string;
|
|
546
|
-
}
|
|
547
|
-
declare class ProviderError extends Error {
|
|
548
|
-
readonly status: number;
|
|
549
|
-
readonly retryable: boolean;
|
|
550
|
-
readonly providerId: string;
|
|
551
|
-
readonly body?: ProviderErrorBody;
|
|
552
|
-
readonly cause?: unknown;
|
|
553
|
-
constructor(message: string, status: number, retryable: boolean, providerId: string, opts?: {
|
|
554
|
-
body?: ProviderErrorBody;
|
|
555
|
-
cause?: unknown;
|
|
556
|
-
});
|
|
557
|
-
/**
|
|
558
|
-
* Render a one-line, user-facing description. Designed for the CLI/TUI
|
|
559
|
-
* status line and the agent's retry warning. Avoids dumping raw JSON
|
|
560
|
-
* (which is what users see today when a 529 lands and the log message
|
|
561
|
-
* includes the full `{"type":"error",...}` body).
|
|
562
|
-
*
|
|
563
|
-
* Examples:
|
|
564
|
-
* "minimax-coding-plan overloaded (529): High traffic detected. Upgrade for highspeed model. [req 06534785201de9c0…]"
|
|
565
|
-
* "openai rate limited (429): Retry after 12s"
|
|
566
|
-
* "anthropic invalid request (400): messages.0.role must be one of 'user'|'assistant'"
|
|
567
|
-
* "groq HTTP 500 (server error)"
|
|
568
|
-
*/
|
|
569
|
-
describe(): string;
|
|
570
|
-
}
|
|
571
|
-
|
|
572
145
|
/**
|
|
573
146
|
* EventBus — observe-only typed event bus.
|
|
574
147
|
* Subscribers cannot modify or cancel. Subscriber exceptions are caught.
|
|
@@ -651,6 +224,29 @@ interface EventMap {
|
|
|
651
224
|
id: string;
|
|
652
225
|
input?: unknown;
|
|
653
226
|
};
|
|
227
|
+
/**
|
|
228
|
+
* Fired for each ToolProgressEvent yielded by `Tool.executeStream`. UIs
|
|
229
|
+
* subscribe to render incremental progress (streaming bash output, file
|
|
230
|
+
* tree counts, etc.) without the tool having to know about the UI.
|
|
231
|
+
*/
|
|
232
|
+
'tool.progress': {
|
|
233
|
+
name: string;
|
|
234
|
+
id: string;
|
|
235
|
+
event: ToolProgressEvent;
|
|
236
|
+
};
|
|
237
|
+
/**
|
|
238
|
+
* Fired when a tool call needs user confirmation and no confirmHandler
|
|
239
|
+
* is registered on the executor. The TUI renders a confirmation dialog
|
|
240
|
+
* from this event. Resolution is driven by calling the resolve function
|
|
241
|
+
* passed in the payload with a decision string ('yes' | 'no' | 'always' | 'deny').
|
|
242
|
+
*/
|
|
243
|
+
'tool.confirm_needed': {
|
|
244
|
+
tool: Tool;
|
|
245
|
+
input: unknown;
|
|
246
|
+
toolUseId: string;
|
|
247
|
+
suggestedPattern: string;
|
|
248
|
+
resolve: (decision: 'yes' | 'no' | 'always' | 'deny') => void;
|
|
249
|
+
};
|
|
654
250
|
/**
|
|
655
251
|
* `output` is a truncated preview of the tool's serialized result text
|
|
656
252
|
* (capped at ~400 chars by the emitter). UIs render this inline in the
|
|
@@ -705,6 +301,12 @@ declare class EventBus {
|
|
|
705
301
|
once<E extends EventName>(event: E, fn: Listener<E>): () => void;
|
|
706
302
|
emit<E extends EventName>(event: E, payload: EventMap[E]): void;
|
|
707
303
|
clear(): void;
|
|
304
|
+
/**
|
|
305
|
+
* V2-D: introspection helper. Pass an `event` to count handlers for a
|
|
306
|
+
* single key, or omit to get the total across every event. Used by the
|
|
307
|
+
* leak-detection smoke test to flag handler accumulation across runs.
|
|
308
|
+
*/
|
|
309
|
+
listenerCount(event?: EventName): number;
|
|
708
310
|
}
|
|
709
311
|
|
|
710
312
|
type LogLevel = 'error' | 'warn' | 'info' | 'debug' | 'trace';
|
|
@@ -911,9 +513,30 @@ interface ToolsConfig {
|
|
|
911
513
|
*/
|
|
912
514
|
autoExtendLimit?: boolean;
|
|
913
515
|
}
|
|
516
|
+
interface ProviderApiKey {
|
|
517
|
+
/** Short human-readable label (e.g. "personal", "work", "rate-limit-backup"). */
|
|
518
|
+
label: string;
|
|
519
|
+
/**
|
|
520
|
+
* The key itself. The field name contains `apiKey` so the secret-vault
|
|
521
|
+
* walker will encrypt it on write and decrypt it on read.
|
|
522
|
+
*/
|
|
523
|
+
apiKey: string;
|
|
524
|
+
/** ISO-8601 timestamp the key was added. */
|
|
525
|
+
createdAt: string;
|
|
526
|
+
}
|
|
914
527
|
interface ProviderConfig {
|
|
915
528
|
type: string;
|
|
529
|
+
/**
|
|
530
|
+
* Legacy single-key field. Still honored as a fallback when `apiKeys`
|
|
531
|
+
* is empty. When `apiKeys`/`activeKey` are present, the config loader
|
|
532
|
+
* mirrors the active entry into this field so downstream consumers
|
|
533
|
+
* (provider construction, wire adapters) need no changes.
|
|
534
|
+
*/
|
|
916
535
|
apiKey?: string;
|
|
536
|
+
/** Multiple keys for the same provider — pick one with `activeKey`. */
|
|
537
|
+
apiKeys?: ProviderApiKey[];
|
|
538
|
+
/** Label of the entry in `apiKeys` to use. Defaults to the first one. */
|
|
539
|
+
activeKey?: string;
|
|
917
540
|
baseUrl?: string;
|
|
918
541
|
headers?: Record<string, string>;
|
|
919
542
|
model?: string;
|
|
@@ -931,6 +554,8 @@ interface ProviderConfig {
|
|
|
931
554
|
models?: string[];
|
|
932
555
|
}
|
|
933
556
|
interface MCPServerConfig {
|
|
557
|
+
/** Human-readable description shown in `wstack mcp list`. */
|
|
558
|
+
description?: string;
|
|
934
559
|
name: string;
|
|
935
560
|
transport: 'stdio' | 'sse' | 'streamable-http';
|
|
936
561
|
command?: string;
|
|
@@ -987,6 +612,19 @@ interface Config {
|
|
|
987
612
|
features: FeaturesConfig;
|
|
988
613
|
yolo?: boolean;
|
|
989
614
|
cwd?: string;
|
|
615
|
+
/**
|
|
616
|
+
* Per-plugin namespaced config sections. Each plugin reads its own
|
|
617
|
+
* subtree via `ConfigStore.getExtension(pluginName)`. Plugins should
|
|
618
|
+
* declare a `configSchema` so the loader validates this section
|
|
619
|
+
* automatically before `setup()` runs.
|
|
620
|
+
*
|
|
621
|
+
* Example:
|
|
622
|
+
* extensions: {
|
|
623
|
+
* 'wstack-auth': { tokenUrl: 'https://...', refreshBefore: 300 },
|
|
624
|
+
* 'wstack-metrics': { sink: 'prometheus', port: 9090 },
|
|
625
|
+
* }
|
|
626
|
+
*/
|
|
627
|
+
extensions?: Record<string, Record<string, unknown>>;
|
|
990
628
|
}
|
|
991
629
|
interface ConfigLoader {
|
|
992
630
|
load(opts?: {
|
|
@@ -994,6 +632,37 @@ interface ConfigLoader {
|
|
|
994
632
|
cwd?: string;
|
|
995
633
|
}): Promise<Config>;
|
|
996
634
|
}
|
|
635
|
+
/**
|
|
636
|
+
* Subscribable view over Config. Plugins and CLI subsystems use this instead
|
|
637
|
+
* of holding a frozen Config reference, so they can react to runtime updates
|
|
638
|
+
* (e.g. `/model` switching the active provider, secrets rotation, dynamic
|
|
639
|
+
* extension reload).
|
|
640
|
+
*
|
|
641
|
+
* The store enforces immutability — `get()` always returns a frozen object.
|
|
642
|
+
* Updates happen through `update(partial)`, which produces a new Config
|
|
643
|
+
* (structurally cloned, then frozen) and notifies watchers.
|
|
644
|
+
*/
|
|
645
|
+
interface ConfigStore {
|
|
646
|
+
get(): Readonly<Config>;
|
|
647
|
+
/**
|
|
648
|
+
* Get a typed top-level section. Convenience for consumers that only
|
|
649
|
+
* care about one slice (e.g. `tools` or `context`).
|
|
650
|
+
*/
|
|
651
|
+
getSection<K extends keyof Config>(key: K): Readonly<Config[K]>;
|
|
652
|
+
/**
|
|
653
|
+
* Return the extension namespace for `pluginName`, or an empty record
|
|
654
|
+
* when none is configured. The returned object is frozen.
|
|
655
|
+
*/
|
|
656
|
+
getExtension(pluginName: string): Readonly<Record<string, unknown>>;
|
|
657
|
+
/**
|
|
658
|
+
* Apply a partial update. Returns the new Config. Watchers are notified
|
|
659
|
+
* synchronously after the update completes. Throws if the result fails
|
|
660
|
+
* any registered invariants (currently: version must stay 1).
|
|
661
|
+
*/
|
|
662
|
+
update(partial: Partial<Config>): Readonly<Config>;
|
|
663
|
+
/** Subscribe to changes. Returns an unsubscribe function. */
|
|
664
|
+
watch(cb: (next: Readonly<Config>, prev: Readonly<Config>) => void): () => void;
|
|
665
|
+
}
|
|
997
666
|
|
|
998
667
|
interface Renderer {
|
|
999
668
|
write(text: string | TextBlock): void;
|
|
@@ -1052,4 +721,4 @@ interface SecretScrubber {
|
|
|
1052
721
|
scrubObject<T>(obj: T): T;
|
|
1053
722
|
}
|
|
1054
723
|
|
|
1055
|
-
export {
|
|
724
|
+
export { Container as A, EventBus as B, type CompactReport as C, type EventName as D, type ErrorHandler as E, type FeaturesConfig as F, type Listener as G, type BindOptions as H, type InputReader as I, type Decorator as J, type EventLogger as K, type LogConfig as L, type MCPServerConfig as M, type EventMap as N, type Factory as O, type PathResolver as P, type Middleware as Q, type Renderer as R, type SecretScrubber as S, type ToolsConfig as T, type MiddlewareHandler as U, type NextFn as V, type WireFamily as W, Pipeline as X, type PipelineOptions as Y, type Token as Z, type ReadonlyPipeline as _, type Compactor as a, type Config as b, type ConfigLoader as c, type ConfigStore as d, type ContextConfig as e, type LogLevel as f, type Logger as g, type MemoryEntry as h, type MemoryScope as i, type MemoryStore as j, type ModelsDevModel as k, type ModelsDevPayload as l, type ModelsDevProvider as m, type ModelsRegistry as n, type PermissionDecision as o, type PermissionPolicy as p, type PluginConfig as q, type PromptOption as r, type ProviderApiKey as s, type ProviderConfig as t, type ResolvedModel as u, type ResolvedProvider as v, type RetryPolicy as w, type SkillLoader as x, type SkillManifest as y, type TrustPolicy as z };
|