@agent-native/core 0.130.2 → 0.131.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +79 -0
- package/corpus/core/docs/content/agent-surfaces.mdx +4 -4
- package/corpus/core/docs/content/automations.mdx +61 -12
- package/corpus/core/docs/content/deployment.mdx +11 -4
- package/corpus/core/docs/content/extensions.mdx +39 -33
- package/corpus/core/docs/content/recurring-jobs.mdx +41 -19
- package/corpus/core/docs/content/template-dispatch-operations.mdx +19 -7
- package/corpus/core/package.json +3 -1
- package/corpus/core/src/a2a/types.ts +6 -0
- package/corpus/core/src/action.ts +68 -0
- package/corpus/core/src/agent/engine/builder-engine.ts +8 -4
- package/corpus/core/src/agent/production-agent.ts +175 -100
- package/corpus/core/src/agent/tool-search.ts +36 -0
- package/corpus/core/src/automations/service.ts +506 -0
- package/corpus/core/src/browser-context/index.ts +392 -0
- package/corpus/core/src/client/AgentPanel.tsx +2 -1
- package/corpus/core/src/client/FeedbackButton.tsx +37 -4
- package/corpus/core/src/client/MultiTabAssistantChat.tsx +21 -0
- package/corpus/core/src/client/agent-chat.ts +31 -3
- package/corpus/core/src/client/agent-page/AgentJobsTab.tsx +438 -310
- package/corpus/core/src/client/agent-page/AgentTabsPage.tsx +4 -4
- package/corpus/core/src/client/agent-page/use-jobs.ts +7 -0
- package/corpus/core/src/client/analytics-session.ts +13 -0
- package/corpus/core/src/client/extensions/ExtensionViewer.tsx +67 -0
- package/corpus/core/src/client/settings/AutomationsSection.tsx +27 -499
- package/corpus/core/src/client/settings/SettingsPanel.tsx +32 -11
- package/corpus/core/src/client/settings/index.ts +2 -0
- package/corpus/core/src/client/use-agent-chat.ts +35 -3
- package/corpus/core/src/client/use-chat-threads.ts +8 -25
- package/corpus/core/src/deploy/build.ts +2 -0
- package/corpus/core/src/deploy/workspace-deploy.ts +2 -0
- package/corpus/core/src/extensions/actions.ts +115 -3
- package/corpus/core/src/extensions/fetch-tool.ts +11 -0
- package/corpus/core/src/extensions/routes.ts +16 -1
- package/corpus/core/src/extensions/web-content.ts +96 -1
- package/corpus/core/src/integrations/computer-supervision.ts +33 -1
- package/corpus/core/src/integrations/index.ts +6 -0
- package/corpus/core/src/integrations/integration-durable-dispatch-config.ts +10 -0
- package/corpus/core/src/integrations/integration-durable-dispatch.ts +4 -0
- package/corpus/core/src/integrations/plugin.ts +94 -41
- package/corpus/core/src/integrations/remote-browser-actions.ts +621 -0
- package/corpus/core/src/jobs/actions/list-recurring-jobs.ts +5 -7
- package/corpus/core/src/jobs/actions/manage-recurring-job.ts +3 -7
- package/corpus/core/src/jobs/background-automation-runner.ts +437 -0
- package/corpus/core/src/jobs/frontmatter.ts +308 -0
- package/corpus/core/src/jobs/scheduler.ts +89 -598
- package/corpus/core/src/jobs/tools.ts +22 -3
- package/corpus/core/src/localization/default-messages.ts +45 -45
- package/corpus/core/src/mcp-client/index.ts +6 -0
- package/corpus/core/src/notifications/actions.ts +5 -0
- package/corpus/core/src/progress/actions.ts +5 -0
- package/corpus/core/src/provider-api/actions/github-repo-files.ts +11 -0
- package/corpus/core/src/provider-api/actions/provider-api.ts +13 -0
- package/corpus/core/src/server/action-discovery.ts +7 -0
- package/corpus/core/src/server/agent-capabilities.ts +43 -8
- package/corpus/core/src/server/agent-chat/action-filters-a2a.ts +63 -1
- package/corpus/core/src/server/agent-chat/browser-team-tools.ts +126 -3
- package/corpus/core/src/server/agent-chat/framework-prompts.ts +7 -11
- package/corpus/core/src/server/agent-chat/plugin-options.ts +3 -3
- package/corpus/core/src/server/agent-chat/script-entries.ts +52 -1
- package/corpus/core/src/server/agent-chat-plugin.ts +25 -5
- package/corpus/core/src/server/attribution.ts +22 -0
- package/corpus/core/src/server/auth.ts +20 -6
- package/corpus/core/src/server/better-auth-instance.ts +10 -2
- package/corpus/core/src/server/core-routes-plugin.ts +10 -1
- package/corpus/core/src/server/csrf.ts +25 -0
- package/corpus/core/src/server/google-oauth.ts +21 -1
- package/corpus/core/src/server/onboarding-html.ts +18 -0
- package/corpus/core/src/server/prompts/framework-core-compact.ts +3 -3
- package/corpus/core/src/server/prompts/framework-core.ts +3 -3
- package/corpus/core/src/server/prompts/shared-rules.ts +3 -3
- package/corpus/core/src/settings/index.ts +1 -0
- package/corpus/core/src/shared/analytics-anonymous-id.ts +35 -0
- package/corpus/core/src/templates/default/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/core/src/templates/default/app/i18n/ar-SA.ts +26 -0
- package/corpus/core/src/templates/default/app/i18n/de-DE.ts +28 -0
- package/corpus/core/src/templates/default/app/i18n/en-US.ts +27 -0
- package/corpus/core/src/templates/default/app/i18n/es-ES.ts +28 -0
- package/corpus/core/src/templates/default/app/i18n/fr-FR.ts +28 -0
- package/corpus/core/src/templates/default/app/i18n/hi-IN.ts +25 -0
- package/corpus/core/src/templates/default/app/i18n/ja-JP.ts +27 -0
- package/corpus/core/src/templates/default/app/i18n/ko-KR.ts +27 -0
- package/corpus/core/src/templates/default/app/i18n/pt-BR.ts +27 -0
- package/corpus/core/src/templates/default/app/i18n/zh-CN.ts +24 -0
- package/corpus/core/src/templates/default/app/i18n/zh-TW.ts +24 -0
- package/corpus/core/src/templates/headless/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/agent-page/SKILL.md +10 -7
- package/corpus/core/src/templates/workspace-core/.agents/skills/automations/SKILL.md +53 -8
- package/corpus/core/src/templates/workspace-core/.agents/skills/browser-sessions/SKILL.md +131 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/extension-points/SKILL.md +13 -4
- package/corpus/core/src/templates/workspace-core/.agents/skills/extensions/SKILL.md +23 -15
- package/corpus/core/src/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +33 -18
- package/corpus/core/src/tracking/providers.ts +1 -0
- package/corpus/core/src/tracking/registry.ts +2 -1
- package/corpus/core/src/tracking/types.ts +1 -0
- package/corpus/core/src/triggers/actions/list-automations.ts +43 -44
- package/corpus/core/src/triggers/actions/manage-automation.ts +17 -48
- package/corpus/core/src/triggers/actions.ts +218 -127
- package/corpus/core/src/triggers/dispatcher.ts +181 -367
- package/corpus/core/src/triggers/routes.ts +84 -27
- package/corpus/core/src/triggers/types.ts +9 -23
- package/corpus/templates/analytics/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/analytics/AGENTS.md +5 -0
- package/corpus/templates/analytics/actions/hubspot-deals.ts +1 -0
- package/corpus/templates/analytics/actions/hubspot-records.ts +1 -0
- package/corpus/templates/analytics/actions/install-dashboard-template.ts +13 -4
- package/corpus/templates/analytics/actions/rename-dashboard.ts +8 -3
- package/corpus/templates/analytics/actions/restore-dashboard-revision.ts +8 -3
- package/corpus/templates/analytics/actions/update-dashboard.ts +22 -5
- package/corpus/templates/analytics/app/components/dashboard/DashboardPanelSkeleton.tsx +7 -1
- package/corpus/templates/analytics/app/components/layout/CommandPalette.tsx +1 -82
- package/corpus/templates/analytics/app/components/layout/NewDashboardDialog.tsx +4 -4
- package/corpus/templates/analytics/app/components/layout/Sidebar.tsx +23 -13
- package/corpus/templates/analytics/app/global.css +21 -0
- package/corpus/templates/analytics/app/i18n-data.ts +165 -101
- package/corpus/templates/analytics/app/lib/custom-block-promotion.ts +62 -0
- package/corpus/templates/analytics/app/pages/adhoc/explorer-dashboard/index.tsx +17 -2
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/PanelEditorDialog.tsx +3 -1
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/SqlChartCard.tsx +77 -12
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/dashboard-save-queue.ts +34 -0
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/index.tsx +42 -26
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/types.ts +15 -0
- package/corpus/templates/analytics/app/pages/analyses/AnalysisDetail.tsx +1 -1
- package/corpus/templates/analytics/changelog/2026-07-29-chat-history-now-closes-smoothly-and-stays-ready-when-you-re.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-29-chat-history-stays-visible-when-you-return-to-the-dashboard.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-29-custom-dashboard-blocks-now-identify-one-off-agent-patches-a.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-29-dashboard-chart-deletions-now-save-in-order-so-removed-rows-.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-29-dashboard-chart-loaders-are-easier-to-see-and-animate-more-s.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-29-plan-mode-can-now-query-connected-analytics-sources-while-ke.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-29-plan-mode-can-use-clips-as-read-only-prompt-context.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-29-signup-entry-pages-now-show-the-first-page-viewed-before-eac.md +6 -0
- package/corpus/templates/analytics/seeds/dashboards/agent-native-templates-first-party.json +26 -1
- package/corpus/templates/analytics/server/lib/agent-chat-plan-mode.ts +0 -33
- package/corpus/templates/analytics/server/lib/analytics-connector-catalog.ts +2 -0
- package/corpus/templates/analytics/server/lib/canonical-first-party-dashboard-repair.ts +13 -3
- package/corpus/templates/analytics/server/lib/dashboard-catalog.ts +9 -1
- package/corpus/templates/analytics/server/lib/first-party-analytics.ts +44 -1
- package/corpus/templates/analytics/server/lib/first-party-metric-catalog.ts +96 -16
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +18 -27
- package/corpus/templates/analytics/server/plugins/core-routes.ts +1 -0
- package/corpus/templates/assets/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/assets/app/components/layout/Sidebar.tsx +4 -8
- package/corpus/templates/assets/changelog/2026-07-29-chat-history-now-closes-smoothly-and-stays-ready-when-you-re.md +6 -0
- package/corpus/templates/assets/changelog/2026-07-29-chat-history-stays-visible-when-you-return-to-the-workspace.md +6 -0
- package/corpus/templates/assets/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
- package/corpus/templates/brain/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/brain/app/components/layout/Sidebar.tsx +3 -7
- package/corpus/templates/brain/app/root.tsx +0 -3
- package/corpus/templates/brain/changelog/2026-07-29-chat-history-now-closes-smoothly-and-stays-ready-when-you-re.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-29-chat-history-stays-visible-when-you-return-to-ask-brain.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-29-extensions-are-no-longer-shown-as-a-default-command-menu-des.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
- package/corpus/templates/calendar/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/calendar/.agents/skills/event-management/SKILL.md +25 -5
- package/corpus/templates/calendar/AGENTS.md +5 -0
- package/corpus/templates/calendar/actions/create-event.ts +43 -13
- package/corpus/templates/calendar/actions/event-action-helpers.ts +131 -1
- package/corpus/templates/calendar/actions/get-event.ts +1 -0
- package/corpus/templates/calendar/actions/manage-event-draft.ts +65 -2
- package/corpus/templates/calendar/app/components/calendar/CreateEventDialog.tsx +438 -258
- package/corpus/templates/calendar/app/components/calendar/DayView.tsx +19 -3
- package/corpus/templates/calendar/app/components/calendar/EventDetailPanel.tsx +7 -3
- package/corpus/templates/calendar/app/components/calendar/EventDetailPopover.tsx +14 -19
- package/corpus/templates/calendar/app/components/calendar/MonthView.tsx +24 -0
- package/corpus/templates/calendar/app/components/calendar/WeekView.tsx +15 -2
- package/corpus/templates/calendar/app/components/layout/Sidebar.tsx +1 -5
- package/corpus/templates/calendar/app/hooks/use-events.ts +51 -5
- package/corpus/templates/calendar/app/i18n-data.ts +50 -0
- package/corpus/templates/calendar/app/lib/all-day-layout.ts +9 -2
- package/corpus/templates/calendar/app/lib/event-form-initialization.ts +4 -8
- package/corpus/templates/calendar/app/lib/event-form-utils.ts +43 -8
- package/corpus/templates/calendar/app/lib/location-suggestions.ts +36 -0
- package/corpus/templates/calendar/app/lib/out-of-office.ts +87 -1
- package/corpus/templates/calendar/app/pages/CalendarView.tsx +82 -20
- package/corpus/templates/calendar/changelog/2026-07-26-out-of-office-events-now-default-to-full-days-with-a-ready.md +6 -0
- package/corpus/templates/calendar/changelog/2026-07-29-recent-calendar-locations-now-appear-as-address-suggestions-.md +6 -0
- package/corpus/templates/calendar/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
- package/corpus/templates/calendar/changelog/2026-07-29-unnamed-events-now-use-a-title-placeholder.md +6 -0
- package/corpus/templates/calendar/server/lib/find-time.ts +29 -5
- package/corpus/templates/calendar/server/lib/google-calendar.ts +2 -0
- package/corpus/templates/calendar/server/lib/ical-fetcher.ts +1 -0
- package/corpus/templates/calendar/shared/api.ts +4 -0
- package/corpus/templates/chat/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/chat/app/components/layout/Sidebar.tsx +1 -5
- package/corpus/templates/chat/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
- package/corpus/templates/clips/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/clips/app/components/library/library-layout.tsx +1 -5
- package/corpus/templates/clips/changelog/2026-07-29-fixed-system-audio-recordings-picking-up-your-microphone-in-.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-29-the-desktop-camera-preview-now-closes-after-a-recording-fin.md +6 -0
- package/corpus/templates/clips/desktop/src/app.tsx +14 -15
- package/corpus/templates/clips/desktop/src/lib/bubble-session.ts +11 -0
- package/corpus/templates/clips/desktop/src/lib/recorder.ts +9 -4
- package/corpus/templates/clips/desktop/src/lib/transcription-capture.ts +11 -0
- package/corpus/templates/clips/server/jobs/transactional-emails.ts +47 -23
- package/corpus/templates/clips/server/lib/transactional-email-store.ts +16 -6
- package/corpus/templates/content/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/content/.agents/skills/content-product-development/SKILL.md +103 -0
- package/corpus/templates/content/.agents/skills/content-product-development/references/verification.md +57 -0
- package/corpus/templates/content/AGENTS.md +2 -0
- package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +1 -6
- package/corpus/templates/content/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
- package/corpus/templates/content/docs/product/README.md +115 -0
- package/corpus/templates/content/docs/product/architecture.md +98 -0
- package/corpus/templates/content/docs/product/capabilities/content.access.page-database.md +76 -0
- package/corpus/templates/content/docs/product/capabilities/content.access.row-private.md +75 -0
- package/corpus/templates/content/docs/product/capabilities/content.access.safe-aggregate.md +75 -0
- package/corpus/templates/content/docs/product/capabilities/content.access.visibility-closure.md +79 -0
- package/corpus/templates/content/docs/product/capabilities/content.action.button.md +67 -0
- package/corpus/templates/content/docs/product/capabilities/content.agent.action-parity.md +73 -0
- package/corpus/templates/content/docs/product/capabilities/content.agent.audience-safe.md +91 -0
- package/corpus/templates/content/docs/product/capabilities/content.agent.automation.md +67 -0
- package/corpus/templates/content/docs/product/capabilities/content.agent.expression-authoring.md +71 -0
- package/corpus/templates/content/docs/product/capabilities/content.agent.presence.md +103 -0
- package/corpus/templates/content/docs/product/capabilities/content.agent.resource-consent.md +90 -0
- package/corpus/templates/content/docs/product/capabilities/content.agent.skill-catalog.md +67 -0
- package/corpus/templates/content/docs/product/capabilities/content.api.cms.md +70 -0
- package/corpus/templates/content/docs/product/capabilities/content.author.code.md +71 -0
- package/corpus/templates/content/docs/product/capabilities/content.author.document-editor.md +71 -0
- package/corpus/templates/content/docs/product/capabilities/content.author.footnotes.md +71 -0
- package/corpus/templates/content/docs/product/capabilities/content.author.math.md +71 -0
- package/corpus/templates/content/docs/product/capabilities/content.author.media.md +71 -0
- package/corpus/templates/content/docs/product/capabilities/content.author.mermaid.md +71 -0
- package/corpus/templates/content/docs/product/capabilities/content.automation.scheduled.md +67 -0
- package/corpus/templates/content/docs/product/capabilities/content.capture.enrich.md +75 -0
- package/corpus/templates/content/docs/product/capabilities/content.command.fabric.md +67 -0
- package/corpus/templates/content/docs/product/capabilities/content.comment.page-owned.md +75 -0
- package/corpus/templates/content/docs/product/capabilities/content.diff.ai-assist.md +75 -0
- package/corpus/templates/content/docs/product/capabilities/content.diff.filtered-review.md +79 -0
- package/corpus/templates/content/docs/product/capabilities/content.diff.in-place.md +80 -0
- package/corpus/templates/content/docs/product/capabilities/content.discussion.page.md +80 -0
- package/corpus/templates/content/docs/product/capabilities/content.embed.host-grant.md +70 -0
- package/corpus/templates/content/docs/product/capabilities/content.embed.mcp-app.md +69 -0
- package/corpus/templates/content/docs/product/capabilities/content.embed.surface.md +74 -0
- package/corpus/templates/content/docs/product/capabilities/content.event.committed.md +85 -0
- package/corpus/templates/content/docs/product/capabilities/content.expression.cached-result.md +71 -0
- package/corpus/templates/content/docs/product/capabilities/content.expression.catalog.md +71 -0
- package/corpus/templates/content/docs/product/capabilities/content.expression.language.md +76 -0
- package/corpus/templates/content/docs/product/capabilities/content.feedback.signal.md +67 -0
- package/corpus/templates/content/docs/product/capabilities/content.form.shared-engine.md +72 -0
- package/corpus/templates/content/docs/product/capabilities/content.history.queryable.md +79 -0
- package/corpus/templates/content/docs/product/capabilities/content.home.global.md +80 -0
- package/corpus/templates/content/docs/product/capabilities/content.job.durable.md +76 -0
- package/corpus/templates/content/docs/product/capabilities/content.knowledge.graph.md +67 -0
- package/corpus/templates/content/docs/product/capabilities/content.knowledge.links.md +67 -0
- package/corpus/templates/content/docs/product/capabilities/content.knowledge.search.md +67 -0
- package/corpus/templates/content/docs/product/capabilities/content.layout.responsive.md +80 -0
- package/corpus/templates/content/docs/product/capabilities/content.navigation.sidebar.md +86 -0
- package/corpus/templates/content/docs/product/capabilities/content.notification.source.md +71 -0
- package/corpus/templates/content/docs/product/capabilities/content.object.block.md +76 -0
- package/corpus/templates/content/docs/product/capabilities/content.object.blocks-field.md +79 -0
- package/corpus/templates/content/docs/product/capabilities/content.object.database.md +92 -0
- package/corpus/templates/content/docs/product/capabilities/content.object.multi-membership.md +75 -0
- package/corpus/templates/content/docs/product/capabilities/content.object.page.md +76 -0
- package/corpus/templates/content/docs/product/capabilities/content.object.reference.md +75 -0
- package/corpus/templates/content/docs/product/capabilities/content.object.transclusion.md +75 -0
- package/corpus/templates/content/docs/product/capabilities/content.organization.teams.md +71 -0
- package/corpus/templates/content/docs/product/capabilities/content.portability.pdf-export.md +78 -0
- package/corpus/templates/content/docs/product/capabilities/content.portability.roundtrip.md +154 -0
- package/corpus/templates/content/docs/product/capabilities/content.portability.source-representation.md +70 -0
- package/corpus/templates/content/docs/product/capabilities/content.portability.vault-export.md +80 -0
- package/corpus/templates/content/docs/product/capabilities/content.presentation.mode.md +76 -0
- package/corpus/templates/content/docs/product/capabilities/content.preset.catalog.md +71 -0
- package/corpus/templates/content/docs/product/capabilities/content.property.actor.md +75 -0
- package/corpus/templates/content/docs/product/capabilities/content.property.catalog.md +76 -0
- package/corpus/templates/content/docs/product/capabilities/content.property.constraints.md +75 -0
- package/corpus/templates/content/docs/product/capabilities/content.property.guarded-change.md +76 -0
- package/corpus/templates/content/docs/product/capabilities/content.property.location.md +71 -0
- package/corpus/templates/content/docs/product/capabilities/content.property.typed.md +71 -0
- package/corpus/templates/content/docs/product/capabilities/content.publish.public.md +75 -0
- package/corpus/templates/content/docs/product/capabilities/content.publish.reading.md +74 -0
- package/corpus/templates/content/docs/product/capabilities/content.query.object.md +114 -0
- package/corpus/templates/content/docs/product/capabilities/content.reader.documents.md +69 -0
- package/corpus/templates/content/docs/product/capabilities/content.reader.surface.md +75 -0
- package/corpus/templates/content/docs/product/capabilities/content.relationship.edge.md +183 -0
- package/corpus/templates/content/docs/product/capabilities/content.renderer.artifact-block.md +71 -0
- package/corpus/templates/content/docs/product/capabilities/content.renderer.custom-block.md +81 -0
- package/corpus/templates/content/docs/product/capabilities/content.renderer.graph.md +71 -0
- package/corpus/templates/content/docs/product/capabilities/content.renderer.typed.md +92 -0
- package/corpus/templates/content/docs/product/capabilities/content.research.annotation.md +75 -0
- package/corpus/templates/content/docs/product/capabilities/content.research.citation.md +70 -0
- package/corpus/templates/content/docs/product/capabilities/content.review.code.md +67 -0
- package/corpus/templates/content/docs/product/capabilities/content.revision.suggestions.md +76 -0
- package/corpus/templates/content/docs/product/capabilities/content.rule.deterministic.md +79 -0
- package/corpus/templates/content/docs/product/capabilities/content.schedule.constraints.md +81 -0
- package/corpus/templates/content/docs/product/capabilities/content.security.private-vault.md +71 -0
- package/corpus/templates/content/docs/product/capabilities/content.share.views.md +140 -0
- package/corpus/templates/content/docs/product/capabilities/content.source.adapters.md +154 -0
- package/corpus/templates/content/docs/product/capabilities/content.source.builder-codec.md +70 -0
- package/corpus/templates/content/docs/product/capabilities/content.source.catalog.md +149 -0
- package/corpus/templates/content/docs/product/capabilities/content.source.file-folder.md +71 -0
- package/corpus/templates/content/docs/product/capabilities/content.source.local-bridge.md +156 -0
- package/corpus/templates/content/docs/product/capabilities/content.source.local-project.md +70 -0
- package/corpus/templates/content/docs/product/capabilities/content.source.page-link.md +70 -0
- package/corpus/templates/content/docs/product/capabilities/content.source.row-union.md +69 -0
- package/corpus/templates/content/docs/product/capabilities/content.source.spaces-files.md +75 -0
- package/corpus/templates/content/docs/product/capabilities/content.source.sync-policy.md +161 -0
- package/corpus/templates/content/docs/product/capabilities/content.system.dependencies.md +80 -0
- package/corpus/templates/content/docs/product/capabilities/content.system.my-tasks.md +75 -0
- package/corpus/templates/content/docs/product/capabilities/content.system.project-status.md +77 -0
- package/corpus/templates/content/docs/product/capabilities/content.system.research-workspace.md +80 -0
- package/corpus/templates/content/docs/product/capabilities/content.system.task-project.md +76 -0
- package/corpus/templates/content/docs/product/capabilities/content.template.governance.md +76 -0
- package/corpus/templates/content/docs/product/capabilities/content.template.graph.md +76 -0
- package/corpus/templates/content/docs/product/capabilities/content.template.item-body.md +71 -0
- package/corpus/templates/content/docs/product/capabilities/content.template.update.md +71 -0
- package/corpus/templates/content/docs/product/capabilities/content.time.types.md +85 -0
- package/corpus/templates/content/docs/product/capabilities/content.version.branching.md +151 -0
- package/corpus/templates/content/docs/product/capabilities/content.version.field-history.md +103 -0
- package/corpus/templates/content/docs/product/capabilities/content.view.canvas.md +94 -0
- package/corpus/templates/content/docs/product/capabilities/content.view.chart.md +91 -0
- package/corpus/templates/content/docs/product/capabilities/content.view.dynamic-create.md +137 -0
- package/corpus/templates/content/docs/product/capabilities/content.view.fast-capture.md +82 -0
- package/corpus/templates/content/docs/product/capabilities/content.view.graph.md +95 -0
- package/corpus/templates/content/docs/product/capabilities/content.view.grouping-aggregation.md +83 -0
- package/corpus/templates/content/docs/product/capabilities/content.view.map.md +77 -0
- package/corpus/templates/content/docs/product/capabilities/content.view.personal-state.md +99 -0
- package/corpus/templates/content/docs/product/capabilities/content.view.pivot.md +76 -0
- package/corpus/templates/content/docs/product/capabilities/content.view.query.md +106 -0
- package/corpus/templates/content/docs/product/capabilities/content.view.renderer-conformance.md +77 -0
- package/corpus/templates/content/docs/product/capabilities/content.view.scale.md +77 -0
- package/corpus/templates/content/docs/product/capabilities/content.view.source-query.md +159 -0
- package/corpus/templates/content/docs/product/capabilities/content.view.timeline.md +86 -0
- package/corpus/templates/content/docs/product/capabilities/content.view.tree.md +77 -0
- package/corpus/templates/content/docs/product/capabilities/content.workspace.multi-scope.md +80 -0
- package/corpus/templates/content/docs/product/capabilities/content.workspace.session-restore.md +76 -0
- package/corpus/templates/content/docs/product/capabilities/content.workspace.view-instance.md +76 -0
- package/corpus/templates/content/docs/product/capabilities/content.workspace.working-set.md +77 -0
- package/corpus/templates/content/docs/product/chapters/content.chapter.capture-research.md +20 -0
- package/corpus/templates/content/docs/product/chapters/content.chapter.connected-sources.md +20 -0
- package/corpus/templates/content/docs/product/chapters/content.chapter.consensus.md +19 -0
- package/corpus/templates/content/docs/product/chapters/content.chapter.durable-home.md +21 -0
- package/corpus/templates/content/docs/product/chapters/content.chapter.publishing-portability.md +21 -0
- package/corpus/templates/content/docs/product/chapters/content.chapter.working-systems.md +27 -0
- package/corpus/templates/content/docs/product/encyclopedia.md +559 -0
- package/corpus/templates/content/docs/product/features/content.feature.bring-your-local-work.md +39 -0
- package/corpus/templates/content/docs/product/features/content.feature.build-living-dashboards.md +34 -0
- package/corpus/templates/content/docs/product/features/content.feature.build-new-surfaces.md +33 -0
- package/corpus/templates/content/docs/product/features/content.feature.capture-into-action.md +34 -0
- package/corpus/templates/content/docs/product/features/content.feature.cite-what-you-found.md +34 -0
- package/corpus/templates/content/docs/product/features/content.feature.collaborate-in-context.md +59 -0
- package/corpus/templates/content/docs/product/features/content.feature.collect-structured-input.md +38 -0
- package/corpus/templates/content/docs/product/features/content.feature.connect-your-sources.md +38 -0
- package/corpus/templates/content/docs/product/features/content.feature.data-that-keeps-itself-right.md +45 -0
- package/corpus/templates/content/docs/product/features/content.feature.durable-foundations.md +48 -0
- package/corpus/templates/content/docs/product/features/content.feature.evolve-systems-safely.md +38 -0
- package/corpus/templates/content/docs/product/features/content.feature.explore-alternatives-safely.md +39 -0
- package/corpus/templates/content/docs/product/features/content.feature.find-your-place-again.md +40 -0
- package/corpus/templates/content/docs/product/features/content.feature.keep-your-private-vault-private.md +39 -0
- package/corpus/templates/content/docs/product/features/content.feature.living-references.md +38 -0
- package/corpus/templates/content/docs/product/features/content.feature.make-the-workspace-yours.md +40 -0
- package/corpus/templates/content/docs/product/features/content.feature.move-without-starting-over.md +38 -0
- package/corpus/templates/content/docs/product/features/content.feature.plan-work-across-time.md +39 -0
- package/corpus/templates/content/docs/product/features/content.feature.publish-with-confidence.md +43 -0
- package/corpus/templates/content/docs/product/features/content.feature.put-your-organizations-know-how-to-work.md +38 -0
- package/corpus/templates/content/docs/product/features/content.feature.read-and-annotate-anything.md +38 -0
- package/corpus/templates/content/docs/product/features/content.feature.review-changes-in-place.md +39 -0
- package/corpus/templates/content/docs/product/features/content.feature.run-projects-your-way.md +44 -0
- package/corpus/templates/content/docs/product/features/content.feature.see-your-information-your-way.md +44 -0
- package/corpus/templates/content/docs/product/features/content.feature.share-how-your-organization-works.md +38 -0
- package/corpus/templates/content/docs/product/features/content.feature.sketch-connections-keep-whats-true.md +39 -0
- package/corpus/templates/content/docs/product/features/content.feature.take-the-whole-vault-with-you.md +39 -0
- package/corpus/templates/content/docs/product/features/content.feature.trust-your-connected-sources.md +40 -0
- package/corpus/templates/content/docs/product/features/content.feature.understand-what-your-data-says.md +39 -0
- package/corpus/templates/content/docs/product/features/content.feature.when-this-happens-that-follows.md +43 -0
- package/corpus/templates/content/docs/product/features/content.feature.work-across-every-workspace.md +37 -0
- package/corpus/templates/content/docs/product/features/content.feature.work-on-content-inside-another-application.md +37 -0
- package/corpus/templates/content/docs/product/roadmap.md +878 -0
- package/corpus/templates/crm/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/crm/app/components/layout/CrmSidebar.tsx +1 -7
- package/corpus/templates/crm/app/i18n/en-US.ts +4 -0
- package/corpus/templates/crm/app/routes/settings.tsx +33 -8
- package/corpus/templates/crm/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
- package/corpus/templates/design/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +133 -63
- package/corpus/templates/design/.generated/bridge/embedded-wheel.generated.ts +19 -2
- package/corpus/templates/design/app/components/design/DesignCanvas.tsx +51 -14
- package/corpus/templates/design/app/components/design/DesignExtensionsPanel.tsx +41 -26
- package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +22 -4
- package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +216 -116
- package/corpus/templates/design/app/components/design/bridge/embedded-wheel.bridge.ts +21 -2
- package/corpus/templates/design/app/components/design/code-workbench/CodeWorkbench.tsx +5 -1
- package/corpus/templates/design/app/components/design/code-workbench/CodeWorkbenchLoader.tsx +10 -2
- package/corpus/templates/design/app/components/design/code-workbench/code-workbench-shell.ts +2 -0
- package/corpus/templates/design/app/components/design/code-workbench/explorer/ExplorerView.tsx +60 -55
- package/corpus/templates/design/app/components/design/design-canvas/content-size-report.ts +88 -2
- package/corpus/templates/design/app/components/design/multi-screen/board-surface-html.ts +3 -2
- package/corpus/templates/design/app/components/design/types.ts +4 -0
- package/corpus/templates/design/app/components/layout/Sidebar.tsx +1 -5
- package/corpus/templates/design/app/pages/design-editor/clipboard-layer-source.ts +28 -0
- package/corpus/templates/design/app/pages/design-editor/clone-and-pen-edit.ts +117 -0
- package/corpus/templates/design/app/pages/design-editor/code-layer-state.ts +3 -1
- package/corpus/templates/design/app/pages/design-editor/pending-edits.ts +120 -74
- package/corpus/templates/design/app/pages/design-editor/pending-structure-verification.ts +11 -0
- package/corpus/templates/design/app/pages/design-editor/react-semantic-handoff.ts +2 -0
- package/corpus/templates/design/app/pages/design-editor/source-location.ts +1 -1
- package/corpus/templates/design/changelog/2026-07-29-copy-rendered-ui-between-live-local-apps-and-design-files-wh.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-design-boards-stay-dark-and-viewport-height-content-keeps-it.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-design-frames-no-longer-grow-continuously-when-their-content.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-the-code-panel-and-apply-design-update-control-now-use-clear.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-the-tools-panel-now-keeps-extension-creation-and-discovery-h.md +6 -0
- package/corpus/templates/design/shared/source-mode.ts +7 -1
- package/corpus/templates/dispatch/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/dispatch/app/i18n-data.ts +171 -0
- package/corpus/templates/dispatch/app/routes/browser-chat.tsx +4 -0
- package/corpus/templates/dispatch/app/routes/browser-connect.tsx +4 -0
- package/corpus/templates/dispatch/changelog/2026-07-29-browser-chat-can-securely-connect-the-agent-native-chrome-ex.md +6 -0
- package/corpus/templates/forms/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/forms/app/components/layout/Sidebar.tsx +1 -6
- package/corpus/templates/forms/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
- package/corpus/templates/macros/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/macros/app/components/layout/AppLayout.tsx +1 -5
- package/corpus/templates/macros/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
- package/corpus/templates/mail/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/mail/app/components/layout/AppLayout.tsx +1 -9
- package/corpus/templates/mail/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
- package/corpus/templates/plan/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/plan/app/components/layout/Sidebar.tsx +3 -7
- package/corpus/templates/plan/app/pages/PlansPage.tsx +2 -2
- package/corpus/templates/plan/changelog/2026-07-29-chat-history-now-closes-smoothly-and-stays-ready-when-you-re.md +6 -0
- package/corpus/templates/plan/changelog/2026-07-29-chat-history-stays-visible-when-you-return-to-ask-plan.md +6 -0
- package/corpus/templates/plan/changelog/2026-07-29-fixed-plan-pages-crashing-when-recent-activity-is-unavailabl.md +6 -0
- package/corpus/templates/plan/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
- package/corpus/templates/slides/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/slides/.agents/skills/analytics-data-for-decks/SKILL.md +48 -0
- package/corpus/templates/slides/.agents/skills/create-deck/SKILL.md +60 -4
- package/corpus/templates/slides/.agents/skills/design-systems/SKILL.md +20 -0
- package/corpus/templates/slides/.agents/skills/slide-editing/SKILL.md +30 -1
- package/corpus/templates/slides/.agents/skills/slide-images/SKILL.md +3 -1
- package/corpus/templates/slides/AGENTS.md +25 -24
- package/corpus/templates/slides/actions/check-image-gen.ts +8 -2
- package/corpus/templates/slides/actions/create-deck.ts +4 -12
- package/corpus/templates/slides/actions/export-pptx.ts +25 -3
- package/corpus/templates/slides/actions/generate-image-api.ts +4 -2
- package/corpus/templates/slides/actions/generate-slides-ai.ts +1 -1
- package/corpus/templates/slides/actions/get-deck-reference-context.ts +136 -0
- package/corpus/templates/slides/actions/get-workspace-defaults.ts +55 -0
- package/corpus/templates/slides/actions/image-gen-status.ts +10 -1
- package/corpus/templates/slides/actions/import-file.ts +53 -38
- package/corpus/templates/slides/actions/list-decks.ts +2 -0
- package/corpus/templates/slides/actions/patch-deck.ts +2 -0
- package/corpus/templates/slides/actions/set-workspace-defaults.ts +50 -0
- package/corpus/templates/slides/actions/view-screen.ts +6 -0
- package/corpus/templates/slides/app/components/comments/SlideCommentsPanel.tsx +1 -1
- package/corpus/templates/slides/app/components/deck/DeckCard.tsx +67 -3
- package/corpus/templates/slides/app/components/deck/SlideRenderer.tsx +40 -8
- package/corpus/templates/slides/app/components/design-system/DesignSystemCard.tsx +33 -8
- package/corpus/templates/slides/app/components/editor/EditorSidebar.tsx +6 -2
- package/corpus/templates/slides/app/components/editor/EditorToolbar.tsx +114 -128
- package/corpus/templates/slides/app/components/editor/ExportMenu.tsx +74 -9
- package/corpus/templates/slides/app/components/editor/ImageGenPanel.tsx +1 -1
- package/corpus/templates/slides/app/components/editor/SlideEditor.tsx +1193 -267
- package/corpus/templates/slides/app/components/editor/SlideStyleInspector.tsx +302 -102
- package/corpus/templates/slides/app/components/editor/rich-text-selection.ts +270 -0
- package/corpus/templates/slides/app/components/editor/slide-escape-arbiter.ts +34 -0
- package/corpus/templates/slides/app/components/editor/slide-object-interactions.ts +368 -0
- package/corpus/templates/slides/app/components/editor/slide-presence.ts +13 -0
- package/corpus/templates/slides/app/components/layout/AgentWorkIndicator.tsx +23 -3
- package/corpus/templates/slides/app/components/layout/Layout.tsx +39 -6
- package/corpus/templates/slides/app/components/layout/Sidebar.tsx +1 -6
- package/corpus/templates/slides/app/components/layout/layout-route-policy.ts +23 -0
- package/corpus/templates/slides/app/components/visual-editor/DrawOverlay.tsx +0 -2
- package/corpus/templates/slides/app/context/DeckContext.tsx +2 -0
- package/corpus/templates/slides/app/global.css +60 -0
- package/corpus/templates/slides/app/hooks/use-agent-generating.ts +76 -5
- package/corpus/templates/slides/app/hooks/use-workspace-defaults.ts +26 -0
- package/corpus/templates/slides/app/i18n/en-US.ts +39 -3
- package/corpus/templates/slides/app/lib/generation-state.ts +13 -3
- package/corpus/templates/slides/app/lib/slide-image-replacement.ts +27 -6
- package/corpus/templates/slides/app/lib/text-tool-shortcut.ts +62 -0
- package/corpus/templates/slides/app/pages/DeckEditor.tsx +197 -83
- package/corpus/templates/slides/app/pages/DesignSystems.tsx +95 -0
- package/corpus/templates/slides/app/pages/Index.tsx +348 -53
- package/corpus/templates/slides/changelog/2026-07-28-pick-an-existing-deck-as-a-style-reference-when-creating-a-n.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-29-ai-editing-status-is-now-quieter-and-only-shows-slide-presen.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-29-design-systems-and-reference-decks-are-easier-to-choose-toge.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-29-generated-decks-now-receive-a-concise-relevant-title-before-.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-29-google-slides-exports-can-connect-your-google-account-direct.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-29-new-deck-prompts-reuse-empty-chats.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-29-new-deck-setup-now-stays-in-the-editor-with-closable-style-a.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-29-selected-words-and-text-runs-can-now-be-styled-independently.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-29-slide-annotation-tools-are-clearer-and-escape-now-exits-anno.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-29-slide-editing-now-opens-with-the-app-navigation-collapsed-fo.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-29-slide-editing-stays-visually-clean-on-hover-without-a-canvas.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-29-slides-now-appear-one-by-one-while-ai-builds-a-deck-with-ste.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-29-text-boxes-now-select-move-duplicate-resize-and-style-like-a.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-29-untitled-decks-now-use-a-clearer-this-deck-label-in-the-agen.md +6 -0
- package/corpus/templates/slides/server/handlers/google-docs-auth.ts +4 -2
- package/corpus/templates/slides/server/handlers/image-providers/builder.ts +305 -0
- package/corpus/templates/slides/server/handlers/image-providers/index.ts +6 -3
- package/corpus/templates/slides/server/plugins/agent-chat.ts +1 -0
- package/corpus/templates/slides/server/workspace-defaults.ts +169 -0
- package/corpus/templates/tasks/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/corpus/templates/tasks/app/components/layout/Sidebar.tsx +31 -8
- package/corpus/templates/tasks/app/i18n/en-US.ts +7 -0
- package/corpus/templates/tasks/app/routes/settings.tsx +25 -2
- package/corpus/templates/tasks/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
- package/corpus/toolkit/CHANGELOG.md +15 -0
- package/corpus/toolkit/README.md +2 -2
- package/corpus/toolkit/package.json +1 -1
- package/corpus/toolkit/src/app-shell/sidebar-footer-actions.tsx +0 -3
- package/corpus/toolkit/src/chat-history.css +1 -0
- package/corpus/toolkit/src/composer/ComposerPlusMenu.tsx +35 -14
- package/corpus/toolkit/src/composer/PromptComposer.tsx +6 -0
- package/corpus/toolkit/src/composer/TiptapComposer.tsx +11 -3
- package/corpus/toolkit/src/design-tweaks/visual-style-controls.tsx +64 -11
- package/dist/a2a/types.d.ts +6 -0
- package/dist/a2a/types.d.ts.map +1 -1
- package/dist/a2a/types.js.map +1 -1
- package/dist/action.d.ts +57 -0
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js +9 -0
- package/dist/action.js.map +1 -1
- package/dist/agent/engine/builder-engine.js +6 -4
- package/dist/agent/engine/builder-engine.js.map +1 -1
- package/dist/agent/production-agent.d.ts +11 -1
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +131 -90
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/tool-search.d.ts +4 -0
- package/dist/agent/tool-search.d.ts.map +1 -1
- package/dist/agent/tool-search.js +30 -0
- package/dist/agent/tool-search.js.map +1 -1
- package/dist/automations/service.d.ts +85 -0
- package/dist/automations/service.d.ts.map +1 -0
- package/dist/automations/service.js +332 -0
- package/dist/automations/service.js.map +1 -0
- package/dist/browser-context/index.d.ts +579 -0
- package/dist/browser-context/index.d.ts.map +1 -0
- package/dist/browser-context/index.js +331 -0
- package/dist/browser-context/index.js.map +1 -0
- package/dist/client/AgentPanel.d.ts.map +1 -1
- package/dist/client/AgentPanel.js +1 -1
- package/dist/client/AgentPanel.js.map +1 -1
- package/dist/client/FeedbackButton.d.ts +6 -2
- package/dist/client/FeedbackButton.d.ts.map +1 -1
- package/dist/client/FeedbackButton.js +20 -3
- package/dist/client/FeedbackButton.js.map +1 -1
- package/dist/client/MultiTabAssistantChat.d.ts.map +1 -1
- package/dist/client/MultiTabAssistantChat.js +19 -2
- package/dist/client/MultiTabAssistantChat.js.map +1 -1
- package/dist/client/agent-chat.d.ts +15 -0
- package/dist/client/agent-chat.d.ts.map +1 -1
- package/dist/client/agent-chat.js +13 -3
- package/dist/client/agent-chat.js.map +1 -1
- package/dist/client/agent-page/AgentJobsTab.d.ts +1 -0
- package/dist/client/agent-page/AgentJobsTab.d.ts.map +1 -1
- package/dist/client/agent-page/AgentJobsTab.js +186 -98
- package/dist/client/agent-page/AgentJobsTab.js.map +1 -1
- package/dist/client/agent-page/AgentTabsPage.js +4 -4
- package/dist/client/agent-page/AgentTabsPage.js.map +1 -1
- package/dist/client/agent-page/use-jobs.d.ts +7 -0
- package/dist/client/agent-page/use-jobs.d.ts.map +1 -1
- package/dist/client/agent-page/use-jobs.js.map +1 -1
- package/dist/client/analytics-session.d.ts.map +1 -1
- package/dist/client/analytics-session.js +13 -0
- package/dist/client/analytics-session.js.map +1 -1
- package/dist/client/extensions/ExtensionViewer.d.ts.map +1 -1
- package/dist/client/extensions/ExtensionViewer.js +29 -6
- package/dist/client/extensions/ExtensionViewer.js.map +1 -1
- package/dist/client/settings/AutomationsSection.d.ts +0 -9
- package/dist/client/settings/AutomationsSection.d.ts.map +1 -1
- package/dist/client/settings/AutomationsSection.js +9 -168
- package/dist/client/settings/AutomationsSection.js.map +1 -1
- package/dist/client/settings/SettingsPanel.d.ts +9 -1
- package/dist/client/settings/SettingsPanel.d.ts.map +1 -1
- package/dist/client/settings/SettingsPanel.js +19 -11
- package/dist/client/settings/SettingsPanel.js.map +1 -1
- package/dist/client/settings/index.d.ts +1 -1
- package/dist/client/settings/index.d.ts.map +1 -1
- package/dist/client/settings/index.js +1 -1
- package/dist/client/settings/index.js.map +1 -1
- package/dist/client/use-agent-chat.d.ts.map +1 -1
- package/dist/client/use-agent-chat.js +20 -3
- package/dist/client/use-agent-chat.js.map +1 -1
- package/dist/client/use-chat-threads.d.ts.map +1 -1
- package/dist/client/use-chat-threads.js +4 -17
- package/dist/client/use-chat-threads.js.map +1 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/collab/struct-routes.d.ts +1 -1
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +2 -1
- package/dist/deploy/build.js.map +1 -1
- package/dist/deploy/workspace-deploy.d.ts.map +1 -1
- package/dist/deploy/workspace-deploy.js +2 -1
- package/dist/deploy/workspace-deploy.js.map +1 -1
- package/dist/extensions/actions.d.ts.map +1 -1
- package/dist/extensions/actions.js +82 -6
- package/dist/extensions/actions.js.map +1 -1
- package/dist/extensions/fetch-tool.d.ts.map +1 -1
- package/dist/extensions/fetch-tool.js +11 -0
- package/dist/extensions/fetch-tool.js.map +1 -1
- package/dist/extensions/routes.d.ts +5 -1
- package/dist/extensions/routes.d.ts.map +1 -1
- package/dist/extensions/routes.js +7 -1
- package/dist/extensions/routes.js.map +1 -1
- package/dist/extensions/web-content.d.ts +1 -0
- package/dist/extensions/web-content.d.ts.map +1 -1
- package/dist/extensions/web-content.js +82 -1
- package/dist/extensions/web-content.js.map +1 -1
- package/dist/file-upload/actions/upload-image.d.ts +1 -1
- package/dist/integrations/computer-supervision.d.ts.map +1 -1
- package/dist/integrations/computer-supervision.js +22 -1
- package/dist/integrations/computer-supervision.js.map +1 -1
- package/dist/integrations/index.d.ts +3 -2
- package/dist/integrations/index.d.ts.map +1 -1
- package/dist/integrations/index.js +3 -2
- package/dist/integrations/index.js.map +1 -1
- package/dist/integrations/integration-durable-dispatch-config.d.ts +2 -0
- package/dist/integrations/integration-durable-dispatch-config.d.ts.map +1 -1
- package/dist/integrations/integration-durable-dispatch-config.js +4 -0
- package/dist/integrations/integration-durable-dispatch-config.js.map +1 -1
- package/dist/integrations/integration-durable-dispatch.d.ts +2 -2
- package/dist/integrations/integration-durable-dispatch.d.ts.map +1 -1
- package/dist/integrations/integration-durable-dispatch.js +2 -2
- package/dist/integrations/integration-durable-dispatch.js.map +1 -1
- package/dist/integrations/plugin.d.ts.map +1 -1
- package/dist/integrations/plugin.js +84 -39
- package/dist/integrations/plugin.js.map +1 -1
- package/dist/integrations/remote-browser-actions.d.ts +7 -0
- package/dist/integrations/remote-browser-actions.d.ts.map +1 -0
- package/dist/integrations/remote-browser-actions.js +482 -0
- package/dist/integrations/remote-browser-actions.js.map +1 -0
- package/dist/jobs/actions/list-recurring-jobs.d.ts.map +1 -1
- package/dist/jobs/actions/list-recurring-jobs.js +4 -6
- package/dist/jobs/actions/list-recurring-jobs.js.map +1 -1
- package/dist/jobs/actions/manage-recurring-job.js +3 -6
- package/dist/jobs/actions/manage-recurring-job.js.map +1 -1
- package/dist/jobs/background-automation-runner.d.ts +76 -0
- package/dist/jobs/background-automation-runner.d.ts.map +1 -0
- package/dist/jobs/background-automation-runner.js +288 -0
- package/dist/jobs/background-automation-runner.js.map +1 -0
- package/dist/jobs/frontmatter.d.ts +63 -0
- package/dist/jobs/frontmatter.d.ts.map +1 -0
- package/dist/jobs/frontmatter.js +216 -0
- package/dist/jobs/frontmatter.js.map +1 -0
- package/dist/jobs/scheduler.d.ts +6 -60
- package/dist/jobs/scheduler.d.ts.map +1 -1
- package/dist/jobs/scheduler.js +67 -484
- package/dist/jobs/scheduler.js.map +1 -1
- package/dist/jobs/tools.d.ts.map +1 -1
- package/dist/jobs/tools.js +24 -3
- package/dist/jobs/tools.js.map +1 -1
- package/dist/localization/default-messages.d.ts +28 -33
- package/dist/localization/default-messages.d.ts.map +1 -1
- package/dist/localization/default-messages.js +34 -39
- package/dist/localization/default-messages.js.map +1 -1
- package/dist/mcp/screen-memory-stdio.d.ts +7 -7
- package/dist/mcp/screen-memory-stdio.d.ts.map +1 -1
- package/dist/mcp-client/index.d.ts.map +1 -1
- package/dist/mcp-client/index.js +4 -0
- package/dist/mcp-client/index.js.map +1 -1
- package/dist/notifications/actions.d.ts.map +1 -1
- package/dist/notifications/actions.js +5 -0
- package/dist/notifications/actions.js.map +1 -1
- package/dist/notifications/routes.d.ts +3 -3
- package/dist/progress/actions.d.ts.map +1 -1
- package/dist/progress/actions.js +5 -0
- package/dist/progress/actions.js.map +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +14 -14
- package/dist/provider-api/actions/github-repo-files.d.ts.map +1 -1
- package/dist/provider-api/actions/github-repo-files.js +9 -0
- package/dist/provider-api/actions/github-repo-files.js.map +1 -1
- package/dist/provider-api/actions/provider-api.d.ts +16 -16
- package/dist/provider-api/actions/provider-api.d.ts.map +1 -1
- package/dist/provider-api/actions/provider-api.js +14 -0
- package/dist/provider-api/actions/provider-api.js.map +1 -1
- package/dist/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/server/action-discovery.d.ts.map +1 -1
- package/dist/server/action-discovery.js +5 -0
- package/dist/server/action-discovery.js.map +1 -1
- package/dist/server/agent-capabilities.d.ts.map +1 -1
- package/dist/server/agent-capabilities.js +32 -3
- package/dist/server/agent-capabilities.js.map +1 -1
- package/dist/server/agent-chat/action-filters-a2a.d.ts +17 -1
- package/dist/server/agent-chat/action-filters-a2a.d.ts.map +1 -1
- package/dist/server/agent-chat/action-filters-a2a.js +50 -1
- package/dist/server/agent-chat/action-filters-a2a.js.map +1 -1
- package/dist/server/agent-chat/browser-team-tools.d.ts.map +1 -1
- package/dist/server/agent-chat/browser-team-tools.js +90 -3
- package/dist/server/agent-chat/browser-team-tools.js.map +1 -1
- package/dist/server/agent-chat/framework-prompts.d.ts.map +1 -1
- package/dist/server/agent-chat/framework-prompts.js +7 -11
- package/dist/server/agent-chat/framework-prompts.js.map +1 -1
- package/dist/server/agent-chat/plugin-options.d.ts +3 -3
- package/dist/server/agent-chat/plugin-options.js.map +1 -1
- package/dist/server/agent-chat/script-entries.d.ts.map +1 -1
- package/dist/server/agent-chat/script-entries.js +43 -1
- package/dist/server/agent-chat/script-entries.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +24 -5
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/attribution.d.ts +6 -0
- package/dist/server/attribution.d.ts.map +1 -1
- package/dist/server/attribution.js +14 -14
- package/dist/server/attribution.js.map +1 -1
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +5 -2
- package/dist/server/auth.js.map +1 -1
- package/dist/server/better-auth-instance.d.ts +2 -1
- package/dist/server/better-auth-instance.d.ts.map +1 -1
- package/dist/server/better-auth-instance.js +6 -3
- package/dist/server/better-auth-instance.js.map +1 -1
- package/dist/server/core-routes-plugin.d.ts +7 -0
- package/dist/server/core-routes-plugin.d.ts.map +1 -1
- package/dist/server/core-routes-plugin.js +3 -1
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/csrf.d.ts.map +1 -1
- package/dist/server/csrf.js +25 -0
- package/dist/server/csrf.js.map +1 -1
- package/dist/server/google-oauth.d.ts +3 -0
- package/dist/server/google-oauth.d.ts.map +1 -1
- package/dist/server/google-oauth.js +12 -1
- package/dist/server/google-oauth.js.map +1 -1
- package/dist/server/onboarding-html.d.ts.map +1 -1
- package/dist/server/onboarding-html.js +18 -0
- package/dist/server/onboarding-html.js.map +1 -1
- package/dist/server/prompts/framework-core-compact.js +3 -3
- package/dist/server/prompts/framework-core-compact.js.map +1 -1
- package/dist/server/prompts/framework-core.js +3 -3
- package/dist/server/prompts/framework-core.js.map +1 -1
- package/dist/server/prompts/shared-rules.js +3 -3
- package/dist/server/prompts/shared-rules.js.map +1 -1
- package/dist/settings/index.d.ts +1 -1
- package/dist/settings/index.d.ts.map +1 -1
- package/dist/settings/index.js +1 -1
- package/dist/settings/index.js.map +1 -1
- package/dist/shared/analytics-anonymous-id.d.ts +12 -0
- package/dist/shared/analytics-anonymous-id.d.ts.map +1 -0
- package/dist/shared/analytics-anonymous-id.js +29 -0
- package/dist/shared/analytics-anonymous-id.js.map +1 -0
- package/dist/templates/chat/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/dist/templates/chat/app/components/layout/Sidebar.tsx +1 -5
- package/dist/templates/chat/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
- package/dist/templates/default/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/dist/templates/default/app/i18n/ar-SA.ts +26 -0
- package/dist/templates/default/app/i18n/de-DE.ts +28 -0
- package/dist/templates/default/app/i18n/en-US.ts +27 -0
- package/dist/templates/default/app/i18n/es-ES.ts +28 -0
- package/dist/templates/default/app/i18n/fr-FR.ts +28 -0
- package/dist/templates/default/app/i18n/hi-IN.ts +25 -0
- package/dist/templates/default/app/i18n/ja-JP.ts +27 -0
- package/dist/templates/default/app/i18n/ko-KR.ts +27 -0
- package/dist/templates/default/app/i18n/pt-BR.ts +27 -0
- package/dist/templates/default/app/i18n/zh-CN.ts +24 -0
- package/dist/templates/default/app/i18n/zh-TW.ts +24 -0
- package/dist/templates/headless/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/dist/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/dist/templates/workspace-core/.agents/skills/agent-page/SKILL.md +10 -7
- package/dist/templates/workspace-core/.agents/skills/automations/SKILL.md +53 -8
- package/dist/templates/workspace-core/.agents/skills/browser-sessions/SKILL.md +131 -0
- package/dist/templates/workspace-core/.agents/skills/extension-points/SKILL.md +13 -4
- package/dist/templates/workspace-core/.agents/skills/extensions/SKILL.md +23 -15
- package/dist/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +33 -18
- package/dist/tracking/providers.d.ts.map +1 -1
- package/dist/tracking/providers.js +1 -0
- package/dist/tracking/providers.js.map +1 -1
- package/dist/tracking/registry.d.ts +1 -0
- package/dist/tracking/registry.d.ts.map +1 -1
- package/dist/tracking/registry.js +1 -0
- package/dist/tracking/registry.js.map +1 -1
- package/dist/tracking/types.d.ts +1 -0
- package/dist/tracking/types.d.ts.map +1 -1
- package/dist/tracking/types.js.map +1 -1
- package/dist/triggers/actions/list-automations.d.ts +7 -0
- package/dist/triggers/actions/list-automations.d.ts.map +1 -1
- package/dist/triggers/actions/list-automations.js +29 -41
- package/dist/triggers/actions/list-automations.js.map +1 -1
- package/dist/triggers/actions/manage-automation.js +15 -33
- package/dist/triggers/actions/manage-automation.js.map +1 -1
- package/dist/triggers/actions.d.ts.map +1 -1
- package/dist/triggers/actions.js +184 -95
- package/dist/triggers/actions.js.map +1 -1
- package/dist/triggers/dispatcher.d.ts +3 -9
- package/dist/triggers/dispatcher.d.ts.map +1 -1
- package/dist/triggers/dispatcher.js +134 -304
- package/dist/triggers/dispatcher.js.map +1 -1
- package/dist/triggers/routes.d.ts.map +1 -1
- package/dist/triggers/routes.js +76 -17
- package/dist/triggers/routes.js.map +1 -1
- package/dist/triggers/types.d.ts +4 -23
- package/dist/triggers/types.d.ts.map +1 -1
- package/dist/triggers/types.js.map +1 -1
- package/docs/content/agent-surfaces.mdx +4 -4
- package/docs/content/automations.mdx +61 -12
- package/docs/content/deployment.mdx +11 -4
- package/docs/content/extensions.mdx +39 -33
- package/docs/content/recurring-jobs.mdx +41 -19
- package/docs/content/template-dispatch-operations.mdx +19 -7
- package/package.json +4 -2
- package/src/a2a/types.ts +6 -0
- package/src/action.ts +68 -0
- package/src/agent/engine/builder-engine.ts +8 -4
- package/src/agent/production-agent.ts +175 -100
- package/src/agent/tool-search.ts +36 -0
- package/src/automations/service.ts +506 -0
- package/src/browser-context/index.ts +392 -0
- package/src/client/AgentPanel.tsx +2 -1
- package/src/client/FeedbackButton.tsx +37 -4
- package/src/client/MultiTabAssistantChat.tsx +21 -0
- package/src/client/agent-chat.ts +31 -3
- package/src/client/agent-page/AgentJobsTab.tsx +438 -310
- package/src/client/agent-page/AgentTabsPage.tsx +4 -4
- package/src/client/agent-page/use-jobs.ts +7 -0
- package/src/client/analytics-session.ts +13 -0
- package/src/client/extensions/ExtensionViewer.tsx +67 -0
- package/src/client/settings/AutomationsSection.tsx +27 -499
- package/src/client/settings/SettingsPanel.tsx +32 -11
- package/src/client/settings/index.ts +2 -0
- package/src/client/use-agent-chat.ts +35 -3
- package/src/client/use-chat-threads.ts +8 -25
- package/src/deploy/build.ts +2 -0
- package/src/deploy/workspace-deploy.ts +2 -0
- package/src/extensions/actions.ts +115 -3
- package/src/extensions/fetch-tool.ts +11 -0
- package/src/extensions/routes.ts +16 -1
- package/src/extensions/web-content.ts +96 -1
- package/src/integrations/computer-supervision.ts +33 -1
- package/src/integrations/index.ts +6 -0
- package/src/integrations/integration-durable-dispatch-config.ts +10 -0
- package/src/integrations/integration-durable-dispatch.ts +4 -0
- package/src/integrations/plugin.ts +94 -41
- package/src/integrations/remote-browser-actions.ts +621 -0
- package/src/jobs/actions/list-recurring-jobs.ts +5 -7
- package/src/jobs/actions/manage-recurring-job.ts +3 -7
- package/src/jobs/background-automation-runner.ts +437 -0
- package/src/jobs/frontmatter.ts +308 -0
- package/src/jobs/scheduler.ts +89 -598
- package/src/jobs/tools.ts +22 -3
- package/src/localization/default-messages.ts +45 -45
- package/src/mcp-client/index.ts +6 -0
- package/src/notifications/actions.ts +5 -0
- package/src/progress/actions.ts +5 -0
- package/src/provider-api/actions/github-repo-files.ts +11 -0
- package/src/provider-api/actions/provider-api.ts +13 -0
- package/src/server/__snapshots__/agent-chat-plugin.surface.spec.ts.snap +4 -4
- package/src/server/action-discovery.ts +7 -0
- package/src/server/agent-capabilities.ts +43 -8
- package/src/server/agent-chat/action-filters-a2a.ts +63 -1
- package/src/server/agent-chat/browser-team-tools.ts +126 -3
- package/src/server/agent-chat/framework-prompts.ts +7 -11
- package/src/server/agent-chat/plugin-options.ts +3 -3
- package/src/server/agent-chat/script-entries.ts +52 -1
- package/src/server/agent-chat-plugin.ts +25 -5
- package/src/server/attribution.ts +22 -0
- package/src/server/auth.ts +20 -6
- package/src/server/better-auth-instance.ts +10 -2
- package/src/server/core-routes-plugin.ts +10 -1
- package/src/server/csrf.ts +25 -0
- package/src/server/google-oauth.ts +21 -1
- package/src/server/onboarding-html.ts +18 -0
- package/src/server/prompts/framework-core-compact.ts +3 -3
- package/src/server/prompts/framework-core.ts +3 -3
- package/src/server/prompts/shared-rules.ts +3 -3
- package/src/settings/index.ts +1 -0
- package/src/shared/analytics-anonymous-id.ts +35 -0
- package/src/templates/chat/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/src/templates/chat/app/components/layout/Sidebar.tsx +1 -5
- package/src/templates/chat/changelog/2026-07-29-sidebar-footers-now-keep-feedback-search-and-collapse-togeth.md +6 -0
- package/src/templates/default/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/src/templates/default/app/i18n/ar-SA.ts +26 -0
- package/src/templates/default/app/i18n/de-DE.ts +28 -0
- package/src/templates/default/app/i18n/en-US.ts +27 -0
- package/src/templates/default/app/i18n/es-ES.ts +28 -0
- package/src/templates/default/app/i18n/fr-FR.ts +28 -0
- package/src/templates/default/app/i18n/hi-IN.ts +25 -0
- package/src/templates/default/app/i18n/ja-JP.ts +27 -0
- package/src/templates/default/app/i18n/ko-KR.ts +27 -0
- package/src/templates/default/app/i18n/pt-BR.ts +27 -0
- package/src/templates/default/app/i18n/zh-CN.ts +24 -0
- package/src/templates/default/app/i18n/zh-TW.ts +24 -0
- package/src/templates/headless/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/src/templates/workspace-core/.agents/skills/agent-native-toolkit/SKILL.md +5 -0
- package/src/templates/workspace-core/.agents/skills/agent-page/SKILL.md +10 -7
- package/src/templates/workspace-core/.agents/skills/automations/SKILL.md +53 -8
- package/src/templates/workspace-core/.agents/skills/browser-sessions/SKILL.md +131 -0
- package/src/templates/workspace-core/.agents/skills/extension-points/SKILL.md +13 -4
- package/src/templates/workspace-core/.agents/skills/extensions/SKILL.md +23 -15
- package/src/templates/workspace-core/.agents/skills/recurring-jobs/SKILL.md +33 -18
- package/src/tracking/providers.ts +1 -0
- package/src/tracking/registry.ts +2 -1
- package/src/tracking/types.ts +1 -0
- package/src/triggers/actions/list-automations.ts +43 -44
- package/src/triggers/actions/manage-automation.ts +17 -48
- package/src/triggers/actions.ts +218 -127
- package/src/triggers/dispatcher.ts +181 -367
- package/src/triggers/routes.ts +84 -27
- package/src/triggers/types.ts +9 -23
package/dist/triggers/routes.js
CHANGED
|
@@ -1,14 +1,23 @@
|
|
|
1
1
|
import { defineEventHandler, getMethod, setResponseStatus, } from "h3";
|
|
2
|
+
import { canUpdateAutomationResource } from "../automations/service.js";
|
|
2
3
|
import { getDbExec } from "../db/client.js";
|
|
3
4
|
import { nextOccurrence, describeCron, isValidCron } from "../jobs/cron.js";
|
|
5
|
+
import { buildJobResourceContent, parseJobResource, } from "../jobs/frontmatter.js";
|
|
4
6
|
import { getOrgContext } from "../org/context.js";
|
|
5
|
-
import { resourceGetByPath, resourceListAllOwners, resourcePut, SHARED_OWNER, } from "../resources/store.js";
|
|
7
|
+
import { organizationIdFromResourceOwner, organizationResourceOwner, resourceGetByPath, resourceListAllOwners, resourcePut, SHARED_OWNER, } from "../resources/store.js";
|
|
6
8
|
import { getSession } from "../server/auth.js";
|
|
7
9
|
import { readBody } from "../server/h3-helpers.js";
|
|
8
|
-
import {
|
|
10
|
+
import { refreshEventSubscriptions } from "./dispatcher.js";
|
|
9
11
|
function automationName(path) {
|
|
10
12
|
return path.replace(/^jobs\//, "").replace(/\.md$/, "");
|
|
11
13
|
}
|
|
14
|
+
function asTriggerFrontmatter(meta) {
|
|
15
|
+
return {
|
|
16
|
+
...meta,
|
|
17
|
+
triggerType: meta.triggerType ?? "schedule",
|
|
18
|
+
mode: meta.mode ?? "agentic",
|
|
19
|
+
};
|
|
20
|
+
}
|
|
12
21
|
function normalizeAutomationPath(input) {
|
|
13
22
|
const rawPath = input.path ?? (input.name ? `jobs/${input.name}.md` : "");
|
|
14
23
|
const path = rawPath.replace(/^\/+/, "");
|
|
@@ -48,11 +57,31 @@ function nextRunForMeta(meta) {
|
|
|
48
57
|
}
|
|
49
58
|
return undefined;
|
|
50
59
|
}
|
|
51
|
-
async function currentUserCanUpdateAutomation(event, userEmail,
|
|
60
|
+
async function currentUserCanUpdateAutomation(event, userEmail, resource, meta) {
|
|
61
|
+
const resourceOwner = resource.owner;
|
|
52
62
|
if (resourceOwner === userEmail)
|
|
53
63
|
return true;
|
|
64
|
+
const resourceOrgId = organizationIdFromResourceOwner(resourceOwner);
|
|
65
|
+
if (resourceOrgId) {
|
|
66
|
+
try {
|
|
67
|
+
const org = await getOrgContext(event);
|
|
68
|
+
if (org.orgId !== resourceOrgId)
|
|
69
|
+
return false;
|
|
70
|
+
return await canUpdateAutomationResource({ userEmail, orgId: resourceOrgId }, resource);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
54
76
|
if (resourceOwner !== SHARED_OWNER)
|
|
55
77
|
return false;
|
|
78
|
+
if (meta.orgId) {
|
|
79
|
+
const activeOrgId = await getOrgContext(event)
|
|
80
|
+
.then((context) => context.orgId)
|
|
81
|
+
.catch(() => null);
|
|
82
|
+
if (activeOrgId !== meta.orgId)
|
|
83
|
+
return false;
|
|
84
|
+
}
|
|
56
85
|
if (meta.createdBy &&
|
|
57
86
|
meta.createdBy.toLowerCase() === userEmail.toLowerCase()) {
|
|
58
87
|
return true;
|
|
@@ -81,13 +110,14 @@ async function currentUserCanUpdateAutomation(event, userEmail, resourceOwner, m
|
|
|
81
110
|
}
|
|
82
111
|
}
|
|
83
112
|
async function resourceToAutomationItem(event, userEmail, resource) {
|
|
84
|
-
const
|
|
113
|
+
const parsed = parseJobResource(resource.content);
|
|
114
|
+
const meta = asTriggerFrontmatter(parsed.meta);
|
|
85
115
|
return {
|
|
86
116
|
id: resource.id,
|
|
87
117
|
name: automationName(resource.path),
|
|
88
118
|
path: resource.path,
|
|
89
119
|
owner: resource.owner,
|
|
90
|
-
canUpdate: await currentUserCanUpdateAutomation(event, userEmail, resource
|
|
120
|
+
canUpdate: await currentUserCanUpdateAutomation(event, userEmail, resource, meta),
|
|
91
121
|
triggerType: meta.triggerType,
|
|
92
122
|
event: meta.event,
|
|
93
123
|
schedule: meta.schedule || undefined,
|
|
@@ -101,14 +131,31 @@ async function resourceToAutomationItem(event, userEmail, resource) {
|
|
|
101
131
|
lastError: meta.lastError,
|
|
102
132
|
nextRun: nextRunForMeta(meta),
|
|
103
133
|
createdBy: meta.createdBy,
|
|
104
|
-
body,
|
|
134
|
+
body: parsed.body,
|
|
105
135
|
};
|
|
106
136
|
}
|
|
107
137
|
export async function listAutomationsForOwner(event, userEmail) {
|
|
108
138
|
const allResources = await resourceListAllOwners("jobs/");
|
|
109
|
-
const
|
|
110
|
-
|
|
111
|
-
|
|
139
|
+
const activeOrgId = await getOrgContext(event)
|
|
140
|
+
.then((context) => context.orgId)
|
|
141
|
+
.catch(() => null);
|
|
142
|
+
const activeOrgOwner = activeOrgId
|
|
143
|
+
? organizationResourceOwner(activeOrgId)
|
|
144
|
+
: null;
|
|
145
|
+
const resources = allResources.filter((resource) => {
|
|
146
|
+
if (!resource.path.endsWith(".md") || resource.path.endsWith(".keep")) {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
if (resource.owner !== userEmail &&
|
|
150
|
+
resource.owner !== SHARED_OWNER &&
|
|
151
|
+
resource.owner !== activeOrgOwner) {
|
|
152
|
+
return false;
|
|
153
|
+
}
|
|
154
|
+
if (resource.owner !== SHARED_OWNER)
|
|
155
|
+
return true;
|
|
156
|
+
const { meta } = parseJobResource(resource.content);
|
|
157
|
+
return !meta.orgId || meta.orgId === activeOrgId;
|
|
158
|
+
});
|
|
112
159
|
return Promise.all(resources.map((resource) => resourceToAutomationItem(event, userEmail, resource)));
|
|
113
160
|
}
|
|
114
161
|
export async function setAutomationEnabledForOwner(event, userEmail, input) {
|
|
@@ -118,28 +165,40 @@ export async function setAutomationEnabledForOwner(event, userEmail, input) {
|
|
|
118
165
|
});
|
|
119
166
|
}
|
|
120
167
|
const path = normalizeAutomationPath(input);
|
|
121
|
-
const
|
|
168
|
+
const activeOrgId = await getOrgContext(event)
|
|
169
|
+
.then((context) => context.orgId)
|
|
170
|
+
.catch(() => null);
|
|
171
|
+
const activeOrgOwner = activeOrgId
|
|
172
|
+
? organizationResourceOwner(activeOrgId)
|
|
173
|
+
: null;
|
|
174
|
+
const requestedOwner = input.owner === SHARED_OWNER
|
|
175
|
+
? SHARED_OWNER
|
|
176
|
+
: input.owner === activeOrgOwner
|
|
177
|
+
? activeOrgOwner
|
|
178
|
+
: userEmail;
|
|
122
179
|
const resource = await resourceGetByPath(requestedOwner, path);
|
|
123
180
|
if (!resource) {
|
|
124
181
|
throw Object.assign(new Error("Automation not found"), { statusCode: 404 });
|
|
125
182
|
}
|
|
126
|
-
const
|
|
127
|
-
const
|
|
183
|
+
const parsed = parseJobResource(resource.content);
|
|
184
|
+
const meta = asTriggerFrontmatter(parsed.meta);
|
|
185
|
+
const allowed = await currentUserCanUpdateAutomation(event, userEmail, resource, meta);
|
|
128
186
|
if (!allowed) {
|
|
129
187
|
throw Object.assign(new Error("Only the automation creator or an org admin can update it."), { statusCode: 403 });
|
|
130
188
|
}
|
|
131
|
-
meta.enabled = input.enabled;
|
|
132
|
-
if (meta.enabled &&
|
|
189
|
+
parsed.meta.enabled = input.enabled;
|
|
190
|
+
if (parsed.meta.enabled &&
|
|
133
191
|
meta.triggerType !== "event" &&
|
|
134
192
|
meta.schedule &&
|
|
135
193
|
isValidCron(meta.schedule)) {
|
|
136
|
-
meta.nextRun = nextOccurrence(meta.schedule).toISOString();
|
|
194
|
+
parsed.meta.nextRun = nextOccurrence(meta.schedule).toISOString();
|
|
137
195
|
}
|
|
138
|
-
|
|
196
|
+
const updatedContent = buildJobResourceContent(parsed.meta, parsed.body);
|
|
197
|
+
await resourcePut(resource.owner, resource.path, updatedContent);
|
|
139
198
|
await refreshEventSubscriptions();
|
|
140
199
|
return resourceToAutomationItem(event, userEmail, {
|
|
141
200
|
...resource,
|
|
142
|
-
content:
|
|
201
|
+
content: updatedContent,
|
|
143
202
|
});
|
|
144
203
|
}
|
|
145
204
|
function routeError(event, err, fallback) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/triggers/routes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,iBAAiB,GAElB,MAAM,IAAI,CAAC;AAEZ,OAAO,EA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,OAAO,UAAU,CAAC,KAAK,EAAE,GAAG,EAAE,6BAA6B,CAAC,CAAC;YAC/D,CAAC;QACH,CAAC;QAED,iBAAiB,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;QAC9B,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAE,CAAC;IACzC,CAAC,CAAC,CAAC;AACL,CAAC","sourcesContent":["import {\n defineEventHandler,\n getMethod,\n setResponseStatus,\n type H3Event,\n} from \"h3\";\n\nimport { getDbExec } from \"../db/client.js\";\nimport { nextOccurrence, describeCron, isValidCron } from \"../jobs/cron.js\";\nimport { getOrgContext } from \"../org/context.js\";\nimport {\n resourceGetByPath,\n resourceListAllOwners,\n resourcePut,\n SHARED_OWNER,\n type Resource,\n} from \"../resources/store.js\";\nimport { getSession } from \"../server/auth.js\";\nimport { readBody } from \"../server/h3-helpers.js\";\nimport {\n buildTriggerContent,\n parseTriggerFrontmatter,\n refreshEventSubscriptions,\n} from \"./dispatcher.js\";\nimport type { TriggerFrontmatter } from \"./types.js\";\n\nexport interface AutomationRouteItem {\n id: string;\n name: string;\n path: string;\n owner: string;\n canUpdate: boolean;\n triggerType: TriggerFrontmatter[\"triggerType\"];\n event?: string;\n schedule?: string;\n scheduleDescription?: string;\n condition?: string;\n mode: TriggerFrontmatter[\"mode\"];\n domain?: string;\n enabled: boolean;\n lastStatus?: TriggerFrontmatter[\"lastStatus\"];\n lastRun?: string;\n lastError?: string;\n nextRun?: string;\n createdBy?: string;\n body: string;\n}\n\ninterface SetAutomationEnabledInput {\n owner?: string;\n path?: string;\n name?: string;\n enabled: boolean;\n}\n\nfunction automationName(path: string): string {\n return path.replace(/^jobs\\//, \"\").replace(/\\.md$/, \"\");\n}\n\nfunction normalizeAutomationPath(input: SetAutomationEnabledInput): string {\n const rawPath = input.path ?? (input.name ? `jobs/${input.name}.md` : \"\");\n const path = rawPath.replace(/^\\/+/, \"\");\n if (\n !path.startsWith(\"jobs/\") ||\n !path.endsWith(\".md\") ||\n path.endsWith(\".keep\") ||\n path.includes(\"..\")\n ) {\n throw Object.assign(\n new Error(\"A valid jobs/*.md automation path is required\"),\n {\n statusCode: 400,\n },\n );\n }\n return path;\n}\n\nfunction scheduleDescription(schedule: string | undefined): string | undefined {\n if (!schedule) return undefined;\n try {\n return describeCron(schedule);\n } catch {\n return schedule;\n }\n}\n\nfunction nextRunForMeta(meta: TriggerFrontmatter): string | undefined {\n if (meta.nextRun) return meta.nextRun;\n if (\n meta.enabled &&\n meta.triggerType !== \"event\" &&\n meta.schedule &&\n isValidCron(meta.schedule)\n ) {\n try {\n return nextOccurrence(meta.schedule).toISOString();\n } catch {\n return undefined;\n }\n }\n return undefined;\n}\n\nasync function currentUserCanUpdateAutomation(\n event: H3Event,\n userEmail: string,\n resourceOwner: string,\n meta: TriggerFrontmatter,\n): Promise<boolean> {\n if (resourceOwner === userEmail) return true;\n if (resourceOwner !== SHARED_OWNER) return false;\n\n if (\n meta.createdBy &&\n meta.createdBy.toLowerCase() === userEmail.toLowerCase()\n ) {\n return true;\n }\n\n let orgId = meta.orgId;\n if (!orgId) {\n try {\n orgId = (await getOrgContext(event)).orgId ?? undefined;\n } catch {\n orgId = undefined;\n }\n }\n if (!orgId) return false;\n\n try {\n const { rows } = await getDbExec().execute({\n sql: `SELECT role FROM org_members WHERE org_id = ? AND LOWER(email) = ? LIMIT 1`,\n args: [orgId, userEmail.toLowerCase()],\n });\n const role = String((rows[0] as any)?.role ?? \"\").toLowerCase();\n return role === \"owner\" || role === \"admin\";\n } catch {\n return false;\n }\n}\n\nasync function resourceToAutomationItem(\n event: H3Event,\n userEmail: string,\n resource: Resource,\n): Promise<AutomationRouteItem> {\n const { meta, body } = parseTriggerFrontmatter(resource.content);\n return {\n id: resource.id,\n name: automationName(resource.path),\n path: resource.path,\n owner: resource.owner,\n canUpdate: await currentUserCanUpdateAutomation(\n event,\n userEmail,\n resource.owner,\n meta,\n ),\n triggerType: meta.triggerType,\n event: meta.event,\n schedule: meta.schedule || undefined,\n scheduleDescription: scheduleDescription(meta.schedule),\n condition: meta.condition,\n mode: meta.mode,\n domain: meta.domain,\n enabled: meta.enabled,\n lastStatus: meta.lastStatus,\n lastRun: meta.lastRun,\n lastError: meta.lastError,\n nextRun: nextRunForMeta(meta),\n createdBy: meta.createdBy,\n body,\n };\n}\n\nexport async function listAutomationsForOwner(\n event: H3Event,\n userEmail: string,\n): Promise<AutomationRouteItem[]> {\n const allResources = await resourceListAllOwners(\"jobs/\");\n const resources = allResources.filter(\n (resource) =>\n (resource.owner === userEmail || resource.owner === SHARED_OWNER) &&\n resource.path.endsWith(\".md\") &&\n !resource.path.endsWith(\".keep\"),\n );\n return Promise.all(\n resources.map((resource) =>\n resourceToAutomationItem(event, userEmail, resource),\n ),\n );\n}\n\nexport async function setAutomationEnabledForOwner(\n event: H3Event,\n userEmail: string,\n input: SetAutomationEnabledInput,\n): Promise<AutomationRouteItem> {\n if (typeof input.enabled !== \"boolean\") {\n throw Object.assign(new Error(\"enabled must be a boolean\"), {\n statusCode: 400,\n });\n }\n\n const path = normalizeAutomationPath(input);\n const requestedOwner =\n input.owner === SHARED_OWNER ? SHARED_OWNER : userEmail;\n const resource = await resourceGetByPath(requestedOwner, path);\n if (!resource) {\n throw Object.assign(new Error(\"Automation not found\"), { statusCode: 404 });\n }\n\n const { meta, body } = parseTriggerFrontmatter(resource.content);\n const allowed = await currentUserCanUpdateAutomation(\n event,\n userEmail,\n resource.owner,\n meta,\n );\n if (!allowed) {\n throw Object.assign(\n new Error(\"Only the automation creator or an org admin can update it.\"),\n { statusCode: 403 },\n );\n }\n\n meta.enabled = input.enabled;\n if (\n meta.enabled &&\n meta.triggerType !== \"event\" &&\n meta.schedule &&\n isValidCron(meta.schedule)\n ) {\n meta.nextRun = nextOccurrence(meta.schedule).toISOString();\n }\n\n await resourcePut(\n resource.owner,\n resource.path,\n buildTriggerContent(meta, body),\n );\n await refreshEventSubscriptions();\n\n return resourceToAutomationItem(event, userEmail, {\n ...resource,\n content: buildTriggerContent(meta, body),\n });\n}\n\nfunction routeError(event: H3Event, err: unknown, fallback: string) {\n const statusCode =\n typeof (err as any)?.statusCode === \"number\"\n ? (err as any).statusCode\n : 500;\n setResponseStatus(event, statusCode);\n return { error: (err as any)?.message ?? fallback };\n}\n\nexport function createAutomationsHandler() {\n return defineEventHandler(async (event: H3Event) => {\n const method = getMethod(event);\n const pathname = (event.path || event.url?.pathname || \"\")\n .split(\"?\")[0]\n .replace(/^\\/+/, \"\")\n .replace(/\\/+$/, \"\");\n\n const session = await getSession(event).catch(() => null);\n if (!session?.email) {\n setResponseStatus(event, 401);\n return { error: \"Unauthenticated\" };\n }\n\n if (\n (pathname === \"fire-test\" || pathname.endsWith(\"/fire-test\")) &&\n method === \"POST\"\n ) {\n try {\n const { emit } = await import(\"../event-bus/index.js\");\n const body = (await readBody(event).catch(() => ({}))) as Record<\n string,\n unknown\n >;\n emit(\n \"test.event.fired\",\n { data: body.data ?? {} },\n { owner: session.email },\n );\n return { ok: true };\n } catch (err) {\n return routeError(event, err, \"Failed to emit test event\");\n }\n }\n\n if (method === \"GET\") {\n try {\n return await listAutomationsForOwner(event, session.email);\n } catch (err) {\n return routeError(event, err, \"Failed to list automations\");\n }\n }\n\n if (method === \"PATCH\" || method === \"PUT\") {\n try {\n const body = (await readBody(event).catch(\n () => ({}),\n )) as SetAutomationEnabledInput | null;\n return await setAutomationEnabledForOwner(event, session.email, {\n owner: body?.owner,\n path: body?.path,\n name: body?.name,\n enabled: (body as any)?.enabled,\n } as SetAutomationEnabledInput);\n } catch (err) {\n return routeError(event, err, \"Failed to update automation\");\n }\n }\n\n setResponseStatus(event, 405);\n return { error: \"Method not allowed\" };\n });\n}\n"]}
|
|
1
|
+
{"version":3,"file":"routes.js","sourceRoot":"","sources":["../../src/triggers/routes.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,SAAS,EACT,iBAAiB,GAElB,MAAM,IAAI,CAAC;AAEZ,OAAO,EAAE,2BAA2B,EAAE,MAAM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setResponseStatus,\n type H3Event,\n} from \"h3\";\n\nimport { canUpdateAutomationResource } from \"../automations/service.js\";\nimport { getDbExec } from \"../db/client.js\";\nimport { nextOccurrence, describeCron, isValidCron } from \"../jobs/cron.js\";\nimport {\n buildJobResourceContent,\n parseJobResource,\n type JobFrontmatter,\n} from \"../jobs/frontmatter.js\";\nimport { getOrgContext } from \"../org/context.js\";\nimport {\n organizationIdFromResourceOwner,\n organizationResourceOwner,\n resourceGetByPath,\n resourceListAllOwners,\n resourcePut,\n SHARED_OWNER,\n type Resource,\n} from \"../resources/store.js\";\nimport { getSession } from \"../server/auth.js\";\nimport { readBody } from \"../server/h3-helpers.js\";\nimport { refreshEventSubscriptions } from \"./dispatcher.js\";\nimport type { TriggerFrontmatter } from \"./types.js\";\n\nexport interface AutomationRouteItem {\n id: string;\n name: string;\n path: string;\n owner: string;\n canUpdate: boolean;\n triggerType: TriggerFrontmatter[\"triggerType\"];\n event?: string;\n schedule?: string;\n scheduleDescription?: string;\n condition?: string;\n mode: TriggerFrontmatter[\"mode\"];\n domain?: string;\n enabled: boolean;\n lastStatus?: TriggerFrontmatter[\"lastStatus\"];\n lastRun?: string;\n lastError?: string;\n nextRun?: string;\n createdBy?: string;\n body: string;\n}\n\ninterface SetAutomationEnabledInput {\n owner?: string;\n path?: string;\n name?: string;\n enabled: boolean;\n}\n\nfunction automationName(path: string): string {\n return path.replace(/^jobs\\//, \"\").replace(/\\.md$/, \"\");\n}\n\nfunction asTriggerFrontmatter(meta: JobFrontmatter): TriggerFrontmatter {\n return {\n ...meta,\n triggerType: meta.triggerType ?? \"schedule\",\n mode: meta.mode ?? \"agentic\",\n };\n}\n\nfunction normalizeAutomationPath(input: SetAutomationEnabledInput): string {\n const rawPath = input.path ?? (input.name ? `jobs/${input.name}.md` : \"\");\n const path = rawPath.replace(/^\\/+/, \"\");\n if (\n !path.startsWith(\"jobs/\") ||\n !path.endsWith(\".md\") ||\n path.endsWith(\".keep\") ||\n path.includes(\"..\")\n ) {\n throw Object.assign(\n new Error(\"A valid jobs/*.md automation path is required\"),\n {\n statusCode: 400,\n },\n );\n }\n return path;\n}\n\nfunction scheduleDescription(schedule: string | undefined): string | undefined {\n if (!schedule) return undefined;\n try {\n return describeCron(schedule);\n } catch {\n return schedule;\n }\n}\n\nfunction nextRunForMeta(meta: TriggerFrontmatter): string | undefined {\n if (meta.nextRun) return meta.nextRun;\n if (\n meta.enabled &&\n meta.triggerType !== \"event\" &&\n meta.schedule &&\n isValidCron(meta.schedule)\n ) {\n try {\n return nextOccurrence(meta.schedule).toISOString();\n } catch {\n return undefined;\n }\n }\n return undefined;\n}\n\nasync function currentUserCanUpdateAutomation(\n event: H3Event,\n userEmail: string,\n resource: Resource,\n meta: TriggerFrontmatter,\n): Promise<boolean> {\n const resourceOwner = resource.owner;\n if (resourceOwner === userEmail) return true;\n const resourceOrgId = organizationIdFromResourceOwner(resourceOwner);\n if (resourceOrgId) {\n try {\n const org = await getOrgContext(event);\n if (org.orgId !== resourceOrgId) return false;\n return await canUpdateAutomationResource(\n { userEmail, orgId: resourceOrgId },\n resource,\n );\n } catch {\n return false;\n }\n }\n if (resourceOwner !== SHARED_OWNER) return false;\n\n if (meta.orgId) {\n const activeOrgId = await getOrgContext(event)\n .then((context) => context.orgId)\n .catch(() => null);\n if (activeOrgId !== meta.orgId) return false;\n }\n\n if (\n meta.createdBy &&\n meta.createdBy.toLowerCase() === userEmail.toLowerCase()\n ) {\n return true;\n }\n\n let orgId = meta.orgId;\n if (!orgId) {\n try {\n orgId = (await getOrgContext(event)).orgId ?? undefined;\n } catch {\n orgId = undefined;\n }\n }\n if (!orgId) return false;\n\n try {\n const { rows } = await getDbExec().execute({\n sql: `SELECT role FROM org_members WHERE org_id = ? AND LOWER(email) = ? LIMIT 1`,\n args: [orgId, userEmail.toLowerCase()],\n });\n const role = String((rows[0] as any)?.role ?? \"\").toLowerCase();\n return role === \"owner\" || role === \"admin\";\n } catch {\n return false;\n }\n}\n\nasync function resourceToAutomationItem(\n event: H3Event,\n userEmail: string,\n resource: Resource,\n): Promise<AutomationRouteItem> {\n const parsed = parseJobResource(resource.content);\n const meta = asTriggerFrontmatter(parsed.meta);\n return {\n id: resource.id,\n name: automationName(resource.path),\n path: resource.path,\n owner: resource.owner,\n canUpdate: await currentUserCanUpdateAutomation(\n event,\n userEmail,\n resource,\n meta,\n ),\n triggerType: meta.triggerType,\n event: meta.event,\n schedule: meta.schedule || undefined,\n scheduleDescription: scheduleDescription(meta.schedule),\n condition: meta.condition,\n mode: meta.mode,\n domain: meta.domain,\n enabled: meta.enabled,\n lastStatus: meta.lastStatus,\n lastRun: meta.lastRun,\n lastError: meta.lastError,\n nextRun: nextRunForMeta(meta),\n createdBy: meta.createdBy,\n body: parsed.body,\n };\n}\n\nexport async function listAutomationsForOwner(\n event: H3Event,\n userEmail: string,\n): Promise<AutomationRouteItem[]> {\n const allResources = await resourceListAllOwners(\"jobs/\");\n const activeOrgId = await getOrgContext(event)\n .then((context) => context.orgId)\n .catch(() => null);\n const activeOrgOwner = activeOrgId\n ? organizationResourceOwner(activeOrgId)\n : null;\n const resources = allResources.filter((resource) => {\n if (!resource.path.endsWith(\".md\") || resource.path.endsWith(\".keep\")) {\n return false;\n }\n if (\n resource.owner !== userEmail &&\n resource.owner !== SHARED_OWNER &&\n resource.owner !== activeOrgOwner\n ) {\n return false;\n }\n if (resource.owner !== SHARED_OWNER) return true;\n const { meta } = parseJobResource(resource.content);\n return !meta.orgId || meta.orgId === activeOrgId;\n });\n return Promise.all(\n resources.map((resource) =>\n resourceToAutomationItem(event, userEmail, resource),\n ),\n );\n}\n\nexport async function setAutomationEnabledForOwner(\n event: H3Event,\n userEmail: string,\n input: SetAutomationEnabledInput,\n): Promise<AutomationRouteItem> {\n if (typeof input.enabled !== \"boolean\") {\n throw Object.assign(new Error(\"enabled must be a boolean\"), {\n statusCode: 400,\n });\n }\n\n const path = normalizeAutomationPath(input);\n const activeOrgId = await getOrgContext(event)\n .then((context) => context.orgId)\n .catch(() => null);\n const activeOrgOwner = activeOrgId\n ? organizationResourceOwner(activeOrgId)\n : null;\n const requestedOwner =\n input.owner === SHARED_OWNER\n ? SHARED_OWNER\n : input.owner === activeOrgOwner\n ? activeOrgOwner\n : userEmail;\n const resource = await resourceGetByPath(requestedOwner, path);\n if (!resource) {\n throw Object.assign(new Error(\"Automation not found\"), { statusCode: 404 });\n }\n\n const parsed = parseJobResource(resource.content);\n const meta = asTriggerFrontmatter(parsed.meta);\n const allowed = await currentUserCanUpdateAutomation(\n event,\n userEmail,\n resource,\n meta,\n );\n if (!allowed) {\n throw Object.assign(\n new Error(\"Only the automation creator or an org admin can update it.\"),\n { statusCode: 403 },\n );\n }\n\n parsed.meta.enabled = input.enabled;\n if (\n parsed.meta.enabled &&\n meta.triggerType !== \"event\" &&\n meta.schedule &&\n isValidCron(meta.schedule)\n ) {\n parsed.meta.nextRun = nextOccurrence(meta.schedule).toISOString();\n }\n\n const updatedContent = buildJobResourceContent(parsed.meta, parsed.body);\n await resourcePut(resource.owner, resource.path, updatedContent);\n await refreshEventSubscriptions();\n\n return resourceToAutomationItem(event, userEmail, {\n ...resource,\n content: updatedContent,\n });\n}\n\nfunction routeError(event: H3Event, err: unknown, fallback: string) {\n const statusCode =\n typeof (err as any)?.statusCode === \"number\"\n ? (err as any).statusCode\n : 500;\n setResponseStatus(event, statusCode);\n return { error: (err as any)?.message ?? fallback };\n}\n\nexport function createAutomationsHandler() {\n return defineEventHandler(async (event: H3Event) => {\n const method = getMethod(event);\n const pathname = (event.path || event.url?.pathname || \"\")\n .split(\"?\")[0]\n .replace(/^\\/+/, \"\")\n .replace(/\\/+$/, \"\");\n\n const session = await getSession(event).catch(() => null);\n if (!session?.email) {\n setResponseStatus(event, 401);\n return { error: \"Unauthenticated\" };\n }\n\n if (\n (pathname === \"fire-test\" || pathname.endsWith(\"/fire-test\")) &&\n method === \"POST\"\n ) {\n try {\n const { emit } = await import(\"../event-bus/index.js\");\n const body = (await readBody(event).catch(() => ({}))) as Record<\n string,\n unknown\n >;\n emit(\n \"test.event.fired\",\n { data: body.data ?? {} },\n { owner: session.email },\n );\n return { ok: true };\n } catch (err) {\n return routeError(event, err, \"Failed to emit test event\");\n }\n }\n\n if (method === \"GET\") {\n try {\n return await listAutomationsForOwner(event, session.email);\n } catch (err) {\n return routeError(event, err, \"Failed to list automations\");\n }\n }\n\n if (method === \"PATCH\" || method === \"PUT\") {\n try {\n const body = (await readBody(event).catch(\n () => ({}),\n )) as SetAutomationEnabledInput | null;\n return await setAutomationEnabledForOwner(event, session.email, {\n owner: body?.owner,\n path: body?.path,\n name: body?.name,\n enabled: (body as any)?.enabled,\n } as SetAutomationEnabledInput);\n } catch (err) {\n return routeError(event, err, \"Failed to update automation\");\n }\n }\n\n setResponseStatus(event, 405);\n return { error: \"Method not allowed\" };\n });\n}\n"]}
|
package/dist/triggers/types.d.ts
CHANGED
|
@@ -5,15 +5,10 @@
|
|
|
5
5
|
* and scheduler infrastructure. Event-triggered jobs are skipped by the
|
|
6
6
|
* cron scheduler and dispatched by the event bus instead.
|
|
7
7
|
*/
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
enabled: boolean;
|
|
8
|
+
import type { JobExecutionMode, JobFrontmatter, JobTriggerType } from "../jobs/frontmatter.js";
|
|
9
|
+
export interface TriggerFrontmatter extends JobFrontmatter {
|
|
11
10
|
/** "schedule" = cron-based (legacy jobs). "event" = fires on bus event. */
|
|
12
|
-
triggerType:
|
|
13
|
-
/** For event triggers: the event name to subscribe to. */
|
|
14
|
-
event?: string;
|
|
15
|
-
/** Natural-language condition evaluated by Haiku before dispatch. */
|
|
16
|
-
condition?: string;
|
|
11
|
+
triggerType: JobTriggerType;
|
|
17
12
|
/**
|
|
18
13
|
* "agentic" = full runAgentLoop; the only mode `manage-automations` will
|
|
19
14
|
* define/update going forward. "deterministic" was removed from the
|
|
@@ -21,21 +16,7 @@ export interface TriggerFrontmatter {
|
|
|
21
16
|
* before the removal may still carry it, and the dispatcher's
|
|
22
17
|
* warn-and-skip branch keeps them inert by design — do not make them fire.
|
|
23
18
|
*/
|
|
24
|
-
mode:
|
|
25
|
-
/** Domain tag for filtering in per-template UIs. */
|
|
26
|
-
domain?: string;
|
|
27
|
-
/**
|
|
28
|
-
* Optional application-owned policy id carried into actions by the trusted
|
|
29
|
-
* trigger dispatcher. It is not model-supplied action input.
|
|
30
|
-
*/
|
|
31
|
-
delegatedPolicyId?: string;
|
|
32
|
-
createdBy?: string;
|
|
33
|
-
orgId?: string;
|
|
34
|
-
runAs?: "creator" | "shared";
|
|
35
|
-
lastRun?: string;
|
|
36
|
-
lastStatus?: "success" | "error" | "running" | "skipped";
|
|
37
|
-
lastError?: string;
|
|
38
|
-
nextRun?: string;
|
|
19
|
+
mode: JobExecutionMode;
|
|
39
20
|
}
|
|
40
21
|
export interface TriggerDispatchContext {
|
|
41
22
|
triggerName: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/triggers/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/triggers/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EACV,gBAAgB,EAChB,cAAc,EACd,cAAc,EACf,MAAM,wBAAwB,CAAC;AAEhC,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,2EAA2E;IAC3E,WAAW,EAAE,cAAc,CAAC;IAC5B;;;;;;OAMG;IACH,IAAI,EAAE,gBAAgB,CAAC;CACxB;AAED,MAAM,WAAW,sBAAsB;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,kBAAkB,CAAC;IACzB,YAAY,CAAC,EAAE,OAAO,CAAC;CACxB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/triggers/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG","sourcesContent":["/**\n * Extended frontmatter for triggers (superset of JobFrontmatter).\n *\n * Stored as markdown resources under `jobs/` — reuses the same storage\n * and scheduler infrastructure. Event-triggered jobs are skipped by the\n * cron scheduler and dispatched by the event bus instead.\n */\n\
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/triggers/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG","sourcesContent":["/**\n * Extended frontmatter for triggers (superset of JobFrontmatter).\n *\n * Stored as markdown resources under `jobs/` — reuses the same storage\n * and scheduler infrastructure. Event-triggered jobs are skipped by the\n * cron scheduler and dispatched by the event bus instead.\n */\n\nimport type {\n JobExecutionMode,\n JobFrontmatter,\n JobTriggerType,\n} from \"../jobs/frontmatter.js\";\n\nexport interface TriggerFrontmatter extends JobFrontmatter {\n /** \"schedule\" = cron-based (legacy jobs). \"event\" = fires on bus event. */\n triggerType: JobTriggerType;\n /**\n * \"agentic\" = full runAgentLoop; the only mode `manage-automations` will\n * define/update going forward. \"deterministic\" was removed from the\n * advertised surface (never implemented) and is legacy-only: rows created\n * before the removal may still carry it, and the dispatcher's\n * warn-and-skip branch keeps them inert by design — do not make them fire.\n */\n mode: JobExecutionMode;\n}\n\nexport interface TriggerDispatchContext {\n triggerName: string;\n triggerBody: string;\n meta: TriggerFrontmatter;\n eventPayload?: unknown;\n}\n"]}
|
|
@@ -59,7 +59,7 @@ The shared page currently provides twelve tabs across two groups:
|
|
|
59
59
|
| Resources | **Remote agents** | A2A connections to other agent-native apps — this replaces what the Connections tab used to also show |
|
|
60
60
|
| Agent | **Snapshots** | A scope preview, token budget, ordered system sections grouped by provenance/governance/source, and the latest live-thread snapshot. Renamed from "Context"; old `#context` links redirect here. |
|
|
61
61
|
| Agent | **Connections** | MCP server management only |
|
|
62
|
-
| Agent | **
|
|
62
|
+
| Agent | **Automations** | Personal and organization Scheduled/Event automations with pause/resume, details, and delete flows. The stable compatibility URL remains `/agent#jobs`. |
|
|
63
63
|
| Agent | **Settings** | Agent model, API keys, limits, voice, and automation settings |
|
|
64
64
|
| Agent | **Access** | The app MCP URL, an A2A agent card when available, and shared setup guides for Claude, ChatGPT, Cursor, Claude Code, Codex, and other clients. Links to `/mcp/connect` for the full connect flow and token fallback. |
|
|
65
65
|
|
|
@@ -165,9 +165,9 @@ is no "browse-everything-at-a-glance" view; if users need that, start from
|
|
|
165
165
|
|
|
166
166
|
When you add the built-in Chat shell, the framework provides five management
|
|
167
167
|
surfaces you don't have to build: **Chat** (the main input), **Resources**
|
|
168
|
-
(skills, memory, instructions, sub-agents, connected MCP servers,
|
|
169
|
-
|
|
170
|
-
|
|
168
|
+
(skills, memory, instructions, sub-agents, and connected MCP servers),
|
|
169
|
+
**Automations**, **Thread history**, and **Settings**. Those are usually enough
|
|
170
|
+
— talk to it, see what it's done, configure how it behaves. Reach for
|
|
171
171
|
[Chat](/docs/template-chat) when you're ready to add that browser UI, or the
|
|
172
172
|
[Dispatch template](/docs/template-dispatch) for a workspace-style starting
|
|
173
173
|
point with Slack/Telegram, scheduled jobs, and shared secrets out of the box.
|
|
@@ -5,9 +5,17 @@ description: "Event-triggered and scheduled automations with natural-language co
|
|
|
5
5
|
|
|
6
6
|
# Automations
|
|
7
7
|
|
|
8
|
-
An **automation** is
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
An **automation** is an agent-executed task that fires on a schedule or when an
|
|
9
|
+
event occurs: _when X happens, do Y_. **Scheduled** and **Event** are the two
|
|
10
|
+
trigger types, not separate products. The agent executes the instructions with
|
|
11
|
+
the same action and tool lifecycle as interactive chat; connected MCP access is
|
|
12
|
+
limited to the automation's explicit `mcpTools` allowlist.
|
|
13
|
+
|
|
14
|
+
The framework originally exposed scheduled automations as **Recurring Jobs**.
|
|
15
|
+
That name, the `jobs/<name>.md` storage path, and the `manage-jobs` tool remain
|
|
16
|
+
for compatibility. New product guidance uses **Automations** as the umbrella;
|
|
17
|
+
see [Recurring Jobs](/docs/recurring-jobs) when maintaining a legacy
|
|
18
|
+
schedule-only integration or working with scheduler internals.
|
|
11
19
|
|
|
12
20
|
<Diagram id="doc-block-jdto24" title="When X happens, do Y" summary="An event fires on the bus, an optional natural-language condition gates it, and the agent runs the automation body with full tool access.">
|
|
13
21
|
|
|
@@ -72,9 +80,21 @@ Event triggers can include a `condition` — a natural-language string evaluated
|
|
|
72
80
|
|
|
73
81
|
The agent discovers available events, confirms the plan, and writes the automation for you.
|
|
74
82
|
|
|
75
|
-
### From the
|
|
83
|
+
### From the Automations UI
|
|
84
|
+
|
|
85
|
+
Open **Automations** on the full-page Agent surface. It is the primary place to
|
|
86
|
+
view scheduled and event-triggered automations, inspect status, pause or resume
|
|
87
|
+
them, and delete them. Its compatibility URL remains `/agent#jobs`, so existing
|
|
88
|
+
links and bookmarks continue to work.
|
|
89
|
+
|
|
90
|
+
<Callout tone="info">
|
|
91
|
+
|
|
92
|
+
**Personal and organization automations use the same management surface.**
|
|
93
|
+
Organization event automations are visible to members but always run as their
|
|
94
|
+
creator. An administrator can manage the definition, but cannot change who it
|
|
95
|
+
runs as.
|
|
76
96
|
|
|
77
|
-
|
|
97
|
+
</Callout>
|
|
78
98
|
|
|
79
99
|
The third path — writing the `jobs/<name>.md` file by hand via `resourcePut` — works exactly as it does for [recurring jobs](/docs/recurring-jobs#creating). For an event-driven automation you add the event-trigger frontmatter below to that same file. An event-triggered job sets `schedule: ""` and supplies `triggerType: event`, an `event` name, and an optional `condition`:
|
|
80
100
|
|
|
@@ -124,6 +144,26 @@ Automations share every field in the [recurring-jobs frontmatter table](/docs/re
|
|
|
124
144
|
|
|
125
145
|
For an event trigger, `schedule` is `""` (empty); for a schedule trigger it carries the cron expression. The dispatcher also writes the same managed `lastRun` / `lastStatus` / `lastError` fields the scheduler does, plus a `"skipped"` status when a condition evaluates to false.
|
|
126
146
|
|
|
147
|
+
`model` selects a per-automation model. `mcpTools` is an explicit list of MCP
|
|
148
|
+
tool names such as `mcp__server__tool`. The shared execution runner exposes
|
|
149
|
+
only those configured MCP tools and fails clearly if a named tool or its
|
|
150
|
+
connected grant is unavailable.
|
|
151
|
+
|
|
152
|
+
### Organization execution identity {#organization-identity}
|
|
153
|
+
|
|
154
|
+
Organization Scheduled and Event automations are shared for visibility and
|
|
155
|
+
management, not execution identity:
|
|
156
|
+
|
|
157
|
+
- `createdBy` is required for an organization event automation, and `runAs` is
|
|
158
|
+
`creator`.
|
|
159
|
+
- Event automations match only events emitted for that creator. An
|
|
160
|
+
organization-scoped automation is not an organization-wide event broadcast.
|
|
161
|
+
- Organization administrators may update or delete the automation, but cannot
|
|
162
|
+
replace `createdBy` or retarget its identity.
|
|
163
|
+
- Before execution, the framework verifies that the creator still exists and
|
|
164
|
+
remains an organization member. If the creator was removed—or membership
|
|
165
|
+
cannot be verified—the automation does not run.
|
|
166
|
+
|
|
127
167
|
## The event bus {#event-bus}
|
|
128
168
|
|
|
129
169
|
Integrations register events at module load time. The bus validates payloads against [Standard Schema](https://standardschema.dev) definitions and dispatches to subscribers.
|
|
@@ -178,7 +218,9 @@ emit(
|
|
|
178
218
|
);
|
|
179
219
|
```
|
|
180
220
|
|
|
181
|
-
The `owner` in the emit metadata scopes which automations fire
|
|
221
|
+
The `owner` in the emit metadata scopes which automations fire. Personal and
|
|
222
|
+
organization event automations both require an exact match with their
|
|
223
|
+
`createdBy` identity.
|
|
182
224
|
|
|
183
225
|
## Conditions {#conditions}
|
|
184
226
|
|
|
@@ -247,7 +289,8 @@ Keys are ad-hoc secrets created by users or the agent for automation use (e.g. `
|
|
|
247
289
|
|
|
248
290
|
## Agent tools {#agent-tools}
|
|
249
291
|
|
|
250
|
-
|
|
292
|
+
Trigger-aware personal and organization operations use `manage-automations`
|
|
293
|
+
with an `action` parameter:
|
|
251
294
|
|
|
252
295
|
| Action | Purpose |
|
|
253
296
|
| ------------- | -------------------------------------------------------------------- |
|
|
@@ -260,6 +303,10 @@ All automation operations are accessed through a single `manage-automations` too
|
|
|
260
303
|
|
|
261
304
|
Additional tool: `web-request` — outbound HTTP with `${keys.NAME}` substitution.
|
|
262
305
|
|
|
306
|
+
`define` and `update` accept personal or organization `scope`, a `model`
|
|
307
|
+
override, and an `mcpTools` allowlist. `manage-jobs` remains the compatibility
|
|
308
|
+
tool for existing schedule-only integrations and delivery metadata.
|
|
309
|
+
|
|
263
310
|
## API endpoints {#api}
|
|
264
311
|
|
|
265
312
|
| Endpoint | Method | Description |
|
|
@@ -283,7 +330,7 @@ Confirm an automation's wiring and condition without waiting for a real provider
|
|
|
283
330
|
|
|
284
331
|
## How dispatch works {#dispatch}
|
|
285
332
|
|
|
286
|
-
<Diagram id="doc-block-1ee1cky" title="The dispatch path" summary="
|
|
333
|
+
<Diagram id="doc-block-1ee1cky" title="The dispatch path" summary="Event and schedule acquisition stay separate, then converge on one identity-checked background execution lifecycle.">
|
|
287
334
|
|
|
288
335
|
```html
|
|
289
336
|
<div class="disp">
|
|
@@ -299,7 +346,8 @@ Confirm an automation's wiring and condition without waiting for a real provider
|
|
|
299
346
|
<div class="diagram-card">
|
|
300
347
|
<span class="diagram-pill">scope</span
|
|
301
348
|
><small class="diagram-muted"
|
|
302
|
-
>
|
|
349
|
+
>match <code>createdBy</code> to the event owner; verify org
|
|
350
|
+
membership</small
|
|
303
351
|
>
|
|
304
352
|
</div>
|
|
305
353
|
<div class="diagram-arrow diagram-muted" aria-hidden="true">↓</div>
|
|
@@ -314,8 +362,8 @@ Confirm an automation's wiring and condition without waiting for a real provider
|
|
|
314
362
|
<div class="diagram-card accent">
|
|
315
363
|
<span class="diagram-pill accent">run</span
|
|
316
364
|
><small class="diagram-muted"
|
|
317
|
-
|
|
318
|
-
|
|
365
|
+
>shared runner resolves identity, model, MCP allowlist, continuation,
|
|
366
|
+
delivery, and usage</small
|
|
319
367
|
>
|
|
320
368
|
</div>
|
|
321
369
|
<div class="diagram-arrow diagram-muted" aria-hidden="true">↓</div>
|
|
@@ -380,6 +428,7 @@ notification to my webhook."_
|
|
|
380
428
|
|
|
381
429
|
```yaml filename="jobs/notify-on-plan-comment.md"
|
|
382
430
|
---
|
|
431
|
+
schedule: ""
|
|
383
432
|
triggerType: event
|
|
384
433
|
event: plan.commented
|
|
385
434
|
condition: "resolutionTarget is human or resolutionTarget is null"
|
|
@@ -400,7 +449,7 @@ for the full `plan.commented` payload reference and all four plan events.
|
|
|
400
449
|
|
|
401
450
|
## What's next
|
|
402
451
|
|
|
403
|
-
- [**Recurring Jobs**](/docs/recurring-jobs) —
|
|
452
|
+
- [**Recurring Jobs**](/docs/recurring-jobs) — legacy compatibility and advanced scheduled-job fields
|
|
404
453
|
- [**Actions**](/docs/actions) — automations can call any registered action via the agent loop
|
|
405
454
|
- [**Workflow Connectors**](/docs/automation-connectors) — pre-configured n8n/Zapier-style workflow invocation, for when ad-hoc `web-request` isn't a strict enough contract
|
|
406
455
|
- [**Security**](/docs/security) — input validation and secret handling
|
|
@@ -582,7 +582,13 @@ write tools:
|
|
|
582
582
|
export default createAgentChatPlugin({
|
|
583
583
|
// Default: "read"
|
|
584
584
|
databaseTools: "read", // "write" | "read" | "off"
|
|
585
|
-
extensionTools:
|
|
585
|
+
extensionTools: true,
|
|
586
|
+
});
|
|
587
|
+
```
|
|
588
|
+
|
|
589
|
+
```ts filename="server/plugins/core-routes.ts"
|
|
590
|
+
export default createCoreRoutesPlugin({
|
|
591
|
+
extensionTools: true,
|
|
586
592
|
});
|
|
587
593
|
```
|
|
588
594
|
|
|
@@ -593,9 +599,10 @@ export default createAgentChatPlugin({
|
|
|
593
599
|
current user/org and schema changes are blocked.
|
|
594
600
|
- `databaseTools: "off"` or `false` — removes raw database tools from the
|
|
595
601
|
agent surface so the app's actions are the only data access path.
|
|
596
|
-
- `extensionTools:
|
|
597
|
-
prompt guidance (`create-extension`, `update-extension`, etc.)
|
|
598
|
-
|
|
602
|
+
- `extensionTools: true` — opts the app into framework extension-management
|
|
603
|
+
actions and prompt guidance (`create-extension`, `update-extension`, etc.).
|
|
604
|
+
Set it on both plugins to also allow authenticated REST creation. Extensions
|
|
605
|
+
are disabled by default.
|
|
599
606
|
|
|
600
607
|
## Production Code Execution {#production-code-execution}
|
|
601
608
|
|
|
@@ -1,11 +1,18 @@
|
|
|
1
1
|
---
|
|
2
2
|
title: "Extensions"
|
|
3
|
-
description: "
|
|
3
|
+
description: "An optional toolkit capability for one-off, sandboxed custom blocks. App code remains the default for durable product behavior."
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# Extensions
|
|
7
7
|
|
|
8
|
-
Extensions are **
|
|
8
|
+
Extensions are an **optional toolkit capability for sandboxed custom blocks**.
|
|
9
|
+
They are disabled by default. A template must opt in before its agent can create
|
|
10
|
+
or manage them; Analytics uses this capability for explicitly requested,
|
|
11
|
+
one-off custom visualizations.
|
|
12
|
+
|
|
13
|
+
For durable behavior, edit the app code. A custom block is an agent-authored
|
|
14
|
+
patch: useful when speed and local specificity matter, but not the default way
|
|
15
|
+
to add a reusable product feature.
|
|
9
16
|
|
|
10
17
|
When the agent needs a one-time interactive answer inside the chat itself, use
|
|
11
18
|
[Generative UI](/docs/generative-ui) instead. Generative UI uses the same
|
|
@@ -37,10 +44,12 @@ Three things make extensions work:
|
|
|
37
44
|
- **Full access to the template's data.** Extensions can call the same actions the agent calls — `list-emails` in Mail, `list-decks` in Slides, `list-recordings` in Clips — so they have everything the host app has.
|
|
38
45
|
- **Built-in storage.** Each extension has its own per-user / per-org key-value store, so it can save state without you adding a new SQL table.
|
|
39
46
|
|
|
40
|
-
|
|
41
|
-
`extensionTools:
|
|
42
|
-
agent-facing
|
|
43
|
-
|
|
47
|
+
Extensions are disabled by default. To expose user-authored extensions, set
|
|
48
|
+
`extensionTools: true` on both `createAgentChatPlugin()` and
|
|
49
|
+
`createCoreRoutesPlugin()`. The first adds the agent-facing actions and prompt
|
|
50
|
+
guidance; the second permits authenticated creation through
|
|
51
|
+
`POST /_agent-native/extensions`. The sandbox runtime and existing read, edit,
|
|
52
|
+
and deep-link routes remain available for compatibility either way.
|
|
44
53
|
|
|
45
54
|
<Diagram id="doc-block-l8xkep" title="The sandbox bridge" summary={"Extension HTML runs in an isolated iframe and reaches the host only through a fixed set of bridge helpers — every call is scoped and access-checked."}>
|
|
46
55
|
|
|
@@ -649,33 +658,30 @@ The framework lets the agent edit the app's source code directly — components,
|
|
|
649
658
|
routes, styles, and business logic. Use this question when either path could
|
|
650
659
|
solve the request:
|
|
651
660
|
|
|
652
|
-
- **Start with
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
|
665
|
-
|
|
|
666
|
-
| **
|
|
667
|
-
| **
|
|
668
|
-
| **Requires a
|
|
669
|
-
| **
|
|
670
|
-
| **
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
one-off custom visualization on a dashboard is a good extension; a new pie,
|
|
677
|
-
multi-bar, or line chart type that should be available across dashboards
|
|
678
|
-
belongs in the template code.
|
|
661
|
+
- **Start with app code** for product behavior, native UI, layout, routes,
|
|
662
|
+
business logic, or anything that should be reused across dashboards or users.
|
|
663
|
+
- **Use a custom block only when the app opts in** and the user explicitly wants
|
|
664
|
+
a bespoke, one-off visualization or interaction in an existing extension
|
|
665
|
+
surface. It is fast and requires no build or deploy, but remains a sandboxed
|
|
666
|
+
agent-authored patch.
|
|
667
|
+
- **Promote durable custom blocks.** If a block becomes useful beyond its
|
|
668
|
+
original one-off context, use **Promote to app code** to hand it to the normal
|
|
669
|
+
source-change workflow. Keep the original block in place until the code
|
|
670
|
+
change is reviewed and deployed.
|
|
671
|
+
|
|
672
|
+
| | Extension | App code edit |
|
|
673
|
+
| --------------------- | ------------------------------ | ------------------------------ |
|
|
674
|
+
| **Created by** | Agent (or user) at runtime | Agent editing source files |
|
|
675
|
+
| **Stored in** | The database | The git repository |
|
|
676
|
+
| **Requires a build** | No | Yes |
|
|
677
|
+
| **Requires a deploy** | No | Yes |
|
|
678
|
+
| **Scope** | One user (or shared with org) | The entire product, every user |
|
|
679
|
+
| **Best for** | Explicit one-off custom blocks | Durable product behavior |
|
|
680
|
+
|
|
681
|
+
Rule of thumb: **default to app code.** In an app that explicitly enables
|
|
682
|
+
extensions, a one-off custom visualization on a dashboard can be a Custom
|
|
683
|
+
Block; a new pie, multi-bar, or line chart type that should be available across
|
|
684
|
+
dashboards belongs in the template code.
|
|
679
685
|
|
|
680
686
|
If what you actually need is a cached, refreshable data source for an existing chart or table — not a new interactive widget — see [Data Programs](/docs/data-programs) instead; it shares this page's sandbox and security posture but has no UI of its own.
|
|
681
687
|
|