@trigger.dev/sdk 0.0.0-prerelease-local-bundle-20260824142657 → 0.0.0-prerelease-20260827125919

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 (45) hide show
  1. package/dist/commonjs/v3/ai.d.ts +31 -8
  2. package/dist/commonjs/v3/ai.js +548 -361
  3. package/dist/commonjs/v3/ai.js.map +1 -1
  4. package/dist/commonjs/v3/chat.d.ts +3 -1
  5. package/dist/commonjs/v3/chat.js +22 -7
  6. package/dist/commonjs/v3/chat.js.map +1 -1
  7. package/dist/commonjs/v3/chat.test.js +13 -4
  8. package/dist/commonjs/v3/chat.test.js.map +1 -1
  9. package/dist/commonjs/v3/sessions.d.ts +4 -10
  10. package/dist/commonjs/v3/sessions.js +73 -47
  11. package/dist/commonjs/v3/sessions.js.map +1 -1
  12. package/dist/commonjs/v3/test/mock-chat-agent.js +1 -0
  13. package/dist/commonjs/v3/test/mock-chat-agent.js.map +1 -1
  14. package/dist/commonjs/v3/test/test-session-handle.js +22 -23
  15. package/dist/commonjs/v3/test/test-session-handle.js.map +1 -1
  16. package/dist/commonjs/version.js +1 -1
  17. package/dist/esm/v3/ai.d.ts +31 -8
  18. package/dist/esm/v3/ai.js +546 -361
  19. package/dist/esm/v3/ai.js.map +1 -1
  20. package/dist/esm/v3/chat.d.ts +3 -1
  21. package/dist/esm/v3/chat.js +22 -7
  22. package/dist/esm/v3/chat.js.map +1 -1
  23. package/dist/esm/v3/chat.test.js +13 -4
  24. package/dist/esm/v3/chat.test.js.map +1 -1
  25. package/dist/esm/v3/sessions.d.ts +4 -10
  26. package/dist/esm/v3/sessions.js +73 -47
  27. package/dist/esm/v3/sessions.js.map +1 -1
  28. package/dist/esm/v3/test/mock-chat-agent.js +2 -1
  29. package/dist/esm/v3/test/mock-chat-agent.js.map +1 -1
  30. package/dist/esm/v3/test/test-session-handle.js +23 -24
  31. package/dist/esm/v3/test/test-session-handle.js.map +1 -1
  32. package/dist/esm/version.js +1 -1
  33. package/docs/ai-chat/client-protocol.mdx +4 -1
  34. package/docs/ai-chat/custom-agents.mdx +58 -1
  35. package/docs/ai-chat/pending-messages.mdx +5 -3
  36. package/docs/ai-chat/reference.mdx +4 -4
  37. package/docs/deployment/atomic-deployment.mdx +12 -0
  38. package/docs/deployment/overview.mdx +7 -1
  39. package/docs/deployment/version-skew-protection.mdx +430 -0
  40. package/docs/github-actions.mdx +33 -5
  41. package/docs/github-integration.mdx +12 -0
  42. package/docs/self-hosting/env/webapp.mdx +1 -0
  43. package/docs/vercel-integration.mdx +43 -9
  44. package/docs/versioning.mdx +2 -0
  45. package/package.json +2 -2
@@ -257,6 +257,26 @@ export type ChatTaskRunPayload<TClientData = unknown, TTools extends ToolSet = T
257
257
  */
258
258
  tools: TTools;
259
259
  };
260
+ /**
261
+ * One message record delivered through {@link chat.messages}.
262
+ *
263
+ * `id` is the append's stable idempotency key and `seqNum` is its monotonic
264
+ * sequence on the Session `.in` channel. Both remain stable if the record is
265
+ * delivered again after a reconnect.
266
+ */
267
+ export type ChatMessageRecord = Readonly<{
268
+ id: string;
269
+ seqNum: number;
270
+ payload: ChatTaskWirePayload;
271
+ }>;
272
+ export type ChatMessages = RealtimeDefinedInputStream<ChatTaskWirePayload> & {
273
+ /** Whether the local buffer head is a message that can be consumed immediately. */
274
+ hasPending(): Promise<boolean>;
275
+ /** Consume one message record, or return `undefined` when the optional timeout elapses. */
276
+ next(options?: {
277
+ timeoutInSeconds?: number;
278
+ }): Promise<ChatMessageRecord | undefined>;
279
+ };
260
280
  /**
261
281
  * Signal received by a `handover-prepare` agent run waiting on
262
282
  * `session.in`. Either the customer's first-turn `streamText` finished
@@ -294,9 +314,8 @@ export type HandoverSignal = {
294
314
  * For the common case prefer `accumulator.consumeHandover()`, which also seeds
295
315
  * `payload.headStartMessages` and applies the partial for you.
296
316
  *
297
- * Must be called at turn 0 before any `chat.messages.waitWithIdleTimeout` —
298
- * that facade consumes and discards non-message chunks, which would swallow the
299
- * handover signal.
317
+ * Safe to call at any point in turn 0: the handover signal has its own route,
318
+ * so a message facade waiting at the same time cannot take it.
300
319
  */
301
320
  declare function waitForHandover(options: {
302
321
  /** The run's wire payload (only `trigger` / `idleTimeoutInSeconds` are read). */
@@ -2460,10 +2479,14 @@ declare function createStopSignal(): {
2460
2479
  * task instead of round-tripping them back from the client:
2461
2480
  * - `lastEventId` — the turn-complete control record's seq_num on
2462
2481
  * `session.out`; where the next turn's output stream resumes.
2463
- * - `sessionInEventId` — the committed-consume cursor on `session.in` as of
2464
- * this turn-complete, letting a raw loop correlate the boundary with the
2465
- * exact input record it acknowledged. Trigger owns input-cursor recovery,
2466
- * so this is for correlation / out-of-sync detection, not required.
2482
+ * - `sessionInEventId` — the safe-to-resume-from cursor on `session.in` as of
2483
+ * this turn-complete. It is the highest sequence that can be resumed past
2484
+ * without skipping an unhandled message, so it is held back behind any
2485
+ * message still buffered unconsumed and is NOT necessarily the sequence of
2486
+ * the record this turn answered. Trigger owns input-cursor recovery, so this
2487
+ * is for correlation / out-of-sync detection, not required. Treat it as a
2488
+ * lower bound: a value below the record you just handled is expected, not a
2489
+ * sign of a lost turn.
2467
2490
  *
2468
2491
  * Either is `undefined` when the corresponding cursor isn't available.
2469
2492
  *
@@ -3010,7 +3033,7 @@ export declare const chat: {
3010
3033
  write(part: UIMessageChunk): void;
3011
3034
  };
3012
3035
  /** Pre-built input stream for receiving messages from the transport. */
3013
- messages: RealtimeDefinedInputStream<ChatTaskWirePayload>;
3036
+ messages: ChatMessages;
3014
3037
  /** Create a managed stop signal wired to the stop input stream. See {@link createStopSignal}. */
3015
3038
  createStopSignal: typeof createStopSignal;
3016
3039
  /** Signal the frontend that the current turn is complete. See {@link chatWriteTurnComplete}. */