@agent-native/core 0.129.2 → 0.130.1
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/a2a-continuation-processor.ts +481 -122
- package/corpus/core/src/integrations/a2a-continuations-store.ts +345 -14
- package/corpus/core/src/integrations/adapters/slack.ts +243 -53
- package/corpus/core/src/integrations/google-docs-poller.ts +3 -0
- package/corpus/core/src/integrations/integration-campaign-recovery.ts +4 -1
- package/corpus/core/src/integrations/plugin.ts +39 -21
- package/corpus/core/src/integrations/task-queue-stats.ts +146 -0
- package/corpus/core/src/integrations/types.ts +25 -4
- package/corpus/core/src/integrations/webhook-handler.ts +46 -16
- package/corpus/core/src/jobs/scheduler.ts +4 -0
- package/corpus/core/src/localization/default-messages.ts +3 -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/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-26-slack-replies-recover-after-connected-app-updates.md +6 -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/.agents/skills/design-systems/SKILL.md +15 -0
- package/corpus/templates/slides/actions/delete-design-system.ts +145 -0
- package/corpus/templates/slides/actions/list-design-systems.ts +94 -2
- package/corpus/templates/slides/actions/patch-deck.ts +29 -17
- package/corpus/templates/slides/app/components/design-system/DesignSystemCard.tsx +43 -1
- package/corpus/templates/slides/app/hooks/use-design-systems.ts +2 -0
- package/corpus/templates/slides/app/i18n/en-US.ts +7 -0
- package/corpus/templates/slides/app/pages/DesignSystems.tsx +56 -1
- package/corpus/templates/slides/changelog/2026-07-28-delete-a-design-system-you-own-from-the-design-systems-page-.md +6 -0
- 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/struct-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/a2a-continuation-processor.d.ts +5 -0
- package/dist/integrations/a2a-continuation-processor.d.ts.map +1 -1
- package/dist/integrations/a2a-continuation-processor.js +293 -79
- package/dist/integrations/a2a-continuation-processor.js.map +1 -1
- package/dist/integrations/a2a-continuations-store.d.ts +23 -1
- package/dist/integrations/a2a-continuations-store.d.ts.map +1 -1
- package/dist/integrations/a2a-continuations-store.js +249 -15
- package/dist/integrations/a2a-continuations-store.js.map +1 -1
- package/dist/integrations/adapters/slack.d.ts.map +1 -1
- package/dist/integrations/adapters/slack.js +155 -31
- package/dist/integrations/adapters/slack.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/integration-campaign-recovery.d.ts.map +1 -1
- package/dist/integrations/integration-campaign-recovery.js +3 -1
- package/dist/integrations/integration-campaign-recovery.js.map +1 -1
- package/dist/integrations/plugin.d.ts.map +1 -1
- package/dist/integrations/plugin.js +29 -12
- package/dist/integrations/plugin.js.map +1 -1
- package/dist/integrations/task-queue-stats.d.ts +12 -0
- package/dist/integrations/task-queue-stats.d.ts.map +1 -1
- package/dist/integrations/task-queue-stats.js +106 -0
- package/dist/integrations/task-queue-stats.js.map +1 -1
- package/dist/integrations/types.d.ts +24 -6
- package/dist/integrations/types.d.ts.map +1 -1
- package/dist/integrations/types.js.map +1 -1
- package/dist/integrations/webhook-handler.d.ts.map +1 -1
- package/dist/integrations/webhook-handler.js +35 -14
- 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/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/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 +3 -4
- 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-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/a2a-continuation-processor.ts +481 -122
- package/src/integrations/a2a-continuations-store.ts +345 -14
- package/src/integrations/adapters/slack.ts +243 -53
- package/src/integrations/google-docs-poller.ts +3 -0
- package/src/integrations/integration-campaign-recovery.ts +4 -1
- package/src/integrations/plugin.ts +39 -21
- package/src/integrations/task-queue-stats.ts +146 -0
- package/src/integrations/types.ts +25 -4
- package/src/integrations/webhook-handler.ts +46 -16
- package/src/jobs/scheduler.ts +4 -0
- package/src/localization/default-messages.ts +3 -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
|
@@ -6,22 +6,26 @@
|
|
|
6
6
|
* grant (reads do not require user write consent, only editor access + a
|
|
7
7
|
* valid bridge connection):
|
|
8
8
|
* 1. assertAccess: the caller must have editor access to the design.
|
|
9
|
-
* 2. Bridge URL resolution: only the current user's own connection row
|
|
9
|
+
* 2. Bridge URL resolution: only the current user's own connection row, in
|
|
10
|
+
* the caller's own org scope. A miss throws a classified 4xx from
|
|
11
|
+
* server/lib/localhost-connection.ts so the client sees the actual
|
|
12
|
+
* condition instead of a generic 500.
|
|
10
13
|
* 3. Loopback check: bridgeUrl must resolve to localhost/127.0.0.1.
|
|
11
14
|
* 4. Bridge token: the connection's stored bridge token is sent as
|
|
12
15
|
* X-Bridge-Token so the bridge can reject unauthorized callers.
|
|
13
16
|
*/
|
|
14
17
|
|
|
15
18
|
import { defineAction } from "@agent-native/core";
|
|
16
|
-
import {
|
|
17
|
-
getRequestOrgId,
|
|
18
|
-
getRequestUserEmail,
|
|
19
|
-
} from "@agent-native/core/server/request-context";
|
|
20
19
|
import { assertAccess } from "@agent-native/core/sharing";
|
|
21
|
-
import { and, eq, isNull } from "drizzle-orm";
|
|
22
20
|
import { z } from "zod";
|
|
23
21
|
|
|
24
|
-
import {
|
|
22
|
+
import {
|
|
23
|
+
fetchLocalhostBridge,
|
|
24
|
+
localhostBridgeRequestError,
|
|
25
|
+
requireLocalhostBridgeToken,
|
|
26
|
+
resolveLocalhostBridgeConnection,
|
|
27
|
+
resolveLocalhostConnectionScope,
|
|
28
|
+
} from "../server/lib/localhost-connection.js";
|
|
25
29
|
|
|
26
30
|
function isLoopbackHostname(hostname: string): boolean {
|
|
27
31
|
const normalized = hostname.toLowerCase();
|
|
@@ -77,53 +81,25 @@ export default defineAction({
|
|
|
77
81
|
run: async ({ designId, connectionId }) => {
|
|
78
82
|
await assertAccess("design", designId, "editor");
|
|
79
83
|
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
const
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
})
|
|
90
|
-
.from(schema.designLocalhostConnections)
|
|
91
|
-
.where(
|
|
92
|
-
and(
|
|
93
|
-
eq(schema.designLocalhostConnections.id, connectionId),
|
|
94
|
-
eq(schema.designLocalhostConnections.ownerEmail, ownerEmail),
|
|
95
|
-
orgId
|
|
96
|
-
? eq(schema.designLocalhostConnections.orgId, orgId)
|
|
97
|
-
: isNull(schema.designLocalhostConnections.orgId),
|
|
98
|
-
),
|
|
99
|
-
)
|
|
100
|
-
.limit(1);
|
|
101
|
-
|
|
102
|
-
if (!connection?.bridgeUrl) {
|
|
103
|
-
throw new Error(
|
|
104
|
-
`No bridge URL found for connection "${connectionId}". ` +
|
|
105
|
-
"Ensure the design bridge is running (npx @agent-native/core@latest design connect).",
|
|
106
|
-
);
|
|
107
|
-
}
|
|
108
|
-
if (!connection.bridgeToken) {
|
|
109
|
-
throw new Error(
|
|
110
|
-
`No bridge token found for connection "${connectionId}". ` +
|
|
111
|
-
"Reconnect via npx @agent-native/core@latest design connect.",
|
|
112
|
-
);
|
|
113
|
-
}
|
|
84
|
+
const scope = await resolveLocalhostConnectionScope();
|
|
85
|
+
const connection = await resolveLocalhostBridgeConnection({
|
|
86
|
+
connectionId,
|
|
87
|
+
...scope,
|
|
88
|
+
});
|
|
89
|
+
const bridgeToken = requireLocalhostBridgeToken(
|
|
90
|
+
connectionId,
|
|
91
|
+
connection.bridgeToken,
|
|
92
|
+
);
|
|
114
93
|
|
|
115
|
-
const
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
"X-Bridge-Token": connection.bridgeToken,
|
|
121
|
-
},
|
|
122
|
-
body: JSON.stringify({}),
|
|
94
|
+
const res = await fetchLocalhostBridge({
|
|
95
|
+
bridgeUrl: normalizeBridgeUrl(connection.bridgeUrl),
|
|
96
|
+
operation: "list-files",
|
|
97
|
+
bridgeToken,
|
|
98
|
+
body: {},
|
|
123
99
|
});
|
|
124
100
|
if (!res.ok) {
|
|
125
101
|
const errText = await res.text().catch(() => res.statusText);
|
|
126
|
-
throw
|
|
102
|
+
throw localhostBridgeRequestError("list-files", res.status, errText);
|
|
127
103
|
}
|
|
128
104
|
const body = (await res.json()) as {
|
|
129
105
|
files?: Array<{ path: string; size: number }>;
|
|
@@ -1,12 +1,9 @@
|
|
|
1
1
|
import { defineAction } from "@agent-native/core";
|
|
2
|
-
import {
|
|
3
|
-
getRequestOrgId,
|
|
4
|
-
getRequestUserEmail,
|
|
5
|
-
} from "@agent-native/core/server/request-context";
|
|
6
2
|
import { and, desc, eq, isNull } from "drizzle-orm";
|
|
7
3
|
import { z } from "zod";
|
|
8
4
|
|
|
9
5
|
import { getDb, schema } from "../server/db/index.js";
|
|
6
|
+
import { resolveLocalhostConnectionScope } from "../server/lib/localhost-connection.js";
|
|
10
7
|
import type {
|
|
11
8
|
DesignBridgeCapability,
|
|
12
9
|
LocalhostDesignRouteManifest,
|
|
@@ -33,9 +30,7 @@ export default defineAction({
|
|
|
33
30
|
readOnly: true,
|
|
34
31
|
http: { method: "GET" },
|
|
35
32
|
run: async ({ id, status }) => {
|
|
36
|
-
const ownerEmail =
|
|
37
|
-
if (!ownerEmail) throw new Error("no authenticated user");
|
|
38
|
-
const orgId = getRequestOrgId() ?? null;
|
|
33
|
+
const { ownerEmail, orgId } = await resolveLocalhostConnectionScope();
|
|
39
34
|
const clauses = [
|
|
40
35
|
eq(schema.designLocalhostConnections.ownerEmail, ownerEmail),
|
|
41
36
|
orgId
|
|
@@ -31,6 +31,7 @@
|
|
|
31
31
|
|
|
32
32
|
import { defineAction } from "@agent-native/core";
|
|
33
33
|
import { seedFromText } from "@agent-native/core/collab";
|
|
34
|
+
import { injectDocumentMarkup } from "@agent-native/core/shared";
|
|
34
35
|
import { assertAccess } from "@agent-native/core/sharing";
|
|
35
36
|
import { and, eq } from "drizzle-orm";
|
|
36
37
|
import { nanoid } from "nanoid";
|
|
@@ -181,8 +182,7 @@ export default defineAction({
|
|
|
181
182
|
.map((entry) => boardObjectEntryToHtmlFragment(entry))
|
|
182
183
|
.join("\n");
|
|
183
184
|
|
|
184
|
-
|
|
185
|
-
boardHtml = boardHtml.replace("</body>", `${fragments}\n</body>`);
|
|
185
|
+
boardHtml = injectDocumentMarkup(boardHtml, `${fragments}\n`);
|
|
186
186
|
}
|
|
187
187
|
|
|
188
188
|
const now = new Date().toISOString();
|
|
@@ -1,6 +1,19 @@
|
|
|
1
|
+
import crypto from "node:crypto";
|
|
2
|
+
import path from "node:path";
|
|
3
|
+
|
|
1
4
|
import { defineAction, embedApp } from "@agent-native/core";
|
|
2
5
|
import { writeAppState } from "@agent-native/core/application-state";
|
|
3
|
-
import {
|
|
6
|
+
import {
|
|
7
|
+
buildDeepLink,
|
|
8
|
+
buildEmbedStartPath,
|
|
9
|
+
createEmbedSessionTicket,
|
|
10
|
+
} from "@agent-native/core/server";
|
|
11
|
+
import {
|
|
12
|
+
getRequestContext,
|
|
13
|
+
getRequestOrgId,
|
|
14
|
+
getRequestUserEmail,
|
|
15
|
+
runWithRequestContext,
|
|
16
|
+
} from "@agent-native/core/server/request-context";
|
|
4
17
|
import { eq } from "drizzle-orm";
|
|
5
18
|
import { z } from "zod";
|
|
6
19
|
|
|
@@ -166,13 +179,53 @@ function isLoopbackUrl(value: string): boolean {
|
|
|
166
179
|
);
|
|
167
180
|
}
|
|
168
181
|
|
|
169
|
-
|
|
182
|
+
const LOCAL_VISUAL_EDIT_TICKET_TTL_SECONDS = 5 * 60;
|
|
183
|
+
const LOCAL_VISUAL_EDIT_PRINCIPAL_DOMAIN =
|
|
184
|
+
"local.visual-edit.agent-native.invalid";
|
|
185
|
+
|
|
186
|
+
/**
|
|
187
|
+
* Stable owner partition for Design rows created by the local CLI skill when
|
|
188
|
+
* no account session exists. This value is never installed as a browser
|
|
189
|
+
* session; it only lets one trusted in-process `pnpm action` invocation compose
|
|
190
|
+
* the existing owner-scoped actions before minting a narrow embed capability.
|
|
191
|
+
*/
|
|
192
|
+
export function localVisualEditWorkspacePrincipal(
|
|
193
|
+
workspacePath = process.cwd(),
|
|
194
|
+
): string {
|
|
195
|
+
const workspaceId = crypto
|
|
196
|
+
.createHash("sha256")
|
|
197
|
+
.update(path.resolve(workspacePath))
|
|
198
|
+
.digest("hex")
|
|
199
|
+
.slice(0, 24);
|
|
200
|
+
return `workspace+${workspaceId}@${LOCAL_VISUAL_EDIT_PRINCIPAL_DOMAIN}`;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
function localVisualEditPath(designId: string): string {
|
|
204
|
+
return `/visual-edit/${encodeURIComponent(designId)}?editorView=overview`;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function localVisualEditDeepLink(designId: string): string {
|
|
170
208
|
return buildDeepLink({
|
|
171
209
|
app: "design",
|
|
172
210
|
view: "editor",
|
|
173
211
|
params: { designId, editorView: "overview" },
|
|
174
|
-
to:
|
|
212
|
+
to: localVisualEditPath(designId),
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
async function createCallerHandoff(
|
|
217
|
+
targetPath: string,
|
|
218
|
+
ownerEmail: string,
|
|
219
|
+
designId: string,
|
|
220
|
+
): Promise<string> {
|
|
221
|
+
const ticket = await createEmbedSessionTicket({
|
|
222
|
+
ownerEmail,
|
|
223
|
+
orgId: getRequestOrgId(),
|
|
224
|
+
targetPath,
|
|
225
|
+
scope: `capability:visual-edit:design:${encodeURIComponent(designId)}`,
|
|
226
|
+
ttlSeconds: LOCAL_VISUAL_EDIT_TICKET_TTL_SECONDS,
|
|
175
227
|
});
|
|
228
|
+
return buildEmbedStartPath(ticket.ticket);
|
|
176
229
|
}
|
|
177
230
|
|
|
178
231
|
function routeManifestFromScreens(args: {
|
|
@@ -211,7 +264,7 @@ function routeManifestFromScreens(args: {
|
|
|
211
264
|
|
|
212
265
|
export default defineAction({
|
|
213
266
|
description:
|
|
214
|
-
"Open or refresh a running localhost app in Design overview mode
|
|
267
|
+
"Open or refresh a running localhost app in Design overview mode without requiring a Design account login. Registers the local bridge, creates or reuses a design, places URL-backed screens, stores the active visual-edit context, and navigates the current Design session to the canvas. Use this from the local /visual-edit skill and for follow-up requests like adding a mobile-size screen.",
|
|
215
268
|
schema: z.object({
|
|
216
269
|
designId: z
|
|
217
270
|
.string()
|
|
@@ -310,153 +363,199 @@ export default defineAction({
|
|
|
310
363
|
height: 680,
|
|
311
364
|
}),
|
|
312
365
|
},
|
|
313
|
-
run: async (args) => {
|
|
366
|
+
run: async (args, ctx) => {
|
|
314
367
|
const devServerUrl = normalizeBaseUrl(args.devServerUrl);
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
368
|
+
const runForPrincipal = async () => {
|
|
369
|
+
const routeManifest = args.routeManifest
|
|
370
|
+
? {
|
|
371
|
+
...args.routeManifest,
|
|
372
|
+
devServerUrl: args.routeManifest.devServerUrl ?? devServerUrl,
|
|
373
|
+
rootPath: args.routeManifest.rootPath ?? args.rootPath,
|
|
374
|
+
}
|
|
375
|
+
: {
|
|
376
|
+
version: 1 as const,
|
|
377
|
+
sourceType: "localhost" as const,
|
|
378
|
+
devServerUrl,
|
|
379
|
+
rootPath: args.rootPath,
|
|
380
|
+
routes:
|
|
381
|
+
routeManifestFromScreens({
|
|
382
|
+
devServerUrl,
|
|
383
|
+
routes: args.routes,
|
|
384
|
+
paths: args.paths,
|
|
385
|
+
}) ?? [],
|
|
386
|
+
generatedAt: new Date().toISOString(),
|
|
387
|
+
};
|
|
388
|
+
const connection = await connectLocalhostAction.run({
|
|
389
|
+
// Let connect-localhost be the single source of truth for stable
|
|
390
|
+
// per-user/per-org id derivation. Duplicating it here can create a second
|
|
391
|
+
// tokenless row after the CLI self-registers the bridge token.
|
|
392
|
+
id: args.connectionId,
|
|
393
|
+
name: args.name,
|
|
394
|
+
devServerUrl,
|
|
395
|
+
bridgeUrl: args.bridgeUrl,
|
|
396
|
+
rootPath: routeManifest.rootPath ?? args.rootPath,
|
|
397
|
+
routeManifest,
|
|
398
|
+
capabilities: args.capabilities,
|
|
399
|
+
bridgeToken: args.bridgeToken,
|
|
400
|
+
previewToken: args.previewToken,
|
|
401
|
+
status: "connected",
|
|
402
|
+
});
|
|
403
|
+
|
|
404
|
+
let designId = args.designId;
|
|
405
|
+
let createdDesign = false;
|
|
406
|
+
let publicReadOnly = false;
|
|
407
|
+
if (!designId) {
|
|
408
|
+
const design = await createDesignAction.run({
|
|
409
|
+
title: args.title ?? `${new URL(devServerUrl).host} visual edit`,
|
|
410
|
+
description:
|
|
411
|
+
args.description ??
|
|
412
|
+
"URL-backed localhost screens prepared by visual-edit.",
|
|
413
|
+
projectType: "prototype",
|
|
414
|
+
});
|
|
415
|
+
designId = design.id;
|
|
416
|
+
createdDesign = true;
|
|
417
|
+
if (args.publicReadOnly && isLoopbackUrl(devServerUrl)) {
|
|
418
|
+
publicReadOnly = true;
|
|
419
|
+
await getDb()
|
|
420
|
+
.update(schema.designs)
|
|
421
|
+
.set({ visibility: "public" })
|
|
422
|
+
.where(eq(schema.designs.id, designId));
|
|
320
423
|
}
|
|
321
|
-
|
|
322
|
-
version: 1 as const,
|
|
323
|
-
sourceType: "localhost" as const,
|
|
324
|
-
devServerUrl,
|
|
325
|
-
rootPath: args.rootPath,
|
|
326
|
-
routes:
|
|
327
|
-
routeManifestFromScreens({
|
|
328
|
-
devServerUrl,
|
|
329
|
-
routes: args.routes,
|
|
330
|
-
paths: args.paths,
|
|
331
|
-
}) ?? [],
|
|
332
|
-
generatedAt: new Date().toISOString(),
|
|
333
|
-
};
|
|
334
|
-
const connection = await connectLocalhostAction.run({
|
|
335
|
-
// Let connect-localhost be the single source of truth for stable
|
|
336
|
-
// per-user/per-org id derivation. Duplicating it here can create a second
|
|
337
|
-
// tokenless row after the CLI self-registers the bridge token.
|
|
338
|
-
id: args.connectionId,
|
|
339
|
-
name: args.name,
|
|
340
|
-
devServerUrl,
|
|
341
|
-
bridgeUrl: args.bridgeUrl,
|
|
342
|
-
rootPath: routeManifest.rootPath ?? args.rootPath,
|
|
343
|
-
routeManifest,
|
|
344
|
-
capabilities: args.capabilities,
|
|
345
|
-
bridgeToken: args.bridgeToken,
|
|
346
|
-
previewToken: args.previewToken,
|
|
347
|
-
status: "connected",
|
|
348
|
-
});
|
|
424
|
+
}
|
|
349
425
|
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
.update(schema.designs)
|
|
367
|
-
.set({ visibility: "public" })
|
|
368
|
-
.where(eq(schema.designs.id, designId));
|
|
426
|
+
const viewports = resolveViewports(args.viewports);
|
|
427
|
+
const requestedRoutes = args.routes?.length
|
|
428
|
+
? args.routes
|
|
429
|
+
: args.paths?.length
|
|
430
|
+
? args.paths.map((path) => ({ path }))
|
|
431
|
+
: viewports
|
|
432
|
+
? routeManifest.routes.map((route) => ({
|
|
433
|
+
routeId: route.id,
|
|
434
|
+
path: route.path,
|
|
435
|
+
title: route.title,
|
|
436
|
+
}))
|
|
437
|
+
: undefined;
|
|
438
|
+
if (viewports && !requestedRoutes?.length) {
|
|
439
|
+
throw new Error(
|
|
440
|
+
"viewports needs at least one route: pass routes/paths, or connect a bridge whose manifest lists routes.",
|
|
441
|
+
);
|
|
369
442
|
}
|
|
370
|
-
}
|
|
371
443
|
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
444
|
+
const screens = await addLocalhostScreensAction.run({
|
|
445
|
+
designId,
|
|
446
|
+
connectionId: connection.id,
|
|
447
|
+
routes:
|
|
448
|
+
viewports && requestedRoutes
|
|
449
|
+
? expandRoutesAcrossViewports({
|
|
450
|
+
routes: requestedRoutes,
|
|
451
|
+
viewports,
|
|
452
|
+
startX: args.startX ?? 0,
|
|
453
|
+
startY: args.startY ?? 0,
|
|
454
|
+
gap: args.gap ?? 160,
|
|
455
|
+
})
|
|
456
|
+
: args.routes,
|
|
457
|
+
paths: viewports ? undefined : args.paths,
|
|
458
|
+
defaultWidth: args.defaultWidth,
|
|
459
|
+
defaultHeight: args.defaultHeight,
|
|
460
|
+
startX: args.startX,
|
|
461
|
+
startY: args.startY,
|
|
462
|
+
gap: args.gap,
|
|
463
|
+
});
|
|
389
464
|
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
})
|
|
402
|
-
: args.routes,
|
|
403
|
-
paths: viewports ? undefined : args.paths,
|
|
404
|
-
defaultWidth: args.defaultWidth,
|
|
405
|
-
defaultHeight: args.defaultHeight,
|
|
406
|
-
startX: args.startX,
|
|
407
|
-
startY: args.startY,
|
|
408
|
-
gap: args.gap,
|
|
409
|
-
});
|
|
465
|
+
const urlPath = localVisualEditPath(designId);
|
|
466
|
+
await writeAppState("visual-edit", {
|
|
467
|
+
designId,
|
|
468
|
+
connectionId: connection.id,
|
|
469
|
+
devServerUrl,
|
|
470
|
+
bridgeUrl: connection.bridgeUrl,
|
|
471
|
+
rootPath: connection.rootPath,
|
|
472
|
+
urlPath,
|
|
473
|
+
screens: screens.screens,
|
|
474
|
+
updatedAt: new Date().toISOString(),
|
|
475
|
+
});
|
|
410
476
|
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
rootPath: connection.rootPath,
|
|
420
|
-
urlPath,
|
|
421
|
-
screens: screens.screens,
|
|
422
|
-
updatedAt: new Date().toISOString(),
|
|
423
|
-
});
|
|
477
|
+
if (args.navigate) {
|
|
478
|
+
await navigateAction.run({
|
|
479
|
+
view: "editor",
|
|
480
|
+
designId,
|
|
481
|
+
editorView: "overview",
|
|
482
|
+
path: urlPath,
|
|
483
|
+
});
|
|
484
|
+
}
|
|
424
485
|
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
486
|
+
const ownerEmail = getRequestUserEmail();
|
|
487
|
+
if (!ownerEmail) {
|
|
488
|
+
throw new Error("visual-edit principal was not established");
|
|
489
|
+
}
|
|
490
|
+
const deepLink = localVisualEditDeepLink(designId);
|
|
491
|
+
const embedStartUrl = isLoopbackUrl(devServerUrl)
|
|
492
|
+
? await createCallerHandoff(urlPath, ownerEmail, designId)
|
|
493
|
+
: undefined;
|
|
494
|
+
|
|
495
|
+
const result = {
|
|
428
496
|
designId,
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
497
|
+
connectionId: connection.id,
|
|
498
|
+
createdDesign,
|
|
499
|
+
publicReadOnly,
|
|
500
|
+
devServerUrl,
|
|
501
|
+
bridgeUrl: connection.bridgeUrl,
|
|
502
|
+
rootPath: connection.rootPath,
|
|
503
|
+
screenCount: screens.screenCount,
|
|
504
|
+
screens: screens.screens,
|
|
505
|
+
placedFrames: screens.placedFrames,
|
|
506
|
+
overview: true,
|
|
507
|
+
urlPath,
|
|
508
|
+
// Safe for model-visible action text and retained links. The MCP App
|
|
509
|
+
// receives the one-time launcher separately through hidden metadata.
|
|
510
|
+
openUrl: deepLink,
|
|
511
|
+
// Minted/stored by connect-localhost; the skill starts the bridge with
|
|
512
|
+
// `design connect --bridge-token <this>` so bridge and row agree.
|
|
513
|
+
bridgeToken: connection.bridgeToken,
|
|
514
|
+
previewToken: connection.previewToken,
|
|
515
|
+
};
|
|
516
|
+
if (embedStartUrl) {
|
|
517
|
+
// Trusted hosts and the CLI runner read this property directly. Keeping
|
|
518
|
+
// it non-enumerable prevents generic object/string serialization from
|
|
519
|
+
// copying the single-use bearer into model-visible action output.
|
|
520
|
+
Object.defineProperty(result, "embedStartUrl", {
|
|
521
|
+
value: embedStartUrl,
|
|
522
|
+
enumerable: false,
|
|
523
|
+
});
|
|
524
|
+
}
|
|
525
|
+
return result as typeof result & { embedStartUrl?: string };
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
if (getRequestUserEmail()) return runForPrincipal();
|
|
529
|
+
if (ctx?.caller !== "cli" || !isLoopbackUrl(devServerUrl)) {
|
|
530
|
+
throw new Error(
|
|
531
|
+
"Signed-out visual-edit is available only through the local CLI for a loopback app.",
|
|
532
|
+
);
|
|
533
|
+
}
|
|
534
|
+
if (args.publicReadOnly === false) {
|
|
535
|
+
throw new Error(
|
|
536
|
+
"Signed-out local visual-edit requires publicReadOnly so the resource can be opened through its narrow editor capability. Sign in to create a private Design resource.",
|
|
537
|
+
);
|
|
432
538
|
}
|
|
433
539
|
|
|
434
|
-
return
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
screenCount: screens.screenCount,
|
|
443
|
-
screens: screens.screens,
|
|
444
|
-
placedFrames: screens.placedFrames,
|
|
445
|
-
overview: true,
|
|
446
|
-
urlPath,
|
|
447
|
-
openUrl: designOverviewDeepLink(designId),
|
|
448
|
-
// Minted/stored by connect-localhost; the skill starts the bridge with
|
|
449
|
-
// `design connect --bridge-token <this>` so bridge and row agree.
|
|
450
|
-
bridgeToken: connection.bridgeToken,
|
|
451
|
-
previewToken: connection.previewToken,
|
|
452
|
-
};
|
|
540
|
+
return runWithRequestContext(
|
|
541
|
+
{
|
|
542
|
+
...(getRequestContext() ?? {}),
|
|
543
|
+
userEmail: localVisualEditWorkspacePrincipal(),
|
|
544
|
+
orgId: undefined,
|
|
545
|
+
},
|
|
546
|
+
runForPrincipal,
|
|
547
|
+
);
|
|
453
548
|
},
|
|
454
549
|
link: ({ result }) => {
|
|
455
550
|
if (!result || typeof result !== "object") return null;
|
|
456
|
-
const designId =
|
|
551
|
+
const { designId } = result as {
|
|
552
|
+
designId?: string;
|
|
553
|
+
};
|
|
457
554
|
if (!designId) return null;
|
|
458
555
|
return {
|
|
459
|
-
|
|
556
|
+
// The single-use embed ticket stays in MCP result metadata. Keep the
|
|
557
|
+
// model-visible link credential-free.
|
|
558
|
+
url: localVisualEditDeepLink(designId),
|
|
460
559
|
label: "Open overview",
|
|
461
560
|
view: "editor",
|
|
462
561
|
};
|
|
@@ -6,7 +6,10 @@
|
|
|
6
6
|
* grant (reads do not require user write consent, only editor access + a
|
|
7
7
|
* valid bridge connection):
|
|
8
8
|
* 1. assertAccess: the caller must have editor access to the design.
|
|
9
|
-
* 2. Bridge URL resolution: only the current user's own connection row
|
|
9
|
+
* 2. Bridge URL resolution: only the current user's own connection row, in
|
|
10
|
+
* the caller's own org scope. A miss throws a classified 4xx from
|
|
11
|
+
* server/lib/localhost-connection.ts so the client sees the actual
|
|
12
|
+
* condition instead of a generic 500.
|
|
10
13
|
* 3. Loopback check: bridgeUrl must resolve to localhost/127.0.0.1.
|
|
11
14
|
* 4. Bridge token: the connection's stored bridge token is sent as
|
|
12
15
|
* X-Bridge-Token so the bridge can reject unauthorized callers. The
|
|
@@ -15,15 +18,16 @@
|
|
|
15
18
|
*/
|
|
16
19
|
|
|
17
20
|
import { defineAction } from "@agent-native/core";
|
|
18
|
-
import {
|
|
19
|
-
getRequestOrgId,
|
|
20
|
-
getRequestUserEmail,
|
|
21
|
-
} from "@agent-native/core/server/request-context";
|
|
22
21
|
import { assertAccess } from "@agent-native/core/sharing";
|
|
23
|
-
import { and, eq, isNull } from "drizzle-orm";
|
|
24
22
|
import { z } from "zod";
|
|
25
23
|
|
|
26
|
-
import {
|
|
24
|
+
import {
|
|
25
|
+
fetchLocalhostBridge,
|
|
26
|
+
localhostBridgeRequestError,
|
|
27
|
+
requireLocalhostBridgeToken,
|
|
28
|
+
resolveLocalhostBridgeConnection,
|
|
29
|
+
resolveLocalhostConnectionScope,
|
|
30
|
+
} from "../server/lib/localhost-connection.js";
|
|
27
31
|
|
|
28
32
|
function isLoopbackHostname(hostname: string): boolean {
|
|
29
33
|
const normalized = hostname.toLowerCase();
|
|
@@ -81,53 +85,25 @@ export default defineAction({
|
|
|
81
85
|
run: async ({ designId, connectionId, path: relPath }) => {
|
|
82
86
|
await assertAccess("design", designId, "editor");
|
|
83
87
|
|
|
84
|
-
const
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
})
|
|
94
|
-
.from(schema.designLocalhostConnections)
|
|
95
|
-
.where(
|
|
96
|
-
and(
|
|
97
|
-
eq(schema.designLocalhostConnections.id, connectionId),
|
|
98
|
-
eq(schema.designLocalhostConnections.ownerEmail, ownerEmail),
|
|
99
|
-
orgId
|
|
100
|
-
? eq(schema.designLocalhostConnections.orgId, orgId)
|
|
101
|
-
: isNull(schema.designLocalhostConnections.orgId),
|
|
102
|
-
),
|
|
103
|
-
)
|
|
104
|
-
.limit(1);
|
|
105
|
-
|
|
106
|
-
if (!connection?.bridgeUrl) {
|
|
107
|
-
throw new Error(
|
|
108
|
-
`No bridge URL found for connection "${connectionId}". ` +
|
|
109
|
-
"Ensure the design bridge is running (npx @agent-native/core@latest design connect).",
|
|
110
|
-
);
|
|
111
|
-
}
|
|
112
|
-
if (!connection.bridgeToken) {
|
|
113
|
-
throw new Error(
|
|
114
|
-
`No bridge token found for connection "${connectionId}". ` +
|
|
115
|
-
"Reconnect via npx @agent-native/core@latest design connect.",
|
|
116
|
-
);
|
|
117
|
-
}
|
|
88
|
+
const scope = await resolveLocalhostConnectionScope();
|
|
89
|
+
const connection = await resolveLocalhostBridgeConnection({
|
|
90
|
+
connectionId,
|
|
91
|
+
...scope,
|
|
92
|
+
});
|
|
93
|
+
const bridgeToken = requireLocalhostBridgeToken(
|
|
94
|
+
connectionId,
|
|
95
|
+
connection.bridgeToken,
|
|
96
|
+
);
|
|
118
97
|
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
"X-Bridge-Token": connection.bridgeToken,
|
|
125
|
-
},
|
|
126
|
-
body: JSON.stringify({ relPath }),
|
|
98
|
+
const res = await fetchLocalhostBridge({
|
|
99
|
+
bridgeUrl: normalizeBridgeUrl(connection.bridgeUrl),
|
|
100
|
+
operation: "read-file",
|
|
101
|
+
bridgeToken,
|
|
102
|
+
body: { relPath },
|
|
127
103
|
});
|
|
128
104
|
if (!res.ok) {
|
|
129
105
|
const errText = await res.text().catch(() => res.statusText);
|
|
130
|
-
throw
|
|
106
|
+
throw localhostBridgeRequestError("read-file", res.status, errText);
|
|
131
107
|
}
|
|
132
108
|
const body = (await res.json()) as {
|
|
133
109
|
content?: string;
|