@cuylabs/agent-core 0.8.0 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (127) hide show
  1. package/README.md +33 -17
  2. package/dist/chunk-2O4MCSQS.js +780 -0
  3. package/dist/chunk-2TTOLHBT.js +198 -0
  4. package/dist/chunk-5FMSGQVX.js +281 -0
  5. package/dist/chunk-5NVVNXPQ.js +288 -0
  6. package/dist/{chunk-CAA7FHIH.js → chunk-6HZBHFOL.js} +3 -103
  7. package/dist/chunk-CJI7PVS2.js +58 -0
  8. package/dist/{chunk-N6HWIEEA.js → chunk-CMYN2RCB.js} +278 -61
  9. package/dist/chunk-FII65CN7.js +117 -0
  10. package/dist/{chunk-IVUJDISU.js → chunk-GFTW23FV.js} +5 -14
  11. package/dist/chunk-I6PKJ7XQ.js +292 -0
  12. package/dist/{chunk-BDBZ3SLK.js → chunk-ICZ66572.js} +48 -4
  13. package/dist/chunk-KYLPMBHD.js +316 -0
  14. package/dist/chunk-MXAP4UG6.js +2956 -0
  15. package/dist/{chunk-RZITT45F.js → chunk-N3VX7FEE.js} +39 -6
  16. package/dist/{chunk-YSLSEQ6B.js → chunk-NDZWXCBZ.js} +218 -95
  17. package/dist/{chunk-P6YF7USR.js → chunk-Q742PSH3.js} +23 -38
  18. package/dist/chunk-QAL3OMI3.js +943 -0
  19. package/dist/{chunk-RFEKJKTO.js → chunk-RN6WZEUF.js} +330 -280
  20. package/dist/{chunk-ZXAKHMWH.js → chunk-ROTGCYDW.js} +22 -84
  21. package/dist/chunk-SPBFQXOT.js +0 -0
  22. package/dist/{chunk-LRHOS4ZN.js → chunk-SPILYYDF.js} +3 -2
  23. package/dist/chunk-SSFBF3US.js +602 -0
  24. package/dist/chunk-SZ2XBPTW.js +8 -0
  25. package/dist/chunk-T4UIX5D7.js +115 -0
  26. package/dist/chunk-TIHPYVAJ.js +102 -0
  27. package/dist/{chunk-YUUJK53A.js → chunk-TOTDGK3P.js} +1 -1
  28. package/dist/chunk-V4RFNEET.js +563 -0
  29. package/dist/chunk-VOUEJSW6.js +0 -0
  30. package/dist/{chunk-4BDA7DQY.js → chunk-WBPOZ7CL.js} +673 -273
  31. package/dist/chunk-X4VN4GIJ.js +185 -0
  32. package/dist/dispatch/index.d.ts +93 -0
  33. package/dist/dispatch/index.js +37 -0
  34. package/dist/events/index.d.ts +93 -0
  35. package/dist/events/index.js +6 -0
  36. package/dist/{runtime → execution}/index.d.ts +120 -34
  37. package/dist/{runtime → execution}/index.js +18 -13
  38. package/dist/index-BCqEGzBj.d.ts +251 -0
  39. package/dist/index.d.ts +490 -122
  40. package/dist/index.js +2104 -615
  41. package/dist/{errors → inference/errors}/index.d.ts +2 -2
  42. package/dist/{errors → inference/errors}/index.js +1 -1
  43. package/dist/inference/index.d.ts +16 -23
  44. package/dist/inference/index.js +45 -16
  45. package/dist/instance-BqV2D5pc.d.ts +5723 -0
  46. package/dist/logger/index.d.ts +50 -0
  47. package/dist/logger/index.js +11 -0
  48. package/dist/mcp/index.d.ts +5 -9
  49. package/dist/mcp/index.js +2 -3
  50. package/dist/middleware/index.d.ts +10 -149
  51. package/dist/middleware/index.js +11 -3
  52. package/dist/model-messages-B4nK9D1-.d.ts +13 -0
  53. package/dist/models/index.d.ts +23 -18
  54. package/dist/models/index.js +48 -11
  55. package/dist/models/reasoning/index.d.ts +4 -0
  56. package/dist/{reasoning → models/reasoning}/index.js +3 -3
  57. package/dist/plugin/index.d.ts +458 -0
  58. package/dist/plugin/index.js +32 -0
  59. package/dist/profiles/index.d.ts +55 -0
  60. package/dist/profiles/index.js +30 -0
  61. package/dist/prompt/index.d.ts +8 -12
  62. package/dist/prompt/index.js +3 -2
  63. package/dist/safety/index.d.ts +109 -14
  64. package/dist/safety/index.js +59 -3
  65. package/dist/sandbox/index.d.ts +81 -0
  66. package/dist/sandbox/index.js +1 -0
  67. package/dist/skill/index.d.ts +10 -8
  68. package/dist/skill/index.js +3 -3
  69. package/dist/storage/index.d.ts +12 -4
  70. package/dist/storage/index.js +1 -1
  71. package/dist/subagents/index.d.ts +177 -0
  72. package/dist/subagents/index.js +78 -0
  73. package/dist/team/index.d.ts +544 -0
  74. package/dist/team/index.js +41 -0
  75. package/dist/tool/host/index.d.ts +41 -0
  76. package/dist/tool/host/index.js +10 -0
  77. package/dist/tool/index.d.ts +125 -21
  78. package/dist/tool/index.js +20 -13
  79. package/dist/{types-VQgymC1N.d.ts → types-Bj_J8u_W.d.ts} +44 -64
  80. package/dist/{types-CHiPh8U2.d.ts → types-C_LCeYNg.d.ts} +7 -7
  81. package/dist/types-RSCv7nQ4.d.ts +59 -0
  82. package/package.json +58 -53
  83. package/dist/builder-UpOWQMW3.d.ts +0 -34
  84. package/dist/chunk-7MUFEN4K.js +0 -559
  85. package/dist/chunk-7VKQ4WPB.js +0 -73
  86. package/dist/chunk-BFM2YHNM.js +0 -222
  87. package/dist/chunk-DWYX7ASF.js +0 -26
  88. package/dist/chunk-KUVSERLJ.js +0 -50
  89. package/dist/chunk-N7P4PN3O.js +0 -84
  90. package/dist/chunk-SDSBEQXG.js +0 -157
  91. package/dist/chunk-SQU2AJHO.js +0 -305
  92. package/dist/chunk-VBWWUHWI.js +0 -724
  93. package/dist/chunk-VEKUXUVF.js +0 -41
  94. package/dist/chunk-VNQBHPCT.js +0 -398
  95. package/dist/chunk-WWYYNWEW.js +0 -259
  96. package/dist/context/index.d.ts +0 -259
  97. package/dist/context/index.js +0 -26
  98. package/dist/events-CE72w8W4.d.ts +0 -149
  99. package/dist/host/index.d.ts +0 -45
  100. package/dist/host/index.js +0 -8
  101. package/dist/index-CWSchSql.d.ts +0 -1058
  102. package/dist/messages-BYWGn8TY.d.ts +0 -110
  103. package/dist/presets/index.d.ts +0 -53
  104. package/dist/presets/index.js +0 -28
  105. package/dist/reasoning/index.d.ts +0 -116
  106. package/dist/registry-DwYqsQkX.d.ts +0 -164
  107. package/dist/runner-e2YRcUoX.d.ts +0 -786
  108. package/dist/scope/index.d.ts +0 -10
  109. package/dist/scope/index.js +0 -14
  110. package/dist/session-manager-B_CWGTsl.d.ts +0 -274
  111. package/dist/signal/index.d.ts +0 -28
  112. package/dist/signal/index.js +0 -6
  113. package/dist/sub-agent/index.d.ts +0 -23
  114. package/dist/sub-agent/index.js +0 -15
  115. package/dist/tool-BHbyUAy3.d.ts +0 -150
  116. package/dist/tool-DLXAR9Ce.d.ts +0 -145
  117. package/dist/tracker-DClqYqTj.d.ts +0 -96
  118. package/dist/tracking/index.d.ts +0 -111
  119. package/dist/tracking/index.js +0 -20
  120. package/dist/types-BfNpU8NS.d.ts +0 -270
  121. package/dist/types-BnpEOYV-.d.ts +0 -50
  122. package/dist/types-CQL-SvTn.d.ts +0 -29
  123. package/dist/types-CWm-7rvB.d.ts +0 -55
  124. package/dist/types-KKDrdU9Y.d.ts +0 -325
  125. package/dist/types-QA4WhEfz.d.ts +0 -138
  126. package/dist/types-QKHHQLLq.d.ts +0 -336
  127. package/dist/types-YuWV4ag7.d.ts +0 -72
@@ -1,18 +1,14 @@
1
- import { A as AgentEvent } from '../events-CE72w8W4.js';
2
- import { T as TokenUsage, M as Message } from '../messages-BYWGn8TY.js';
3
- import { S as ScopeSnapshot } from '../types-CQL-SvTn.js';
4
- import { S as StepProcessingOptions, z as StepProcessingOutput, l as AgentTurnStepCommitSnapshot, r as CreateAgentTurnStepCommitBatchOptions, d as AgentTurnCommitBatch, P as PrepareModelStepOptions, u as PreparedAgentModelStep, R as RunModelStepOptions, x as RunToolBatchOptions, y as RunToolBatchResult, C as CommitOutputOptions, p as CommitStepOptions, j as AgentTurnState, n as AgentTurnStepCommitToolResult, m as AgentTurnStepCommitToolCall } from '../types-QKHHQLLq.js';
5
- export { A as AgentTurnActiveToolCall, a as AgentTurnBoundaryMetadata, b as AgentTurnBoundarySnapshot, c as AgentTurnCommitApplier, e as AgentTurnCommitOptions, f as AgentTurnEngine, g as AgentTurnEngineOptions, h as AgentTurnPhase, i as AgentTurnResolvedToolCall, k as AgentTurnStateAdvanceOptions, o as AgentTurnStepRuntimeConfig, q as CreateAgentTurnStateOptions, v as ProcessorOptions, w as ProcessorOutput, B as advanceAgentTurnState, E as createAgentTurnEngine, F as createAgentTurnState, G as failAgentTurnState } from '../types-QKHHQLLq.js';
6
- import { A as AnyInferenceResult } from '../types-KKDrdU9Y.js';
7
- import { ModelMessage } from 'ai';
8
- import '../tool-BHbyUAy3.js';
1
+ import { e as AnyInferenceResult, cB as StepProcessingOptions, cC as StepProcessingOutput, a6 as AgentTurnStepCommitSnapshot, aF as CreateAgentTurnStepCommitBatchOptions, _ as AgentTurnCommitBatch, b$ as PrepareModelStepOptions, c0 as PreparedAgentModelStep, cb as RunModelStepOptions, A as AgentEvent, cc as RunToolBatchOptions, cd as RunToolBatchResult, av as CommitOutputOptions, aw as CommitStepOptions, dg as TokenUsage, v as ScopeSnapshot, a4 as AgentTurnState, dn as ToolMetadata, a8 as AgentTurnStepCommitToolResult, a7 as AgentTurnStepCommitToolCall, M as Message, dv as UserMessage, ar as AssistantMessage, dm as ToolMessage, cM as SystemMessage } from '../instance-BqV2D5pc.js';
2
+ export { Q as AgentTurnActiveToolCall, X as AgentTurnBoundaryMetadata, Y as AgentTurnBoundarySnapshot, Z as AgentTurnCommitApplier, $ as AgentTurnCommitOptions, a0 as AgentTurnEngine, a1 as AgentTurnEngineOptions, a2 as AgentTurnPhase, a3 as AgentTurnResolvedToolCall, a5 as AgentTurnStateAdvanceOptions, a9 as AgentTurnStepRuntimeConfig, aE as CreateAgentTurnStateOptions, dy as advanceAgentTurnState, dC as createAgentTurnEngine, dD as createAgentTurnState, dK as failAgentTurnState } from '../instance-BqV2D5pc.js';
3
+ import { L as Logger } from '../types-RSCv7nQ4.js';
4
+ export { c as convertAgentMessagesToModelMessages } from '../model-messages-B4nK9D1-.js';
5
+ import '../types-C_LCeYNg.js';
6
+ import 'ai';
9
7
  import 'zod';
10
- import '../tool-DLXAR9Ce.js';
11
- import '../types-CHiPh8U2.js';
12
- import '../runner-e2YRcUoX.js';
13
- import '@ai-sdk/provider-utils';
14
- import '../types-BfNpU8NS.js';
15
8
  import '../types-CQaXbRsS.js';
9
+ import '../types-Bj_J8u_W.js';
10
+ import '@ai-sdk/provider-utils';
11
+ import '../sandbox/index.js';
16
12
  import '../llm-error-D93FNNLY.js';
17
13
 
18
14
  /**
@@ -38,10 +34,6 @@ declare class ContextOverflowError extends Error {
38
34
  * Process an inference stream into runtime step events.
39
35
  */
40
36
  declare function processStepStream(stream: AnyInferenceResult, options: StepProcessingOptions): Promise<StepProcessingOutput>;
41
- /**
42
- * @deprecated Use `processStepStream`.
43
- */
44
- declare const processStream: typeof processStepStream;
45
37
 
46
38
  declare function createAgentTurnStepCommitBatch(step: number, snapshot: AgentTurnStepCommitSnapshot, options?: CreateAgentTurnStepCommitBatchOptions): AgentTurnCommitBatch | undefined;
47
39
 
@@ -57,6 +49,13 @@ declare function runModelStep(options: RunModelStepOptions): AsyncGenerator<Agen
57
49
 
58
50
  /**
59
51
  * Execute planned tool calls outside the AI SDK loop.
52
+ *
53
+ * When multiple tool calls are pending, the batch is partitioned:
54
+ * - Tools that declare `capabilities.parallelSafe` run concurrently
55
+ * - All other tools run serially (in original order)
56
+ *
57
+ * Serial tools always run after the parallel batch completes, preserving
58
+ * the invariant that non-parallel-safe tools never overlap with anything.
60
59
  */
61
60
  declare function runToolBatch(options: RunToolBatchOptions): Promise<RunToolBatchResult>;
62
61
 
@@ -80,6 +79,8 @@ interface AgentTaskPayload {
80
79
  interface AgentTaskExecutionContext {
81
80
  /** Abort signal propagated to agent.chat(). */
82
81
  signal?: AbortSignal;
82
+ /** Stable identifier for this task execution when supplied by the caller. */
83
+ executionId?: string;
83
84
  /** Optional trigger descriptor from caller (for logging/routing). */
84
85
  trigger?: string;
85
86
  /**
@@ -87,6 +88,45 @@ interface AgentTaskExecutionContext {
87
88
  * For scheduled jobs, a job ID is a good candidate.
88
89
  */
89
90
  fallbackSessionKey?: string;
91
+ /**
92
+ * Optional prior execution state to resume from. When provided, the task
93
+ * runner restores accumulated response, usage, tool results, and step
94
+ * counter from this snapshot before streaming the next agent.chat() turn.
95
+ *
96
+ * This enables runtime providers (e.g. Dapr) to implement crash recovery
97
+ * on the direct (non-workflow) execution path: load the last checkpoint
98
+ * from the execution store, then re-run with `restoreFrom` so the turn
99
+ * continues from where it left off rather than starting fresh.
100
+ *
101
+ * The snapshot only provides accumulated bookkeeping — the actual
102
+ * conversation context is recovered through the session storage layer
103
+ * (same sessionId → same persisted messages).
104
+ */
105
+ restoreFrom?: AgentTaskResumeSnapshot;
106
+ }
107
+ /**
108
+ * Portable snapshot of prior execution state used for resume.
109
+ *
110
+ * This is intentionally a minimal subset — just enough for the task runner
111
+ * to restore its accumulators. The full `AgentTaskExecutionSnapshot` (with
112
+ * turn state, events, scope) lives in the runtime provider's execution store.
113
+ */
114
+ interface AgentTaskResumeSnapshot {
115
+ /** Accumulated response text from prior execution. */
116
+ response: string;
117
+ /** Accumulated token usage from prior execution. */
118
+ usage: TokenUsage;
119
+ /** Tool calls completed in the prior execution. */
120
+ toolCalls: Array<{
121
+ name: string;
122
+ result: unknown;
123
+ }>;
124
+ /** Step counter to resume from. */
125
+ step: number;
126
+ /** Event counter to resume from. */
127
+ eventCount: number;
128
+ /** ISO timestamp of the original execution start. */
129
+ startedAt: string;
90
130
  }
91
131
  interface AgentTaskResult {
92
132
  response: string;
@@ -116,6 +156,7 @@ interface AgentTaskExecutionRun<TPayload extends AgentTaskPayload = AgentTaskPay
116
156
  payload: Readonly<TPayload>;
117
157
  context: Readonly<AgentTaskExecutionContext>;
118
158
  sessionId: string;
159
+ executionId: string;
119
160
  startedAt: string;
120
161
  scope?: ScopeSnapshot;
121
162
  }
@@ -157,7 +198,7 @@ interface AgentTaskObserver<TPayload extends AgentTaskPayload = AgentTaskPayload
157
198
  * it into activities so child spans (AI SDK, tool calls) are
158
199
  * correlated under the observer's root span.
159
200
  */
160
- getOtelContext?(sessionId: string): unknown;
201
+ getOtelContext?(sessionId: string, executionId?: string): unknown;
161
202
  /**
162
203
  * Activate the OTel context for a session around a function call.
163
204
  *
@@ -166,7 +207,7 @@ interface AgentTaskObserver<TPayload extends AgentTaskPayload = AgentTaskPayload
166
207
  * execution mode. The observer wraps `fn` in `context.with()` so
167
208
  * that `context.active()` returns the session's trace context.
168
209
  */
169
- activateContext?<T>(sessionId: string, fn: () => T): T;
210
+ activateContext?<T>(sessionId: string, executionId: string, fn: () => T): T;
170
211
  }
171
212
  interface AgentTaskCheckpointStrategyInput<TPayload extends AgentTaskPayload = AgentTaskPayload> {
172
213
  run: AgentTaskExecutionRun<TPayload>;
@@ -205,6 +246,8 @@ interface AgentTaskRunnerOptions<TPayload extends AgentTaskPayload = AgentTaskPa
205
246
  * `defaultAgentTaskCheckpointStrategy(...)`.
206
247
  */
207
248
  checkpointStrategy?: AgentTaskCheckpointStrategy<TPayload>;
249
+ /** Logger for diagnostic output. Defaults to silent. */
250
+ logger?: Logger;
208
251
  }
209
252
  /**
210
253
  * Create a reusable task runner that maps generic task payloads to `agent.chat()`.
@@ -255,6 +298,7 @@ interface AgentWorkflowToolMessageSnapshot {
255
298
  toolCallId: string;
256
299
  toolName: string;
257
300
  result: unknown;
301
+ metadata?: ToolMetadata;
258
302
  compactedAt?: number;
259
303
  }
260
304
  interface AgentWorkflowSystemMessageSnapshot {
@@ -264,7 +308,7 @@ interface AgentWorkflowSystemMessageSnapshot {
264
308
  content: string;
265
309
  }
266
310
  type AgentWorkflowMessageSnapshot = AgentWorkflowUserMessageSnapshot | AgentWorkflowAssistantMessageSnapshot | AgentWorkflowToolMessageSnapshot | AgentWorkflowSystemMessageSnapshot;
267
- type AgentWorkflowTurnPhase = "model-step" | "tool-batch" | "step-commit" | "output-commit" | "completed" | "failed";
311
+ type AgentWorkflowTurnPhase = "input-commit" | "model-step" | "tool-batch" | "step-commit" | "output-commit" | "completed" | "failed";
268
312
  interface AgentWorkflowReplayDecision {
269
313
  toolCallId: string;
270
314
  toolName: string;
@@ -291,11 +335,17 @@ interface AgentWorkflowToolCallResult {
291
335
  toolResult: AgentTurnStepCommitToolResult;
292
336
  turnState?: AgentTurnState;
293
337
  }
338
+ interface AgentWorkflowInterventionSnapshot {
339
+ id: string;
340
+ message: string;
341
+ createdAt: string;
342
+ }
294
343
  interface AgentWorkflowTurnState {
295
344
  sessionId: string;
296
345
  systemPrompts: string[];
297
346
  messages: AgentWorkflowMessageSnapshot[];
298
347
  phase: AgentWorkflowTurnPhase;
348
+ pendingInput?: AgentWorkflowUserMessageSnapshot;
299
349
  step: number;
300
350
  maxSteps: number;
301
351
  usage?: TokenUsage;
@@ -306,6 +356,19 @@ interface AgentWorkflowTurnState {
306
356
  error?: string;
307
357
  startedAt: string;
308
358
  updatedAt: string;
359
+ /**
360
+ * Pending steering messages injected by an external client.
361
+ * In direct execution, the `InterventionController` handles this.
362
+ * In durable execution, pending messages are drained at each
363
+ * model-step boundary and injected as user messages.
364
+ */
365
+ pendingInterventions?: AgentWorkflowInterventionSnapshot[];
366
+ /**
367
+ * Deferred follow-up messages queued by an external client.
368
+ * These are held until the current turn completes and can then be
369
+ * surfaced by the host as candidate next-turn messages.
370
+ */
371
+ queuedFollowUps?: AgentWorkflowInterventionSnapshot[];
309
372
  }
310
373
  interface CreateAgentWorkflowTurnStateOptions {
311
374
  sessionId: string;
@@ -313,15 +376,30 @@ interface CreateAgentWorkflowTurnStateOptions {
313
376
  maxSteps: number;
314
377
  systemPrompts?: string[];
315
378
  initialMessages?: AgentWorkflowMessageSnapshot[];
379
+ initialInput?: AgentWorkflowUserMessageSnapshot;
316
380
  initialStep?: number;
317
381
  }
318
- declare function snapshotAgentWorkflowMessage(message: Message): AgentWorkflowMessageSnapshot;
319
- declare function snapshotAgentWorkflowMessages(messages: Message[]): AgentWorkflowMessageSnapshot[];
320
- declare function restoreAgentWorkflowMessage(snapshot: AgentWorkflowMessageSnapshot): Message;
321
- declare function restoreAgentWorkflowMessages(snapshots: AgentWorkflowMessageSnapshot[]): Message[];
322
382
  declare function createAgentWorkflowTurnState(options: CreateAgentWorkflowTurnStateOptions): AgentWorkflowTurnState;
323
383
  declare function cloneAgentWorkflowTurnState(state: AgentWorkflowTurnState): AgentWorkflowTurnState;
384
+ declare function applyWorkflowInterventions(state: AgentWorkflowTurnState, interventions: readonly AgentWorkflowInterventionSnapshot[], updatedAt: string): AgentWorkflowTurnState;
385
+ /**
386
+ * Drain pending intervention messages from the workflow state,
387
+ * injecting each as a user message into `state.messages`.
388
+ *
389
+ * Returns the updated state with `pendingInterventions` cleared.
390
+ * If there are no pending interventions, returns the state unchanged.
391
+ *
392
+ * This is the durable-execution equivalent of
393
+ * `InterventionController.drainImmediate()` in the direct path.
394
+ */
395
+ declare function drainWorkflowInterventions(state: AgentWorkflowTurnState, updatedAt: string): AgentWorkflowTurnState;
396
+ declare function queueWorkflowFollowUps(state: AgentWorkflowTurnState, followUps: readonly AgentWorkflowInterventionSnapshot[], updatedAt: string): AgentWorkflowTurnState;
324
397
 
398
+ interface AgentWorkflowInputCommitPlan {
399
+ kind: "input-commit";
400
+ sessionId: string;
401
+ messages: AgentWorkflowMessageSnapshot[];
402
+ }
325
403
  interface AgentWorkflowModelStepPlan {
326
404
  kind: "model-step";
327
405
  sessionId: string;
@@ -344,13 +422,21 @@ interface AgentWorkflowToolCallPlan {
344
422
  turnState: AgentWorkflowTurnState["turnState"];
345
423
  replayDecision?: AgentWorkflowReplayDecision;
346
424
  }
425
+ interface AgentWorkflowToolBatchPlan {
426
+ kind: "tool-batch";
427
+ step: number;
428
+ sessionId: string;
429
+ toolCalls: AgentTurnStepCommitToolCall[];
430
+ turnState: AgentWorkflowTurnState["turnState"];
431
+ replayDecisions: Record<string, AgentWorkflowReplayDecision>;
432
+ }
347
433
  interface AgentWorkflowOutputCommitPlan {
348
434
  kind: "output-commit";
349
435
  sessionId: string;
350
436
  text: string;
351
437
  usage?: TokenUsage;
352
438
  }
353
- type AgentWorkflowOperationPlan = AgentWorkflowModelStepPlan | AgentWorkflowToolCallPlan | AgentWorkflowStepCommitPlan | AgentWorkflowOutputCommitPlan;
439
+ type AgentWorkflowOperationPlan = AgentWorkflowInputCommitPlan | AgentWorkflowModelStepPlan | AgentWorkflowToolCallPlan | AgentWorkflowToolBatchPlan | AgentWorkflowStepCommitPlan | AgentWorkflowOutputCommitPlan;
354
440
 
355
441
  /**
356
442
  * Decide which deterministic workflow operation should run next.
@@ -382,13 +468,13 @@ declare function recordAgentWorkflowReplayDecision(state: AgentWorkflowTurnState
382
468
  */
383
469
  declare function failAgentWorkflowTurnState(state: AgentWorkflowTurnState, error: Error, updatedAt: string): AgentWorkflowTurnState;
384
470
 
385
- /**
386
- * Convert framework messages into Vercel AI SDK model messages.
387
- *
388
- * This keeps the message translation logic reusable for workflow activities
389
- * and other runtime integrations without forcing those integrations to reach
390
- * into `Agent` internals.
391
- */
392
- declare function convertAgentMessagesToModelMessages(messages: Message[]): ModelMessage[];
471
+ declare function snapshotAgentWorkflowMessage(message: UserMessage): AgentWorkflowUserMessageSnapshot;
472
+ declare function snapshotAgentWorkflowMessage(message: AssistantMessage): AgentWorkflowAssistantMessageSnapshot;
473
+ declare function snapshotAgentWorkflowMessage(message: ToolMessage): AgentWorkflowToolMessageSnapshot;
474
+ declare function snapshotAgentWorkflowMessage(message: SystemMessage): AgentWorkflowSystemMessageSnapshot;
475
+ declare function snapshotAgentWorkflowMessage(message: Message): AgentWorkflowMessageSnapshot;
476
+ declare function snapshotAgentWorkflowMessages(messages: Message[]): AgentWorkflowMessageSnapshot[];
477
+ declare function restoreAgentWorkflowMessage(snapshot: AgentWorkflowMessageSnapshot): Message;
478
+ declare function restoreAgentWorkflowMessages(snapshots: AgentWorkflowMessageSnapshot[]): Message[];
393
479
 
394
- export { type AgentTaskChatAdapter, type AgentTaskCheckpointReason, type AgentTaskCheckpointStrategy, type AgentTaskCheckpointStrategyInput, type AgentTaskExecutionCheckpoint, type AgentTaskExecutionContext, type AgentTaskExecutionRun, type AgentTaskExecutionSnapshot, type AgentTaskObserver, type AgentTaskPayload, type AgentTaskResult, type AgentTaskRunner, type AgentTaskRunnerOptions, AgentTurnCommitBatch, AgentTurnState, AgentTurnStepCommitSnapshot, AgentTurnStepCommitToolCall, AgentTurnStepCommitToolResult, type AgentWorkflowAssistantMessageSnapshot, type AgentWorkflowCommitResult, type AgentWorkflowMessageSnapshot, type AgentWorkflowModelStepPlan, type AgentWorkflowModelStepResult, type AgentWorkflowOperationPlan, type AgentWorkflowOutputCommitPlan, type AgentWorkflowReplayDecision, type AgentWorkflowStepCommitPlan, type AgentWorkflowSystemMessageSnapshot, type AgentWorkflowToolBatchResult, type AgentWorkflowToolCallPlan, type AgentWorkflowToolCallResult, type AgentWorkflowToolCallSnapshot, type AgentWorkflowToolMessageSnapshot, type AgentWorkflowTurnPhase, type AgentWorkflowTurnState, type AgentWorkflowUserMessageSnapshot, CommitOutputOptions, CommitStepOptions, ContextOverflowError, CreateAgentTurnStepCommitBatchOptions, type CreateAgentWorkflowTurnStateOptions, DoomLoopError, PrepareModelStepOptions, PreparedAgentModelStep, RunModelStepOptions, RunToolBatchOptions, RunToolBatchResult, StepProcessingOptions, StepProcessingOutput, applyAgentWorkflowCommitResult, applyAgentWorkflowModelStepResult, applyAgentWorkflowToolBatchResult, applyAgentWorkflowToolCallResult, cloneAgentWorkflowTurnState, commitOutput, commitStep, convertAgentMessagesToModelMessages, createAgentTaskRunner, createAgentTurnStepCommitBatch, createAgentWorkflowTurnState, defaultAgentTaskCheckpointStrategy, failAgentWorkflowTurnState, planNextAgentWorkflowOperation, prepareModelStep, processStepStream, processStream, recordAgentWorkflowReplayDecision, restoreAgentWorkflowMessage, restoreAgentWorkflowMessages, runModelStep, runToolBatch, snapshotAgentWorkflowMessage, snapshotAgentWorkflowMessages };
480
+ export { type AgentTaskChatAdapter, type AgentTaskCheckpointReason, type AgentTaskCheckpointStrategy, type AgentTaskCheckpointStrategyInput, type AgentTaskExecutionCheckpoint, type AgentTaskExecutionContext, type AgentTaskExecutionRun, type AgentTaskExecutionSnapshot, type AgentTaskObserver, type AgentTaskPayload, type AgentTaskResult, type AgentTaskResumeSnapshot, type AgentTaskRunner, type AgentTaskRunnerOptions, AgentTurnCommitBatch, AgentTurnState, AgentTurnStepCommitSnapshot, AgentTurnStepCommitToolCall, AgentTurnStepCommitToolResult, type AgentWorkflowAssistantMessageSnapshot, type AgentWorkflowCommitResult, type AgentWorkflowInputCommitPlan, type AgentWorkflowInterventionSnapshot, type AgentWorkflowMessageSnapshot, type AgentWorkflowModelStepPlan, type AgentWorkflowModelStepResult, type AgentWorkflowOperationPlan, type AgentWorkflowOutputCommitPlan, type AgentWorkflowReplayDecision, type AgentWorkflowStepCommitPlan, type AgentWorkflowSystemMessageSnapshot, type AgentWorkflowToolBatchPlan, type AgentWorkflowToolBatchResult, type AgentWorkflowToolCallPlan, type AgentWorkflowToolCallResult, type AgentWorkflowToolCallSnapshot, type AgentWorkflowToolMessageSnapshot, type AgentWorkflowTurnPhase, type AgentWorkflowTurnState, type AgentWorkflowUserMessageSnapshot, CommitOutputOptions, CommitStepOptions, ContextOverflowError, CreateAgentTurnStepCommitBatchOptions, type CreateAgentWorkflowTurnStateOptions, DoomLoopError, PrepareModelStepOptions, PreparedAgentModelStep, RunModelStepOptions, RunToolBatchOptions, RunToolBatchResult, StepProcessingOptions, StepProcessingOutput, applyAgentWorkflowCommitResult, applyAgentWorkflowModelStepResult, applyAgentWorkflowToolBatchResult, applyAgentWorkflowToolCallResult, applyWorkflowInterventions, cloneAgentWorkflowTurnState, commitOutput, commitStep, createAgentTaskRunner, createAgentTurnStepCommitBatch, createAgentWorkflowTurnState, defaultAgentTaskCheckpointStrategy, drainWorkflowInterventions, failAgentWorkflowTurnState, planNextAgentWorkflowOperation, prepareModelStep, processStepStream, queueWorkflowFollowUps, recordAgentWorkflowReplayDecision, restoreAgentWorkflowMessage, restoreAgentWorkflowMessages, runModelStep, runToolBatch, snapshotAgentWorkflowMessage, snapshotAgentWorkflowMessages };
@@ -7,22 +7,23 @@ import {
7
7
  applyAgentWorkflowModelStepResult,
8
8
  applyAgentWorkflowToolBatchResult,
9
9
  applyAgentWorkflowToolCallResult,
10
+ applyWorkflowInterventions,
10
11
  cloneAgentWorkflowTurnState,
11
12
  commitOutput,
12
13
  commitStep,
13
- convertAgentMessagesToModelMessages,
14
14
  createAgentTaskRunner,
15
15
  createAgentTurnEngine,
16
16
  createAgentTurnState,
17
17
  createAgentTurnStepCommitBatch,
18
18
  createAgentWorkflowTurnState,
19
19
  defaultAgentTaskCheckpointStrategy,
20
+ drainWorkflowInterventions,
20
21
  failAgentTurnState,
21
22
  failAgentWorkflowTurnState,
22
23
  planNextAgentWorkflowOperation,
23
24
  prepareModelStep,
24
25
  processStepStream,
25
- processStream,
26
+ queueWorkflowFollowUps,
26
27
  recordAgentWorkflowReplayDecision,
27
28
  restoreAgentWorkflowMessage,
28
29
  restoreAgentWorkflowMessages,
@@ -30,16 +31,18 @@ import {
30
31
  runToolBatch,
31
32
  snapshotAgentWorkflowMessage,
32
33
  snapshotAgentWorkflowMessages
33
- } from "../chunk-4BDA7DQY.js";
34
- import "../chunk-WWYYNWEW.js";
35
- import "../chunk-N6HWIEEA.js";
36
- import "../chunk-7VKQ4WPB.js";
37
- import "../chunk-VEKUXUVF.js";
38
- import "../chunk-SQU2AJHO.js";
39
- import "../chunk-N7P4PN3O.js";
40
- import "../chunk-RZITT45F.js";
41
- import "../chunk-RFEKJKTO.js";
42
- import "../chunk-DWYX7ASF.js";
34
+ } from "../chunk-WBPOZ7CL.js";
35
+ import {
36
+ convertAgentMessagesToModelMessages
37
+ } from "../chunk-CMYN2RCB.js";
38
+ import "../chunk-5NVVNXPQ.js";
39
+ import "../chunk-N3VX7FEE.js";
40
+ import "../chunk-RN6WZEUF.js";
41
+ import "../chunk-CJI7PVS2.js";
42
+ import "../chunk-I6PKJ7XQ.js";
43
+ import "../chunk-V4RFNEET.js";
44
+ import "../chunk-FII65CN7.js";
45
+ import "../chunk-T4UIX5D7.js";
43
46
  export {
44
47
  AgentTurnEngine,
45
48
  ContextOverflowError,
@@ -49,6 +52,7 @@ export {
49
52
  applyAgentWorkflowModelStepResult,
50
53
  applyAgentWorkflowToolBatchResult,
51
54
  applyAgentWorkflowToolCallResult,
55
+ applyWorkflowInterventions,
52
56
  cloneAgentWorkflowTurnState,
53
57
  commitOutput,
54
58
  commitStep,
@@ -59,12 +63,13 @@ export {
59
63
  createAgentTurnStepCommitBatch,
60
64
  createAgentWorkflowTurnState,
61
65
  defaultAgentTaskCheckpointStrategy,
66
+ drainWorkflowInterventions,
62
67
  failAgentTurnState,
63
68
  failAgentWorkflowTurnState,
64
69
  planNextAgentWorkflowOperation,
65
70
  prepareModelStep,
66
71
  processStepStream,
67
- processStream,
72
+ queueWorkflowFollowUps,
68
73
  recordAgentWorkflowReplayDecision,
69
74
  restoreAgentWorkflowMessage,
70
75
  restoreAgentWorkflowMessages,
@@ -0,0 +1,251 @@
1
+ import { R as ReasoningLevel, a as ReasoningConfig } from './types-CQaXbRsS.js';
2
+ import { LanguageModel } from 'ai';
3
+ import { ProviderOptions } from '@ai-sdk/provider-utils';
4
+
5
+ /**
6
+ * Model Capability Types for @cuylabs/agent-core
7
+ *
8
+ * Defines the structure for model capabilities that can be sourced from
9
+ * static patterns, local cache, or remote APIs.
10
+ */
11
+ /**
12
+ * Input modalities a model can accept
13
+ */
14
+ type InputModality = "text" | "image" | "audio" | "video" | "pdf";
15
+ /**
16
+ * Output modalities a model can produce
17
+ */
18
+ type OutputModality = "text" | "image" | "audio" | "video";
19
+ /**
20
+ * Comprehensive model capabilities
21
+ */
22
+ interface ModelCapabilities {
23
+ /** Model supports extended reasoning/thinking */
24
+ reasoning: boolean;
25
+ /** Model supports function/tool calling */
26
+ toolCalling: boolean;
27
+ /** Model supports temperature adjustment */
28
+ temperature: boolean;
29
+ /** Model supports file attachments */
30
+ attachments: boolean;
31
+ /** Model supports streaming responses */
32
+ streaming: boolean;
33
+ /** Supported input modalities */
34
+ inputModalities: InputModality[];
35
+ /** Supported output modalities */
36
+ outputModalities: OutputModality[];
37
+ /** Maximum context window in tokens */
38
+ contextWindow?: number;
39
+ /** Maximum output tokens */
40
+ maxOutput?: number;
41
+ }
42
+ /**
43
+ * Provider-specific compatibility flags
44
+ * These handle quirks in different provider implementations
45
+ */
46
+ interface ProviderCompatibility {
47
+ /** Supports OpenAI-style reasoning_effort parameter */
48
+ supportsReasoningEffort?: boolean;
49
+ /** Supports developer/system role distinction */
50
+ supportsDeveloperRole?: boolean;
51
+ /** Field name for max tokens (varies by provider) */
52
+ maxTokensField?: "max_tokens" | "max_completion_tokens";
53
+ /** Requires thinking as text tags vs structured */
54
+ requiresThinkingTags?: boolean;
55
+ /** Provider-specific thinking format */
56
+ thinkingFormat?: "openai" | "anthropic" | "google" | "zai";
57
+ }
58
+ /**
59
+ * Complete model entry with metadata
60
+ */
61
+ interface ModelEntry {
62
+ /** Model identifier (e.g., "gpt-4o", "claude-sonnet-4") */
63
+ id: string;
64
+ /** Human-readable model name */
65
+ name: string;
66
+ /** Provider identifier (e.g., "openai", "anthropic") */
67
+ provider: string;
68
+ /** Model capabilities */
69
+ capabilities: ModelCapabilities;
70
+ /** Provider-specific compatibility settings */
71
+ compatibility?: ProviderCompatibility;
72
+ /** Cost per million tokens (input) */
73
+ costInput?: number;
74
+ /** Cost per million tokens (output) */
75
+ costOutput?: number;
76
+ /** When this entry was last updated */
77
+ updatedAt?: string;
78
+ }
79
+ /**
80
+ * Priority levels for capability sources
81
+ */
82
+ declare enum SourcePriority {
83
+ /** User configuration overrides everything */
84
+ UserConfig = 0,
85
+ /** Local cache from previous fetch */
86
+ LocalCache = 1,
87
+ /** Bundled static data (build-time) */
88
+ BundledData = 2,
89
+ /** Pattern-based inference (fallback) */
90
+ PatternMatch = 3,
91
+ /** Remote API (if network available) */
92
+ RemoteAPI = 4
93
+ }
94
+ /**
95
+ * Result from a capability source lookup
96
+ */
97
+ interface SourceResult {
98
+ /** The model entry if found */
99
+ entry?: ModelEntry;
100
+ /** Which source provided this result */
101
+ source: SourcePriority;
102
+ /** Whether this is a confident match */
103
+ confident: boolean;
104
+ /** Error message if lookup failed */
105
+ error?: string;
106
+ }
107
+ /**
108
+ * Capability source interface
109
+ */
110
+ interface CapabilitySource {
111
+ /** Source priority (lower = higher priority) */
112
+ priority: SourcePriority;
113
+ /** Human-readable source name */
114
+ name: string;
115
+ /** Look up capabilities for a model */
116
+ lookup(modelId: string, provider?: string): Promise<SourceResult>;
117
+ /** Check if this source is available */
118
+ isAvailable(): Promise<boolean>;
119
+ }
120
+ /**
121
+ * Options for the capability resolver
122
+ */
123
+ interface ResolverOptions {
124
+ /** Enable remote API fetching (default: false) */
125
+ enableRemoteFetch?: boolean;
126
+ /** Remote API URL (default: https://models.dev) */
127
+ remoteApiUrl?: string;
128
+ /** Cache directory path */
129
+ cachePath?: string;
130
+ /** Cache TTL in milliseconds (default: 1 hour) */
131
+ cacheTtlMs?: number;
132
+ /** Network timeout in milliseconds (default: 10 seconds) */
133
+ networkTimeoutMs?: number;
134
+ /** Custom user overrides for specific models */
135
+ modelOverrides?: Record<string, Partial<ModelCapabilities>>;
136
+ }
137
+ /**
138
+ * Default resolver options
139
+ */
140
+ declare const DEFAULT_RESOLVER_OPTIONS: Required<ResolverOptions>;
141
+
142
+ /**
143
+ * Provider-Specific Reasoning Option Builders
144
+ *
145
+ * Each function takes a {@link ReasoningLevel} and returns the
146
+ * provider-options object expected by the Vercel AI SDK's
147
+ * `providerOptions` parameter.
148
+ *
149
+ * Provider key mapping (`getProviderOptionsKey`) is also defined
150
+ * here so that callers can wrap the raw options correctly.
151
+ */
152
+
153
+ /**
154
+ * Build OpenAI reasoning options.
155
+ *
156
+ * OpenAI reasoning models use:
157
+ * - `reasoningEffort` — controls depth
158
+ * - `reasoningSummary` — controls whether reasoning is streamed
159
+ * (`"auto"` = condensed summary, `"detailed"` = full)
160
+ *
161
+ * `reasoningSummary` requires a verified OpenAI organisation.
162
+ * Set `CODE_AGENT_DISABLE_REASONING_SUMMARY=true` to skip it.
163
+ */
164
+ declare function buildOpenAIOptions(level: ReasoningLevel, compat?: ProviderCompatibility): Record<string, unknown> | undefined;
165
+ /**
166
+ * Build Anthropic thinking options.
167
+ *
168
+ * Uses `thinking.type: "enabled"` with `budgetTokens`.
169
+ */
170
+ declare function buildAnthropicOptions(level: ReasoningLevel): Record<string, unknown> | undefined;
171
+ /**
172
+ * Build Google / Gemini reasoning options.
173
+ *
174
+ * - **Gemini 3+** uses `thinkingLevel` (`"low"` / `"high"`)
175
+ * - **Gemini 2.5 and earlier** uses `thinkingBudget` (token count)
176
+ */
177
+ declare function buildGoogleOptions(level: ReasoningLevel, modelId?: string): Record<string, unknown> | undefined;
178
+ /**
179
+ * Build xAI / Grok reasoning options.
180
+ */
181
+ declare function buildXAIOptions(level: ReasoningLevel): Record<string, unknown> | undefined;
182
+ /**
183
+ * Build Groq reasoning options.
184
+ */
185
+ declare function buildGroqOptions(level: ReasoningLevel): Record<string, unknown> | undefined;
186
+ /**
187
+ * Build Amazon Bedrock reasoning options.
188
+ *
189
+ * - Anthropic / Claude models use `budgetTokens`
190
+ * - Amazon Nova models use `maxReasoningEffort`
191
+ */
192
+ declare function buildBedrockOptions(level: ReasoningLevel, modelId?: string): Record<string, unknown> | undefined;
193
+ /**
194
+ * Build OpenRouter reasoning options.
195
+ */
196
+ declare function buildOpenRouterOptions(level: ReasoningLevel): Record<string, unknown> | undefined;
197
+ /**
198
+ * Resolve the `providerOptions` key for a given SDK provider string.
199
+ *
200
+ * Falls back to the first dot-segment (e.g. `"foo.bar"` → `"foo"`).
201
+ */
202
+ declare function getProviderOptionsKey(provider: string): string;
203
+
204
+ /**
205
+ * Reasoning Configuration & Option Builders
206
+ *
207
+ * Orchestrates capability detection and provider-specific option
208
+ * building to produce ready-to-use `providerOptions` for the
209
+ * Vercel AI SDK.
210
+ *
211
+ * Two flavours of every function are provided:
212
+ * - **Async** (`getReasoningConfig`, `buildReasoningOptions`) —
213
+ * uses the full capability resolver (network + cache).
214
+ * - **Sync** (`getReasoningConfigSync`, `buildReasoningOptionsSync`) —
215
+ * uses fast pattern-matching only (no network).
216
+ */
217
+
218
+ /**
219
+ * Get the reasoning configuration for a model.
220
+ *
221
+ * Uses the full capability resolver (including network lookups)
222
+ * for the most accurate result.
223
+ */
224
+ declare function getReasoningConfig(model: LanguageModel): Promise<ReasoningConfig>;
225
+ /**
226
+ * Synchronous reasoning config using pattern-matching only.
227
+ *
228
+ * Faster but less accurate than {@link getReasoningConfig}.
229
+ * Good for hot paths where async is impractical.
230
+ */
231
+ declare function getReasoningConfigSync(model: LanguageModel): ReasoningConfig;
232
+ /**
233
+ * Build `providerOptions` for a reasoning level (async).
234
+ *
235
+ * Returns `undefined` when reasoning is off or unsupported.
236
+ */
237
+ declare function buildReasoningOptions(model: LanguageModel, level: ReasoningLevel): Promise<ProviderOptions | undefined>;
238
+ /**
239
+ * Build `providerOptions` for a reasoning level (sync / pattern-only).
240
+ */
241
+ declare function buildReasoningOptionsSync(model: LanguageModel, level: ReasoningLevel): ProviderOptions | undefined;
242
+ /**
243
+ * Check whether a model supports reasoning (async, full resolver).
244
+ */
245
+ declare function supportsReasoning(model: LanguageModel): Promise<boolean>;
246
+ /**
247
+ * Synchronous check using pattern-matching only.
248
+ */
249
+ declare function supportsReasoningSync(model: LanguageModel): boolean;
250
+
251
+ export { type CapabilitySource as C, DEFAULT_RESOLVER_OPTIONS as D, type InputModality as I, type ModelCapabilities as M, type OutputModality as O, type ProviderCompatibility as P, type ResolverOptions as R, SourcePriority as S, type ModelEntry as a, type SourceResult as b, buildAnthropicOptions as c, buildBedrockOptions as d, buildGoogleOptions as e, buildGroqOptions as f, buildOpenAIOptions as g, buildOpenRouterOptions as h, buildReasoningOptions as i, buildReasoningOptionsSync as j, buildXAIOptions as k, getProviderOptionsKey as l, getReasoningConfig as m, getReasoningConfigSync as n, supportsReasoningSync as o, supportsReasoning as s };