@anvia/core 1.0.0-rc.1 → 1.0.0-rc.11

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 (162) hide show
  1. package/README.md +433 -85
  2. package/dist/agent/index.d.ts +57 -19
  3. package/dist/agent/index.js +32 -17
  4. package/dist/agent/interactions/index.d.ts +122 -0
  5. package/dist/agent/interactions/index.js +20 -0
  6. package/dist/agent-qRKa3ibC.d.ts +154 -0
  7. package/dist/chunk-3RM57ZT2.js +31 -0
  8. package/dist/chunk-3RM57ZT2.js.map +1 -0
  9. package/dist/chunk-3RWESPUG.js +331 -0
  10. package/dist/chunk-3RWESPUG.js.map +1 -0
  11. package/dist/{chunk-DMPUP4R3.js → chunk-3SKZ2BKP.js} +7 -5
  12. package/dist/chunk-3SKZ2BKP.js.map +1 -0
  13. package/dist/chunk-3XQGVDU5.js +69 -0
  14. package/dist/chunk-3XQGVDU5.js.map +1 -0
  15. package/dist/chunk-3ZLM6OAZ.js +4773 -0
  16. package/dist/chunk-3ZLM6OAZ.js.map +1 -0
  17. package/dist/chunk-6BBOCFHV.js +323 -0
  18. package/dist/chunk-6BBOCFHV.js.map +1 -0
  19. package/dist/chunk-7JLAIN6E.js +15 -0
  20. package/dist/chunk-7JLAIN6E.js.map +1 -0
  21. package/dist/chunk-7PHMK7W4.js +1516 -0
  22. package/dist/chunk-7PHMK7W4.js.map +1 -0
  23. package/dist/chunk-AHLKV6KP.js +86 -0
  24. package/dist/chunk-AHLKV6KP.js.map +1 -0
  25. package/dist/{chunk-FNQB2JEH.js → chunk-AZB6N7P4.js} +94 -65
  26. package/dist/chunk-AZB6N7P4.js.map +1 -0
  27. package/dist/{chunk-I6G7BC42.js → chunk-D4PACGPA.js} +2 -6
  28. package/dist/chunk-D4PACGPA.js.map +1 -0
  29. package/dist/chunk-EFLT7XZD.js +51 -0
  30. package/dist/chunk-EFLT7XZD.js.map +1 -0
  31. package/dist/{chunk-R2LJSQUW.js → chunk-EMZKPRE6.js} +267 -107
  32. package/dist/chunk-EMZKPRE6.js.map +1 -0
  33. package/dist/chunk-I3Q7XSBB.js +59 -0
  34. package/dist/chunk-I3Q7XSBB.js.map +1 -0
  35. package/dist/chunk-J6LVLV6P.js +13 -0
  36. package/dist/chunk-J6LVLV6P.js.map +1 -0
  37. package/dist/chunk-LTXABCOO.js +127 -0
  38. package/dist/chunk-LTXABCOO.js.map +1 -0
  39. package/dist/chunk-OJBFDBLG.js +164 -0
  40. package/dist/chunk-OJBFDBLG.js.map +1 -0
  41. package/dist/chunk-QGX73TSQ.js +177 -0
  42. package/dist/chunk-QGX73TSQ.js.map +1 -0
  43. package/dist/chunk-SJMSS5SI.js +171 -0
  44. package/dist/chunk-SJMSS5SI.js.map +1 -0
  45. package/dist/chunk-SPD4XVR7.js +29 -0
  46. package/dist/chunk-SPD4XVR7.js.map +1 -0
  47. package/dist/chunk-T2C3CGDQ.js +56 -0
  48. package/dist/chunk-T2C3CGDQ.js.map +1 -0
  49. package/dist/{chunk-5XKDW36Z.js → chunk-YA7BMX7D.js} +99 -57
  50. package/dist/chunk-YA7BMX7D.js.map +1 -0
  51. package/dist/chunk-ZA564323.js +331 -0
  52. package/dist/chunk-ZA564323.js.map +1 -0
  53. package/dist/completion/index.d.ts +5 -4
  54. package/dist/completion/index.js +34 -28
  55. package/dist/documents/index.d.ts +34 -0
  56. package/dist/documents/index.js +340 -0
  57. package/dist/documents/index.js.map +1 -0
  58. package/dist/{dynamic-tools-i9woysFa.d.ts → dynamic-tools-aIZlg5x1.d.ts} +21 -9
  59. package/dist/embeddings/index.d.ts +11 -9
  60. package/dist/embeddings/index.js +3 -3
  61. package/dist/evals/index.d.ts +54 -25
  62. package/dist/evals/index.js +197 -114
  63. package/dist/evals/index.js.map +1 -1
  64. package/dist/extractor/index.d.ts +23 -26
  65. package/dist/extractor/index.js +9 -8
  66. package/dist/guardrails/index.d.ts +7 -129
  67. package/dist/guardrails/index.js +1 -1
  68. package/dist/image-generation/index.d.ts +18 -16
  69. package/dist/image-generation/index.js +4 -2
  70. package/dist/index.d.ts +24 -25
  71. package/dist/index.js +80 -56
  72. package/dist/internal/agent.d.ts +33 -30
  73. package/dist/internal/agent.js +50 -15
  74. package/dist/internal/agent.js.map +1 -1
  75. package/dist/mcp/index.d.ts +7 -15
  76. package/dist/mcp/index.js +3 -348
  77. package/dist/mcp/index.js.map +1 -1
  78. package/dist/memory/index.d.ts +23 -6
  79. package/dist/memory/index.js +14 -10
  80. package/dist/{middleware-KynLg_RW.d.ts → middleware-kcF8AusP.d.ts} +10 -7
  81. package/dist/model-call-options-CZkSw_xN.d.ts +6 -0
  82. package/dist/model-listing/index.d.ts +3 -1
  83. package/dist/observability/index.d.ts +22 -6
  84. package/dist/observability/index.js +10 -5
  85. package/dist/observability/index.js.map +1 -1
  86. package/dist/pipeline/index.d.ts +103 -58
  87. package/dist/pipeline/index.js +421 -236
  88. package/dist/pipeline/index.js.map +1 -1
  89. package/dist/provider-output-error-BEwDgVv3.d.ts +99 -0
  90. package/dist/{retry-D3Ruy-ba.d.ts → retry-CjvSlKGW.d.ts} +2 -1
  91. package/dist/skills/index.d.ts +5 -4
  92. package/dist/skills/index.js +8 -7
  93. package/dist/speech-generation/index.d.ts +37 -0
  94. package/dist/speech-generation/index.js +10 -0
  95. package/dist/text-ZLECpQE7.d.ts +32 -0
  96. package/dist/{think-tool-DZqZj2LV.d.ts → think-tool-BwCsJ365.d.ts} +16 -2
  97. package/dist/tool/index.d.ts +10 -7
  98. package/dist/tool/index.js +13 -10
  99. package/dist/{tool-C_8GudXn.d.ts → tool-BpqpoRSE.d.ts} +17 -8
  100. package/dist/transcription/index.d.ts +23 -14
  101. package/dist/transcription/index.js +4 -2
  102. package/dist/{index-DxB74ybJ.d.ts → types-CLCLFpAL.d.ts} +153 -91
  103. package/dist/types-CSYt7-It.d.ts +170 -0
  104. package/dist/types-CXNE592e.d.ts +130 -0
  105. package/dist/types-Cr4uiYo5.d.ts +99 -0
  106. package/dist/{types-DhQfwiZn.d.ts → types-DC1U1XwW.d.ts} +1 -1
  107. package/dist/types-DgvozfPc.d.ts +349 -0
  108. package/dist/types-DhkodEft.d.ts +105 -0
  109. package/dist/types-DjqRHeAi.d.ts +31 -0
  110. package/dist/vector-store/index.d.ts +34 -34
  111. package/dist/vector-store/index.js +10 -6
  112. package/package.json +22 -16
  113. package/dist/agent-DGYY_onS.d.ts +0 -145
  114. package/dist/audio-generation/index.d.ts +0 -31
  115. package/dist/audio-generation/index.js +0 -8
  116. package/dist/chunk-5XKDW36Z.js.map +0 -1
  117. package/dist/chunk-6WGGTJE6.js +0 -139
  118. package/dist/chunk-6WGGTJE6.js.map +0 -1
  119. package/dist/chunk-A3UBYTJT.js +0 -157
  120. package/dist/chunk-A3UBYTJT.js.map +0 -1
  121. package/dist/chunk-ADH7NNCS.js +0 -512
  122. package/dist/chunk-ADH7NNCS.js.map +0 -1
  123. package/dist/chunk-CQNNSZPG.js +0 -9
  124. package/dist/chunk-CQNNSZPG.js.map +0 -1
  125. package/dist/chunk-DMPUP4R3.js.map +0 -1
  126. package/dist/chunk-DZ3CKYTH.js +0 -267
  127. package/dist/chunk-DZ3CKYTH.js.map +0 -1
  128. package/dist/chunk-FNQB2JEH.js.map +0 -1
  129. package/dist/chunk-I6G7BC42.js.map +0 -1
  130. package/dist/chunk-IL3ZSNJI.js +0 -3748
  131. package/dist/chunk-IL3ZSNJI.js.map +0 -1
  132. package/dist/chunk-J6GNQART.js +0 -122
  133. package/dist/chunk-J6GNQART.js.map +0 -1
  134. package/dist/chunk-M3IOWB4Y.js +0 -280
  135. package/dist/chunk-M3IOWB4Y.js.map +0 -1
  136. package/dist/chunk-QY5GZ7HR.js +0 -39
  137. package/dist/chunk-QY5GZ7HR.js.map +0 -1
  138. package/dist/chunk-R2LJSQUW.js.map +0 -1
  139. package/dist/chunk-RFDVKCIE.js +0 -12
  140. package/dist/chunk-RFDVKCIE.js.map +0 -1
  141. package/dist/chunk-RMUBRRSK.js +0 -34
  142. package/dist/chunk-RMUBRRSK.js.map +0 -1
  143. package/dist/chunk-RXKHOYEH.js +0 -466
  144. package/dist/chunk-RXKHOYEH.js.map +0 -1
  145. package/dist/chunk-XDRSPSR7.js +0 -38
  146. package/dist/chunk-XDRSPSR7.js.map +0 -1
  147. package/dist/chunk-XWUC7CIT.js +0 -1
  148. package/dist/chunk-XWUC7CIT.js.map +0 -1
  149. package/dist/errors-CYKUcU89.d.ts +0 -17
  150. package/dist/json-Zo7K3xmt.d.ts +0 -40
  151. package/dist/loaders/index.d.ts +0 -86
  152. package/dist/loaders/index.js +0 -299
  153. package/dist/loaders/index.js.map +0 -1
  154. package/dist/types-B3A4YxaA.d.ts +0 -354
  155. package/dist/types-BBEGKB9m.d.ts +0 -119
  156. package/dist/types-DT3nEemY.d.ts +0 -79
  157. package/dist/types-DulRCYdB.d.ts +0 -70
  158. package/dist/types-p55Jc-sr.d.ts +0 -47
  159. package/dist/ui/index.d.ts +0 -107
  160. package/dist/ui/index.js +0 -10
  161. /package/dist/{audio-generation → agent/interactions}/index.js.map +0 -0
  162. /package/dist/{ui → speech-generation}/index.js.map +0 -0
@@ -1,9 +1,11 @@
1
- import { a as RetryOptions } from './retry-D3Ruy-ba.js';
2
- import { M as Message, g as CompletionResponse, U as Usage, V as ReasoningContentType, p as ToolCall, h as CompletionSource, o as ProviderToolCall, j as ContextUsage, f as CompletionRequest, u as ToolResultContent, X as ToolCallArgumentsMode, J as JsonObject, K as CompletionModelCapabilities, r as ToolDefinition, l as JsonValue } from './types-B3A4YxaA.js';
3
- import { GuardrailPolicyInput, GuardrailDecisionRecord } from './guardrails/index.js';
4
- import { A as AgentMiddleware } from './middleware-KynLg_RW.js';
1
+ import { AgentInteractionRequest, AgentContinuation, AgentInteractionResponse } from './agent/interactions/index.js';
2
+ import { b as RetrySetting } from './retry-CjvSlKGW.js';
3
+ import { M as Message, g as CompletionResponse, U as Usage, R as ReasoningContentType, u as ToolCallPart, i as CompletionSource, r as ProviderToolCall, G as UserMessage, C as CompletionFinishReason, l as ContextUsage, f as CompletionRequest, z as ToolResultOutput, y as ToolResultContentPart, _ as ToolInteractionResponsePart, Z as ToolCallArgumentsMode, J as JsonObject, V as CompletionModelCapabilities, w as ToolDefinition } from './types-DgvozfPc.js';
4
+ import { d as GuardrailPolicyInput, a as GuardrailDecisionRecord } from './types-DhkodEft.js';
5
+ import { e as MemoryCompactionInfo, A as MemoryScope } from './types-CSYt7-It.js';
5
6
  import { D as DeepReadonly, M as MaybePromise } from './type-utils-CtHVDRn_.js';
6
- import { d as ToolCallStreamEvent } from './tool-C_8GudXn.js';
7
+ import { d as ToolCallStreamEvent } from './tool-BpqpoRSE.js';
8
+ import { A as AgentMiddleware } from './middleware-kcF8AusP.js';
7
9
 
8
10
  type AgentLifecycleRunEvent = {
9
11
  runId: string;
@@ -34,72 +36,113 @@ type AgentToolFinishEvent = (AgentToolFinishEventBase & {
34
36
  success: false;
35
37
  error: unknown;
36
38
  });
37
- type AgentFinishEvent = AgentLifecycleRunEvent & {
38
- output: string;
39
+ type AgentFinishEventBase = AgentLifecycleRunEvent & {
40
+ text: string;
39
41
  usage: DeepReadonly<Usage>;
40
42
  messages: DeepReadonly<Message[]>;
43
+ memoryCompaction?: DeepReadonly<MemoryCompactionInfo> | undefined;
41
44
  };
45
+ type AgentFinishEvent<Output = string> = (AgentFinishEventBase & {
46
+ status: "completed";
47
+ output: DeepReadonly<Output>;
48
+ }) | (AgentFinishEventBase & {
49
+ status: "blocked";
50
+ stage: "input" | "output";
51
+ }) | (AgentFinishEventBase & {
52
+ status: "suspended";
53
+ interaction: DeepReadonly<AgentInteractionRequest>;
54
+ });
42
55
  type AgentErrorEvent = AgentLifecycleRunEvent & {
43
56
  error: unknown;
44
57
  usage: DeepReadonly<Usage>;
45
58
  messages: DeepReadonly<Message[]>;
46
59
  };
47
- type AgentLifecycle<RawResponse = unknown> = {
60
+ type AgentLifecycle<Output = string, RawResponse = unknown> = {
48
61
  onStart?(event: AgentStartEvent): MaybePromise<void>;
49
62
  onStepFinish?(event: AgentStepFinishEvent<RawResponse>): MaybePromise<void>;
50
63
  onToolStart?(event: AgentToolStartEvent): MaybePromise<void>;
51
64
  onToolFinish?(event: AgentToolFinishEvent): MaybePromise<void>;
52
- onFinish?(event: AgentFinishEvent): MaybePromise<void>;
65
+ onFinish?(event: AgentFinishEvent<Output>): MaybePromise<void>;
53
66
  onError?(event: AgentErrorEvent): MaybePromise<void>;
54
67
  };
55
68
 
56
- type AgentInput = string | Message | Message[];
57
- type AgentRunOptions = {
69
+ type AgentPrompt = string | UserMessage;
70
+ type AgentInput = {
71
+ prompt: AgentPrompt;
72
+ messages?: never;
73
+ session?: MemoryScope | undefined;
74
+ continuation?: never;
75
+ response?: never;
76
+ } | {
77
+ messages: readonly Message[];
78
+ prompt?: never;
79
+ session?: never;
80
+ continuation?: never;
81
+ response?: never;
82
+ } | {
83
+ continuation: AgentContinuation;
84
+ response: AgentInteractionResponse;
85
+ prompt?: never;
86
+ messages?: never;
87
+ session?: never;
88
+ };
89
+ type AgentSteerInput = {
90
+ prompt: AgentPrompt;
91
+ messages?: never;
92
+ } | {
93
+ messages: readonly UserMessage[];
94
+ prompt?: never;
95
+ };
96
+ type AgentRunSettings<Output = string, RawResponse = unknown> = {
58
97
  maxTurns?: number | undefined;
59
- retries?: RetryOptions | undefined;
60
- lifecycle?: AgentLifecycle | undefined;
98
+ retries?: RetrySetting | undefined;
99
+ abortSignal?: AbortSignal | undefined;
100
+ lifecycle?: AgentLifecycle<Output, RawResponse> | undefined;
61
101
  guardrails?: GuardrailPolicyInput | undefined;
62
102
  toolConcurrency?: number | undefined;
63
103
  middlewares?: readonly AgentMiddleware[] | undefined;
64
104
  trace?: AgentTraceOptions | undefined;
65
105
  };
66
- type AgentResponse = {
67
- status: "completed";
106
+ type AgentRunOptions<Output = string, RawResponse = unknown> = AgentInput & AgentRunSettings<Output, RawResponse>;
107
+ type AgentMemoryCompactionOptions = {
108
+ session: MemoryScope;
109
+ abortSignal?: AbortSignal | undefined;
110
+ };
111
+ type AgentRunLink = Readonly<{
112
+ runId: string;
113
+ interactionId: string;
114
+ }>;
115
+ type AgentOutcomeBase = {
68
116
  runId: string;
69
- output: string;
117
+ text: string;
70
118
  usage: Usage;
119
+ finishReason?: CompletionFinishReason | undefined;
120
+ providerFinishReason?: string | undefined;
71
121
  contextUsage?: ContextUsage | undefined;
72
122
  messages: Message[];
73
123
  trace?: AgentTraceInfo | undefined;
74
124
  guardrails?: GuardrailDecisionRecord[] | undefined;
75
125
  sources?: CompletionSource[] | undefined;
76
126
  providerToolCalls?: ProviderToolCall[] | undefined;
127
+ memoryCompaction?: MemoryCompactionInfo | undefined;
128
+ resumedFrom?: AgentRunLink | undefined;
77
129
  };
78
- type AgentApprovalRequiredResult = {
79
- status: "approval_required";
80
- runId: string;
81
- approval: AgentToolApprovalRequest;
82
- usage: Usage;
83
- messages: Message[];
84
- };
85
- type AgentResult = AgentResponse | AgentApprovalRequiredResult;
86
- type AgentToolApprovalRequest = {
87
- id: string;
88
- toolName: string;
89
- toolCallId?: string | undefined;
90
- reason?: string | undefined;
91
- input: unknown;
130
+ type AgentResponse<Output = string> = AgentOutcomeBase & {
131
+ type: "response";
132
+ output: Output;
92
133
  };
93
- type AgentApprovalRequiredEvent = Omit<AgentApprovalRequiredResult, "status"> & {
94
- type: "approval_required";
134
+ type AgentBlockedOutcome = AgentOutcomeBase & {
135
+ type: "blocked";
136
+ stage: "input" | "output";
137
+ reason: string;
138
+ message?: string | undefined;
95
139
  };
96
- type AgentApprovalDecision = {
97
- approved: true;
98
- reason?: string;
99
- } | {
100
- approved: false;
101
- reason?: string;
140
+ type AgentInteractionOutcome = AgentOutcomeBase & {
141
+ type: "interaction";
142
+ interaction: AgentInteractionRequest;
143
+ continuation: AgentContinuation;
102
144
  };
145
+ type AgentOutcome<Output = string> = AgentResponse<Output> | AgentBlockedOutcome | AgentInteractionOutcome;
103
146
  type AgentDeltaEvent = {
104
147
  type: "text_delta";
105
148
  delta: string;
@@ -111,7 +154,7 @@ type AgentDeltaEvent = {
111
154
  signature?: string;
112
155
  } | {
113
156
  type: "tool_call";
114
- toolCall: ToolCall;
157
+ toolCall: ToolCallPart;
115
158
  } | {
116
159
  type: "source";
117
160
  source: CompletionSource;
@@ -124,10 +167,6 @@ type AgentErrorStreamEvent = {
124
167
  error: unknown;
125
168
  usage: Usage;
126
169
  };
127
- type AgentStreamOptions = AgentRunOptions & {
128
- /** @default true */
129
- includeToolCallDeltas?: boolean;
130
- };
131
170
  type AgentToolCallDeltaEvent = {
132
171
  type: "tool_call_delta";
133
172
  turn: number;
@@ -138,7 +177,24 @@ type AgentToolCallDeltaEvent = {
138
177
  argumentsMode?: ToolCallArgumentsMode;
139
178
  signature?: string;
140
179
  };
141
- type AgentChildStreamEventBase<RawResponse = unknown> = {
180
+ type AgentMemoryCompactionEvent = MemoryCompactionInfo & {
181
+ type: "memory_compaction";
182
+ };
183
+ type AgentInteractionResponseEvent = {
184
+ type: "interaction_response";
185
+ response: ToolInteractionResponsePart;
186
+ sourceRunId: string;
187
+ };
188
+ type AgentSteerReceipt = Readonly<{
189
+ id: string;
190
+ status: "queued";
191
+ }>;
192
+ type AgentSteeringAppliedEvent = {
193
+ type: "steering_applied";
194
+ id: string;
195
+ turn: number;
196
+ };
197
+ type AgentChildStreamEventBase<Output = string, RawResponse = unknown> = {
142
198
  type: "turn_start";
143
199
  turn: number;
144
200
  prompt: Message;
@@ -162,7 +218,7 @@ type AgentChildStreamEventBase<RawResponse = unknown> = {
162
218
  } | {
163
219
  type: "tool_call";
164
220
  turn: number;
165
- toolCall: ToolCall;
221
+ toolCall: ToolCallPart;
166
222
  } | {
167
223
  type: "source";
168
224
  turn: number;
@@ -175,11 +231,13 @@ type AgentChildStreamEventBase<RawResponse = unknown> = {
175
231
  type: "tool_result";
176
232
  turn: number;
177
233
  toolName: string;
178
- toolCallId?: string;
234
+ toolCallId: string;
235
+ callId?: string;
179
236
  internalCallId: string;
180
237
  args: string;
238
+ output: ToolResultOutput;
181
239
  result: string;
182
- structuredResult?: ToolResultContent[] | undefined;
240
+ structuredResult?: readonly ToolResultContentPart[] | undefined;
183
241
  } | {
184
242
  type: "turn_end";
185
243
  turn: number;
@@ -189,22 +247,9 @@ type AgentChildStreamEventBase<RawResponse = unknown> = {
189
247
  type: "guardrail_decision";
190
248
  turn?: number | undefined;
191
249
  decision: GuardrailDecisionRecord;
192
- } | {
193
- type: "final";
194
- runId: string;
195
- output: string;
196
- usage: Usage;
197
- contextUsage?: ContextUsage | undefined;
198
- messages: Message[];
199
- trace?: AgentTraceInfo | undefined;
200
- guardrails?: GuardrailDecisionRecord[] | undefined;
201
- sources?: CompletionSource[] | undefined;
202
- providerToolCalls?: ProviderToolCall[] | undefined;
203
- } | AgentApprovalRequiredEvent | AgentErrorStreamEvent;
204
- type AgentChildStreamEventWithoutToolCallDeltas<RawResponse = unknown> = AgentChildStreamEventBase<RawResponse>;
205
- type AgentChildStreamEvent<RawResponse = unknown> = AgentChildStreamEventBase<RawResponse> | AgentToolCallDeltaEvent;
206
- type AgentChildStreamEventWithToolCallDeltas<RawResponse = unknown> = AgentChildStreamEvent<RawResponse>;
207
- type AgentToolStreamEvent<ChildEvent> = {
250
+ } | AgentMemoryCompactionEvent | AgentInteractionResponseEvent | AgentSteeringAppliedEvent | AgentOutcome<Output> | AgentErrorStreamEvent;
251
+ type AgentChildStreamEvent<Output = string, RawResponse = unknown> = AgentChildStreamEventBase<Output, RawResponse> | AgentToolCallDeltaEvent;
252
+ type AgentToolStreamEvent = {
208
253
  type: "agent_tool_event";
209
254
  turn: number;
210
255
  toolName: string;
@@ -212,28 +257,32 @@ type AgentToolStreamEvent<ChildEvent> = {
212
257
  internalCallId: string;
213
258
  agentId: string;
214
259
  agentName?: string;
215
- event: ChildEvent;
216
- };
217
- type AgentStreamEventWithoutToolCallDeltas<RawResponse = unknown> = AgentChildStreamEventWithoutToolCallDeltas<RawResponse> | AgentToolStreamEvent<AgentChildStreamEventWithoutToolCallDeltas<RawResponse>>;
218
- type AgentStreamEvent<RawResponse = unknown> = AgentChildStreamEvent<RawResponse> | AgentToolStreamEvent<AgentChildStreamEvent<RawResponse>>;
219
- type AgentStreamEventWithToolCallDeltas<RawResponse = unknown> = AgentStreamEvent<RawResponse>;
220
- interface AgentStream<Event = AgentStreamEvent> extends AsyncIterable<Event> {
221
- steer(input: AgentInput): boolean;
260
+ event: AgentChildStreamEvent<unknown, unknown>;
261
+ };
262
+ type AgentStreamEvent<Output = string, RawResponse = unknown> = AgentChildStreamEvent<Output, RawResponse> | AgentToolStreamEvent;
263
+ interface AgentStream<Output = string, RawResponse = unknown> extends AsyncIterable<AgentStreamEvent<Output, RawResponse>> {
264
+ readonly events: AsyncIterable<AgentStreamEvent<Output, RawResponse>>;
265
+ readonly textStream: AsyncIterable<string>;
266
+ readonly text: Promise<string>;
267
+ readonly result: Promise<AgentOutcome<Output>>;
268
+ steer(input: AgentSteerInput): AgentSteerReceipt;
269
+ cancel(reason?: string): void;
222
270
  }
223
271
 
224
272
  type AgentTraceInfo = {
273
+ readonly observer: string;
225
274
  readonly traceId?: string | undefined;
226
275
  readonly observationId?: string | undefined;
227
276
  };
277
+ type AgentObserverTraceInfo = Omit<AgentTraceInfo, "observer">;
228
278
  type AgentTraceOptions = {
229
279
  readonly name?: string | undefined;
230
280
  readonly userId?: string | undefined;
231
281
  readonly sessionId?: string | undefined;
232
- readonly metadata?: Readonly<Record<string, unknown>> | undefined;
282
+ readonly metadata?: DeepReadonly<JsonObject> | undefined;
233
283
  readonly tags?: readonly string[] | undefined;
234
284
  readonly version?: string | undefined;
235
285
  readonly traceId?: string | undefined;
236
- readonly failOnObserverError?: boolean | undefined;
237
286
  readonly promptRef?: AgentRunPromptRef | undefined;
238
287
  };
239
288
  type AgentRunPromptRef = {
@@ -251,13 +300,25 @@ type AgentRunStartArgs = {
251
300
  readonly history: readonly DeepReadonly<Message>[];
252
301
  readonly maxTurns: number;
253
302
  };
254
- type AgentRunEndArgs = {
255
- readonly output: string;
303
+ type AgentRunEndArgsBase = {
304
+ readonly runId: string;
305
+ readonly text: string;
256
306
  readonly usage: DeepReadonly<Usage>;
257
307
  readonly messages: readonly DeepReadonly<Message>[];
258
308
  readonly sources?: readonly DeepReadonly<CompletionSource>[] | undefined;
259
309
  readonly providerToolCalls?: readonly DeepReadonly<ProviderToolCall>[] | undefined;
260
- };
310
+ readonly resumedFrom?: DeepReadonly<AgentRunLink> | undefined;
311
+ };
312
+ type AgentRunEndArgs = (AgentRunEndArgsBase & {
313
+ readonly status: "completed";
314
+ readonly output: unknown;
315
+ }) | (AgentRunEndArgsBase & {
316
+ readonly status: "blocked";
317
+ readonly stage: "input" | "output";
318
+ }) | (AgentRunEndArgsBase & {
319
+ readonly status: "suspended";
320
+ readonly interaction: DeepReadonly<AgentInteractionRequest>;
321
+ });
261
322
  type AgentRunErrorArgs = {
262
323
  readonly error: unknown;
263
324
  readonly usage: DeepReadonly<Usage>;
@@ -265,7 +326,7 @@ type AgentRunErrorArgs = {
265
326
  };
266
327
  type AgentGenerationModelInfo = {
267
328
  readonly provider: string;
268
- readonly defaultModel: string;
329
+ readonly modelId: string;
269
330
  readonly capabilities?: DeepReadonly<CompletionModelCapabilities> | undefined;
270
331
  };
271
332
  type AgentGenerationStartArgs = {
@@ -289,13 +350,13 @@ type AgentGenerationUpdateArgs = {
289
350
  };
290
351
  type AgentRunEventArgs = {
291
352
  readonly name: string;
292
- readonly attributes?: Readonly<Record<string, DeepReadonly<JsonValue> | undefined>> | undefined;
353
+ readonly attributes?: DeepReadonly<JsonObject> | undefined;
293
354
  readonly level?: "DEFAULT" | "WARNING" | "ERROR" | undefined;
294
- readonly timestamp?: Date | string | undefined;
355
+ readonly timestamp?: string | undefined;
295
356
  };
296
357
  type AgentToolStartArgs = {
297
358
  readonly turn: number;
298
- readonly toolCall: DeepReadonly<ToolCall>;
359
+ readonly toolCall: DeepReadonly<ToolCallPart>;
299
360
  readonly toolName: string;
300
361
  readonly args: string;
301
362
  readonly internalCallId: string;
@@ -305,12 +366,15 @@ type AgentToolStartArgs = {
305
366
  };
306
367
  type AgentToolEndArgs = AgentToolStartArgs & {
307
368
  readonly result: string;
308
- readonly structuredResult?: readonly DeepReadonly<ToolResultContent>[] | undefined;
369
+ readonly structuredResult?: readonly DeepReadonly<ToolResultContentPart>[] | undefined;
309
370
  readonly skipped: boolean;
310
371
  };
311
372
  type AgentToolErrorArgs = AgentToolStartArgs & {
312
373
  readonly error: unknown;
313
374
  };
375
+ type AgentToolSuspendedArgs = AgentToolStartArgs & {
376
+ readonly interaction: DeepReadonly<AgentInteractionRequest>;
377
+ };
314
378
  type AgentToolStreamEventArgs = AgentToolStartArgs & {
315
379
  readonly event: DeepReadonly<ToolCallStreamEvent>;
316
380
  };
@@ -322,10 +386,11 @@ interface AgentGenerationObserver {
322
386
  interface AgentToolObserver {
323
387
  streamEvent?(args: AgentToolStreamEventArgs): void | Promise<void>;
324
388
  end(args: AgentToolEndArgs): void | Promise<void>;
389
+ suspend?(args: AgentToolSuspendedArgs): void | Promise<void>;
325
390
  error?(args: AgentToolErrorArgs): void | Promise<void>;
326
391
  }
327
392
  interface AgentRunObserver {
328
- readonly trace?: AgentTraceInfo | undefined;
393
+ readonly trace?: AgentObserverTraceInfo | undefined;
329
394
  startGeneration?(args: AgentGenerationStartArgs): AgentGenerationObserver | undefined | Promise<AgentGenerationObserver | undefined>;
330
395
  startTool?(args: AgentToolStartArgs): AgentToolObserver | undefined | Promise<AgentToolObserver | undefined>;
331
396
  end(args: AgentRunEndArgs): void | Promise<void>;
@@ -334,16 +399,13 @@ interface AgentRunObserver {
334
399
  }
335
400
  interface AgentObserver {
336
401
  startRun(args: AgentRunStartArgs): AgentRunObserver | undefined | Promise<AgentRunObserver | undefined>;
337
- flush?(): void | Promise<void>;
338
- shutdown?(): void | Promise<void>;
339
402
  }
340
- type AgentObserverRegistration = {
341
- readonly observer: AgentObserver;
342
- readonly failOnObserverError?: boolean | undefined;
343
- };
344
- type ObserveOptions = {
345
- readonly failOnObserverError?: boolean | undefined;
403
+ type AgentObserverMap = Readonly<Record<string, AgentObserver>>;
404
+ type AgentObserverErrorPolicy = "ignore" | "throw";
405
+ type AgentObservabilityOptions<Observers extends AgentObserverMap = AgentObserverMap> = {
406
+ readonly observers: Observers;
407
+ readonly primaryTrace?: Extract<keyof Observers, string> | undefined;
408
+ readonly errorPolicy?: AgentObserverErrorPolicy | undefined;
346
409
  };
347
- declare function createObserver(observer: AgentObserver): AgentObserver;
348
410
 
349
- export { type AgentApprovalDecision as A, type AgentObserverRegistration as B, type AgentGenerationEndArgs as C, type AgentGenerationErrorArgs as D, type AgentGenerationModelInfo as E, type AgentGenerationObserver as F, type AgentGenerationStartArgs as G, type AgentGenerationUpdateArgs as H, type AgentRunEndArgs as I, type AgentRunErrorArgs as J, type AgentRunEventArgs as K, type AgentRunObserver as L, type AgentRunPromptRef as M, type AgentRunStartArgs as N, type ObserveOptions as O, type AgentToolEndArgs as P, type AgentToolErrorArgs as Q, type AgentToolObserver as R, type AgentToolStartArgs as S, type AgentToolStreamEventArgs as T, type AgentTraceInfo as U, type AgentTraceOptions as V, createObserver as W, type AgentApprovalRequiredEvent as a, type AgentApprovalRequiredResult as b, type AgentChildStreamEvent as c, type AgentChildStreamEventWithToolCallDeltas as d, type AgentChildStreamEventWithoutToolCallDeltas as e, type AgentDeltaEvent as f, type AgentErrorEvent as g, type AgentErrorStreamEvent as h, type AgentFinishEvent as i, type AgentInput as j, type AgentLifecycle as k, type AgentResponse as l, type AgentResult as m, type AgentRunOptions as n, type AgentStartEvent as o, type AgentStepFinishEvent as p, type AgentStream as q, type AgentStreamEvent as r, type AgentStreamEventWithToolCallDeltas as s, type AgentStreamEventWithoutToolCallDeltas as t, type AgentStreamOptions as u, type AgentToolApprovalRequest as v, type AgentToolCallDeltaEvent as w, type AgentToolFinishEvent as x, type AgentToolStartEvent as y, type AgentObserver as z };
411
+ export type { AgentBlockedOutcome as A, AgentGenerationModelInfo as B, AgentGenerationObserver as C, AgentGenerationStartArgs as D, AgentGenerationUpdateArgs as E, AgentObservabilityOptions as F, AgentObserver as G, AgentObserverErrorPolicy as H, AgentObserverMap as I, AgentObserverTraceInfo as J, AgentRunEndArgs as K, AgentRunErrorArgs as L, AgentRunEventArgs as M, AgentRunObserver as N, AgentRunPromptRef as O, AgentRunStartArgs as P, AgentToolEndArgs as Q, AgentToolErrorArgs as R, AgentToolObserver as S, AgentToolStartArgs as T, AgentToolStreamEventArgs as U, AgentToolSuspendedArgs as V, AgentTraceInfo as W, AgentTraceOptions as X, AgentChildStreamEvent as a, AgentDeltaEvent as b, AgentErrorEvent as c, AgentErrorStreamEvent as d, AgentFinishEvent as e, AgentInput as f, AgentInteractionOutcome as g, AgentLifecycle as h, AgentMemoryCompactionEvent as i, AgentMemoryCompactionOptions as j, AgentOutcome as k, AgentPrompt as l, AgentResponse as m, AgentRunOptions as n, AgentRunSettings as o, AgentStartEvent as p, AgentSteerInput as q, AgentSteerReceipt as r, AgentStepFinishEvent as s, AgentStream as t, AgentStreamEvent as u, AgentToolCallDeltaEvent as v, AgentToolFinishEvent as w, AgentToolStartEvent as x, AgentGenerationEndArgs as y, AgentGenerationErrorArgs as z };
@@ -0,0 +1,170 @@
1
+ import { U as Usage, J as JsonObject, M as Message, S as SystemMessage, c as CompletionModel } from './types-DgvozfPc.js';
2
+ import { b as RetrySetting } from './retry-CjvSlKGW.js';
3
+
4
+ type MemorySavePolicy = "message" | "turn" | "run";
5
+ type MemoryScope = {
6
+ sessionId: string;
7
+ userId?: string | undefined;
8
+ metadata?: JsonObject | undefined;
9
+ };
10
+ type MemoryScopeKeyOptions = {
11
+ includeUserId?: boolean | undefined;
12
+ metadataKeys?: readonly string[] | undefined;
13
+ };
14
+ type CreateMemoryScopeKeyOptions = MemoryScopeKeyOptions & {
15
+ scope: MemoryScope;
16
+ };
17
+ type MemoryScopeKeyResolver = MemoryScopeKeyOptions | ((options: {
18
+ scope: MemoryScope;
19
+ }) => string);
20
+ type MemoryLoadOptions = {
21
+ scope: MemoryScope;
22
+ };
23
+ type MemoryAppendOptions = {
24
+ scope: MemoryScope;
25
+ runId: string;
26
+ turn: number;
27
+ messages: Message[];
28
+ };
29
+ type MemoryClearOptions = {
30
+ scope: MemoryScope;
31
+ };
32
+ type MemoryErrorOptions = {
33
+ scope: MemoryScope;
34
+ runId: string;
35
+ error: unknown;
36
+ messages: Message[];
37
+ };
38
+ type MemoryConversationListOptions = {
39
+ limit: number;
40
+ userId?: string | undefined;
41
+ };
42
+ type MemoryConversationGetOptions = {
43
+ ref: string;
44
+ };
45
+ type MemoryConversationSummary = {
46
+ /** Opaque, store-specific reference used to retrieve this exact conversation. */
47
+ ref: string;
48
+ sessionId: string;
49
+ userId?: string | undefined;
50
+ metadata?: JsonObject | undefined;
51
+ createdAt: string;
52
+ updatedAt: string;
53
+ messageCount: number;
54
+ };
55
+ type MemoryConversationMessage = {
56
+ position: number;
57
+ runId: string;
58
+ turn: number;
59
+ createdAt: string;
60
+ message: Message;
61
+ };
62
+ type MemoryConversation = MemoryConversationSummary & {
63
+ messages: MemoryConversationMessage[];
64
+ };
65
+ /** Optional, read-only discovery surface for developer tooling such as Studio. */
66
+ interface MemoryInspector {
67
+ listConversations(options: MemoryConversationListOptions): Promise<MemoryConversationSummary[]>;
68
+ getConversation(options: MemoryConversationGetOptions): Promise<MemoryConversation | undefined>;
69
+ }
70
+ interface MemoryStore {
71
+ readonly inspector?: MemoryInspector | undefined;
72
+ readonly compaction?: MemoryCompactionCapability | undefined;
73
+ load(options: MemoryLoadOptions): Promise<Message[]>;
74
+ append(options: MemoryAppendOptions): Promise<void>;
75
+ clear(options: MemoryClearOptions): Promise<void>;
76
+ recordError?(options: MemoryErrorOptions): Promise<void>;
77
+ }
78
+ type MemoryCompactionMetadata = {
79
+ version: 1;
80
+ compactedMessageCount: number;
81
+ };
82
+ type MemoryCompactionMessage = Omit<SystemMessage, "metadata"> & {
83
+ metadata: {
84
+ anvia: {
85
+ memoryCompaction: MemoryCompactionMetadata;
86
+ };
87
+ };
88
+ };
89
+ type MemoryCompactionSnapshot = {
90
+ /** Opaque store revision used to reject stale compaction replacements. */
91
+ revision: string;
92
+ messages: Message[];
93
+ };
94
+ type MemoryCompactionSnapshotOptions = {
95
+ scope: MemoryScope;
96
+ };
97
+ type MemoryCompactionReplacePrefixOptions = {
98
+ scope: MemoryScope;
99
+ revision: string;
100
+ messageCount: number;
101
+ replacement: MemoryCompactionMessage;
102
+ runId: string;
103
+ };
104
+ type MemoryCompactionReplacePrefixResult = {
105
+ status: "committed" | "conflict";
106
+ };
107
+ /** Optional atomic prefix-replacement capability used by automatic memory compaction. */
108
+ interface MemoryCompactionCapability {
109
+ snapshot(options: MemoryCompactionSnapshotOptions): Promise<MemoryCompactionSnapshot>;
110
+ replacePrefix(options: MemoryCompactionReplacePrefixOptions): Promise<MemoryCompactionReplacePrefixResult>;
111
+ }
112
+ type MemoryCompactorInput = {
113
+ scope: MemoryScope;
114
+ messages: Message[];
115
+ abortSignal?: AbortSignal | undefined;
116
+ };
117
+ type MemoryCompactorResult = {
118
+ summary: string;
119
+ usage?: Usage | undefined;
120
+ };
121
+ type MemoryCompactor = (input: MemoryCompactorInput) => Promise<MemoryCompactorResult>;
122
+ /** Counts the approximate or exact model tokens represented by a message list. */
123
+ type MemoryTokenCounter = (messages: readonly Message[]) => number | Promise<number>;
124
+ type CreateSummaryMemoryCompactorOptions = {
125
+ model: CompletionModel;
126
+ instructions?: string | undefined;
127
+ maxTokens?: number | undefined;
128
+ temperature?: number | undefined;
129
+ providerOptions?: JsonObject | undefined;
130
+ retries?: RetrySetting | undefined;
131
+ };
132
+ type MemoryCompactionConflictRetryOptions = {
133
+ maxAttempts: number;
134
+ };
135
+ type MemoryCompactionOptions = {
136
+ trigger: {
137
+ afterTokens: number;
138
+ };
139
+ retention?: {
140
+ recentTokens?: number | undefined;
141
+ };
142
+ tokenCounter?: MemoryTokenCounter | undefined;
143
+ compactor: MemoryCompactor;
144
+ conflictRetries?: false | MemoryCompactionConflictRetryOptions | undefined;
145
+ };
146
+ type MemoryOptions = {
147
+ savePolicy?: MemorySavePolicy | undefined;
148
+ compaction?: MemoryCompactionOptions | undefined;
149
+ };
150
+ type MemoryCompactionInfo = {
151
+ originalMessageCount: number;
152
+ compactedMessageCount: number;
153
+ retainedMessageCount: number;
154
+ originalTokenCount: number;
155
+ compactedTokenCount: number;
156
+ retainedTokenCount: number;
157
+ resultTokenCount: number;
158
+ attempts: number;
159
+ usage: Usage;
160
+ };
161
+ type MemoryCompactionResult = ({
162
+ type: "compacted";
163
+ } & MemoryCompactionInfo) | {
164
+ type: "skipped";
165
+ reason: "nothing_to_compact";
166
+ originalMessageCount: number;
167
+ originalTokenCount: number;
168
+ };
169
+
170
+ export type { MemoryScope as A, MemoryScopeKeyOptions as B, CreateMemoryScopeKeyOptions as C, MemoryScopeKeyResolver as D, MemoryStore as E, MemoryTokenCounter as F, MemoryAppendOptions as M, CreateSummaryMemoryCompactorOptions as a, MemoryClearOptions as b, MemoryCompactionCapability as c, MemoryCompactionConflictRetryOptions as d, MemoryCompactionInfo as e, MemoryCompactionMessage as f, MemoryCompactionMetadata as g, MemoryCompactionOptions as h, MemoryCompactionReplacePrefixOptions as i, MemoryCompactionReplacePrefixResult as j, MemoryCompactionResult as k, MemoryCompactionSnapshot as l, MemoryCompactionSnapshotOptions as m, MemoryCompactor as n, MemoryCompactorInput as o, MemoryCompactorResult as p, MemoryConversation as q, MemoryConversationGetOptions as r, MemoryConversationListOptions as s, MemoryConversationMessage as t, MemoryConversationSummary as u, MemoryErrorOptions as v, MemoryInspector as w, MemoryLoadOptions as x, MemoryOptions as y, MemorySavePolicy as z };