Commit Graph

7259 Commits

Author SHA1 Message Date
Eric Allam d54e6a291f feat(chat): tool approvals support — ID-matched message replacement, sendEmail example, approval UI 2026-05-10 22:11:03 +01:00
Eric Allam d6ac62fc5d feat(chat): allow generateMessageId in uiMessageStreamOptions, auto-pass originalMessages 2026-05-10 22:11:03 +01:00
Eric Allam 258ddb2305 fix(sdk): inject prepareStep in toStreamTextOptions even without chat.prompt.set() 2026-05-10 22:11:03 +01:00
Eric Allam b99bd75a8f feat(chat): add stopGeneration, fix onTurnComplete/onFinishPromise, add /chats/[chatId] route to ai-chat 2026-05-10 22:11:03 +01:00
Eric Allam e9586959b6 Add run agent view 2026-05-10 22:11:03 +01:00
Eric Allam 77a755c753 Support for upgrading an agent to a new version 2026-05-10 22:11:03 +01:00
Eric Allam 7f649efbba Add support for optionally validating UI messages 2026-05-10 22:11:03 +01:00
Eric Allam 15c2ee8cd6 add agent mcp tools 2026-05-10 22:11:03 +01:00
Eric Allam 9831a2f951 Add server-to-server chat support and subagent support to the playground, plus docs 2026-05-10 22:11:03 +01:00
Eric Allam 55029507ee Add the chat client and strip agent crumbs 2026-05-10 22:11:03 +01:00
Eric Allam f4817fd9d2 Some design tweaks, improvements to playground options, rename unnamed preloaded conversations on first message 2026-05-10 22:11:03 +01:00
Eric Allam ae2123b49a playground ui tweaks 2026-05-10 22:11:03 +01:00
Eric Allam 91b21ea6af feat: upgrade streamdown to v2.5.0 with custom Trigger.dev Shiki theme
- Upgrade streamdown from v1.4.0 to v2.5.0 with @streamdown/code plugin
- Custom Shiki theme matching the Trigger.dev VS Code dark theme colors
- Consolidate duplicated lazy StreamdownRenderer into shared component
- Patch streamdown to inline highlighted body (fixes Arc browser)
- Add streamdown storybook page for visual testing
- Handle AGENT triggerSource in TestTaskPresenter exhaustive switch
- Update Tailwind config to scan streamdown dist for utility classes
2026-05-10 22:11:03 +01:00
Eric Allam 89de993b54 chat.task -> chat.agent
plus playground support, including playground conversations, and a new
agent list
2026-05-10 22:10:22 +01:00
Eric Allam 254bf42fe9 Add support for triggering from the backend 2026-05-10 22:10:16 +01:00
Eric Allam 817367aa73 feat(sdk): add onChatSuspend/onChatResume hooks, exitAfterPreloadIdle, chat.withClientData, and ChatBuilder 2026-05-10 22:10:11 +01:00
Eric Allam dde3934670 feat(sdk): ctx on chat.task hooks; ai-chat E2B sandbox; docs patterns
- Pass TaskRunContext through chat lifecycle events, CompactedEvent, and
  ChatTaskRunPayload; use ctx.run.id for chat access tokens
- Export TaskRunContext from @trigger.dev/sdk
- ai-chat reference: executeCode via E2B, code-sandbox module, warm on
  onTurnStart, dispose on token onWait and onComplete; chat.local run id
- Docs: database persistence + code sandbox pattern pages; reference and
  backend updates for ctx; chat.defer anchor; navigation
2026-05-10 22:10:11 +01:00
Eric Allam 5a8ba63726 Add run-scoped PAT renewal for chat transport 2026-05-10 22:09:48 +01:00
Eric Allam be820d084a feat(sdk): ToolSet typing for toolFromTask, ai.toolExecute, deprecate ai.tool
- Assert toolFromTask return as AI SDK ToolSet-compatible; import ToolSet from ai
- Add changesets for @trigger.dev/sdk
- ai-chat reference: chat-tools module, registry language model helper, streamText cleanup
- Prisma migration removing user tool demo; demo docs and next config tweaks
2026-05-10 22:09:48 +01:00
Eric Allam 71abce7f93 feat(chat): add chat.inject() for background context injection and chat.defer improvements
- chat.inject(): queue model messages from background work for injection
  at the next prepareStep boundary or before the next turn's run()
- Deferred work from onTurnComplete no longer blocks waiting for next message
- Background queue persists across turns (not reset) so deferred work from
  onTurnComplete can inject into the next turn
- Reference app: self-review pattern using generateObject + chat.inject()
- Hide transient data-turn-status and data-background-context-injected parts in UI
2026-05-10 22:09:48 +01:00
Eric Allam 9d334e8ace feat(ai): add triggerAndSubscribe method and use it in ai.tool
Replace triggerAndWait with triggerAndSubscribe in ai.tool to fix:
- Parallel tool calls (no more preventMultipleWaits errors)
- Stop signal while suspended (parent stays alive, child gets cancelled)

New task.triggerAndSubscribe() method: trigger + subscribeToRun in a
single span, with abort signal support and cancelOnAbort option.

Convert deepResearch to a schemaTask + ai.tool in the reference app.

refs TRI-7986
2026-05-10 22:09:48 +01:00
Eric Allam 49e858ef56 Add a writer to easily write chunks in callbacks 2026-05-10 22:09:48 +01:00
Eric Allam f05d638717 feat(chat): add compaction option, pendingMessages steering, and usePendingMessages hook 2026-05-10 22:09:48 +01:00
Eric Allam f7442f1312 better compaction support in our other chat variants 2026-05-10 22:09:48 +01:00
Eric Allam c21e920a3b feat: support message compaction 2026-05-10 22:09:48 +01:00
Eric Allam aeb0fbb6a2 refactor: rename warmTimeout to idleTimeout across chat APIs 2026-05-10 22:09:48 +01:00
Eric Allam 856d2527d0 feat(chat): add chat.prompt API with provider registry support 2026-05-10 22:09:48 +01:00
Eric Allam 18ca682169 Add metadata to the streamText call 2026-05-10 22:08:38 +01:00
Eric Allam 78900720af Add support for toUIMessageStream() options 2026-05-10 22:08:38 +01:00
Eric Allam 1f6ea4b2d9 Introduce the chat session API and better docs organization 2026-05-10 22:08:38 +01:00
Eric Allam 25f7dedd14 feat(chat): add composable primitives, raw task example, and task mode switcher 2026-05-10 22:08:38 +01:00
Eric Allam 2908b3598d feat(streams): add inputStream.waitWithWarmup(), warm timeout config in sidebar, preload payload option 2026-05-10 22:08:38 +01:00
Eric Allam 7aa5964141 fix(reference): replace hand-rolled HTML stripping with turndown 2026-05-10 22:08:38 +01:00
Eric Allam dc84597ff5 feat(chat): add chat.defer(), preload toggle, TTFB measurement, and fix ChatTaskWirePayload export 2026-05-10 22:08:35 +01:00
Eric Allam 3d0b02752e feat(chat): auto-hydrate chat.local values in ai.tool subtasks 2026-05-10 22:08:35 +01:00
Eric Allam 01fab9dfd4 docs: add sequence diagrams to ai-chat guide 2026-05-10 22:08:35 +01:00
Eric Allam ebc3199d8c docs: add mermaid architecture diagrams for ai-chat system 2026-05-10 22:08:35 +01:00
Eric Allam b2dc691951 feat(chat): add preload support, dynamic tools, and preload-specific timeouts
- Add onPreload hook and preloaded field to all lifecycle events
- Add transport.preload(chatId) for eagerly starting runs before first message
- Add preloadWarmTimeoutInSeconds and preloadTimeout task options
- Add preload:true run tag and chat.preloaded span attributes
- Add UserTool model for per-user dynamic tools loaded from DB
- Load dynamic tools in onPreload/onChatStart via chat.local
- Build dynamicTool() instances in run and spread into streamText tools
- Reference project: preload on new chat, dynamic company-info and user-preferences tools
2026-05-10 22:08:35 +01:00
Eric Allam 1cc19f8ca8 feat(ai): pass chat context and toolCallId to subtasks, add typed ai.chatContext helpers
- Store chat turn context (chatId, turn, continuation, clientData) in locals for auto-detection
- toolFromTask now auto-detects chat context and passes it to subtask metadata
- Skip serializing messages array (can be large, rarely needed by subtasks)
- Tag subtask runs with toolCallId for dashboard visibility
- Add ai.toolCallId() convenience helper
- Add ai.chatContext<typeof myChat>() with typed clientData inference
- Add ai.chatContextOrThrow<typeof myChat>() that throws if not in a chat context
- Update deepResearch example to use ai.chatContextOrThrow
- Document all helpers in ai-chat guide
2026-05-10 22:08:35 +01:00
Eric Allam acb1f9820e feat(chat): expose typed chat.stream, add deepResearch subtask example, per-chat model persistence, debug panel
- Export chat.stream (typed RealtimeDefinedStream<UIMessageChunk>) for writing custom data to the chat stream
- Add deepResearch subtask using data-* chunks to stream progress back to parent chat via target: root
- Use AI SDK data-research-progress chunk protocol with id-based updates for live progress
- Add ResearchProgress component and generic data-* fallback renderer in frontend
- Persist model per chat in DB (schema + onChatStart), model selector only on new chats
- Add collapsible debug panel showing run ID (with dashboard link), chat ID, model, status, session info
- Document chat.stream API, data-* chunks, and subtask streaming pattern in docs
2026-05-10 22:08:35 +01:00
Eric Allam 6b8df32cf8 Some improvements to the example ai-chat 2026-05-10 22:08:35 +01:00
Eric Allam 5c1aa24a04 feat(chat): add stop handling, abort cleanup, continuation support, and reference project enhancements
- Fix onFinish race condition: await onFinishPromise so capturedResponseMessage is set before accumulation
- Add chat.isStopped() helper accessible from anywhere during a turn
- Add chat.cleanupAbortedParts() to remove incomplete tool/reasoning/text parts on stop
- Auto-cleanup aborted parts before passing to onTurnComplete
- Clean incoming messages from frontend to prevent tool_use without tool_result API errors
- Add stopped and rawResponseMessage fields to TurnCompleteEvent
- Add continuation and previousRunId fields to all lifecycle hooks and run payload
- Add span attributes (chat.id, chat.turn, chat.stopped, chat.continuation, chat.previous_run_id, etc.)
- Add webFetch tool and reasoning model support to ai-chat reference project
- Render reasoning parts in frontend chat component
- Document all new fields in ai-chat guide
2026-05-10 22:08:35 +01:00
Eric Allam fc9768a66f feat: add chat.local for per-run typed data with Proxy access and dirty tracking 2026-05-10 22:08:35 +01:00
Eric Allam 28afa9829e Make clientData typesafe and pass to all chat.task hooks 2026-05-10 22:08:35 +01:00
Eric Allam 800725fb46 Add triggerOptions to the transport, auto-tag with the chat ID 2026-05-10 22:08:35 +01:00
Eric Allam 2b00606c31 use locals for the chat pipe counter instead of a module global 2026-05-10 22:08:35 +01:00
Eric Allam 0df407edc4 fixed chat tests 2026-05-10 22:08:35 +01:00
Eric Allam 5f361552bf update pnpm link file 2026-05-10 22:08:35 +01:00
Eric Allam 1151b20530 Minor fixes around reconnecting streams 2026-05-10 22:08:35 +01:00
Eric Allam 21050cc7e3 feat: add onTurnStart hook, lastEventId support, and stream resume deduplication 2026-05-10 22:08:35 +01:00