Commit Graph

7177 Commits

Author SHA1 Message Date
Eric Allam d5b94ddf24 feat(chat): add stopGeneration, fix onTurnComplete/onFinishPromise, add /chats/[chatId] route to ai-chat 2026-04-17 16:19:23 +01:00
Eric Allam 556266a8b2 Add run agent view 2026-04-17 16:19:23 +01:00
Eric Allam 12ab2fc9da Support for upgrading an agent to a new version 2026-04-17 16:19:23 +01:00
Eric Allam bc3f6f4116 Add support for optionally validating UI messages 2026-04-17 16:19:23 +01:00
Eric Allam ffca287993 add agent mcp tools 2026-04-17 16:19:23 +01:00
Eric Allam 2b6c074318 Add server-to-server chat support and subagent support to the playground, plus docs 2026-04-17 16:19:23 +01:00
Eric Allam 0941f2a0c8 Add the chat client and strip agent crumbs 2026-04-17 16:19:23 +01:00
Eric Allam 3e1b51583d Some design tweaks, improvements to playground options, rename unnamed preloaded conversations on first message 2026-04-17 16:19:23 +01:00
Eric Allam 74d72e4945 playground ui tweaks 2026-04-17 16:19:23 +01:00
Eric Allam b9cb2d0d0a 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-04-17 16:19:23 +01:00
Eric Allam e9fb7c3b7c chat.task -> chat.agent
plus playground support, including playground conversations, and a new
agent list
2026-04-17 16:19:23 +01:00
Eric Allam 865b820858 Add support for triggering from the backend 2026-04-17 16:19:23 +01:00
Eric Allam 1808a63f73 feat(sdk): add onChatSuspend/onChatResume hooks, exitAfterPreloadIdle, chat.withClientData, and ChatBuilder 2026-04-17 16:19:23 +01:00
Eric Allam cb543f3343 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-04-17 16:19:23 +01:00
Eric Allam 430a81f1b2 Add run-scoped PAT renewal for chat transport 2026-04-17 16:19:23 +01:00
Eric Allam 6b9cba647f 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-04-17 16:19:23 +01:00
Eric Allam a7159559d6 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-04-17 16:19:23 +01:00
Eric Allam e3ff442600 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-04-17 16:19:23 +01:00
Eric Allam de878670b7 Add a writer to easily write chunks in callbacks 2026-04-17 16:19:23 +01:00
Eric Allam c294f8a7cd feat(chat): add compaction option, pendingMessages steering, and usePendingMessages hook 2026-04-17 16:19:23 +01:00
Eric Allam 6761dcd136 better compaction support in our other chat variants 2026-04-17 16:19:23 +01:00
Eric Allam 85a9cde620 feat: support message compaction 2026-04-17 16:19:23 +01:00
Eric Allam 659839edf8 refactor: rename warmTimeout to idleTimeout across chat APIs 2026-04-17 16:19:23 +01:00
Eric Allam dd5b6c1492 feat(chat): add chat.prompt API with provider registry support 2026-04-17 16:19:23 +01:00
Eric Allam 6cdb662ecf Add metadata to the streamText call 2026-04-17 16:19:23 +01:00
Eric Allam 627db05c56 Add support for toUIMessageStream() options 2026-04-17 16:19:23 +01:00
Eric Allam a458120c59 Introduce the chat session API and better docs organization 2026-04-17 16:19:23 +01:00
Eric Allam 74c8610b8d feat(chat): add composable primitives, raw task example, and task mode switcher 2026-04-17 16:19:23 +01:00
Eric Allam 3c1d9f0f34 feat(streams): add inputStream.waitWithWarmup(), warm timeout config in sidebar, preload payload option 2026-04-17 16:19:23 +01:00
Eric Allam 4de5e41d47 fix(reference): replace hand-rolled HTML stripping with turndown 2026-04-17 16:19:23 +01:00
Eric Allam 447570e8e0 feat(chat): add chat.defer(), preload toggle, TTFB measurement, and fix ChatTaskWirePayload export 2026-04-17 16:19:23 +01:00
Eric Allam 37955af9a6 feat(chat): auto-hydrate chat.local values in ai.tool subtasks 2026-04-17 16:19:23 +01:00
Eric Allam 5b3d381633 docs: add sequence diagrams to ai-chat guide 2026-04-17 16:19:23 +01:00
Eric Allam 5a7fb627e5 docs: add mermaid architecture diagrams for ai-chat system 2026-04-17 16:19:23 +01:00
Eric Allam ad291c44d2 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-04-17 16:19:23 +01:00
Eric Allam 8363b4462a 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-04-17 16:19:23 +01:00
Eric Allam 2101829404 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-04-17 16:19:23 +01:00
Eric Allam cb6d99decf Some improvements to the example ai-chat 2026-04-17 16:19:23 +01:00
Eric Allam 5b527a5439 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-04-17 16:19:23 +01:00
Eric Allam 2369297145 feat: add chat.local for per-run typed data with Proxy access and dirty tracking 2026-04-17 16:19:23 +01:00
Eric Allam 610067f29a Make clientData typesafe and pass to all chat.task hooks 2026-04-17 16:19:23 +01:00
Eric Allam 4a1a0f1701 Add triggerOptions to the transport, auto-tag with the chat ID 2026-04-17 16:19:23 +01:00
Eric Allam 600069ffa1 use locals for the chat pipe counter instead of a module global 2026-04-17 16:19:23 +01:00
Eric Allam 3ae26683a6 fixed chat tests 2026-04-17 16:19:23 +01:00
Eric Allam fb03c199a3 update pnpm link file 2026-04-17 16:19:23 +01:00
Eric Allam be405bbe28 Minor fixes around reconnecting streams 2026-04-17 16:19:23 +01:00
Eric Allam a59e37c07e feat: add onTurnStart hook, lastEventId support, and stream resume deduplication 2026-04-17 16:19:23 +01:00
Eric Allam a7b439f42e remove postinstall hook 2026-04-17 16:19:23 +01:00
Eric Allam c3d9378283 Add ai chat to the sidebar for now 2026-04-17 16:19:23 +01:00
Eric Allam 081c569401 build full example with persisting messages, adding necessary hooks, and documenting it all 2026-04-17 16:19:23 +01:00