@cuylabs/agent-core 0.5.0 → 0.6.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.
@@ -1,8 +1,175 @@
1
1
  import * as ai from 'ai';
2
- import { LanguageModel } from 'ai';
2
+ import { LanguageModel, ModelMessage, TelemetrySettings } from 'ai';
3
3
  import { T as TokenUsage, M as Message } from './messages-BYWGn8TY.js';
4
4
  import { d as SkillConfig, T as Tool } from './tool-pFAnJc5Y.js';
5
5
  import { b as ToolContext } from './tool-DYp6-cC3.js';
6
+ import { R as ReasoningLevel } from './types-CQaXbRsS.js';
7
+
8
+ /**
9
+ * Stream types for @cuylabs/agent-core
10
+ *
11
+ * Defines the canonical StreamChunk union and related types
12
+ * for both AI SDK native and custom stream providers.
13
+ */
14
+ /**
15
+ * Stream chunk types (AI SDK compatible + custom streams)
16
+ *
17
+ * This is the single canonical definition — used by both the
18
+ * streaming module and custom stream providers.
19
+ */
20
+ type StreamChunk = {
21
+ type: "text-start";
22
+ } | {
23
+ type: "text-delta";
24
+ text: string;
25
+ } | {
26
+ type: "text-end";
27
+ } | {
28
+ type: "reasoning-start";
29
+ id: string;
30
+ } | {
31
+ type: "reasoning-delta";
32
+ id: string;
33
+ text: string;
34
+ } | {
35
+ type: "reasoning-end";
36
+ id: string;
37
+ } | {
38
+ type: "tool-call";
39
+ toolName: string;
40
+ toolCallId: string;
41
+ input: unknown;
42
+ } | {
43
+ type: "tool-result";
44
+ toolName: string;
45
+ toolCallId: string;
46
+ output: unknown;
47
+ } | {
48
+ type: "tool-error";
49
+ toolName: string;
50
+ toolCallId: string;
51
+ error: unknown;
52
+ } | {
53
+ type: "finish-step";
54
+ usage?: {
55
+ inputTokens?: number;
56
+ outputTokens?: number;
57
+ totalTokens?: number;
58
+ };
59
+ finishReason?: string;
60
+ } | {
61
+ type: "finish";
62
+ totalUsage?: {
63
+ inputTokens?: number;
64
+ outputTokens?: number;
65
+ totalTokens?: number;
66
+ };
67
+ } | {
68
+ type: "error";
69
+ error: unknown;
70
+ } | {
71
+ type: "start-step";
72
+ } | {
73
+ type: "start";
74
+ } | {
75
+ type: "abort";
76
+ } | {
77
+ type: "computer-call";
78
+ callId: string;
79
+ action: unknown;
80
+ pendingSafetyChecks?: unknown[];
81
+ } | {
82
+ type: "step-usage";
83
+ usage: {
84
+ inputTokens: number;
85
+ outputTokens: number;
86
+ totalTokens: number;
87
+ };
88
+ };
89
+ /**
90
+ * Custom stream provider function type.
91
+ *
92
+ * This matches the signature needed for agent-core's LLM module,
93
+ * returning a StreamProviderResult-compatible object.
94
+ */
95
+ type StreamProvider = (input: StreamProviderInput) => Promise<StreamProviderResult>;
96
+ /**
97
+ * Input for custom stream providers
98
+ */
99
+ interface StreamProviderInput {
100
+ /** System prompt */
101
+ system: string;
102
+ /** Messages to send */
103
+ messages: Array<{
104
+ role: string;
105
+ content: unknown;
106
+ }>;
107
+ /** Abort signal */
108
+ abortSignal?: AbortSignal;
109
+ /** Max iterations */
110
+ maxSteps?: number;
111
+ }
112
+ /**
113
+ * Result from custom stream providers (AI SDK StreamTextResult compatible)
114
+ */
115
+ interface StreamProviderResult {
116
+ /** Async iterable of stream chunks */
117
+ fullStream: AsyncIterable<StreamChunk>;
118
+ /** Promise resolving to final text */
119
+ text: Promise<string>;
120
+ /** Promise resolving to usage stats */
121
+ usage: Promise<{
122
+ inputTokens: number;
123
+ outputTokens: number;
124
+ totalTokens: number;
125
+ }>;
126
+ /** Promise resolving to finish reason */
127
+ finishReason: Promise<string>;
128
+ }
129
+ /**
130
+ * Configuration for stream provider factory.
131
+ * Contains everything needed to create a stream provider for a specific model.
132
+ */
133
+ interface StreamProviderConfig {
134
+ /** API key to use */
135
+ apiKey?: string;
136
+ /** Display dimensions */
137
+ display?: {
138
+ width: number;
139
+ height: number;
140
+ };
141
+ /** Environment type */
142
+ environment?: string;
143
+ /** Enable debug logging */
144
+ debug?: boolean;
145
+ }
146
+ /**
147
+ * Stream provider factory - creates a stream provider for a given model.
148
+ *
149
+ * This is attached to enhanced tools (like computer tools) to allow
150
+ * the Agent to automatically configure the right stream provider
151
+ * when a model requires custom handling (e.g., OpenAI computer-use-preview).
152
+ */
153
+ type StreamProviderFactory = (modelId: string, config: StreamProviderConfig) => StreamProvider;
154
+ /**
155
+ * Enhanced tools array with additional capabilities.
156
+ *
157
+ * This extends the standard Tool.AnyInfo[] with optional metadata
158
+ * that the Agent can use for automatic configuration.
159
+ */
160
+ interface EnhancedTools extends Array<unknown> {
161
+ /**
162
+ * Factory to create a stream provider for models that need custom streaming.
163
+ * Called by the Agent when it detects a model that requires special handling.
164
+ */
165
+ __streamProviderFactory?: StreamProviderFactory;
166
+ /**
167
+ * Model patterns that require the custom stream provider.
168
+ * Used by the Agent to detect when to use the factory.
169
+ * Default patterns: ["computer-use-preview"]
170
+ */
171
+ __customStreamModels?: string[];
172
+ }
6
173
 
7
174
  /** Agent status for UI display */
8
175
  type AgentStatus = "idle" | "processing" | "thinking" | "reasoning" | "calling-tool" | "waiting-approval" | "error";
@@ -127,6 +294,7 @@ type AgentEvent = {
127
294
  } | {
128
295
  type: "complete";
129
296
  usage?: TokenUsage;
297
+ output?: string;
130
298
  };
131
299
  /**
132
300
  * Processor result - what happens after processing a turn
@@ -389,6 +557,83 @@ interface ToolCallDecision {
389
557
  /** Reason for denial — returned to the model as the tool output */
390
558
  reason?: string;
391
559
  }
560
+ /**
561
+ * Mutable model invocation payload presented to middleware before an LLM call.
562
+ */
563
+ interface ModelCallInput {
564
+ model: LanguageModel;
565
+ system: string[];
566
+ messages: ModelMessage[];
567
+ temperature?: number;
568
+ topP?: number;
569
+ maxOutputTokens?: number;
570
+ maxSteps?: number;
571
+ reasoningLevel?: ReasoningLevel;
572
+ telemetry?: TelemetrySettings;
573
+ customStreamProvider?: StreamProvider;
574
+ toolExecutionMode?: "auto" | "plan";
575
+ }
576
+ /**
577
+ * Context shared across model middleware hooks for a single step.
578
+ */
579
+ interface ModelCallContext {
580
+ sessionID: string;
581
+ step: number;
582
+ cwd: string;
583
+ abort: AbortSignal;
584
+ model: LanguageModel;
585
+ toolNames: string[];
586
+ mcpToolNames: string[];
587
+ }
588
+ /**
589
+ * Return this from `model.input(...)` to stop an LLM call entirely.
590
+ */
591
+ interface BlockedModelCall {
592
+ block: true;
593
+ reason: string;
594
+ }
595
+ /**
596
+ * Final step result exposed to model middleware after the stream is processed.
597
+ */
598
+ interface ModelCallOutput {
599
+ text: string;
600
+ usage?: TokenUsage;
601
+ finishReason?: string;
602
+ }
603
+ /**
604
+ * Optional model-specific hooks grouped under `middleware.model`.
605
+ */
606
+ interface AgentModelHooks {
607
+ /**
608
+ * Review or rewrite the model request before the LLM is invoked.
609
+ *
610
+ * Return:
611
+ * - `undefined` to keep the current request
612
+ * - a `ModelCallInput` object to replace the request
613
+ * - `{ block: true, reason }` to cancel the model call
614
+ *
615
+ * Hooks run in middleware array order. The first block stops the call.
616
+ */
617
+ input?(input: ModelCallInput, ctx: ModelCallContext): Promise<ModelCallInput | BlockedModelCall | void>;
618
+ /**
619
+ * Review or rewrite raw stream chunks as they arrive from the model.
620
+ *
621
+ * Return:
622
+ * - `undefined` to keep the current chunk
623
+ * - a `StreamChunk` to replace it
624
+ * - `null` to drop it from downstream processing
625
+ *
626
+ * Hooks run in middleware array order.
627
+ */
628
+ chunk?(chunk: StreamChunk, ctx: ModelCallContext): Promise<StreamChunk | null | void>;
629
+ /**
630
+ * Review or rewrite the fully processed model result for the current step.
631
+ *
632
+ * Hooks run in reverse middleware order so outer middleware sees the final
633
+ * shaped result, matching `afterToolCall(...)`.
634
+ */
635
+ output?(output: ModelCallOutput, ctx: ModelCallContext): Promise<ModelCallOutput | void>;
636
+ }
392
637
  /**
393
638
  * Agent middleware — composable lifecycle hooks.
394
639
  *
@@ -397,6 +642,9 @@ interface ToolCallDecision {
397
642
  * Ordering:
398
643
  * - `beforeToolCall`: runs in array order, first "deny" wins
399
644
  * - `afterToolCall`: runs in reverse order (innermost first)
645
+ * - `model.input`: runs in array order, first block wins
646
+ * - `model.chunk`: runs in array order on raw stream chunks
647
+ * - `model.output`: runs in reverse order
400
648
  * - `promptSections`: all run, sections merged
401
649
  * - `onEvent`: all run in parallel (non-blocking)
402
650
  * - `onChatStart` / `onChatEnd`: run in array order, awaited sequentially
@@ -420,6 +668,11 @@ interface ToolCallDecision {
420
668
  interface AgentMiddleware {
421
669
  /** Middleware name (for logging and debugging) */
422
670
  name: string;
671
+ /**
672
+ * Optional hooks for shaping model requests, raw stream chunks,
673
+ * and final step outputs.
674
+ */
675
+ model?: AgentModelHooks;
423
676
  /**
424
677
  * Intercept a tool call before execution.
425
678
  *
@@ -538,6 +791,9 @@ declare class MiddlewareRunner {
538
791
  get hasMiddleware(): boolean;
539
792
  /** Get the middleware list (for fork inheritance) */
540
793
  getMiddleware(): readonly AgentMiddleware[];
794
+ runModelInput(input: ModelCallInput, ctx: ModelCallContext): Promise<ModelCallInput | BlockedModelCall>;
795
+ runModelChunk(chunk: StreamChunk, ctx: ModelCallContext): Promise<StreamChunk | undefined>;
796
+ runModelOutput(output: ModelCallOutput, ctx: ModelCallContext): Promise<ModelCallOutput>;
541
797
  /**
542
798
  * Run all `beforeToolCall` hooks in order.
543
799
  *
@@ -593,4 +849,4 @@ declare class MiddlewareRunner {
593
849
  }): Promise<void>;
594
850
  }
595
851
 
596
- export { type AgentEvent as A, type EnvironmentInfo as E, type InstructionFile as I, MiddlewareRunner as M, type PromptConfig as P, type StreamInput as S, type ToolCallDecision as T, type PromptBuildContext as a, type PromptSection as b, type ModelFamily as c, type ProcessorResult as d, type AgentTurnBoundaryKind as e, type AgentMiddleware as f, type AgentStatus as g, type ApprovalEvent as h };
852
+ export { type AgentEvent as A, type BlockedModelCall as B, type EnhancedTools as E, type InstructionFile as I, MiddlewareRunner as M, type PromptConfig as P, type StreamChunk as S, type ToolCallDecision as T, type PromptBuildContext as a, type PromptSection as b, type ModelFamily as c, type ProcessorResult as d, type StreamProvider as e, type ModelCallInput as f, type AgentTurnBoundaryKind as g, type AgentMiddleware as h, type AgentModelHooks as i, type AgentStatus as j, type ApprovalEvent as k, type EnvironmentInfo as l, type ModelCallContext as m, type ModelCallOutput as n, type StreamInput as o, type StreamProviderConfig as p, type StreamProviderFactory as q, type StreamProviderInput as r, type StreamProviderResult as s };
@@ -1,7 +1,7 @@
1
- import { A as AgentEvent } from '../runner-C7aMP_x3.js';
1
+ import { A as AgentEvent } from '../runner-G1wxEgac.js';
2
2
  import { T as TokenUsage, M as Message } from '../messages-BYWGn8TY.js';
3
- import { n as AgentTurnStepCommitSnapshot, t as CreateAgentTurnStepCommitBatchOptions, f as AgentTurnCommitBatch, K as PrepareModelStepOptions, M as PreparedAgentModelStep, U as RunModelStepOptions, a as ProcessorOutput, V as RunToolBatchOptions, W as RunToolBatchResult, C as CommitOutputOptions, r as CommitStepOptions, l as AgentTurnState, p as AgentTurnStepCommitToolResult, o as AgentTurnStepCommitToolCall } from '../types-MM1JoX5T.js';
4
- export { b as AgentTurnActiveToolCall, c as AgentTurnBoundaryMetadata, d as AgentTurnBoundarySnapshot, e as AgentTurnCommitApplier, g as AgentTurnCommitOptions, h as AgentTurnEngine, i as AgentTurnEngineOptions, j as AgentTurnPhase, k as AgentTurnResolvedToolCall, m as AgentTurnStateAdvanceOptions, q as AgentTurnStepRuntimeConfig, s as CreateAgentTurnStateOptions, a2 as advanceAgentTurnState, a4 as createAgentTurnEngine, a5 as createAgentTurnState, a8 as failAgentTurnState } from '../types-MM1JoX5T.js';
3
+ import { n as AgentTurnStepCommitSnapshot, t as CreateAgentTurnStepCommitBatchOptions, f as AgentTurnCommitBatch, J as PrepareModelStepOptions, K as PreparedAgentModelStep, S as RunModelStepOptions, a as ProcessorOutput, U as RunToolBatchOptions, V as RunToolBatchResult, C as CommitOutputOptions, r as CommitStepOptions, l as AgentTurnState, p as AgentTurnStepCommitToolResult, o as AgentTurnStepCommitToolCall } from '../types-BWo810L_.js';
4
+ export { b as AgentTurnActiveToolCall, c as AgentTurnBoundaryMetadata, d as AgentTurnBoundarySnapshot, e as AgentTurnCommitApplier, g as AgentTurnCommitOptions, h as AgentTurnEngine, i as AgentTurnEngineOptions, j as AgentTurnPhase, k as AgentTurnResolvedToolCall, m as AgentTurnStateAdvanceOptions, q as AgentTurnStepRuntimeConfig, s as CreateAgentTurnStateOptions, X as advanceAgentTurnState, Z as createAgentTurnEngine, _ as createAgentTurnState, a1 as failAgentTurnState } from '../types-BWo810L_.js';
5
5
  import { ModelMessage } from 'ai';
6
6
  import '../tool-pFAnJc5Y.js';
7
7
  import 'zod';
@@ -26,7 +26,7 @@ import {
26
26
  runToolBatch,
27
27
  snapshotAgentWorkflowMessage,
28
28
  snapshotAgentWorkflowMessages
29
- } from "../chunk-IMGQOTU2.js";
29
+ } from "../chunk-3C4VKG4P.js";
30
30
  import "../chunk-FG4MD5MU.js";
31
31
  import "../chunk-VEKUXUVF.js";
32
32
  import "../chunk-QAQADS4X.js";
@@ -1,14 +1,14 @@
1
- export { c as AgentProfile, D as DEFAULT_MAX_CONCURRENT, d as DEFAULT_MAX_SPAWN_DEPTH, e as DEFAULT_SESSION_TITLE_PREFIX, S as SubAgentCompletedResult, f as SubAgentHandle, g as SubAgentStatus, h as SubAgentToolConfig, i as SubAgentTracker, j as SubAgentUsage, l as createSubAgentTools } from '../index-p0kOsVsE.js';
1
+ export { c as AgentProfile, D as DEFAULT_MAX_CONCURRENT, d as DEFAULT_MAX_SPAWN_DEPTH, e as DEFAULT_SESSION_TITLE_PREFIX, S as SubAgentCompletedResult, f as SubAgentHandle, g as SubAgentStatus, h as SubAgentToolConfig, i as SubAgentTracker, j as SubAgentUsage, l as createSubAgentTools } from '../index-DZQJD_hp.js';
2
2
  import 'ai';
3
3
  import '../types-CQaXbRsS.js';
4
4
  import '../tool-pFAnJc5Y.js';
5
5
  import 'zod';
6
6
  import '../tool-DYp6-cC3.js';
7
- import '../runner-C7aMP_x3.js';
7
+ import '../runner-G1wxEgac.js';
8
8
  import '../messages-BYWGn8TY.js';
9
9
  import '../session-manager-Uawm2Le7.js';
10
10
  import '../types-VQgymC1N.js';
11
11
  import '../tracker-DClqYqTj.js';
12
- import '../builder-RcTZuYnO.js';
12
+ import '../builder-BKkipazh.js';
13
13
  import '../registry-CuRWWtcT.js';
14
- import '../types-MM1JoX5T.js';
14
+ import '../types-BWo810L_.js';
@@ -1,10 +1,11 @@
1
1
  import { T as Tool } from '../tool-pFAnJc5Y.js';
2
2
  export { C as CompatibleSchema, I as InferSchemaOutput, k as defineTool } from '../tool-pFAnJc5Y.js';
3
3
  import { a as ToolReplayPolicy, F as FileOperationMeta, N as NormalizedToolReplayPolicy, d as ToolHost, e as TurnTrackerContext } from '../tool-DYp6-cC3.js';
4
- import { M as MiddlewareRunner } from '../runner-C7aMP_x3.js';
4
+ import { M as MiddlewareRunner } from '../runner-G1wxEgac.js';
5
5
  import 'zod';
6
6
  import 'ai';
7
7
  import '../messages-BYWGn8TY.js';
8
+ import '../types-CQaXbRsS.js';
8
9
 
9
10
  /**
10
11
  * Normalize a tool replay policy into explicit, infrastructure-agnostic
@@ -1,176 +1,10 @@
1
1
  import { StreamTextResult, ToolSet, Output, LanguageModel, ModelMessage, TelemetrySettings } from 'ai';
2
2
  import { T as Tool } from './tool-pFAnJc5Y.js';
3
3
  import { d as ToolHost, e as TurnTrackerContext, N as NormalizedToolReplayPolicy } from './tool-DYp6-cC3.js';
4
- import { d as ProcessorResult, A as AgentEvent, M as MiddlewareRunner, e as AgentTurnBoundaryKind } from './runner-C7aMP_x3.js';
4
+ import { d as ProcessorResult, A as AgentEvent, S as StreamChunk, e as StreamProvider, M as MiddlewareRunner, f as ModelCallInput, g as AgentTurnBoundaryKind } from './runner-G1wxEgac.js';
5
5
  import { R as ReasoningLevel } from './types-CQaXbRsS.js';
6
6
  import { T as TokenUsage, M as Message } from './messages-BYWGn8TY.js';
7
7
 
8
- /**
9
- * Stream types for @cuylabs/agent-core
10
- *
11
- * Defines the canonical StreamChunk union and related types
12
- * for both AI SDK native and custom stream providers.
13
- */
14
- /**
15
- * Stream chunk types (AI SDK compatible + custom streams)
16
- *
17
- * This is the single canonical definition — used by both the
18
- * streaming module and custom stream providers.
19
- */
20
- type StreamChunk = {
21
- type: "text-start";
22
- } | {
23
- type: "text-delta";
24
- text: string;
25
- } | {
26
- type: "text-end";
27
- } | {
28
- type: "reasoning-start";
29
- id: string;
30
- } | {
31
- type: "reasoning-delta";
32
- id: string;
33
- text: string;
34
- } | {
35
- type: "reasoning-end";
36
- id: string;
37
- } | {
38
- type: "tool-call";
39
- toolName: string;
40
- toolCallId: string;
41
- input: unknown;
42
- } | {
43
- type: "tool-result";
44
- toolName: string;
45
- toolCallId: string;
46
- output: unknown;
47
- } | {
48
- type: "tool-error";
49
- toolName: string;
50
- toolCallId: string;
51
- error: unknown;
52
- } | {
53
- type: "finish-step";
54
- usage?: {
55
- inputTokens?: number;
56
- outputTokens?: number;
57
- totalTokens?: number;
58
- };
59
- finishReason?: string;
60
- } | {
61
- type: "finish";
62
- totalUsage?: {
63
- inputTokens?: number;
64
- outputTokens?: number;
65
- totalTokens?: number;
66
- };
67
- } | {
68
- type: "error";
69
- error: unknown;
70
- } | {
71
- type: "start-step";
72
- } | {
73
- type: "start";
74
- } | {
75
- type: "abort";
76
- } | {
77
- type: "computer-call";
78
- callId: string;
79
- action: unknown;
80
- pendingSafetyChecks?: unknown[];
81
- } | {
82
- type: "step-usage";
83
- usage: {
84
- inputTokens: number;
85
- outputTokens: number;
86
- totalTokens: number;
87
- };
88
- };
89
- /**
90
- * Custom stream provider function type.
91
- *
92
- * This matches the signature needed for agent-core's LLM module,
93
- * returning a StreamProviderResult-compatible object.
94
- */
95
- type StreamProvider = (input: StreamProviderInput) => Promise<StreamProviderResult>;
96
- /**
97
- * Input for custom stream providers
98
- */
99
- interface StreamProviderInput {
100
- /** System prompt */
101
- system: string;
102
- /** Messages to send */
103
- messages: Array<{
104
- role: string;
105
- content: unknown;
106
- }>;
107
- /** Abort signal */
108
- abortSignal?: AbortSignal;
109
- /** Max iterations */
110
- maxSteps?: number;
111
- }
112
- /**
113
- * Result from custom stream providers (AI SDK StreamTextResult compatible)
114
- */
115
- interface StreamProviderResult {
116
- /** Async iterable of stream chunks */
117
- fullStream: AsyncIterable<StreamChunk>;
118
- /** Promise resolving to final text */
119
- text: Promise<string>;
120
- /** Promise resolving to usage stats */
121
- usage: Promise<{
122
- inputTokens: number;
123
- outputTokens: number;
124
- totalTokens: number;
125
- }>;
126
- /** Promise resolving to finish reason */
127
- finishReason: Promise<string>;
128
- }
129
- /**
130
- * Configuration for stream provider factory.
131
- * Contains everything needed to create a stream provider for a specific model.
132
- */
133
- interface StreamProviderConfig {
134
- /** API key to use */
135
- apiKey?: string;
136
- /** Display dimensions */
137
- display?: {
138
- width: number;
139
- height: number;
140
- };
141
- /** Environment type */
142
- environment?: string;
143
- /** Enable debug logging */
144
- debug?: boolean;
145
- }
146
- /**
147
- * Stream provider factory - creates a stream provider for a given model.
148
- *
149
- * This is attached to enhanced tools (like computer tools) to allow
150
- * the Agent to automatically configure the right stream provider
151
- * when a model requires custom handling (e.g., OpenAI computer-use-preview).
152
- */
153
- type StreamProviderFactory = (modelId: string, config: StreamProviderConfig) => StreamProvider;
154
- /**
155
- * Enhanced tools array with additional capabilities.
156
- *
157
- * This extends the standard Tool.AnyInfo[] with optional metadata
158
- * that the Agent can use for automatic configuration.
159
- */
160
- interface EnhancedTools extends Array<unknown> {
161
- /**
162
- * Factory to create a stream provider for models that need custom streaming.
163
- * Called by the Agent when it detects a model that requires special handling.
164
- */
165
- __streamProviderFactory?: StreamProviderFactory;
166
- /**
167
- * Model patterns that require the custom stream provider.
168
- * Used by the Agent to detect when to use the factory.
169
- * Default patterns: ["computer-use-preview"]
170
- */
171
- __customStreamModels?: string[];
172
- }
173
-
174
8
  /**
175
9
  * Doom-loop handling contracts for repeated tool invocations.
176
10
  */
@@ -507,6 +341,8 @@ type ToolExecutionMode = "auto" | "plan";
507
341
  interface LLMStreamInput {
508
342
  /** Session ID */
509
343
  sessionID: string;
344
+ /** Step number within the current turn */
345
+ step?: number;
510
346
  /** Model to use */
511
347
  model: LanguageModel;
512
348
  /** System prompt parts */
@@ -549,6 +385,8 @@ interface LLMStreamInput {
549
385
  middleware?: MiddlewareRunner;
550
386
  /** AI SDK telemetry settings */
551
387
  telemetry?: TelemetrySettings;
388
+ /** Internal snapshot of the resolved model request after middleware input hooks. */
389
+ activeModelCall?: ModelCallInput;
552
390
  }
553
391
  /**
554
392
  * Step information surfaced to callers.
@@ -807,4 +645,4 @@ interface RunToolBatchResult {
807
645
  }>>;
808
646
  }
809
647
 
810
- export { type StreamProviderFactory as $, type AnyStreamResult as A, LLMError as B, type CommitOutputOptions as C, DEFAULT_RETRY_CONFIG as D, type ErrorCategory as E, type LLMErrorOptions as F, type LLMStreamResult as G, type OnInterventionApplied as H, InterventionController as I, type PendingIntervention as J, type PrepareModelStepOptions as K, type LLMStreamInput as L, type PreparedAgentModelStep as M, type RetryConfig as N, OUTPUT_TOKEN_MAX as O, type ProcessorOptions as P, type RetryHandlerOptions as Q, type ResponseHeaders as R, type RetryState as S, type ToolExecutionMode as T, type RunModelStepOptions as U, type RunToolBatchOptions as V, type RunToolBatchResult as W, type StepInfo as X, type StreamChunk as Y, type StreamProvider as Z, type StreamProviderConfig as _, type ProcessorOutput as a, type StreamProviderInput as a0, type StreamProviderResult as a1, advanceAgentTurnState as a2, calculateDelay as a3, createAgentTurnEngine as a4, createAgentTurnState as a5, createRetryHandler as a6, createRetryState as a7, failAgentTurnState as a8, shouldRetry as a9, sleep as aa, withRetry as ab, type AgentTurnActiveToolCall as b, type AgentTurnBoundaryMetadata as c, type AgentTurnBoundarySnapshot as d, type AgentTurnCommitApplier as e, type AgentTurnCommitBatch as f, type AgentTurnCommitOptions as g, AgentTurnEngine as h, type AgentTurnEngineOptions as i, type AgentTurnPhase as j, type AgentTurnResolvedToolCall as k, type AgentTurnState as l, type AgentTurnStateAdvanceOptions as m, type AgentTurnStepCommitSnapshot as n, type AgentTurnStepCommitToolCall as o, type AgentTurnStepCommitToolResult as p, type AgentTurnStepRuntimeConfig as q, type CommitStepOptions as r, type CreateAgentTurnStateOptions as s, type CreateAgentTurnStepCommitBatchOptions as t, type CustomStreamProvider as u, type CustomStreamResult as v, type DoomLoopAction as w, type DoomLoopHandler as x, type DoomLoopRequest as y, type EnhancedTools as z };
648
+ export { createRetryHandler as $, type AnyStreamResult as A, type LLMErrorOptions as B, type CommitOutputOptions as C, DEFAULT_RETRY_CONFIG as D, type ErrorCategory as E, type LLMStreamResult as F, type OnInterventionApplied as G, type PendingIntervention as H, InterventionController as I, type PrepareModelStepOptions as J, type PreparedAgentModelStep as K, type LLMStreamInput as L, type RetryConfig as M, type RetryHandlerOptions as N, OUTPUT_TOKEN_MAX as O, type ProcessorOptions as P, type RetryState as Q, type ResponseHeaders as R, type RunModelStepOptions as S, type ToolExecutionMode as T, type RunToolBatchOptions as U, type RunToolBatchResult as V, type StepInfo as W, advanceAgentTurnState as X, calculateDelay as Y, createAgentTurnEngine as Z, createAgentTurnState as _, type ProcessorOutput as a, createRetryState as a0, failAgentTurnState as a1, shouldRetry as a2, sleep as a3, withRetry as a4, type AgentTurnActiveToolCall as b, type AgentTurnBoundaryMetadata as c, type AgentTurnBoundarySnapshot as d, type AgentTurnCommitApplier as e, type AgentTurnCommitBatch as f, type AgentTurnCommitOptions as g, AgentTurnEngine as h, type AgentTurnEngineOptions as i, type AgentTurnPhase as j, type AgentTurnResolvedToolCall as k, type AgentTurnState as l, type AgentTurnStateAdvanceOptions as m, type AgentTurnStepCommitSnapshot as n, type AgentTurnStepCommitToolCall as o, type AgentTurnStepCommitToolResult as p, type AgentTurnStepRuntimeConfig as q, type CommitStepOptions as r, type CreateAgentTurnStateOptions as s, type CreateAgentTurnStepCommitBatchOptions as t, type CustomStreamProvider as u, type CustomStreamResult as v, type DoomLoopAction as w, type DoomLoopHandler as x, type DoomLoopRequest as y, LLMError as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cuylabs/agent-core",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Embeddable AI agent infrastructure — execution, sessions, tools, skills, sub-agents, tracing",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",