experimental-a2 0.0.0 → 0.2.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.
- package/CHANGELOG.md +43 -0
- package/dist/ai-server.browser.js +2 -2
- package/dist/ai-server.d.ts +19 -7
- package/dist/ai-server.js +730 -96
- package/dist/ai.d.ts +32 -11
- package/dist/ai.js +253 -75
- package/dist/client.d.ts +1 -1
- package/dist/client.js +4 -4
- package/dist/{contract-B0kAXoaL.js → contract-CG_adnu_.js} +2 -1
- package/dist/{contract-DL8btVd9.d.ts → contract-C_3dIIEU.d.ts} +4 -1
- package/dist/devtools-server.browser.js +2 -2
- package/dist/devtools-server.js +1 -1
- package/dist/http.d.ts +1 -1
- package/dist/http.js +4 -3
- package/dist/idempotent-replay-BMyHrP0L.js +19 -0
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/{internal-Dm8Ejnud.js → internal-D6wNxTck.js} +3 -3
- package/dist/{log-Dg1I8NRr.d.ts → log-ldf5g8Cx.d.ts} +74 -56
- package/dist/log-memory.d.ts +1 -1
- package/dist/log-memory.js +173 -96
- package/dist/{log-polling-RO7kclzR.js → log-polling-6COoN60V.js} +1 -1
- package/dist/log-postgres.d.ts +1 -1
- package/dist/log-postgres.js +235 -192
- package/dist/log-redis.d.ts +1 -1
- package/dist/log-redis.js +453 -263
- package/dist/log-sqlite.d.ts +1 -1
- package/dist/log-sqlite.js +216 -127
- package/dist/otel.d.ts +1 -1
- package/dist/otel.js +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +1 -1
- package/dist/recovery-vercel.d.ts +2 -2
- package/dist/recovery-vercel.js +9 -10
- package/dist/server-DJgD2YWP.js +877 -0
- package/dist/server.browser.js +4 -4
- package/dist/server.d.ts +46 -27
- package/dist/server.js +1 -1
- package/dist/{telemetry-C78al20p.d.ts → telemetry-Cso0qyHQ.d.ts} +1 -1
- package/dist/{wire-2QpU1EtJ.js → wire-BVsgR8o9.js} +1 -1
- package/docs/01-quickstart.mdx +7 -7
- package/docs/concepts/01-contracts.mdx +22 -22
- package/docs/concepts/02-handlers.mdx +223 -89
- package/docs/concepts/03-durability.mdx +199 -112
- package/docs/concepts/04-state.mdx +27 -1
- package/docs/guides/01-timers.mdx +4 -4
- package/docs/guides/02-cancellation.mdx +32 -4
- package/docs/guides/05-production.mdx +61 -27
- package/docs/guides/06-ai-agents.mdx +151 -70
- package/docs/guides/07-devtools.mdx +6 -3
- package/docs/guides/08-application-data.mdx +5 -6
- package/docs/index.mdx +30 -14
- package/docs/reference/01-api.mdx +305 -70
- package/package.json +31 -31
- package/dist/server-DYsnKTTy.js +0 -780
package/dist/ai.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as EventDefs, c as Reducer, n as Contract, t as AppendInput, u as StandardSchemaV1 } from "./contract-C_3dIIEU.js";
|
|
2
2
|
import { FinishReason, JSONValue, LanguageModelUsage, UIMessage, UIMessageChunk } from "ai";
|
|
3
3
|
//#region src/ai.d.ts
|
|
4
4
|
type AgentStatus = "idle" | "generating" | "waiting" | "failed" | "closed";
|
|
5
|
-
type GenerationReason = "message" | "
|
|
5
|
+
type GenerationReason = "message" | "tool" | "input" | "retry";
|
|
6
6
|
type SessionCreatedPayload = {
|
|
7
7
|
metadata?: JSONValue;
|
|
8
8
|
};
|
|
@@ -32,6 +32,7 @@ type RetryGenerationOptions = {
|
|
|
32
32
|
responseMessageId: string;
|
|
33
33
|
retryId: string;
|
|
34
34
|
};
|
|
35
|
+
type RetryRequestedPayload = RetryGenerationOptions;
|
|
35
36
|
type GenerationStartedPayload = {
|
|
36
37
|
requestId: string;
|
|
37
38
|
messageId: string;
|
|
@@ -64,6 +65,7 @@ type GenerationFailedPayload = {
|
|
|
64
65
|
error: string;
|
|
65
66
|
/** True when a later attempt replaced an incomplete attempt. */
|
|
66
67
|
superseded?: boolean;
|
|
68
|
+
stepLimit?: boolean;
|
|
67
69
|
};
|
|
68
70
|
type ToolCalledPayload = {
|
|
69
71
|
requestId: string;
|
|
@@ -74,6 +76,7 @@ type ToolCalledPayload = {
|
|
|
74
76
|
input: unknown;
|
|
75
77
|
dynamic?: boolean;
|
|
76
78
|
providerExecuted?: boolean;
|
|
79
|
+
supportsDeferredResults?: boolean;
|
|
77
80
|
providerMetadata?: unknown;
|
|
78
81
|
toolMetadata?: unknown;
|
|
79
82
|
title?: string;
|
|
@@ -106,19 +109,21 @@ type ApprovalRequestedPayload = {
|
|
|
106
109
|
};
|
|
107
110
|
type ApprovalRespondedPayload = {
|
|
108
111
|
messageId: string;
|
|
112
|
+
generationId: string;
|
|
109
113
|
approvalId: string;
|
|
110
114
|
approved: boolean;
|
|
111
115
|
reason?: string;
|
|
112
116
|
};
|
|
113
117
|
type InputRequestedPayload = {
|
|
114
118
|
messageId: string;
|
|
115
|
-
generationId
|
|
119
|
+
generationId: string;
|
|
116
120
|
inputId: string;
|
|
117
121
|
name: string;
|
|
118
122
|
question?: JSONValue;
|
|
119
123
|
};
|
|
120
124
|
type InputRespondedPayload = {
|
|
121
125
|
messageId: string;
|
|
126
|
+
generationId: string;
|
|
122
127
|
inputId: string;
|
|
123
128
|
name: string;
|
|
124
129
|
value: JSONValue;
|
|
@@ -131,6 +136,7 @@ type CompactionCompletedPayload<M extends UIMessage> = {
|
|
|
131
136
|
generationId: string;
|
|
132
137
|
throughMessageId: string;
|
|
133
138
|
messages: M[];
|
|
139
|
+
retainedMessageIds?: string[];
|
|
134
140
|
};
|
|
135
141
|
type AIEventDefs<M extends UIMessage = UIMessage> = {
|
|
136
142
|
"ai.session.created": StandardSchemaV1<SessionCreatedPayload>;
|
|
@@ -139,6 +145,7 @@ type AIEventDefs<M extends UIMessage = UIMessage> = {
|
|
|
139
145
|
"ai.message.completed": StandardSchemaV1<MessageCompletedPayload>;
|
|
140
146
|
"ai.message.interrupted": StandardSchemaV1<MessageInterruptedPayload>;
|
|
141
147
|
"ai.generation.requested": StandardSchemaV1<GenerationRequestedPayload>;
|
|
148
|
+
"ai.retry.requested": StandardSchemaV1<RetryRequestedPayload>;
|
|
142
149
|
"ai.generation.started": StandardSchemaV1<GenerationStartedPayload>;
|
|
143
150
|
"ai.generation.progress": StandardSchemaV1<GenerationProgressPayload>;
|
|
144
151
|
"ai.generation.completed": StandardSchemaV1<GenerationCompletedPayload>;
|
|
@@ -171,6 +178,15 @@ type ActiveGenerationProjection<M extends UIMessage = UIMessage> = {
|
|
|
171
178
|
type: "ai.tool.result";
|
|
172
179
|
payload: ToolResultPayload;
|
|
173
180
|
}>;
|
|
181
|
+
approvalEvents: Array<{
|
|
182
|
+
index: number;
|
|
183
|
+
type: "ai.approval.requested";
|
|
184
|
+
payload: ApprovalRequestedPayload;
|
|
185
|
+
} | {
|
|
186
|
+
index: number;
|
|
187
|
+
type: "ai.approval.responded";
|
|
188
|
+
payload: ApprovalRespondedPayload;
|
|
189
|
+
}>;
|
|
174
190
|
};
|
|
175
191
|
type PendingApproval = ApprovalRequestedPayload;
|
|
176
192
|
type PendingInput = InputRequestedPayload;
|
|
@@ -199,6 +215,7 @@ type CompactionState<M extends UIMessage> = {
|
|
|
199
215
|
generationId: string;
|
|
200
216
|
throughMessageId: string;
|
|
201
217
|
messages?: M[];
|
|
218
|
+
retainedMessageIds?: string[];
|
|
202
219
|
};
|
|
203
220
|
type GenerationUsage = {
|
|
204
221
|
generationId: string;
|
|
@@ -212,7 +229,10 @@ type AIState<M extends UIMessage = UIMessage> = {
|
|
|
212
229
|
messages: M[];
|
|
213
230
|
status: AgentStatus;
|
|
214
231
|
activeGeneration: ActiveGeneration | null;
|
|
232
|
+
activeRequestId: string | null;
|
|
233
|
+
activeResponseMessageId: string | null;
|
|
215
234
|
activeProjection: ActiveGenerationProjection<M> | null;
|
|
235
|
+
responseGenerationIds: Record<string, string>;
|
|
216
236
|
pendingApprovals: PendingApproval[];
|
|
217
237
|
pendingInputs: PendingInput[];
|
|
218
238
|
tools: ToolActivity[];
|
|
@@ -242,6 +262,7 @@ declare function reduceAIState<M extends UIMessage>(state: AIState<M>, event: {
|
|
|
242
262
|
type: string;
|
|
243
263
|
payload: unknown;
|
|
244
264
|
index: number;
|
|
265
|
+
id?: string;
|
|
245
266
|
}): AIState<M>;
|
|
246
267
|
/** Derive AI SDK UI messages directly from an A2 event history. */
|
|
247
268
|
declare function deriveUIMessages<M extends UIMessage = UIMessage>(history: readonly {
|
|
@@ -256,18 +277,18 @@ declare function createReducer<D extends EventDefs>(options: {
|
|
|
256
277
|
}): Reducer<D, AIState<AIMessageFrom<D>>>;
|
|
257
278
|
type ProtocolInput<M extends UIMessage, K extends keyof AIEventDefs<M> & string> = AppendInput<Pick<AIEventDefs<M>, K>>;
|
|
258
279
|
type AIInputs = {
|
|
259
|
-
/** Record a message
|
|
260
|
-
message<M extends UIMessage>(message: M): ProtocolInput<M, "ai.message.created"
|
|
280
|
+
/** Record a message. The server schedules user messages in arrival order. */
|
|
281
|
+
message<M extends UIMessage>(message: M): ProtocolInput<M, "ai.message.created">[];
|
|
261
282
|
/** Record a message without requesting a generation. */
|
|
262
283
|
seed<M extends UIMessage>(message: M): ProtocolInput<M, "ai.message.created">[];
|
|
263
|
-
/** Answer an AI SDK tool approval
|
|
264
|
-
approval(response: ApprovalRespondedPayload): ProtocolInput<UIMessage, "ai.approval.responded"
|
|
265
|
-
/** Answer an application-defined input request
|
|
266
|
-
input(response: InputRespondedPayload): ProtocolInput<UIMessage, "ai.input.responded"
|
|
284
|
+
/** Answer an AI SDK tool approval. The tool barrier owns continuation. */
|
|
285
|
+
approval(response: ApprovalRespondedPayload): ProtocolInput<UIMessage, "ai.approval.responded">[];
|
|
286
|
+
/** Answer an application-defined input request. */
|
|
287
|
+
input(response: InputRespondedPayload): ProtocolInput<UIMessage, "ai.input.responded">[];
|
|
267
288
|
/** Record an application-defined request for input. */
|
|
268
289
|
requestInput(request: InputRequestedPayload): ProtocolInput<UIMessage, "ai.input.requested">[];
|
|
269
290
|
/** Request a fresh attempt for a failed response. */
|
|
270
|
-
retry(options: RetryGenerationOptions): ProtocolInput<UIMessage, "ai.
|
|
291
|
+
retry(options: RetryGenerationOptions): ProtocolInput<UIMessage, "ai.retry.requested">[];
|
|
271
292
|
/** Interrupt the active response for a message. */
|
|
272
293
|
interrupt(interruption: MessageInterruptedPayload): ProtocolInput<UIMessage, "ai.message.interrupted">[];
|
|
273
294
|
};
|
|
@@ -279,4 +300,4 @@ declare const inputs: AIInputs;
|
|
|
279
300
|
*/
|
|
280
301
|
declare function agent<M extends UIMessage = UIMessage, E extends EventDefs = Record<never, never>>(options: AgentOptions<M, E>): AgentDefinition<M, AIEventDefs<M> & E>;
|
|
281
302
|
//#endregion
|
|
282
|
-
export { AIEventDefs, AIInputs, AIState, ActiveGeneration, ActiveGenerationProjection, AgentDefinition, AgentOptions, AgentStatus, ApprovalRequestedPayload, ApprovalRespondedPayload, CompactionCompletedPayload, CompactionRequestedPayload, CompactionState, type FinishReason, GenerationCompletedPayload, GenerationFailedPayload, GenerationProgressPayload, GenerationReason, GenerationRequestedPayload, GenerationStartedPayload, GenerationUsage, InputRequestedPayload, InputRespondedPayload, type JSONValue, type LanguageModelUsage, MessageCompletedPayload, MessageCreatedPayload, MessageInterruptedPayload, PendingApproval, PendingInput, RetryGenerationOptions, SessionClosedPayload, SessionCreatedPayload, ToolActivity, ToolCalledPayload, ToolResultPayload, type UIMessage, type UIMessageChunk, agent, createEvents, createReducer, deriveUIMessages, events, inputs, reduceAIState };
|
|
303
|
+
export { AIEventDefs, AIInputs, AIState, ActiveGeneration, ActiveGenerationProjection, AgentDefinition, AgentOptions, AgentStatus, ApprovalRequestedPayload, ApprovalRespondedPayload, CompactionCompletedPayload, CompactionRequestedPayload, CompactionState, type FinishReason, GenerationCompletedPayload, GenerationFailedPayload, GenerationProgressPayload, GenerationReason, GenerationRequestedPayload, GenerationStartedPayload, GenerationUsage, InputRequestedPayload, InputRespondedPayload, type JSONValue, type LanguageModelUsage, MessageCompletedPayload, MessageCreatedPayload, MessageInterruptedPayload, PendingApproval, PendingInput, RetryGenerationOptions, RetryRequestedPayload, SessionClosedPayload, SessionCreatedPayload, ToolActivity, ToolCalledPayload, ToolResultPayload, type UIMessage, type UIMessageChunk, agent, createEvents, createReducer, deriveUIMessages, events, inputs, reduceAIState };
|