@cuylabs/agent-core 0.9.0 → 0.10.0

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 (116) hide show
  1. package/README.md +33 -17
  2. package/dist/chunk-2O4MCSQS.js +780 -0
  3. package/dist/chunk-2TTOLHBT.js +198 -0
  4. package/dist/chunk-5FMSGQVX.js +281 -0
  5. package/dist/chunk-5NVVNXPQ.js +288 -0
  6. package/dist/{chunk-EKR6PKXU.js → chunk-6HZBHFOL.js} +3 -3
  7. package/dist/chunk-CJI7PVS2.js +58 -0
  8. package/dist/{chunk-WKHDSSXG.js → chunk-CMYN2RCB.js} +146 -46
  9. package/dist/chunk-FII65CN7.js +117 -0
  10. package/dist/{chunk-UHCJEM2E.js → chunk-ICZ66572.js} +13 -6
  11. package/dist/chunk-KYLPMBHD.js +316 -0
  12. package/dist/chunk-MXAP4UG6.js +2956 -0
  13. package/dist/{chunk-4QFNWPIF.js → chunk-N3VX7FEE.js} +35 -2
  14. package/dist/{chunk-MAZ5DY5B.js → chunk-NDZWXCBZ.js} +213 -78
  15. package/dist/{chunk-MHKK374K.js → chunk-Q742PSH3.js} +11 -27
  16. package/dist/{chunk-WGZAPU6N.js → chunk-QAL3OMI3.js} +15 -1
  17. package/dist/{chunk-UDCZ673N.js → chunk-RN6WZEUF.js} +27 -23
  18. package/dist/{chunk-ZXAKHMWH.js → chunk-ROTGCYDW.js} +22 -84
  19. package/dist/chunk-SPBFQXOT.js +0 -0
  20. package/dist/chunk-SSFBF3US.js +602 -0
  21. package/dist/chunk-SZ2XBPTW.js +8 -0
  22. package/dist/chunk-T4UIX5D7.js +115 -0
  23. package/dist/{chunk-IYWQOJMQ.js → chunk-TIHPYVAJ.js} +34 -34
  24. package/dist/{chunk-RKEW5WXI.js → chunk-TOTDGK3P.js} +1 -1
  25. package/dist/chunk-V4RFNEET.js +563 -0
  26. package/dist/chunk-VOUEJSW6.js +0 -0
  27. package/dist/{chunk-J4QDGZIA.js → chunk-WBPOZ7CL.js} +659 -275
  28. package/dist/chunk-X4VN4GIJ.js +185 -0
  29. package/dist/dispatch/index.d.ts +93 -0
  30. package/dist/dispatch/index.js +37 -0
  31. package/dist/events/index.d.ts +93 -0
  32. package/dist/events/index.js +6 -0
  33. package/dist/{runtime → execution}/index.d.ts +120 -35
  34. package/dist/{runtime → execution}/index.js +17 -11
  35. package/dist/index.d.ts +489 -115
  36. package/dist/index.js +1665 -462
  37. package/dist/inference/errors/index.js +1 -1
  38. package/dist/inference/index.d.ts +13 -21
  39. package/dist/inference/index.js +15 -12
  40. package/dist/instance-BqV2D5pc.d.ts +5723 -0
  41. package/dist/logger/index.d.ts +50 -0
  42. package/dist/logger/index.js +11 -0
  43. package/dist/mcp/index.d.ts +5 -9
  44. package/dist/mcp/index.js +2 -3
  45. package/dist/middleware/index.d.ts +10 -150
  46. package/dist/middleware/index.js +10 -2
  47. package/dist/model-messages-B4nK9D1-.d.ts +13 -0
  48. package/dist/models/index.d.ts +5 -2
  49. package/dist/models/index.js +2 -1
  50. package/dist/models/reasoning/index.js +2 -1
  51. package/dist/plugin/index.d.ts +55 -11
  52. package/dist/plugin/index.js +1 -1
  53. package/dist/profiles/index.d.ts +55 -0
  54. package/dist/{presets → profiles}/index.js +10 -10
  55. package/dist/prompt/index.d.ts +8 -13
  56. package/dist/safety/index.d.ts +109 -14
  57. package/dist/safety/index.js +59 -3
  58. package/dist/sandbox/index.d.ts +81 -0
  59. package/dist/sandbox/index.js +1 -0
  60. package/dist/skill/index.d.ts +10 -8
  61. package/dist/skill/index.js +2 -2
  62. package/dist/storage/index.d.ts +12 -4
  63. package/dist/storage/index.js +1 -1
  64. package/dist/subagents/index.d.ts +177 -0
  65. package/dist/subagents/index.js +78 -0
  66. package/dist/team/index.d.ts +544 -0
  67. package/dist/team/index.js +41 -0
  68. package/dist/tool/host/index.d.ts +41 -0
  69. package/dist/tool/host/index.js +10 -0
  70. package/dist/tool/index.d.ts +111 -21
  71. package/dist/tool/index.js +20 -13
  72. package/dist/{types-VQgymC1N.d.ts → types-Bj_J8u_W.d.ts} +44 -64
  73. package/dist/{types-CHiPh8U2.d.ts → types-C_LCeYNg.d.ts} +7 -7
  74. package/dist/types-RSCv7nQ4.d.ts +59 -0
  75. package/package.json +46 -47
  76. package/dist/builder-BgZ_j4Vs.d.ts +0 -35
  77. package/dist/chunk-5ARZJWD2.js +0 -259
  78. package/dist/chunk-DXFBQMXP.js +0 -53
  79. package/dist/chunk-H3FUYU52.js +0 -81
  80. package/dist/chunk-JLXG2SH7.js +0 -905
  81. package/dist/chunk-N7P4PN3O.js +0 -84
  82. package/dist/chunk-OFDKHNCX.js +0 -727
  83. package/dist/chunk-SDSBEQXG.js +0 -157
  84. package/dist/chunk-VEKUXUVF.js +0 -41
  85. package/dist/chunk-VNQBHPCT.js +0 -398
  86. package/dist/chunk-WWYYNWEW.js +0 -259
  87. package/dist/context/index.d.ts +0 -259
  88. package/dist/context/index.js +0 -26
  89. package/dist/events-CE72w8W4.d.ts +0 -149
  90. package/dist/host/index.d.ts +0 -45
  91. package/dist/host/index.js +0 -8
  92. package/dist/index-DQuTZ8xL.d.ts +0 -1335
  93. package/dist/messages-BYWGn8TY.d.ts +0 -110
  94. package/dist/presets/index.d.ts +0 -53
  95. package/dist/registry-DwYqsQkX.d.ts +0 -164
  96. package/dist/runner-CI-XeR16.d.ts +0 -91
  97. package/dist/scope/index.d.ts +0 -10
  98. package/dist/scope/index.js +0 -14
  99. package/dist/session-manager-KbYt2WUh.d.ts +0 -282
  100. package/dist/signal/index.d.ts +0 -28
  101. package/dist/signal/index.js +0 -6
  102. package/dist/sub-agent/index.d.ts +0 -24
  103. package/dist/sub-agent/index.js +0 -32
  104. package/dist/tool-CZWN3KbO.d.ts +0 -141
  105. package/dist/tool-DkhSCV2Y.d.ts +0 -145
  106. package/dist/tracker-DClqYqTj.d.ts +0 -96
  107. package/dist/tracking/index.d.ts +0 -111
  108. package/dist/tracking/index.js +0 -20
  109. package/dist/types-BfNpU8NS.d.ts +0 -270
  110. package/dist/types-BlOKk-Bb.d.ts +0 -330
  111. package/dist/types-BlZwmnuW.d.ts +0 -50
  112. package/dist/types-CQL-SvTn.d.ts +0 -29
  113. package/dist/types-CWm-7rvB.d.ts +0 -55
  114. package/dist/types-DTSkxakL.d.ts +0 -651
  115. package/dist/types-DmDwi2zI.d.ts +0 -339
  116. package/dist/types-YuWV4ag7.d.ts +0 -72
@@ -1,330 +0,0 @@
1
- import { StreamTextResult, ToolSet, Output, LanguageModel, ModelMessage, TelemetrySettings } from 'ai';
2
- import { T as Tool } from './tool-CZWN3KbO.js';
3
- import { T as ToolHost } from './types-CHiPh8U2.js';
4
- import { M as MiddlewareRunner } from './runner-CI-XeR16.js';
5
- import { S as StreamChunk, f as StreamProvider, M as ModelCallInput } from './types-DTSkxakL.js';
6
- import { R as ReasoningLevel } from './types-CQaXbRsS.js';
7
- import { d as TurnTrackerContext } from './tool-DkhSCV2Y.js';
8
- import { L as LLMError } from './llm-error-D93FNNLY.js';
9
-
10
- /**
11
- * Intervention Controller for @cuylabs/agent-core
12
- *
13
- * Manages mid-turn message injection into running agent turns.
14
- * Uses Vercel AI SDK v6's `prepareStep` hook for zero-overhead
15
- * integration at step boundaries (between LLM calls in a multi-step turn).
16
- *
17
- * Instead of polling a queue after each tool execution, this leverages
18
- * the SDK's native step lifecycle. The
19
- * `prepareStep` callback fires before every LLM call, giving us a
20
- * natural injection point with no custom loop machinery.
21
- *
22
- * Two injection modes:
23
- * - **Immediate**: `intervene(msg)` — injected at the next step boundary
24
- * - **Deferred**: `queueNext(msg)` — held until the turn completes
25
- */
26
- /** A queued intervention message waiting to be applied */
27
- interface PendingIntervention {
28
- /** Unique identifier for tracking */
29
- readonly id: string;
30
- /** The user message to inject */
31
- readonly message: string;
32
- /** When the intervention was created */
33
- readonly createdAt: Date;
34
- }
35
- /**
36
- * Callback fired when an intervention is applied to a step.
37
- *
38
- * The agent uses this to push `intervention-applied` events into
39
- * the streaming event queue so they reach the consumer in the
40
- * correct order relative to other events.
41
- */
42
- type OnInterventionApplied = (intervention: PendingIntervention) => void;
43
- /**
44
- * Manages mid-turn message injection for agents.
45
- *
46
- * This is the core primitive that connects user redirection intent
47
- * to the AI SDK's multi-step loop. The flow:
48
- *
49
- * 1. Consumer calls `agent.intervene("focus on auth.ts")` from any async context
50
- * 2. The message is queued as a `PendingIntervention`
51
- * 3. At the next step boundary, `prepareStep` drains the queue
52
- * 4. The message is appended to the LLM's input messages
53
- * 5. The LLM responds to the redirect naturally
54
- *
55
- * Thread safety: All operations are synchronous and run on the
56
- * same event loop. No locks needed — Node.js guarantees ordering.
57
- *
58
- * @example
59
- * ```typescript
60
- * const ctrl = new InterventionController();
61
- *
62
- * // Queue an intervention (from a UI handler, WebSocket, etc.)
63
- * const id = ctrl.intervene("stop refactoring, fix the failing test first");
64
- *
65
- * // Later, in prepareStep:
66
- * const pending = ctrl.drainImmediate();
67
- * // → [{ id, message: "stop refactoring...", createdAt }]
68
- * ```
69
- */
70
- declare class InterventionController {
71
- /** Immediate interventions — applied at the next step boundary */
72
- private immediate;
73
- /** Deferred messages — held until the turn completes */
74
- private deferred;
75
- /**
76
- * Callback fired when an intervention is wired into a step.
77
- * Set by the Agent before starting a chat turn, cleared after.
78
- */
79
- onApplied?: OnInterventionApplied;
80
- /**
81
- * Inject a message at the next LLM step boundary.
82
- *
83
- * The message is appended as a user message to the conversation
84
- * before the next LLM call in the current multi-step turn. The
85
- * LLM will see it and can adjust its behavior accordingly.
86
- *
87
- * Safe to call from any async context while `chat()` is running.
88
- * If called when no turn is active, the message will be picked up
89
- * by the first step of the next `chat()` call.
90
- *
91
- * @param message - The user message to inject
92
- * @returns Intervention ID for tracking
93
- */
94
- intervene(message: string): string;
95
- /**
96
- * Drain and return all pending immediate interventions.
97
- * The internal queue is cleared atomically.
98
- *
99
- * @internal Called by the LLM stream's `prepareStep` hook
100
- */
101
- drainImmediate(): PendingIntervention[];
102
- /** Adopt existing immediate interventions without changing their IDs. */
103
- adoptImmediate(items: PendingIntervention[]): void;
104
- /** Whether there are pending immediate interventions */
105
- get hasPending(): boolean;
106
- /** Number of pending immediate interventions */
107
- get pendingCount(): number;
108
- /**
109
- * Queue a message for after the current turn completes.
110
- *
111
- * Unlike `intervene()`, this does **not** inject mid-turn. The
112
- * message is held and available via `drainDeferred()` after
113
- * `chat()` finishes. The consumer decides whether to send it
114
- * as a new turn.
115
- *
116
- * @param message - The message to queue
117
- * @returns Intervention ID for tracking
118
- */
119
- queueNext(message: string): string;
120
- /**
121
- * Drain and return all deferred messages.
122
- * The internal queue is cleared atomically.
123
- */
124
- drainDeferred(): PendingIntervention[];
125
- /** Adopt existing deferred interventions without changing their IDs. */
126
- adoptDeferred(items: PendingIntervention[]): void;
127
- /** Whether there are deferred messages */
128
- get hasDeferred(): boolean;
129
- /** Number of deferred messages */
130
- get deferredCount(): number;
131
- /** Clear all queues (immediate + deferred) */
132
- clear(): void;
133
- /** Reset the controller for a new turn (clears onApplied, keeps queues) */
134
- resetCallbacks(): void;
135
- }
136
-
137
- /**
138
- * Retry logic with exponential backoff for @cuylabs/agent-core
139
- *
140
- * Provides configurable retry behavior with header-aware delays,
141
- * exponential backoff, and abort signal support.
142
- */
143
-
144
- /**
145
- * Retry configuration
146
- */
147
- interface RetryConfig {
148
- /** Maximum number of retry attempts (default: 3) */
149
- maxAttempts?: number;
150
- /** Initial delay in ms (default: 2000) */
151
- initialDelayMs?: number;
152
- /** Backoff multiplier (default: 2) */
153
- backoffFactor?: number;
154
- /** Maximum delay without headers in ms (default: 30000) */
155
- maxDelayMs?: number;
156
- /** Whether to jitter delays (default: true) */
157
- jitter?: boolean;
158
- /** Callback when retrying */
159
- onRetry?: (attempt: number, delayMs: number, error: LLMError) => void;
160
- }
161
- /**
162
- * Default retry configuration
163
- */
164
- declare const DEFAULT_RETRY_CONFIG: Required<Omit<RetryConfig, "onRetry">>;
165
- /**
166
- * Tracks retry state across attempts
167
- */
168
- interface RetryState {
169
- /** Current attempt number (1-indexed) */
170
- attempt: number;
171
- /** Total errors encountered */
172
- errors: LLMError[];
173
- /** Whether more retries are available */
174
- canRetry: boolean;
175
- /** Delay until next retry (if applicable) */
176
- nextDelayMs?: number;
177
- }
178
- /**
179
- * Creates initial retry state
180
- */
181
- declare function createRetryState(): RetryState;
182
- /**
183
- * Calculate delay for a retry attempt
184
- */
185
- declare function calculateDelay(attempt: number, error: LLMError | undefined, config: Required<Omit<RetryConfig, "onRetry">>): number;
186
- /**
187
- * Sleep for a duration, respecting abort signal
188
- */
189
- declare function sleep(ms: number, signal?: AbortSignal): Promise<void>;
190
- /**
191
- * Execute a function with retry logic
192
- */
193
- declare function withRetry<T>(fn: (attempt: number) => Promise<T>, config?: RetryConfig, signal?: AbortSignal): Promise<T>;
194
- /**
195
- * Options for retry handler
196
- */
197
- interface RetryHandlerOptions extends RetryConfig {
198
- /** Abort signal */
199
- signal?: AbortSignal;
200
- }
201
- /**
202
- * Creates a retry handler that wraps stream creation
203
- */
204
- declare function createRetryHandler(options?: RetryHandlerOptions): <T>(createStream: (attempt: number) => Promise<T>) => Promise<T>;
205
- /**
206
- * Checks if more retries should be attempted
207
- */
208
- declare function shouldRetry(error: unknown, attempt: number, maxAttempts?: number): boolean;
209
-
210
- /** Stream result type - uses default Output for text streaming. */
211
- type InferenceStreamResult = StreamTextResult<ToolSet, Output.Output<string, string, never>>;
212
- /**
213
- * @deprecated Use `InferenceStreamResult`.
214
- */
215
- type LLMStreamResult = InferenceStreamResult;
216
-
217
- /**
218
- * Custom stream result type - compatible shape from external providers.
219
- */
220
- type InferenceCustomResult = {
221
- fullStream: AsyncIterable<StreamChunk>;
222
- text: Promise<string>;
223
- usage: Promise<{
224
- inputTokens: number;
225
- outputTokens: number;
226
- totalTokens: number;
227
- }>;
228
- finishReason: Promise<string>;
229
- };
230
- /** Union type for stream results - either AI SDK or custom. */
231
- type AnyInferenceResult = InferenceStreamResult | InferenceCustomResult;
232
- /**
233
- * @deprecated Use `InferenceCustomResult`.
234
- */
235
- type CustomStreamResult = InferenceCustomResult;
236
- /**
237
- * @deprecated Use `AnyInferenceResult`.
238
- */
239
- type AnyStreamResult = AnyInferenceResult;
240
- /** Default max output tokens. */
241
- declare const DEFAULT_MAX_OUTPUT_TOKENS = 32000;
242
- /**
243
- * @deprecated Use `DEFAULT_MAX_OUTPUT_TOKENS`.
244
- */
245
- declare const OUTPUT_TOKEN_MAX = 32000;
246
- /**
247
- * @deprecated Use StreamProvider from types instead.
248
- */
249
- type CustomStreamProvider = StreamProvider;
250
- /** Control whether AI SDK tool definitions auto-execute or only expose calls. */
251
- type ToolExecutionMode = "auto" | "plan";
252
- /**
253
- * Input for model inference stream creation.
254
- */
255
- interface InferenceStreamInput {
256
- /** Session ID */
257
- sessionID: string;
258
- /** Step number within the current turn */
259
- step?: number;
260
- /** Model to use */
261
- model: LanguageModel;
262
- /** System prompt parts */
263
- system: string[];
264
- /** Messages to send */
265
- messages: ModelMessage[];
266
- /** Abort signal */
267
- abort: AbortSignal;
268
- /** Tools to use */
269
- tools: Record<string, Tool.Info>;
270
- /** Whether tools should auto-execute or only be surfaced as tool calls. */
271
- toolExecutionMode?: ToolExecutionMode;
272
- /** Working directory */
273
- cwd: string;
274
- /** Execution environment for tools */
275
- host?: ToolHost;
276
- /** Temperature */
277
- temperature?: number;
278
- /** Top-p */
279
- topP?: number;
280
- /** Max output tokens */
281
- maxOutputTokens?: number;
282
- /** Max steps (tool iterations) */
283
- maxSteps?: number;
284
- /** Reasoning level for extended-thinking models */
285
- reasoningLevel?: ReasoningLevel;
286
- /** Retry configuration */
287
- retry?: RetryConfig;
288
- /** Callback for step completion */
289
- onStepFinish?: (step: InferenceStepInfo) => void | Promise<void>;
290
- /** Custom stream provider */
291
- customStreamProvider?: StreamProvider;
292
- /** Turn tracker for automatic file baseline capture */
293
- turnTracker?: TurnTrackerContext;
294
- /** Pre-built MCP tools */
295
- mcpTools?: ToolSet;
296
- /** Intervention controller for mid-turn message injection */
297
- intervention?: InterventionController;
298
- /** Middleware runner for lifecycle hooks */
299
- middleware?: MiddlewareRunner;
300
- /** AI SDK telemetry settings */
301
- telemetry?: TelemetrySettings;
302
- /** Internal snapshot of the resolved model request after middleware input hooks. */
303
- activeModelCall?: ModelCallInput;
304
- }
305
- /**
306
- * Step information surfaced to callers.
307
- */
308
- interface InferenceStepInfo {
309
- toolResults?: Array<{
310
- toolName: string;
311
- toolCallId: string;
312
- output: unknown;
313
- }>;
314
- usage?: {
315
- inputTokens?: number;
316
- outputTokens?: number;
317
- totalTokens?: number;
318
- };
319
- finishReason?: string;
320
- }
321
- /**
322
- * @deprecated Use `InferenceStreamInput`.
323
- */
324
- type LLMStreamInput = InferenceStreamInput;
325
- /**
326
- * @deprecated Use `InferenceStepInfo`.
327
- */
328
- type StepInfo = InferenceStepInfo;
329
-
330
- export { type AnyInferenceResult as A, type CustomStreamProvider as C, DEFAULT_MAX_OUTPUT_TOKENS as D, type InferenceStreamInput as I, type LLMStreamInput as L, OUTPUT_TOKEN_MAX as O, type PendingIntervention as P, type RetryConfig as R, type StepInfo as S, type ToolExecutionMode as T, type AnyStreamResult as a, type CustomStreamResult as b, DEFAULT_RETRY_CONFIG as c, type InferenceCustomResult as d, type InferenceStepInfo as e, type InferenceStreamResult as f, type LLMStreamResult as g, type RetryHandlerOptions as h, type RetryState as i, calculateDelay as j, createRetryHandler as k, createRetryState as l, sleep as m, InterventionController as n, type OnInterventionApplied as o, shouldRetry as s, withRetry as w };
@@ -1,50 +0,0 @@
1
- import { LanguageModel } from 'ai';
2
- import { R as ReasoningLevel } from './types-CQaXbRsS.js';
3
- import { T as Tool } from './tool-CZWN3KbO.js';
4
-
5
- /**
6
- * Agent preset - a reusable configuration profile.
7
- */
8
- interface Preset {
9
- /** Unique identifier for this preset */
10
- name: string;
11
- /** Human-readable description */
12
- description: string;
13
- /**
14
- * Tool allow patterns (glob-like).
15
- * If provided, only tools matching these patterns are candidates.
16
- */
17
- allowTools?: string[];
18
- /**
19
- * Tool deny patterns (glob-like).
20
- * Deny patterns apply only after allow matching, so explicit allows win.
21
- */
22
- denyTools?: string[];
23
- /**
24
- * Override system prompt.
25
- * Use `{basePrompt}` to include the parent's system prompt.
26
- */
27
- systemPrompt?: string;
28
- /** Override temperature (0-1). */
29
- temperature?: number;
30
- /** Override max steps. */
31
- maxSteps?: number;
32
- /** Override reasoning level. */
33
- reasoningLevel?: ReasoningLevel;
34
- /** Override model. */
35
- model?: LanguageModel;
36
- }
37
- /**
38
- * Result of applying a preset - ready for `fork()`.
39
- */
40
- interface AppliedPreset {
41
- name: string;
42
- systemPrompt?: string;
43
- tools?: Tool.AnyInfo[];
44
- temperature?: number;
45
- maxSteps?: number;
46
- reasoningLevel?: ReasoningLevel;
47
- model?: LanguageModel;
48
- }
49
-
50
- export type { AppliedPreset as A, Preset as P };
@@ -1,29 +0,0 @@
1
- type ScopeKind = "task" | "turn" | "model" | "tool" | "commit" | "sub-agent" | "activity";
2
- type ScopeAttributeValue = string | number | boolean | null;
3
- type ScopeAttributes = Record<string, ScopeAttributeValue | undefined>;
4
- interface Scope {
5
- id: string;
6
- rootId: string;
7
- kind: ScopeKind;
8
- name: string;
9
- parentId?: string;
10
- depth: number;
11
- startedAt: string;
12
- sessionId?: string;
13
- taskId?: string;
14
- step?: number;
15
- attributes: ScopeAttributes;
16
- }
17
- type ScopeSnapshot = Scope;
18
- interface ScopeOptions {
19
- id?: string;
20
- kind: ScopeKind;
21
- name: string;
22
- parent?: ScopeSnapshot | null;
23
- sessionId?: string;
24
- taskId?: string;
25
- step?: number;
26
- attributes?: ScopeAttributes;
27
- }
28
-
29
- export type { ScopeSnapshot as S, Scope as a, ScopeAttributeValue as b, ScopeAttributes as c, ScopeKind as d, ScopeOptions as e };
@@ -1,55 +0,0 @@
1
- /**
2
- * Risk level for operations.
3
- */
4
- type RiskLevel = "safe" | "moderate" | "dangerous";
5
- /**
6
- * User response to an approval request.
7
- */
8
- type ApprovalAction = "allow" | "deny" | "remember";
9
- /**
10
- * Approval request sent to the UI/handler.
11
- */
12
- interface ApprovalRequest {
13
- /** Unique request ID */
14
- id: string;
15
- /** Session ID */
16
- sessionId: string;
17
- /** Tool name */
18
- tool: string;
19
- /** Tool arguments */
20
- args: unknown;
21
- /** Human-readable description */
22
- description: string;
23
- /** Risk level */
24
- risk: RiskLevel;
25
- /** Patterns that would be remembered if "remember" is chosen */
26
- patterns: string[];
27
- /** Timestamp */
28
- timestamp: number;
29
- }
30
- /**
31
- * Rule for auto-approving/denying operations.
32
- */
33
- interface ApprovalRule {
34
- /** Pattern to match (glob-style) */
35
- pattern: string;
36
- /** Tool to match (`*` for all) */
37
- tool: string;
38
- /** Action to take */
39
- action: "allow" | "deny";
40
- }
41
- /**
42
- * Configuration for the approval handler.
43
- */
44
- interface ApprovalConfig {
45
- /** Default action when no rule matches (default: "ask") */
46
- defaultAction?: "allow" | "deny" | "ask";
47
- /** Pre-configured rules */
48
- rules?: ApprovalRule[];
49
- /** Handler for approval requests */
50
- onRequest?: (request: ApprovalRequest) => Promise<ApprovalAction>;
51
- /** Timeout for approval requests in ms (default: 5 minutes) */
52
- timeout?: number;
53
- }
54
-
55
- export type { ApprovalAction as A, RiskLevel as R, ApprovalConfig as a, ApprovalRequest as b, ApprovalRule as c };