@agent-native/core 0.131.5 → 0.131.7
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 +3 -3
- package/corpus/core/CHANGELOG.md +70 -0
- package/corpus/core/docs/content/agent-native-toolkit.mdx +13 -6
- package/corpus/core/docs/content/cloneable-saas.mdx +5 -5
- package/corpus/core/docs/content/creating-templates.mdx +9 -0
- package/corpus/core/docs/content/deployment.mdx +18 -12
- package/corpus/core/docs/content/doctor.mdx +8 -1
- package/corpus/core/docs/content/drop-in-agent.mdx +1 -1
- package/corpus/core/docs/content/extensions.mdx +18 -18
- package/corpus/core/docs/content/faq.mdx +4 -4
- package/corpus/core/docs/content/key-concepts.mdx +30 -21
- package/corpus/core/docs/content/security.mdx +2 -2
- package/corpus/core/docs/content/template-brain-developers.mdx +4 -1
- package/corpus/core/docs/content/template-mail-developers.mdx +4 -1
- package/corpus/core/docs/content/what-is-agent-native.mdx +6 -6
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/a2a/client.ts +449 -66
- package/corpus/core/src/a2a/correlation.ts +31 -0
- package/corpus/core/src/a2a/invoke.ts +4 -2
- package/corpus/core/src/a2a/types.ts +4 -0
- package/corpus/core/src/action.ts +3 -0
- package/corpus/core/src/agent/action-continuation-guidance.ts +2 -1
- package/corpus/core/src/agent/engine/registry.ts +98 -6
- package/corpus/core/src/agent/production-agent.ts +151 -18
- package/corpus/core/src/agent/run-loop-with-resume.ts +190 -3
- package/corpus/core/src/agent/run-manager.ts +117 -41
- package/corpus/core/src/agent/thread-debug-history.ts +86 -0
- package/corpus/core/src/agent/types.ts +3 -1
- package/corpus/core/src/cli/create.ts +11 -1
- package/corpus/core/src/cli/templates-meta.ts +2 -2
- package/corpus/core/src/client/agent-chat-adapter.ts +91 -13
- package/corpus/core/src/client/resources/McpIntegrationDialog.tsx +11 -9
- package/corpus/core/src/client/sse-event-processor.ts +17 -3
- package/corpus/core/src/db/client.ts +57 -17
- package/corpus/core/src/guards/no-env-credentials.ts +2 -0
- package/corpus/core/src/integrations/adapters/slack.ts +8 -3
- package/corpus/core/src/localization/default-messages.ts +44 -0
- package/corpus/core/src/observability/traces.ts +78 -5
- package/corpus/core/src/scripts/call-agent.ts +294 -11
- package/corpus/core/src/scripts/describe-workspace-apps.ts +2 -2
- package/corpus/core/src/secrets/crypto.ts +156 -35
- package/corpus/core/src/secrets/storage.ts +64 -26
- package/corpus/core/src/server/agent-capabilities.ts +1 -1
- package/corpus/core/src/server/agent-chat/action-filters-a2a.ts +113 -7
- package/corpus/core/src/server/agent-chat/context-tools.ts +2 -0
- package/corpus/core/src/server/agent-chat/plugin-options.ts +34 -1
- package/corpus/core/src/server/agent-chat/prompt-resources.ts +1 -1
- package/corpus/core/src/server/agent-chat-plugin.ts +91 -59
- package/corpus/core/src/templates/default/.agents/skills/secrets/SKILL.md +19 -7
- package/corpus/core/src/templates/headless/.agents/skills/secrets/SKILL.md +19 -7
- package/corpus/core/src/templates/workspace-core/.agents/skills/a2a-protocol/SKILL.md +18 -7
- package/corpus/core/src/templates/workspace-core/.agents/skills/composable-mini-apps/SKILL.md +15 -14
- package/corpus/core/src/templates/workspace-core/.agents/skills/secrets/SKILL.md +19 -7
- package/corpus/core/src/vite/client.ts +1 -0
- package/corpus/templates/analytics/.agents/skills/dashboard-ops/SKILL.md +5 -4
- package/corpus/templates/analytics/.agents/skills/gong/SKILL.md +6 -4
- package/corpus/templates/analytics/AGENTS.md +7 -4
- package/corpus/templates/analytics/actions/query-agent-native-analytics.ts +4 -3
- package/corpus/templates/analytics/changelog/2026-07-30-delegated-analytics-questions-now-return-a-useful-current-me.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-30-scheduled-dashboard-emails-complete-every-panel-without-pool.md +6 -0
- package/corpus/templates/analytics/scripts/emit-netlify-dashboard-report-cron.ts +28 -1
- package/corpus/templates/analytics/server/jobs/dashboard-report.ts +18 -11
- package/corpus/templates/analytics/server/lib/analytics-connector-catalog.ts +4 -4
- package/corpus/templates/analytics/server/lib/canonical-first-party-dashboard-repair.ts +9 -5
- package/corpus/templates/analytics/server/lib/dashboard-panel-query.ts +6 -2
- package/corpus/templates/analytics/server/lib/dashboard-panel-source-resolver.ts +11 -4
- package/corpus/templates/analytics/server/lib/dashboard-report-render.ts +49 -31
- package/corpus/templates/analytics/server/lib/first-party-analytics.ts +16 -8
- package/corpus/templates/analytics/server/lib/first-party-metric-catalog.ts +9 -3
- package/corpus/templates/analytics/server/lib/production-serverless-runtime.ts +11 -0
- package/corpus/templates/analytics/server/lib/real-data-actions.ts +10 -0
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +3 -2
- package/corpus/templates/analytics/server/plugins/analytics-alert-jobs.ts +2 -1
- package/corpus/templates/analytics/server/plugins/dashboard-report-jobs.ts +2 -1
- package/corpus/templates/analytics/server/plugins/uptime-monitor-jobs.ts +1 -12
- package/corpus/templates/brain/.agents/skills/brain/RUNBOOK.md +54 -6
- package/corpus/templates/brain/.agents/skills/brain/SKILL.md +20 -9
- package/corpus/templates/brain/.agents/skills/ingestion-and-connectors/SKILL.md +33 -1
- package/corpus/templates/brain/AGENTS.md +3 -1
- package/corpus/templates/brain/README.md +4 -1
- package/corpus/templates/brain/actions/_schemas.ts +30 -8
- package/corpus/templates/brain/actions/ask-brain.ts +124 -14
- package/corpus/templates/brain/actions/create-source.ts +18 -2
- package/corpus/templates/brain/actions/enqueue-captures-distillation.ts +8 -123
- package/corpus/templates/brain/actions/enqueue-distillation.ts +6 -127
- package/corpus/templates/brain/actions/import-capture.ts +17 -5
- package/corpus/templates/brain/actions/import-transcript.ts +17 -5
- package/corpus/templates/brain/actions/update-source.ts +25 -5
- package/corpus/templates/brain/app/components/layout/Sidebar.tsx +1 -1
- package/corpus/templates/brain/changelog/2026-07-30-blessed-resources-can-feed-cited-company-answers.md +6 -0
- package/corpus/templates/brain/changelog/2026-07-30-the-left-sidebar-no-longer-shows-a-blank-organization-placeh.md +6 -0
- package/corpus/templates/brain/server/lib/brain.ts +49 -19
- package/corpus/templates/brain/server/lib/distillation-queue.ts +147 -0
- package/corpus/templates/brain/server/lib/source-policy.ts +264 -0
- package/corpus/templates/brain/server/plugins/agent-chat.ts +3 -2
- package/corpus/templates/brain/server/routes/api/_agent-native/brain/ingest.post.ts +116 -19
- package/corpus/templates/clips/app/components/meetings/google-oauth-identity-notice.tsx +51 -0
- package/corpus/templates/clips/app/i18n/en-US.ts +4 -0
- package/corpus/templates/clips/app/routes/_app.meetings._index.tsx +3 -1
- package/corpus/templates/clips/changelog/2026-07-30-google-calendar-warning.md +6 -0
- package/corpus/templates/content/app/components/editor/VisualEditor.tsx +72 -8
- package/corpus/templates/content/changelog/2026-07-30-the-slash-command-hint-now-stays-on-only-the-active-empty-li.md +6 -0
- package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +506 -11
- package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +148 -17
- package/corpus/templates/design/app/components/design/canvas-interactions/design-canvas-interactions.ts +357 -0
- package/corpus/templates/design/app/components/design/inspector/ScrubInput.tsx +7 -466
- package/corpus/templates/design/app/components/design/inspector/scrub-input-utils.ts +15 -311
- package/corpus/templates/design/app/components/visual-editor/CanvasCommentPins.tsx +19 -997
- package/corpus/templates/design/app/components/visual-editor/DrawOverlay.tsx +8 -1216
- package/corpus/templates/design/app/hooks/useDesignHotkeys.ts +31 -38
- package/corpus/templates/design/package.json +0 -1
- package/corpus/templates/dispatch/AGENTS.md +8 -0
- package/corpus/templates/dispatch/DEVELOPING.md +29 -0
- package/corpus/templates/dispatch/actions/view-screen.ts +34 -2
- package/corpus/templates/dispatch/app/i18n-data.ts +457 -0
- package/corpus/templates/dispatch/changelog/2026-07-30-delegated-dispatch-work-continues-reliably-in-the-background.md +6 -0
- package/corpus/templates/dispatch/changelog/2026-07-30-find-failed-runs-across-apps.md +6 -0
- package/corpus/templates/dispatch/netlify.toml +3 -0
- package/corpus/templates/plan/actions/get-visual-plan.ts +10 -6
- package/corpus/templates/plan/actions/patch-visual-plan-source.ts +117 -1
- package/corpus/templates/plan/actions/update-visual-plan.ts +56 -14
- package/corpus/templates/plan/app/pages/PlansPage.tsx +1 -1
- package/corpus/templates/plan/changelog/2026-07-30-plan-agents-recover-with-targeted-writes.md +6 -0
- package/corpus/templates/plan/shared/plan-content.ts +35 -0
- package/corpus/templates/slides/.agents/skills/analytics-data-for-decks/SKILL.md +8 -12
- package/corpus/templates/slides/AGENTS.md +4 -4
- package/corpus/templates/slides/actions/create-deck.ts +1 -1
- package/corpus/templates/slides/actions/duplicate-deck.ts +19 -4
- package/corpus/templates/slides/app/components/deck/DeckCard.tsx +2 -10
- package/corpus/templates/slides/app/components/deck/MermaidRenderer.tsx +12 -1
- package/corpus/templates/slides/app/components/deck/SlideRenderer.tsx +30 -13
- package/corpus/templates/slides/app/components/editor/DeckEditorSkeleton.tsx +35 -0
- package/corpus/templates/slides/app/components/editor/EditorSidebar.tsx +63 -56
- package/corpus/templates/slides/app/components/editor/EditorToolbar.tsx +21 -76
- package/corpus/templates/slides/app/components/editor/SlideEditor.tsx +1110 -292
- package/corpus/templates/slides/app/components/editor/SlideOverflowWarning.tsx +53 -0
- package/corpus/templates/slides/app/components/editor/SlideStyleInspector.tsx +235 -18
- package/corpus/templates/slides/app/components/editor/SpeakerNotesPanel.tsx +4 -1
- package/corpus/templates/slides/app/components/editor/canvas-interactions/index.ts +11 -0
- package/corpus/templates/slides/app/components/editor/canvas-interactions/slides-canvas-adapter.ts +129 -0
- package/corpus/templates/slides/app/components/editor/selection-overlay-measurement.ts +70 -0
- package/corpus/templates/slides/app/components/editor/slide-object-interactions.ts +519 -65
- package/corpus/templates/slides/app/components/visual-editor/CanvasCommentPins.tsx +36 -426
- package/corpus/templates/slides/app/components/visual-editor/DrawOverlay.tsx +19 -458
- package/corpus/templates/slides/app/context/DeckContext.tsx +179 -72
- package/corpus/templates/slides/app/global.css +105 -0
- package/corpus/templates/slides/app/i18n/en-US.ts +8 -0
- package/corpus/templates/slides/app/lib/deck-editor-loading.ts +26 -0
- package/corpus/templates/slides/app/lib/mermaid-blocks.ts +27 -0
- package/corpus/templates/slides/app/pages/DeckEditor.tsx +71 -38
- package/corpus/templates/slides/app/pages/Index.tsx +98 -41
- package/corpus/templates/slides/changelog/2026-07-30-deck-loading-no-longer-flashes-an-unavailable-message.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-duplicating-a-deck-from-the-deck-list-now-opens-the-copy-imm.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-layout-overflow-warning-is-readable-and-dismissible.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-new-decks-now-start-with-an-empty-slide-list-when-no-slides-.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-shared-canvas-annotations.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-slide-objects-can-be-moved-as-a-group-copied-and-pasted-with.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-slide-text-editing-and-object-controls-now-match-google-slides.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-style-panel-now-scrolls-with-speaker-notes-open-shows-the-sl.md +6 -0
- package/corpus/templates/slides/changelog/2026-07-30-top-toolbar-controls-now-use-consistent-sizing-with-undo-and.md +6 -0
- package/corpus/templates/slides/netlify.toml +3 -1
- package/corpus/templates/slides/package.json +0 -1
- package/corpus/templates/slides/server/lib/chat-attachments.ts +18 -0
- package/corpus/templates/slides/server/plugins/agent-chat.ts +5 -0
- package/corpus/templates/slides/vite.config.ts +0 -1
- package/corpus/toolkit/CHANGELOG.md +13 -0
- package/corpus/toolkit/README.md +19 -0
- package/corpus/toolkit/agent-native.eject.json +38 -0
- package/corpus/toolkit/package.json +29 -1
- package/corpus/toolkit/src/canvas-annotations/CanvasCommentPins.tsx +861 -0
- package/corpus/toolkit/src/canvas-annotations/DrawOverlay.tsx +1233 -0
- package/corpus/toolkit/src/canvas-annotations/index.ts +15 -0
- package/corpus/toolkit/src/canvas-annotations/types.ts +14 -0
- package/corpus/toolkit/src/canvas-interactions/canvas-interactions.ts +933 -0
- package/corpus/toolkit/src/canvas-interactions/index.ts +67 -0
- package/corpus/toolkit/src/design-tweaks/scrub-input-utils.ts +311 -0
- package/corpus/toolkit/src/design-tweaks/scrub-input.tsx +491 -0
- package/corpus/toolkit/src/design-tweaks/visual-style-controls.tsx +26 -171
- package/corpus/toolkit/src/index.ts +1 -0
- package/dist/a2a/client.d.ts +23 -0
- package/dist/a2a/client.d.ts.map +1 -1
- package/dist/a2a/client.js +309 -44
- package/dist/a2a/client.js.map +1 -1
- package/dist/a2a/correlation.d.ts +1 -0
- package/dist/a2a/correlation.d.ts.map +1 -1
- package/dist/a2a/correlation.js +27 -0
- package/dist/a2a/correlation.js.map +1 -1
- package/dist/a2a/invoke.d.ts.map +1 -1
- package/dist/a2a/invoke.js +4 -2
- package/dist/a2a/invoke.js.map +1 -1
- package/dist/a2a/types.d.ts +4 -0
- package/dist/a2a/types.d.ts.map +1 -1
- package/dist/a2a/types.js.map +1 -1
- package/dist/action.d.ts +3 -0
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js.map +1 -1
- package/dist/agent/action-continuation-guidance.d.ts.map +1 -1
- package/dist/agent/action-continuation-guidance.js +2 -1
- package/dist/agent/action-continuation-guidance.js.map +1 -1
- package/dist/agent/engine/registry.d.ts.map +1 -1
- package/dist/agent/engine/registry.js +82 -8
- package/dist/agent/engine/registry.js.map +1 -1
- package/dist/agent/production-agent.d.ts +40 -1
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +113 -15
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/run-loop-with-resume.d.ts +21 -0
- package/dist/agent/run-loop-with-resume.d.ts.map +1 -1
- package/dist/agent/run-loop-with-resume.js +163 -4
- package/dist/agent/run-loop-with-resume.js.map +1 -1
- package/dist/agent/run-manager.d.ts +16 -9
- package/dist/agent/run-manager.d.ts.map +1 -1
- package/dist/agent/run-manager.js +93 -42
- package/dist/agent/run-manager.js.map +1 -1
- package/dist/agent/thread-debug-history.d.ts +10 -0
- package/dist/agent/thread-debug-history.d.ts.map +1 -0
- package/dist/agent/thread-debug-history.js +68 -0
- package/dist/agent/thread-debug-history.js.map +1 -0
- package/dist/agent/types.d.ts +3 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +6 -1
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/templates-meta.js +2 -2
- package/dist/cli/templates-meta.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +76 -13
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/resources/McpIntegrationDialog.d.ts.map +1 -1
- package/dist/client/resources/McpIntegrationDialog.js +1 -1
- package/dist/client/resources/McpIntegrationDialog.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +12 -3
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +48 -17
- package/dist/db/client.js.map +1 -1
- package/dist/guards/no-env-credentials.d.ts.map +1 -1
- package/dist/guards/no-env-credentials.js +2 -0
- package/dist/guards/no-env-credentials.js.map +1 -1
- package/dist/integrations/adapters/slack.js +7 -3
- package/dist/integrations/adapters/slack.js.map +1 -1
- package/dist/localization/default-messages.d.ts +43 -0
- package/dist/localization/default-messages.d.ts.map +1 -1
- package/dist/localization/default-messages.js +43 -0
- package/dist/localization/default-messages.js.map +1 -1
- package/dist/observability/traces.d.ts +3 -1
- package/dist/observability/traces.d.ts.map +1 -1
- package/dist/observability/traces.js +73 -4
- package/dist/observability/traces.js.map +1 -1
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +12 -12
- package/dist/provider-api/actions/provider-api.d.ts +13 -13
- package/dist/provider-api/corpus-jobs.d.ts +2 -2
- package/dist/scripts/call-agent.d.ts.map +1 -1
- package/dist/scripts/call-agent.js +237 -12
- package/dist/scripts/call-agent.js.map +1 -1
- package/dist/scripts/describe-workspace-apps.js +2 -2
- package/dist/scripts/describe-workspace-apps.js.map +1 -1
- package/dist/secrets/crypto.d.ts +36 -21
- package/dist/secrets/crypto.d.ts.map +1 -1
- package/dist/secrets/crypto.js +134 -33
- package/dist/secrets/crypto.js.map +1 -1
- package/dist/secrets/storage.d.ts +6 -6
- package/dist/secrets/storage.d.ts.map +1 -1
- package/dist/secrets/storage.js +43 -26
- package/dist/secrets/storage.js.map +1 -1
- package/dist/server/agent-capabilities.js +1 -1
- package/dist/server/agent-capabilities.js.map +1 -1
- package/dist/server/agent-chat/action-filters-a2a.d.ts +17 -3
- package/dist/server/agent-chat/action-filters-a2a.d.ts.map +1 -1
- package/dist/server/agent-chat/action-filters-a2a.js +94 -3
- package/dist/server/agent-chat/action-filters-a2a.js.map +1 -1
- package/dist/server/agent-chat/context-tools.d.ts.map +1 -1
- package/dist/server/agent-chat/context-tools.js +2 -0
- package/dist/server/agent-chat/context-tools.js.map +1 -1
- package/dist/server/agent-chat/plugin-options.d.ts +23 -0
- package/dist/server/agent-chat/plugin-options.d.ts.map +1 -1
- package/dist/server/agent-chat/plugin-options.js +4 -1
- package/dist/server/agent-chat/plugin-options.js.map +1 -1
- package/dist/server/agent-chat/prompt-resources.js +1 -1
- package/dist/server/agent-chat/prompt-resources.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts +2 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +79 -56
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/realtime-token.d.ts +1 -1
- package/dist/templates/default/.agents/skills/secrets/SKILL.md +19 -7
- package/dist/templates/headless/.agents/skills/secrets/SKILL.md +19 -7
- package/dist/templates/workspace-core/.agents/skills/a2a-protocol/SKILL.md +18 -7
- package/dist/templates/workspace-core/.agents/skills/composable-mini-apps/SKILL.md +15 -14
- package/dist/templates/workspace-core/.agents/skills/secrets/SKILL.md +19 -7
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +1 -0
- package/dist/vite/client.js.map +1 -1
- package/docs/content/agent-native-toolkit.mdx +13 -6
- package/docs/content/cloneable-saas.mdx +5 -5
- package/docs/content/creating-templates.mdx +9 -0
- package/docs/content/deployment.mdx +18 -12
- package/docs/content/doctor.mdx +8 -1
- package/docs/content/drop-in-agent.mdx +1 -1
- package/docs/content/extensions.mdx +18 -18
- package/docs/content/faq.mdx +4 -4
- package/docs/content/key-concepts.mdx +30 -21
- package/docs/content/security.mdx +2 -2
- package/docs/content/template-brain-developers.mdx +4 -1
- package/docs/content/template-mail-developers.mdx +4 -1
- package/docs/content/what-is-agent-native.mdx +6 -6
- package/package.json +3 -3
- package/src/a2a/client.ts +449 -66
- package/src/a2a/correlation.ts +31 -0
- package/src/a2a/invoke.ts +4 -2
- package/src/a2a/types.ts +4 -0
- package/src/action.ts +3 -0
- package/src/agent/action-continuation-guidance.ts +2 -1
- package/src/agent/engine/registry.ts +98 -6
- package/src/agent/production-agent.ts +151 -18
- package/src/agent/run-loop-with-resume.ts +190 -3
- package/src/agent/run-manager.ts +117 -41
- package/src/agent/thread-debug-history.ts +86 -0
- package/src/agent/types.ts +3 -1
- package/src/cli/create.ts +11 -1
- package/src/cli/templates-meta.ts +2 -2
- package/src/client/agent-chat-adapter.ts +91 -13
- package/src/client/resources/McpIntegrationDialog.tsx +11 -9
- package/src/client/sse-event-processor.ts +17 -3
- package/src/db/client.ts +57 -17
- package/src/guards/no-env-credentials.ts +2 -0
- package/src/integrations/adapters/slack.ts +8 -3
- package/src/localization/default-messages.ts +44 -0
- package/src/observability/traces.ts +78 -5
- package/src/scripts/call-agent.ts +294 -11
- package/src/scripts/describe-workspace-apps.ts +2 -2
- package/src/secrets/crypto.ts +156 -35
- package/src/secrets/storage.ts +64 -26
- package/src/server/agent-capabilities.ts +1 -1
- package/src/server/agent-chat/action-filters-a2a.ts +113 -7
- package/src/server/agent-chat/context-tools.ts +2 -0
- package/src/server/agent-chat/plugin-options.ts +34 -1
- package/src/server/agent-chat/prompt-resources.ts +1 -1
- package/src/server/agent-chat-plugin.ts +91 -59
- package/src/templates/default/.agents/skills/secrets/SKILL.md +19 -7
- package/src/templates/headless/.agents/skills/secrets/SKILL.md +19 -7
- package/src/templates/workspace-core/.agents/skills/a2a-protocol/SKILL.md +18 -7
- package/src/templates/workspace-core/.agents/skills/composable-mini-apps/SKILL.md +15 -14
- package/src/templates/workspace-core/.agents/skills/secrets/SKILL.md +19 -7
- package/src/vite/client.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"context-tools.js","sourceRoot":"","sources":["../../../src/server/agent-chat/context-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mCAAmC,EAAE,MAAM,oBAAoB,CAAC;AAEzE,OAAO,EACL,mBAAmB,EACnB,4BAA4B,EAC5B,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,8EAA8E;AAC9E,mEAAmE;AACnE,yEAAyE;AACzE,6EAA6E;AAC7E,sBAAsB;AACtB,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAA2B;IAChE,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;8FAoBoF;IAE5F,cAAc,EAAE;;;;;;;+KAO6J;IAE7K,aAAa,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qiBAiCohB;IAEniB,gBAAgB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0YAkCsX;IAExY,OAAO,EAAE;;yoBAE8nB;IAEvoB,OAAO,EAAE;;;;;;;;;;;;;;;;;;;2HAmBgH;IAEzH,YAAY,EA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;4BACL,IAAI,EAAE,QAAQ;4BACd,WAAW,EACT,0HAA0H;yBAC7H;wBACD,WAAW,EAAE;4BACX,IAAI,EAAE,QAAQ;4BACd,WAAW,EACT,8HAA8H;yBACjI;qBACF;oBACD,QAAQ,EAAE,CAAC,QAAQ,CAAC;iBACrB;aACF;YACD,GAAG,EAAE,KAAK,EAAE,IAAI,EAAE,EAAE,CAClB,mBAAmB,CAAC,sBAAsB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAC1D;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { ACTION_CHAT_UI_DATA_WIDGET_RENDERER } from \"../../action-ui.js\";\nimport type { ActionEntry } from \"../../agent/production-agent.js\";\nimport {\n clampDataWidgetRows,\n DATA_WIDGET_MAX_CHART_POINTS,\n DATA_WIDGET_MAX_ROWS,\n dataWidgetResultSchema,\n} from \"../../data-widgets/index.js\";\nimport { getRequestRunContext } from \"../request-context.js\";\n\n// ---------------------------------------------------------------------------\n// Framework-owned \"context\" action entries: get-framework-context,\n// refresh-screen, the URL/ask-question tools, and the native data-widget\n// renderer. These are generic, template-agnostic tools registered into every\n// app's tool surface.\n// ---------------------------------------------------------------------------\n\n/**\n * Verbose framework sections returned by the `get-framework-context` tool.\n * Keyed by topic so the agent can request specific sections.\n * Not template-specific — lives outside buildFrameworkPrompts().\n */\nexport const FRAMEWORK_CONTEXT_SECTIONS: Record<string, string> = {\n embeds: `### Inline Embeds\n\nYou can embed an interactive view inline in your chat reply by writing an \\`embed\\` fenced code block. The chat renderer swaps the fence for a sandboxed iframe pointing at a route inside this app.\n\nSyntax:\n\n\\`\\`\\`\\`\n\\`\\`\\`embed\nsrc: /some/path?param=value\naspect: 16/9\ntitle: Optional label\n\\`\\`\\`\n\\`\\`\\`\\`\n\nKeys:\n- \\`src\\` (required) — **must be a same-origin path starting with \\`/\\`**. Cross-origin URLs are blocked. No \\`javascript:\\` or \\`data:\\` URLs.\n- \\`aspect\\` (optional) — one of \\`16/9\\` (default), \\`4/3\\`, \\`3/2\\`, \\`2/1\\`, \\`21/9\\`, \\`1/1\\`.\n- \\`title\\` (optional) — accessible label / hover tooltip.\n- \\`height\\` (optional) — fixed pixel height when aspect ratio isn't a good fit.\n\nUse for charts, visualizations, previews. Don't use for simple text/tables or external sites.`,\n\n \"chat-history\": `### Chat History\n\nYou can search and restore previous chat conversations using \\`chat-history\\`:\n- \\`chat-history\\` (action: \"search\") — Search or list past chat threads by keyword. Archived threads are excluded by default; pass \\`includeArchived: true\\` to also see them.\n- \\`chat-history\\` (action: \"open\") — Open a chat thread in the UI as a new tab and focus it\n- \\`chat-history\\` (actions: \"rename\", \"pin\", \"unpin\", \"archive\") — Organize a known chat thread by ID. Archiving a thread hides it from the default chat list and search.\n\nWhen the user asks to find a previous conversation, use \\`chat-history\\` with action \"search\" first to find matching threads, then action \"open\" to restore the one they want.`,\n\n \"agent-teams\": `### Agent Teams — Orchestration\n\nYou can delegate to background sub-agents with the \\`agent-teams\\` tool:\n- \\`agent-teams\\` (action: \"spawn\") — Launch a sub-agent on a task. It runs in its own thread with a clean context while you stay available; a live preview card appears in the chat. The spawn result confirms launch only, not completion. Optionally pass a custom agent profile from \\`agents/*.md\\` via the \\`agent\\` parameter.\n- \\`agent-teams\\` (action: \"status\") — Check a running sub-agent's progress.\n- \\`agent-teams\\` (action: \"read-result\") — Read a finished sub-agent's output.\n- \\`agent-teams\\` (action: \"send\") — Message a running sub-agent.\n- \\`agent-teams\\` (action: \"list\") — List sub-agent tasks.\n\nSub-agents inherit all of your template tools but **cannot spawn sub-agents themselves** — only you orchestrate.\n\n**User intent phrases.** If the user asks you to use a \"sub-agent\" or \"background agent\", that is explicit delegation intent. Also treat phrases like \"run these in the background\", \"kick off the rest\", \"run the queued items\", \"batch run these jobs\", \"parallelize this\", or \"start the next batch\" as delegation intent when the context is a set of independent work items.\n\n**Spawn is not completion.** A successful \\`spawn\\` call means the sub-agent started and is running. Tell the user it started, show the task id if useful, and then use \\`status\\`/\\`list\\`/\\`read-result\\` to monitor it. Never say the delegated task \"completed\", \"ran successfully\", or \"finished\" until \\`status\\` or \\`read-result\\` reports \\`completed\\` or \\`errored\\`. If a task is still running, say that plainly.\n\n**Default to doing the work yourself in this thread.** A sub-agent costs real tokens and adds a merge step, so reach for one only when delegation clearly pays for that overhead.\n\n**Delegate ONE sub-agent** when a task is self-contained and heavy: deep research, long multi-step content generation, or a noisy scan whose intermediate steps would clutter this thread. The sub-agent gets its own clean context and hands you back a distilled result.\n\n**Fan out to MULTIPLE sub-agents ONLY** for units of work that are genuinely independent and don't depend on each other's decisions — e.g. research three unrelated competitors, summarize five separate threads, draft sections that don't reference one another. Each gets a distinct slice.\n\n**Do NOT parallelize tightly-coupled work** — one cohesive artifact, edits that must agree with each other, or anything needing a single consistent voice or style. Parallel sub-agents can't see each other's choices and their outputs will clash. For coupled work, do it yourself, or chain sub-agents one at a time, feeding each result into the next.\n\n**Cap fan-out:** aim for 1, use up to ~3, and go beyond that only for clearly independent bulk work. More sub-agents means more tokens and a harder merge.\n\n**Briefing contract.** A sub-agent starts in a fresh thread and can only see the brief you give it — it cannot see this conversation or ask you to clarify before it runs. Make every brief self-contained:\n1. **Objective** — what \"done\" looks like, in a sentence or two.\n2. **Context** — the specific facts it needs from this conversation: IDs, names, the user's actual goal, constraints, prior decisions. Paste the specifics; don't assume it knows them.\n3. **Output format** — what to return and how (e.g. \"a 3-bullet summary with source links\", \"the drafted email body only\") so the result drops cleanly into your synthesis.\n4. **Boundaries** — what NOT to do, and for parallel sub-agents, which slice is theirs so they don't overlap.\n\nPut the objective and output format in \\`task\\`; put longer context in \\`instructions\\`.\n\n**Synthesis discipline.** After the sub-agents you depend on finish, poll \\`status\\`/\\`list\\` until they're complete, then pull each one's output with \\`read-result\\`. Do NOT paste their outputs back to back. Read all results, reconcile any disagreements, de-duplicate, and write ONE integrated answer in your own voice. If two sub-agents conflict, resolve it or flag the discrepancy explicitly rather than presenting both. When findings came from distinct investigations, briefly note which finding came from where so the user can trust the merge.`,\n\n \"recurring-jobs\": `### Recurring Jobs\n\nYou can create recurring jobs that run on a cron schedule. Jobs are resource files under \\`jobs/\\`.\n\n- \\`manage-jobs\\` (action: \"create\") — Create a new recurring job with a cron schedule and instructions\n- \\`manage-jobs\\` (action: \"list\") — List all recurring jobs and their status\n- \\`manage-jobs\\` (action: \"update\") — Update a job's schedule, instructions, or toggle enabled/disabled\n- Delete a job with the \\`resources\\` tool: \\`action: \"delete\"\\`, \\`path: \"jobs/<name>.md\"\\`\n\nConvert natural language to 5-field cron format:\n- \"every morning\" / \"daily at 9am\" → \\`0 9 * * *\\`\n- \"every weekday at 9am\" → \\`0 9 * * 1-5\\`\n- \"every hour\" → \\`0 * * * *\\`\n- \"every monday at 9am\" → \\`0 9 * * 1\\`\n\nWhen a recurring job needs a connected MCP, discover the exact MCP tool names\navailable in the current user/org context and pass them in the create call's\n\\`mcpTools\\` array. Bind only the tools the job needs; do not put an MCP URL,\nOAuth token, or arbitrary endpoint in the instructions. The scheduler resolves\nthe selected tools with the job owner's existing connector grant and fails\nclearly if a connector is revoked or a selected tool disappears. For imports,\nnormalize the provider response and call the app's bounded idempotent import\naction once with the full batch rather than issuing one write per item.\n\n#### Suggesting \"Save as automation\"\n\nWhen you finish a task that has obvious recurring value — daily inbox triage, weekly metrics summaries, archive sweeps, status digests, anything the user would plausibly want re-run on a fresh cadence — close the response with ONE short line offering to save it. Examples:\n\n- After \"Summarize my unread emails\": _\"Want me to run this every morning?\"_\n- After \"What's our top traffic source this week\": _\"Want a weekly digest on Mondays?\"_\n- After \"Archive emails older than 30 days\": _\"Should I run this every Sunday?\"_\n\nIf the user says yes, call \\`manage-jobs\\` (action: \"create\") with the original prompt as the job's instructions and the cadence they confirmed.\n\nDo NOT add this offer for one-shot work: lookups (find Alice, what's the schema, who reported X), single drafts/replies, navigation requests, or any task whose value is in the moment. Skip it when the prompt is already explicitly recurring (the user said \"every morning…\" — you'd be asking what they already told you). One short sentence at most; do not turn it into a list of cadence options.`,\n\n builder: `### Connecting Builder.io\n\nWhen the user asks to connect Builder.io or you hit a \"Builder not configured\" error, call the \\`connect-builder\\` tool. It renders a Connect/code-change card inline — do NOT write out multi-step setup instructions yourself. Inspect the returned \\`builderEnabled\\` flag: \\`true\\` means Builder Cloud Agents can take the code-change handoff, while \\`false\\` means this requires a code change and the user should edit locally or use Builder.io to edit this code in the cloud and continue customizing the app any way they like. If Builder Cloud Agents are not available for this workspace, never send the user to Builder org settings or beta settings.`,\n\n browser: `### Browser Automation\n\nYou can activate a real Chrome browser via Builder.io for tasks that need full page rendering:\n- Extracting design tokens from JS-heavy or SPA websites (computed styles, rendered colors/fonts)\n- Taking screenshots of live pages\n- Testing interactive flows on deployed URLs\n- Reading content from pages that require JavaScript execution\n\n**How to use:**\n1. In local development, call \\`set-browser-control\\` with \\`{\"enabled\":true,\"backend\":\"chrome-devtools\"}\\` after confirming once with the user. In production, use \\`activate-browser\\` for Builder-provisioned Chrome.\n2. On your next action, use \\`mcp__chrome-devtools__navigate_page\\`, \\`mcp__chrome-devtools__evaluate_script\\`, \\`mcp__chrome-devtools__take_screenshot\\`, etc.\n3. If Builder is not connected, call \\`connect-builder\\` first\n\n**When to recommend browser automation:**\n- User wants to import a design system from a URL (JS-rendered sites give almost no useful data from plain HTML fetch)\n- User asks you to check how a deployed site looks or behaves\n- Any task involving reading computed/rendered page state\n- When \\`web-request\\` returns minimal/skeleton HTML from a modern SPA\n\nPrefer \\`web-request\\` for simple API calls and static pages. Use browser automation when you need the real rendered page.`,\n\n \"call-agent\": `### call-agent — External Apps Only\n\nThe \\`call-agent\\` tool sends a message to a DIFFERENT, separately-deployed app's agent (A2A protocol). It is **not** for calling actions within the current app.\n\n**NEVER use \\`call-agent\\` to:**\n- Call your own app by name\n- Perform tasks you can accomplish with your own registered tools\n\n**ONLY use \\`call-agent\\` when:**\n- The user explicitly asks you to communicate with a different app\n- You need data that only another deployed app can provide\n- You need brand-consistent generated media and this app does not have a native generation action; call agent \"assets\" and keep returned asset IDs and URLs verbatim\n\nIf \\`call-agent\\` says a downstream agent accepted the subtask and will post its result separately, do not call that same agent again for the same subtask. Continue any remaining work and answer with the completed results you have.`,\n\n memory: `### Structured Memory\n\nYour memory index (\\`memory/MEMORY.md\\`) is loaded at the start of every conversation.\n\n**Tools:**\n- \\`save-memory\\` — Create or update a memory (name, type, description, content)\n- \\`delete-memory\\` — Remove a memory and its index entry\n- \\`resources\\` with \\`action: \"read\"\\` and \\`path: \"memory/<name>.md\"\\` — Read the full content of a specific memory\n\n**Memory types:** user, feedback, project, reference\n\n**When to save (proactively):**\n- User corrects your approach → \\`feedback\\`\n- User shares preferences → \\`user\\`\n- Non-obvious pattern or gotcha → \\`feedback\\`\n- Personal context (contacts, team) → \\`user\\`\n- Project context to track → \\`project\\`\n\n**Rules:**\n- Don't save things obvious from code or standard framework behavior\n- When updating, read first and merge — don't overwrite\n- Keep descriptions concise\n- One memory per logical topic`,\n\n \"sql-tools\": `### SQL Tools\n\nWhen database tools are enabled, \\`db-schema\\` refreshes the schema and \\`db-query\\` runs read-only SELECT queries with current user/org scoping. Raw SQL write tools are only available when the app explicitly opts into database write tools; by default, writes go through typed app actions. Some apps configure database tools as read-only or off; only use tools that are actually present in your tool list.\n\n- \\`db-schema\\` — refresh the full schema with indexes and foreign keys\n- \\`db-query\\` — run a SELECT (read-only; results already filtered to the current user/org)\n- \\`db-exec\\` — only when present: run INSERT / UPDATE / DELETE / REPLACE for scoped maintenance. For normal product data writes, use a typed app action instead.\n- \\`db-patch\\` — only when present: surgical search-and-replace on a large text column. If a typed app action exists for the resource, use that action.\n\n### When to pick which SQL tool\n- A template-specific action exists for the table → use that action (it encodes business rules and pushes live Yjs updates)\n- Read data → \\`db-query\\`. Never re-add \\`WHERE owner_email = ...\\` — scoping already applies it.\n- Raw write tools are present and no app action exists → use \\`db-exec\\` or \\`db-patch\\` only for deliberate maintenance, not normal product workflows.\n\n### External data sources vs the app database\nThe \\`db-*\\` tools ONLY query the app's own SQL database. They do NOT reach external data warehouses. If the user asks about tables NOT in the schema, use the appropriate template action instead.`,\n};\n\nexport function createFrameworkContextEntry(): Record<string, ActionEntry> {\n const topicList = Object.keys(FRAMEWORK_CONTEXT_SECTIONS).join(\", \");\n return {\n \"get-framework-context\": {\n tool: {\n description: `Read detailed framework instructions for a specific capability. Available topics: ${topicList}. Call with topic=\"all\" to get everything.`,\n parameters: {\n type: \"object\" as const,\n properties: {\n topic: {\n type: \"string\",\n description: `Topic to read. One of: ${topicList}, or \"all\" for everything.`,\n },\n },\n required: [\"topic\"],\n },\n },\n run: async (args: Record<string, string>) => {\n const topic = String(args.topic ?? \"all\").toLowerCase();\n if (topic === \"all\") {\n return Object.values(FRAMEWORK_CONTEXT_SECTIONS).join(\"\\n\\n\");\n }\n const section = FRAMEWORK_CONTEXT_SECTIONS[topic];\n if (!section) {\n return `Unknown topic \"${topic}\". Available: ${topicList}`;\n }\n return section;\n },\n readOnly: true,\n },\n };\n}\n\n/**\n * Creates the `refresh-screen` tool. Writes a bump to `application_state`\n * under a well-known key; the client's `useDbSync` watches for this and\n * invalidates react-query caches so the on-screen UI re-fetches its data\n * without a full page reload.\n *\n * This is the standard way for the agent to say \"the data on the screen\n * just changed, please refresh it\" — e.g. after editing a dashboard config,\n * updating a form schema, or mutating a row that the current view renders.\n */\nexport function createRefreshScreenEntry(): Record<string, ActionEntry> {\n return {\n \"refresh-screen\": {\n // Writes __screen_refresh__ to application_state, which emits its own\n // distinct `screen-refresh` poll event. Don't double-emit a generic\n // `action` event on top of that.\n readOnly: true,\n // Refetching volatile on-screen state is the entire point of this\n // tool — an identical repeat call (even with the same scope) is a\n // legitimate re-refresh, not a redundant read to skip.\n dedupe: false,\n tool: {\n description:\n \"Manually refresh the user's current screen. The framework ALREADY auto-refreshes after any successful mutating action tool call (template actions and any enabled raw DB write tools) — you do NOT need to call this after a normal action. Use it only when (a) you mutated data via a path the framework can't detect (e.g. a direct write to an external system the app mirrors), or (b) you want to pass a `scope` hint so the UI narrows which queries to refetch. The UI re-fetches its queries without a full page reload.\",\n parameters: {\n type: \"object\",\n properties: {\n scope: {\n type: \"string\",\n description:\n \"Optional hint describing what changed (e.g. 'dashboard', 'form', 'settings'). Templates may use it to narrow which queries to invalidate; if omitted, all queries are invalidated.\",\n },\n },\n },\n },\n run: async (args) => {\n const { writeAppState } =\n await import(\"../../application-state/script-helpers.js\");\n const nonce = Date.now();\n const scope = typeof args?.scope === \"string\" ? args.scope : undefined;\n await writeAppState(SCREEN_REFRESH_KEY, {\n nonce,\n ...(scope ? { scope } : {}),\n });\n return `refreshed${scope ? ` (scope: ${scope})` : \"\"}`;\n },\n },\n };\n}\n\n/** Well-known application-state key used by the refresh-screen tool. */\nconst SCREEN_REFRESH_KEY = \"__screen_refresh__\";\nconst SAFE_BROWSER_TAB_ID_RE = /^[A-Za-z0-9_-]{1,96}$/;\n\nexport function appStateKeyForBrowserTab(\n key: string,\n browserTabId: unknown,\n): string {\n if (typeof browserTabId !== \"string\") return key;\n const trimmed = browserTabId.trim();\n return SAFE_BROWSER_TAB_ID_RE.test(trimmed) ? `${key}:${trimmed}` : key;\n}\n\n/**\n * Creates the `set-search-params` / `set-url-path` tools. Writes a one-shot\n * URL command to application_state; the client's URLSync component applies\n * it via react-router (no full page reload) and then deletes the command.\n *\n * This is how the agent edits URL state — filter query params, route\n * changes, hash — without needing a per-template navigate action. The\n * current URL is visible to the agent via the auto-injected `<current-url>`\n * block, which includes parsed search params.\n */\nexport function createUrlTools(): Record<string, ActionEntry> {\n return {\n \"set-search-params\": {\n // Writes __set_url__ to application_state, which the app-state watcher\n // already surfaces as a poll event. No need to double-emit.\n readOnly: true,\n tool: {\n description:\n \"Update the URL query string on the user's current page. Use this to change dashboard/list filters, search terms, or any other state the app stores in `?foo=bar` style query params. One-shot — the UI applies it in ~1s without a page reload. See the current URL + parsed search params in the auto-injected `<current-url>` block. Keys are the exact query param names as they appear in the URL (e.g. `f_pubDateStart`, not just `pubDateStart`). Set a value to null or empty string to clear that param. By default merges over existing params — pass `merge: false` to replace them all.\",\n parameters: {\n type: \"object\",\n properties: {\n params: {\n type: \"object\",\n description:\n 'Map of query param → value. Each value is a string, or null/\"\" to clear. Example: {\"f_pubDateStart\": null, \"f_cadence\": \"MONTH\"}.',\n },\n merge: {\n type: \"string\",\n description:\n '\"true\" (default) merges over existing params; \"false\" replaces them entirely.',\n enum: [\"true\", \"false\"],\n },\n },\n required: [\"params\"],\n },\n },\n run: async (args) => {\n const params = (args?.params ?? {}) as unknown as Record<\n string,\n string | null\n >;\n const merge = (args as any)?.merge !== \"false\";\n const { writeAppState } =\n await import(\"../../application-state/script-helpers.js\");\n await writeAppState(\n appStateKeyForBrowserTab(\n \"__set_url__\",\n getRequestRunContext()?.browserTabId,\n ),\n {\n searchParams: params,\n mergeSearchParams: merge,\n // Unique-per-write token. The client's URLSync hook dedups by this\n // so a fire-and-forget DELETE that loses its race against the next\n // polling refetch can't cause the same URL command to be applied\n // repeatedly (which caused the editor to bounce between slides\n // when an agent turn errored partway through).\n _writeId: `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,\n },\n );\n const keys = Object.keys(params);\n return `set-search-params: ${keys.length} key${keys.length === 1 ? \"\" : \"s\"}${merge ? \"\" : \" (replace)\"}`;\n },\n },\n \"set-url-path\": {\n // Same as set-search-params — writes application_state, already emits\n // via the app-state watcher.\n readOnly: true,\n tool: {\n description:\n \"Navigate the user to a different pathname, optionally also setting search params. For most template-specific routing prefer the template's `navigate` action if it exists — this is the generic fallback. One-shot, applied by the client without a page reload.\",\n parameters: {\n type: \"object\",\n properties: {\n pathname: {\n type: \"string\",\n description: \"New URL pathname (e.g. '/adhoc/weekly').\",\n },\n params: {\n type: \"object\",\n description:\n 'Optional query params to set alongside the path change. String values set, null/\"\" clears.',\n },\n merge: {\n type: \"string\",\n description:\n '\"true\" (default) merges over existing params; \"false\" starts fresh.',\n enum: [\"true\", \"false\"],\n },\n },\n required: [\"pathname\"],\n },\n },\n run: async (args) => {\n const pathname = String(args?.pathname ?? \"\");\n if (!pathname.startsWith(\"/\")) {\n return \"Error: pathname must start with '/'.\";\n }\n const params = (args?.params ?? {}) as unknown as Record<\n string,\n string | null\n >;\n const merge = (args as any)?.merge !== \"false\";\n const { writeAppState } =\n await import(\"../../application-state/script-helpers.js\");\n await writeAppState(\n appStateKeyForBrowserTab(\n \"__set_url__\",\n getRequestRunContext()?.browserTabId,\n ),\n {\n pathname,\n searchParams: params,\n mergeSearchParams: merge,\n // See note in set-search-params: unique-per-write dedup token so a\n // race between GET and consume-DELETE in URLSync can't re-apply\n // this command.\n _writeId: `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,\n },\n );\n return `set-url-path: ${pathname}`;\n },\n },\n \"ask-question\": {\n tool: {\n description:\n \"Ask the user a multiple-choice clarifying question and render it inline in the chat. Use this ONLY when you are genuinely blocked on a decision you cannot resolve from context and a wrong guess would be costly — an ambiguous metric, date range, or grain; a real fork in approach. Present 2-5 concrete options and mark the most likely one recommended. Do NOT use it for confirmations, for things the user already specified, or to dodge easy work you could just do. Ask at most once per turn. Calling this yields the turn: stop and wait for the user's answer.\",\n parameters: {\n type: \"object\",\n properties: {\n question: {\n type: \"string\",\n description:\n \"The complete question to ask the user. Clear, specific, ends with a question mark.\",\n },\n header: {\n type: \"string\",\n description:\n 'Optional very short label (max ~12 chars) shown as a chip/heading above the question, e.g. \"Date range\", \"Approach\", \"Library\".',\n },\n options: {\n type: \"string\",\n description:\n 'A JSON array of 2-4 distinct, mutually-exclusive options (unless `allowMultiple` is true), each `{ \"label\": string, \"value\"?: string, \"description\"?: string, \"preview\"?: string, \"recommended\"?: boolean }`. `label` is 1-5 words; `description` explains the trade-off; `preview` is optional content (mockup, code snippet, short comparison) rendered under the option. `value` defaults to `label` when omitted. Mark the most likely option `\"recommended\": true`. Do NOT add an \"Other\" option — free text is provided automatically when `allowFreeText` is on.',\n },\n allowFreeText: {\n type: \"string\",\n description:\n 'Whether the user may also type a free-text \"Other\" answer. \"true\" (default) or \"false\".',\n enum: [\"true\", \"false\"],\n },\n allowMultiple: {\n type: \"string\",\n description:\n 'Whether the user may select more than one option (multi-select). \"true\" or \"false\" (default).',\n enum: [\"true\", \"false\"],\n },\n },\n required: [\"question\", \"options\"],\n },\n },\n run: async (args) => {\n const question = String(args?.question ?? \"\").trim();\n if (!question) return \"Error: 'question' is required.\";\n const header = String(args?.header ?? \"\").trim();\n const allowMultiple = String(args?.allowMultiple ?? \"\") === \"true\";\n const allowFreeText = String(args?.allowFreeText ?? \"true\") !== \"false\";\n\n let parsedOptions: unknown;\n try {\n parsedOptions = JSON.parse(String(args?.options ?? \"[]\"));\n } catch {\n return \"Error: 'options' must be a JSON array of { label, value?, description?, recommended? }.\";\n }\n if (!Array.isArray(parsedOptions) || parsedOptions.length === 0) {\n return \"Error: 'options' must be a non-empty JSON array of { label, value?, description?, recommended? }.\";\n }\n\n type AskOption = {\n label: string;\n value: string;\n description?: string;\n preview?: string;\n recommended?: boolean;\n };\n const options = parsedOptions\n .map((raw): AskOption | null => {\n const opt = (raw ?? {}) as Record<string, unknown>;\n const label =\n typeof opt.label === \"string\" && opt.label.trim()\n ? opt.label.trim()\n : typeof opt.value === \"string\"\n ? String(opt.value).trim()\n : \"\";\n if (!label) return null;\n const value =\n typeof opt.value === \"string\" && opt.value.trim()\n ? opt.value.trim()\n : label;\n const option: AskOption = { label, value };\n if (typeof opt.description === \"string\" && opt.description.trim()) {\n option.description = opt.description.trim();\n }\n if (typeof opt.preview === \"string\" && opt.preview.trim()) {\n option.preview = opt.preview;\n }\n if (opt.recommended === true) option.recommended = true;\n return option;\n })\n .filter((opt): opt is AskOption => opt !== null);\n if (options.length === 0) {\n return \"Error: 'options' must contain at least one option with a label.\";\n }\n\n // Shape must match the GuidedQuestionFlow renderer in\n // client/guided-questions.tsx: a `text-options` question whose options\n // carry `value`, with `multiSelect` for multi-pick and `allowOther` for\n // free text. The renderer otherwise injects \"Explore\"/\"Decide\" options,\n // which would be noise for a focused clarifying question, so disable them.\n const payload = {\n questions: [\n {\n id: \"q1\",\n type: \"text-options\" as const,\n question,\n ...(header ? { header } : {}),\n required: !allowFreeText,\n multiSelect: allowMultiple,\n allowOther: allowFreeText,\n includeExplore: false,\n includeDecide: false,\n options,\n },\n ],\n };\n\n const { writeAppState } =\n await import(\"../../application-state/script-helpers.js\");\n await writeAppState(\n appStateKeyForBrowserTab(\n \"guided-questions\",\n getRequestRunContext()?.browserTabId,\n ),\n payload,\n );\n return \"Asked the user a clarifying question and rendered it in the chat. Stop here and wait for their answer — do not proceed or assume an answer.\";\n },\n },\n };\n}\n\nexport function createDataWidgetActionEntries(): Record<string, ActionEntry> {\n return {\n \"render-data-widget\": {\n readOnly: true,\n parallelSafe: true,\n chatUI: {\n renderer: ACTION_CHAT_UI_DATA_WIDGET_RENDERER,\n title: \"Data widget\",\n description: \"Render a validated native data table or chart in chat.\",\n },\n tool: {\n description: `Render a native Agent-Native chat data widget from compact, real data you already retrieved or the user provided. Use this for in-chat tables, charts, graphs, trends, and compact reports when no domain-specific action already returns a native widget. Never fabricate rows or metrics just to make a chart. Rows travel as tool arguments you type out one token at a time, so this is only for already-summarized data: at most ${DATA_WIDGET_MAX_ROWS} table rows and ${DATA_WIDGET_MAX_CHART_POINTS} chart points (anything beyond that is dropped). For a larger result set, aggregate it first, or state the total and show only the top rows — never re-serialize a full query result here.`,\n parameters: {\n type: \"object\",\n properties: {\n widget: {\n type: \"string\",\n enum: [\"data-table\", \"data-chart\", \"data-insights\"],\n description:\n \"Widget kind. Use data-chart for a chart, data-table for a table, or data-insights for a combined summary/chart/table card.\",\n },\n widgetId: {\n type: \"string\",\n description: \"Optional stable widget identifier.\",\n },\n title: {\n type: \"string\",\n description: \"Optional widget title.\",\n },\n summary: {\n type: \"object\",\n description:\n \"Optional scalar summary values for data-insights cards.\",\n },\n display: {\n type: \"object\",\n description:\n \"Optional display metadata: title, description, primaryAction.\",\n },\n table: {\n type: \"object\",\n description:\n \"For data-table/data-insights: { title?, columns: [{ key, label, align? }], rows, totalRows?, sampledRows?, truncated? }.\",\n },\n chartSeries: {\n type: \"object\",\n description:\n \"For data-chart/data-insights: { type: 'bar'|'line'|'area', title?, xKey, series: [{ key, label, color? }], data, sampled? }.\",\n },\n },\n required: [\"widget\"],\n },\n },\n run: async (args) =>\n clampDataWidgetRows(dataWidgetResultSchema.parse(args)),\n },\n };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"context-tools.js","sourceRoot":"","sources":["../../../src/server/agent-chat/context-tools.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,mCAAmC,EAAE,MAAM,oBAAoB,CAAC;AAEzE,OAAO,EACL,mBAAmB,EACnB,4BAA4B,EAC5B,oBAAoB,EACpB,sBAAsB,GACvB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,oBAAoB,EAAE,MAAM,uBAAuB,CAAC;AAE7D,8EAA8E;AAC9E,mEAAmE;AACnE,yEAAyE;AACzE,6EAA6E;AAC7E,sBAAsB;AACtB,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,CAAC,MAAM,0BAA0B,GAA2B;IAChE,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;8FAoBoF;IAE5F,cAAc,EAAE;;;;;;;+KAO6J;IAE7K,aAAa,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;qiBAiCohB;IAEniB,gBAAgB,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;0YAkCsX;IAExY,OAAO,EAAE;;yoBAE8nB;IAEvoB,OAAO,EAAE;;;;;;;;;;;;;;;;;;;2HAmBgH;IAEzH,YAAY,EAAE;;;;;;;;;;;;;;;wOAewN;IAEtO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;+BAsBqB;IAE7B,WAAW,EAAE;;;;;;;;;;;;;;;oMAeqL;CACnM,CAAC;AAEF,MAAM,UAAU,2BAA2B;IACzC,MAAM,SAAS,GAAG,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,C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AC,sBAAsB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;SAC1D;KACF,CAAC;AACJ,CAAC","sourcesContent":["import { ACTION_CHAT_UI_DATA_WIDGET_RENDERER } from \"../../action-ui.js\";\nimport type { ActionEntry } from \"../../agent/production-agent.js\";\nimport {\n clampDataWidgetRows,\n DATA_WIDGET_MAX_CHART_POINTS,\n DATA_WIDGET_MAX_ROWS,\n dataWidgetResultSchema,\n} from \"../../data-widgets/index.js\";\nimport { getRequestRunContext } from \"../request-context.js\";\n\n// ---------------------------------------------------------------------------\n// Framework-owned \"context\" action entries: get-framework-context,\n// refresh-screen, the URL/ask-question tools, and the native data-widget\n// renderer. These are generic, template-agnostic tools registered into every\n// app's tool surface.\n// ---------------------------------------------------------------------------\n\n/**\n * Verbose framework sections returned by the `get-framework-context` tool.\n * Keyed by topic so the agent can request specific sections.\n * Not template-specific — lives outside buildFrameworkPrompts().\n */\nexport const FRAMEWORK_CONTEXT_SECTIONS: Record<string, string> = {\n embeds: `### Inline Embeds\n\nYou can embed an interactive view inline in your chat reply by writing an \\`embed\\` fenced code block. The chat renderer swaps the fence for a sandboxed iframe pointing at a route inside this app.\n\nSyntax:\n\n\\`\\`\\`\\`\n\\`\\`\\`embed\nsrc: /some/path?param=value\naspect: 16/9\ntitle: Optional label\n\\`\\`\\`\n\\`\\`\\`\\`\n\nKeys:\n- \\`src\\` (required) — **must be a same-origin path starting with \\`/\\`**. Cross-origin URLs are blocked. No \\`javascript:\\` or \\`data:\\` URLs.\n- \\`aspect\\` (optional) — one of \\`16/9\\` (default), \\`4/3\\`, \\`3/2\\`, \\`2/1\\`, \\`21/9\\`, \\`1/1\\`.\n- \\`title\\` (optional) — accessible label / hover tooltip.\n- \\`height\\` (optional) — fixed pixel height when aspect ratio isn't a good fit.\n\nUse for charts, visualizations, previews. Don't use for simple text/tables or external sites.`,\n\n \"chat-history\": `### Chat History\n\nYou can search and restore previous chat conversations using \\`chat-history\\`:\n- \\`chat-history\\` (action: \"search\") — Search or list past chat threads by keyword. Archived threads are excluded by default; pass \\`includeArchived: true\\` to also see them.\n- \\`chat-history\\` (action: \"open\") — Open a chat thread in the UI as a new tab and focus it\n- \\`chat-history\\` (actions: \"rename\", \"pin\", \"unpin\", \"archive\") — Organize a known chat thread by ID. Archiving a thread hides it from the default chat list and search.\n\nWhen the user asks to find a previous conversation, use \\`chat-history\\` with action \"search\" first to find matching threads, then action \"open\" to restore the one they want.`,\n\n \"agent-teams\": `### Agent Teams — Orchestration\n\nYou can delegate to background sub-agents with the \\`agent-teams\\` tool:\n- \\`agent-teams\\` (action: \"spawn\") — Launch a sub-agent on a task. It runs in its own thread with a clean context while you stay available; a live preview card appears in the chat. The spawn result confirms launch only, not completion. Optionally pass a custom agent profile from \\`agents/*.md\\` via the \\`agent\\` parameter.\n- \\`agent-teams\\` (action: \"status\") — Check a running sub-agent's progress.\n- \\`agent-teams\\` (action: \"read-result\") — Read a finished sub-agent's output.\n- \\`agent-teams\\` (action: \"send\") — Message a running sub-agent.\n- \\`agent-teams\\` (action: \"list\") — List sub-agent tasks.\n\nSub-agents inherit all of your template tools but **cannot spawn sub-agents themselves** — only you orchestrate.\n\n**User intent phrases.** If the user asks you to use a \"sub-agent\" or \"background agent\", that is explicit delegation intent. Also treat phrases like \"run these in the background\", \"kick off the rest\", \"run the queued items\", \"batch run these jobs\", \"parallelize this\", or \"start the next batch\" as delegation intent when the context is a set of independent work items.\n\n**Spawn is not completion.** A successful \\`spawn\\` call means the sub-agent started and is running. Tell the user it started, show the task id if useful, and then use \\`status\\`/\\`list\\`/\\`read-result\\` to monitor it. Never say the delegated task \"completed\", \"ran successfully\", or \"finished\" until \\`status\\` or \\`read-result\\` reports \\`completed\\` or \\`errored\\`. If a task is still running, say that plainly.\n\n**Default to doing the work yourself in this thread.** A sub-agent costs real tokens and adds a merge step, so reach for one only when delegation clearly pays for that overhead.\n\n**Delegate ONE sub-agent** when a task is self-contained and heavy: deep research, long multi-step content generation, or a noisy scan whose intermediate steps would clutter this thread. The sub-agent gets its own clean context and hands you back a distilled result.\n\n**Fan out to MULTIPLE sub-agents ONLY** for units of work that are genuinely independent and don't depend on each other's decisions — e.g. research three unrelated competitors, summarize five separate threads, draft sections that don't reference one another. Each gets a distinct slice.\n\n**Do NOT parallelize tightly-coupled work** — one cohesive artifact, edits that must agree with each other, or anything needing a single consistent voice or style. Parallel sub-agents can't see each other's choices and their outputs will clash. For coupled work, do it yourself, or chain sub-agents one at a time, feeding each result into the next.\n\n**Cap fan-out:** aim for 1, use up to ~3, and go beyond that only for clearly independent bulk work. More sub-agents means more tokens and a harder merge.\n\n**Briefing contract.** A sub-agent starts in a fresh thread and can only see the brief you give it — it cannot see this conversation or ask you to clarify before it runs. Make every brief self-contained:\n1. **Objective** — what \"done\" looks like, in a sentence or two.\n2. **Context** — the specific facts it needs from this conversation: IDs, names, the user's actual goal, constraints, prior decisions. Paste the specifics; don't assume it knows them.\n3. **Output format** — what to return and how (e.g. \"a 3-bullet summary with source links\", \"the drafted email body only\") so the result drops cleanly into your synthesis.\n4. **Boundaries** — what NOT to do, and for parallel sub-agents, which slice is theirs so they don't overlap.\n\nPut the objective and output format in \\`task\\`; put longer context in \\`instructions\\`.\n\n**Synthesis discipline.** After the sub-agents you depend on finish, poll \\`status\\`/\\`list\\` until they're complete, then pull each one's output with \\`read-result\\`. Do NOT paste their outputs back to back. Read all results, reconcile any disagreements, de-duplicate, and write ONE integrated answer in your own voice. If two sub-agents conflict, resolve it or flag the discrepancy explicitly rather than presenting both. When findings came from distinct investigations, briefly note which finding came from where so the user can trust the merge.`,\n\n \"recurring-jobs\": `### Recurring Jobs\n\nYou can create recurring jobs that run on a cron schedule. Jobs are resource files under \\`jobs/\\`.\n\n- \\`manage-jobs\\` (action: \"create\") — Create a new recurring job with a cron schedule and instructions\n- \\`manage-jobs\\` (action: \"list\") — List all recurring jobs and their status\n- \\`manage-jobs\\` (action: \"update\") — Update a job's schedule, instructions, or toggle enabled/disabled\n- Delete a job with the \\`resources\\` tool: \\`action: \"delete\"\\`, \\`path: \"jobs/<name>.md\"\\`\n\nConvert natural language to 5-field cron format:\n- \"every morning\" / \"daily at 9am\" → \\`0 9 * * *\\`\n- \"every weekday at 9am\" → \\`0 9 * * 1-5\\`\n- \"every hour\" → \\`0 * * * *\\`\n- \"every monday at 9am\" → \\`0 9 * * 1\\`\n\nWhen a recurring job needs a connected MCP, discover the exact MCP tool names\navailable in the current user/org context and pass them in the create call's\n\\`mcpTools\\` array. Bind only the tools the job needs; do not put an MCP URL,\nOAuth token, or arbitrary endpoint in the instructions. The scheduler resolves\nthe selected tools with the job owner's existing connector grant and fails\nclearly if a connector is revoked or a selected tool disappears. For imports,\nnormalize the provider response and call the app's bounded idempotent import\naction once with the full batch rather than issuing one write per item.\n\n#### Suggesting \"Save as automation\"\n\nWhen you finish a task that has obvious recurring value — daily inbox triage, weekly metrics summaries, archive sweeps, status digests, anything the user would plausibly want re-run on a fresh cadence — close the response with ONE short line offering to save it. Examples:\n\n- After \"Summarize my unread emails\": _\"Want me to run this every morning?\"_\n- After \"What's our top traffic source this week\": _\"Want a weekly digest on Mondays?\"_\n- After \"Archive emails older than 30 days\": _\"Should I run this every Sunday?\"_\n\nIf the user says yes, call \\`manage-jobs\\` (action: \"create\") with the original prompt as the job's instructions and the cadence they confirmed.\n\nDo NOT add this offer for one-shot work: lookups (find Alice, what's the schema, who reported X), single drafts/replies, navigation requests, or any task whose value is in the moment. Skip it when the prompt is already explicitly recurring (the user said \"every morning…\" — you'd be asking what they already told you). One short sentence at most; do not turn it into a list of cadence options.`,\n\n builder: `### Connecting Builder.io\n\nWhen the user asks to connect Builder.io or you hit a \"Builder not configured\" error, call the \\`connect-builder\\` tool. It renders a Connect/code-change card inline — do NOT write out multi-step setup instructions yourself. Inspect the returned \\`builderEnabled\\` flag: \\`true\\` means Builder Cloud Agents can take the code-change handoff, while \\`false\\` means this requires a code change and the user should edit locally or use Builder.io to edit this code in the cloud and continue customizing the app any way they like. If Builder Cloud Agents are not available for this workspace, never send the user to Builder org settings or beta settings.`,\n\n browser: `### Browser Automation\n\nYou can activate a real Chrome browser via Builder.io for tasks that need full page rendering:\n- Extracting design tokens from JS-heavy or SPA websites (computed styles, rendered colors/fonts)\n- Taking screenshots of live pages\n- Testing interactive flows on deployed URLs\n- Reading content from pages that require JavaScript execution\n\n**How to use:**\n1. In local development, call \\`set-browser-control\\` with \\`{\"enabled\":true,\"backend\":\"chrome-devtools\"}\\` after confirming once with the user. In production, use \\`activate-browser\\` for Builder-provisioned Chrome.\n2. On your next action, use \\`mcp__chrome-devtools__navigate_page\\`, \\`mcp__chrome-devtools__evaluate_script\\`, \\`mcp__chrome-devtools__take_screenshot\\`, etc.\n3. If Builder is not connected, call \\`connect-builder\\` first\n\n**When to recommend browser automation:**\n- User wants to import a design system from a URL (JS-rendered sites give almost no useful data from plain HTML fetch)\n- User asks you to check how a deployed site looks or behaves\n- Any task involving reading computed/rendered page state\n- When \\`web-request\\` returns minimal/skeleton HTML from a modern SPA\n\nPrefer \\`web-request\\` for simple API calls and static pages. Use browser automation when you need the real rendered page.`,\n\n \"call-agent\": `### call-agent — External Apps Only\n\nThe \\`call-agent\\` tool sends a message to a DIFFERENT, separately-deployed app's agent (A2A protocol). It is **not** for calling actions within the current app.\n\nUse a natural-language \\`message\\` by default. The receiving app owns interpretation and runs with its own instructions, skills, connected sources, data dictionary, and tools. Do not choose its provider, schema, query, joins, or SQL for it. A direct \\`action\\` + \\`input\\` call is only for an exact bounded read whose complete contract is already known; it is never a workaround for unreliable delegation.\n\n**NEVER use \\`call-agent\\` to:**\n- Call your own app by name\n- Perform tasks you can accomplish with your own registered tools\n\n**ONLY use \\`call-agent\\` when:**\n- The user explicitly asks you to communicate with a different app\n- You need data that only another deployed app can provide\n- You need brand-consistent generated media and this app does not have a native generation action; call agent \"assets\" and keep returned asset IDs and URLs verbatim\n\nIf \\`call-agent\\` says a downstream agent accepted the subtask and will post its result separately, do not call that same agent again for the same subtask. Continue any remaining work and answer with the completed results you have.`,\n\n memory: `### Structured Memory\n\nYour memory index (\\`memory/MEMORY.md\\`) is loaded at the start of every conversation.\n\n**Tools:**\n- \\`save-memory\\` — Create or update a memory (name, type, description, content)\n- \\`delete-memory\\` — Remove a memory and its index entry\n- \\`resources\\` with \\`action: \"read\"\\` and \\`path: \"memory/<name>.md\"\\` — Read the full content of a specific memory\n\n**Memory types:** user, feedback, project, reference\n\n**When to save (proactively):**\n- User corrects your approach → \\`feedback\\`\n- User shares preferences → \\`user\\`\n- Non-obvious pattern or gotcha → \\`feedback\\`\n- Personal context (contacts, team) → \\`user\\`\n- Project context to track → \\`project\\`\n\n**Rules:**\n- Don't save things obvious from code or standard framework behavior\n- When updating, read first and merge — don't overwrite\n- Keep descriptions concise\n- One memory per logical topic`,\n\n \"sql-tools\": `### SQL Tools\n\nWhen database tools are enabled, \\`db-schema\\` refreshes the schema and \\`db-query\\` runs read-only SELECT queries with current user/org scoping. Raw SQL write tools are only available when the app explicitly opts into database write tools; by default, writes go through typed app actions. Some apps configure database tools as read-only or off; only use tools that are actually present in your tool list.\n\n- \\`db-schema\\` — refresh the full schema with indexes and foreign keys\n- \\`db-query\\` — run a SELECT (read-only; results already filtered to the current user/org)\n- \\`db-exec\\` — only when present: run INSERT / UPDATE / DELETE / REPLACE for scoped maintenance. For normal product data writes, use a typed app action instead.\n- \\`db-patch\\` — only when present: surgical search-and-replace on a large text column. If a typed app action exists for the resource, use that action.\n\n### When to pick which SQL tool\n- A template-specific action exists for the table → use that action (it encodes business rules and pushes live Yjs updates)\n- Read data → \\`db-query\\`. Never re-add \\`WHERE owner_email = ...\\` — scoping already applies it.\n- Raw write tools are present and no app action exists → use \\`db-exec\\` or \\`db-patch\\` only for deliberate maintenance, not normal product workflows.\n\n### External data sources vs the app database\nThe \\`db-*\\` tools ONLY query the app's own SQL database. They do NOT reach external data warehouses. If the user asks about tables NOT in the schema, use the appropriate template action instead.`,\n};\n\nexport function createFrameworkContextEntry(): Record<string, ActionEntry> {\n const topicList = Object.keys(FRAMEWORK_CONTEXT_SECTIONS).join(\", \");\n return {\n \"get-framework-context\": {\n tool: {\n description: `Read detailed framework instructions for a specific capability. Available topics: ${topicList}. Call with topic=\"all\" to get everything.`,\n parameters: {\n type: \"object\" as const,\n properties: {\n topic: {\n type: \"string\",\n description: `Topic to read. One of: ${topicList}, or \"all\" for everything.`,\n },\n },\n required: [\"topic\"],\n },\n },\n run: async (args: Record<string, string>) => {\n const topic = String(args.topic ?? \"all\").toLowerCase();\n if (topic === \"all\") {\n return Object.values(FRAMEWORK_CONTEXT_SECTIONS).join(\"\\n\\n\");\n }\n const section = FRAMEWORK_CONTEXT_SECTIONS[topic];\n if (!section) {\n return `Unknown topic \"${topic}\". Available: ${topicList}`;\n }\n return section;\n },\n readOnly: true,\n },\n };\n}\n\n/**\n * Creates the `refresh-screen` tool. Writes a bump to `application_state`\n * under a well-known key; the client's `useDbSync` watches for this and\n * invalidates react-query caches so the on-screen UI re-fetches its data\n * without a full page reload.\n *\n * This is the standard way for the agent to say \"the data on the screen\n * just changed, please refresh it\" — e.g. after editing a dashboard config,\n * updating a form schema, or mutating a row that the current view renders.\n */\nexport function createRefreshScreenEntry(): Record<string, ActionEntry> {\n return {\n \"refresh-screen\": {\n // Writes __screen_refresh__ to application_state, which emits its own\n // distinct `screen-refresh` poll event. Don't double-emit a generic\n // `action` event on top of that.\n readOnly: true,\n // Refetching volatile on-screen state is the entire point of this\n // tool — an identical repeat call (even with the same scope) is a\n // legitimate re-refresh, not a redundant read to skip.\n dedupe: false,\n tool: {\n description:\n \"Manually refresh the user's current screen. The framework ALREADY auto-refreshes after any successful mutating action tool call (template actions and any enabled raw DB write tools) — you do NOT need to call this after a normal action. Use it only when (a) you mutated data via a path the framework can't detect (e.g. a direct write to an external system the app mirrors), or (b) you want to pass a `scope` hint so the UI narrows which queries to refetch. The UI re-fetches its queries without a full page reload.\",\n parameters: {\n type: \"object\",\n properties: {\n scope: {\n type: \"string\",\n description:\n \"Optional hint describing what changed (e.g. 'dashboard', 'form', 'settings'). Templates may use it to narrow which queries to invalidate; if omitted, all queries are invalidated.\",\n },\n },\n },\n },\n run: async (args) => {\n const { writeAppState } =\n await import(\"../../application-state/script-helpers.js\");\n const nonce = Date.now();\n const scope = typeof args?.scope === \"string\" ? args.scope : undefined;\n await writeAppState(SCREEN_REFRESH_KEY, {\n nonce,\n ...(scope ? { scope } : {}),\n });\n return `refreshed${scope ? ` (scope: ${scope})` : \"\"}`;\n },\n },\n };\n}\n\n/** Well-known application-state key used by the refresh-screen tool. */\nconst SCREEN_REFRESH_KEY = \"__screen_refresh__\";\nconst SAFE_BROWSER_TAB_ID_RE = /^[A-Za-z0-9_-]{1,96}$/;\n\nexport function appStateKeyForBrowserTab(\n key: string,\n browserTabId: unknown,\n): string {\n if (typeof browserTabId !== \"string\") return key;\n const trimmed = browserTabId.trim();\n return SAFE_BROWSER_TAB_ID_RE.test(trimmed) ? `${key}:${trimmed}` : key;\n}\n\n/**\n * Creates the `set-search-params` / `set-url-path` tools. Writes a one-shot\n * URL command to application_state; the client's URLSync component applies\n * it via react-router (no full page reload) and then deletes the command.\n *\n * This is how the agent edits URL state — filter query params, route\n * changes, hash — without needing a per-template navigate action. The\n * current URL is visible to the agent via the auto-injected `<current-url>`\n * block, which includes parsed search params.\n */\nexport function createUrlTools(): Record<string, ActionEntry> {\n return {\n \"set-search-params\": {\n // Writes __set_url__ to application_state, which the app-state watcher\n // already surfaces as a poll event. No need to double-emit.\n readOnly: true,\n tool: {\n description:\n \"Update the URL query string on the user's current page. Use this to change dashboard/list filters, search terms, or any other state the app stores in `?foo=bar` style query params. One-shot — the UI applies it in ~1s without a page reload. See the current URL + parsed search params in the auto-injected `<current-url>` block. Keys are the exact query param names as they appear in the URL (e.g. `f_pubDateStart`, not just `pubDateStart`). Set a value to null or empty string to clear that param. By default merges over existing params — pass `merge: false` to replace them all.\",\n parameters: {\n type: \"object\",\n properties: {\n params: {\n type: \"object\",\n description:\n 'Map of query param → value. Each value is a string, or null/\"\" to clear. Example: {\"f_pubDateStart\": null, \"f_cadence\": \"MONTH\"}.',\n },\n merge: {\n type: \"string\",\n description:\n '\"true\" (default) merges over existing params; \"false\" replaces them entirely.',\n enum: [\"true\", \"false\"],\n },\n },\n required: [\"params\"],\n },\n },\n run: async (args) => {\n const params = (args?.params ?? {}) as unknown as Record<\n string,\n string | null\n >;\n const merge = (args as any)?.merge !== \"false\";\n const { writeAppState } =\n await import(\"../../application-state/script-helpers.js\");\n await writeAppState(\n appStateKeyForBrowserTab(\n \"__set_url__\",\n getRequestRunContext()?.browserTabId,\n ),\n {\n searchParams: params,\n mergeSearchParams: merge,\n // Unique-per-write token. The client's URLSync hook dedups by this\n // so a fire-and-forget DELETE that loses its race against the next\n // polling refetch can't cause the same URL command to be applied\n // repeatedly (which caused the editor to bounce between slides\n // when an agent turn errored partway through).\n _writeId: `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,\n },\n );\n const keys = Object.keys(params);\n return `set-search-params: ${keys.length} key${keys.length === 1 ? \"\" : \"s\"}${merge ? \"\" : \" (replace)\"}`;\n },\n },\n \"set-url-path\": {\n // Same as set-search-params — writes application_state, already emits\n // via the app-state watcher.\n readOnly: true,\n tool: {\n description:\n \"Navigate the user to a different pathname, optionally also setting search params. For most template-specific routing prefer the template's `navigate` action if it exists — this is the generic fallback. One-shot, applied by the client without a page reload.\",\n parameters: {\n type: \"object\",\n properties: {\n pathname: {\n type: \"string\",\n description: \"New URL pathname (e.g. '/adhoc/weekly').\",\n },\n params: {\n type: \"object\",\n description:\n 'Optional query params to set alongside the path change. String values set, null/\"\" clears.',\n },\n merge: {\n type: \"string\",\n description:\n '\"true\" (default) merges over existing params; \"false\" starts fresh.',\n enum: [\"true\", \"false\"],\n },\n },\n required: [\"pathname\"],\n },\n },\n run: async (args) => {\n const pathname = String(args?.pathname ?? \"\");\n if (!pathname.startsWith(\"/\")) {\n return \"Error: pathname must start with '/'.\";\n }\n const params = (args?.params ?? {}) as unknown as Record<\n string,\n string | null\n >;\n const merge = (args as any)?.merge !== \"false\";\n const { writeAppState } =\n await import(\"../../application-state/script-helpers.js\");\n await writeAppState(\n appStateKeyForBrowserTab(\n \"__set_url__\",\n getRequestRunContext()?.browserTabId,\n ),\n {\n pathname,\n searchParams: params,\n mergeSearchParams: merge,\n // See note in set-search-params: unique-per-write dedup token so a\n // race between GET and consume-DELETE in URLSync can't re-apply\n // this command.\n _writeId: `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`,\n },\n );\n return `set-url-path: ${pathname}`;\n },\n },\n \"ask-question\": {\n tool: {\n description:\n \"Ask the user a multiple-choice clarifying question and render it inline in the chat. Use this ONLY when you are genuinely blocked on a decision you cannot resolve from context and a wrong guess would be costly — an ambiguous metric, date range, or grain; a real fork in approach. Present 2-5 concrete options and mark the most likely one recommended. Do NOT use it for confirmations, for things the user already specified, or to dodge easy work you could just do. Ask at most once per turn. Calling this yields the turn: stop and wait for the user's answer.\",\n parameters: {\n type: \"object\",\n properties: {\n question: {\n type: \"string\",\n description:\n \"The complete question to ask the user. Clear, specific, ends with a question mark.\",\n },\n header: {\n type: \"string\",\n description:\n 'Optional very short label (max ~12 chars) shown as a chip/heading above the question, e.g. \"Date range\", \"Approach\", \"Library\".',\n },\n options: {\n type: \"string\",\n description:\n 'A JSON array of 2-4 distinct, mutually-exclusive options (unless `allowMultiple` is true), each `{ \"label\": string, \"value\"?: string, \"description\"?: string, \"preview\"?: string, \"recommended\"?: boolean }`. `label` is 1-5 words; `description` explains the trade-off; `preview` is optional content (mockup, code snippet, short comparison) rendered under the option. `value` defaults to `label` when omitted. Mark the most likely option `\"recommended\": true`. Do NOT add an \"Other\" option — free text is provided automatically when `allowFreeText` is on.',\n },\n allowFreeText: {\n type: \"string\",\n description:\n 'Whether the user may also type a free-text \"Other\" answer. \"true\" (default) or \"false\".',\n enum: [\"true\", \"false\"],\n },\n allowMultiple: {\n type: \"string\",\n description:\n 'Whether the user may select more than one option (multi-select). \"true\" or \"false\" (default).',\n enum: [\"true\", \"false\"],\n },\n },\n required: [\"question\", \"options\"],\n },\n },\n run: async (args) => {\n const question = String(args?.question ?? \"\").trim();\n if (!question) return \"Error: 'question' is required.\";\n const header = String(args?.header ?? \"\").trim();\n const allowMultiple = String(args?.allowMultiple ?? \"\") === \"true\";\n const allowFreeText = String(args?.allowFreeText ?? \"true\") !== \"false\";\n\n let parsedOptions: unknown;\n try {\n parsedOptions = JSON.parse(String(args?.options ?? \"[]\"));\n } catch {\n return \"Error: 'options' must be a JSON array of { label, value?, description?, recommended? }.\";\n }\n if (!Array.isArray(parsedOptions) || parsedOptions.length === 0) {\n return \"Error: 'options' must be a non-empty JSON array of { label, value?, description?, recommended? }.\";\n }\n\n type AskOption = {\n label: string;\n value: string;\n description?: string;\n preview?: string;\n recommended?: boolean;\n };\n const options = parsedOptions\n .map((raw): AskOption | null => {\n const opt = (raw ?? {}) as Record<string, unknown>;\n const label =\n typeof opt.label === \"string\" && opt.label.trim()\n ? opt.label.trim()\n : typeof opt.value === \"string\"\n ? String(opt.value).trim()\n : \"\";\n if (!label) return null;\n const value =\n typeof opt.value === \"string\" && opt.value.trim()\n ? opt.value.trim()\n : label;\n const option: AskOption = { label, value };\n if (typeof opt.description === \"string\" && opt.description.trim()) {\n option.description = opt.description.trim();\n }\n if (typeof opt.preview === \"string\" && opt.preview.trim()) {\n option.preview = opt.preview;\n }\n if (opt.recommended === true) option.recommended = true;\n return option;\n })\n .filter((opt): opt is AskOption => opt !== null);\n if (options.length === 0) {\n return \"Error: 'options' must contain at least one option with a label.\";\n }\n\n // Shape must match the GuidedQuestionFlow renderer in\n // client/guided-questions.tsx: a `text-options` question whose options\n // carry `value`, with `multiSelect` for multi-pick and `allowOther` for\n // free text. The renderer otherwise injects \"Explore\"/\"Decide\" options,\n // which would be noise for a focused clarifying question, so disable them.\n const payload = {\n questions: [\n {\n id: \"q1\",\n type: \"text-options\" as const,\n question,\n ...(header ? { header } : {}),\n required: !allowFreeText,\n multiSelect: allowMultiple,\n allowOther: allowFreeText,\n includeExplore: false,\n includeDecide: false,\n options,\n },\n ],\n };\n\n const { writeAppState } =\n await import(\"../../application-state/script-helpers.js\");\n await writeAppState(\n appStateKeyForBrowserTab(\n \"guided-questions\",\n getRequestRunContext()?.browserTabId,\n ),\n payload,\n );\n return \"Asked the user a clarifying question and rendered it in the chat. Stop here and wait for their answer — do not proceed or assume an answer.\";\n },\n },\n };\n}\n\nexport function createDataWidgetActionEntries(): Record<string, ActionEntry> {\n return {\n \"render-data-widget\": {\n readOnly: true,\n parallelSafe: true,\n chatUI: {\n renderer: ACTION_CHAT_UI_DATA_WIDGET_RENDERER,\n title: \"Data widget\",\n description: \"Render a validated native data table or chart in chat.\",\n },\n tool: {\n description: `Render a native Agent-Native chat data widget from compact, real data you already retrieved or the user provided. Use this for in-chat tables, charts, graphs, trends, and compact reports when no domain-specific action already returns a native widget. Never fabricate rows or metrics just to make a chart. Rows travel as tool arguments you type out one token at a time, so this is only for already-summarized data: at most ${DATA_WIDGET_MAX_ROWS} table rows and ${DATA_WIDGET_MAX_CHART_POINTS} chart points (anything beyond that is dropped). For a larger result set, aggregate it first, or state the total and show only the top rows — never re-serialize a full query result here.`,\n parameters: {\n type: \"object\",\n properties: {\n widget: {\n type: \"string\",\n enum: [\"data-table\", \"data-chart\", \"data-insights\"],\n description:\n \"Widget kind. Use data-chart for a chart, data-table for a table, or data-insights for a combined summary/chart/table card.\",\n },\n widgetId: {\n type: \"string\",\n description: \"Optional stable widget identifier.\",\n },\n title: {\n type: \"string\",\n description: \"Optional widget title.\",\n },\n summary: {\n type: \"object\",\n description:\n \"Optional scalar summary values for data-insights cards.\",\n },\n display: {\n type: \"object\",\n description:\n \"Optional display metadata: title, description, primaryAction.\",\n },\n table: {\n type: \"object\",\n description:\n \"For data-table/data-insights: { title?, columns: [{ key, label, align? }], rows, totalRows?, sampledRows?, truncated? }.\",\n },\n chartSeries: {\n type: \"object\",\n description:\n \"For data-chart/data-insights: { type: 'bar'|'line'|'area', title?, xKey, series: [{ key, label, color? }], data, sampled? }.\",\n },\n },\n required: [\"widget\"],\n },\n },\n run: async (args) =>\n clampDataWidgetRows(dataWidgetResultSchema.parse(args)),\n },\n };\n}\n"]}
|
|
@@ -310,6 +310,25 @@ export interface AgentChatPluginOptions {
|
|
|
310
310
|
* unless `writes: "allowlisted"` is explicitly selected.
|
|
311
311
|
*/
|
|
312
312
|
externalAgents?: ExternalAgentPolicy;
|
|
313
|
+
/**
|
|
314
|
+
* Allow this app's A2A agent to delegate to a different app through the
|
|
315
|
+
* built-in `call-agent` tool. Enabled by default so a receiver keeps the
|
|
316
|
+
* same cross-app capability as its interactive agent. Set false only for an
|
|
317
|
+
* intentionally isolated app. Core enforces a bounded delegation path so
|
|
318
|
+
* cycle safety does not depend on removing the tool.
|
|
319
|
+
*/
|
|
320
|
+
a2aAgentDelegation?: boolean;
|
|
321
|
+
/**
|
|
322
|
+
* Resource budget for delegated A2A/MCP agent turns. Defaults are stricter
|
|
323
|
+
* than interactive chat because every retained tool result is re-sent on
|
|
324
|
+
* later iterations and delegated callers need a compact answer, not a raw
|
|
325
|
+
* transcript. Apps may raise one limit deliberately for proven workloads.
|
|
326
|
+
*/
|
|
327
|
+
delegatedRunPolicy?: {
|
|
328
|
+
maxIterations?: number;
|
|
329
|
+
maxRunInputTokens?: number;
|
|
330
|
+
maxToolResultChars?: number;
|
|
331
|
+
};
|
|
313
332
|
/**
|
|
314
333
|
* Skip mounting the remote MCP protocol route.
|
|
315
334
|
*
|
|
@@ -354,6 +373,10 @@ export interface AgentChatPluginOptions {
|
|
|
354
373
|
toolLimits?: {
|
|
355
374
|
timeoutMs?: number;
|
|
356
375
|
maxResultChars?: number;
|
|
376
|
+
/** Absolute cap applied even when an individual action declares more. */
|
|
377
|
+
hardMaxResultChars?: number;
|
|
357
378
|
};
|
|
358
379
|
}
|
|
380
|
+
/** Cross-app agent delegation is a workspace default; false is an isolation opt-out. */
|
|
381
|
+
export declare function resolveA2AAgentDelegationEnabled(options?: Pick<AgentChatPluginOptions, "a2aAgentDelegation">): boolean;
|
|
359
382
|
//# sourceMappingURL=plugin-options.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-options.d.ts","sourceRoot":"","sources":["../../../src/server/agent-chat/plugin-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iCAAiC,CAAC;AACnE,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AACnF,OAAO,KAAK,EACV,mBAAmB,EACnB,kBAAkB,EAClB,eAAe,EAChB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,oCAAoC,CAAC;AAC9E,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D;4EAC4E;AAC5E,MAAM,MAAM,cAAc,GAAG,CAAC,QAAQ,EAAE,GAAG,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;AAErE,MAAM,WAAW,sBAAsB;IACrC,+DAA+D;IAC/D,OAAO,CAAC,EACJ,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAC3B,CAAC,MACG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAC3B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IAC9C,wCAAwC;IACxC,OAAO,CAAC,EACJ,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAC3B,CAAC,MACG,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAC3B,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC;IAC9C,mEAAmE;IACnE,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,qDAAqD;IACrD,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,q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AErC;;;;;;OAMG;IACH,kBAAkB,CAAC,EAAE,OAAO,CAAC;IAE7B;;;;;OAKG;IACH,kBAAkB,CAAC,EAAE;QACnB,aAAa,CAAC,EAAE,MAAM,CAAC;QACvB,iBAAiB,CAAC,EAAE,MAAM,CAAC;QAC3B,kBAAkB,CAAC,EAAE,MAAM,CAAC;KAC7B,CAAC;IAEF;;;;;;;OAOG;IACH,UAAU,CAAC,EAAE,OAAO,CAAC;IAErB;;;;;;;;;;;;;;;;;;OAkBG;IACH,aAAa,CAAC,EAAE;QACd,UAAU,CAAC,EAAE,KAAK,GAAG,WAAW,GAAG,SAAS,CAAC;QAC7C;;;;WAIG;QACH,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;KACxB,CAAC;IAEF;;;OAGG;IACH,UAAU,CAAC,EAAE;QACX,SAAS,CAAC,EAAE,MAAM,CAAC;QACnB,cAAc,CAAC,EAAE,MAAM,CAAC;QACxB,yEAAyE;QACzE,kBAAkB,CAAC,EAAE,MAAM,CAAC;KAC7B,CAAC;CACH;AAED,wFAAwF;AACxF,wBAAgB,gCAAgC,CAC9C,OAAO,CAAC,EAAE,IAAI,CAAC,sBAAsB,EAAE,oBAAoB,CAAC,GAC3D,OAAO,CAET"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin-options.js","sourceRoot":"","sources":["../../../src/server/agent-chat/plugin-options.ts"],"names":[],"mappings":"","sourcesContent":["import type { ActionEntry } from \"../../agent/production-agent.js\";\nimport type { AgentLoopFinalResponseGuard } from \"../../agent/production-agent.js\";\nimport type {\n AgentChatAttachment,\n AgentChatReference,\n MentionProvider,\n} from \"../../agent/types.js\";\nimport type { ExternalAgentPolicy } from \"../../mcp/external-agent-policy.js\";\nimport type { DatabaseToolsOption } from \"../../scripts/db/tool-mode.js\";\nimport type { PromptExamples } from \"../prompts/index.js\";\n\n/** Shape of a Nitro plugin function: receives the Nitro app instance at\n * startup and may register routes/hooks synchronously or asynchronously. */\nexport type NitroPluginDef = (nitroApp: any) => void | Promise<void>;\n\nexport interface AgentChatPluginOptions {\n /** Template-specific actions (email ops, booking ops, etc.) */\n actions?:\n | Record<string, ActionEntry>\n | (() =>\n | Record<string, ActionEntry>\n | Promise<Record<string, ActionEntry>>);\n /** @deprecated Use `actions` instead */\n scripts?:\n | Record<string, ActionEntry>\n | (() =>\n | Record<string, ActionEntry>\n | Promise<Record<string, ActionEntry>>);\n /** System prompt for the agent. A sensible default is provided. */\n systemPrompt?: string;\n /** Additional system prompt prepended in dev mode */\n devSystemPrompt?: string;\n /** Model to use. Defaults to the resolved engine's default model. */\n model?: string;\n /** Optional per-app agent run chunk budget in milliseconds. Defaults to\n * AGENT_RUN_SOFT_TIMEOUT_MS when set, otherwise no framework-imposed\n * timeout. When reached, long runs continue through the hidden continuation\n * path instead of surfacing a timeout warning. */\n runSoftTimeoutMs?: number;\n /** Optional per-app run-manager no-progress watchdog in milliseconds. */\n runNoProgressTimeoutMs?: number;\n /**\n * Opt this app into Netlify durable background-function agent-chat runs. This\n * gives hosted agent turns the 15-minute async-function budget when the app's\n * Netlify build also emits the background function. Set this to `false` to\n * explicitly disable a stale deploy-wide `AGENT_CHAT_DURABLE_BACKGROUND`\n * flag for this app.\n */\n durableBackgroundRuns?: boolean;\n /** Anthropic API key. Falls back to ANTHROPIC_API_KEY env var */\n apiKey?: string;\n /**\n * Agent engine to use. Can be a pre-constructed AgentEngine, a registered\n * engine name (e.g. \"anthropic\", \"ai-sdk:openai\"), or an object with name\n * and config. Defaults to the \"anthropic\" engine using ANTHROPIC_API_KEY.\n */\n engine?:\n | import(\"../../agent/engine/types.js\").AgentEngine\n | string\n | { name: string; config: Record<string, unknown> };\n /** Route path. Default: /_agent-native/agent-chat */\n path?: string;\n /** Custom mention providers for @-tagging template entities */\n mentionProviders?:\n | Record<string, MentionProvider>\n | (() =>\n | Record<string, MentionProvider>\n | Promise<Record<string, MentionProvider>>);\n /** App ID used to exclude self from agent discovery (e.g., \"mail\", \"calendar\") */\n appId?: string;\n /** Optional MCP server branding surfaced during the initialize handshake. */\n mcpServerInfo?: {\n /** Human-facing title. Defaults to the capitalized app id/name. */\n title?: string;\n /** Host-facing description. Defaults to \"Agent-native <app> agent\". */\n description?: string;\n /** Canonical app URL. Relative URLs are resolved against the request origin. */\n websiteUrl?: string;\n /** App icons. Relative `src` values are resolved against the request origin. */\n icons?: Array<{\n src: string;\n mimeType?: string;\n sizes?: string[];\n theme?: \"light\" | \"dark\";\n }>;\n };\n /**\n * Optional callback to resolve the org ID for the current request.\n * When provided, the resolved value is set as AGENT_ORG_ID env var so\n * that db-query/db-exec automatically scope by org_id in addition to\n * owner_email.\n *\n * If not provided, the framework automatically uses `session.orgId` from\n * Better Auth's active organization. Only provide this callback when you\n * need custom org resolution logic (e.g., Atlassian org mapping).\n */\n resolveOrgId?: (event: any) => string | null | Promise<string | null>;\n /**\n * Optional owner resolver for public/anonymous chat surfaces. When the\n * normal app session is missing, this callback may return a synthetic\n * owner id for a narrowly-scoped public request (for example, a public\n * shared document page). Anonymous requests use a read-only tool set by\n * default so public viewers cannot mutate app data through the agent.\n */\n anonymousOwner?: (event: any) => string | null | Promise<string | null>;\n /**\n * Keep anonymous-owner requests on read-only template actions. Defaults to\n * true. Only disable for single-tenant apps that intentionally allow public\n * agent mutations.\n */\n anonymousReadOnly?: boolean;\n /**\n * Optional auth adapter for the HTTP action route\n * (`/_agent-native/actions/*`). Its `resolveCaller` runs before the\n * cookie/bearer `getSession` chain, letting an app accept caller identities\n * `getSession` doesn't understand (e.g. an A2A JWT verified with\n * `verifyA2AToken`) declaratively, instead of pre-seeding request context\n * from a Nitro `request` hook.\n *\n * Returning `null` defers to the normal chain; THROWING hard-rejects with a\n * 401 (an invalid/forged credential must not fall through to a same-origin\n * session cookie). A resolved caller's org comes exclusively from the\n * verified credential — the returned `orgId` or the owner-email membership\n * lookup — never from the request's session cookie.\n * See {@link import(\"../action-routes.js\").ActionRouteAuthAdapter}.\n */\n actionRouteAuth?: import(\"../action-routes.js\").ActionRouteAuthAdapter;\n /**\n * Optional callback to append template-specific context to the system\n * prompt on each request. Runs after AGENTS.md / skills / memory are\n * loaded and before the schema block — use it to inject dynamic SQL\n * context like a data dictionary, active feature flags, or whatever\n * the agent should know about *right now* for this user/org.\n *\n * Return `null` or an empty string to skip. The string you return is\n * appended verbatim, so wrap it in your own XML tags (e.g.\n * `<data-dictionary>…</data-dictionary>`) to keep the prompt scannable.\n *\n * Called on every request in every prompt variant (lean, lazy, full).\n * Templates that want to suppress it in a particular mode should return\n * `null` from the callback based on their own logic.\n */\n extraContext?: (\n event: any,\n owner: string,\n ) => string | null | Promise<string | null>;\n /**\n * Optional final-answer guard. Templates can use this to require a\n * corrective retry before accepting a text-only final answer, e.g. forcing\n * real data-source tool calls for analytics requests.\n */\n finalResponseGuard?: AgentLoopFinalResponseGuard;\n /**\n * Optional per-template request normalizer. Runs after authentication and\n * before the model sees the message, so apps can translate chat attachments\n * into template-native file handles while preserving the user's visible text.\n */\n prepareRequest?: (details: {\n event: any;\n ownerEmail: string | null;\n message: string;\n displayMessage?: string;\n attachments: AgentChatAttachment[];\n references: AgentChatReference[];\n threadId?: string;\n internalContinuation?: boolean;\n mode: \"act\" | \"plan\";\n }) =>\n | void\n | {\n message?: string;\n displayMessage?: string;\n attachments?: AgentChatAttachment[];\n }\n | Promise<void | {\n message?: string;\n displayMessage?: string;\n attachments?: AgentChatAttachment[];\n }>;\n /**\n * Use ONLY the template's `systemPrompt` and the actions list — skip the\n * framework prompt wrapper, resource loading (AGENTS.md/LEARNINGS.md/\n * memory), the SQL schema block, and the workspace files/skills/agents\n * inventory. Intended for minimal or voice-first apps where a long,\n * generic preamble adds latency and iteration noise without adding value.\n *\n * When set, the same lean prompt is used in both dev and prod modes. In\n * dev mode the tool registry is ALSO swapped to the template's actions\n * (same set as prod) — the dev-only bash/db-exec/file-system tools\n * and the resource/docs/chat/team/job/browser scripts are dropped. The\n * lean system prompt has no bash-usage guidance, so routing actions\n * through bash would break. If you need the full dev tool surface,\n * leave this off.\n */\n leanPrompt?: boolean;\n /**\n * Skip auto-injecting the workspace files/skills/agents inventory on the\n * first message of a conversation while keeping the normal prompt, resources,\n * and tool surface. Use this for domain-focused apps where broad workspace\n * inventory is mostly latency/noise unless the user explicitly references it.\n *\n * `leanPrompt: true` and the default `lazyContext` mode imply this because\n * those catalogs are already discoverable through resources, docs-search,\n * tool-search, and the compact resource indexes. Set `false` explicitly only\n * when a workspace-wide inventory is central to the app's first-turn job.\n */\n skipFilesContext?: boolean;\n /**\n * Initial native tool schemas to send to the LLM provider. When set, the\n * agent starts with only these tools plus `tool-search`; the live registry\n * remains searchable, and matching schemas from `tool-search` results are\n * loaded into the next model request. Use this for domain-focused apps that\n * have a few common actions and many rare framework utilities. Common\n * discovery and resource-reading tools are promoted automatically when\n * present. Provider, MCP, extension, and code-execution schemas stay behind\n * tool-search unless the app explicitly includes them in this list.\n */\n initialToolNames?: string[];\n /**\n * Controls whether broad provider/corpus tools and their workflow prompt are\n * loaded into the first model request. Use `\"lazy\"` for apps that can answer\n * ordinary lookups from a compact curated tool set; corpus tools remain\n * discoverable through tool-search and the full retry surface.\n *\n * @default \"initial\"\n */\n corpusTools?: \"initial\" | \"lazy\";\n /**\n * Use a compact system prompt with on-demand context loading. The system\n * prompt includes essential behavioral rules and action signatures, but\n * defers verbose framework details, SQL schema, skills, learnings, and\n * memory behind tools (`get-framework-context`, `db-schema`,\n * `resources` (action: read)). The agent fetches these on-demand when needed.\n *\n * This reduces the system prompt by ~60-70%, significantly improving\n * time-to-first-token and reducing \"thinking\" time. The agent retains\n * all capabilities — it just loads context lazily instead of upfront.\n *\n * Defaults to `true`. Set to `false` to use the original full prompt.\n * Ignored when `leanPrompt` is set (lean mode is even more minimal).\n */\n lazyContext?: boolean;\n /**\n * In dev mode, register the template's actions as native tools the agent\n * can call directly with structured JSON args — skipping the default\n * `bash(command=\"pnpm action <name> ...\")` indirection.\n *\n * The default dev behavior shells out because it \"mirrors how Claude Code\n * works locally\" and reduces empty-object tool calls for templates with\n * simple string args. But templates whose actions take structured data\n * (objects, arrays, nested JSON) can't round-trip those cleanly through\n * the CLI parser — stringified JSON on the way in, loss of type fidelity\n * on the way out.\n *\n * Set to `true` to get the same tool surface in dev that production uses.\n * `leanPrompt: true` implies this already (lean mode has no bash-usage\n * guidance, so actions must be native). Set this flag without\n * `leanPrompt` when you want native actions AND the full system prompt.\n *\n * Defaults to `false`.\n */\n nativeActionsInDev?: boolean;\n /**\n * Expose raw SQL/native database tools to the app agent.\n *\n * Defaults to `\"read\"`: `db-schema`/`db-query` are available for inspection,\n * while writes route through typed app actions. Set to `\"write\"` (also\n * `true`) to expose `db-exec`/`db-patch` for scoped raw SQL maintenance.\n * Set to `\"off\"` (also `false`) for chat-first apps that want agents to use\n * typed actions only.\n */\n databaseTools?: DatabaseToolsOption;\n /**\n * Expose framework extension management actions (`create-extension`,\n * `update-extension`, `list-extensions`, etc.) to the app agent. Defaults to\n * false. Set to true for apps that intentionally let the LLM create or\n * manage sandboxed extension mini-apps. Core extension routes may still be\n * mounted for compatibility and app-owned surfaces.\n */\n extensionTools?: boolean;\n /**\n * Optional A2A-only deterministic response path. Runs after inbound A2A text\n * and user context are resolved, but before an agent engine/model is loaded.\n * Return a message to complete the A2A task without invoking the LLM, or\n * null/undefined to continue through the normal agent loop.\n */\n a2aMessageFallback?: (details: {\n message: import(\"../../a2a/types.js\").Message;\n text: string;\n context: import(\"../../a2a/types.js\").A2AHandlerContext;\n userEmail: string | undefined;\n }) =>\n | import(\"../../a2a/types.js\").Message\n | string\n | null\n | undefined\n | Promise<import(\"../../a2a/types.js\").Message | string | null | undefined>;\n /**\n * Optional injectable prompt examples for core rules (rule 5 auto-refresh\n * examples and rule 8 external provider names). When absent, generic\n * placeholders are used so no template-specific names appear in the core\n * prompt by default.\n *\n * - `providerActions`: external provider action names this template exposes\n * (e.g. `[\"warehouse-query\", \"crm-records\"]` for a template).\n * - `appActions`: representative template action names for rule 5's refresh\n * examples (e.g. `[\"log-meal\", \"update-form\"]` for a forms template).\n */\n promptExamples?: PromptExamples;\n /**\n * Curated allow-list of action names to serve external **connector** clients\n * on a hosted multi-tenant deployment.\n *\n * Whenever this list is non-empty it is active by default for **every**\n * caller (hosted connectors, code/stdio clients, and the local CLI): external\n * MCP clients see (and can call) only these actions plus the builtin\n * cross-app tools (`list_apps`, `open_app`, `ask_app`, `create_embed_session`).\n * Calls to any tool outside the list are rejected with \"Unknown tool\".\n * This prevents the full ~105-tool catalog from bloating external-agent\n * context windows and removes footguns (db-exec, seed-*, extension suite,\n * browser-session tools) from connectors. It is no longer gated behind an\n * environment variable, and the catalog is never inferred from the client.\n *\n * `tool-search` stays available for discovery; a trimmed action still needs\n * the connector catalog, authenticated-read policy, or full-catalog opt-in\n * before an external caller can execute it.\n * Callers who need the full surface up front opt in explicitly with\n * `agent-native connect --full-catalog` (embeds a `catalog_scope: \"full\"`\n * claim in their connect-minted JWT) or the deployment-wide\n * `AGENT_NATIVE_MCP_FULL_CATALOG=1` env override.\n *\n * Declare here rather than in MCPConfig directly; the plugin copies it through.\n */\n connectorCatalog?: string[];\n\n /**\n * Default authenticated external-agent policy. In `auto` read mode, every\n * action explicitly marked as GET + readOnly + publicAgent.requiresAuth is\n * added to the connector surface automatically. Writes remain ask_app-only\n * unless `writes: \"allowlisted\"` is explicitly selected.\n */\n externalAgents?: ExternalAgentPolicy;\n\n /**\n * Skip mounting the remote MCP protocol route.\n *\n * Most apps should leave this off so agent chat, A2A, and MCP share one\n * runtime. Hosted apps with a dedicated early MCP plugin can set this to\n * true so their external connector does not depend on the heavier chat\n * plugin initialization path.\n */\n disableMcp?: boolean;\n\n /**\n * Code-execution capability for the production agent.\n *\n * - `\"off\"` (default) — no code-execution tools in production.\n * - `\"sandboxed\"` — registers the `run-code` tool (isolated Node.js sandbox\n * with a bridge to allowlisted registered tools). Safe for shared or\n * hosted deployments.\n * - `\"trusted\"` — registers both the full coding tool registry\n * (bash / read / edit / write) and the `run-code` sandbox. Only use in\n * single-tenant or operator-controlled deployments where full shell access\n * to the host machine is intentional.\n *\n * The `AGENT_PROD_CODE_EXECUTION` environment variable (`\"trusted\"`,\n * `\"sandboxed\"`, or `\"off\"`) takes precedence over this option, allowing\n * per-deployment overrides without code changes.\n *\n * Dev-mode behavior is unchanged — both the coding tools and `run-code` are\n * always available when the environment allows toggling.\n */\n codeExecution?: {\n production?: \"off\" | \"sandboxed\" | \"trusted\";\n /**\n * Extra registered-tool names the sandbox bridge may forward (beyond the\n * default allowlist: provider-api-request, provider-api-docs,\n * provider-api-catalog, web-request).\n */\n bridgeTools?: string[];\n };\n\n /**\n * App-level default tool-call limits. Individual actions override these with\n * their own `timeoutMs` / `maxResultChars` declarations.\n */\n toolLimits?: { timeoutMs?: number; maxResultChars?: number };\n}\n"]}
|
|
1
|
+
{"version":3,"file":"plugin-options.js","sourceRoot":"","sources":["../../../src/server/agent-chat/plugin-options.ts"],"names":[],"mappings":"AA+ZA,wFAAwF;AACxF,MAAM,UAAU,gCAAgC,CAC9C,OAA4D;IAE5D,OAAO,OAAO,EAAE,kBAAkB,KAAK,KAAK,CAAC;AAC/C,CAAC","sourcesContent":["import type { ActionEntry } from \"../../agent/production-agent.js\";\nimport type { AgentLoopFinalResponseGuard } from \"../../agent/production-agent.js\";\nimport type {\n AgentChatAttachment,\n AgentChatReference,\n MentionProvider,\n} from \"../../agent/types.js\";\nimport type { ExternalAgentPolicy } from \"../../mcp/external-agent-policy.js\";\nimport type { DatabaseToolsOption } from \"../../scripts/db/tool-mode.js\";\nimport type { PromptExamples } from \"../prompts/index.js\";\n\n/** Shape of a Nitro plugin function: receives the Nitro app instance at\n * startup and may register routes/hooks synchronously or asynchronously. */\nexport type NitroPluginDef = (nitroApp: any) => void | Promise<void>;\n\nexport interface AgentChatPluginOptions {\n /** Template-specific actions (email ops, booking ops, etc.) */\n actions?:\n | Record<string, ActionEntry>\n | (() =>\n | Record<string, ActionEntry>\n | Promise<Record<string, ActionEntry>>);\n /** @deprecated Use `actions` instead */\n scripts?:\n | Record<string, ActionEntry>\n | (() =>\n | Record<string, ActionEntry>\n | Promise<Record<string, ActionEntry>>);\n /** System prompt for the agent. A sensible default is provided. */\n systemPrompt?: string;\n /** Additional system prompt prepended in dev mode */\n devSystemPrompt?: string;\n /** Model to use. Defaults to the resolved engine's default model. */\n model?: string;\n /** Optional per-app agent run chunk budget in milliseconds. Defaults to\n * AGENT_RUN_SOFT_TIMEOUT_MS when set, otherwise no framework-imposed\n * timeout. When reached, long runs continue through the hidden continuation\n * path instead of surfacing a timeout warning. */\n runSoftTimeoutMs?: number;\n /** Optional per-app run-manager no-progress watchdog in milliseconds. */\n runNoProgressTimeoutMs?: number;\n /**\n * Opt this app into Netlify durable background-function agent-chat runs. This\n * gives hosted agent turns the 15-minute async-function budget when the app's\n * Netlify build also emits the background function. Set this to `false` to\n * explicitly disable a stale deploy-wide `AGENT_CHAT_DURABLE_BACKGROUND`\n * flag for this app.\n */\n durableBackgroundRuns?: boolean;\n /** Anthropic API key. Falls back to ANTHROPIC_API_KEY env var */\n apiKey?: string;\n /**\n * Agent engine to use. Can be a pre-constructed AgentEngine, a registered\n * engine name (e.g. \"anthropic\", \"ai-sdk:openai\"), or an object with name\n * and config. Defaults to the \"anthropic\" engine using ANTHROPIC_API_KEY.\n */\n engine?:\n | import(\"../../agent/engine/types.js\").AgentEngine\n | string\n | { name: string; config: Record<string, unknown> };\n /** Route path. Default: /_agent-native/agent-chat */\n path?: string;\n /** Custom mention providers for @-tagging template entities */\n mentionProviders?:\n | Record<string, MentionProvider>\n | (() =>\n | Record<string, MentionProvider>\n | Promise<Record<string, MentionProvider>>);\n /** App ID used to exclude self from agent discovery (e.g., \"mail\", \"calendar\") */\n appId?: string;\n /** Optional MCP server branding surfaced during the initialize handshake. */\n mcpServerInfo?: {\n /** Human-facing title. Defaults to the capitalized app id/name. */\n title?: string;\n /** Host-facing description. Defaults to \"Agent-native <app> agent\". */\n description?: string;\n /** Canonical app URL. Relative URLs are resolved against the request origin. */\n websiteUrl?: string;\n /** App icons. Relative `src` values are resolved against the request origin. */\n icons?: Array<{\n src: string;\n mimeType?: string;\n sizes?: string[];\n theme?: \"light\" | \"dark\";\n }>;\n };\n /**\n * Optional callback to resolve the org ID for the current request.\n * When provided, the resolved value is set as AGENT_ORG_ID env var so\n * that db-query/db-exec automatically scope by org_id in addition to\n * owner_email.\n *\n * If not provided, the framework automatically uses `session.orgId` from\n * Better Auth's active organization. Only provide this callback when you\n * need custom org resolution logic (e.g., Atlassian org mapping).\n */\n resolveOrgId?: (event: any) => string | null | Promise<string | null>;\n /**\n * Optional owner resolver for public/anonymous chat surfaces. When the\n * normal app session is missing, this callback may return a synthetic\n * owner id for a narrowly-scoped public request (for example, a public\n * shared document page). Anonymous requests use a read-only tool set by\n * default so public viewers cannot mutate app data through the agent.\n */\n anonymousOwner?: (event: any) => string | null | Promise<string | null>;\n /**\n * Keep anonymous-owner requests on read-only template actions. Defaults to\n * true. Only disable for single-tenant apps that intentionally allow public\n * agent mutations.\n */\n anonymousReadOnly?: boolean;\n /**\n * Optional auth adapter for the HTTP action route\n * (`/_agent-native/actions/*`). Its `resolveCaller` runs before the\n * cookie/bearer `getSession` chain, letting an app accept caller identities\n * `getSession` doesn't understand (e.g. an A2A JWT verified with\n * `verifyA2AToken`) declaratively, instead of pre-seeding request context\n * from a Nitro `request` hook.\n *\n * Returning `null` defers to the normal chain; THROWING hard-rejects with a\n * 401 (an invalid/forged credential must not fall through to a same-origin\n * session cookie). A resolved caller's org comes exclusively from the\n * verified credential — the returned `orgId` or the owner-email membership\n * lookup — never from the request's session cookie.\n * See {@link import(\"../action-routes.js\").ActionRouteAuthAdapter}.\n */\n actionRouteAuth?: import(\"../action-routes.js\").ActionRouteAuthAdapter;\n /**\n * Optional callback to append template-specific context to the system\n * prompt on each request. Runs after AGENTS.md / skills / memory are\n * loaded and before the schema block — use it to inject dynamic SQL\n * context like a data dictionary, active feature flags, or whatever\n * the agent should know about *right now* for this user/org.\n *\n * Return `null` or an empty string to skip. The string you return is\n * appended verbatim, so wrap it in your own XML tags (e.g.\n * `<data-dictionary>…</data-dictionary>`) to keep the prompt scannable.\n *\n * Called on every request in every prompt variant (lean, lazy, full).\n * Templates that want to suppress it in a particular mode should return\n * `null` from the callback based on their own logic.\n */\n extraContext?: (\n event: any,\n owner: string,\n ) => string | null | Promise<string | null>;\n /**\n * Optional final-answer guard. Templates can use this to require a\n * corrective retry before accepting a text-only final answer, e.g. forcing\n * real data-source tool calls for analytics requests.\n */\n finalResponseGuard?: AgentLoopFinalResponseGuard;\n /**\n * Optional per-template request normalizer. Runs after authentication and\n * before the model sees the message, so apps can translate chat attachments\n * into template-native file handles while preserving the user's visible text.\n */\n prepareRequest?: (details: {\n event: any;\n ownerEmail: string | null;\n message: string;\n displayMessage?: string;\n attachments: AgentChatAttachment[];\n references: AgentChatReference[];\n threadId?: string;\n internalContinuation?: boolean;\n mode: \"act\" | \"plan\";\n }) =>\n | void\n | {\n message?: string;\n displayMessage?: string;\n attachments?: AgentChatAttachment[];\n }\n | Promise<void | {\n message?: string;\n displayMessage?: string;\n attachments?: AgentChatAttachment[];\n }>;\n /**\n * Use ONLY the template's `systemPrompt` and the actions list — skip the\n * framework prompt wrapper, resource loading (AGENTS.md/LEARNINGS.md/\n * memory), the SQL schema block, and the workspace files/skills/agents\n * inventory. Intended for minimal or voice-first apps where a long,\n * generic preamble adds latency and iteration noise without adding value.\n *\n * When set, the same lean prompt is used in both dev and prod modes. In\n * dev mode the tool registry is ALSO swapped to the template's actions\n * (same set as prod) — the dev-only bash/db-exec/file-system tools\n * and the resource/docs/chat/team/job/browser scripts are dropped. The\n * lean system prompt has no bash-usage guidance, so routing actions\n * through bash would break. If you need the full dev tool surface,\n * leave this off.\n */\n leanPrompt?: boolean;\n /**\n * Skip auto-injecting the workspace files/skills/agents inventory on the\n * first message of a conversation while keeping the normal prompt, resources,\n * and tool surface. Use this for domain-focused apps where broad workspace\n * inventory is mostly latency/noise unless the user explicitly references it.\n *\n * `leanPrompt: true` and the default `lazyContext` mode imply this because\n * those catalogs are already discoverable through resources, docs-search,\n * tool-search, and the compact resource indexes. Set `false` explicitly only\n * when a workspace-wide inventory is central to the app's first-turn job.\n */\n skipFilesContext?: boolean;\n /**\n * Initial native tool schemas to send to the LLM provider. When set, the\n * agent starts with only these tools plus `tool-search`; the live registry\n * remains searchable, and matching schemas from `tool-search` results are\n * loaded into the next model request. Use this for domain-focused apps that\n * have a few common actions and many rare framework utilities. Common\n * discovery and resource-reading tools are promoted automatically when\n * present. Provider, MCP, extension, and code-execution schemas stay behind\n * tool-search unless the app explicitly includes them in this list.\n */\n initialToolNames?: string[];\n /**\n * Controls whether broad provider/corpus tools and their workflow prompt are\n * loaded into the first model request. Use `\"lazy\"` for apps that can answer\n * ordinary lookups from a compact curated tool set; corpus tools remain\n * discoverable through tool-search and the full retry surface.\n *\n * @default \"initial\"\n */\n corpusTools?: \"initial\" | \"lazy\";\n /**\n * Use a compact system prompt with on-demand context loading. The system\n * prompt includes essential behavioral rules and action signatures, but\n * defers verbose framework details, SQL schema, skills, learnings, and\n * memory behind tools (`get-framework-context`, `db-schema`,\n * `resources` (action: read)). The agent fetches these on-demand when needed.\n *\n * This reduces the system prompt by ~60-70%, significantly improving\n * time-to-first-token and reducing \"thinking\" time. The agent retains\n * all capabilities — it just loads context lazily instead of upfront.\n *\n * Defaults to `true`. Set to `false` to use the original full prompt.\n * Ignored when `leanPrompt` is set (lean mode is even more minimal).\n */\n lazyContext?: boolean;\n /**\n * In dev mode, register the template's actions as native tools the agent\n * can call directly with structured JSON args — skipping the default\n * `bash(command=\"pnpm action <name> ...\")` indirection.\n *\n * The default dev behavior shells out because it \"mirrors how Claude Code\n * works locally\" and reduces empty-object tool calls for templates with\n * simple string args. But templates whose actions take structured data\n * (objects, arrays, nested JSON) can't round-trip those cleanly through\n * the CLI parser — stringified JSON on the way in, loss of type fidelity\n * on the way out.\n *\n * Set to `true` to get the same tool surface in dev that production uses.\n * `leanPrompt: true` implies this already (lean mode has no bash-usage\n * guidance, so actions must be native). Set this flag without\n * `leanPrompt` when you want native actions AND the full system prompt.\n *\n * Defaults to `false`.\n */\n nativeActionsInDev?: boolean;\n /**\n * Expose raw SQL/native database tools to the app agent.\n *\n * Defaults to `\"read\"`: `db-schema`/`db-query` are available for inspection,\n * while writes route through typed app actions. Set to `\"write\"` (also\n * `true`) to expose `db-exec`/`db-patch` for scoped raw SQL maintenance.\n * Set to `\"off\"` (also `false`) for chat-first apps that want agents to use\n * typed actions only.\n */\n databaseTools?: DatabaseToolsOption;\n /**\n * Expose framework extension management actions (`create-extension`,\n * `update-extension`, `list-extensions`, etc.) to the app agent. Defaults to\n * false. Set to true for apps that intentionally let the LLM create or\n * manage sandboxed extension mini-apps. Core extension routes may still be\n * mounted for compatibility and app-owned surfaces.\n */\n extensionTools?: boolean;\n /**\n * Optional A2A-only deterministic response path. Runs after inbound A2A text\n * and user context are resolved, but before an agent engine/model is loaded.\n * Return a message to complete the A2A task without invoking the LLM, or\n * null/undefined to continue through the normal agent loop.\n */\n a2aMessageFallback?: (details: {\n message: import(\"../../a2a/types.js\").Message;\n text: string;\n context: import(\"../../a2a/types.js\").A2AHandlerContext;\n userEmail: string | undefined;\n }) =>\n | import(\"../../a2a/types.js\").Message\n | string\n | null\n | undefined\n | Promise<import(\"../../a2a/types.js\").Message | string | null | undefined>;\n /**\n * Optional injectable prompt examples for core rules (rule 5 auto-refresh\n * examples and rule 8 external provider names). When absent, generic\n * placeholders are used so no template-specific names appear in the core\n * prompt by default.\n *\n * - `providerActions`: external provider action names this template exposes\n * (e.g. `[\"warehouse-query\", \"crm-records\"]` for a template).\n * - `appActions`: representative template action names for rule 5's refresh\n * examples (e.g. `[\"log-meal\", \"update-form\"]` for a forms template).\n */\n promptExamples?: PromptExamples;\n /**\n * Curated allow-list of action names to serve external **connector** clients\n * on a hosted multi-tenant deployment.\n *\n * Whenever this list is non-empty it is active by default for **every**\n * caller (hosted connectors, code/stdio clients, and the local CLI): external\n * MCP clients see (and can call) only these actions plus the builtin\n * cross-app tools (`list_apps`, `open_app`, `ask_app`, `create_embed_session`).\n * Calls to any tool outside the list are rejected with \"Unknown tool\".\n * This prevents the full ~105-tool catalog from bloating external-agent\n * context windows and removes footguns (db-exec, seed-*, extension suite,\n * browser-session tools) from connectors. It is no longer gated behind an\n * environment variable, and the catalog is never inferred from the client.\n *\n * `tool-search` stays available for discovery; a trimmed action still needs\n * the connector catalog, authenticated-read policy, or full-catalog opt-in\n * before an external caller can execute it.\n * Callers who need the full surface up front opt in explicitly with\n * `agent-native connect --full-catalog` (embeds a `catalog_scope: \"full\"`\n * claim in their connect-minted JWT) or the deployment-wide\n * `AGENT_NATIVE_MCP_FULL_CATALOG=1` env override.\n *\n * Declare here rather than in MCPConfig directly; the plugin copies it through.\n */\n connectorCatalog?: string[];\n\n /**\n * Default authenticated external-agent policy. In `auto` read mode, every\n * action explicitly marked as GET + readOnly + publicAgent.requiresAuth is\n * added to the connector surface automatically. Writes remain ask_app-only\n * unless `writes: \"allowlisted\"` is explicitly selected.\n */\n externalAgents?: ExternalAgentPolicy;\n\n /**\n * Allow this app's A2A agent to delegate to a different app through the\n * built-in `call-agent` tool. Enabled by default so a receiver keeps the\n * same cross-app capability as its interactive agent. Set false only for an\n * intentionally isolated app. Core enforces a bounded delegation path so\n * cycle safety does not depend on removing the tool.\n */\n a2aAgentDelegation?: boolean;\n\n /**\n * Resource budget for delegated A2A/MCP agent turns. Defaults are stricter\n * than interactive chat because every retained tool result is re-sent on\n * later iterations and delegated callers need a compact answer, not a raw\n * transcript. Apps may raise one limit deliberately for proven workloads.\n */\n delegatedRunPolicy?: {\n maxIterations?: number;\n maxRunInputTokens?: number;\n maxToolResultChars?: number;\n };\n\n /**\n * Skip mounting the remote MCP protocol route.\n *\n * Most apps should leave this off so agent chat, A2A, and MCP share one\n * runtime. Hosted apps with a dedicated early MCP plugin can set this to\n * true so their external connector does not depend on the heavier chat\n * plugin initialization path.\n */\n disableMcp?: boolean;\n\n /**\n * Code-execution capability for the production agent.\n *\n * - `\"off\"` (default) — no code-execution tools in production.\n * - `\"sandboxed\"` — registers the `run-code` tool (isolated Node.js sandbox\n * with a bridge to allowlisted registered tools). Safe for shared or\n * hosted deployments.\n * - `\"trusted\"` — registers both the full coding tool registry\n * (bash / read / edit / write) and the `run-code` sandbox. Only use in\n * single-tenant or operator-controlled deployments where full shell access\n * to the host machine is intentional.\n *\n * The `AGENT_PROD_CODE_EXECUTION` environment variable (`\"trusted\"`,\n * `\"sandboxed\"`, or `\"off\"`) takes precedence over this option, allowing\n * per-deployment overrides without code changes.\n *\n * Dev-mode behavior is unchanged — both the coding tools and `run-code` are\n * always available when the environment allows toggling.\n */\n codeExecution?: {\n production?: \"off\" | \"sandboxed\" | \"trusted\";\n /**\n * Extra registered-tool names the sandbox bridge may forward (beyond the\n * default allowlist: provider-api-request, provider-api-docs,\n * provider-api-catalog, web-request).\n */\n bridgeTools?: string[];\n };\n\n /**\n * App-level default tool-call limits. Individual actions override these with\n * their own `timeoutMs` / `maxResultChars` declarations.\n */\n toolLimits?: {\n timeoutMs?: number;\n maxResultChars?: number;\n /** Absolute cap applied even when an individual action declares more. */\n hardMaxResultChars?: number;\n };\n}\n\n/** Cross-app agent delegation is a workspace default; false is an isolation opt-out. */\nexport function resolveA2AAgentDelegationEnabled(\n options?: Pick<AgentChatPluginOptions, \"a2aAgentDelegation\">,\n): boolean {\n return options?.a2aAgentDelegation !== false;\n}\n"]}
|
|
@@ -780,7 +780,7 @@ export async function loadResourcesForPrompt(owner, compact = false, selfAppId,
|
|
|
780
780
|
// Nothing else in the prompt or the initial tool surface tells the agent
|
|
781
781
|
// which peer apps exist, so this block is not droppable: without it the
|
|
782
782
|
// agent reports cross-app work as impossible instead of delegating.
|
|
783
|
-
addSection(`<available-apps>\nWorkspace apps available over A2A/call-agent:\n${lines.join("\n")}\n\
|
|
783
|
+
addSection(`<available-apps>\nWorkspace apps available over A2A/call-agent:\n${lines.join("\n")}\n\nWhen another app owns the work or data, use \`call-agent\` with the app id and a natural-language message. The receiving specialist owns source selection, schema interpretation, queries, joins, and use of its local tools. Direct action invocation is optional for an exact bounded read with a fully known schema; never use it to compensate for unreliable delegation.\n\nThese one-liners are the only cross-app detail in this prompt. Before building a capability another app may already own, before telling the user what is or is not possible across apps, and whenever the user asks which app to use, call \`describe-workspace-apps\` - it reads each peer's live agent card for current purpose and optional capability details. Never hand-maintain a list of workspace apps in code or docs; it goes stale silently.\n</available-apps>`, "required");
|
|
784
784
|
}
|
|
785
785
|
}
|
|
786
786
|
catch {
|