@agent-native/core 0.68.1 → 0.68.3

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 (129) hide show
  1. package/README.md +4 -4
  2. package/corpus/README.md +2 -2
  3. package/corpus/core/CHANGELOG.md +16 -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 +35 -2
  7. package/corpus/core/package.json +1 -1
  8. package/corpus/core/src/cli/pr-visual-recap-workflow.ts +1 -1
  9. package/corpus/core/src/client/AgentPanel.tsx +2 -4
  10. package/corpus/core/src/client/CommandMenu.tsx +98 -3
  11. package/corpus/core/src/client/ConnectBuilderCard.tsx +11 -2
  12. package/corpus/core/src/client/index.ts +2 -0
  13. package/corpus/core/src/extensions/content-patch.ts +12 -2
  14. package/corpus/core/src/oauth-tokens/google-refresh.ts +32 -17
  15. package/corpus/core/src/provider-api/index.ts +37 -17
  16. package/corpus/core/src/server/auth.ts +6 -8
  17. package/corpus/core/src/server/better-auth-instance.ts +19 -4
  18. package/corpus/core/src/server/core-routes-plugin.ts +157 -5
  19. package/corpus/core/src/server/google-oauth-credentials.ts +51 -0
  20. package/corpus/core/src/server/index.ts +8 -0
  21. package/corpus/core/src/server/onboarding-html.ts +2 -1
  22. package/corpus/core/src/server/social-og-image.ts +6 -1
  23. package/corpus/core/src/vite/client.ts +83 -1
  24. package/corpus/templates/analytics/app/routes/$.tsx +9 -0
  25. package/corpus/templates/calendar/app/components/calendar/DayView.tsx +33 -1
  26. package/corpus/templates/calendar/app/components/calendar/EventAttendeesSection.tsx +11 -3
  27. package/corpus/templates/calendar/app/components/calendar/EventCard.tsx +25 -2
  28. package/corpus/templates/calendar/app/components/calendar/EventDetailPanel.tsx +12 -0
  29. package/corpus/templates/calendar/app/components/calendar/EventDetailPopover.tsx +7 -2
  30. package/corpus/templates/calendar/app/components/calendar/GoogleConnectBanner.tsx +37 -78
  31. package/corpus/templates/calendar/app/components/calendar/WeekView.tsx +33 -1
  32. package/corpus/templates/calendar/app/components/layout/Sidebar.tsx +46 -3
  33. package/corpus/templates/calendar/app/hooks/use-google-auth.ts +203 -2
  34. package/corpus/templates/calendar/app/lib/event-colors.ts +1 -4
  35. package/corpus/templates/calendar/app/lib/rsvp-status.tsx +6 -0
  36. package/corpus/templates/calendar/app/pages/CalendarView.tsx +9 -4
  37. package/corpus/templates/calendar/app/pages/NotFound.tsx +1 -1
  38. package/corpus/templates/calendar/app/pages/Settings.tsx +25 -1
  39. package/corpus/templates/calendar/app/routes/_app.$.tsx +9 -0
  40. package/corpus/templates/calendar/server/handlers/google-auth.ts +152 -12
  41. package/corpus/templates/calendar/server/lib/google-calendar.ts +63 -14
  42. package/corpus/templates/calendar/server/plugins/auth.ts +4 -20
  43. package/corpus/templates/calendar/shared/api.ts +4 -0
  44. package/corpus/templates/clips/.agents/skills/recording/SKILL.md +17 -0
  45. package/corpus/templates/clips/actions/sync-calendars.ts +6 -7
  46. package/corpus/templates/clips/app/components/capture-install-options.tsx +157 -0
  47. package/corpus/templates/clips/app/components/library/library-layout.tsx +9 -8
  48. package/corpus/templates/clips/app/components/recorder/pre-record-panel.tsx +4 -6
  49. package/corpus/templates/clips/app/lib/capture-install-options.ts +14 -0
  50. package/corpus/templates/clips/app/root.tsx +54 -2
  51. package/corpus/templates/clips/app/routes/_app.dictate.tsx +9 -13
  52. package/corpus/templates/clips/app/routes/_app.meetings.$meetingId.tsx +5 -7
  53. package/corpus/templates/clips/app/routes/_app.meetings._index.tsx +5 -7
  54. package/corpus/templates/clips/app/routes/download.tsx +49 -0
  55. package/corpus/templates/clips/app/routes/record.tsx +4 -4
  56. package/corpus/templates/clips/app/routes/share.$shareId.tsx +5 -6
  57. package/corpus/templates/clips/chrome-extension/STORE_DRAFT.md +29 -0
  58. package/corpus/templates/clips/server/lib/calendar-event-meetings.ts +6 -7
  59. package/corpus/templates/clips/server/lib/google-calendar-client.ts +61 -0
  60. package/corpus/templates/clips/server/routes/_agent-native/google/auth-url.get.ts +19 -12
  61. package/corpus/templates/clips/server/routes/_agent-native/google/callback.get.ts +6 -6
  62. package/corpus/templates/content/vite.config.ts +37 -1
  63. package/corpus/templates/design/app/pages/NotFound.tsx +1 -1
  64. package/corpus/templates/design/app/routes/$.tsx +9 -0
  65. package/corpus/templates/mail/app/pages/NotFound.tsx +1 -1
  66. package/corpus/templates/mail/app/routes/$.tsx +9 -0
  67. package/corpus/templates/plan/app/global.css +2 -2
  68. package/corpus/templates/slides/app/pages/NotFound.tsx +1 -1
  69. package/corpus/templates/slides/app/routes/$.tsx +9 -0
  70. package/corpus/templates/slides/server/lib/google-docs-oauth.ts +81 -25
  71. package/corpus/templates/videos/app/pages/NotFound.tsx +1 -1
  72. package/dist/cli/pr-visual-recap-workflow.d.ts +1 -1
  73. package/dist/cli/pr-visual-recap-workflow.d.ts.map +1 -1
  74. package/dist/cli/pr-visual-recap-workflow.js +1 -1
  75. package/dist/cli/pr-visual-recap-workflow.js.map +1 -1
  76. package/dist/client/AgentPanel.d.ts +1 -1
  77. package/dist/client/AgentPanel.d.ts.map +1 -1
  78. package/dist/client/AgentPanel.js +1 -1
  79. package/dist/client/AgentPanel.js.map +1 -1
  80. package/dist/client/CommandMenu.d.ts +15 -2
  81. package/dist/client/CommandMenu.d.ts.map +1 -1
  82. package/dist/client/CommandMenu.js +46 -3
  83. package/dist/client/CommandMenu.js.map +1 -1
  84. package/dist/client/ConnectBuilderCard.d.ts.map +1 -1
  85. package/dist/client/ConnectBuilderCard.js +11 -2
  86. package/dist/client/ConnectBuilderCard.js.map +1 -1
  87. package/dist/client/index.d.ts +1 -1
  88. package/dist/client/index.d.ts.map +1 -1
  89. package/dist/client/index.js.map +1 -1
  90. package/dist/extensions/content-patch.d.ts.map +1 -1
  91. package/dist/extensions/content-patch.js +10 -2
  92. package/dist/extensions/content-patch.js.map +1 -1
  93. package/dist/oauth-tokens/google-refresh.d.ts.map +1 -1
  94. package/dist/oauth-tokens/google-refresh.js +29 -17
  95. package/dist/oauth-tokens/google-refresh.js.map +1 -1
  96. package/dist/provider-api/index.d.ts.map +1 -1
  97. package/dist/provider-api/index.js +28 -16
  98. package/dist/provider-api/index.js.map +1 -1
  99. package/dist/server/auth.d.ts.map +1 -1
  100. package/dist/server/auth.js +6 -6
  101. package/dist/server/auth.js.map +1 -1
  102. package/dist/server/better-auth-instance.d.ts.map +1 -1
  103. package/dist/server/better-auth-instance.js +18 -4
  104. package/dist/server/better-auth-instance.js.map +1 -1
  105. package/dist/server/core-routes-plugin.d.ts +5 -0
  106. package/dist/server/core-routes-plugin.d.ts.map +1 -1
  107. package/dist/server/core-routes-plugin.js +107 -5
  108. package/dist/server/core-routes-plugin.js.map +1 -1
  109. package/dist/server/google-oauth-credentials.d.ts +15 -0
  110. package/dist/server/google-oauth-credentials.d.ts.map +1 -0
  111. package/dist/server/google-oauth-credentials.js +34 -0
  112. package/dist/server/google-oauth-credentials.js.map +1 -0
  113. package/dist/server/index.d.ts +1 -0
  114. package/dist/server/index.d.ts.map +1 -1
  115. package/dist/server/index.js +1 -0
  116. package/dist/server/index.js.map +1 -1
  117. package/dist/server/onboarding-html.d.ts.map +1 -1
  118. package/dist/server/onboarding-html.js +2 -1
  119. package/dist/server/onboarding-html.js.map +1 -1
  120. package/dist/server/social-og-image.d.ts.map +1 -1
  121. package/dist/server/social-og-image.js +5 -1
  122. package/dist/server/social-og-image.js.map +1 -1
  123. package/dist/vite/client.d.ts.map +1 -1
  124. package/dist/vite/client.js +83 -1
  125. package/dist/vite/client.js.map +1 -1
  126. package/docs/content/authentication.md +16 -2
  127. package/docs/content/template-analytics.md +14 -9
  128. package/docs/content/template-clips.md +35 -2
  129. package/package.json +1 -1
@@ -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,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ACL,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 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,OAA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ChunkRecovery } 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"]}
@@ -1 +1 @@
1
- {"version":3,"file":"content-patch.d.ts","sourceRoot":"","sources":["../../src/extensions/content-patch.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,oBAAoB,GAC5B;IACE,EAAE,CAAC,EAAE,SAAS,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,GACD;IACE,EAAE,EAAE,eAAe,GAAG,cAAc,CAAC;IACrC,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,GACD;IACE,EAAE,EAAE,iBAAiB,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,EAAE,MAAM,CAAC;IAChB,iBAAiB,CAAC,EAAE,OAAO,CAAC;IAC5B,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAA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AC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,GACD;IACE,EAAE,EAAE,cAAc,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,GACD;IACE,EAAE,EAAE,gBAAgB,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,GACD;IACE,EAAE,EAAE,eAAe,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,OAAO,CAAC;IACd,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AAEN,MAAM,WAAW,0BAA0B;IACzC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACjC,KAAK,CAAC,EAAE,oBAAoB,EAAE,CAAC;IAC/B,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB;AAED,MAAM,WAAW,4BAA4B;IAC3C,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,wBAAsB,2BAA2B,CAC/C,cAAc,EAAE,MAAM,EACtB,IAAI,EAAE,0BAA0B,GAC/B,OAAO,CAAC,4BAA4B,CAAC,CA+BvC;AAED,wBAAsB,mBAAmB,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAsB1E"}
@@ -29,13 +29,21 @@ export async function applyExtensionContentUpdate(currentContent, opts) {
29
29
  export async function formatExtensionHtml(content) {
30
30
  try {
31
31
  const prettier = await import("prettier");
32
- return await prettier.format(content, {
32
+ const formatted = await prettier.format(content, {
33
33
  parser: "html",
34
34
  htmlWhitespaceSensitivity: "ignore",
35
35
  });
36
+ return typeof formatted === "string" ? formatted : content;
36
37
  }
37
38
  catch (err) {
38
- throw new Error(`Unable to format extension HTML with Prettier: ${err?.message ?? err}`);
39
+ const message = String(err?.message ?? err);
40
+ if (message.includes("Cannot find package 'prettier'") ||
41
+ message.includes('Cannot find package "prettier"') ||
42
+ message.includes("Cannot find module 'prettier'") ||
43
+ message.includes('Cannot find module "prettier"')) {
44
+ return content;
45
+ }
46
+ throw new Error(`Unable to format extension HTML with Prettier: ${message}`);
39
47
  }
40
48
  }
41
49
  function applyEdit(content, edit) {
@@ -1 +1 @@
1
- {"version":3,"file":"content-patch.js","sourceRoot":"","sources":["../../src/extensions/content-patch.ts"],"names":[],"mappings":"AA+EA,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,cAAsB,EACtB,IAAgC;IAEhC,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,cAAc,CAAC;IAC7C,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;QACvC,MAAM,IAAI,GAAyB;YACjC,EAAE,EAAE,SAAS;YACb,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,EAAE,KAAK,CAAC,OAAO;YACtB,GAAG,EAAE,KAAK,CAAC,GAAG;YACd,eAAe,EAAE,KAAK,CAAC,eAAe;YACtC,QAAQ,EAAE,KAAK,CAAC,QAAQ;SACzB,CAAC;QACF,MAAM,MAAM,GAAG,SAAS,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;QACxC,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC;QACzB,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;IAC/B,CAAC;I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nE,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC;IAChE,IAAI,GAAG;QAAE,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACzB,OAAO,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;AACrC,CAAC;AAED,SAAS,YAAY,CAAC,KAAa;IACjC,OAAO,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC;AACnD,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO,KAAK,CAAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC","sourcesContent":["export type ExtensionLegacyPatch = {\n find: string;\n replace: string;\n all?: boolean;\n expectedMatches?: number;\n required?: boolean;\n};\n\nexport type ExtensionContentEdit =\n | {\n op?: \"replace\";\n find: string;\n replace: string;\n all?: boolean;\n occurrence?: number;\n expectedMatches?: number;\n required?: boolean;\n }\n | {\n op: \"insert-before\" | \"insert-after\";\n marker: string;\n content: string;\n occurrence?: number;\n expectedMatches?: number;\n required?: boolean;\n }\n | {\n op: \"replace-between\";\n start: string;\n end: string;\n content: string;\n includeDelimiters?: boolean;\n expectedMatches?: number;\n required?: boolean;\n }\n | {\n op: \"replace-section\";\n section: string;\n content: string;\n keepMarkers?: boolean;\n required?: boolean;\n }\n | {\n op: \"wrap-section\";\n section: string;\n before: string;\n after: string;\n keepMarkers?: boolean;\n required?: boolean;\n }\n | {\n op: \"remove-section\";\n section: string;\n keepMarkers?: boolean;\n required?: boolean;\n }\n | {\n op: \"regex-replace\";\n pattern: string;\n replace: string;\n flags?: string;\n all?: boolean;\n expectedMatches?: number;\n required?: boolean;\n };\n\nexport interface ExtensionContentUpdateOpts {\n content?: string;\n patches?: ExtensionLegacyPatch[];\n edits?: ExtensionContentEdit[];\n format?: boolean;\n}\n\nexport interface ExtensionContentUpdateResult {\n content: string;\n applied: string[];\n formatted: boolean;\n}\n\nexport async function applyExtensionContentUpdate(\n currentContent: string,\n opts: ExtensionContentUpdateOpts,\n): Promise<ExtensionContentUpdateResult> {\n let content = opts.content ?? currentContent;\n const applied: string[] = [];\n\n for (const patch of opts.patches ?? []) {\n const edit: ExtensionContentEdit = {\n op: \"replace\",\n find: patch.find,\n replace: patch.replace,\n all: patch.all,\n expectedMatches: patch.expectedMatches,\n required: patch.required,\n };\n const result = applyEdit(content, edit);\n content = result.content;\n applied.push(result.summary);\n }\n\n for (const edit of opts.edits ?? []) {\n const result = applyEdit(content, edit);\n content = result.content;\n applied.push(result.summary);\n }\n\n let formatted = false;\n if (opts.format) {\n content = await formatExtensionHtml(content);\n formatted = true;\n }\n\n return { content, applied, formatted };\n}\n\nexport async function formatExtensionHtml(content: string): Promise<string> {\n try {\n const prettier = await import(\"prettier\");\n return await prettier.format(content, {\n parser: \"html\",\n htmlWhitespaceSensitivity: \"ignore\",\n });\n } catch (err: any) {\n throw new Error(\n `Unable to format extension HTML with Prettier: ${err?.message ?? err}`,\n );\n }\n}\n\nfunction applyEdit(\n content: string,\n edit: ExtensionContentEdit,\n): { content: string; summary: string } {\n const op = edit.op ?? \"replace\";\n switch (op) {\n case \"replace\":\n return applyLiteralReplace(\n content,\n edit as Extract<ExtensionContentEdit, { op?: \"replace\" }>,\n );\n case \"insert-before\":\n case \"insert-after\":\n return applyInsert(\n content,\n edit as Extract<\n ExtensionContentEdit,\n { op: \"insert-before\" | \"insert-after\" }\n >,\n );\n case \"replace-between\":\n return applyReplaceBetween(\n content,\n edit as Extract<ExtensionContentEdit, { op: \"replace-between\" }>,\n );\n case \"replace-section\":\n case \"wrap-section\":\n case \"remove-section\":\n return applySectionEdit(\n content,\n edit as Extract<\n ExtensionContentEdit,\n { op: \"replace-section\" | \"wrap-section\" | \"remove-section\" }\n >,\n );\n case \"regex-replace\":\n return applyRegexReplace(\n content,\n edit as Extract<ExtensionContentEdit, { op: \"regex-replace\" }>,\n );\n default:\n throw new Error(`Unsupported extension edit operation: ${op}`);\n }\n}\n\nfunction applyLiteralReplace(\n content: string,\n edit: Extract<ExtensionContentEdit, { op?: \"replace\" }>,\n): { content: string; summary: string } {\n const matches = countOccurrences(content, edit.find);\n assertMatchCount(\"replace\", matches, edit.expectedMatches, edit.required);\n if (matches === 0) return { content, summary: \"replace:0\" };\n\n if (edit.occurrence !== undefined) {\n return {\n content: replaceNth(content, edit.find, edit.replace, edit.occurrence),\n summary: `replace:nth:${edit.occurrence}`,\n };\n }\n\n if (edit.all) {\n return {\n content: content.split(edit.find).join(edit.replace),\n summary: `replace:all:${matches}`,\n };\n }\n\n return {\n content: content.replace(edit.find, edit.replace),\n summary: \"replace:first\",\n };\n}\n\nfunction applyInsert(\n content: string,\n edit: Extract<ExtensionContentEdit, { op: \"insert-before\" | \"insert-after\" }>,\n): { content: string; summary: string } {\n const matches = countOccurrences(content, edit.marker);\n assertMatchCount(edit.op, matches, edit.expectedMatches, edit.required);\n if (matches === 0) return { content, summary: `${edit.op}:0` };\n\n const occurrence = edit.occurrence ?? 1;\n const index = nthIndexOf(content, edit.marker, occurrence);\n if (index < 0) {\n throw new Error(`${edit.op} could not find occurrence ${occurrence}`);\n }\n const insertAt =\n edit.op === \"insert-before\" ? index : index + edit.marker.length;\n return {\n content:\n content.slice(0, insertAt) + edit.content + content.slice(insertAt),\n summary: `${edit.op}:${occurrence}`,\n };\n}\n\nfunction applyReplaceBetween(\n content: string,\n edit: Extract<ExtensionContentEdit, { op: \"replace-between\" }>,\n): { content: string; summary: string } {\n const ranges = findBetweenRanges(content, edit.start, edit.end);\n assertMatchCount(\n \"replace-between\",\n ranges.length,\n edit.expectedMatches,\n edit.required,\n );\n if (!ranges.length) return { content, summary: \"replace-between:0\" };\n if (ranges.length > 1 && edit.expectedMatches === undefined) {\n throw new Error(\n `replace-between matched ${ranges.length} ranges; pass expectedMatches to confirm`,\n );\n }\n\n let next = content;\n for (const range of ranges.slice().reverse()) {\n const start = edit.includeDelimiters ? range.start : range.innerStart;\n const end = edit.includeDelimiters ? range.end : range.innerEnd;\n next = next.slice(0, start) + edit.content + next.slice(end);\n }\n return { content: next, summary: `replace-between:${ranges.length}` };\n}\n\nfunction applySectionEdit(\n content: string,\n edit: Extract<\n ExtensionContentEdit,\n { op: \"replace-section\" | \"wrap-section\" | \"remove-section\" }\n >,\n): { content: string; summary: string } {\n const section = findSection(content, edit.section);\n const required = edit.required !== false;\n if (!section) {\n if (required) throw new Error(`Section not found: ${edit.section}`);\n return { content, summary: `${edit.op}:0` };\n }\n\n const keepMarkers = edit.keepMarkers !== false;\n const replaceStart = keepMarkers ? section.innerStart : section.start;\n const replaceEnd = keepMarkers ? section.innerEnd : section.end;\n const inner = content.slice(section.innerStart, section.innerEnd);\n let replacement = \"\";\n\n if (edit.op === \"replace-section\") {\n replacement = edit.content;\n } else if (edit.op === \"wrap-section\") {\n replacement = edit.before + inner + edit.after;\n } else {\n replacement = \"\";\n }\n\n return {\n content:\n content.slice(0, replaceStart) + replacement + content.slice(replaceEnd),\n summary: `${edit.op}:${edit.section}`,\n };\n}\n\nfunction applyRegexReplace(\n content: string,\n edit: Extract<ExtensionContentEdit, { op: \"regex-replace\" }>,\n): { content: string; summary: string } {\n const flags = normalizeRegexFlags(edit.flags, edit.all);\n const regex = new RegExp(edit.pattern, flags);\n const countRegex = new RegExp(edit.pattern, ensureGlobal(flags));\n const matches = Array.from(content.matchAll(countRegex)).length;\n assertMatchCount(\n \"regex-replace\",\n matches,\n edit.expectedMatches,\n edit.required,\n );\n if (matches === 0) return { content, summary: \"regex-replace:0\" };\n return {\n content: content.replace(regex, edit.replace),\n summary: `regex-replace:${edit.all ? \"all\" : \"first\"}:${matches}`,\n };\n}\n\nfunction assertMatchCount(\n op: string,\n actual: number,\n expected: number | undefined,\n required: boolean | undefined,\n): void {\n if (expected !== undefined && actual !== expected) {\n throw new Error(`${op} expected ${expected} match(es), found ${actual}`);\n }\n if (expected === undefined && required !== false && actual === 0) {\n throw new Error(`${op} found no matches`);\n }\n}\n\nfunction countOccurrences(content: string, needle: string): number {\n if (!needle) throw new Error(\"Patch find/marker text cannot be empty\");\n let count = 0;\n let index = 0;\n while (true) {\n index = content.indexOf(needle, index);\n if (index < 0) return count;\n count += 1;\n index += needle.length;\n }\n}\n\nfunction nthIndexOf(\n content: string,\n needle: string,\n occurrence: number,\n): number {\n if (!Number.isInteger(occurrence) || occurrence < 1) {\n throw new Error(\"occurrence must be a positive integer\");\n }\n let index = -1;\n let from = 0;\n for (let i = 0; i < occurrence; i += 1) {\n index = content.indexOf(needle, from);\n if (index < 0) return -1;\n from = index + needle.length;\n }\n return index;\n}\n\nfunction replaceNth(\n content: string,\n find: string,\n replace: string,\n occurrence: number,\n): string {\n const index = nthIndexOf(content, find, occurrence);\n if (index < 0) {\n throw new Error(`replace could not find occurrence ${occurrence}`);\n }\n return content.slice(0, index) + replace + content.slice(index + find.length);\n}\n\nfunction findBetweenRanges(\n content: string,\n startMarker: string,\n endMarker: string,\n): Array<{ start: number; innerStart: number; innerEnd: number; end: number }> {\n if (!startMarker || !endMarker) {\n throw new Error(\"replace-between requires non-empty start and end markers\");\n }\n const ranges: Array<{\n start: number;\n innerStart: number;\n innerEnd: number;\n end: number;\n }> = [];\n let cursor = 0;\n while (cursor < content.length) {\n const start = content.indexOf(startMarker, cursor);\n if (start < 0) break;\n const innerStart = start + startMarker.length;\n const innerEnd = content.indexOf(endMarker, innerStart);\n if (innerEnd < 0) {\n throw new Error(\"replace-between found a start marker without an end\");\n }\n const end = innerEnd + endMarker.length;\n ranges.push({ start, innerStart, innerEnd, end });\n cursor = end;\n }\n return ranges;\n}\n\nfunction findSection(\n content: string,\n sectionId: string,\n): { start: number; innerStart: number; innerEnd: number; end: number } | null {\n if (!sectionId.trim()) throw new Error(\"section id cannot be empty\");\n const escaped = escapeRegex(sectionId.trim());\n const startRe = new RegExp(\n `<!--\\\\s*(?:agent-native:section\\\\s+${escaped}|section:${escaped}|section\\\\s+${escaped})\\\\s*-->`,\n );\n const startMatch = startRe.exec(content);\n if (!startMatch || startMatch.index === undefined) return null;\n\n const endRe = new RegExp(\n `<!--\\\\s*/(?:agent-native:section\\\\s+${escaped}|section:${escaped}|section\\\\s+${escaped})\\\\s*-->`,\n );\n endRe.lastIndex = startMatch.index + startMatch[0].length;\n const rest = content.slice(startMatch.index + startMatch[0].length);\n const endMatch = endRe.exec(rest);\n if (!endMatch || endMatch.index === undefined) {\n throw new Error(`Section ${sectionId} has a start marker without an end`);\n }\n\n const start = startMatch.index;\n const innerStart = startMatch.index + startMatch[0].length;\n const innerEnd = innerStart + endMatch.index;\n const end = innerEnd + endMatch[0].length;\n return { start, innerStart, innerEnd, end };\n}\n\nfunction normalizeRegexFlags(flags: string | undefined, all?: boolean): string {\n const unique = new Set((flags ?? \"\").split(\"\").filter(Boolean));\n if (all) unique.add(\"g\");\n return Array.from(unique).join(\"\");\n}\n\nfunction ensureGlobal(flags: string): string {\n return flags.includes(\"g\") ? flags : `${flags}g`;\n}\n\nfunction escapeRegex(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\n}\n"]}
1
+ {"version":3,"file":"content-patch.js","sourceRoot":"","sources":["../../src/extensions/content-patch.ts"],"names":[],"mappings":"AA+EA,MAAM,CAAC,KAAK,UAAU,2BAA2B,CAC/C,cAAsB,EACtB,IAAgC;IAEhC,IAAI,OAAO,GAAG,IAAI,CAAC,OAAO,IAAI,cAAc,CAAC;IAC7C,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,KAAK,MAAM,KAAK,IAAI,IAAI,CAAC,OAAO,IAAI,EAAE,EAAE,CAAC;QACvC,MAAM,IAAI,GAAyB;YACjC,EAAE,EAAE,SAAS;YACb,IAAI,EAAE,KAAK,CAAC,IAAI;YAChB,OAAO,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AAC,OAAO,CAAC,qBAAqB,EAAE,MAAM,CAAC,CAAC;AACtD,CAAC","sourcesContent":["export type ExtensionLegacyPatch = {\n find: string;\n replace: string;\n all?: boolean;\n expectedMatches?: number;\n required?: boolean;\n};\n\nexport type ExtensionContentEdit =\n | {\n op?: \"replace\";\n find: string;\n replace: string;\n all?: boolean;\n occurrence?: number;\n expectedMatches?: number;\n required?: boolean;\n }\n | {\n op: \"insert-before\" | \"insert-after\";\n marker: string;\n content: string;\n occurrence?: number;\n expectedMatches?: number;\n required?: boolean;\n }\n | {\n op: \"replace-between\";\n start: string;\n end: string;\n content: string;\n includeDelimiters?: boolean;\n expectedMatches?: number;\n required?: boolean;\n }\n | {\n op: \"replace-section\";\n section: string;\n content: string;\n keepMarkers?: boolean;\n required?: boolean;\n }\n | {\n op: \"wrap-section\";\n section: string;\n before: string;\n after: string;\n keepMarkers?: boolean;\n required?: boolean;\n }\n | {\n op: \"remove-section\";\n section: string;\n keepMarkers?: boolean;\n required?: boolean;\n }\n | {\n op: \"regex-replace\";\n pattern: string;\n replace: string;\n flags?: string;\n all?: boolean;\n expectedMatches?: number;\n required?: boolean;\n };\n\nexport interface ExtensionContentUpdateOpts {\n content?: string;\n patches?: ExtensionLegacyPatch[];\n edits?: ExtensionContentEdit[];\n format?: boolean;\n}\n\nexport interface ExtensionContentUpdateResult {\n content: string;\n applied: string[];\n formatted: boolean;\n}\n\nexport async function applyExtensionContentUpdate(\n currentContent: string,\n opts: ExtensionContentUpdateOpts,\n): Promise<ExtensionContentUpdateResult> {\n let content = opts.content ?? currentContent;\n const applied: string[] = [];\n\n for (const patch of opts.patches ?? []) {\n const edit: ExtensionContentEdit = {\n op: \"replace\",\n find: patch.find,\n replace: patch.replace,\n all: patch.all,\n expectedMatches: patch.expectedMatches,\n required: patch.required,\n };\n const result = applyEdit(content, edit);\n content = result.content;\n applied.push(result.summary);\n }\n\n for (const edit of opts.edits ?? []) {\n const result = applyEdit(content, edit);\n content = result.content;\n applied.push(result.summary);\n }\n\n let formatted = false;\n if (opts.format) {\n content = await formatExtensionHtml(content);\n formatted = true;\n }\n\n return { content, applied, formatted };\n}\n\nexport async function formatExtensionHtml(content: string): Promise<string> {\n try {\n const prettier = await import(\"prettier\");\n const formatted = await prettier.format(content, {\n parser: \"html\",\n htmlWhitespaceSensitivity: \"ignore\",\n });\n return typeof formatted === \"string\" ? formatted : content;\n } catch (err: any) {\n const message = String(err?.message ?? err);\n if (\n message.includes(\"Cannot find package 'prettier'\") ||\n message.includes('Cannot find package \"prettier\"') ||\n message.includes(\"Cannot find module 'prettier'\") ||\n message.includes('Cannot find module \"prettier\"')\n ) {\n return content;\n }\n throw new Error(\n `Unable to format extension HTML with Prettier: ${message}`,\n );\n }\n}\n\nfunction applyEdit(\n content: string,\n edit: ExtensionContentEdit,\n): { content: string; summary: string } {\n const op = edit.op ?? \"replace\";\n switch (op) {\n case \"replace\":\n return applyLiteralReplace(\n content,\n edit as Extract<ExtensionContentEdit, { op?: \"replace\" }>,\n );\n case \"insert-before\":\n case \"insert-after\":\n return applyInsert(\n content,\n edit as Extract<\n ExtensionContentEdit,\n { op: \"insert-before\" | \"insert-after\" }\n >,\n );\n case \"replace-between\":\n return applyReplaceBetween(\n content,\n edit as Extract<ExtensionContentEdit, { op: \"replace-between\" }>,\n );\n case \"replace-section\":\n case \"wrap-section\":\n case \"remove-section\":\n return applySectionEdit(\n content,\n edit as Extract<\n ExtensionContentEdit,\n { op: \"replace-section\" | \"wrap-section\" | \"remove-section\" }\n >,\n );\n case \"regex-replace\":\n return applyRegexReplace(\n content,\n edit as Extract<ExtensionContentEdit, { op: \"regex-replace\" }>,\n );\n default:\n throw new Error(`Unsupported extension edit operation: ${op}`);\n }\n}\n\nfunction applyLiteralReplace(\n content: string,\n edit: Extract<ExtensionContentEdit, { op?: \"replace\" }>,\n): { content: string; summary: string } {\n const matches = countOccurrences(content, edit.find);\n assertMatchCount(\"replace\", matches, edit.expectedMatches, edit.required);\n if (matches === 0) return { content, summary: \"replace:0\" };\n\n if (edit.occurrence !== undefined) {\n return {\n content: replaceNth(content, edit.find, edit.replace, edit.occurrence),\n summary: `replace:nth:${edit.occurrence}`,\n };\n }\n\n if (edit.all) {\n return {\n content: content.split(edit.find).join(edit.replace),\n summary: `replace:all:${matches}`,\n };\n }\n\n return {\n content: content.replace(edit.find, edit.replace),\n summary: \"replace:first\",\n };\n}\n\nfunction applyInsert(\n content: string,\n edit: Extract<ExtensionContentEdit, { op: \"insert-before\" | \"insert-after\" }>,\n): { content: string; summary: string } {\n const matches = countOccurrences(content, edit.marker);\n assertMatchCount(edit.op, matches, edit.expectedMatches, edit.required);\n if (matches === 0) return { content, summary: `${edit.op}:0` };\n\n const occurrence = edit.occurrence ?? 1;\n const index = nthIndexOf(content, edit.marker, occurrence);\n if (index < 0) {\n throw new Error(`${edit.op} could not find occurrence ${occurrence}`);\n }\n const insertAt =\n edit.op === \"insert-before\" ? index : index + edit.marker.length;\n return {\n content:\n content.slice(0, insertAt) + edit.content + content.slice(insertAt),\n summary: `${edit.op}:${occurrence}`,\n };\n}\n\nfunction applyReplaceBetween(\n content: string,\n edit: Extract<ExtensionContentEdit, { op: \"replace-between\" }>,\n): { content: string; summary: string } {\n const ranges = findBetweenRanges(content, edit.start, edit.end);\n assertMatchCount(\n \"replace-between\",\n ranges.length,\n edit.expectedMatches,\n edit.required,\n );\n if (!ranges.length) return { content, summary: \"replace-between:0\" };\n if (ranges.length > 1 && edit.expectedMatches === undefined) {\n throw new Error(\n `replace-between matched ${ranges.length} ranges; pass expectedMatches to confirm`,\n );\n }\n\n let next = content;\n for (const range of ranges.slice().reverse()) {\n const start = edit.includeDelimiters ? range.start : range.innerStart;\n const end = edit.includeDelimiters ? range.end : range.innerEnd;\n next = next.slice(0, start) + edit.content + next.slice(end);\n }\n return { content: next, summary: `replace-between:${ranges.length}` };\n}\n\nfunction applySectionEdit(\n content: string,\n edit: Extract<\n ExtensionContentEdit,\n { op: \"replace-section\" | \"wrap-section\" | \"remove-section\" }\n >,\n): { content: string; summary: string } {\n const section = findSection(content, edit.section);\n const required = edit.required !== false;\n if (!section) {\n if (required) throw new Error(`Section not found: ${edit.section}`);\n return { content, summary: `${edit.op}:0` };\n }\n\n const keepMarkers = edit.keepMarkers !== false;\n const replaceStart = keepMarkers ? section.innerStart : section.start;\n const replaceEnd = keepMarkers ? section.innerEnd : section.end;\n const inner = content.slice(section.innerStart, section.innerEnd);\n let replacement = \"\";\n\n if (edit.op === \"replace-section\") {\n replacement = edit.content;\n } else if (edit.op === \"wrap-section\") {\n replacement = edit.before + inner + edit.after;\n } else {\n replacement = \"\";\n }\n\n return {\n content:\n content.slice(0, replaceStart) + replacement + content.slice(replaceEnd),\n summary: `${edit.op}:${edit.section}`,\n };\n}\n\nfunction applyRegexReplace(\n content: string,\n edit: Extract<ExtensionContentEdit, { op: \"regex-replace\" }>,\n): { content: string; summary: string } {\n const flags = normalizeRegexFlags(edit.flags, edit.all);\n const regex = new RegExp(edit.pattern, flags);\n const countRegex = new RegExp(edit.pattern, ensureGlobal(flags));\n const matches = Array.from(content.matchAll(countRegex)).length;\n assertMatchCount(\n \"regex-replace\",\n matches,\n edit.expectedMatches,\n edit.required,\n );\n if (matches === 0) return { content, summary: \"regex-replace:0\" };\n return {\n content: content.replace(regex, edit.replace),\n summary: `regex-replace:${edit.all ? \"all\" : \"first\"}:${matches}`,\n };\n}\n\nfunction assertMatchCount(\n op: string,\n actual: number,\n expected: number | undefined,\n required: boolean | undefined,\n): void {\n if (expected !== undefined && actual !== expected) {\n throw new Error(`${op} expected ${expected} match(es), found ${actual}`);\n }\n if (expected === undefined && required !== false && actual === 0) {\n throw new Error(`${op} found no matches`);\n }\n}\n\nfunction countOccurrences(content: string, needle: string): number {\n if (!needle) throw new Error(\"Patch find/marker text cannot be empty\");\n let count = 0;\n let index = 0;\n while (true) {\n index = content.indexOf(needle, index);\n if (index < 0) return count;\n count += 1;\n index += needle.length;\n }\n}\n\nfunction nthIndexOf(\n content: string,\n needle: string,\n occurrence: number,\n): number {\n if (!Number.isInteger(occurrence) || occurrence < 1) {\n throw new Error(\"occurrence must be a positive integer\");\n }\n let index = -1;\n let from = 0;\n for (let i = 0; i < occurrence; i += 1) {\n index = content.indexOf(needle, from);\n if (index < 0) return -1;\n from = index + needle.length;\n }\n return index;\n}\n\nfunction replaceNth(\n content: string,\n find: string,\n replace: string,\n occurrence: number,\n): string {\n const index = nthIndexOf(content, find, occurrence);\n if (index < 0) {\n throw new Error(`replace could not find occurrence ${occurrence}`);\n }\n return content.slice(0, index) + replace + content.slice(index + find.length);\n}\n\nfunction findBetweenRanges(\n content: string,\n startMarker: string,\n endMarker: string,\n): Array<{ start: number; innerStart: number; innerEnd: number; end: number }> {\n if (!startMarker || !endMarker) {\n throw new Error(\"replace-between requires non-empty start and end markers\");\n }\n const ranges: Array<{\n start: number;\n innerStart: number;\n innerEnd: number;\n end: number;\n }> = [];\n let cursor = 0;\n while (cursor < content.length) {\n const start = content.indexOf(startMarker, cursor);\n if (start < 0) break;\n const innerStart = start + startMarker.length;\n const innerEnd = content.indexOf(endMarker, innerStart);\n if (innerEnd < 0) {\n throw new Error(\"replace-between found a start marker without an end\");\n }\n const end = innerEnd + endMarker.length;\n ranges.push({ start, innerStart, innerEnd, end });\n cursor = end;\n }\n return ranges;\n}\n\nfunction findSection(\n content: string,\n sectionId: string,\n): { start: number; innerStart: number; innerEnd: number; end: number } | null {\n if (!sectionId.trim()) throw new Error(\"section id cannot be empty\");\n const escaped = escapeRegex(sectionId.trim());\n const startRe = new RegExp(\n `<!--\\\\s*(?:agent-native:section\\\\s+${escaped}|section:${escaped}|section\\\\s+${escaped})\\\\s*-->`,\n );\n const startMatch = startRe.exec(content);\n if (!startMatch || startMatch.index === undefined) return null;\n\n const endRe = new RegExp(\n `<!--\\\\s*/(?:agent-native:section\\\\s+${escaped}|section:${escaped}|section\\\\s+${escaped})\\\\s*-->`,\n );\n endRe.lastIndex = startMatch.index + startMatch[0].length;\n const rest = content.slice(startMatch.index + startMatch[0].length);\n const endMatch = endRe.exec(rest);\n if (!endMatch || endMatch.index === undefined) {\n throw new Error(`Section ${sectionId} has a start marker without an end`);\n }\n\n const start = startMatch.index;\n const innerStart = startMatch.index + startMatch[0].length;\n const innerEnd = innerStart + endMatch.index;\n const end = innerEnd + endMatch[0].length;\n return { start, innerStart, innerEnd, end };\n}\n\nfunction normalizeRegexFlags(flags: string | undefined, all?: boolean): string {\n const unique = new Set((flags ?? \"\").split(\"\").filter(Boolean));\n if (all) unique.add(\"g\");\n return Array.from(unique).join(\"\");\n}\n\nfunction ensureGlobal(flags: string): string {\n return flags.includes(\"g\") ? flags : `${flags}g`;\n}\n\nfunction escapeRegex(value: string): string {\n return value.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\");\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`.
@@ -1 +1 @@
1
- {"version":3,"file":"google-refresh.js","sourceRoot":"","sources":["../../src/oauth-tokens/google-refresh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAEhE,MAAM,gBAAgB,GAAG,qCAAqC,CAAC;AAiB/D,KAAK,UAAU,UAAU,CAAC,YAAoB;IAC5C,MAAM,QAAQ,GAAG,OAAO,CAAC,GAAG,CAAC,gBAAgB,CAAC;IAC9C,MAAM,YAAY,GAAG,OAAO,CAAC,GAAG,CAAC,oBAAoB,CAAC;IACtD,IAAI,CAAC,QAAQ,IAAI,CAAC,YAAY,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,gBAAgB,EAAE;QACxC,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,mCAAmC,EAAE;QAChE,IAAI,EAAE,IAAI,eAAe,CAAC;YACxB,aAAa,EAAE,YAAY;YAC3B,SAAS,EAAE,QAAQ;YACnB,aAAa,EAAE,YAAY;YAC3B,UAAU,EAAE,eAAe;SAC5B,CAAC;KACH,CAAC,CAAC;IACH,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAA4B,CAAC;IAC3D,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,GAAG,GAAG,CAAC,IAAI,CAAC,iBAAiB;YACjC,IAAI,CAAC,KAAK;YACV,GAAG,CAAC,UAAU,CAAW,CAAC;QAC5B,MAAM,IA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AO,YAAY,KAAK,QAAQ;QAChC,YAAY;QACZ,OAAO,IAAI,YAAY,EACvB,CAAC;QACA,YAAsC,CAAC,KAAK,EAAE,CAAC;IAClD,CAAC;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,IAAI,OAAO,IAAI,MAAM,EAAE,CAAC;QAC7D,MAAgC,CAAC,KAAK,EAAE,CAAC;IAC5C,CAAC;AACH,CAAC","sourcesContent":["/**\n * Proactive Google OAuth token refresh.\n *\n * Templates already refresh tokens reactively in their `getValidAccessToken`\n * helpers — but that only runs when an action makes an API call. If the user\n * is idle for an hour, the next call pays the refresh latency, and any error\n * surfaces as a user-facing failure.\n *\n * This module scans the `oauth_tokens` table on a timer and refreshes any\n * token that's within `expiryBufferMs` of expiring. Templates opt in via a\n * server plugin (see `templates/mail/server/plugins/oauth-refresh.ts`).\n */\n\nimport { listOAuthAccounts, saveOAuthTokens } from \"./store.js\";\n\nconst GOOGLE_TOKEN_URL = \"https://oauth2.googleapis.com/token\";\n\ninterface GoogleTokens {\n access_token?: string;\n refresh_token?: string;\n expiry_date?: number;\n token_type?: string;\n scope?: string;\n}\n\ninterface RefreshResponse {\n access_token: string;\n expires_in: number;\n token_type: string;\n scope?: string;\n}\n\nasync function refreshOne(refreshToken: string): Promise<RefreshResponse> {\n const clientId = process.env.GOOGLE_CLIENT_ID;\n const clientSecret = process.env.GOOGLE_CLIENT_SECRET;\n if (!clientId || !clientSecret) {\n throw new Error(\"GOOGLE_CLIENT_ID/SECRET not set\");\n }\n const res = await fetch(GOOGLE_TOKEN_URL, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n body: new URLSearchParams({\n refresh_token: refreshToken,\n client_id: clientId,\n client_secret: clientSecret,\n grant_type: \"refresh_token\",\n }),\n });\n const data = (await res.json()) as Record<string, unknown>;\n if (!res.ok) {\n const err = (data.error_description ||\n data.error ||\n res.statusText) as string;\n throw new Error(err);\n }\n return data as unknown as RefreshResponse;\n}\n\n/**\n * Scan all stored Google tokens and refresh any expiring within `bufferMs`.\n * Errors per-account are logged and swallowed so one bad token doesn't block\n * the rest.\n */\nexport async function refreshExpiringGoogleTokens(\n opts: {\n bufferMs?: number;\n } = {},\n): Promise<void> {\n const bufferMs = opts.bufferMs ?? 15 * 60 * 1000;\n let accounts: Awaited<ReturnType<typeof listOAuthAccounts>>;\n try {\n accounts = await listOAuthAccounts(\"google\");\n } catch (err) {\n console.error(\"[google-refresh] failed to list accounts:\", err);\n return;\n }\n const now = Date.now();\n for (const acct of accounts) {\n const tokens = acct.tokens as GoogleTokens;\n if (!tokens?.refresh_token) continue;\n if (tokens.expiry_date && tokens.expiry_date > now + bufferMs) continue;\n try {\n const refreshed = await refreshOne(tokens.refresh_token);\n const merged: GoogleTokens = {\n ...tokens,\n access_token: refreshed.access_token,\n expiry_date: now + refreshed.expires_in * 1000,\n token_type: refreshed.token_type,\n scope: refreshed.scope ?? tokens.scope,\n };\n await saveOAuthTokens(\n \"google\",\n acct.accountId,\n merged as unknown as Record<string, unknown>,\n );\n } catch (err) {\n // Common case: invalid_grant when the user revoked access or changed\n // their Google password. Leave the row in place so the UI shows the\n // account and the user can re-OAuth — don't auto-delete.\n console.warn(\n `[google-refresh] refresh failed for ${acct.accountId}:`,\n (err as Error).message,\n );\n }\n }\n}\n\nlet _started = false;\nlet _timer: ReturnType<typeof setInterval> | undefined;\n\n/**\n * Start the refresh loop. Idempotent — calling more than once is a no-op,\n * so multiple plugins/templates loading this in the same process are safe.\n */\nexport function startGoogleTokenRefreshLoop(\n opts: {\n /** How often to scan. Default: 20 minutes. */\n intervalMs?: number;\n /** Refresh tokens expiring within this window. Default: 15 minutes. */\n bufferMs?: number;\n } = {},\n): void {\n if (_started) return;\n _started = true;\n\n // In dev mode the local DB is usually the shared prod DB. Proactively\n // refreshing every user's token with local OAuth credentials always fails\n // (wrong client_id/secret). Tokens still refresh reactively on-demand.\n if (process.env.NODE_ENV !== \"production\") {\n return;\n }\n const intervalMs = opts.intervalMs ?? 20 * 60 * 1000;\n const bufferMs = opts.bufferMs ?? 15 * 60 * 1000;\n\n // Kick off an initial pass shortly after startup (not immediately — the DB\n // may still be initializing).\n const initialTimer = setTimeout(() => {\n refreshExpiringGoogleTokens({ bufferMs }).catch((err) => {\n console.error(\"[google-refresh] initial pass failed:\", err);\n });\n }, 30_000);\n\n _timer = setInterval(() => {\n refreshExpiringGoogleTokens({ bufferMs }).catch((err) => {\n console.error(\"[google-refresh] interval pass failed:\", err);\n });\n }, intervalMs);\n\n // Don't let either timer keep the process alive on its own.\n if (\n typeof initialTimer === \"object\" &&\n initialTimer &&\n \"unref\" in initialTimer\n ) {\n (initialTimer as { unref: () => void }).unref();\n }\n if (typeof _timer === \"object\" && _timer && \"unref\" in _timer) {\n (_timer as { unref: () => void }).unref();\n }\n}\n"]}
1
+ {"version":3,"file":"google-refresh.js","sourceRoot":"","sources":["../../src/oauth-tokens/google-refresh.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,iBAAiB,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAChE,OAAO,EAAE,yCAAyC,EAAE,MAAM,uCAAuC,CAAC;AAElG,MAAM,gBAAgB,GAAG,qCAAqC,CAAC;AAiB/D,KAAK,UAAU,UAAU,CAAC,YAAoB;IAC5C,MAAM,oBAAoB,GAAG,yCAAyC,EAAE,CAAC;IACzE,IAAI,CAAC,oBAAoB,CAAC,MAAM,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,iCAAiC,CAAC,CAAC;IACrD,CAAC;IAED,IAAI,IAAI,GAAmC,IAAI,CAAC;IAChD,IAAI,cAAc,GAAG,gBAAgB,CAAC;IACtC,KAAK,MAAM,WAAW,IAAI,oBAAoB,EAAE,CAAC;QAC/C,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,gBAAgB,EAAE;YACxC,MAAM,EAAE,MAAM;YACd,OAAO,EAAE,EAAE,cAAc,EAAE,mCAAmC,E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,GAAG,EAAE,GAAG,IAAI,CAAC;IACrD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;IAEjD,2EAA2E;IAC3E,8BAA8B;IAC9B,MAAM,YAAY,GAAG,UAAU,CAAC,GAAG,EAAE;QACnC,2BAA2B,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACtD,OAAO,CAAC,KAAK,CAAC,uCAAuC,EAAE,GAAG,CAAC,CAAC;QAC9D,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,MAAM,CAAC,CAAC;IAEX,MAAM,GAAG,WAAW,CAAC,GAAG,EAAE;QACxB,2BAA2B,CAAC,EAAE,QAAQ,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE;YACtD,OAAO,CAAC,KAAK,CAAC,wCAAwC,EAAE,GAAG,CAAC,CAAC;QAC/D,CAAC,CAAC,CAAC;IACL,CAAC,EAAE,UAAU,CAAC,CAAC;IAEf,4DAA4D;IAC5D,IACE,OAAO,YAAY,KAAK,QAAQ;QAChC,YAAY;QACZ,OAAO,IAAI,YAAY,EACvB,CAAC;QACA,YAAsC,CAAC,KAAK,EAAE,CAAC;IAClD,CAAC;IACD,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,IAAI,OAAO,IAAI,MAAM,EAAE,CAAC;QAC7D,MAAgC,CAAC,KAAK,EAAE,CAAC;IAC5C,CAAC;AACH,CAAC","sourcesContent":["/**\n * Proactive Google OAuth token refresh.\n *\n * Templates already refresh tokens reactively in their `getValidAccessToken`\n * helpers — but that only runs when an action makes an API call. If the user\n * is idle for an hour, the next call pays the refresh latency, and any error\n * surfaces as a user-facing failure.\n *\n * This module scans the `oauth_tokens` table on a timer and refreshes any\n * token that's within `expiryBufferMs` of expiring. Templates opt in via a\n * server plugin (see `templates/mail/server/plugins/oauth-refresh.ts`).\n */\n\nimport { listOAuthAccounts, saveOAuthTokens } from \"./store.js\";\nimport { resolveGoogleProviderCredentialCandidates } from \"../server/google-oauth-credentials.js\";\n\nconst GOOGLE_TOKEN_URL = \"https://oauth2.googleapis.com/token\";\n\ninterface GoogleTokens {\n access_token?: string;\n refresh_token?: string;\n expiry_date?: number;\n token_type?: string;\n scope?: string;\n}\n\ninterface RefreshResponse {\n access_token: string;\n expires_in: number;\n token_type: string;\n scope?: string;\n}\n\nasync function refreshOne(refreshToken: string): Promise<RefreshResponse> {\n const credentialCandidates = resolveGoogleProviderCredentialCandidates();\n if (!credentialCandidates.length) {\n throw new Error(\"GOOGLE_CLIENT_ID/SECRET not set\");\n }\n\n let data: Record<string, unknown> | null = null;\n let lastStatusText = \"refresh failed\";\n for (const credentials of credentialCandidates) {\n const res = await fetch(GOOGLE_TOKEN_URL, {\n method: \"POST\",\n headers: { \"Content-Type\": \"application/x-www-form-urlencoded\" },\n body: new URLSearchParams({\n refresh_token: refreshToken,\n client_id: credentials.clientId,\n client_secret: credentials.clientSecret,\n grant_type: \"refresh_token\",\n }),\n });\n lastStatusText = res.statusText;\n data = (await res.json()) as Record<string, unknown>;\n if (res.ok) return data as unknown as RefreshResponse;\n if (\n data.error !== \"invalid_grant\" &&\n data.error !== \"unauthorized_client\" &&\n data.error !== \"invalid_client\"\n ) {\n break;\n }\n }\n\n if (data) {\n const err = (data.error_description ||\n data.error ||\n lastStatusText) as string;\n throw new Error(err);\n }\n throw new Error(lastStatusText);\n}\n\n/**\n * Scan all stored Google tokens and refresh any expiring within `bufferMs`.\n * Errors per-account are logged and swallowed so one bad token doesn't block\n * the rest.\n */\nexport async function refreshExpiringGoogleTokens(\n opts: {\n bufferMs?: number;\n } = {},\n): Promise<void> {\n const bufferMs = opts.bufferMs ?? 15 * 60 * 1000;\n let accounts: Awaited<ReturnType<typeof listOAuthAccounts>>;\n try {\n accounts = await listOAuthAccounts(\"google\");\n } catch (err) {\n console.error(\"[google-refresh] failed to list accounts:\", err);\n return;\n }\n const now = Date.now();\n for (const acct of accounts) {\n const tokens = acct.tokens as GoogleTokens;\n if (!tokens?.refresh_token) continue;\n if (tokens.expiry_date && tokens.expiry_date > now + bufferMs) continue;\n try {\n const refreshed = await refreshOne(tokens.refresh_token);\n const merged: GoogleTokens = {\n ...tokens,\n access_token: refreshed.access_token,\n expiry_date: now + refreshed.expires_in * 1000,\n token_type: refreshed.token_type,\n scope: refreshed.scope ?? tokens.scope,\n };\n await saveOAuthTokens(\n \"google\",\n acct.accountId,\n merged as unknown as Record<string, unknown>,\n );\n } catch (err) {\n // Common case: invalid_grant when the user revoked access or changed\n // their Google password. Leave the row in place so the UI shows the\n // account and the user can re-OAuth — don't auto-delete.\n console.warn(\n `[google-refresh] refresh failed for ${acct.accountId}:`,\n (err as Error).message,\n );\n }\n }\n}\n\nlet _started = false;\nlet _timer: ReturnType<typeof setInterval> | undefined;\n\n/**\n * Start the refresh loop. Idempotent — calling more than once is a no-op,\n * so multiple plugins/templates loading this in the same process are safe.\n */\nexport function startGoogleTokenRefreshLoop(\n opts: {\n /** How often to scan. Default: 20 minutes. */\n intervalMs?: number;\n /** Refresh tokens expiring within this window. Default: 15 minutes. */\n bufferMs?: number;\n } = {},\n): void {\n if (_started) return;\n _started = true;\n\n // In dev mode the local DB is usually the shared prod DB. Proactively\n // refreshing every user's token with local OAuth credentials always fails\n // (wrong client_id/secret). Tokens still refresh reactively on-demand.\n if (process.env.NODE_ENV !== \"production\") {\n return;\n }\n const intervalMs = opts.intervalMs ?? 20 * 60 * 1000;\n const bufferMs = opts.bufferMs ?? 15 * 60 * 1000;\n\n // Kick off an initial pass shortly after startup (not immediately — the DB\n // may still be initializing).\n const initialTimer = setTimeout(() => {\n refreshExpiringGoogleTokens({ bufferMs }).catch((err) => {\n console.error(\"[google-refresh] initial pass failed:\", err);\n });\n }, 30_000);\n\n _timer = setInterval(() => {\n refreshExpiringGoogleTokens({ bufferMs }).catch((err) => {\n console.error(\"[google-refresh] interval pass failed:\", err);\n });\n }, intervalMs);\n\n // Don't let either timer keep the process alive on its own.\n if (\n typeof initialTimer === \"object\" &&\n initialTimer &&\n \"unref\" in initialTimer\n ) {\n (initialTimer as { unref: () => void }).unref();\n }\n if (typeof _timer === \"object\" && _timer && \"unref\" in _timer) {\n (_timer as { unref: () => void }).unref();\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/provider-api/index.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,yBAAyB,CAAC;AAKjC,OAAO,EAEL,KAAK,uBAAuB,EAC5B,KAAK,cAAc,EACnB,KAAK,eAAe,EACrB,MAAM,8BAA8B,CAAC;AAQtC,OAAO,KAAK,EAAE,8BAA8B,EAAE,MAAM,2BAA2B,CAAC;AAChF,OAAO,KAAK,EACV,oBAAoB,EAErB,MAAM,sBAAsB,CAAC;AAS9B,YAAY,EACV,oBAAoB,EACpB,mBAAmB,EACnB,sBAAsB,EACtB,wBAAwB,GACzB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,qBAAqB,GACtB,MAAM,sBAAsB,CAAC;AAE9B,eAAO,MAAM,gBAAgB,kSA0BnB,CAAC;AAEX,MAAM,MAAM,aAAa,GAAG,CAAC,OAAO,gBAAgB,CAAC,CAAC,MAAM,CAAC,CAAC;AAE9D,MAAM,MAAM,iBAAiB,GACzB,KAAK,GACL,MAAM,GACN,KAAK,GACL,OAAO,GACP,QAAQ,GACR,MAAM,CAAC;AAEX,kDAAkD;AAClD,MAAM,WAAW,mBAAmB;IAClC;;;OAGG;IACH,UAAU,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;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;;;;;;;;;;;;;;;;;;;;;;;;;kBAyyCnC,MAAM,EAAE;;sBAEJ,OAAO,EAAE;;kBAEb,OAAO,EAAE;;uBAEJ,OAAO,EAAE;sBACV,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAPZ,MAAM,EAAE;;sBAEJ,OAAO,EAAE;;kBAEb,OAAO,EAAE;;uBAEJ,OAAO,EAAE;sBACV,MAAM,EAAE;;;;;;;;;;;;;;;;;GAruC/B;AAeD,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,sBAAsB,EAC5B,OAAO,EAAE,yBAAyB,oBAwNnC;AAOD,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,4BAA4B,EAClC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,8BAA8B,CAAC,CAqFzC;AAED,wBAAsB,2BAA2B,CAC/C,IAAI,EAAE,8BAA8B,EACpC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,gCAAgC,CAAC,CAoF3C;AAED,wBAAsB,wBAAwB,CAC5C,IAAI,EAAE,4BAA4B,EAClC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,8BAA8B,CAAC,CAkDzC;AAED,wBAAsB,yBAAyB,CAC7C,IAAI,EAAE,6BAA6B,EACnC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,+BAA+B,CAAC,CAwE1C;AAED,wBAAsB,0BAA0B,CAC9C,IAAI,EAAE,8BAA8B,EACpC,OAAO,EAAE,yBAAyB,GACjC,OAAO,CAAC,gCAAgC,CAAC,CA0D3C;AA+uBD,wBAAsB,oCAAoC,CACxD,OAAO,EAAE,kCAAkC,GAC1C,OAAO,CAAC,6BAA6B,GAAG,IAAI,CAAC,CAkC/C"}
@@ -4,6 +4,7 @@ import { createSsrfSafeDispatcher, isBlockedExtensionUrlWithDns, } from "../exte
4
4
  import { processWebContent, } from "../extensions/web-content.js";
5
5
  import { deleteOAuthTokens, listOAuthAccountsByOwner, saveOAuthTokens, } from "../oauth-tokens/index.js";
6
6
  import { getCredentialContext } from "../server/request-context.js";
7
+ import { resolveGoogleProviderCredentialCandidates } from "../server/google-oauth-credentials.js";
7
8
  import { resolveWorkspaceConnectionCredentialForApp } from "../workspace-connections/credentials.js";
8
9
  import { createProviderQuotaIdentity, createProviderRequestDedupeKey, executeWithProviderQuota, } from "./quota-governor.js";
9
10
  export { upsertCustomProvider, deleteCustomProvider, listCustomProviders, getCustomProvider, validateCustomBaseUrl, } from "./custom-registry.js";
@@ -2447,27 +2448,38 @@ async function getValidOAuthAccessToken(options) {
2447
2448
  throw new Error(`${options.oauthProvider} OAuth token is expired and automatic refresh is not configured for provider-api.`);
2448
2449
  }
2449
2450
  async function refreshGoogleOAuthToken(options, refreshToken) {
2450
- const clientId = process.env.GOOGLE_CLIENT_ID;
2451
- const clientSecret = process.env.GOOGLE_CLIENT_SECRET;
2452
- if (!clientId || !clientSecret) {
2451
+ const credentialCandidates = resolveGoogleProviderCredentialCandidates();
2452
+ if (!credentialCandidates.length) {
2453
2453
  throw new Error("GOOGLE_CLIENT_ID/SECRET not set for Google OAuth refresh.");
2454
2454
  }
2455
- const res = await fetch("https://oauth2.googleapis.com/token", {
2456
- method: "POST",
2457
- headers: { "Content-Type": "application/x-www-form-urlencoded" },
2458
- body: new URLSearchParams({
2459
- refresh_token: refreshToken,
2460
- client_id: clientId,
2461
- client_secret: clientSecret,
2462
- grant_type: "refresh_token",
2463
- }),
2464
- });
2465
- const data = (await res.json());
2466
- if (!res.ok || !data.access_token) {
2455
+ let data = null;
2456
+ let lastStatusText = "refresh failed";
2457
+ for (const credentials of credentialCandidates) {
2458
+ const res = await fetch("https://oauth2.googleapis.com/token", {
2459
+ method: "POST",
2460
+ headers: { "Content-Type": "application/x-www-form-urlencoded" },
2461
+ body: new URLSearchParams({
2462
+ refresh_token: refreshToken,
2463
+ client_id: credentials.clientId,
2464
+ client_secret: credentials.clientSecret,
2465
+ grant_type: "refresh_token",
2466
+ }),
2467
+ });
2468
+ lastStatusText = res.statusText;
2469
+ data = (await res.json());
2470
+ if (res.ok && data.access_token)
2471
+ break;
2467
2472
  if (data.error && PERMANENT_GOOGLE_OAUTH_REFRESH_ERRORS.has(data.error)) {
2473
+ continue;
2474
+ }
2475
+ const detail = data.error_description ?? data.error ?? lastStatusText;
2476
+ throw new Error(`Google OAuth refresh failed: ${detail}`);
2477
+ }
2478
+ if (!data?.access_token) {
2479
+ if (data?.error && PERMANENT_GOOGLE_OAUTH_REFRESH_ERRORS.has(data.error)) {
2468
2480
  await deleteOAuthTokens(options.oauthProvider, options.accountId);
2469
2481
  }
2470
- const detail = data.error_description ?? data.error ?? res.statusText;
2482
+ const detail = data?.error_description ?? data?.error ?? lastStatusText;
2471
2483
  throw new Error(`Google OAuth refresh failed: ${detail}`);
2472
2484
  }
2473
2485
  const merged = {