@agent-native/core 0.68.0 → 0.68.2

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 (152) hide show
  1. package/README.md +4 -4
  2. package/corpus/README.md +2 -2
  3. package/corpus/core/CHANGELOG.md +18 -0
  4. package/corpus/core/docs/content/authentication.md +16 -2
  5. package/corpus/core/docs/content/template-analytics.md +14 -9
  6. package/corpus/core/docs/content/template-clips.md +30 -2
  7. package/corpus/core/package.json +1 -1
  8. package/corpus/core/src/agent/engine/builder-engine.ts +22 -3
  9. package/corpus/core/src/agent/engine/types.ts +1 -0
  10. package/corpus/core/src/agent/production-agent.ts +2 -0
  11. package/corpus/core/src/agent/types.ts +1 -0
  12. package/corpus/core/src/cli/pr-visual-recap-workflow.ts +1 -1
  13. package/corpus/core/src/client/AssistantChat.tsx +45 -6
  14. package/corpus/core/src/client/CommandMenu.tsx +98 -3
  15. package/corpus/core/src/client/ConnectBuilderCard.tsx +11 -2
  16. package/corpus/core/src/client/active-run-state.ts +16 -0
  17. package/corpus/core/src/client/guided-questions.tsx +73 -17
  18. package/corpus/core/src/client/index.ts +2 -0
  19. package/corpus/core/src/client/sse-event-processor.ts +9 -0
  20. package/corpus/core/src/oauth-tokens/google-refresh.ts +32 -17
  21. package/corpus/core/src/provider-api/index.ts +37 -17
  22. package/corpus/core/src/server/auth.ts +6 -8
  23. package/corpus/core/src/server/better-auth-instance.ts +19 -4
  24. package/corpus/core/src/server/core-routes-plugin.ts +157 -5
  25. package/corpus/core/src/server/google-oauth-credentials.ts +51 -0
  26. package/corpus/core/src/server/index.ts +8 -0
  27. package/corpus/core/src/server/onboarding-html.ts +2 -1
  28. package/corpus/core/src/templates/workspace-root/.env.example +4 -0
  29. package/corpus/templates/analytics/app/routes/$.tsx +9 -0
  30. package/corpus/templates/calendar/app/components/calendar/DayView.tsx +33 -1
  31. package/corpus/templates/calendar/app/components/calendar/EventAttendeesSection.tsx +11 -3
  32. package/corpus/templates/calendar/app/components/calendar/EventCard.tsx +25 -2
  33. package/corpus/templates/calendar/app/components/calendar/EventDetailPanel.tsx +12 -0
  34. package/corpus/templates/calendar/app/components/calendar/EventDetailPopover.tsx +7 -2
  35. package/corpus/templates/calendar/app/components/calendar/GoogleConnectBanner.tsx +37 -78
  36. package/corpus/templates/calendar/app/components/calendar/WeekView.tsx +33 -1
  37. package/corpus/templates/calendar/app/components/layout/Sidebar.tsx +46 -3
  38. package/corpus/templates/calendar/app/hooks/use-google-auth.ts +203 -2
  39. package/corpus/templates/calendar/app/lib/event-colors.ts +1 -4
  40. package/corpus/templates/calendar/app/lib/rsvp-status.tsx +6 -0
  41. package/corpus/templates/calendar/app/pages/CalendarView.tsx +9 -4
  42. package/corpus/templates/calendar/app/pages/NotFound.tsx +1 -1
  43. package/corpus/templates/calendar/app/pages/Settings.tsx +25 -1
  44. package/corpus/templates/calendar/app/routes/_app.$.tsx +9 -0
  45. package/corpus/templates/calendar/server/handlers/google-auth.ts +152 -12
  46. package/corpus/templates/calendar/server/lib/google-calendar.ts +63 -14
  47. package/corpus/templates/calendar/server/plugins/auth.ts +4 -20
  48. package/corpus/templates/calendar/shared/api.ts +4 -0
  49. package/corpus/templates/clips/.agents/skills/recording/SKILL.md +17 -0
  50. package/corpus/templates/clips/actions/sync-calendars.ts +6 -7
  51. package/corpus/templates/clips/app/components/capture-install-options.tsx +157 -0
  52. package/corpus/templates/clips/app/components/library/library-layout.tsx +9 -8
  53. package/corpus/templates/clips/app/components/recorder/pre-record-panel.tsx +4 -6
  54. package/corpus/templates/clips/app/lib/capture-install-options.ts +13 -0
  55. package/corpus/templates/clips/app/root.tsx +54 -2
  56. package/corpus/templates/clips/app/routes/_app.dictate.tsx +9 -13
  57. package/corpus/templates/clips/app/routes/_app.meetings.$meetingId.tsx +5 -7
  58. package/corpus/templates/clips/app/routes/_app.meetings._index.tsx +5 -7
  59. package/corpus/templates/clips/app/routes/download.tsx +49 -0
  60. package/corpus/templates/clips/app/routes/record.tsx +4 -4
  61. package/corpus/templates/clips/app/routes/share.$shareId.tsx +5 -6
  62. package/corpus/templates/clips/chrome-extension/STORE_DRAFT.md +26 -0
  63. package/corpus/templates/clips/server/lib/calendar-event-meetings.ts +6 -7
  64. package/corpus/templates/clips/server/lib/google-calendar-client.ts +61 -0
  65. package/corpus/templates/clips/server/routes/_agent-native/google/auth-url.get.ts +19 -12
  66. package/corpus/templates/clips/server/routes/_agent-native/google/callback.get.ts +6 -6
  67. package/corpus/templates/design/actions/show-design-questions.ts +15 -1
  68. package/corpus/templates/design/app/hooks/use-agent-generating.ts +47 -8
  69. package/corpus/templates/design/app/pages/DesignEditor.tsx +6 -0
  70. package/corpus/templates/design/app/pages/NotFound.tsx +1 -1
  71. package/corpus/templates/design/app/routes/$.tsx +9 -0
  72. package/corpus/templates/mail/app/pages/NotFound.tsx +1 -1
  73. package/corpus/templates/mail/app/routes/$.tsx +9 -0
  74. package/corpus/templates/plan/app/global.css +2 -2
  75. package/corpus/templates/slides/app/pages/NotFound.tsx +1 -1
  76. package/corpus/templates/slides/app/routes/$.tsx +9 -0
  77. package/corpus/templates/slides/server/lib/google-docs-oauth.ts +81 -25
  78. package/corpus/templates/videos/app/pages/NotFound.tsx +1 -1
  79. package/dist/agent/engine/builder-engine.d.ts.map +1 -1
  80. package/dist/agent/engine/builder-engine.js +21 -3
  81. package/dist/agent/engine/builder-engine.js.map +1 -1
  82. package/dist/agent/engine/types.d.ts +2 -0
  83. package/dist/agent/engine/types.d.ts.map +1 -1
  84. package/dist/agent/engine/types.js.map +1 -1
  85. package/dist/agent/production-agent.d.ts.map +1 -1
  86. package/dist/agent/production-agent.js +3 -0
  87. package/dist/agent/production-agent.js.map +1 -1
  88. package/dist/agent/types.d.ts +2 -0
  89. package/dist/agent/types.d.ts.map +1 -1
  90. package/dist/agent/types.js.map +1 -1
  91. package/dist/cli/pr-visual-recap-workflow.d.ts +1 -1
  92. package/dist/cli/pr-visual-recap-workflow.d.ts.map +1 -1
  93. package/dist/cli/pr-visual-recap-workflow.js +1 -1
  94. package/dist/cli/pr-visual-recap-workflow.js.map +1 -1
  95. package/dist/client/AssistantChat.d.ts.map +1 -1
  96. package/dist/client/AssistantChat.js +42 -7
  97. package/dist/client/AssistantChat.js.map +1 -1
  98. package/dist/client/CommandMenu.d.ts +15 -2
  99. package/dist/client/CommandMenu.d.ts.map +1 -1
  100. package/dist/client/CommandMenu.js +46 -3
  101. package/dist/client/CommandMenu.js.map +1 -1
  102. package/dist/client/ConnectBuilderCard.d.ts.map +1 -1
  103. package/dist/client/ConnectBuilderCard.js +11 -2
  104. package/dist/client/ConnectBuilderCard.js.map +1 -1
  105. package/dist/client/active-run-state.d.ts +2 -0
  106. package/dist/client/active-run-state.d.ts.map +1 -1
  107. package/dist/client/active-run-state.js +10 -0
  108. package/dist/client/active-run-state.js.map +1 -1
  109. package/dist/client/guided-questions.d.ts +2 -0
  110. package/dist/client/guided-questions.d.ts.map +1 -1
  111. package/dist/client/guided-questions.js +52 -7
  112. package/dist/client/guided-questions.js.map +1 -1
  113. package/dist/client/index.d.ts +1 -1
  114. package/dist/client/index.d.ts.map +1 -1
  115. package/dist/client/index.js.map +1 -1
  116. package/dist/client/sse-event-processor.d.ts +1 -1
  117. package/dist/client/sse-event-processor.d.ts.map +1 -1
  118. package/dist/client/sse-event-processor.js +7 -1
  119. package/dist/client/sse-event-processor.js.map +1 -1
  120. package/dist/oauth-tokens/google-refresh.d.ts.map +1 -1
  121. package/dist/oauth-tokens/google-refresh.js +29 -17
  122. package/dist/oauth-tokens/google-refresh.js.map +1 -1
  123. package/dist/provider-api/index.d.ts.map +1 -1
  124. package/dist/provider-api/index.js +28 -16
  125. package/dist/provider-api/index.js.map +1 -1
  126. package/dist/server/auth.d.ts.map +1 -1
  127. package/dist/server/auth.js +6 -6
  128. package/dist/server/auth.js.map +1 -1
  129. package/dist/server/better-auth-instance.d.ts.map +1 -1
  130. package/dist/server/better-auth-instance.js +18 -4
  131. package/dist/server/better-auth-instance.js.map +1 -1
  132. package/dist/server/core-routes-plugin.d.ts +5 -0
  133. package/dist/server/core-routes-plugin.d.ts.map +1 -1
  134. package/dist/server/core-routes-plugin.js +107 -5
  135. package/dist/server/core-routes-plugin.js.map +1 -1
  136. package/dist/server/google-oauth-credentials.d.ts +15 -0
  137. package/dist/server/google-oauth-credentials.d.ts.map +1 -0
  138. package/dist/server/google-oauth-credentials.js +34 -0
  139. package/dist/server/google-oauth-credentials.js.map +1 -0
  140. package/dist/server/index.d.ts +1 -0
  141. package/dist/server/index.d.ts.map +1 -1
  142. package/dist/server/index.js +1 -0
  143. package/dist/server/index.js.map +1 -1
  144. package/dist/server/onboarding-html.d.ts.map +1 -1
  145. package/dist/server/onboarding-html.js +2 -1
  146. package/dist/server/onboarding-html.js.map +1 -1
  147. package/dist/templates/workspace-root/.env.example +4 -0
  148. package/docs/content/authentication.md +16 -2
  149. package/docs/content/template-analytics.md +14 -9
  150. package/docs/content/template-clips.md +30 -2
  151. package/package.json +1 -1
  152. package/src/templates/workspace-root/.env.example +4 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AAEvE,yBAAyB,EAAE,CAAC;AAC5B,6BAA6B,EAAE,CAAC;AAEhC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EACL,qBAAqB,EACrB,+BAA+B,EAC/B,qBAAqB,EACrB,oCAAoC,EACpC,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC1B,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,aAAa,GASd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,qBAAqB,GAGtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,M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BAAmB,CAAC","sourcesContent":["import { installRouteChunkRecovery } from \"./route-chunk-recovery.js\";\nimport { stripAuthRedirectParamFromUrl } from \"./auth-redirect-url.js\";\n\ninstallRouteChunkRecovery();\nstripAuthRedirectParamFromUrl();\n\nexport { getBrowserTabId } from \"./browser-tab-id.js\";\n\nexport {\n addContextToAgentChat,\n appendAgentChatContextToMessage,\n clearAgentChatContext,\n formatAgentChatContextItemsForPrompt,\n listAgentChatContext,\n refreshAgentChatContext,\n removeAgentChatContextItem,\n sendToAgentChat,\n parseSubmitChatMessage,\n setAgentChatContextItem,\n setContextToAgentChat,\n generateTabId,\n type ParsedSubmitChat,\n type AgentChatContextItem,\n type AgentChatContextMessage,\n type AgentChatContextMutationOptions,\n type AgentChatContextRemoveOptions,\n type AgentChatContextSetOptions,\n type AgentChatContextState,\n type AgentChatMessage,\n} from \"./agent-chat.js\";\nexport {\n saveAgentEngineApiKey,\n type AgentEngineProvider,\n type SaveAgentEngineApiKeyOptions,\n} from \"./agent-engine-key.js\";\nexport { useAgentChatGenerating } from \"./use-agent-chat.js\";\nexport {\n useAgentChatContext,\n type UseAgentChatContextResult,\n} from \"./use-agent-chat-context.js\";\nexport { useCodeMode, useDevMode } from \"./use-dev-mode.js\";\nexport {\n agentNativePath,\n appApiPath,\n appBasePath,\n appPath,\n} from \"./api-path.js\";\nexport {\n deleteClientAppState,\n readClientAppState,\n setClientAppState,\n writeClientAppState,\n type ClientAppStateReadOptions,\n type ClientAppStateWriteOptions,\n} from \"./application-state.js\";\nexport {\n useAgentRouteState,\n useSemanticNavigationState,\n type AgentRouteLocation,\n type SemanticNavigationCommandEnvelope,\n type UseAgentRouteStateOptions,\n type UseAgentRouteStateResult,\n type UseSemanticNavigationStateOptions,\n type UseSemanticNavigationStateResult,\n} from \"./route-state.js\";\nexport {\n ensureEmbedAuthFetchInterceptor,\n getEmbedAuthToken,\n isEmbedAuthActive,\n isEmbedMcpChatBridgeActive,\n} from \"./embed-auth.js\";\nexport {\n codeAgentTranscriptEventsToContent,\n createCodeAgentChatAdapter,\n type CodeAgentChatController,\n type CodeAgentChatControlResult,\n type CodeAgentChatFollowUpMode,\n type CodeAgentChatTranscriptEvent,\n type CreateCodeAgentChatAdapterOptions,\n} from \"./code-agent-chat-adapter.js\";\nexport {\n buildRepositoryFromCodeAgentTranscript,\n type BuildRepositoryFromCodeAgentTranscriptOptions,\n type CodeAgentThreadTranscriptEvent,\n} from \"../agent/thread-data-builder.js\";\nexport {\n compareCodeAgentTranscriptEvents,\n getCodeAgentTranscriptSeq,\n isCodeAgentRunActive,\n mergeCodeAgentTranscriptEvents,\n type CodeAgentRunStateLike,\n type CodeAgentTranscriptOrderEvent,\n} from \"../code-agents/transcript-order.js\";\nexport { useSendToAgentChat } from \"./use-send-to-agent-chat.js\";\nexport {\n useChatModels,\n type UseChatModelsResult,\n type EngineModelGroup,\n} from \"./use-chat-models.js\";\nexport {\n CodeRequiredDialog,\n type CodeRequiredDialogProps,\n} from \"./components/CodeRequiredDialog.js\";\nexport {\n useAgentEngineConfigured,\n type AgentEngineConfiguredState,\n type UseAgentEngineConfiguredResult,\n} from \"./use-agent-engine-configured.js\";\nexport { BuilderSetupCard } from \"./chat/run-recovery.js\";\nexport {\n AgentConversation,\n AgentConversationMessageView,\n normalizeCodeAgentTranscriptForConversation,\n useNearBottomAutoscroll,\n type CodeAgentConversationTranscriptEvent,\n type CodeAgentConversationTranscriptEventType,\n type NormalizeCodeAgentTranscriptOptions,\n type AgentConversationArtifact,\n type AgentConversationAttachment,\n type AgentConversationMessage,\n type AgentConversationMessagePart,\n type AgentConversationMessageRole,\n type AgentConversationNotice,\n type AgentConversationNoticeTone,\n type AgentConversationToolCall,\n type AgentConversationToolState,\n} from \"./conversation/index.js\";\nexport { McpAppRenderer } from \"./mcp-apps/McpAppRenderer.js\";\nexport {\n AGENT_NATIVE_MCP_APP_HOST_MESSAGE_TYPES,\n getMcpAppHostContext,\n openMcpAppHostLink,\n requestMcpAppDisplayMode,\n sendMcpAppHostMessage,\n updateMcpAppModelContext,\n useMcpAppHostContext,\n type AgentNativeMcpAppHostMessageType,\n type McpAppDisplayMode,\n type McpAppHostChatMessage,\n type McpAppHostCapabilities,\n type McpAppHostContext,\n type McpAppHostContextSnapshot,\n type McpAppModelContextContentPart,\n type McpAppModelContextUpdate,\n} from \"./mcp-app-host.js\";\nexport {\n CodeAgentIndicator,\n type CodeAgentIndicatorProps,\n} from \"./components/CodeAgentIndicator.js\";\nexport {\n useDbSync,\n useFileWatcher,\n useScreenRefreshKey,\n} from \"./use-db-sync.js\";\nexport {\n useChangeVersion,\n useChangeVersions,\n getChangeVersion,\n bumpChangeVersion,\n} from \"./use-change-version.js\";\nexport { useReconciledState } from \"./use-external-value.js\";\nexport {\n buildDynamicAgentSuggestions,\n dedupeSuggestions,\n mergeAgentSuggestions,\n normalizeAgentDynamicSuggestionsConfig,\n useAgentDynamicSuggestions,\n type AgentDynamicSuggestionContext,\n type AgentDynamicSuggestionsConfig,\n type AgentDynamicSuggestionsOption,\n} from \"./dynamic-suggestions.js\";\nexport { cn } from \"./utils.js\";\nexport {\n // Shared editor core (Phase 1): the ONE configurable surface both the plan\n // and content editors build on.\n SharedRichEditor,\n createSharedEditorExtensions,\n MARKDOWN_DIALECT_CONFIG,\n useCollabReconcile,\n RICH_MARKDOWN_PROGRAMMATIC_TRANSACTION,\n getEditorMarkdown,\n SlashCommandMenu,\n DEFAULT_SLASH_COMMANDS,\n createImageSlashCommand,\n // Shared block-level image node + injectable upload contract. Plans opt in\n // via `features.image` + `onImageUpload`; Content keeps its own image block.\n SharedImage,\n createImageExtension,\n pickAndInsertImage,\n uploadEditorImage,\n BubbleToolbar,\n buildDefaultBubbleItems,\n // Back-compat alias + factory kept for existing embedders and specs.\n RichMarkdownEditor,\n createRichMarkdownExtensions,\n // Single-doc plan editor primitives: the GFM↔ProseMirror serializer, the\n // run-id prose attribute, and the shared drag-handle (block grip + reorder).\n RunId,\n RUN_ID_NODE_TYPES,\n gfmToProseJSON,\n proseJSONToGfm,\n DragHandle,\n DEFAULT_DRAG_HANDLE_WRAPPER_SELECTOR,\n // Generic registry-block Tiptap NodeView + side-map provider + dedupe plugin.\n // Hosts mount the node from `createRegistryBlockNode` as an extra extension\n // and wrap the editor in `RegistryBlockDataProvider`.\n createRegistryBlockNode,\n RegistryBlockNodeView,\n RegistryBlockDataProvider,\n useRegistryBlockData,\n // Shared registry-derived block slash-command builder (plan + content adapt it).\n buildRegistryBlockSlashItems,\n getRegistryBlockSlashDescription,\n getRegistryBlockSlashSearchText,\n type BuildRegistryBlockSlashItemsOptions,\n type DragHandleDropContext,\n type DragHandleDropPlacement,\n type DragHandleOptions,\n type CreateRegistryBlockNodeOptions,\n type RegistryBlockDataValue,\n type RegistryBlockSideMapBlock,\n type SharedRichEditorProps,\n type SharedEditorCollab,\n type SharedEditorFeatures,\n type CreateSharedEditorExtensionsOptions,\n type UseCollabReconcileOptions,\n type UseCollabReconcileResult,\n type SlashCommandItem,\n type SlashCommandMenuProps,\n type ImageUploadFn,\n type SharedImageOptions,\n type BubbleToolbarItem,\n type BubbleToolbarProps,\n type RichMarkdownDialect,\n type RichMarkdownEditorPreset,\n type RichMarkdownEditorProps,\n type RichMarkdownCollabUser,\n type CreateRichMarkdownExtensionsOptions,\n} from \"./rich-markdown-editor/index.js\";\n// ProseMirror node JSON shape — re-exported so the plan template (which has no\n// direct @tiptap dep) can type its doc↔blocks serializer.\nexport type { JSONContent } from \"@tiptap/core\";\nexport { ApiKeySettings } from \"./components/ApiKeySettings.js\";\nexport { useSession, type AuthSession } from \"./use-session.js\";\nexport {\n RequireSession,\n buildSignInReturnHref,\n type RequireSessionProps,\n} from \"./require-session.js\";\nexport {\n sendToFrame,\n onFrameMessage,\n requestUserInfo,\n getFrameOrigin,\n getFramePostMessageTargetOrigin,\n getCallbackOrigin,\n oauthRedirectUri,\n isInFrame,\n enterStyleEditing,\n enterTextEditing,\n exitSelectionMode,\n type UserInfo,\n} from \"./frame.js\";\nexport {\n getBuilderParentOrigin,\n isInBuilderFrame,\n sendToBuilderChat,\n type BuilderChatMessage,\n} from \"./builder-frame.js\";\nexport {\n AgentNative,\n useAgentNativeScreenContext,\n type AgentNativeCommandCallback,\n type AgentNativeCommandCallbackInfo,\n type AgentNativeProps,\n} from \"./AgentNative.js\";\nexport {\n AgentNativeEmbedded,\n useAgentNativeEmbeddedBrowserSession,\n type AgentNativeEmbeddedBrowserSessionOptions,\n type AgentNativeEmbeddedCommandCallback,\n type AgentNativeEmbeddedCommandCallbackInfo,\n type AgentNativeEmbeddedProps,\n type UseAgentNativeEmbeddedBrowserSessionOptions,\n} from \"./AgentNativeEmbedded.js\";\nexport {\n defineClientAction,\n type AgentNativeClientActionDefinition,\n type AgentNativeClientActionRunner,\n} from \"./client-action.js\";\nexport {\n AgentNativeFrame,\n type AgentNativeFrameProps,\n} from \"./AgentNativeFrame.js\";\nexport {\n AgentNativeRouteWarmup,\n type AgentNativeRouteWarmupProps,\n} from \"./route-warmup.js\";\nexport {\n AgentNativeExtensionFrame,\n AgentNativeExtensionSlot,\n type AgentNativeExtensionFrameProps,\n type AgentNativeExtensionPermissionList,\n type AgentNativeExtensionSlotProps,\n type AgentNativeExtensionStorageScopeList,\n} from \"./extensions/AgentNativeExtensionFrame.js\";\nexport {\n AGENT_NATIVE_EXTENSION_MESSAGE_TYPES,\n buildAgentNativeExtensionHtml,\n createHttpAgentNativeExtensionStorage,\n createLocalStorageAgentNativeExtensionStorage,\n getAgentNativeExtensionManifest,\n isAgentNativeExtensionAllowedInSlot,\n normalizeAgentNativeExtensionSandbox,\n type AgentNativeExtensionDefinition,\n type AgentNativeExtensionManifest,\n type AgentNativeExtensionMessageType,\n type AgentNativeExtensionStorage,\n type AgentNativeExtensionStorageContext,\n type AgentNativeExtensionStorageOptions,\n type AgentNativeExtensionStorageRow,\n type AgentNativeExtensionStorageScope,\n type BuildAgentNativeExtensionHtmlOptions,\n type CreateHttpAgentNativeExtensionStorageOptions,\n} from \"./extensions/portable-extension.js\";\nexport {\n AGENT_NATIVE_HOST_BRIDGE_VERSION,\n AGENT_NATIVE_HOST_MESSAGE_TYPES,\n announceAgentNativeFrameReady,\n createAgentNativeHostBridge,\n defaultAgentNativeHostCommands,\n onAgentNativeHostInit,\n readAgentNativeScreenContext,\n requestAgentNativeHostActions,\n requestAgentNativeHostContext,\n runAgentNativeHostAction,\n sendAgentNativeHostCommand,\n type AgentNativeActionAvailability,\n type AgentNativeActionManifestEntry,\n type AgentNativeClientAction,\n type AgentNativeClientActionApprovalConfig,\n type AgentNativeClientActionGetter,\n type AgentNativeClientActionRuntime,\n type AgentNativeClientActions,\n type AgentNativeHostAuth,\n type AgentNativeHostAuthPayload,\n type AgentNativeHostBridge,\n type AgentNativeHostBridgeEvent,\n type AgentNativeHostBridgeOptions,\n type AgentNativeHostCapabilities,\n type AgentNativeHostCommandHandler,\n type AgentNativeHostCommandHandlers,\n type AgentNativeHostCommandRequest,\n type AgentNativeHostContext,\n type AgentNativeHostContextGetter,\n type AgentNativeHostInit,\n type AgentNativeHostMessageType,\n type AgentNativeHostRequestOptions,\n type AgentNativeHostResourceContext,\n type AgentNativeHostRouteContext,\n type AgentNativeHostSelectionContext,\n type AgentNativeHostSession,\n type AgentNativeJsonSchema,\n type AgentNativeScreenSnapshot,\n type AgentNativeScreenSnapshotOptions,\n type BuiltInAgentNativeHostCommand,\n} from \"./host-bridge.js\";\nexport {\n AGENT_NATIVE_HOST_TOOL_NAMES,\n createAgentNativeHostTools,\n type AgentNativeHostToolDefinition,\n type AgentNativeHostToolName,\n type AgentNativeHostToolParameters,\n type AgentNativeHostToolSet,\n type CreateAgentNativeHostToolsOptions,\n type RunAgentNativeHostActionToolInput,\n type SendAgentNativeHostCommandToolInput,\n} from \"./host-tools.js\";\nexport {\n createAgentNativeBrowserSessionBridge,\n startAgentNativeBrowserSessionBridge,\n type AgentNativeBrowserSessionBridge,\n type AgentNativeBrowserSessionBridgeOptions,\n} from \"./browser-session-bridge.js\";\nexport type {\n AgentNativeBrowserSession,\n AgentNativeBrowserSessionAction,\n AgentNativeBrowserSessionRecord,\n AgentNativeBrowserSessionRequest,\n AgentNativeBrowserSessionRequestStatus,\n AgentNativeBrowserSessionRequestType,\n CreateAgentNativeBrowserSessionRequestInput,\n RegisterAgentNativeBrowserSessionInput,\n} from \"../browser-sessions/types.js\";\nexport {\n NewWorkspaceAppFlow,\n type NewWorkspaceAppFlowProps,\n type VaultSecretOption,\n} from \"./NewWorkspaceAppFlow.js\";\nexport {\n AssistantChat,\n clearChatStorage,\n type AssistantChatProps,\n type AssistantChatHandle,\n type AssistantChatAdapterContext,\n} from \"./AssistantChat.js\";\nexport {\n MultiTabAssistantChat,\n type MultiTabAssistantChatProps,\n type MultiTabAssistantChatHeaderProps,\n} from \"./MultiTabAssistantChat.js\";\nexport { RunStuckBanner, type RunStuckBannerProps } from \"./RunStuckBanner.js\";\nexport {\n useRunStuckDetection,\n useAbortRun,\n type RunStuckState,\n type UseRunStuckDetectionOptions,\n} from \"./use-run-stuck-detection.js\";\nexport {\n createAgentChatAdapter,\n type AgentChatSurfaceKind,\n type CreateAgentChatAdapterOptions,\n} from \"./agent-chat-adapter.js\";\nexport {\n AgentComposerFrame,\n type AgentComposerFrameProps,\n PromptComposer,\n TiptapComposer,\n AGENT_PROMPT_MAX_INLINE_IMAGE_BYTES,\n AGENT_PROMPT_MAX_INLINE_TEXT_CHARS,\n escapePromptAttachmentAttribute,\n formatPromptWithAttachments,\n isInlineableAgentPromptFile,\n readAgentPromptAttachment,\n type PromptComposerProps,\n type PromptComposerFile,\n type PromptComposerSubmitOptions,\n type ComposerSubmitIntent,\n type AgentPromptAttachment,\n type ReadAgentPromptAttachmentOptions,\n type AgentComposerLayoutVariant,\n type SlashCommand,\n type SkillResult,\n type TiptapComposerHandle,\n type TiptapComposerProps,\n type TiptapComposerSubmitOptions,\n} from \"./composer/index.js\";\nexport {\n GuidedQuestionFlow,\n useGuidedQuestionFlow,\n askUserQuestion,\n formatGuidedAnswerValue,\n formatGuidedAnswersForAgent,\n getOtherGuidedAnswerText,\n hasGuidedAnswer,\n isOtherGuidedAnswer,\n makeOtherGuidedAnswer,\n normalizeGuidedAnswers,\n type AskUserQuestionInput,\n type AskUserQuestionOption,\n type AskUserQuestionResult,\n type GuidedQuestion,\n type GuidedQuestionAnswers,\n type GuidedQuestionFlowProps,\n type GuidedQuestionOption,\n type GuidedQuestionPayload,\n type GuidedQuestionType,\n type UseGuidedQuestionFlowOptions,\n} from \"./guided-questions.js\";\nexport {\n useChatThreads,\n type ChatThreadScope,\n type ChatThreadSnapshot,\n type ChatThreadSummary,\n type ChatThreadData,\n type ChatThreadShareLink,\n type ChatThreadShareState,\n type UseChatThreadsOptions,\n} from \"./use-chat-threads.js\";\nexport { AgentChatHome, type AgentChatHomeProps } from \"./AgentChatHome.js\";\nexport {\n AgentChatSurface,\n AgentPanel,\n AgentSidebar,\n AgentToggleButton,\n focusAgentChat,\n type AgentChatSurfaceMode,\n type AgentChatSurfaceProps,\n type AgentPanelProps,\n type AgentSidebarProps,\n} from \"./AgentPanel.js\";\nexport {\n AGENT_CHAT_HOME_HANDOFF_TTL_MS,\n AGENT_CHAT_VIEW_TRANSITION_CLASS,\n AGENT_CHAT_VIEW_TRANSITION_NAME,\n consumeAgentChatHomeHandoff,\n getAgentChatViewTransitionStyle,\n markAgentChatHomeHandoff,\n navigateWithAgentChatViewTransition,\n startAgentChatViewTransition,\n supportsAgentChatViewTransition,\n type AgentChatHomeHandoffOptions,\n type AgentChatViewTransition,\n type AgentChatViewTransitionOptions,\n} from \"./chat-view-transition.js\";\nexport {\n useAgentChatHomeHandoff,\n useAgentChatHomeHandoffLinks,\n type UseAgentChatHomeHandoffLinksOptions,\n type UseAgentChatHomeHandoffOptions,\n} from \"./use-agent-chat-home-handoff.js\";\nexport {\n requestAgentSidebarOpen,\n SIDEBAR_STATE_CHANGE_EVENT,\n setAgentSidebarOpenPreference,\n type AgentSidebarStateChangeDetail,\n type AgentSidebarStateMode,\n type AgentSidebarStateSource,\n} from \"./agent-sidebar-state.js\";\nexport {\n clearReservedToolRenderersForTests,\n clearToolRenderersForTests,\n registerActionChatRenderer,\n registerFallbackToolRenderer,\n registerReservedActionChatRenderer,\n registerReservedFallbackToolRenderer,\n registerReservedToolRenderer,\n registerToolRenderer,\n resolveToolRenderer,\n type ActionChatRendererRegistration,\n type ToolRendererComponent,\n type ToolRendererContext,\n type ToolRendererMatch,\n type ToolRendererProps,\n type ToolRendererRegistration,\n} from \"./chat/tool-render-registry.js\";\nexport * from \"./chat/connectors.js\";\nexport * from \"./chat/runtime.js\";\nexport {\n ACTION_CHAT_UI_DATA_CHART_RENDERER,\n ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER,\n ACTION_CHAT_UI_DATA_TABLE_RENDERER,\n ACTION_CHAT_UI_DATA_WIDGET_RENDERER,\n type ActionChatUIConfig,\n} from \"../action-ui.js\";\nexport {\n DATA_CHART_WIDGET,\n DATA_INSIGHTS_WIDGET,\n DATA_TABLE_WIDGET,\n createDataChartWidgetResult,\n createDataInsightsWidgetResult,\n createDataTableWidgetResult,\n dataChartWidgetResultSchema,\n dataChartWidgetSchema,\n dataInsightsWidgetResultSchema,\n dataTableWidgetResultSchema,\n dataTableWidgetSchema,\n dataWidgetResultSchema,\n isDataChartWidget,\n isDataTableWidget,\n isDataWidgetResult,\n normalizeDataWidgetKind,\n normalizeDataWidgetResult,\n type DataChartSeriesDefinition,\n type DataChartWidget,\n type DataChartWidgetResult,\n type DataChartWidgetResultInput,\n type DataInsightsWidgetResult,\n type DataInsightsWidgetResultInput,\n type DataTableColumn,\n type DataTableWidget,\n type DataTableWidgetResult,\n type DataTableWidgetResultInput,\n type DataWidgetDisplay,\n type DataWidgetKind,\n type DataWidgetResult,\n type DataWidgetResultMetadata,\n} from \"./chat/widgets/data-widget-types.js\";\nexport { AgentNativeIcon } from \"./components/icons/AgentNativeIcon.js\";\nexport { SettingsPanel, type SettingsPanelProps } from \"./settings/index.js\";\nexport { useBuilderStatus } from \"./settings/useBuilderStatus.js\";\nexport {\n openBuilderConnectPopup,\n useBuilderConnectFlow,\n type BuilderConnectFlow,\n type BuilderConnectFlowOptions,\n type OpenBuilderConnectPopupOptions,\n} from \"./settings/useBuilderStatus.js\";\n// Deprecated — use AgentSidebar + AgentToggleButton instead\nexport {\n ProductionAgentPanel,\n type ProductionAgentPanelProps,\n} from \"./ProductionAgentPanel.js\";\nexport {\n useProductionAgent,\n type ProductionAgentMessage,\n type UseProductionAgentOptions,\n type UseProductionAgentResult,\n} from \"./useProductionAgent.js\";\nexport { Turnstile, type TurnstileProps } from \"./Turnstile.js\";\nexport {\n OpenSourceBadge,\n PoweredByBadge,\n type OpenSourceBadgeProps,\n type PoweredByBadgeProps,\n} from \"./PoweredByBadge.js\";\nexport {\n StarfieldBackground,\n type StarfieldBackgroundProps,\n} from \"./StarfieldBackground.js\";\nexport { FeedbackButton, type FeedbackButtonProps } from \"./FeedbackButton.js\";\nexport {\n DevDatabaseLink,\n type DevDatabaseLinkProps,\n} from \"./db-admin/DevDatabaseLink.js\";\nexport { ErrorBoundary } from \"./ErrorBoundary.js\";\nexport {\n installRouteChunkRecovery,\n reloadForStaleChunk,\n recoverFromStaleChunkError,\n} from \"./route-chunk-recovery.js\";\nexport { ClientOnly } from \"./ClientOnly.js\";\nexport { DefaultSpinner } from \"./DefaultSpinner.js\";\nexport {\n getThemeInitScript,\n themeInitScript,\n type ThemePreference,\n} from \"./theme.js\";\nexport {\n APPEARANCE_PRESETS,\n applyAppearance,\n getStoredAppearance,\n useAppearance,\n useAppearanceSync,\n type AppearancePresetId,\n} from \"./appearance.js\";\nexport {\n AppearancePicker,\n type AppearancePickerProps,\n} from \"./AppearancePicker.js\";\nexport { AgentTerminal, type AgentTerminalProps } from \"./terminal/index.js\";\nexport {\n trackEvent,\n trackSessionStatus,\n configureTracking,\n setSentryUser,\n captureError,\n captureClientException,\n type ClientCaptureContext,\n} from \"./analytics.js\";\nexport { track } from \"./track.js\";\nexport {\n useCollaborativeDoc,\n isReconcileLeadClient,\n emailToColor,\n emailToName,\n dedupeCollabUsersByEmail,\n type UseCollaborativeDocOptions,\n type UseCollaborativeDocResult,\n type CollabUser,\n} from \"../collab/client.js\";\nexport { AGENT_CLIENT_ID } from \"../collab/agent-identity.js\";\n// Presence kit\nexport {\n usePresence,\n toNormalized,\n fromNormalized,\n type OtherPresence,\n type PresencePayload,\n type UsePresenceResult,\n type NormalizedPoint,\n} from \"../collab/presence.js\";\nexport {\n useFollowUser,\n type UseFollowUserOptions,\n type UseFollowUserResult,\n type ViewportDescriptor,\n} from \"../collab/follow-mode.js\";\nexport {\n ResourcesPanel,\n ResourceTree,\n ResourceEditor,\n useResources,\n useResourceTree,\n useResource,\n useCreateResource,\n useUpdateResource,\n useDeleteResource,\n useUploadResource,\n type Resource,\n type ResourceMeta,\n type TreeNode,\n type ResourceScope,\n type ResourceTreeProps,\n type ResourceEditorProps,\n} from \"./resources/index.js\";\nexport type {\n AppToFrameMessage,\n FrameToAppMessage,\n FrameMessage,\n CodeCompleteMessage,\n ChatRunningMessage,\n} from \"./frame-protocol.js\";\nexport {\n CommandMenu,\n useCommandMenuShortcut,\n openAgentSidebar,\n submitToAgent,\n type CommandMenuProps,\n type CommandGroupProps,\n type CommandItemProps,\n type CommandShortcutProps,\n} from \"./CommandMenu.js\";\nexport {\n DevOverlay,\n useDevOverlayShortcut,\n registerDevPanel,\n unregisterDevPanel,\n listDevPanels,\n subscribeDevPanels,\n useDevOption,\n clearAllDevOverlayStorage,\n devOptionKey,\n DEV_OVERLAY_STORAGE_PREFIX,\n type DevOverlayProps,\n type DevPanel,\n type DevOption,\n type DevBooleanOption,\n type DevSelectOption,\n type DevStringOption,\n type DevActionOption,\n type DevOptionValue,\n} from \"./dev-overlay/index.js\";\nexport {\n callAction,\n useActionQuery,\n useActionMutation,\n type ActionRegistry,\n type ClientActionCallOptions,\n type ClientActionMethod,\n} from \"./use-action.js\";\nexport { createAgentNativeQueryClient } from \"./create-query-client.js\";\nexport { AppProviders, type AppProvidersProps } from \"./app-providers.js\";\nexport { usePinchZoom, type UsePinchZoomOptions } from \"./use-pinch-zoom.js\";\nexport {\n ShareButton,\n ShareDialog,\n VisibilityBadge,\n type ShareButtonProps,\n type ShareDialogProps,\n type VisibilityBadgeProps,\n} from \"./sharing/index.js\";\nexport {\n postNavigate,\n isInAgentEmbed,\n AGENT_NAVIGATE_MESSAGE_TYPE,\n type AgentNavigateMessage,\n} from \"./embed.js\";\nexport { IframeEmbed, parseEmbedBody } from \"./IframeEmbed.js\";\nexport {\n useAvatarUrl,\n uploadAvatar,\n invalidateAvatarCache,\n} from \"./use-avatar.js\";\nexport {\n ObservabilityDashboard,\n ThumbsFeedback,\n} from \"./observability/index.js\";\n// Presence UI components\nexport {\n PresenceBar,\n type PresenceBarProps,\n} from \"./components/PresenceBar.js\";\nexport {\n AgentPresenceChip,\n type AgentPresenceChipProps,\n} from \"./components/AgentPresenceChip.js\";\nexport {\n LiveCursorOverlay,\n type LiveCursorOverlayProps,\n type CursorMapFn,\n} from \"./components/LiveCursorOverlay.js\";\nexport {\n RemoteSelectionRings,\n type RemoteSelectionRingsProps,\n} from \"./components/RemoteSelectionRings.js\";\n// Structured data collaboration hooks\nexport {\n useCollaborativeMap,\n useCollaborativeArray,\n type UseCollaborativeMapOptions,\n type UseCollaborativeMapResult,\n type UseCollaborativeArrayOptions,\n type UseCollaborativeArrayResult,\n} from \"../collab/client-struct.js\";\nexport { NotificationsBell } from \"./notifications/index.js\";\n// Block registry (also available as the dedicated `@agent-native/core/blocks`\n// subpath, which server/agent code should prefer via `/blocks/server`).\nexport {\n defineBlock,\n BlockRegistry,\n registerBlocks,\n BlockRegistryProvider,\n useBlockRegistry,\n useOptionalBlockRegistry,\n BlockView,\n SchemaBlockEditor,\n markdown,\n richtext,\n introspect,\n serializeSpecBlock,\n parseSpecBlock,\n createAttrReader,\n describeBlocksForAgent,\n renderBlockVocabularyReference,\n type BlockSpec,\n type BlockPlacement,\n type BlockMdxConfig,\n type BlockAttrReader,\n type BlockRenderContext,\n type BlockReadProps,\n type BlockEditProps,\n type MdxAttrValue,\n type FieldKind,\n type FieldDescriptor,\n type MdxJsxNode,\n type MdxAttrNode,\n type SerializableBlock,\n type ParsedBlockBase,\n type BlockAgentDoc,\n} from \"./blocks/index.js\";\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/client/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACtE,OAAO,EAAE,6BAA6B,EAAE,MAAM,wBAAwB,CAAC;AAEvE,yBAAyB,EAAE,CAAC;AAC5B,6BAA6B,EAAE,CAAC;AAEhC,OAAO,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO,EACL,qBAAqB,EACrB,+BAA+B,EAC/B,qBAAqB,EACrB,oCAAoC,EACpC,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC1B,eAAe,EACf,sBAAsB,EACtB,uBAAuB,EACvB,qBAAqB,EACrB,aAAa,GASd,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,qBAAqB,GAGtB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAC7D,OAAO,EACL,mBAAmB,GAEpB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC5D,OAAO,EACL,eAAe,EACf,UAAU,EACV,WAAW,EACX,OAAO,GACR,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,oBAAoB,EACpB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,GAGpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,kBAAkB,EAClB,0BAA0B,GAO3B,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,+BAA+B,EAC/B,iBAAiB,EACjB,iBAAiB,EACjB,0BAA0B,GAC3B,MAAM,iBA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AC;AAC/D,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,qBAAqB,GACtB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,sBAAsB,EACtB,cAAc,GACf,MAAM,0BAA0B,CAAC;AAClC,yBAAyB;AACzB,OAAO,EACL,WAAW,GAEZ,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,iBAAiB,GAElB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,iBAAiB,GAGlB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,oBAAoB,GAErB,MAAM,sCAAsC,CAAC;AAC9C,sCAAsC;AACtC,OAAO,EACL,mBAAmB,EACnB,qBAAqB,GAKtB,MAAM,4BAA4B,CAAC;AACpC,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,8EAA8E;AAC9E,wEAAwE;AACxE,OAAO,EACL,WAAW,EACX,aAAa,EACb,cAAc,EACd,qBAAqB,EACrB,gBAAgB,EAChB,wBAAwB,EACxB,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,gBAAgB,EAChB,sBAAsB,EACtB,8BAA8B,GAgB/B,MAAM,mBAAmB,CAAC","sourcesContent":["import { installRouteChunkRecovery } from \"./route-chunk-recovery.js\";\nimport { stripAuthRedirectParamFromUrl } from \"./auth-redirect-url.js\";\n\ninstallRouteChunkRecovery();\nstripAuthRedirectParamFromUrl();\n\nexport { getBrowserTabId } from \"./browser-tab-id.js\";\n\nexport {\n addContextToAgentChat,\n appendAgentChatContextToMessage,\n clearAgentChatContext,\n formatAgentChatContextItemsForPrompt,\n listAgentChatContext,\n refreshAgentChatContext,\n removeAgentChatContextItem,\n sendToAgentChat,\n parseSubmitChatMessage,\n setAgentChatContextItem,\n setContextToAgentChat,\n generateTabId,\n type ParsedSubmitChat,\n type AgentChatContextItem,\n type AgentChatContextMessage,\n type AgentChatContextMutationOptions,\n type AgentChatContextRemoveOptions,\n type AgentChatContextSetOptions,\n type AgentChatContextState,\n type AgentChatMessage,\n} from \"./agent-chat.js\";\nexport {\n saveAgentEngineApiKey,\n type AgentEngineProvider,\n type SaveAgentEngineApiKeyOptions,\n} from \"./agent-engine-key.js\";\nexport { useAgentChatGenerating } from \"./use-agent-chat.js\";\nexport {\n useAgentChatContext,\n type UseAgentChatContextResult,\n} from \"./use-agent-chat-context.js\";\nexport { useCodeMode, useDevMode } from \"./use-dev-mode.js\";\nexport {\n agentNativePath,\n appApiPath,\n appBasePath,\n appPath,\n} from \"./api-path.js\";\nexport {\n deleteClientAppState,\n readClientAppState,\n setClientAppState,\n writeClientAppState,\n type ClientAppStateReadOptions,\n type ClientAppStateWriteOptions,\n} from \"./application-state.js\";\nexport {\n useAgentRouteState,\n useSemanticNavigationState,\n type AgentRouteLocation,\n type SemanticNavigationCommandEnvelope,\n type UseAgentRouteStateOptions,\n type UseAgentRouteStateResult,\n type UseSemanticNavigationStateOptions,\n type UseSemanticNavigationStateResult,\n} from \"./route-state.js\";\nexport {\n ensureEmbedAuthFetchInterceptor,\n getEmbedAuthToken,\n isEmbedAuthActive,\n isEmbedMcpChatBridgeActive,\n} from \"./embed-auth.js\";\nexport {\n codeAgentTranscriptEventsToContent,\n createCodeAgentChatAdapter,\n type CodeAgentChatController,\n type CodeAgentChatControlResult,\n type CodeAgentChatFollowUpMode,\n type CodeAgentChatTranscriptEvent,\n type CreateCodeAgentChatAdapterOptions,\n} from \"./code-agent-chat-adapter.js\";\nexport {\n buildRepositoryFromCodeAgentTranscript,\n type BuildRepositoryFromCodeAgentTranscriptOptions,\n type CodeAgentThreadTranscriptEvent,\n} from \"../agent/thread-data-builder.js\";\nexport {\n compareCodeAgentTranscriptEvents,\n getCodeAgentTranscriptSeq,\n isCodeAgentRunActive,\n mergeCodeAgentTranscriptEvents,\n type CodeAgentRunStateLike,\n type CodeAgentTranscriptOrderEvent,\n} from \"../code-agents/transcript-order.js\";\nexport { useSendToAgentChat } from \"./use-send-to-agent-chat.js\";\nexport {\n useChatModels,\n type UseChatModelsResult,\n type EngineModelGroup,\n} from \"./use-chat-models.js\";\nexport {\n CodeRequiredDialog,\n type CodeRequiredDialogProps,\n} from \"./components/CodeRequiredDialog.js\";\nexport {\n useAgentEngineConfigured,\n type AgentEngineConfiguredState,\n type UseAgentEngineConfiguredResult,\n} from \"./use-agent-engine-configured.js\";\nexport { BuilderSetupCard } from \"./chat/run-recovery.js\";\nexport {\n AgentConversation,\n AgentConversationMessageView,\n normalizeCodeAgentTranscriptForConversation,\n useNearBottomAutoscroll,\n type CodeAgentConversationTranscriptEvent,\n type CodeAgentConversationTranscriptEventType,\n type NormalizeCodeAgentTranscriptOptions,\n type AgentConversationArtifact,\n type AgentConversationAttachment,\n type AgentConversationMessage,\n type AgentConversationMessagePart,\n type AgentConversationMessageRole,\n type AgentConversationNotice,\n type AgentConversationNoticeTone,\n type AgentConversationToolCall,\n type AgentConversationToolState,\n} from \"./conversation/index.js\";\nexport { McpAppRenderer } from \"./mcp-apps/McpAppRenderer.js\";\nexport {\n AGENT_NATIVE_MCP_APP_HOST_MESSAGE_TYPES,\n getMcpAppHostContext,\n openMcpAppHostLink,\n requestMcpAppDisplayMode,\n sendMcpAppHostMessage,\n updateMcpAppModelContext,\n useMcpAppHostContext,\n type AgentNativeMcpAppHostMessageType,\n type McpAppDisplayMode,\n type McpAppHostChatMessage,\n type McpAppHostCapabilities,\n type McpAppHostContext,\n type McpAppHostContextSnapshot,\n type McpAppModelContextContentPart,\n type McpAppModelContextUpdate,\n} from \"./mcp-app-host.js\";\nexport {\n CodeAgentIndicator,\n type CodeAgentIndicatorProps,\n} from \"./components/CodeAgentIndicator.js\";\nexport {\n useDbSync,\n useFileWatcher,\n useScreenRefreshKey,\n} from \"./use-db-sync.js\";\nexport {\n useChangeVersion,\n useChangeVersions,\n getChangeVersion,\n bumpChangeVersion,\n} from \"./use-change-version.js\";\nexport { useReconciledState } from \"./use-external-value.js\";\nexport {\n buildDynamicAgentSuggestions,\n dedupeSuggestions,\n mergeAgentSuggestions,\n normalizeAgentDynamicSuggestionsConfig,\n useAgentDynamicSuggestions,\n type AgentDynamicSuggestionContext,\n type AgentDynamicSuggestionsConfig,\n type AgentDynamicSuggestionsOption,\n} from \"./dynamic-suggestions.js\";\nexport { cn } from \"./utils.js\";\nexport {\n // Shared editor core (Phase 1): the ONE configurable surface both the plan\n // and content editors build on.\n SharedRichEditor,\n createSharedEditorExtensions,\n MARKDOWN_DIALECT_CONFIG,\n useCollabReconcile,\n RICH_MARKDOWN_PROGRAMMATIC_TRANSACTION,\n getEditorMarkdown,\n SlashCommandMenu,\n DEFAULT_SLASH_COMMANDS,\n createImageSlashCommand,\n // Shared block-level image node + injectable upload contract. Plans opt in\n // via `features.image` + `onImageUpload`; Content keeps its own image block.\n SharedImage,\n createImageExtension,\n pickAndInsertImage,\n uploadEditorImage,\n BubbleToolbar,\n buildDefaultBubbleItems,\n // Back-compat alias + factory kept for existing embedders and specs.\n RichMarkdownEditor,\n createRichMarkdownExtensions,\n // Single-doc plan editor primitives: the GFM↔ProseMirror serializer, the\n // run-id prose attribute, and the shared drag-handle (block grip + reorder).\n RunId,\n RUN_ID_NODE_TYPES,\n gfmToProseJSON,\n proseJSONToGfm,\n DragHandle,\n DEFAULT_DRAG_HANDLE_WRAPPER_SELECTOR,\n // Generic registry-block Tiptap NodeView + side-map provider + dedupe plugin.\n // Hosts mount the node from `createRegistryBlockNode` as an extra extension\n // and wrap the editor in `RegistryBlockDataProvider`.\n createRegistryBlockNode,\n RegistryBlockNodeView,\n RegistryBlockDataProvider,\n useRegistryBlockData,\n // Shared registry-derived block slash-command builder (plan + content adapt it).\n buildRegistryBlockSlashItems,\n getRegistryBlockSlashDescription,\n getRegistryBlockSlashSearchText,\n type BuildRegistryBlockSlashItemsOptions,\n type DragHandleDropContext,\n type DragHandleDropPlacement,\n type DragHandleOptions,\n type CreateRegistryBlockNodeOptions,\n type RegistryBlockDataValue,\n type RegistryBlockSideMapBlock,\n type SharedRichEditorProps,\n type SharedEditorCollab,\n type SharedEditorFeatures,\n type CreateSharedEditorExtensionsOptions,\n type UseCollabReconcileOptions,\n type UseCollabReconcileResult,\n type SlashCommandItem,\n type SlashCommandMenuProps,\n type ImageUploadFn,\n type SharedImageOptions,\n type BubbleToolbarItem,\n type BubbleToolbarProps,\n type RichMarkdownDialect,\n type RichMarkdownEditorPreset,\n type RichMarkdownEditorProps,\n type RichMarkdownCollabUser,\n type CreateRichMarkdownExtensionsOptions,\n} from \"./rich-markdown-editor/index.js\";\n// ProseMirror node JSON shape — re-exported so the plan template (which has no\n// direct @tiptap dep) can type its doc↔blocks serializer.\nexport type { JSONContent } from \"@tiptap/core\";\nexport { ApiKeySettings } from \"./components/ApiKeySettings.js\";\nexport { useSession, type AuthSession } from \"./use-session.js\";\nexport {\n RequireSession,\n buildSignInReturnHref,\n type RequireSessionProps,\n} from \"./require-session.js\";\nexport {\n sendToFrame,\n onFrameMessage,\n requestUserInfo,\n getFrameOrigin,\n getFramePostMessageTargetOrigin,\n getCallbackOrigin,\n oauthRedirectUri,\n isInFrame,\n enterStyleEditing,\n enterTextEditing,\n exitSelectionMode,\n type UserInfo,\n} from \"./frame.js\";\nexport {\n getBuilderParentOrigin,\n isInBuilderFrame,\n sendToBuilderChat,\n type BuilderChatMessage,\n} from \"./builder-frame.js\";\nexport {\n AgentNative,\n useAgentNativeScreenContext,\n type AgentNativeCommandCallback,\n type AgentNativeCommandCallbackInfo,\n type AgentNativeProps,\n} from \"./AgentNative.js\";\nexport {\n AgentNativeEmbedded,\n useAgentNativeEmbeddedBrowserSession,\n type AgentNativeEmbeddedBrowserSessionOptions,\n type AgentNativeEmbeddedCommandCallback,\n type AgentNativeEmbeddedCommandCallbackInfo,\n type AgentNativeEmbeddedProps,\n type UseAgentNativeEmbeddedBrowserSessionOptions,\n} from \"./AgentNativeEmbedded.js\";\nexport {\n defineClientAction,\n type AgentNativeClientActionDefinition,\n type AgentNativeClientActionRunner,\n} from \"./client-action.js\";\nexport {\n AgentNativeFrame,\n type AgentNativeFrameProps,\n} from \"./AgentNativeFrame.js\";\nexport {\n AgentNativeRouteWarmup,\n type AgentNativeRouteWarmupProps,\n} from \"./route-warmup.js\";\nexport {\n AgentNativeExtensionFrame,\n AgentNativeExtensionSlot,\n type AgentNativeExtensionFrameProps,\n type AgentNativeExtensionPermissionList,\n type AgentNativeExtensionSlotProps,\n type AgentNativeExtensionStorageScopeList,\n} from \"./extensions/AgentNativeExtensionFrame.js\";\nexport {\n AGENT_NATIVE_EXTENSION_MESSAGE_TYPES,\n buildAgentNativeExtensionHtml,\n createHttpAgentNativeExtensionStorage,\n createLocalStorageAgentNativeExtensionStorage,\n getAgentNativeExtensionManifest,\n isAgentNativeExtensionAllowedInSlot,\n normalizeAgentNativeExtensionSandbox,\n type AgentNativeExtensionDefinition,\n type AgentNativeExtensionManifest,\n type AgentNativeExtensionMessageType,\n type AgentNativeExtensionStorage,\n type AgentNativeExtensionStorageContext,\n type AgentNativeExtensionStorageOptions,\n type AgentNativeExtensionStorageRow,\n type AgentNativeExtensionStorageScope,\n type BuildAgentNativeExtensionHtmlOptions,\n type CreateHttpAgentNativeExtensionStorageOptions,\n} from \"./extensions/portable-extension.js\";\nexport {\n AGENT_NATIVE_HOST_BRIDGE_VERSION,\n AGENT_NATIVE_HOST_MESSAGE_TYPES,\n announceAgentNativeFrameReady,\n createAgentNativeHostBridge,\n defaultAgentNativeHostCommands,\n onAgentNativeHostInit,\n readAgentNativeScreenContext,\n requestAgentNativeHostActions,\n requestAgentNativeHostContext,\n runAgentNativeHostAction,\n sendAgentNativeHostCommand,\n type AgentNativeActionAvailability,\n type AgentNativeActionManifestEntry,\n type AgentNativeClientAction,\n type AgentNativeClientActionApprovalConfig,\n type AgentNativeClientActionGetter,\n type AgentNativeClientActionRuntime,\n type AgentNativeClientActions,\n type AgentNativeHostAuth,\n type AgentNativeHostAuthPayload,\n type AgentNativeHostBridge,\n type AgentNativeHostBridgeEvent,\n type AgentNativeHostBridgeOptions,\n type AgentNativeHostCapabilities,\n type AgentNativeHostCommandHandler,\n type AgentNativeHostCommandHandlers,\n type AgentNativeHostCommandRequest,\n type AgentNativeHostContext,\n type AgentNativeHostContextGetter,\n type AgentNativeHostInit,\n type AgentNativeHostMessageType,\n type AgentNativeHostRequestOptions,\n type AgentNativeHostResourceContext,\n type AgentNativeHostRouteContext,\n type AgentNativeHostSelectionContext,\n type AgentNativeHostSession,\n type AgentNativeJsonSchema,\n type AgentNativeScreenSnapshot,\n type AgentNativeScreenSnapshotOptions,\n type BuiltInAgentNativeHostCommand,\n} from \"./host-bridge.js\";\nexport {\n AGENT_NATIVE_HOST_TOOL_NAMES,\n createAgentNativeHostTools,\n type AgentNativeHostToolDefinition,\n type AgentNativeHostToolName,\n type AgentNativeHostToolParameters,\n type AgentNativeHostToolSet,\n type CreateAgentNativeHostToolsOptions,\n type RunAgentNativeHostActionToolInput,\n type SendAgentNativeHostCommandToolInput,\n} from \"./host-tools.js\";\nexport {\n createAgentNativeBrowserSessionBridge,\n startAgentNativeBrowserSessionBridge,\n type AgentNativeBrowserSessionBridge,\n type AgentNativeBrowserSessionBridgeOptions,\n} from \"./browser-session-bridge.js\";\nexport type {\n AgentNativeBrowserSession,\n AgentNativeBrowserSessionAction,\n AgentNativeBrowserSessionRecord,\n AgentNativeBrowserSessionRequest,\n AgentNativeBrowserSessionRequestStatus,\n AgentNativeBrowserSessionRequestType,\n CreateAgentNativeBrowserSessionRequestInput,\n RegisterAgentNativeBrowserSessionInput,\n} from \"../browser-sessions/types.js\";\nexport {\n NewWorkspaceAppFlow,\n type NewWorkspaceAppFlowProps,\n type VaultSecretOption,\n} from \"./NewWorkspaceAppFlow.js\";\nexport {\n AssistantChat,\n clearChatStorage,\n type AssistantChatProps,\n type AssistantChatHandle,\n type AssistantChatAdapterContext,\n} from \"./AssistantChat.js\";\nexport {\n MultiTabAssistantChat,\n type MultiTabAssistantChatProps,\n type MultiTabAssistantChatHeaderProps,\n} from \"./MultiTabAssistantChat.js\";\nexport { RunStuckBanner, type RunStuckBannerProps } from \"./RunStuckBanner.js\";\nexport {\n useRunStuckDetection,\n useAbortRun,\n type RunStuckState,\n type UseRunStuckDetectionOptions,\n} from \"./use-run-stuck-detection.js\";\nexport {\n createAgentChatAdapter,\n type AgentChatSurfaceKind,\n type CreateAgentChatAdapterOptions,\n} from \"./agent-chat-adapter.js\";\nexport {\n AgentComposerFrame,\n type AgentComposerFrameProps,\n PromptComposer,\n TiptapComposer,\n AGENT_PROMPT_MAX_INLINE_IMAGE_BYTES,\n AGENT_PROMPT_MAX_INLINE_TEXT_CHARS,\n escapePromptAttachmentAttribute,\n formatPromptWithAttachments,\n isInlineableAgentPromptFile,\n readAgentPromptAttachment,\n type PromptComposerProps,\n type PromptComposerFile,\n type PromptComposerSubmitOptions,\n type ComposerSubmitIntent,\n type AgentPromptAttachment,\n type ReadAgentPromptAttachmentOptions,\n type AgentComposerLayoutVariant,\n type SlashCommand,\n type SkillResult,\n type TiptapComposerHandle,\n type TiptapComposerProps,\n type TiptapComposerSubmitOptions,\n} from \"./composer/index.js\";\nexport {\n GuidedQuestionFlow,\n useGuidedQuestionFlow,\n askUserQuestion,\n formatGuidedAnswerValue,\n formatGuidedAnswersForAgent,\n getOtherGuidedAnswerText,\n hasGuidedAnswer,\n isOtherGuidedAnswer,\n makeOtherGuidedAnswer,\n normalizeGuidedAnswers,\n type AskUserQuestionInput,\n type AskUserQuestionOption,\n type AskUserQuestionResult,\n type GuidedQuestion,\n type GuidedQuestionAnswers,\n type GuidedQuestionFlowProps,\n type GuidedQuestionOption,\n type GuidedQuestionPayload,\n type GuidedQuestionType,\n type UseGuidedQuestionFlowOptions,\n} from \"./guided-questions.js\";\nexport {\n useChatThreads,\n type ChatThreadScope,\n type ChatThreadSnapshot,\n type ChatThreadSummary,\n type ChatThreadData,\n type ChatThreadShareLink,\n type ChatThreadShareState,\n type UseChatThreadsOptions,\n} from \"./use-chat-threads.js\";\nexport { AgentChatHome, type AgentChatHomeProps } from \"./AgentChatHome.js\";\nexport {\n AgentChatSurface,\n AgentPanel,\n AgentSidebar,\n AgentToggleButton,\n focusAgentChat,\n type AgentChatSurfaceMode,\n type AgentChatSurfaceProps,\n type AgentPanelProps,\n type AgentSidebarProps,\n} from \"./AgentPanel.js\";\nexport {\n AGENT_CHAT_HOME_HANDOFF_TTL_MS,\n AGENT_CHAT_VIEW_TRANSITION_CLASS,\n AGENT_CHAT_VIEW_TRANSITION_NAME,\n consumeAgentChatHomeHandoff,\n getAgentChatViewTransitionStyle,\n markAgentChatHomeHandoff,\n navigateWithAgentChatViewTransition,\n startAgentChatViewTransition,\n supportsAgentChatViewTransition,\n type AgentChatHomeHandoffOptions,\n type AgentChatViewTransition,\n type AgentChatViewTransitionOptions,\n} from \"./chat-view-transition.js\";\nexport {\n useAgentChatHomeHandoff,\n useAgentChatHomeHandoffLinks,\n type UseAgentChatHomeHandoffLinksOptions,\n type UseAgentChatHomeHandoffOptions,\n} from \"./use-agent-chat-home-handoff.js\";\nexport {\n requestAgentSidebarOpen,\n SIDEBAR_STATE_CHANGE_EVENT,\n setAgentSidebarOpenPreference,\n type AgentSidebarStateChangeDetail,\n type AgentSidebarStateMode,\n type AgentSidebarStateSource,\n} from \"./agent-sidebar-state.js\";\nexport {\n clearReservedToolRenderersForTests,\n clearToolRenderersForTests,\n registerActionChatRenderer,\n registerFallbackToolRenderer,\n registerReservedActionChatRenderer,\n registerReservedFallbackToolRenderer,\n registerReservedToolRenderer,\n registerToolRenderer,\n resolveToolRenderer,\n type ActionChatRendererRegistration,\n type ToolRendererComponent,\n type ToolRendererContext,\n type ToolRendererMatch,\n type ToolRendererProps,\n type ToolRendererRegistration,\n} from \"./chat/tool-render-registry.js\";\nexport * from \"./chat/connectors.js\";\nexport * from \"./chat/runtime.js\";\nexport {\n ACTION_CHAT_UI_DATA_CHART_RENDERER,\n ACTION_CHAT_UI_DATA_INSIGHTS_RENDERER,\n ACTION_CHAT_UI_DATA_TABLE_RENDERER,\n ACTION_CHAT_UI_DATA_WIDGET_RENDERER,\n type ActionChatUIConfig,\n} from \"../action-ui.js\";\nexport {\n DATA_CHART_WIDGET,\n DATA_INSIGHTS_WIDGET,\n DATA_TABLE_WIDGET,\n createDataChartWidgetResult,\n createDataInsightsWidgetResult,\n createDataTableWidgetResult,\n dataChartWidgetResultSchema,\n dataChartWidgetSchema,\n dataInsightsWidgetResultSchema,\n dataTableWidgetResultSchema,\n dataTableWidgetSchema,\n dataWidgetResultSchema,\n isDataChartWidget,\n isDataTableWidget,\n isDataWidgetResult,\n normalizeDataWidgetKind,\n normalizeDataWidgetResult,\n type DataChartSeriesDefinition,\n type DataChartWidget,\n type DataChartWidgetResult,\n type DataChartWidgetResultInput,\n type DataInsightsWidgetResult,\n type DataInsightsWidgetResultInput,\n type DataTableColumn,\n type DataTableWidget,\n type DataTableWidgetResult,\n type DataTableWidgetResultInput,\n type DataWidgetDisplay,\n type DataWidgetKind,\n type DataWidgetResult,\n type DataWidgetResultMetadata,\n} from \"./chat/widgets/data-widget-types.js\";\nexport { AgentNativeIcon } from \"./components/icons/AgentNativeIcon.js\";\nexport { SettingsPanel, type SettingsPanelProps } from \"./settings/index.js\";\nexport { useBuilderStatus } from \"./settings/useBuilderStatus.js\";\nexport {\n openBuilderConnectPopup,\n useBuilderConnectFlow,\n type BuilderConnectFlow,\n type BuilderConnectFlowOptions,\n type OpenBuilderConnectPopupOptions,\n} from \"./settings/useBuilderStatus.js\";\n// Deprecated — use AgentSidebar + AgentToggleButton instead\nexport {\n ProductionAgentPanel,\n type ProductionAgentPanelProps,\n} from \"./ProductionAgentPanel.js\";\nexport {\n useProductionAgent,\n type ProductionAgentMessage,\n type UseProductionAgentOptions,\n type UseProductionAgentResult,\n} from \"./useProductionAgent.js\";\nexport { Turnstile, type TurnstileProps } from \"./Turnstile.js\";\nexport {\n OpenSourceBadge,\n PoweredByBadge,\n type OpenSourceBadgeProps,\n type PoweredByBadgeProps,\n} from \"./PoweredByBadge.js\";\nexport {\n StarfieldBackground,\n type StarfieldBackgroundProps,\n} from \"./StarfieldBackground.js\";\nexport { FeedbackButton, type FeedbackButtonProps } from \"./FeedbackButton.js\";\nexport {\n DevDatabaseLink,\n type DevDatabaseLinkProps,\n} from \"./db-admin/DevDatabaseLink.js\";\nexport { ErrorBoundary } from \"./ErrorBoundary.js\";\nexport {\n installRouteChunkRecovery,\n reloadForStaleChunk,\n recoverFromStaleChunkError,\n} from \"./route-chunk-recovery.js\";\nexport { ClientOnly } from \"./ClientOnly.js\";\nexport { DefaultSpinner } from \"./DefaultSpinner.js\";\nexport {\n getThemeInitScript,\n themeInitScript,\n type ThemePreference,\n} from \"./theme.js\";\nexport {\n APPEARANCE_PRESETS,\n applyAppearance,\n getStoredAppearance,\n useAppearance,\n useAppearanceSync,\n type AppearancePresetId,\n} from \"./appearance.js\";\nexport {\n AppearancePicker,\n type AppearancePickerProps,\n} from \"./AppearancePicker.js\";\nexport { AgentTerminal, type AgentTerminalProps } from \"./terminal/index.js\";\nexport {\n trackEvent,\n trackSessionStatus,\n configureTracking,\n setSentryUser,\n captureError,\n captureClientException,\n type ClientCaptureContext,\n} from \"./analytics.js\";\nexport { track } from \"./track.js\";\nexport {\n useCollaborativeDoc,\n isReconcileLeadClient,\n emailToColor,\n emailToName,\n dedupeCollabUsersByEmail,\n type UseCollaborativeDocOptions,\n type UseCollaborativeDocResult,\n type CollabUser,\n} from \"../collab/client.js\";\nexport { AGENT_CLIENT_ID } from \"../collab/agent-identity.js\";\n// Presence kit\nexport {\n usePresence,\n toNormalized,\n fromNormalized,\n type OtherPresence,\n type PresencePayload,\n type UsePresenceResult,\n type NormalizedPoint,\n} from \"../collab/presence.js\";\nexport {\n useFollowUser,\n type UseFollowUserOptions,\n type UseFollowUserResult,\n type ViewportDescriptor,\n} from \"../collab/follow-mode.js\";\nexport {\n ResourcesPanel,\n ResourceTree,\n ResourceEditor,\n useResources,\n useResourceTree,\n useResource,\n useCreateResource,\n useUpdateResource,\n useDeleteResource,\n useUploadResource,\n type Resource,\n type ResourceMeta,\n type TreeNode,\n type ResourceScope,\n type ResourceTreeProps,\n type ResourceEditorProps,\n} from \"./resources/index.js\";\nexport type {\n AppToFrameMessage,\n FrameToAppMessage,\n FrameMessage,\n CodeCompleteMessage,\n ChatRunningMessage,\n} from \"./frame-protocol.js\";\nexport {\n CommandMenu,\n useCommandMenuShortcut,\n openAgentSidebar,\n submitToAgent,\n type CommandMenuProps,\n type CommandMenuDoc,\n type CommandDocsGroupProps,\n type CommandGroupProps,\n type CommandItemProps,\n type CommandShortcutProps,\n} from \"./CommandMenu.js\";\nexport {\n DevOverlay,\n useDevOverlayShortcut,\n registerDevPanel,\n unregisterDevPanel,\n listDevPanels,\n subscribeDevPanels,\n useDevOption,\n clearAllDevOverlayStorage,\n devOptionKey,\n DEV_OVERLAY_STORAGE_PREFIX,\n type DevOverlayProps,\n type DevPanel,\n type DevOption,\n type DevBooleanOption,\n type DevSelectOption,\n type DevStringOption,\n type DevActionOption,\n type DevOptionValue,\n} from \"./dev-overlay/index.js\";\nexport {\n callAction,\n useActionQuery,\n useActionMutation,\n type ActionRegistry,\n type ClientActionCallOptions,\n type ClientActionMethod,\n} from \"./use-action.js\";\nexport { createAgentNativeQueryClient } from \"./create-query-client.js\";\nexport { AppProviders, type AppProvidersProps } from \"./app-providers.js\";\nexport { usePinchZoom, type UsePinchZoomOptions } from \"./use-pinch-zoom.js\";\nexport {\n ShareButton,\n ShareDialog,\n VisibilityBadge,\n type ShareButtonProps,\n type ShareDialogProps,\n type VisibilityBadgeProps,\n} from \"./sharing/index.js\";\nexport {\n postNavigate,\n isInAgentEmbed,\n AGENT_NAVIGATE_MESSAGE_TYPE,\n type AgentNavigateMessage,\n} from \"./embed.js\";\nexport { IframeEmbed, parseEmbedBody } from \"./IframeEmbed.js\";\nexport {\n useAvatarUrl,\n uploadAvatar,\n invalidateAvatarCache,\n} from \"./use-avatar.js\";\nexport {\n ObservabilityDashboard,\n ThumbsFeedback,\n} from \"./observability/index.js\";\n// Presence UI components\nexport {\n PresenceBar,\n type PresenceBarProps,\n} from \"./components/PresenceBar.js\";\nexport {\n AgentPresenceChip,\n type AgentPresenceChipProps,\n} from \"./components/AgentPresenceChip.js\";\nexport {\n LiveCursorOverlay,\n type LiveCursorOverlayProps,\n type CursorMapFn,\n} from \"./components/LiveCursorOverlay.js\";\nexport {\n RemoteSelectionRings,\n type RemoteSelectionRingsProps,\n} from \"./components/RemoteSelectionRings.js\";\n// Structured data collaboration hooks\nexport {\n useCollaborativeMap,\n useCollaborativeArray,\n type UseCollaborativeMapOptions,\n type UseCollaborativeMapResult,\n type UseCollaborativeArrayOptions,\n type UseCollaborativeArrayResult,\n} from \"../collab/client-struct.js\";\nexport { NotificationsBell } from \"./notifications/index.js\";\n// Block registry (also available as the dedicated `@agent-native/core/blocks`\n// subpath, which server/agent code should prefer via `/blocks/server`).\nexport {\n defineBlock,\n BlockRegistry,\n registerBlocks,\n BlockRegistryProvider,\n useBlockRegistry,\n useOptionalBlockRegistry,\n BlockView,\n SchemaBlockEditor,\n markdown,\n richtext,\n introspect,\n serializeSpecBlock,\n parseSpecBlock,\n createAttrReader,\n describeBlocksForAgent,\n renderBlockVocabularyReference,\n type BlockSpec,\n type BlockPlacement,\n type BlockMdxConfig,\n type BlockAttrReader,\n type BlockRenderContext,\n type BlockReadProps,\n type BlockEditProps,\n type MdxAttrValue,\n type FieldKind,\n type FieldDescriptor,\n type MdxJsxNode,\n type MdxAttrNode,\n type SerializableBlock,\n type ParsedBlockBase,\n type BlockAgentDoc,\n} from \"./blocks/index.js\";\n"]}
@@ -113,5 +113,5 @@ export declare function readSSEStream(body: ReadableStream<Uint8Array>, content:
113
113
  */
114
114
  export declare function readSSEStreamRaw(body: ReadableStream<Uint8Array>, content: ContentPart[], toolCallCounter: {
115
115
  value: number;
116
- }, tabId: string | undefined, onUpdate: (content: ContentPart[]) => void): Promise<void>;
116
+ }, tabId: string | undefined, onUpdate: (content: ContentPart[]) => void, onSeq?: (seq: number) => void): Promise<void>;
117
117
  //# sourceMappingURL=sse-event-processor.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"sse-event-processor.d.ts","sourceRoot":"","sources":["../../src/client/sse-event-processor.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAC9D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAK1D,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,6BAA6B,CAAC;AAItE,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAA;CAAE,GAC9B;IACE,IAAI,EAAE,WAAW,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,MAAM,CAAC,EAAE,kBAAkB,CAAC;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;;;;OAKG;IACH,QAAQ,CAAC,EAAE;QAAE,WAAW,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,CAAC;IACxD;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC1C,CAAC;AAEN,MAAM,WAAW,QAAQ;IACvB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gFAAgF;IAChF,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,C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C1C,KAAK,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,GAC5B,OAAO,CAAC,IAAI,CAAC,CA8Ff"}
@@ -212,6 +212,9 @@ export function processEvent(ev, content, toolCallCounter, tabId) {
212
212
  result: { content: [...content] },
213
213
  };
214
214
  }
215
+ if (ev.type === "stream_keepalive") {
216
+ return { action: "continue" };
217
+ }
215
218
  if (ev.type === "activity") {
216
219
  const tool = ev.tool?.trim() || undefined;
217
220
  const label = humanizeToolLabelText(ev.label ?? "Working", tool);
@@ -657,7 +660,7 @@ export async function* readSSEStream(body, content, toolCallCounter, tabId, onSe
657
660
  * content array in-place and calls onUpdate for each meaningful change.
658
661
  * Designed for reconnection scenarios where we render outside assistant-ui's runtime.
659
662
  */
660
- export async function readSSEStreamRaw(body, content, toolCallCounter, tabId, onUpdate) {
663
+ export async function readSSEStreamRaw(body, content, toolCallCounter, tabId, onUpdate, onSeq) {
661
664
  const reader = body.getReader();
662
665
  const decoder = new TextDecoder();
663
666
  let buf = "";
@@ -692,6 +695,9 @@ export async function readSSEStreamRaw(body, content, toolCallCounter, tabId, on
692
695
  }
693
696
  sawDataEvent = true;
694
697
  lastMeaningfulEventAt = Date.now();
698
+ if (ev.seq !== undefined && onSeq) {
699
+ onSeq(ev.seq);
700
+ }
695
701
  const { action, autoContinue } = processEvent(ev, content, toolCallCounter, tabId);
696
702
  if (action === "yield" ||
697
703
  action === "done" ||
@@ -1 +1 @@
1
- {"version":3,"file":"sse-event-processor.js","sourceRoot":"","sources":["../../src/client/sse-event-processor.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,kCAAkC,EAClC,+BAA+B,GAChC,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAyE5E,MAAM,uBAAuB,GAC3B,iDAAiD,CAAC;AAEpD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,CAAC;QACH,CAAC;IACH,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YACH,MAAM,CAAC,WAAW,EAAE,CAAC;QACvB,CAAC;QAAC,MAAM,CAAC;YACP,qEAAqE;QACvE,CAAC;IACH,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,oBAAoB;QAAE,QAAQ,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IACxE,MAAM,IAAI,uBAAuB,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import type { ChatModelRunResult } from \"@assistant-ui/react\";\nimport type { ActionChatUIConfig } from \"../action-ui.js\";\nimport {\n LLM_MISSING_CREDENTIALS_ERROR_CODE,\n LLM_MISSING_CREDENTIALS_MESSAGE,\n} from \"../agent/engine/credential-errors.js\";\nimport type { AgentMcpAppPayload } from \"../mcp-client/app-result.js\";\nimport { formatChatErrorText, normalizeChatError } from \"./error-format.js\";\nimport { humanizeToolLabelText, runningToolLabel } from \"./tool-display.js\";\n\nexport type ContentPart =\n | { type: \"text\"; text: string }\n | {\n type: \"tool-call\";\n toolCallId: string;\n toolName: string;\n argsText: string;\n args: Record<string, string>;\n result?: string;\n mcpApp?: AgentMcpAppPayload;\n chatUI?: ActionChatUIConfig;\n activity?: boolean;\n /**\n * Set when the server emitted an `approval_required` event for this tool\n * call (opt-in `needsApproval` actions). The action did NOT run; the UI\n * renders an Approve/Deny affordance. `approvalKey` is echoed back in\n * `approvedToolCalls` to approve, `dismissed` records a local Deny.\n */\n approval?: { approvalKey: string; dismissed?: boolean };\n /**\n * Structured metadata from the coding-tools executor side-channel.\n * Present only on code-agent tool calls from executors new enough to\n * emit it. The `toolKind` discriminant identifies the shape.\n */\n structuredMeta?: Record<string, unknown>;\n };\n\nexport interface SSEEvent {\n type: string;\n text?: string;\n tool?: string;\n /** Server-assigned call identifier emitted on tool_start / tool_done events. */\n id?: string;\n label?: string;\n input?: Record<string, string>;\n result?: string;\n mcpApp?: AgentMcpAppPayload;\n chatUI?: ActionChatUIConfig;\n /** Stable key the client echoes back in `approvedToolCalls` to approve a\n * paused `needsApproval` tool call. Present on `approval_required` events. */\n approvalKey?: string;\n error?: string;\n seq?: number;\n agent?: string;\n status?: string;\n reason?: string;\n // Agent task fields\n taskId?: string;\n threadId?: string;\n description?: string;\n preview?: string;\n currentStep?: string;\n summary?: string;\n // Structured error metadata — Builder gateway sets these on quota/auth/setup\n // failures so the UI can render a CTA alongside the error text.\n errorCode?: string;\n upgradeUrl?: string;\n details?: string;\n recoverable?: boolean;\n maxIterations?: number;\n}\n\nexport type AgentAutoContinueReason =\n | \"run_timeout\"\n | \"loop_limit\"\n | \"no_progress\"\n | \"stream_ended\"\n | \"stale_run\";\n\nexport type AgentActivityTrailEntry = { label: string; tool?: string };\n\nconst INTERRUPTED_TOOL_RESULT =\n \"Interrupted before this tool returned a result.\";\n\nexport function settleInterruptedToolCalls(\n content: ContentPart[],\n result = INTERRUPTED_TOOL_RESULT,\n): boolean {\n let changed = false;\n for (const part of content) {\n if (\n part.type === \"tool-call\" &&\n part.result === undefined &&\n part.activity !== true\n ) {\n part.result = result;\n changed = true;\n }\n }\n return changed;\n}\n\nexport class AgentAutoContinueSignal extends Error {\n readonly reason: AgentAutoContinueReason;\n readonly maxIterations?: number;\n readonly activityTrail: AgentActivityTrailEntry[];\n\n constructor(options: {\n reason: AgentAutoContinueReason;\n maxIterations?: number;\n activityTrail?: AgentActivityTrailEntry[];\n }) {\n super(`Agent run needs automatic continuation: ${options.reason}`);\n this.name = \"AgentAutoContinueSignal\";\n this.reason = options.reason;\n this.maxIterations = options.maxIterations;\n this.activityTrail = options.activityTrail ?? [];\n }\n}\n\nexport const SSE_NO_PROGRESS_TIMEOUT_MS = 75_000;\n\ntype ActivityTrailEntry = AgentActivityTrailEntry;\n\nfunction findPendingToolCallIndex(\n content: ContentPart[],\n toolName: string,\n toolCallId?: string,\n): number {\n // Prefer id-based match when the event carries an id: parallel same-name\n // calls can be in flight simultaneously, and name-only matching would\n // attach a result to the wrong call.\n if (toolCallId) {\n for (let i = content.length - 1; i >= 0; i--) {\n const part = content[i];\n if (\n part.type === \"tool-call\" &&\n part.toolCallId === toolCallId &&\n part.result === undefined\n ) {\n return i;\n }\n }\n // Fall through to name-matching: the start event may have arrived before\n // the server started emitting ids (e.g. older server build), so the\n // stored toolCallId is the locally-generated \"tc_N\" value rather than the\n // server-assigned one. In that case match by name as a fallback.\n }\n for (let i = content.length - 1; i >= 0; i--) {\n const part = content[i];\n if (\n part.type === \"tool-call\" &&\n part.toolName === toolName &&\n part.result === undefined\n ) {\n return i;\n }\n }\n return -1;\n}\n\nfunction appendActivityTrail(\n trail: ActivityTrailEntry[],\n next: ActivityTrailEntry,\n) {\n const label = next.label.trim();\n if (!label) return;\n const tool = next.tool?.trim();\n const last = trail[trail.length - 1];\n if (last?.label === label && last.tool === tool) return;\n trail.push({ label, ...(tool ? { tool } : {}) });\n if (trail.length > 8) {\n trail.splice(0, trail.length - 8);\n }\n}\n\nasync function readChunkWithProgressTimeout(\n reader: ReadableStreamDefaultReader<Uint8Array>,\n lastMeaningfulEventAt: number,\n): Promise<ReadableStreamReadResult<Uint8Array>> {\n const elapsed = Date.now() - lastMeaningfulEventAt;\n const timeoutMs = Math.max(0, SSE_NO_PROGRESS_TIMEOUT_MS - elapsed);\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n const readPromise = reader.read();\n // If the timeout wins and cancellation causes the pending read to reject,\n // swallow that rejection because the generator is already recovering.\n void readPromise.catch(() => {});\n\n const timeoutPromise = new Promise<\"timeout\">((resolve) => {\n timeoutId = setTimeout(() => resolve(\"timeout\"), timeoutMs);\n });\n const result = await Promise.race([readPromise, timeoutPromise]);\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n if (result === \"timeout\") {\n await reader.cancel(\"no_progress\").catch(() => {});\n throw new AgentAutoContinueSignal({ reason: \"no_progress\" });\n }\n return result;\n}\n\nfunction isAutoRecoverableError(ev: SSEEvent, errMsg: string): boolean {\n const code = String(ev.errorCode ?? \"\").toLowerCase();\n const msg = errMsg.toLowerCase();\n\n if (\n code === \"context_length_exceeded\" ||\n code === \"input_too_long\" ||\n code.startsWith(\"credits-limit\") ||\n code === \"billing_error\" ||\n code === \"unauthorized\" ||\n code === \"authentication_error\" ||\n code === \"permission_error\" ||\n code === \"http_401\" ||\n code === \"http_403\" ||\n code === \"rate_limit_exceeded\" ||\n code === \"gateway_not_enabled\" ||\n code === \"missing_api_key\" ||\n code === \"missing_credentials\" ||\n code === \"invalid_request_error\" ||\n code === \"request_too_large\" ||\n code === \"not_found_error\" ||\n code === \"model_not_found\" ||\n code === \"provider_rate_limited\" ||\n // `builder_gateway_error` is the no-detail fallback the Builder engine\n // emits when the gateway returns `{type:\"stop\",reason:\"error\"}` with no\n // explanation — almost always the upstream provider giving up (model\n // quota hit, account misconfiguration, opaque downstream failure). The\n // production-agent already retries this synchronously up to MAX_RETRIES\n // before the error escapes to the SSE stream, so by the time the client\n // sees it, retrying again with another POST /agent-chat will hit the\n // same wall. This used to send the chat into a 32-continuation runaway\n // (each turn cleared+regenerated visible content) for users hitting a\n // misbehaving Builder route. Surface the error instead.\n code === \"builder_gateway_error\"\n ) {\n return false;\n }\n\n if (\n code === \"builder_gateway_network_error\" ||\n code === \"builder_gateway_timeout\" ||\n code === \"stale_run\" ||\n code === \"timeout\" ||\n code === \"timeout_error\" ||\n code === \"http_408\" ||\n code === \"http_429\" ||\n code === \"http_500\" ||\n code === \"http_502\" ||\n code === \"http_503\" ||\n code === \"http_504\" ||\n code === \"rate_limited\" ||\n code === \"too_many_concurrent_requests\" ||\n code === \"overloaded_error\"\n ) {\n return true;\n }\n\n if (ev.recoverable === true) return true;\n\n if (msg.includes(\"daily gateway request cap\")) return false;\n\n // \"gateway error\" intentionally absent — that's the no-detail Builder\n // gateway fallback and the production-agent already retries it\n // synchronously up to MAX_RETRIES before the error escapes here. Treating\n // it as auto-recoverable on top of that produced a 32-continuation\n // runaway in production for users hitting a misbehaving Builder route.\n // (See `code === \"builder_gateway_error\"` in the not-recoverable list.)\n return (\n msg.includes(\"overloaded\") ||\n msg.includes(\"rate_limit\") ||\n msg.includes(\"too many requests\") ||\n msg.includes(\"timeout\") ||\n msg.includes(\"gateway timeout\") ||\n msg.includes(\"inactivity timeout\") ||\n msg.includes(\"socket hang up\") ||\n msg.includes(\"connection reset\") ||\n msg.includes(\"connection\") ||\n msg.includes(\"network\") ||\n msg.includes(\"stream closed\") ||\n msg.includes(\"stream ended\") ||\n msg.includes(\"temporarily unavailable\") ||\n msg.includes(\"502\") ||\n msg.includes(\"503\") ||\n msg.includes(\"504\") ||\n msg.includes(\"529\")\n );\n}\n\nfunction isMissingCredentialText(message: string, errorCode?: string): boolean {\n const code = String(errorCode ?? \"\").toLowerCase();\n const msg = message.toLowerCase();\n return (\n code === \"missing_api_key\" ||\n code === \"missing_credentials\" ||\n msg.includes(\"apikey\") ||\n msg.includes(\"authtoken\") ||\n msg.includes(\"anthropic_api_key\") ||\n msg.includes(\"missing_api_key\") ||\n msg.includes(\"missing api key\") ||\n msg.includes(\"missing credentials\") ||\n msg.includes(\"no llm provider\") ||\n msg.includes(\"llm provider is connected\")\n );\n}\n\nfunction dispatchActivityClear(tabId: string | undefined) {\n if (typeof window === \"undefined\") return;\n window.dispatchEvent(\n new CustomEvent(\"agent-chat:activity-clear\", {\n detail: { tabId },\n }),\n );\n}\n\n/**\n * Process a single SSE event and update the content accumulator.\n * Returns: \"continue\" to keep going, \"done\" to stop, or a yield-ready result.\n */\nexport function processEvent(\n ev: SSEEvent,\n content: ContentPart[],\n toolCallCounter: { value: number },\n tabId: string | undefined,\n): {\n action:\n | \"continue\"\n | \"done\"\n | \"yield\"\n | \"error\"\n | \"missing_api_key\"\n | \"auto_continue\";\n result?: ChatModelRunResult;\n autoContinue?: {\n reason: AgentAutoContinueReason;\n maxIterations?: number;\n };\n} {\n if (ev.type === \"clear\") {\n // Server is retrying — discard partial text/tool output from the failed attempt\n content.length = 0;\n dispatchActivityClear(tabId);\n return { action: \"continue\" };\n }\n\n if (ev.type === \"text\") {\n const lastPart = content[content.length - 1];\n if (lastPart && lastPart.type === \"text\") {\n lastPart.text += ev.text ?? \"\";\n } else {\n content.push({ type: \"text\", text: ev.text ?? \"\" });\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"activity\") {\n const tool = ev.tool?.trim() || undefined;\n const label = humanizeToolLabelText(ev.label ?? \"Working\", tool);\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(\"agent-chat:activity\", {\n detail: {\n label,\n ...(tool ? { tool } : {}),\n tabId,\n },\n }),\n );\n }\n if (!tool) return { action: \"continue\" };\n\n const pendingToolCallIndex = findPendingToolCallIndex(content, tool);\n if (pendingToolCallIndex === -1) {\n content.push({\n type: \"tool-call\",\n toolCallId: `tc_${++toolCallCounter.value}`,\n toolName: tool,\n argsText: \"\",\n args: {},\n activity: true,\n });\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"tool_start\") {\n const args = (ev.input ?? {}) as Record<string, string>;\n const tool = ev.tool ?? \"unknown\";\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(\"agent-native:tool-start\", {\n detail: { tool, input: args },\n }),\n );\n window.dispatchEvent(\n new CustomEvent(\"agent-chat:activity\", {\n detail: {\n label: runningToolLabel(tool),\n tool,\n tabId,\n },\n }),\n );\n }\n // Pass the server-assigned id so we upgrade the pending activity card\n // using id-match when available (parallel same-name calls stay separate).\n const pendingToolCallIndex = findPendingToolCallIndex(content, tool, ev.id);\n const pendingToolCall =\n pendingToolCallIndex >= 0 ? content[pendingToolCallIndex] : undefined;\n if (\n pendingToolCall &&\n pendingToolCall.type === \"tool-call\" &&\n pendingToolCall.activity === true &&\n pendingToolCall.argsText === \"\" &&\n Object.keys(pendingToolCall.args).length === 0\n ) {\n // Upgrade the pending activity card in place. Prefer the server-assigned\n // id so the subsequent tool_done can match it precisely (parallel\n // same-name calls each carry their own id). Fall back to the\n // locally-generated id already on the card.\n content[pendingToolCallIndex] = {\n type: \"tool-call\",\n toolCallId: ev.id ?? pendingToolCall.toolCallId,\n toolName: tool,\n argsText: JSON.stringify(args),\n args,\n };\n } else {\n content.push({\n type: \"tool-call\",\n toolCallId: ev.id ?? `tc_${++toolCallCounter.value}`,\n toolName: tool,\n argsText: JSON.stringify(args),\n args,\n });\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"approval_required\") {\n // Opt-in `needsApproval` gate: the server emitted `tool_start` immediately\n // before this, so the matching tool-call part already exists. Mark it as\n // awaiting approval so the UI can render the Approve/Deny affordance. The\n // action did NOT execute; a paused `tool_done` follows.\n const approvalTool = ev.tool ?? \"unknown\";\n const approvalKey = ev.approvalKey;\n if (approvalKey) {\n const idx = findPendingToolCallIndex(content, approvalTool, ev.id);\n if (idx >= 0) {\n const part = content[idx];\n if (part.type === \"tool-call\") {\n part.approval = { approvalKey };\n }\n }\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"tool_done\") {\n // Normalize identically to tool_start (which stores `ev.tool ?? \"unknown\"`)\n // so a tool_done frame with an undefined tool name still matches its\n // pending tool-call entry instead of leaving it forever unresolved.\n const doneTool = ev.tool ?? \"unknown\";\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(\"agent-native:tool-done\", {\n detail: { tool: doneTool, result: ev.result },\n }),\n );\n }\n // Use id-based lookup when available so parallel same-name tool calls\n // get their results correctly assigned; fall back to name-matching.\n const doneIdx = findPendingToolCallIndex(content, doneTool, ev.id);\n if (doneIdx >= 0) {\n const part = content[doneIdx];\n if (part.type === \"tool-call\") {\n part.result = ev.result ?? \"\";\n if (ev.mcpApp) part.mcpApp = ev.mcpApp;\n if (ev.chatUI) part.chatUI = ev.chatUI;\n }\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"agent_call\") {\n const agentName = ev.agent ?? \"agent\";\n if (ev.status === \"start\") {\n const toolCallId = `tc_${++toolCallCounter.value}`;\n content.push({\n type: \"tool-call\",\n toolCallId,\n toolName: `agent:${agentName}`,\n argsText: \"\",\n args: {},\n });\n } else if (ev.status === \"done\" || ev.status === \"error\") {\n for (let i = content.length - 1; i >= 0; i--) {\n const part = content[i];\n if (\n part.type === \"tool-call\" &&\n part.toolName === `agent:${agentName}` &&\n part.result === undefined\n ) {\n part.result = ev.status === \"error\" ? \"Error calling agent\" : \"Done\";\n break;\n }\n }\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"agent_call_text\") {\n const agentName = ev.agent ?? \"agent\";\n // Find the in-progress agent tool-call and append streaming text to argsText\n for (let i = content.length - 1; i >= 0; i--) {\n const part = content[i];\n if (\n part.type === \"tool-call\" &&\n part.toolName === `agent:${agentName}` &&\n part.result === undefined\n ) {\n part.argsText += ev.text ?? \"\";\n break;\n }\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n // ─── Agent task events (sub-agent chips) ─────────────────────────\n // These events are dispatched as CustomEvents so AgentTaskCard components\n // can listen for updates to their specific taskId.\n if (\n ev.type === \"agent_task\" ||\n ev.type === \"agent_task_update\" ||\n ev.type === \"agent_task_complete\"\n ) {\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(new CustomEvent(\"agent-task-event\", { detail: ev }));\n }\n // Don't add to content — the agent-teams tool call handles rendering\n return { action: \"continue\" };\n }\n\n if (ev.type === \"missing_api_key\") {\n const errMsg = LLM_MISSING_CREDENTIALS_MESSAGE;\n const errorCode = LLM_MISSING_CREDENTIALS_ERROR_CODE;\n const runError = {\n message: normalizeChatError(errMsg, errorCode).message,\n errorCode,\n };\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(new Event(\"agent-chat:missing-api-key\"));\n window.dispatchEvent(\n new CustomEvent(\"agent-chat:run-error\", {\n detail: { ...runError, tabId },\n }),\n );\n }\n settleInterruptedToolCalls(content);\n content.push({\n type: \"text\",\n text: formatChatErrorText(errMsg, undefined, errorCode),\n });\n return {\n action: \"missing_api_key\",\n result: {\n content: [...content],\n status: { type: \"incomplete\" as const, reason: \"error\" as const },\n metadata: { custom: { runError } },\n } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"loop_limit\") {\n const maxIterations =\n typeof ev.maxIterations === \"number\" ? ev.maxIterations : undefined;\n return {\n action: \"auto_continue\",\n autoContinue: {\n reason: \"loop_limit\",\n ...(maxIterations ? { maxIterations } : {}),\n },\n };\n }\n\n if (ev.type === \"auto_continue\") {\n const reason =\n ev.reason === \"stream_ended\" ||\n ev.reason === \"loop_limit\" ||\n ev.reason === \"no_progress\" ||\n ev.reason === \"run_timeout\"\n ? ev.reason\n : ev.errorCode === \"stream_ended\" ||\n ev.errorCode === \"loop_limit\" ||\n ev.errorCode === \"no_progress\" ||\n ev.errorCode === \"run_timeout\"\n ? ev.errorCode\n : ev.error === \"stream_ended\" ||\n ev.error === \"loop_limit\" ||\n ev.error === \"no_progress\" ||\n ev.error === \"run_timeout\"\n ? ev.error\n : ev.status === \"stream_ended\" ||\n ev.status === \"loop_limit\" ||\n ev.status === \"no_progress\" ||\n ev.status === \"run_timeout\"\n ? ev.status\n : \"run_timeout\";\n return {\n action: \"auto_continue\",\n autoContinue: {\n reason,\n ...(typeof ev.maxIterations === \"number\"\n ? { maxIterations: ev.maxIterations }\n : {}),\n },\n };\n }\n\n if (ev.type === \"error\") {\n const errMsg = ev.error ?? \"Unknown error\";\n if (\n (ev.errorCode === \"run_timeout\" && ev.recoverable) ||\n isAutoRecoverableError(ev, errMsg)\n ) {\n return {\n action: \"auto_continue\",\n autoContinue: {\n reason:\n ev.errorCode === \"stale_run\"\n ? \"stale_run\"\n : ev.errorCode === \"builder_gateway_timeout\" ||\n ev.errorCode === \"run_timeout\" ||\n errMsg.toLowerCase().includes(\"timeout\")\n ? \"run_timeout\"\n : \"stream_ended\",\n },\n };\n }\n const normalized = normalizeChatError(errMsg, ev.errorCode);\n if (isMissingCredentialText(errMsg, ev.errorCode)) {\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(new Event(\"agent-chat:missing-api-key\"));\n }\n }\n const runError = {\n message: normalized.message,\n ...(normalized.details || ev.details\n ? { details: ev.details ?? normalized.details }\n : {}),\n ...(ev.errorCode ? { errorCode: ev.errorCode } : {}),\n ...(ev.recoverable ? { recoverable: ev.recoverable } : {}),\n };\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(\"agent-chat:run-error\", {\n detail: { ...runError, tabId },\n }),\n );\n }\n settleInterruptedToolCalls(content);\n content.push({\n type: \"text\",\n text: formatChatErrorText(errMsg, ev.upgradeUrl, ev.errorCode),\n });\n return {\n action: \"error\",\n result: {\n content: [...content],\n status: { type: \"incomplete\" as const, reason: \"error\" as const },\n metadata: { custom: { runError } },\n } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"done\") {\n return {\n action: \"done\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n return { action: \"continue\" };\n}\n\n/**\n * Read and process SSE events from a ReadableStream response body.\n * Yields ChatModelRunResult for each meaningful event.\n *\n * When `runId` is provided, every yielded result carries\n * `metadata.custom.runId` so the UI can expose the trace ID via\n * \"Copy Request ID\" — including mid-stream, so users can grab it before\n * the run completes (or if the run hangs / ends prematurely).\n */\nexport async function* readSSEStream(\n body: ReadableStream<Uint8Array>,\n content: ContentPart[],\n toolCallCounter: { value: number },\n tabId: string | undefined,\n onSeq?: (seq: number) => void,\n runId?: string | null,\n): AsyncGenerator<ChatModelRunResult> {\n const reader = body.getReader();\n const decoder = new TextDecoder();\n let buf = \"\";\n let lastMeaningfulEventAt = Date.now();\n const activityTrail: ActivityTrailEntry[] = [];\n\n const withStreamMetadata = (r: ChatModelRunResult): ChatModelRunResult => {\n if (!runId && activityTrail.length === 0) return r;\n const metadata = (r.metadata ?? {}) as Record<string, unknown>;\n const custom =\n metadata.custom && typeof metadata.custom === \"object\"\n ? (metadata.custom as Record<string, unknown>)\n : {};\n const runError =\n runId && custom.runError && typeof custom.runError === \"object\"\n ? {\n ...(custom.runError as Record<string, unknown>),\n runId,\n }\n : custom.runError;\n return {\n ...r,\n metadata: {\n ...metadata,\n custom: {\n ...custom,\n ...(runId ? { runId } : {}),\n ...(runError ? { runError } : {}),\n ...(activityTrail.length > 0\n ? { activityTrail: [...activityTrail] }\n : {}),\n },\n },\n };\n };\n\n try {\n while (true) {\n const { done, value } = await readChunkWithProgressTimeout(\n reader,\n lastMeaningfulEventAt,\n );\n if (done) break;\n\n buf += decoder.decode(value, { stream: true });\n const lines = buf.split(\"\\n\");\n buf = lines.pop() ?? \"\";\n let sawDataEvent = false;\n\n for (const line of lines) {\n if (!line.startsWith(\"data: \")) continue;\n const raw = line.slice(6).trim();\n if (!raw) continue;\n\n let ev: SSEEvent;\n try {\n ev = JSON.parse(raw);\n } catch {\n continue;\n }\n sawDataEvent = true;\n lastMeaningfulEventAt = Date.now();\n\n // Track sequence number for reconnection\n if (ev.seq !== undefined && onSeq) {\n onSeq(ev.seq);\n }\n\n if (ev.type === \"clear\") {\n activityTrail.length = 0;\n } else if (ev.type === \"activity\") {\n const tool = ev.tool?.trim() || undefined;\n appendActivityTrail(activityTrail, {\n label: humanizeToolLabelText(ev.label ?? \"Working\", tool),\n ...(tool ? { tool } : {}),\n });\n } else if (ev.type === \"tool_start\") {\n const tool = ev.tool ?? \"unknown\";\n appendActivityTrail(activityTrail, {\n label: runningToolLabel(tool),\n tool,\n });\n }\n\n const { action, result, autoContinue } = processEvent(\n ev,\n content,\n toolCallCounter,\n tabId,\n );\n\n if (result) yield withStreamMetadata(result);\n if (action === \"auto_continue\") {\n throw new AgentAutoContinueSignal(\n autoContinue\n ? { ...autoContinue, activityTrail: [...activityTrail] }\n : { reason: \"stream_ended\", activityTrail: [...activityTrail] },\n );\n }\n if (\n action === \"done\" ||\n action === \"error\" ||\n action === \"missing_api_key\"\n ) {\n return;\n }\n }\n\n if (\n !sawDataEvent &&\n Date.now() - lastMeaningfulEventAt >= SSE_NO_PROGRESS_TIMEOUT_MS\n ) {\n throw new AgentAutoContinueSignal({ reason: \"no_progress\" });\n }\n }\n } finally {\n try {\n reader.releaseLock();\n } catch {\n // The timeout path cancels the stream before unwinding; some runtimes\n // still consider the pending read active for a tick.\n }\n }\n\n // Stream ended without explicit done event. Even an empty content array is\n // abnormal here: a healthy run emits a terminal `done` event. Treat this as\n // recoverable so the adapter can first reconnect to the run, then continue\n // from durable history if the producer is gone.\n throw new AgentAutoContinueSignal({\n reason: \"stream_ended\",\n activityTrail: [...activityTrail],\n });\n}\n\n/**\n * Read raw SSE events from a ReadableStream and process them into ContentPart[].\n * Unlike readSSEStream, this doesn't yield ChatModelRunResult — it updates the\n * content array in-place and calls onUpdate for each meaningful change.\n * Designed for reconnection scenarios where we render outside assistant-ui's runtime.\n */\nexport async function readSSEStreamRaw(\n body: ReadableStream<Uint8Array>,\n content: ContentPart[],\n toolCallCounter: { value: number },\n tabId: string | undefined,\n onUpdate: (content: ContentPart[]) => void,\n): Promise<void> {\n const reader = body.getReader();\n const decoder = new TextDecoder();\n let buf = \"\";\n let lastMeaningfulEventAt = Date.now();\n // Tracks whether the most recent content state was already pushed via\n // onUpdate inside the loop, so the post-loop flush below doesn't emit the\n // identical content a second time when the stream closes without a terminal\n // event.\n let emittedLatestContent = false;\n\n try {\n while (true) {\n const { done, value } = await readChunkWithProgressTimeout(\n reader,\n lastMeaningfulEventAt,\n );\n if (done) break;\n\n buf += decoder.decode(value, { stream: true });\n const lines = buf.split(\"\\n\");\n buf = lines.pop() ?? \"\";\n\n let updated = false;\n let sawDataEvent = false;\n for (const line of lines) {\n if (!line.startsWith(\"data: \")) continue;\n const raw = line.slice(6).trim();\n if (!raw) continue;\n\n let ev: SSEEvent;\n try {\n ev = JSON.parse(raw);\n } catch {\n continue;\n }\n sawDataEvent = true;\n lastMeaningfulEventAt = Date.now();\n\n const { action, autoContinue } = processEvent(\n ev,\n content,\n toolCallCounter,\n tabId,\n );\n\n if (\n action === \"yield\" ||\n action === \"done\" ||\n action === \"error\" ||\n action === \"missing_api_key\"\n ) {\n updated = true;\n }\n if (action === \"auto_continue\") {\n onUpdate([...content]);\n throw new AgentAutoContinueSignal(\n autoContinue ?? { reason: \"stream_ended\" },\n );\n }\n if (\n action === \"done\" ||\n action === \"error\" ||\n action === \"missing_api_key\"\n ) {\n onUpdate([...content]);\n return;\n }\n }\n\n if (updated) {\n onUpdate([...content]);\n emittedLatestContent = true;\n }\n if (\n !sawDataEvent &&\n Date.now() - lastMeaningfulEventAt >= SSE_NO_PROGRESS_TIMEOUT_MS\n ) {\n throw new AgentAutoContinueSignal({ reason: \"no_progress\" });\n }\n }\n } finally {\n try {\n reader.releaseLock();\n } catch {\n // See readSSEStream: cancellation may race lock release in browsers.\n }\n }\n if (content.length > 0 && !emittedLatestContent) onUpdate([...content]);\n throw new AgentAutoContinueSignal({ reason: \"stream_ended\" });\n}\n"]}
1
+ {"version":3,"file":"sse-event-processor.js","sourceRoot":"","sources":["../../src/client/sse-event-processor.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,kCAAkC,EAClC,+BAA+B,GAChC,MAAM,sCAAsC,CAAC;AAE9C,OAAO,EAAE,mBAAmB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AAyE5E,MAAM,uBAAuB,GAC3B,iDAAiD,CAAC;AAEpD,MAAM,UAAU,0BAA0B,CACxC,OAAsB,EACtB,MAAM,GAAG,uBAAuB;IAEhC,IAAI,OAAO,GAAG,KAAK,CAAC;IACpB,KAAK,MAAM,IAAI,IAAI,OAAO,EAAE,CAAC;QAC3B,IACE,IAAI,CA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AChE,CAAC;gBACD,MAAM,IAAI,uBAAuB,CAAC,EAAE,MAAM,EAAE,aAAa,EAAE,CAAC,CAAC;YAC/D,CAAC;QACH,CAAC;IACH,CAAC;YAAS,CAAC;QACT,IAAI,CAAC;YACH,MAAM,CAAC,WAAW,EAAE,CAAC;QACvB,CAAC;QAAC,MAAM,CAAC;YACP,qEAAqE;QACvE,CAAC;IACH,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,IAAI,CAAC,oBAAoB;QAAE,QAAQ,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IACxE,MAAM,IAAI,uBAAuB,CAAC,EAAE,MAAM,EAAE,cAAc,EAAE,CAAC,CAAC;AAChE,CAAC","sourcesContent":["import type { ChatModelRunResult } from \"@assistant-ui/react\";\nimport type { ActionChatUIConfig } from \"../action-ui.js\";\nimport {\n LLM_MISSING_CREDENTIALS_ERROR_CODE,\n LLM_MISSING_CREDENTIALS_MESSAGE,\n} from \"../agent/engine/credential-errors.js\";\nimport type { AgentMcpAppPayload } from \"../mcp-client/app-result.js\";\nimport { formatChatErrorText, normalizeChatError } from \"./error-format.js\";\nimport { humanizeToolLabelText, runningToolLabel } from \"./tool-display.js\";\n\nexport type ContentPart =\n | { type: \"text\"; text: string }\n | {\n type: \"tool-call\";\n toolCallId: string;\n toolName: string;\n argsText: string;\n args: Record<string, string>;\n result?: string;\n mcpApp?: AgentMcpAppPayload;\n chatUI?: ActionChatUIConfig;\n activity?: boolean;\n /**\n * Set when the server emitted an `approval_required` event for this tool\n * call (opt-in `needsApproval` actions). The action did NOT run; the UI\n * renders an Approve/Deny affordance. `approvalKey` is echoed back in\n * `approvedToolCalls` to approve, `dismissed` records a local Deny.\n */\n approval?: { approvalKey: string; dismissed?: boolean };\n /**\n * Structured metadata from the coding-tools executor side-channel.\n * Present only on code-agent tool calls from executors new enough to\n * emit it. The `toolKind` discriminant identifies the shape.\n */\n structuredMeta?: Record<string, unknown>;\n };\n\nexport interface SSEEvent {\n type: string;\n text?: string;\n tool?: string;\n /** Server-assigned call identifier emitted on tool_start / tool_done events. */\n id?: string;\n label?: string;\n input?: Record<string, string>;\n result?: string;\n mcpApp?: AgentMcpAppPayload;\n chatUI?: ActionChatUIConfig;\n /** Stable key the client echoes back in `approvedToolCalls` to approve a\n * paused `needsApproval` tool call. Present on `approval_required` events. */\n approvalKey?: string;\n error?: string;\n seq?: number;\n agent?: string;\n status?: string;\n reason?: string;\n // Agent task fields\n taskId?: string;\n threadId?: string;\n description?: string;\n preview?: string;\n currentStep?: string;\n summary?: string;\n // Structured error metadata — Builder gateway sets these on quota/auth/setup\n // failures so the UI can render a CTA alongside the error text.\n errorCode?: string;\n upgradeUrl?: string;\n details?: string;\n recoverable?: boolean;\n maxIterations?: number;\n}\n\nexport type AgentAutoContinueReason =\n | \"run_timeout\"\n | \"loop_limit\"\n | \"no_progress\"\n | \"stream_ended\"\n | \"stale_run\";\n\nexport type AgentActivityTrailEntry = { label: string; tool?: string };\n\nconst INTERRUPTED_TOOL_RESULT =\n \"Interrupted before this tool returned a result.\";\n\nexport function settleInterruptedToolCalls(\n content: ContentPart[],\n result = INTERRUPTED_TOOL_RESULT,\n): boolean {\n let changed = false;\n for (const part of content) {\n if (\n part.type === \"tool-call\" &&\n part.result === undefined &&\n part.activity !== true\n ) {\n part.result = result;\n changed = true;\n }\n }\n return changed;\n}\n\nexport class AgentAutoContinueSignal extends Error {\n readonly reason: AgentAutoContinueReason;\n readonly maxIterations?: number;\n readonly activityTrail: AgentActivityTrailEntry[];\n\n constructor(options: {\n reason: AgentAutoContinueReason;\n maxIterations?: number;\n activityTrail?: AgentActivityTrailEntry[];\n }) {\n super(`Agent run needs automatic continuation: ${options.reason}`);\n this.name = \"AgentAutoContinueSignal\";\n this.reason = options.reason;\n this.maxIterations = options.maxIterations;\n this.activityTrail = options.activityTrail ?? [];\n }\n}\n\nexport const SSE_NO_PROGRESS_TIMEOUT_MS = 75_000;\n\ntype ActivityTrailEntry = AgentActivityTrailEntry;\n\nfunction findPendingToolCallIndex(\n content: ContentPart[],\n toolName: string,\n toolCallId?: string,\n): number {\n // Prefer id-based match when the event carries an id: parallel same-name\n // calls can be in flight simultaneously, and name-only matching would\n // attach a result to the wrong call.\n if (toolCallId) {\n for (let i = content.length - 1; i >= 0; i--) {\n const part = content[i];\n if (\n part.type === \"tool-call\" &&\n part.toolCallId === toolCallId &&\n part.result === undefined\n ) {\n return i;\n }\n }\n // Fall through to name-matching: the start event may have arrived before\n // the server started emitting ids (e.g. older server build), so the\n // stored toolCallId is the locally-generated \"tc_N\" value rather than the\n // server-assigned one. In that case match by name as a fallback.\n }\n for (let i = content.length - 1; i >= 0; i--) {\n const part = content[i];\n if (\n part.type === \"tool-call\" &&\n part.toolName === toolName &&\n part.result === undefined\n ) {\n return i;\n }\n }\n return -1;\n}\n\nfunction appendActivityTrail(\n trail: ActivityTrailEntry[],\n next: ActivityTrailEntry,\n) {\n const label = next.label.trim();\n if (!label) return;\n const tool = next.tool?.trim();\n const last = trail[trail.length - 1];\n if (last?.label === label && last.tool === tool) return;\n trail.push({ label, ...(tool ? { tool } : {}) });\n if (trail.length > 8) {\n trail.splice(0, trail.length - 8);\n }\n}\n\nasync function readChunkWithProgressTimeout(\n reader: ReadableStreamDefaultReader<Uint8Array>,\n lastMeaningfulEventAt: number,\n): Promise<ReadableStreamReadResult<Uint8Array>> {\n const elapsed = Date.now() - lastMeaningfulEventAt;\n const timeoutMs = Math.max(0, SSE_NO_PROGRESS_TIMEOUT_MS - elapsed);\n let timeoutId: ReturnType<typeof setTimeout> | null = null;\n const readPromise = reader.read();\n // If the timeout wins and cancellation causes the pending read to reject,\n // swallow that rejection because the generator is already recovering.\n void readPromise.catch(() => {});\n\n const timeoutPromise = new Promise<\"timeout\">((resolve) => {\n timeoutId = setTimeout(() => resolve(\"timeout\"), timeoutMs);\n });\n const result = await Promise.race([readPromise, timeoutPromise]);\n if (timeoutId) {\n clearTimeout(timeoutId);\n }\n if (result === \"timeout\") {\n await reader.cancel(\"no_progress\").catch(() => {});\n throw new AgentAutoContinueSignal({ reason: \"no_progress\" });\n }\n return result;\n}\n\nfunction isAutoRecoverableError(ev: SSEEvent, errMsg: string): boolean {\n const code = String(ev.errorCode ?? \"\").toLowerCase();\n const msg = errMsg.toLowerCase();\n\n if (\n code === \"context_length_exceeded\" ||\n code === \"input_too_long\" ||\n code.startsWith(\"credits-limit\") ||\n code === \"billing_error\" ||\n code === \"unauthorized\" ||\n code === \"authentication_error\" ||\n code === \"permission_error\" ||\n code === \"http_401\" ||\n code === \"http_403\" ||\n code === \"rate_limit_exceeded\" ||\n code === \"gateway_not_enabled\" ||\n code === \"missing_api_key\" ||\n code === \"missing_credentials\" ||\n code === \"invalid_request_error\" ||\n code === \"request_too_large\" ||\n code === \"not_found_error\" ||\n code === \"model_not_found\" ||\n code === \"provider_rate_limited\" ||\n // `builder_gateway_error` is the no-detail fallback the Builder engine\n // emits when the gateway returns `{type:\"stop\",reason:\"error\"}` with no\n // explanation — almost always the upstream provider giving up (model\n // quota hit, account misconfiguration, opaque downstream failure). The\n // production-agent already retries this synchronously up to MAX_RETRIES\n // before the error escapes to the SSE stream, so by the time the client\n // sees it, retrying again with another POST /agent-chat will hit the\n // same wall. This used to send the chat into a 32-continuation runaway\n // (each turn cleared+regenerated visible content) for users hitting a\n // misbehaving Builder route. Surface the error instead.\n code === \"builder_gateway_error\"\n ) {\n return false;\n }\n\n if (\n code === \"builder_gateway_network_error\" ||\n code === \"builder_gateway_timeout\" ||\n code === \"stale_run\" ||\n code === \"timeout\" ||\n code === \"timeout_error\" ||\n code === \"http_408\" ||\n code === \"http_429\" ||\n code === \"http_500\" ||\n code === \"http_502\" ||\n code === \"http_503\" ||\n code === \"http_504\" ||\n code === \"rate_limited\" ||\n code === \"too_many_concurrent_requests\" ||\n code === \"overloaded_error\"\n ) {\n return true;\n }\n\n if (ev.recoverable === true) return true;\n\n if (msg.includes(\"daily gateway request cap\")) return false;\n\n // \"gateway error\" intentionally absent — that's the no-detail Builder\n // gateway fallback and the production-agent already retries it\n // synchronously up to MAX_RETRIES before the error escapes here. Treating\n // it as auto-recoverable on top of that produced a 32-continuation\n // runaway in production for users hitting a misbehaving Builder route.\n // (See `code === \"builder_gateway_error\"` in the not-recoverable list.)\n return (\n msg.includes(\"overloaded\") ||\n msg.includes(\"rate_limit\") ||\n msg.includes(\"too many requests\") ||\n msg.includes(\"timeout\") ||\n msg.includes(\"gateway timeout\") ||\n msg.includes(\"inactivity timeout\") ||\n msg.includes(\"socket hang up\") ||\n msg.includes(\"connection reset\") ||\n msg.includes(\"connection\") ||\n msg.includes(\"network\") ||\n msg.includes(\"stream closed\") ||\n msg.includes(\"stream ended\") ||\n msg.includes(\"temporarily unavailable\") ||\n msg.includes(\"502\") ||\n msg.includes(\"503\") ||\n msg.includes(\"504\") ||\n msg.includes(\"529\")\n );\n}\n\nfunction isMissingCredentialText(message: string, errorCode?: string): boolean {\n const code = String(errorCode ?? \"\").toLowerCase();\n const msg = message.toLowerCase();\n return (\n code === \"missing_api_key\" ||\n code === \"missing_credentials\" ||\n msg.includes(\"apikey\") ||\n msg.includes(\"authtoken\") ||\n msg.includes(\"anthropic_api_key\") ||\n msg.includes(\"missing_api_key\") ||\n msg.includes(\"missing api key\") ||\n msg.includes(\"missing credentials\") ||\n msg.includes(\"no llm provider\") ||\n msg.includes(\"llm provider is connected\")\n );\n}\n\nfunction dispatchActivityClear(tabId: string | undefined) {\n if (typeof window === \"undefined\") return;\n window.dispatchEvent(\n new CustomEvent(\"agent-chat:activity-clear\", {\n detail: { tabId },\n }),\n );\n}\n\n/**\n * Process a single SSE event and update the content accumulator.\n * Returns: \"continue\" to keep going, \"done\" to stop, or a yield-ready result.\n */\nexport function processEvent(\n ev: SSEEvent,\n content: ContentPart[],\n toolCallCounter: { value: number },\n tabId: string | undefined,\n): {\n action:\n | \"continue\"\n | \"done\"\n | \"yield\"\n | \"error\"\n | \"missing_api_key\"\n | \"auto_continue\";\n result?: ChatModelRunResult;\n autoContinue?: {\n reason: AgentAutoContinueReason;\n maxIterations?: number;\n };\n} {\n if (ev.type === \"clear\") {\n // Server is retrying — discard partial text/tool output from the failed attempt\n content.length = 0;\n dispatchActivityClear(tabId);\n return { action: \"continue\" };\n }\n\n if (ev.type === \"text\") {\n const lastPart = content[content.length - 1];\n if (lastPart && lastPart.type === \"text\") {\n lastPart.text += ev.text ?? \"\";\n } else {\n content.push({ type: \"text\", text: ev.text ?? \"\" });\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"stream_keepalive\") {\n return { action: \"continue\" };\n }\n\n if (ev.type === \"activity\") {\n const tool = ev.tool?.trim() || undefined;\n const label = humanizeToolLabelText(ev.label ?? \"Working\", tool);\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(\"agent-chat:activity\", {\n detail: {\n label,\n ...(tool ? { tool } : {}),\n tabId,\n },\n }),\n );\n }\n if (!tool) return { action: \"continue\" };\n\n const pendingToolCallIndex = findPendingToolCallIndex(content, tool);\n if (pendingToolCallIndex === -1) {\n content.push({\n type: \"tool-call\",\n toolCallId: `tc_${++toolCallCounter.value}`,\n toolName: tool,\n argsText: \"\",\n args: {},\n activity: true,\n });\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"tool_start\") {\n const args = (ev.input ?? {}) as Record<string, string>;\n const tool = ev.tool ?? \"unknown\";\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(\"agent-native:tool-start\", {\n detail: { tool, input: args },\n }),\n );\n window.dispatchEvent(\n new CustomEvent(\"agent-chat:activity\", {\n detail: {\n label: runningToolLabel(tool),\n tool,\n tabId,\n },\n }),\n );\n }\n // Pass the server-assigned id so we upgrade the pending activity card\n // using id-match when available (parallel same-name calls stay separate).\n const pendingToolCallIndex = findPendingToolCallIndex(content, tool, ev.id);\n const pendingToolCall =\n pendingToolCallIndex >= 0 ? content[pendingToolCallIndex] : undefined;\n if (\n pendingToolCall &&\n pendingToolCall.type === \"tool-call\" &&\n pendingToolCall.activity === true &&\n pendingToolCall.argsText === \"\" &&\n Object.keys(pendingToolCall.args).length === 0\n ) {\n // Upgrade the pending activity card in place. Prefer the server-assigned\n // id so the subsequent tool_done can match it precisely (parallel\n // same-name calls each carry their own id). Fall back to the\n // locally-generated id already on the card.\n content[pendingToolCallIndex] = {\n type: \"tool-call\",\n toolCallId: ev.id ?? pendingToolCall.toolCallId,\n toolName: tool,\n argsText: JSON.stringify(args),\n args,\n };\n } else {\n content.push({\n type: \"tool-call\",\n toolCallId: ev.id ?? `tc_${++toolCallCounter.value}`,\n toolName: tool,\n argsText: JSON.stringify(args),\n args,\n });\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"approval_required\") {\n // Opt-in `needsApproval` gate: the server emitted `tool_start` immediately\n // before this, so the matching tool-call part already exists. Mark it as\n // awaiting approval so the UI can render the Approve/Deny affordance. The\n // action did NOT execute; a paused `tool_done` follows.\n const approvalTool = ev.tool ?? \"unknown\";\n const approvalKey = ev.approvalKey;\n if (approvalKey) {\n const idx = findPendingToolCallIndex(content, approvalTool, ev.id);\n if (idx >= 0) {\n const part = content[idx];\n if (part.type === \"tool-call\") {\n part.approval = { approvalKey };\n }\n }\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"tool_done\") {\n // Normalize identically to tool_start (which stores `ev.tool ?? \"unknown\"`)\n // so a tool_done frame with an undefined tool name still matches its\n // pending tool-call entry instead of leaving it forever unresolved.\n const doneTool = ev.tool ?? \"unknown\";\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(\"agent-native:tool-done\", {\n detail: { tool: doneTool, result: ev.result },\n }),\n );\n }\n // Use id-based lookup when available so parallel same-name tool calls\n // get their results correctly assigned; fall back to name-matching.\n const doneIdx = findPendingToolCallIndex(content, doneTool, ev.id);\n if (doneIdx >= 0) {\n const part = content[doneIdx];\n if (part.type === \"tool-call\") {\n part.result = ev.result ?? \"\";\n if (ev.mcpApp) part.mcpApp = ev.mcpApp;\n if (ev.chatUI) part.chatUI = ev.chatUI;\n }\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"agent_call\") {\n const agentName = ev.agent ?? \"agent\";\n if (ev.status === \"start\") {\n const toolCallId = `tc_${++toolCallCounter.value}`;\n content.push({\n type: \"tool-call\",\n toolCallId,\n toolName: `agent:${agentName}`,\n argsText: \"\",\n args: {},\n });\n } else if (ev.status === \"done\" || ev.status === \"error\") {\n for (let i = content.length - 1; i >= 0; i--) {\n const part = content[i];\n if (\n part.type === \"tool-call\" &&\n part.toolName === `agent:${agentName}` &&\n part.result === undefined\n ) {\n part.result = ev.status === \"error\" ? \"Error calling agent\" : \"Done\";\n break;\n }\n }\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"agent_call_text\") {\n const agentName = ev.agent ?? \"agent\";\n // Find the in-progress agent tool-call and append streaming text to argsText\n for (let i = content.length - 1; i >= 0; i--) {\n const part = content[i];\n if (\n part.type === \"tool-call\" &&\n part.toolName === `agent:${agentName}` &&\n part.result === undefined\n ) {\n part.argsText += ev.text ?? \"\";\n break;\n }\n }\n return {\n action: \"yield\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n // ─── Agent task events (sub-agent chips) ─────────────────────────\n // These events are dispatched as CustomEvents so AgentTaskCard components\n // can listen for updates to their specific taskId.\n if (\n ev.type === \"agent_task\" ||\n ev.type === \"agent_task_update\" ||\n ev.type === \"agent_task_complete\"\n ) {\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(new CustomEvent(\"agent-task-event\", { detail: ev }));\n }\n // Don't add to content — the agent-teams tool call handles rendering\n return { action: \"continue\" };\n }\n\n if (ev.type === \"missing_api_key\") {\n const errMsg = LLM_MISSING_CREDENTIALS_MESSAGE;\n const errorCode = LLM_MISSING_CREDENTIALS_ERROR_CODE;\n const runError = {\n message: normalizeChatError(errMsg, errorCode).message,\n errorCode,\n };\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(new Event(\"agent-chat:missing-api-key\"));\n window.dispatchEvent(\n new CustomEvent(\"agent-chat:run-error\", {\n detail: { ...runError, tabId },\n }),\n );\n }\n settleInterruptedToolCalls(content);\n content.push({\n type: \"text\",\n text: formatChatErrorText(errMsg, undefined, errorCode),\n });\n return {\n action: \"missing_api_key\",\n result: {\n content: [...content],\n status: { type: \"incomplete\" as const, reason: \"error\" as const },\n metadata: { custom: { runError } },\n } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"loop_limit\") {\n const maxIterations =\n typeof ev.maxIterations === \"number\" ? ev.maxIterations : undefined;\n return {\n action: \"auto_continue\",\n autoContinue: {\n reason: \"loop_limit\",\n ...(maxIterations ? { maxIterations } : {}),\n },\n };\n }\n\n if (ev.type === \"auto_continue\") {\n const reason =\n ev.reason === \"stream_ended\" ||\n ev.reason === \"loop_limit\" ||\n ev.reason === \"no_progress\" ||\n ev.reason === \"run_timeout\"\n ? ev.reason\n : ev.errorCode === \"stream_ended\" ||\n ev.errorCode === \"loop_limit\" ||\n ev.errorCode === \"no_progress\" ||\n ev.errorCode === \"run_timeout\"\n ? ev.errorCode\n : ev.error === \"stream_ended\" ||\n ev.error === \"loop_limit\" ||\n ev.error === \"no_progress\" ||\n ev.error === \"run_timeout\"\n ? ev.error\n : ev.status === \"stream_ended\" ||\n ev.status === \"loop_limit\" ||\n ev.status === \"no_progress\" ||\n ev.status === \"run_timeout\"\n ? ev.status\n : \"run_timeout\";\n return {\n action: \"auto_continue\",\n autoContinue: {\n reason,\n ...(typeof ev.maxIterations === \"number\"\n ? { maxIterations: ev.maxIterations }\n : {}),\n },\n };\n }\n\n if (ev.type === \"error\") {\n const errMsg = ev.error ?? \"Unknown error\";\n if (\n (ev.errorCode === \"run_timeout\" && ev.recoverable) ||\n isAutoRecoverableError(ev, errMsg)\n ) {\n return {\n action: \"auto_continue\",\n autoContinue: {\n reason:\n ev.errorCode === \"stale_run\"\n ? \"stale_run\"\n : ev.errorCode === \"builder_gateway_timeout\" ||\n ev.errorCode === \"run_timeout\" ||\n errMsg.toLowerCase().includes(\"timeout\")\n ? \"run_timeout\"\n : \"stream_ended\",\n },\n };\n }\n const normalized = normalizeChatError(errMsg, ev.errorCode);\n if (isMissingCredentialText(errMsg, ev.errorCode)) {\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(new Event(\"agent-chat:missing-api-key\"));\n }\n }\n const runError = {\n message: normalized.message,\n ...(normalized.details || ev.details\n ? { details: ev.details ?? normalized.details }\n : {}),\n ...(ev.errorCode ? { errorCode: ev.errorCode } : {}),\n ...(ev.recoverable ? { recoverable: ev.recoverable } : {}),\n };\n if (typeof window !== \"undefined\") {\n window.dispatchEvent(\n new CustomEvent(\"agent-chat:run-error\", {\n detail: { ...runError, tabId },\n }),\n );\n }\n settleInterruptedToolCalls(content);\n content.push({\n type: \"text\",\n text: formatChatErrorText(errMsg, ev.upgradeUrl, ev.errorCode),\n });\n return {\n action: \"error\",\n result: {\n content: [...content],\n status: { type: \"incomplete\" as const, reason: \"error\" as const },\n metadata: { custom: { runError } },\n } as ChatModelRunResult,\n };\n }\n\n if (ev.type === \"done\") {\n return {\n action: \"done\",\n result: { content: [...content] } as ChatModelRunResult,\n };\n }\n\n return { action: \"continue\" };\n}\n\n/**\n * Read and process SSE events from a ReadableStream response body.\n * Yields ChatModelRunResult for each meaningful event.\n *\n * When `runId` is provided, every yielded result carries\n * `metadata.custom.runId` so the UI can expose the trace ID via\n * \"Copy Request ID\" — including mid-stream, so users can grab it before\n * the run completes (or if the run hangs / ends prematurely).\n */\nexport async function* readSSEStream(\n body: ReadableStream<Uint8Array>,\n content: ContentPart[],\n toolCallCounter: { value: number },\n tabId: string | undefined,\n onSeq?: (seq: number) => void,\n runId?: string | null,\n): AsyncGenerator<ChatModelRunResult> {\n const reader = body.getReader();\n const decoder = new TextDecoder();\n let buf = \"\";\n let lastMeaningfulEventAt = Date.now();\n const activityTrail: ActivityTrailEntry[] = [];\n\n const withStreamMetadata = (r: ChatModelRunResult): ChatModelRunResult => {\n if (!runId && activityTrail.length === 0) return r;\n const metadata = (r.metadata ?? {}) as Record<string, unknown>;\n const custom =\n metadata.custom && typeof metadata.custom === \"object\"\n ? (metadata.custom as Record<string, unknown>)\n : {};\n const runError =\n runId && custom.runError && typeof custom.runError === \"object\"\n ? {\n ...(custom.runError as Record<string, unknown>),\n runId,\n }\n : custom.runError;\n return {\n ...r,\n metadata: {\n ...metadata,\n custom: {\n ...custom,\n ...(runId ? { runId } : {}),\n ...(runError ? { runError } : {}),\n ...(activityTrail.length > 0\n ? { activityTrail: [...activityTrail] }\n : {}),\n },\n },\n };\n };\n\n try {\n while (true) {\n const { done, value } = await readChunkWithProgressTimeout(\n reader,\n lastMeaningfulEventAt,\n );\n if (done) break;\n\n buf += decoder.decode(value, { stream: true });\n const lines = buf.split(\"\\n\");\n buf = lines.pop() ?? \"\";\n let sawDataEvent = false;\n\n for (const line of lines) {\n if (!line.startsWith(\"data: \")) continue;\n const raw = line.slice(6).trim();\n if (!raw) continue;\n\n let ev: SSEEvent;\n try {\n ev = JSON.parse(raw);\n } catch {\n continue;\n }\n sawDataEvent = true;\n lastMeaningfulEventAt = Date.now();\n\n // Track sequence number for reconnection\n if (ev.seq !== undefined && onSeq) {\n onSeq(ev.seq);\n }\n\n if (ev.type === \"clear\") {\n activityTrail.length = 0;\n } else if (ev.type === \"activity\") {\n const tool = ev.tool?.trim() || undefined;\n appendActivityTrail(activityTrail, {\n label: humanizeToolLabelText(ev.label ?? \"Working\", tool),\n ...(tool ? { tool } : {}),\n });\n } else if (ev.type === \"tool_start\") {\n const tool = ev.tool ?? \"unknown\";\n appendActivityTrail(activityTrail, {\n label: runningToolLabel(tool),\n tool,\n });\n }\n\n const { action, result, autoContinue } = processEvent(\n ev,\n content,\n toolCallCounter,\n tabId,\n );\n\n if (result) yield withStreamMetadata(result);\n if (action === \"auto_continue\") {\n throw new AgentAutoContinueSignal(\n autoContinue\n ? { ...autoContinue, activityTrail: [...activityTrail] }\n : { reason: \"stream_ended\", activityTrail: [...activityTrail] },\n );\n }\n if (\n action === \"done\" ||\n action === \"error\" ||\n action === \"missing_api_key\"\n ) {\n return;\n }\n }\n\n if (\n !sawDataEvent &&\n Date.now() - lastMeaningfulEventAt >= SSE_NO_PROGRESS_TIMEOUT_MS\n ) {\n throw new AgentAutoContinueSignal({ reason: \"no_progress\" });\n }\n }\n } finally {\n try {\n reader.releaseLock();\n } catch {\n // The timeout path cancels the stream before unwinding; some runtimes\n // still consider the pending read active for a tick.\n }\n }\n\n // Stream ended without explicit done event. Even an empty content array is\n // abnormal here: a healthy run emits a terminal `done` event. Treat this as\n // recoverable so the adapter can first reconnect to the run, then continue\n // from durable history if the producer is gone.\n throw new AgentAutoContinueSignal({\n reason: \"stream_ended\",\n activityTrail: [...activityTrail],\n });\n}\n\n/**\n * Read raw SSE events from a ReadableStream and process them into ContentPart[].\n * Unlike readSSEStream, this doesn't yield ChatModelRunResult — it updates the\n * content array in-place and calls onUpdate for each meaningful change.\n * Designed for reconnection scenarios where we render outside assistant-ui's runtime.\n */\nexport async function readSSEStreamRaw(\n body: ReadableStream<Uint8Array>,\n content: ContentPart[],\n toolCallCounter: { value: number },\n tabId: string | undefined,\n onUpdate: (content: ContentPart[]) => void,\n onSeq?: (seq: number) => void,\n): Promise<void> {\n const reader = body.getReader();\n const decoder = new TextDecoder();\n let buf = \"\";\n let lastMeaningfulEventAt = Date.now();\n // Tracks whether the most recent content state was already pushed via\n // onUpdate inside the loop, so the post-loop flush below doesn't emit the\n // identical content a second time when the stream closes without a terminal\n // event.\n let emittedLatestContent = false;\n\n try {\n while (true) {\n const { done, value } = await readChunkWithProgressTimeout(\n reader,\n lastMeaningfulEventAt,\n );\n if (done) break;\n\n buf += decoder.decode(value, { stream: true });\n const lines = buf.split(\"\\n\");\n buf = lines.pop() ?? \"\";\n\n let updated = false;\n let sawDataEvent = false;\n for (const line of lines) {\n if (!line.startsWith(\"data: \")) continue;\n const raw = line.slice(6).trim();\n if (!raw) continue;\n\n let ev: SSEEvent;\n try {\n ev = JSON.parse(raw);\n } catch {\n continue;\n }\n sawDataEvent = true;\n lastMeaningfulEventAt = Date.now();\n\n if (ev.seq !== undefined && onSeq) {\n onSeq(ev.seq);\n }\n\n const { action, autoContinue } = processEvent(\n ev,\n content,\n toolCallCounter,\n tabId,\n );\n\n if (\n action === \"yield\" ||\n action === \"done\" ||\n action === \"error\" ||\n action === \"missing_api_key\"\n ) {\n updated = true;\n }\n if (action === \"auto_continue\") {\n onUpdate([...content]);\n throw new AgentAutoContinueSignal(\n autoContinue ?? { reason: \"stream_ended\" },\n );\n }\n if (\n action === \"done\" ||\n action === \"error\" ||\n action === \"missing_api_key\"\n ) {\n onUpdate([...content]);\n return;\n }\n }\n\n if (updated) {\n onUpdate([...content]);\n emittedLatestContent = true;\n }\n if (\n !sawDataEvent &&\n Date.now() - lastMeaningfulEventAt >= SSE_NO_PROGRESS_TIMEOUT_MS\n ) {\n throw new AgentAutoContinueSignal({ reason: \"no_progress\" });\n }\n }\n } finally {\n try {\n reader.releaseLock();\n } catch {\n // See readSSEStream: cancellation may race lock release in browsers.\n }\n }\n if (content.length > 0 && !emittedLatestContent) onUpdate([...content]);\n throw new AgentAutoContinueSignal({ reason: \"stream_ended\" });\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"google-refresh.d.ts","sourceRoot":"","sources":["../../src/oauth-tokens/google-refresh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA+CH;;;;GAIG;AACH,wBAAsB,2BAA2B,CAC/C,IAAI,GAAE;IACJ,QAAQ,CAAC,EAAE,MAAM,CAAC;CACd,GACL,OAAO,CAAC,IAAI,CAAC,CAsCf;AAKD;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,GAAE;IACJ,8CAA8C;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACd,GACL,IAAI,CAsCN"}
1
+ {"version":3,"file":"google-refresh.d.ts","sourceRoot":"","sources":["../../src/oauth-tokens/google-refresh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AA8DH;;;;GAIG;AACH,wBAAsB,2BAA2B,CAC/C,IAAI,GAAE;IACJ,QAAQ,CAAC,EAAE,MAAM,CAAC;CACd,GACL,OAAO,CAAC,IAAI,CAAC,CAsCf;AAKD;;;GAGG;AACH,wBAAgB,2BAA2B,CACzC,IAAI,GAAE;IACJ,8CAA8C;IAC9C,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,uEAAuE;IACvE,QAAQ,CAAC,EAAE,MAAM,CAAC;CACd,GACL,IAAI,CAsCN"}
@@ -11,31 +11,43 @@
11
11
  * server plugin (see `templates/mail/server/plugins/oauth-refresh.ts`).
12
12
  */
13
13
  import { listOAuthAccounts, saveOAuthTokens } from "./store.js";
14
+ import { resolveGoogleProviderCredentialCandidates } from "../server/google-oauth-credentials.js";
14
15
  const GOOGLE_TOKEN_URL = "https://oauth2.googleapis.com/token";
15
16
  async function refreshOne(refreshToken) {
16
- const clientId = process.env.GOOGLE_CLIENT_ID;
17
- const clientSecret = process.env.GOOGLE_CLIENT_SECRET;
18
- if (!clientId || !clientSecret) {
17
+ const credentialCandidates = resolveGoogleProviderCredentialCandidates();
18
+ if (!credentialCandidates.length) {
19
19
  throw new Error("GOOGLE_CLIENT_ID/SECRET not set");
20
20
  }
21
- const res = await fetch(GOOGLE_TOKEN_URL, {
22
- method: "POST",
23
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
24
- body: new URLSearchParams({
25
- refresh_token: refreshToken,
26
- client_id: clientId,
27
- client_secret: clientSecret,
28
- grant_type: "refresh_token",
29
- }),
30
- });
31
- const data = (await res.json());
32
- if (!res.ok) {
21
+ let data = null;
22
+ let lastStatusText = "refresh failed";
23
+ for (const credentials of credentialCandidates) {
24
+ const res = await fetch(GOOGLE_TOKEN_URL, {
25
+ method: "POST",
26
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
27
+ body: new URLSearchParams({
28
+ refresh_token: refreshToken,
29
+ client_id: credentials.clientId,
30
+ client_secret: credentials.clientSecret,
31
+ grant_type: "refresh_token",
32
+ }),
33
+ });
34
+ lastStatusText = res.statusText;
35
+ data = (await res.json());
36
+ if (res.ok)
37
+ return data;
38
+ if (data.error !== "invalid_grant" &&
39
+ data.error !== "unauthorized_client" &&
40
+ data.error !== "invalid_client") {
41
+ break;
42
+ }
43
+ }
44
+ if (data) {
33
45
  const err = (data.error_description ||
34
46
  data.error ||
35
- res.statusText);
47
+ lastStatusText);
36
48
  throw new Error(err);
37
49
  }
38
- return data;
50
+ throw new Error(lastStatusText);
39
51
  }
40
52
  /**
41
53
  * Scan all stored Google tokens and refresh any expiring within `bufferMs`.