@fevex/core 0.1.0-alpha.0 → 0.1.0-alpha.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (52) hide show
  1. package/README.md +1110 -52
  2. package/dist/agents/index.d.mts +2 -23
  3. package/dist/agents/index.mjs +1 -1
  4. package/dist/artifacts/index.d.mts +2 -0
  5. package/dist/artifacts/index.mjs +2 -0
  6. package/dist/artifacts-gUzemET7.mjs +440 -0
  7. package/dist/channels/index.d.mts +2 -0
  8. package/dist/channels/index.mjs +192 -0
  9. package/dist/evals/index.d.mts +153 -0
  10. package/dist/evals/index.mjs +422 -0
  11. package/dist/fevex-_KOsOsB8.d.mts +129 -0
  12. package/dist/http/index.d.mts +150 -0
  13. package/dist/http/index.mjs +692 -0
  14. package/dist/index-26ilbzAs.d.mts +50 -0
  15. package/dist/index-B8EcvWeN.d.mts +103 -0
  16. package/dist/index-BEqYWean.d.mts +118 -0
  17. package/dist/index-Btth7rdL.d.mts +58 -0
  18. package/dist/index-CFzrvDQ0.d.mts +21 -0
  19. package/dist/index-CIHWc5V1.d.mts +116 -0
  20. package/dist/index-D7r0puBi.d.mts +64 -0
  21. package/dist/index-DHcfIfh-.d.mts +224 -0
  22. package/dist/index-DUhNa7IR.d.mts +73 -0
  23. package/dist/index-lCCFokc6.d.mts +617 -0
  24. package/dist/index.d.mts +39 -15
  25. package/dist/index.mjs +4962 -208
  26. package/dist/knowledge/index.d.mts +2 -0
  27. package/dist/knowledge/index.mjs +289 -0
  28. package/dist/model-stream-JQdHDDcj.mjs +131 -0
  29. package/dist/models/index.d.mts +2 -27
  30. package/dist/observability/index.d.mts +2 -0
  31. package/dist/observability/index.mjs +1 -0
  32. package/dist/policies/index.d.mts +2 -0
  33. package/dist/policies/index.mjs +6 -0
  34. package/dist/run-error-Cr17wPGH.mjs +23 -0
  35. package/dist/run-support-CmZ6Xo6H.mjs +162 -0
  36. package/dist/runtime/index.d.mts +2 -17
  37. package/dist/runtime/index.mjs +354 -1
  38. package/dist/sandbox/index.d.mts +2 -0
  39. package/dist/sandbox/index.mjs +147 -0
  40. package/dist/teams/index.d.mts +2 -0
  41. package/dist/teams/index.mjs +2 -0
  42. package/dist/teams-Ctz676G4.mjs +82 -0
  43. package/dist/testing/index.d.mts +40 -8
  44. package/dist/testing/index.mjs +668 -23
  45. package/dist/tools/index.d.mts +3 -31
  46. package/dist/tools/index.mjs +442 -2
  47. package/dist/types-CckDlhYo.d.mts +575 -0
  48. package/dist/workflows/index.d.mts +2 -0
  49. package/dist/workflows/index.mjs +6 -0
  50. package/package.json +43 -3
  51. package/dist/exact-definition-NHBBFlFR.d.mts +0 -4
  52. package/dist/index-D_RBJmVt.d.mts +0 -44
@@ -0,0 +1,617 @@
1
+ import { o as ToolEmbeddingCache, t as ToolReranker, z as ExactDefinition } from "./index-DHcfIfh-.mjs";
2
+ import { c as ReasoningEffort, i as ModelRef, l as ToolChoice, r as ModelMetadata, s as ModelUsage, t as ModelGateway, u as EmbeddingModel } from "./index-D7r0puBi.mjs";
3
+ import { f as RunId, g as ToolSpec, i as AgentMessage, l as JsonValue, o as ExecutionContext, s as JsonObject, t as AgentEvent } from "./types-CckDlhYo.mjs";
4
+ import { StandardSchemaV1 } from "@standard-schema/spec";
5
+ //#region src/runtime/run-store.d.ts
6
+ /** Stable identifier for conversation history shared across runs. */
7
+ type SessionId = string;
8
+ type RunStatus = 'running' | 'paused' | 'completed' | 'failed' | 'cancelled';
9
+ interface ApprovalRequest {
10
+ id: string;
11
+ toolCallId: string;
12
+ toolName: string;
13
+ toolLabel?: string;
14
+ input: JsonValue;
15
+ risk: 'read' | 'write' | 'sensitive' | 'destructive';
16
+ requestedAt: string;
17
+ }
18
+ type ElicitationMode = 'pause' | 'forbid';
19
+ type ApprovalMode = 'pause' | 'deny';
20
+ interface ElicitationRequest {
21
+ id: string;
22
+ toolCallId: string;
23
+ prompt: string;
24
+ responseSchema: JsonObject;
25
+ requestedAt: string;
26
+ expiresAt?: string;
27
+ }
28
+ type AgentRunPause = {
29
+ type: 'elicitation';
30
+ request: ElicitationRequest;
31
+ } | {
32
+ type: 'approval';
33
+ approval: ApprovalRequest;
34
+ } | {
35
+ type: 'tool_execution_unknown';
36
+ toolCallId: string;
37
+ toolName: string;
38
+ input: JsonValue;
39
+ };
40
+ type RunPause = AgentRunPause | {
41
+ type: 'workflow_child';
42
+ childRunId: RunId;
43
+ childPause: AgentRunPause;
44
+ } | {
45
+ type: 'workflow_children';
46
+ children: Array<{
47
+ stepId: string;
48
+ childRunId: RunId;
49
+ childPause: AgentRunPause;
50
+ }>;
51
+ } | {
52
+ type: 'workflow_timer';
53
+ stepId: string;
54
+ resumeAt: string;
55
+ } | {
56
+ type: 'workflow_event';
57
+ stepId: string;
58
+ eventName: string;
59
+ };
60
+ interface ApprovalResolution {
61
+ type: 'approval';
62
+ approvalId: string;
63
+ decision: 'approve' | 'reject';
64
+ actor: {
65
+ id: string;
66
+ type?: string;
67
+ };
68
+ }
69
+ interface ElicitationResolution {
70
+ type: 'elicitation';
71
+ requestId: string;
72
+ value: JsonValue;
73
+ actor: {
74
+ id: string;
75
+ type?: string;
76
+ };
77
+ }
78
+ type ToolExecutionResolution = {
79
+ type: 'tool_execution';
80
+ toolCallId: string;
81
+ decision: 'use_output';
82
+ output: JsonValue;
83
+ actor: {
84
+ id: string;
85
+ type?: string;
86
+ };
87
+ } | {
88
+ type: 'tool_execution';
89
+ toolCallId: string;
90
+ decision: 'retry';
91
+ actor: {
92
+ id: string;
93
+ type?: string;
94
+ };
95
+ };
96
+ type TimerResolution = {
97
+ type: 'timer';
98
+ actor?: {
99
+ id: string;
100
+ type?: string;
101
+ };
102
+ };
103
+ type EventResolution = {
104
+ type: 'event';
105
+ eventName: string;
106
+ payload?: JsonValue;
107
+ actor?: {
108
+ id: string;
109
+ type?: string;
110
+ };
111
+ };
112
+ type ResumeRunResolution = ElicitationResolution | ApprovalResolution | ToolExecutionResolution | TimerResolution | EventResolution;
113
+ /** Correlation fields for runs created by a workflow or team coordinator. */
114
+ interface RunCorrelation {
115
+ /** Run that created this one. */
116
+ parentRunId?: RunId;
117
+ /** Top-level run in the correlation tree. */
118
+ rootRunId?: RunId;
119
+ }
120
+ interface AgentRun<TOutput = JsonValue> extends RunCorrelation {
121
+ kind?: 'agent';
122
+ id: RunId;
123
+ sessionId: SessionId;
124
+ agentName: string;
125
+ /** Effective model identity retained after checkpoint cleanup. Absent on older runs. */
126
+ modelName?: string;
127
+ modelMetadata?: ModelMetadata;
128
+ status: RunStatus;
129
+ revision: number;
130
+ pause?: RunPause;
131
+ createdAt: string;
132
+ updatedAt: string;
133
+ /** Absolute deadline for the run, derived from `RunRequest.deadlineMs`. */
134
+ deadlineAt?: string;
135
+ output?: TOutput;
136
+ error?: string;
137
+ usage?: ModelUsage;
138
+ }
139
+ interface WorkflowRun<TOutput = JsonValue> extends RunCorrelation {
140
+ kind: 'workflow';
141
+ id: RunId;
142
+ sessionId: SessionId;
143
+ workflowName: string;
144
+ status: RunStatus;
145
+ revision: number;
146
+ pause?: RunPause;
147
+ createdAt: string;
148
+ updatedAt: string;
149
+ /** Absolute deadline for the run, derived from `RunRequest.deadlineMs`. */
150
+ deadlineAt?: string;
151
+ output?: TOutput;
152
+ error?: string;
153
+ usage?: ModelUsage;
154
+ }
155
+ interface TeamRun<TOutput = JsonValue> extends RunCorrelation {
156
+ kind: 'team';
157
+ id: RunId;
158
+ sessionId: SessionId;
159
+ teamName: string;
160
+ status: RunStatus;
161
+ revision: number;
162
+ pause?: RunPause;
163
+ createdAt: string;
164
+ updatedAt: string;
165
+ /** Absolute deadline for the run, derived from `RunRequest.deadlineMs`. */
166
+ deadlineAt?: string;
167
+ output?: TOutput;
168
+ error?: string;
169
+ usage?: ModelUsage;
170
+ }
171
+ type CoordinatorRun<TOutput = JsonValue> = WorkflowRun<TOutput> | TeamRun<TOutput>;
172
+ type RunRecord<TOutput = unknown> = AgentRun<TOutput> | WorkflowRun<TOutput> | TeamRun<TOutput>;
173
+ interface SessionCompaction {
174
+ /** Derived summary for the first `coveredMessages` history entries. */
175
+ summary: string;
176
+ coveredMessages: number;
177
+ updatedAt: string;
178
+ }
179
+ interface Session {
180
+ /** Optimistic history revision. Missing on legacy sessions means zero. Store-managed. */
181
+ revision?: number;
182
+ id: SessionId;
183
+ history: AgentMessage[];
184
+ /** Reusable summary; the original history remains the source of truth. */
185
+ compaction?: SessionCompaction;
186
+ createdAt: string;
187
+ updatedAt: string;
188
+ }
189
+ interface ListEventsOptions {
190
+ after?: AgentEvent['id'];
191
+ /** Maximum results; omitted preserves the complete result for existing consumers. */
192
+ limit?: number;
193
+ /** Sequence order. Use descending with limit: 1 for the latest event. */
194
+ order?: 'asc' | 'desc';
195
+ }
196
+ declare function validateListEventsOptions(options: ListEventsOptions): void;
197
+ type RetainableRunStatus = 'completed' | 'failed' | 'cancelled';
198
+ interface PurgeRunsOptions {
199
+ /** Delete runs created strictly before this ISO timestamp. */
200
+ before?: string;
201
+ /** Terminal statuses to delete. Defaults to completed, failed and cancelled. */
202
+ statuses?: RetainableRunStatus[];
203
+ /** Maximum runs to delete in one call. */
204
+ limit?: number;
205
+ }
206
+ interface PurgeRunsResult {
207
+ runs: number;
208
+ sessions: number;
209
+ }
210
+ /** Optional capability for stores that can delete terminal runs and empty sessions. */
211
+ interface RetainableRunStore extends RunStore {
212
+ purgeRuns(options?: PurgeRunsOptions): Promise<PurgeRunsResult>;
213
+ }
214
+ declare function isRetainableRunStore(store: RunStore): store is RetainableRunStore;
215
+ declare function validatePurgeRunsOptions(options?: PurgeRunsOptions): {
216
+ statuses: RetainableRunStatus[];
217
+ before?: string;
218
+ limit?: number;
219
+ };
220
+ interface RunStore {
221
+ getRun<TRun extends RunRecord<unknown> = AgentRun>(runId: RunId): Promise<TRun | undefined>;
222
+ saveRun(run: RunRecord): Promise<void>;
223
+ getSession(sessionId: SessionId): Promise<Session | undefined>;
224
+ /** Compare and advance revision; reject active/paused sessions and stale snapshots. */
225
+ saveSession(session: Session): Promise<void>;
226
+ appendEvent(event: AgentEvent): Promise<void>;
227
+ listEvents(runId: RunId, options?: ListEventsOptions): Promise<AgentEvent[]>;
228
+ }
229
+ interface CredentialStore {
230
+ resolve(input: {
231
+ name: string;
232
+ namespace?: string;
233
+ actor?: {
234
+ id: string;
235
+ type?: string;
236
+ };
237
+ }): Promise<string | undefined>;
238
+ }
239
+ interface PendingToolExecution {
240
+ call: {
241
+ id: string;
242
+ name: string;
243
+ input: JsonValue;
244
+ };
245
+ input: JsonValue;
246
+ idempotencyKey: string;
247
+ attempt: number;
248
+ }
249
+ interface RunCheckpoint {
250
+ version: 2;
251
+ kind?: 'agent';
252
+ runId: RunId;
253
+ modelName?: string;
254
+ reasoning?: ReasoningEffort;
255
+ definitionHash: string;
256
+ limits?: AgentLimits;
257
+ contextBudget?: ContextBudget;
258
+ toolSearch?: ToolSearchCheckpointOptions;
259
+ loadedTools?: string[];
260
+ messages: AgentMessage[];
261
+ inputContent: string;
262
+ context?: ExecutionContext;
263
+ usage?: ModelUsage;
264
+ providerState?: JsonValue;
265
+ step: number;
266
+ toolCallCount: number;
267
+ seenToolCallIds: string[];
268
+ pendingTools: PendingToolExecution[];
269
+ pendingIndex: number;
270
+ effectiveElicitationMode?: ElicitationMode;
271
+ effectiveApprovalMode?: ApprovalMode;
272
+ effectiveToolChoice?: ToolChoice;
273
+ }
274
+ type WorkflowStepRecord = {
275
+ type: 'agent';
276
+ status: 'running';
277
+ agentName: string;
278
+ childRunId: RunId;
279
+ metadata?: JsonObject;
280
+ } | {
281
+ type: 'agent';
282
+ status: 'completed';
283
+ agentName: string;
284
+ childRunId: RunId;
285
+ result: RunResult<JsonValue>;
286
+ compensation?: WorkflowCompensationRecord;
287
+ metadata?: JsonObject;
288
+ } | {
289
+ type: 'parallel';
290
+ status: 'running';
291
+ metadata?: JsonObject;
292
+ } | {
293
+ type: 'parallel';
294
+ status: 'completed';
295
+ result: JsonObject;
296
+ compensation?: WorkflowCompensationRecord;
297
+ metadata?: JsonObject;
298
+ } | {
299
+ type: 'wait';
300
+ status: 'running';
301
+ wait: WorkflowWaitRecord;
302
+ } | {
303
+ type: 'wait';
304
+ status: 'completed';
305
+ wait: WorkflowWaitRecord;
306
+ payload?: JsonValue;
307
+ actor?: NonNullable<ExecutionContext['actor']>;
308
+ receivedAt?: string;
309
+ };
310
+ interface WorkflowCompensationRecord {
311
+ status: 'pending' | 'completed' | 'failed';
312
+ error?: string;
313
+ }
314
+ type WorkflowWaitRecord = {
315
+ type: 'timer';
316
+ resumeAt: string;
317
+ } | {
318
+ type: 'event';
319
+ eventName: string;
320
+ requireActor: boolean;
321
+ };
322
+ interface WorkflowBudgetUsage {
323
+ usage?: ModelUsage;
324
+ steps: number;
325
+ toolCalls: number;
326
+ }
327
+ interface WorkflowCheckpoint {
328
+ version: 2;
329
+ kind: 'workflow';
330
+ runId: RunId;
331
+ workflowName: string;
332
+ model?: string;
333
+ reasoning?: ReasoningEffort;
334
+ definitionHash: string;
335
+ input: JsonValue;
336
+ context?: ExecutionContext;
337
+ steps: Record<string, WorkflowStepRecord>;
338
+ limits?: AgentLimits;
339
+ budget?: WorkflowBudgetUsage;
340
+ }
341
+ interface TeamCheckpoint extends Omit<WorkflowCheckpoint, 'kind' | 'workflowName'> {
342
+ kind: 'team';
343
+ teamName: string;
344
+ }
345
+ type CoordinatorCheckpoint = WorkflowCheckpoint | TeamCheckpoint;
346
+ type StoredRunCheckpoint = RunCheckpoint | WorkflowCheckpoint | TeamCheckpoint;
347
+ type ToolExecutionStatus = 'started' | 'completed' | 'failed' | 'unknown';
348
+ interface ToolExecutionRecord {
349
+ runId: RunId;
350
+ toolCallId: string;
351
+ toolName: string;
352
+ input: JsonValue;
353
+ status: ToolExecutionStatus;
354
+ attempt: number;
355
+ idempotencyKey: string;
356
+ output?: JsonValue;
357
+ error?: string;
358
+ updatedAt: string;
359
+ }
360
+ /** Store assigns a new generation on creation/acquisition; callers must retain it. */
361
+ interface RunLease {
362
+ generation: number;
363
+ runId: RunId;
364
+ ownerId: string;
365
+ expiresAt: string;
366
+ }
367
+ interface ExecutionCommit {
368
+ /** Current lease identity; ownership, generation and expiry are checked atomically. */
369
+ lease: Pick<RunLease, 'ownerId' | 'generation'>;
370
+ expectedRevision: number;
371
+ run: RunRecord;
372
+ checkpoint?: StoredRunCheckpoint | null;
373
+ session?: Session;
374
+ toolExecution?: ToolExecutionRecord;
375
+ events?: AgentEvent[];
376
+ }
377
+ /** Atomically reserve the session until this run is terminal, including across pause/crash. */
378
+ interface ExecutionCreate {
379
+ run: RunRecord;
380
+ checkpoint: StoredRunCheckpoint;
381
+ /** Snapshot used to prepare the run; revision must match the stored history. */
382
+ session: Session;
383
+ lease: RunLease;
384
+ events: AgentEvent[];
385
+ }
386
+ interface DurableRunStore extends RunStore {
387
+ getCheckpoint<TCheckpoint extends StoredRunCheckpoint = RunCheckpoint>(runId: RunId): Promise<TCheckpoint | undefined>;
388
+ getToolExecution(runId: RunId, toolCallId: string): Promise<ToolExecutionRecord | undefined>;
389
+ /** On success, assigns run/session revisions and lease generation 1. */
390
+ createExecution(create: ExecutionCreate): Promise<boolean>;
391
+ commitExecution(commit: ExecutionCommit): Promise<boolean>;
392
+ /** Acquires only absent/expired leases and assigns a strictly newer generation. */
393
+ acquireLease(lease: RunLease): Promise<boolean>;
394
+ /** Requires matching owner/generation and an unexpired stored lease. */
395
+ renewLease(lease: RunLease): Promise<boolean>;
396
+ /** Expires a matching token while retaining its generation for future acquisitions. */
397
+ releaseLease(runId: RunId, ownerId: string, generation: number): Promise<void>;
398
+ }
399
+ declare function isDurableRunStore(store: RunStore): store is DurableRunStore;
400
+ interface RunRequest<TInput = unknown, TOutput = unknown> {
401
+ input: TInput;
402
+ model?: string;
403
+ reasoning?: ReasoningEffort;
404
+ context?: ExecutionContext;
405
+ limits?: AgentLimits;
406
+ contextBudget?: ContextBudget;
407
+ toolSearch?: ToolSearchOptions;
408
+ elicitation?: ElicitationMode;
409
+ approvalMode?: ApprovalMode;
410
+ toolChoice?: ToolChoice;
411
+ sessionId?: SessionId;
412
+ signal?: AbortSignal;
413
+ /** Maximum wall-clock time for this run, including time spent paused. */
414
+ deadlineMs?: number;
415
+ }
416
+ interface RunResult<TOutput = unknown> {
417
+ runId: RunId;
418
+ sessionId: SessionId;
419
+ output: TOutput;
420
+ events?: AgentEvent[];
421
+ usage?: ModelUsage;
422
+ }
423
+ //#endregion
424
+ //#region src/runtime/compaction.d.ts
425
+ /** Estimates the input tokens of messages and tool definitions. */
426
+ type ContextTokenEstimator = (input: {
427
+ messages: AgentMessage[];
428
+ tools?: ToolSpec[];
429
+ }) => number;
430
+ interface ContextCompactionInput {
431
+ agentName: string;
432
+ sessionId: SessionId;
433
+ /** Older turns and earlier tool batches; system prefix, current request and latest batch are preserved. */
434
+ messages: AgentMessage[];
435
+ tools?: ToolSpec[];
436
+ /** Estimated tokens of the whole prompt before compaction. */
437
+ estimatedTokens: number;
438
+ /** Soft budget for the messages returned by the compactor. */
439
+ targetTokens: number;
440
+ /** Hard model context window. */
441
+ contextWindow: number;
442
+ step: number;
443
+ context?: ExecutionContext;
444
+ signal?: AbortSignal;
445
+ /** Estimates messages with the runtime's configured estimator. */
446
+ estimateTokens(messages: AgentMessage[]): number;
447
+ }
448
+ /** Returns the replacement for the older conversation messages. */
449
+ interface ContextCompactor {
450
+ compact(input: ContextCompactionInput): AgentMessage[] | Promise<AgentMessage[]>;
451
+ }
452
+ interface ContextCompactionOptions {
453
+ /** Defaults to a deterministic digest compactor. */
454
+ compactor?: ContextCompactor;
455
+ /** Defaults to a character-based estimate. */
456
+ estimateTokens?: ContextTokenEstimator;
457
+ /** Redacts the summary before it enters the context.compacted event. */
458
+ redactSummary?: (summary: string) => string;
459
+ }
460
+ /** Cumulative runtime counters for automatic context compaction. */
461
+ interface ContextCompactionStats {
462
+ compactions: number;
463
+ removedMessages: number;
464
+ estimatedTokens: number;
465
+ compactedTokens: number;
466
+ savedTokens: number;
467
+ }
468
+ interface ResolvedContextBudget {
469
+ contextWindow: number;
470
+ reserveOutputTokens: number;
471
+ compactAt: number;
472
+ targetTokens: number;
473
+ safetyFactor: number;
474
+ }
475
+ /** Validates a context budget and fills in defaults. */
476
+ declare function resolveContextBudget(budget: ContextBudget | undefined, label: string): ResolvedContextBudget | undefined;
477
+ /**
478
+ * Rough provider-neutral estimate: about four characters per token plus
479
+ * message and tool framing. Hosts can inject a real tokenizer instead.
480
+ */
481
+ declare function estimateContextTokens(input: {
482
+ messages: AgentMessage[];
483
+ tools?: ToolSpec[];
484
+ }): number;
485
+ interface ModelContextCompactorOptions {
486
+ /** Model used only to summarize older context. */
487
+ model: ModelGateway;
488
+ /** Overrides the built-in summarization instructions. */
489
+ systemPrompt?: string;
490
+ /** Maximum output tokens for the summary. Defaults to 1,024. */
491
+ maxOutputTokens?: number;
492
+ /** Maximum characters sent to one summarization call. Defaults to 120,000. */
493
+ maxInputChars?: number;
494
+ }
495
+ /**
496
+ * Creates a semantic compactor backed by a model. Use a cheap, fast model and
497
+ * keep it separate from the agent model when possible. Large transcripts are
498
+ * summarized in chunks and then merged.
499
+ */
500
+ declare function createModelContextCompactor(options: ModelContextCompactorOptions): ContextCompactor;
501
+ interface DigestContextCompactorOptions {
502
+ /** Maximum characters kept from one message. Defaults to 400. */
503
+ maxCharsPerMessage?: number;
504
+ }
505
+ /**
506
+ * Deterministic compactor used when the host does not inject one. It keeps
507
+ * role-aware excerpts of older messages and drops the oldest excerpts first.
508
+ * It never calls a model.
509
+ */
510
+ declare function createDigestContextCompactor(options?: DigestContextCompactorOptions): ContextCompactor;
511
+ //#endregion
512
+ //#region src/runtime/in-memory-run-store.d.ts
513
+ /**
514
+ * In-process durable store intended for development and tests.
515
+ *
516
+ * Values are cloned at the boundary so callers cannot mutate persisted state.
517
+ * Data is lost when the process exits.
518
+ */
519
+ declare class InMemoryRunStore implements DurableRunStore {
520
+ #private;
521
+ getRun<TRun extends RunRecord<unknown> = AgentRun>(runId: RunId): Promise<TRun | undefined>;
522
+ saveRun(run: RunRecord): Promise<void>;
523
+ getSession(sessionId: SessionId): Promise<Session | undefined>;
524
+ saveSession(session: Session): Promise<void>;
525
+ appendEvent(event: AgentEvent): Promise<void>;
526
+ listEvents(runId: RunId, options?: ListEventsOptions): Promise<AgentEvent[]>;
527
+ getCheckpoint<TCheckpoint extends StoredRunCheckpoint = RunCheckpoint>(runId: RunId): Promise<TCheckpoint | undefined>;
528
+ getToolExecution(runId: RunId, toolCallId: string): Promise<ToolExecutionRecord | undefined>;
529
+ createExecution(create: ExecutionCreate): Promise<boolean>;
530
+ commitExecution(commit: ExecutionCommit): Promise<boolean>;
531
+ purgeRuns(options?: PurgeRunsOptions): Promise<PurgeRunsResult>;
532
+ acquireLease(lease: RunLease): Promise<boolean>;
533
+ renewLease(lease: RunLease): Promise<boolean>;
534
+ releaseLease(runId: RunId, ownerId: string, generation: number): Promise<void>;
535
+ }
536
+ //#endregion
537
+ //#region src/agents/agent.d.ts
538
+ /** Resource limits enforced by the runtime for a single agent run. */
539
+ interface AgentLimits {
540
+ maxSteps?: number;
541
+ maxToolCalls?: number;
542
+ maxInputTokens?: number | false;
543
+ maxOutputTokens?: number | false;
544
+ /** Maximum serialized bytes for one tool result. Use `false` to disable the default cap. */
545
+ maxToolResultBytes?: number | false;
546
+ }
547
+ /**
548
+ * Per-request model context budget. It is separate from
549
+ * {@link AgentLimits.maxInputTokens}, which caps cumulative spend for a run.
550
+ */
551
+ interface ContextBudget {
552
+ /** Model context window in tokens. */
553
+ contextWindow: number;
554
+ /** Tokens reserved for the next model output. Defaults to 0. */
555
+ reserveOutputTokens?: number;
556
+ /** Fraction of the usable window that triggers compaction. Defaults to 0.8. */
557
+ compactAt?: number;
558
+ /** Target tokens after compaction. Defaults below the compaction threshold. */
559
+ targetTokens?: number;
560
+ /** Multiplier applied to estimates to leave headroom. Defaults to 1.1. */
561
+ safetyFactor?: number;
562
+ }
563
+ interface ToolSearchSemanticOptions {
564
+ /** Embedding model used to index tools and queries. */
565
+ embeddings: EmbeddingModel;
566
+ /** Cache for tool vectors. Defaults to the runtime cache. */
567
+ cache?: ToolEmbeddingCache;
568
+ /** Vector candidates considered before fusion. Defaults to 20. */
569
+ topK?: number;
570
+ /** Minimum cosine score for vector candidates. Defaults to 0. */
571
+ minScore?: number;
572
+ /** Optional second-stage reranker over the fused candidates. */
573
+ reranker?: ToolReranker;
574
+ }
575
+ /** On-demand tool discovery for agents with large tool catalogs. */
576
+ interface ToolSearchOptions {
577
+ /** `auto` enables search above the configured thresholds. Defaults to `auto`. */
578
+ mode?: 'auto' | 'on' | 'off';
579
+ /** Tool-count threshold for `auto`. Defaults to 30. */
580
+ threshold?: number;
581
+ /** Estimated tool-token threshold for `auto`. */
582
+ tokenThreshold?: number;
583
+ /** Maximum tools returned by one search. Defaults to 5. */
584
+ limit?: number;
585
+ /** Tool names exposed without a search. */
586
+ pinned?: string[];
587
+ /** Optional hybrid lexical + vector retrieval. */
588
+ semantic?: ToolSearchSemanticOptions;
589
+ }
590
+ /** Serializable tool-search options stored in a run checkpoint. */
591
+ type ToolSearchCheckpointOptions = Omit<ToolSearchOptions, 'semantic'>;
592
+ interface AgentDefinition<TInput = unknown, TOutput = unknown> {
593
+ name: string;
594
+ instructions: string;
595
+ model?: ModelRef;
596
+ tools?: string[];
597
+ context?: string[];
598
+ memory?: {
599
+ read?: boolean;
600
+ write?: boolean;
601
+ limit?: number;
602
+ };
603
+ skills?: string[];
604
+ reasoning?: ReasoningEffort;
605
+ modelOptions?: Record<string, unknown>;
606
+ toolChoice?: ToolChoice;
607
+ elicitation?: ElicitationMode;
608
+ approvalMode?: ApprovalMode;
609
+ inputSchema?: StandardSchemaV1<unknown, TInput>;
610
+ outputSchema?: StandardSchemaV1<unknown, TOutput>;
611
+ limits?: AgentLimits;
612
+ contextBudget?: ContextBudget;
613
+ toolSearch?: ToolSearchOptions;
614
+ }
615
+ declare function defineAgent<T extends AgentDefinition>(agent: ExactDefinition<T, AgentDefinition>): T;
616
+ //#endregion
617
+ export { SessionCompaction as $, ElicitationMode as A, ResumeRunResolution as B, ApprovalMode as C, CoordinatorRun as D, CoordinatorCheckpoint as E, ExecutionCreate as F, RunLease as G, RetainableRunStore as H, ListEventsOptions as I, RunRequest as J, RunPause as K, PendingToolExecution as L, ElicitationResolution as M, EventResolution as N, CredentialStore as O, ExecutionCommit as P, Session as Q, PurgeRunsOptions as R, AgentRunPause as S, ApprovalResolution as T, RunCheckpoint as U, RetainableRunStatus as V, RunCorrelation as W, RunStatus as X, RunResult as Y, RunStore as Z, createDigestContextCompactor as _, validatePurgeRunsOptions as _t, ToolSearchOptions as a, ToolExecutionRecord as at, resolveContextBudget as b, InMemoryRunStore as c, WorkflowBudgetUsage as ct, ContextCompactionStats as d, WorkflowRun as dt, SessionId as et, ContextCompactor as f, WorkflowStepRecord as ft, ResolvedContextBudget as g, validateListEventsOptions as gt, ModelContextCompactorOptions as h, isRetainableRunStore as ht, ToolSearchCheckpointOptions as i, TimerResolution as it, ElicitationRequest as j, DurableRunStore as k, ContextCompactionInput as l, WorkflowCheckpoint as lt, DigestContextCompactorOptions as m, isDurableRunStore as mt, AgentLimits as n, TeamCheckpoint as nt, ToolSearchSemanticOptions as o, ToolExecutionResolution as ot, ContextTokenEstimator as p, WorkflowWaitRecord as pt, RunRecord as q, ContextBudget as r, TeamRun as rt, defineAgent as s, ToolExecutionStatus as st, AgentDefinition as t, StoredRunCheckpoint as tt, ContextCompactionOptions as u, WorkflowCompensationRecord as ut, createModelContextCompactor as v, ApprovalRequest as w, AgentRun as x, estimateContextTokens as y, PurgeRunsResult as z };