@agent-native/core 0.97.0 → 0.98.0
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.
- package/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +32 -0
- package/corpus/core/docs/content/authentication.mdx +3 -3
- package/corpus/core/docs/content/doctor.mdx +170 -0
- package/corpus/core/docs/content/external-agents.mdx +8 -7
- package/corpus/core/docs/content/locales/ar-SA/authentication.mdx +2 -2
- package/corpus/core/docs/content/locales/ar-SA/external-agents.mdx +8 -7
- package/corpus/core/docs/content/locales/ar-SA/mcp-protocol.mdx +1 -1
- package/corpus/core/docs/content/locales/ar-SA/security.mdx +2 -0
- package/corpus/core/docs/content/locales/de-DE/authentication.mdx +1 -1
- package/corpus/core/docs/content/locales/de-DE/external-agents.mdx +8 -7
- package/corpus/core/docs/content/locales/de-DE/mcp-protocol.mdx +1 -1
- package/corpus/core/docs/content/locales/de-DE/security.mdx +2 -0
- package/corpus/core/docs/content/locales/es-ES/authentication.mdx +2 -2
- package/corpus/core/docs/content/locales/es-ES/external-agents.mdx +8 -7
- package/corpus/core/docs/content/locales/es-ES/mcp-protocol.mdx +1 -1
- package/corpus/core/docs/content/locales/es-ES/security.mdx +2 -0
- package/corpus/core/docs/content/locales/fr-FR/authentication.mdx +1 -1
- package/corpus/core/docs/content/locales/fr-FR/external-agents.mdx +8 -7
- package/corpus/core/docs/content/locales/fr-FR/mcp-protocol.mdx +1 -1
- package/corpus/core/docs/content/locales/fr-FR/security.mdx +2 -0
- package/corpus/core/docs/content/locales/hi-IN/authentication.mdx +2 -2
- package/corpus/core/docs/content/locales/hi-IN/external-agents.mdx +8 -7
- package/corpus/core/docs/content/locales/hi-IN/mcp-protocol.mdx +1 -1
- package/corpus/core/docs/content/locales/hi-IN/security.mdx +2 -0
- package/corpus/core/docs/content/locales/ja-JP/authentication.mdx +2 -2
- package/corpus/core/docs/content/locales/ja-JP/external-agents.mdx +8 -7
- package/corpus/core/docs/content/locales/ja-JP/mcp-protocol.mdx +1 -1
- package/corpus/core/docs/content/locales/ja-JP/security.mdx +2 -0
- package/corpus/core/docs/content/locales/ko-KR/authentication.mdx +2 -2
- package/corpus/core/docs/content/locales/ko-KR/external-agents.mdx +8 -7
- package/corpus/core/docs/content/locales/ko-KR/mcp-protocol.mdx +1 -1
- package/corpus/core/docs/content/locales/ko-KR/security.mdx +2 -0
- package/corpus/core/docs/content/locales/pt-BR/authentication.mdx +2 -2
- package/corpus/core/docs/content/locales/pt-BR/external-agents.mdx +8 -7
- package/corpus/core/docs/content/locales/pt-BR/mcp-protocol.mdx +1 -1
- package/corpus/core/docs/content/locales/pt-BR/security.mdx +2 -0
- package/corpus/core/docs/content/locales/zh-CN/authentication.mdx +2 -2
- package/corpus/core/docs/content/locales/zh-CN/external-agents.mdx +8 -7
- package/corpus/core/docs/content/locales/zh-CN/mcp-protocol.mdx +1 -1
- package/corpus/core/docs/content/locales/zh-CN/security.mdx +2 -0
- package/corpus/core/docs/content/locales/zh-TW/authentication.mdx +2 -2
- package/corpus/core/docs/content/locales/zh-TW/external-agents.mdx +8 -7
- package/corpus/core/docs/content/locales/zh-TW/mcp-protocol.mdx +1 -1
- package/corpus/core/docs/content/locales/zh-TW/security.mdx +2 -0
- package/corpus/core/docs/content/mcp-protocol.mdx +1 -1
- package/corpus/core/docs/content/security.mdx +2 -0
- package/corpus/core/package.json +5 -1
- package/corpus/core/scripts/finalize-build.mjs +63 -3
- package/corpus/core/scripts/materialize-source-corpus.mjs +101 -15
- package/corpus/core/src/action.ts +42 -0
- package/corpus/core/src/agent/engine/builder-engine.ts +3 -0
- package/corpus/core/src/agent/engine/context-directives-transform.ts +69 -0
- package/corpus/core/src/agent/engine/continuation-dispatch-retry.ts +168 -0
- package/corpus/core/src/agent/engine/tool-call-journal-seed.ts +85 -0
- package/corpus/core/src/agent/production-agent.ts +129 -244
- package/corpus/core/src/cli/doctor.ts +9 -3
- package/corpus/core/src/cli/plan-local.ts +10 -2
- package/corpus/core/src/cli/skills-content/assets-skill.ts +83 -0
- package/corpus/core/src/cli/skills-content/canvas.ts +153 -0
- package/corpus/core/src/cli/skills-content/connection.ts +52 -0
- package/corpus/core/src/cli/skills-content/content-skill.ts +109 -0
- package/corpus/core/src/cli/skills-content/design-exploration-skill.ts +118 -0
- package/corpus/core/src/cli/skills-content/design-visual-edit-skill.ts +228 -0
- package/corpus/core/src/cli/skills-content/document-quality.ts +196 -0
- package/corpus/core/src/cli/skills-content/exemplar.ts +69 -0
- package/corpus/core/src/cli/skills-content/help.ts +77 -0
- package/corpus/core/src/cli/skills-content/index.ts +22 -0
- package/corpus/core/src/cli/skills-content/local-files.ts +95 -0
- package/corpus/core/src/cli/skills-content/plan-setup-auth.ts +80 -0
- package/corpus/core/src/cli/skills-content/visual-plan-skill.ts +470 -0
- package/corpus/core/src/cli/skills-content/visual-recap-skill.ts +547 -0
- package/corpus/core/src/cli/skills-content/visualize-repo-skill.ts +93 -0
- package/corpus/core/src/cli/skills-content/wireframe.ts +349 -0
- package/corpus/core/src/cli/skills.ts +27 -2733
- package/corpus/core/src/client/AgentPanel.tsx +6 -5
- package/corpus/core/src/client/CommandMenu.tsx +16 -5
- package/corpus/core/src/client/FeedbackButton.tsx +2 -2
- package/corpus/core/src/client/app-providers.tsx +18 -5
- package/corpus/core/src/client/chat/tool-call-display.tsx +3 -3
- package/corpus/core/src/client/composer/PastedTextChip.tsx +1 -1
- package/corpus/core/src/client/composer/RealtimeVoiceMode.tsx +143 -45
- package/corpus/core/src/client/composer/TiptapComposer.tsx +1 -1
- package/corpus/core/src/client/composer/VoiceButton.tsx +21 -5
- package/corpus/core/src/client/composer/useRealtimeVoiceMode.tsx +107 -10
- package/corpus/core/src/client/context-xray/ContextXRayPanel.tsx +5 -2
- package/corpus/core/src/client/extensions/ExtensionEditor.tsx +37 -4
- package/corpus/core/src/client/extensions/ExtensionQueryErrorState.tsx +47 -0
- package/corpus/core/src/client/extensions/ExtensionSlot.tsx +39 -10
- package/corpus/core/src/client/extensions/ExtensionViewer.tsx +44 -6
- package/corpus/core/src/client/extensions/ExtensionsListPage.tsx +12 -3
- package/corpus/core/src/client/extensions/ExtensionsSidebarSection.tsx +49 -11
- package/corpus/core/src/client/index.ts +0 -13
- package/corpus/core/src/client/progress/RunsTray.tsx +10 -3
- package/corpus/core/src/client/settings/SettingsTabsPage.tsx +7 -0
- package/corpus/core/src/client/settings/useBuilderStatus.ts +6 -0
- package/corpus/core/src/client/tool-cells/EditCell.tsx +19 -16
- package/corpus/core/src/client/tool-cells/FilesChangedSummary.tsx +26 -23
- package/corpus/core/src/client/tool-cells/WriteCell.tsx +19 -16
- package/corpus/core/src/client/visual-style-controls.tsx +1 -1
- package/corpus/core/src/deploy/build.ts +36 -14
- package/corpus/core/src/integrations/google-docs-poller.ts +23 -2
- package/corpus/core/src/integrations/plugin.ts +10 -0
- package/corpus/core/src/integrations/webhook-handler.ts +27 -2
- package/corpus/core/src/jobs/scheduler.ts +28 -2
- package/corpus/core/src/localization/default-messages.ts +8 -1
- package/corpus/core/src/mcp/oauth-token.ts +6 -1
- package/corpus/core/src/observability/routes.ts +36 -0
- package/corpus/core/src/observability/sentiment.ts +261 -0
- package/corpus/core/src/observability/store.ts +23 -0
- package/corpus/core/src/observability/traces.ts +49 -63
- package/corpus/core/src/observability/tracking-identity.ts +55 -0
- package/corpus/core/src/observability/types.ts +13 -0
- package/corpus/core/src/secrets/storage.ts +67 -3
- package/corpus/core/src/server/agent-chat/action-filters-a2a.ts +199 -0
- package/corpus/core/src/server/agent-chat/browser-team-tools.ts +510 -0
- package/corpus/core/src/server/agent-chat/context-tools.ts +595 -0
- package/corpus/core/src/server/agent-chat/framework-prompts.ts +470 -0
- package/corpus/core/src/server/agent-chat/lazy-fs.ts +11 -0
- package/corpus/core/src/server/agent-chat/mcp-glue.ts +91 -0
- package/corpus/core/src/server/agent-chat/plugin-options.ts +350 -0
- package/corpus/core/src/server/agent-chat/process-run-failure.ts +62 -0
- package/corpus/core/src/server/agent-chat/prompt-resources.ts +688 -0
- package/corpus/core/src/server/agent-chat/recurring-jobs-runtime.ts +80 -0
- package/corpus/core/src/server/agent-chat/request-surface.ts +71 -0
- package/corpus/core/src/server/agent-chat/run-code-tools.ts +67 -0
- package/corpus/core/src/server/agent-chat/script-entries.ts +779 -0
- package/corpus/core/src/server/agent-chat/shared-thread.ts +301 -0
- package/corpus/core/src/server/agent-chat/skill-frontmatter.ts +41 -0
- package/corpus/core/src/server/agent-chat-plugin.ts +364 -4182
- package/corpus/core/src/server/agent-teams.ts +26 -3
- package/corpus/core/src/server/auth.ts +55 -57
- package/corpus/core/src/server/credential-provider.ts +22 -25
- package/corpus/core/src/server/edge.ts +1 -0
- package/corpus/core/src/server/onboarding-html.ts +1 -16
- package/corpus/core/src/server/realtime-voice.ts +40 -5
- package/corpus/core/src/server/request-origin.ts +6 -2
- package/corpus/core/src/server/ssr-handler.ts +55 -2
- package/corpus/core/src/sharing/access.ts +155 -11
- package/corpus/core/src/sharing/registry.ts +7 -0
- package/corpus/core/src/styles/agent-native.css +15 -14
- package/corpus/core/src/templates/default/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/core/src/templates/default/app/i18n/ar-SA.ts +6 -0
- package/corpus/core/src/templates/default/app/i18n/de-DE.ts +6 -0
- package/corpus/core/src/templates/default/app/i18n/en-US.ts +6 -0
- package/corpus/core/src/templates/default/app/i18n/es-ES.ts +6 -0
- package/corpus/core/src/templates/default/app/i18n/fr-FR.ts +6 -0
- package/corpus/core/src/templates/default/app/i18n/hi-IN.ts +6 -0
- package/corpus/core/src/templates/default/app/i18n/ja-JP.ts +6 -0
- package/corpus/core/src/templates/default/app/i18n/ko-KR.ts +6 -0
- package/corpus/core/src/templates/default/app/i18n/pt-BR.ts +6 -0
- package/corpus/core/src/templates/default/app/i18n/zh-CN.ts +6 -0
- package/corpus/core/src/templates/default/app/i18n/zh-TW.ts +6 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +27 -29
- package/corpus/core/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +2 -1
- package/corpus/core/src/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/core/src/templates/workspace-core/.agents/skills/observability/SKILL.md +32 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/writing-agent-instructions/SKILL.md +25 -0
- package/corpus/core/src/templates/workspace-core/src/server/index.ts +4 -2
- package/corpus/core/src/testing.ts +26 -0
- package/corpus/core/src/triggers/dispatcher.ts +23 -2
- package/corpus/core/src/vite/client.ts +126 -2
- package/corpus/core/tsconfig.cli.json +1 -1
- package/corpus/core/tsconfig.json +5 -1
- package/corpus/templates/analytics/.agents/skills/bigquery/SKILL.md +2 -2
- package/corpus/templates/analytics/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/analytics/AGENTS.md +19 -6
- package/corpus/templates/analytics/actions/install-dashboard-template.ts +79 -43
- package/corpus/templates/analytics/actions/list-explorer-dashboards.ts +3 -3
- package/corpus/templates/analytics/actions/list-sql-dashboards.ts +8 -3
- package/corpus/templates/analytics/actions/rename-analysis.ts +8 -2
- package/corpus/templates/analytics/actions/rename-dashboard.ts +8 -7
- package/corpus/templates/analytics/actions/view-screen.ts +4 -23
- package/corpus/templates/analytics/app/components/ResourceLoadError.tsx +42 -0
- package/corpus/templates/analytics/app/components/layout/CommandPalette.tsx +85 -70
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +107 -89
- package/corpus/templates/analytics/app/components/layout/SidebarLoadError.tsx +24 -0
- package/corpus/templates/analytics/app/hooks/use-dashboard-views.ts +15 -5
- package/corpus/templates/analytics/app/i18n/zh-TW.ts +4 -0
- package/corpus/templates/analytics/app/i18n-data.ts +40 -0
- package/corpus/templates/analytics/app/pages/Settings.tsx +6 -2
- package/corpus/templates/analytics/app/pages/adhoc/explorer/components/SqlPreview.tsx +36 -20
- package/corpus/templates/analytics/app/pages/adhoc/explorer/index.tsx +34 -20
- package/corpus/templates/analytics/app/pages/adhoc/explorer/use-explorer-config.ts +42 -41
- package/corpus/templates/analytics/app/pages/adhoc/explorer-dashboard/index.tsx +43 -36
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/ViewsMenu.tsx +11 -2
- package/corpus/templates/analytics/app/root.tsx +13 -1
- package/corpus/templates/analytics/app/routes/_index.tsx +14 -2
- package/corpus/templates/analytics/changelog/2026-07-03-agent-llm-observability-dashboard.md +1 -1
- package/corpus/templates/analytics/changelog/2026-07-11-agent-feedback-sentiment-dashboard.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-analytics-chats-now-start-faster-by-loading-metric-definitio.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-command-and-sql-previews-now-respond-without-lag.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-command-search-now-reports-loading-failures-and-lets-you-ret.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-dashboard-navigation-now-loads-faster-and-reports-request-fa.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-inferred-message-sentiment-dashboard.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-microphone-settings-from-realtime-voice-mode-now-open-the-vo.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-more-dashboard-edit-paths-are-now-safe-against-simultaneous-.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-renaming-a-dashboard-is-now-safe-against-simultaneous-agent-.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-renaming-an-analysis-is-now-safe-against-simultaneous-edits.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-11-workspace-mounted-analytics-now-opens-ask-reliably-and-route.md +6 -0
- package/corpus/templates/analytics/docs/schemas/first-party-analytics.md +37 -3
- package/corpus/templates/analytics/seeds/dashboards/agent-native-templates-first-party.json +339 -1
- package/corpus/templates/analytics/server/lib/dashboard-catalog.ts +1 -24
- package/corpus/templates/analytics/server/lib/dashboard-seeds.ts +0 -5
- package/corpus/templates/analytics/server/lib/dashboards-store.ts +289 -20
- package/corpus/templates/analytics/server/lib/data-dictionary-context.ts +106 -34
- package/corpus/templates/analytics/server/lib/demo-dashboards.ts +4 -1
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +11 -39
- package/corpus/templates/assets/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/assets/app/components/create/RecentDraftsSection.tsx +30 -4
- package/corpus/templates/assets/app/routes/library.tsx +49 -5
- package/corpus/templates/assets/changelog/2026-07-11-library-load-failures-now-show-a-retry-action.md +6 -0
- package/corpus/templates/brain/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/calendar/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/calendar/.env.example +5 -0
- package/corpus/templates/calendar/app/components/calendar/EventCard.tsx +2 -2
- package/corpus/templates/calendar/app/i18n/zh-TW.ts +2 -0
- package/corpus/templates/calendar/app/i18n-data.ts +20 -0
- package/corpus/templates/calendar/app/pages/BookingLinksPage.tsx +37 -1
- package/corpus/templates/calendar/app/pages/BookingsList.tsx +20 -3
- package/corpus/templates/calendar/changelog/2026-07-11-booking-load-failures-now-show-a-retry-action.md +6 -0
- package/corpus/templates/calendar/changelog/2026-07-11-event-cards-give-subtle-press-feedback-and-smoother-hover.md +6 -0
- package/corpus/templates/chat/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/clips/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/clips/actions/decline-invite.ts +8 -0
- package/corpus/templates/clips/app/components/library/folder-tree.tsx +209 -187
- package/corpus/templates/clips/app/components/meetings/meeting-card.tsx +2 -2
- package/corpus/templates/clips/app/components/player/reactions-tray.tsx +17 -5
- package/corpus/templates/clips/app/components/player/scrubber.tsx +5 -3
- package/corpus/templates/clips/app/components/recorder/pre-record-panel.tsx +2 -2
- package/corpus/templates/clips/app/components/workspace/insights-hub.tsx +119 -95
- package/corpus/templates/clips/app/global.css +45 -0
- package/corpus/templates/clips/app/root.tsx +4 -0
- package/corpus/templates/clips/app/routes/_app.notifications.tsx +23 -2
- package/corpus/templates/clips/app/routes/_app.trash.tsx +24 -2
- package/corpus/templates/clips/changelog/2026-07-11-controls-and-folders-now-move-more-smoothly.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-11-declining-an-invitation-now-requires-being-its-recipient.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-11-recording-overlays-are-lighter-weight-and-no-longer-cause-pa.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-11-workspace-load-failures-now-show-a-retry-action.md +6 -0
- package/corpus/templates/clips/chrome-extension/src/overlay.css +34 -5
- package/corpus/templates/clips/chrome-extension/src/styles.css +2 -2
- package/corpus/templates/clips/desktop/src/styles.css +71 -26
- package/corpus/templates/content/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/content/actions/move-document.ts +34 -18
- package/corpus/templates/content/app/components/QueryErrorState.tsx +39 -0
- package/corpus/templates/content/app/components/editor/LinkHoverPreview.tsx +1 -1
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +225 -1435
- package/corpus/templates/content/app/components/editor/database/GalleryView.tsx +368 -0
- package/corpus/templates/content/app/components/editor/database/ListView.tsx +353 -0
- package/corpus/templates/content/app/components/editor/database/TimelineView.tsx +580 -0
- package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +11 -2
- package/corpus/templates/content/app/global.css +19 -19
- package/corpus/templates/content/app/root.tsx +2 -2
- package/corpus/templates/content/app/routes/_app._index.tsx +11 -1
- package/corpus/templates/content/changelog/2026-07-11-document-load-failures-now-show-a-retry-action.md +6 -0
- package/corpus/templates/content/changelog/2026-07-11-editor-toggle-feedback-now-feels-more-responsive.md +6 -0
- package/corpus/templates/content/changelog/2026-07-11-moving-documents-at-the-same-time-no-longer-scrambles-their-.md +6 -0
- package/corpus/templates/content/changelog/2026-07-11-public-document-chats-now-start-faster-while-keeping-full-do.md +6 -0
- package/corpus/templates/content/changelog/2026-07-11-reopening-a-comment-now-uses-consistent-permissions-everywhe.md +6 -0
- package/corpus/templates/content/changelog/2026-07-11-sidebar-resizing-now-tracks-your-cursor-instantly-instead-of.md +6 -0
- package/corpus/templates/content/server/lib/public-documents.ts +47 -10
- package/corpus/templates/content/server/routes/api/comments/[id].patch.ts +24 -24
- package/corpus/templates/design/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/design/app/components/QueryErrorState.tsx +24 -0
- package/corpus/templates/design/app/components/design/CanvasContextMenu.tsx +1 -1
- package/corpus/templates/design/app/components/design/DesignImportPanel.tsx +5 -2
- package/corpus/templates/design/app/components/design/EditPanel.tsx +326 -319
- package/corpus/templates/design/app/components/design/LayersPanel.tsx +198 -193
- package/corpus/templates/design/app/components/design/edit-panel/panel-primitives.tsx +11 -4
- package/corpus/templates/design/app/components/design/inspector/DesignColorPicker.tsx +1 -1
- package/corpus/templates/design/app/components/layout/Layout.tsx +1 -1
- package/corpus/templates/design/app/pages/DesignSystems.tsx +7 -1
- package/corpus/templates/design/app/pages/Index.tsx +14 -2
- package/corpus/templates/design/app/pages/Present.tsx +16 -3
- package/corpus/templates/design/app/pages/Templates.tsx +10 -4
- package/corpus/templates/design/app/pages/design-editor/canvas-primitive-insert.ts +484 -0
- package/corpus/templates/design/app/pages/design-editor/clone-and-pen-edit.ts +378 -0
- package/corpus/templates/design/app/pages/design-editor/design-data-geometry-utils.ts +138 -0
- package/corpus/templates/design/app/pages/design-editor/dom-utils.ts +15 -0
- package/corpus/templates/design/app/pages/design-editor/generation-prompt-directives.ts +180 -0
- package/corpus/templates/design/app/pages/design-editor/html-layer-positioning.ts +226 -0
- package/corpus/templates/design/app/pages/design-editor/png-export-render.ts +348 -0
- package/corpus/templates/design/app/pages/design-editor/screen-command-utils.ts +160 -0
- package/corpus/templates/design/app/pages/design-editor/text-edit-utils.ts +238 -0
- package/corpus/templates/design/app/pages/design-editor/tool-state.ts +23 -1
- package/corpus/templates/design/app/pages/design-editor/types.ts +25 -0
- package/corpus/templates/design/app/root.tsx +10 -1
- package/corpus/templates/design/changelog/2026-07-11-canvas-context-menus-now-open-without-motion-jitter.md +6 -0
- package/corpus/templates/design/changelog/2026-07-11-design-load-failures-now-show-a-retry-action.md +6 -0
- package/corpus/templates/design/changelog/2026-07-11-inspector-tooltips-appear-instantly-as-you-sweep-across-icon.md +6 -0
- package/corpus/templates/dispatch/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/dispatch/app/i18n/zh-TW.ts +10 -0
- package/corpus/templates/dispatch/app/i18n-data.ts +123 -0
- package/corpus/templates/dispatch/app/routes/integrations.tsx +163 -144
- package/corpus/templates/dispatch/changelog/2026-07-11-dispatch-mcp-connections-now-start-with-safer-app-access-and.md +6 -0
- package/corpus/templates/dispatch/changelog/2026-07-11-overview-and-chat-now-share-a-cleaner-more-stable-flow.md +6 -0
- package/corpus/templates/dispatch/changelog/2026-07-11-query-errors-now-show-a-retry-option.md +6 -0
- package/corpus/templates/forms/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/forms/app/components/layout/Sidebar.tsx +3 -3
- package/corpus/templates/forms/app/root.tsx +34 -8
- package/corpus/templates/macros/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/macros/app/components/DailyProgress.tsx +25 -5
- package/corpus/templates/macros/app/components/QueryErrorState.tsx +31 -0
- package/corpus/templates/macros/app/components/WeightTracker.tsx +5 -1
- package/corpus/templates/macros/app/components/ui/button.tsx +1 -1
- package/corpus/templates/macros/app/components/ui/progress.tsx +1 -1
- package/corpus/templates/macros/app/components/ui/tabs.tsx +1 -1
- package/corpus/templates/macros/app/i18n/ar-SA.ts +2 -0
- package/corpus/templates/macros/app/i18n/de-DE.ts +2 -0
- package/corpus/templates/macros/app/i18n/en-US.ts +2 -0
- package/corpus/templates/macros/app/i18n/es-ES.ts +2 -0
- package/corpus/templates/macros/app/i18n/fr-FR.ts +2 -0
- package/corpus/templates/macros/app/i18n/hi-IN.ts +2 -0
- package/corpus/templates/macros/app/i18n/ja-JP.ts +2 -0
- package/corpus/templates/macros/app/i18n/ko-KR.ts +2 -0
- package/corpus/templates/macros/app/i18n/pt-BR.ts +2 -0
- package/corpus/templates/macros/app/i18n/zh-CN.ts +2 -0
- package/corpus/templates/macros/app/i18n/zh-TW.ts +2 -0
- package/corpus/templates/macros/app/routes/_index.tsx +22 -12
- package/corpus/templates/macros/app/routes/analytics.tsx +31 -10
- package/corpus/templates/macros/changelog/2026-07-11-daily-tracking-now-loads-and-updates-more-quickly.md +6 -0
- package/corpus/templates/macros/changelog/2026-07-11-data-load-failures-now-show-a-clear-error-with-a-retry-actio.md +6 -0
- package/corpus/templates/mail/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/mail/.env.example +16 -11
- package/corpus/templates/mail/actions/list-emails.ts +39 -35
- package/corpus/templates/mail/app/components/email/ComposeModal.tsx +58 -6
- package/corpus/templates/mail/app/components/email/EmailListItem.tsx +35 -2
- package/corpus/templates/mail/app/components/layout/AppLayout.tsx +113 -104
- package/corpus/templates/mail/app/root.tsx +8 -10
- package/corpus/templates/mail/changelog/2026-07-11-compose-and-navigation-motion-now-feel-faster-and-smoother.md +6 -0
- package/corpus/templates/mail/changelog/2026-07-11-swipe-to-archive-or-snooze-now-responds-to-quick-flicks-not-.md +6 -0
- package/corpus/templates/mail/changelog/2026-07-11-the-assistant-now-sees-the-same-inbox-you-do-snoozed-mail-st.md +6 -0
- package/corpus/templates/mail/server/handlers/emails.ts +25 -69
- package/corpus/templates/mail/server/lib/list-inbox-emails.ts +169 -0
- package/corpus/templates/plan/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/plan/.env.example +4 -0
- package/corpus/templates/plan/actions/create-plan-design.ts +89 -81
- package/corpus/templates/plan/actions/create-prototype-plan.ts +72 -59
- package/corpus/templates/plan/actions/create-ui-plan.ts +70 -55
- package/corpus/templates/plan/actions/create-visual-plan.ts +65 -51
- package/corpus/templates/plan/actions/update-local-plan-folder.ts +43 -30
- package/corpus/templates/plan/actions/update-visual-plan.ts +81 -64
- package/corpus/templates/plan/app/components/layout/Sidebar.tsx +17 -0
- package/corpus/templates/plan/app/components/ui/tabs.tsx +1 -1
- package/corpus/templates/plan/app/i18n/ar-SA.ts +10 -0
- package/corpus/templates/plan/app/i18n/de-DE.ts +10 -0
- package/corpus/templates/plan/app/i18n/en-US.ts +10 -0
- package/corpus/templates/plan/app/i18n/es-ES.ts +10 -0
- package/corpus/templates/plan/app/i18n/fr-FR.ts +10 -0
- package/corpus/templates/plan/app/i18n/hi-IN.ts +10 -0
- package/corpus/templates/plan/app/i18n/ja-JP.ts +10 -0
- package/corpus/templates/plan/app/i18n/ko-KR.ts +10 -0
- package/corpus/templates/plan/app/i18n/pt-BR.ts +10 -0
- package/corpus/templates/plan/app/i18n/zh-CN.ts +10 -0
- package/corpus/templates/plan/app/i18n/zh-TW.ts +10 -0
- package/corpus/templates/plan/app/lib/plan-local-bridge.ts +80 -1
- package/corpus/templates/plan/app/pages/PlansPage.tsx +152 -4
- package/corpus/templates/plan/app/root.tsx +11 -0
- package/corpus/templates/plan/changelog/2026-07-11-local-plans-now-explain-and-recover-from-browser-permission-.md +6 -0
- package/corpus/templates/plan/changelog/2026-07-11-plan-edits-now-save-atomically-and-can-no-longer-partially-a.md +6 -0
- package/corpus/templates/plan/changelog/2026-07-11-plan-lists-now-show-a-clear-error-with-a-retry-action-when-t.md +6 -0
- package/corpus/templates/plan/shared/plan-content.ts +546 -260
- package/corpus/templates/slides/.agents/skills/frontend-design/SKILL.md +1 -1
- package/corpus/templates/slides/actions/delete-slide-comment.ts +49 -0
- package/corpus/templates/slides/actions/update-slide-comment.ts +93 -0
- package/corpus/templates/slides/actions/view-screen.ts +14 -6
- package/corpus/templates/slides/app/components/comments/SlideCommentsPanel.tsx +33 -10
- package/corpus/templates/slides/app/components/editor/EditorSidebar.tsx +1 -1
- package/corpus/templates/slides/app/components/editor/EditorToolbar.tsx +1 -1
- package/corpus/templates/slides/app/components/editor/GenerateSlidesDialog.tsx +2 -2
- package/corpus/templates/slides/app/components/presentation/PresentationView.tsx +4 -2
- package/corpus/templates/slides/app/components/visual-editor/CanvasCommentPins.tsx +4 -3
- package/corpus/templates/slides/app/context/DeckContext.tsx +9 -0
- package/corpus/templates/slides/app/i18n/ar-SA.ts +6 -0
- package/corpus/templates/slides/app/i18n/de-DE.ts +6 -0
- package/corpus/templates/slides/app/i18n/en-US.ts +6 -0
- package/corpus/templates/slides/app/i18n/es-ES.ts +6 -0
- package/corpus/templates/slides/app/i18n/fr-FR.ts +6 -0
- package/corpus/templates/slides/app/i18n/hi-IN.ts +6 -0
- package/corpus/templates/slides/app/i18n/ja-JP.ts +6 -0
- package/corpus/templates/slides/app/i18n/ko-KR.ts +6 -0
- package/corpus/templates/slides/app/i18n/pt-BR.ts +6 -0
- package/corpus/templates/slides/app/i18n/zh-CN.ts +5 -0
- package/corpus/templates/slides/app/i18n/zh-TW.ts +5 -0
- package/corpus/templates/slides/app/pages/DesignSystems.tsx +23 -2
- package/corpus/templates/slides/app/pages/Index.tsx +29 -1
- package/corpus/templates/slides/changelog/2026-07-11-comment-load-failures-now-show-a-retry-action-instead-of-say.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-11-comment-pins-now-clear-with-a-faster-smoother-confirmation.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-11-deck-and-design-system-load-failures-now-show-a-retry-action.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-11-editor-toggles-and-toolbar-menus-now-animate-smoothly.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-11-the-assistant-can-now-resolve-reopen-and-delete-slide-commen.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-11-viewing-slides-no-longer-loads-every-deck-s-full-contents-in.md +6 -0
- package/corpus/templates/slides/server/routes/api/comments/[id].delete.ts +29 -48
- package/corpus/templates/slides/server/routes/api/comments/[id].patch.ts +29 -65
- package/dist/action.d.ts +23 -0
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js +13 -0
- package/dist/action.js.map +1 -1
- package/dist/agent/engine/builder-engine.d.ts.map +1 -1
- package/dist/agent/engine/builder-engine.js +3 -0
- package/dist/agent/engine/builder-engine.js.map +1 -1
- package/dist/agent/engine/context-directives-transform.d.ts +25 -0
- package/dist/agent/engine/context-directives-transform.d.ts.map +1 -0
- package/dist/agent/engine/context-directives-transform.js +53 -0
- package/dist/agent/engine/context-directives-transform.js.map +1 -0
- package/dist/agent/engine/continuation-dispatch-retry.d.ts +40 -0
- package/dist/agent/engine/continuation-dispatch-retry.d.ts.map +1 -0
- package/dist/agent/engine/continuation-dispatch-retry.js +109 -0
- package/dist/agent/engine/continuation-dispatch-retry.js.map +1 -0
- package/dist/agent/engine/tool-call-journal-seed.d.ts +46 -0
- package/dist/agent/engine/tool-call-journal-seed.d.ts.map +1 -0
- package/dist/agent/engine/tool-call-journal-seed.js +60 -0
- package/dist/agent/engine/tool-call-journal-seed.js.map +1 -0
- package/dist/agent/production-agent.d.ts +7 -0
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +102 -222
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/cli/doctor.d.ts.map +1 -1
- package/dist/cli/doctor.js +7 -3
- package/dist/cli/doctor.js.map +1 -1
- package/dist/cli/plan-local.d.ts.map +1 -1
- package/dist/cli/plan-local.js +8 -2
- package/dist/cli/plan-local.js.map +1 -1
- package/dist/cli/skills-content/assets-skill.d.ts +2 -0
- package/dist/cli/skills-content/assets-skill.d.ts.map +1 -0
- package/dist/cli/skills-content/assets-skill.js +84 -0
- package/dist/cli/skills-content/assets-skill.js.map +1 -0
- package/dist/cli/skills-content/canvas.d.ts +4 -0
- package/dist/cli/skills-content/canvas.d.ts.map +1 -0
- package/dist/cli/skills-content/canvas.js +152 -0
- package/dist/cli/skills-content/canvas.js.map +1 -0
- package/dist/cli/skills-content/connection.d.ts +2 -0
- package/dist/cli/skills-content/connection.d.ts.map +1 -0
- package/dist/cli/skills-content/connection.js +53 -0
- package/dist/cli/skills-content/connection.js.map +1 -0
- package/dist/cli/skills-content/content-skill.d.ts +2 -0
- package/dist/cli/skills-content/content-skill.d.ts.map +1 -0
- package/dist/cli/skills-content/content-skill.js +110 -0
- package/dist/cli/skills-content/content-skill.js.map +1 -0
- package/dist/cli/skills-content/design-exploration-skill.d.ts +2 -0
- package/dist/cli/skills-content/design-exploration-skill.d.ts.map +1 -0
- package/dist/cli/skills-content/design-exploration-skill.js +119 -0
- package/dist/cli/skills-content/design-exploration-skill.js.map +1 -0
- package/dist/cli/skills-content/design-visual-edit-skill.d.ts +2 -0
- package/dist/cli/skills-content/design-visual-edit-skill.d.ts.map +1 -0
- package/dist/cli/skills-content/design-visual-edit-skill.js +229 -0
- package/dist/cli/skills-content/design-visual-edit-skill.js.map +1 -0
- package/dist/cli/skills-content/document-quality.d.ts +4 -0
- package/dist/cli/skills-content/document-quality.d.ts.map +1 -0
- package/dist/cli/skills-content/document-quality.js +195 -0
- package/dist/cli/skills-content/document-quality.js.map +1 -0
- package/dist/cli/skills-content/exemplar.d.ts +4 -0
- package/dist/cli/skills-content/exemplar.d.ts.map +1 -0
- package/dist/cli/skills-content/exemplar.js +68 -0
- package/dist/cli/skills-content/exemplar.js.map +1 -0
- package/dist/cli/skills-content/help.d.ts +2 -0
- package/dist/cli/skills-content/help.d.ts.map +1 -0
- package/dist/cli/skills-content/help.js +78 -0
- package/dist/cli/skills-content/help.js.map +1 -0
- package/dist/cli/skills-content/index.d.ts +23 -0
- package/dist/cli/skills-content/index.d.ts.map +1 -0
- package/dist/cli/skills-content/index.js +23 -0
- package/dist/cli/skills-content/index.js.map +1 -0
- package/dist/cli/skills-content/local-files.d.ts +2 -0
- package/dist/cli/skills-content/local-files.d.ts.map +1 -0
- package/dist/cli/skills-content/local-files.js +96 -0
- package/dist/cli/skills-content/local-files.js.map +1 -0
- package/dist/cli/skills-content/plan-setup-auth.d.ts +9 -0
- package/dist/cli/skills-content/plan-setup-auth.d.ts.map +1 -0
- package/dist/cli/skills-content/plan-setup-auth.js +81 -0
- package/dist/cli/skills-content/plan-setup-auth.js.map +1 -0
- package/dist/cli/skills-content/visual-plan-skill.d.ts +2 -0
- package/dist/cli/skills-content/visual-plan-skill.d.ts.map +1 -0
- package/dist/cli/skills-content/visual-plan-skill.js +471 -0
- package/dist/cli/skills-content/visual-plan-skill.js.map +1 -0
- package/dist/cli/skills-content/visual-recap-skill.d.ts +2 -0
- package/dist/cli/skills-content/visual-recap-skill.d.ts.map +1 -0
- package/dist/cli/skills-content/visual-recap-skill.js +548 -0
- package/dist/cli/skills-content/visual-recap-skill.js.map +1 -0
- package/dist/cli/skills-content/visualize-repo-skill.d.ts +2 -0
- package/dist/cli/skills-content/visualize-repo-skill.d.ts.map +1 -0
- package/dist/cli/skills-content/visualize-repo-skill.js +94 -0
- package/dist/cli/skills-content/visualize-repo-skill.js.map +1 -0
- package/dist/cli/skills-content/wireframe.d.ts +4 -0
- package/dist/cli/skills-content/wireframe.d.ts.map +1 -0
- package/dist/cli/skills-content/wireframe.js +347 -0
- package/dist/cli/skills-content/wireframe.js.map +1 -0
- package/dist/cli/skills.d.ts +2 -10
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +2 -2710
- package/dist/cli/skills.js.map +1 -1
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +4 -2
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/CommandMenu.d.ts.map +1 -1
- package/dist/client/CommandMenu.js +15 -3
- package/dist/client/CommandMenu.js.map +1 -1
- package/dist/client/FeedbackButton.js +2 -2
- package/dist/client/FeedbackButton.js.map +1 -1
- package/dist/client/app-providers.d.ts +13 -5
- package/dist/client/app-providers.d.ts.map +1 -1
- package/dist/client/app-providers.js +9 -6
- package/dist/client/app-providers.js.map +1 -1
- package/dist/client/chat/tool-call-display.d.ts +4 -0
- package/dist/client/chat/tool-call-display.d.ts.map +1 -1
- package/dist/client/chat/tool-call-display.js +3 -3
- package/dist/client/chat/tool-call-display.js.map +1 -1
- package/dist/client/composer/PastedTextChip.js +1 -1
- package/dist/client/composer/PastedTextChip.js.map +1 -1
- package/dist/client/composer/RealtimeVoiceMode.d.ts +3 -1
- package/dist/client/composer/RealtimeVoiceMode.d.ts.map +1 -1
- package/dist/client/composer/RealtimeVoiceMode.js +35 -14
- package/dist/client/composer/RealtimeVoiceMode.js.map +1 -1
- package/dist/client/composer/TiptapComposer.js +1 -1
- package/dist/client/composer/TiptapComposer.js.map +1 -1
- package/dist/client/composer/VoiceButton.d.ts +2 -0
- package/dist/client/composer/VoiceButton.d.ts.map +1 -1
- package/dist/client/composer/VoiceButton.js +9 -3
- package/dist/client/composer/VoiceButton.js.map +1 -1
- package/dist/client/composer/useRealtimeVoiceMode.d.ts +5 -0
- package/dist/client/composer/useRealtimeVoiceMode.d.ts.map +1 -1
- package/dist/client/composer/useRealtimeVoiceMode.js +91 -12
- package/dist/client/composer/useRealtimeVoiceMode.js.map +1 -1
- package/dist/client/context-xray/ContextXRayPanel.d.ts.map +1 -1
- package/dist/client/context-xray/ContextXRayPanel.js +4 -1
- package/dist/client/context-xray/ContextXRayPanel.js.map +1 -1
- package/dist/client/extensions/ExtensionEditor.d.ts.map +1 -1
- package/dist/client/extensions/ExtensionEditor.js +15 -5
- package/dist/client/extensions/ExtensionEditor.js.map +1 -1
- package/dist/client/extensions/ExtensionQueryErrorState.d.ts +8 -0
- package/dist/client/extensions/ExtensionQueryErrorState.d.ts.map +1 -0
- package/dist/client/extensions/ExtensionQueryErrorState.js +11 -0
- package/dist/client/extensions/ExtensionQueryErrorState.js.map +1 -0
- package/dist/client/extensions/ExtensionSlot.d.ts.map +1 -1
- package/dist/client/extensions/ExtensionSlot.js +17 -7
- package/dist/client/extensions/ExtensionSlot.js.map +1 -1
- package/dist/client/extensions/ExtensionViewer.d.ts.map +1 -1
- package/dist/client/extensions/ExtensionViewer.js +17 -7
- package/dist/client/extensions/ExtensionViewer.js.map +1 -1
- package/dist/client/extensions/ExtensionsListPage.d.ts.map +1 -1
- package/dist/client/extensions/ExtensionsListPage.js +5 -3
- package/dist/client/extensions/ExtensionsListPage.js.map +1 -1
- package/dist/client/extensions/ExtensionsSidebarSection.d.ts.map +1 -1
- package/dist/client/extensions/ExtensionsSidebarSection.js +21 -8
- package/dist/client/extensions/ExtensionsSidebarSection.js.map +1 -1
- package/dist/client/index.d.ts +0 -2
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +0 -5
- package/dist/client/index.js.map +1 -1
- package/dist/client/progress/RunsTray.d.ts.map +1 -1
- package/dist/client/progress/RunsTray.js +7 -3
- package/dist/client/progress/RunsTray.js.map +1 -1
- package/dist/client/settings/SettingsTabsPage.d.ts.map +1 -1
- package/dist/client/settings/SettingsTabsPage.js +4 -0
- package/dist/client/settings/SettingsTabsPage.js.map +1 -1
- package/dist/client/settings/useBuilderStatus.d.ts +2 -0
- package/dist/client/settings/useBuilderStatus.d.ts.map +1 -1
- package/dist/client/settings/useBuilderStatus.js +4 -0
- package/dist/client/settings/useBuilderStatus.js.map +1 -1
- package/dist/client/tool-cells/EditCell.d.ts.map +1 -1
- package/dist/client/tool-cells/EditCell.js +2 -1
- package/dist/client/tool-cells/EditCell.js.map +1 -1
- package/dist/client/tool-cells/FilesChangedSummary.d.ts.map +1 -1
- package/dist/client/tool-cells/FilesChangedSummary.js +2 -1
- package/dist/client/tool-cells/FilesChangedSummary.js.map +1 -1
- package/dist/client/tool-cells/WriteCell.d.ts.map +1 -1
- package/dist/client/tool-cells/WriteCell.js +2 -1
- package/dist/client/tool-cells/WriteCell.js.map +1 -1
- package/dist/client/visual-style-controls.js +1 -1
- package/dist/client/visual-style-controls.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +36 -14
- package/dist/deploy/build.js.map +1 -1
- package/dist/integrations/google-docs-poller.d.ts +7 -0
- package/dist/integrations/google-docs-poller.d.ts.map +1 -1
- package/dist/integrations/google-docs-poller.js +13 -3
- package/dist/integrations/google-docs-poller.js.map +1 -1
- package/dist/integrations/plugin.d.ts.map +1 -1
- package/dist/integrations/plugin.js +10 -0
- package/dist/integrations/plugin.js.map +1 -1
- package/dist/integrations/webhook-handler.d.ts +11 -0
- package/dist/integrations/webhook-handler.d.ts.map +1 -1
- package/dist/integrations/webhook-handler.js +16 -4
- package/dist/integrations/webhook-handler.js.map +1 -1
- package/dist/jobs/scheduler.d.ts +12 -0
- package/dist/jobs/scheduler.d.ts.map +1 -1
- package/dist/jobs/scheduler.js +13 -3
- package/dist/jobs/scheduler.js.map +1 -1
- package/dist/localization/default-messages.d.ts +7 -0
- package/dist/localization/default-messages.d.ts.map +1 -1
- package/dist/localization/default-messages.js +8 -1
- package/dist/localization/default-messages.js.map +1 -1
- package/dist/mcp/oauth-token.d.ts +1 -1
- package/dist/mcp/oauth-token.d.ts.map +1 -1
- package/dist/mcp/oauth-token.js +6 -1
- package/dist/mcp/oauth-token.js.map +1 -1
- package/dist/notifications/routes.d.ts +2 -2
- package/dist/observability/routes.d.ts.map +1 -1
- package/dist/observability/routes.js +32 -0
- package/dist/observability/routes.js.map +1 -1
- package/dist/observability/sentiment.d.ts +42 -0
- package/dist/observability/sentiment.d.ts.map +1 -0
- package/dist/observability/sentiment.js +196 -0
- package/dist/observability/sentiment.js.map +1 -0
- package/dist/observability/store.d.ts +5 -0
- package/dist/observability/store.d.ts.map +1 -1
- package/dist/observability/store.js +17 -0
- package/dist/observability/store.js.map +1 -1
- package/dist/observability/traces.d.ts +2 -0
- package/dist/observability/traces.d.ts.map +1 -1
- package/dist/observability/traces.js +42 -57
- package/dist/observability/traces.js.map +1 -1
- package/dist/observability/tracking-identity.d.ts +3 -0
- package/dist/observability/tracking-identity.d.ts.map +1 -0
- package/dist/observability/tracking-identity.js +51 -0
- package/dist/observability/tracking-identity.js.map +1 -0
- package/dist/observability/types.d.ts +10 -0
- package/dist/observability/types.d.ts.map +1 -1
- package/dist/observability/types.js +3 -0
- package/dist/observability/types.js.map +1 -1
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/secrets/storage.d.ts +6 -0
- package/dist/secrets/storage.d.ts.map +1 -1
- package/dist/secrets/storage.js +61 -3
- package/dist/secrets/storage.js.map +1 -1
- package/dist/server/agent-chat/action-filters-a2a.d.ts +50 -0
- package/dist/server/agent-chat/action-filters-a2a.d.ts.map +1 -0
- package/dist/server/agent-chat/action-filters-a2a.js +127 -0
- package/dist/server/agent-chat/action-filters-a2a.js.map +1 -0
- package/dist/server/agent-chat/browser-team-tools.d.ts +21 -0
- package/dist/server/agent-chat/browser-team-tools.d.ts.map +1 -0
- package/dist/server/agent-chat/browser-team-tools.js +417 -0
- package/dist/server/agent-chat/browser-team-tools.js.map +1 -0
- package/dist/server/agent-chat/context-tools.d.ts +33 -0
- package/dist/server/agent-chat/context-tools.d.ts.map +1 -0
- package/dist/server/agent-chat/context-tools.js +520 -0
- package/dist/server/agent-chat/context-tools.js.map +1 -0
- package/dist/server/agent-chat/framework-prompts.d.ts +65 -0
- package/dist/server/agent-chat/framework-prompts.d.ts.map +1 -0
- package/dist/server/agent-chat/framework-prompts.js +403 -0
- package/dist/server/agent-chat/framework-prompts.js.map +1 -0
- package/dist/server/agent-chat/lazy-fs.d.ts +2 -0
- package/dist/server/agent-chat/lazy-fs.d.ts.map +1 -0
- package/dist/server/agent-chat/lazy-fs.js +11 -0
- package/dist/server/agent-chat/lazy-fs.js.map +1 -0
- package/dist/server/agent-chat/mcp-glue.d.ts +9 -0
- package/dist/server/agent-chat/mcp-glue.d.ts.map +1 -0
- package/dist/server/agent-chat/mcp-glue.js +63 -0
- package/dist/server/agent-chat/mcp-glue.js.map +1 -0
- package/dist/server/agent-chat/plugin-options.d.ts +322 -0
- package/dist/server/agent-chat/plugin-options.d.ts.map +1 -0
- package/dist/server/agent-chat/plugin-options.js +2 -0
- package/dist/server/agent-chat/plugin-options.js.map +1 -0
- package/dist/server/agent-chat/process-run-failure.d.ts +12 -0
- package/dist/server/agent-chat/process-run-failure.d.ts.map +1 -0
- package/dist/server/agent-chat/process-run-failure.js +24 -0
- package/dist/server/agent-chat/process-run-failure.js.map +1 -0
- package/dist/server/agent-chat/prompt-resources.d.ts +28 -0
- package/dist/server/agent-chat/prompt-resources.d.ts.map +1 -0
- package/dist/server/agent-chat/prompt-resources.js +514 -0
- package/dist/server/agent-chat/prompt-resources.js.map +1 -0
- package/dist/server/agent-chat/recurring-jobs-runtime.d.ts +5 -0
- package/dist/server/agent-chat/recurring-jobs-runtime.d.ts.map +1 -0
- package/dist/server/agent-chat/recurring-jobs-runtime.js +53 -0
- package/dist/server/agent-chat/recurring-jobs-runtime.js.map +1 -0
- package/dist/server/agent-chat/request-surface.d.ts +8 -0
- package/dist/server/agent-chat/request-surface.d.ts.map +1 -0
- package/dist/server/agent-chat/request-surface.js +56 -0
- package/dist/server/agent-chat/request-surface.js.map +1 -0
- package/dist/server/agent-chat/run-code-tools.d.ts +17 -0
- package/dist/server/agent-chat/run-code-tools.d.ts.map +1 -0
- package/dist/server/agent-chat/run-code-tools.js +55 -0
- package/dist/server/agent-chat/run-code-tools.js.map +1 -0
- package/dist/server/agent-chat/script-entries.d.ts +47 -0
- package/dist/server/agent-chat/script-entries.d.ts.map +1 -0
- package/dist/server/agent-chat/script-entries.js +633 -0
- package/dist/server/agent-chat/script-entries.js.map +1 -0
- package/dist/server/agent-chat/shared-thread.d.ts +33 -0
- package/dist/server/agent-chat/shared-thread.d.ts.map +1 -0
- package/dist/server/agent-chat/shared-thread.js +242 -0
- package/dist/server/agent-chat/shared-thread.js.map +1 -0
- package/dist/server/agent-chat/skill-frontmatter.d.ts +7 -0
- package/dist/server/agent-chat/skill-frontmatter.d.ts.map +1 -0
- package/dist/server/agent-chat/skill-frontmatter.js +26 -0
- package/dist/server/agent-chat/skill-frontmatter.js.map +1 -0
- package/dist/server/agent-chat-plugin.d.ts +45 -486
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +173 -3005
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/agent-teams.d.ts +10 -0
- package/dist/server/agent-teams.d.ts.map +1 -1
- package/dist/server/agent-teams.js +13 -3
- package/dist/server/agent-teams.js.map +1 -1
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +50 -52
- package/dist/server/auth.js.map +1 -1
- package/dist/server/credential-provider.d.ts.map +1 -1
- package/dist/server/credential-provider.js +22 -21
- package/dist/server/credential-provider.js.map +1 -1
- package/dist/server/edge.d.ts +1 -0
- package/dist/server/edge.d.ts.map +1 -1
- package/dist/server/edge.js +1 -0
- package/dist/server/edge.js.map +1 -1
- package/dist/server/onboarding-html.d.ts.map +1 -1
- package/dist/server/onboarding-html.js +1 -16
- package/dist/server/onboarding-html.js.map +1 -1
- package/dist/server/realtime-voice.d.ts +3 -0
- package/dist/server/realtime-voice.d.ts.map +1 -1
- package/dist/server/realtime-voice.js +29 -5
- package/dist/server/realtime-voice.js.map +1 -1
- package/dist/server/request-origin.d.ts.map +1 -1
- package/dist/server/request-origin.js +6 -3
- package/dist/server/request-origin.js.map +1 -1
- package/dist/server/ssr-handler.d.ts.map +1 -1
- package/dist/server/ssr-handler.js +47 -2
- package/dist/server/ssr-handler.js.map +1 -1
- package/dist/sharing/access.d.ts +63 -3
- package/dist/sharing/access.d.ts.map +1 -1
- package/dist/sharing/access.js +53 -15
- package/dist/sharing/access.js.map +1 -1
- package/dist/sharing/registry.d.ts +7 -0
- package/dist/sharing/registry.d.ts.map +1 -1
- package/dist/sharing/registry.js.map +1 -1
- package/dist/styles/agent-native.css +15 -14
- package/dist/templates/default/.agents/skills/frontend-design/SKILL.md +1 -1
- package/dist/templates/default/app/i18n/ar-SA.ts +6 -0
- package/dist/templates/default/app/i18n/de-DE.ts +6 -0
- package/dist/templates/default/app/i18n/en-US.ts +6 -0
- package/dist/templates/default/app/i18n/es-ES.ts +6 -0
- package/dist/templates/default/app/i18n/fr-FR.ts +6 -0
- package/dist/templates/default/app/i18n/hi-IN.ts +6 -0
- package/dist/templates/default/app/i18n/ja-JP.ts +6 -0
- package/dist/templates/default/app/i18n/ko-KR.ts +6 -0
- package/dist/templates/default/app/i18n/pt-BR.ts +6 -0
- package/dist/templates/default/app/i18n/zh-CN.ts +6 -0
- package/dist/templates/default/app/i18n/zh-TW.ts +6 -0
- package/dist/templates/workspace-core/.agents/skills/authentication/SKILL.md +27 -29
- package/dist/templates/workspace-core/.agents/skills/external-agents/SKILL.md +2 -1
- package/dist/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +1 -1
- package/dist/templates/workspace-core/.agents/skills/observability/SKILL.md +32 -0
- package/dist/templates/workspace-core/.agents/skills/writing-agent-instructions/SKILL.md +25 -0
- package/dist/templates/workspace-core/src/server/index.ts +4 -2
- package/dist/testing.d.ts +16 -0
- package/dist/testing.d.ts.map +1 -0
- package/dist/testing.js +16 -0
- package/dist/testing.js.map +1 -0
- package/dist/triggers/dispatcher.d.ts +7 -0
- package/dist/triggers/dispatcher.d.ts.map +1 -1
- package/dist/triggers/dispatcher.js +13 -3
- package/dist/triggers/dispatcher.js.map +1 -1
- package/dist/vite/client.d.ts +16 -1
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +105 -2
- package/dist/vite/client.js.map +1 -1
- package/docs/content/authentication.mdx +3 -3
- package/docs/content/doctor.mdx +170 -0
- package/docs/content/external-agents.mdx +8 -7
- package/docs/content/locales/ar-SA/authentication.mdx +2 -2
- package/docs/content/locales/ar-SA/external-agents.mdx +8 -7
- package/docs/content/locales/ar-SA/mcp-protocol.mdx +1 -1
- package/docs/content/locales/ar-SA/security.mdx +2 -0
- package/docs/content/locales/de-DE/authentication.mdx +1 -1
- package/docs/content/locales/de-DE/external-agents.mdx +8 -7
- package/docs/content/locales/de-DE/mcp-protocol.mdx +1 -1
- package/docs/content/locales/de-DE/security.mdx +2 -0
- package/docs/content/locales/es-ES/authentication.mdx +2 -2
- package/docs/content/locales/es-ES/external-agents.mdx +8 -7
- package/docs/content/locales/es-ES/mcp-protocol.mdx +1 -1
- package/docs/content/locales/es-ES/security.mdx +2 -0
- package/docs/content/locales/fr-FR/authentication.mdx +1 -1
- package/docs/content/locales/fr-FR/external-agents.mdx +8 -7
- package/docs/content/locales/fr-FR/mcp-protocol.mdx +1 -1
- package/docs/content/locales/fr-FR/security.mdx +2 -0
- package/docs/content/locales/hi-IN/authentication.mdx +2 -2
- package/docs/content/locales/hi-IN/external-agents.mdx +8 -7
- package/docs/content/locales/hi-IN/mcp-protocol.mdx +1 -1
- package/docs/content/locales/hi-IN/security.mdx +2 -0
- package/docs/content/locales/ja-JP/authentication.mdx +2 -2
- package/docs/content/locales/ja-JP/external-agents.mdx +8 -7
- package/docs/content/locales/ja-JP/mcp-protocol.mdx +1 -1
- package/docs/content/locales/ja-JP/security.mdx +2 -0
- package/docs/content/locales/ko-KR/authentication.mdx +2 -2
- package/docs/content/locales/ko-KR/external-agents.mdx +8 -7
- package/docs/content/locales/ko-KR/mcp-protocol.mdx +1 -1
- package/docs/content/locales/ko-KR/security.mdx +2 -0
- package/docs/content/locales/pt-BR/authentication.mdx +2 -2
- package/docs/content/locales/pt-BR/external-agents.mdx +8 -7
- package/docs/content/locales/pt-BR/mcp-protocol.mdx +1 -1
- package/docs/content/locales/pt-BR/security.mdx +2 -0
- package/docs/content/locales/zh-CN/authentication.mdx +2 -2
- package/docs/content/locales/zh-CN/external-agents.mdx +8 -7
- package/docs/content/locales/zh-CN/mcp-protocol.mdx +1 -1
- package/docs/content/locales/zh-CN/security.mdx +2 -0
- package/docs/content/locales/zh-TW/authentication.mdx +2 -2
- package/docs/content/locales/zh-TW/external-agents.mdx +8 -7
- package/docs/content/locales/zh-TW/mcp-protocol.mdx +1 -1
- package/docs/content/locales/zh-TW/security.mdx +2 -0
- package/docs/content/mcp-protocol.mdx +1 -1
- package/docs/content/security.mdx +2 -0
- package/package.json +6 -2
- package/src/templates/default/.agents/skills/frontend-design/SKILL.md +1 -1
- package/src/templates/default/app/i18n/ar-SA.ts +6 -0
- package/src/templates/default/app/i18n/de-DE.ts +6 -0
- package/src/templates/default/app/i18n/en-US.ts +6 -0
- package/src/templates/default/app/i18n/es-ES.ts +6 -0
- package/src/templates/default/app/i18n/fr-FR.ts +6 -0
- package/src/templates/default/app/i18n/hi-IN.ts +6 -0
- package/src/templates/default/app/i18n/ja-JP.ts +6 -0
- package/src/templates/default/app/i18n/ko-KR.ts +6 -0
- package/src/templates/default/app/i18n/pt-BR.ts +6 -0
- package/src/templates/default/app/i18n/zh-CN.ts +6 -0
- package/src/templates/default/app/i18n/zh-TW.ts +6 -0
- package/src/templates/workspace-core/.agents/skills/authentication/SKILL.md +27 -29
- package/src/templates/workspace-core/.agents/skills/external-agents/SKILL.md +2 -1
- package/src/templates/workspace-core/.agents/skills/frontend-design/SKILL.md +1 -1
- package/src/templates/workspace-core/.agents/skills/observability/SKILL.md +32 -0
- package/src/templates/workspace-core/.agents/skills/writing-agent-instructions/SKILL.md +25 -0
- package/src/templates/workspace-core/src/server/index.ts +4 -2
- package/corpus/core/src/client/ProductionAgentPanel.tsx +0 -9
- package/corpus/core/src/client/auth-redirect-url.ts +0 -23
- package/corpus/core/src/client/useProductionAgent.ts +0 -253
- package/corpus/core/src/shared/auth-redirect-url.ts +0 -1
- package/corpus/templates/analytics/app/pages/Index.tsx +0 -16
- package/corpus/templates/analytics/seeds/dashboards/agent-observability-llm.json +0 -173
- package/dist/client/ProductionAgentPanel.d.ts +0 -6
- package/dist/client/ProductionAgentPanel.d.ts.map +0 -1
- package/dist/client/ProductionAgentPanel.js +0 -6
- package/dist/client/ProductionAgentPanel.js.map +0 -1
- package/dist/client/auth-redirect-url.d.ts +0 -2
- package/dist/client/auth-redirect-url.d.ts.map +0 -1
- package/dist/client/auth-redirect-url.js +0 -19
- package/dist/client/auth-redirect-url.js.map +0 -1
- package/dist/client/useProductionAgent.d.ts +0 -24
- package/dist/client/useProductionAgent.d.ts.map +0 -1
- package/dist/client/useProductionAgent.js +0 -179
- package/dist/client/useProductionAgent.js.map +0 -1
- package/dist/shared/auth-redirect-url.d.ts +0 -2
- package/dist/shared/auth-redirect-url.d.ts.map +0 -1
- package/dist/shared/auth-redirect-url.js +0 -2
- package/dist/shared/auth-redirect-url.js.map +0 -1
|
@@ -8,6 +8,13 @@ export interface GoogleDocsPollerOptions {
|
|
|
8
8
|
systemPrompt: string;
|
|
9
9
|
/** Action entries for the agent */
|
|
10
10
|
actions: Record<string, ActionEntry>;
|
|
11
|
+
/**
|
|
12
|
+
* Tool names to expose on the FIRST engine request. See
|
|
13
|
+
* `WebhookHandlerOptions.initialToolNames` (`webhook-handler.ts`) — same
|
|
14
|
+
* semantics, shared `actions` source from `createIntegrationsPlugin`. Omit
|
|
15
|
+
* to keep the full `actions` set visible up front (current behavior).
|
|
16
|
+
*/
|
|
17
|
+
initialToolNames?: string[];
|
|
11
18
|
/** Model to use */
|
|
12
19
|
model: string;
|
|
13
20
|
/** Anthropic API key */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-docs-poller.d.ts","sourceRoot":"","sources":["../../src/integrations/google-docs-poller.ts"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"google-docs-poller.d.ts","sourceRoot":"","sources":["../../src/integrations/google-docs-poller.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,WAAW,EACjB,MAAM,8BAA8B,CAAC;AAkCtC,MAAM,WAAW,uBAAuB;IACtC,6EAA6E;IAC7E,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,wEAAwE;IACxE,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,kCAAkC;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,mCAAmC;IACnC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;IACrC;;;;;OAKG;IACH,gBAAgB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC5B,mBAAmB;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,wBAAwB;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,yBAAyB;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,sEAAsE;IACtE,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAWD;;;;;GAKG;AACH,wBAAsB,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC,CAqExE;AAiMD;;;;GAIG;AACH,wBAAsB,cAAc,CAClC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAmCf;AAED;;;GAGG;AACH,wBAAsB,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC,CAa5D;AA2KD;;;;;;;;;;GAUG;AACH,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,uBAAuB,GAC/B,OAAO,CAAC,IAAI,CAAC,CAmCf;AAgCD;;GAEG;AACH,wBAAsB,oBAAoB,IAAI,OAAO,CAAC,IAAI,CAAC,CAW1D"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { createAnthropicEngine } from "../agent/engine/index.js";
|
|
2
|
-
import { runAgentLoop, actionsToEngineTools, } from "../agent/production-agent.js";
|
|
2
|
+
import { runAgentLoop, actionsToEngineTools, filterInitialEngineTools, } from "../agent/production-agent.js";
|
|
3
3
|
import { startRun } from "../agent/run-manager.js";
|
|
4
4
|
import { buildAssistantMessage, extractThreadMeta, } from "../agent/thread-data-builder.js";
|
|
5
|
+
import { attachToolSearch } from "../agent/tool-search.js";
|
|
5
6
|
import { createThread, getThread, updateThreadData, } from "../chat-threads/store.js";
|
|
6
7
|
import { resolveOrgIdForEmail } from "../org/context.js";
|
|
7
8
|
import { runWithRequestContext } from "../server/request-context.js";
|
|
@@ -317,7 +318,15 @@ async function processComment(fileId, commentId, text, senderName, options, exis
|
|
|
317
318
|
{ role: "user", content: [{ type: "text", text }] },
|
|
318
319
|
];
|
|
319
320
|
const engine = createAnthropicEngine({ apiKey: options.apiKey });
|
|
320
|
-
|
|
321
|
+
// Attach tool-search on a shallow copy so framework additions merged in by
|
|
322
|
+
// `createIntegrationsPlugin` (integration memory, `call-agent`) can be
|
|
323
|
+
// deferred behind it without mutating the plugin's long-lived registry.
|
|
324
|
+
// `runAgentLoop`'s `expandActiveTools` re-expands from `availableTools`
|
|
325
|
+
// after a tool-search call, so anything filtered out of the initial
|
|
326
|
+
// `tools` list stays reachable.
|
|
327
|
+
const runnableActions = attachToolSearch({ ...options.actions });
|
|
328
|
+
const availableTools = actionsToEngineTools(runnableActions);
|
|
329
|
+
const tools = filterInitialEngineTools(availableTools, options.initialToolNames);
|
|
321
330
|
const runId = `gdocs-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;
|
|
322
331
|
const capturedThreadId = threadId;
|
|
323
332
|
const orgId = (await resolveOrgIdForEmail(options.ownerEmail)) ?? undefined;
|
|
@@ -327,8 +336,9 @@ async function processComment(fileId, commentId, text, senderName, options, exis
|
|
|
327
336
|
model: options.model,
|
|
328
337
|
systemPrompt: options.systemPrompt,
|
|
329
338
|
tools,
|
|
339
|
+
availableTools,
|
|
330
340
|
messages,
|
|
331
|
-
actions:
|
|
341
|
+
actions: runnableActions,
|
|
332
342
|
send,
|
|
333
343
|
signal,
|
|
334
344
|
}));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"google-docs-poller.js","sourceRoot":"","sources":["../../src/integrations/google-docs-poller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,EACL,YAAY,EACZ,oBAAoB,GAErB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAkB,MAAM,yBAAyB,CAAC;AACnE,OAAO,EACL,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,YAAY,EACZ,SAAS,EACT,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AO,CAAC,KAAK,CAAC,6BAA6B,EAAE,MAAM,CAAC,CAAC;QACvD,CAAC;IACH,CAAC;IAED,UAAU,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC;IACvB,cAAc,GAAG,WAAW,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAE/C,MAAM,KAAK,GAAG,sBAAsB,EAAE,CAAC;IACvC,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,CACT,8CAA8C,UAAU,GAAG,IAAI,uBAAuB,KAAK,IAAI,gBAAgB,GAAG,CACnH,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB;IACxC,IAAI,cAAc,EAAE,CAAC;QACnB,aAAa,CAAC,cAAc,CAAC,CAAC;QAC9B,cAAc,GAAG,IAAI,CAAC;IACxB,CAAC;IACD,IAAI,iBAAiB,EAAE,CAAC;QACtB,YAAY,CAAC,iBAAiB,CAAC,CAAC;QAChC,iBAAiB,GAAG,IAAI,CAAC;IAC3B,CAAC;IACD,MAAM,SAAS,EAAE,CAAC;IAClB,aAAa,GAAG,IAAI,CAAC;AACvB,CAAC","sourcesContent":["import { createAnthropicEngine } from \"../agent/engine/index.js\";\nimport type { EngineMessage } from \"../agent/engine/types.js\";\nimport {\n runAgentLoop,\n actionsToEngineTools,\n type ActionEntry,\n} from \"../agent/production-agent.js\";\nimport { startRun, type ActiveRun } from \"../agent/run-manager.js\";\nimport {\n buildAssistantMessage,\n extractThreadMeta,\n} from \"../agent/thread-data-builder.js\";\nimport {\n createThread,\n getThread,\n updateThreadData,\n} from \"../chat-threads/store.js\";\nimport { resolveOrgIdForEmail } from \"../org/context.js\";\nimport { runWithRequestContext } from \"../server/request-context.js\";\nimport {\n getServiceAccountAccessToken,\n getServiceAccountEmail,\n getStartPageToken,\n googleDocsAdapter,\n listChanges,\n listDocComments,\n} from \"./adapters/google-docs.js\";\nimport { getIntegrationConfig, saveIntegrationConfig } from \"./config-store.js\";\nimport { getThreadMapping, saveThreadMapping } from \"./thread-mapping-store.js\";\nimport type { IncomingMessage } from \"./types.js\";\n\nconst PLATFORM = \"google-docs\";\nconst DEFAULT_TRIGGER = \"@agent\";\n\n/** Track processed comment IDs to avoid reprocessing */\nconst processedComments = new Set<string>();\n/** Track last-checked time per document for comment filtering */\nconst lastCheckedTimes = new Map<string, string>();\n\nexport interface GoogleDocsPollerOptions {\n /** Polling interval in milliseconds (fallback mode). Default: 30000 (30s) */\n intervalMs?: number;\n /** Trigger keyword in comments. Default: \"@agent\" (case-insensitive) */\n triggerKeyword?: string;\n /** System prompt for the agent */\n systemPrompt: string;\n /** Action entries for the agent */\n actions: Record<string, ActionEntry>;\n /** Model to use */\n model: string;\n /** Anthropic API key */\n apiKey: string;\n /** Thread owner email */\n ownerEmail: string;\n /** Webhook URL for push mode (set by plugin from WEBHOOK_BASE_URL) */\n webhookUrl?: string;\n}\n\nlet pollerInterval: ReturnType<typeof setInterval> | null = null;\nlet activeOptions: GoogleDocsPollerOptions | null = null;\n\n// ─── Watch Channel Management ───────────────────────────────────────────────\n\n/** How long a watch channel lasts (Google max is ~24h, we use 23h to renew early) */\nconst WATCH_CHANNEL_TTL_MS = 23 * 60 * 60 * 1000;\nlet watchRenewalTimer: ReturnType<typeof setTimeout> | null = null;\n\n/**\n * Register a Google Drive changes.watch channel so Google pushes\n * notifications to our webhook instead of us polling.\n *\n * Returns true if the watch was registered successfully.\n */\nexport async function registerWatch(webhookUrl: string): Promise<boolean> {\n const accessToken = await getServiceAccountAccessToken();\n if (!accessToken) return false;\n\n // Get the current page token as the starting point\n let pageToken = await getPageToken();\n if (!pageToken) {\n pageToken = await getStartPageToken(accessToken);\n await setPageToken(pageToken);\n }\n\n const channelId = `gdocs-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;\n const expiration = Date.now() + WATCH_CHANNEL_TTL_MS;\n\n try {\n const res = await fetch(\n \"https://www.googleapis.com/drive/v3/changes/watch\",\n {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${accessToken}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n id: channelId,\n type: \"web_hook\",\n address: webhookUrl,\n expiration: expiration,\n payload: true,\n }),\n },\n );\n\n if (!res.ok) {\n const err = await res.text();\n console.error(\"[google-docs] Failed to register watch:\", err);\n return false;\n }\n\n const data = (await res.json()) as {\n id: string;\n resourceId: string;\n expiration: string;\n };\n\n // Save channel info for renewal and stopping\n await saveIntegrationConfig(\n PLATFORM,\n {\n channelId: data.id,\n resourceId: data.resourceId,\n expiration: data.expiration,\n webhookUrl,\n },\n \"watch-channel\",\n );\n\n console.log(\n `[google-docs] Watch registered (channel: ${data.id}, expires: ${new Date(parseInt(data.expiration)).toISOString()})`,\n );\n\n // Schedule renewal before expiration\n scheduleWatchRenewal(webhookUrl);\n\n return true;\n } catch (err) {\n console.error(\"[google-docs] Watch registration error:\", err);\n return false;\n }\n}\n\n/**\n * Stop an existing watch channel.\n */\nasync function stopWatch(): Promise<void> {\n const config = await getIntegrationConfig(PLATFORM, \"watch-channel\");\n if (!config?.configData?.channelId) return;\n\n const accessToken = await getServiceAccountAccessToken();\n if (!accessToken) return;\n\n try {\n await fetch(\"https://www.googleapis.com/drive/v3/channels/stop\", {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${accessToken}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n id: config.configData.channelId,\n resourceId: config.configData.resourceId,\n }),\n });\n } catch {\n // Best effort — channel may have expired already\n }\n\n await saveIntegrationConfig(PLATFORM, {}, \"watch-channel\");\n}\n\n/**\n * Schedule automatic watch renewal before the channel expires.\n */\nfunction scheduleWatchRenewal(webhookUrl: string): void {\n if (watchRenewalTimer) clearTimeout(watchRenewalTimer);\n\n // Renew 1 hour before expiration\n const renewIn = WATCH_CHANNEL_TTL_MS - 60 * 60 * 1000;\n\n watchRenewalTimer = setTimeout(async () => {\n console.log(\"[google-docs] Renewing watch channel...\");\n await stopWatch();\n await registerWatch(webhookUrl);\n }, renewIn);\n}\n\n// ─── Page Token Management ──────────────────────────────────────────────────\n\nasync function getPageToken(): Promise<string | null> {\n const config = await getIntegrationConfig(PLATFORM, \"page-token\");\n return (config?.configData?.pageToken as string) ?? null;\n}\n\nasync function setPageToken(token: string): Promise<void> {\n await saveIntegrationConfig(PLATFORM, { pageToken: token }, \"page-token\");\n}\n\n// ─── Comment Detection ──────────────────────────────────────────────────────\n\nfunction isAgentMention(commentText: string, triggerKeyword: string): boolean {\n return commentText.toLowerCase().includes(triggerKeyword.toLowerCase());\n}\n\nfunction commentKey(fileId: string, commentId: string): string {\n return `${fileId}:${commentId}`;\n}\n\n/**\n * Check a single document for new agent-directed comments.\n */\nasync function checkDocumentComments(\n fileId: string,\n accessToken: string,\n options: GoogleDocsPollerOptions,\n): Promise<void> {\n const triggerKeyword = options.triggerKeyword ?? DEFAULT_TRIGGER;\n const serviceEmail = getServiceAccountEmail();\n\n const lastChecked = lastCheckedTimes.get(fileId);\n const comments = await listDocComments(fileId, accessToken, lastChecked);\n const now = new Date().toISOString();\n\n for (const comment of comments) {\n if (comment.resolved) continue;\n\n const key = commentKey(fileId, comment.id);\n\n // Skip comments authored by the service account\n if (\n serviceEmail &&\n comment.author.emailAddress?.toLowerCase() === serviceEmail.toLowerCase()\n ) {\n continue;\n }\n\n const existingMapping = await getThreadMapping(PLATFORM, key);\n\n if (existingMapping) {\n // Durable per-reply dedup: the in-memory `processedComments` Set does not\n // survive serverless cold starts (see pending-tasks-store H3 note), which\n // would let already-answered replies be reprocessed and double-posted.\n // Persist processed reply ids in the existing SQL thread mapping instead.\n const persistedReplyIds =\n existingMapping.platformContext.processedReplyIds;\n const processedReplyIds = new Set<string>(\n Array.isArray(persistedReplyIds) ? (persistedReplyIds as string[]) : [],\n );\n\n // Check for new follow-up replies from users\n const newUserReplies = (comment.replies ?? []).filter((r) => {\n if (\n serviceEmail &&\n r.author.emailAddress?.toLowerCase() === serviceEmail.toLowerCase()\n ) {\n return false;\n }\n const replyKey = `${key}:reply:${r.id}`;\n if (processedReplyIds.has(r.id) || processedComments.has(replyKey))\n return false;\n if (!isAgentMention(r.content, triggerKeyword)) return false;\n return true;\n });\n\n for (const reply of newUserReplies) {\n const replyKey = `${key}:reply:${reply.id}`;\n processedComments.add(replyKey);\n processedReplyIds.add(reply.id);\n // Persist immediately so a crash/cold-start between replies cannot\n // re-answer this reply on the next invocation.\n await saveThreadMapping(\n PLATFORM,\n key,\n existingMapping.internalThreadId,\n {\n ...existingMapping.platformContext,\n processedReplyIds: Array.from(processedReplyIds),\n },\n );\n\n const text = reply.content\n .replace(\n new RegExp(\n triggerKeyword.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"),\n \"gi\",\n ),\n \"\",\n )\n .trim();\n\n await processComment(\n fileId,\n comment.id,\n text,\n reply.author.displayName,\n options,\n existingMapping.internalThreadId,\n );\n }\n continue;\n }\n\n // New comment — check if it mentions the agent\n if (!isAgentMention(comment.content, triggerKeyword)) continue;\n\n processedComments.add(key);\n\n let text = comment.content;\n if (comment.quotedFileContent?.value) {\n text = `[Highlighted text: \"${comment.quotedFileContent.value}\"]\\n\\n${text}`;\n }\n\n text = text\n .replace(\n new RegExp(triggerKeyword.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"), \"gi\"),\n \"\",\n )\n .trim();\n\n await processComment(\n fileId,\n comment.id,\n text,\n comment.author.displayName,\n options,\n );\n }\n\n lastCheckedTimes.set(fileId, now);\n}\n\n// ─── Process Changes ────────────────────────────────────────────────────────\n\n/**\n * Process pending Drive changes — called by both push notifications and polling.\n * Fetches changes since the last page token, finds Google Docs that changed,\n * and checks their comments for agent mentions.\n */\nexport async function processChanges(\n options: GoogleDocsPollerOptions,\n): Promise<void> {\n const accessToken = await getServiceAccountAccessToken();\n if (!accessToken) return;\n\n let pageToken = await getPageToken();\n if (!pageToken) {\n pageToken = await getStartPageToken(accessToken);\n await setPageToken(pageToken);\n return; // First run — just save the cursor\n }\n\n const { changes, nextPageToken } = await listChanges(pageToken, accessToken);\n await setPageToken(nextPageToken);\n\n if (changes.length === 0) return;\n\n // Deduplicate and filter to Google Docs\n const docFileIds = new Set<string>();\n for (const change of changes) {\n if (change.removed) continue;\n if (\n change.file?.mimeType === \"application/vnd.google-apps.document\" ||\n !change.file?.mimeType\n ) {\n docFileIds.add(change.fileId);\n }\n }\n\n for (const fileId of docFileIds) {\n try {\n await checkDocumentComments(fileId, accessToken, options);\n } catch (err) {\n console.error(`[google-docs] Error checking comments on ${fileId}:`, err);\n }\n }\n}\n\n/**\n * Handle a push notification from Google Drive changes.watch.\n * Called from the integration webhook route.\n */\nexport async function handlePushNotification(): Promise<void> {\n if (!activeOptions) {\n console.warn(\n \"[google-docs] Push notification received but poller not configured\",\n );\n return;\n }\n\n try {\n await processChanges(activeOptions);\n } catch (err) {\n console.error(\"[google-docs] Error processing push notification:\", err);\n }\n}\n\n// ─── Agent Processing ───────────────────────────────────────────────────────\n\nasync function processComment(\n fileId: string,\n commentId: string,\n text: string,\n senderName: string,\n options: GoogleDocsPollerOptions,\n existingThreadId?: string,\n): Promise<void> {\n const adapter = googleDocsAdapter();\n const key = commentKey(fileId, commentId);\n\n const incoming: IncomingMessage = {\n platform: PLATFORM,\n externalThreadId: key,\n text,\n senderName,\n platformContext: { fileId, commentId },\n timestamp: Date.now(),\n };\n\n let threadId = existingThreadId;\n if (!threadId) {\n const thread = await createThread(options.ownerEmail, {\n title: `Google Doc: ${senderName}`,\n });\n await saveThreadMapping(PLATFORM, key, thread.id, { fileId, commentId });\n threadId = thread.id;\n }\n\n const thread = await getThread(threadId);\n const existingMessages: EngineMessage[] = [];\n if (thread?.threadData) {\n try {\n const data = JSON.parse(thread.threadData);\n if (Array.isArray(data.messages)) {\n for (const msg of data.messages) {\n const m = msg.message ?? msg;\n const textContent =\n typeof m.content === \"string\"\n ? m.content\n : Array.isArray(m.content)\n ? m.content\n .filter((c: any) => c.type === \"text\")\n .map((c: any) => c.text)\n .join(\"\\n\")\n : \"\";\n if (m.role === \"user\") {\n existingMessages.push({\n role: \"user\",\n content: [{ type: \"text\", text: textContent }],\n });\n } else if (m.role === \"assistant\") {\n existingMessages.push({\n role: \"assistant\",\n content: [{ type: \"text\", text: textContent }],\n });\n }\n }\n }\n } catch {}\n }\n\n const messages: EngineMessage[] = [\n ...existingMessages,\n { role: \"user\", content: [{ type: \"text\", text }] },\n ];\n\n const engine = createAnthropicEngine({ apiKey: options.apiKey });\n const tools = actionsToEngineTools(options.actions);\n const runId = `gdocs-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;\n const capturedThreadId = threadId;\n const orgId = (await resolveOrgIdForEmail(options.ownerEmail)) ?? undefined;\n\n startRun(\n runId,\n capturedThreadId,\n async (send, signal) => {\n await runWithRequestContext(\n { userEmail: options.ownerEmail, orgId, isIntegrationCaller: true },\n () =>\n runAgentLoop({\n engine,\n model: options.model,\n systemPrompt: options.systemPrompt,\n tools,\n messages,\n actions: options.actions,\n send,\n signal,\n }),\n );\n },\n async (completedRun: ActiveRun) => {\n try {\n let responseText = \"\";\n for (const runEvent of completedRun.events) {\n if (runEvent.event.type === \"text\") {\n responseText += runEvent.event.text;\n }\n }\n if (!responseText.trim()) responseText = \"(No response)\";\n\n const outgoing = adapter.formatAgentResponse(responseText);\n await adapter.sendResponse(outgoing, incoming);\n await persistThreadData(capturedThreadId, text, completedRun, thread);\n } catch (err) {\n console.error(\"[google-docs] Error sending response:\", err);\n }\n },\n );\n}\n\nasync function persistThreadData(\n threadId: string,\n userText: string,\n completedRun: ActiveRun,\n thread: any,\n): Promise<void> {\n try {\n let repo: any;\n try {\n repo = JSON.parse(thread?.threadData || \"{}\");\n } catch {\n repo = {};\n }\n if (!Array.isArray(repo.messages)) repo.messages = [];\n\n repo.messages.push({\n id: `msg-${Date.now()}-user`,\n role: \"user\",\n content: [{ type: \"text\", text: userText }],\n createdAt: new Date().toISOString(),\n });\n\n const assistantMsg = buildAssistantMessage(\n completedRun.events ?? [],\n completedRun.runId,\n );\n if (assistantMsg) repo.messages.push(assistantMsg);\n\n const meta = extractThreadMeta(repo);\n await updateThreadData(\n threadId,\n JSON.stringify(repo),\n meta.title || thread?.title || \"Google Doc Comment\",\n meta.preview || thread?.preview || \"\",\n repo.messages.length,\n );\n } catch {\n // Best-effort\n }\n}\n\n// ─── Poller (Hybrid: Push Primary, Poll Fallback) ───────────────────────────\n\n/**\n * Start the Google Docs integration.\n *\n * Hybrid approach:\n * 1. Attempts to register a Google Drive changes.watch webhook for\n * near-instant push notifications (~seconds latency)\n * 2. Falls back to polling if the watch registration fails\n * (e.g. domain not verified, local dev)\n * 3. Even in push mode, polls at a slow interval (5min) as a safety net\n * in case a push notification is missed\n */\nexport async function startGoogleDocsPoller(\n options: GoogleDocsPollerOptions,\n): Promise<void> {\n if (pollerInterval) {\n console.warn(\"[google-docs] Already running\");\n return;\n }\n\n activeOptions = options;\n\n // Check if integration is enabled before trying to register watch\n const config = await getIntegrationConfig(PLATFORM);\n if (!config?.configData?.enabled) {\n // Still start the poll loop so it picks up when enabled later\n startPollLoop(options, options.intervalMs ?? 30_000);\n return;\n }\n\n // Try to register push notifications\n const webhookUrl = options.webhookUrl;\n let pushMode = false;\n\n if (webhookUrl) {\n pushMode = await registerWatch(webhookUrl);\n if (pushMode) {\n console.log(\"[google-docs] Push mode active — using Drive webhooks\");\n // In push mode, still poll slowly as a safety net (every 5 min)\n startPollLoop(options, 5 * 60 * 1000);\n }\n }\n\n if (!pushMode) {\n console.log(\n \"[google-docs] Polling mode — push registration failed or no webhook URL\",\n );\n startPollLoop(options, options.intervalMs ?? 30_000);\n }\n}\n\nfunction startPollLoop(\n options: GoogleDocsPollerOptions,\n intervalMs: number,\n): void {\n async function poll() {\n try {\n const config = await getIntegrationConfig(PLATFORM);\n if (!config?.configData?.enabled) return;\n await processChanges(options);\n } catch (err) {\n // Unwrap ErrorEvent (Neon WS driver emits these on network failure) so logs show the real cause\n const detail =\n err instanceof Error\n ? err\n : ((err as any)?.error ?? (err as any)?.message ?? err);\n console.error(\"[google-docs] Poller error:\", detail);\n }\n }\n\n setTimeout(poll, 5000);\n pollerInterval = setInterval(poll, intervalMs);\n\n const email = getServiceAccountEmail();\n if (process.env.DEBUG) {\n console.log(\n `[google-docs] Poll loop started (interval: ${intervalMs / 1000}s, service account: ${email ?? \"not configured\"})`,\n );\n }\n}\n\n/**\n * Stop the Google Docs integration.\n */\nexport async function stopGoogleDocsPoller(): Promise<void> {\n if (pollerInterval) {\n clearInterval(pollerInterval);\n pollerInterval = null;\n }\n if (watchRenewalTimer) {\n clearTimeout(watchRenewalTimer);\n watchRenewalTimer = null;\n }\n await stopWatch();\n activeOptions = null;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"google-docs-poller.js","sourceRoot":"","sources":["../../src/integrations/google-docs-poller.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,qBAAqB,EAAE,MAAM,0BAA0B,CAAC;AAEjE,OAAO,EACL,YAAY,EACZ,oBAAoB,EACpB,wBAAwB,GAEzB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAkB,MAAM,yBAAyB,CAAC;AACnE,OAAO,EACL,qBAAqB,EACrB,iBAAiB,GAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EACL,YAAY,EACZ,SAAS,EACT,gBAAgB,GACjB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AACrE,OAAO,EACL,4BAA4B,EAC5B,sBAAsB,EACtB,iBAAiB,EACjB,iBAAiB,EACjB,WAAW,EACX,eAAe,GAChB,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAChF,OAAO,EAA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EAAE,IAAI,CAAC,CAAC;IACvB,cAAc,GAAG,WAAW,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;IAE/C,MAAM,KAAK,GAAG,sBAAsB,EAAE,CAAC;IACvC,IAAI,OAAO,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;QACtB,OAAO,CAAC,GAAG,CACT,8CAA8C,UAAU,GAAG,IAAI,uBAAuB,KAAK,IAAI,gBAAgB,GAAG,CACnH,CAAC;IACJ,CAAC;AACH,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB;IACxC,IAAI,cAAc,EAAE,CAAC;QACnB,aAAa,CAAC,cAAc,CAAC,CAAC;QAC9B,cAAc,GAAG,IAAI,CAAC;IACxB,CAAC;IACD,IAAI,iBAAiB,EAAE,CAAC;QACtB,YAAY,CAAC,iBAAiB,CAAC,CAAC;QAChC,iBAAiB,GAAG,IAAI,CAAC;IAC3B,CAAC;IACD,MAAM,SAAS,EAAE,CAAC;IAClB,aAAa,GAAG,IAAI,CAAC;AACvB,CAAC","sourcesContent":["import { createAnthropicEngine } from \"../agent/engine/index.js\";\nimport type { EngineMessage } from \"../agent/engine/types.js\";\nimport {\n runAgentLoop,\n actionsToEngineTools,\n filterInitialEngineTools,\n type ActionEntry,\n} from \"../agent/production-agent.js\";\nimport { startRun, type ActiveRun } from \"../agent/run-manager.js\";\nimport {\n buildAssistantMessage,\n extractThreadMeta,\n} from \"../agent/thread-data-builder.js\";\nimport { attachToolSearch } from \"../agent/tool-search.js\";\nimport {\n createThread,\n getThread,\n updateThreadData,\n} from \"../chat-threads/store.js\";\nimport { resolveOrgIdForEmail } from \"../org/context.js\";\nimport { runWithRequestContext } from \"../server/request-context.js\";\nimport {\n getServiceAccountAccessToken,\n getServiceAccountEmail,\n getStartPageToken,\n googleDocsAdapter,\n listChanges,\n listDocComments,\n} from \"./adapters/google-docs.js\";\nimport { getIntegrationConfig, saveIntegrationConfig } from \"./config-store.js\";\nimport { getThreadMapping, saveThreadMapping } from \"./thread-mapping-store.js\";\nimport type { IncomingMessage } from \"./types.js\";\n\nconst PLATFORM = \"google-docs\";\nconst DEFAULT_TRIGGER = \"@agent\";\n\n/** Track processed comment IDs to avoid reprocessing */\nconst processedComments = new Set<string>();\n/** Track last-checked time per document for comment filtering */\nconst lastCheckedTimes = new Map<string, string>();\n\nexport interface GoogleDocsPollerOptions {\n /** Polling interval in milliseconds (fallback mode). Default: 30000 (30s) */\n intervalMs?: number;\n /** Trigger keyword in comments. Default: \"@agent\" (case-insensitive) */\n triggerKeyword?: string;\n /** System prompt for the agent */\n systemPrompt: string;\n /** Action entries for the agent */\n actions: Record<string, ActionEntry>;\n /**\n * Tool names to expose on the FIRST engine request. See\n * `WebhookHandlerOptions.initialToolNames` (`webhook-handler.ts`) — same\n * semantics, shared `actions` source from `createIntegrationsPlugin`. Omit\n * to keep the full `actions` set visible up front (current behavior).\n */\n initialToolNames?: string[];\n /** Model to use */\n model: string;\n /** Anthropic API key */\n apiKey: string;\n /** Thread owner email */\n ownerEmail: string;\n /** Webhook URL for push mode (set by plugin from WEBHOOK_BASE_URL) */\n webhookUrl?: string;\n}\n\nlet pollerInterval: ReturnType<typeof setInterval> | null = null;\nlet activeOptions: GoogleDocsPollerOptions | null = null;\n\n// ─── Watch Channel Management ───────────────────────────────────────────────\n\n/** How long a watch channel lasts (Google max is ~24h, we use 23h to renew early) */\nconst WATCH_CHANNEL_TTL_MS = 23 * 60 * 60 * 1000;\nlet watchRenewalTimer: ReturnType<typeof setTimeout> | null = null;\n\n/**\n * Register a Google Drive changes.watch channel so Google pushes\n * notifications to our webhook instead of us polling.\n *\n * Returns true if the watch was registered successfully.\n */\nexport async function registerWatch(webhookUrl: string): Promise<boolean> {\n const accessToken = await getServiceAccountAccessToken();\n if (!accessToken) return false;\n\n // Get the current page token as the starting point\n let pageToken = await getPageToken();\n if (!pageToken) {\n pageToken = await getStartPageToken(accessToken);\n await setPageToken(pageToken);\n }\n\n const channelId = `gdocs-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;\n const expiration = Date.now() + WATCH_CHANNEL_TTL_MS;\n\n try {\n const res = await fetch(\n \"https://www.googleapis.com/drive/v3/changes/watch\",\n {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${accessToken}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n id: channelId,\n type: \"web_hook\",\n address: webhookUrl,\n expiration: expiration,\n payload: true,\n }),\n },\n );\n\n if (!res.ok) {\n const err = await res.text();\n console.error(\"[google-docs] Failed to register watch:\", err);\n return false;\n }\n\n const data = (await res.json()) as {\n id: string;\n resourceId: string;\n expiration: string;\n };\n\n // Save channel info for renewal and stopping\n await saveIntegrationConfig(\n PLATFORM,\n {\n channelId: data.id,\n resourceId: data.resourceId,\n expiration: data.expiration,\n webhookUrl,\n },\n \"watch-channel\",\n );\n\n console.log(\n `[google-docs] Watch registered (channel: ${data.id}, expires: ${new Date(parseInt(data.expiration)).toISOString()})`,\n );\n\n // Schedule renewal before expiration\n scheduleWatchRenewal(webhookUrl);\n\n return true;\n } catch (err) {\n console.error(\"[google-docs] Watch registration error:\", err);\n return false;\n }\n}\n\n/**\n * Stop an existing watch channel.\n */\nasync function stopWatch(): Promise<void> {\n const config = await getIntegrationConfig(PLATFORM, \"watch-channel\");\n if (!config?.configData?.channelId) return;\n\n const accessToken = await getServiceAccountAccessToken();\n if (!accessToken) return;\n\n try {\n await fetch(\"https://www.googleapis.com/drive/v3/channels/stop\", {\n method: \"POST\",\n headers: {\n Authorization: `Bearer ${accessToken}`,\n \"Content-Type\": \"application/json\",\n },\n body: JSON.stringify({\n id: config.configData.channelId,\n resourceId: config.configData.resourceId,\n }),\n });\n } catch {\n // Best effort — channel may have expired already\n }\n\n await saveIntegrationConfig(PLATFORM, {}, \"watch-channel\");\n}\n\n/**\n * Schedule automatic watch renewal before the channel expires.\n */\nfunction scheduleWatchRenewal(webhookUrl: string): void {\n if (watchRenewalTimer) clearTimeout(watchRenewalTimer);\n\n // Renew 1 hour before expiration\n const renewIn = WATCH_CHANNEL_TTL_MS - 60 * 60 * 1000;\n\n watchRenewalTimer = setTimeout(async () => {\n console.log(\"[google-docs] Renewing watch channel...\");\n await stopWatch();\n await registerWatch(webhookUrl);\n }, renewIn);\n}\n\n// ─── Page Token Management ──────────────────────────────────────────────────\n\nasync function getPageToken(): Promise<string | null> {\n const config = await getIntegrationConfig(PLATFORM, \"page-token\");\n return (config?.configData?.pageToken as string) ?? null;\n}\n\nasync function setPageToken(token: string): Promise<void> {\n await saveIntegrationConfig(PLATFORM, { pageToken: token }, \"page-token\");\n}\n\n// ─── Comment Detection ──────────────────────────────────────────────────────\n\nfunction isAgentMention(commentText: string, triggerKeyword: string): boolean {\n return commentText.toLowerCase().includes(triggerKeyword.toLowerCase());\n}\n\nfunction commentKey(fileId: string, commentId: string): string {\n return `${fileId}:${commentId}`;\n}\n\n/**\n * Check a single document for new agent-directed comments.\n */\nasync function checkDocumentComments(\n fileId: string,\n accessToken: string,\n options: GoogleDocsPollerOptions,\n): Promise<void> {\n const triggerKeyword = options.triggerKeyword ?? DEFAULT_TRIGGER;\n const serviceEmail = getServiceAccountEmail();\n\n const lastChecked = lastCheckedTimes.get(fileId);\n const comments = await listDocComments(fileId, accessToken, lastChecked);\n const now = new Date().toISOString();\n\n for (const comment of comments) {\n if (comment.resolved) continue;\n\n const key = commentKey(fileId, comment.id);\n\n // Skip comments authored by the service account\n if (\n serviceEmail &&\n comment.author.emailAddress?.toLowerCase() === serviceEmail.toLowerCase()\n ) {\n continue;\n }\n\n const existingMapping = await getThreadMapping(PLATFORM, key);\n\n if (existingMapping) {\n // Durable per-reply dedup: the in-memory `processedComments` Set does not\n // survive serverless cold starts (see pending-tasks-store H3 note), which\n // would let already-answered replies be reprocessed and double-posted.\n // Persist processed reply ids in the existing SQL thread mapping instead.\n const persistedReplyIds =\n existingMapping.platformContext.processedReplyIds;\n const processedReplyIds = new Set<string>(\n Array.isArray(persistedReplyIds) ? (persistedReplyIds as string[]) : [],\n );\n\n // Check for new follow-up replies from users\n const newUserReplies = (comment.replies ?? []).filter((r) => {\n if (\n serviceEmail &&\n r.author.emailAddress?.toLowerCase() === serviceEmail.toLowerCase()\n ) {\n return false;\n }\n const replyKey = `${key}:reply:${r.id}`;\n if (processedReplyIds.has(r.id) || processedComments.has(replyKey))\n return false;\n if (!isAgentMention(r.content, triggerKeyword)) return false;\n return true;\n });\n\n for (const reply of newUserReplies) {\n const replyKey = `${key}:reply:${reply.id}`;\n processedComments.add(replyKey);\n processedReplyIds.add(reply.id);\n // Persist immediately so a crash/cold-start between replies cannot\n // re-answer this reply on the next invocation.\n await saveThreadMapping(\n PLATFORM,\n key,\n existingMapping.internalThreadId,\n {\n ...existingMapping.platformContext,\n processedReplyIds: Array.from(processedReplyIds),\n },\n );\n\n const text = reply.content\n .replace(\n new RegExp(\n triggerKeyword.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"),\n \"gi\",\n ),\n \"\",\n )\n .trim();\n\n await processComment(\n fileId,\n comment.id,\n text,\n reply.author.displayName,\n options,\n existingMapping.internalThreadId,\n );\n }\n continue;\n }\n\n // New comment — check if it mentions the agent\n if (!isAgentMention(comment.content, triggerKeyword)) continue;\n\n processedComments.add(key);\n\n let text = comment.content;\n if (comment.quotedFileContent?.value) {\n text = `[Highlighted text: \"${comment.quotedFileContent.value}\"]\\n\\n${text}`;\n }\n\n text = text\n .replace(\n new RegExp(triggerKeyword.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\"), \"gi\"),\n \"\",\n )\n .trim();\n\n await processComment(\n fileId,\n comment.id,\n text,\n comment.author.displayName,\n options,\n );\n }\n\n lastCheckedTimes.set(fileId, now);\n}\n\n// ─── Process Changes ────────────────────────────────────────────────────────\n\n/**\n * Process pending Drive changes — called by both push notifications and polling.\n * Fetches changes since the last page token, finds Google Docs that changed,\n * and checks their comments for agent mentions.\n */\nexport async function processChanges(\n options: GoogleDocsPollerOptions,\n): Promise<void> {\n const accessToken = await getServiceAccountAccessToken();\n if (!accessToken) return;\n\n let pageToken = await getPageToken();\n if (!pageToken) {\n pageToken = await getStartPageToken(accessToken);\n await setPageToken(pageToken);\n return; // First run — just save the cursor\n }\n\n const { changes, nextPageToken } = await listChanges(pageToken, accessToken);\n await setPageToken(nextPageToken);\n\n if (changes.length === 0) return;\n\n // Deduplicate and filter to Google Docs\n const docFileIds = new Set<string>();\n for (const change of changes) {\n if (change.removed) continue;\n if (\n change.file?.mimeType === \"application/vnd.google-apps.document\" ||\n !change.file?.mimeType\n ) {\n docFileIds.add(change.fileId);\n }\n }\n\n for (const fileId of docFileIds) {\n try {\n await checkDocumentComments(fileId, accessToken, options);\n } catch (err) {\n console.error(`[google-docs] Error checking comments on ${fileId}:`, err);\n }\n }\n}\n\n/**\n * Handle a push notification from Google Drive changes.watch.\n * Called from the integration webhook route.\n */\nexport async function handlePushNotification(): Promise<void> {\n if (!activeOptions) {\n console.warn(\n \"[google-docs] Push notification received but poller not configured\",\n );\n return;\n }\n\n try {\n await processChanges(activeOptions);\n } catch (err) {\n console.error(\"[google-docs] Error processing push notification:\", err);\n }\n}\n\n// ─── Agent Processing ───────────────────────────────────────────────────────\n\nasync function processComment(\n fileId: string,\n commentId: string,\n text: string,\n senderName: string,\n options: GoogleDocsPollerOptions,\n existingThreadId?: string,\n): Promise<void> {\n const adapter = googleDocsAdapter();\n const key = commentKey(fileId, commentId);\n\n const incoming: IncomingMessage = {\n platform: PLATFORM,\n externalThreadId: key,\n text,\n senderName,\n platformContext: { fileId, commentId },\n timestamp: Date.now(),\n };\n\n let threadId = existingThreadId;\n if (!threadId) {\n const thread = await createThread(options.ownerEmail, {\n title: `Google Doc: ${senderName}`,\n });\n await saveThreadMapping(PLATFORM, key, thread.id, { fileId, commentId });\n threadId = thread.id;\n }\n\n const thread = await getThread(threadId);\n const existingMessages: EngineMessage[] = [];\n if (thread?.threadData) {\n try {\n const data = JSON.parse(thread.threadData);\n if (Array.isArray(data.messages)) {\n for (const msg of data.messages) {\n const m = msg.message ?? msg;\n const textContent =\n typeof m.content === \"string\"\n ? m.content\n : Array.isArray(m.content)\n ? m.content\n .filter((c: any) => c.type === \"text\")\n .map((c: any) => c.text)\n .join(\"\\n\")\n : \"\";\n if (m.role === \"user\") {\n existingMessages.push({\n role: \"user\",\n content: [{ type: \"text\", text: textContent }],\n });\n } else if (m.role === \"assistant\") {\n existingMessages.push({\n role: \"assistant\",\n content: [{ type: \"text\", text: textContent }],\n });\n }\n }\n }\n } catch {}\n }\n\n const messages: EngineMessage[] = [\n ...existingMessages,\n { role: \"user\", content: [{ type: \"text\", text }] },\n ];\n\n const engine = createAnthropicEngine({ apiKey: options.apiKey });\n // Attach tool-search on a shallow copy so framework additions merged in by\n // `createIntegrationsPlugin` (integration memory, `call-agent`) can be\n // deferred behind it without mutating the plugin's long-lived registry.\n // `runAgentLoop`'s `expandActiveTools` re-expands from `availableTools`\n // after a tool-search call, so anything filtered out of the initial\n // `tools` list stays reachable.\n const runnableActions = attachToolSearch({ ...options.actions });\n const availableTools = actionsToEngineTools(runnableActions);\n const tools = filterInitialEngineTools(\n availableTools,\n options.initialToolNames,\n );\n const runId = `gdocs-${Date.now()}-${Math.random().toString(36).slice(2, 8)}`;\n const capturedThreadId = threadId;\n const orgId = (await resolveOrgIdForEmail(options.ownerEmail)) ?? undefined;\n\n startRun(\n runId,\n capturedThreadId,\n async (send, signal) => {\n await runWithRequestContext(\n { userEmail: options.ownerEmail, orgId, isIntegrationCaller: true },\n () =>\n runAgentLoop({\n engine,\n model: options.model,\n systemPrompt: options.systemPrompt,\n tools,\n availableTools,\n messages,\n actions: runnableActions,\n send,\n signal,\n }),\n );\n },\n async (completedRun: ActiveRun) => {\n try {\n let responseText = \"\";\n for (const runEvent of completedRun.events) {\n if (runEvent.event.type === \"text\") {\n responseText += runEvent.event.text;\n }\n }\n if (!responseText.trim()) responseText = \"(No response)\";\n\n const outgoing = adapter.formatAgentResponse(responseText);\n await adapter.sendResponse(outgoing, incoming);\n await persistThreadData(capturedThreadId, text, completedRun, thread);\n } catch (err) {\n console.error(\"[google-docs] Error sending response:\", err);\n }\n },\n );\n}\n\nasync function persistThreadData(\n threadId: string,\n userText: string,\n completedRun: ActiveRun,\n thread: any,\n): Promise<void> {\n try {\n let repo: any;\n try {\n repo = JSON.parse(thread?.threadData || \"{}\");\n } catch {\n repo = {};\n }\n if (!Array.isArray(repo.messages)) repo.messages = [];\n\n repo.messages.push({\n id: `msg-${Date.now()}-user`,\n role: \"user\",\n content: [{ type: \"text\", text: userText }],\n createdAt: new Date().toISOString(),\n });\n\n const assistantMsg = buildAssistantMessage(\n completedRun.events ?? [],\n completedRun.runId,\n );\n if (assistantMsg) repo.messages.push(assistantMsg);\n\n const meta = extractThreadMeta(repo);\n await updateThreadData(\n threadId,\n JSON.stringify(repo),\n meta.title || thread?.title || \"Google Doc Comment\",\n meta.preview || thread?.preview || \"\",\n repo.messages.length,\n );\n } catch {\n // Best-effort\n }\n}\n\n// ─── Poller (Hybrid: Push Primary, Poll Fallback) ───────────────────────────\n\n/**\n * Start the Google Docs integration.\n *\n * Hybrid approach:\n * 1. Attempts to register a Google Drive changes.watch webhook for\n * near-instant push notifications (~seconds latency)\n * 2. Falls back to polling if the watch registration fails\n * (e.g. domain not verified, local dev)\n * 3. Even in push mode, polls at a slow interval (5min) as a safety net\n * in case a push notification is missed\n */\nexport async function startGoogleDocsPoller(\n options: GoogleDocsPollerOptions,\n): Promise<void> {\n if (pollerInterval) {\n console.warn(\"[google-docs] Already running\");\n return;\n }\n\n activeOptions = options;\n\n // Check if integration is enabled before trying to register watch\n const config = await getIntegrationConfig(PLATFORM);\n if (!config?.configData?.enabled) {\n // Still start the poll loop so it picks up when enabled later\n startPollLoop(options, options.intervalMs ?? 30_000);\n return;\n }\n\n // Try to register push notifications\n const webhookUrl = options.webhookUrl;\n let pushMode = false;\n\n if (webhookUrl) {\n pushMode = await registerWatch(webhookUrl);\n if (pushMode) {\n console.log(\"[google-docs] Push mode active — using Drive webhooks\");\n // In push mode, still poll slowly as a safety net (every 5 min)\n startPollLoop(options, 5 * 60 * 1000);\n }\n }\n\n if (!pushMode) {\n console.log(\n \"[google-docs] Polling mode — push registration failed or no webhook URL\",\n );\n startPollLoop(options, options.intervalMs ?? 30_000);\n }\n}\n\nfunction startPollLoop(\n options: GoogleDocsPollerOptions,\n intervalMs: number,\n): void {\n async function poll() {\n try {\n const config = await getIntegrationConfig(PLATFORM);\n if (!config?.configData?.enabled) return;\n await processChanges(options);\n } catch (err) {\n // Unwrap ErrorEvent (Neon WS driver emits these on network failure) so logs show the real cause\n const detail =\n err instanceof Error\n ? err\n : ((err as any)?.error ?? (err as any)?.message ?? err);\n console.error(\"[google-docs] Poller error:\", detail);\n }\n }\n\n setTimeout(poll, 5000);\n pollerInterval = setInterval(poll, intervalMs);\n\n const email = getServiceAccountEmail();\n if (process.env.DEBUG) {\n console.log(\n `[google-docs] Poll loop started (interval: ${intervalMs / 1000}s, service account: ${email ?? \"not configured\"})`,\n );\n }\n}\n\n/**\n * Stop the Google Docs integration.\n */\nexport async function stopGoogleDocsPoller(): Promise<void> {\n if (pollerInterval) {\n clearInterval(pollerInterval);\n pollerInterval = null;\n }\n if (watchRenewalTimer) {\n clearTimeout(watchRenewalTimer);\n watchRenewalTimer = null;\n }\n await stopWatch();\n activeOptions = null;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/integrations/plugin.ts"],"names":[],"mappings":"AAqIA,OAAO,KAAK,EAEV,yBAAyB,EAG1B,MAAM,YAAY,CAAC;AAOpB,KAAK,cAAc,GAAG,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AA4F9D,KAAK,yBAAyB,GAAG;IAC/B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAUF,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,yBAAyB,GAClC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAsFlC;AA+ND;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,CAAC,EAAE,yBAAyB,GAClC,cAAc,
|
|
1
|
+
{"version":3,"file":"plugin.d.ts","sourceRoot":"","sources":["../../src/integrations/plugin.ts"],"names":[],"mappings":"AAqIA,OAAO,KAAK,EAEV,yBAAyB,EAG1B,MAAM,YAAY,CAAC;AAOpB,KAAK,cAAc,GAAG,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AA4F9D,KAAK,yBAAyB,GAAG;IAC/B,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAUF,wBAAsB,oBAAoB,CACxC,QAAQ,EAAE,yBAAyB,GAClC,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAsFlC;AA+ND;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACtC,OAAO,CAAC,EAAE,yBAAyB,GAClC,cAAc,CAq6DhB;AAED;;GAEG;AACH,eAAO,MAAM,yBAAyB,gBAA6B,CAAC"}
|
|
@@ -448,6 +448,13 @@ export function createIntegrationsPlugin(options) {
|
|
|
448
448
|
...localActions,
|
|
449
449
|
...callAgentEntry,
|
|
450
450
|
};
|
|
451
|
+
// Keep the app's own actions visible on the first request to the model;
|
|
452
|
+
// defer the framework additions merged in above (integration memory,
|
|
453
|
+
// call-agent) behind the tool-search entry `handleWebhook` /
|
|
454
|
+
// `startGoogleDocsPoller` attach to `actions`. The run loop's mid-run
|
|
455
|
+
// tool expansion still lets the model discover and call them after a
|
|
456
|
+
// search — see `filterInitialEngineTools` / `expandActiveTools`.
|
|
457
|
+
const initialToolNames = Object.keys(localActions);
|
|
451
458
|
const h3 = getH3App(nitroApp);
|
|
452
459
|
const P = `${FRAMEWORK_ROUTE_PREFIX}/integrations`;
|
|
453
460
|
async function requireSession(event) {
|
|
@@ -1231,6 +1238,7 @@ export function createIntegrationsPlugin(options) {
|
|
|
1231
1238
|
adapter,
|
|
1232
1239
|
systemPrompt: baseSystemPrompt + resources,
|
|
1233
1240
|
actions,
|
|
1241
|
+
initialToolNames,
|
|
1234
1242
|
model,
|
|
1235
1243
|
apiKey: getApiKey(),
|
|
1236
1244
|
engine: options?.engine,
|
|
@@ -1918,6 +1926,7 @@ export function createIntegrationsPlugin(options) {
|
|
|
1918
1926
|
// where providers such as Discord enforce a 3-second deadline.
|
|
1919
1927
|
systemPrompt: baseSystemPrompt,
|
|
1920
1928
|
actions,
|
|
1929
|
+
initialToolNames,
|
|
1921
1930
|
model,
|
|
1922
1931
|
apiKey: getApiKey(),
|
|
1923
1932
|
engine: options?.engine,
|
|
@@ -2019,6 +2028,7 @@ export function createIntegrationsPlugin(options) {
|
|
|
2019
2028
|
void startGoogleDocsPoller({
|
|
2020
2029
|
systemPrompt: baseSystemPrompt,
|
|
2021
2030
|
actions,
|
|
2031
|
+
initialToolNames,
|
|
2022
2032
|
model: model ?? "",
|
|
2023
2033
|
apiKey: getApiKey(),
|
|
2024
2034
|
ownerEmail: "integration@google-docs",
|