@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
package/src/a2a/activity.ts
CHANGED
|
@@ -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,
|
package/src/agent/run-manager.ts
CHANGED
|
@@ -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 {
|
package/src/agent/run-store.ts
CHANGED
|
@@ -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
|
|
package/src/agent/types.ts
CHANGED
|
@@ -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();
|
package/src/checkpoints/index.ts
CHANGED
|
@@ -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
|
+
}
|
package/src/cli/create.ts
CHANGED
|
@@ -637,7 +637,7 @@ async function scaffoldOneAppIntoWorkspace(
|
|
|
637
637
|
);
|
|
638
638
|
|
|
639
639
|
try {
|
|
640
|
-
await scaffoldAppTemplate(appDir, templateName);
|
|
640
|
+
const resolution = await scaffoldAppTemplate(appDir, templateName);
|
|
641
641
|
replacePlaceholders(
|
|
642
642
|
appDir,
|
|
643
643
|
appName,
|
|
@@ -655,7 +655,10 @@ async function scaffoldOneAppIntoWorkspace(
|
|
|
655
655
|
dispatchDependencyVersion: getDispatchDependencyVersion(),
|
|
656
656
|
toolkitDependencyVersion: getToolkitDependencyVersion(),
|
|
657
657
|
});
|
|
658
|
-
fixPackageJsonName(appDir, appName, templateName
|
|
658
|
+
fixPackageJsonName(appDir, appName, templateName, {
|
|
659
|
+
...resolution,
|
|
660
|
+
shape: "workspace",
|
|
661
|
+
});
|
|
659
662
|
fixWebManifestName(appDir, appName, templateName);
|
|
660
663
|
rewriteNetlifyToml(appDir, appName, "workspace");
|
|
661
664
|
renameGitignore(appDir);
|
|
@@ -736,9 +739,9 @@ async function createStandaloneApp(
|
|
|
736
739
|
: `Downloading the ${template} template from GitHub...`,
|
|
737
740
|
);
|
|
738
741
|
try {
|
|
739
|
-
await scaffoldAppTemplate(targetDir, template);
|
|
742
|
+
const resolution = await scaffoldAppTemplate(targetDir, template);
|
|
740
743
|
s.message(`Setting up ${name}…`);
|
|
741
|
-
postProcessStandalone(name, targetDir, template);
|
|
744
|
+
postProcessStandalone(name, targetDir, template, resolution);
|
|
742
745
|
s.stop("App created!");
|
|
743
746
|
} catch (err: any) {
|
|
744
747
|
s.stop("Failed to create app.");
|
|
@@ -789,6 +792,17 @@ function cleanupOnFailure(targetDir: string): void {
|
|
|
789
792
|
* Shared scaffolding helpers
|
|
790
793
|
* ───────────────────────────────────────────────────────────────────────── */
|
|
791
794
|
|
|
795
|
+
/** Where a scaffolded template's bytes came from, recorded so
|
|
796
|
+
* `agent-native template sync` can reproduce them later. */
|
|
797
|
+
export interface ScaffoldTemplateResolution {
|
|
798
|
+
templateRef?: string;
|
|
799
|
+
templateSource?: "github" | "bundled" | "local-checkout";
|
|
800
|
+
}
|
|
801
|
+
|
|
802
|
+
export interface ScaffoldProvenance extends ScaffoldTemplateResolution {
|
|
803
|
+
shape?: "workspace" | "standalone";
|
|
804
|
+
}
|
|
805
|
+
|
|
792
806
|
/**
|
|
793
807
|
* Scaffold a single app template into `targetDir`. Resolves:
|
|
794
808
|
* - "headless" / legacy "blank" → bundled action-first template
|
|
@@ -799,7 +813,7 @@ function cleanupOnFailure(targetDir: string): void {
|
|
|
799
813
|
async function scaffoldAppTemplate(
|
|
800
814
|
targetDir: string,
|
|
801
815
|
template: string,
|
|
802
|
-
): Promise<
|
|
816
|
+
): Promise<ScaffoldTemplateResolution> {
|
|
803
817
|
fs.mkdirSync(path.dirname(targetDir), { recursive: true });
|
|
804
818
|
|
|
805
819
|
// Normalize legacy / renamed aliases.
|
|
@@ -814,13 +828,16 @@ async function scaffoldAppTemplate(
|
|
|
814
828
|
);
|
|
815
829
|
}
|
|
816
830
|
copyDir(headlessDir, targetDir);
|
|
817
|
-
return
|
|
831
|
+
return {
|
|
832
|
+
templateSource: "bundled",
|
|
833
|
+
templateRef: getGitHubTemplateRefCandidates()[0],
|
|
834
|
+
};
|
|
818
835
|
}
|
|
819
836
|
|
|
820
837
|
if (resolved.startsWith("github:")) {
|
|
821
838
|
const repo = resolved.slice("github:".length);
|
|
822
839
|
await downloadGitHubRepo(repo, targetDir);
|
|
823
|
-
return;
|
|
840
|
+
return {};
|
|
824
841
|
}
|
|
825
842
|
|
|
826
843
|
if (!getTemplate(resolved)) {
|
|
@@ -836,13 +853,29 @@ async function scaffoldAppTemplate(
|
|
|
836
853
|
const localTemplate = findLocalTemplate(sourceTemplate);
|
|
837
854
|
if (localTemplate) {
|
|
838
855
|
copyDir(localTemplate, targetDir);
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
targetDir,
|
|
844
|
-
);
|
|
856
|
+
return {
|
|
857
|
+
templateSource: localTemplateSourceKind(localTemplate),
|
|
858
|
+
templateRef: getGitHubTemplateRefCandidates()[0],
|
|
859
|
+
};
|
|
845
860
|
}
|
|
861
|
+
const templateRef = await downloadGitHubSubdir(
|
|
862
|
+
REPO,
|
|
863
|
+
`${TEMPLATES_DIR}/${sourceTemplate}`,
|
|
864
|
+
targetDir,
|
|
865
|
+
);
|
|
866
|
+
return { templateSource: "github", templateRef };
|
|
867
|
+
}
|
|
868
|
+
|
|
869
|
+
/** A template dir inside the installed core package ships with the CLI;
|
|
870
|
+
* anything above it belongs to a framework checkout. */
|
|
871
|
+
function localTemplateSourceKind(
|
|
872
|
+
localTemplate: string,
|
|
873
|
+
): "bundled" | "local-checkout" {
|
|
874
|
+
const packageRoot = path.resolve(__dirname, "../..");
|
|
875
|
+
const rel = path.relative(packageRoot, path.resolve(localTemplate));
|
|
876
|
+
return rel && !rel.startsWith("..") && !path.isAbsolute(rel)
|
|
877
|
+
? "bundled"
|
|
878
|
+
: "local-checkout";
|
|
846
879
|
}
|
|
847
880
|
|
|
848
881
|
function templateSourceName(name: string): string {
|
|
@@ -1000,6 +1033,17 @@ async function scaffoldRequiredPackages(
|
|
|
1000
1033
|
}
|
|
1001
1034
|
}
|
|
1002
1035
|
}
|
|
1036
|
+
// These packages' `exports` maps point at `./dist/*`, and `dist/` is
|
|
1037
|
+
// gitignored (never committed), so a scaffolded workspace must build
|
|
1038
|
+
// it on install. pnpm always runs `prepare` for workspace packages,
|
|
1039
|
+
// unlike `postinstall`, so this is the reliable hook.
|
|
1040
|
+
if (
|
|
1041
|
+
pkg.scripts &&
|
|
1042
|
+
typeof pkg.scripts.build === "string" &&
|
|
1043
|
+
!pkg.scripts.prepare
|
|
1044
|
+
) {
|
|
1045
|
+
pkg.scripts.prepare = "npm run build";
|
|
1046
|
+
}
|
|
1003
1047
|
fs.writeFileSync(pkgJsonPath, JSON.stringify(pkg, null, 2) + "\n");
|
|
1004
1048
|
} catch {}
|
|
1005
1049
|
}
|
|
@@ -1039,12 +1083,16 @@ function postProcessStandalone(
|
|
|
1039
1083
|
name: string,
|
|
1040
1084
|
targetDir: string,
|
|
1041
1085
|
templateName?: string,
|
|
1086
|
+
resolution?: ScaffoldTemplateResolution,
|
|
1042
1087
|
): void {
|
|
1043
1088
|
const appTitle = appTitleForScaffold(name);
|
|
1044
1089
|
replacePlaceholders(targetDir, name, appTitle);
|
|
1045
1090
|
rewriteTrackingAppId(targetDir, name, templateName);
|
|
1046
1091
|
rewriteAgentChatAppId(targetDir, name, templateName);
|
|
1047
|
-
fixPackageJsonName(targetDir, name, templateName
|
|
1092
|
+
fixPackageJsonName(targetDir, name, templateName, {
|
|
1093
|
+
...resolution,
|
|
1094
|
+
shape: "standalone",
|
|
1095
|
+
});
|
|
1048
1096
|
fixWebManifestName(targetDir, name, templateName);
|
|
1049
1097
|
rewriteNetlifyToml(targetDir, name, "standalone");
|
|
1050
1098
|
|
|
@@ -1393,6 +1441,19 @@ export {
|
|
|
1393
1441
|
startShapePromptOptions as _startShapePromptOptions,
|
|
1394
1442
|
shouldSkipScaffoldEntry as _shouldSkipScaffoldEntry,
|
|
1395
1443
|
tarExtractArgs as _tarExtractArgs,
|
|
1444
|
+
downloadGitHubSubdir as _downloadGitHubSubdir,
|
|
1445
|
+
findLocalTemplate as _findLocalTemplate,
|
|
1446
|
+
templateSourceName as _templateSourceName,
|
|
1447
|
+
normalizeTemplateName as _normalizeTemplateName,
|
|
1448
|
+
appTitleForScaffold as _appTitleForScaffold,
|
|
1449
|
+
replacePlaceholders as _replacePlaceholders,
|
|
1450
|
+
rewriteTrackingAppId as _rewriteTrackingAppId,
|
|
1451
|
+
rewriteAgentChatAppId as _rewriteAgentChatAppId,
|
|
1452
|
+
fixWebManifestName as _fixWebManifestName,
|
|
1453
|
+
copyDir as _copyDir,
|
|
1454
|
+
localTemplateSourceKind as _localTemplateSourceKind,
|
|
1455
|
+
REPO as _REPO,
|
|
1456
|
+
TEMPLATES_DIR as _TEMPLATES_DIR,
|
|
1396
1457
|
};
|
|
1397
1458
|
|
|
1398
1459
|
/* ─────────────────────────────────────────────────────────────────────────
|
|
@@ -1479,13 +1540,17 @@ async function downloadAndExtract(
|
|
|
1479
1540
|
}
|
|
1480
1541
|
}
|
|
1481
1542
|
|
|
1543
|
+
/** Resolves to the ref that actually succeeded so callers can record it. */
|
|
1482
1544
|
async function downloadGitHubSubdir(
|
|
1483
1545
|
repo: string,
|
|
1484
1546
|
subdir: string,
|
|
1485
1547
|
targetDir: string,
|
|
1486
|
-
|
|
1548
|
+
refOverride?: string[],
|
|
1549
|
+
): Promise<string> {
|
|
1487
1550
|
validateRepoName(repo);
|
|
1488
|
-
const refs =
|
|
1551
|
+
const refs = refOverride?.length
|
|
1552
|
+
? refOverride
|
|
1553
|
+
: getGitHubTemplateRefCandidates();
|
|
1489
1554
|
if (refs.length === 0) {
|
|
1490
1555
|
throw new Error(
|
|
1491
1556
|
"Cannot download first-party scaffold files without a versioned @agent-native/core package.",
|
|
@@ -1510,7 +1575,7 @@ async function downloadGitHubSubdir(
|
|
|
1510
1575
|
);
|
|
1511
1576
|
}
|
|
1512
1577
|
copyDir(srcDir, targetDir);
|
|
1513
|
-
return;
|
|
1578
|
+
return ref;
|
|
1514
1579
|
} catch (err) {
|
|
1515
1580
|
errors.push(
|
|
1516
1581
|
` ${ref}: ${err instanceof Error ? err.message.split("\n")[0] : String(err)}`,
|
|
@@ -1678,6 +1743,7 @@ function fixPackageJsonName(
|
|
|
1678
1743
|
appDir: string,
|
|
1679
1744
|
name: string,
|
|
1680
1745
|
templateName?: string,
|
|
1746
|
+
provenance?: ScaffoldProvenance,
|
|
1681
1747
|
): void {
|
|
1682
1748
|
const pkgPath = path.join(appDir, "package.json");
|
|
1683
1749
|
if (!fs.existsSync(pkgPath)) return;
|
|
@@ -1706,9 +1772,18 @@ function fixPackageJsonName(
|
|
|
1706
1772
|
!Array.isArray(pkg["agent-native"])
|
|
1707
1773
|
? pkg["agent-native"]
|
|
1708
1774
|
: {};
|
|
1775
|
+
const coreVersion = getCorePackageVersion();
|
|
1709
1776
|
agentNative.scaffold = {
|
|
1710
1777
|
template: trackingTemplateName(templateName),
|
|
1711
1778
|
frameworkSkills: scaffoldGuidance,
|
|
1779
|
+
...(provenance?.templateRef
|
|
1780
|
+
? { templateRef: provenance.templateRef }
|
|
1781
|
+
: {}),
|
|
1782
|
+
...(provenance?.templateSource
|
|
1783
|
+
? { templateSource: provenance.templateSource }
|
|
1784
|
+
: {}),
|
|
1785
|
+
...(coreVersion ? { coreVersion } : {}),
|
|
1786
|
+
...(provenance?.shape ? { shape: provenance.shape } : {}),
|
|
1712
1787
|
};
|
|
1713
1788
|
pkg["agent-native"] = agentNative;
|
|
1714
1789
|
}
|
|
@@ -2286,6 +2361,19 @@ function shouldSkipScaffoldEntry(name: string, srcPath?: string): boolean {
|
|
|
2286
2361
|
) {
|
|
2287
2362
|
return true;
|
|
2288
2363
|
}
|
|
2364
|
+
// `.generated/bridge` is committed source, not a build artifact: the design
|
|
2365
|
+
// app imports it at module load, so skipping it yields a workspace that 500s
|
|
2366
|
+
// on every page. Everything else under `.generated` is regenerated at dev time.
|
|
2367
|
+
if (pathParts?.at(-2) === ".generated") {
|
|
2368
|
+
return name !== "bridge";
|
|
2369
|
+
}
|
|
2370
|
+
if (
|
|
2371
|
+
name === ".generated" &&
|
|
2372
|
+
srcPath &&
|
|
2373
|
+
fs.existsSync(path.join(srcPath, "bridge"))
|
|
2374
|
+
) {
|
|
2375
|
+
return false;
|
|
2376
|
+
}
|
|
2289
2377
|
if (
|
|
2290
2378
|
name === "node_modules" ||
|
|
2291
2379
|
name === ".agent-native" ||
|