@robota-sdk/agent-core 3.0.0-beta.83 → 3.0.0-beta.84

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 (46) hide show
  1. package/CHANGELOG.md +47 -0
  2. package/README.md +154 -116
  3. package/dist/browser/bounded-output-D3cgiOrh.js +2 -0
  4. package/dist/browser/bounded-output-D3cgiOrh.js.map +1 -0
  5. package/dist/browser/{command-executor-cI7XJ374.js → command-executor-BsBTcghZ.js} +2 -2
  6. package/dist/browser/{command-executor-cI7XJ374.js.map → command-executor-BsBTcghZ.js.map} +1 -1
  7. package/dist/browser/index.d.ts +1206 -902
  8. package/dist/browser/index.d.ts.map +1 -1
  9. package/dist/browser/index.js +11 -11
  10. package/dist/browser/index.js.map +1 -1
  11. package/dist/node/bounded-output-D3cgiOrh.js +2 -0
  12. package/dist/node/bounded-output-D3cgiOrh.js.map +1 -0
  13. package/dist/node/{command-executor-DV-H2oD6.js → command-executor-BdE1zg3q.js} +2 -2
  14. package/dist/node/{command-executor-DV-H2oD6.js.map → command-executor-BdE1zg3q.js.map} +1 -1
  15. package/dist/node/{command-executor-Aat_q7P2.cjs → command-executor-CPGK8I8l.cjs} +1 -1
  16. package/dist/node/{http-executor-71JiIdFP.cjs → http-executor-BYiKn8h3.cjs} +1 -1
  17. package/dist/node/{index-D1_Mak-n.d.cts → index-DXZ-pyEr.d.ts} +1207 -902
  18. package/dist/node/index-DXZ-pyEr.d.ts.map +1 -0
  19. package/dist/node/{index-D4iJ5IsN.d.ts → index-gEUh4G-t.d.cts} +1207 -902
  20. package/dist/node/index-gEUh4G-t.d.cts.map +1 -0
  21. package/dist/node/index.cjs +9 -9
  22. package/dist/node/index.d.cts +3 -3
  23. package/dist/node/index.d.ts +3 -3
  24. package/dist/node/index.js +9 -9
  25. package/dist/node/index.js.map +1 -1
  26. package/dist/node/node.cjs +1 -1
  27. package/dist/node/node.d.cts +1 -1
  28. package/dist/node/node.d.ts +1 -1
  29. package/dist/node/node.js +1 -1
  30. package/dist/node/testing/index.d.cts +1 -1
  31. package/dist/node/testing/index.d.ts +1 -1
  32. package/dist/node/{types-gNrckgFE.d.ts → types-BQ-sKCQS.d.cts} +3 -4
  33. package/dist/node/types-BQ-sKCQS.d.cts.map +1 -0
  34. package/dist/node/{types-gNrckgFE.d.cts → types-BQ-sKCQS.d.ts} +3 -4
  35. package/dist/node/types-BQ-sKCQS.d.ts.map +1 -0
  36. package/dist/node/verdict-decoder-D412SAGd.cjs +1 -0
  37. package/package.json +3 -3
  38. package/dist/browser/bounded-output-DpjpS98g.js +0 -2
  39. package/dist/browser/bounded-output-DpjpS98g.js.map +0 -1
  40. package/dist/node/bounded-output-DpjpS98g.js +0 -2
  41. package/dist/node/bounded-output-DpjpS98g.js.map +0 -1
  42. package/dist/node/index-D1_Mak-n.d.cts.map +0 -1
  43. package/dist/node/index-D4iJ5IsN.d.ts.map +0 -1
  44. package/dist/node/types-gNrckgFE.d.cts.map +0 -1
  45. package/dist/node/types-gNrckgFE.d.ts.map +0 -1
  46. package/dist/node/verdict-decoder-Estx9MtY.cjs +0 -1
@@ -61,146 +61,37 @@ declare const TypeUtils: {
61
61
  isUniversalValue: (value: TUniversalValue) => value is TUniversalValue;
62
62
  };
63
63
  //#endregion
64
- //#region src/interfaces/cache.d.ts
65
- /**
66
- * Cache key identifying a unique LLM execution request
67
- */
68
- interface ICacheKey {
69
- /** SHA-256 hash of the serialized request */
70
- hash: string;
71
- /** Model identifier */
72
- model: string;
73
- /** Provider name */
74
- provider: string;
75
- }
76
- /**
77
- * Cached LLM response entry
78
- */
79
- interface ICacheEntry {
80
- /** Cache key that produced this entry */
81
- key: ICacheKey;
82
- /** Cached response content */
83
- response: string;
84
- /** When the entry was cached */
85
- timestamp: number;
86
- /** SHA-256 integrity hash of the response */
87
- integrityHash: string;
88
- }
89
- /**
90
- * Cache storage interface for pluggable backends
91
- */
92
- interface ICacheStorage {
93
- /** Retrieve a cached entry by key hash */
94
- get(hash: string): ICacheEntry | undefined;
95
- /** Store a cache entry */
96
- set(entry: ICacheEntry): void;
97
- /** Delete a cached entry by key hash */
98
- delete(hash: string): boolean;
99
- /** Clear all cached entries */
100
- clear(): void;
101
- /** Get cache statistics */
102
- getStats(): ICacheStats;
103
- }
104
- /**
105
- * Cache performance statistics
106
- */
107
- interface ICacheStats {
108
- /** Number of cache hits */
109
- hits: number;
110
- /** Number of cache misses */
111
- misses: number;
112
- /** Current number of cached entries */
113
- entries: number;
114
- /** Hit rate (hits / (hits + misses)), 0 if no lookups */
115
- hitRate: number;
64
+ //#region src/interfaces/tool-continuation.d.ts
65
+ /** Core-owned identity, independent of a provider's reusable tool-call identifier. */
66
+ interface IToolActionIdentity {
67
+ executionId: string;
68
+ actionId: string;
69
+ parentCallId: string;
70
+ toolCallId: string;
71
+ toolName: string;
116
72
  }
117
- /**
118
- * Configuration options for execution caching
119
- */
120
- interface ICacheOptions {
121
- /** Whether caching is enabled */
122
- enabled: boolean;
123
- /** Maximum number of cached entries */
124
- maxEntries: number;
125
- /** Time-to-live in milliseconds */
126
- ttlMs: number;
73
+ interface IToolContinuationPrompt {
74
+ kind: string;
75
+ data: TToolParameters;
127
76
  }
128
- //#endregion
129
- //#region src/interfaces/interaction.d.ts
130
- /**
131
- * UI-agnostic "ask the user" contract (CMD-004).
132
- *
133
- * The SSOT for the interaction action lives in agent-core so every interaction *source* can reach it:
134
- * command execution (`ICommandHostContext`, agent-framework) AND tool execution
135
- * (`IToolExecutionContext`, agent-core, for model-issued questions — CMD-005). These are pure types
136
- * with no runtime dependency, so the contract crosses a serialization/transport boundary unchanged
137
- * (no function-valued fields).
138
- *
139
- * A single shape covers every interaction kind, parameterised by fields rather than split into
140
- * variants:
141
- * - confirm → two options, `maxSelect` 1
142
- * - single → options, `maxSelect` 1
143
- * - multi → options, `maxSelect` > 1
144
- * - free text → no options, `allowFreeText` true
145
- * - secret → free text with `masked` true
146
- */
147
- /** One predefined option the user can choose. */
148
- interface IActionOption {
149
- value: string;
150
- label: string;
151
- description?: string;
77
+ interface IToolWaitRequest extends IToolActionIdentity, IToolContinuationPrompt {
78
+ requestId: string;
152
79
  }
153
- /** Pre-selected option values and/or prefilled free text for an action request. */
154
- interface IActionDefault {
155
- values?: readonly string[];
156
- text?: string;
80
+ interface IToolWaitResponse {
81
+ requestId: string;
82
+ responseId: string;
83
+ response: TToolParameters;
157
84
  }
158
- /** One request for the user to answer. See the module doc for how the fields encode each kind. */
159
- interface IActionRequest {
160
- /** Correlation key; the ask port resolves a given id exactly once (idempotent, first-answer wins). */
161
- id: string;
162
- title: string;
163
- description?: string;
164
- /** Predefined options. Empty/omitted ⇒ pure free-text entry. */
165
- options?: readonly IActionOption[];
166
- /** Minimum selections required (default 1). */
167
- minSelect?: number;
168
- /** Maximum selections allowed (default 1 ⇒ single; > 1 ⇒ multi). */
169
- maxSelect?: number;
170
- /** Allow a typed custom answer in addition to / instead of the options. */
171
- allowFreeText?: boolean;
172
- /** Free-text entry is masked (secret entry such as an API key); the renderer hides input. */
173
- masked?: boolean;
174
- /** Allow submitting empty free text. */
175
- allowEmpty?: boolean;
176
- /** Placeholder shown in the free-text field. */
177
- placeholder?: string;
178
- /** Maximum options shown before scrolling (renderer hint). */
179
- maxVisible?: number;
180
- /** Pre-selected option values and/or prefilled free text. */
181
- default?: IActionDefault;
85
+ interface IToolWaitState {
86
+ request: IToolWaitRequest;
87
+ response?: IToolWaitResponse;
182
88
  }
183
- /**
184
- * The user's answer to an {@link IActionRequest}. `answer` carries the selected option values and/or
185
- * the typed text; `cancelled` means the user dismissed the request, or no interactive renderer was
186
- * available to answer it.
187
- */
188
- type TActionResponse = {
189
- type: 'answer';
190
- values: readonly string[];
191
- text?: string;
192
- } | {
193
- type: 'cancelled';
194
- };
195
- /**
196
- * The injected "ask the user" port — a single seam reachable by every interaction source (command
197
- * execution now; tool execution for model-issued questions later) and rendered per-environment by each
198
- * transport. The concurrency model (broadcast to attached interactive channels, first answer wins,
199
- * later answers for an already-resolved `id` ignored) is owned by the port implementation, not the
200
- * contract.
201
- */
202
- interface IUserInteraction {
203
- ask(request: IActionRequest): Promise<TActionResponse>;
89
+ /** Available before effect admission. The runtime owns interpretation and authorization. */
90
+ interface IToolContinuation {
91
+ readonly action: IToolActionIdentity;
92
+ readonly waits: readonly IToolWaitState[];
93
+ /** Return a saved response or persist a request and suspend this execution. */
94
+ request(prompt: IToolContinuationPrompt): Promise<TToolParameters>;
204
95
  }
205
96
  //#endregion
206
97
  //#region src/interfaces/messages.d.ts
@@ -552,10 +443,14 @@ declare class RateLimitError extends RobotaError {
552
443
  */
553
444
  declare class NetworkError extends RobotaError {
554
445
  readonly originalError?: Error | undefined;
446
+ /** `undefined` for a network failure with no provider context (e.g. a generic timeout). */
447
+ readonly provider?: string | undefined;
555
448
  readonly code = "NETWORK_ERROR";
556
449
  readonly category: "system";
557
450
  readonly recoverable = true;
558
- constructor(message: string, originalError?: Error | undefined, context?: TErrorContextData);
451
+ constructor(message: string, originalError?: Error | undefined, context?: TErrorContextData,
452
+ /** `undefined` for a network failure with no provider context (e.g. a generic timeout). */
453
+ provider?: string | undefined);
559
454
  }
560
455
  /**
561
456
  * Tool execution errors
@@ -596,11 +491,24 @@ declare class SameToolInputLoopError extends RobotaError {
596
491
  * Model not available errors
597
492
  */
598
493
  declare class ModelNotAvailableError extends RobotaError {
494
+ /** `undefined` when the failure names no model — a provider adapter classifying a raw HTTP
495
+ * response by status alone does not always know which model the vendor meant. */
496
+ readonly model: string | undefined;
497
+ readonly provider: string;
599
498
  readonly availableModels?: string[] | undefined;
600
499
  readonly code = "MODEL_NOT_AVAILABLE";
601
500
  readonly category: "user";
602
501
  readonly recoverable = false;
603
- constructor(model: string, provider: string, availableModels?: string[] | undefined, context?: TErrorContextData);
502
+ constructor(
503
+ /** `undefined` when the failure names no model — a provider adapter classifying a raw HTTP
504
+ * response by status alone does not always know which model the vendor meant. */
505
+ model: string | undefined, provider: string, availableModels?: string[] | undefined,
506
+ /**
507
+ * `context.originalMessage`, when given, is the vendor's own text (already scrubbed of any
508
+ * credential by the caller) — folded into `message` so a "Details" disclosure built from
509
+ * `message` alone still shows the real cause instead of just this class's fixed sentence.
510
+ */
511
+ context?: TErrorContextData);
604
512
  }
605
513
  /**
606
514
  * Circuit breaker open error
@@ -641,6 +549,25 @@ declare class CacheIntegrityError extends RobotaError {
641
549
  }
642
550
  //#endregion
643
551
  //#region src/utils/provider-failure.d.ts
552
+ /**
553
+ * Strip anything that reads like a credential out of vendor text before it is kept on a typed error.
554
+ * A vendor's error body is not supposed to echo request headers, but a misconfigured self-hosted
555
+ * gateway can bounce the raw request back (an `Authorization` header, a `Bearer` token, an `api_key=`
556
+ * query parameter, or the whole request re-serialized as JSON) — this runs once, ahead of every
557
+ * classification below, so nothing built from `message` (the wire frame's `message`, a GUI "Details"
558
+ * disclosure) can leak one.
559
+ *
560
+ * Each pattern gets its own fixed replacement, bounded to the credential token — never a shared
561
+ * callback keyed on "does this match have a capture group", which for a pattern with none receives
562
+ * the match's numeric offset instead of `undefined` and silently prints that number.
563
+ *
564
+ * The key-name and value quotes are each optional and captured (`(")?`) rather than matched and
565
+ * dropped: JSON re-serializes a header as `"Authorization": "Bearer sk-..."`, and the closing quote
566
+ * right after the key name breaks a match that only expects `\s*[:=]` next — capturing it lets the
567
+ * replacement echo it back (`Authorization$1: $2[REDACTED]`) so quoted and unquoted text both read
568
+ * naturally, and `SECRET_VALUE` excluding `"` leaves a closing value quote alone to survive untouched.
569
+ */
570
+ declare function scrubSecrets(text: string): string;
644
571
  /** Why a provider call failed, as far as switching models is concerned. */
645
572
  type TProviderFailureReason = 'overloaded' | 'service-unavailable' | 'server-error' | 'model-unavailable' | 'authentication' | 'billing' | 'rate-limit' | 'invalid-request' | 'network' | 'aborted' | 'unknown';
646
573
  interface IProviderFailureClassification {
@@ -660,9 +587,15 @@ declare function readProviderFailureDetails(error: unknown): IProviderFailureDet
660
587
  /**
661
588
  * Turn whatever an adapter caught into a typed provider failure.
662
589
  *
663
- * Aborts and errors already in the taxonomy pass through unchanged, a rate limit becomes a
664
- * `RateLimitError`, and anything else becomes a `ProviderError` carrying the status and type the
665
- * vendor reported, with the original kept as `originalError`.
590
+ * Aborts and errors already in the taxonomy pass through unchanged. Everything else is classified by
591
+ * the same status/type rules `classifyLayer` uses to decide switchability — a rate limit, an
592
+ * authentication failure, a model the vendor does not serve, and a transport failure each become
593
+ * their own typed error (so `AuthenticationError`/`ModelNotAvailableError`/`NetworkError` are actually
594
+ * thrown, not just recognized after the fact); anything left over becomes a `ProviderError` carrying
595
+ * the status and type the vendor reported, with the original kept as `originalError`. Every branch
596
+ * keeps the vendor's own (scrubbed) message and status/type — as the text baked into `message` for
597
+ * the types that already carry a free-form one, and as `context` alongside it — so a "Details"
598
+ * disclosure built from `message` downstream never has less to say than the vendor did.
666
599
  */
667
600
  declare function toProviderError(error: unknown, provider: string, operation: string): Error;
668
601
  /**
@@ -1271,227 +1204,306 @@ type TProviderOptionValueBase = string | number | boolean | undefined | null | T
1271
1204
  [key: string]: TProviderOptionValueBase;
1272
1205
  };
1273
1206
  //#endregion
1274
- //#region src/interfaces/response-format.d.ts
1207
+ //#region src/event-service/interfaces.d.ts
1275
1208
  /**
1276
- * Response format configuration
1209
+ * @fileoverview Event service interface definitions.
1210
+ *
1211
+ * These interfaces are the single source of truth for event-related contracts
1212
+ * within @robota-sdk/agent-core.
1277
1213
  */
1278
- interface IResponseFormatConfig {
1279
- type?: 'text' | 'json_object' | 'json_schema';
1280
- /** JSON schema payload; required when `type` is `'json_schema'` (CORE-015). */
1281
- schema?: Record<string, TConfigValue>;
1282
- /** Schema name forwarded to provider native structured-output surfaces. */
1283
- name?: string;
1284
- }
1285
1214
  /**
1286
- * Safety setting configuration
1215
+ * Primitive value types for event payloads.
1287
1216
  */
1288
- interface ISafetySetting {
1289
- category: string;
1290
- threshold: string;
1291
- [key: string]: TConfigValue;
1292
- }
1293
- //#endregion
1294
- //#region src/schema/zod-schema-types.d.ts
1295
- interface IZodParseResult {
1296
- success: boolean;
1297
- data?: unknown;
1298
- error?: unknown;
1299
- }
1300
- interface IZodSchemaDef {
1301
- typeName?: string;
1302
- innerType?: IZodSchema;
1303
- valueType?: IZodSchema;
1304
- checks?: Array<{
1305
- kind: string;
1306
- value?: TUniversalValue;
1307
- }>;
1308
- shape?: () => Record<string, IZodSchema>;
1309
- type?: IZodSchema;
1310
- /**
1311
- * `ZodEnum` holds an ARRAY here; `ZodNativeEnum` holds the enum OBJECT itself (CORE-041). One Zod
1312
- * field name, two shapes — the converter narrows before reading it.
1313
- */
1314
- values?: TUniversalValue[] | Record<string, TUniversalValue>;
1315
- description?: string;
1316
- unknownKeys?: 'passthrough' | 'strip' | 'strict';
1317
- /** `ZodEffects` (`.refine()` / `.transform()`) holds the schema it wraps here. */
1318
- schema?: IZodSchema;
1319
- /** `ZodUnion` / `ZodDiscriminatedUnion` members. */
1320
- options?: IZodSchema[];
1321
- /** `ZodLiteral` value. */
1322
- value?: TUniversalValue;
1323
- }
1324
- interface IZodSchema {
1325
- parse(value: unknown): unknown;
1326
- safeParse(value: unknown): IZodParseResult;
1327
- _def?: IZodSchemaDef;
1328
- }
1217
+ type TEventPrimitiveValue = string | number | boolean | null | undefined;
1329
1218
  /**
1330
- * Schema conversion options
1219
+ * Recursive universal value type for event payloads (JSON-like + Date).
1331
1220
  */
1332
- interface ISchemaConversionOptions {
1333
- includeDescription?: boolean;
1334
- strictTypes?: boolean;
1335
- allowAdditionalProperties?: boolean;
1336
- }
1337
- //#endregion
1338
- //#region src/schema/structured-output.d.ts
1339
- /** Explicit raw-JSON-schema form of `IRunOptions.output`. */
1340
- interface IJsonSchemaOutput {
1341
- /** JSON Schema (object root, universal subset) the response must match. */
1342
- jsonSchema: IToolSchema['parameters'];
1343
- /** Optional schema name forwarded to provider native surfaces. */
1344
- name?: string;
1345
- }
1346
- /** Accepted `IRunOptions.output` values: a Zod schema or an explicit JSON-schema wrapper. */
1347
- type TStructuredOutputSchema = IZodSchema | IJsonSchemaOutput;
1348
- type TStructuredOutputValidation = {
1349
- success: true;
1350
- value: unknown;
1351
- } | {
1352
- success: false;
1353
- issues: string[];
1354
- };
1355
- /** Internal SSOT representation every `output` value normalizes to. */
1356
- interface IStructuredOutputSpec {
1357
- name: string;
1358
- jsonSchema: IToolSchema['parameters'];
1359
- validate(value: unknown): TStructuredOutputValidation;
1221
+ type TEventUniversalValue = TEventPrimitiveValue | Date | TEventUniversalValue[] | IEventObjectValue;
1222
+ interface IEventObjectValue {
1223
+ [key: string]: TEventUniversalValue;
1360
1224
  }
1361
- /** Normalize an accepted `output` value into the internal spec. */
1362
- declare function normalizeStructuredOutput(output: TStructuredOutputSchema): IStructuredOutputSpec;
1363
1225
  /**
1364
- * Validate a value against the universal JSON-schema subset (`IParameterSchema`). Covers type,
1365
- * required, enum, items, nested properties, unions and numeric bounds — the full expressible
1366
- * surface of the subset, at every level.
1367
- *
1368
- * CORE-039: this is the ONE complete walk. `parameter-validator` delegates its depth here rather
1369
- * than keeping a second, shallower copy, and the two must therefore agree by construction.
1226
+ * Logger data type for event metadata.
1370
1227
  */
1371
- declare function validateAgainstJsonSchema(schema: IParameterSchema, value: unknown, path: string): string[];
1228
+ type TEventLoggerData = Record<string, TEventUniversalValue | Date | Error>;
1372
1229
  /**
1373
- * Parse the model's final text into a JSON value. Tolerates a fenced
1374
- * ```json code block wrapper (providers without native enforcement commonly
1375
- * emit one); the parsed value is still strictly schema-validated afterwards.
1230
+ * A single segment in an explicit ownerPath.
1231
+ *
1232
+ * Path-only rule:
1233
+ * - Relationships must be derived from these explicit segments, not from parsing IDs.
1376
1234
  */
1377
- declare function parseStructuredResponseText(text: string): {
1378
- success: true;
1379
- value: unknown;
1380
- } | {
1381
- success: false;
1382
- issue: string;
1235
+ interface IOwnerPathSegment {
1236
+ type: string;
1237
+ id: string;
1238
+ }
1239
+ /**
1240
+ * Event context that accompanies an emitted event.
1241
+ * This is the single source of truth for deterministic linking in subscribers.
1242
+ */
1243
+ interface IEventContext {
1244
+ ownerType: string;
1245
+ ownerId: string;
1246
+ ownerPath: IOwnerPathSegment[];
1247
+ /** Depth of the current execution in the hierarchy (0 = root) */
1248
+ depth?: number;
1249
+ /** Unique span identifier for distributed tracing correlation */
1250
+ spanId?: string;
1251
+ /** Optional structured metadata for debugging/observability */
1252
+ metadata?: TEventLoggerData;
1253
+ }
1254
+ /**
1255
+ * Allowed extension values for event payloads.
1256
+ */
1257
+ type TEventExtensionValue = TEventUniversalValue | TEventLoggerData | Error | IEventContext | IOwnerPathSegment[];
1258
+ /**
1259
+ * Base event payload shape.
1260
+ * Emitters may add additional fields, but MUST keep linkage information explicit.
1261
+ */
1262
+ interface IBaseEventData {
1263
+ /** Timestamp when the event was emitted. This is required for deterministic ordering. */
1264
+ timestamp: Date;
1265
+ /** Optional structured metadata */
1266
+ metadata?: TEventLoggerData;
1267
+ /** Extensible fields for event-specific payloads */
1268
+ [key: string]: TEventExtensionValue | undefined;
1269
+ }
1270
+ /**
1271
+ * Execution-related event payload.
1272
+ */
1273
+ interface IExecutionEventData extends IBaseEventData {}
1274
+ /**
1275
+ * Tool-related event payload.
1276
+ */
1277
+ interface IToolEventData extends IBaseEventData {
1278
+ toolName?: string;
1279
+ parameters?: Record<string, TEventUniversalValue>;
1280
+ }
1281
+ /**
1282
+ * Agent-related event payload.
1283
+ */
1284
+ interface IAgentEventData extends IBaseEventData {
1285
+ agentId?: string;
1286
+ }
1287
+ type TEventListener = (eventType: string, data: IBaseEventData, context?: IEventContext) => void;
1288
+ /**
1289
+ * Minimal EventService contract for emitting events.
1290
+ */
1291
+ interface IEventService {
1292
+ emit(eventType: string, data: IBaseEventData, context?: IEventContext): void;
1293
+ subscribe(listener: TEventListener): void;
1294
+ unsubscribe(listener: TEventListener): void;
1295
+ }
1296
+ /**
1297
+ * Explicit owner binding information used for scoped event emission.
1298
+ */
1299
+ interface IEventServiceOwnerBinding {
1300
+ ownerType: string;
1301
+ ownerId: string;
1302
+ ownerPath: IOwnerPathSegment[];
1303
+ }
1304
+ //#endregion
1305
+ //#region src/event-service/event-service.d.ts
1306
+ /**
1307
+ * Abstract base for event services.
1308
+ * Concrete implementations decide how events are delivered.
1309
+ */
1310
+ declare abstract class AbstractEventService implements IEventService {
1311
+ private listeners;
1312
+ abstract emit(eventType: string, data: IBaseEventData, context?: IEventContext): void;
1313
+ subscribe(listener: TEventListener): void;
1314
+ unsubscribe(listener: TEventListener): void;
1315
+ protected notifyListeners(eventType: string, data: IBaseEventData, context?: IEventContext): void;
1316
+ }
1317
+ /**
1318
+ * Default no-op event service (production-safe).
1319
+ * When injected, emit() intentionally does nothing.
1320
+ */
1321
+ declare class DefaultEventService extends AbstractEventService {
1322
+ emit(_eventType: string, _data: IBaseEventData, _context?: IEventContext): void;
1323
+ }
1324
+ /**
1325
+ * Singleton default event service instance.
1326
+ */
1327
+ declare const DEFAULT_ABSTRACT_EVENT_SERVICE: IEventService;
1328
+ /**
1329
+ * Check if a given service is the default no-op implementation.
1330
+ */
1331
+ declare function isDefaultEventService(service: IEventService): boolean;
1332
+ /**
1333
+ * Compose a full event name from owner prefix and local name.
1334
+ * Local names must not contain dots.
1335
+ */
1336
+ declare function composeEventName(ownerType: string, localName: string): string;
1337
+ /**
1338
+ * Generate a unique span ID for distributed tracing correlation. Exported so a per-operation timing
1339
+ * source (SELFHOST-004) can mint a span id it puts on BOTH the event payload and the event context.
1340
+ */
1341
+ declare function generateSpanId(): string;
1342
+ /**
1343
+ * A scoped event service that always emits with an owner binding applied.
1344
+ */
1345
+ declare class StructuredEventService extends AbstractEventService {
1346
+ private readonly base;
1347
+ private readonly binding;
1348
+ constructor(base: IEventService, binding: IEventServiceOwnerBinding);
1349
+ emit(eventType: string, data: IBaseEventData, context?: IEventContext): void;
1350
+ subscribe(listener: TEventListener): void;
1351
+ unsubscribe(listener: TEventListener): void;
1352
+ }
1353
+ /**
1354
+ * Bind an EventService to an explicit owner path.
1355
+ * This is the standard entry point for scoped emission (path-only architecture).
1356
+ */
1357
+ declare function bindWithOwnerPath(base: IEventService, binding: IEventServiceOwnerBinding): IEventService;
1358
+ /**
1359
+ * Alias for bindWithOwnerPath for historical call sites.
1360
+ * Intentionally forwards to the single authoritative implementation.
1361
+ */
1362
+ declare function bindEventServiceOwner(base: IEventService, binding: IEventServiceOwnerBinding): IEventService;
1363
+ /**
1364
+ * Observable EventService that notifies subscribed listeners.
1365
+ */
1366
+ declare class ObservableEventService extends AbstractEventService {
1367
+ emit(eventType: string, data: IBaseEventData, context?: IEventContext): void;
1368
+ }
1369
+ //#endregion
1370
+ //#region src/event-service/task-events.d.ts
1371
+ declare const TASK_EVENTS: {
1372
+ readonly ASSIGNED: "assigned";
1373
+ readonly COMPLETED: "completed";
1383
1374
  };
1375
+ declare const TASK_EVENT_PREFIX: "task";
1384
1376
  //#endregion
1385
- //#region src/interfaces/run-options.d.ts
1377
+ //#region src/event-service/user-events.d.ts
1378
+ declare const USER_EVENTS: {
1379
+ readonly MESSAGE: "message";
1380
+ readonly INPUT: "input";
1381
+ };
1382
+ declare const USER_EVENT_PREFIX: "user";
1383
+ type TUserEvent = (typeof USER_EVENTS)[keyof typeof USER_EVENTS];
1384
+ //#endregion
1385
+ //#region src/event-service/span-events.d.ts
1386
1386
  /**
1387
- * The per-RUN contract: what one `run()` may override or observe, as distinct from the agent's
1388
- * standing configuration in `IAgentConfig`.
1389
- *
1390
- * Split out of `agent.ts` when PEER-007 added `driverId`. That file sits at a frozen size baseline,
1391
- * and the anti-monolith rule asks for a split rather than one more field on a file already at its
1392
- * limit. The two execution-event types come along because `onExecutionEvent` is their only consumer
1393
- * — leaving them behind would have made this module import back from `agent.ts`.
1387
+ * SELFHOST-004: per-operation span lifecycle event names. Mirrors the `TASK_EVENTS`/`USER_EVENTS`
1388
+ * pattern (a const name set + a prefix). The local name is distinctive (`span_completed`, not a bare
1389
+ * `completed`) so a consumer can identify a span-completion regardless of the emitting owner's prefix.
1394
1390
  */
1395
- type TExecutionEventData = Record<string, unknown>;
1396
- type TExecutionEventCallback = (event: string, data: TExecutionEventData) => void;
1391
+ declare const SPAN_EVENTS: {
1392
+ readonly COMPLETED: "span_completed";
1393
+ };
1394
+ /** Content-free completion of one provider round, separate from legacy tool timing events. */
1395
+ declare const PROVIDER_CALL_EVENTS: {
1396
+ readonly COMPLETED: "provider_call_completed";
1397
+ };
1398
+ /** A provider request moved to another model after the one it was on failed. */
1399
+ declare const PROVIDER_FALLBACK_EVENTS: {
1400
+ readonly SWITCHED: "provider_fallback";
1401
+ };
1402
+ /** The notice a `provider_fallback` event carries, or `undefined` when the payload is malformed. */
1403
+ declare function readModelFallbackNotice(data: Readonly<Record<string, unknown>>): IModelFallbackNotice | undefined;
1404
+ /** Content-free completion of the body actually awaited by one permitted tool call. */
1405
+ declare const TOOL_BODY_EVENTS: {
1406
+ readonly COMPLETED: "tool_body_completed";
1407
+ };
1408
+ /** Content-free decision reached for one tool call before any body runs. */
1409
+ declare const TOOL_PERMISSION_EVENTS: {
1410
+ readonly DECIDED: "tool_permission_decided";
1411
+ };
1412
+ declare const SPAN_EVENT_PREFIX: "span";
1413
+ type TSpanEvent = (typeof SPAN_EVENTS)[keyof typeof SPAN_EVENTS];
1397
1414
  /**
1398
- * Agent run options - type-safe interface for all agent execution options
1415
+ * SELFHOST-004: span-completion event payload — JOINS the span id with its measured duration and the
1416
+ * operation name (raw scalars ONLY; references no transport type). Emitted by the per-operation timing
1417
+ * source (e.g. `FunctionTool`) so a consuming layer (`agent-framework`) can build a record span entry
1418
+ * WITHOUT `agent-core` depending on `agent-interface-transport` (no cycle). The payload `spanId` is the
1419
+ * AUTHORITATIVE id a consumer reads; owner/turn correlation is applied by the event service's binding
1420
+ * (`ownerPath` on the emitted `IEventContext`). Note the context's own auto-minted `spanId` is a
1421
+ * separate scope tag and need not equal this payload id — always read the payload id for the span.
1399
1422
  */
1400
- interface IRunOptions {
1401
- /** Run-scoped temperature override — wins over `defaultModel.temperature` (CORE-016). */
1402
- temperature?: number;
1403
- /** Run-scoped max output tokens override — wins over `defaultModel.maxTokens` (CORE-016). */
1404
- maxTokens?: number;
1405
- /**
1406
- * Run-scoped tool-invocation directive — wins over `defaultModel.toolChoice` (CORE-017).
1407
- * `'auto'` (model decides), `'none'` (suppress tool calls), `'required'` (must call some
1408
- * tool), or `{ tool: name }` (must call the named tool; the name is validated against the
1409
- * run's tool list and a miss throws). Forcing applies to the run's first model call only;
1410
- * rounds after tool results revert to `'auto'` (see `TToolChoice`).
1411
- */
1412
- toolChoice?: TToolChoice;
1413
- /**
1414
- * Leave a provider's own hosted tools (a vendor-run web search) out of this run's requests. They
1415
- * run at the vendor and never pass the permission gate, so a run whose tools a policy restricts
1416
- * must not reach them.
1417
- */
1418
- withholdHostedTools?: boolean;
1419
- sessionId?: string;
1420
- userId?: string;
1421
- /**
1422
- * PEER-007 (issue #1915): who this run is attributed to, for display. Per-run because it changes
1423
- * per turn — one session serves the operator and any peer addressing it. Never authorization.
1424
- */
1425
- driverId?: string;
1426
- /**
1427
- * Where this run's turn came from (a peer's message, an external event, an agent wake-up), stored
1428
- * beside `driverId` on the user message so a transcript carried elsewhere still says it. Display
1429
- * only, like `driverId`; absent for the operator's own turn.
1430
- */
1431
- turnSource?: string;
1432
- metadata?: TMetadata;
1433
- /**
1434
- * Run-scoped EPHEMERAL system context (SELFHOST-008 P3). A transient system-role block included in THIS
1435
- * run's provider request(s) only — it is **never written to the conversation store** and never persisted,
1436
- * so it does not bloat history or force a static-system-prompt rebuild. Content-free neutral channel: the
1437
- * caller decides what to put here (e.g. per-turn recalled memory). Absent ⇒ no change.
1438
- */
1439
- ephemeralSystemContext?: string;
1440
- /**
1441
- * Host-owned trace context for this run's provider calls. Each invoked call — forced summary
1442
- * included, cache hits excluded — gets a `traceparent` whose parent is that call's own span, and
1443
- * only an adapter whose origin is listed sends it. Never recorded in execution events.
1444
- */
1445
- traceContext?: IRunTraceContext;
1446
- /**
1447
- * AbortSignal for cancelling execution. Aborting an in-flight run does not throw: `run()` resolves
1448
- * (and `runStream()` returns) the last assistant text the turn committed before the abort, possibly
1449
- * `''`; a reply cut off mid-stream is kept in history with `state: 'interrupted'`. Read
1450
- * `signal.aborted` to tell an interrupted run from a completed one.
1451
- */
1452
- signal?: AbortSignal;
1453
- /** Join an aborted/timed-out provider call before completing; an uncooperative call may remain pending. */
1454
- awaitProviderSettlement?: boolean;
1455
- /** Per-run streaming text callback. Prefer this over mutating provider callback state. */
1456
- onTextDelta?: TTextDeltaCallback;
1457
- /** Per-run replay event callback for provider/tool execution boundaries. */
1458
- onExecutionEvent?: TExecutionEventCallback;
1459
- /**
1460
- * Maximum execution rounds for this run. A **round** is one provider (model) call plus the
1461
- * execution of every tool call that reply requested; a reply with no tool calls ends the loop,
1462
- * so a plain Q&A turn is exactly 1 round. This caps model/tool cycles within ONE `run()` — it is
1463
- * not a tool-count limit and not a multi-turn conversation limit. When the cap is hit the run
1464
- * stops after the current round. Use 0 for no core round cap. Defaults to
1465
- * `IAgentConfig.maxExecutionRounds`.
1466
- */
1467
- maxExecutionRounds?: number;
1468
- /** Max times the same tool may be called with identical input before aborting. Unset = no limit. */
1469
- maxSameToolInputs?: number;
1470
- /**
1471
- * Treat a turn that ends in tool calls (no trailing text) as a valid completion instead of
1472
- * forcing one extra provider call to generate a summary (CORE-011). For decision-agent patterns
1473
- * (router/orchestrator/classifier) the tool call IS the answer — this removes the one-call tax.
1474
- * The summary call is the one made when the round cap ends the loop on a tool round; before the cap
1475
- * the model is called again after tool results as usual, so a decision agent sets
1476
- * `maxExecutionRounds` too (e.g. `1`). The run resolves with the turn's text, or `''` when it
1477
- * produced none; consumers read the outcome from the tool results.
1478
- */
1479
- allowToolOnlyCompletion?: boolean;
1480
- /**
1481
- * Schema-enforced structured output (CORE-015). Accepts a Zod schema or an explicit
1482
- * `{ jsonSchema }` wrapper. `run` then resolves to the validated, typed object instead of a
1483
- * string: the schema is forwarded to the provider's native structured-output surface where one
1484
- * exists, and the final response is always parsed and validated core-side; a violation triggers
1485
- * a bounded retry with the validation issues fed back as the next turn's input. Every attempt is
1486
- * a real conversation turn (history stays append-only). Exhausted retries throw
1487
- * `StructuredOutputError`.
1488
- */
1489
- output?: TStructuredOutputSchema;
1490
- /**
1491
- * Retry budget for structured output validation failures — the number of additional attempts
1492
- * after the first (default 2). Only meaningful with `output` set.
1493
- */
1494
- outputRetries?: number;
1423
+ interface ISpanCompletionEventData extends IBaseEventData {
1424
+ /** The span id (equals the emitted event's context `spanId`). */
1425
+ spanId: string;
1426
+ /** Measured wall-clock duration of the operation, in milliseconds. */
1427
+ durationMs: number;
1428
+ /** The operation name (e.g. the tool name). */
1429
+ op: string;
1430
+ }
1431
+ //#endregion
1432
+ //#region src/interfaces/interaction.d.ts
1433
+ /**
1434
+ * UI-agnostic "ask the user" contract (CMD-004).
1435
+ *
1436
+ * The SSOT for the interaction action lives in agent-core so every interaction *source* can reach it:
1437
+ * command execution (`ICommandHostContext`, agent-framework) AND tool execution
1438
+ * (`IToolExecutionContext`, agent-core, for model-issued questions — CMD-005). These are pure types
1439
+ * with no runtime dependency, so the contract crosses a serialization/transport boundary unchanged
1440
+ * (no function-valued fields).
1441
+ *
1442
+ * A single shape covers every interaction kind, parameterised by fields rather than split into
1443
+ * variants:
1444
+ * - confirm → two options, `maxSelect` 1
1445
+ * - single → options, `maxSelect` 1
1446
+ * - multi → options, `maxSelect` > 1
1447
+ * - free text → no options, `allowFreeText` true
1448
+ * - secret → free text with `masked` true
1449
+ */
1450
+ /** One predefined option the user can choose. */
1451
+ interface IActionOption {
1452
+ value: string;
1453
+ label: string;
1454
+ description?: string;
1455
+ }
1456
+ /** Pre-selected option values and/or prefilled free text for an action request. */
1457
+ interface IActionDefault {
1458
+ values?: readonly string[];
1459
+ text?: string;
1460
+ }
1461
+ /** One request for the user to answer. See the module doc for how the fields encode each kind. */
1462
+ interface IActionRequest {
1463
+ /** Correlation key; the ask port resolves a given id exactly once (idempotent, first-answer wins). */
1464
+ id: string;
1465
+ title: string;
1466
+ description?: string;
1467
+ /** Predefined options. Empty/omitted ⇒ pure free-text entry. */
1468
+ options?: readonly IActionOption[];
1469
+ /** Minimum selections required (default 1). */
1470
+ minSelect?: number;
1471
+ /** Maximum selections allowed (default 1 ⇒ single; > 1 ⇒ multi). */
1472
+ maxSelect?: number;
1473
+ /** Allow a typed custom answer in addition to / instead of the options. */
1474
+ allowFreeText?: boolean;
1475
+ /** Free-text entry is masked (secret entry such as an API key); the renderer hides input. */
1476
+ masked?: boolean;
1477
+ /** Allow submitting empty free text. */
1478
+ allowEmpty?: boolean;
1479
+ /** Placeholder shown in the free-text field. */
1480
+ placeholder?: string;
1481
+ /** Maximum options shown before scrolling (renderer hint). */
1482
+ maxVisible?: number;
1483
+ /** Pre-selected option values and/or prefilled free text. */
1484
+ default?: IActionDefault;
1485
+ }
1486
+ /**
1487
+ * The user's answer to an {@link IActionRequest}. `answer` carries the selected option values and/or
1488
+ * the typed text; `cancelled` means the user dismissed the request, or no interactive renderer was
1489
+ * available to answer it.
1490
+ */
1491
+ type TActionResponse = {
1492
+ type: 'answer';
1493
+ values: readonly string[];
1494
+ text?: string;
1495
+ } | {
1496
+ type: 'cancelled';
1497
+ };
1498
+ /**
1499
+ * The injected "ask the user" port — a single seam reachable by every interaction source (command
1500
+ * execution now; tool execution for model-issued questions later) and rendered per-environment by each
1501
+ * transport. The concurrency model (broadcast to attached interactive channels, first answer wins,
1502
+ * later answers for an already-resolved `id` ignored) is owned by the port implementation, not the
1503
+ * contract.
1504
+ */
1505
+ interface IUserInteraction {
1506
+ ask(request: IActionRequest): Promise<TActionResponse>;
1495
1507
  }
1496
1508
  //#endregion
1497
1509
  //#region src/interfaces/tool-search.d.ts
@@ -1529,654 +1541,884 @@ interface IDeferredToolCatalog {
1529
1541
  loadDeferredTools(names: readonly string[]): IToolSchema[];
1530
1542
  }
1531
1543
  //#endregion
1532
- //#region src/plugins/event-emitter/types.d.ts
1533
- declare const EXECUTION_EVENT_NAMES: {
1534
- readonly START: "execution.start";
1535
- readonly COMPLETE: "execution.complete";
1536
- readonly ERROR: "execution.error";
1537
- };
1538
- declare const TOOL_EVENT_NAMES: {
1539
- readonly CALL_START: "tool.call_start";
1540
- readonly CALL_COMPLETE: "tool.call_complete";
1541
- readonly CALL_ERROR: "tool.call_error";
1542
- };
1543
- declare const AGENT_EVENT_NAMES: {
1544
- readonly EXECUTION_START: "agent.execution_start";
1545
- readonly EXECUTION_COMPLETE: "agent.execution_complete";
1546
- readonly EXECUTION_ERROR: "agent.execution_error";
1547
- readonly CREATED: "agent.created";
1548
- };
1549
- type TExecutionEventName = (typeof EXECUTION_EVENT_NAMES)[keyof typeof EXECUTION_EVENT_NAMES];
1550
- type TToolEventName = (typeof TOOL_EVENT_NAMES)[keyof typeof TOOL_EVENT_NAMES];
1551
- type TAgentEventName = (typeof AGENT_EVENT_NAMES)[keyof typeof AGENT_EVENT_NAMES];
1552
- /**
1553
- * Event types that can be emitted.
1554
- *
1555
- * IMPORTANT:
1556
- * - Do not use string literals for event names outside this module.
1557
- * - Import and use EVENT_EMITTER_EVENTS instead.
1558
- */
1559
- declare const EVENT_EMITTER_EVENTS: {
1560
- readonly EXECUTION_START: "execution.start";
1561
- readonly EXECUTION_COMPLETE: "execution.complete";
1562
- readonly EXECUTION_ERROR: "execution.error";
1563
- readonly TOOL_BEFORE_EXECUTE: "tool.beforeExecute";
1564
- readonly TOOL_AFTER_EXECUTE: "tool.afterExecute";
1565
- readonly TOOL_SUCCESS: "tool.success";
1566
- readonly TOOL_ERROR: "tool.call_error";
1567
- readonly CONVERSATION_START: "conversation.start";
1568
- readonly CONVERSATION_COMPLETE: "conversation.complete";
1569
- readonly CONVERSATION_ERROR: "conversation.error";
1570
- readonly AGENT_EXECUTION_START: "agent.execution_start";
1571
- readonly AGENT_EXECUTION_COMPLETE: "agent.execution_complete";
1572
- readonly AGENT_EXECUTION_ERROR: "agent.execution_error";
1573
- readonly AGENT_CREATED: "agent.created";
1574
- readonly AGENT_DESTROYED: "agent.destroyed";
1575
- readonly PLUGIN_LOADED: "plugin.loaded";
1576
- readonly PLUGIN_UNLOADED: "plugin.unloaded";
1577
- readonly PLUGIN_ERROR: "plugin.error";
1578
- readonly ERROR_OCCURRED: "error.occurred";
1579
- readonly WARNING_OCCURRED: "warning.occurred";
1580
- readonly MODULE_INITIALIZE_START: "module.initialize.start";
1581
- readonly MODULE_INITIALIZE_COMPLETE: "module.initialize.complete";
1582
- readonly MODULE_INITIALIZE_ERROR: "module.initialize.error";
1583
- readonly MODULE_EXECUTION_START: "module.execution.start";
1584
- readonly MODULE_EXECUTION_COMPLETE: "module.execution.complete";
1585
- readonly MODULE_EXECUTION_ERROR: "module.execution.error";
1586
- readonly MODULE_DISPOSE_START: "module.dispose.start";
1587
- readonly MODULE_DISPOSE_COMPLETE: "module.dispose.complete";
1588
- readonly MODULE_DISPOSE_ERROR: "module.dispose.error";
1589
- readonly MODULE_REGISTERED: "module.registered";
1590
- readonly MODULE_UNREGISTERED: "module.unregistered";
1591
- readonly EXECUTION_HIERARCHY: "execution.hierarchy";
1592
- readonly EXECUTION_REALTIME: "execution.realtime";
1593
- readonly TOOL_REALTIME: "tool.realtime";
1594
- readonly CUSTOM: "custom";
1595
- };
1596
- type TEventName = TExecutionEventName | TToolEventName | TAgentEventName | 'tool.beforeExecute' | 'tool.afterExecute' | 'tool.success' | 'conversation.start' | 'conversation.complete' | 'conversation.error' | 'agent.destroyed' | 'plugin.loaded' | 'plugin.unloaded' | 'plugin.error' | 'error.occurred' | 'warning.occurred' | 'module.initialize.start' | 'module.initialize.complete' | 'module.initialize.error' | 'module.execution.start' | 'module.execution.complete' | 'module.execution.error' | 'module.dispose.start' | 'module.dispose.complete' | 'module.dispose.error' | 'module.registered' | 'module.unregistered' | 'execution.hierarchy' | 'execution.realtime' | 'tool.realtime' | 'custom';
1597
- /**
1598
- * Valid event data value types
1599
- */
1600
- type TEventDataValue = string | number | boolean | Date | null | undefined | TEventDataValue[] | {
1601
- [key: string]: TEventDataValue;
1602
- };
1603
- /**
1604
- * Event data structure
1605
- */
1606
- interface IEventEmitterEventData {
1607
- type: TEventName;
1608
- timestamp: Date;
1609
- executionId?: string;
1610
- sessionId?: string;
1611
- userId?: string;
1612
- data?: Record<string, TEventDataValue>;
1613
- error?: Error;
1614
- metadata?: Record<string, TEventDataValue>;
1615
- }
1616
- /**
1617
- * Event listener function
1618
- */
1619
- type TEventEmitterListener = (event: IEventEmitterEventData) => void | Promise<void>;
1620
- /**
1621
- * Console-like interface for the EventEmitterPlugin.
1622
- *
1623
- * Use this interface for typing instead of the concrete EventEmitterPlugin class.
1624
- */
1625
- interface IEventEmitterPlugin {
1626
- on(eventType: TEventName, listener: TEventEmitterListener, options?: {
1627
- once?: boolean;
1628
- filter?: (event: IEventEmitterEventData) => boolean;
1629
- }): string;
1630
- once(eventType: TEventName, listener: TEventEmitterListener, filter?: (event: IEventEmitterEventData) => boolean): string;
1631
- off(eventType: TEventName, handlerIdOrListener: string | TEventEmitterListener): boolean;
1632
- emit(eventType: TEventName, eventData?: Partial<IEventEmitterEventData>): Promise<void>;
1633
- }
1634
- //#endregion
1635
- //#region src/abstracts/abstract-module-types.d.ts
1636
- /** Module execution context */
1637
- interface IModuleExecutionContext {
1638
- executionId?: string;
1639
- sessionId?: string;
1640
- userId?: string;
1641
- agentName?: string;
1642
- metadata?: Record<string, string | number | boolean | Date>;
1643
- [key: string]: string | number | boolean | Date | Record<string, string | number | boolean | Date> | undefined;
1644
- }
1645
- /** Module execution result */
1646
- interface IModuleExecutionResult {
1647
- success: boolean;
1648
- data?: IModuleResultData;
1649
- error?: Error;
1650
- duration?: number;
1651
- metadata?: Record<string, string | number | boolean | Date>;
1652
- }
1653
- /** Module result data */
1654
- interface IModuleResultData {
1655
- [key: string]: string | number | boolean | Record<string, string | number | boolean> | undefined;
1656
- }
1657
- /** Base module options */
1658
- interface IBaseModuleOptions {
1659
- enabled?: boolean;
1660
- config?: Record<string, string | number | boolean>;
1661
- }
1662
- /** Module capabilities */
1663
- interface IModuleCapabilities {
1664
- capabilities: string[];
1665
- dependencies?: string[];
1666
- optionalDependencies?: string[];
1667
- }
1668
- /** Module type descriptor */
1669
- interface IModuleDescriptor {
1670
- type: string;
1671
- category: ModuleCategory;
1672
- layer: ModuleLayer;
1673
- dependencies?: string[];
1674
- capabilities?: string[];
1675
- }
1676
- /** Module categories */
1677
- declare enum ModuleCategory {
1678
- CORE = "core",
1679
- STORAGE = "storage",
1680
- PROCESSING = "processing",
1681
- INTEGRATION = "integration",
1682
- INTERFACE = "interface",
1683
- CAPABILITY = "capability"
1684
- }
1685
- /** Module layers */
1686
- declare enum ModuleLayer {
1687
- INFRASTRUCTURE = "infrastructure",
1688
- CORE = "core",
1689
- APPLICATION = "application",
1690
- DOMAIN = "domain",
1691
- PRESENTATION = "presentation"
1692
- }
1693
- /** Module data for introspection */
1694
- interface IModuleData {
1695
- name: string;
1696
- version: string;
1697
- type: string;
1698
- enabled: boolean;
1699
- initialized: boolean;
1700
- capabilities: IModuleCapabilities;
1701
- metadata?: Record<string, string | number | boolean>;
1702
- }
1703
- /** Module statistics */
1704
- interface IModuleStats {
1705
- enabled: boolean;
1706
- initialized: boolean;
1707
- executionCount: number;
1708
- errorCount: number;
1709
- lastActivity?: Date;
1710
- averageExecutionTime?: number;
1711
- [key: string]: string | number | boolean | Date | undefined;
1712
- }
1713
- /** Type-safe module interface */
1714
- interface IModule<TOptions extends IBaseModuleOptions = IBaseModuleOptions, TStats = IModuleStats> {
1715
- name: string;
1716
- version: string;
1717
- enabled: boolean;
1718
- initialize(options?: TOptions, eventEmitter?: IEventEmitterPlugin): Promise<void>;
1719
- dispose?(): Promise<void>;
1720
- execute?(context: IModuleExecutionContext): Promise<IModuleExecutionResult>;
1721
- getModuleType(): IModuleDescriptor;
1722
- getCapabilities(): IModuleCapabilities;
1723
- getData?(): IModuleData;
1724
- getStats?(): TStats;
1725
- isEnabled(): boolean;
1726
- isInitialized(): boolean;
1727
- }
1728
- //#endregion
1729
- //#region src/event-service/interfaces.d.ts
1544
+ //#region src/interfaces/tool.d.ts
1545
+ /** Awaited host admission for effective parameters, immediately before a tool body. */
1546
+ type TToolEffectAdmission<TParameters = TToolParameters> = (parameters: TParameters) => Promise<void>;
1547
+ type TToolContextExtensionValue = TUniversalValue | Date | Error | TLoggerData | TContextData | TToolParameters | TToolMetadata;
1730
1548
  /**
1731
- * @fileoverview Event service interface definitions.
1549
+ * Tool metadata structure - specific type definition
1550
+ */
1551
+ type TToolMetadata = Record<string, string | number | boolean | string[] | number[] | boolean[] | TToolParameters>;
1552
+ /**
1553
+ * Tool execution data - domain payload for tool results.
1732
1554
  *
1733
- * These interfaces are the single source of truth for event-related contracts
1734
- * within @robota-sdk/agent-core.
1555
+ * IMPORTANT:
1556
+ * - This must support structured tool outputs without resorting to `any`.
1557
+ * - Prefer `ToolResultData` (derived from the canonical `UniversalValue` axis).
1735
1558
  */
1736
1559
  /**
1737
- * Primitive value types for event payloads.
1560
+ * Tool execution result - extended for ToolExecutionData compatibility
1738
1561
  */
1739
- type TEventPrimitiveValue = string | number | boolean | null | undefined;
1562
+ interface IToolResult {
1563
+ success: boolean;
1564
+ data?: TUniversalValue;
1565
+ error?: string;
1566
+ metadata?: TToolMetadata;
1567
+ [key: string]: TToolContextExtensionValue | undefined;
1568
+ }
1740
1569
  /**
1741
- * Recursive universal value type for event payloads (JSON-like + Date).
1570
+ * Enhanced tool execution result with additional metadata
1742
1571
  */
1743
- type TEventUniversalValue = TEventPrimitiveValue | Date | TEventUniversalValue[] | IEventObjectValue;
1744
- interface IEventObjectValue {
1745
- [key: string]: TEventUniversalValue;
1572
+ interface IToolExecutionResult {
1573
+ /** Whether execution was successful */
1574
+ success: boolean;
1575
+ /** Tool name that was executed */
1576
+ toolName?: string;
1577
+ /** Execution result or data */
1578
+ result?: TUniversalValue;
1579
+ /** Error message if execution failed */
1580
+ error?: string;
1581
+ /** Execution duration in milliseconds */
1582
+ duration?: number;
1583
+ /** Unique execution ID */
1584
+ executionId?: string;
1585
+ /** Additional metadata */
1586
+ metadata?: TToolMetadata;
1746
1587
  }
1747
1588
  /**
1748
- * Logger data type for event metadata.
1589
+ * Tool execution context - type-safe context for tool execution
1590
+ * Enhanced with hierarchical execution tracking support
1749
1591
  */
1750
- type TEventLoggerData = Record<string, TEventUniversalValue | Date | Error>;
1592
+ interface IToolExecutionContext {
1593
+ toolName: string;
1594
+ parameters: TToolParameters;
1595
+ /** Runtime-owned barrier, consumed after permission and before entering the tool. */
1596
+ beforeToolEffect?: TToolEffectAdmission;
1597
+ /** Journaled pre-effect request/response port for admission-aware runtime wrappers. */
1598
+ continuation?: IToolContinuation;
1599
+ /**
1600
+ * Run-scoped cancellation signal (CORE-018). Long-running tools MUST honor it: terminate
1601
+ * the underlying work (kill the child process, abort the network request) and return an
1602
+ * interrupted/failed result. Completing silently after an abort is a contract violation.
1603
+ */
1604
+ signal?: AbortSignal;
1605
+ /** Direct remote calls deny decisions that would require human interaction. */
1606
+ permissionInteraction?: 'interactive' | 'deny';
1607
+ executionId?: string;
1608
+ userId?: string;
1609
+ sessionId?: string;
1610
+ metadata?: TToolMetadata;
1611
+ /** Parent execution ID for hierarchical tool execution tracking */
1612
+ parentExecutionId?: string;
1613
+ /** Root execution ID (Team/Agent level) for complete execution tree tracking */
1614
+ rootExecutionId?: string;
1615
+ /** Execution depth level (0: Team, 1: Agent, 2: Tool, etc.) */
1616
+ executionLevel?: number;
1617
+ /** Execution path array showing the complete execution hierarchy */
1618
+ executionPath?: string[];
1619
+ /** Real-time execution data for accurate tracking (no simulation) */
1620
+ realTimeData?: {
1621
+ /** Actual execution start time */
1622
+ startTime: Date;
1623
+ /** Actual input parameters passed to the tool */
1624
+ actualParameters: TToolParameters;
1625
+ /** Tool-provided estimated duration (optional) */
1626
+ estimatedDuration?: number;
1627
+ };
1628
+ /**
1629
+ * Additional tool execution context extensions.
1630
+ *
1631
+ * IMPORTANT:
1632
+ * - Avoid ad-hoc top-level fields to keep the contract stable.
1633
+ * - Use this map for forward-compatible extra data with constrained value types.
1634
+ */
1635
+ extensions?: Record<string, TToolContextExtensionValue>;
1636
+ /** Owner context propagated from EventService */
1637
+ ownerType?: string;
1638
+ ownerId?: string;
1639
+ ownerPath?: IOwnerPathSegment[];
1640
+ sourceId?: string;
1641
+ /**
1642
+ * Tool-call scoped EventService instance.
1643
+ * Caller (ExecutionService/ToolExecutionService) is responsible for providing
1644
+ * an ownerPath-bound EventService for this tool call.
1645
+ */
1646
+ eventService?: IEventService;
1647
+ /**
1648
+ * Unbound base EventService instance.
1649
+ *
1650
+ * Required when a tool needs to create another owner-bound EventService
1651
+ * for a different owner (e.g., creating an agent from a tool call).
1652
+ *
1653
+ * NOTE: Do not wrap an already owner-bound EventService to bind a different owner.
1654
+ * Owner-bound instances must not be layered across different owners.
1655
+ */
1656
+ baseEventService?: IEventService;
1657
+ /**
1658
+ * The service this call's caller would give the tool with `setEventService`, carried with the
1659
+ * call instead. One tool instance can serve several agents, and the service set on it is
1660
+ * whichever agent set one last; a tool that emits events of its own (the `FunctionTool` span)
1661
+ * emits them here when present, so they reach the agent that made the call. The no-op default
1662
+ * service means that caller wants none.
1663
+ */
1664
+ instanceEventService?: IEventService;
1665
+ /**
1666
+ * Injected "ask the user" port (CMD-004). Present when an interactive renderer is attached, letting
1667
+ * a tool solicit a structured answer from the user (the model-issued question seam consumed by
1668
+ * CMD-005). Absent in non-interactive contexts; a tool that asks must treat absence as "no human
1669
+ * available" (never a silent guess).
1670
+ */
1671
+ ask?: IUserInteraction['ask'];
1672
+ /**
1673
+ * CLI-1990: the deferred-tool catalog the runtime injects (`ToolExecutionService`), so a search
1674
+ * tool can list what is withheld and load it for the rest of the session. Present on every tool
1675
+ * call the execution loop issues; a tool other than the search tool has no reason to read it.
1676
+ */
1677
+ deferredTools?: IDeferredToolCatalog;
1678
+ /**
1679
+ * The ID core mints for this one tool body, unique even when a vendor reuses its tool call ID.
1680
+ * The body's exported span is derived from it, so it is also what a propagated parent names.
1681
+ */
1682
+ toolBodyId?: string;
1683
+ /**
1684
+ * Present only when the run carries trusted trace context: the `traceparent` naming this body's
1685
+ * span and the exact origins it may be sent to. A tool that makes outbound requests sends it only
1686
+ * to a listed origin.
1687
+ */
1688
+ outboundTraceContext?: IOutboundTraceContext;
1689
+ /**
1690
+ * Present only when the host lets shell children inherit the trace: the environment naming this
1691
+ * body's span. Only the foreground shell tool applies it, to its own child.
1692
+ */
1693
+ shellTraceEnv?: ISubprocessTraceEnv;
1694
+ /**
1695
+ * Present only when the host lets command hooks inherit the trace: the environment naming the
1696
+ * prompt root, for the hooks fired around this body. Separate from {@link shellTraceEnv}, whose
1697
+ * span is the body's own.
1698
+ */
1699
+ hookTraceEnv?: ISubprocessTraceEnv;
1700
+ }
1751
1701
  /**
1752
- * A single segment in an explicit ownerPath.
1753
- *
1754
- * Path-only rule:
1755
- * - Relationships must be derived from these explicit segments, not from parsing IDs.
1702
+ * Parameter validation result
1756
1703
  */
1757
- interface IOwnerPathSegment {
1758
- type: string;
1759
- id: string;
1704
+ interface IParameterValidationResult {
1705
+ /** Whether parameters are valid */
1706
+ isValid: boolean;
1707
+ /** Validation error messages */
1708
+ errors: string[];
1760
1709
  }
1761
1710
  /**
1762
- * Event context that accompanies an emitted event.
1763
- * This is the single source of truth for deterministic linking in subscribers.
1711
+ * Generic tool executor function
1764
1712
  */
1765
- interface IEventContext {
1766
- ownerType: string;
1767
- ownerId: string;
1768
- ownerPath: IOwnerPathSegment[];
1769
- /** Depth of the current execution in the hierarchy (0 = root) */
1770
- depth?: number;
1771
- /** Unique span identifier for distributed tracing correlation */
1772
- spanId?: string;
1773
- /** Optional structured metadata for debugging/observability */
1774
- metadata?: TEventLoggerData;
1713
+ type TToolExecutor<TParams = TToolParameters, TResult = TUniversalValue> = (parameters: TParams, context?: IToolExecutionContext) => Promise<TResult>;
1714
+ /**
1715
+ * Base tool interface
1716
+ */
1717
+ interface ITool {
1718
+ /** Tool schema */
1719
+ schema: IToolSchema;
1720
+ /**
1721
+ * Execute the tool with given parameters
1722
+ */
1723
+ execute(parameters: TToolParameters, context?: IToolExecutionContext): Promise<IToolResult>;
1724
+ /**
1725
+ * Validate tool parameters
1726
+ */
1727
+ validate(parameters: TToolParameters): boolean;
1728
+ /**
1729
+ * Validate tool parameters with detailed result
1730
+ */
1731
+ validateParameters(parameters: TToolParameters): IParameterValidationResult;
1732
+ /**
1733
+ * Get tool description
1734
+ */
1735
+ getDescription(): string;
1775
1736
  }
1776
1737
  /**
1777
- * Allowed extension values for event payloads.
1738
+ * Function tool implementation
1778
1739
  */
1779
- type TEventExtensionValue = TEventUniversalValue | TEventLoggerData | Error | IEventContext | IOwnerPathSegment[];
1740
+ interface IFunctionTool extends ITool {
1741
+ /** Function to execute */
1742
+ fn: TToolExecutor;
1743
+ }
1780
1744
  /**
1781
- * Base event payload shape.
1782
- * Emitters may add additional fields, but MUST keep linkage information explicit.
1745
+ * Tool registry interface
1783
1746
  */
1784
- interface IBaseEventData {
1785
- /** Timestamp when the event was emitted. This is required for deterministic ordering. */
1786
- timestamp: Date;
1787
- /** Optional structured metadata */
1788
- metadata?: TEventLoggerData;
1789
- /** Extensible fields for event-specific payloads */
1790
- [key: string]: TEventExtensionValue | undefined;
1747
+ interface IToolRegistry {
1748
+ /**
1749
+ * Register a tool
1750
+ */
1751
+ register(tool: ITool): void;
1752
+ /**
1753
+ * Unregister a tool
1754
+ */
1755
+ unregister(name: string): void;
1756
+ /**
1757
+ * Get tool by name
1758
+ */
1759
+ get(name: string): ITool | undefined;
1760
+ /**
1761
+ * Get all registered tools
1762
+ */
1763
+ getAll(): ITool[];
1764
+ /**
1765
+ * Get tool schemas
1766
+ */
1767
+ getSchemas(): IToolSchema[];
1768
+ /**
1769
+ * Check if tool exists
1770
+ */
1771
+ has(name: string): boolean;
1772
+ /**
1773
+ * Clear all tools
1774
+ */
1775
+ clear(): void;
1776
+ }
1777
+ //#endregion
1778
+ //#region src/interfaces/execution-journal.d.ts
1779
+ /** Data-only provider options; callbacks, signals, tracing and adapter credentials are excluded. */
1780
+ type TJournalModelOptions = Pick<IChatOptions, 'model' | 'tools' | 'maxTokens' | 'temperature' | 'effort' | 'toolChoice' | 'nativeWebTools' | 'responseFormat'>;
1781
+ interface IJournalIdentity {
1782
+ recordId: string;
1783
+ executionId: string;
1784
+ }
1785
+ interface IJournalModelIdentity {
1786
+ callId: string;
1787
+ providerId: string;
1788
+ modelId: string;
1789
+ }
1790
+ interface IJournalActionIdentity {
1791
+ actionId: string;
1792
+ parentCallId: string;
1793
+ toolCallId: string;
1794
+ toolName: string;
1795
+ }
1796
+ interface IExecutionContinuationState {
1797
+ version: 1;
1798
+ kind: 'round' | 'summary';
1799
+ startedAt: string;
1800
+ turnMessageId: string;
1801
+ model: Pick<IChatOptions, 'maxTokens' | 'temperature' | 'effort' | 'toolChoice'> & {
1802
+ provider: string;
1803
+ model: string;
1804
+ topP?: number;
1805
+ };
1806
+ timeout?: number;
1807
+ toolSearch?: TToolSearchSetting;
1808
+ structuredOutput: boolean;
1809
+ /** Versioned data contract; runtime callbacks and signals are supplied by the recovering host. */
1810
+ options: Pick<IChatOptions, 'maxTokens' | 'temperature' | 'toolChoice'> & {
1811
+ maxExecutionRounds: number;
1812
+ maxSameToolInputs?: number;
1813
+ allowToolOnlyCompletion: boolean;
1814
+ withholdHostedTools: boolean;
1815
+ ephemeralSystemContext?: string;
1816
+ sessionId?: string;
1817
+ userId?: string;
1818
+ metadata?: TMetadata;
1819
+ };
1820
+ toolsExecuted: string[];
1821
+ consecutiveUnknownToolFailureRounds: number;
1822
+ forcedSummaryInstruction?: string;
1823
+ loadedDeferredTools?: string[];
1824
+ }
1825
+ /** Canonical private history, separate from transformed/ephemeral provider input. */
1826
+ interface IExecutionRoundCheckpoint {
1827
+ version: 1;
1828
+ effectAdmission: 'required';
1829
+ messages: TUniversalMessage[];
1830
+ round: number;
1831
+ contextLimit: number;
1832
+ cumulativeInputTokens: number;
1833
+ sameToolInputCounts: Array<[string, number]>;
1834
+ maxSameToolInputs?: number;
1835
+ continuation?: IExecutionContinuationState;
1836
+ /** Versioned state belonging to a runtime wrapper, never inferred from transcript text. */
1837
+ owner?: {
1838
+ kind: string;
1839
+ version: number;
1840
+ state: TToolParameters;
1841
+ };
1791
1842
  }
1792
- /**
1793
- * Execution-related event payload.
1794
- */
1795
- interface IExecutionEventData extends IBaseEventData {}
1796
- /**
1797
- * Tool-related event payload.
1798
- */
1799
- interface IToolEventData extends IBaseEventData {
1800
- toolName?: string;
1801
- parameters?: Record<string, TEventUniversalValue>;
1843
+ type TExecutionJournalRecord = IJournalIdentity & ((IJournalModelIdentity & {
1844
+ kind: 'model-request';
1845
+ messages: TUniversalMessage[];
1846
+ options: TJournalModelOptions;
1847
+ checkpoint?: IExecutionRoundCheckpoint;
1848
+ }) | (IJournalModelIdentity & {
1849
+ kind: 'model-response';
1850
+ response: TUniversalMessage;
1851
+ }) | (IJournalModelIdentity & {
1852
+ kind: 'model-cache-hit';
1853
+ response: TUniversalMessage;
1854
+ checkpoint?: IExecutionRoundCheckpoint;
1855
+ }) | (IJournalModelIdentity & {
1856
+ kind: 'model-failure';
1857
+ error: {
1858
+ name: string;
1859
+ message: string;
1860
+ };
1861
+ }) | (IJournalActionIdentity & {
1862
+ kind: 'tool-intent';
1863
+ parameters: TToolParameters;
1864
+ }) | (IJournalActionIdentity & {
1865
+ kind: 'tool-dispatch';
1866
+ }) | (IJournalActionIdentity & {
1867
+ kind: 'tool-effect-start';
1868
+ parameters: TToolParameters;
1869
+ }) | (IJournalActionIdentity & {
1870
+ kind: 'tool-wait';
1871
+ request: IToolContinuationPrompt & {
1872
+ requestId: string;
1873
+ };
1874
+ }) | (IJournalActionIdentity & {
1875
+ kind: 'tool-response';
1876
+ response: IToolWaitResponse;
1877
+ }) | (IJournalActionIdentity & {
1878
+ kind: 'tool-result';
1879
+ result: IToolExecutionResult;
1880
+ loadedDeferredTools?: string[];
1881
+ }));
1882
+ /**
1883
+ * Awaited, fail-closed execution boundary. Rejection stops this run before further dispatch.
1884
+ * The host owns storage, serialization of message dates, idempotency and recovery decisions.
1885
+ * Model records describe an adapter invocation, not its opaque retries or network requests.
1886
+ * Only a supported mandatory-effect checkpoint can prove an unstarted action; an intent alone cannot.
1887
+ */
1888
+ interface IExecutionJournal {
1889
+ append(record: TExecutionJournalRecord): Promise<void>;
1890
+ }
1891
+ /**
1892
+ * Reads the complete, ordered, current prefix from the same authority used for append.
1893
+ * The host must hold exclusive fenced ownership and drain the old runtime before recovery.
1894
+ * Appending an identical recordId is idempotent; conflicting content must be rejected.
1895
+ */
1896
+ interface IRecoverableExecutionJournal extends IExecutionJournal {
1897
+ read(executionId: string): Promise<readonly TExecutionJournalRecord[]>;
1898
+ }
1899
+ interface IResumeToolCallsOptions {
1900
+ executionId: string;
1901
+ callId: string;
1902
+ journal: IRecoverableExecutionJournal;
1903
+ /** Exact replies to saved requests; receipts are persisted before further execution. */
1904
+ toolResponses?: readonly IToolWaitResponse[];
1905
+ signal?: AbortSignal;
1906
+ /** Observe newly committed recovery history using the ordinary history-mutation contract. */
1907
+ onExecutionEvent?: (event: string, data: Record<string, unknown>) => void;
1802
1908
  }
1803
1909
  /**
1804
- * Agent-related event payload.
1910
+ * Continue the latest settled invocation on the original provider/model under exclusive host ownership.
1911
+ * Structured-output validators and unknown effects require reconciliation rather than automatic replay.
1912
+ * Turn-level lifecycle hooks are omitted because their effects have no durable receipts;
1913
+ * hosts requiring those effects must settle them separately. Recovered history remains available.
1805
1914
  */
1806
- interface IAgentEventData extends IBaseEventData {
1807
- agentId?: string;
1915
+ interface IResumeExecutionOptions extends Omit<IResumeToolCallsOptions, 'callId'> {
1916
+ onTextDelta?: IChatOptions['onTextDelta'];
1917
+ traceContext?: IRunTraceContext;
1808
1918
  }
1809
- type TEventListener = (eventType: string, data: IBaseEventData, context?: IEventContext) => void;
1810
- /**
1811
- * Minimal EventService contract for emitting events.
1812
- */
1813
- interface IEventService {
1814
- emit(eventType: string, data: IBaseEventData, context?: IEventContext): void;
1815
- subscribe(listener: TEventListener): void;
1816
- unsubscribe(listener: TEventListener): void;
1919
+ interface IResumeToolCallsResult {
1920
+ executionId: string;
1921
+ callId: string;
1922
+ messages: TUniversalMessage[];
1817
1923
  }
1818
- /**
1819
- * Explicit owner binding information used for scoped event emission.
1820
- */
1821
- interface IEventServiceOwnerBinding {
1822
- ownerType: string;
1823
- ownerId: string;
1824
- ownerPath: IOwnerPathSegment[];
1924
+ /** Host-owned identity for a journaled provider invocation, including routing changes. */
1925
+ interface IModelJournalContext {
1926
+ journal: IExecutionJournal;
1927
+ executionId: string;
1928
+ callId: string;
1929
+ checkpoint?: IExecutionRoundCheckpoint;
1930
+ route(): {
1931
+ providerId: string;
1932
+ modelId: string;
1933
+ };
1825
1934
  }
1826
1935
  //#endregion
1827
- //#region src/event-service/event-service.d.ts
1936
+ //#region src/interfaces/cache.d.ts
1828
1937
  /**
1829
- * Abstract base for event services.
1830
- * Concrete implementations decide how events are delivered.
1938
+ * Cache key identifying a unique LLM execution request
1831
1939
  */
1832
- declare abstract class AbstractEventService implements IEventService {
1833
- private listeners;
1834
- abstract emit(eventType: string, data: IBaseEventData, context?: IEventContext): void;
1835
- subscribe(listener: TEventListener): void;
1836
- unsubscribe(listener: TEventListener): void;
1837
- protected notifyListeners(eventType: string, data: IBaseEventData, context?: IEventContext): void;
1940
+ interface ICacheKey {
1941
+ /** SHA-256 hash of the serialized request */
1942
+ hash: string;
1943
+ /** Model identifier */
1944
+ model: string;
1945
+ /** Provider name */
1946
+ provider: string;
1838
1947
  }
1839
1948
  /**
1840
- * Default no-op event service (production-safe).
1841
- * When injected, emit() intentionally does nothing.
1949
+ * Cached LLM response entry
1842
1950
  */
1843
- declare class DefaultEventService extends AbstractEventService {
1844
- emit(_eventType: string, _data: IBaseEventData, _context?: IEventContext): void;
1951
+ interface ICacheEntry {
1952
+ /** Cache key that produced this entry */
1953
+ key: ICacheKey;
1954
+ /** Cached response content */
1955
+ response: string;
1956
+ /** When the entry was cached */
1957
+ timestamp: number;
1958
+ /** SHA-256 integrity hash of the response */
1959
+ integrityHash: string;
1845
1960
  }
1846
1961
  /**
1847
- * Singleton default event service instance.
1848
- */
1849
- declare const DEFAULT_ABSTRACT_EVENT_SERVICE: IEventService;
1850
- /**
1851
- * Check if a given service is the default no-op implementation.
1852
- */
1853
- declare function isDefaultEventService(service: IEventService): boolean;
1854
- /**
1855
- * Compose a full event name from owner prefix and local name.
1856
- * Local names must not contain dots.
1857
- */
1858
- declare function composeEventName(ownerType: string, localName: string): string;
1859
- /**
1860
- * Generate a unique span ID for distributed tracing correlation. Exported so a per-operation timing
1861
- * source (SELFHOST-004) can mint a span id it puts on BOTH the event payload and the event context.
1962
+ * Cache storage interface for pluggable backends
1862
1963
  */
1863
- declare function generateSpanId(): string;
1964
+ interface ICacheStorage {
1965
+ /** Retrieve a cached entry by key hash */
1966
+ get(hash: string): ICacheEntry | undefined;
1967
+ /** Store a cache entry */
1968
+ set(entry: ICacheEntry): void;
1969
+ /** Delete a cached entry by key hash */
1970
+ delete(hash: string): boolean;
1971
+ /** Clear all cached entries */
1972
+ clear(): void;
1973
+ /** Get cache statistics */
1974
+ getStats(): ICacheStats;
1975
+ }
1864
1976
  /**
1865
- * A scoped event service that always emits with an owner binding applied.
1977
+ * Cache performance statistics
1866
1978
  */
1867
- declare class StructuredEventService extends AbstractEventService {
1868
- private readonly base;
1869
- private readonly binding;
1870
- constructor(base: IEventService, binding: IEventServiceOwnerBinding);
1871
- emit(eventType: string, data: IBaseEventData, context?: IEventContext): void;
1872
- subscribe(listener: TEventListener): void;
1873
- unsubscribe(listener: TEventListener): void;
1979
+ interface ICacheStats {
1980
+ /** Number of cache hits */
1981
+ hits: number;
1982
+ /** Number of cache misses */
1983
+ misses: number;
1984
+ /** Current number of cached entries */
1985
+ entries: number;
1986
+ /** Hit rate (hits / (hits + misses)), 0 if no lookups */
1987
+ hitRate: number;
1874
1988
  }
1875
1989
  /**
1876
- * Bind an EventService to an explicit owner path.
1877
- * This is the standard entry point for scoped emission (path-only architecture).
1990
+ * Configuration options for execution caching
1878
1991
  */
1879
- declare function bindWithOwnerPath(base: IEventService, binding: IEventServiceOwnerBinding): IEventService;
1992
+ interface ICacheOptions {
1993
+ /** Whether caching is enabled */
1994
+ enabled: boolean;
1995
+ /** Maximum number of cached entries */
1996
+ maxEntries: number;
1997
+ /** Time-to-live in milliseconds */
1998
+ ttlMs: number;
1999
+ }
2000
+ //#endregion
2001
+ //#region src/interfaces/response-format.d.ts
1880
2002
  /**
1881
- * Alias for bindWithOwnerPath for historical call sites.
1882
- * Intentionally forwards to the single authoritative implementation.
2003
+ * Response format configuration
1883
2004
  */
1884
- declare function bindEventServiceOwner(base: IEventService, binding: IEventServiceOwnerBinding): IEventService;
2005
+ interface IResponseFormatConfig {
2006
+ type?: 'text' | 'json_object' | 'json_schema';
2007
+ /** JSON schema payload; required when `type` is `'json_schema'` (CORE-015). */
2008
+ schema?: Record<string, TConfigValue>;
2009
+ /** Schema name forwarded to provider native structured-output surfaces. */
2010
+ name?: string;
2011
+ }
1885
2012
  /**
1886
- * Observable EventService that notifies subscribed listeners.
2013
+ * Safety setting configuration
1887
2014
  */
1888
- declare class ObservableEventService extends AbstractEventService {
1889
- emit(eventType: string, data: IBaseEventData, context?: IEventContext): void;
2015
+ interface ISafetySetting {
2016
+ category: string;
2017
+ threshold: string;
2018
+ [key: string]: TConfigValue;
1890
2019
  }
1891
2020
  //#endregion
1892
- //#region src/event-service/task-events.d.ts
1893
- declare const TASK_EVENTS: {
1894
- readonly ASSIGNED: "assigned";
1895
- readonly COMPLETED: "completed";
1896
- };
1897
- declare const TASK_EVENT_PREFIX: "task";
1898
- //#endregion
1899
- //#region src/event-service/user-events.d.ts
1900
- declare const USER_EVENTS: {
1901
- readonly MESSAGE: "message";
1902
- readonly INPUT: "input";
1903
- };
1904
- declare const USER_EVENT_PREFIX: "user";
1905
- type TUserEvent = (typeof USER_EVENTS)[keyof typeof USER_EVENTS];
1906
- //#endregion
1907
- //#region src/event-service/span-events.d.ts
1908
- /**
1909
- * SELFHOST-004: per-operation span lifecycle event names. Mirrors the `TASK_EVENTS`/`USER_EVENTS`
1910
- * pattern (a const name set + a prefix). The local name is distinctive (`span_completed`, not a bare
1911
- * `completed`) so a consumer can identify a span-completion regardless of the emitting owner's prefix.
1912
- */
1913
- declare const SPAN_EVENTS: {
1914
- readonly COMPLETED: "span_completed";
1915
- };
1916
- /** Content-free completion of one provider round, separate from legacy tool timing events. */
1917
- declare const PROVIDER_CALL_EVENTS: {
1918
- readonly COMPLETED: "provider_call_completed";
1919
- };
1920
- /** A provider request moved to another model after the one it was on failed. */
1921
- declare const PROVIDER_FALLBACK_EVENTS: {
1922
- readonly SWITCHED: "provider_fallback";
1923
- };
1924
- /** The notice a `provider_fallback` event carries, or `undefined` when the payload is malformed. */
1925
- declare function readModelFallbackNotice(data: Readonly<Record<string, unknown>>): IModelFallbackNotice | undefined;
1926
- /** Content-free completion of the body actually awaited by one permitted tool call. */
1927
- declare const TOOL_BODY_EVENTS: {
1928
- readonly COMPLETED: "tool_body_completed";
1929
- };
1930
- /** Content-free decision reached for one tool call before any body runs. */
1931
- declare const TOOL_PERMISSION_EVENTS: {
1932
- readonly DECIDED: "tool_permission_decided";
1933
- };
1934
- declare const SPAN_EVENT_PREFIX: "span";
1935
- type TSpanEvent = (typeof SPAN_EVENTS)[keyof typeof SPAN_EVENTS];
2021
+ //#region src/schema/zod-schema-types.d.ts
2022
+ interface IZodParseResult {
2023
+ success: boolean;
2024
+ data?: unknown;
2025
+ error?: unknown;
2026
+ }
2027
+ interface IZodSchemaDef {
2028
+ typeName?: string;
2029
+ innerType?: IZodSchema;
2030
+ valueType?: IZodSchema;
2031
+ checks?: Array<{
2032
+ kind: string;
2033
+ value?: TUniversalValue;
2034
+ }>;
2035
+ shape?: () => Record<string, IZodSchema>;
2036
+ type?: IZodSchema;
2037
+ /**
2038
+ * `ZodEnum` holds an ARRAY here; `ZodNativeEnum` holds the enum OBJECT itself (CORE-041). One Zod
2039
+ * field name, two shapes — the converter narrows before reading it.
2040
+ */
2041
+ values?: TUniversalValue[] | Record<string, TUniversalValue>;
2042
+ description?: string;
2043
+ unknownKeys?: 'passthrough' | 'strip' | 'strict';
2044
+ /** `ZodEffects` (`.refine()` / `.transform()`) holds the schema it wraps here. */
2045
+ schema?: IZodSchema;
2046
+ /** `ZodUnion` / `ZodDiscriminatedUnion` members. */
2047
+ options?: IZodSchema[];
2048
+ /** `ZodLiteral` value. */
2049
+ value?: TUniversalValue;
2050
+ }
2051
+ interface IZodSchema {
2052
+ parse(value: unknown): unknown;
2053
+ safeParse(value: unknown): IZodParseResult;
2054
+ _def?: IZodSchemaDef;
2055
+ }
1936
2056
  /**
1937
- * SELFHOST-004: span-completion event payload — JOINS the span id with its measured duration and the
1938
- * operation name (raw scalars ONLY; references no transport type). Emitted by the per-operation timing
1939
- * source (e.g. `FunctionTool`) so a consuming layer (`agent-framework`) can build a record span entry
1940
- * WITHOUT `agent-core` depending on `agent-interface-transport` (no cycle). The payload `spanId` is the
1941
- * AUTHORITATIVE id a consumer reads; owner/turn correlation is applied by the event service's binding
1942
- * (`ownerPath` on the emitted `IEventContext`). Note the context's own auto-minted `spanId` is a
1943
- * separate scope tag and need not equal this payload id — always read the payload id for the span.
2057
+ * Schema conversion options
1944
2058
  */
1945
- interface ISpanCompletionEventData extends IBaseEventData {
1946
- /** The span id (equals the emitted event's context `spanId`). */
1947
- spanId: string;
1948
- /** Measured wall-clock duration of the operation, in milliseconds. */
1949
- durationMs: number;
1950
- /** The operation name (e.g. the tool name). */
1951
- op: string;
2059
+ interface ISchemaConversionOptions {
2060
+ includeDescription?: boolean;
2061
+ strictTypes?: boolean;
2062
+ allowAdditionalProperties?: boolean;
1952
2063
  }
1953
2064
  //#endregion
1954
- //#region src/interfaces/tool.d.ts
1955
- type TToolContextExtensionValue = TUniversalValue | Date | Error | TLoggerData | TContextData | TToolParameters | TToolMetadata;
1956
- /**
1957
- * Tool metadata structure - specific type definition
1958
- */
1959
- type TToolMetadata = Record<string, string | number | boolean | string[] | number[] | boolean[] | TToolParameters>;
2065
+ //#region src/schema/structured-output.d.ts
2066
+ /** Explicit raw-JSON-schema form of `IRunOptions.output`. */
2067
+ interface IJsonSchemaOutput {
2068
+ /** JSON Schema (object root, universal subset) the response must match. */
2069
+ jsonSchema: IToolSchema['parameters'];
2070
+ /** Optional schema name forwarded to provider native surfaces. */
2071
+ name?: string;
2072
+ }
2073
+ /** Accepted `IRunOptions.output` values: a Zod schema or an explicit JSON-schema wrapper. */
2074
+ type TStructuredOutputSchema = IZodSchema | IJsonSchemaOutput;
2075
+ type TStructuredOutputValidation = {
2076
+ success: true;
2077
+ value: unknown;
2078
+ } | {
2079
+ success: false;
2080
+ issues: string[];
2081
+ };
2082
+ /** Internal SSOT representation every `output` value normalizes to. */
2083
+ interface IStructuredOutputSpec {
2084
+ name: string;
2085
+ jsonSchema: IToolSchema['parameters'];
2086
+ validate(value: unknown): TStructuredOutputValidation;
2087
+ }
2088
+ /** Normalize an accepted `output` value into the internal spec. */
2089
+ declare function normalizeStructuredOutput(output: TStructuredOutputSchema): IStructuredOutputSpec;
1960
2090
  /**
1961
- * Tool execution data - domain payload for tool results.
2091
+ * Validate a value against the universal JSON-schema subset (`IParameterSchema`). Covers type,
2092
+ * required, enum, items, nested properties, unions and numeric bounds — the full expressible
2093
+ * surface of the subset, at every level.
1962
2094
  *
1963
- * IMPORTANT:
1964
- * - This must support structured tool outputs without resorting to `any`.
1965
- * - Prefer `ToolResultData` (derived from the canonical `UniversalValue` axis).
2095
+ * CORE-039: this is the ONE complete walk. `parameter-validator` delegates its depth here rather
2096
+ * than keeping a second, shallower copy, and the two must therefore agree by construction.
1966
2097
  */
2098
+ declare function validateAgainstJsonSchema(schema: IParameterSchema, value: unknown, path: string): string[];
1967
2099
  /**
1968
- * Tool execution result - extended for ToolExecutionData compatibility
2100
+ * Parse the model's final text into a JSON value. Tolerates a fenced
2101
+ * ```json code block wrapper (providers without native enforcement commonly
2102
+ * emit one); the parsed value is still strictly schema-validated afterwards.
1969
2103
  */
1970
- interface IToolResult {
1971
- success: boolean;
1972
- data?: TUniversalValue;
1973
- error?: string;
1974
- metadata?: TToolMetadata;
1975
- [key: string]: TToolContextExtensionValue | undefined;
1976
- }
2104
+ declare function parseStructuredResponseText(text: string): {
2105
+ success: true;
2106
+ value: unknown;
2107
+ } | {
2108
+ success: false;
2109
+ issue: string;
2110
+ };
2111
+ //#endregion
2112
+ //#region src/interfaces/run-options.d.ts
1977
2113
  /**
1978
- * Enhanced tool execution result with additional metadata
2114
+ * The per-RUN contract: what one `run()` may override or observe, as distinct from the agent's
2115
+ * standing configuration in `IAgentConfig`.
2116
+ *
2117
+ * Split out of `agent.ts` when PEER-007 added `driverId`. That file sits at a frozen size baseline,
2118
+ * and the anti-monolith rule asks for a split rather than one more field on a file already at its
2119
+ * limit. The two execution-event types come along because `onExecutionEvent` is their only consumer
2120
+ * — leaving them behind would have made this module import back from `agent.ts`.
1979
2121
  */
1980
- interface IToolExecutionResult {
1981
- /** Whether execution was successful */
1982
- success: boolean;
1983
- /** Tool name that was executed */
1984
- toolName?: string;
1985
- /** Execution result or data */
1986
- result?: TUniversalValue;
1987
- /** Error message if execution failed */
1988
- error?: string;
1989
- /** Execution duration in milliseconds */
1990
- duration?: number;
1991
- /** Unique execution ID */
1992
- executionId?: string;
1993
- /** Additional metadata */
1994
- metadata?: TToolMetadata;
1995
- }
2122
+ type TExecutionEventData = Record<string, unknown>;
2123
+ type TExecutionEventCallback = (event: string, data: TExecutionEventData) => void;
1996
2124
  /**
1997
- * Tool execution context - type-safe context for tool execution
1998
- * Enhanced with hierarchical execution tracking support
2125
+ * Agent run options - type-safe interface for all agent execution options
1999
2126
  */
2000
- interface IToolExecutionContext {
2001
- toolName: string;
2002
- parameters: TToolParameters;
2127
+ interface IRunOptions {
2128
+ /** Run-scoped temperature override — wins over `defaultModel.temperature` (CORE-016). */
2129
+ temperature?: number;
2130
+ /** Run-scoped max output tokens override — wins over `defaultModel.maxTokens` (CORE-016). */
2131
+ maxTokens?: number;
2003
2132
  /**
2004
- * Run-scoped cancellation signal (CORE-018). Long-running tools MUST honor it: terminate
2005
- * the underlying work (kill the child process, abort the network request) and return an
2006
- * interrupted/failed result. Completing silently after an abort is a contract violation.
2133
+ * Run-scoped tool-invocation directive — wins over `defaultModel.toolChoice` (CORE-017).
2134
+ * `'auto'` (model decides), `'none'` (suppress tool calls), `'required'` (must call some
2135
+ * tool), or `{ tool: name }` (must call the named tool; the name is validated against the
2136
+ * run's tool list and a miss throws). Forcing applies to the run's first model call only;
2137
+ * rounds after tool results revert to `'auto'` (see `TToolChoice`).
2007
2138
  */
2008
- signal?: AbortSignal;
2009
- /** Direct remote calls deny decisions that would require human interaction. */
2010
- permissionInteraction?: 'interactive' | 'deny';
2011
- executionId?: string;
2012
- userId?: string;
2013
- sessionId?: string;
2014
- metadata?: TToolMetadata;
2015
- /** Parent execution ID for hierarchical tool execution tracking */
2016
- parentExecutionId?: string;
2017
- /** Root execution ID (Team/Agent level) for complete execution tree tracking */
2018
- rootExecutionId?: string;
2019
- /** Execution depth level (0: Team, 1: Agent, 2: Tool, etc.) */
2020
- executionLevel?: number;
2021
- /** Execution path array showing the complete execution hierarchy */
2022
- executionPath?: string[];
2023
- /** Real-time execution data for accurate tracking (no simulation) */
2024
- realTimeData?: {
2025
- /** Actual execution start time */
2026
- startTime: Date;
2027
- /** Actual input parameters passed to the tool */
2028
- actualParameters: TToolParameters;
2029
- /** Tool-provided estimated duration (optional) */
2030
- estimatedDuration?: number;
2031
- };
2139
+ toolChoice?: TToolChoice;
2032
2140
  /**
2033
- * Additional tool execution context extensions.
2034
- *
2035
- * IMPORTANT:
2036
- * - Avoid ad-hoc top-level fields to keep the contract stable.
2037
- * - Use this map for forward-compatible extra data with constrained value types.
2141
+ * Leave a provider's own hosted tools (a vendor-run web search) out of this run's requests. They
2142
+ * run at the vendor and never pass the permission gate, so a run whose tools a policy restricts
2143
+ * must not reach them.
2038
2144
  */
2039
- extensions?: Record<string, TToolContextExtensionValue>;
2040
- /** Owner context propagated from EventService */
2041
- ownerType?: string;
2042
- ownerId?: string;
2043
- ownerPath?: IOwnerPathSegment[];
2044
- sourceId?: string;
2145
+ withholdHostedTools?: boolean;
2146
+ sessionId?: string;
2147
+ userId?: string;
2045
2148
  /**
2046
- * Tool-call scoped EventService instance.
2047
- * Caller (ExecutionService/ToolExecutionService) is responsible for providing
2048
- * an ownerPath-bound EventService for this tool call.
2149
+ * PEER-007 (issue #1915): who this run is attributed to, for display. Per-run because it changes
2150
+ * per turn — one session serves the operator and any peer addressing it. Never authorization.
2049
2151
  */
2050
- eventService?: IEventService;
2152
+ driverId?: string;
2051
2153
  /**
2052
- * Unbound base EventService instance.
2053
- *
2054
- * Required when a tool needs to create another owner-bound EventService
2055
- * for a different owner (e.g., creating an agent from a tool call).
2056
- *
2057
- * NOTE: Do not wrap an already owner-bound EventService to bind a different owner.
2058
- * Owner-bound instances must not be layered across different owners.
2154
+ * Where this run's turn came from (a peer's message, an external event, an agent wake-up), stored
2155
+ * beside `driverId` on the user message so a transcript carried elsewhere still says it. Display
2156
+ * only, like `driverId`; absent for the operator's own turn.
2059
2157
  */
2060
- baseEventService?: IEventService;
2158
+ turnSource?: string;
2159
+ metadata?: TMetadata;
2061
2160
  /**
2062
- * The service this call's caller would give the tool with `setEventService`, carried with the
2063
- * call instead. One tool instance can serve several agents, and the service set on it is
2064
- * whichever agent set one last; a tool that emits events of its own (the `FunctionTool` span)
2065
- * emits them here when present, so they reach the agent that made the call. The no-op default
2066
- * service means that caller wants none.
2161
+ * Run-scoped EPHEMERAL system context (SELFHOST-008 P3). A transient system-role block included in THIS
2162
+ * run's provider request(s) only — it is **never written to the conversation store**. An explicitly
2163
+ * configured execution journal records it as request/recovery state. It does not bloat conversation
2164
+ * history or force a static-system-prompt rebuild. Content-free neutral channel: the
2165
+ * caller decides what to put here (e.g. per-turn recalled memory). Absent ⇒ no change.
2067
2166
  */
2068
- instanceEventService?: IEventService;
2167
+ ephemeralSystemContext?: string;
2069
2168
  /**
2070
- * Injected "ask the user" port (CMD-004). Present when an interactive renderer is attached, letting
2071
- * a tool solicit a structured answer from the user (the model-issued question seam consumed by
2072
- * CMD-005). Absent in non-interactive contexts; a tool that asks must treat absence as "no human
2073
- * available" (never a silent guess).
2169
+ * Host-owned trace context for this run's provider calls. Each invoked call — forced summary
2170
+ * included, cache hits excluded — gets a `traceparent` whose parent is that call's own span, and
2171
+ * only an adapter whose origin is listed sends it. Never recorded in execution events.
2074
2172
  */
2075
- ask?: IUserInteraction['ask'];
2173
+ traceContext?: IRunTraceContext;
2076
2174
  /**
2077
- * CLI-1990: the deferred-tool catalog the runtime injects (`ToolExecutionService`), so a search
2078
- * tool can list what is withheld and load it for the rest of the session. Present on every tool
2079
- * call the execution loop issues; a tool other than the search tool has no reason to read it.
2175
+ * AbortSignal for cancelling execution. Aborting an in-flight run does not throw: `run()` resolves
2176
+ * (and `runStream()` returns) the last assistant text the turn committed before the abort, possibly
2177
+ * `''`; a reply cut off mid-stream is kept in history with `state: 'interrupted'`. Read
2178
+ * `signal.aborted` to tell an interrupted run from a completed one.
2080
2179
  */
2081
- deferredTools?: IDeferredToolCatalog;
2180
+ signal?: AbortSignal;
2181
+ /** Join an aborted/timed-out provider call before completing; an uncooperative call may remain pending. */
2182
+ awaitProviderSettlement?: boolean;
2183
+ /** Per-run streaming text callback. Prefer this over mutating provider callback state. */
2184
+ onTextDelta?: TTextDeltaCallback;
2185
+ /** Per-run replay event callback for provider/tool execution boundaries. */
2186
+ onExecutionEvent?: TExecutionEventCallback;
2187
+ /** Awaited model/tool admission and result records. Failures terminate this run. */
2188
+ executionJournal?: IExecutionJournal;
2082
2189
  /**
2083
- * The ID core mints for this one tool body, unique even when a vendor reuses its tool call ID.
2084
- * The body's exported span is derived from it, so it is also what a propagated parent names.
2190
+ * Maximum execution rounds for this run. A **round** is one provider (model) call plus the
2191
+ * execution of every tool call that reply requested; a reply with no tool calls ends the loop,
2192
+ * so a plain Q&A turn is exactly 1 round. This caps model/tool cycles within ONE `run()` — it is
2193
+ * not a tool-count limit and not a multi-turn conversation limit. When the cap is hit the run
2194
+ * stops after the current round. Use 0 for no core round cap. Defaults to
2195
+ * `IAgentConfig.maxExecutionRounds`.
2085
2196
  */
2086
- toolBodyId?: string;
2197
+ maxExecutionRounds?: number;
2198
+ /** Max times the same tool may be called with identical input before aborting. Unset = no limit. */
2199
+ maxSameToolInputs?: number;
2087
2200
  /**
2088
- * Present only when the run carries trusted trace context: the `traceparent` naming this body's
2089
- * span and the exact origins it may be sent to. A tool that makes outbound requests sends it only
2090
- * to a listed origin.
2201
+ * Treat a turn that ends in tool calls (no trailing text) as a valid completion instead of
2202
+ * forcing one extra provider call to generate a summary (CORE-011). For decision-agent patterns
2203
+ * (router/orchestrator/classifier) the tool call IS the answer — this removes the one-call tax.
2204
+ * The summary call is the one made when the round cap ends the loop on a tool round; before the cap
2205
+ * the model is called again after tool results as usual, so a decision agent sets
2206
+ * `maxExecutionRounds` too (e.g. `1`). The run resolves with the turn's text, or `''` when it
2207
+ * produced none; consumers read the outcome from the tool results.
2091
2208
  */
2092
- outboundTraceContext?: IOutboundTraceContext;
2209
+ allowToolOnlyCompletion?: boolean;
2093
2210
  /**
2094
- * Present only when the host lets shell children inherit the trace: the environment naming this
2095
- * body's span. Only the foreground shell tool applies it, to its own child.
2211
+ * Schema-enforced structured output (CORE-015). Accepts a Zod schema or an explicit
2212
+ * `{ jsonSchema }` wrapper. `run` then resolves to the validated, typed object instead of a
2213
+ * string: the schema is forwarded to the provider's native structured-output surface where one
2214
+ * exists, and the final response is always parsed and validated core-side; a violation triggers
2215
+ * a bounded retry with the validation issues fed back as the next turn's input. Every attempt is
2216
+ * a real conversation turn (history stays append-only). Exhausted retries throw
2217
+ * `StructuredOutputError`.
2096
2218
  */
2097
- shellTraceEnv?: ISubprocessTraceEnv;
2219
+ output?: TStructuredOutputSchema;
2098
2220
  /**
2099
- * Present only when the host lets command hooks inherit the trace: the environment naming the
2100
- * prompt root, for the hooks fired around this body. Separate from {@link shellTraceEnv}, whose
2101
- * span is the body's own.
2221
+ * Retry budget for structured output validation failures — the number of additional attempts
2222
+ * after the first (default 2). Only meaningful with `output` set.
2102
2223
  */
2103
- hookTraceEnv?: ISubprocessTraceEnv;
2224
+ outputRetries?: number;
2104
2225
  }
2226
+ //#endregion
2227
+ //#region src/plugins/event-emitter/types.d.ts
2228
+ declare const EXECUTION_EVENT_NAMES: {
2229
+ readonly START: "execution.start";
2230
+ readonly COMPLETE: "execution.complete";
2231
+ readonly ERROR: "execution.error";
2232
+ };
2233
+ declare const TOOL_EVENT_NAMES: {
2234
+ readonly CALL_START: "tool.call_start";
2235
+ readonly CALL_COMPLETE: "tool.call_complete";
2236
+ readonly CALL_ERROR: "tool.call_error";
2237
+ };
2238
+ declare const AGENT_EVENT_NAMES: {
2239
+ readonly EXECUTION_START: "agent.execution_start";
2240
+ readonly EXECUTION_COMPLETE: "agent.execution_complete";
2241
+ readonly EXECUTION_ERROR: "agent.execution_error";
2242
+ readonly CREATED: "agent.created";
2243
+ };
2244
+ type TExecutionEventName = (typeof EXECUTION_EVENT_NAMES)[keyof typeof EXECUTION_EVENT_NAMES];
2245
+ type TToolEventName = (typeof TOOL_EVENT_NAMES)[keyof typeof TOOL_EVENT_NAMES];
2246
+ type TAgentEventName = (typeof AGENT_EVENT_NAMES)[keyof typeof AGENT_EVENT_NAMES];
2105
2247
  /**
2106
- * Parameter validation result
2248
+ * Event types that can be emitted.
2249
+ *
2250
+ * IMPORTANT:
2251
+ * - Do not use string literals for event names outside this module.
2252
+ * - Import and use EVENT_EMITTER_EVENTS instead.
2107
2253
  */
2108
- interface IParameterValidationResult {
2109
- /** Whether parameters are valid */
2110
- isValid: boolean;
2111
- /** Validation error messages */
2112
- errors: string[];
2113
- }
2254
+ declare const EVENT_EMITTER_EVENTS: {
2255
+ readonly EXECUTION_START: "execution.start";
2256
+ readonly EXECUTION_COMPLETE: "execution.complete";
2257
+ readonly EXECUTION_ERROR: "execution.error";
2258
+ readonly TOOL_BEFORE_EXECUTE: "tool.beforeExecute";
2259
+ readonly TOOL_AFTER_EXECUTE: "tool.afterExecute";
2260
+ readonly TOOL_SUCCESS: "tool.success";
2261
+ readonly TOOL_ERROR: "tool.call_error";
2262
+ readonly CONVERSATION_START: "conversation.start";
2263
+ readonly CONVERSATION_COMPLETE: "conversation.complete";
2264
+ readonly CONVERSATION_ERROR: "conversation.error";
2265
+ readonly AGENT_EXECUTION_START: "agent.execution_start";
2266
+ readonly AGENT_EXECUTION_COMPLETE: "agent.execution_complete";
2267
+ readonly AGENT_EXECUTION_ERROR: "agent.execution_error";
2268
+ readonly AGENT_CREATED: "agent.created";
2269
+ readonly AGENT_DESTROYED: "agent.destroyed";
2270
+ readonly PLUGIN_LOADED: "plugin.loaded";
2271
+ readonly PLUGIN_UNLOADED: "plugin.unloaded";
2272
+ readonly PLUGIN_ERROR: "plugin.error";
2273
+ readonly ERROR_OCCURRED: "error.occurred";
2274
+ readonly WARNING_OCCURRED: "warning.occurred";
2275
+ readonly MODULE_INITIALIZE_START: "module.initialize.start";
2276
+ readonly MODULE_INITIALIZE_COMPLETE: "module.initialize.complete";
2277
+ readonly MODULE_INITIALIZE_ERROR: "module.initialize.error";
2278
+ readonly MODULE_EXECUTION_START: "module.execution.start";
2279
+ readonly MODULE_EXECUTION_COMPLETE: "module.execution.complete";
2280
+ readonly MODULE_EXECUTION_ERROR: "module.execution.error";
2281
+ readonly MODULE_DISPOSE_START: "module.dispose.start";
2282
+ readonly MODULE_DISPOSE_COMPLETE: "module.dispose.complete";
2283
+ readonly MODULE_DISPOSE_ERROR: "module.dispose.error";
2284
+ readonly MODULE_REGISTERED: "module.registered";
2285
+ readonly MODULE_UNREGISTERED: "module.unregistered";
2286
+ readonly EXECUTION_HIERARCHY: "execution.hierarchy";
2287
+ readonly EXECUTION_REALTIME: "execution.realtime";
2288
+ readonly TOOL_REALTIME: "tool.realtime";
2289
+ readonly CUSTOM: "custom";
2290
+ };
2291
+ type TEventName = TExecutionEventName | TToolEventName | TAgentEventName | 'tool.beforeExecute' | 'tool.afterExecute' | 'tool.success' | 'conversation.start' | 'conversation.complete' | 'conversation.error' | 'agent.destroyed' | 'plugin.loaded' | 'plugin.unloaded' | 'plugin.error' | 'error.occurred' | 'warning.occurred' | 'module.initialize.start' | 'module.initialize.complete' | 'module.initialize.error' | 'module.execution.start' | 'module.execution.complete' | 'module.execution.error' | 'module.dispose.start' | 'module.dispose.complete' | 'module.dispose.error' | 'module.registered' | 'module.unregistered' | 'execution.hierarchy' | 'execution.realtime' | 'tool.realtime' | 'custom';
2114
2292
  /**
2115
- * Generic tool executor function
2293
+ * Valid event data value types
2116
2294
  */
2117
- type TToolExecutor<TParams = TToolParameters, TResult = TUniversalValue> = (parameters: TParams, context?: IToolExecutionContext) => Promise<TResult>;
2295
+ type TEventDataValue = string | number | boolean | Date | null | undefined | TEventDataValue[] | {
2296
+ [key: string]: TEventDataValue;
2297
+ };
2118
2298
  /**
2119
- * Base tool interface
2299
+ * Event data structure
2120
2300
  */
2121
- interface ITool {
2122
- /** Tool schema */
2123
- schema: IToolSchema;
2124
- /**
2125
- * Execute the tool with given parameters
2126
- */
2127
- execute(parameters: TToolParameters, context?: IToolExecutionContext): Promise<IToolResult>;
2128
- /**
2129
- * Validate tool parameters
2130
- */
2131
- validate(parameters: TToolParameters): boolean;
2132
- /**
2133
- * Validate tool parameters with detailed result
2134
- */
2135
- validateParameters(parameters: TToolParameters): IParameterValidationResult;
2136
- /**
2137
- * Get tool description
2138
- */
2139
- getDescription(): string;
2301
+ interface IEventEmitterEventData {
2302
+ type: TEventName;
2303
+ timestamp: Date;
2304
+ executionId?: string;
2305
+ sessionId?: string;
2306
+ userId?: string;
2307
+ data?: Record<string, TEventDataValue>;
2308
+ error?: Error;
2309
+ metadata?: Record<string, TEventDataValue>;
2140
2310
  }
2141
2311
  /**
2142
- * Function tool implementation
2312
+ * Event listener function
2143
2313
  */
2144
- interface IFunctionTool extends ITool {
2145
- /** Function to execute */
2146
- fn: TToolExecutor;
2147
- }
2314
+ type TEventEmitterListener = (event: IEventEmitterEventData) => void | Promise<void>;
2148
2315
  /**
2149
- * Tool registry interface
2316
+ * Console-like interface for the EventEmitterPlugin.
2317
+ *
2318
+ * Use this interface for typing instead of the concrete EventEmitterPlugin class.
2150
2319
  */
2151
- interface IToolRegistry {
2152
- /**
2153
- * Register a tool
2154
- */
2155
- register(tool: ITool): void;
2156
- /**
2157
- * Unregister a tool
2158
- */
2159
- unregister(name: string): void;
2160
- /**
2161
- * Get tool by name
2162
- */
2163
- get(name: string): ITool | undefined;
2164
- /**
2165
- * Get all registered tools
2166
- */
2167
- getAll(): ITool[];
2168
- /**
2169
- * Get tool schemas
2170
- */
2171
- getSchemas(): IToolSchema[];
2172
- /**
2173
- * Check if tool exists
2174
- */
2175
- has(name: string): boolean;
2176
- /**
2177
- * Clear all tools
2178
- */
2179
- clear(): void;
2320
+ interface IEventEmitterPlugin {
2321
+ on(eventType: TEventName, listener: TEventEmitterListener, options?: {
2322
+ once?: boolean;
2323
+ filter?: (event: IEventEmitterEventData) => boolean;
2324
+ }): string;
2325
+ once(eventType: TEventName, listener: TEventEmitterListener, filter?: (event: IEventEmitterEventData) => boolean): string;
2326
+ off(eventType: TEventName, handlerIdOrListener: string | TEventEmitterListener): boolean;
2327
+ emit(eventType: TEventName, eventData?: Partial<IEventEmitterEventData>): Promise<void>;
2328
+ }
2329
+ //#endregion
2330
+ //#region src/abstracts/abstract-module-types.d.ts
2331
+ /** Module execution context */
2332
+ interface IModuleExecutionContext {
2333
+ executionId?: string;
2334
+ sessionId?: string;
2335
+ userId?: string;
2336
+ agentName?: string;
2337
+ metadata?: Record<string, string | number | boolean | Date>;
2338
+ [key: string]: string | number | boolean | Date | Record<string, string | number | boolean | Date> | undefined;
2339
+ }
2340
+ /** Module execution result */
2341
+ interface IModuleExecutionResult {
2342
+ success: boolean;
2343
+ data?: IModuleResultData;
2344
+ error?: Error;
2345
+ duration?: number;
2346
+ metadata?: Record<string, string | number | boolean | Date>;
2347
+ }
2348
+ /** Module result data */
2349
+ interface IModuleResultData {
2350
+ [key: string]: string | number | boolean | Record<string, string | number | boolean> | undefined;
2351
+ }
2352
+ /** Base module options */
2353
+ interface IBaseModuleOptions {
2354
+ enabled?: boolean;
2355
+ config?: Record<string, string | number | boolean>;
2356
+ }
2357
+ /** Module capabilities */
2358
+ interface IModuleCapabilities {
2359
+ capabilities: string[];
2360
+ dependencies?: string[];
2361
+ optionalDependencies?: string[];
2362
+ }
2363
+ /** Module type descriptor */
2364
+ interface IModuleDescriptor {
2365
+ type: string;
2366
+ category: ModuleCategory;
2367
+ layer: ModuleLayer;
2368
+ dependencies?: string[];
2369
+ capabilities?: string[];
2370
+ }
2371
+ /** Module categories */
2372
+ declare enum ModuleCategory {
2373
+ CORE = "core",
2374
+ STORAGE = "storage",
2375
+ PROCESSING = "processing",
2376
+ INTEGRATION = "integration",
2377
+ INTERFACE = "interface",
2378
+ CAPABILITY = "capability"
2379
+ }
2380
+ /** Module layers */
2381
+ declare enum ModuleLayer {
2382
+ INFRASTRUCTURE = "infrastructure",
2383
+ CORE = "core",
2384
+ APPLICATION = "application",
2385
+ DOMAIN = "domain",
2386
+ PRESENTATION = "presentation"
2387
+ }
2388
+ /** Module data for introspection */
2389
+ interface IModuleData {
2390
+ name: string;
2391
+ version: string;
2392
+ type: string;
2393
+ enabled: boolean;
2394
+ initialized: boolean;
2395
+ capabilities: IModuleCapabilities;
2396
+ metadata?: Record<string, string | number | boolean>;
2397
+ }
2398
+ /** Module statistics */
2399
+ interface IModuleStats {
2400
+ enabled: boolean;
2401
+ initialized: boolean;
2402
+ executionCount: number;
2403
+ errorCount: number;
2404
+ lastActivity?: Date;
2405
+ averageExecutionTime?: number;
2406
+ [key: string]: string | number | boolean | Date | undefined;
2407
+ }
2408
+ /** Type-safe module interface */
2409
+ interface IModule<TOptions extends IBaseModuleOptions = IBaseModuleOptions, TStats = IModuleStats> {
2410
+ name: string;
2411
+ version: string;
2412
+ enabled: boolean;
2413
+ initialize(options?: TOptions, eventEmitter?: IEventEmitterPlugin): Promise<void>;
2414
+ dispose?(): Promise<void>;
2415
+ execute?(context: IModuleExecutionContext): Promise<IModuleExecutionResult>;
2416
+ getModuleType(): IModuleDescriptor;
2417
+ getCapabilities(): IModuleCapabilities;
2418
+ getData?(): IModuleData;
2419
+ getStats?(): TStats;
2420
+ isEnabled(): boolean;
2421
+ isInitialized(): boolean;
2180
2422
  }
2181
2423
  //#endregion
2182
2424
  //#region src/abstracts/abstract-plugin-types.d.ts
@@ -2510,6 +2752,11 @@ interface IAbstractTool<TParams = TToolParameters, TResult = IToolResult> {
2510
2752
  interface IToolContract<TParameters = TToolParameters, TResult = IToolResult> {
2511
2753
  readonly schema: IToolSchema;
2512
2754
  execute(parameters: TParameters, context: IToolExecutionContext): Promise<TResult>;
2755
+ /**
2756
+ * Wrappers await admission exactly once with final canonical arguments after preconditions and before
2757
+ * the body. Denial returns without admission. Admission failures propagate unchanged.
2758
+ */
2759
+ executeWithAdmission?(parameters: TParameters, context: IToolExecutionContext, admit: TToolEffectAdmission<TParameters>): Promise<TResult>;
2513
2760
  validate(parameters: TParameters): boolean;
2514
2761
  validateParameters(parameters: TParameters): IParameterValidationResult;
2515
2762
  getDescription(): string;
@@ -3120,6 +3367,8 @@ interface IToolManager {
3120
3367
  * deferral is not engaged. The same member `IDeferredToolCatalog` declares.
3121
3368
  */
3122
3369
  listDeferredTools(): IToolSchema[];
3370
+ /** Loaded residency for compatible execution checkpoints. */
3371
+ getLoadedDeferredTools?(): string[];
3123
3372
  /**
3124
3373
  * CLI-1990: mark deferred tools loaded for the rest of the session and return their schemas; an
3125
3374
  * unknown name throws, naming it, before anything is loaded. The same member
@@ -4444,6 +4693,35 @@ declare class ErrorUtils {
4444
4693
  static wrapProviderError(error: TErrorExternalInput, provider: string, operation: string): ProviderError;
4445
4694
  }
4446
4695
  //#endregion
4696
+ //#region src/utils/execution-journal-error.d.ts
4697
+ /** A persistence/admission failure must never become a model-visible, retryable tool failure. */
4698
+ declare class ExecutionJournalError extends Error {
4699
+ readonly code = "EXECUTION_JOURNAL_FAILED";
4700
+ readonly recordId: string;
4701
+ readonly kind: TExecutionJournalRecord['kind'];
4702
+ constructor(record: TExecutionJournalRecord, cause: unknown);
4703
+ }
4704
+ //#endregion
4705
+ //#region src/utils/execution-suspended-error.d.ts
4706
+ /** A persisted wait is control flow, never a failed tool result or semantic completion. */
4707
+ declare class ExecutionSuspendedError extends Error {
4708
+ readonly code = "EXECUTION_SUSPENDED";
4709
+ readonly requests: readonly IToolWaitRequest[];
4710
+ constructor(requests: readonly IToolWaitRequest[]);
4711
+ }
4712
+ //#endregion
4713
+ //#region src/utils/execution-recovery-error.d.ts
4714
+ type TExecutionRecoveryErrorCode = 'EXECUTION_RECOVERY_INVALID' | 'EXECUTION_RECOVERY_REQUIRED' | 'EXECUTION_RECOVERY_CONFLICT';
4715
+ /** Recovery refuses unproven effects or history instead of guessing whether to replay them. */
4716
+ declare class ExecutionRecoveryError extends Error {
4717
+ readonly code: TExecutionRecoveryErrorCode;
4718
+ readonly actionIds: readonly string[];
4719
+ constructor(code: TExecutionRecoveryErrorCode, message: string, actionIds?: readonly string[]);
4720
+ }
4721
+ //#endregion
4722
+ //#region src/utils/execution-control-error.d.ts
4723
+ declare function isExecutionControlError(error: unknown): error is ExecutionJournalError | ExecutionRecoveryError | ExecutionSuspendedError;
4724
+ //#endregion
4447
4725
  //#region src/utils/timer-types.d.ts
4448
4726
  /**
4449
4727
  * Cross-platform timer identifier type.
@@ -4551,6 +4829,9 @@ declare function subprocessTraceEnvironment(base: Readonly<Record<string, string
4551
4829
  */
4552
4830
  declare function traceHeadersFor(baseUrl: string | undefined, traceContext: IOutboundTraceContext | undefined): Readonly<Record<string, string>>;
4553
4831
  //#endregion
4832
+ //#region src/services/execution-journal.d.ts
4833
+ declare function callJournaledProvider(chat: (messages: TUniversalMessage[], options: IChatOptions) => Promise<TUniversalMessage>, messages: TUniversalMessage[], options: IChatOptions, context?: IModelJournalContext): Promise<TUniversalMessage>;
4834
+ //#endregion
4554
4835
  //#region src/schema/zod-to-json-schema.d.ts
4555
4836
  /**
4556
4837
  * Convert a Zod schema to the universal JSON-schema subset.
@@ -5481,6 +5762,7 @@ declare class Tools extends AbstractManager implements IToolManager {
5481
5762
  /** Whether a call to this tool would execute now: registered, and offered by the projection. */
5482
5763
  isToolOffered(name: string): boolean;
5483
5764
  /** Deferred tools not yet loaded — the population a search discovers. Empty while deferral is off. */
5765
+ getLoadedDeferredTools(): string[];
5484
5766
  listDeferredTools(): IToolSchema[];
5485
5767
  /**
5486
5768
  * Mark deferred tools loaded for the rest of the session. Every name is resolved before any is
@@ -5620,6 +5902,16 @@ declare class Robota extends RobotaBase implements IAgent<IAgentConfig, IRunOpti
5620
5902
  listRuntimeTools(): Promise<IToolSchema[]>;
5621
5903
  /** Explicit tool invocation through the same executor used by model turns. */
5622
5904
  invokeRuntimeTool(name: string, parameters: TToolParameters, context: IToolExecutionContext): Promise<IToolExecutionResult>;
5905
+ /**
5906
+ * Resume a compatible journaled execution without adding input or repeating settled calls.
5907
+ * Retain restored history for the host to checkpoint or discard, including on interruption.
5908
+ */
5909
+ resume(value: IResumeExecutionOptions): Promise<string>;
5910
+ /**
5911
+ * Restore the latest journaled tool batch without a model call or new user input.
5912
+ * The host must own the journal exclusively and settle the previous runtime first.
5913
+ */
5914
+ resumeToolCalls(value: IResumeToolCallsOptions): Promise<IResumeToolCallsResult>;
5623
5915
  /**
5624
5916
  * Concurrency contract (CORE-012): a Robota instance owns ONE conversation history, so
5625
5917
  * concurrent `run`/`runStream` calls on the same instance are serialized on an internal queue —
@@ -6000,6 +6292,19 @@ declare function isRegistryTransactionError(error: unknown): error is IRegistryT
6000
6292
  */
6001
6293
  declare function runRegistryTransaction(steps: readonly IRegistryTransactionStep[]): Promise<void>;
6002
6294
  //#endregion
6295
+ //#region src/services/provider-call-usage.d.ts
6296
+ type TProviderUsageProvenance = 'complete' | 'partial' | 'absent';
6297
+ interface IVerifiedProviderCallUsage {
6298
+ readonly provenance: TProviderUsageProvenance;
6299
+ readonly promptTokens?: number;
6300
+ readonly completionTokens?: number;
6301
+ readonly totalTokens?: number;
6302
+ /** The part of `promptTokens` served from the provider's prompt cache, when it was reported. */
6303
+ readonly cacheReadTokens?: number;
6304
+ }
6305
+ /** Keep billing/telemetry stricter than context-window heuristics: only adapter-attested totals count. */
6306
+ declare function verifiedProviderCallUsage(message: TUniversalMessage | undefined): IVerifiedProviderCallUsage;
6307
+ //#endregion
6003
6308
  //#region src/services/execution-usage.d.ts
6004
6309
  /**
6005
6310
  * Aggregate token totals over a whole session/sub-session history.
@@ -7016,8 +7321,7 @@ declare function estimateBlendedCostPer1000(modelId: string): number | undefined
7016
7321
  * `packages/agent-core/docs/HOOK-CATALOG.md` § "Blocking semantics" — cited here rather than
7017
7322
  * recounted, because two different groupings of the same set were in circulation and a second copy
7018
7323
  * is what let them drift. Which events enforce is recorded in `HOOK_ENFORCEMENT_POLICY`
7019
- * (`./enforcement-policy.ts`); see the catalog SSOT `packages/agent-core/docs/HOOK-CATALOG.md` for
7020
- * per-event timing, fire-site, and blocking semantics.
7324
+ * (`./enforcement-policy.ts`); the catalog also gives per-event timing and fire sites.
7021
7325
  */
7022
7326
  type THookEvent = 'PreToolUse' | 'PostToolUse' | 'SessionStart' | 'SessionEnd' | 'Stop' | 'StopFailure' | 'PreCompact' | 'PostCompact' | 'UserPromptSubmit' | 'SubagentStart' | 'SubagentStop' | 'WorktreeCreate' | 'WorktreeRemove' | 'PreModelCall' | 'PostModelCall' | 'PermissionDecision';
7023
7327
  /** Claude Code compatible session end reasons. */
@@ -7118,7 +7422,7 @@ interface IHookInput {
7118
7422
  agent_type?: string;
7119
7423
  /** Subagent transcript path when available (SubagentStop only) */
7120
7424
  agent_transcript_path?: string;
7121
- /** Claude Code permission mode at time of event (e.g. "default", "plan", "acceptEdits", "bypassPermissions") */
7425
+ /** Permission mode at the time of the event (e.g. "default", "plan", "acceptEdits", "bypassPermissions", "auto") */
7122
7426
  permission_mode?: string;
7123
7427
  /**
7124
7428
  * Provider model identifier for the model call (PreModelCall/PostModelCall only).
@@ -7295,5 +7599,5 @@ declare function decodeHookVerdict(raw: string, source: THookDefinition['type'],
7295
7599
  /** Does a hook that reached no verdict block at this event? */
7296
7600
  declare function isEnforcing(event: THookEvent): boolean;
7297
7601
  //#endregion
7298
- export { AGENT_EVENTS, AGENT_EVENT_PREFIX, AbstractAIProvider, AbstractAgent, AbstractEventService, AbstractExecutor, AbstractManager, AbstractPlugin, AbstractTool, AgentFactory, AgentTemplates, AuthenticationError, CONFIRM_NO, CONFIRM_YES, CONTEXT_ESTIMATE_CHARS_PER_TOKEN, CacheIntegrityError, CircuitBreakerOpenError, ConfigurationError, ConsoleLogger, ConversationHistory, ConversationStore, DEFAULT_ABSTRACT_EVENT_SERVICE, DEFAULT_BACKGROUND_PERMISSION_POLICY, DEFAULT_CONTEXT_WINDOW, DEFAULT_MAX_OUTPUT, DEFAULT_TOOL_RESULT_HARD_CHARS, DEFAULT_TOOL_RESULT_WARNING_CHARS, DEFERRED_WITHOUT_LOADER_MESSAGE, DefaultEventService, ENV_REFERENCE_PREFIX, EVENT_EMITTER_EVENTS, EXECUTION_EVENTS, EXECUTION_EVENT_PREFIX, ErrorUtils, EventEmitterPlugin, EventHistoryModule, ExecutionProxy, FunctionTool, GuardrailExecutor, type IAIProvider, type IAIProviderInstance, type IAIProviderManager, type IAbstractTool, type IAbstractToolOptions, type IActionDefault, type IActionOption, type IActionRequest, type IAgent, type IAgentConfig, type IAgentCreationStats, type IAgentEventData, type IAgentFactoryOptions, type IAgentHookDefinition, type IAgentLifecycleEvents, type IAgentTemplate, type IAssistantMessage, type IAssistantUsageMetadata, type IBaseEventData, type IBaseMessage, type IBoundedOutput, type IBoundedOutputOptions, type ICacheEntry, type ICacheKey, type ICacheOptions, type ICacheStats, type ICacheStorage, type IChatExecutionRequest, type IChatOptions, type ICommandHookDefinition, type IContextOptions, type IContextTokenEstimate, type IContextTokenEstimateOptions, type IContextTokenUsage, type IContextWindowState, type IConversationContext, type IConversationResponse, type IConversationService, type IConversationServiceOptions, type ICredentialKey, type ICredentialStore, type ICriticalPathContext, type IDeferredToolCatalog, type IDestroyResult, type IDirent, type IEventContext, type IEventEmitterEventData, type IEventEmitterHierarchicalEventData, type IEventEmitterMetrics, type IEventEmitterMetricsSnapshot, type IEventEmitterPlugin, type IEventEmitterPluginOptions, type IEventHistoryModule, type IEventHistoryRecord, type IEventHistorySnapshot, type IEventObjectValue, type IEventService, type IEventServiceOwnerBinding, type IExecutionEventData, type IExecutionProxyConfig, type IExecutor, IExecutorAwareProviderConfig, type IExecutorChatResult, type IExecutorStreamMessageEvent, type IExecutorStreamTerminalEvent, type IFileSystem, type IFileSystemAsync, type IFunctionTool, type IGroupChatOrchestrationSpec, type IGuardrailHookDefinition, type IGuardrailResult, type IHandoffOrchestrationSpec, type IHierarchicalOrchestrationSpec, type IHistoryEntry, type IHookGroup, type IHookInput, type IHookTypeExecutor, type IHttpHookDefinition, type IImageComposeRequest, type IImageEditRequest, type IImageGenerationProvider, type IImageGenerationRequest, type IImageGenerationResult, type IInlineImageInputSource, type IInlineImageMessagePart, type IJsonSchemaOutput, type ILocalExecutorConfig, ILogger, ILoggerOptions, IManagerLifecycleOptions, type IMediaOutputRef, type IMediaProviderConfig, type IMediaProviderCredentialRequirement, type IMediaProviderDefinition, type IMediaProviderOverrides, type IMessageTokenUsage, type IModelCapabilityDeviation, type IModelDefinition, type IModelEffortCapability, type IModelEffortOutcome, type IModelEffortResolution, type IModelFallbackNotice, type IModelPrice, type IModelRef, type IObjectParameterSchema, type IOpenAPIToolConfig, type IOrchestrationDelegation, type IOrchestrationEventData, type IOrchestrationRunResult, type IOrchestrationStep, type IOrchestrationStepResult, type IOutboundTraceContext, type IOwnerPathSegment, type IParallelOrchestrationSpec, type IParameterRule, type IParameterSchema, type IParameterValidationResult, type IPermissionEvaluationContext, type IPermissionLists, type IPermissionPatternProblem, type IPermissionPolicyContext, type IPermissionPolicyProjection, IPlatformShell, IPlatformShellResolutionRequest, type IPlugin, type IPluginConfig, type IPluginContext, type IPluginContract, type IPluginData, type IPluginErrorContext, type IPluginExecutionContext, type IPluginExecutionResult, type IPluginHooks, type IPluginOptions, type IPluginStats, type IProgressReportingTool, type IPromptHookDefinition, type IProviderCapabilities, type IProviderCapabilityTable, type IProviderCredentialRequirement, type IProviderDefinition, type IProviderDefinitionConfig, type IProviderEndpoint, type IProviderFailureClassification, IProviderFailureDetails, type IProviderFunctionCallingCapability, type IProviderMediaError, type IProviderModelCatalog, type IProviderModelCatalogEntry, type IProviderModelEffortTable, type IProviderNativeRawPayloadEvent, type IProviderNativeWebToolCapabilities, type IProviderNativeWebToolCapability, type IProviderNativeWebToolRequest, type IProviderOptions, type IProviderProbeResult, type IProviderProfileConfig, type IProviderProfileDefaults, type IProviderRequest, IProviderRuntimeConfig, type IProviderSetupHelpLink, type IProviderSetupStepDefinition, type IProviderSpecificOptions, type IProviderStructuredOutputCapability, type IRawProviderResponse, type IReadOnlyCommandContext, type IRegistryOwnedLifecycle, type IRegistryTransactionError, type IRegistryTransactionStep, type IRemoteExecutorConfig, type IResponseFormatConfig, type IRunOptions, type IRunTraceContext, type ISchemaClosureChange, type ISchemaClosureOptions, type ISchemaConversionOptions, type ISequentialOrchestrationSpec, type ISession, type ISessionUsageTotals, ISimpleValidationResult, type ISpanCompletionEventData, type ISpinner, type IStats, type IStreamExecutionRequest, type IStreamingChunk, type IStructuredOutputResolutionInput, type IStructuredOutputSpec, type ISubprocessTraceEnv, type ISystemMessage, type ITemplateApplicationResult, type ITerminalOutput, type ITextMessagePart, type ITokenUsage, type ITokenUsageWithCacheRead, type ITool, type IToolCall, type IToolContract, type IToolEventData, type IToolExecutionContext, type IToolExecutionRequest, type IToolExecutionResult, type IToolExecutionStep, type IToolFactory, type IToolManager, type IToolMessage, type IToolPermissionArgument, type IToolPermissionProfile, type IToolRegistry, type IToolResult, type IToolResultAdmissionOptions, type IToolResultSpillStore, type IToolSchema, type IToolSchemaProjection, type IToolSchemaProjectionChange, type IToolSchemaProjectionProfile, type IToolWithEventService, type IUniversalObjectValue, type IUriImageInputSource, type IUriImageMessagePart, type IUserInteraction, type IUserMessage, IUtilLogEntry, type IVideoGenerationProvider, type IVideoGenerationRequest, type IVideoJobAccepted, type IVideoJobSnapshot, type IZodParseResult, type IZodSchema, type IZodSchemaDef, InMemoryEventEmitterMetrics, LocalExecutor, MAX_TOOL_RESULT_CHARS, MODEL_EFFORT_VALUES, MODEL_PRICES, MessageConverter, ModelNotAvailableError, NetworkError, ORCHESTRATION_EVENTS, ORCHESTRATION_EVENT_PREFIX, ObservableEventService, PARAMETER_SCHEMA_KEYWORDS, PERMISSIVE_TOOL_SCHEMA_PROFILE, PROTECTED_DIRECTORY_NAMES, PROTECTED_FILE_NAMES, PROVIDER_CALL_EVENTS, PROVIDER_FALLBACK_EVENTS, PluginCategory, PluginError, PluginPriority, ProviderError, RISK_CLASS_POLICY, RateLimitError, Robota, RobotaError, SPAN_EVENTS, SPAN_EVENT_PREFIX, STRICT_TOOL_SCHEMA_PROFILE, SameToolInputLoopError, SilentLogger, StorageError, StructuredEventService, StructuredOutputError, TASK_EVENTS, TASK_EVENT_PREFIX, type TActionResponse, type TArgumentKind, type TBackgroundPermissionPolicy, TComplexConfigValue, TConfigData, TConfigValue, TContextData, type TConversationContextMetadata, type TEnvResolver, TErrorContextData, TErrorExternalInput, type TEventEmitterListener, type TEventExtensionValue, type TEventListener, type TEventLoggerData, type TEventName, type TEventUniversalValue, type TExecutionEventCallback, type TExecutionEventData, type TExecutionEventName, type TExecutorStreamEvent, type TGuardrail, type THookDefinition, type THookEvent, type THookOutcome, type THooksConfig, type TImageInputSource, type TJSONSchemaEnum, type TJSONSchemaKind, TLoggerData, type TManagerToolParameters, type TMatchDirection, TMessageConverterRegistry, TMessageFormatConverter, type TMessageState, TMetadata, TMetadataValue, type TModelEffort, type TModelEffortDisposition, type TModelEffortNativeControl, type TModelEffortOutcomeCallback, type TModelEffortProviderDispatch, type TModelEffortSelection, type TModelFallbackCallback, TOOL_BODY_EVENTS, TOOL_EVENTS, TOOL_EVENT_PREFIX, TOOL_PERMISSION_EVENTS, TOOL_SCHEMA_PROJECTION_MAX_DEPTH, TOOL_SCHEMA_PROJECTION_MAX_NODES, TOOL_SEARCH_TOOL_NAME, type TOrchestrationEvent, type TOrchestrationPrimitive, type TOutputRetention, type TParameterDefaultValue, type TPermissionDecision, type TPermissionMode, type TPrimitiveValue, type TProviderConfigValue, type TProviderCredentialField, type TProviderFailureReason, TProviderLoggingData, type TProviderMediaResult, TProviderMessage, type TProviderModelCapability, type TProviderModelCatalogStatus, type TProviderModelLifecycle, type TProviderNativeRawPayload, type TProviderNativeRawPayloadCallback, type TProviderNativeRawPayloadKind, type TProviderOptionValueBase, type TProviderSetupField, type TProviderSetupHelpLinkKind, TRUST_TO_MODE, type TResolveInWorkspace, type TResponseMetadata, type TRoleModelMap, type TSessionEndReason, TShellKind, type TSpanEvent, type TStructuredOutputMechanism, type TStructuredOutputProvenance, type TStructuredOutputSchema, type TStructuredOutputValidation, type TSubprocessTraceClass, type TTextDeltaCallback, type TTimerId, type TToolArgs, type TToolChoice, type TToolExecutionFunction, type TToolExecutionParameters, type TToolExecutor, type TToolMetadata, TToolParameters, type TToolProgressCallback, type TToolResultAdmissionErrorCode, type TToolRiskClass, type TToolSchemaProjectionOutcome, type TToolSchemaProjectionProfileBase, type TToolSearchMode, type TToolSearchSetting, type TTrustLevel, type TUniversalArrayValue, type TUniversalMessage, type TUniversalMessageMetadata, type TUniversalMessagePart, type TUniversalMessageRole, type TUniversalValue, type TUserEvent, TUtilLogLevel, ToolExecutionError, ToolRegistry, ToolResultAdmissionError, TypeUtils, UNCLASSIFIED_TOOL_FALLBACK, USER_EVENTS, USER_EVENT_PREFIX, UnsupportedShellError, ValidationError, Validator, admitToolResult, allowRulesForAutoMode, applyPresetToolLists, assertProviderNativeWebToolsAvailable, assertResidentToolRemains, bindEventServiceOwner, bindWithOwnerPath, buildTraceparent, calculateModelCost, chatEntryToMessage, classifyProviderFailure, clearRegisteredToolProfiles, closeObjectSchemas, collectAssistantUsageMetadata, composeEventName, confirmAction, createAssistantMessage, createBoundedOutput, createDefaultProviderCapabilities, createExecutionProxy, createImageProviderFromDefinition, createLogger, createModelEffortOutcome, createProviderFromConfig, createRecordEnvResolver, createSystemMessage, createToolMessage, createUserMessage, createVideoProviderFromDefinition, decodeHookVerdict, estimateBlendedCostPer1000, estimateContextTokensFromMessages, estimateSerializedContextTokens, estimateToolSchemaTokens, evaluatePermission, extractEnumValues, findInvalidPermissionPatterns, findMediaProviderDefinition, findModelDefinition, findPermissionPatternWarnings, findProviderDefinition, formatEnvReference, formatSupportedProviderTypes, formatTokenCount, generateSpanId, getGlobalLogLevel, getGlobalLoggerSink, getMessagesForAPI, getModelContextWindow, getModelMaxOutput, getModelName, getProviderCapabilities, getProviderCredentialRequirement, getSchemaTypeName, getToolEstimatedDuration, getToolExecutionSteps, getToolPermissionProfile, hasUsableSecretReference, hasValidationConstraints, hashToolSchema, isAbortFailure, isAssistantMessage, isBroadExecutionAllowRule, isChatEntry, isConfirmed, isDefaultEventService, isEnforcing, isEnvReference, isImageGenerationProvider, isMediaProviderDefinition, isMintedSpanId, isModelEffort, isProgressReportingTool, isProtectedPath, isReadOnlyCommandLine, isRegistryTransactionError, isSystemMessage, isToolDeniedOutright, isToolMessage, isUserMessage, isVideoGenerationProvider, lifecycleOf, logger, lookupModelPrice, matchesAnyPattern, messageToHistoryEntry, modelDeclaresCapability, multiSelectAction, normalizeProviderConfig, normalizeStructuredOutput, outboundTraceContextFor, parseParameterRule, parseStructuredResponseText, peerDriverOf, printablePeerDriver, processEnvResolver, projectPermissionPolicy, projectToolSchema, providerCallSpanId, readModelFallbackNotice, readProviderFailureDetails, readTokenUsageFromMessage, readTokenUsageFromMetadata, registerModelMetadata, registerToolPermissionProfile, removesCriticalPath, requiresFreshApproval, resolveEnvReference, resolveMediaProviderConfig, resolveModelCapabilities, resolveModelCapability, resolveModelEffort, resolvePlatformShell, resolveStructuredOutputCapability, runHooks, runRegistryTransaction, selectAction, setGlobalLogLevel, setGlobalLoggerSink, setToolProgressCallback, shellArgumentForDisplay, spanIdFromMintedId, splitCommandSegments, startPeriodicTask, stopPeriodicTask, subprocessTraceEnvironment, sumHistoryUsage, sumMessagesUsage, textAction, toProviderError, toolNameMatches, toolNamesToPatterns, toolTraceContextFor, traceEnvFor, traceHeadersFor, validateAgainstJsonSchema, validateAgentConfig, validateApiKey, validateModelName, validatePermissionPattern, validateProviderName, validateUserInput, wasToolResultAdmitted, withEventEmission, zodToJsonSchema };
7602
+ export { AGENT_EVENTS, AGENT_EVENT_PREFIX, AbstractAIProvider, AbstractAgent, AbstractEventService, AbstractExecutor, AbstractManager, AbstractPlugin, AbstractTool, AgentFactory, AgentTemplates, AuthenticationError, CONFIRM_NO, CONFIRM_YES, CONTEXT_ESTIMATE_CHARS_PER_TOKEN, CacheIntegrityError, CircuitBreakerOpenError, ConfigurationError, ConsoleLogger, ConversationHistory, ConversationStore, DEFAULT_ABSTRACT_EVENT_SERVICE, DEFAULT_BACKGROUND_PERMISSION_POLICY, DEFAULT_CONTEXT_WINDOW, DEFAULT_MAX_OUTPUT, DEFAULT_TOOL_RESULT_HARD_CHARS, DEFAULT_TOOL_RESULT_WARNING_CHARS, DEFERRED_WITHOUT_LOADER_MESSAGE, DefaultEventService, ENV_REFERENCE_PREFIX, EVENT_EMITTER_EVENTS, EXECUTION_EVENTS, EXECUTION_EVENT_PREFIX, ErrorUtils, EventEmitterPlugin, EventHistoryModule, ExecutionJournalError, ExecutionProxy, ExecutionRecoveryError, ExecutionSuspendedError, FunctionTool, GuardrailExecutor, type IAIProvider, type IAIProviderInstance, type IAIProviderManager, type IAbstractTool, type IAbstractToolOptions, type IActionDefault, type IActionOption, type IActionRequest, type IAgent, type IAgentConfig, type IAgentCreationStats, type IAgentEventData, type IAgentFactoryOptions, type IAgentHookDefinition, type IAgentLifecycleEvents, type IAgentTemplate, type IAssistantMessage, type IAssistantUsageMetadata, type IBaseEventData, type IBaseMessage, type IBoundedOutput, type IBoundedOutputOptions, type ICacheEntry, type ICacheKey, type ICacheOptions, type ICacheStats, type ICacheStorage, type IChatExecutionRequest, type IChatOptions, type ICommandHookDefinition, type IContextOptions, type IContextTokenEstimate, type IContextTokenEstimateOptions, type IContextTokenUsage, type IContextWindowState, type IConversationContext, type IConversationResponse, type IConversationService, type IConversationServiceOptions, type ICredentialKey, type ICredentialStore, type ICriticalPathContext, type IDeferredToolCatalog, type IDestroyResult, type IDirent, type IEventContext, type IEventEmitterEventData, type IEventEmitterHierarchicalEventData, type IEventEmitterMetrics, type IEventEmitterMetricsSnapshot, type IEventEmitterPlugin, type IEventEmitterPluginOptions, type IEventHistoryModule, type IEventHistoryRecord, type IEventHistorySnapshot, type IEventObjectValue, type IEventService, type IEventServiceOwnerBinding, type IExecutionContinuationState, type IExecutionEventData, type IExecutionJournal, type IExecutionProxyConfig, type IExecutionRoundCheckpoint, type IExecutor, IExecutorAwareProviderConfig, type IExecutorChatResult, type IExecutorStreamMessageEvent, type IExecutorStreamTerminalEvent, type IFileSystem, type IFileSystemAsync, type IFunctionTool, type IGroupChatOrchestrationSpec, type IGuardrailHookDefinition, type IGuardrailResult, type IHandoffOrchestrationSpec, type IHierarchicalOrchestrationSpec, type IHistoryEntry, type IHookGroup, type IHookInput, type IHookTypeExecutor, type IHttpHookDefinition, type IImageComposeRequest, type IImageEditRequest, type IImageGenerationProvider, type IImageGenerationRequest, type IImageGenerationResult, type IInlineImageInputSource, type IInlineImageMessagePart, type IJsonSchemaOutput, type ILocalExecutorConfig, ILogger, ILoggerOptions, IManagerLifecycleOptions, type IMediaOutputRef, type IMediaProviderConfig, type IMediaProviderCredentialRequirement, type IMediaProviderDefinition, type IMediaProviderOverrides, type IMessageTokenUsage, type IModelCapabilityDeviation, type IModelDefinition, type IModelEffortCapability, type IModelEffortOutcome, type IModelEffortResolution, type IModelFallbackNotice, type IModelJournalContext, type IModelPrice, type IModelRef, type IObjectParameterSchema, type IOpenAPIToolConfig, type IOrchestrationDelegation, type IOrchestrationEventData, type IOrchestrationRunResult, type IOrchestrationStep, type IOrchestrationStepResult, type IOutboundTraceContext, type IOwnerPathSegment, type IParallelOrchestrationSpec, type IParameterRule, type IParameterSchema, type IParameterValidationResult, type IPermissionEvaluationContext, type IPermissionLists, type IPermissionPatternProblem, type IPermissionPolicyContext, type IPermissionPolicyProjection, IPlatformShell, IPlatformShellResolutionRequest, type IPlugin, type IPluginConfig, type IPluginContext, type IPluginContract, type IPluginData, type IPluginErrorContext, type IPluginExecutionContext, type IPluginExecutionResult, type IPluginHooks, type IPluginOptions, type IPluginStats, type IProgressReportingTool, type IPromptHookDefinition, type IProviderCapabilities, type IProviderCapabilityTable, type IProviderCredentialRequirement, type IProviderDefinition, type IProviderDefinitionConfig, type IProviderEndpoint, type IProviderFailureClassification, IProviderFailureDetails, type IProviderFunctionCallingCapability, type IProviderMediaError, type IProviderModelCatalog, type IProviderModelCatalogEntry, type IProviderModelEffortTable, type IProviderNativeRawPayloadEvent, type IProviderNativeWebToolCapabilities, type IProviderNativeWebToolCapability, type IProviderNativeWebToolRequest, type IProviderOptions, type IProviderProbeResult, type IProviderProfileConfig, type IProviderProfileDefaults, type IProviderRequest, IProviderRuntimeConfig, type IProviderSetupHelpLink, type IProviderSetupStepDefinition, type IProviderSpecificOptions, type IProviderStructuredOutputCapability, type IRawProviderResponse, type IReadOnlyCommandContext, type IRecoverableExecutionJournal, type IRegistryOwnedLifecycle, type IRegistryTransactionError, type IRegistryTransactionStep, type IRemoteExecutorConfig, type IResponseFormatConfig, type IResumeExecutionOptions, type IResumeToolCallsOptions, type IResumeToolCallsResult, type IRunOptions, type IRunTraceContext, type ISchemaClosureChange, type ISchemaClosureOptions, type ISchemaConversionOptions, type ISequentialOrchestrationSpec, type ISession, type ISessionUsageTotals, ISimpleValidationResult, type ISpanCompletionEventData, type ISpinner, type IStats, type IStreamExecutionRequest, type IStreamingChunk, type IStructuredOutputResolutionInput, type IStructuredOutputSpec, type ISubprocessTraceEnv, type ISystemMessage, type ITemplateApplicationResult, type ITerminalOutput, type ITextMessagePart, type ITokenUsage, type ITokenUsageWithCacheRead, type ITool, type IToolActionIdentity, type IToolCall, type IToolContinuation, type IToolContinuationPrompt, type IToolContract, type IToolEventData, type IToolExecutionContext, type IToolExecutionRequest, type IToolExecutionResult, type IToolExecutionStep, type IToolFactory, type IToolManager, type IToolMessage, type IToolPermissionArgument, type IToolPermissionProfile, type IToolRegistry, type IToolResult, type IToolResultAdmissionOptions, type IToolResultSpillStore, type IToolSchema, type IToolSchemaProjection, type IToolSchemaProjectionChange, type IToolSchemaProjectionProfile, type IToolWaitRequest, type IToolWaitResponse, type IToolWaitState, type IToolWithEventService, type IUniversalObjectValue, type IUriImageInputSource, type IUriImageMessagePart, type IUserInteraction, type IUserMessage, IUtilLogEntry, type IVerifiedProviderCallUsage, type IVideoGenerationProvider, type IVideoGenerationRequest, type IVideoJobAccepted, type IVideoJobSnapshot, type IZodParseResult, type IZodSchema, type IZodSchemaDef, InMemoryEventEmitterMetrics, LocalExecutor, MAX_TOOL_RESULT_CHARS, MODEL_EFFORT_VALUES, MODEL_PRICES, MessageConverter, ModelNotAvailableError, NetworkError, ORCHESTRATION_EVENTS, ORCHESTRATION_EVENT_PREFIX, ObservableEventService, PARAMETER_SCHEMA_KEYWORDS, PERMISSIVE_TOOL_SCHEMA_PROFILE, PROTECTED_DIRECTORY_NAMES, PROTECTED_FILE_NAMES, PROVIDER_CALL_EVENTS, PROVIDER_FALLBACK_EVENTS, PluginCategory, PluginError, PluginPriority, ProviderError, RISK_CLASS_POLICY, RateLimitError, Robota, RobotaError, SPAN_EVENTS, SPAN_EVENT_PREFIX, STRICT_TOOL_SCHEMA_PROFILE, SameToolInputLoopError, SilentLogger, StorageError, StructuredEventService, StructuredOutputError, TASK_EVENTS, TASK_EVENT_PREFIX, type TActionResponse, type TArgumentKind, type TBackgroundPermissionPolicy, TComplexConfigValue, TConfigData, TConfigValue, TContextData, type TConversationContextMetadata, type TEnvResolver, TErrorContextData, TErrorExternalInput, type TEventEmitterListener, type TEventExtensionValue, type TEventListener, type TEventLoggerData, type TEventName, type TEventUniversalValue, type TExecutionEventCallback, type TExecutionEventData, type TExecutionEventName, type TExecutionJournalRecord, type TExecutionRecoveryErrorCode, type TExecutorStreamEvent, type TGuardrail, type THookDefinition, type THookEvent, type THookOutcome, type THooksConfig, type TImageInputSource, type TJSONSchemaEnum, type TJSONSchemaKind, type TJournalModelOptions, TLoggerData, type TManagerToolParameters, type TMatchDirection, TMessageConverterRegistry, TMessageFormatConverter, type TMessageState, TMetadata, TMetadataValue, type TModelEffort, type TModelEffortDisposition, type TModelEffortNativeControl, type TModelEffortOutcomeCallback, type TModelEffortProviderDispatch, type TModelEffortSelection, type TModelFallbackCallback, TOOL_BODY_EVENTS, TOOL_EVENTS, TOOL_EVENT_PREFIX, TOOL_PERMISSION_EVENTS, TOOL_SCHEMA_PROJECTION_MAX_DEPTH, TOOL_SCHEMA_PROJECTION_MAX_NODES, TOOL_SEARCH_TOOL_NAME, type TOrchestrationEvent, type TOrchestrationPrimitive, type TOutputRetention, type TParameterDefaultValue, type TPermissionDecision, type TPermissionMode, type TPrimitiveValue, type TProviderConfigValue, type TProviderCredentialField, type TProviderFailureReason, TProviderLoggingData, type TProviderMediaResult, TProviderMessage, type TProviderModelCapability, type TProviderModelCatalogStatus, type TProviderModelLifecycle, type TProviderNativeRawPayload, type TProviderNativeRawPayloadCallback, type TProviderNativeRawPayloadKind, type TProviderOptionValueBase, type TProviderSetupField, type TProviderSetupHelpLinkKind, type TProviderUsageProvenance, TRUST_TO_MODE, type TResolveInWorkspace, type TResponseMetadata, type TRoleModelMap, type TSessionEndReason, TShellKind, type TSpanEvent, type TStructuredOutputMechanism, type TStructuredOutputProvenance, type TStructuredOutputSchema, type TStructuredOutputValidation, type TSubprocessTraceClass, type TTextDeltaCallback, type TTimerId, type TToolArgs, type TToolChoice, type TToolEffectAdmission, type TToolExecutionFunction, type TToolExecutionParameters, type TToolExecutor, type TToolMetadata, TToolParameters, type TToolProgressCallback, type TToolResultAdmissionErrorCode, type TToolRiskClass, type TToolSchemaProjectionOutcome, type TToolSchemaProjectionProfileBase, type TToolSearchMode, type TToolSearchSetting, type TTrustLevel, type TUniversalArrayValue, type TUniversalMessage, type TUniversalMessageMetadata, type TUniversalMessagePart, type TUniversalMessageRole, type TUniversalValue, type TUserEvent, TUtilLogLevel, ToolExecutionError, ToolRegistry, ToolResultAdmissionError, TypeUtils, UNCLASSIFIED_TOOL_FALLBACK, USER_EVENTS, USER_EVENT_PREFIX, UnsupportedShellError, ValidationError, Validator, admitToolResult, allowRulesForAutoMode, applyPresetToolLists, assertProviderNativeWebToolsAvailable, assertResidentToolRemains, bindEventServiceOwner, bindWithOwnerPath, buildTraceparent, calculateModelCost, callJournaledProvider, chatEntryToMessage, classifyProviderFailure, clearRegisteredToolProfiles, closeObjectSchemas, collectAssistantUsageMetadata, composeEventName, confirmAction, createAssistantMessage, createBoundedOutput, createDefaultProviderCapabilities, createExecutionProxy, createImageProviderFromDefinition, createLogger, createModelEffortOutcome, createProviderFromConfig, createRecordEnvResolver, createSystemMessage, createToolMessage, createUserMessage, createVideoProviderFromDefinition, decodeHookVerdict, estimateBlendedCostPer1000, estimateContextTokensFromMessages, estimateSerializedContextTokens, estimateToolSchemaTokens, evaluatePermission, extractEnumValues, findInvalidPermissionPatterns, findMediaProviderDefinition, findModelDefinition, findPermissionPatternWarnings, findProviderDefinition, formatEnvReference, formatSupportedProviderTypes, formatTokenCount, generateSpanId, getGlobalLogLevel, getGlobalLoggerSink, getMessagesForAPI, getModelContextWindow, getModelMaxOutput, getModelName, getProviderCapabilities, getProviderCredentialRequirement, getSchemaTypeName, getToolEstimatedDuration, getToolExecutionSteps, getToolPermissionProfile, hasUsableSecretReference, hasValidationConstraints, hashToolSchema, isAbortFailure, isAssistantMessage, isBroadExecutionAllowRule, isChatEntry, isConfirmed, isDefaultEventService, isEnforcing, isEnvReference, isExecutionControlError, isImageGenerationProvider, isMediaProviderDefinition, isMintedSpanId, isModelEffort, isProgressReportingTool, isProtectedPath, isReadOnlyCommandLine, isRegistryTransactionError, isSystemMessage, isToolDeniedOutright, isToolMessage, isUserMessage, isVideoGenerationProvider, lifecycleOf, logger, lookupModelPrice, matchesAnyPattern, messageToHistoryEntry, modelDeclaresCapability, multiSelectAction, normalizeProviderConfig, normalizeStructuredOutput, outboundTraceContextFor, parseParameterRule, parseStructuredResponseText, peerDriverOf, printablePeerDriver, processEnvResolver, projectPermissionPolicy, projectToolSchema, providerCallSpanId, readModelFallbackNotice, readProviderFailureDetails, readTokenUsageFromMessage, readTokenUsageFromMetadata, registerModelMetadata, registerToolPermissionProfile, removesCriticalPath, requiresFreshApproval, resolveEnvReference, resolveMediaProviderConfig, resolveModelCapabilities, resolveModelCapability, resolveModelEffort, resolvePlatformShell, resolveStructuredOutputCapability, runHooks, runRegistryTransaction, scrubSecrets, selectAction, setGlobalLogLevel, setGlobalLoggerSink, setToolProgressCallback, shellArgumentForDisplay, spanIdFromMintedId, splitCommandSegments, startPeriodicTask, stopPeriodicTask, subprocessTraceEnvironment, sumHistoryUsage, sumMessagesUsage, textAction, toProviderError, toolNameMatches, toolNamesToPatterns, toolTraceContextFor, traceEnvFor, traceHeadersFor, validateAgainstJsonSchema, validateAgentConfig, validateApiKey, validateModelName, validatePermissionPattern, validateProviderName, validateUserInput, verifiedProviderCallUsage, wasToolResultAdmitted, withEventEmission, zodToJsonSchema };
7299
7603
  //# sourceMappingURL=index.d.ts.map