@cuylabs/agent-core 0.8.0 → 0.9.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 (68) hide show
  1. package/dist/{builder-UpOWQMW3.d.ts → builder-BgZ_j4Vs.d.ts} +2 -1
  2. package/dist/{chunk-RZITT45F.js → chunk-4QFNWPIF.js} +4 -4
  3. package/dist/{chunk-BFM2YHNM.js → chunk-5ARZJWD2.js} +74 -37
  4. package/dist/{chunk-KUVSERLJ.js → chunk-DXFBQMXP.js} +5 -2
  5. package/dist/{chunk-CAA7FHIH.js → chunk-EKR6PKXU.js} +0 -100
  6. package/dist/{chunk-IVUJDISU.js → chunk-GFTW23FV.js} +5 -14
  7. package/dist/{chunk-7VKQ4WPB.js → chunk-H3FUYU52.js} +11 -3
  8. package/dist/chunk-I6PKJ7XQ.js +292 -0
  9. package/dist/chunk-IYWQOJMQ.js +102 -0
  10. package/dist/{chunk-4BDA7DQY.js → chunk-J4QDGZIA.js} +19 -3
  11. package/dist/{chunk-7MUFEN4K.js → chunk-JLXG2SH7.js} +349 -3
  12. package/dist/{chunk-YSLSEQ6B.js → chunk-MAZ5DY5B.js} +18 -30
  13. package/dist/{chunk-P6YF7USR.js → chunk-MHKK374K.js} +12 -11
  14. package/dist/{chunk-VBWWUHWI.js → chunk-OFDKHNCX.js} +4 -1
  15. package/dist/{chunk-YUUJK53A.js → chunk-RKEW5WXI.js} +1 -1
  16. package/dist/{chunk-LRHOS4ZN.js → chunk-SPILYYDF.js} +3 -2
  17. package/dist/{chunk-RFEKJKTO.js → chunk-UDCZ673N.js} +321 -275
  18. package/dist/{chunk-BDBZ3SLK.js → chunk-UHCJEM2E.js} +39 -2
  19. package/dist/chunk-WGZAPU6N.js +929 -0
  20. package/dist/{chunk-N6HWIEEA.js → chunk-WKHDSSXG.js} +140 -23
  21. package/dist/index-BCqEGzBj.d.ts +251 -0
  22. package/dist/{index-CWSchSql.d.ts → index-DQuTZ8xL.d.ts} +290 -13
  23. package/dist/index.d.ts +23 -29
  24. package/dist/index.js +776 -490
  25. package/dist/{errors → inference/errors}/index.d.ts +2 -2
  26. package/dist/{errors → inference/errors}/index.js +1 -1
  27. package/dist/inference/index.d.ts +10 -9
  28. package/dist/inference/index.js +34 -8
  29. package/dist/middleware/index.d.ts +5 -4
  30. package/dist/middleware/index.js +3 -3
  31. package/dist/models/index.d.ts +18 -16
  32. package/dist/models/index.js +47 -11
  33. package/dist/models/reasoning/index.d.ts +4 -0
  34. package/dist/{reasoning → models/reasoning}/index.js +2 -3
  35. package/dist/plugin/index.d.ts +414 -0
  36. package/dist/plugin/index.js +32 -0
  37. package/dist/presets/index.d.ts +3 -3
  38. package/dist/presets/index.js +7 -5
  39. package/dist/prompt/index.d.ts +6 -5
  40. package/dist/prompt/index.js +3 -2
  41. package/dist/runner-CI-XeR16.d.ts +91 -0
  42. package/dist/runtime/index.d.ts +7 -6
  43. package/dist/runtime/index.js +6 -7
  44. package/dist/safety/index.d.ts +1 -1
  45. package/dist/safety/index.js +1 -1
  46. package/dist/{session-manager-B_CWGTsl.d.ts → session-manager-KbYt2WUh.d.ts} +8 -0
  47. package/dist/signal/index.js +1 -1
  48. package/dist/skill/index.d.ts +2 -2
  49. package/dist/skill/index.js +3 -3
  50. package/dist/storage/index.d.ts +2 -2
  51. package/dist/storage/index.js +1 -1
  52. package/dist/sub-agent/index.d.ts +10 -9
  53. package/dist/sub-agent/index.js +21 -4
  54. package/dist/tool/index.d.ts +19 -5
  55. package/dist/tool/index.js +2 -2
  56. package/dist/{tool-BHbyUAy3.d.ts → tool-CZWN3KbO.d.ts} +1 -10
  57. package/dist/{tool-DLXAR9Ce.d.ts → tool-DkhSCV2Y.d.ts} +1 -1
  58. package/dist/tracking/index.d.ts +1 -1
  59. package/dist/tracking/index.js +1 -1
  60. package/dist/{types-KKDrdU9Y.d.ts → types-BlOKk-Bb.d.ts} +9 -4
  61. package/dist/{types-BnpEOYV-.d.ts → types-BlZwmnuW.d.ts} +1 -1
  62. package/dist/{runner-e2YRcUoX.d.ts → types-DTSkxakL.d.ts} +3 -138
  63. package/dist/{types-QKHHQLLq.d.ts → types-DmDwi2zI.d.ts} +7 -4
  64. package/package.json +15 -9
  65. package/dist/chunk-DWYX7ASF.js +0 -26
  66. package/dist/chunk-SQU2AJHO.js +0 -305
  67. package/dist/reasoning/index.d.ts +0 -116
  68. package/dist/types-QA4WhEfz.d.ts +0 -138
@@ -0,0 +1,414 @@
1
+ import { A as AgentMiddleware, c as PromptSection } from '../types-DTSkxakL.js';
2
+ import { T as Tool } from '../tool-CZWN3KbO.js';
3
+ import { ZodType } from 'zod';
4
+ import { Jiti } from 'jiti';
5
+ import 'ai';
6
+ import '@ai-sdk/provider-utils';
7
+ import '../events-CE72w8W4.js';
8
+ import '../messages-BYWGn8TY.js';
9
+ import '../types-BfNpU8NS.js';
10
+ import '../types-CQL-SvTn.js';
11
+ import '../tool-DkhSCV2Y.js';
12
+ import '../types-CHiPh8U2.js';
13
+ import '../types-CQaXbRsS.js';
14
+
15
+ /**
16
+ * PluginEventBus — string-keyed pub/sub for inter-plugin communication.
17
+ *
18
+ * Channel names are namespaced by convention:
19
+ * "finance:transaction-created", "crm:contact-updated".
20
+ */
21
+ /** Remove a previously registered listener. */
22
+ type PluginUnsubscribe = () => void;
23
+ /** Listener function for a specific channel. */
24
+ type PluginEventHandler = (data: unknown) => void;
25
+ /**
26
+ * Minimal event bus interface. Plugins depend only on this.
27
+ */
28
+ interface PluginEventBusAPI {
29
+ emit(channel: string, data: unknown): void;
30
+ on(channel: string, handler: PluginEventHandler): PluginUnsubscribe;
31
+ }
32
+ /**
33
+ * In-process event bus. Dispatches synchronously.
34
+ * Listener errors are caught silently.
35
+ */
36
+ declare class PluginEventBus implements PluginEventBusAPI {
37
+ private readonly channels;
38
+ emit(channel: string, data: unknown): void;
39
+ on(channel: string, handler: PluginEventHandler): PluginUnsubscribe;
40
+ /** Number of active channels. */
41
+ get size(): number;
42
+ /** Remove all listeners. */
43
+ clear(): void;
44
+ }
45
+
46
+ /**
47
+ * Plugin types — contracts for the extension system.
48
+ *
49
+ * Plugins contribute tools, middleware, commands, prompt sections,
50
+ * and lifecycle hooks to an agent without coupling to a specific host.
51
+ */
52
+
53
+ /** Static metadata about a plugin (from package.json or inline). */
54
+ interface PluginCompatibility {
55
+ /** Expected plugin API version supported by the host (exact match). */
56
+ apiVersion?: string;
57
+ /** Supported Node.js version range (supports exact or comparator syntax). */
58
+ node?: string;
59
+ }
60
+ interface PluginManifest {
61
+ /** Unique plugin identifier (e.g. "brave-search", "finance") */
62
+ id: string;
63
+ /** Human-readable display name */
64
+ name?: string;
65
+ /** Short description */
66
+ description?: string;
67
+ /** SemVer string */
68
+ version?: string;
69
+ /** Compatibility requirements validated by the host at load time. */
70
+ compatibility?: PluginCompatibility;
71
+ }
72
+ /** A user-facing command registered by a plugin. Host-dependent surfacing. */
73
+ interface PluginCommand {
74
+ /** Command name (without leading slash) */
75
+ name: string;
76
+ /** Optional aliases */
77
+ alias?: string[];
78
+ /** One-line description shown in help */
79
+ summary: string;
80
+ /** Execute the command. Return the text to display, or null for silent. */
81
+ execute: (args: string) => Promise<string | null>;
82
+ }
83
+ type PluginSettingsSchema<T = unknown> = ZodType<T>;
84
+ interface PluginSettingsDefinition<T = unknown> {
85
+ /** Settings namespace. Defaults to the plugin ID. */
86
+ namespace?: string;
87
+ /** Whether missing settings are allowed. Defaults to true. */
88
+ optional?: boolean;
89
+ /** Zod schema used to validate the resolved settings object. */
90
+ schema: PluginSettingsSchema<T>;
91
+ }
92
+ /** Namespace-isolated config access. The host injects the implementation. */
93
+ interface PluginSettingsProvider {
94
+ /**
95
+ * Read the config value for a given namespace.
96
+ *
97
+ * @param namespace Plugin's config key (e.g. "brave-search")
98
+ * @returns The config object, or undefined if not configured.
99
+ */
100
+ get<T = unknown>(namespace: string): T | undefined;
101
+ /**
102
+ * Read and validate a namespace with a schema.
103
+ *
104
+ * Returns undefined when the namespace is not configured.
105
+ */
106
+ parse<T>(namespace: string, schema: PluginSettingsSchema<T>): T | undefined;
107
+ /**
108
+ * Read and validate a namespace with a schema.
109
+ *
110
+ * Throws when the namespace is missing or invalid.
111
+ */
112
+ require<T>(namespace: string, schema: PluginSettingsSchema<T>): T;
113
+ }
114
+ /** Session lifecycle hooks a plugin can register. */
115
+ interface PluginLifecycleHooks {
116
+ activate?: (ctx: PluginSessionContext) => Promise<void> | void;
117
+ deactivate?: () => Promise<void> | void;
118
+ }
119
+ /** Context available during plugin activation. */
120
+ interface PluginSessionContext {
121
+ /** Agent's working directory */
122
+ cwd: string;
123
+ /** Session ID (if session-based) */
124
+ sessionId?: string;
125
+ }
126
+ /** The API surface passed to a plugin's entry function. */
127
+ interface PluginContext {
128
+ /** Working directory of the agent (project root) */
129
+ cwd: string;
130
+ /** Plugin's own manifest (id, name, version). Read-only. */
131
+ manifest: Readonly<PluginManifest>;
132
+ /** Register a tool the LLM can call */
133
+ addTool(tool: Tool.AnyInfo): void;
134
+ /** Register middleware (model hooks, tool guards, prompt sections) */
135
+ addMiddleware(mw: AgentMiddleware): void;
136
+ /** Register a user-facing command (host-dependent) */
137
+ addCommand(cmd: PluginCommand): void;
138
+ /** Add a dynamic prompt section injected at system-prompt build time. */
139
+ addPromptSection(section: PromptSection): void;
140
+ /** Inter-plugin event bus (string-keyed pub/sub). */
141
+ events: PluginEventBus;
142
+ /** Plugin-namespaced settings from the host. */
143
+ settings: PluginSettingsProvider;
144
+ /** Register an activation hook (fires when the agent session starts). */
145
+ onActivate(fn: (ctx: PluginSessionContext) => Promise<void> | void): void;
146
+ /** Register a deactivation hook (fires when the agent session ends). */
147
+ onDeactivate(fn: () => Promise<void> | void): void;
148
+ }
149
+ /** The function shape a plugin file must default-export. */
150
+ type PluginInit = (ctx: PluginContext) => void | Promise<void>;
151
+ /** Aggregated contributions from all loaded plugins. */
152
+ interface PluginContributions {
153
+ /** Tools to add to the agent's tool set */
154
+ tools: Tool.AnyInfo[];
155
+ /** Middleware to prepend to the agent's middleware stack */
156
+ middleware: AgentMiddleware[];
157
+ /** User-facing commands (host-dependent surfacing) */
158
+ commands: PluginCommand[];
159
+ /** Dynamic prompt sections */
160
+ promptSections: PromptSection[];
161
+ /** Loader / plugin errors (non-fatal — the rest of the system keeps working) */
162
+ errors: Array<{
163
+ pluginId: string;
164
+ error: string;
165
+ }>;
166
+ }
167
+
168
+ /**
169
+ * Plugin settings — namespace-isolated layered configuration.
170
+ */
171
+
172
+ /** Settings provider that always returns undefined. */
173
+ declare class NullSettings implements PluginSettingsProvider {
174
+ get<T = unknown>(_namespace: string): T | undefined;
175
+ parse<T>(_namespace: string, _schema: PluginSettingsSchema<T>): T | undefined;
176
+ require<T>(namespace: string, _schema: PluginSettingsSchema<T>): T;
177
+ }
178
+ /** Settings provider backed by a plain object. Top-level keys are plugin namespaces. */
179
+ declare class StaticSettings implements PluginSettingsProvider {
180
+ private readonly data;
181
+ constructor(data: Record<string, unknown>);
182
+ get<T = unknown>(namespace: string): T | undefined;
183
+ parse<T>(namespace: string, schema: PluginSettingsSchema<T>): T | undefined;
184
+ require<T>(namespace: string, schema: PluginSettingsSchema<T>): T;
185
+ }
186
+ /** Merges multiple settings sources in priority order (later layers win). */
187
+ declare class LayeredSettings implements PluginSettingsProvider {
188
+ private readonly layers;
189
+ constructor(layers: PluginSettingsProvider[]);
190
+ get<T = unknown>(namespace: string): T | undefined;
191
+ parse<T>(namespace: string, schema: PluginSettingsSchema<T>): T | undefined;
192
+ require<T>(namespace: string, schema: PluginSettingsSchema<T>): T;
193
+ }
194
+ /** Wraps a provider with validated overrides for specific namespaces. */
195
+ declare class ValidatedSettings implements PluginSettingsProvider {
196
+ private readonly base;
197
+ private readonly overrides;
198
+ constructor(base: PluginSettingsProvider, overrides: Record<string, unknown>);
199
+ get<T = unknown>(namespace: string): T | undefined;
200
+ parse<T>(namespace: string, schema: PluginSettingsSchema<T>): T | undefined;
201
+ require<T>(namespace: string, schema: PluginSettingsSchema<T>): T;
202
+ }
203
+
204
+ /**
205
+ * Plugin loader — filesystem discovery and dynamic import via jiti.
206
+ *
207
+ * Scans `.cuylabs/plugins/` and explicit paths for plugin entries.
208
+ * Files starting with `_` are ignored. Each plugin must default-export
209
+ * a PluginInit function.
210
+ *
211
+ * Uses jiti for TypeScript-native loading — users drop raw `.ts` files
212
+ * and they work without a build step. Transpiled output is cached to
213
+ * disk for fast subsequent loads.
214
+ *
215
+ * Framework packages (`@cuylabs/*`) are auto-aliased so plugins can
216
+ * `import { ... } from "@cuylabs/agent-core"` without any user config.
217
+ * Resolution uses `import.meta.resolve` (ESM standard) with a monorepo
218
+ * workspace fallback for development.
219
+ */
220
+
221
+ /** Options for configuring the plugin loader's jiti instance. */
222
+ interface PluginLoaderOptions {
223
+ /** Extra module aliases (e.g. `{ "@my-lib": "./src/lib" }`). */
224
+ alias?: Record<string, string>;
225
+ /** Modules to skip transforming (already compiled). */
226
+ nativeModules?: string[];
227
+ /** Enable source maps in error stacks (default: true). */
228
+ sourceMaps?: boolean;
229
+ /** Enable jiti debug logging (default: false). */
230
+ debug?: boolean;
231
+ /**
232
+ * Disable automatic `@cuylabs/*` alias resolution.
233
+ * When false, plugins must resolve framework packages on their own.
234
+ * @default true
235
+ */
236
+ autoAlias?: boolean;
237
+ }
238
+ /**
239
+ * Auto-resolve `@cuylabs/*` packages to their filesystem paths.
240
+ *
241
+ * Uses two strategies in order:
242
+ * 1. `import.meta.resolve(specifier)` — standard ESM resolution.
243
+ * Works when packages are in node_modules (installed via npm/pnpm).
244
+ * 2. Monorepo workspace fallback — walk up from this file to find
245
+ * the workspace root, then check `packages/<name>/dist/index.js`.
246
+ *
247
+ * Results are cached for the process lifetime.
248
+ */
249
+ declare function resolveFrameworkAliases(): Record<string, string>;
250
+ /** Reset cached framework aliases (for testing). */
251
+ declare function resetFrameworkAliases(): void;
252
+ /** Get or create a shared jiti instance for plugin loading. */
253
+ declare function getPluginLoader(options?: PluginLoaderOptions): Jiti;
254
+ /** Reset the shared jiti instance (for testing). */
255
+ declare function resetPluginLoader(): void;
256
+ /** A discovered plugin file with its resolved entry path and manifest. */
257
+ interface DiscoveredPlugin {
258
+ entryPath: string;
259
+ manifest: PluginManifest;
260
+ }
261
+ /** Discover plugin files on disk from convention dir and explicit paths. */
262
+ declare function discoverPlugins(cwd: string, extraPaths?: string[]): Promise<DiscoveredPlugin[]>;
263
+ /** Dynamically import a plugin file and extract its init function. */
264
+ declare function loadPluginModule(entryPath: string, options?: PluginLoaderOptions): Promise<PluginInit>;
265
+
266
+ /**
267
+ * Declarative plugin authoring — `definePlugin()`.
268
+ *
269
+ * Converts a static plugin definition into a `PluginInit` function.
270
+ * The registry and imperative layer stay unchanged; this is sugar
271
+ * that makes plugins inspectable, type-safe, and easier to author.
272
+ */
273
+
274
+ /** Declarative plugin definition passed to `definePlugin()`. */
275
+ interface PluginDefinition {
276
+ /** Unique plugin identifier. */
277
+ id: string;
278
+ /** Human-readable display name. */
279
+ name?: string;
280
+ /** Short description. */
281
+ description?: string;
282
+ /** SemVer string. */
283
+ version?: string;
284
+ /** Host/runtime compatibility validated before the plugin is committed. */
285
+ compatibility?: PluginCompatibility;
286
+ /** Optional settings schema to validate before the plugin is committed. */
287
+ settings?: PluginSettingsDefinition;
288
+ /** Tools the LLM can call. Statically declared — inspectable without execution. */
289
+ tools?: Tool.AnyInfo[];
290
+ /** Middleware hooks (model I/O, tool guards, prompt sections). */
291
+ middleware?: AgentMiddleware[];
292
+ /** User-facing commands. */
293
+ commands?: PluginCommand[];
294
+ /** Dynamic prompt sections injected at system-prompt build time. */
295
+ promptSections?: PromptSection[];
296
+ /**
297
+ * Imperative activation hook — runs when the agent session starts.
298
+ * Use for dynamic setup that can't be expressed declaratively
299
+ * (starting servers, loading config, managing state).
300
+ */
301
+ activate?: (ctx: PluginActivateContext) => Promise<void> | void;
302
+ /**
303
+ * Imperative deactivation hook — runs when the agent session ends.
304
+ */
305
+ deactivate?: () => Promise<void> | void;
306
+ /**
307
+ * Full imperative escape hatch — runs during plugin loading.
308
+ * Receives the raw PluginContext for anything the declarative
309
+ * fields can't express. Runs after all declarative contributions
310
+ * have been registered.
311
+ */
312
+ setup?: (ctx: PluginContext) => void | Promise<void>;
313
+ }
314
+ /** Context passed to the declarative `activate` hook. */
315
+ interface PluginActivateContext extends PluginSessionContext {
316
+ /** The plugin's own event bus. */
317
+ events: PluginContext["events"];
318
+ /** The plugin's settings provider. */
319
+ settings: PluginContext["settings"];
320
+ }
321
+ /**
322
+ * Create a plugin from a declarative definition.
323
+ *
324
+ * Returns a `PluginInit` function that the registry executes normally.
325
+ * The definition object is attached as `init.__definition` so the
326
+ * registry can inspect it without running the plugin.
327
+ */
328
+ declare function definePlugin(def: PluginDefinition): PluginInit;
329
+ /** A PluginInit created by `definePlugin()` — carries the static definition. */
330
+ interface DefinePluginInit extends PluginInit {
331
+ __definition: PluginDefinition;
332
+ }
333
+ /** Type guard: check if a PluginInit was created by `definePlugin()`. */
334
+ declare function isDefinedPlugin(init: PluginInit): init is DefinePluginInit;
335
+
336
+ /**
337
+ * PluginRegistry — orchestrates the full plugin lifecycle.
338
+ *
339
+ * `loadAll` → `activate` → (agent runs) → `deactivate`.
340
+ * Owns the shared PluginEventBus and wires isolated PluginContext per plugin.
341
+ */
342
+
343
+ interface PluginRegistryCompatibilityOptions {
344
+ /** Supported plugin API version (exact match). */
345
+ apiVersion?: string;
346
+ /** Runtime Node.js version. Defaults to the current process version. */
347
+ nodeVersion?: string;
348
+ }
349
+ interface PluginRegistryTimeoutOptions {
350
+ /** Maximum time allowed for a plugin init function. */
351
+ load?: number | false;
352
+ /** Maximum time allowed per activation hook. */
353
+ activate?: number | false;
354
+ /** Maximum time allowed per deactivation hook. */
355
+ deactivate?: number | false;
356
+ }
357
+ interface PluginRegistryOptions {
358
+ /** Settings provider. Defaults to NullSettings (no config). */
359
+ settings?: PluginSettingsProvider;
360
+ /** Shared event bus. A fresh one is created if omitted. */
361
+ events?: PluginEventBus;
362
+ /** Options for the jiti-powered plugin loader. */
363
+ loader?: PluginLoaderOptions;
364
+ /** Host compatibility context used to reject incompatible plugins. */
365
+ compatibility?: PluginRegistryCompatibilityOptions;
366
+ /** Timeouts applied to init and lifecycle hooks. */
367
+ timeouts?: PluginRegistryTimeoutOptions;
368
+ }
369
+ declare class PluginRegistry {
370
+ private readonly settings;
371
+ private readonly eventBus;
372
+ private readonly loaderOptions;
373
+ private readonly compatibilityContext;
374
+ private readonly timeouts;
375
+ private readonly plugins;
376
+ private readonly pluginIds;
377
+ private readonly commandOwners;
378
+ private readonly commandTokens;
379
+ private readonly _contributions;
380
+ private activated;
381
+ private activeSessionContext?;
382
+ constructor(options?: PluginRegistryOptions);
383
+ /** The shared event bus wired to all loaded plugins. */
384
+ get events(): PluginEventBus;
385
+ /** Read-only view of everything plugins have contributed. */
386
+ get contributions(): Readonly<PluginContributions>;
387
+ /** Number of successfully loaded plugins. */
388
+ get pluginCount(): number;
389
+ /** Get the static definition for a plugin (if it used `definePlugin()`). */
390
+ getDefinition(pluginId: string): PluginDefinition | undefined;
391
+ /** Get all static definitions (only for declarative plugins). */
392
+ get definitions(): ReadonlyArray<Readonly<PluginDefinition>>;
393
+ /** Get the plugin ID that contributed a command. */
394
+ getCommandOwner(command: PluginCommand): string | undefined;
395
+ /** Record a host-level plugin error without throwing. */
396
+ recordError(pluginId: string, error: string): void;
397
+ /** Discover, load, and execute all plugins. */
398
+ loadAll(cwd: string, extraPaths?: string[]): Promise<void>;
399
+ /** Load a single plugin from its init function (programmatic / tests). */
400
+ loadOne(init: PluginInit, manifest: PluginManifest, cwd: string, entryPath?: string): Promise<void>;
401
+ /** Fire `onActivate` hooks sequentially in load order. */
402
+ activate(ctx: PluginSessionContext): Promise<void>;
403
+ /** Fire `onDeactivate` hooks in reverse load order. */
404
+ deactivate(): Promise<void>;
405
+ private executePlugin;
406
+ private resolvePluginSettings;
407
+ private findCommandConflict;
408
+ private checkCommandTokenConflict;
409
+ private commitPlugin;
410
+ private runActivateHooks;
411
+ private runDeactivateHooks;
412
+ }
413
+
414
+ export { type DefinePluginInit, type DiscoveredPlugin, LayeredSettings, NullSettings, type PluginActivateContext, type PluginCommand, type PluginCompatibility, type PluginContext, type PluginContributions, type PluginDefinition, PluginEventBus, type PluginEventBusAPI, type PluginEventHandler, type PluginInit, type PluginLifecycleHooks, type PluginLoaderOptions, type PluginManifest, PluginRegistry, type PluginRegistryCompatibilityOptions, type PluginRegistryOptions, type PluginRegistryTimeoutOptions, type PluginSessionContext, type PluginSettingsDefinition, type PluginSettingsProvider, type PluginSettingsSchema, type PluginUnsubscribe, StaticSettings, ValidatedSettings, definePlugin, discoverPlugins, getPluginLoader, isDefinedPlugin, loadPluginModule, resetFrameworkAliases, resetPluginLoader, resolveFrameworkAliases };
@@ -0,0 +1,32 @@
1
+ import {
2
+ LayeredSettings,
3
+ NullSettings,
4
+ PluginEventBus,
5
+ PluginRegistry,
6
+ StaticSettings,
7
+ ValidatedSettings,
8
+ definePlugin,
9
+ discoverPlugins,
10
+ getPluginLoader,
11
+ isDefinedPlugin,
12
+ loadPluginModule,
13
+ resetFrameworkAliases,
14
+ resetPluginLoader,
15
+ resolveFrameworkAliases
16
+ } from "../chunk-WGZAPU6N.js";
17
+ export {
18
+ LayeredSettings,
19
+ NullSettings,
20
+ PluginEventBus,
21
+ PluginRegistry,
22
+ StaticSettings,
23
+ ValidatedSettings,
24
+ definePlugin,
25
+ discoverPlugins,
26
+ getPluginLoader,
27
+ isDefinedPlugin,
28
+ loadPluginModule,
29
+ resetFrameworkAliases,
30
+ resetPluginLoader,
31
+ resolveFrameworkAliases
32
+ };
@@ -1,9 +1,9 @@
1
- import { P as Preset, A as AppliedPreset } from '../types-BnpEOYV-.js';
2
- import { T as Tool } from '../tool-BHbyUAy3.js';
1
+ import { P as Preset, A as AppliedPreset } from '../types-BlZwmnuW.js';
2
+ import { T as Tool } from '../tool-CZWN3KbO.js';
3
3
  import 'ai';
4
4
  import '../types-CQaXbRsS.js';
5
5
  import 'zod';
6
- import '../tool-DLXAR9Ce.js';
6
+ import '../tool-DkhSCV2Y.js';
7
7
  import '../types-CHiPh8U2.js';
8
8
  import '../types-CQL-SvTn.js';
9
9
 
@@ -1,17 +1,19 @@
1
1
  import {
2
- Presets,
3
2
  applyPreset,
3
+ createPreset,
4
+ filterTools,
5
+ mergePresets
6
+ } from "../chunk-IYWQOJMQ.js";
7
+ import {
8
+ Presets,
4
9
  careful,
5
10
  code,
6
- createPreset,
7
11
  explore,
8
- filterTools,
9
- mergePresets,
10
12
  plan,
11
13
  quick,
12
14
  review,
13
15
  watch
14
- } from "../chunk-CAA7FHIH.js";
16
+ } from "../chunk-EKR6PKXU.js";
15
17
  export {
16
18
  Presets,
17
19
  applyPreset,
@@ -1,18 +1,19 @@
1
- import { c as ModelFamily, g as EnvironmentInfo, I as InstructionFile } from '../runner-e2YRcUoX.js';
2
- export { a as PromptBuildContext, P as PromptConfig, b as PromptSection } from '../runner-e2YRcUoX.js';
1
+ import { e as ModelFamily, h as EnvironmentInfo, I as InstructionFile } from '../types-DTSkxakL.js';
2
+ export { P as PromptBuildContext, d as PromptConfig, c as PromptSection } from '../types-DTSkxakL.js';
3
3
  import { LanguageModel } from 'ai';
4
- export { P as PromptBuilder, c as createPromptBuilder } from '../builder-UpOWQMW3.js';
4
+ export { P as PromptBuilder, c as createPromptBuilder } from '../builder-BgZ_j4Vs.js';
5
5
  export { d as SkillConfig } from '../types-BfNpU8NS.js';
6
6
  import '@ai-sdk/provider-utils';
7
7
  import '../events-CE72w8W4.js';
8
8
  import '../messages-BYWGn8TY.js';
9
9
  import '../types-CQL-SvTn.js';
10
- import '../tool-DLXAR9Ce.js';
10
+ import '../tool-DkhSCV2Y.js';
11
11
  import '../types-CHiPh8U2.js';
12
- import '../tool-BHbyUAy3.js';
12
+ import '../tool-CZWN3KbO.js';
13
13
  import 'zod';
14
14
  import '../types-CQaXbRsS.js';
15
15
  import '../registry-DwYqsQkX.js';
16
+ import '../runner-CI-XeR16.js';
16
17
 
17
18
  /**
18
19
  * Prompt Templates — Base system prompts per model family
@@ -19,8 +19,9 @@ import {
19
19
  getTemplate,
20
20
  loadGlobalInstructions,
21
21
  summarizeEnvironment
22
- } from "../chunk-IVUJDISU.js";
23
- import "../chunk-LRHOS4ZN.js";
22
+ } from "../chunk-GFTW23FV.js";
23
+ import "../chunk-SPILYYDF.js";
24
+ import "../chunk-I6PKJ7XQ.js";
24
25
  export {
25
26
  DEFAULT_INSTRUCTION_PATTERNS,
26
27
  DEFAULT_MAX_DEPTH,
@@ -0,0 +1,91 @@
1
+ import { A as AgentMiddleware, M as ModelCallInput, a as ModelCallContext, B as BlockedModelCall, S as StreamChunk, b as ModelCallOutput, T as ToolCallDecision, P as PromptBuildContext, c as PromptSection } from './types-DTSkxakL.js';
2
+ import { A as AgentEvent } from './events-CE72w8W4.js';
3
+ import { T as TokenUsage } from './messages-BYWGn8TY.js';
4
+ import { T as ToolContext } from './tool-DkhSCV2Y.js';
5
+ import { T as Tool } from './tool-CZWN3KbO.js';
6
+
7
+ /**
8
+ * Middleware Runner
9
+ *
10
+ * Executes middleware hooks in the correct order with proper
11
+ * error handling and short-circuit semantics.
12
+ *
13
+ * This is the internal engine — consumers never see it.
14
+ * They interact with middleware through AgentConfig.middleware.
15
+ */
16
+
17
+ /**
18
+ * Middleware runner — holds an ordered list of middleware and
19
+ * exposes methods to run each hook type with correct semantics.
20
+ *
21
+ * Immutable after construction. Fork creates a new runner
22
+ * (with inherited + additional middleware).
23
+ */
24
+ declare class MiddlewareRunner {
25
+ private readonly stack;
26
+ constructor(middleware?: AgentMiddleware[]);
27
+ /** Number of registered middleware */
28
+ get count(): number;
29
+ /** Whether any middleware is registered */
30
+ get hasMiddleware(): boolean;
31
+ /** Get the middleware list (for fork inheritance) */
32
+ getMiddleware(): readonly AgentMiddleware[];
33
+ runModelInput(input: ModelCallInput, ctx: ModelCallContext): Promise<ModelCallInput | BlockedModelCall>;
34
+ runModelChunk(chunk: StreamChunk, ctx: ModelCallContext): Promise<StreamChunk | undefined>;
35
+ runModelOutput(output: ModelCallOutput, ctx: ModelCallContext): Promise<ModelCallOutput>;
36
+ /**
37
+ * Run all `beforeToolCall` hooks in order.
38
+ *
39
+ * Returns `{ action: "allow" }` if all middleware allow (or have no hook).
40
+ * Returns `{ action: "deny", reason }` on first denial — remaining
41
+ * middleware are skipped.
42
+ */
43
+ runBeforeToolCall(tool: string, args: unknown, ctx: ToolContext): Promise<ToolCallDecision>;
44
+ /**
45
+ * Run all `afterToolCall` hooks in reverse order.
46
+ *
47
+ * Each hook receives the result from the previous hook (or the
48
+ * original tool result for the first hook). Errors are caught
49
+ * and logged — the original result passes through.
50
+ */
51
+ runAfterToolCall(tool: string, args: unknown, result: Tool.ExecuteResult, ctx: ToolContext): Promise<Tool.ExecuteResult>;
52
+ /**
53
+ * Collect prompt sections from all middleware.
54
+ *
55
+ * Returns a flat array of sections. Each middleware can return a single
56
+ * section, an array of sections, or undefined/empty.
57
+ */
58
+ collectPromptSections(ctx: PromptBuildContext): PromptSection[];
59
+ /**
60
+ * Broadcast an event to all middleware observers.
61
+ *
62
+ * Non-blocking — errors are caught and logged. This never
63
+ * slows down the streaming pipeline.
64
+ */
65
+ emitEvent(event: AgentEvent): void;
66
+ /**
67
+ * Get the OTel context for a session from the telemetry middleware.
68
+ * Returns undefined if no telemetry middleware is registered.
69
+ */
70
+ getOtelContext(sessionId: string): unknown | undefined;
71
+ /**
72
+ * Run all `onChatStart` hooks in order.
73
+ *
74
+ * Errors are caught and logged — a broken logger should not
75
+ * prevent the chat from starting.
76
+ */
77
+ runChatStart(sessionId: string, message: string): Promise<void>;
78
+ /**
79
+ * Run all `onChatEnd` hooks in order.
80
+ *
81
+ * Always called, even when the stream errored. Errors in handlers
82
+ * are caught and logged.
83
+ */
84
+ runChatEnd(sessionId: string, result: {
85
+ usage?: TokenUsage;
86
+ error?: Error;
87
+ output?: string;
88
+ }): Promise<void>;
89
+ }
90
+
91
+ export { MiddlewareRunner as M };
@@ -1,15 +1,16 @@
1
1
  import { A as AgentEvent } from '../events-CE72w8W4.js';
2
2
  import { T as TokenUsage, M as Message } from '../messages-BYWGn8TY.js';
3
3
  import { S as ScopeSnapshot } from '../types-CQL-SvTn.js';
4
- import { S as StepProcessingOptions, z as StepProcessingOutput, l as AgentTurnStepCommitSnapshot, r as CreateAgentTurnStepCommitBatchOptions, d as AgentTurnCommitBatch, P as PrepareModelStepOptions, u as PreparedAgentModelStep, R as RunModelStepOptions, x as RunToolBatchOptions, y as RunToolBatchResult, C as CommitOutputOptions, p as CommitStepOptions, j as AgentTurnState, n as AgentTurnStepCommitToolResult, m as AgentTurnStepCommitToolCall } from '../types-QKHHQLLq.js';
5
- export { A as AgentTurnActiveToolCall, a as AgentTurnBoundaryMetadata, b as AgentTurnBoundarySnapshot, c as AgentTurnCommitApplier, e as AgentTurnCommitOptions, f as AgentTurnEngine, g as AgentTurnEngineOptions, h as AgentTurnPhase, i as AgentTurnResolvedToolCall, k as AgentTurnStateAdvanceOptions, o as AgentTurnStepRuntimeConfig, q as CreateAgentTurnStateOptions, v as ProcessorOptions, w as ProcessorOutput, B as advanceAgentTurnState, E as createAgentTurnEngine, F as createAgentTurnState, G as failAgentTurnState } from '../types-QKHHQLLq.js';
6
- import { A as AnyInferenceResult } from '../types-KKDrdU9Y.js';
4
+ import { S as StepProcessingOptions, z as StepProcessingOutput, l as AgentTurnStepCommitSnapshot, r as CreateAgentTurnStepCommitBatchOptions, d as AgentTurnCommitBatch, P as PrepareModelStepOptions, u as PreparedAgentModelStep, R as RunModelStepOptions, x as RunToolBatchOptions, y as RunToolBatchResult, C as CommitOutputOptions, p as CommitStepOptions, j as AgentTurnState, n as AgentTurnStepCommitToolResult, m as AgentTurnStepCommitToolCall } from '../types-DmDwi2zI.js';
5
+ export { A as AgentTurnActiveToolCall, a as AgentTurnBoundaryMetadata, b as AgentTurnBoundarySnapshot, c as AgentTurnCommitApplier, e as AgentTurnCommitOptions, f as AgentTurnEngine, g as AgentTurnEngineOptions, h as AgentTurnPhase, i as AgentTurnResolvedToolCall, k as AgentTurnStateAdvanceOptions, o as AgentTurnStepRuntimeConfig, q as CreateAgentTurnStateOptions, v as ProcessorOptions, w as ProcessorOutput, B as advanceAgentTurnState, E as createAgentTurnEngine, F as createAgentTurnState, G as failAgentTurnState } from '../types-DmDwi2zI.js';
6
+ import { A as AnyInferenceResult } from '../types-BlOKk-Bb.js';
7
7
  import { ModelMessage } from 'ai';
8
- import '../tool-BHbyUAy3.js';
8
+ import '../tool-CZWN3KbO.js';
9
9
  import 'zod';
10
- import '../tool-DLXAR9Ce.js';
10
+ import '../tool-DkhSCV2Y.js';
11
11
  import '../types-CHiPh8U2.js';
12
- import '../runner-e2YRcUoX.js';
12
+ import '../runner-CI-XeR16.js';
13
+ import '../types-DTSkxakL.js';
13
14
  import '@ai-sdk/provider-utils';
14
15
  import '../types-BfNpU8NS.js';
15
16
  import '../types-CQaXbRsS.js';
@@ -30,16 +30,15 @@ import {
30
30
  runToolBatch,
31
31
  snapshotAgentWorkflowMessage,
32
32
  snapshotAgentWorkflowMessages
33
- } from "../chunk-4BDA7DQY.js";
33
+ } from "../chunk-J4QDGZIA.js";
34
34
  import "../chunk-WWYYNWEW.js";
35
- import "../chunk-N6HWIEEA.js";
36
- import "../chunk-7VKQ4WPB.js";
35
+ import "../chunk-WKHDSSXG.js";
36
+ import "../chunk-H3FUYU52.js";
37
37
  import "../chunk-VEKUXUVF.js";
38
- import "../chunk-SQU2AJHO.js";
38
+ import "../chunk-4QFNWPIF.js";
39
39
  import "../chunk-N7P4PN3O.js";
40
- import "../chunk-RZITT45F.js";
41
- import "../chunk-RFEKJKTO.js";
42
- import "../chunk-DWYX7ASF.js";
40
+ import "../chunk-UDCZ673N.js";
41
+ import "../chunk-I6PKJ7XQ.js";
43
42
  export {
44
43
  AgentTurnEngine,
45
44
  ContextOverflowError,
@@ -28,7 +28,7 @@ declare class ApprovalTimeoutError extends Error {
28
28
  */
29
29
  declare function createApprovalHandler(config?: ApprovalConfig): {
30
30
  request: (sessionId: string, tool: string, args: unknown, customRisks?: Record<string, RiskLevel>) => Promise<void>;
31
- cancelAll: (reason?: string) => void;
31
+ cancelAll: (_reason?: string) => void;
32
32
  addRule: (rule: ApprovalRule) => void;
33
33
  getRules: () => readonly ApprovalRule[];
34
34
  clearSessionRules: () => void;