@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
|
@@ -18,6 +18,10 @@ type ToolSearchResult = {
|
|
|
18
18
|
source?: string;
|
|
19
19
|
description: string;
|
|
20
20
|
score: number;
|
|
21
|
+
/** Whether this result can be loaded and called in the current registry. */
|
|
22
|
+
callable: boolean;
|
|
23
|
+
/** How the action behaves while the agent is in Plan mode. */
|
|
24
|
+
planAvailability: "read" | "conditional" | "act-only";
|
|
21
25
|
parameters: ToolParameterSummary[];
|
|
22
26
|
inputSchema?: unknown;
|
|
23
27
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-search.d.ts","sourceRoot":"","sources":["../../src/agent/tool-search.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAEzD,eAAO,MAAM,uBAAuB,gBAAgB,CAAC;AAErD,KAAK,cAAc,GAAG;IACpB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,cAAc,CAAC,EAAE,OAAO,CAAC;CAC1B,CAAC;AAEF,KAAK,oBAAoB,GAAG;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,OAAO,CAAC;IAClB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,IAAI,CAAC,EAAE,MAAM,EAAE,CAAC;CACjB,CAAC;AAEF,KAAK,gBAAgB,GAAG;IACtB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,GAAG,KAAK,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,oBAAoB,EAAE,CAAC;IACnC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAKF,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE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AAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,4EAA4E;IAC5E,QAAQ,EAAE,OAAO,CAAC;IAClB,8DAA8D;IAC9D,gBAAgB,EAAE,MAAM,GAAG,aAAa,GAAG,UAAU,CAAC;IACtD,UAAU,EAAE,oBAAoB,EAAE,CAAC;IACnC,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB,CAAC;AAEF,KAAK,iBAAiB,GAAG;IACvB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AAKF,wBAAgB,qBAAqB,CACnC,WAAW,EAAE,MAAM,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EAC9C,OAAO,GAAE,iBAAsB,GAC9B,WAAW,CA8Bb;AAED,wBAAgB,gBAAgB,CAC9B,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACrC,OAAO,GAAE,iBAAsB,GAC9B,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAM7B;AAED,wBAAgB,kBAAkB,CAChC,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,EACrC,IAAI,GAAE,cAAmB,EACzB,OAAO,GAAE,iBAAsB,GAC9B;IACD,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,gBAAgB,EAAE,CAAC;CAC7B,CAkIA"}
|
|
@@ -65,6 +65,8 @@ export function searchToolRegistry(registry, args = {}, options = {}) {
|
|
|
65
65
|
name,
|
|
66
66
|
kind: parseMcpToolName(name) ? "mcp" : "action",
|
|
67
67
|
score: 0,
|
|
68
|
+
callable: registry[name]?.allowInPlanMode !== false,
|
|
69
|
+
planAvailability: getPlanAvailability(name, registry[name]),
|
|
68
70
|
description: "Already returned by an earlier identical tool-search call.",
|
|
69
71
|
parameters: [],
|
|
70
72
|
})),
|
|
@@ -86,6 +88,8 @@ export function searchToolRegistry(registry, args = {}, options = {}) {
|
|
|
86
88
|
const parsedMcp = parseMcpToolName(name);
|
|
87
89
|
const kind = parsedMcp ? "mcp" : "action";
|
|
88
90
|
const source = parsedMcp?.serverId;
|
|
91
|
+
const callable = entry.allowInPlanMode !== false;
|
|
92
|
+
const planAvailability = getPlanAvailability(name, entry);
|
|
89
93
|
if (listAll) {
|
|
90
94
|
candidates.push({
|
|
91
95
|
name,
|
|
@@ -93,6 +97,8 @@ export function searchToolRegistry(registry, args = {}, options = {}) {
|
|
|
93
97
|
...(source ? { source } : {}),
|
|
94
98
|
description: truncate(description, 140),
|
|
95
99
|
score: 0,
|
|
100
|
+
callable,
|
|
101
|
+
planAvailability,
|
|
96
102
|
parameters: [],
|
|
97
103
|
});
|
|
98
104
|
continue;
|
|
@@ -115,6 +121,8 @@ export function searchToolRegistry(registry, args = {}, options = {}) {
|
|
|
115
121
|
...(source ? { source } : {}),
|
|
116
122
|
description,
|
|
117
123
|
score,
|
|
124
|
+
callable,
|
|
125
|
+
planAvailability,
|
|
118
126
|
parameters,
|
|
119
127
|
...(includeSchemas ? { inputSchema: entry.tool.parameters ?? {} } : {}),
|
|
120
128
|
});
|
|
@@ -146,6 +154,28 @@ export function searchToolRegistry(registry, args = {}, options = {}) {
|
|
|
146
154
|
rememberToolSearchResult(cacheKey, result);
|
|
147
155
|
return result;
|
|
148
156
|
}
|
|
157
|
+
const PLAN_MODE_BLOCKED_DISCOVERY_TOOLS = new Set([
|
|
158
|
+
"refresh-screen",
|
|
159
|
+
"set-search-params",
|
|
160
|
+
"set-url-path",
|
|
161
|
+
]);
|
|
162
|
+
function getPlanAvailability(name, entry) {
|
|
163
|
+
if (!entry || entry.allowInPlanMode === false)
|
|
164
|
+
return "act-only";
|
|
165
|
+
if (PLAN_MODE_BLOCKED_DISCOVERY_TOOLS.has(name))
|
|
166
|
+
return "act-only";
|
|
167
|
+
if (name === "bash")
|
|
168
|
+
return "conditional";
|
|
169
|
+
if (typeof entry.planMode?.effect === "function")
|
|
170
|
+
return "conditional";
|
|
171
|
+
if (entry.planMode?.effect === "read")
|
|
172
|
+
return "read";
|
|
173
|
+
if (entry.planMode?.effect === "write" ||
|
|
174
|
+
entry.planMode?.effect === "unknown") {
|
|
175
|
+
return "act-only";
|
|
176
|
+
}
|
|
177
|
+
return entry.readOnly === true ? "read" : "act-only";
|
|
178
|
+
}
|
|
149
179
|
function normalizeToolSearchCacheKey(options) {
|
|
150
180
|
return JSON.stringify({
|
|
151
181
|
query: options.query.trim().toLowerCase(),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tool-search.js","sourceRoot":"","sources":["../../src/agent/tool-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAGpE,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAAC;AA+BrD,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB,MAAM,UAAU,qBAAqB,CACnC,WAA8C,EAC9C,OAAO,GAAsB,EAAE;IAE/B,OAAO;QACL,IAAI,EAAE;YACJ,WAAW,EACT,ohBAAohB;YACthB,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,WAAW,EACT,kSAAkS;qBACrS;oBACD,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,sDAAsD,OAAO,CAAC,YAAY,IAAI,aAAa,kDAAkD;qBAC3J;oBACD,cAAc,EAAE;wBACd,IAAI,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C;QACvC,IAAI,GAAG,CAAC,QAAQ,CAAC,KAAK,CAAC;YAAE,KAAK,IAAI,CAAC,CAAC;IACtC,CAAC;IAED,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa;IAC7B,MAAM,IAAI,GAAG,IAAI,GAAG,EAAU,CAAC;IAC/B,KAAK,MAAM,KAAK,IAAI,cAAc,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACrD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;YAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,cAAc,CAAC,KAAa;IACnC,OAAO,KAAK;SACT,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;SACtC,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,IAAI,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAa;IACxC,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAC3C,CAAC","sourcesContent":["import { parseMcpToolName } from \"../mcp-client/manager.js\";\nimport { isMcpToolAllowedForRequest } from \"../mcp-client/visibility.js\";\nimport { getRequestRunContext } from \"../server/request-context.js\";\nimport type { ActionEntry } from \"./production-agent.js\";\n\nexport const TOOL_SEARCH_ACTION_NAME = \"tool-search\";\n\ntype ToolSearchArgs = {\n query?: unknown;\n limit?: unknown;\n includeSchemas?: unknown;\n};\n\ntype ToolParameterSummary = {\n name: string;\n type?: string;\n required: boolean;\n description?: string;\n enum?: string[];\n};\n\ntype ToolSearchResult = {\n name: string;\n kind: \"action\" | \"mcp\";\n source?: string;\n description: string;\n score: number;\n parameters: ToolParameterSummary[];\n inputSchema?: unknown;\n};\n\ntype ToolSearchOptions = {\n defaultLimit?: number;\n maxLimit?: number;\n};\n\nconst DEFAULT_LIMIT = 8;\nconst MAX_LIMIT = 25;\n\nexport function createToolSearchEntry(\n getRegistry: () => Record<string, ActionEntry>,\n options: ToolSearchOptions = {},\n): ActionEntry {\n return {\n tool: {\n description:\n \"Discover callable tools/actions, including connected MCP server tools named `mcp__<server>__<tool>`. Call it with NO query to list every available tool by name with a one-line description (cheap — no input schemas); names from that menu are not loaded for calling yet, so call tool-search again with a specific query for the tool/capability before invoking it. Use this whenever you need a capability but aren't sure which tool to call — most tools are not loaded into context up front, so this is how you find and then call them.\",\n parameters: {\n type: \"object\",\n properties: {\n query: {\n type: \"string\",\n description:\n \"What capability to find, e.g. `send slack message`, `create calendar event`, `zapier gmail`, or `browser screenshot`. Omit to list every available tool name (the full menu) with one-line descriptions; then call tool-search again with a specific query before calling a tool from that menu.\",\n },\n limit: {\n type: \"number\",\n description: `Maximum results to return for a query. Defaults to ${options.defaultLimit ?? DEFAULT_LIMIT}. Ignored when listing the full menu (no query).`,\n },\n includeSchemas: {\n type: \"boolean\",\n description:\n \"When true, include each matching tool's full input schema. Default false.\",\n },\n },\n },\n },\n http: false,\n readOnly: true,\n run: async (args: Record<string, string>) =>\n searchToolRegistry(getRegistry(), args, options),\n };\n}\n\nexport function attachToolSearch(\n registry: Record<string, ActionEntry>,\n options: ToolSearchOptions = {},\n): Record<string, ActionEntry> {\n registry[TOOL_SEARCH_ACTION_NAME] = createToolSearchEntry(\n () => registry,\n options,\n );\n return registry;\n}\n\nexport function searchToolRegistry(\n registry: Record<string, ActionEntry>,\n args: ToolSearchArgs = {},\n options: ToolSearchOptions = {},\n): {\n query: string;\n totalTools: number;\n count: number;\n repeated?: boolean;\n message?: string;\n results: ToolSearchResult[];\n} {\n const query = String(args.query ?? \"\").trim();\n // No query → \"menu\" mode: list every available tool by name + a terse\n // description, with no parameter summaries or input schemas. This is the\n // cheap, non-opaque counterpart to the compact catalog: the agent can see\n // the full set of tools for a small token cost, then search/load the few it\n // actually needs. A query switches to ranked search with parameter details.\n const listAll = query.length === 0;\n const includeSchemas = !listAll && parseBoolean(args.includeSchemas);\n const limit = parseLimit(\n args.limit,\n options.defaultLimit ?? DEFAULT_LIMIT,\n options.maxLimit ?? MAX_LIMIT,\n );\n const cacheKey = normalizeToolSearchCacheKey({\n query,\n limit,\n includeSchemas,\n });\n const runCtx = getRequestRunContext();\n const priorSearch = includeSchemas\n ? undefined\n : runCtx?.toolSearchReads?.[cacheKey];\n if (priorSearch) {\n return {\n query,\n totalTools: priorSearch.totalTools,\n count: priorSearch.resultNames.length,\n repeated: true,\n message:\n \"This exact tool-search query already ran in this agent run. Use the previously returned schemas/details instead of searching again.\",\n results: priorSearch.resultNames.map((name) => ({\n name,\n kind: parseMcpToolName(name) ? (\"mcp\" as const) : (\"action\" as const),\n score: 0,\n description:\n \"Already returned by an earlier identical tool-search call.\",\n parameters: [],\n })),\n };\n }\n const queryTokens = tokenize(query);\n\n const candidates: ToolSearchResult[] = [];\n let totalTools = 0;\n\n for (const [name, entry] of Object.entries(registry)) {\n if (!entry?.tool || name === TOOL_SEARCH_ACTION_NAME) continue;\n if (entry.agentTool === false) continue;\n if (name.startsWith(\"mcp__\") && !isMcpToolAllowedForRequest(name)) {\n continue;\n }\n\n totalTools++;\n const description = normalizeWhitespace(entry.tool.description ?? \"\");\n const parsedMcp = parseMcpToolName(name);\n const kind = parsedMcp ? \"mcp\" : \"action\";\n const source = parsedMcp?.serverId;\n\n if (listAll) {\n candidates.push({\n name,\n kind,\n ...(source ? { source } : {}),\n description: truncate(description, 140),\n score: 0,\n parameters: [],\n });\n continue;\n }\n\n const parameters = summarizeParameters(entry.tool.parameters);\n const score = scoreTool({\n query,\n queryTokens,\n name,\n source,\n description,\n parameters,\n kind,\n });\n\n if (score <= 0) continue;\n\n candidates.push({\n name,\n kind,\n ...(source ? { source } : {}),\n description,\n score,\n parameters,\n ...(includeSchemas ? { inputSchema: entry.tool.parameters ?? {} } : {}),\n });\n }\n\n if (listAll) {\n candidates.sort((a, b) => a.name.localeCompare(b.name));\n const result = {\n query,\n totalTools,\n count: candidates.length,\n message:\n 'Menu mode lists tool names only; it does not load schemas for calling. Before invoking a tool found here, call tool-search again with a specific query such as the tool name or capability (for example, { \"query\": \"hubspot-deals\" }).',\n results: candidates,\n };\n rememberToolSearchResult(cacheKey, result);\n return result;\n }\n\n candidates.sort((a, b) => {\n if (b.score !== a.score) return b.score - a.score;\n return a.name.localeCompare(b.name);\n });\n\n const result = {\n query,\n totalTools,\n count: Math.min(candidates.length, limit),\n results: candidates.slice(0, limit),\n };\n if (!includeSchemas) rememberToolSearchResult(cacheKey, result);\n return result;\n}\n\nfunction normalizeToolSearchCacheKey(options: {\n query: string;\n limit: number;\n includeSchemas: boolean;\n}): string {\n return JSON.stringify({\n query: options.query.trim().toLowerCase(),\n limit: options.limit,\n includeSchemas: options.includeSchemas,\n });\n}\n\nfunction rememberToolSearchResult(\n cacheKey: string,\n result: { totalTools: number; results: Array<{ name: string }> },\n) {\n const runCtx = getRequestRunContext();\n if (!runCtx) return;\n const reads = (runCtx.toolSearchReads ??= {});\n reads[cacheKey] = {\n totalTools: result.totalTools,\n resultNames: result.results.map((item) => item.name),\n };\n}\n\nfunction truncate(value: string, max: number): string {\n if (value.length <= max) return value;\n return `${value.slice(0, max - 1).trimEnd()}…`;\n}\n\nfunction parseLimit(value: unknown, fallback: number, max: number): number {\n const n =\n typeof value === \"number\"\n ? value\n : typeof value === \"string\" && value.trim()\n ? Number(value)\n : fallback;\n if (!Number.isFinite(n) || n <= 0) return fallback;\n return Math.max(1, Math.min(max, Math.floor(n)));\n}\n\nfunction parseBoolean(value: unknown): boolean {\n if (typeof value === \"boolean\") return value;\n if (typeof value !== \"string\") return false;\n const normalized = value.trim().toLowerCase();\n return normalized === \"true\" || normalized === \"1\" || normalized === \"yes\";\n}\n\nfunction summarizeParameters(schema: unknown): ToolParameterSummary[] {\n if (!schema || typeof schema !== \"object\") return [];\n const obj = schema as {\n properties?: Record<string, unknown>;\n required?: unknown;\n };\n const properties = obj.properties;\n if (!properties || typeof properties !== \"object\") return [];\n const required = new Set(\n Array.isArray(obj.required)\n ? obj.required.filter(\n (value): value is string => typeof value === \"string\",\n )\n : [],\n );\n\n return Object.entries(properties).map(([name, raw]) => {\n const prop =\n raw && typeof raw === \"object\" ? (raw as Record<string, unknown>) : {};\n const enumValues = Array.isArray(prop.enum)\n ? prop.enum.map((value) => String(value)).slice(0, 20)\n : undefined;\n return {\n name,\n type: summarizeType(prop.type),\n required: required.has(name),\n description:\n typeof prop.description === \"string\"\n ? normalizeWhitespace(prop.description)\n : undefined,\n ...(enumValues && enumValues.length > 0 ? { enum: enumValues } : {}),\n };\n });\n}\n\nfunction summarizeType(value: unknown): string | undefined {\n if (typeof value === \"string\") return value;\n if (Array.isArray(value)) {\n const parts = value.filter((v): v is string => typeof v === \"string\");\n return parts.length > 0 ? parts.join(\" | \") : undefined;\n }\n return undefined;\n}\n\nfunction scoreTool(input: {\n query: string;\n queryTokens: string[];\n name: string;\n source?: string;\n description: string;\n parameters: ToolParameterSummary[];\n kind: \"action\" | \"mcp\";\n}): number {\n if (input.queryTokens.length === 0) return 1;\n\n const name = searchableText(input.name);\n const source = searchableText(input.source ?? \"\");\n const description = searchableText(input.description);\n const params = searchableText(\n input.parameters\n .map((p) => `${p.name} ${p.type ?? \"\"} ${p.description ?? \"\"}`)\n .join(\" \"),\n );\n const all = `${name} ${source} ${description} ${params} ${input.kind}`;\n const phrase = searchableText(input.query);\n\n let score = 0;\n if (name.includes(phrase)) score += 14;\n if (source && source.includes(phrase)) score += 10;\n if (description.includes(phrase)) score += 8;\n if (params.includes(phrase)) score += 5;\n\n for (const token of input.queryTokens) {\n if (name.split(\" \").includes(token)) score += 9;\n else if (name.includes(token)) score += 6;\n\n if (source) {\n if (source.split(\" \").includes(token)) score += 6;\n else if (source.includes(token)) score += 3;\n }\n\n if (description.includes(token)) score += 3;\n if (params.includes(token)) score += 2;\n if (all.includes(token)) score += 1;\n }\n\n return score;\n}\n\nfunction tokenize(value: string): string[] {\n const seen = new Set<string>();\n for (const token of searchableText(value).split(\" \")) {\n if (token.length > 0) seen.add(token);\n }\n return Array.from(seen);\n}\n\nfunction searchableText(value: string): string {\n return value\n .replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \" \")\n .trim();\n}\n\nfunction normalizeWhitespace(value: string): string {\n return value.replace(/\\s+/g, \" \").trim();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"tool-search.js","sourceRoot":"","sources":["../../src/agent/tool-search.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,0BAA0B,EAAE,MAAM,6BAA6B,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAGpE,MAAM,CAAC,MAAM,uBAAuB,GAAG,aAAa,CAAC;AAmCrD,MAAM,aAAa,GAAG,CAAC,CAAC;AACxB,MAAM,SAAS,GAAG,EAAE,CAAC;AAErB,MAAM,UAAU,qBAAqB,CACnC,WAA8C,EAC9C,OAAO,GAAsB,EAAE;IAE/B,OAAO;QACL,IAAI,EAAE;YACJ,WAAW,EACT,ohBAAohB;YACthB,UAAU,EAAE;gBACV,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,WAAW,EACT,kSAAkS;qBACrS;oBACD,KAAK,EAAE;wBACL,IAAI,EAAE,QAAQ;wBACd,WAAW,EAAE,sDAAsD,OAAO,CAAC,YAAY,IAAI,aAAa,kDAAkD;qBAC3J;oBACD,cAAc,EAAE;wBACd,IAAI,EAAE,SAAS;wBACf,WAAW,EACT,2EAA2E;qBAC9E;iBACF;aACF;SACF;QACD,IAAI,EAAE,KAAK;QACX,QAAQ,EAAE,IAAI;QACd,GAAG,EAAE,KAAK,EAAE,I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AAC,KAAK,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,EAAE,CAAC;QACrD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC;YAAE,IAAI,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IACxC,CAAC;IACD,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC1B,CAAC;AAED,SAAS,cAAc,CAAC,KAAa;IACnC,OAAO,KAAK;SACT,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;SACtC,WAAW,EAAE;SACb,OAAO,CAAC,aAAa,EAAE,GAAG,CAAC;SAC3B,IAAI,EAAE,CAAC;AACZ,CAAC;AAED,SAAS,mBAAmB,CAAC,KAAa;IACxC,OAAO,KAAK,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAC3C,CAAC","sourcesContent":["import { parseMcpToolName } from \"../mcp-client/manager.js\";\nimport { isMcpToolAllowedForRequest } from \"../mcp-client/visibility.js\";\nimport { getRequestRunContext } from \"../server/request-context.js\";\nimport type { ActionEntry } from \"./production-agent.js\";\n\nexport const TOOL_SEARCH_ACTION_NAME = \"tool-search\";\n\ntype ToolSearchArgs = {\n query?: unknown;\n limit?: unknown;\n includeSchemas?: unknown;\n};\n\ntype ToolParameterSummary = {\n name: string;\n type?: string;\n required: boolean;\n description?: string;\n enum?: string[];\n};\n\ntype ToolSearchResult = {\n name: string;\n kind: \"action\" | \"mcp\";\n source?: string;\n description: string;\n score: number;\n /** Whether this result can be loaded and called in the current registry. */\n callable: boolean;\n /** How the action behaves while the agent is in Plan mode. */\n planAvailability: \"read\" | \"conditional\" | \"act-only\";\n parameters: ToolParameterSummary[];\n inputSchema?: unknown;\n};\n\ntype ToolSearchOptions = {\n defaultLimit?: number;\n maxLimit?: number;\n};\n\nconst DEFAULT_LIMIT = 8;\nconst MAX_LIMIT = 25;\n\nexport function createToolSearchEntry(\n getRegistry: () => Record<string, ActionEntry>,\n options: ToolSearchOptions = {},\n): ActionEntry {\n return {\n tool: {\n description:\n \"Discover callable tools/actions, including connected MCP server tools named `mcp__<server>__<tool>`. Call it with NO query to list every available tool by name with a one-line description (cheap — no input schemas); names from that menu are not loaded for calling yet, so call tool-search again with a specific query for the tool/capability before invoking it. Use this whenever you need a capability but aren't sure which tool to call — most tools are not loaded into context up front, so this is how you find and then call them.\",\n parameters: {\n type: \"object\",\n properties: {\n query: {\n type: \"string\",\n description:\n \"What capability to find, e.g. `send slack message`, `create calendar event`, `zapier gmail`, or `browser screenshot`. Omit to list every available tool name (the full menu) with one-line descriptions; then call tool-search again with a specific query before calling a tool from that menu.\",\n },\n limit: {\n type: \"number\",\n description: `Maximum results to return for a query. Defaults to ${options.defaultLimit ?? DEFAULT_LIMIT}. Ignored when listing the full menu (no query).`,\n },\n includeSchemas: {\n type: \"boolean\",\n description:\n \"When true, include each matching tool's full input schema. Default false.\",\n },\n },\n },\n },\n http: false,\n readOnly: true,\n run: async (args: Record<string, string>) =>\n searchToolRegistry(getRegistry(), args, options),\n };\n}\n\nexport function attachToolSearch(\n registry: Record<string, ActionEntry>,\n options: ToolSearchOptions = {},\n): Record<string, ActionEntry> {\n registry[TOOL_SEARCH_ACTION_NAME] = createToolSearchEntry(\n () => registry,\n options,\n );\n return registry;\n}\n\nexport function searchToolRegistry(\n registry: Record<string, ActionEntry>,\n args: ToolSearchArgs = {},\n options: ToolSearchOptions = {},\n): {\n query: string;\n totalTools: number;\n count: number;\n repeated?: boolean;\n message?: string;\n results: ToolSearchResult[];\n} {\n const query = String(args.query ?? \"\").trim();\n // No query → \"menu\" mode: list every available tool by name + a terse\n // description, with no parameter summaries or input schemas. This is the\n // cheap, non-opaque counterpart to the compact catalog: the agent can see\n // the full set of tools for a small token cost, then search/load the few it\n // actually needs. A query switches to ranked search with parameter details.\n const listAll = query.length === 0;\n const includeSchemas = !listAll && parseBoolean(args.includeSchemas);\n const limit = parseLimit(\n args.limit,\n options.defaultLimit ?? DEFAULT_LIMIT,\n options.maxLimit ?? MAX_LIMIT,\n );\n const cacheKey = normalizeToolSearchCacheKey({\n query,\n limit,\n includeSchemas,\n });\n const runCtx = getRequestRunContext();\n const priorSearch = includeSchemas\n ? undefined\n : runCtx?.toolSearchReads?.[cacheKey];\n if (priorSearch) {\n return {\n query,\n totalTools: priorSearch.totalTools,\n count: priorSearch.resultNames.length,\n repeated: true,\n message:\n \"This exact tool-search query already ran in this agent run. Use the previously returned schemas/details instead of searching again.\",\n results: priorSearch.resultNames.map((name) => ({\n name,\n kind: parseMcpToolName(name) ? (\"mcp\" as const) : (\"action\" as const),\n score: 0,\n callable: registry[name]?.allowInPlanMode !== false,\n planAvailability: getPlanAvailability(name, registry[name]),\n description:\n \"Already returned by an earlier identical tool-search call.\",\n parameters: [],\n })),\n };\n }\n const queryTokens = tokenize(query);\n\n const candidates: ToolSearchResult[] = [];\n let totalTools = 0;\n\n for (const [name, entry] of Object.entries(registry)) {\n if (!entry?.tool || name === TOOL_SEARCH_ACTION_NAME) continue;\n if (entry.agentTool === false) continue;\n if (name.startsWith(\"mcp__\") && !isMcpToolAllowedForRequest(name)) {\n continue;\n }\n\n totalTools++;\n const description = normalizeWhitespace(entry.tool.description ?? \"\");\n const parsedMcp = parseMcpToolName(name);\n const kind = parsedMcp ? \"mcp\" : \"action\";\n const source = parsedMcp?.serverId;\n const callable = entry.allowInPlanMode !== false;\n const planAvailability = getPlanAvailability(name, entry);\n\n if (listAll) {\n candidates.push({\n name,\n kind,\n ...(source ? { source } : {}),\n description: truncate(description, 140),\n score: 0,\n callable,\n planAvailability,\n parameters: [],\n });\n continue;\n }\n\n const parameters = summarizeParameters(entry.tool.parameters);\n const score = scoreTool({\n query,\n queryTokens,\n name,\n source,\n description,\n parameters,\n kind,\n });\n\n if (score <= 0) continue;\n\n candidates.push({\n name,\n kind,\n ...(source ? { source } : {}),\n description,\n score,\n callable,\n planAvailability,\n parameters,\n ...(includeSchemas ? { inputSchema: entry.tool.parameters ?? {} } : {}),\n });\n }\n\n if (listAll) {\n candidates.sort((a, b) => a.name.localeCompare(b.name));\n const result = {\n query,\n totalTools,\n count: candidates.length,\n message:\n 'Menu mode lists tool names only; it does not load schemas for calling. Before invoking a tool found here, call tool-search again with a specific query such as the tool name or capability (for example, { \"query\": \"hubspot-deals\" }).',\n results: candidates,\n };\n rememberToolSearchResult(cacheKey, result);\n return result;\n }\n\n candidates.sort((a, b) => {\n if (b.score !== a.score) return b.score - a.score;\n return a.name.localeCompare(b.name);\n });\n\n const result = {\n query,\n totalTools,\n count: Math.min(candidates.length, limit),\n results: candidates.slice(0, limit),\n };\n if (!includeSchemas) rememberToolSearchResult(cacheKey, result);\n return result;\n}\n\nconst PLAN_MODE_BLOCKED_DISCOVERY_TOOLS = new Set([\n \"refresh-screen\",\n \"set-search-params\",\n \"set-url-path\",\n]);\n\nfunction getPlanAvailability(\n name: string,\n entry: ActionEntry | undefined,\n): ToolSearchResult[\"planAvailability\"] {\n if (!entry || entry.allowInPlanMode === false) return \"act-only\";\n if (PLAN_MODE_BLOCKED_DISCOVERY_TOOLS.has(name)) return \"act-only\";\n if (name === \"bash\") return \"conditional\";\n if (typeof entry.planMode?.effect === \"function\") return \"conditional\";\n if (entry.planMode?.effect === \"read\") return \"read\";\n if (\n entry.planMode?.effect === \"write\" ||\n entry.planMode?.effect === \"unknown\"\n ) {\n return \"act-only\";\n }\n return entry.readOnly === true ? \"read\" : \"act-only\";\n}\n\nfunction normalizeToolSearchCacheKey(options: {\n query: string;\n limit: number;\n includeSchemas: boolean;\n}): string {\n return JSON.stringify({\n query: options.query.trim().toLowerCase(),\n limit: options.limit,\n includeSchemas: options.includeSchemas,\n });\n}\n\nfunction rememberToolSearchResult(\n cacheKey: string,\n result: { totalTools: number; results: Array<{ name: string }> },\n) {\n const runCtx = getRequestRunContext();\n if (!runCtx) return;\n const reads = (runCtx.toolSearchReads ??= {});\n reads[cacheKey] = {\n totalTools: result.totalTools,\n resultNames: result.results.map((item) => item.name),\n };\n}\n\nfunction truncate(value: string, max: number): string {\n if (value.length <= max) return value;\n return `${value.slice(0, max - 1).trimEnd()}…`;\n}\n\nfunction parseLimit(value: unknown, fallback: number, max: number): number {\n const n =\n typeof value === \"number\"\n ? value\n : typeof value === \"string\" && value.trim()\n ? Number(value)\n : fallback;\n if (!Number.isFinite(n) || n <= 0) return fallback;\n return Math.max(1, Math.min(max, Math.floor(n)));\n}\n\nfunction parseBoolean(value: unknown): boolean {\n if (typeof value === \"boolean\") return value;\n if (typeof value !== \"string\") return false;\n const normalized = value.trim().toLowerCase();\n return normalized === \"true\" || normalized === \"1\" || normalized === \"yes\";\n}\n\nfunction summarizeParameters(schema: unknown): ToolParameterSummary[] {\n if (!schema || typeof schema !== \"object\") return [];\n const obj = schema as {\n properties?: Record<string, unknown>;\n required?: unknown;\n };\n const properties = obj.properties;\n if (!properties || typeof properties !== \"object\") return [];\n const required = new Set(\n Array.isArray(obj.required)\n ? obj.required.filter(\n (value): value is string => typeof value === \"string\",\n )\n : [],\n );\n\n return Object.entries(properties).map(([name, raw]) => {\n const prop =\n raw && typeof raw === \"object\" ? (raw as Record<string, unknown>) : {};\n const enumValues = Array.isArray(prop.enum)\n ? prop.enum.map((value) => String(value)).slice(0, 20)\n : undefined;\n return {\n name,\n type: summarizeType(prop.type),\n required: required.has(name),\n description:\n typeof prop.description === \"string\"\n ? normalizeWhitespace(prop.description)\n : undefined,\n ...(enumValues && enumValues.length > 0 ? { enum: enumValues } : {}),\n };\n });\n}\n\nfunction summarizeType(value: unknown): string | undefined {\n if (typeof value === \"string\") return value;\n if (Array.isArray(value)) {\n const parts = value.filter((v): v is string => typeof v === \"string\");\n return parts.length > 0 ? parts.join(\" | \") : undefined;\n }\n return undefined;\n}\n\nfunction scoreTool(input: {\n query: string;\n queryTokens: string[];\n name: string;\n source?: string;\n description: string;\n parameters: ToolParameterSummary[];\n kind: \"action\" | \"mcp\";\n}): number {\n if (input.queryTokens.length === 0) return 1;\n\n const name = searchableText(input.name);\n const source = searchableText(input.source ?? \"\");\n const description = searchableText(input.description);\n const params = searchableText(\n input.parameters\n .map((p) => `${p.name} ${p.type ?? \"\"} ${p.description ?? \"\"}`)\n .join(\" \"),\n );\n const all = `${name} ${source} ${description} ${params} ${input.kind}`;\n const phrase = searchableText(input.query);\n\n let score = 0;\n if (name.includes(phrase)) score += 14;\n if (source && source.includes(phrase)) score += 10;\n if (description.includes(phrase)) score += 8;\n if (params.includes(phrase)) score += 5;\n\n for (const token of input.queryTokens) {\n if (name.split(\" \").includes(token)) score += 9;\n else if (name.includes(token)) score += 6;\n\n if (source) {\n if (source.split(\" \").includes(token)) score += 6;\n else if (source.includes(token)) score += 3;\n }\n\n if (description.includes(token)) score += 3;\n if (params.includes(token)) score += 2;\n if (all.includes(token)) score += 1;\n }\n\n return score;\n}\n\nfunction tokenize(value: string): string[] {\n const seen = new Set<string>();\n for (const token of searchableText(value).split(\" \")) {\n if (token.length > 0) seen.add(token);\n }\n return Array.from(seen);\n}\n\nfunction searchableText(value: string): string {\n return value\n .replace(/([a-z0-9])([A-Z])/g, \"$1 $2\")\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \" \")\n .trim();\n}\n\nfunction normalizeWhitespace(value: string): string {\n return value.replace(/\\s+/g, \" \").trim();\n}\n"]}
|
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import { type JobFrontmatter } from "../jobs/frontmatter.js";
|
|
2
|
+
import { type Resource } from "../resources/store.js";
|
|
3
|
+
export type AutomationScope = "personal" | "organization";
|
|
4
|
+
export interface AutomationActor {
|
|
5
|
+
userEmail: string;
|
|
6
|
+
orgId?: string | null;
|
|
7
|
+
}
|
|
8
|
+
export interface AutomationDefinition {
|
|
9
|
+
resource: Resource;
|
|
10
|
+
name: string;
|
|
11
|
+
scope: AutomationScope;
|
|
12
|
+
meta: JobFrontmatter & {
|
|
13
|
+
triggerType: "schedule" | "event";
|
|
14
|
+
mode: "agentic" | "deterministic";
|
|
15
|
+
};
|
|
16
|
+
body: string;
|
|
17
|
+
canUpdate: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface AutomationDelivery {
|
|
20
|
+
originScopeId?: string;
|
|
21
|
+
platform?: string;
|
|
22
|
+
destination?: string;
|
|
23
|
+
threadRef?: string;
|
|
24
|
+
tenantId?: string;
|
|
25
|
+
}
|
|
26
|
+
export interface DefineAutomationInput {
|
|
27
|
+
name: string;
|
|
28
|
+
scope: AutomationScope;
|
|
29
|
+
triggerType: "schedule" | "event";
|
|
30
|
+
body: string;
|
|
31
|
+
schedule?: string;
|
|
32
|
+
event?: string;
|
|
33
|
+
condition?: string;
|
|
34
|
+
domain?: string;
|
|
35
|
+
delegatedPolicyId?: string;
|
|
36
|
+
model?: string;
|
|
37
|
+
mcpTools?: unknown;
|
|
38
|
+
delivery?: AutomationDelivery;
|
|
39
|
+
}
|
|
40
|
+
export type DefinedAutomation = Omit<AutomationDefinition, "resource">;
|
|
41
|
+
export interface UpdateAutomationInput {
|
|
42
|
+
name: string;
|
|
43
|
+
scope: AutomationScope;
|
|
44
|
+
enabled?: boolean;
|
|
45
|
+
body?: string;
|
|
46
|
+
condition?: string | null;
|
|
47
|
+
delegatedPolicyId?: string | null;
|
|
48
|
+
schedule?: string;
|
|
49
|
+
model?: string | null;
|
|
50
|
+
mcpTools?: unknown;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Compatibility adapters may expose both explicit automations and legacy
|
|
54
|
+
* scheduled jobs. Keep their mutation authorization on the same boundary as
|
|
55
|
+
* the canonical service without forcing legacy resources through the explicit
|
|
56
|
+
* automation classifier.
|
|
57
|
+
*/
|
|
58
|
+
export declare function canUpdateAutomationResource(actorInput: AutomationActor, resource: Resource): Promise<boolean>;
|
|
59
|
+
export declare function listAutomationDefinitions(actorInput: AutomationActor, scope: AutomationScope): Promise<AutomationDefinition[]>;
|
|
60
|
+
export declare function defineAutomation(actorInput: AutomationActor, input: DefineAutomationInput): Promise<DefinedAutomation>;
|
|
61
|
+
export declare function updateAutomation(actorInput: AutomationActor, input: UpdateAutomationInput): Promise<AutomationDefinition>;
|
|
62
|
+
export declare function deleteAutomation(actorInput: AutomationActor, scope: AutomationScope, name: string): Promise<void>;
|
|
63
|
+
export interface AutomationExecutionIdentity {
|
|
64
|
+
userEmail: string;
|
|
65
|
+
orgId?: string;
|
|
66
|
+
eventOwner: string;
|
|
67
|
+
}
|
|
68
|
+
export type AutomationExecutionIdentityResult = {
|
|
69
|
+
ok: true;
|
|
70
|
+
identity: AutomationExecutionIdentity;
|
|
71
|
+
} | {
|
|
72
|
+
ok: false;
|
|
73
|
+
reason: string;
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Resolve the identity used by an explicit automation run.
|
|
77
|
+
*
|
|
78
|
+
* Organization automations are visible through their organization owner, but
|
|
79
|
+
* always execute as their immutable creator. Event dispatchers must also
|
|
80
|
+
* require EventMeta.owner to equal `eventOwner`; organization visibility does
|
|
81
|
+
* not make an event organization-wide.
|
|
82
|
+
*/
|
|
83
|
+
export declare function resolveAutomationExecutionIdentity(resourceOwner: string, meta: JobFrontmatter): Promise<AutomationExecutionIdentityResult>;
|
|
84
|
+
export declare function automationMatchesEventOwner(identity: AutomationExecutionIdentity, eventOwner: string | undefined): boolean;
|
|
85
|
+
//# sourceMappingURL=service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../src/automations/service.ts"],"names":[],"mappings":"AAEA,OAAO,EAIL,KAAK,cAAc,EACpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAOL,KAAK,QAAQ,EACd,MAAM,uBAAuB,CAAC;AAE/B,MAAM,MAAM,eAAe,GAAG,UAAU,GAAG,cAAc,CAAC;AAE1D,MAAM,WAAW,eAAe;IAC9B,SAAS,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED,MAAM,WAAW,oBAAoB;IACnC,QAAQ,EAAE,QAAQ,CAAC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Q,EAAE,2BAA2B,EACrC,UAAU,EAAE,MAAM,GAAG,SAAS,GAC7B,OAAO,CAKT"}
|
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
import { getDbExec } from "../db/client.js";
|
|
2
|
+
import { isValidCron, nextOccurrence } from "../jobs/cron.js";
|
|
3
|
+
import { buildJobResourceContent, normalizeJobMcpTools, parseJobResource, } from "../jobs/frontmatter.js";
|
|
4
|
+
import { organizationIdFromResourceOwner, organizationResourceOwner, resourceDelete, resourceGetByPath, resourceList, resourcePut, } from "../resources/store.js";
|
|
5
|
+
function httpError(message, statusCode) {
|
|
6
|
+
return Object.assign(new Error(message), { statusCode });
|
|
7
|
+
}
|
|
8
|
+
function normalizeActor(actor) {
|
|
9
|
+
const userEmail = actor.userEmail.trim().toLowerCase();
|
|
10
|
+
if (!userEmail)
|
|
11
|
+
throw httpError("Not authenticated.", 401);
|
|
12
|
+
return { userEmail, orgId: actor.orgId?.trim() || null };
|
|
13
|
+
}
|
|
14
|
+
function automationName(path) {
|
|
15
|
+
return path.replace(/^jobs\//, "").replace(/\.md$/, "");
|
|
16
|
+
}
|
|
17
|
+
function automationPath(name) {
|
|
18
|
+
const normalized = name
|
|
19
|
+
.trim()
|
|
20
|
+
.toLowerCase()
|
|
21
|
+
.replace(/[^a-z0-9-]/g, "-");
|
|
22
|
+
if (!normalized) {
|
|
23
|
+
throw httpError("Automation name is required (lowercase, hyphens).", 400);
|
|
24
|
+
}
|
|
25
|
+
return `jobs/${normalized}.md`;
|
|
26
|
+
}
|
|
27
|
+
function ownerForScope(actor, scope) {
|
|
28
|
+
if (scope === "personal")
|
|
29
|
+
return actor.userEmail;
|
|
30
|
+
if (!actor.orgId) {
|
|
31
|
+
throw httpError("An organization is required for organization automations.", 400);
|
|
32
|
+
}
|
|
33
|
+
return organizationResourceOwner(actor.orgId);
|
|
34
|
+
}
|
|
35
|
+
async function readOrganizationMembership(orgId, email) {
|
|
36
|
+
const result = await getDbExec().execute({
|
|
37
|
+
sql: "SELECT role FROM org_members WHERE org_id = ? AND LOWER(email) = ? LIMIT 1",
|
|
38
|
+
args: [orgId, email.toLowerCase()],
|
|
39
|
+
});
|
|
40
|
+
if (!result.rows.length)
|
|
41
|
+
return null;
|
|
42
|
+
return { role: String(result.rows[0]?.role ?? "").toLowerCase() };
|
|
43
|
+
}
|
|
44
|
+
async function requireOrganizationMembership(actor) {
|
|
45
|
+
if (!actor.orgId) {
|
|
46
|
+
throw httpError("An organization is required for organization automations.", 400);
|
|
47
|
+
}
|
|
48
|
+
const membership = await readOrganizationMembership(actor.orgId, actor.userEmail);
|
|
49
|
+
if (!membership) {
|
|
50
|
+
throw httpError("You are no longer a member of this organization.", 403);
|
|
51
|
+
}
|
|
52
|
+
return membership;
|
|
53
|
+
}
|
|
54
|
+
function isOrganizationAdmin(membership) {
|
|
55
|
+
return membership.role === "owner" || membership.role === "admin";
|
|
56
|
+
}
|
|
57
|
+
async function mutationAccess(actorInput, resource, meta) {
|
|
58
|
+
const actor = normalizeActor(actorInput);
|
|
59
|
+
const resourceOrgId = organizationIdFromResourceOwner(resource.owner);
|
|
60
|
+
if (!resourceOrgId) {
|
|
61
|
+
return {
|
|
62
|
+
actor,
|
|
63
|
+
canUpdate: resource.owner.toLowerCase() === actor.userEmail,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
if (actor.orgId !== resourceOrgId) {
|
|
67
|
+
return { actor, canUpdate: false };
|
|
68
|
+
}
|
|
69
|
+
const membership = await requireOrganizationMembership(actor);
|
|
70
|
+
const isCreator = meta.createdBy?.trim().toLowerCase() === actor.userEmail.toLowerCase();
|
|
71
|
+
return {
|
|
72
|
+
actor,
|
|
73
|
+
canUpdate: isCreator || isOrganizationAdmin(membership),
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Compatibility adapters may expose both explicit automations and legacy
|
|
78
|
+
* scheduled jobs. Keep their mutation authorization on the same boundary as
|
|
79
|
+
* the canonical service without forcing legacy resources through the explicit
|
|
80
|
+
* automation classifier.
|
|
81
|
+
*/
|
|
82
|
+
export async function canUpdateAutomationResource(actorInput, resource) {
|
|
83
|
+
const { meta } = parseJobResource(resource.content);
|
|
84
|
+
return (await mutationAccess(actorInput, resource, meta)).canUpdate;
|
|
85
|
+
}
|
|
86
|
+
function assertExplicitAutomation(resource) {
|
|
87
|
+
const parsed = parseJobResource(resource.content);
|
|
88
|
+
if (parsed.classification.kind !== "automation") {
|
|
89
|
+
throw httpError(`"${automationName(resource.path)}" is a legacy scheduled job. Use manage-jobs for compatibility.`, 400);
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
resource,
|
|
93
|
+
meta: {
|
|
94
|
+
...parsed.meta,
|
|
95
|
+
triggerType: parsed.classification.triggerType,
|
|
96
|
+
mode: parsed.meta.mode ?? "agentic",
|
|
97
|
+
},
|
|
98
|
+
body: parsed.body,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
async function readDefinition(actorInput, scope, name) {
|
|
102
|
+
const actor = normalizeActor(actorInput);
|
|
103
|
+
if (scope === "organization")
|
|
104
|
+
await requireOrganizationMembership(actor);
|
|
105
|
+
const owner = ownerForScope(actor, scope);
|
|
106
|
+
const path = automationPath(name);
|
|
107
|
+
const resource = await resourceGetByPath(owner, path);
|
|
108
|
+
if (!resource) {
|
|
109
|
+
throw httpError(`Automation "${automationName(path)}" not found.`, 404);
|
|
110
|
+
}
|
|
111
|
+
const definition = assertExplicitAutomation(resource);
|
|
112
|
+
const access = await mutationAccess(actor, resource, definition.meta);
|
|
113
|
+
return {
|
|
114
|
+
...definition,
|
|
115
|
+
name: automationName(resource.path),
|
|
116
|
+
scope,
|
|
117
|
+
canUpdate: access.canUpdate,
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
export async function listAutomationDefinitions(actorInput, scope) {
|
|
121
|
+
const actor = normalizeActor(actorInput);
|
|
122
|
+
const membership = scope === "organization"
|
|
123
|
+
? await requireOrganizationMembership(actor)
|
|
124
|
+
: undefined;
|
|
125
|
+
const owner = ownerForScope(actor, scope);
|
|
126
|
+
const resources = await resourceList(owner, "jobs/");
|
|
127
|
+
const automations = [];
|
|
128
|
+
for (const resourceMeta of resources) {
|
|
129
|
+
if (!resourceMeta.path.endsWith(".md") ||
|
|
130
|
+
resourceMeta.path.endsWith(".keep")) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
const resource = await resourceGetByPath(owner, resourceMeta.path);
|
|
134
|
+
if (!resource)
|
|
135
|
+
continue;
|
|
136
|
+
const parsed = parseJobResource(resource.content);
|
|
137
|
+
if (parsed.classification.kind !== "automation")
|
|
138
|
+
continue;
|
|
139
|
+
const isCreator = parsed.meta.createdBy?.trim().toLowerCase() === actor.userEmail;
|
|
140
|
+
automations.push({
|
|
141
|
+
resource,
|
|
142
|
+
name: automationName(resource.path),
|
|
143
|
+
scope,
|
|
144
|
+
meta: {
|
|
145
|
+
...parsed.meta,
|
|
146
|
+
triggerType: parsed.classification.triggerType,
|
|
147
|
+
mode: parsed.meta.mode ?? "agentic",
|
|
148
|
+
},
|
|
149
|
+
body: parsed.body,
|
|
150
|
+
canUpdate: scope === "personal" ||
|
|
151
|
+
isCreator ||
|
|
152
|
+
(membership ? isOrganizationAdmin(membership) : false),
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
return automations;
|
|
156
|
+
}
|
|
157
|
+
export async function defineAutomation(actorInput, input) {
|
|
158
|
+
const actor = normalizeActor(actorInput);
|
|
159
|
+
if (input.scope === "organization") {
|
|
160
|
+
await requireOrganizationMembership(actor);
|
|
161
|
+
}
|
|
162
|
+
const owner = ownerForScope(actor, input.scope);
|
|
163
|
+
const path = automationPath(input.name);
|
|
164
|
+
if (await resourceGetByPath(owner, path)) {
|
|
165
|
+
throw httpError(`An automation named "${automationName(path)}" already exists.`, 409);
|
|
166
|
+
}
|
|
167
|
+
const body = input.body.trim();
|
|
168
|
+
if (!body)
|
|
169
|
+
throw httpError("body is required.", 400);
|
|
170
|
+
const schedule = input.schedule?.trim() ?? "";
|
|
171
|
+
const event = input.event?.trim() ?? "";
|
|
172
|
+
if (input.triggerType === "schedule" && !isValidCron(schedule)) {
|
|
173
|
+
throw httpError(schedule
|
|
174
|
+
? `invalid cron expression "${schedule}".`
|
|
175
|
+
: "schedule is required for scheduled automations.", 400);
|
|
176
|
+
}
|
|
177
|
+
if (input.triggerType === "event" && !event) {
|
|
178
|
+
throw httpError("event is required for event-triggered automations.", 400);
|
|
179
|
+
}
|
|
180
|
+
const mcpTools = normalizeJobMcpTools(input.mcpTools);
|
|
181
|
+
const meta = {
|
|
182
|
+
schedule: input.triggerType === "schedule" ? schedule : "",
|
|
183
|
+
enabled: true,
|
|
184
|
+
triggerType: input.triggerType,
|
|
185
|
+
event: input.triggerType === "event" ? event : undefined,
|
|
186
|
+
condition: input.condition?.trim() || undefined,
|
|
187
|
+
mode: "agentic",
|
|
188
|
+
domain: input.domain?.trim() || undefined,
|
|
189
|
+
delegatedPolicyId: input.delegatedPolicyId?.trim() || undefined,
|
|
190
|
+
createdBy: actor.userEmail,
|
|
191
|
+
orgId: input.scope === "organization" ? actor.orgId : undefined,
|
|
192
|
+
runAs: "creator",
|
|
193
|
+
nextRun: input.triggerType === "schedule"
|
|
194
|
+
? nextOccurrence(schedule).toISOString()
|
|
195
|
+
: undefined,
|
|
196
|
+
model: input.model?.trim() || undefined,
|
|
197
|
+
mcpTools: mcpTools?.length ? mcpTools : undefined,
|
|
198
|
+
originScopeId: input.delivery?.originScopeId,
|
|
199
|
+
deliveryPlatform: input.delivery?.platform,
|
|
200
|
+
deliveryDestination: input.delivery?.destination,
|
|
201
|
+
deliveryThreadRef: input.delivery?.threadRef,
|
|
202
|
+
deliveryTenantId: input.delivery?.tenantId,
|
|
203
|
+
};
|
|
204
|
+
const content = buildJobResourceContent(meta, body);
|
|
205
|
+
await resourcePut(owner, path, content);
|
|
206
|
+
return {
|
|
207
|
+
name: automationName(path),
|
|
208
|
+
scope: input.scope,
|
|
209
|
+
meta: { ...meta, triggerType: input.triggerType, mode: "agentic" },
|
|
210
|
+
body,
|
|
211
|
+
canUpdate: true,
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
export async function updateAutomation(actorInput, input) {
|
|
215
|
+
const definition = await readDefinition(actorInput, input.scope, input.name);
|
|
216
|
+
if (!definition.canUpdate) {
|
|
217
|
+
throw httpError("Only the automation's creator or an organization admin can update it.", 403);
|
|
218
|
+
}
|
|
219
|
+
const { meta } = definition;
|
|
220
|
+
if (input.schedule !== undefined) {
|
|
221
|
+
if (meta.triggerType !== "schedule") {
|
|
222
|
+
throw httpError("Event automations do not have a cron schedule.", 400);
|
|
223
|
+
}
|
|
224
|
+
if (!isValidCron(input.schedule)) {
|
|
225
|
+
throw httpError(`Invalid cron expression "${input.schedule}".`, 400);
|
|
226
|
+
}
|
|
227
|
+
meta.schedule = input.schedule;
|
|
228
|
+
meta.nextRun = nextOccurrence(input.schedule).toISOString();
|
|
229
|
+
}
|
|
230
|
+
if (input.enabled !== undefined) {
|
|
231
|
+
meta.enabled = input.enabled;
|
|
232
|
+
if (input.enabled &&
|
|
233
|
+
meta.triggerType === "schedule" &&
|
|
234
|
+
isValidCron(meta.schedule)) {
|
|
235
|
+
meta.nextRun = nextOccurrence(meta.schedule).toISOString();
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
if (input.condition !== undefined) {
|
|
239
|
+
meta.condition = input.condition?.trim() || undefined;
|
|
240
|
+
}
|
|
241
|
+
if (input.delegatedPolicyId !== undefined) {
|
|
242
|
+
meta.delegatedPolicyId = input.delegatedPolicyId?.trim() || undefined;
|
|
243
|
+
}
|
|
244
|
+
if (input.model !== undefined) {
|
|
245
|
+
meta.model = input.model?.trim() || undefined;
|
|
246
|
+
}
|
|
247
|
+
if (input.mcpTools !== undefined) {
|
|
248
|
+
const mcpTools = normalizeJobMcpTools(input.mcpTools);
|
|
249
|
+
meta.mcpTools = mcpTools?.length ? mcpTools : undefined;
|
|
250
|
+
}
|
|
251
|
+
if (input.scope === "organization") {
|
|
252
|
+
meta.orgId = organizationIdFromResourceOwner(definition.resource.owner);
|
|
253
|
+
meta.runAs = "creator";
|
|
254
|
+
}
|
|
255
|
+
const body = input.body === undefined ? definition.body : input.body.trim();
|
|
256
|
+
if (!body)
|
|
257
|
+
throw httpError("Automation body is required.", 400);
|
|
258
|
+
await resourcePut(definition.resource.owner, definition.resource.path, buildJobResourceContent(meta, body));
|
|
259
|
+
return { ...definition, meta, body };
|
|
260
|
+
}
|
|
261
|
+
export async function deleteAutomation(actorInput, scope, name) {
|
|
262
|
+
const definition = await readDefinition(actorInput, scope, name);
|
|
263
|
+
if (!definition.canUpdate) {
|
|
264
|
+
throw httpError("Only the automation's creator or an organization admin can delete it.", 403);
|
|
265
|
+
}
|
|
266
|
+
await resourceDelete(definition.resource.id);
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Resolve the identity used by an explicit automation run.
|
|
270
|
+
*
|
|
271
|
+
* Organization automations are visible through their organization owner, but
|
|
272
|
+
* always execute as their immutable creator. Event dispatchers must also
|
|
273
|
+
* require EventMeta.owner to equal `eventOwner`; organization visibility does
|
|
274
|
+
* not make an event organization-wide.
|
|
275
|
+
*/
|
|
276
|
+
export async function resolveAutomationExecutionIdentity(resourceOwner, meta) {
|
|
277
|
+
const orgId = organizationIdFromResourceOwner(resourceOwner);
|
|
278
|
+
if (!orgId) {
|
|
279
|
+
const userEmail = (meta.createdBy || resourceOwner).trim().toLowerCase();
|
|
280
|
+
if (!userEmail || userEmail !== resourceOwner.trim().toLowerCase()) {
|
|
281
|
+
return {
|
|
282
|
+
ok: false,
|
|
283
|
+
reason: "Personal automation creator does not match its owner.",
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
return { ok: true, identity: { userEmail, eventOwner: userEmail } };
|
|
287
|
+
}
|
|
288
|
+
const userEmail = meta.createdBy?.trim().toLowerCase();
|
|
289
|
+
if (!userEmail) {
|
|
290
|
+
return {
|
|
291
|
+
ok: false,
|
|
292
|
+
reason: "Organization automation has no creator identity.",
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
if (meta.runAs !== "creator") {
|
|
296
|
+
return {
|
|
297
|
+
ok: false,
|
|
298
|
+
reason: "Organization automations must run as their creator.",
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
if (meta.orgId && meta.orgId !== orgId) {
|
|
302
|
+
return {
|
|
303
|
+
ok: false,
|
|
304
|
+
reason: "Organization automation metadata does not match its owner.",
|
|
305
|
+
};
|
|
306
|
+
}
|
|
307
|
+
const user = await getDbExec().execute({
|
|
308
|
+
sql: `SELECT 1 FROM "user" WHERE LOWER(email) = ? LIMIT 1`,
|
|
309
|
+
args: [userEmail],
|
|
310
|
+
});
|
|
311
|
+
if (!user.rows.length) {
|
|
312
|
+
return {
|
|
313
|
+
ok: false,
|
|
314
|
+
reason: `Automation creator "${userEmail}" no longer exists.`,
|
|
315
|
+
};
|
|
316
|
+
}
|
|
317
|
+
if (!(await readOrganizationMembership(orgId, userEmail))) {
|
|
318
|
+
return {
|
|
319
|
+
ok: false,
|
|
320
|
+
reason: `Automation creator "${userEmail}" is no longer a member of organization "${orgId}".`,
|
|
321
|
+
};
|
|
322
|
+
}
|
|
323
|
+
return {
|
|
324
|
+
ok: true,
|
|
325
|
+
identity: { userEmail, orgId, eventOwner: userEmail },
|
|
326
|
+
};
|
|
327
|
+
}
|
|
328
|
+
export function automationMatchesEventOwner(identity, eventOwner) {
|
|
329
|
+
return (typeof eventOwner === "string" &&
|
|
330
|
+
eventOwner.trim().toLowerCase() === identity.eventOwner);
|
|
331
|
+
}
|
|
332
|
+
//# sourceMappingURL=service.js.map
|