@agent-native/core 0.129.1 → 0.130.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 +78 -0
- package/corpus/core/docs/content/cloneable-saas.mdx +114 -0
- package/corpus/core/docs/content/creating-templates.mdx +28 -2
- package/corpus/core/docs/content/syncing-template-changes.mdx +7 -0
- package/corpus/core/docs/content/template-clips-developers.mdx +12 -5
- package/corpus/core/docs/content/template-dispatch-developers.mdx +1 -1
- package/corpus/core/docs/content/template-dispatch.mdx +1 -1
- package/corpus/core/package.json +1 -1
- package/corpus/core/src/action-ui.ts +1 -0
- package/corpus/core/src/action.ts +5 -1
- package/corpus/core/src/agent/engine/ai-sdk-engine.ts +15 -5
- package/corpus/core/src/agent/harness/runner.ts +5 -0
- package/corpus/core/src/agent/production-agent.ts +33 -0
- package/corpus/core/src/agent/run-loop-with-resume.ts +5 -0
- package/corpus/core/src/agent/run-manager.ts +126 -1
- package/corpus/core/src/agent/thread-data-builder.ts +47 -2
- package/corpus/core/src/agent/types.ts +2 -0
- package/corpus/core/src/chat-threads/store.ts +4 -5
- package/corpus/core/src/cli/create.ts +1139 -65
- package/corpus/core/src/cli/design-connect.ts +3 -7
- package/corpus/core/src/cli/index.ts +5 -3
- package/corpus/core/src/cli/skills-content/design-visual-edit-skill.ts +83 -47
- package/corpus/core/src/client/AssistantChat.tsx +27 -16
- package/corpus/core/src/client/agent-chat-adapter.ts +24 -0
- package/corpus/core/src/client/blocks/library/wireframe-kit.tsx +17 -2
- package/corpus/core/src/client/chat/index.ts +1 -0
- package/corpus/core/src/client/chat/message-components.tsx +104 -1
- package/corpus/core/src/client/chat/run-recovery.tsx +15 -3
- package/corpus/core/src/client/chat/widgets/DataTableWidget.tsx +10 -29
- package/corpus/core/src/client/chat/widgets/WorkspaceFileWidget.tsx +71 -0
- package/corpus/core/src/client/chat/widgets/builtin-tool-renderers.tsx +22 -0
- package/corpus/core/src/client/chat/widgets/workspace-file-result.ts +49 -0
- package/corpus/core/src/client/embed-auth.ts +2 -0
- package/corpus/core/src/client/org/InvitationBanner.tsx +14 -1
- package/corpus/core/src/client/org/OrgSwitcher.tsx +23 -0
- package/corpus/core/src/client/org/TeamPage.tsx +130 -0
- package/corpus/core/src/client/org/WorkspaceNotice.tsx +85 -0
- package/corpus/core/src/client/org/hooks.ts +14 -0
- package/corpus/core/src/client/org/index.ts +2 -0
- package/corpus/core/src/client/resources/McpIntegrationDialog.tsx +27 -40
- package/corpus/core/src/client/resources/ResourcesPanel.tsx +134 -51
- package/corpus/core/src/client/resources/mcp-integration-catalog.ts +7 -0
- package/corpus/core/src/client/resources/use-resources.ts +6 -0
- package/corpus/core/src/client/use-action.ts +3 -1
- package/corpus/core/src/client/widgets/index.ts +1 -0
- package/corpus/core/src/coding-tools/run-code.ts +2 -1
- package/corpus/core/src/db/client.ts +28 -4
- package/corpus/core/src/deploy/build.ts +31 -3
- package/corpus/core/src/eject/remote-mcp-presets.ts +1 -1
- package/corpus/core/src/index.browser.ts +1 -0
- package/corpus/core/src/index.ts +1 -0
- package/corpus/core/src/integrations/google-docs-poller.ts +3 -0
- package/corpus/core/src/integrations/webhook-handler.ts +28 -11
- package/corpus/core/src/jobs/scheduler.ts +4 -0
- package/corpus/core/src/localization/default-messages.ts +3 -2
- package/corpus/core/src/mcp/build-server.ts +20 -2
- package/corpus/core/src/observability/traces.ts +48 -12
- package/corpus/core/src/org/handlers.ts +52 -1
- package/corpus/core/src/org/migrations.ts +4 -0
- package/corpus/core/src/org/plugin.ts +14 -0
- package/corpus/core/src/org/schema.ts +1 -0
- package/corpus/core/src/org/types.ts +8 -0
- package/corpus/core/src/org/workspace-url.ts +74 -0
- package/corpus/core/src/resources/handlers.ts +35 -5
- package/corpus/core/src/scripts/runner.ts +183 -5
- package/corpus/core/src/server/action-routes.ts +32 -2
- package/corpus/core/src/server/agent-chat-plugin.ts +29 -0
- package/corpus/core/src/server/agent-teams.ts +10 -1
- package/corpus/core/src/server/auth.ts +33 -7
- package/corpus/core/src/server/embed-route.ts +9 -0
- package/corpus/core/src/server/embed-session.ts +62 -3
- package/corpus/core/src/server/open-route.ts +20 -6
- package/corpus/core/src/server/prompts/framework-core-compact.ts +1 -1
- package/corpus/core/src/server/prompts/framework-core.ts +1 -0
- package/corpus/core/src/server/request-context.ts +36 -1
- package/corpus/core/src/shared/embed-auth.ts +1 -0
- package/corpus/core/src/shared/html-document.ts +115 -0
- package/corpus/core/src/shared/index.ts +1 -0
- package/corpus/core/src/sharing/access.ts +8 -1
- package/corpus/core/src/sharing/registry.ts +11 -2
- package/corpus/core/src/workspace-files/actions.ts +100 -0
- package/corpus/core/src/workspace-files/tool.ts +4 -0
- package/corpus/templates/analytics/.agents/skills/analysis-workspace/SKILL.md +4 -0
- package/corpus/templates/analytics/.agents/skills/hubspot/SKILL.md +9 -1
- package/corpus/templates/analytics/AGENTS.md +17 -24
- package/corpus/templates/analytics/actions/data-source-status.ts +11 -1
- package/corpus/templates/analytics/app/i18n-data.ts +34 -0
- package/corpus/templates/analytics/app/lib/data-source-status.ts +86 -0
- package/corpus/templates/analytics/app/lib/native-mcp-exclusions.ts +9 -0
- package/corpus/templates/analytics/app/pages/DataSources.tsx +184 -20
- package/corpus/templates/analytics/changelog/2026-07-28-native-analytics-data-sources-no-longer-show-duplicate-mc.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-29-exports-now-appear-in-chat-with-a-direct-download-instead-of.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-29-queued-chat-prompts-no-longer-resend-after-analytics-navigat.md +6 -0
- package/corpus/templates/analytics/changelog/2026-07-29-scheduled-dashboard-emails-load-every-panel-reliably-without.md +6 -0
- package/corpus/templates/analytics/scripts/emit-netlify-dashboard-report-cron.ts +6 -3
- package/corpus/templates/analytics/server/lib/credential-keys.ts +1 -1
- package/corpus/templates/analytics/server/lib/hubspot.ts +1 -1
- package/corpus/templates/analytics/server/lib/provider-credentials.ts +55 -1
- package/corpus/templates/analytics/server/plugins/agent-chat.ts +123 -27
- package/corpus/templates/analytics/server/routes/[...page].get.ts +2 -7
- package/corpus/templates/analytics/vite.config.ts +7 -0
- package/corpus/templates/brain/actions/list-connection-providers.ts +100 -2
- package/corpus/templates/brain/app/lib/brain.ts +10 -0
- package/corpus/templates/brain/app/routes/sources.tsx +15 -4
- package/corpus/templates/brain/changelog/2026-07-29-brain-automatically-retries-failed-source-syncs-and-guides-y.md +6 -0
- package/corpus/templates/brain/jobs/process-ingest-queue.ts +13 -0
- package/corpus/templates/brain/server/jobs/sync-sources.ts +27 -22
- package/corpus/templates/brain/server/plugins/agent-chat.ts +2 -1
- package/corpus/templates/brain/server/routes/api/brain/queue/run.post.ts +7 -1
- package/corpus/templates/clips/AGENTS.md +1 -1
- package/corpus/templates/clips/actions/create-recording-agent-link.ts +11 -1
- package/corpus/templates/clips/actions/update-comment.ts +68 -0
- package/corpus/templates/clips/app/components/editor/editor-layout.tsx +0 -1
- package/corpus/templates/clips/app/components/player/comments-panel.tsx +221 -65
- package/corpus/templates/clips/app/components/player/video-player.tsx +101 -27
- package/corpus/templates/clips/app/i18n/en-US.ts +2 -1
- package/corpus/templates/clips/app/routes/bug-report.done.tsx +48 -27
- package/corpus/templates/clips/app/routes/bug-report.tsx +43 -4
- package/corpus/templates/clips/app/routes/record.tsx +2 -0
- package/corpus/templates/clips/changelog/2026-07-29-clip-playback-now-recovers-instead-of-getting-stuck-when-a-b.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-29-comments-can-now-be-edited-after-posting.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-29-download-actions-now-use-a-shorter-clearer-label.md +6 -0
- package/corpus/templates/clips/changelog/2026-07-29-embedded-bug-reports-now-return-a-temporary-agent-readable.md +6 -0
- package/corpus/templates/clips/desktop/src-tauri/src/native_screen.rs +1 -1
- package/corpus/templates/clips/desktop/src-tauri/src/system_audio.rs +21 -1
- package/corpus/templates/clips/shared/bug-report.ts +99 -0
- package/corpus/templates/content/actions/_content-database-personal-view.ts +7 -1
- package/corpus/templates/content/app/components/editor/database/DatabaseView.tsx +5 -2
- package/corpus/templates/content/app/components/sidebar/DocumentSidebar.tsx +20 -8
- package/corpus/templates/content/changelog/2026-07-29-missing-databases-no-longer-trigger-repeated-personal-view-e.md +6 -0
- package/corpus/templates/design/.agents/skills/visual-edit/SKILL.md +83 -47
- package/corpus/templates/design/.generated/bridge/editor-chrome.generated.ts +474 -55
- package/corpus/templates/design/.generated/bridge/embedded-wheel.generated.ts +3 -0
- package/corpus/templates/design/.generated/bridge/hit-test.generated.ts +18 -1
- package/corpus/templates/design/.generated/bridge/source-location.generated.ts +348 -0
- package/corpus/templates/design/actions/add-localhost-screens.ts +2 -7
- package/corpus/templates/design/actions/apply-visual-edit.ts +7 -1
- package/corpus/templates/design/actions/connect-localhost.ts +5 -9
- package/corpus/templates/design/actions/create-component.ts +16 -13
- package/corpus/templates/design/actions/grant-localhost-write-consent.ts +2 -7
- package/corpus/templates/design/actions/list-design-source-capabilities.ts +4 -7
- package/corpus/templates/design/actions/list-local-files.ts +26 -50
- package/corpus/templates/design/actions/list-localhost-connections.ts +2 -7
- package/corpus/templates/design/actions/migrate-board-objects-to-file.ts +2 -2
- package/corpus/templates/design/actions/open-visual-edit.ts +234 -135
- package/corpus/templates/design/actions/read-local-file.ts +26 -50
- package/corpus/templates/design/actions/request-localhost-write-consent.ts +2 -7
- package/corpus/templates/design/actions/write-local-file.ts +31 -73
- package/corpus/templates/design/app/components/design/DesignCanvas.tsx +307 -133
- package/corpus/templates/design/app/components/design/EditPanel.tsx +94 -22
- package/corpus/templates/design/app/components/design/MultiScreenCanvas.tsx +137 -60
- package/corpus/templates/design/app/components/design/ResponsiveInteractBar.tsx +75 -14
- package/corpus/templates/design/app/components/design/bridge/editor-chrome.bridge.ts +755 -97
- package/corpus/templates/design/app/components/design/bridge/embedded-wheel.bridge.ts +8 -0
- package/corpus/templates/design/app/components/design/bridge/hit-test.bridge.ts +24 -1
- package/corpus/templates/design/app/components/design/bridge/source-location.bridge.ts +530 -0
- package/corpus/templates/design/app/components/design/code-workbench/CodeWorkbenchLoader.tsx +278 -0
- package/corpus/templates/design/app/components/design/code-workbench/editor/MonacoHost.tsx +32 -12
- package/corpus/templates/design/app/components/design/code-workbench/editor/monaco-setup.ts +14 -3
- package/corpus/templates/design/app/components/design/code-workbench/explorer/ExplorerView.tsx +87 -24
- package/corpus/templates/design/app/components/design/code-workbench/explorer/FileTree.tsx +36 -0
- package/corpus/templates/design/app/components/design/code-workbench/store.tsx +2 -1
- package/corpus/templates/design/app/components/design/code-workbench/workspace/localhost-provider.ts +48 -8
- package/corpus/templates/design/app/components/design/design-canvas/content-size-report.ts +3 -13
- package/corpus/templates/design/app/components/design/design-canvas/embedded-frame.ts +4 -2
- package/corpus/templates/design/app/components/design/design-canvas/hit-test.ts +3 -13
- package/corpus/templates/design/app/components/design/edit-panel/element-classification.ts +3 -1
- package/corpus/templates/design/app/components/design/edit-panel/inspect-code-source.ts +93 -0
- package/corpus/templates/design/app/components/design/multi-screen/board-surface-html.ts +4 -2
- package/corpus/templates/design/app/components/design/multi-screen/cross-screen-drop.ts +35 -0
- package/corpus/templates/design/app/components/design/multi-screen/iframe-targeting.ts +24 -0
- package/corpus/templates/design/app/components/design/multi-screen/types.ts +9 -0
- package/corpus/templates/design/app/components/design/types.ts +29 -0
- package/corpus/templates/design/app/components/layout/Layout.tsx +7 -4
- package/corpus/templates/design/app/hooks/use-navigation-state.ts +3 -0
- package/corpus/templates/design/app/i18n-data.ts +153 -46
- package/corpus/templates/design/app/i18n-responsive-interact.ts +12 -12
- package/corpus/templates/design/app/lib/design-editor-route.ts +23 -0
- package/corpus/templates/design/app/pages/VisualEdit.tsx +19 -6
- package/corpus/templates/design/app/pages/design-editor/action-error.ts +19 -0
- package/corpus/templates/design/app/pages/design-editor/canvas-primitive-insert.ts +29 -0
- package/corpus/templates/design/app/pages/design-editor/clone-and-pen-edit.ts +6 -0
- package/corpus/templates/design/app/pages/design-editor/code-layer-state.ts +277 -15
- package/corpus/templates/design/app/pages/design-editor/editor-state.ts +75 -9
- package/corpus/templates/design/app/pages/design-editor/layer-state-scope.ts +28 -0
- package/corpus/templates/design/app/pages/design-editor/live-screen-layer-drop.ts +41 -0
- package/corpus/templates/design/app/pages/design-editor/pending-edits.ts +496 -41
- package/corpus/templates/design/app/pages/design-editor/pending-live-edit-unload-guard.ts +27 -0
- package/corpus/templates/design/app/pages/design-editor/pending-structure-verification.ts +10 -0
- package/corpus/templates/design/app/pages/design-editor/react-semantic-handoff.ts +168 -9
- package/corpus/templates/design/app/pages/design-editor/responsive-interact.ts +41 -3
- package/corpus/templates/design/app/pages/design-editor/screen-command-utils.ts +5 -0
- package/corpus/templates/design/app/pages/design-editor/selection-state.ts +42 -13
- package/corpus/templates/design/app/pages/design-editor/source-location.ts +180 -0
- package/corpus/templates/design/app/pages/design-editor/tool-state.ts +17 -0
- package/corpus/templates/design/app/public-routes.ts +1 -0
- package/corpus/templates/design/app/routes/visual-edit.$id.tsx +15 -0
- package/corpus/templates/design/changelog/2026-06-29-screen-overview-is-easier-to-find-and-named-screens-open-dir.md +1 -1
- package/corpus/templates/design/changelog/2026-07-28-deleting-a-selected-element-now-removes-it-from-the-live-pre.md +6 -0
- package/corpus/templates/design/changelog/2026-07-28-deleting-an-element-on-a-connected-localhost-screen-now-queu.md +6 -0
- package/corpus/templates/design/changelog/2026-07-28-interact-mode-now-shows-a-responsive-device-preview-with-pre.md +6 -0
- package/corpus/templates/design/changelog/2026-07-28-layer-hide-and-lock-now-apply-to-the-live-preview-instead-of.md +6 -0
- package/corpus/templates/design/changelog/2026-07-28-layers-panel-selections-on-a-connected-localhost-screen-can-.md +6 -0
- package/corpus/templates/design/changelog/2026-07-28-locked-layers-now-show-a-subtle-dashed-outline-in-the-live-p.md +6 -0
- package/corpus/templates/design/changelog/2026-07-28-the-apply-design-updates-button-now-counts-pending-live-text.md +6 -0
- package/corpus/templates/design/changelog/2026-07-28-the-design-canvas-no-longer-stalls-on-a-render-loop-while-a-.md +6 -0
- package/corpus/templates/design/changelog/2026-07-28-visual-edit-on-a-local-dev-server-no-longer-requires-signing.md +6 -0
- package/corpus/templates/design/changelog/2026-07-28-visual-edits-on-a-react-19-app-no-longer-report-a-source-lin.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-an-edit-that-cannot-be-written-to-source-now-names-the-reaso.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-applying-a-primitive-dropped-onto-a-connected-localhost-scre.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-changing-a-style-in-the-inspector-now-updates-a-connected-lo.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-choosing-edit-or-annotate-from-a-focused-screen-now-returns-.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-concurrent-source-edits-now-return-a-clear-conflict-response.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-creating-a-component-from-an-element-that-repeats-in-the-sou.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-deleting-an-element-you-just-dropped-onto-a-live-screen-no-l.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-dragging-a-layer-across-screens-no-longer-dies-when-the-poin.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-dragging-an-element-from-a-stored-screen-into-a-live-localho.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-drawing-a-box-on-the-canvas-and-dragging-it-into-a-connected.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-fixed-a-loading-screen-flicker-when-reopening-designs-with-a.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-interact-mode-has-edit-and-annotate-buttons-again-so-you-can.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-layer-groups-can-be-dropped-onto-live-localhost-screens.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-localhost-source-errors-now-say-what-actually-went-wrong-whi.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-opening-or-refreshing-a-live-localhost-screen-in-single-scre.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-redo-after-undoing-a-drop-onto-a-live-screen-puts-the-elemen.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-shapes-can-be-drawn-directly-onto-live-localhost-screens.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-shapes-drawn-on-the-canvas-board-now-appear-immediately-inst.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-style-edits-on-a-running-localhost-screen-now-preview-live-a.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-the-apply-design-updates-control-now-appears-as-a-clean-conn.md +6 -0
- package/corpus/templates/design/changelog/2026-07-29-visual-edits-on-a-mapped-component-instance-now-tell-the-age.md +6 -0
- package/corpus/templates/design/server/lib/design-data-access.ts +21 -7
- package/corpus/templates/design/server/lib/localhost-connection.ts +240 -0
- package/corpus/templates/design/server/routes/[...page].get.ts +2 -5
- package/corpus/templates/design/server/source-workspace.ts +2 -0
- package/corpus/templates/design/shared/code-layer.ts +43 -0
- package/corpus/templates/design/shared/html-content.ts +26 -0
- package/corpus/templates/design/shared/html-integrity.ts +21 -1
- package/corpus/templates/design/shared/local-jsx-visual-edit.ts +15 -0
- package/corpus/templates/design/shared/source-mode.ts +76 -0
- package/corpus/templates/dispatch/changelog/2026-07-29-workspace-members-without-admin-access-now-see-a-clear-permi.md +6 -0
- package/corpus/templates/dispatch/server/lib/usage-metrics.ts +2 -1
- package/corpus/templates/plan/app/lib/plan-annotation-runtime.ts +3 -4
- package/corpus/templates/plan/server/routes/[...page].get.ts +2 -5
- package/corpus/templates/slides/actions/patch-deck.ts +29 -17
- package/corpus/toolkit/CHANGELOG.md +6 -0
- package/corpus/toolkit/package.json +1 -1
- package/corpus/toolkit/src/composer/ComposerPlusMenu.tsx +3 -2
- package/dist/action-ui.d.ts +1 -0
- package/dist/action-ui.d.ts.map +1 -1
- package/dist/action-ui.js +1 -0
- package/dist/action-ui.js.map +1 -1
- package/dist/action.d.ts +5 -1
- package/dist/action.d.ts.map +1 -1
- package/dist/action.js.map +1 -1
- package/dist/agent/engine/ai-sdk-engine.d.ts.map +1 -1
- package/dist/agent/engine/ai-sdk-engine.js +13 -5
- package/dist/agent/engine/ai-sdk-engine.js.map +1 -1
- package/dist/agent/harness/runner.d.ts.map +1 -1
- package/dist/agent/harness/runner.js +5 -0
- package/dist/agent/harness/runner.js.map +1 -1
- package/dist/agent/production-agent.d.ts +16 -0
- package/dist/agent/production-agent.d.ts.map +1 -1
- package/dist/agent/production-agent.js +18 -1
- package/dist/agent/production-agent.js.map +1 -1
- package/dist/agent/run-loop-with-resume.d.ts.map +1 -1
- package/dist/agent/run-loop-with-resume.js +6 -0
- package/dist/agent/run-loop-with-resume.js.map +1 -1
- package/dist/agent/run-manager.d.ts +14 -0
- package/dist/agent/run-manager.d.ts.map +1 -1
- package/dist/agent/run-manager.js +91 -1
- package/dist/agent/run-manager.js.map +1 -1
- package/dist/agent/thread-data-builder.d.ts +3 -0
- package/dist/agent/thread-data-builder.d.ts.map +1 -1
- package/dist/agent/thread-data-builder.js +35 -3
- package/dist/agent/thread-data-builder.js.map +1 -1
- package/dist/agent/types.d.ts +2 -0
- package/dist/agent/types.d.ts.map +1 -1
- package/dist/agent/types.js.map +1 -1
- package/dist/chat-threads/store.d.ts.map +1 -1
- package/dist/chat-threads/store.js +4 -6
- package/dist/chat-threads/store.js.map +1 -1
- package/dist/cli/create.d.ts +66 -6
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +765 -66
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/design-connect.d.ts.map +1 -1
- package/dist/cli/design-connect.js +2 -7
- package/dist/cli/design-connect.js.map +1 -1
- package/dist/cli/index.js +5 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/skills-content/design-visual-edit-skill.d.ts +1 -1
- package/dist/cli/skills-content/design-visual-edit-skill.d.ts.map +1 -1
- package/dist/cli/skills-content/design-visual-edit-skill.js +83 -47
- package/dist/cli/skills-content/design-visual-edit-skill.js.map +1 -1
- package/dist/client/AssistantChat.d.ts.map +1 -1
- package/dist/client/AssistantChat.js +16 -9
- package/dist/client/AssistantChat.js.map +1 -1
- package/dist/client/agent-chat-adapter.d.ts.map +1 -1
- package/dist/client/agent-chat-adapter.js +21 -0
- package/dist/client/agent-chat-adapter.js.map +1 -1
- package/dist/client/blocks/library/wireframe-kit.d.ts +2 -0
- package/dist/client/blocks/library/wireframe-kit.d.ts.map +1 -1
- package/dist/client/blocks/library/wireframe-kit.js +8 -2
- package/dist/client/blocks/library/wireframe-kit.js.map +1 -1
- package/dist/client/chat/index.d.ts +1 -1
- package/dist/client/chat/index.d.ts.map +1 -1
- package/dist/client/chat/index.js +1 -1
- package/dist/client/chat/index.js.map +1 -1
- package/dist/client/chat/message-components.d.ts +17 -0
- package/dist/client/chat/message-components.d.ts.map +1 -1
- package/dist/client/chat/message-components.js +24 -2
- package/dist/client/chat/message-components.js.map +1 -1
- package/dist/client/chat/run-recovery.d.ts +6 -0
- package/dist/client/chat/run-recovery.d.ts.map +1 -1
- package/dist/client/chat/run-recovery.js +13 -3
- package/dist/client/chat/run-recovery.js.map +1 -1
- package/dist/client/chat/widgets/DataTableWidget.d.ts.map +1 -1
- package/dist/client/chat/widgets/DataTableWidget.js +2 -3
- package/dist/client/chat/widgets/DataTableWidget.js.map +1 -1
- package/dist/client/chat/widgets/WorkspaceFileWidget.d.ts +5 -0
- package/dist/client/chat/widgets/WorkspaceFileWidget.d.ts.map +1 -0
- package/dist/client/chat/widgets/WorkspaceFileWidget.js +34 -0
- package/dist/client/chat/widgets/WorkspaceFileWidget.js.map +1 -0
- package/dist/client/chat/widgets/builtin-tool-renderers.d.ts.map +1 -1
- package/dist/client/chat/widgets/builtin-tool-renderers.js +13 -1
- package/dist/client/chat/widgets/builtin-tool-renderers.js.map +1 -1
- package/dist/client/chat/widgets/workspace-file-result.d.ts +12 -0
- package/dist/client/chat/widgets/workspace-file-result.d.ts.map +1 -0
- package/dist/client/chat/widgets/workspace-file-result.js +34 -0
- package/dist/client/chat/widgets/workspace-file-result.js.map +1 -0
- package/dist/client/embed-auth.d.ts.map +1 -1
- package/dist/client/embed-auth.js +2 -1
- package/dist/client/embed-auth.js.map +1 -1
- package/dist/client/org/InvitationBanner.d.ts +5 -2
- package/dist/client/org/InvitationBanner.d.ts.map +1 -1
- package/dist/client/org/InvitationBanner.js +9 -2
- package/dist/client/org/InvitationBanner.js.map +1 -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 +27 -3
- package/dist/client/org/TeamPage.js.map +1 -1
- package/dist/client/org/WorkspaceNotice.d.ts +18 -0
- package/dist/client/org/WorkspaceNotice.d.ts.map +1 -0
- package/dist/client/org/WorkspaceNotice.js +56 -0
- package/dist/client/org/WorkspaceNotice.js.map +1 -0
- package/dist/client/org/hooks.d.ts +1 -0
- package/dist/client/org/hooks.d.ts.map +1 -1
- package/dist/client/org/hooks.js +12 -0
- package/dist/client/org/hooks.js.map +1 -1
- package/dist/client/org/index.d.ts +2 -1
- package/dist/client/org/index.d.ts.map +1 -1
- package/dist/client/org/index.js +2 -1
- package/dist/client/org/index.js.map +1 -1
- package/dist/client/resources/McpIntegrationDialog.d.ts.map +1 -1
- package/dist/client/resources/McpIntegrationDialog.js +8 -12
- package/dist/client/resources/McpIntegrationDialog.js.map +1 -1
- package/dist/client/resources/ResourcesPanel.d.ts +3 -0
- package/dist/client/resources/ResourcesPanel.d.ts.map +1 -1
- package/dist/client/resources/ResourcesPanel.js +49 -20
- package/dist/client/resources/ResourcesPanel.js.map +1 -1
- package/dist/client/resources/mcp-integration-catalog.d.ts +1 -0
- package/dist/client/resources/mcp-integration-catalog.d.ts.map +1 -1
- package/dist/client/resources/mcp-integration-catalog.js +3 -0
- package/dist/client/resources/mcp-integration-catalog.js.map +1 -1
- package/dist/client/resources/use-resources.d.ts +1 -0
- package/dist/client/resources/use-resources.d.ts.map +1 -1
- package/dist/client/resources/use-resources.js +3 -0
- package/dist/client/resources/use-resources.js.map +1 -1
- package/dist/client/use-action.d.ts +3 -1
- package/dist/client/use-action.d.ts.map +1 -1
- package/dist/client/use-action.js +3 -1
- package/dist/client/use-action.js.map +1 -1
- package/dist/client/widgets/index.d.ts +1 -1
- package/dist/client/widgets/index.d.ts.map +1 -1
- package/dist/client/widgets/index.js +1 -1
- package/dist/client/widgets/index.js.map +1 -1
- package/dist/coding-tools/run-code.js +2 -1
- package/dist/coding-tools/run-code.js.map +1 -1
- package/dist/collab/awareness.d.ts +2 -2
- package/dist/collab/awareness.d.ts.map +1 -1
- package/dist/collab/routes.d.ts +1 -1
- package/dist/db/client.d.ts +1 -0
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +24 -3
- package/dist/db/client.js.map +1 -1
- package/dist/deploy/build.d.ts.map +1 -1
- package/dist/deploy/build.js +25 -3
- package/dist/deploy/build.js.map +1 -1
- package/dist/eject/remote-mcp-presets.js +1 -1
- package/dist/eject/remote-mcp-presets.js.map +1 -1
- package/dist/index.browser.d.ts +1 -1
- package/dist/index.browser.d.ts.map +1 -1
- package/dist/index.browser.js +1 -1
- package/dist/index.browser.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/integrations/google-docs-poller.d.ts.map +1 -1
- package/dist/integrations/google-docs-poller.js +4 -1
- package/dist/integrations/google-docs-poller.js.map +1 -1
- package/dist/integrations/webhook-handler.d.ts.map +1 -1
- package/dist/integrations/webhook-handler.js +23 -11
- package/dist/integrations/webhook-handler.js.map +1 -1
- package/dist/jobs/scheduler.js +4 -0
- package/dist/jobs/scheduler.js.map +1 -1
- package/dist/localization/default-messages.d.ts +3 -2
- package/dist/localization/default-messages.d.ts.map +1 -1
- package/dist/localization/default-messages.js +3 -2
- package/dist/localization/default-messages.js.map +1 -1
- package/dist/mcp/build-server.d.ts.map +1 -1
- package/dist/mcp/build-server.js +10 -1
- package/dist/mcp/build-server.js.map +1 -1
- package/dist/notifications/routes.d.ts +1 -1
- package/dist/observability/traces.d.ts.map +1 -1
- package/dist/observability/traces.js +27 -7
- package/dist/observability/traces.js.map +1 -1
- package/dist/org/handlers.d.ts +15 -0
- package/dist/org/handlers.d.ts.map +1 -1
- package/dist/org/handlers.js +45 -1
- package/dist/org/handlers.js.map +1 -1
- package/dist/org/migrations.d.ts.map +1 -1
- package/dist/org/migrations.js +4 -0
- package/dist/org/migrations.js.map +1 -1
- package/dist/org/plugin.d.ts +1 -0
- package/dist/org/plugin.d.ts.map +1 -1
- package/dist/org/plugin.js +10 -1
- package/dist/org/plugin.js.map +1 -1
- package/dist/org/schema.d.ts +19 -0
- package/dist/org/schema.d.ts.map +1 -1
- package/dist/org/schema.js +1 -0
- package/dist/org/schema.js.map +1 -1
- package/dist/org/types.d.ts +8 -0
- package/dist/org/types.d.ts.map +1 -1
- package/dist/org/types.js.map +1 -1
- package/dist/org/workspace-url.d.ts +32 -0
- package/dist/org/workspace-url.d.ts.map +1 -0
- package/dist/org/workspace-url.js +63 -0
- package/dist/org/workspace-url.js.map +1 -0
- package/dist/progress/routes.d.ts +1 -1
- package/dist/provider-api/actions/custom-provider-registration.d.ts +11 -11
- package/dist/provider-api/actions/provider-api.d.ts +7 -7
- package/dist/resources/handlers.d.ts +2 -3
- package/dist/resources/handlers.d.ts.map +1 -1
- package/dist/resources/handlers.js +25 -5
- package/dist/resources/handlers.js.map +1 -1
- package/dist/scripts/runner.d.ts +17 -0
- package/dist/scripts/runner.d.ts.map +1 -1
- package/dist/scripts/runner.js +130 -5
- package/dist/scripts/runner.js.map +1 -1
- package/dist/secrets/routes.d.ts +9 -9
- package/dist/server/action-routes.d.ts.map +1 -1
- package/dist/server/action-routes.js +24 -2
- package/dist/server/action-routes.js.map +1 -1
- package/dist/server/agent-chat-plugin.d.ts.map +1 -1
- package/dist/server/agent-chat-plugin.js +26 -1
- package/dist/server/agent-chat-plugin.js.map +1 -1
- package/dist/server/agent-engine-api-key-route.d.ts +1 -1
- package/dist/server/agent-teams.d.ts.map +1 -1
- package/dist/server/agent-teams.js +10 -1
- package/dist/server/agent-teams.js.map +1 -1
- package/dist/server/auth.d.ts +22 -0
- package/dist/server/auth.d.ts.map +1 -1
- package/dist/server/auth.js +33 -7
- package/dist/server/auth.js.map +1 -1
- package/dist/server/embed-route.d.ts.map +1 -1
- package/dist/server/embed-route.js +6 -1
- package/dist/server/embed-route.js.map +1 -1
- package/dist/server/embed-session.d.ts +7 -0
- package/dist/server/embed-session.d.ts.map +1 -1
- package/dist/server/embed-session.js +46 -4
- package/dist/server/embed-session.js.map +1 -1
- package/dist/server/open-route.d.ts.map +1 -1
- package/dist/server/open-route.js +17 -7
- package/dist/server/open-route.js.map +1 -1
- package/dist/server/prompts/framework-core-compact.js +1 -1
- package/dist/server/prompts/framework-core-compact.js.map +1 -1
- package/dist/server/prompts/framework-core.d.ts.map +1 -1
- package/dist/server/prompts/framework-core.js +1 -0
- package/dist/server/prompts/framework-core.js.map +1 -1
- package/dist/server/request-context.d.ts +26 -0
- package/dist/server/request-context.d.ts.map +1 -1
- package/dist/server/request-context.js +18 -1
- package/dist/server/request-context.js.map +1 -1
- package/dist/shared/embed-auth.d.ts +1 -0
- package/dist/shared/embed-auth.d.ts.map +1 -1
- package/dist/shared/embed-auth.js +1 -0
- package/dist/shared/embed-auth.js.map +1 -1
- package/dist/shared/html-document.d.ts +12 -0
- package/dist/shared/html-document.d.ts.map +1 -0
- package/dist/shared/html-document.js +92 -0
- package/dist/shared/html-document.js.map +1 -0
- package/dist/shared/index.d.ts +1 -0
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +1 -0
- package/dist/shared/index.js.map +1 -1
- package/dist/sharing/access.d.ts +1 -0
- package/dist/sharing/access.d.ts.map +1 -1
- package/dist/sharing/access.js +8 -2
- package/dist/sharing/access.js.map +1 -1
- package/dist/sharing/registry.d.ts +3 -0
- package/dist/sharing/registry.d.ts.map +1 -1
- package/dist/sharing/registry.js.map +1 -1
- package/dist/workspace-files/actions.d.ts +28 -0
- package/dist/workspace-files/actions.d.ts.map +1 -0
- package/dist/workspace-files/actions.js +75 -0
- package/dist/workspace-files/actions.js.map +1 -0
- package/dist/workspace-files/tool.d.ts.map +1 -1
- package/dist/workspace-files/tool.js +4 -0
- package/dist/workspace-files/tool.js.map +1 -1
- package/docs/content/cloneable-saas.mdx +114 -0
- package/docs/content/creating-templates.mdx +28 -2
- package/docs/content/syncing-template-changes.mdx +7 -0
- package/docs/content/template-clips-developers.mdx +12 -5
- package/docs/content/template-dispatch-developers.mdx +1 -1
- package/docs/content/template-dispatch.mdx +1 -1
- package/package.json +2 -2
- package/src/action-ui.ts +1 -0
- package/src/action.ts +5 -1
- package/src/agent/engine/ai-sdk-engine.ts +15 -5
- package/src/agent/harness/runner.ts +5 -0
- package/src/agent/production-agent.ts +33 -0
- package/src/agent/run-loop-with-resume.ts +5 -0
- package/src/agent/run-manager.ts +126 -1
- package/src/agent/thread-data-builder.ts +47 -2
- package/src/agent/types.ts +2 -0
- package/src/chat-threads/store.ts +4 -5
- package/src/cli/create.ts +1139 -65
- package/src/cli/design-connect.ts +3 -7
- package/src/cli/index.ts +5 -3
- package/src/cli/skills-content/design-visual-edit-skill.ts +83 -47
- package/src/client/AssistantChat.tsx +27 -16
- package/src/client/agent-chat-adapter.ts +24 -0
- package/src/client/blocks/library/wireframe-kit.tsx +17 -2
- package/src/client/chat/index.ts +1 -0
- package/src/client/chat/message-components.tsx +104 -1
- package/src/client/chat/run-recovery.tsx +15 -3
- package/src/client/chat/widgets/DataTableWidget.tsx +10 -29
- package/src/client/chat/widgets/WorkspaceFileWidget.tsx +71 -0
- package/src/client/chat/widgets/builtin-tool-renderers.tsx +22 -0
- package/src/client/chat/widgets/workspace-file-result.ts +49 -0
- package/src/client/embed-auth.ts +2 -0
- package/src/client/org/InvitationBanner.tsx +14 -1
- package/src/client/org/OrgSwitcher.tsx +23 -0
- package/src/client/org/TeamPage.tsx +130 -0
- package/src/client/org/WorkspaceNotice.tsx +85 -0
- package/src/client/org/hooks.ts +14 -0
- package/src/client/org/index.ts +2 -0
- package/src/client/resources/McpIntegrationDialog.tsx +27 -40
- package/src/client/resources/ResourcesPanel.tsx +134 -51
- package/src/client/resources/mcp-integration-catalog.ts +7 -0
- package/src/client/resources/use-resources.ts +6 -0
- package/src/client/use-action.ts +3 -1
- package/src/client/widgets/index.ts +1 -0
- package/src/coding-tools/run-code.ts +2 -1
- package/src/db/client.ts +28 -4
- package/src/deploy/build.ts +31 -3
- package/src/eject/remote-mcp-presets.ts +1 -1
- package/src/index.browser.ts +1 -0
- package/src/index.ts +1 -0
- package/src/integrations/google-docs-poller.ts +3 -0
- package/src/integrations/webhook-handler.ts +28 -11
- package/src/jobs/scheduler.ts +4 -0
- package/src/localization/default-messages.ts +3 -2
- package/src/mcp/build-server.ts +20 -2
- package/src/observability/traces.ts +48 -12
- package/src/org/handlers.ts +52 -1
- package/src/org/migrations.ts +4 -0
- package/src/org/plugin.ts +14 -0
- package/src/org/schema.ts +1 -0
- package/src/org/types.ts +8 -0
- package/src/org/workspace-url.ts +74 -0
- package/src/resources/handlers.ts +35 -5
- package/src/scripts/runner.ts +183 -5
- package/src/server/__snapshots__/agent-chat-plugin.surface.spec.ts.snap +2 -1
- package/src/server/action-routes.ts +32 -2
- package/src/server/agent-chat-plugin.ts +29 -0
- package/src/server/agent-teams.ts +10 -1
- package/src/server/auth.ts +33 -7
- package/src/server/embed-route.ts +9 -0
- package/src/server/embed-session.ts +62 -3
- package/src/server/open-route.ts +20 -6
- package/src/server/prompts/framework-core-compact.ts +1 -1
- package/src/server/prompts/framework-core.ts +1 -0
- package/src/server/request-context.ts +36 -1
- package/src/shared/embed-auth.ts +1 -0
- package/src/shared/html-document.ts +115 -0
- package/src/shared/index.ts +1 -0
- package/src/sharing/access.ts +8 -1
- package/src/sharing/registry.ts +11 -2
- package/src/workspace-files/actions.ts +100 -0
- package/src/workspace-files/tool.ts +4 -0
- package/corpus/templates/design/changelog/2026-07-28-interact-mode-can-preview-designs-in-responsive-device-sizes.md +0 -6
- package/corpus/templates/design/changelog/2026-07-28-interact-mode-now-opens-a-full-screen-responsive-preview-wit.md +0 -6
|
@@ -0,0 +1,240 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Server-side helpers for localhost design connections: the org scope every
|
|
3
|
+
* query against `design_localhost_connections` must use, and a classified
|
|
4
|
+
* resolver for the bridge transport.
|
|
5
|
+
*
|
|
6
|
+
* Scope
|
|
7
|
+
* =====
|
|
8
|
+
* Connection rows are keyed by (ownerEmail, orgId). `getRequestOrgId()` is
|
|
9
|
+
* undefined outside a request store — `pnpm action connect-localhost`, cron,
|
|
10
|
+
* any CLI caller — and is also null for a request whose org membership read
|
|
11
|
+
* failed, so those callers wrote and read under a different scope than the same
|
|
12
|
+
* user's browser session: the connection rendered in the UI and every
|
|
13
|
+
* server-side read of it missed. Resolve the scope through
|
|
14
|
+
* `resolveLocalhostConnectionScope()` rather than reading the request org
|
|
15
|
+
* directly, so both sides land on the same partition.
|
|
16
|
+
*
|
|
17
|
+
* Errors
|
|
18
|
+
* ======
|
|
19
|
+
* Every miss is classified and thrown with a 4xx `statusCode`, because the
|
|
20
|
+
* action HTTP surface echoes a message only for explicit client errors — an
|
|
21
|
+
* unclassified throw reaches the browser as `{"error":"Internal server error"}`
|
|
22
|
+
* with the real cause server-log-only. Messages name the connection and the
|
|
23
|
+
* fix; the bridge token is never echoed.
|
|
24
|
+
*/
|
|
25
|
+
|
|
26
|
+
import { resolveOrgIdForEmail } from "@agent-native/core/org";
|
|
27
|
+
import {
|
|
28
|
+
getRequestOrgId,
|
|
29
|
+
getRequestUserEmail,
|
|
30
|
+
} from "@agent-native/core/server/request-context";
|
|
31
|
+
import { and, eq, isNull } from "drizzle-orm";
|
|
32
|
+
|
|
33
|
+
import { getDb, schema } from "../db/index.js";
|
|
34
|
+
|
|
35
|
+
const CONNECT_HINT = "npx @agent-native/core@latest design connect";
|
|
36
|
+
|
|
37
|
+
export interface LocalhostConnectionScope {
|
|
38
|
+
ownerEmail: string;
|
|
39
|
+
orgId: string | null;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Owner + org partition for connection and write-grant rows. */
|
|
43
|
+
export async function resolveLocalhostConnectionScope(): Promise<LocalhostConnectionScope> {
|
|
44
|
+
const ownerEmail = getRequestUserEmail();
|
|
45
|
+
if (!ownerEmail) throw new Error("no authenticated user");
|
|
46
|
+
const requestOrgId = getRequestOrgId();
|
|
47
|
+
return {
|
|
48
|
+
ownerEmail,
|
|
49
|
+
// resolveOrgIdForEmail honors an explicit Personal selection, so this
|
|
50
|
+
// cannot promote a caller into an org they left.
|
|
51
|
+
orgId: requestOrgId ?? (await resolveOrgIdForEmail(ownerEmail)),
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type LocalhostConnectionErrorCode =
|
|
56
|
+
| "connection-not-found"
|
|
57
|
+
| "connection-scope-mismatch"
|
|
58
|
+
| "bridge-not-running"
|
|
59
|
+
| "bridge-token-missing"
|
|
60
|
+
| "bridge-unreachable"
|
|
61
|
+
| "bridge-auth-rejected"
|
|
62
|
+
| "bridge-request-failed";
|
|
63
|
+
|
|
64
|
+
export class LocalhostConnectionError extends Error {
|
|
65
|
+
readonly errorCode: LocalhostConnectionErrorCode;
|
|
66
|
+
readonly statusCode: number;
|
|
67
|
+
|
|
68
|
+
constructor(
|
|
69
|
+
errorCode: LocalhostConnectionErrorCode,
|
|
70
|
+
message: string,
|
|
71
|
+
statusCode: number,
|
|
72
|
+
) {
|
|
73
|
+
super(message);
|
|
74
|
+
this.name = "LocalhostConnectionError";
|
|
75
|
+
this.errorCode = errorCode;
|
|
76
|
+
this.statusCode = statusCode;
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
export interface LocalhostBridgeConnection {
|
|
81
|
+
bridgeUrl: string;
|
|
82
|
+
bridgeToken: string | null;
|
|
83
|
+
rootPath: string | null;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
function describeScope(orgId: string | null): string {
|
|
87
|
+
return orgId ? "an organization workspace" : "the personal workspace";
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Load the bridge transport for one connection in the caller's scope.
|
|
92
|
+
*
|
|
93
|
+
* Throws a classified `LocalhostConnectionError` instead of returning a
|
|
94
|
+
* partial row: "invisible in this scope", "never existed", and "bridge not
|
|
95
|
+
* running" have different fixes, and collapsing them into one miss is what
|
|
96
|
+
* made this surface as an opaque 500.
|
|
97
|
+
*/
|
|
98
|
+
export async function resolveLocalhostBridgeConnection(args: {
|
|
99
|
+
connectionId: string;
|
|
100
|
+
ownerEmail: string;
|
|
101
|
+
orgId: string | null;
|
|
102
|
+
}): Promise<LocalhostBridgeConnection> {
|
|
103
|
+
const { connectionId, ownerEmail, orgId } = args;
|
|
104
|
+
const db = getDb();
|
|
105
|
+
const [connection] = await db
|
|
106
|
+
.select({
|
|
107
|
+
bridgeUrl: schema.designLocalhostConnections.bridgeUrl,
|
|
108
|
+
bridgeToken: schema.designLocalhostConnections.bridgeToken,
|
|
109
|
+
rootPath: schema.designLocalhostConnections.rootPath,
|
|
110
|
+
})
|
|
111
|
+
.from(schema.designLocalhostConnections)
|
|
112
|
+
.where(
|
|
113
|
+
and(
|
|
114
|
+
eq(schema.designLocalhostConnections.id, connectionId),
|
|
115
|
+
eq(schema.designLocalhostConnections.ownerEmail, ownerEmail),
|
|
116
|
+
orgId
|
|
117
|
+
? eq(schema.designLocalhostConnections.orgId, orgId)
|
|
118
|
+
: isNull(schema.designLocalhostConnections.orgId),
|
|
119
|
+
),
|
|
120
|
+
)
|
|
121
|
+
.limit(1);
|
|
122
|
+
|
|
123
|
+
if (!connection) {
|
|
124
|
+
const [outOfScope] = await db
|
|
125
|
+
.select({ orgId: schema.designLocalhostConnections.orgId })
|
|
126
|
+
.from(schema.designLocalhostConnections)
|
|
127
|
+
.where(
|
|
128
|
+
and(
|
|
129
|
+
eq(schema.designLocalhostConnections.id, connectionId),
|
|
130
|
+
eq(schema.designLocalhostConnections.ownerEmail, ownerEmail),
|
|
131
|
+
),
|
|
132
|
+
)
|
|
133
|
+
.limit(1);
|
|
134
|
+
|
|
135
|
+
if (outOfScope) {
|
|
136
|
+
throw new LocalhostConnectionError(
|
|
137
|
+
"connection-scope-mismatch",
|
|
138
|
+
`Local connection "${connectionId}" is registered in ` +
|
|
139
|
+
`${describeScope(outOfScope.orgId ?? null)} but this request runs in ` +
|
|
140
|
+
`${describeScope(orgId)}, so it cannot be read back. Reconnect the ` +
|
|
141
|
+
`local app from this workspace (\`${CONNECT_HINT}\`) and retry.`,
|
|
142
|
+
409,
|
|
143
|
+
);
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
throw new LocalhostConnectionError(
|
|
147
|
+
"connection-not-found",
|
|
148
|
+
`No local connection "${connectionId}" for this account. Connect the ` +
|
|
149
|
+
`local app first (\`${CONNECT_HINT}\`), then retry.`,
|
|
150
|
+
404,
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (!connection.bridgeUrl) {
|
|
155
|
+
throw new LocalhostConnectionError(
|
|
156
|
+
"bridge-not-running",
|
|
157
|
+
`Local connection "${connectionId}" has no bridge URL — the design ` +
|
|
158
|
+
`bridge is not running for it. Start it with \`${CONNECT_HINT}\` and retry.`,
|
|
159
|
+
424,
|
|
160
|
+
);
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return connection as LocalhostBridgeConnection;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/**
|
|
167
|
+
* POST one bridge operation. A dead bridge rejects `fetch` with a bare
|
|
168
|
+
* TypeError, which is unclassified and therefore reaches the client as a
|
|
169
|
+
* generic 500 — the same opaque failure a missing connection row used to be.
|
|
170
|
+
*/
|
|
171
|
+
export async function fetchLocalhostBridge(args: {
|
|
172
|
+
bridgeUrl: string;
|
|
173
|
+
operation: string;
|
|
174
|
+
bridgeToken: string;
|
|
175
|
+
body: unknown;
|
|
176
|
+
}): Promise<Response> {
|
|
177
|
+
const { bridgeUrl, operation, bridgeToken, body } = args;
|
|
178
|
+
try {
|
|
179
|
+
return await fetch(`${bridgeUrl}/${operation}`, {
|
|
180
|
+
method: "POST",
|
|
181
|
+
headers: {
|
|
182
|
+
"Content-Type": "application/json",
|
|
183
|
+
"X-Bridge-Token": bridgeToken,
|
|
184
|
+
},
|
|
185
|
+
body: JSON.stringify(body),
|
|
186
|
+
});
|
|
187
|
+
} catch (cause) {
|
|
188
|
+
throw new LocalhostConnectionError(
|
|
189
|
+
"bridge-unreachable",
|
|
190
|
+
`Could not reach the design bridge at ${bridgeUrl} for ${operation} ` +
|
|
191
|
+
`(${cause instanceof Error ? cause.message : String(cause)}). It is ` +
|
|
192
|
+
`registered but not accepting connections — restart it with ` +
|
|
193
|
+
`\`${CONNECT_HINT}\` and retry.`,
|
|
194
|
+
424,
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Classify a non-2xx bridge response. 401/403 means the bridge rejected the
|
|
201
|
+
* token: every bridge start mints a fresh one, so a restart leaves the stored
|
|
202
|
+
* token stale while the connection row still looks healthy.
|
|
203
|
+
*/
|
|
204
|
+
export function localhostBridgeRequestError(
|
|
205
|
+
operation: string,
|
|
206
|
+
status: number,
|
|
207
|
+
errText: string,
|
|
208
|
+
): LocalhostConnectionError {
|
|
209
|
+
if (status === 401 || status === 403) {
|
|
210
|
+
return new LocalhostConnectionError(
|
|
211
|
+
"bridge-auth-rejected",
|
|
212
|
+
`The design bridge rejected authentication for ${operation} (${status}). ` +
|
|
213
|
+
"The stored bridge token is stale — each bridge start mints a fresh " +
|
|
214
|
+
`token, so reconnect with \`${CONNECT_HINT}\` (and re-grant write ` +
|
|
215
|
+
"consent if you were writing), then retry.",
|
|
216
|
+
409,
|
|
217
|
+
);
|
|
218
|
+
}
|
|
219
|
+
return new LocalhostConnectionError(
|
|
220
|
+
"bridge-request-failed",
|
|
221
|
+
`Bridge ${operation} failed (${status}): ${errText}`,
|
|
222
|
+
424,
|
|
223
|
+
);
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** Bridge token for callers that have no other source for one. */
|
|
227
|
+
export function requireLocalhostBridgeToken(
|
|
228
|
+
connectionId: string,
|
|
229
|
+
bridgeToken: string | null,
|
|
230
|
+
): string {
|
|
231
|
+
if (!bridgeToken) {
|
|
232
|
+
throw new LocalhostConnectionError(
|
|
233
|
+
"bridge-token-missing",
|
|
234
|
+
`Local connection "${connectionId}" has no bridge token. Reconnect the ` +
|
|
235
|
+
`local app (\`${CONNECT_HINT}\`) and retry.`,
|
|
236
|
+
424,
|
|
237
|
+
);
|
|
238
|
+
}
|
|
239
|
+
return bridgeToken;
|
|
240
|
+
}
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
import { createH3SSRHandler } from "@agent-native/core/server/ssr-handler";
|
|
6
6
|
import {
|
|
7
7
|
buildAgentReadableResourceDiscovery,
|
|
8
|
+
injectDocumentMarkup,
|
|
8
9
|
renderAgentReadableResourceDiscoveryScript,
|
|
9
10
|
} from "@agent-native/core/shared";
|
|
10
11
|
import {
|
|
@@ -48,11 +49,7 @@ function queryString(value: unknown): string {
|
|
|
48
49
|
|
|
49
50
|
function injectScript(html: string, script: string): string {
|
|
50
51
|
if (html.includes("agent-native-design-agent-context")) return html;
|
|
51
|
-
|
|
52
|
-
return html.replace("</head>", `${script}</head>`);
|
|
53
|
-
if (html.includes("</body>"))
|
|
54
|
-
return html.replace("</body>", `${script}</body>`);
|
|
55
|
-
return `${html}${script}`;
|
|
52
|
+
return injectDocumentMarkup(html, script, { target: "head" });
|
|
56
53
|
}
|
|
57
54
|
|
|
58
55
|
export default defineEventHandler(async (event) => {
|
|
@@ -255,6 +255,8 @@ export async function readLiveSourceFile(file: SourceWorkspaceFile): Promise<{
|
|
|
255
255
|
* read-check-write lock closes the race after this preparation step.
|
|
256
256
|
*/
|
|
257
257
|
export class SourceWorkspaceEditConflictError extends Error {
|
|
258
|
+
readonly statusCode = 409;
|
|
259
|
+
|
|
258
260
|
constructor(
|
|
259
261
|
message = "Source file changed since the editor snapshot was prepared.",
|
|
260
262
|
) {
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
type ComponentInstance,
|
|
10
10
|
} from "./component-model";
|
|
11
11
|
import type { TailwindBreakpointPrefix } from "./design-state.js";
|
|
12
|
+
import { isStandaloneHttpUrl } from "./html-content.js";
|
|
12
13
|
import {
|
|
13
14
|
getPropertyClasses,
|
|
14
15
|
parseClassGroups,
|
|
@@ -21,6 +22,14 @@ import {
|
|
|
21
22
|
} from "./responsive-classes.js";
|
|
22
23
|
import type { DesignSourceType } from "./source-mode";
|
|
23
24
|
|
|
25
|
+
/**
|
|
26
|
+
* Shown when a document transform is handed a URL-backed (localhost/fusion)
|
|
27
|
+
* screen's stored content. Same wording from both producers so the message
|
|
28
|
+
* doesn't depend on which gesture the user happened to use.
|
|
29
|
+
*/
|
|
30
|
+
export const URL_BACKED_SCREEN_EDIT_REFUSAL =
|
|
31
|
+
"This screen is backed by a live route URL, not editable markup — layers cannot be moved into or out of it. Edit the running app's source instead.";
|
|
32
|
+
|
|
24
33
|
export type CodeLayerSourceKind =
|
|
25
34
|
| "design-file"
|
|
26
35
|
| "inline-html"
|
|
@@ -3984,6 +3993,24 @@ export function applyVisualEdit(
|
|
|
3984
3993
|
),
|
|
3985
3994
|
};
|
|
3986
3995
|
}
|
|
3996
|
+
// See moveNodeBetweenDocuments' twin guard: a URL-backed screen stores its
|
|
3997
|
+
// route, not a document, and every edit below concatenates against `html`.
|
|
3998
|
+
// Callers only ever check `status`, so refusing here turns ~40 gesture and
|
|
3999
|
+
// action call sites into "nothing happened" instead of a screen silently
|
|
4000
|
+
// unbound from the running app.
|
|
4001
|
+
if (isStandaloneHttpUrl(html)) {
|
|
4002
|
+
return {
|
|
4003
|
+
content: html,
|
|
4004
|
+
projection: buildCodeLayerProjection(html, { source }),
|
|
4005
|
+
result: patchResult(
|
|
4006
|
+
"unsupported",
|
|
4007
|
+
source,
|
|
4008
|
+
intent,
|
|
4009
|
+
false,
|
|
4010
|
+
URL_BACKED_SCREEN_EDIT_REFUSAL,
|
|
4011
|
+
),
|
|
4012
|
+
};
|
|
4013
|
+
}
|
|
3987
4014
|
|
|
3988
4015
|
const initial = buildProjection(html, source);
|
|
3989
4016
|
|
|
@@ -4344,6 +4371,22 @@ export function moveNodeBetweenDocuments(
|
|
|
4344
4371
|
): MoveNodeBetweenDocumentsResult {
|
|
4345
4372
|
const { nodeId, anchorNodeId, placement = "inside" } = opts;
|
|
4346
4373
|
|
|
4374
|
+
// A URL-backed (localhost/fusion) screen stores its route URL as content,
|
|
4375
|
+
// not a document. Both branches below end in string concatenation against
|
|
4376
|
+
// `destHtml`, so a URL destination yields "http://host/<div …>" — a screen
|
|
4377
|
+
// permanently unbound from the running app, with no parse error anywhere.
|
|
4378
|
+
// Refusing HERE and not only at the persist gate matters: callers move
|
|
4379
|
+
// several files in one gesture and write the source screens first, so a
|
|
4380
|
+
// late refusal would delete the node from its source and land it nowhere.
|
|
4381
|
+
if (isStandaloneHttpUrl(destHtml) || isStandaloneHttpUrl(sourceHtml)) {
|
|
4382
|
+
return {
|
|
4383
|
+
sourceHtml,
|
|
4384
|
+
destHtml,
|
|
4385
|
+
status: "unsupported",
|
|
4386
|
+
message: URL_BACKED_SCREEN_EDIT_REFUSAL,
|
|
4387
|
+
};
|
|
4388
|
+
}
|
|
4389
|
+
|
|
4347
4390
|
// --- Locate the node in sourceHtml ---
|
|
4348
4391
|
const sourceElements = parseHtmlElements(sourceHtml);
|
|
4349
4392
|
const sourceTarget = sourceElements.find(
|
|
@@ -1,3 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A URL-backed screen's `design_files.content` is the route URL itself, not a
|
|
3
|
+
* document. Any transform that parses stored content as HTML must refuse this
|
|
4
|
+
* shape: `DOMParser` happily turns the URL into body text, so the "edited"
|
|
5
|
+
* document that comes back out has silently replaced the route.
|
|
6
|
+
*
|
|
7
|
+
* Lives in `shared/` so the server write path and `code-layer`'s document
|
|
8
|
+
* transforms can reach the same predicate the editor uses — there must never
|
|
9
|
+
* be a second one to keep in step.
|
|
10
|
+
*/
|
|
11
|
+
export function isStandaloneHttpUrl(value: string): boolean {
|
|
12
|
+
const trimmed = value.trim();
|
|
13
|
+
// `new URL()` alone is not enough: the WHATWG parser strips newlines and
|
|
14
|
+
// percent-encodes spaces and markup rather than failing, so it accepts
|
|
15
|
+
// `http://localhost:8210/<div …>` — precisely the corrupted "route with a
|
|
16
|
+
// serialized subtree glued on" shape this predicate must call NOT a URL.
|
|
17
|
+
if (/[\s<>]/.test(trimmed)) return false;
|
|
18
|
+
if (!/^https?:\/\//i.test(trimmed)) return false;
|
|
19
|
+
try {
|
|
20
|
+
const parsed = new URL(trimmed);
|
|
21
|
+
return parsed.protocol === "http:" || parsed.protocol === "https:";
|
|
22
|
+
} catch {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
1
27
|
export function isProbablyHtmlDocumentContent(content: string): boolean {
|
|
2
28
|
const trimmed = content.trimStart();
|
|
3
29
|
if (!trimmed) return true;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { isStandaloneHttpUrl } from "./html-content.js";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Stable error code shared by browser and server write paths. Keep this value
|
|
3
5
|
* transport-safe: action errors may preserve either `code` or only `message`.
|
|
@@ -24,7 +26,8 @@ export type DesignHtmlIntegrityIssue =
|
|
|
24
26
|
| "element-unclosed"
|
|
25
27
|
| "close-tag-orphaned"
|
|
26
28
|
| "content-truncated"
|
|
27
|
-
| "runtime-missing"
|
|
29
|
+
| "runtime-missing"
|
|
30
|
+
| "url-backed-screen-replaced";
|
|
28
31
|
|
|
29
32
|
/**
|
|
30
33
|
* Reporting the symptom instead of the cause sends the fix to the wrong line:
|
|
@@ -74,6 +77,8 @@ const DOCUMENT_SHAPE_MESSAGES: Partial<
|
|
|
74
77
|
"an editor-managed <style>/<script> marker is no longer attached to its element — it was likely split by a partial edit",
|
|
75
78
|
"managed-marker-duplicated":
|
|
76
79
|
"an editor-managed <style>/<script> block appears more than once; there must be exactly one of each",
|
|
80
|
+
"url-backed-screen-replaced":
|
|
81
|
+
"this screen's content is its live route URL, and the write would replace it with document markup — that permanently unbinds the screen from the running app. Edit the app's own source instead",
|
|
77
82
|
};
|
|
78
83
|
|
|
79
84
|
export function describeDesignHtmlIntegrityIssue(
|
|
@@ -907,6 +912,21 @@ export function assertDesignHtmlEditIntegrity(args: {
|
|
|
907
912
|
fileType: string;
|
|
908
913
|
filename?: string;
|
|
909
914
|
}): void {
|
|
915
|
+
// Checked before the fileType gate and before any document-shape reasoning:
|
|
916
|
+
// a URL-backed screen's stored content is a route, not markup, so none of
|
|
917
|
+
// the rules below can see the damage. Concatenating a serialized subtree
|
|
918
|
+
// onto the route still parses as a URL to `new URL()` and still balances as
|
|
919
|
+
// a fragment, so every other pass here says "valid" while the screen's live
|
|
920
|
+
// binding is destroyed for good. Re-pointing the route (URL -> URL) stays
|
|
921
|
+
// allowed; only URL -> markup is the one-way door.
|
|
922
|
+
if (
|
|
923
|
+
isStandaloneHttpUrl(args.previousContent) &&
|
|
924
|
+
!isStandaloneHttpUrl(args.nextContent)
|
|
925
|
+
) {
|
|
926
|
+
throw new DesignHtmlIntegrityError("url-backed-screen-replaced", {
|
|
927
|
+
filename: args.filename,
|
|
928
|
+
});
|
|
929
|
+
}
|
|
910
930
|
if (args.fileType.toLowerCase() !== "html") return;
|
|
911
931
|
const previousIsDocument = isDocumentHtml(args.previousContent);
|
|
912
932
|
const nextIsDocument = isDocumentHtml(args.nextContent);
|
|
@@ -1,8 +1,16 @@
|
|
|
1
|
+
import type { SourcePositionPrecision } from "./source-mode.js";
|
|
1
2
|
import { previewSourceDiff } from "./source-workspace.js";
|
|
2
3
|
|
|
3
4
|
export interface LocalJsxSourceAnchor {
|
|
4
5
|
line: number;
|
|
5
6
|
column: number;
|
|
7
|
+
/**
|
|
8
|
+
* Whether line/column are authored coordinates. A "transformed" anchor is a
|
|
9
|
+
* position in the dev server's output (React 19's only tier), so seeking to
|
|
10
|
+
* it in the authored file lands on an unrelated line — usually no JSX at all,
|
|
11
|
+
* but occasionally the wrong element, which would edit silently.
|
|
12
|
+
*/
|
|
13
|
+
positionPrecision?: SourcePositionPrecision;
|
|
6
14
|
runtimeMultiplicity?: number;
|
|
7
15
|
scope?:
|
|
8
16
|
| "single-instance"
|
|
@@ -195,6 +203,13 @@ export function planLocalJsxVisualEdit(args: {
|
|
|
195
203
|
intent: LocalJsxLeafIntent;
|
|
196
204
|
}): LocalJsxVisualEditResult {
|
|
197
205
|
const { content, anchor, intent } = args;
|
|
206
|
+
if (anchor.positionPrecision === "transformed") {
|
|
207
|
+
return fail(
|
|
208
|
+
content,
|
|
209
|
+
"needsAgent",
|
|
210
|
+
"The source anchor's line and column are the dev server's transformed coordinates (React 19 exposes no authored position), so they cannot be seeked in the authored file.",
|
|
211
|
+
);
|
|
212
|
+
}
|
|
198
213
|
if (
|
|
199
214
|
(anchor.runtimeMultiplicity ?? 1) !== 1 ||
|
|
200
215
|
anchor.scope === "repeated-render" ||
|
|
@@ -57,10 +57,86 @@ export const DESIGN_SOURCE_TYPES = ["inline", "localhost", "fusion"] as const;
|
|
|
57
57
|
* read (same-origin policy), and inline screens may not carry these attrs.
|
|
58
58
|
*/
|
|
59
59
|
export interface ElementProvenance {
|
|
60
|
+
/** Runtime/compiler family that exposed this location. */
|
|
61
|
+
framework?: ElementProvenanceFramework;
|
|
60
62
|
sourceFile?: string;
|
|
61
63
|
line?: number;
|
|
62
64
|
column?: number;
|
|
63
65
|
component?: string;
|
|
66
|
+
/**
|
|
67
|
+
* Where the nearest enclosing component was instantiated (`<Card …>` in the
|
|
68
|
+
* parent), as opposed to the element's own authoring site above. All
|
|
69
|
+
* `.map()`-produced siblings share one owner site, so `ownerKey` — their
|
|
70
|
+
* React key — is the only source-derived signal that separates them.
|
|
71
|
+
*/
|
|
72
|
+
ownerSourceFile?: string;
|
|
73
|
+
ownerLine?: number;
|
|
74
|
+
ownerColumn?: number;
|
|
75
|
+
ownerComponentName?: string;
|
|
76
|
+
ownerKey?: string;
|
|
77
|
+
/**
|
|
78
|
+
* Which tier produced `line`/`column`. Absent means the tier was never
|
|
79
|
+
* reported, which is NOT the same as authored — see
|
|
80
|
+
* `sourcePositionPrecision`.
|
|
81
|
+
*/
|
|
82
|
+
method?: ElementProvenanceMethod;
|
|
83
|
+
/**
|
|
84
|
+
* Which tier produced `ownerLine`/`ownerColumn`. Separate from `method`
|
|
85
|
+
* because the two tiers routinely differ: a source plugin stamps an
|
|
86
|
+
* authored `data-attribute` position on the element while the owner site is
|
|
87
|
+
* only reachable through a React 19 owner stack (transformed).
|
|
88
|
+
*/
|
|
89
|
+
ownerMethod?: ElementProvenanceMethod;
|
|
90
|
+
/**
|
|
91
|
+
* Set when the element resolved to NO location, so callers can tell "this
|
|
92
|
+
* app never exposes source locations" from "the runtime has not reported
|
|
93
|
+
* yet". Never set alongside a resolved `sourceFile`.
|
|
94
|
+
*/
|
|
95
|
+
unavailableReason?: ElementProvenanceUnavailableReason;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export type ElementProvenanceUnavailableReason =
|
|
99
|
+
| "not-framework"
|
|
100
|
+
| "not-react" // legacy bridge payload
|
|
101
|
+
| "no-debug-info";
|
|
102
|
+
|
|
103
|
+
/** Which tier produced a provenance position. */
|
|
104
|
+
export type ElementProvenanceMethod =
|
|
105
|
+
| "data-attribute" // build-time transform's data-source-*/data-loc attributes
|
|
106
|
+
| "debug-source" // React <=18 structured `_debugSource` fiber field
|
|
107
|
+
| "debug-stack" // React 19 `_debugStack` owner stack
|
|
108
|
+
| "vue-inspector" // Vue dev compiler's `__v_inspector` vnode prop
|
|
109
|
+
| "svelte-meta"; // Svelte dev compiler's `__svelte_meta.loc`
|
|
110
|
+
|
|
111
|
+
export type ElementProvenanceFramework = "html" | "react" | "vue" | "svelte";
|
|
112
|
+
|
|
113
|
+
export const ELEMENT_PROVENANCE_METHODS: readonly ElementProvenanceMethod[] = [
|
|
114
|
+
"data-attribute",
|
|
115
|
+
"debug-source",
|
|
116
|
+
"debug-stack",
|
|
117
|
+
"vue-inspector",
|
|
118
|
+
"svelte-meta",
|
|
119
|
+
];
|
|
120
|
+
|
|
121
|
+
export type SourcePositionPrecision = "authored" | "transformed" | "unknown";
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* React 19 deleted `_debugSource`, and its `jsxDEV` drops the authored
|
|
125
|
+
* `__source` argument the dev transform still emits, so the only surviving
|
|
126
|
+
* position is a `_debugStack` frame — a position in the file the dev server
|
|
127
|
+
* SERVES. Under any transforming dev server that is the transformed line, not
|
|
128
|
+
* the authored one: measured on the React 19.2 + Vite 8 target, `<h1>`
|
|
129
|
+
* authored at line 13 reports as line 26.
|
|
130
|
+
*
|
|
131
|
+
* So a `debug-stack` position must never be presented as the authored JSX
|
|
132
|
+
* line, and deterministic writers must not seek to it. `unknown` (no tier
|
|
133
|
+
* reported) is deliberately not folded into `authored`.
|
|
134
|
+
*/
|
|
135
|
+
export function sourcePositionPrecision(
|
|
136
|
+
method: ElementProvenanceMethod | undefined,
|
|
137
|
+
): SourcePositionPrecision {
|
|
138
|
+
if (method === "debug-stack") return "transformed";
|
|
139
|
+
return method ? "authored" : "unknown";
|
|
64
140
|
}
|
|
65
141
|
|
|
66
142
|
export function parseDataLocProvenance(
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
getRequestUserEmail,
|
|
13
13
|
} from "@agent-native/core/server";
|
|
14
14
|
import { getSetting } from "@agent-native/core/settings";
|
|
15
|
+
import { ForbiddenError } from "@agent-native/core/sharing";
|
|
15
16
|
import {
|
|
16
17
|
getUsageSummary,
|
|
17
18
|
usageBillingForEngine,
|
|
@@ -350,7 +351,7 @@ async function assertCanViewMetrics(): Promise<{
|
|
|
350
351
|
if (!orgId) {
|
|
351
352
|
return { viewerEmail, orgId, role };
|
|
352
353
|
}
|
|
353
|
-
throw new
|
|
354
|
+
throw new ForbiddenError(
|
|
354
355
|
"Only organization owners and admins can view workspace usage metrics.",
|
|
355
356
|
);
|
|
356
357
|
}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { injectDocumentMarkup } from "@agent-native/core/shared";
|
|
2
|
+
|
|
1
3
|
import type { PlanAnnotationAnchor } from "@/lib/plan-native-anchors";
|
|
2
4
|
|
|
3
5
|
export type PreferredEditor =
|
|
@@ -1418,10 +1420,7 @@ export function injectAnnotationRuntime(input: {
|
|
|
1418
1420
|
}, true);
|
|
1419
1421
|
})();
|
|
1420
1422
|
</script>`;
|
|
1421
|
-
|
|
1422
|
-
return html.replace("</body>", `${runtime}</body>`);
|
|
1423
|
-
}
|
|
1424
|
-
return `${html}${runtime}`;
|
|
1423
|
+
return injectDocumentMarkup(html, runtime);
|
|
1425
1424
|
}
|
|
1426
1425
|
|
|
1427
1426
|
function escapeRuntimeJsString(value: string) {
|
|
@@ -5,6 +5,7 @@ import {
|
|
|
5
5
|
import { createH3SSRHandler } from "@agent-native/core/server/ssr-handler";
|
|
6
6
|
import {
|
|
7
7
|
buildAgentReadableResourceDiscovery,
|
|
8
|
+
injectDocumentMarkup,
|
|
8
9
|
renderAgentReadableResourceDiscoveryScript,
|
|
9
10
|
} from "@agent-native/core/shared";
|
|
10
11
|
import {
|
|
@@ -58,11 +59,7 @@ function queryString(value: unknown): string {
|
|
|
58
59
|
|
|
59
60
|
function injectScript(html: string, script: string): string {
|
|
60
61
|
if (html.includes("agent-native-plan-agent-context")) return html;
|
|
61
|
-
|
|
62
|
-
return html.replace("</head>", `${script}</head>`);
|
|
63
|
-
if (html.includes("</body>"))
|
|
64
|
-
return html.replace("</body>", `${script}</body>`);
|
|
65
|
-
return `${html}${script}`;
|
|
62
|
+
return injectDocumentMarkup(html, script, { target: "head" });
|
|
66
63
|
}
|
|
67
64
|
|
|
68
65
|
export default defineEventHandler(async (event) => {
|
|
@@ -289,6 +289,30 @@ export function applyOperation(deck: any, op: Operation): void {
|
|
|
289
289
|
}
|
|
290
290
|
}
|
|
291
291
|
|
|
292
|
+
/**
|
|
293
|
+
* Resolve the last operation in a sequence. For example, when typing a new name
|
|
294
|
+
* this will be the latest name of the deck in a sequence of keystrokes.
|
|
295
|
+
*/
|
|
296
|
+
export function resolveDeckColumnUpdates(
|
|
297
|
+
current: { title: string; designSystemId: string | null },
|
|
298
|
+
operations: Operation[],
|
|
299
|
+
): { title: string; designSystemId: string | null } {
|
|
300
|
+
const fieldOps = operations
|
|
301
|
+
.filter(
|
|
302
|
+
(op): op is z.infer<typeof PatchDeckFieldsOp> =>
|
|
303
|
+
op.op === "patch-deck-fields",
|
|
304
|
+
)
|
|
305
|
+
.reverse();
|
|
306
|
+
const titleOp = fieldOps.find((op) => typeof op.fields.title === "string");
|
|
307
|
+
const dsOp = fieldOps.find((op) => "designSystemId" in op.fields);
|
|
308
|
+
return {
|
|
309
|
+
title: titleOp?.fields.title ?? current.title,
|
|
310
|
+
designSystemId: dsOp
|
|
311
|
+
? (dsOp.fields.designSystemId ?? null)
|
|
312
|
+
: current.designSystemId,
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
|
|
292
316
|
// ---------------------------------------------------------------------------
|
|
293
317
|
// Action definition
|
|
294
318
|
// ---------------------------------------------------------------------------
|
|
@@ -342,23 +366,11 @@ export default defineAction({
|
|
|
342
366
|
const now = new Date().toISOString();
|
|
343
367
|
deck.updatedAt = now;
|
|
344
368
|
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
);
|
|
351
|
-
const sqlTitle = titleOp?.fields.title ?? row.title;
|
|
352
|
-
|
|
353
|
-
// For patch-deck-fields ops that include designSystemId, update the
|
|
354
|
-
// SQL designSystemId column (used by list queries and sharing checks).
|
|
355
|
-
const dsOp = operations.find(
|
|
356
|
-
(op): op is z.infer<typeof PatchDeckFieldsOp> =>
|
|
357
|
-
op.op === "patch-deck-fields" && "designSystemId" in op.fields,
|
|
358
|
-
);
|
|
359
|
-
const sqlDesignSystemId = dsOp
|
|
360
|
-
? (dsOp.fields.designSystemId ?? null)
|
|
361
|
-
: row.designSystemId;
|
|
369
|
+
const { title: sqlTitle, designSystemId: sqlDesignSystemId } =
|
|
370
|
+
resolveDeckColumnUpdates(
|
|
371
|
+
{ title: row.title, designSystemId: row.designSystemId },
|
|
372
|
+
operations,
|
|
373
|
+
);
|
|
362
374
|
|
|
363
375
|
let generationRecord:
|
|
364
376
|
| {
|
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
# @agent-native/toolkit
|
|
2
2
|
|
|
3
|
+
## 0.10.12
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 279e855: Default MCP connections to personal OAuth, keep personal MCP setup available to organization members, hide unusable organization controls, and honor app preset filters in ejected UIs.
|
|
8
|
+
|
|
3
9
|
## 0.10.11
|
|
4
10
|
|
|
5
11
|
### Patch Changes
|