@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
|
@@ -0,0 +1,770 @@
|
|
|
1
|
+
// desktop-locate.mjs — find the Maude desktop app's server for a project, and ask the app for one
|
|
2
|
+
// (#206 T6.3d; DDR-250; contract `apps/studio/client/v2/contracts/206-cli-reuses-desktop.md` §3–§4).
|
|
3
|
+
//
|
|
4
|
+
// While the desktop app runs it owns a checkout's server. The app writes a registry,
|
|
5
|
+
// `<app_data_dir>/servers.json` (0600 in a 0700 dir), naming each project root it serves with a
|
|
6
|
+
// port and a per-spawn `attestKey`. A terminal `maude design` verb believes a port from it only after
|
|
7
|
+
// the server there answers a fresh nonce:
|
|
8
|
+
//
|
|
9
|
+
// mac = HMAC-SHA256(attestKey as UTF-8, "maude-attest/1\n" + nonce + "\n" + rootId + "\n" + port)
|
|
10
|
+
//
|
|
11
|
+
// (`GET /_api/shell/attest?n=`, apps/studio/shell/attest.ts), compared in constant time. A port
|
|
12
|
+
// squatter, a respawned sibling or a planted listener cannot answer it. Only the PORT is used, always
|
|
13
|
+
// on 127.0.0.1 — never a URL from any file.
|
|
14
|
+
//
|
|
15
|
+
// Trust rules:
|
|
16
|
+
// • The registry is read only when it is a regular file of this user, at most 1 MiB, not writable
|
|
17
|
+
// by group or others, `v: 1`, and its `app.pid` is alive (the same rules as shell/cli-yield.ts).
|
|
18
|
+
// This module never creates it, nor its folder.
|
|
19
|
+
// • When the registry names this root as RUNNING, the project's `_server.json` is never a trust
|
|
20
|
+
// input: a planted copy cannot redirect a verb. If that server does not attest, the answer is
|
|
21
|
+
// `unverified` and callers fail closed (no `_server.json` fallback).
|
|
22
|
+
// • When the app is not running, or has no running server for this root, callers keep today's
|
|
23
|
+
// `_server.json` + pid + `/_health` rootId check (studio-locate.mjs, server-up.sh).
|
|
24
|
+
//
|
|
25
|
+
// sec-loopback-bearer §7 — an app server requires its per-spawn API key from every caller. The registry
|
|
26
|
+
// entry carries it (`apiKey`); this module hands it out only with an ATTESTED port (never for an entry
|
|
27
|
+
// whose server did not answer the challenge), and never reads a key from any project file. Callers send
|
|
28
|
+
// it as `x-maude-api-key` (studio-locate.mjs `studioHeaders`; bash helpers through `key` mode below).
|
|
29
|
+
//
|
|
30
|
+
// The CLI → app socket (`cli.sock`, beside the registry): one JSON request per connection, one JSON
|
|
31
|
+
// reply. Used only when it is a socket of this user; absent → today's behaviour. The CLI never
|
|
32
|
+
// launches the app.
|
|
33
|
+
//
|
|
34
|
+
// Leaf module: node built-ins only. Also runnable (`node desktop-locate.mjs <mode> …`) for the bash
|
|
35
|
+
// helpers — see `main` at the bottom for the modes and exit codes.
|
|
36
|
+
|
|
37
|
+
import { createHash, createHmac, randomBytes, timingSafeEqual } from 'node:crypto';
|
|
38
|
+
import { lstatSync, readFileSync, realpathSync } from 'node:fs';
|
|
39
|
+
import { createConnection } from 'node:net';
|
|
40
|
+
import { homedir } from 'node:os';
|
|
41
|
+
import { dirname, isAbsolute, join, resolve } from 'node:path';
|
|
42
|
+
import { fileURLToPath } from 'node:url';
|
|
43
|
+
|
|
44
|
+
export const REGISTRY_FILE_ENV = 'MAUDE_APP_REGISTRY_FILE';
|
|
45
|
+
export const APP_IDENTIFIER = 'com.maude.app';
|
|
46
|
+
export const SOCKET_FILE = 'cli.sock';
|
|
47
|
+
export const ATTEST_DOMAIN = 'maude-attest/1';
|
|
48
|
+
const ATTEST_KEY_RE = /^[0-9a-fA-F]{64}$/;
|
|
49
|
+
const REGISTRY_MAX_BYTES = 1024 * 1024;
|
|
50
|
+
const REPLY_MAX_BYTES = 64 * 1024;
|
|
51
|
+
const LABEL_RE = /^[A-Za-z0-9._-]{1,64}$/;
|
|
52
|
+
|
|
53
|
+
export const CAP_FULL_LINE =
|
|
54
|
+
'Maude has 3 busy projects open — using a separate server for this run.';
|
|
55
|
+
export const BRANCH_UNSENT_LINE =
|
|
56
|
+
'Maude has unsaved changes for another branch in this folder; save or discard them first.';
|
|
57
|
+
export const SHEET_LIMIT_LINE =
|
|
58
|
+
'Maude asked about new folders too often just now — using a separate server for this run. Open the folder in Maude yourself (File › Open project…) to skip the question.';
|
|
59
|
+
|
|
60
|
+
// The characters that reorder or hide the text around them (bidi controls and marks, zero-width and
|
|
61
|
+
// other invisible format characters, line/paragraph separators, tag characters) — the same set the
|
|
62
|
+
// app strips from a branch name (project_resolve.rs `is_invisible`). A branch name from the app or the
|
|
63
|
+
// registry is printed in the terminal; it never needs one.
|
|
64
|
+
const INVISIBLE = [
|
|
65
|
+
[0xad, 0xad],
|
|
66
|
+
[0x34f, 0x34f],
|
|
67
|
+
[0x61c, 0x61c],
|
|
68
|
+
[0x115f, 0x1160],
|
|
69
|
+
[0x17b4, 0x17b5],
|
|
70
|
+
[0x180b, 0x180f],
|
|
71
|
+
[0x200b, 0x200f],
|
|
72
|
+
[0x2028, 0x202e],
|
|
73
|
+
[0x2060, 0x206f],
|
|
74
|
+
[0x3164, 0x3164],
|
|
75
|
+
[0xfe00, 0xfe0f],
|
|
76
|
+
[0xfeff, 0xfeff],
|
|
77
|
+
[0xffa0, 0xffa0],
|
|
78
|
+
[0xfff0, 0xfffb],
|
|
79
|
+
[0x1bca0, 0x1bca3],
|
|
80
|
+
[0x1d173, 0x1d17a],
|
|
81
|
+
[0xe0000, 0xe0fff],
|
|
82
|
+
];
|
|
83
|
+
const isInvisible = (cp) => INVISIBLE.some(([lo, hi]) => cp >= lo && cp <= hi);
|
|
84
|
+
const isControl = (cp) => cp <= 0x1f || (cp >= 0x7f && cp <= 0x9f);
|
|
85
|
+
|
|
86
|
+
/** A branch name (or any app-supplied one-line name) fit for the terminal: one line, nothing hidden. */
|
|
87
|
+
export function cleanName(s) {
|
|
88
|
+
let out = '';
|
|
89
|
+
for (const ch of String(s)) {
|
|
90
|
+
const cp = ch.codePointAt(0);
|
|
91
|
+
if (isInvisible(cp)) continue;
|
|
92
|
+
out += isControl(cp) ? ' ' : ch;
|
|
93
|
+
}
|
|
94
|
+
return out;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/** http.ts rootIdentity, verbatim: sha256(realpath(root)) hex, first 12. */
|
|
98
|
+
export function rootIdentity(root) {
|
|
99
|
+
let resolved = root;
|
|
100
|
+
try {
|
|
101
|
+
resolved = realpathSync(root);
|
|
102
|
+
} catch {
|
|
103
|
+
/* hash what we were told */
|
|
104
|
+
}
|
|
105
|
+
return createHash('sha256').update(resolved, 'utf8').digest('hex').slice(0, 12);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function real(p) {
|
|
109
|
+
try {
|
|
110
|
+
return realpathSync(p);
|
|
111
|
+
} catch {
|
|
112
|
+
return null;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const underTest = (e) => !!e && (!!e.NODE_TEST_CONTEXT || e.NODE_ENV === 'test');
|
|
117
|
+
|
|
118
|
+
/** The registry the app writes: Tauri's `app_data_dir()` + `servers.json` (cli-yield.ts registryPath). */
|
|
119
|
+
export function registryPath(env = process.env, platform = process.platform, home = homedir()) {
|
|
120
|
+
const override = env[REGISTRY_FILE_ENV];
|
|
121
|
+
if (override && isAbsolute(override)) return override;
|
|
122
|
+
// Under a test runner (node --test, bun test) only an explicit override counts: a suite that runs
|
|
123
|
+
// server-up or `design open` on this Mac must never reach the person's running Maude.
|
|
124
|
+
if (underTest(env) || underTest(process.env)) return null;
|
|
125
|
+
return appDataRegistryPath(env, platform, home);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** The platform default alone (no override, no test guard): computed, never created. */
|
|
129
|
+
export function appDataRegistryPath(
|
|
130
|
+
env = process.env,
|
|
131
|
+
platform = process.platform,
|
|
132
|
+
home = homedir()
|
|
133
|
+
) {
|
|
134
|
+
if (platform === 'darwin')
|
|
135
|
+
return join(home, 'Library', 'Application Support', APP_IDENTIFIER, 'servers.json');
|
|
136
|
+
if (platform === 'win32')
|
|
137
|
+
return env.APPDATA ? join(env.APPDATA, APP_IDENTIFIER, 'servers.json') : null;
|
|
138
|
+
const data = env.XDG_DATA_HOME && isAbsolute(env.XDG_DATA_HOME) ? env.XDG_DATA_HOME : null;
|
|
139
|
+
return join(data ?? join(home, '.local', 'share'), APP_IDENTIFIER, 'servers.json');
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
const validPort = (p) => Number.isInteger(p) && p >= 1 && p <= 65535;
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* The registry, or null when it is absent, not a regular file of this user, writable by group or
|
|
146
|
+
* others, over 1 MiB, or malformed. Entries that are not well-formed are dropped one by one.
|
|
147
|
+
*/
|
|
148
|
+
export function readRegistry(file) {
|
|
149
|
+
if (!file) return null;
|
|
150
|
+
try {
|
|
151
|
+
const st = lstatSync(file);
|
|
152
|
+
if (!st.isFile() || st.size > REGISTRY_MAX_BYTES) return null;
|
|
153
|
+
const uid = process.getuid?.();
|
|
154
|
+
if (uid !== undefined && st.uid !== uid) return null;
|
|
155
|
+
if (process.platform !== 'win32' && (st.mode & 0o022) !== 0) return null;
|
|
156
|
+
const doc = JSON.parse(readFileSync(file, 'utf8'));
|
|
157
|
+
if (doc?.v !== 1 || !Array.isArray(doc.servers)) return null;
|
|
158
|
+
const appPid = doc.app?.pid;
|
|
159
|
+
if (!Number.isInteger(appPid) || appPid <= 0) return null;
|
|
160
|
+
const servers = [];
|
|
161
|
+
for (const s of doc.servers) {
|
|
162
|
+
if (!s || typeof s !== 'object') continue;
|
|
163
|
+
if (typeof s.root !== 'string' || !isAbsolute(s.root)) continue;
|
|
164
|
+
if (s.state !== 'running' && s.state !== 'resting') continue;
|
|
165
|
+
const e = { root: s.root, state: s.state };
|
|
166
|
+
if (typeof s.rootId === 'string') e.rootId = s.rootId;
|
|
167
|
+
if (typeof s.label === 'string' && LABEL_RE.test(s.label)) e.label = s.label;
|
|
168
|
+
e.kind = s.kind === 'worktree' ? 'worktree' : 'project';
|
|
169
|
+
if (typeof s.branch === 'string') e.branch = cleanName(s.branch);
|
|
170
|
+
if (Number.isInteger(s.pid) && s.pid > 0) e.pid = s.pid;
|
|
171
|
+
if (validPort(s.port)) e.port = s.port;
|
|
172
|
+
if (typeof s.attestKey === 'string' && ATTEST_KEY_RE.test(s.attestKey))
|
|
173
|
+
e.attestKey = s.attestKey;
|
|
174
|
+
if (typeof s.apiKey === 'string' && ATTEST_KEY_RE.test(s.apiKey)) e.apiKey = s.apiKey;
|
|
175
|
+
// a running entry without a port or a key cannot be verified: it reads as not running
|
|
176
|
+
if (e.state === 'running' && (e.port === undefined || e.attestKey === undefined))
|
|
177
|
+
e.state = 'starting';
|
|
178
|
+
servers.push(e);
|
|
179
|
+
}
|
|
180
|
+
return { appPid, servers };
|
|
181
|
+
} catch {
|
|
182
|
+
return null;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
/** Alive and ours to signal. EPERM (another user's process) is not the app. */
|
|
187
|
+
export function pidAlive(pid) {
|
|
188
|
+
try {
|
|
189
|
+
process.kill(pid, 0);
|
|
190
|
+
return true;
|
|
191
|
+
} catch {
|
|
192
|
+
return false;
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** The app socket beside the registry, when it is a socket of this user; else null. */
|
|
197
|
+
export function appSocketPath(file) {
|
|
198
|
+
if (!file) return null;
|
|
199
|
+
const sock = join(dirname(file), SOCKET_FILE);
|
|
200
|
+
try {
|
|
201
|
+
const st = lstatSync(sock);
|
|
202
|
+
if (!st.isSocket()) return null;
|
|
203
|
+
const uid = process.getuid?.();
|
|
204
|
+
if (uid !== undefined && st.uid !== uid) return null;
|
|
205
|
+
return sock;
|
|
206
|
+
} catch {
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
export function attestMac(key, nonce, rootId, port) {
|
|
212
|
+
return createHmac('sha256', key)
|
|
213
|
+
.update(`${ATTEST_DOMAIN}\n${nonce}\n${rootId}\n${port}`)
|
|
214
|
+
.digest('hex');
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
/** Constant-time compare (hashed first, so a length difference leaks nothing). */
|
|
218
|
+
export function macMatches(got, want) {
|
|
219
|
+
if (typeof got !== 'string' || !got) return false;
|
|
220
|
+
const a = createHash('sha256').update(got).digest();
|
|
221
|
+
const b = createHash('sha256').update(want).digest();
|
|
222
|
+
return timingSafeEqual(a, b);
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
/**
|
|
226
|
+
* Does the server at `port` hold `entry.attestKey` for `rootId`? A fresh 32-hex nonce per call;
|
|
227
|
+
* only 127.0.0.1; a redirect is a failure. Never throws.
|
|
228
|
+
*/
|
|
229
|
+
export async function verifyAttest(port, entry, { rootId, timeoutMs = 1500 } = {}) {
|
|
230
|
+
if (!validPort(port) || !entry?.attestKey || !rootId) return false;
|
|
231
|
+
const n = randomBytes(16).toString('hex');
|
|
232
|
+
try {
|
|
233
|
+
const r = await fetch(`http://127.0.0.1:${port}/_api/shell/attest?n=${n}`, {
|
|
234
|
+
redirect: 'manual',
|
|
235
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
236
|
+
});
|
|
237
|
+
if (r.status !== 200) return false;
|
|
238
|
+
const body = await r.json();
|
|
239
|
+
return macMatches(body?.mac, attestMac(entry.attestKey, n, rootId, port));
|
|
240
|
+
} catch {
|
|
241
|
+
return false;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
|
|
246
|
+
|
|
247
|
+
/** The app's view of `root`, read once: `{ file, reg, entries, socket }`, or null (no app). */
|
|
248
|
+
function appView(root, env, alive) {
|
|
249
|
+
const file = registryPath(env);
|
|
250
|
+
const reg = readRegistry(file);
|
|
251
|
+
if (!reg || !alive(reg.appPid)) return null;
|
|
252
|
+
const want = real(root) ?? resolve(root);
|
|
253
|
+
const id = rootIdentity(root);
|
|
254
|
+
const entries = reg.servers.filter(
|
|
255
|
+
(e) => (real(e.root) ?? e.root) === want && (e.rootId === undefined || e.rootId === id)
|
|
256
|
+
);
|
|
257
|
+
return { file, reg, entries, socket: appSocketPath(file), rootId: id };
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* What the app says about `root`. Never throws.
|
|
262
|
+
* { state: 'no-app' } no registry, or its app is not running
|
|
263
|
+
* { state: 'absent' | 'resting' | 'starting', socket } the app runs, with no usable server here
|
|
264
|
+
* { state: 'running', port, label, kind, socket } an attested app server for this root
|
|
265
|
+
* { state: 'unverified', socket } the registry names a running server for
|
|
266
|
+
* this root, but it did not attest
|
|
267
|
+
*/
|
|
268
|
+
export async function probeDesktop(
|
|
269
|
+
root,
|
|
270
|
+
{ env = process.env, alive = pidAlive, timeoutMs = 1500, attempts = 1, retryDelayMs = 500 } = {}
|
|
271
|
+
) {
|
|
272
|
+
try {
|
|
273
|
+
for (let i = 0; i < Math.max(1, attempts); i++) {
|
|
274
|
+
if (i > 0) await sleep(retryDelayMs);
|
|
275
|
+
const v = appView(root, env, alive);
|
|
276
|
+
if (!v) return { state: 'no-app' };
|
|
277
|
+
const running = v.entries.filter((e) => e.state === 'running');
|
|
278
|
+
if (!running.length) {
|
|
279
|
+
const state = v.entries.some((e) => e.state === 'starting')
|
|
280
|
+
? 'starting'
|
|
281
|
+
: v.entries.length
|
|
282
|
+
? 'resting'
|
|
283
|
+
: 'absent';
|
|
284
|
+
return { state, socket: v.socket };
|
|
285
|
+
}
|
|
286
|
+
for (const e of running) {
|
|
287
|
+
if (await verifyAttest(e.port, e, { rootId: v.rootId, timeoutMs })) {
|
|
288
|
+
return {
|
|
289
|
+
state: 'running',
|
|
290
|
+
port: e.port,
|
|
291
|
+
label: e.label ?? null,
|
|
292
|
+
kind: e.kind,
|
|
293
|
+
socket: v.socket,
|
|
294
|
+
...(e.apiKey ? { apiKey: e.apiKey } : {}),
|
|
295
|
+
};
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
if (i === Math.max(1, attempts) - 1) return { state: 'unverified', socket: v.socket };
|
|
299
|
+
}
|
|
300
|
+
} catch {
|
|
301
|
+
/* fall through */
|
|
302
|
+
}
|
|
303
|
+
return { state: 'no-app' };
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
const served = (p) => ({
|
|
307
|
+
port: p.port,
|
|
308
|
+
label: p.label,
|
|
309
|
+
kind: p.kind,
|
|
310
|
+
...(p.apiKey ? { apiKey: p.apiKey } : {}),
|
|
311
|
+
});
|
|
312
|
+
|
|
313
|
+
/** `{ port, label, kind, apiKey? }` of the attested app server for `root`, or null (contract §8). */
|
|
314
|
+
export async function locateDesktop(root, opts = {}) {
|
|
315
|
+
const p = await probeDesktop(root, opts);
|
|
316
|
+
return p.state === 'running' ? served(p) : null;
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
/* -------------------------------------------- terminal-started servers (sec-loopback-bearer §7.5) */
|
|
320
|
+
|
|
321
|
+
const TERMINAL_KEY_MAX_BYTES = 4096;
|
|
322
|
+
export const LAUNCH_PARAM = 'maude-launch';
|
|
323
|
+
const LAUNCH_DOMAIN = 'maude-launch/1';
|
|
324
|
+
const HELPER_LAUNCH_DOMAIN = 'maude-launch-helper/1';
|
|
325
|
+
|
|
326
|
+
/** apps/studio/shell/key-file.ts `serverKeyDir`, verbatim: `<state>/maude/servers`. */
|
|
327
|
+
export function serverKeyDir(env = process.env, home = homedir()) {
|
|
328
|
+
const s = env.XDG_STATE_HOME;
|
|
329
|
+
const state = s && isAbsolute(s) ? s : join(env.HOME || home, '.local', 'state');
|
|
330
|
+
return join(state, 'maude', 'servers');
|
|
331
|
+
}
|
|
332
|
+
|
|
333
|
+
/**
|
|
334
|
+
* The key a terminal-started server for `root` wrote for itself (shell/key-file.ts), when it names
|
|
335
|
+
* `port` and a live pid; else null. Read only when the file is a regular file of this user, 0600
|
|
336
|
+
* (nothing for group or others) and small. Synchronous; never throws. The caller has already tied
|
|
337
|
+
* `port` to `root` (`/_health` rootId) — this never decides which server is the project's.
|
|
338
|
+
*/
|
|
339
|
+
export function terminalKeyFor(root, port, { env = process.env, alive = pidAlive } = {}) {
|
|
340
|
+
try {
|
|
341
|
+
const id = rootIdentity(root);
|
|
342
|
+
const file = join(serverKeyDir(env), `${id}.json`);
|
|
343
|
+
const st = lstatSync(file);
|
|
344
|
+
if (!st.isFile() || st.size > TERMINAL_KEY_MAX_BYTES) return null;
|
|
345
|
+
const uid = process.getuid?.();
|
|
346
|
+
if (uid !== undefined && st.uid !== uid) return null;
|
|
347
|
+
if (process.platform !== 'win32' && (st.mode & 0o077) !== 0) return null;
|
|
348
|
+
const rec = JSON.parse(readFileSync(file, 'utf8'));
|
|
349
|
+
if (rec?.v !== 1 || rec.rootId !== id || rec.port !== Number(port)) return null;
|
|
350
|
+
if (typeof rec.apiKey !== 'string' || !ATTEST_KEY_RE.test(rec.apiKey)) return null;
|
|
351
|
+
if (!Number.isInteger(rec.pid) || rec.pid <= 0 || !alive(rec.pid)) return null;
|
|
352
|
+
return rec.apiKey;
|
|
353
|
+
} catch {
|
|
354
|
+
return null;
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
/**
|
|
359
|
+
* A one-time launch token for a server holding `key` (shell/api-key.ts `mintLaunchToken`, verbatim).
|
|
360
|
+
* `helper` (a capture helper's own browser): `h<ts>.<nonce>.<mac>` under its own domain, so the
|
|
361
|
+
* server keeps that session in the helpers' small budget and it never evicts the person's.
|
|
362
|
+
*/
|
|
363
|
+
export function mintLaunchToken(key, nowSec = Math.floor(Date.now() / 1000), kind = 'person') {
|
|
364
|
+
const nonce = randomBytes(16).toString('hex');
|
|
365
|
+
const ts = String(Math.floor(nowSec));
|
|
366
|
+
const helper = kind === 'helper';
|
|
367
|
+
const domain = helper ? HELPER_LAUNCH_DOMAIN : LAUNCH_DOMAIN;
|
|
368
|
+
const mac = createHmac('sha256', key).update(`${domain}\n${ts}\n${nonce}`).digest('hex');
|
|
369
|
+
return `${helper ? 'h' : ''}${ts}.${nonce}.${mac}`;
|
|
370
|
+
}
|
|
371
|
+
|
|
372
|
+
/** `/_health` on `port` names `root` (a reused port may be another project's). */
|
|
373
|
+
async function healthNames(root, port, timeoutMs = 1500) {
|
|
374
|
+
try {
|
|
375
|
+
const res = await fetch(`http://127.0.0.1:${port}/_health`, {
|
|
376
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
377
|
+
});
|
|
378
|
+
if (!res.ok) return false;
|
|
379
|
+
const h = await res.json();
|
|
380
|
+
return h?.app === 'design' && h.rootId === rootIdentity(root);
|
|
381
|
+
} catch {
|
|
382
|
+
return false;
|
|
383
|
+
}
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
/**
|
|
387
|
+
* The key for whichever server serves `root` on `port`: the app's attested one (registry), else a
|
|
388
|
+
* terminal-started one (its key file, after `/_health` names this root). `{ key }` (null = that
|
|
389
|
+
* server needs none it told us about), or `{ unverified: true }` when the app serves this root but
|
|
390
|
+
* did not attest — fail closed, the same as `port` mode. Never throws.
|
|
391
|
+
*/
|
|
392
|
+
export async function serverKeyFor(root, port, opts = {}) {
|
|
393
|
+
const env = opts.env ?? process.env;
|
|
394
|
+
const p = await probeDesktop(root, { ...opts, env });
|
|
395
|
+
if (p.state === 'unverified') return { unverified: true };
|
|
396
|
+
if (p.state === 'running' && p.port === Number(port)) return { key: p.apiKey ?? null };
|
|
397
|
+
// A terminal server's key file is read first: with none there is nothing to send, so no probe
|
|
398
|
+
// goes out (a keyless server keeps answering the helpers exactly as before). With one, the key
|
|
399
|
+
// still leaves only after `/_health` names this project on that port.
|
|
400
|
+
const key = terminalKeyFor(root, port, { env });
|
|
401
|
+
if (!key) return { key: null };
|
|
402
|
+
if (!(await healthNames(root, port, opts.timeoutMs))) return { key: null };
|
|
403
|
+
return { key };
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* `serverKeyFor` for a synchronous caller (`claimWritesSync`): the app's entry for `port` is believed
|
|
408
|
+
* only when `attest(port, nonce)` (the caller's own synchronous GET of `/_api/shell/attest?n=`)
|
|
409
|
+
* returns the MAC its attest key makes; else a terminal server's key file. Never throws.
|
|
410
|
+
*/
|
|
411
|
+
export function serverKeyForSync(root, port, { env = process.env, alive = pidAlive, attest } = {}) {
|
|
412
|
+
try {
|
|
413
|
+
const p = Number(port);
|
|
414
|
+
const view = appView(root, env, alive);
|
|
415
|
+
const e = view?.entries.find((x) => x.state === 'running' && x.port === p);
|
|
416
|
+
if (e) {
|
|
417
|
+
if (!e.apiKey || !e.attestKey || typeof attest !== 'function') return null;
|
|
418
|
+
const n = randomBytes(16).toString('hex');
|
|
419
|
+
return macMatches(attest(p, n), attestMac(e.attestKey, n, view.rootId, p)) ? e.apiKey : null;
|
|
420
|
+
}
|
|
421
|
+
return terminalKeyFor(root, p, { env, alive });
|
|
422
|
+
} catch {
|
|
423
|
+
return null;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* sec-loopback-bearer §7.6 — the API key for `root`'s app server on `port`, or null (no app, another
|
|
429
|
+
* port, no key, or the server there did not attest). Never throws.
|
|
430
|
+
*/
|
|
431
|
+
export async function apiKeyFor(root, port, opts = {}) {
|
|
432
|
+
const p = await probeDesktop(root, opts);
|
|
433
|
+
return p.state === 'running' && p.port === Number(port) ? (p.apiKey ?? null) : null;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/**
|
|
437
|
+
* `locateDesktop`, waited for: a tab the app has just shown may still be booting its server (the
|
|
438
|
+
* app waits up to 45 s for one). Null once `waitMs` has passed or the app is gone.
|
|
439
|
+
*/
|
|
440
|
+
export async function waitDesktop(root, { waitMs = 45_000, pollMs = 500, ...opts } = {}) {
|
|
441
|
+
const until = Date.now() + waitMs;
|
|
442
|
+
for (;;) {
|
|
443
|
+
const p = await probeDesktop(root, opts);
|
|
444
|
+
if (p.state === 'running') return served(p);
|
|
445
|
+
if (p.state === 'no-app' || Date.now() >= until) return null;
|
|
446
|
+
await sleep(pollMs);
|
|
447
|
+
}
|
|
448
|
+
}
|
|
449
|
+
|
|
450
|
+
/**
|
|
451
|
+
* One request over the app socket: `{ v: 1, ...req }`, one JSON reply. Null when the app is not
|
|
452
|
+
* running, there is no socket, or the exchange fails. Never throws.
|
|
453
|
+
*/
|
|
454
|
+
export async function askApp(req, { env = process.env, alive = pidAlive, timeoutMs = 2500 } = {}) {
|
|
455
|
+
const file = registryPath(env);
|
|
456
|
+
const reg = readRegistry(file);
|
|
457
|
+
if (!reg || !alive(reg.appPid)) return null;
|
|
458
|
+
const sock = appSocketPath(file);
|
|
459
|
+
if (!sock) return null;
|
|
460
|
+
const body = `${JSON.stringify({ v: 1, ...req })}\n`;
|
|
461
|
+
if (Buffer.byteLength(body) > 8192) return null;
|
|
462
|
+
return new Promise((done) => {
|
|
463
|
+
let buf = '';
|
|
464
|
+
let settled = false;
|
|
465
|
+
const finish = (v) => {
|
|
466
|
+
if (settled) return;
|
|
467
|
+
settled = true;
|
|
468
|
+
clearTimeout(timer);
|
|
469
|
+
try {
|
|
470
|
+
c.destroy();
|
|
471
|
+
} catch {
|
|
472
|
+
/* closed */
|
|
473
|
+
}
|
|
474
|
+
done(v);
|
|
475
|
+
};
|
|
476
|
+
const tryParse = () => {
|
|
477
|
+
try {
|
|
478
|
+
const v = JSON.parse(buf);
|
|
479
|
+
return v && typeof v === 'object' ? v : null;
|
|
480
|
+
} catch {
|
|
481
|
+
return undefined;
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
const c = createConnection({ path: sock });
|
|
485
|
+
const timer = setTimeout(() => finish(null), timeoutMs);
|
|
486
|
+
c.setEncoding('utf8');
|
|
487
|
+
c.on('connect', () => c.end(body));
|
|
488
|
+
c.on('data', (d) => {
|
|
489
|
+
buf += d;
|
|
490
|
+
if (buf.length > REPLY_MAX_BYTES) return finish(null);
|
|
491
|
+
const v = tryParse();
|
|
492
|
+
if (v !== undefined) finish(v);
|
|
493
|
+
});
|
|
494
|
+
c.on('end', () => finish(tryParse() ?? null));
|
|
495
|
+
c.on('error', () => finish(null));
|
|
496
|
+
});
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
const leaseId = (root) => `cli-${rootIdentity(root)}`;
|
|
500
|
+
|
|
501
|
+
/** Best-effort lease renewal for an app tab this run is using (contract §6 "Busy"). */
|
|
502
|
+
export async function renewLease(root, { env = process.env, ttlSec = 300 } = {}) {
|
|
503
|
+
const r = await askApp(
|
|
504
|
+
{ op: 'lease', id: leaseId(root), root: real(root) ?? resolve(root), ttlSec },
|
|
505
|
+
{ env, timeoutMs: 1000 }
|
|
506
|
+
);
|
|
507
|
+
return r?.ok === true;
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/** After the app said `running` on `port`: the registry's entry for it must attest. */
|
|
511
|
+
async function attestReplyPort(root, port, { env, alive, timeoutMs, waitMs = 3000 }) {
|
|
512
|
+
const until = Date.now() + waitMs;
|
|
513
|
+
for (;;) {
|
|
514
|
+
const v = appView(root, env, alive);
|
|
515
|
+
const e = v?.entries.find((x) => x.state === 'running' && x.port === port);
|
|
516
|
+
if (e && (await verifyAttest(port, e, { rootId: v.rootId, timeoutMs }))) return e;
|
|
517
|
+
if (Date.now() >= until) return null;
|
|
518
|
+
await sleep(250);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* Ask the app to serve (`purpose:'capture'`) or show (`op:'show'`) `root`, and wait out a consent
|
|
524
|
+
* sheet (≤ consentWaitMs). Never throws.
|
|
525
|
+
* { state: 'running', port, label, kind, warning? } attested
|
|
526
|
+
* { state: 'shown', label } op 'show' only
|
|
527
|
+
* { state: 'fallback', reason, line? } use today's path (a separate server)
|
|
528
|
+
* { state: 'refused', reason, line } stop: the app said no for a reason that
|
|
529
|
+
* must reach the person (exit 4)
|
|
530
|
+
*/
|
|
531
|
+
export async function ensureDesktop(
|
|
532
|
+
root,
|
|
533
|
+
{
|
|
534
|
+
env = process.env,
|
|
535
|
+
alive = pidAlive,
|
|
536
|
+
purpose = 'capture',
|
|
537
|
+
show = null,
|
|
538
|
+
lease = true,
|
|
539
|
+
timeoutMs = 1500,
|
|
540
|
+
// the app answers `ensure` (and a `status` whose sheet was answered Open) only once the tab's
|
|
541
|
+
// server is up — it waits up to 45 s for one (cli_channel.rs SERVER_WAIT_MS)
|
|
542
|
+
ensureTimeoutMs = 50_000,
|
|
543
|
+
consentWaitMs = 60_000,
|
|
544
|
+
pollMs = 1000,
|
|
545
|
+
log = () => {},
|
|
546
|
+
} = {}
|
|
547
|
+
) {
|
|
548
|
+
const absRoot = real(root) ?? resolve(root);
|
|
549
|
+
const req =
|
|
550
|
+
purpose === 'show'
|
|
551
|
+
? { op: 'show', root: absRoot, ...(show ?? {}) }
|
|
552
|
+
: {
|
|
553
|
+
op: 'ensure',
|
|
554
|
+
root: absRoot,
|
|
555
|
+
purpose,
|
|
556
|
+
...(lease ? { lease: { id: leaseId(root), ttlSec: 300 } } : {}),
|
|
557
|
+
};
|
|
558
|
+
const expectBranch = env.MAUDE_EXPECT_BRANCH;
|
|
559
|
+
if (req.op === 'ensure' && expectBranch) req.expect = { branch: expectBranch };
|
|
560
|
+
let reply = await askApp(req, { env, alive, timeoutMs: ensureTimeoutMs });
|
|
561
|
+
if (!reply) return { state: 'fallback', reason: 'no-socket' };
|
|
562
|
+
const until = Date.now() + consentWaitMs;
|
|
563
|
+
let asked = false;
|
|
564
|
+
while (reply?.status === 'consent' && typeof reply.ticket === 'string') {
|
|
565
|
+
if (!asked) log('… Maude is asking whether to open this folder — answer in the Maude window.');
|
|
566
|
+
asked = true;
|
|
567
|
+
if (Date.now() >= until) return { state: 'fallback', reason: 'consent-timeout' };
|
|
568
|
+
await sleep(pollMs);
|
|
569
|
+
reply =
|
|
570
|
+
(await askApp(
|
|
571
|
+
{ op: 'status', ticket: reply.ticket },
|
|
572
|
+
{ env, alive, timeoutMs: ensureTimeoutMs }
|
|
573
|
+
)) ?? reply;
|
|
574
|
+
}
|
|
575
|
+
const warning = reply?.warning;
|
|
576
|
+
if (warning?.kind === 'branch-changed') {
|
|
577
|
+
const was = typeof warning.was === 'string' ? cleanName(warning.was) : '?';
|
|
578
|
+
const now = typeof warning.now === 'string' ? cleanName(warning.now) : '?';
|
|
579
|
+
log(`! This folder switched from ${was} to ${now}; Maude relabelled its tab.`);
|
|
580
|
+
}
|
|
581
|
+
switch (reply?.status) {
|
|
582
|
+
case 'shown':
|
|
583
|
+
return { state: 'shown', label: typeof reply.label === 'string' ? reply.label : null };
|
|
584
|
+
case 'running': {
|
|
585
|
+
if (!validPort(reply.port)) return { state: 'fallback', reason: 'bad-reply' };
|
|
586
|
+
const e = await attestReplyPort(root, reply.port, { env, alive, timeoutMs });
|
|
587
|
+
if (!e) return { state: 'fallback', reason: 'unverified' };
|
|
588
|
+
return {
|
|
589
|
+
state: 'running',
|
|
590
|
+
port: reply.port,
|
|
591
|
+
label: e.label ?? null,
|
|
592
|
+
kind: e.kind,
|
|
593
|
+
...(e.apiKey ? { apiKey: e.apiKey } : {}),
|
|
594
|
+
...(warning ? { warning } : {}),
|
|
595
|
+
};
|
|
596
|
+
}
|
|
597
|
+
case 'cap-full':
|
|
598
|
+
return { state: 'fallback', reason: 'cap-full', line: CAP_FULL_LINE };
|
|
599
|
+
case 'denied':
|
|
600
|
+
return { state: 'fallback', reason: 'denied' };
|
|
601
|
+
case 'refused':
|
|
602
|
+
if (reply.reason === 'branch-changed-unsent')
|
|
603
|
+
return { state: 'refused', reason: reply.reason, line: BRANCH_UNSENT_LINE };
|
|
604
|
+
if (reply.reason === 'too-many-sheets')
|
|
605
|
+
return { state: 'fallback', reason: reply.reason, line: SHEET_LIMIT_LINE };
|
|
606
|
+
return { state: 'fallback', reason: 'refused' };
|
|
607
|
+
default:
|
|
608
|
+
return { state: 'fallback', reason: 'bad-reply' };
|
|
609
|
+
}
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
/** Is `pid` the app or one of the servers its registry names? (never signal those) */
|
|
613
|
+
export function isAppPid(pid, { env = process.env } = {}) {
|
|
614
|
+
if (!Number.isInteger(pid) || pid <= 0) return false;
|
|
615
|
+
const reg = readRegistry(registryPath(env));
|
|
616
|
+
if (!reg) return false;
|
|
617
|
+
return reg.appPid === pid || reg.servers.some((e) => e.pid === pid);
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
/* ---------------------------------------------------------------------------------- the CLI */
|
|
621
|
+
|
|
622
|
+
const USAGE = `usage: desktop-locate.mjs <mode> --root <repo> [options]
|
|
623
|
+
port [--ensure capture|show] [--lease] print the app server's port for the project
|
|
624
|
+
show [--canvas c] [--artboard a] [--element e] [--mode m] ask the app to show the project
|
|
625
|
+
restart ask the app to restart its server for the project
|
|
626
|
+
key --port N print the API key of the server on port N (the app's
|
|
627
|
+
attested one, else a terminal server's key file)
|
|
628
|
+
launch-url --port N [--host 127.0.0.1] [--helper] print a one-time opening URL for the server on
|
|
629
|
+
port N (--helper: for a capture helper's own browser)
|
|
630
|
+
app-pid --pid N exit 0 when N is the app or one of its servers
|
|
631
|
+
exit: 0 ok · 10 not the app's (use the project's own server; no key) · 11 the app serves this project but
|
|
632
|
+
it did not answer the check (do not use _server.json) · 4 refused (message on stderr) · 2 usage
|
|
633
|
+
`;
|
|
634
|
+
|
|
635
|
+
function argsOf(argv) {
|
|
636
|
+
const o = { mode: argv[0] };
|
|
637
|
+
for (let i = 1; i < argv.length; i++) {
|
|
638
|
+
const a = argv[i];
|
|
639
|
+
const v = argv[i + 1];
|
|
640
|
+
if (a === '--lease') o.lease = true;
|
|
641
|
+
else if (a === '--helper') o.helper = true;
|
|
642
|
+
else if (
|
|
643
|
+
[
|
|
644
|
+
'--root',
|
|
645
|
+
'--ensure',
|
|
646
|
+
'--canvas',
|
|
647
|
+
'--artboard',
|
|
648
|
+
'--element',
|
|
649
|
+
'--mode',
|
|
650
|
+
'--pid',
|
|
651
|
+
'--port',
|
|
652
|
+
'--host',
|
|
653
|
+
].includes(a)
|
|
654
|
+
) {
|
|
655
|
+
if (v === undefined) return { error: `${a} needs a value` };
|
|
656
|
+
o[a.slice(2)] = v;
|
|
657
|
+
i++;
|
|
658
|
+
} else return { error: `unknown arg ${a}` };
|
|
659
|
+
}
|
|
660
|
+
return o;
|
|
661
|
+
}
|
|
662
|
+
|
|
663
|
+
export async function main(
|
|
664
|
+
argv,
|
|
665
|
+
{ env = process.env, out = process.stdout, err = process.stderr } = {}
|
|
666
|
+
) {
|
|
667
|
+
const a = argsOf(argv);
|
|
668
|
+
if (a.error || !a.mode) {
|
|
669
|
+
err.write(`${a.error ? `desktop-locate: ${a.error}\n` : ''}${USAGE}`);
|
|
670
|
+
return 2;
|
|
671
|
+
}
|
|
672
|
+
const log = (l) => err.write(`${l}\n`);
|
|
673
|
+
const refuse = (line) => {
|
|
674
|
+
log(`✗ ${line}`);
|
|
675
|
+
return 4;
|
|
676
|
+
};
|
|
677
|
+
if (a.mode === 'app-pid') return isAppPid(Number(a.pid), { env }) ? 0 : 1;
|
|
678
|
+
if (!a.root) {
|
|
679
|
+
err.write(`desktop-locate: --root is required\n${USAGE}`);
|
|
680
|
+
return 2;
|
|
681
|
+
}
|
|
682
|
+
const root = resolve(a.root);
|
|
683
|
+
if (a.mode === 'port') {
|
|
684
|
+
const p = await probeDesktop(root, { env, attempts: 4, retryDelayMs: 750 });
|
|
685
|
+
// `--ensure show` (/design:browse): the app shows the project itself — nothing on stdout
|
|
686
|
+
if (a.ensure === 'show' && p.state !== 'no-app' && p.socket) {
|
|
687
|
+
const r = await ensureDesktop(root, { env, purpose: 'show', log });
|
|
688
|
+
if (r.state === 'shown') {
|
|
689
|
+
log('✓ Maude is showing this project.');
|
|
690
|
+
return 0;
|
|
691
|
+
}
|
|
692
|
+
if (r.state === 'refused') return refuse(r.line);
|
|
693
|
+
if (r.line) log(r.line);
|
|
694
|
+
}
|
|
695
|
+
if (p.state === 'running') {
|
|
696
|
+
if (a.lease && p.socket) await renewLease(root, { env });
|
|
697
|
+
out.write(`${p.port}\n`);
|
|
698
|
+
return 0;
|
|
699
|
+
}
|
|
700
|
+
if (p.state === 'unverified') {
|
|
701
|
+
log(
|
|
702
|
+
'✗ Maude has this project open, but its server did not answer the check. Close and reopen the tab in Maude, or quit Maude to use a separate server.'
|
|
703
|
+
);
|
|
704
|
+
return 11;
|
|
705
|
+
}
|
|
706
|
+
if (p.state === 'no-app' || a.ensure !== 'capture' || !p.socket) return 10;
|
|
707
|
+
const r = await ensureDesktop(root, { env, purpose: 'capture', lease: !!a.lease, log });
|
|
708
|
+
if (r.state === 'running') {
|
|
709
|
+
out.write(`${r.port}\n`);
|
|
710
|
+
return 0;
|
|
711
|
+
}
|
|
712
|
+
if (r.state === 'refused') return refuse(r.line);
|
|
713
|
+
if (r.line) log(r.line);
|
|
714
|
+
return 10;
|
|
715
|
+
}
|
|
716
|
+
if (a.mode === 'show') {
|
|
717
|
+
const show = {};
|
|
718
|
+
for (const k of ['canvas', 'artboard', 'element', 'mode']) if (a[k]) show[k] = a[k];
|
|
719
|
+
const r = await ensureDesktop(root, { env, purpose: 'show', show, log });
|
|
720
|
+
if (r.state === 'shown') return 0;
|
|
721
|
+
if (r.state === 'refused') return refuse(r.line);
|
|
722
|
+
return 10;
|
|
723
|
+
}
|
|
724
|
+
if (a.mode === 'key' || a.mode === 'launch-url') {
|
|
725
|
+
if (!validPort(Number(a.port))) {
|
|
726
|
+
err.write(`desktop-locate: ${a.mode} needs --port N\n${USAGE}`);
|
|
727
|
+
return 2;
|
|
728
|
+
}
|
|
729
|
+
// the app's attested server, else a terminal-started one's key file (sec-loopback-bearer §7.5)
|
|
730
|
+
const r = await serverKeyFor(root, Number(a.port), { env });
|
|
731
|
+
if (r.unverified) return 11;
|
|
732
|
+
if (a.mode === 'launch-url') {
|
|
733
|
+
// a browser opens the studio with a one-time token (a server that needs no key: the plain URL)
|
|
734
|
+
const host = a.host === '127.0.0.1' ? '127.0.0.1' : 'localhost';
|
|
735
|
+
const base = `http://${host}:${Number(a.port)}/`;
|
|
736
|
+
const token = r.key ? mintLaunchToken(r.key, undefined, a.helper ? 'helper' : 'person') : '';
|
|
737
|
+
out.write(`${token ? `${base}?${LAUNCH_PARAM}=${token}` : base}\n`);
|
|
738
|
+
return 0;
|
|
739
|
+
}
|
|
740
|
+
if (!r.key) return 10;
|
|
741
|
+
// stdout is the key and nothing else: a helper captures it into a shell variable and hands it to
|
|
742
|
+
// curl through a config on stdin, never argv (sec-loopback-bearer §7.6)
|
|
743
|
+
out.write(`${r.key}\n`);
|
|
744
|
+
return 0;
|
|
745
|
+
}
|
|
746
|
+
if (a.mode === 'restart') {
|
|
747
|
+
const r = await askApp({ op: 'restart', root: real(root) ?? root }, { env, timeoutMs: 5000 });
|
|
748
|
+
if (!r) return 10;
|
|
749
|
+
return r.status === 'restarting' ? 0 : 4;
|
|
750
|
+
}
|
|
751
|
+
err.write(`desktop-locate: unknown mode ${a.mode}\n${USAGE}`);
|
|
752
|
+
return 2;
|
|
753
|
+
}
|
|
754
|
+
|
|
755
|
+
const isMain = (() => {
|
|
756
|
+
try {
|
|
757
|
+
return (
|
|
758
|
+
!!process.argv[1] &&
|
|
759
|
+
realpathSync(process.argv[1]) === realpathSync(fileURLToPath(import.meta.url))
|
|
760
|
+
);
|
|
761
|
+
} catch {
|
|
762
|
+
return false;
|
|
763
|
+
}
|
|
764
|
+
})();
|
|
765
|
+
if (isMain) {
|
|
766
|
+
main(process.argv.slice(2)).then(
|
|
767
|
+
(code) => process.exit(code),
|
|
768
|
+
() => process.exit(10)
|
|
769
|
+
);
|
|
770
|
+
}
|