experimental-a2 0.18.1 → 0.19.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 +28 -0
- package/dist/{ai-BMLlI2Ff.d.ts → ai-Cz3hqVhk.d.ts} +33 -16
- package/dist/ai-Cz3hqVhk.d.ts.map +1 -0
- package/dist/ai-client.d.ts +1 -1
- package/dist/ai-client.js +1 -1
- package/dist/ai-control-CvLbW10B.js +46 -0
- package/dist/ai-control-CvLbW10B.js.map +1 -0
- package/dist/ai-fx.d.ts +1 -1
- package/dist/ai-fx.d.ts.map +1 -1
- package/dist/ai-fx.js +30 -10
- package/dist/ai-fx.js.map +1 -1
- package/dist/{ai-harness-BuLh_EYi.js → ai-harness-BuuC-gJ3.js} +79 -15
- package/dist/ai-harness-BuuC-gJ3.js.map +1 -0
- package/dist/{ai-harness-B2suP2Qh.d.ts → ai-harness-CV6rXbB3.d.ts} +2 -2
- package/dist/ai-harness-CV6rXbB3.d.ts.map +1 -0
- package/dist/{ai-D6mGlO8j.js → ai-mMiWul1T.js} +116 -77
- package/dist/ai-mMiWul1T.js.map +1 -0
- package/dist/ai-pi.d.ts +1 -1
- package/dist/ai-pi.d.ts.map +1 -1
- package/dist/ai-pi.js +55 -10
- package/dist/ai-pi.js.map +1 -1
- package/dist/ai-react.d.ts +1 -1
- package/dist/ai-react.js +1 -1
- package/dist/ai-server.d.ts +2 -2
- package/dist/ai-server.d.ts.map +1 -1
- package/dist/ai-server.js +118 -50
- package/dist/ai-server.js.map +1 -1
- package/dist/ai.d.ts +2 -2
- package/dist/ai.js +1 -1
- package/dist/scheduler-vercel.d.ts.map +1 -1
- package/dist/scheduler-vercel.js +1 -4
- package/dist/scheduler-vercel.js.map +1 -1
- package/docs/agents/03-conversations.mdx +25 -13
- package/docs/agents/04-harnesses.mdx +51 -5
- package/docs/contract/03-sessions.mdx +1 -1
- package/docs/reference/04-ai.mdx +27 -18
- package/docs/reference/05-adapters.mdx +2 -2
- package/docs/server/02-timers.mdx +1 -1
- package/docs/server/05-production.mdx +2 -2
- package/examples/playground/DEPLOY.md +9 -0
- package/examples/playground/app/a0/a0.css +244 -5
- package/examples/playground/app/a0/app-view.tsx +2 -1
- package/examples/playground/app/a0/attachments.ts +133 -0
- package/examples/playground/app/a0/chat.test.tsx +504 -0
- package/examples/playground/app/a0/chat.tsx +623 -63
- package/examples/playground/app/a0/context-menu.tsx +38 -11
- package/examples/playground/app/a0/model.test.ts +28 -0
- package/examples/playground/app/a0/model.ts +30 -0
- package/examples/playground/app/a0/server.ts +5 -0
- package/examples/playground/app/a0/uploads/route.ts +29 -0
- package/examples/playground/app/agent/[agentId]/agent-client.tsx +2 -1
- package/examples/playground/app/agent/[agentId]/agent-queue.test.tsx +1 -0
- package/examples/playground/app/agent/model.test.ts +12 -3
- package/examples/playground/app/chat/[chatId]/agent-state.test.ts +1 -5
- package/examples/playground/next.config.ts +7 -4
- package/examples/playground/package.json +3 -1
- package/package.json +1 -1
- package/src/ai-agent.ts +4 -0
- package/src/ai-client-state.ts +21 -9
- package/src/ai-context-schema.ts +28 -4
- package/src/ai-context.ts +83 -3
- package/src/ai-control-server.ts +70 -43
- package/src/ai-control-state.ts +3 -4
- package/src/ai-control.ts +59 -10
- package/src/ai-coordinator.ts +7 -6
- package/src/ai-fx.ts +58 -20
- package/src/ai-harness.ts +153 -29
- package/src/ai-message-shape.ts +41 -0
- package/src/ai-pi.ts +88 -32
- package/src/ai-stored-state.ts +1 -3
- package/src/ai.ts +116 -77
- package/src/libfx.d.ts +8 -1
- package/src/scheduler-vercel.ts +1 -12
- package/dist/ai-BMLlI2Ff.d.ts.map +0 -1
- package/dist/ai-D6mGlO8j.js.map +0 -1
- package/dist/ai-harness-B2suP2Qh.d.ts.map +0 -1
- package/dist/ai-harness-BuLh_EYi.js.map +0 -1
- package/examples/playground/app/a0/no-photon.cjs +0 -4
package/src/ai.ts
CHANGED
|
@@ -23,7 +23,8 @@ import {
|
|
|
23
23
|
} from './ai-client-state.ts'
|
|
24
24
|
export type { PendingQueueCommand } from './ai-client-state.ts'
|
|
25
25
|
import { applyControlChanges } from './ai-control-state.ts'
|
|
26
|
-
import {
|
|
26
|
+
import { STEERED_REASON, unexplainedAdmission } from './ai-control.ts'
|
|
27
|
+
import { isJSONCompatible, isRecord, isUIMessage } from './ai-message-shape.ts'
|
|
27
28
|
import { AI_EVENT_ID_PREFIX } from './ai-id.ts'
|
|
28
29
|
import type {
|
|
29
30
|
ControlCommit,
|
|
@@ -31,6 +32,7 @@ import type {
|
|
|
31
32
|
ControlCommand,
|
|
32
33
|
ControlReceipt,
|
|
33
34
|
InboxItem,
|
|
35
|
+
InputRef,
|
|
34
36
|
ToolExecutionRequest,
|
|
35
37
|
WorkReport,
|
|
36
38
|
} from './ai-control.ts'
|
|
@@ -39,6 +41,7 @@ export type {
|
|
|
39
41
|
ControlCommand,
|
|
40
42
|
ControlReceipt,
|
|
41
43
|
InboxItem,
|
|
44
|
+
InputRef,
|
|
42
45
|
} from './ai-control.ts'
|
|
43
46
|
import { contract as createContract } from './contract.ts'
|
|
44
47
|
import type { Contract, ContractEvent, EventDefs } from './contract.ts'
|
|
@@ -139,10 +142,15 @@ export type TranscriptMessage<M extends UIMessage> = Omit<M, 'parts'> & {
|
|
|
139
142
|
|
|
140
143
|
export type SessionCreatedPayload = { metadata?: JSONValue }
|
|
141
144
|
export type SessionClosedPayload = { reason?: string }
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
145
|
+
/**
|
|
146
|
+
* A message entering the transcript. Its content is the command's that brought
|
|
147
|
+
* it in, which every reader of the transcript has already folded.
|
|
148
|
+
*/
|
|
149
|
+
export type MessageCreatedPayload = {
|
|
150
|
+
messageId: string
|
|
151
|
+
role: UIMessage['role']
|
|
152
|
+
/** For user messages, false records passive context. Omission schedules. */
|
|
153
|
+
generate?: false
|
|
146
154
|
}
|
|
147
155
|
export type MessageCompletedPayload = { messageId: string }
|
|
148
156
|
type MessageInterruption = {
|
|
@@ -312,7 +320,7 @@ export type AIEventDefs<M extends UIMessage = UIMessage> = {
|
|
|
312
320
|
}>
|
|
313
321
|
'ai.session.created': StandardSchemaV1<SessionCreatedPayload>
|
|
314
322
|
'ai.session.closed': StandardSchemaV1<SessionClosedPayload>
|
|
315
|
-
'ai.message.created': StandardSchemaV1<MessageCreatedPayload
|
|
323
|
+
'ai.message.created': StandardSchemaV1<MessageCreatedPayload>
|
|
316
324
|
'ai.message.completed': StandardSchemaV1<MessageCompletedPayload>
|
|
317
325
|
'ai.message.interrupted': StandardSchemaV1<MessageInterruptedPayload>
|
|
318
326
|
'ai.generation.requested': StandardSchemaV1<GenerationRequestedPayload>
|
|
@@ -402,7 +410,7 @@ export type GenerationUsage = {
|
|
|
402
410
|
export type AIState<M extends UIMessage = UIMessage> = {
|
|
403
411
|
inbox: { paused: boolean; items: InboxItem<M>[] }
|
|
404
412
|
pendingQueueCommands?: PendingQueueCommand<M>[]
|
|
405
|
-
active: ActiveTurn
|
|
413
|
+
active: ActiveTurn | null
|
|
406
414
|
starting: boolean
|
|
407
415
|
receipt: ControlReceipt | null
|
|
408
416
|
pausedGenerationIds?: Record<string, true>
|
|
@@ -433,13 +441,13 @@ export type AIState<M extends UIMessage = UIMessage> = {
|
|
|
433
441
|
error: string | null
|
|
434
442
|
}
|
|
435
443
|
|
|
436
|
-
/** The `UIMessage` type a contract's
|
|
444
|
+
/** The `UIMessage` type a contract's input commands carry. */
|
|
437
445
|
export type AIMessageOf<D> = D extends {
|
|
438
|
-
readonly 'ai.
|
|
446
|
+
readonly 'ai.control.requested': infer S extends StandardSchemaV1
|
|
439
447
|
}
|
|
440
|
-
? StandardSchemaV1.InferOutput<S> extends
|
|
441
|
-
infer M extends UIMessage
|
|
442
|
-
|
|
448
|
+
? Extract<StandardSchemaV1.InferOutput<S>, { action: 'send' }> extends {
|
|
449
|
+
message: infer M extends UIMessage
|
|
450
|
+
}
|
|
443
451
|
? M
|
|
444
452
|
: UIMessage
|
|
445
453
|
: UIMessage
|
|
@@ -529,33 +537,6 @@ const schema = <T>(
|
|
|
529
537
|
},
|
|
530
538
|
})
|
|
531
539
|
|
|
532
|
-
const isRecord = (value: unknown): value is Record<string, unknown> =>
|
|
533
|
-
typeof value === 'object' && value !== null && !Array.isArray(value)
|
|
534
|
-
|
|
535
|
-
const isJSONCompatible = (
|
|
536
|
-
value: unknown,
|
|
537
|
-
seen: Set<object> = new Set(),
|
|
538
|
-
): boolean => {
|
|
539
|
-
if (
|
|
540
|
-
value === null ||
|
|
541
|
-
typeof value === 'string' ||
|
|
542
|
-
typeof value === 'boolean'
|
|
543
|
-
) {
|
|
544
|
-
return true
|
|
545
|
-
}
|
|
546
|
-
if (typeof value === 'number') return Number.isFinite(value)
|
|
547
|
-
if (typeof value === 'undefined') return true
|
|
548
|
-
if (typeof value !== 'object') return false
|
|
549
|
-
if (seen.has(value)) return false
|
|
550
|
-
seen.add(value)
|
|
551
|
-
const valid = Array.isArray(value)
|
|
552
|
-
? value.every((item) => isJSONCompatible(item, seen))
|
|
553
|
-
: Object.getPrototypeOf(value) === Object.prototype &&
|
|
554
|
-
Object.values(value).every((item) => isJSONCompatible(item, seen))
|
|
555
|
-
seen.delete(value)
|
|
556
|
-
return valid
|
|
557
|
-
}
|
|
558
|
-
|
|
559
540
|
const jsonObject = <T extends object>(
|
|
560
541
|
label: string,
|
|
561
542
|
check: (value: Record<string, unknown>) => boolean,
|
|
@@ -584,45 +565,39 @@ const optionalStringField = (
|
|
|
584
565
|
key: string,
|
|
585
566
|
): boolean => value[key] === undefined || typeof value[key] === 'string'
|
|
586
567
|
|
|
587
|
-
const messageValue = (value: unknown): value is UIMessage =>
|
|
588
|
-
isRecord(value) &&
|
|
589
|
-
typeof value['id'] === 'string' &&
|
|
590
|
-
(value['role'] === 'user' ||
|
|
591
|
-
value['role'] === 'assistant' ||
|
|
592
|
-
value['role'] === 'system') &&
|
|
593
|
-
Array.isArray(value['parts']) &&
|
|
594
|
-
value['parts'].every(
|
|
595
|
-
(part) => isRecord(part) && typeof part['type'] === 'string',
|
|
596
|
-
) &&
|
|
597
|
-
isJSONCompatible(value)
|
|
598
|
-
|
|
599
568
|
const validateMessage = <M extends UIMessage>(
|
|
600
569
|
value: unknown,
|
|
601
570
|
messageSchema?: StandardSchemaV1<M>,
|
|
602
571
|
): SchemaResult<M> => {
|
|
603
|
-
if (!
|
|
572
|
+
if (!isUIMessage(value)) return issue('invalid AI SDK UIMessage')
|
|
604
573
|
if (!messageSchema) return { value: value as M }
|
|
605
574
|
return validateSync(messageSchema, value, 'the AI message')
|
|
606
575
|
}
|
|
607
576
|
|
|
608
|
-
const
|
|
609
|
-
|
|
610
|
-
)
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
577
|
+
const messageCreatedSchema: StandardSchemaV1<MessageCreatedPayload> = schema(
|
|
578
|
+
'ai.message.created',
|
|
579
|
+
(value) => {
|
|
580
|
+
if (
|
|
581
|
+
!isRecord(value) ||
|
|
582
|
+
Object.keys(value).some(
|
|
583
|
+
(key) => key !== 'messageId' && key !== 'role' && key !== 'generate',
|
|
584
|
+
) ||
|
|
585
|
+
!stringField(value, 'messageId') ||
|
|
586
|
+
(value['role'] !== 'user' &&
|
|
587
|
+
value['role'] !== 'assistant' &&
|
|
588
|
+
value['role'] !== 'system') ||
|
|
589
|
+
(value['generate'] !== undefined && value['generate'] !== false)
|
|
590
|
+
)
|
|
591
|
+
return issue('invalid ai.message.created payload')
|
|
619
592
|
return {
|
|
620
593
|
value: {
|
|
621
|
-
|
|
622
|
-
|
|
594
|
+
messageId: value['messageId'] as string,
|
|
595
|
+
role: value['role'],
|
|
596
|
+
...(value['generate'] === false ? { generate: false as const } : {}),
|
|
623
597
|
},
|
|
624
598
|
}
|
|
625
|
-
}
|
|
599
|
+
},
|
|
600
|
+
)
|
|
626
601
|
|
|
627
602
|
const progressPayloadSchema: StandardSchemaV1<GenerationProgressPayload> =
|
|
628
603
|
schema('ai.generation.progress', (value) => {
|
|
@@ -731,6 +706,14 @@ export function createEvents<M extends UIMessage = UIMessage>(options?: {
|
|
|
731
706
|
'AI command',
|
|
732
707
|
)
|
|
733
708
|
if (payload.issues) return { issues: payload.issues }
|
|
709
|
+
if (
|
|
710
|
+
action === 'interrupt' &&
|
|
711
|
+
isRecord(payload.value) &&
|
|
712
|
+
payload.value['reason'] === STEERED_REASON
|
|
713
|
+
)
|
|
714
|
+
return issue(
|
|
715
|
+
`the interruption reason "${STEERED_REASON}" is reserved for steering`,
|
|
716
|
+
)
|
|
734
717
|
return { value: { action, [key]: payload.value } as ControlCommand<M> }
|
|
735
718
|
}
|
|
736
719
|
if (action === 'send' || action === 'edit' || action === 'steer') {
|
|
@@ -857,7 +840,7 @@ export function createEvents<M extends UIMessage = UIMessage>(options?: {
|
|
|
857
840
|
'ai.session.closed': jsonObject('ai.session.closed', (value) =>
|
|
858
841
|
optionalStringField(value, 'reason'),
|
|
859
842
|
),
|
|
860
|
-
'ai.message.created':
|
|
843
|
+
'ai.message.created': messageCreatedSchema,
|
|
861
844
|
'ai.message.completed': jsonObject('ai.message.completed', (value) =>
|
|
862
845
|
stringField(value, 'messageId'),
|
|
863
846
|
),
|
|
@@ -1036,7 +1019,7 @@ export function createEvents<M extends UIMessage = UIMessage>(options?: {
|
|
|
1036
1019
|
export const events: AIEventDefs<UIMessage> = createEvents()
|
|
1037
1020
|
|
|
1038
1021
|
const initialState = <M extends UIMessage>(): AIState<M> => ({
|
|
1039
|
-
inbox:
|
|
1022
|
+
inbox: { paused: false, items: [] },
|
|
1040
1023
|
pendingQueueCommands: [],
|
|
1041
1024
|
active: null,
|
|
1042
1025
|
starting: false,
|
|
@@ -1153,6 +1136,22 @@ export function reduceAIState<M extends UIMessage>(
|
|
|
1153
1136
|
)
|
|
1154
1137
|
}
|
|
1155
1138
|
|
|
1139
|
+
/**
|
|
1140
|
+
* An input's content, while it is queued or about to enter the transcript:
|
|
1141
|
+
* its inbox item's, or its pending send's or steer's, whose command id is the
|
|
1142
|
+
* input's id.
|
|
1143
|
+
*/
|
|
1144
|
+
function inputContent<M extends UIMessage>(state: AIState<M>, id: string): M {
|
|
1145
|
+
const queued = state.inbox.items.find((item) => item.id === id)?.message
|
|
1146
|
+
if (queued !== undefined) return queued
|
|
1147
|
+
const command = state.pendingQueueCommands?.find(
|
|
1148
|
+
(item) => item.commandId === id,
|
|
1149
|
+
)?.command
|
|
1150
|
+
if (command?.action === 'send' || command?.action === 'steer')
|
|
1151
|
+
return command.message
|
|
1152
|
+
throw unexplainedAdmission(id)
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1156
1155
|
function reduceAIEvent<M extends UIMessage>(
|
|
1157
1156
|
state: AIState<M>,
|
|
1158
1157
|
event: { type: string; payload: unknown; index: number; id?: string },
|
|
@@ -1177,12 +1176,35 @@ function reduceAIEvent<M extends UIMessage>(
|
|
|
1177
1176
|
}
|
|
1178
1177
|
case 'ai.control.committed': {
|
|
1179
1178
|
const commit = event.payload as ControlCommit
|
|
1180
|
-
const
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1179
|
+
const changes = commit.changes.filter(
|
|
1180
|
+
(change) => change.path[0] === 'inbox' || change.path[0] === 'active',
|
|
1181
|
+
)
|
|
1182
|
+
let { inbox, active } = state
|
|
1183
|
+
if (changes.length > 0) {
|
|
1184
|
+
// A commit holds inputs by reference; their content is the commands'.
|
|
1185
|
+
const visible = applyControlChanges({
|
|
1186
|
+
state: {
|
|
1187
|
+
inbox: {
|
|
1188
|
+
...inbox,
|
|
1189
|
+
items: inbox.items.map(
|
|
1190
|
+
({ message: _, ...input }): InputRef => input,
|
|
1191
|
+
),
|
|
1192
|
+
},
|
|
1193
|
+
active,
|
|
1194
|
+
},
|
|
1195
|
+
changes,
|
|
1196
|
+
})
|
|
1197
|
+
const queued = new Map(inbox.items.map((item) => [item.id, item]))
|
|
1198
|
+
inbox = {
|
|
1199
|
+
...visible.inbox,
|
|
1200
|
+
items: visible.inbox.items.map((input) => ({
|
|
1201
|
+
...input,
|
|
1202
|
+
message:
|
|
1203
|
+
queued.get(input.id)?.message ?? inputContent(state, input.id),
|
|
1204
|
+
})),
|
|
1205
|
+
}
|
|
1206
|
+
active = visible.active
|
|
1207
|
+
}
|
|
1186
1208
|
const { phase } = commit.view
|
|
1187
1209
|
const status: AgentStatus = commit.view.closed
|
|
1188
1210
|
? 'closed'
|
|
@@ -1199,7 +1221,8 @@ function reduceAIEvent<M extends UIMessage>(
|
|
|
1199
1221
|
: 'idle'
|
|
1200
1222
|
return {
|
|
1201
1223
|
...state,
|
|
1202
|
-
|
|
1224
|
+
inbox,
|
|
1225
|
+
active,
|
|
1203
1226
|
status,
|
|
1204
1227
|
activeRequestId: commit.view.requestId,
|
|
1205
1228
|
activeRequestReason: commit.view.requestReason,
|
|
@@ -1214,9 +1237,24 @@ function reduceAIEvent<M extends UIMessage>(
|
|
|
1214
1237
|
const settled = pending.find(
|
|
1215
1238
|
(item) => item.commandId === receipt.commandId,
|
|
1216
1239
|
)
|
|
1240
|
+
// An edit's content takes effect at its receipt.
|
|
1241
|
+
const edited =
|
|
1242
|
+
receipt.outcome === 'applied' && settled?.command.action === 'edit'
|
|
1243
|
+
? settled.command.message
|
|
1244
|
+
: undefined
|
|
1217
1245
|
return {
|
|
1218
1246
|
...state,
|
|
1219
1247
|
receipt,
|
|
1248
|
+
...(edited === undefined
|
|
1249
|
+
? {}
|
|
1250
|
+
: {
|
|
1251
|
+
inbox: {
|
|
1252
|
+
...state.inbox,
|
|
1253
|
+
items: state.inbox.items.map((item) =>
|
|
1254
|
+
item.id === edited.id ? { ...item, message: edited } : item,
|
|
1255
|
+
),
|
|
1256
|
+
},
|
|
1257
|
+
}),
|
|
1220
1258
|
...(settled === undefined
|
|
1221
1259
|
? {}
|
|
1222
1260
|
: {
|
|
@@ -1329,7 +1367,8 @@ function reduceAIEvent<M extends UIMessage>(
|
|
|
1329
1367
|
activeProjection: null,
|
|
1330
1368
|
}
|
|
1331
1369
|
case 'ai.message.created': {
|
|
1332
|
-
const {
|
|
1370
|
+
const { messageId } = event.payload as MessageCreatedPayload
|
|
1371
|
+
const message = inputContent(state, messageId)
|
|
1333
1372
|
return {
|
|
1334
1373
|
...state,
|
|
1335
1374
|
messages: upsertMessage(state.messages, message),
|
|
@@ -2516,7 +2555,7 @@ export function handlerContext<D extends AgentToolEventDefs = AIEventDefs>(
|
|
|
2516
2555
|
}
|
|
2517
2556
|
|
|
2518
2557
|
/** The built-in AI reducer's name, and so its checkpoint identity. */
|
|
2519
|
-
export const AI_STATE_REDUCER = 'a2.ai.state.
|
|
2558
|
+
export const AI_STATE_REDUCER = 'a2.ai.state.v27'
|
|
2520
2559
|
|
|
2521
2560
|
/**
|
|
2522
2561
|
* The built-in AI protocol plus application events, as a core contract whose
|
package/src/libfx.d.ts
CHANGED
|
@@ -14,8 +14,15 @@ declare module 'libfx' {
|
|
|
14
14
|
cancel(): void
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
+
export type FxPromptBlock =
|
|
18
|
+
| { type: 'text'; text: string }
|
|
19
|
+
| { type: 'image'; data: string; mimeType: string }
|
|
20
|
+
|
|
17
21
|
export type FxAgent = {
|
|
18
|
-
prompt(
|
|
22
|
+
prompt(
|
|
23
|
+
input: string | FxPromptBlock[],
|
|
24
|
+
options?: { signal?: AbortSignal },
|
|
25
|
+
): FxTurn
|
|
19
26
|
checkpoint(): Promise<Uint8Array>
|
|
20
27
|
close(): Promise<void>
|
|
21
28
|
}
|
package/src/scheduler-vercel.ts
CHANGED
|
@@ -100,12 +100,9 @@ export type VercelQueuesOptions = {
|
|
|
100
100
|
/** Vercel Queues rejects shorter visibility changes. */
|
|
101
101
|
const MIN_VISIBILITY_SECONDS = 30
|
|
102
102
|
|
|
103
|
-
/** Vercel Queues' maximum message retention
|
|
103
|
+
/** Vercel Queues' maximum message retention; its default is a day. */
|
|
104
104
|
const MAX_RETENTION_SECONDS = 7 * 24 * 60 * 60
|
|
105
105
|
|
|
106
|
-
/** Leave the final retention day for delivery and retries. */
|
|
107
|
-
const MAX_DELAY_SECONDS = 6 * 24 * 60 * 60
|
|
108
|
-
|
|
109
106
|
const TOPIC_PATTERN = /^[A-Za-z0-9_-]+$/
|
|
110
107
|
const RETRYABLE_HTTP_CLIENT_STATUSES = new Set([408, 409, 425, 429])
|
|
111
108
|
/** The SDK's send path maps these statuses to name-only error instances. */
|
|
@@ -257,14 +254,6 @@ export function vercelQueues(options: VercelQueuesOptions = {}): A2Scheduler {
|
|
|
257
254
|
0,
|
|
258
255
|
Math.ceil((deliveryTargetAt - nowMs) / 1_000),
|
|
259
256
|
)
|
|
260
|
-
if (deliveryDelaySeconds > MAX_DELAY_SECONDS) {
|
|
261
|
-
throw classifySchedulerSendFailure(
|
|
262
|
-
new RangeError(
|
|
263
|
-
'vercelQueues() tasks cannot be delayed more than 6 days',
|
|
264
|
-
),
|
|
265
|
-
'terminal',
|
|
266
|
-
)
|
|
267
|
-
}
|
|
268
257
|
const message: SchedulerTask = { ...task, dueAt }
|
|
269
258
|
const idempotencyKey =
|
|
270
259
|
task.kind === 'drain'
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ai-BMLlI2Ff.d.ts","names":[],"sources":["../src/ai-message-base.ts","../src/ai-control.ts","../src/ai-client-state.ts","../src/ai-projector.ts","../src/ai-progress-batches.ts","../src/ai-message-projection.ts","../src/ai.ts"],"mappings":";;;;KAGK;EAAc;;EAAsB;;EAAmB;;KACvD,aAAa,eAAe;KAC5B;EAAa,OAAO;;EAAiC,QAAQ;;KAEtD;EACV;EACA,SAAS;EACT,QAAQ,eAAe;;;;KCIb,UAAU,UAAU,YAAY;EAC1C;EACA,SAAS;EACT;EACA;;KAGU,eAAe,UAAU,YAAY;EAC3C;EAAgB,SAAS;EAAG;;EAC5B;EAAgB,SAAS;;EACzB;EAAgB;EAAiB;;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B;EAEhC;EAAsB;;EACtB;EAAmB;;KAEf;EACV;IAAY;IAAgB;;EAC5B;EACA,QAAQ;EACR;EACA;;KAEU;EACV;EACA;EACA;;KAEU,wBAAwB;KACxB;EACV;EACA;EACA;EACA;EACA;;EAEA;EACA;;KAEU;;EAEV;EACA,QAAQ;;KAEE;EACV;EACA;EACA;EACA;EACA,eAAe;EACf,QAAQ;EACR;;KAEU;EACV;EACA;EACA;EACA;EACA;;EAEA;EACA;;KAEU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;KAEU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;;KAEU;EACV;EACA;EACA;EACA;EACA;EACA;EACA;;KAEU;EACV;EACA;EACA;EACA;EACA;EACA;;KAEU;EACV;EACA;EACA;EACA;EACA;EACA,WAAW;;KAED;EACV;EACA;EACA;EACA;EACA;EACA,OAAO;;KAEG;EACV;EACA;;KAEU;EAAkC;;KAClC;EACV;EACA,QAAQ;;KAEE;EACN;;EACA;EAAoB,QAAQ;;EAC5B;;KAEM;EACV;EACA;EACA;EACA;EACA;EACA;;KAEU,2BAA2B,UAAU;EAC/C;EACA;EACA;EACA,UAAU;EACV;EACA;EACA,QAAQ;;KAGE,YAAY,UAAU,cAAY;EAC5C,wBAAwB,iBAAiB,eAAe;EACxD,wBAAwB,iBAAiB;EACzC,sBAAsB,iBAAiB;EACvC,oBAAoB,iBAAiB;EACrC,+BAA+B,iBAAiB;EAChD,wBAAwB;IACtB;IACA;;EAEF,sBAAsB,iBAAiB;EACvC,qBAAqB,iBAAiB;EACtC,sBAAsB,iBAAiB,sBAAsB;EAC7D,wBAAwB,iBAAiB;EACzC,0BAA0B,iBAAiB;EAC3C,2BAA2B,iBAAiB;EAC5C,sBAAsB,iBAAiB;EACvC,yBAAyB,iBAAiB;EAC1C,0BAA0B,iBAAiB;EAC3C,2BAA2B,iBAAiB;EAC5C,wBAAw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