@agent-native/core 0.121.2 → 0.122.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/corpus/README.md +2 -2
- package/corpus/core/CHANGELOG.md +139 -0
- package/corpus/core/docs/content/actions.mdx +2 -2
- package/corpus/core/docs/content/agent-surfaces.mdx +1 -1
- package/corpus/core/docs/content/authentication.mdx +2 -0
- package/corpus/core/docs/content/deployment.mdx +36 -0
- package/corpus/core/docs/content/http-api.mdx +266 -0
- package/corpus/core/docs/content/syncing-template-changes.mdx +159 -0
- package/corpus/core/package.json +2 -1
- package/corpus/core/src/a2a/activity.ts +38 -27
- package/corpus/core/src/agent/engine/builder-engine.ts +35 -4
- package/corpus/core/src/agent/run-manager.ts +20 -1
- package/corpus/core/src/agent/run-store.ts +4 -1
- package/corpus/core/src/agent/types.ts +28 -8
- package/corpus/core/src/chat-threads/store.ts +45 -0
- package/corpus/core/src/checkpoints/index.ts +2 -0
- package/corpus/core/src/checkpoints/route-match.ts +13 -0
- package/corpus/core/src/cli/create.ts +105 -17
- package/corpus/core/src/cli/index.ts +20 -0
- package/corpus/core/src/cli/template-baseline.ts +410 -0
- package/corpus/core/src/cli/template-sync.ts +1004 -0
- package/corpus/core/src/cli/templates-meta.ts +1 -0
- package/corpus/core/src/client/AssistantChat.tsx +38 -12
- package/corpus/core/src/client/NewWorkspaceAppFlow.tsx +75 -10
- package/corpus/core/src/client/chat/message-components.tsx +127 -66
- package/corpus/core/src/client/chat/tool-call-display.tsx +29 -5
- package/corpus/core/src/client/error-format.ts +18 -0
- package/corpus/core/src/client/org/OrgSwitcher.tsx +30 -8
- package/corpus/core/src/client/org/TeamPage.tsx +7 -6
- package/corpus/core/src/client/sse-event-processor.ts +3 -0
- package/corpus/core/src/data-widgets/index.ts +41 -0
- package/corpus/core/src/deploy/build.ts +11 -9
- package/corpus/core/src/integrations/webhook-handler.ts +63 -9
- package/corpus/core/src/org/auto-join-domain.ts +4 -3
- package/corpus/core/src/org/context.ts +108 -39
- package/corpus/core/src/org/index.ts +5 -0
- package/corpus/core/src/org/service-identity.ts +60 -0
- package/corpus/core/src/provider-api/index.ts +22 -1
- package/corpus/core/src/scripts/docs/search.ts +12 -1
- package/corpus/core/src/server/agent-chat/context-tools.ts +9 -4
- package/corpus/core/src/server/agent-chat/framework-prompts.ts +38 -66
- package/corpus/core/src/server/agent-chat-plugin.ts +17 -10
- package/corpus/core/src/server/agents-bundle.ts +84 -5
- package/corpus/core/src/server/auth.ts +4 -3
- package/corpus/core/src/server/builder-browser.ts +47 -19
- package/corpus/core/src/server/core-routes-plugin.ts +2 -2
- package/corpus/core/src/server/credential-provider.ts +209 -68
- package/corpus/core/src/server/index.ts +3 -0
- package/corpus/core/src/server/prompts/framework-core-compact.ts +6 -13
- package/corpus/core/src/server/prompts/framework-core.ts +9 -21
- package/corpus/core/src/server/prompts/index.ts +0 -1
- package/corpus/core/src/server/prompts/shared-rules.ts +19 -11
- package/corpus/core/src/server/ssr-handler.ts +13 -2
- package/corpus/core/src/settings/user-settings.ts +13 -1
- package/corpus/core/src/shared/cache-control.ts +141 -0
- package/corpus/core/src/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/core/src/templates/chat/_gitignore +1 -0
- package/corpus/core/src/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/core/src/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/core/src/templates/workspace-core/.agents/skills/performance/SKILL.md +19 -0
- package/corpus/core/src/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/core/src/templates/workspace-core/.agents/skills/visual-answer/SKILL.md +1 -0
- package/corpus/core/src/vite/agents-bundle-plugin.ts +7 -6
- package/corpus/core/src/vite/client.ts +5 -0
- package/corpus/templates/analytics/.agents/skills/adhoc-analysis/SKILL.md +4 -5
- package/corpus/templates/analytics/.agents/skills/admin-surfaces/SKILL.md +55 -0
- package/corpus/templates/analytics/.agents/skills/dashboard-management/SKILL.md +10 -0
- package/corpus/templates/analytics/.agents/skills/dashboard-management/references/template-catalog-and-demo.md +62 -0
- package/corpus/templates/analytics/.agents/skills/dashboard-ops/SKILL.md +85 -0
- package/corpus/templates/analytics/.agents/skills/data-querying/SKILL.md +27 -2
- package/corpus/templates/analytics/.agents/skills/data-querying/references/inline-chart-embeds.md +139 -0
- package/corpus/templates/analytics/.agents/skills/monitoring/SKILL.md +77 -0
- package/corpus/templates/analytics/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/analytics/AGENTS.md +91 -563
- package/corpus/templates/analytics/_gitignore +1 -0
- package/corpus/templates/analytics/actions/bigquery.ts +12 -4
- package/corpus/templates/analytics/actions/generate-chart.ts +5 -5
- package/corpus/templates/analytics/app/components/dashboard/SqlChart.tsx +30 -1
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/DashboardFilterBar.tsx +3 -0
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/SqlChartCard.tsx +1 -1
- package/corpus/templates/analytics/app/pages/adhoc/sql-dashboard/index.tsx +1 -0
- package/corpus/templates/analytics/changelog/2026-07-24-analytics-finds-saved-dashboards-and-queries-far-more-reliab.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-24-notion-access-errors-now-explain-that-a-page-needs-sharing-w.md +6 -0
- package/corpus/templates/analytics/server/lib/agent-chat-plan-mode.ts +7 -0
- package/corpus/templates/analytics/server/lib/analytics-query-catalog.ts +191 -30
- package/corpus/templates/analytics/server/lib/bigquery.ts +11 -1
- package/corpus/templates/analytics/server/lib/notion.ts +15 -4
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +10 -0
- package/corpus/templates/assets/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/brain/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/brain/_gitignore +1 -0
- package/corpus/templates/calendar/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/calendar/_gitignore +1 -0
- package/corpus/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/chat/_gitignore +1 -0
- package/corpus/templates/clips/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/clips/.agents/skills/video-sharing/SKILL.md +34 -0
- package/corpus/templates/clips/AGENTS.md +5 -4
- package/corpus/templates/clips/_gitignore +1 -0
- package/corpus/templates/clips/actions/cleanup-transcript.ts +5 -0
- package/corpus/templates/clips/actions/get-recording-insights.ts +44 -8
- package/corpus/templates/clips/actions/get-recording-player-data.ts +39 -70
- package/corpus/templates/clips/actions/list-clip-views.ts +2 -4
- package/corpus/templates/clips/actions/list-recordings.ts +69 -19
- package/corpus/templates/clips/actions/list-viewers.ts +5 -2
- package/corpus/templates/clips/actions/regenerate-summary.ts +5 -1
- package/corpus/templates/clips/actions/request-transcript.ts +28 -1
- package/corpus/templates/clips/app/components/editor/stitch-manager.tsx +21 -1
- package/corpus/templates/clips/app/components/meetings/quick-ask-sidebar.tsx +14 -1
- package/corpus/templates/clips/app/components/player/insights-panel.tsx +8 -20
- package/corpus/templates/clips/app/components/player/recording-views-badge.tsx +335 -0
- package/corpus/templates/clips/app/components/player/video-player.tsx +13 -8
- package/corpus/templates/clips/app/components/sharing/share-ui.tsx +2 -1
- package/corpus/templates/clips/app/i18n/en-US.ts +13 -2
- package/corpus/templates/clips/app/lib/capture-permissions.ts +110 -0
- package/corpus/templates/clips/app/lib/recording-link.ts +32 -0
- package/corpus/templates/clips/app/routes/_app.meetings.$meetingId.tsx +27 -0
- package/corpus/templates/clips/app/routes/r.$recordingId.tsx +46 -15
- package/corpus/templates/clips/app/routes/record.tsx +77 -31
- package/corpus/templates/clips/app/routes/share.$shareId.tsx +42 -31
- package/corpus/templates/clips/changelog/2026-07-24-clip-pages-now-show-a-view-count-with-viewer-avatars-next-to.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-clip-summaries-read-like-a-description-you-d-write-yourself-.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-clip-view-counts-now-separate-human-views-from-agent-views-s.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-clips-actions-can-now-be-called-by-org-service-tokens-so-ext.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-clips-no-longer-briefly-shows-a-dock-icon-while-launching.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-fixed-owner-and-editor-share-links-redirecting-to-the-record.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-meeting-and-note-recordings-now-start-as-a-compact-pill-on-t.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-new-clips-now-copy-a-shareable-link-instead-of-the-owner-onl.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-opening-a-share-link-as-the-clip-s-owner-now-goes-straight-t.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-permissions-and-rewind-controls-now-use-compact-consistent-h.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-quitting-the-desktop-app-no-longer-shows-a-false-macos-crash.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-screen-recording-permission-errors-now-name-the-exact-app-to.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-the-desktop-app-now-copies-a-new-clip-s-share-link-to-your-c.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-the-recording-toolbar-now-stays-above-other-apps-including-o.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-transcript-captions-now-use-real-speech-timings-instead-of-a.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-24-video-playback-no-longer-stutters-and-replays-the-last-momen.md +6 -0
- package/corpus/templates/clips/chrome-extension/src/background.ts +17 -1
- package/corpus/templates/clips/desktop/package.json +2 -0
- package/corpus/templates/clips/desktop/src/app.tsx +89 -0
- package/corpus/templates/clips/desktop/src/hooks/useMeetingTranscription.ts +9 -3
- package/corpus/templates/clips/desktop/src/lib/audio-meter.ts +51 -0
- package/corpus/templates/clips/desktop/src/lib/native-notification.ts +44 -0
- package/corpus/templates/clips/desktop/src/lib/recording-link.ts +67 -0
- package/corpus/templates/clips/desktop/src/overlays/live-audio-bars.tsx +35 -35
- package/corpus/templates/clips/desktop/src/overlays/live-transcript.tsx +3 -2
- package/corpus/templates/clips/desktop/src/overlays/recording-pill.tsx +47 -46
- package/corpus/templates/clips/desktop/src/styles.css +127 -78
- package/corpus/templates/clips/desktop/src-tauri/Cargo.toml +7 -0
- package/corpus/templates/clips/desktop/src-tauri/Info.plist +6 -0
- package/corpus/templates/clips/desktop/src-tauri/capabilities/default.json +1 -0
- package/corpus/templates/clips/desktop/src-tauri/src/clips/mod.rs +7 -3
- package/corpus/templates/clips/desktop/src-tauri/src/lib.rs +4 -1
- package/corpus/templates/clips/desktop/src-tauri/src/main.rs +8 -0
- package/corpus/templates/clips/desktop/src-tauri/src/recording_indicator.rs +21 -10
- package/corpus/templates/clips/desktop/src-tauri/src/util.rs +40 -0
- package/corpus/templates/clips/server/db/schema.ts +25 -0
- package/corpus/templates/clips/server/lib/agent-views.ts +145 -0
- package/corpus/templates/clips/server/lib/public-agent-context.ts +7 -0
- package/corpus/templates/clips/server/lib/recording-share-grant.ts +79 -0
- package/corpus/templates/clips/server/lib/recordings.ts +51 -3
- package/corpus/templates/clips/server/plugins/db.ts +23 -0
- package/corpus/templates/clips/server/routes/api/public-recording.get.ts +49 -17
- package/corpus/templates/clips/shared/recording-link.ts +43 -0
- package/corpus/templates/clips/shared/share-attribution.ts +4 -0
- package/corpus/templates/clips/shared/share-dashboard-redirect.ts +42 -0
- package/corpus/templates/clips/shared/view-analytics.ts +26 -0
- package/corpus/templates/content/.agents/skills/content/SKILL.md +5 -0
- package/corpus/templates/content/.agents/skills/content/references/local-file-mode.md +135 -0
- package/corpus/templates/content/.agents/skills/document-editing/SKILL.md +12 -0
- package/corpus/templates/content/.agents/skills/document-editing/references/databases.md +238 -0
- package/corpus/templates/content/.agents/skills/document-editing/references/document-behavior.md +91 -0
- package/corpus/templates/content/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/content/AGENTS.md +62 -583
- package/corpus/templates/content/_gitignore +1 -0
- package/corpus/templates/design/.agents/skills/creative-context/SKILL.md +11 -0
- package/corpus/templates/design/.agents/skills/design-generation/SKILL.md +50 -8
- package/corpus/templates/design/.agents/skills/design-generation/references/code-layers.md +81 -0
- package/corpus/templates/design/.agents/skills/design-generation/references/code-workspace.md +42 -0
- package/corpus/templates/design/.agents/skills/design-generation/references/editor-extensions.md +34 -0
- package/corpus/templates/design/.agents/skills/responsive-breakpoints/SKILL.md +4 -1
- package/corpus/templates/design/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/design/.agents/skills/visual-edit/SKILL.md +17 -0
- package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +8196 -0
- package/corpus/templates/design/.generated/bridge/embedded-wheel.generated.ts +265 -0
- package/corpus/templates/design/.generated/bridge/hit-test.generated.ts +642 -0
- package/corpus/templates/design/.generated/bridge/motion-preview.generated.ts +571 -0
- package/corpus/templates/design/.generated/bridge/nav.generated.ts +91 -0
- package/corpus/templates/design/.generated/bridge/sample.generated.ts +23 -0
- package/corpus/templates/design/.generated/bridge/shader-fill-preview.generated.ts +263 -0
- package/corpus/templates/design/.generated/bridge/shader-runtime.generated.ts +518 -0
- package/corpus/templates/design/.generated/bridge/tweak.generated.ts +20 -0
- package/corpus/templates/design/.generated/bridge/zoom.generated.ts +32 -0
- package/corpus/templates/design/AGENTS.md +88 -503
- package/corpus/templates/design/_gitignore +1 -0
- package/corpus/templates/dispatch/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/dispatch/_gitignore +1 -0
- package/corpus/templates/dispatch/changelog/2026-07-24-signing-in-now-puts-you-in-your-companys-workspace.md +6 -0
- package/corpus/templates/forms/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/forms/_gitignore +1 -0
- package/corpus/templates/forms/server/lib/public-form-ssr.ts +2 -2
- package/corpus/templates/macros/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/macros/_gitignore +1 -0
- package/corpus/templates/mail/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/mail/_gitignore +1 -0
- package/corpus/templates/plan/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/plan/_gitignore +1 -0
- package/corpus/templates/slides/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/slides/_gitignore +1 -0
- package/corpus/templates/slides/server/plugins/db.ts +4 -0
- package/corpus/templates/tasks/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/corpus/templates/tasks/AGENTS.md +1 -1
- package/corpus/templates/tasks/_gitignore +1 -0
- package/dist/a2a/activity.d.ts +4 -1
- package/dist/a2a/activity.d.ts.map +1 -1
- package/dist/a2a/activity.js +27 -16
- package/dist/a2a/activity.js.map +1 -1
- package/dist/agent/engine/builder-engine.d.ts +1 -0
- package/dist/agent/engine/builder-engine.d.ts.map +1 -1
- package/dist/agent/engine/builder-engine.js +31 -4
- package/dist/agent/engine/builder-engine.js.map +1 -1
- package/dist/agent/run-manager.d.ts.map +1 -1
- package/dist/agent/run-manager.js +18 -1
- package/dist/agent/run-manager.js.map +1 -1
- package/dist/agent/run-store.d.ts +1 -0
- package/dist/agent/run-store.d.ts.map +1 -1
- package/dist/agent/run-store.js +2 -1
- package/dist/agent/run-store.js.map +1 -1
- package/dist/agent/types.d.ts +12 -1
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js +21 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/chat-threads/store.d.ts +10 -0
- package/dist/chat-threads/store.d.ts.map +1 -1
- package/dist/chat-threads/store.js +41 -0
- package/dist/chat-threads/store.js.map +1 -1
- package/dist/checkpoints/index.d.ts +1 -0
- package/dist/checkpoints/index.d.ts.map +1 -1
- package/dist/checkpoints/index.js +1 -0
- package/dist/checkpoints/index.js.map +1 -1
- package/dist/checkpoints/route-match.d.ts +8 -0
- package/dist/checkpoints/route-match.d.ts.map +1 -0
- package/dist/checkpoints/route-match.js +13 -0
- package/dist/checkpoints/route-match.js.map +1 -0
- package/dist/cli/create.d.ts +35 -4
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +69 -19
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/index.js +19 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/template-baseline.d.ts +54 -0
- package/dist/cli/template-baseline.d.ts.map +1 -0
- package/dist/cli/template-baseline.js +334 -0
- package/dist/cli/template-baseline.js.map +1 -0
- package/dist/cli/template-sync.d.ts +57 -0
- package/dist/cli/template-sync.d.ts.map +1 -0
- package/dist/cli/template-sync.js +787 -0
- package/dist/cli/template-sync.js.map +1 -0
- package/dist/cli/templates-meta.d.ts.map +1 -1
- package/dist/cli/templates-meta.js +1 -0
- package/dist/cli/templates-meta.js.map +1 -1
- package/dist/client/AssistantChat.d.ts +2 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +38 -10
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/NewWorkspaceAppFlow.d.ts.map +1 -1
- package/dist/client/NewWorkspaceAppFlow.js +32 -2
- package/dist/client/NewWorkspaceAppFlow.js.map +1 -1
- package/dist/client/chat/message-components.d.ts +20 -0
- package/dist/client/chat/message-components.d.ts.map +1 -1
- package/dist/client/chat/message-components.js +81 -46
- package/dist/client/chat/message-components.js.map +1 -1
- package/dist/client/chat/tool-call-display.d.ts.map +1 -1
- package/dist/client/chat/tool-call-display.js +14 -6
- package/dist/client/chat/tool-call-display.js.map +1 -1
- package/dist/client/error-format.d.ts.map +1 -1
- package/dist/client/error-format.js +13 -0
- package/dist/client/error-format.js.map +1 -1
- package/dist/client/org/OrgSwitcher.d.ts +8 -1
- package/dist/client/org/OrgSwitcher.d.ts.map +1 -1
- package/dist/client/org/OrgSwitcher.js +3 -2
- package/dist/client/org/OrgSwitcher.js.map +1 -1
- package/dist/client/org/TeamPage.d.ts.map +1 -1
- package/dist/client/org/TeamPage.js +1 -1
- package/dist/client/org/TeamPage.js.map +1 -1
- package/dist/client/sse-event-processor.d.ts.map +1 -1
- package/dist/client/sse-event-processor.js +3 -0
- package/dist/client/sse-event-processor.js.map +1 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/data-widgets/index.d.ts +3 -0
- package/dist/data-widgets/index.d.ts.map +1 -1
- package/dist/data-widgets/index.js +33 -0
- package/dist/data-widgets/index.js.map +1 -1
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +11 -7
- package/dist/deploy/build.js.map +1 -1
- package/dist/eject/provider-api-definitions.d.ts +1 -0
- package/dist/eject/provider-api-definitions.d.ts.map +1 -1
- package/dist/integrations/webhook-handler.d.ts.map +1 -1
- package/dist/integrations/webhook-handler.js +46 -9
- package/dist/integrations/webhook-handler.js.map +1 -1
- package/dist/org/auto-join-domain.d.ts +3 -2
- package/dist/org/auto-join-domain.d.ts.map +1 -1
- package/dist/org/auto-join-domain.js +1 -1
- package/dist/org/auto-join-domain.js.map +1 -1
- package/dist/org/context.d.ts.map +1 -1
- package/dist/org/context.js +84 -28
- package/dist/org/context.js.map +1 -1
- package/dist/org/index.d.ts +1 -0
- package/dist/org/index.d.ts.map +1 -1
- package/dist/org/index.js +1 -0
- package/dist/org/index.js.map +1 -1
- package/dist/org/service-identity.d.ts +43 -0
- package/dist/org/service-identity.d.ts.map +1 -0
- package/dist/org/service-identity.js +34 -0
- package/dist/org/service-identity.js.map +1 -0
- package/dist/provider-api/actions/custom-provider-registration.d.ts +14 -14
- package/dist/provider-api/actions/provider-api.d.ts +13 -11
- package/dist/provider-api/actions/provider-api.d.ts.map +1 -1
- package/dist/provider-api/index.d.ts +4 -0
- package/dist/provider-api/index.d.ts.map +1 -1
- package/dist/provider-api/index.js +17 -1
- package/dist/provider-api/index.js.map +1 -1
- package/dist/resources/handlers.d.ts +1 -1
- package/dist/scripts/docs/search.d.ts.map +1 -1
- package/dist/scripts/docs/search.js +12 -1
- package/dist/scripts/docs/search.js.map +1 -1
- package/dist/server/agent-chat/context-tools.d.ts.map +1 -1
- package/dist/server/agent-chat/context-tools.js +3 -3
- package/dist/server/agent-chat/context-tools.js.map +1 -1
- package/dist/server/agent-chat/framework-prompts.d.ts +8 -3
- package/dist/server/agent-chat/framework-prompts.d.ts.map +1 -1
- package/dist/server/agent-chat/framework-prompts.js +33 -62
- package/dist/server/agent-chat/framework-prompts.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +16 -10
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agents-bundle.d.ts +18 -0
- package/dist/server/agents-bundle.d.ts.map +1 -1
- package/dist/server/agents-bundle.js +70 -4
- package/dist/server/agents-bundle.js.map +1 -1
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +4 -3
- package/dist/server/auth.js.map +1 -1
- package/dist/server/builder-browser.d.ts.map +1 -1
- package/dist/server/builder-browser.js +43 -19
- package/dist/server/builder-browser.js.map +1 -1
- package/dist/server/core-routes-plugin.js +2 -2
- package/dist/server/core-routes-plugin.js.map +1 -1
- package/dist/server/credential-provider.d.ts +38 -2
- package/dist/server/credential-provider.d.ts.map +1 -1
- package/dist/server/credential-provider.js +142 -64
- package/dist/server/credential-provider.js.map +1 -1
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +1 -1
- package/dist/server/index.js.map +1 -1
- package/dist/server/prompts/framework-core-compact.d.ts +1 -1
- package/dist/server/prompts/framework-core-compact.d.ts.map +1 -1
- package/dist/server/prompts/framework-core-compact.js +7 -13
- package/dist/server/prompts/framework-core-compact.js.map +1 -1
- package/dist/server/prompts/framework-core.d.ts +1 -1
- package/dist/server/prompts/framework-core.d.ts.map +1 -1
- package/dist/server/prompts/framework-core.js +10 -21
- package/dist/server/prompts/framework-core.js.map +1 -1
- package/dist/server/prompts/index.d.ts +1 -1
- package/dist/server/prompts/index.d.ts.map +1 -1
- package/dist/server/prompts/index.js +1 -1
- package/dist/server/prompts/index.js.map +1 -1
- package/dist/server/prompts/shared-rules.d.ts +16 -10
- package/dist/server/prompts/shared-rules.d.ts.map +1 -1
- package/dist/server/prompts/shared-rules.js +19 -10
- package/dist/server/prompts/shared-rules.js.map +1 -1
- package/dist/server/ssr-handler.d.ts +1 -1
- package/dist/server/ssr-handler.d.ts.map +1 -1
- package/dist/server/ssr-handler.js +10 -3
- package/dist/server/ssr-handler.js.map +1 -1
- package/dist/settings/user-settings.d.ts.map +1 -1
- package/dist/settings/user-settings.js +13 -1
- package/dist/settings/user-settings.js.map +1 -1
- package/dist/shared/cache-control.d.ts +52 -0
- package/dist/shared/cache-control.d.ts.map +1 -1
- package/dist/shared/cache-control.js +107 -0
- package/dist/shared/cache-control.js.map +1 -1
- package/dist/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/dist/templates/chat/_gitignore +1 -0
- package/dist/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/dist/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/dist/templates/workspace-core/.agents/skills/performance/SKILL.md +19 -0
- package/dist/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/dist/templates/workspace-core/.agents/skills/visual-answer/SKILL.md +1 -0
- package/dist/vite/agents-bundle-plugin.d.ts.map +1 -1
- package/dist/vite/agents-bundle-plugin.js +8 -7
- package/dist/vite/agents-bundle-plugin.js.map +1 -1
- package/dist/vite/client.d.ts.map +1 -1
- package/dist/vite/client.js +2 -0
- package/dist/vite/client.js.map +1 -1
- package/docs/content/actions.mdx +2 -2
- package/docs/content/agent-surfaces.mdx +1 -1
- package/docs/content/authentication.mdx +2 -0
- package/docs/content/deployment.mdx +36 -0
- package/docs/content/http-api.mdx +266 -0
- package/docs/content/syncing-template-changes.mdx +159 -0
- package/package.json +4 -3
- package/src/a2a/activity.ts +38 -27
- package/src/agent/engine/builder-engine.ts +35 -4
- package/src/agent/run-manager.ts +20 -1
- package/src/agent/run-store.ts +4 -1
- package/src/agent/types.ts +28 -8
- package/src/chat-threads/store.ts +45 -0
- package/src/checkpoints/index.ts +2 -0
- package/src/checkpoints/route-match.ts +13 -0
- package/src/cli/create.ts +105 -17
- package/src/cli/index.ts +20 -0
- package/src/cli/template-baseline.ts +410 -0
- package/src/cli/template-sync.ts +1004 -0
- package/src/cli/templates-meta.ts +1 -0
- package/src/client/AssistantChat.tsx +38 -12
- package/src/client/NewWorkspaceAppFlow.tsx +75 -10
- package/src/client/chat/message-components.tsx +127 -66
- package/src/client/chat/tool-call-display.tsx +29 -5
- package/src/client/error-format.ts +18 -0
- package/src/client/org/OrgSwitcher.tsx +30 -8
- package/src/client/org/TeamPage.tsx +7 -6
- package/src/client/sse-event-processor.ts +3 -0
- package/src/data-widgets/index.ts +41 -0
- package/src/deploy/build.ts +11 -9
- package/src/integrations/webhook-handler.ts +63 -9
- package/src/org/auto-join-domain.ts +4 -3
- package/src/org/context.ts +108 -39
- package/src/org/index.ts +5 -0
- package/src/org/service-identity.ts +60 -0
- package/src/provider-api/index.ts +22 -1
- package/src/scripts/docs/search.ts +12 -1
- package/src/server/__snapshots__/agent-chat-plugin.surface.spec.ts.snap +25 -36
- package/src/server/agent-chat/context-tools.ts +9 -4
- package/src/server/agent-chat/framework-prompts.ts +38 -66
- package/src/server/agent-chat-plugin.ts +17 -10
- package/src/server/agents-bundle.ts +84 -5
- package/src/server/auth.ts +4 -3
- package/src/server/builder-browser.ts +47 -19
- package/src/server/core-routes-plugin.ts +2 -2
- package/src/server/credential-provider.ts +209 -68
- package/src/server/index.ts +3 -0
- package/src/server/prompts/framework-core-compact.ts +6 -13
- package/src/server/prompts/framework-core.ts +9 -21
- package/src/server/prompts/index.ts +0 -1
- package/src/server/prompts/shared-rules.ts +19 -11
- package/src/server/ssr-handler.ts +13 -2
- package/src/settings/user-settings.ts +13 -1
- package/src/shared/cache-control.ts +141 -0
- package/src/templates/chat/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/src/templates/chat/_gitignore +1 -0
- package/src/templates/default/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/src/templates/headless/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/src/templates/workspace-core/.agents/skills/performance/SKILL.md +19 -0
- package/src/templates/workspace-core/.agents/skills/upgrade-agent-native/SKILL.md +24 -2
- package/src/templates/workspace-core/.agents/skills/visual-answer/SKILL.md +1 -0
- package/src/vite/agents-bundle-plugin.ts +7 -6
- package/src/vite/client.ts +5 -0
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: "Syncing Template Changes"
|
|
3
|
+
description: "agent-native template pulls later upstream first-party template changes into an app that was generated from a template, using a real per-file three-way merge against a pristine baseline."
|
|
4
|
+
---
|
|
5
|
+
|
|
6
|
+
# Syncing Template Changes
|
|
7
|
+
|
|
8
|
+
`agent-native create` copies a first-party template into your app and then makes it yours — substituting the app name, renaming `_gitignore`, rewriting `package.json`, pinning `workspace:*` and `catalog:` dependencies to concrete versions, and (in a workspace) swapping in inherited auth and chat plugins. From that moment the app is a fork. Fixes and improvements that land in the template upstream do not reach it.
|
|
9
|
+
|
|
10
|
+
`agent-native upgrade` does not close that gap. It moves package versions, runs import codemods, and refreshes skill directories — it never touches a file that was copied out of a template.
|
|
11
|
+
|
|
12
|
+
`agent-native template` is the missing half. It re-fetches the template at a newer version, re-applies the exact transforms `create` applied, and merges the result into your app file by file.
|
|
13
|
+
|
|
14
|
+
## Quick start {#quick-start}
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
agent-native upgrade
|
|
18
|
+
agent-native template sync
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`sync` defaults to the template version matching your installed `@agent-native/core`, so running it after `upgrade` keeps code and packages on the same version.
|
|
22
|
+
|
|
23
|
+
Look before you merge:
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
agent-native template status
|
|
27
|
+
agent-native template diff
|
|
28
|
+
```
|
|
29
|
+
|
|
30
|
+
## How the merge works {#how-the-merge-works}
|
|
31
|
+
|
|
32
|
+
A useful merge needs three trees, not two:
|
|
33
|
+
|
|
34
|
+
- **base** — the pristine template as it was when your app was generated.
|
|
35
|
+
- **theirs** — the same template at the version you are syncing to, put through the same transform pipeline.
|
|
36
|
+
- **ours** — your app as it stands now.
|
|
37
|
+
|
|
38
|
+
With those, every file falls into a clear case. Upstream did not touch it, so it is left alone. You never touched it, so it fast-forwards. Both of you changed it, so it gets conflict markers. Nothing is overwritten just because it differs.
|
|
39
|
+
|
|
40
|
+
Without a base, "sync" can only mean overwrite, which silently discards your work or reverts upstream's.
|
|
41
|
+
|
|
42
|
+
## The baseline {#the-baseline}
|
|
43
|
+
|
|
44
|
+
The base tree is stored as a git ref in your own repo:
|
|
45
|
+
|
|
46
|
+
```txt
|
|
47
|
+
refs/agent-native/template-baseline/apps/slides
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
It is written with git plumbing against a throwaway index file. Your `HEAD`, your branch, your index, and your working tree are never touched — running `template baseline` mid-edit is safe, and `git status` reads identically before and after.
|
|
51
|
+
|
|
52
|
+
On first write, the fetch and push refspecs for `refs/agent-native/*` are added to your remote so the baseline survives a clone. If the app is not in a git repo, the baseline falls back to a tarball under `.agent-native/`.
|
|
53
|
+
|
|
54
|
+
Apps generated before provenance existed have no baseline. Create one, then sync:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
agent-native template baseline
|
|
58
|
+
agent-native template sync
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## Provenance {#provenance}
|
|
62
|
+
|
|
63
|
+
`create` records what a later merge needs in the app's `package.json`:
|
|
64
|
+
|
|
65
|
+
```json
|
|
66
|
+
{
|
|
67
|
+
"agent-native": {
|
|
68
|
+
"scaffold": {
|
|
69
|
+
"template": "slides",
|
|
70
|
+
"frameworkSkills": "default",
|
|
71
|
+
"templateRef": "@agent-native/core@0.120.3",
|
|
72
|
+
"templateSource": "github",
|
|
73
|
+
"coreVersion": "0.120.3",
|
|
74
|
+
"shape": "workspace"
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
`templateRef` is the immutable tag the template was actually fetched from, which is what makes the base reproducible. `shape` decides whether the workspace transforms are replayed during materialization.
|
|
81
|
+
|
|
82
|
+
## Commands {#commands}
|
|
83
|
+
|
|
84
|
+
### status {#status}
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
agent-native template status [app]
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
Reports the recorded ref, the latest available ref, whether a baseline exists, how many files upstream changed, and how many you have modified locally.
|
|
91
|
+
|
|
92
|
+
### diff {#diff}
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
agent-native template diff [app] [--to <ref>]
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
A read-only unified diff of what changed upstream between your baseline and the target. Writes nothing.
|
|
99
|
+
|
|
100
|
+
### sync {#sync}
|
|
101
|
+
|
|
102
|
+
```bash
|
|
103
|
+
agent-native template sync [app] [--to <ref>] [--dry-run] [--force]
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
Performs the merge. `--to` defaults to the ref matching the installed core. `--dry-run` prints the plan without writing.
|
|
107
|
+
|
|
108
|
+
`sync` refuses to run when the app directory has uncommitted changes, so a bad merge is always recoverable with `git checkout`. `--force` overrides this; prefer committing first.
|
|
109
|
+
|
|
110
|
+
When the merge is clean, the baseline advances automatically. When there are conflicts it deliberately does not — see `accept`.
|
|
111
|
+
|
|
112
|
+
### accept {#accept}
|
|
113
|
+
|
|
114
|
+
```bash
|
|
115
|
+
agent-native template accept [app]
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
Advances the baseline after you resolve conflict markers. It refuses while any `<<<<<<<` remains, so the baseline can never move past an unresolved merge and quietly bake conflict markers into your next base.
|
|
119
|
+
|
|
120
|
+
### baseline {#baseline}
|
|
121
|
+
|
|
122
|
+
```bash
|
|
123
|
+
agent-native template baseline [app] [--ref <ref>] [--template <name>]
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
Records a baseline for an app that predates scaffold provenance. Pass `--ref` when you know which version the app actually came from; the closer it is to the truth, the fewer phantom conflicts the first sync produces.
|
|
127
|
+
|
|
128
|
+
## What is never merged {#what-is-never-merged}
|
|
129
|
+
|
|
130
|
+
Some files are yours by definition, and some cannot be merged meaningfully:
|
|
131
|
+
|
|
132
|
+
- Secrets and local config: `.env`, `.env.local`
|
|
133
|
+
- Lockfiles: `pnpm-lock.yaml`
|
|
134
|
+
- Generated output: `node_modules`, `.output`, `.react-router`, `dist`, `build`
|
|
135
|
+
- App-owned content: `learnings.md`, pending entries under `changelog/`
|
|
136
|
+
|
|
137
|
+
Binary files are never marker-merged. If both sides changed one, your copy is kept and the file is reported for manual handling. Symlinks are reported rather than clobbered.
|
|
138
|
+
|
|
139
|
+
## Contributing changes back {#contributing-changes-back}
|
|
140
|
+
|
|
141
|
+
Syncing is one-directional by design: upstream is the source of truth for template content, and the transforms `create` applies are not perfectly reversible. Recovering `{{APP_NAME}}` from a concrete app name is a guess, and files that `create` rewrote wholesale — `package.json`, `netlify.toml`, `app/root.tsx`, `server/plugins/auth.ts` — have no faithful inverse at all.
|
|
142
|
+
|
|
143
|
+
If you are working inside the framework monorepo and want to push an app-side improvement back into a template, the `contribute:template` script does the reverse pass with those limits made explicit:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
pnpm contribute:template --app <path-to-app> --dry-run
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
It diffs your app against its baseline so only your own changes are candidates, inverts the placeholder substitution on just those files, three-way merges them into `templates/<name>/` as unstaged edits on the current branch, and prints everything it refused to touch so you can port the intent by hand.
|
|
150
|
+
|
|
151
|
+
## Relationship to other commands {#relationship-to-other-commands}
|
|
152
|
+
|
|
153
|
+
| Command | Moves |
|
|
154
|
+
| ---------------------------- | -------------------------------------------------------------- |
|
|
155
|
+
| `agent-native upgrade` | `@agent-native/*` package versions, imports, skill directories |
|
|
156
|
+
| `agent-native template sync` | files copied out of a template at scaffold time |
|
|
157
|
+
| `agent-native eject` | a framework component into app-owned source, with provenance |
|
|
158
|
+
|
|
159
|
+
`upgrade` and `template sync` are complementary and safe to run together. `eject` is the opposite move — it takes ownership of a file deliberately, and ejected files are tracked separately in `agent-native.ejections.json`.
|
package/corpus/core/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@agent-native/core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.122.0",
|
|
4
4
|
"description": "Framework for agent-native application development — where AI agents and UI share SQL state, actions, and context",
|
|
5
5
|
"homepage": "https://github.com/BuilderIO/agent-native#readme",
|
|
6
6
|
"bugs": {
|
|
@@ -139,6 +139,7 @@
|
|
|
139
139
|
"./client/AgentPanel": "./dist/client/AgentPanel.js",
|
|
140
140
|
"./client/application-state": "./dist/client/application-state.js",
|
|
141
141
|
"./client/api-path": "./dist/client/api-path.js",
|
|
142
|
+
"./client/clipboard": "./dist/client/clipboard.js",
|
|
142
143
|
"./client/route-state": "./dist/client/route-state.js",
|
|
143
144
|
"./client/observability": "./dist/client/observability/index.js",
|
|
144
145
|
"./client/onboarding": "./dist/client/onboarding/index.js",
|
|
@@ -37,6 +37,9 @@ export interface A2AAgentActivitySnapshot extends Record<string, unknown> {
|
|
|
37
37
|
activePhase: A2AAgentActivityPhase;
|
|
38
38
|
reasoning: string[];
|
|
39
39
|
toolCalls: A2AAgentActivityToolCall[];
|
|
40
|
+
/** Response text segments, indexed by how many tool calls preceded them. */
|
|
41
|
+
response?: string[];
|
|
42
|
+
/** Tail segment only. Kept so peers predating `response` still render. */
|
|
40
43
|
responseText?: string;
|
|
41
44
|
}
|
|
42
45
|
|
|
@@ -47,7 +50,7 @@ export interface A2AAgentActivityState {
|
|
|
47
50
|
activePhase: A2AAgentActivityPhase;
|
|
48
51
|
reasoning: string[];
|
|
49
52
|
toolCalls: A2AAgentActivityToolCall[];
|
|
50
|
-
|
|
53
|
+
response: string[];
|
|
51
54
|
}
|
|
52
55
|
|
|
53
56
|
export function createA2AAgentActivityState(
|
|
@@ -60,7 +63,7 @@ export function createA2AAgentActivityState(
|
|
|
60
63
|
activePhase: "reasoning",
|
|
61
64
|
reasoning: [],
|
|
62
65
|
toolCalls: [],
|
|
63
|
-
|
|
66
|
+
response: [],
|
|
64
67
|
};
|
|
65
68
|
}
|
|
66
69
|
|
|
@@ -90,7 +93,6 @@ export function applyA2AAgentActivityEvent(
|
|
|
90
93
|
break;
|
|
91
94
|
case "tool_start":
|
|
92
95
|
next.activePhase = "tool";
|
|
93
|
-
next.responseText = "";
|
|
94
96
|
next.toolCalls = appendToolCall(next.toolCalls, toolFromEvent(event));
|
|
95
97
|
changed = true;
|
|
96
98
|
break;
|
|
@@ -101,10 +103,11 @@ export function applyA2AAgentActivityEvent(
|
|
|
101
103
|
break;
|
|
102
104
|
case "text":
|
|
103
105
|
next.activePhase = "responding";
|
|
104
|
-
next.
|
|
105
|
-
next.
|
|
106
|
+
next.response = appendBoundedSegment(
|
|
107
|
+
next.response,
|
|
106
108
|
event.text,
|
|
107
109
|
MAX_A2A_ACTIVITY_RESPONSE_CHARS,
|
|
110
|
+
next.toolCalls.length,
|
|
108
111
|
);
|
|
109
112
|
changed = true;
|
|
110
113
|
break;
|
|
@@ -117,7 +120,7 @@ export function applyA2AAgentActivityEvent(
|
|
|
117
120
|
changed = true;
|
|
118
121
|
break;
|
|
119
122
|
case "clear":
|
|
120
|
-
next.
|
|
123
|
+
next.response = [];
|
|
121
124
|
changed = true;
|
|
122
125
|
break;
|
|
123
126
|
}
|
|
@@ -138,10 +141,15 @@ export function buildA2AAgentActivitySnapshot(
|
|
|
138
141
|
activePhase: state.activePhase,
|
|
139
142
|
reasoning: state.reasoning,
|
|
140
143
|
toolCalls: state.toolCalls,
|
|
141
|
-
...(state.
|
|
144
|
+
...(state.response.length ? { response: state.response } : {}),
|
|
145
|
+
...(tailSegment(state) ? { responseText: tailSegment(state) } : {}),
|
|
142
146
|
};
|
|
143
147
|
}
|
|
144
148
|
|
|
149
|
+
function tailSegment(state: A2AAgentActivityState): string {
|
|
150
|
+
return state.response[state.toolCalls.length] ?? "";
|
|
151
|
+
}
|
|
152
|
+
|
|
145
153
|
export function buildA2AAgentActivityPart(
|
|
146
154
|
state: A2AAgentActivityState,
|
|
147
155
|
): DataPart {
|
|
@@ -165,8 +173,10 @@ export function parseA2AAgentActivityPart(
|
|
|
165
173
|
!isPhase(data.activePhase) ||
|
|
166
174
|
data.updatedAt < data.startedAt ||
|
|
167
175
|
data.durationMs !== data.updatedAt - data.startedAt ||
|
|
168
|
-
!
|
|
176
|
+
!isSafeSegments(data.reasoning, MAX_A2A_ACTIVITY_REASONING_CHARS) ||
|
|
169
177
|
!isSafeToolCalls(data.toolCalls) ||
|
|
178
|
+
(data.response !== undefined &&
|
|
179
|
+
!isSafeSegments(data.response, MAX_A2A_ACTIVITY_RESPONSE_CHARS)) ||
|
|
170
180
|
(data.responseText !== undefined &&
|
|
171
181
|
!isSafeText(data.responseText, MAX_A2A_ACTIVITY_RESPONSE_CHARS)) ||
|
|
172
182
|
activityCharacterCount(data) > MAX_A2A_ACTIVITY_TOTAL_CHARS
|
|
@@ -193,14 +203,6 @@ function toolFromEvent(
|
|
|
193
203
|
};
|
|
194
204
|
}
|
|
195
205
|
|
|
196
|
-
function appendBoundedText(
|
|
197
|
-
current: string,
|
|
198
|
-
addition: string,
|
|
199
|
-
maxChars: number,
|
|
200
|
-
) {
|
|
201
|
-
return sanitizeText(`${current}${addition}`, maxChars);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
206
|
function appendBoundedSegment(
|
|
205
207
|
current: string[],
|
|
206
208
|
addition: string,
|
|
@@ -293,7 +295,7 @@ function isPhase(value: unknown): value is A2AAgentActivityPhase {
|
|
|
293
295
|
);
|
|
294
296
|
}
|
|
295
297
|
|
|
296
|
-
function
|
|
298
|
+
function isSafeSegments(value: unknown, maxChars: number): value is string[] {
|
|
297
299
|
return (
|
|
298
300
|
Array.isArray(value) &&
|
|
299
301
|
value.length <= MAX_A2A_ACTIVITY_REASONING_SEGMENTS &&
|
|
@@ -301,8 +303,8 @@ function isSafeReasoning(value: unknown): value is string[] {
|
|
|
301
303
|
(total, text) =>
|
|
302
304
|
total + (typeof text === "string" ? text.length : Infinity),
|
|
303
305
|
0,
|
|
304
|
-
) <=
|
|
305
|
-
value.every((text) => isSafeText(text,
|
|
306
|
+
) <= maxChars &&
|
|
307
|
+
value.every((text) => isSafeText(text, maxChars))
|
|
306
308
|
);
|
|
307
309
|
}
|
|
308
310
|
|
|
@@ -349,14 +351,14 @@ function isSafeToolId(value: unknown): value is string {
|
|
|
349
351
|
}
|
|
350
352
|
|
|
351
353
|
function activityCharacterCount(data: Record<string, unknown>): number {
|
|
352
|
-
const reasoning =
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
:
|
|
358
|
-
|
|
359
|
-
|
|
354
|
+
const reasoning = segmentCharacterCount(data.reasoning);
|
|
355
|
+
// `responseText` duplicates the tail of `response`; counting both would
|
|
356
|
+
// reject a snapshot that is within budget.
|
|
357
|
+
const response = Array.isArray(data.response)
|
|
358
|
+
? segmentCharacterCount(data.response)
|
|
359
|
+
: typeof data.responseText === "string"
|
|
360
|
+
? data.responseText.length
|
|
361
|
+
: 0;
|
|
360
362
|
const tools = Array.isArray(data.toolCalls)
|
|
361
363
|
? data.toolCalls.reduce((total, tool) => {
|
|
362
364
|
if (!isRecord(tool)) return total;
|
|
@@ -369,3 +371,12 @@ function activityCharacterCount(data: Record<string, unknown>): number {
|
|
|
369
371
|
: 0;
|
|
370
372
|
return reasoning + response + tools;
|
|
371
373
|
}
|
|
374
|
+
|
|
375
|
+
function segmentCharacterCount(value: unknown): number {
|
|
376
|
+
return Array.isArray(value)
|
|
377
|
+
? value.reduce(
|
|
378
|
+
(total, text) => total + (typeof text === "string" ? text.length : 0),
|
|
379
|
+
0,
|
|
380
|
+
)
|
|
381
|
+
: 0;
|
|
382
|
+
}
|
|
@@ -71,6 +71,8 @@ const MAX_BACKGROUND_BUILDER_GATEWAY_TIMEOUT_MS = 14 * 60_000;
|
|
|
71
71
|
const MAX_LOCAL_BUILDER_GATEWAY_TIMEOUT_MS =
|
|
72
72
|
MAX_BACKGROUND_BUILDER_GATEWAY_TIMEOUT_MS;
|
|
73
73
|
const BUILDER_GATEWAY_NETWORK_ERROR_CODE = "builder_gateway_network_error";
|
|
74
|
+
export const BUILDER_MODEL_UNAUTHORIZED_ERROR_CODE =
|
|
75
|
+
"builder_model_unauthorized";
|
|
74
76
|
|
|
75
77
|
export const BUILDER_DEFAULT_MODEL = BUILDER_MODEL_CONFIG.defaultModel;
|
|
76
78
|
|
|
@@ -669,8 +671,16 @@ async function* parseJsonlStream(
|
|
|
669
671
|
explicitErrMsg ??
|
|
670
672
|
`Gateway error (no detail; raw event: ${JSON.stringify(event)})`;
|
|
671
673
|
const gatewayErrCode = event.errorCode ?? event.code;
|
|
674
|
+
// The gateway already authenticated this request before streaming,
|
|
675
|
+
// so a bare "Unauthorized" here means the account cannot use this
|
|
676
|
+
// model — not that the connection is broken. Only a message that
|
|
677
|
+
// names the credential may tear down the Builder connection.
|
|
672
678
|
const isCredentialAuthError =
|
|
673
679
|
Boolean(explicitErrMsg) &&
|
|
680
|
+
isBuilderCredentialAuthErrorInStream(String(errMsg));
|
|
681
|
+
const isModelAuthError =
|
|
682
|
+
Boolean(explicitErrMsg) &&
|
|
683
|
+
!isCredentialAuthError &&
|
|
674
684
|
isBuilderCredentialAuthError(String(errMsg));
|
|
675
685
|
// Anthropic's bare "Connection error." often arrives here with no
|
|
676
686
|
// gateway code. Tag it as a network error so in-run retries and
|
|
@@ -680,10 +690,12 @@ async function* parseJsonlStream(
|
|
|
680
690
|
isProviderConnectionErrorMessage(String(explicitErrMsg));
|
|
681
691
|
const errCode = isCredentialAuthError
|
|
682
692
|
? "builder_auth_error"
|
|
683
|
-
:
|
|
684
|
-
?
|
|
685
|
-
:
|
|
686
|
-
|
|
693
|
+
: isModelAuthError
|
|
694
|
+
? BUILDER_MODEL_UNAUTHORIZED_ERROR_CODE
|
|
695
|
+
: isProviderConnectionError
|
|
696
|
+
? BUILDER_GATEWAY_NETWORK_ERROR_CODE
|
|
697
|
+
: (gatewayErrCode ??
|
|
698
|
+
(!explicitErrMsg ? "builder_gateway_error" : undefined));
|
|
687
699
|
console.error(
|
|
688
700
|
`[builder-engine] stop reason=error model=${model} code=${errCode ?? "(none)"} error=${errMsg}`,
|
|
689
701
|
);
|
|
@@ -988,6 +1000,25 @@ function isBuilderCredentialAuthError(message: string): boolean {
|
|
|
988
1000
|
);
|
|
989
1001
|
}
|
|
990
1002
|
|
|
1003
|
+
/**
|
|
1004
|
+
* Stricter than {@link isBuilderCredentialAuthError} for errors that arrive
|
|
1005
|
+
* inside an already-authenticated stream, where a bare "unauthorized" is far
|
|
1006
|
+
* more likely to be a per-model entitlement rejection than a bad credential.
|
|
1007
|
+
* Misreading one there disconnects Builder for every model, including the ones
|
|
1008
|
+
* that still work.
|
|
1009
|
+
*/
|
|
1010
|
+
function isBuilderCredentialAuthErrorInStream(message: string): boolean {
|
|
1011
|
+
if (!isBuilderCredentialAuthError(message)) return false;
|
|
1012
|
+
const lowerMessage = message.toLowerCase();
|
|
1013
|
+
return (
|
|
1014
|
+
lowerMessage.includes("private key") ||
|
|
1015
|
+
lowerMessage.includes("access token") ||
|
|
1016
|
+
lowerMessage.includes("invalid token") ||
|
|
1017
|
+
lowerMessage.includes("invalid_token") ||
|
|
1018
|
+
lowerMessage.includes("token invalid")
|
|
1019
|
+
);
|
|
1020
|
+
}
|
|
1021
|
+
|
|
991
1022
|
function normalizeBuilderGatewayFetchError(
|
|
992
1023
|
err: unknown,
|
|
993
1024
|
timedOut: boolean,
|
|
@@ -29,6 +29,7 @@ import {
|
|
|
29
29
|
setRunError,
|
|
30
30
|
setRunTerminalReason,
|
|
31
31
|
} from "./run-store.js";
|
|
32
|
+
import { isContinuationTerminalReason } from "./types.js";
|
|
32
33
|
import type { AgentChatEvent, RunEvent, RunStatus } from "./types.js";
|
|
33
34
|
|
|
34
35
|
export interface ActiveRun {
|
|
@@ -1429,10 +1430,28 @@ function subscribeFromSQL(
|
|
|
1429
1430
|
return;
|
|
1430
1431
|
}
|
|
1431
1432
|
} else if (run?.status === "completed") {
|
|
1433
|
+
// A chunk boundary is also status "completed" (with a
|
|
1434
|
+
// continuation terminal_reason, and a chained successor run
|
|
1435
|
+
// already carrying the turn). Synthesizing `done` here told the
|
|
1436
|
+
// client the agent stopped while it was still working, which
|
|
1437
|
+
// surfaced as a premature "stopped without sending a final
|
|
1438
|
+
// message". Prefer the run's REAL terminal event, then the
|
|
1439
|
+
// terminal_reason, before falling back to `done`.
|
|
1440
|
+
const existing = await getLastTerminalRunEvent(runId).catch(
|
|
1441
|
+
() => null,
|
|
1442
|
+
);
|
|
1443
|
+
const terminalEvent = existing
|
|
1444
|
+
? existing.event
|
|
1445
|
+
: isContinuationTerminalReason(run.terminalReason)
|
|
1446
|
+
? { type: "auto_continue", reason: run.terminalReason }
|
|
1447
|
+
: { type: "done" };
|
|
1432
1448
|
try {
|
|
1433
1449
|
controller.enqueue(
|
|
1434
1450
|
encoder.encode(
|
|
1435
|
-
`data: ${JSON.stringify({
|
|
1451
|
+
`data: ${JSON.stringify({
|
|
1452
|
+
...terminalEvent,
|
|
1453
|
+
seq: existing?.seq ?? lastSeq,
|
|
1454
|
+
})}\n\n`,
|
|
1436
1455
|
),
|
|
1437
1456
|
);
|
|
1438
1457
|
} catch {
|
|
@@ -1929,11 +1929,12 @@ export async function getRunById(runId: string): Promise<{
|
|
|
1929
1929
|
startedAt: number;
|
|
1930
1930
|
errorCode: string | null;
|
|
1931
1931
|
errorDetail: string | null;
|
|
1932
|
+
terminalReason: string | null;
|
|
1932
1933
|
} | null> {
|
|
1933
1934
|
await ensureRunTables();
|
|
1934
1935
|
const client = getDbExec();
|
|
1935
1936
|
const { rows } = await client.execute({
|
|
1936
|
-
sql: `SELECT id, thread_id, status, started_at, error_code, error_detail FROM agent_runs WHERE id = ?`,
|
|
1937
|
+
sql: `SELECT id, thread_id, status, started_at, error_code, error_detail, terminal_reason FROM agent_runs WHERE id = ?`,
|
|
1937
1938
|
args: [runId],
|
|
1938
1939
|
});
|
|
1939
1940
|
if (rows.length === 0) return null;
|
|
@@ -1944,6 +1945,7 @@ export async function getRunById(runId: string): Promise<{
|
|
|
1944
1945
|
started_at: number | string;
|
|
1945
1946
|
error_code?: string | null;
|
|
1946
1947
|
error_detail?: string | null;
|
|
1948
|
+
terminal_reason?: string | null;
|
|
1947
1949
|
};
|
|
1948
1950
|
return {
|
|
1949
1951
|
id: r.id,
|
|
@@ -1952,6 +1954,7 @@ export async function getRunById(runId: string): Promise<{
|
|
|
1952
1954
|
startedAt: Number(r.started_at),
|
|
1953
1955
|
errorCode: r.error_code ?? null,
|
|
1954
1956
|
errorDetail: r.error_detail ?? null,
|
|
1957
|
+
terminalReason: r.terminal_reason ?? null,
|
|
1955
1958
|
};
|
|
1956
1959
|
}
|
|
1957
1960
|
|
|
@@ -369,18 +369,38 @@ export type AgentChatEvent =
|
|
|
369
369
|
}
|
|
370
370
|
| {
|
|
371
371
|
type: "auto_continue";
|
|
372
|
-
reason:
|
|
373
|
-
| "run_timeout"
|
|
374
|
-
| "loop_limit"
|
|
375
|
-
| "max_tokens"
|
|
376
|
-
| "no_progress"
|
|
377
|
-
| "stream_ended"
|
|
378
|
-
| "gateway_timeout"
|
|
379
|
-
| "network_interrupted";
|
|
372
|
+
reason: ContinuationReason;
|
|
380
373
|
maxIterations?: number;
|
|
381
374
|
}
|
|
382
375
|
| { type: "clear" };
|
|
383
376
|
|
|
377
|
+
export const CONTINUATION_REASONS = [
|
|
378
|
+
"run_timeout",
|
|
379
|
+
"loop_limit",
|
|
380
|
+
"max_tokens",
|
|
381
|
+
"no_progress",
|
|
382
|
+
"stream_ended",
|
|
383
|
+
"gateway_timeout",
|
|
384
|
+
"network_interrupted",
|
|
385
|
+
] as const;
|
|
386
|
+
|
|
387
|
+
export type ContinuationReason = (typeof CONTINUATION_REASONS)[number];
|
|
388
|
+
|
|
389
|
+
/**
|
|
390
|
+
* True when an `agent_runs.terminal_reason` marks a CHUNK boundary rather than
|
|
391
|
+
* the end of the turn. Both writers (`terminalReasonForRun` in run-manager and
|
|
392
|
+
* `markBackgroundContinuationChunkTerminal` in production-agent) record
|
|
393
|
+
* status='completed' with one of these while a chained successor run carries the
|
|
394
|
+
* turn on, so such a row must never be reported to a client as a plain `done`.
|
|
395
|
+
* Mirrored client-side by `BACKGROUND_CONTINUATION_TERMINAL_REASONS`.
|
|
396
|
+
*/
|
|
397
|
+
export function isContinuationTerminalReason(reason: unknown): boolean {
|
|
398
|
+
return (
|
|
399
|
+
reason === "auto_continue" ||
|
|
400
|
+
CONTINUATION_REASONS.includes(reason as ContinuationReason)
|
|
401
|
+
);
|
|
402
|
+
}
|
|
403
|
+
|
|
384
404
|
export interface RunEvent {
|
|
385
405
|
seq: number;
|
|
386
406
|
event: AgentChatEvent;
|
|
@@ -1290,6 +1290,51 @@ export async function getThreadByShareToken(
|
|
|
1290
1290
|
return null;
|
|
1291
1291
|
}
|
|
1292
1292
|
|
|
1293
|
+
/**
|
|
1294
|
+
* Grant a user an explicit share on a thread they don't own. Used by the
|
|
1295
|
+
* messaging-integration path, where a channel conversation runs as the
|
|
1296
|
+
* integration service principal and so creates a thread owned by
|
|
1297
|
+
* `integration@<platform>` rather than the human who asked — without this the
|
|
1298
|
+
* "Open thread" deep link resolves to a 404 for them.
|
|
1299
|
+
*
|
|
1300
|
+
* Idempotent, and never downgrades an existing stronger role.
|
|
1301
|
+
*/
|
|
1302
|
+
export async function grantThreadUserShare(
|
|
1303
|
+
threadId: string,
|
|
1304
|
+
userEmail: string,
|
|
1305
|
+
role: ShareRole,
|
|
1306
|
+
grantedBy: string,
|
|
1307
|
+
): Promise<void> {
|
|
1308
|
+
const normalizedEmail = userEmail.trim().toLowerCase();
|
|
1309
|
+
if (!threadId || !normalizedEmail.includes("@")) return;
|
|
1310
|
+
await ensureTable();
|
|
1311
|
+
const client = getDbExec();
|
|
1312
|
+
const { rows } = await client.execute({
|
|
1313
|
+
sql: `SELECT id, role FROM chat_thread_shares WHERE resource_id = ? AND principal_type = 'user' AND LOWER(principal_id) = ?`,
|
|
1314
|
+
args: [threadId, normalizedEmail],
|
|
1315
|
+
});
|
|
1316
|
+
const existing = rows[0];
|
|
1317
|
+
if (existing) {
|
|
1318
|
+
if (roleSatisfies(existing.role as ShareRole, role)) return;
|
|
1319
|
+
await client.execute({
|
|
1320
|
+
sql: `UPDATE chat_thread_shares SET role = ? WHERE id = ?`,
|
|
1321
|
+
args: [role, existing.id as string],
|
|
1322
|
+
});
|
|
1323
|
+
return;
|
|
1324
|
+
}
|
|
1325
|
+
await client.execute({
|
|
1326
|
+
sql: `INSERT INTO chat_thread_shares (id, resource_id, principal_type, principal_id, role, created_by, created_at) VALUES (?, ?, 'user', ?, ?, ?, ?)`,
|
|
1327
|
+
args: [
|
|
1328
|
+
crypto.randomUUID(),
|
|
1329
|
+
threadId,
|
|
1330
|
+
normalizedEmail,
|
|
1331
|
+
role,
|
|
1332
|
+
grantedBy,
|
|
1333
|
+
new Date().toISOString(),
|
|
1334
|
+
],
|
|
1335
|
+
});
|
|
1336
|
+
}
|
|
1337
|
+
|
|
1293
1338
|
export async function deleteThread(id: string): Promise<boolean> {
|
|
1294
1339
|
await ensureTable();
|
|
1295
1340
|
const client = getDbExec();
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The framework mount shim normally rewrites `event.path` to the mount-relative
|
|
3
|
+
* remainder ("/restore"), but it falls back to the unstripped request path when
|
|
4
|
+
* `event.url` is read-only on the host runtime. Accept both so a restore POST
|
|
5
|
+
* never silently 405s.
|
|
6
|
+
*/
|
|
7
|
+
export function isCheckpointRestorePath(path: string | undefined): boolean {
|
|
8
|
+
if (!path) return false;
|
|
9
|
+
return (
|
|
10
|
+
/(^|\/)checkpoints\/restore(?:[/?]|$)/.test(path) ||
|
|
11
|
+
/^\/?restore(?:[/?]|$)/.test(path)
|
|
12
|
+
);
|
|
13
|
+
}
|