@1agh/maude 2.0.8 → 2.1.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/README.md +2 -1
- package/apps/hub/src/project-transactions/kernel.mjs +13 -7
- package/apps/studio/access/closure.ts +86 -10
- package/apps/studio/access/filters.ts +18 -1
- package/apps/studio/access/request.ts +8 -0
- package/apps/studio/acp/design-write-verb.ts +12 -2
- package/apps/studio/acp/env.ts +7 -2
- package/apps/studio/acp/index.ts +15 -4
- package/apps/studio/acp/login-state.ts +22 -5
- package/apps/studio/acp/may-scope.ts +38 -1
- package/apps/studio/acp/plugin-bootstrap.ts +13 -1
- package/apps/studio/acp/probe.ts +11 -4
- package/apps/studio/actions/agents.ts +110 -28
- package/apps/studio/actions/canvas-keys.ts +4 -2
- package/apps/studio/actions/ctx.ts +3 -0
- package/apps/studio/actions/defs/annotation.ts +84 -2
- package/apps/studio/actions/defs/app.ts +28 -1
- package/apps/studio/actions/defs/edit.ts +13 -0
- package/apps/studio/actions/defs/export.ts +12 -0
- package/apps/studio/actions/defs/sync.ts +18 -0
- package/apps/studio/actions/defs/video.ts +9 -0
- package/apps/studio/actions/documents.ts +6 -1
- package/apps/studio/actions/keymap.gen.ts +147 -9
- package/apps/studio/actions/menu.ts +5 -1
- package/apps/studio/actions/types.ts +4 -2
- package/apps/studio/actions/verbs.ts +9 -0
- package/apps/studio/actions.manifest.json +300 -45
- package/apps/studio/actions.parity.json +19 -1
- package/apps/studio/ai/save-hold.ts +2 -1
- package/apps/studio/ai/write-claim-scope.ts +7 -1
- package/apps/studio/ai/write-claim.ts +154 -3
- package/apps/studio/annotations/ai-read.ts +42 -6
- package/apps/studio/annotations/ai-write.ts +145 -2
- package/apps/studio/annotations/board-ops.ts +34 -3
- package/apps/studio/annotations/checklist-ops.ts +374 -0
- package/apps/studio/annotations/elements/checkitem.model.ts +129 -0
- package/apps/studio/annotations/elements/sticky.model.ts +54 -2
- package/apps/studio/annotations/ops.ts +30 -0
- package/apps/studio/annotations/registry.ts +9 -1
- package/apps/studio/annotations/templates.ts +4 -2
- package/apps/studio/annotations/text-steps.ts +114 -10
- package/apps/studio/annotations/ui/checklist-wire.ts +129 -0
- package/apps/studio/annotations/ui/checklist.tsx +429 -0
- package/apps/studio/annotations/ui/element-node.tsx +48 -2
- package/apps/studio/annotations/ui/template-place.ts +11 -1
- package/apps/studio/annotations/v1-adapter.ts +22 -3
- package/apps/studio/annotations-context-toolbar.tsx +12 -0
- package/apps/studio/annotations-layer.tsx +442 -49
- package/apps/studio/annotations-model.ts +4 -2
- package/apps/studio/api.ts +148 -21
- package/apps/studio/artboard-live-gate.tsx +54 -17
- package/apps/studio/artboard-still-persist.ts +166 -0
- package/apps/studio/artboard-still-raster.ts +6 -2
- package/apps/studio/artboard-still.ts +390 -20
- package/apps/studio/asset-added.ts +154 -0
- package/apps/studio/asset-details.ts +46 -3
- package/apps/studio/asset-origins.ts +5 -3
- package/apps/studio/asset-trash.ts +6 -1
- package/apps/studio/bin/_agent-browser-safe.mjs +3 -4
- package/apps/studio/bin/_annotate-post.mjs +14 -5
- package/apps/studio/bin/_audio-search.mjs +8 -2
- package/apps/studio/bin/_curl-local.mjs +7 -4
- package/apps/studio/bin/_desktop-locate.sh +145 -0
- package/apps/studio/bin/_ds-check-live.mjs +2 -1
- package/apps/studio/bin/_exports.mjs +38 -2
- package/apps/studio/bin/_history.mjs +79 -8
- package/apps/studio/bin/_import-asset.mjs +14 -9
- package/apps/studio/bin/_import-figma.mjs +510 -98
- package/apps/studio/bin/_index-cli.mjs +10 -21
- package/apps/studio/bin/_ingest-footage.mjs +24 -6
- package/apps/studio/bin/_media-probe.mjs +232 -0
- package/apps/studio/bin/_perf-probe-open.mjs +6 -0
- package/apps/studio/bin/_perf-probe-safari.mjs +6 -0
- package/apps/studio/bin/_perf-probe-studio.mjs +6 -1
- package/apps/studio/bin/_perf-probe.mjs +8 -3
- package/apps/studio/bin/_perf-sweep-shared.mjs +789 -0
- package/apps/studio/bin/_perf-sweep.mjs +240 -0
- package/apps/studio/bin/_record-shot.sh +33 -8
- package/apps/studio/bin/_screenshot-playwright.mjs +45 -2
- package/apps/studio/bin/_studio-verb.mjs +8 -3
- package/apps/studio/bin/_thumb-route.mjs +21 -0
- package/apps/studio/bin/_thumbs-playwright.mjs +83 -1
- package/apps/studio/bin/_transcribe.mjs +22 -6
- package/apps/studio/bin/_unsynced-refs.mjs +22 -0
- package/apps/studio/bin/_url-guard.mjs +120 -5
- package/apps/studio/bin/_url-guard.sh +29 -7
- package/apps/studio/bin/_video-limits.mjs +104 -0
- package/apps/studio/bin/_video-playwright.mjs +119 -19
- package/apps/studio/bin/_video-proxy.mjs +130 -0
- package/apps/studio/bin/_write-claim.mjs +38 -16
- package/apps/studio/bin/annotate.mjs +12 -2
- package/apps/studio/bin/canvas-rects.sh +19 -4
- package/apps/studio/bin/chat-open.sh +7 -1
- package/apps/studio/bin/draw-proof.sh +6 -2
- package/apps/studio/bin/generate.sh +32 -10
- package/apps/studio/bin/handoff.sh +2 -2
- package/apps/studio/bin/perf.sh +96 -15
- package/apps/studio/bin/photo-adjust.sh +6 -3
- package/apps/studio/bin/photo-bg-remove.sh +2 -2
- package/apps/studio/bin/prep.sh +21 -4
- package/apps/studio/bin/read-annotations.mjs +3 -0
- package/apps/studio/bin/runtime-health.sh +27 -1
- package/apps/studio/bin/screenshot.sh +152 -12
- package/apps/studio/bin/server-up.sh +64 -6
- package/apps/studio/bin/smoke.sh +43 -8
- package/apps/studio/bin/to-lottie.sh +3 -2
- package/apps/studio/bin/video-proxy.sh +27 -0
- package/apps/studio/bin/visual-sanity.sh +3 -1
- package/apps/studio/bridge/dgn-protocol.ts +157 -1
- package/apps/studio/bridge/mode-shows.ts +8 -6
- package/apps/studio/bridge/still-webp.ts +233 -0
- package/apps/studio/build.ts +18 -0
- package/apps/studio/canvas-build.ts +93 -11
- package/apps/studio/canvas-comment-mount.tsx +53 -8
- package/apps/studio/canvas-edit.ts +34 -1
- package/apps/studio/canvas-lib-module.ts +210 -0
- package/apps/studio/canvas-lib.tsx +3 -12
- package/apps/studio/canvas-pipeline.ts +111 -5
- package/apps/studio/canvas-shell.tsx +8 -11
- package/apps/studio/canvas-theme-pill.tsx +5 -3
- package/apps/studio/check/index.ts +12 -5
- package/apps/studio/check/video.ts +18 -2
- package/apps/studio/client/app.jsx +65 -7
- package/apps/studio/client/clipboard-relay.ts +193 -16
- package/apps/studio/client/comments-overlay.css +18 -0
- package/apps/studio/client/export-center.jsx +30 -0
- package/apps/studio/client/generate-dialog.jsx +49 -4
- package/apps/studio/client/github.js +7 -0
- package/apps/studio/client/home/HomeAccountsRow.jsx +221 -0
- package/apps/studio/client/home/HomeConnection.jsx +111 -0
- package/apps/studio/client/home/home-accounts-model.js +110 -1
- package/apps/studio/client/home/home-api.js +9 -2
- package/apps/studio/client/home/home-app.jsx +126 -13
- package/apps/studio/client/home/home-model.js +69 -1
- package/apps/studio/client/home/home-where-model.js +105 -0
- package/apps/studio/client/home/home.css +239 -1
- package/apps/studio/client/hooks/use-canvas-bridge.jsx +173 -98
- package/apps/studio/client/hooks/use-palette-and-panels.jsx +5 -1
- package/apps/studio/client/hooks/use-tabs.jsx +11 -4
- package/apps/studio/client/panels/DiffView.jsx +7 -1
- package/apps/studio/client/panels/TeamProjects.jsx +137 -134
- package/apps/studio/client/panels/chat-context.js +2 -0
- package/apps/studio/client/panels/slash-commands.gen.js +13 -13
- package/apps/studio/client/selection-scope.js +16 -9
- package/apps/studio/client/share-link.js +12 -0
- package/apps/studio/client/shell/viewport.jsx +11 -1
- package/apps/studio/client/shell-events.js +8 -0
- package/apps/studio/client/styles/3-kit-maude-v2.css +16 -0
- package/apps/studio/client/styles/_index.css +4 -0
- package/apps/studio/client/v2/ai/Feed.jsx +1 -1
- package/apps/studio/client/v2/ai/OfferCard.jsx +34 -0
- package/apps/studio/client/v2/ai/activity-line.js +54 -1
- package/apps/studio/client/v2/ai/ai-offer.js +21 -1
- package/apps/studio/client/v2/ai/run-model.js +3 -1
- package/apps/studio/client/v2/annotations/vote-store.js +28 -4
- package/apps/studio/client/v2/assets/asset-drop-session.js +37 -2
- package/apps/studio/client/v2/assets/canvas-drop-catcher.jsx +7 -5
- package/apps/studio/client/v2/assets/details-model.js +1 -1
- package/apps/studio/client/v2/assets/details.jsx +5 -0
- package/apps/studio/client/v2/assets/tile-drag.js +11 -7
- package/apps/studio/client/v2/comments/comments-panel.jsx +22 -3
- package/apps/studio/client/v2/create/duplicate-done.js +6 -2
- package/apps/studio/client/v2/diagnostics/diagnostics-host.jsx +1 -0
- package/apps/studio/client/v2/diagnostics/diagnostics-model.js +32 -2
- package/apps/studio/client/v2/diagnostics/diagnostics-sheet.jsx +35 -8
- package/apps/studio/client/v2/diagnostics/diagnostics.css +34 -0
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details-model.js +113 -3
- package/apps/studio/client/v2/diagnostics/sync-details/sync-details.jsx +343 -6
- package/apps/studio/client/v2/diagnostics/sync-details/unsynced-refs.js +55 -0
- package/apps/studio/client/v2/ds/review.css +1 -1
- package/apps/studio/client/v2/export/exports-model.js +7 -0
- package/apps/studio/client/v2/export/exports-panel.jsx +1 -0
- package/apps/studio/client/v2/export/job-row.jsx +32 -2
- package/apps/studio/client/v2/handoff/ready-card.jsx +1 -1
- package/apps/studio/client/v2/history/compare-view.jsx +1 -0
- package/apps/studio/client/v2/inspector/css-write.js +6 -1
- package/apps/studio/client/v2/inspector/frame.jsx +28 -4
- package/apps/studio/client/v2/inspector/kinds/clip-model.js +51 -0
- package/apps/studio/client/v2/inspector/kinds/clip.jsx +75 -2
- package/apps/studio/client/v2/inspector/model.js +21 -0
- package/apps/studio/client/v2/inspector/sections/fill.jsx +12 -3
- package/apps/studio/client/v2/inspector/sections/recent-colours.js +8 -5
- package/apps/studio/client/v2/inspector/view-mode.jsx +11 -1
- package/apps/studio/client/v2/link-server/LinkServerDialog.jsx +492 -0
- package/apps/studio/client/v2/link-server/LinkServerHost.jsx +42 -0
- package/apps/studio/client/v2/link-server/link-server-api.js +142 -0
- package/apps/studio/client/v2/link-server/link-server-model.js +438 -0
- package/apps/studio/client/v2/link-server/link-server.css +109 -0
- package/apps/studio/client/v2/onboarding/AdvancedSheets.jsx +31 -86
- package/apps/studio/client/v2/onboarding/onboarding-model.js +1 -18
- package/apps/studio/client/v2/preview/link-follow.js +4 -2
- package/apps/studio/client/v2/preview/preview-chrome-host.jsx +16 -6
- package/apps/studio/client/v2/search/help-model.js +2 -0
- package/apps/studio/client/v2/search/search-keywords.js +3 -2
- package/apps/studio/client/v2/settings/account.jsx +4 -2
- package/apps/studio/client/v2/settings/advanced-section.jsx +344 -137
- package/apps/studio/client/v2/settings/connection-row.jsx +3 -59
- package/apps/studio/client/v2/settings/connections-section.jsx +118 -425
- package/apps/studio/client/v2/settings/general-section.jsx +155 -24
- package/apps/studio/client/v2/settings/project-sync-settings.jsx +4 -3
- package/apps/studio/client/v2/settings/reset-section.jsx +14 -3
- package/apps/studio/client/v2/settings/settings-card.jsx +142 -0
- package/apps/studio/client/v2/settings/settings-cards.js +220 -0
- package/apps/studio/client/v2/settings/settings-handlers.js +7 -6
- package/apps/studio/client/v2/settings/settings-model.js +100 -31
- package/apps/studio/client/v2/settings/settings-sheet.jsx +25 -6
- package/apps/studio/client/v2/settings/settings.css +374 -64
- package/apps/studio/client/v2/settings/this-project-card.jsx +730 -0
- package/apps/studio/client/v2/settings/this-project-model.js +172 -0
- package/apps/studio/client/v2/settings/use-connections.js +3 -2
- package/apps/studio/client/v2/settings/use-open-card.js +37 -0
- package/apps/studio/client/v2/share/share-sheet.jsx +28 -11
- package/apps/studio/client/v2/shell/api-session-boot.js +6 -0
- package/apps/studio/client/v2/shell/api-session.js +126 -0
- package/apps/studio/client/v2/shell/connection-state.js +197 -0
- package/apps/studio/client/v2/shell/floating-panels.css +31 -1
- package/apps/studio/client/v2/shell/image-pick.js +61 -8
- package/apps/studio/client/v2/shell/menu-aim.js +43 -0
- package/apps/studio/client/v2/shell/menu-runner.js +25 -7
- package/apps/studio/client/v2/shell/occlusion-insets.js +18 -1
- package/apps/studio/client/v2/shell/project-account-bus.js +36 -0
- package/apps/studio/client/v2/shell/project-account-card.jsx +357 -148
- package/apps/studio/client/v2/shell/project-account-model.js +272 -149
- package/apps/studio/client/v2/shell/project-account-toast.js +66 -0
- package/apps/studio/client/v2/shell/project-account.css +237 -0
- package/apps/studio/client/v2/shell/project-pill.jsx +52 -6
- package/apps/studio/client/v2/shell/share-cluster-host.jsx +166 -83
- package/apps/studio/client/v2/shell/shell-parity.js +3 -2
- package/apps/studio/client/v2/shell/shell-parity.json +71 -36
- package/apps/studio/client/v2/shell/still-bridge.js +194 -0
- package/apps/studio/client/v2/shell/still-store.js +319 -0
- package/apps/studio/client/v2/shell/use-account.js +2 -0
- package/apps/studio/client/v2/shell/use-tool-panels.js +2 -1
- package/apps/studio/client/v2/signin/use-signin.js +1 -1
- package/apps/studio/client/v2/timeline/Timeline.jsx +15 -0
- package/apps/studio/client/v2/timeline/frame-handle-model.js +142 -0
- package/apps/studio/client/v2/timeline/frame-handle.jsx +151 -0
- package/apps/studio/clip-ops.ts +126 -8
- package/apps/studio/cloud/endpoints.ts +29 -4
- package/apps/studio/collab/ai-activity.ts +10 -8
- package/apps/studio/collab/awareness-bridge.ts +34 -9
- package/apps/studio/collab/index.ts +3 -0
- package/apps/studio/collab/registry.ts +41 -10
- package/apps/studio/comment-reattach.ts +149 -0
- package/apps/studio/comments/mine-stamp.ts +15 -7
- package/apps/studio/comments/ops.ts +52 -8
- package/apps/studio/comments-overlay.tsx +146 -9
- package/apps/studio/dist/client.bundle.js +892 -885
- package/apps/studio/dist/comment-mount.js +2 -2
- package/apps/studio/dist/styles.css +1 -1
- package/apps/studio/dom-selection.ts +87 -18
- package/apps/studio/ds/board/directions.css +8 -0
- package/apps/studio/ds/board/outline.tsx +16 -0
- package/apps/studio/ds/canvas-check.ts +6 -0
- package/apps/studio/edit-ops/clip/reframe.ts +19 -3
- package/apps/studio/edit-ops/clip-carry.ts +602 -0
- package/apps/studio/edit-ops/clipboard.ts +318 -23
- package/apps/studio/edit-ops/dispatch.ts +20 -2
- package/apps/studio/edit-ops/scope-names.ts +249 -40
- package/apps/studio/edit-ops/slot-defaults.ts +3 -0
- package/apps/studio/edit-ops/types.ts +6 -0
- package/apps/studio/editing/align-bar.tsx +33 -9
- package/apps/studio/editing/artboard-actions.ts +5 -0
- package/apps/studio/editing/artboard-menu.tsx +6 -2
- package/apps/studio/editing/click-to-type.ts +1 -1
- package/apps/studio/editing/clip-words.ts +48 -0
- package/apps/studio/editing/clipboard.ts +21 -6
- package/apps/studio/editing/declared-background.ts +25 -0
- package/apps/studio/editing/index.tsx +3 -0
- package/apps/studio/editing/object-keys.ts +4 -4
- package/apps/studio/editing/object-menu.tsx +13 -3
- package/apps/studio/editing/pen/points.tsx +61 -0
- package/apps/studio/editing/text-in-place.tsx +11 -0
- package/apps/studio/editing/video-frame-handle.tsx +425 -0
- package/apps/studio/exporters/capture-prepass.ts +374 -0
- package/apps/studio/exporters/degraded.ts +148 -0
- package/apps/studio/exporters/hub-render-door.ts +28 -2
- package/apps/studio/exporters/index.ts +3 -1
- package/apps/studio/exporters/job-budget.ts +93 -0
- package/apps/studio/exporters/jobs.ts +215 -28
- package/apps/studio/exporters/parity-check.ts +254 -0
- package/apps/studio/exporters/remote.ts +209 -15
- package/apps/studio/exporters/svg-inline.ts +87 -0
- package/apps/studio/exporters/video-render-lib.ts +88 -26
- package/apps/studio/exporters/video.ts +29 -6
- package/apps/studio/figma/assets.ts +58 -43
- package/apps/studio/figma/codegen-fonts.ts +100 -0
- package/apps/studio/figma/fig-decode.ts +390 -25
- package/apps/studio/figma/fig-kiwi.ts +18 -4
- package/apps/studio/figma/fig-vector.ts +59 -3
- package/apps/studio/figma/sanitize.ts +2 -0
- package/apps/studio/figma/style-map.ts +293 -48
- package/apps/studio/figma/to-artboard.ts +455 -69
- package/apps/studio/figma/to-strokes.ts +44 -11
- package/apps/studio/figma/types.ts +13 -0
- package/apps/studio/footage/schema.ts +3 -3
- package/apps/studio/generation/adapters/elevenlabs.ts +7 -1
- package/apps/studio/generation/adapters/groq.ts +8 -1
- package/apps/studio/generation/spend.ts +312 -0
- package/apps/studio/generation/types.ts +12 -0
- package/apps/studio/handoff/run.ts +1 -1
- package/apps/studio/handoff/targets.ts +2 -2
- package/apps/studio/handoff/write-scopes.ts +1 -1
- package/apps/studio/history/describe-annotations.ts +4 -0
- package/apps/studio/home/accounts.ts +30 -11
- package/apps/studio/home/cloud.ts +6 -1
- package/apps/studio/home/create-local.ts +32 -3
- package/apps/studio/home/hub-health.ts +76 -0
- package/apps/studio/home/routes.ts +15 -4
- package/apps/studio/http.ts +438 -86
- package/apps/studio/imported-module-ids.ts +91 -0
- package/apps/studio/inspect.ts +2 -0
- package/apps/studio/migrate/hub.ts +8 -1
- package/apps/studio/notifications.tsx +47 -5
- package/apps/studio/paths.ts +10 -1
- package/apps/studio/port.ts +3 -2
- package/apps/studio/preview/preview-camera.tsx +15 -382
- package/apps/studio/readiness.ts +10 -1
- package/apps/studio/release-build.ts +51 -0
- package/apps/studio/routes/agent.ts +188 -9
- package/apps/studio/routes/ai.ts +43 -11
- package/apps/studio/routes/annotations.ts +27 -1
- package/apps/studio/routes/assets.ts +18 -1
- package/apps/studio/routes/canvas-origin.ts +12 -9
- package/apps/studio/routes/cloud-move.ts +15 -0
- package/apps/studio/routes/edit.ts +3 -0
- package/apps/studio/routes/export.ts +51 -0
- package/apps/studio/routes/generate.ts +42 -12
- package/apps/studio/routes/hub-link-folder.ts +334 -0
- package/apps/studio/routes/hub-signin.ts +78 -1
- package/apps/studio/routes/index.ts +9 -1
- package/apps/studio/routes/shell.ts +217 -5
- package/apps/studio/routes/sync.ts +136 -8
- package/apps/studio/routes/votes.ts +2 -1
- package/apps/studio/schema/annotations.v2.schema.json +143 -1
- package/apps/studio/schema/beats.v1.schema.json +1 -1
- package/apps/studio/schema/edl.v1.schema.json +1 -1
- package/apps/studio/schema/formats.ts +3 -3
- package/apps/studio/schema/transcript.v1.schema.json +1 -1
- package/apps/studio/server.ts +142 -43
- package/apps/studio/shell/api-key.ts +503 -0
- package/apps/studio/shell/attest.ts +59 -0
- package/apps/studio/shell/capture-url.ts +20 -0
- package/apps/studio/shell/cli-yield.ts +276 -0
- package/apps/studio/shell/clip-transfer.ts +302 -0
- package/apps/studio/shell/key-file.ts +108 -0
- package/apps/studio/shell/server-json.ts +75 -0
- package/apps/studio/shell/worktree.ts +19 -0
- package/apps/studio/spoof-chars.ts +9 -0
- package/apps/studio/studio-page-host.ts +1 -1
- package/apps/studio/sync/accepted-cold-start.ts +144 -8
- package/apps/studio/sync/accepted-link.ts +76 -29
- package/apps/studio/sync/action-stage.ts +575 -44
- package/apps/studio/sync/adopt-held.ts +85 -0
- package/apps/studio/sync/ctl-heal.ts +58 -0
- package/apps/studio/sync/file-ledger.ts +38 -4
- package/apps/studio/sync/file-membership.ts +16 -1
- package/apps/studio/sync/file-plane.ts +289 -22
- package/apps/studio/sync/held-deletes.ts +86 -5
- package/apps/studio/sync/hub-link.ts +8 -0
- package/apps/studio/sync/index.ts +196 -12
- package/apps/studio/sync/journal-client.ts +50 -4
- package/apps/studio/sync/link-consent.ts +22 -75
- package/apps/studio/sync/link-survey.ts +252 -0
- package/apps/studio/sync/local-kernel.ts +296 -8
- package/apps/studio/sync/projection.ts +22 -3
- package/apps/studio/sync/seed-progress.ts +12 -0
- package/apps/studio/sync/source-recovery.ts +59 -3
- package/apps/studio/sync/status.ts +19 -2
- package/apps/studio/sync/unsynced-refs.ts +397 -0
- package/apps/studio/sync/writer-registry.ts +20 -0
- package/apps/studio/thumbs/service.ts +4 -1
- package/apps/studio/tool-palette.tsx +23 -0
- package/apps/studio/ui-prefs.ts +40 -0
- package/apps/studio/use-agent-presence.tsx +2 -2
- package/apps/studio/use-canvas-keys.ts +6 -1
- package/apps/studio/video/format-ids.ts +2 -2
- package/apps/studio/video/inject.ts +31 -0
- package/apps/studio/video/media-risk.ts +58 -0
- package/apps/studio/video/object-fit.ts +137 -0
- package/apps/studio/video/provider-transcript.ts +141 -0
- package/apps/studio/whats-new.json +137 -0
- package/apps/studio/workspace-mode.ts +1 -0
- package/apps/studio/ws.ts +5 -0
- package/cli/commands/design.mjs +119 -8
- package/cli/lib/bash-guard.mjs +366 -6
- package/cli/lib/confine-read.mjs +1 -0
- package/cli/lib/design-help.gen.mjs +3 -2
- package/cli/lib/design-hook.mjs +387 -81
- package/cli/lib/design-link.mjs +16 -1
- package/cli/lib/design-open.mjs +49 -3
- package/cli/lib/desktop-locate.mjs +770 -0
- package/cli/lib/handoff.mjs +1 -1
- package/cli/lib/hook-state.mjs +291 -0
- package/cli/lib/pkg-root.mjs +65 -13
- package/cli/lib/studio-locate.mjs +59 -16
- package/package.json +15 -8
- package/plugins/design/templates/_shell.html +13 -0
- package/apps/studio/client/v2/onboarding/HubSheet.jsx +0 -212
- package/apps/studio/client/v2/shell/account-card-model.js +0 -114
- package/apps/studio/client/v2/shell/account-card.jsx +0 -189
|
@@ -91,6 +91,11 @@ export interface ExportRouteDeps {
|
|
|
91
91
|
designRoot: string;
|
|
92
92
|
rects?(canvasRel: string): Promise<RectsManifest | null>;
|
|
93
93
|
};
|
|
94
|
+
/**
|
|
95
|
+
* #128 T3.7b — stop one of this session's unfinished exports (a cloud row on a desktop, a job on a
|
|
96
|
+
* cell). `missing` is also what another member's job answers (V2-1.16 U1).
|
|
97
|
+
*/
|
|
98
|
+
cancel(id: string, session: string): Promise<ExportCancelResult> | ExportCancelResult;
|
|
94
99
|
/** S8.4 — run a group job's failed items again; `session` = who asks (the job queue's owner check) */
|
|
95
100
|
retry(
|
|
96
101
|
id: string,
|
|
@@ -100,6 +105,11 @@ export interface ExportRouteDeps {
|
|
|
100
105
|
): Promise<RetryResult>;
|
|
101
106
|
}
|
|
102
107
|
|
|
108
|
+
/** #128 T3.7b — what a Cancel did (the route's answers: 200 / 404 / 409 / 403 / 502). */
|
|
109
|
+
export type ExportCancelResult =
|
|
110
|
+
| { ok: true }
|
|
111
|
+
| { ok: false; reason: 'missing' | 'not-running' | 'forbidden' | 'unreachable' };
|
|
112
|
+
|
|
103
113
|
/** The role refusal — the same shape the local gate answers a read-only write with. */
|
|
104
114
|
const capabilityRefusal = () => json(403, ACP_REFUSAL);
|
|
105
115
|
|
|
@@ -286,6 +296,21 @@ function parseRetryBody(text: string): { id: string; items?: string[] } | null {
|
|
|
286
296
|
return { id: b.id, items: b.items as string[] };
|
|
287
297
|
}
|
|
288
298
|
|
|
299
|
+
/** The cancel body: `{id}`, nothing else. */
|
|
300
|
+
function parseCancelBody(text: string): { id: string } | null {
|
|
301
|
+
let body: unknown;
|
|
302
|
+
try {
|
|
303
|
+
body = JSON.parse(text);
|
|
304
|
+
} catch {
|
|
305
|
+
return null;
|
|
306
|
+
}
|
|
307
|
+
if (!body || typeof body !== 'object' || Array.isArray(body)) return null;
|
|
308
|
+
const b = body as Record<string, unknown>;
|
|
309
|
+
if (Object.keys(b).some((k) => k !== 'id')) return null;
|
|
310
|
+
if (typeof b.id !== 'string' || !b.id || b.id.length > 64) return null;
|
|
311
|
+
return { id: b.id };
|
|
312
|
+
}
|
|
313
|
+
|
|
289
314
|
export function createExportRoutes(deps: ExportRouteDeps): RouteSpec[] {
|
|
290
315
|
return [
|
|
291
316
|
{
|
|
@@ -454,6 +479,32 @@ export function createExportRoutes(deps: ExportRouteDeps): RouteSpec[] {
|
|
|
454
479
|
return json(200, { items });
|
|
455
480
|
},
|
|
456
481
|
},
|
|
482
|
+
{
|
|
483
|
+
// #128 T3.7b — the Exports row's Cancel: stops one of THIS session's unfinished exports. On a
|
|
484
|
+
// cell the job's abort also cancels it on the render service; on a desktop a cloud row asks the
|
|
485
|
+
// hub, whose door stops the cell's job. The export class and the owner's jobs only.
|
|
486
|
+
method: 'POST',
|
|
487
|
+
path: '/_api/export-jobs/cancel',
|
|
488
|
+
origin: 'main',
|
|
489
|
+
readOnly: 'allowed',
|
|
490
|
+
handle: async (req) => {
|
|
491
|
+
const a = deps.access(req);
|
|
492
|
+
if (!a.can('export', null) && a.grants.length === 0) return capabilityRefusal();
|
|
493
|
+
if (Number(req.headers.get('content-length')) > MAX_BODY)
|
|
494
|
+
return json(413, { error: 'too-large' });
|
|
495
|
+
const text = await req.text();
|
|
496
|
+
if (text.length > MAX_BODY) return json(413, { error: 'too-large' });
|
|
497
|
+
const body = parseCancelBody(text);
|
|
498
|
+
if (!body) return json(400, { error: 'bad-cancel', message: 'body must be {id}' });
|
|
499
|
+
const r = await deps.cancel(body.id, sessionFromRequest(req));
|
|
500
|
+
if (r.ok) return json(200, { ok: true, id: body.id }) as Response;
|
|
501
|
+
// not yours ≡ never existed: the same answer the download and retry routes give
|
|
502
|
+
if (r.reason === 'missing') return new Response('Not found', { status: 404 });
|
|
503
|
+
if (r.reason === 'forbidden') return capabilityRefusal();
|
|
504
|
+
if (r.reason === 'unreachable') return json(502, { error: 'unreachable' });
|
|
505
|
+
return json(409, { error: r.reason });
|
|
506
|
+
},
|
|
507
|
+
},
|
|
457
508
|
{
|
|
458
509
|
method: 'POST',
|
|
459
510
|
path: '/_api/export-jobs/retry',
|
|
@@ -27,6 +27,7 @@ import { readGen } from '../generation/gen-sidecar.ts';
|
|
|
27
27
|
import { type GenerationJobQueue, GenerationQueueFullError } from '../generation/jobs.ts';
|
|
28
28
|
import { configuredProviders, getProviderKey } from '../generation/keys.ts';
|
|
29
29
|
import { createAdapter, getProviderModels, providersForModality } from '../generation/registry.ts';
|
|
30
|
+
import { estimateJobCost, type SpendGuard } from '../generation/spend.ts';
|
|
30
31
|
import {
|
|
31
32
|
aspectFor,
|
|
32
33
|
COMMON_RATIOS,
|
|
@@ -83,6 +84,8 @@ export interface GenerateRouteDeps {
|
|
|
83
84
|
concurrency: number;
|
|
84
85
|
quotes: Quotes;
|
|
85
86
|
groups: TakeGroups;
|
|
87
|
+
/** the spend cap (generation/spend.ts); absent = no cap (a test that builds its own deps) */
|
|
88
|
+
spend?: SpendGuard;
|
|
86
89
|
/** run ONE take: resolve the key at run time, submit, land the result in assets/ */
|
|
87
90
|
submit(req: GenRequest, signal: AbortSignal): Promise<{ assets: string[] }>;
|
|
88
91
|
/** read a designRoot-relative text file (`assets/<sha8>.gen.json`), or null */
|
|
@@ -213,6 +216,10 @@ export function createGenerateRoutes(deps: GenerateRouteDeps): RouteSpec[] {
|
|
|
213
216
|
aspect,
|
|
214
217
|
artboard: { id: t.artboard, label: t.label },
|
|
215
218
|
seconds: Math.round(seconds),
|
|
219
|
+
estimateUsd: estimateJobCost(
|
|
220
|
+
{ modality: 'image', provider: p.descriptor.id, model: model.id },
|
|
221
|
+
n
|
|
222
|
+
),
|
|
216
223
|
lines: consentLines(p.descriptor, seconds),
|
|
217
224
|
});
|
|
218
225
|
},
|
|
@@ -256,6 +263,19 @@ export function createGenerateRoutes(deps: GenerateRouteDeps): RouteSpec[] {
|
|
|
256
263
|
return json(409, { ok: false, reason: 'no-consent' });
|
|
257
264
|
const chosen = pick(deps, { provider, model });
|
|
258
265
|
if (!chosen) return json(409, { ok: false, reason: 'no-provider' });
|
|
266
|
+
// The spend cap. The quote the person just accepted IS the confirm for these takes (the app's consent
|
|
267
|
+
// card), so only the per-run and per-day caps apply; the whole group is counted up front and a take
|
|
268
|
+
// that fails gives its share back.
|
|
269
|
+
const each = estimateJobCost({ modality: 'image', provider, model });
|
|
270
|
+
const admitted = deps.spend?.admit({
|
|
271
|
+
key: `takes:${provider}:${model}:${n}`,
|
|
272
|
+
estimate: each * n,
|
|
273
|
+
confirmed: true,
|
|
274
|
+
});
|
|
275
|
+
if (admitted && !admitted.ok) {
|
|
276
|
+
const { status, ...why } = admitted;
|
|
277
|
+
return json(status, why);
|
|
278
|
+
}
|
|
259
279
|
try {
|
|
260
280
|
const g = deps.groups.start({
|
|
261
281
|
prompt,
|
|
@@ -266,21 +286,28 @@ export function createGenerateRoutes(deps: GenerateRouteDeps): RouteSpec[] {
|
|
|
266
286
|
target: { canvas: t.canvas, artboard: t.artboard },
|
|
267
287
|
licence: chosen.p.descriptor.licence ?? null,
|
|
268
288
|
by: deps.displayName?.(req) ?? null,
|
|
269
|
-
run: (take, signal) =>
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
289
|
+
run: async (take, signal) => {
|
|
290
|
+
try {
|
|
291
|
+
return await deps.submit(
|
|
292
|
+
{
|
|
293
|
+
modality: 'image',
|
|
294
|
+
provider,
|
|
295
|
+
model,
|
|
296
|
+
prompt,
|
|
297
|
+
aspectRatio: aspect,
|
|
298
|
+
params: { take },
|
|
299
|
+
},
|
|
300
|
+
signal
|
|
301
|
+
);
|
|
302
|
+
} catch (err) {
|
|
303
|
+
if (admitted?.ok) admitted.refund(each);
|
|
304
|
+
throw err;
|
|
305
|
+
}
|
|
306
|
+
},
|
|
281
307
|
});
|
|
282
308
|
return json(202, { ok: true, group: g.group, jobIds: g.jobIds, n: g.n });
|
|
283
309
|
} catch (err) {
|
|
310
|
+
if (admitted?.ok) admitted.refund();
|
|
284
311
|
if (err instanceof GenerationQueueFullError)
|
|
285
312
|
return json(429, { ok: false, reason: 'busy', message: err.message });
|
|
286
313
|
throw err;
|
|
@@ -365,6 +392,8 @@ export interface GenerateLiveDeps {
|
|
|
365
392
|
access(req: Request): Access;
|
|
366
393
|
artboard: GenerateRouteDeps['artboard'];
|
|
367
394
|
jobs: GenerationJobQueue;
|
|
395
|
+
/** the spend cap */
|
|
396
|
+
spend?: SpendGuard;
|
|
368
397
|
/** api.saveAsset — magic-byte sniff + content address (DDR-088) */
|
|
369
398
|
saveAsset: LocalizeDeps['saveAsset'];
|
|
370
399
|
emit?(g: TakeGroup): void;
|
|
@@ -411,6 +440,7 @@ export function generateDepsFor(o: GenerateLiveDeps): GenerateRouteDeps {
|
|
|
411
440
|
concurrency: Math.max(1, Number(process.env.MAUDE_GENERATE_MAX_CONCURRENT) || 2),
|
|
412
441
|
quotes: createQuotes(),
|
|
413
442
|
groups,
|
|
443
|
+
spend: o.spend,
|
|
414
444
|
submit: async (req, signal) => {
|
|
415
445
|
// the key is resolved AT RUN TIME, never cached; the adapter never touches the filesystem
|
|
416
446
|
const apiKey = await getProviderKey(req.provider);
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
// 2.1.1 — "Link your server" in a project tab connects THIS folder to the person's own team server
|
|
2
|
+
// (decision maude/v2-2.1.1-b5-link-folder-confirm-before-merge).
|
|
3
|
+
//
|
|
4
|
+
// POST /_api/hub/link-folder { url } → { ok, state: 'linked', url, sync }
|
|
5
|
+
// | { ok, state: 'needs-confirm', confirm, counts, host }
|
|
6
|
+
// POST /_api/hub/link-folder { url, confirm } → { ok, state: 'linked', … } (the person said yes)
|
|
7
|
+
//
|
|
8
|
+
// The sign-in already happened on the server's own page (`/_api/hub-signin/*`), which stored this Mac's
|
|
9
|
+
// credential for it; this route only uses that credential. A self-hosted server holds ONE project:
|
|
10
|
+
//
|
|
11
|
+
// • (2.1.1 T8) a server this Mac never linked any folder to → ALWAYS the confirm below first, with
|
|
12
|
+
// what goes up (`empty: true` when the server holds nothing) — the server's survey is its word;
|
|
13
|
+
// • it holds nothing yet → link now: the folder's format marker goes up first (raise-only, V2-1.12
|
|
14
|
+
// §5.2, as Move to cloud), then the attach lane (`cloud/endpoints.ts` `attachStored` → `linkFolder`:
|
|
15
|
+
// linkedHub in config.json, the link recorded on this Mac, the live sync runtime cycled — whose
|
|
16
|
+
// seed-up uploads the folder);
|
|
17
|
+
// • it already holds work → NOTHING is written: the answer counts what only this Mac has, what only
|
|
18
|
+
// the server has and what differs (sync/link-survey.ts), with a one-time confirm code bound to that
|
|
19
|
+
// server. A second POST with the code links, exactly as above. Never a silent two-way merge.
|
|
20
|
+
//
|
|
21
|
+
// linkedHub is written only by the attach lane, only on success. A folder already linked to another
|
|
22
|
+
// server, a worktree tab, a server this Mac holds no sign-in for and a server on a newer format than
|
|
23
|
+
// this build are refused before anything moves.
|
|
24
|
+
//
|
|
25
|
+
// MAIN ORIGIN, WINDOW ONLY: it spends the team-server credential and uploads the project, so it is the
|
|
26
|
+
// person's act in the Maude window — the same gate as Move to cloud (`Sec-Fetch-Site: same-origin`,
|
|
27
|
+
// which a page cannot forge and the loopback helper refuses to send), plus PERSON_ONLY (shell/api-key.ts)
|
|
28
|
+
// and `guardTableRoute`'s CSRF + DNS-rebind gates. Never canvas-safe; a cell never serves it
|
|
29
|
+
// (apps/hub/src/studio-manifest.mjs: REFUSED — a cell holds no team-server credential of its own).
|
|
30
|
+
// No answer ever carries a credential.
|
|
31
|
+
|
|
32
|
+
import { randomBytes } from 'node:crypto';
|
|
33
|
+
import { readFileSync } from 'node:fs';
|
|
34
|
+
import { join } from 'node:path';
|
|
35
|
+
|
|
36
|
+
import type { CloudEndpointResult } from '../cloud/endpoints.ts';
|
|
37
|
+
import { SUPPORTED_FORMAT } from '../format.ts';
|
|
38
|
+
import { hubAddress } from '../home/hub.ts';
|
|
39
|
+
import { createHubFormatClient } from '../migrate/hub.ts';
|
|
40
|
+
import { worktreeOf } from '../shell/worktree.ts';
|
|
41
|
+
import type { CanvasGroupLike } from '../sync/file-membership.ts';
|
|
42
|
+
import { getHubRecord, normalizeUrl } from '../sync/hubs-config.ts';
|
|
43
|
+
import { hubEverLinked, linksPath, normHub, projectLinkOf } from '../sync/link-consent.ts';
|
|
44
|
+
import {
|
|
45
|
+
compareSurveys,
|
|
46
|
+
holdsWork,
|
|
47
|
+
type LinkComparison,
|
|
48
|
+
surveyHub,
|
|
49
|
+
surveyLocal,
|
|
50
|
+
} from '../sync/link-survey.ts';
|
|
51
|
+
import type { RouteSpec } from './table.ts';
|
|
52
|
+
|
|
53
|
+
export const HUB_LINK_FOLDER_PATH = '/_api/hub/link-folder';
|
|
54
|
+
|
|
55
|
+
export interface HubLinkFolderDeps {
|
|
56
|
+
designRoot: string;
|
|
57
|
+
/** config.json `canvasGroups` — the plane's walk classifies against them */
|
|
58
|
+
canvasGroups?: () => readonly CanvasGroupLike[] | undefined;
|
|
59
|
+
/** the folder's own format marker (config.json `formatVersion ?? 1`) */
|
|
60
|
+
localFormat: () => number;
|
|
61
|
+
/** the attach lane (cloud/endpoints.ts) — the one place linkedHub is written */
|
|
62
|
+
attachStored(hubUrl: string): Promise<CloudEndpointResult>;
|
|
63
|
+
/** this profile's hubs.json; absent = `hubsConfigPath()` */
|
|
64
|
+
hubsConfigPath?: string;
|
|
65
|
+
/** #206 §5 — the main project's name when this server serves a worktree tab */
|
|
66
|
+
worktreeOf?: () => string | null;
|
|
67
|
+
/** 2.1.1 T8 — the folder holding `.design/`: "already linked" is decided by THIS Mac's link record
|
|
68
|
+
* for it (sync/link-consent.ts), never by the committed config.json alone. Absent = the record is
|
|
69
|
+
* not consulted (the claim alone decides, as before). */
|
|
70
|
+
repoRoot?: string;
|
|
71
|
+
/** this Mac's link records (`project-links.json`); absent = `linksPath()` */
|
|
72
|
+
linksFile?: string;
|
|
73
|
+
/** seams for tests */
|
|
74
|
+
fetchImpl?: typeof fetch;
|
|
75
|
+
now?: () => number;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** CONTRACT §3–§4 voice. Every refusal says nothing was linked. */
|
|
79
|
+
export const LINK_FOLDER_WORDS = {
|
|
80
|
+
windowOnly: 'Link your server from the Maude window.',
|
|
81
|
+
badAddress: 'That doesn’t look like a server address. Nothing was linked.',
|
|
82
|
+
signedOut: (host: string) => `Sign in to ${host} first. Nothing was linked.`,
|
|
83
|
+
offline: (host: string) =>
|
|
84
|
+
`${host} didn’t answer. Nothing was linked — try again when this Mac is online.`,
|
|
85
|
+
linkedElsewhere: (host: string) =>
|
|
86
|
+
`This project already syncs with ${host}. Unlink it there first. Nothing was linked.`,
|
|
87
|
+
worktree: (main: string) => `This folder syncs from ${main}. Link ${main} instead.`,
|
|
88
|
+
newer: (host: string) =>
|
|
89
|
+
`${host} runs a newer Maude than this one. Update Maude, then link again. Nothing was linked.`,
|
|
90
|
+
format: (host: string) =>
|
|
91
|
+
`${host} needs an update before this project can sync with it. Nothing was linked.`,
|
|
92
|
+
// 2.1.1 T14 — the server's software is current, but its project is still on the old format and only
|
|
93
|
+
// the project's OWNER can raise it: a member can do nothing about "needs an update"
|
|
94
|
+
formatOwner: (host: string) =>
|
|
95
|
+
`${host} is on an older format. Its owner needs to open it in Maude 2.1 once before this folder can sync. Nothing was linked.`,
|
|
96
|
+
expired: 'That confirmation expired. Press Link again to see what syncing would do.',
|
|
97
|
+
failed: 'Linking didn’t finish. Your work is still on this Mac.',
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
const CONFIRM_TTL_MS = 10 * 60_000;
|
|
101
|
+
const MAX_PENDING = 16;
|
|
102
|
+
|
|
103
|
+
const json = (status: number, body: unknown) =>
|
|
104
|
+
Response.json(body, { status, headers: { 'Cache-Control': 'no-store' } });
|
|
105
|
+
|
|
106
|
+
const hostOf = (url: string) => {
|
|
107
|
+
try {
|
|
108
|
+
return new URL(url).host;
|
|
109
|
+
} catch {
|
|
110
|
+
return url;
|
|
111
|
+
}
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
class LinkRefusal extends Error {
|
|
115
|
+
constructor(
|
|
116
|
+
readonly status: number,
|
|
117
|
+
readonly reason: string,
|
|
118
|
+
message: string
|
|
119
|
+
) {
|
|
120
|
+
super(message);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
export function createHubLinkFolderRoutes(deps: HubLinkFolderDeps): RouteSpec[] {
|
|
125
|
+
const doFetch = deps.fetchImpl ?? fetch;
|
|
126
|
+
const now = deps.now ?? Date.now;
|
|
127
|
+
/** confirm code → the server it was shown for. One use; a restart forgets them (the safe way). */
|
|
128
|
+
const pending = new Map<string, { url: string; expires: number }>();
|
|
129
|
+
/** Serialises POSTs: two presses must not link twice or race the config write. */
|
|
130
|
+
let gate: Promise<unknown> = Promise.resolve();
|
|
131
|
+
|
|
132
|
+
const linksFile = () => deps.linksFile ?? linksPath();
|
|
133
|
+
|
|
134
|
+
/** The server this folder is linked to ON THIS MAC, or null. The committed `linkedHub` is a claim
|
|
135
|
+
* (a clone, a peer's edit): it counts only when this Mac's link record for the folder names the
|
|
136
|
+
* same server (gate-b-sec4). An unconfirmed claim is "not linked" — never "already linked", never
|
|
137
|
+
* "unlink it there first" pointing at a host the repo names. */
|
|
138
|
+
function linkedHub(): string | null {
|
|
139
|
+
let url: string;
|
|
140
|
+
try {
|
|
141
|
+
const cfg = JSON.parse(readFileSync(join(deps.designRoot, 'config.json'), 'utf8'));
|
|
142
|
+
const raw = cfg?.linkedHub?.url;
|
|
143
|
+
if (typeof raw !== 'string' || !raw) return null;
|
|
144
|
+
try {
|
|
145
|
+
url = normalizeUrl(raw);
|
|
146
|
+
} catch {
|
|
147
|
+
url = raw;
|
|
148
|
+
}
|
|
149
|
+
} catch {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
if (deps.repoRoot === undefined) return url;
|
|
153
|
+
const rec = projectLinkOf(deps.repoRoot, linksFile());
|
|
154
|
+
return rec && rec.hub === normHub(url) ? url : null;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function mint(url: string): string {
|
|
158
|
+
const t = now();
|
|
159
|
+
for (const [k, v] of pending) if (v.expires <= t) pending.delete(k);
|
|
160
|
+
while (pending.size >= MAX_PENDING) {
|
|
161
|
+
const oldest = pending.keys().next().value;
|
|
162
|
+
if (oldest === undefined) break;
|
|
163
|
+
pending.delete(oldest);
|
|
164
|
+
}
|
|
165
|
+
const code = randomBytes(18).toString('base64url');
|
|
166
|
+
pending.set(code, { url, expires: t + CONFIRM_TTL_MS });
|
|
167
|
+
return code;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function redeem(code: string, url: string): boolean {
|
|
171
|
+
const row = pending.get(code);
|
|
172
|
+
if (!row) return false;
|
|
173
|
+
pending.delete(code); // one use, whatever the outcome
|
|
174
|
+
return row.url === url && row.expires > now();
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** V2-1.12 §5.2 — raise-only, before the first seed-up; a newer server is refused. */
|
|
178
|
+
async function checkFormat(url: string, token: string): Promise<void> {
|
|
179
|
+
const host = hostOf(url);
|
|
180
|
+
const client = createHubFormatClient({ url, token }, doFetch);
|
|
181
|
+
const health = await client.health();
|
|
182
|
+
if (!health.ok) throw new LinkRefusal(503, 'offline', LINK_FOLDER_WORDS.offline(host));
|
|
183
|
+
const hub = health.formatVersion ?? 1;
|
|
184
|
+
if (hub > SUPPORTED_FORMAT)
|
|
185
|
+
throw new LinkRefusal(409, 'format-newer', LINK_FOLDER_WORDS.newer(host));
|
|
186
|
+
const local = deps.localFormat();
|
|
187
|
+
if (!(local > 1) || hub >= local) return;
|
|
188
|
+
if (!health.capabilities.includes('format-v2'))
|
|
189
|
+
throw new LinkRefusal(409, 'format', LINK_FOLDER_WORDS.format(host));
|
|
190
|
+
const set = await client.setFormat(local === 2 ? 2 : 1);
|
|
191
|
+
if (!set.ok) {
|
|
192
|
+
if (set.status === 0) throw new LinkRefusal(503, 'offline', LINK_FOLDER_WORDS.offline(host));
|
|
193
|
+
// the owner's door: a member's bearer is refused there
|
|
194
|
+
if (set.status === 401 || set.status === 403)
|
|
195
|
+
throw new LinkRefusal(409, 'format-owner', LINK_FOLDER_WORDS.formatOwner(host));
|
|
196
|
+
throw new LinkRefusal(409, 'format', LINK_FOLDER_WORDS.format(host));
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
async function link(url: string, token: string): Promise<Response> {
|
|
201
|
+
await checkFormat(url, token);
|
|
202
|
+
const attached = await deps.attachStored(url);
|
|
203
|
+
const j = (attached.json ?? {}) as {
|
|
204
|
+
ok?: unknown;
|
|
205
|
+
url?: unknown;
|
|
206
|
+
sync?: unknown;
|
|
207
|
+
note?: unknown;
|
|
208
|
+
};
|
|
209
|
+
if (attached.status === 401)
|
|
210
|
+
throw new LinkRefusal(401, 'signed-out', LINK_FOLDER_WORDS.signedOut(hostOf(url)));
|
|
211
|
+
if (attached.status !== 200 || j.ok !== true || typeof j.url !== 'string')
|
|
212
|
+
throw new LinkRefusal(502, 'failed', LINK_FOLDER_WORDS.failed);
|
|
213
|
+
// the attach answer, minus anything but what the dialog reads (it carries no credential today;
|
|
214
|
+
// naming the fields keeps it that way if the lane's answer ever grows)
|
|
215
|
+
return json(200, {
|
|
216
|
+
ok: true,
|
|
217
|
+
state: 'linked',
|
|
218
|
+
url: j.url,
|
|
219
|
+
sync: j.sync ?? null,
|
|
220
|
+
...(typeof j.note === 'string' ? { note: j.note } : {}),
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
async function handle(req: Request): Promise<Response> {
|
|
225
|
+
let body: { url?: unknown; confirm?: unknown } = {};
|
|
226
|
+
try {
|
|
227
|
+
const text = await req.text();
|
|
228
|
+
if (text.length > 4096) throw new Error('too long');
|
|
229
|
+
body = text.trim() ? JSON.parse(text) : {};
|
|
230
|
+
if (!body || typeof body !== 'object' || Array.isArray(body))
|
|
231
|
+
throw new Error('not an object');
|
|
232
|
+
} catch {
|
|
233
|
+
return json(400, { ok: false, reason: 'bad-request', error: LINK_FOLDER_WORDS.badAddress });
|
|
234
|
+
}
|
|
235
|
+
// 2.1.1 T8 — the one address grammar every other door uses: https, or http only on loopback (the
|
|
236
|
+
// credential and the whole folder never travel in clear to a remote host)
|
|
237
|
+
const addr = hubAddress(body.url);
|
|
238
|
+
if (!addr.ok)
|
|
239
|
+
return json(400, { ok: false, reason: 'bad-address', error: LINK_FOLDER_WORDS.badAddress });
|
|
240
|
+
const url = addr.url;
|
|
241
|
+
const host = hostOf(url);
|
|
242
|
+
|
|
243
|
+
const linked = linkedHub();
|
|
244
|
+
if (linked && linked === url)
|
|
245
|
+
return json(200, { ok: true, state: 'linked', url, already: true });
|
|
246
|
+
if (linked)
|
|
247
|
+
return json(409, {
|
|
248
|
+
ok: false,
|
|
249
|
+
reason: 'linked-elsewhere',
|
|
250
|
+
error: LINK_FOLDER_WORDS.linkedElsewhere(hostOf(linked)),
|
|
251
|
+
});
|
|
252
|
+
|
|
253
|
+
const rec = getHubRecord(url, deps.hubsConfigPath);
|
|
254
|
+
if (!rec?.token)
|
|
255
|
+
return json(401, {
|
|
256
|
+
ok: false,
|
|
257
|
+
reason: 'signed-out',
|
|
258
|
+
error: LINK_FOLDER_WORDS.signedOut(host),
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
try {
|
|
262
|
+
if (body.confirm !== undefined) {
|
|
263
|
+
if (typeof body.confirm !== 'string' || !redeem(body.confirm, url))
|
|
264
|
+
return json(409, {
|
|
265
|
+
ok: false,
|
|
266
|
+
reason: 'confirm-expired',
|
|
267
|
+
error: LINK_FOLDER_WORDS.expired,
|
|
268
|
+
});
|
|
269
|
+
return await link(url, rec.token);
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
const there = await surveyHub(url, rec.token, doFetch);
|
|
273
|
+
if (!there.ok) {
|
|
274
|
+
return there.reason === 'signed-out'
|
|
275
|
+
? json(401, { ok: false, reason: 'signed-out', error: LINK_FOLDER_WORDS.signedOut(host) })
|
|
276
|
+
: json(503, { ok: false, reason: 'offline', error: LINK_FOLDER_WORDS.offline(host) });
|
|
277
|
+
}
|
|
278
|
+
// 2.1.1 T8 — the FIRST link to a server this Mac never linked always asks, with what goes up,
|
|
279
|
+
// whatever the server says it holds (its survey is the server's word, not the person's).
|
|
280
|
+
const first = !hubEverLinked(url, linksFile());
|
|
281
|
+
if (!holdsWork(there.survey) && !first) return await link(url, rec.token);
|
|
282
|
+
|
|
283
|
+
const counts: LinkComparison = compareSurveys(
|
|
284
|
+
surveyLocal(deps.designRoot, deps.canvasGroups?.()),
|
|
285
|
+
there.survey
|
|
286
|
+
);
|
|
287
|
+
return json(200, {
|
|
288
|
+
ok: true,
|
|
289
|
+
state: 'needs-confirm',
|
|
290
|
+
host,
|
|
291
|
+
counts,
|
|
292
|
+
confirm: mint(url),
|
|
293
|
+
// the server holds nothing: the dialog says what goes up, not what merges
|
|
294
|
+
...(holdsWork(there.survey) ? {} : { empty: true }),
|
|
295
|
+
});
|
|
296
|
+
} catch (err) {
|
|
297
|
+
if (err instanceof LinkRefusal)
|
|
298
|
+
return json(err.status, { ok: false, reason: err.reason, error: err.message });
|
|
299
|
+
console.error(`[hub-link-folder] ${(err as Error)?.message}`);
|
|
300
|
+
return json(500, { ok: false, reason: 'failed', error: LINK_FOLDER_WORDS.failed });
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
return [
|
|
305
|
+
{
|
|
306
|
+
method: 'POST',
|
|
307
|
+
path: '/_api/hub/link-folder',
|
|
308
|
+
origin: 'main',
|
|
309
|
+
// the `session` class, like Move to cloud: linking your own folder is the owner's act on their own
|
|
310
|
+
// place; a folder already linked (the only one a hub role applies to) answers 409 first
|
|
311
|
+
readOnly: 'allowed',
|
|
312
|
+
handle(req) {
|
|
313
|
+
// the person's act in the Maude window: only a browser's own same-origin fetch carries this
|
|
314
|
+
if (req.headers.get('sec-fetch-site') !== 'same-origin')
|
|
315
|
+
return json(403, {
|
|
316
|
+
ok: false,
|
|
317
|
+
reason: 'window-only',
|
|
318
|
+
error: LINK_FOLDER_WORDS.windowOnly,
|
|
319
|
+
});
|
|
320
|
+
// #206 §5: a worktree tab syncs from its main project — linking it would make a second copy
|
|
321
|
+
const main = (deps.worktreeOf ?? worktreeOf)();
|
|
322
|
+
if (main)
|
|
323
|
+
return json(409, {
|
|
324
|
+
ok: false,
|
|
325
|
+
reason: 'worktree',
|
|
326
|
+
error: LINK_FOLDER_WORDS.worktree(main),
|
|
327
|
+
});
|
|
328
|
+
const next = gate.then(() => handle(req));
|
|
329
|
+
gate = next.catch(() => null);
|
|
330
|
+
return next;
|
|
331
|
+
},
|
|
332
|
+
},
|
|
333
|
+
];
|
|
334
|
+
}
|
|
@@ -4,6 +4,13 @@
|
|
|
4
4
|
// POST /_api/hub-signin/poll { id } → { ok, pending } | { ok, url, user } | { ok:false, error }
|
|
5
5
|
// POST /_api/hub-signin/cancel { id } → { ok }
|
|
6
6
|
// GET /_api/hub-signin/return ?state&code | ?state&error (the browser's hop back from the hub)
|
|
7
|
+
// POST /_api/hub-signin/check { url } → { ok, reachable, url, version } | { ok:false, reason, error }
|
|
8
|
+
//
|
|
9
|
+
// 2.1.1 T5 — "Link your server" checks the address as it is typed: `check` is Home's `/_home/hub/test`
|
|
10
|
+
// (home/hub.ts `createHomeHub().test`) for a project tab — ONE tokenless GET <server>/health, no
|
|
11
|
+
// redirect followed, no credential, only `{ ok, version }` reflected back. `start` takes an invite
|
|
12
|
+
// (the key, or the server's own `/join/<key>` link, which must name the same server — home/hub.ts
|
|
13
|
+
// `hubInviteToken`), so the invite opens the server's own invite page here as it does on Home.
|
|
7
14
|
//
|
|
8
15
|
// MAIN ORIGIN ONLY: these mint and store a team-server credential, which the untrusted canvas
|
|
9
16
|
// origin (DDR-054) must never reach. `guardTableRoute` applies the CSRF + DNS-rebind gates to all
|
|
@@ -16,6 +23,9 @@
|
|
|
16
23
|
// A cell never serves these (apps/hub/src/studio-manifest.mjs: REFUSED) — a cell holds no team
|
|
17
24
|
// server credential of its own.
|
|
18
25
|
|
|
26
|
+
import { isHomePort, isLoopbackAddress, isTokenBridgePort } from '../bin/_curl-local.mjs';
|
|
27
|
+
import { classifyAddress } from '../bin/_fetch-asset.mjs';
|
|
28
|
+
import { createHomeHub, hubAddress, hubInviteToken } from '../home/hub.ts';
|
|
19
29
|
import {
|
|
20
30
|
createHubBrowserSignIn,
|
|
21
31
|
type HubBrowserSignIn,
|
|
@@ -29,6 +39,39 @@ export interface HubSigninRouteDeps {
|
|
|
29
39
|
/** The team server this project syncs with — a renewed sign-in for it cycles sync. */
|
|
30
40
|
linkedHubUrl?: () => string | null | undefined;
|
|
31
41
|
restartSync?: () => Promise<unknown> | undefined;
|
|
42
|
+
/** The address check's network seam (tests); default `fetch`. */
|
|
43
|
+
fetchImpl?: typeof fetch;
|
|
44
|
+
/** 2.1.1 T8 — a loopback port the check never reaches (default: the app's Home server and token
|
|
45
|
+
* bridge, from the app-owned run files — the same ports the loopback helper refuses). */
|
|
46
|
+
refusedLocalPort?: (port: number) => boolean;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* 2.1.1 T8 — where the address check never sends its GET: an IP literal in a private, link-local or
|
|
51
|
+
* reserved range, and, on loopback, this Mac's own app services (Home, the token bridge). A loopback
|
|
52
|
+
* team server for local development stays allowed. Host NAMES are not resolved here (no DNS lookup on
|
|
53
|
+
* a person's keystroke); the check reflects only `{ ok, version }`. Returns a refusal reason or null.
|
|
54
|
+
*/
|
|
55
|
+
export function checkTargetRefusal(
|
|
56
|
+
url: string,
|
|
57
|
+
refusedLocalPort: (port: number) => boolean = (p) => isHomePort(p) || isTokenBridgePort(p)
|
|
58
|
+
): string | null {
|
|
59
|
+
let u: URL;
|
|
60
|
+
try {
|
|
61
|
+
u = new URL(url);
|
|
62
|
+
} catch {
|
|
63
|
+
return 'bad-address';
|
|
64
|
+
}
|
|
65
|
+
const host = u.hostname.replace(/^\[|\]$/g, '');
|
|
66
|
+
const loopback = host === 'localhost' || isLoopbackAddress(host);
|
|
67
|
+
if (loopback) {
|
|
68
|
+
const port = Number(u.port || (u.protocol === 'https:' ? 443 : 80));
|
|
69
|
+
return refusedLocalPort(port) ? 'local-service' : null;
|
|
70
|
+
}
|
|
71
|
+
const reason = classifyAddress(host);
|
|
72
|
+
// a public IP literal and every host name pass; any classified range is refused
|
|
73
|
+
if (reason === null || reason === 'not an ip address') return null;
|
|
74
|
+
return 'private-address';
|
|
32
75
|
}
|
|
33
76
|
|
|
34
77
|
async function body(req: Request): Promise<Record<string, unknown>> {
|
|
@@ -64,6 +107,8 @@ export function createHubSigninRoutes(deps: HubSigninRouteDeps = {}): RouteSpec[
|
|
|
64
107
|
if (sameServer(deps.linkedHubUrl?.(), url)) await deps.restartSync?.();
|
|
65
108
|
},
|
|
66
109
|
});
|
|
110
|
+
// the check only: Home's tokenless probe (no redirect, no ambient credentials)
|
|
111
|
+
const checker = createHomeHub(deps.fetchImpl ? { fetchImpl: deps.fetchImpl } : {});
|
|
67
112
|
return [
|
|
68
113
|
{
|
|
69
114
|
method: 'POST',
|
|
@@ -72,7 +117,22 @@ export function createHubSigninRoutes(deps: HubSigninRouteDeps = {}): RouteSpec[
|
|
|
72
117
|
readOnly: 'allowed',
|
|
73
118
|
async handle(req) {
|
|
74
119
|
const b = await body(req);
|
|
75
|
-
|
|
120
|
+
// 2.1.1 N5 — the same target refusal as `/check`: start probes the server too
|
|
121
|
+
const target = hubAddress(b.url);
|
|
122
|
+
if (target.ok && checkTargetRefusal(target.url, deps.refusedLocalPort))
|
|
123
|
+
return json(
|
|
124
|
+
{ ok: false, reason: 'bad-address', error: "That isn't a team server address." },
|
|
125
|
+
400
|
|
126
|
+
);
|
|
127
|
+
let invite: string | undefined;
|
|
128
|
+
if (b.invite !== undefined && b.invite !== null && b.invite !== '') {
|
|
129
|
+
const at = hubAddress(b.url);
|
|
130
|
+
if (!at.ok) return json({ ok: false, error: at.error }, 400);
|
|
131
|
+
const t = hubInviteToken(b.invite, at.url);
|
|
132
|
+
if (!t.ok) return json({ ok: false, error: t.error }, 400);
|
|
133
|
+
invite = t.value;
|
|
134
|
+
}
|
|
135
|
+
const r = await signIn.start(b.url, new URL(req.url).origin, invite ? { invite } : {});
|
|
76
136
|
return r.ok
|
|
77
137
|
? json(r)
|
|
78
138
|
: json(
|
|
@@ -100,6 +160,23 @@ export function createHubSigninRoutes(deps: HubSigninRouteDeps = {}): RouteSpec[
|
|
|
100
160
|
return json({ ok: true });
|
|
101
161
|
},
|
|
102
162
|
},
|
|
163
|
+
{
|
|
164
|
+
method: 'POST',
|
|
165
|
+
path: '/_api/hub-signin/check',
|
|
166
|
+
origin: 'main',
|
|
167
|
+
readOnly: 'allowed',
|
|
168
|
+
async handle(req) {
|
|
169
|
+
const b = await body(req);
|
|
170
|
+
const a = hubAddress(b.url);
|
|
171
|
+
if (a.ok && checkTargetRefusal(a.url, deps.refusedLocalPort))
|
|
172
|
+
return json(
|
|
173
|
+
{ ok: false, reason: 'bad-address', error: "That isn't a team server address." },
|
|
174
|
+
400
|
|
175
|
+
);
|
|
176
|
+
const r = await checker.test(b);
|
|
177
|
+
return json(r.body, r.status);
|
|
178
|
+
},
|
|
179
|
+
},
|
|
103
180
|
{
|
|
104
181
|
method: 'GET',
|
|
105
182
|
// A literal (the route scrapers read `path:` strings) — HUB_SIGNIN_RETURN_PATH, asserted by the test.
|
|
@@ -45,6 +45,7 @@ import { createGenerateRoutes, type GenerateRouteDeps } from './generate.ts';
|
|
|
45
45
|
import { createHandoffRoutes, type HandoffRouteDeps } from './handoff.ts';
|
|
46
46
|
import { createHelpGuidesRoutes, type HelpGuidesDeps } from './help-guides.ts';
|
|
47
47
|
import { createHistoryRoutes, type HistoryRouteDeps } from './history.ts';
|
|
48
|
+
import { createHubLinkFolderRoutes, type HubLinkFolderDeps } from './hub-link-folder.ts';
|
|
48
49
|
import { createHubSigninRoutes, type HubSigninRouteDeps } from './hub-signin.ts';
|
|
49
50
|
import { createImportLinkRoutes, type ImportLinkRouteDeps } from './import-link.ts';
|
|
50
51
|
import { createKindRoutes } from './kinds.ts';
|
|
@@ -143,6 +144,8 @@ export interface RouteDeps {
|
|
|
143
144
|
connections?: ConnectionsRouteDeps;
|
|
144
145
|
/** Issue #204 — `/_api/hub-signin/*` (main origin): sign in to a team server on its own page */
|
|
145
146
|
hubSignin?: HubSigninRouteDeps;
|
|
147
|
+
/** 2.1.1 — `POST /_api/hub/link-folder` (main origin, window only): THIS folder joins the person's team server */
|
|
148
|
+
hubLinkFolder?: HubLinkFolderDeps;
|
|
146
149
|
/** S8.19 — `GET /_api/asset-state` (main origin): disk + upload queue + hub presence */
|
|
147
150
|
assetState?: AssetStateRouteDeps;
|
|
148
151
|
/** S8.13 — `POST /_api/assets/trash` (main origin, Can edit on the project): assets + sidecars to `_trash/`;
|
|
@@ -209,7 +212,11 @@ export function allSpecs(deps: RouteDeps): RouteSpec[] {
|
|
|
209
212
|
...createOutboxRoutes(deps.outbox),
|
|
210
213
|
...createProjectFormatRoutes(deps.projectFormat),
|
|
211
214
|
...agentRouteSpecs(deps.agent),
|
|
212
|
-
...createShellRoutes({
|
|
215
|
+
...createShellRoutes({
|
|
216
|
+
...deps.shell,
|
|
217
|
+
runs: deps.agent.runs,
|
|
218
|
+
designRoot: deps.pins.designRoot,
|
|
219
|
+
}),
|
|
213
220
|
...createPinsRoutes(deps.pins),
|
|
214
221
|
...createAiRoutes(deps.ai),
|
|
215
222
|
...createChatRoutes(deps.chat),
|
|
@@ -270,6 +277,7 @@ export function allSpecs(deps: RouteDeps): RouteSpec[] {
|
|
|
270
277
|
...(deps.helpGuides ? createHelpGuidesRoutes(deps.helpGuides) : []),
|
|
271
278
|
...(deps.connections ? createConnectionsRoutes(deps.connections) : []),
|
|
272
279
|
...createHubSigninRoutes(deps.hubSignin ?? {}),
|
|
280
|
+
...(deps.hubLinkFolder ? createHubLinkFolderRoutes(deps.hubLinkFolder) : []),
|
|
273
281
|
...createAssetStateRoutes(deps.assetState ?? { service: () => null }),
|
|
274
282
|
...(deps.assetTrash ? createAssetTrashRoutes(deps.assetTrash) : []),
|
|
275
283
|
// P8 round 7 — POST /_api/assets/rename (routes/asset-rename.ts): the same deps and verdict as Move to trash
|