@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
package/cli/lib/design-hook.mjs
CHANGED
|
@@ -24,13 +24,16 @@
|
|
|
24
24
|
//
|
|
25
25
|
// State per Claude Code session in <designRoot>/_runs/<session>/ (runtime, DDR-115):
|
|
26
26
|
// snap/<tool_use_id> bytes before that edit (`.new` marker: the file did not exist)
|
|
27
|
-
// base/<sha(path)> bytes before the run first touched the file (stop-tier `against`)
|
|
28
|
-
//
|
|
27
|
+
// base/<sha(path)> bytes before the run first touched the file (stop-tier `against`)
|
|
28
|
+
// #168 E1: each counts only while it hashes to its record in the hook
|
|
29
|
+
// state outside the project (hook-state.mjs `<session>/snaps/`), where
|
|
30
|
+
// the `.bash` mark also lives: an AI shell call wrote the file first — no
|
|
31
|
+
// base, Stop checks it whole
|
|
29
32
|
// Only the hooks write base/, snap/, bash/, touched.json and stop-last* — main agent included (D1).
|
|
30
33
|
// touched.json files this run changed ({at, by, via, artboards}: artboards the
|
|
31
34
|
// studio mapped the edits to; null = unknown → any capture of the canvas)
|
|
32
|
-
//
|
|
33
|
-
//
|
|
35
|
+
// Stop's screenshot gate reads the captures `maude design screenshot` made under this session from
|
|
36
|
+
// the hook state only (#168 E3: `<session>/shots.jsonl`, or the root's when no session is known).
|
|
34
37
|
// bash/<tool_use_id>.json a write verb's start ({at, snaps}) — post-bash binds what changed since;
|
|
35
38
|
// a call that leaves a process running ({bg, by, seen}) keeps it until
|
|
36
39
|
// the run ends, and every Stop binds what changed since `seen`
|
|
@@ -67,18 +70,30 @@ import { dirname, isAbsolute, join, relative, resolve, sep } from 'node:path';
|
|
|
67
70
|
import {
|
|
68
71
|
bashBackgrounds,
|
|
69
72
|
bashMayWrite,
|
|
70
|
-
|
|
73
|
+
callCoverage,
|
|
71
74
|
classifyBash,
|
|
72
|
-
designLaneHashes,
|
|
73
75
|
designVerbOf,
|
|
74
76
|
designWritesSince,
|
|
77
|
+
laneDiff,
|
|
78
|
+
laneSnapshot,
|
|
75
79
|
maudeWords,
|
|
76
|
-
namedDesignFiles,
|
|
77
80
|
parseBash,
|
|
78
81
|
} from './bash-guard.mjs';
|
|
79
82
|
import { realpathDeep } from './confine-out.mjs';
|
|
80
83
|
import { sessionRoot } from './confine-root.mjs';
|
|
81
84
|
import { cleanFinding, cleanText, fileText, findingLine } from './finding-text.mjs';
|
|
85
|
+
import {
|
|
86
|
+
bashStatePath,
|
|
87
|
+
dropRunState,
|
|
88
|
+
lanesCachePath,
|
|
89
|
+
pruneStates,
|
|
90
|
+
readState,
|
|
91
|
+
removeState,
|
|
92
|
+
shotsPath,
|
|
93
|
+
snapshotRecordPath,
|
|
94
|
+
writePrivateCopy,
|
|
95
|
+
writeState,
|
|
96
|
+
} from './hook-state.mjs';
|
|
82
97
|
import { DESIGN_REL, findProjectRoot, locateStudio, postStudio } from './studio-locate.mjs';
|
|
83
98
|
|
|
84
99
|
export const HOOK_EVENTS = [
|
|
@@ -649,7 +664,7 @@ async function sessionStart(ctx) {
|
|
|
649
664
|
`export MAUDE_HOOK_SESSION=${ctx.session}\nexport MAUDE_SESSION_ROOT=${q}\n`
|
|
650
665
|
);
|
|
651
666
|
} catch {
|
|
652
|
-
/* no env file: captures go to
|
|
667
|
+
/* no env file: captures go to the root's session-less record */
|
|
653
668
|
}
|
|
654
669
|
}
|
|
655
670
|
const lines = [];
|
|
@@ -805,21 +820,54 @@ function targetOf(ctx, input) {
|
|
|
805
820
|
const snapRel = (ctx, toolUseId) => `_runs/${ctx.session}/snap/${toolUseId}`;
|
|
806
821
|
const baseRel = (ctx, rel) => `_runs/${ctx.session}/base/${sha(rel).slice(0, 16)}`;
|
|
807
822
|
|
|
808
|
-
/**
|
|
823
|
+
/** `_runs/<session>/{snap|base}/<name>` → its hash record in the hook state, or null. */
|
|
824
|
+
const SNAP_REL_RE = /^_runs\/([A-Za-z0-9_-]{1,128})\/(snap|base)\/([^/]+)$/;
|
|
825
|
+
function snapRecord(ctx, rel) {
|
|
826
|
+
const m = SNAP_REL_RE.exec(rel);
|
|
827
|
+
return m ? snapshotRecordPath(ctx.root, m[1], m[2], m[3]) : null;
|
|
828
|
+
}
|
|
829
|
+
|
|
830
|
+
/**
|
|
831
|
+
* Save `cur` (or the "did not exist" marker) at `rel` under designRoot — the studio reads it there —
|
|
832
|
+
* and its sha256 in the hook state outside the project (#168 E1): `loadSnapshot` trusts the bytes
|
|
833
|
+
* only while they hash to that record. No record (an unsafe name, a failed write) = no snapshot.
|
|
834
|
+
*/
|
|
809
835
|
function saveSnapshot(ctx, rel, cur) {
|
|
836
|
+
const rec = snapRecord(ctx, rel);
|
|
837
|
+
if (!rec) return;
|
|
810
838
|
const abs = join(ctx.designRoot, rel);
|
|
811
|
-
|
|
812
|
-
|
|
839
|
+
try {
|
|
840
|
+
if (cur === null) writeAt(`${abs}.new`, '');
|
|
841
|
+
else writeAt(abs, cur);
|
|
842
|
+
writeState(
|
|
843
|
+
rec,
|
|
844
|
+
cur === null ? { v: 1, existed: false } : { v: 1, existed: true, sha: sha(cur) }
|
|
845
|
+
);
|
|
846
|
+
} catch {
|
|
847
|
+
removeState(rec);
|
|
848
|
+
}
|
|
813
849
|
}
|
|
850
|
+
const verifiedCopy = (ctx, content) => writePrivateCopy(ctx.root, ctx.session, content);
|
|
851
|
+
/** Has the hook recorded a snapshot (or a shell mark) at `rel` — whatever its bytes now hold? */
|
|
852
|
+
const snapshotRecorded = (ctx, rel) => {
|
|
853
|
+
const rec = snapRecord(ctx, rel);
|
|
854
|
+
return rec !== null && readState(rec) !== null;
|
|
855
|
+
};
|
|
814
856
|
/**
|
|
815
857
|
* p8-secfix-hook F4 — the run base is the file as it was before the run first wrote it. A shell
|
|
816
858
|
* call the hook can't read (a python heredoc, `nohup … &`) writes without a snapshot, so the next
|
|
817
859
|
* edit's first sight of the file would be AFTER that write and every finding the shell call planted
|
|
818
|
-
* would read as "pre-existing". Such a file gets a `.bash`
|
|
860
|
+
* would read as "pre-existing". Such a file gets a `.bash` mark instead of a base: no base is
|
|
819
861
|
* ever saved for it in this run, and Stop checks it with none (every finding counts as the run's).
|
|
862
|
+
* #168 E1: the mark is a hook-state record (outside the project), so removing a file in the run
|
|
863
|
+
* folder never lets a base be taken after the shell write.
|
|
820
864
|
*/
|
|
821
|
-
const
|
|
822
|
-
const shellWrote = (ctx, rel) =>
|
|
865
|
+
const shellMarkRel = (ctx, rel) => `${baseRel(ctx, rel)}.bash`;
|
|
866
|
+
const shellWrote = (ctx, rel) => snapshotRecorded(ctx, shellMarkRel(ctx, rel));
|
|
867
|
+
function writeShellMark(ctx, rel) {
|
|
868
|
+
const rec = snapRecord(ctx, shellMarkRel(ctx, rel));
|
|
869
|
+
if (rec) writeState(rec, { v: 1, shell: true });
|
|
870
|
+
}
|
|
823
871
|
|
|
824
872
|
/**
|
|
825
873
|
* p8-secfix-hook-2 N1 — when this turn began (`turn.json`, written by the prompt hook), or null
|
|
@@ -861,27 +909,37 @@ function shellMayHaveWritten(ctx, rel) {
|
|
|
861
909
|
});
|
|
862
910
|
}
|
|
863
911
|
|
|
864
|
-
/**
|
|
912
|
+
/**
|
|
913
|
+
* Save the run's base of `rel` (= `cur`) unless it has one, or a shell call wrote it first. A base
|
|
914
|
+
* the hook recorded counts as had even when its bytes were changed since (#168 E1): it is never
|
|
915
|
+
* re-taken from the file, and Stop then checks the file with no base.
|
|
916
|
+
*/
|
|
865
917
|
function ensureBase(ctx, rel, cur) {
|
|
866
918
|
const base = baseRel(ctx, rel);
|
|
867
|
-
if (
|
|
868
|
-
if (shellMayHaveWritten(ctx, rel))
|
|
919
|
+
if (snapshotRecorded(ctx, base) || shellWrote(ctx, rel)) return;
|
|
920
|
+
if (shellMayHaveWritten(ctx, rel)) writeShellMark(ctx, rel);
|
|
869
921
|
else saveSnapshot(ctx, base, cur);
|
|
870
922
|
}
|
|
871
923
|
|
|
872
924
|
/** A shell call wrote `rel` before the run had a base of it: mark it (see ensureBase). */
|
|
873
925
|
function markShellWrite(ctx, rel) {
|
|
874
|
-
if (!
|
|
875
|
-
writeAt(shellMarkAbs(ctx, rel), '');
|
|
926
|
+
if (!snapshotRecorded(ctx, baseRel(ctx, rel)) && !shellWrote(ctx, rel)) writeShellMark(ctx, rel);
|
|
876
927
|
}
|
|
877
928
|
|
|
878
|
-
/**
|
|
929
|
+
/**
|
|
930
|
+
* { existed, content, rel, sha } of a saved snapshot, or null when there is none. #168 E1: only one
|
|
931
|
+
* the hook recorded, whose bytes still hash to the record — a copy planted in the run folder, or one
|
|
932
|
+
* rewritten since, is no snapshot.
|
|
933
|
+
*/
|
|
879
934
|
function loadSnapshot(ctx, rel) {
|
|
880
|
-
const
|
|
881
|
-
const
|
|
882
|
-
if (
|
|
883
|
-
if (
|
|
884
|
-
return null;
|
|
935
|
+
const rec = snapRecord(ctx, rel);
|
|
936
|
+
const r = rec ? readState(rec) : null;
|
|
937
|
+
if (r?.v !== 1) return null;
|
|
938
|
+
if (r.existed === false) return { existed: false, content: null, rel };
|
|
939
|
+
if (r.existed !== true || typeof r.sha !== 'string') return null;
|
|
940
|
+
const content = readOr(join(ctx.designRoot, rel));
|
|
941
|
+
if (content === null || sha(content) !== r.sha) return null;
|
|
942
|
+
return { existed: true, content, rel, sha: r.sha };
|
|
885
943
|
}
|
|
886
944
|
|
|
887
945
|
/**
|
|
@@ -902,7 +960,8 @@ async function check(ctx, studio, rel, tier, snapshot, self) {
|
|
|
902
960
|
tier,
|
|
903
961
|
strict: true,
|
|
904
962
|
introduced: true,
|
|
905
|
-
|
|
963
|
+
// #168 E1: the hash the hook verified, so the studio can refuse bytes changed since
|
|
964
|
+
...(snapshot?.existed ? { snapshot: snapshot.rel, snapshotSha: snapshot.sha } : {}),
|
|
906
965
|
},
|
|
907
966
|
{ timeoutMs: 900 }
|
|
908
967
|
);
|
|
@@ -924,12 +983,21 @@ async function check(ctx, studio, rel, tier, snapshot, self) {
|
|
|
924
983
|
'--root',
|
|
925
984
|
ctx.root,
|
|
926
985
|
];
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
986
|
+
// #168 E1: the local check reads the bytes the hook verified, from the hook state — not the run
|
|
987
|
+
// folder copy, which could change between the hash check and the read
|
|
988
|
+
const against = snapshot?.existed ? verifiedCopy(ctx, snapshot.content) : null;
|
|
989
|
+
if (against) args.push('--against', against);
|
|
990
|
+
else if (snapshot?.existed) return null; // could not hold the verified bytes: fail open
|
|
991
|
+
let p;
|
|
992
|
+
try {
|
|
993
|
+
p = spawnSync(self[0], [...self.slice(1), 'design', 'check', ...args], {
|
|
994
|
+
encoding: 'utf8',
|
|
995
|
+
timeout: tier === 'stop' ? 20000 : 1200,
|
|
996
|
+
env: { ...process.env, MAUDE_NO_UPDATE_CHECK: '1' },
|
|
997
|
+
});
|
|
998
|
+
} finally {
|
|
999
|
+
if (against) removeState(against);
|
|
1000
|
+
}
|
|
933
1001
|
try {
|
|
934
1002
|
const results = JSON.parse(p.stdout);
|
|
935
1003
|
const errors = results.flatMap((x) => x.errors ?? []);
|
|
@@ -1152,11 +1220,15 @@ function recordTouch(ctx, rel, { by, via, artboards, at = Date.now() }) {
|
|
|
1152
1220
|
writeAt(p, JSON.stringify(touched));
|
|
1153
1221
|
}
|
|
1154
1222
|
|
|
1155
|
-
/**
|
|
1223
|
+
/**
|
|
1224
|
+
* Captures of `rel` at or after `since`: this session's shots, plus session-less ones. #168 E3: read
|
|
1225
|
+
* only from the hook state outside the project (`_record-shot.sh` writes there); a shots.jsonl in
|
|
1226
|
+
* the run folder is never evidence.
|
|
1227
|
+
*/
|
|
1156
1228
|
function shotsOf(ctx, rel, since) {
|
|
1157
1229
|
const out = [];
|
|
1158
|
-
for (const p of [
|
|
1159
|
-
const text = readOr(p);
|
|
1230
|
+
for (const p of [shotsPath(ctx.root, ctx.session), shotsPath(ctx.root, null)]) {
|
|
1231
|
+
const text = p ? readOr(p) : null;
|
|
1160
1232
|
if (!text) continue;
|
|
1161
1233
|
for (const line of text.split('\n')) {
|
|
1162
1234
|
try {
|
|
@@ -1394,22 +1466,49 @@ async function preBash(ctx, input) {
|
|
|
1394
1466
|
// p8-secfix-hook F2 — a call that leaves a process running (`nohup … &`, `run_in_background`)
|
|
1395
1467
|
// keeps its mark until the turn ends: Stop binds what that process wrote after the call returned
|
|
1396
1468
|
const bg =
|
|
1397
|
-
input.tool_input?.run_in_background === true ||
|
|
1469
|
+
input.tool_input?.run_in_background === true ||
|
|
1470
|
+
// #168 E4: a script file the call runs (inside the project) is read for detaching too
|
|
1471
|
+
bashBackgrounds(command, { unparsed: false, cwd: ctx.cwd, root: ctx.root })
|
|
1398
1472
|
? { bg: true, by: input.agent_type ?? 'main' }
|
|
1399
1473
|
: {};
|
|
1400
1474
|
// p8-a1-claims — `interp`: something in the call writes without claiming (no table: assume so).
|
|
1401
1475
|
// A terminal-lane verb cannot claim either (no MAUDE_CHAT_ID names a chat).
|
|
1402
|
-
const interp = !
|
|
1403
|
-
// Such a call gets a time window for the canvases its command NAMES only (bash-guard
|
|
1404
|
-
// `namedDesignFiles`): a person's save to any other canvas during it stays theirs.
|
|
1405
|
-
const files = interp ? namedDesignFiles(ctx.designRoot, command) : [];
|
|
1406
|
-
// p8-sec2-attrib A1 — a path it only computes (`sed -i … *.tsx`, `find -exec`, `'Ho'+'me.tsx'`) is
|
|
1407
|
-
// not named, yet the call may write it: hash every canvas lane now, so its end binds exactly the
|
|
1408
|
-
// files whose bytes changed (the studio drops what a person's save landed). A call that names
|
|
1409
|
-
// nothing opens an all-canvas window for the run stage instead (it takes outside writes; no hold).
|
|
1476
|
+
const interp = !claiming || bashMayWrite(command, claiming) || !hookChat();
|
|
1410
1477
|
const at = Date.now();
|
|
1411
|
-
|
|
1412
|
-
|
|
1478
|
+
// #164 — what such a call can plausibly write (bash-guard `callCoverage`): `named` canvases (a
|
|
1479
|
+
// create included), `all` of them, or `none` (`pnpm test`, `git pull`: no snapshot, no window; a
|
|
1480
|
+
// canvas it writes lands as outside). A terminal-lane verb whose only reason to be here is the missing
|
|
1481
|
+
// chat is never `all`.
|
|
1482
|
+
let cover = { mode: 'none', files: [] };
|
|
1483
|
+
if (interp) {
|
|
1484
|
+
cover = callCoverage(ctx.designRoot, ctx.cwd, command);
|
|
1485
|
+
if (cover.mode === 'all' && claiming && !bashMayWrite(command, claiming))
|
|
1486
|
+
cover = { mode: 'none', files: [] };
|
|
1487
|
+
}
|
|
1488
|
+
// The lane manifest (stat key + sha256 per canvas file) is taken now, outside the project
|
|
1489
|
+
// (hook-state.mjs): post-bash diffs against it and settles exactly the files whose bytes changed.
|
|
1490
|
+
// Any failure here means no window and no claim: the call's writes land as outside, never the AI's.
|
|
1491
|
+
if (cover.mode !== 'none') {
|
|
1492
|
+
try {
|
|
1493
|
+
const statePath = bashStatePath(ctx.root, ctx.session, toolUseId);
|
|
1494
|
+
if (!statePath) throw new Error('unsafe key');
|
|
1495
|
+
const manifest = laneSnapshot(ctx.designRoot, { cache: readState(lanesCachePath(ctx.root)) });
|
|
1496
|
+
writeState(statePath, {
|
|
1497
|
+
v: 1,
|
|
1498
|
+
at,
|
|
1499
|
+
mode: cover.mode,
|
|
1500
|
+
files: cover.files,
|
|
1501
|
+
...(verbOnly ? { verbOnly: true } : {}),
|
|
1502
|
+
...bg,
|
|
1503
|
+
snaps,
|
|
1504
|
+
manifest,
|
|
1505
|
+
});
|
|
1506
|
+
writeState(lanesCachePath(ctx.root), manifest);
|
|
1507
|
+
pruneStates(ctx.root);
|
|
1508
|
+
} catch {
|
|
1509
|
+
cover = { mode: 'none', files: [] };
|
|
1510
|
+
}
|
|
1511
|
+
}
|
|
1413
1512
|
writeAt(
|
|
1414
1513
|
join(ctx.run, 'bash', `${toolUseId}.json`),
|
|
1415
1514
|
JSON.stringify({
|
|
@@ -1417,10 +1516,11 @@ async function preBash(ctx, input) {
|
|
|
1417
1516
|
snaps,
|
|
1418
1517
|
...(verbOnly ? { verbOnly: true } : {}),
|
|
1419
1518
|
...bg,
|
|
1420
|
-
...(interp ? { interp: true,
|
|
1519
|
+
...(interp ? { interp: true, mode: cover.mode, files: cover.files } : {}),
|
|
1421
1520
|
})
|
|
1422
1521
|
);
|
|
1423
|
-
if (
|
|
1522
|
+
if (cover.mode !== 'none')
|
|
1523
|
+
await bashWindow(ctx, toolUseId, true, cover.files, cover.mode === 'all');
|
|
1424
1524
|
return null;
|
|
1425
1525
|
}
|
|
1426
1526
|
|
|
@@ -1517,26 +1617,207 @@ async function postBash(ctx, input) {
|
|
|
1517
1617
|
const toolUseId = hookKey(input.tool_use_id);
|
|
1518
1618
|
if (!toolUseId) return null;
|
|
1519
1619
|
const markP = join(ctx.run, 'bash', `${toolUseId}.json`);
|
|
1520
|
-
|
|
1620
|
+
// #164 F7 — a windowed call's mode, coverage and background flag come from the state file kept
|
|
1621
|
+
// OUTSIDE the project; the in-project mark (the AI can rewrite or delete it) adds nothing to them.
|
|
1622
|
+
const mark = effectiveMark(ctx, toolUseId, readJson(markP, null));
|
|
1521
1623
|
if (!mark || typeof mark.at !== 'number') return null; // not a write verb
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1624
|
+
const by = input.agent_type ?? 'main';
|
|
1625
|
+
// #164 — a call with a window (`named` / `all`) is settled by what it changed; a background one
|
|
1626
|
+
// keeps its window and settles at Stop (`drainBackground`)
|
|
1627
|
+
if (windowedMark(mark)) {
|
|
1628
|
+
if (!mark.bg) {
|
|
1629
|
+
await settleCall(ctx, toolUseId, mark, by);
|
|
1630
|
+
rmSync(markP, { force: true });
|
|
1631
|
+
} else writeAt(markP, JSON.stringify({ ...mark, seen: Date.now() }));
|
|
1632
|
+
return null;
|
|
1633
|
+
}
|
|
1634
|
+
// a call with no window (`none`): nothing of it can be told from a person's save, so only the
|
|
1635
|
+
// canvases a `maude design` verb in it snapshotted are bound
|
|
1636
|
+
if (mark.interp === true && !Object.keys(mark.snaps ?? {}).length) {
|
|
1637
|
+
if (mark.bg) writeAt(markP, JSON.stringify({ ...mark, seen: Date.now() }));
|
|
1638
|
+
else rmSync(markP, { force: true });
|
|
1639
|
+
return null;
|
|
1640
|
+
}
|
|
1641
|
+
await bindBashWrites(ctx, toolUseId, mark, by, mark.at);
|
|
1527
1642
|
if (mark.bg) writeAt(markP, JSON.stringify({ ...mark, seen: Date.now() }));
|
|
1528
1643
|
else rmSync(markP, { force: true });
|
|
1529
1644
|
return null;
|
|
1530
1645
|
}
|
|
1531
1646
|
|
|
1647
|
+
/** #164 — does this mark carry a window the studio parked writes for? */
|
|
1648
|
+
const windowedMark = (mark) => mark?.mode === 'named' || mark?.mode === 'all';
|
|
1649
|
+
|
|
1650
|
+
/**
|
|
1651
|
+
* #164 F7 — the call's window state as pre-bash recorded it outside the project, or null when there
|
|
1652
|
+
* is none (no window was opened, or the file is gone / torn / not of the expected shape).
|
|
1653
|
+
*/
|
|
1654
|
+
function callState(ctx, toolUseId) {
|
|
1655
|
+
const p = bashStatePath(ctx.root, ctx.session, toolUseId);
|
|
1656
|
+
const st = p ? readState(p, null) : null;
|
|
1657
|
+
if (!st || typeof st !== 'object' || st.v !== 1 || !windowedMark(st)) return null;
|
|
1658
|
+
if (typeof st.at !== 'number' || !Number.isFinite(st.at)) return null;
|
|
1659
|
+
return st;
|
|
1660
|
+
}
|
|
1661
|
+
|
|
1662
|
+
/**
|
|
1663
|
+
* The mark post-bash and Stop act on. With a valid state file the call is windowed exactly as the
|
|
1664
|
+
* state says (mode, files, bg, verbOnly, snaps, start time) and the in-project `mark` adds only its
|
|
1665
|
+
* `seen` stamp. Without one, `mark` is all there is: a windowed `mark` then settles with nothing
|
|
1666
|
+
* claimed (it only closes the window), and one that is not windowed is as before.
|
|
1667
|
+
*/
|
|
1668
|
+
function effectiveMark(ctx, toolUseId, mark) {
|
|
1669
|
+
const st = callState(ctx, toolUseId);
|
|
1670
|
+
if (!st) return mark && typeof mark === 'object' ? mark : null;
|
|
1671
|
+
return {
|
|
1672
|
+
at: st.at,
|
|
1673
|
+
interp: true,
|
|
1674
|
+
mode: st.mode,
|
|
1675
|
+
files: Array.isArray(st.files) ? st.files.filter((f) => typeof f === 'string') : [],
|
|
1676
|
+
snaps: st.snaps && typeof st.snaps === 'object' ? st.snaps : {},
|
|
1677
|
+
...(st.verbOnly === true ? { verbOnly: true } : {}),
|
|
1678
|
+
...(st.bg === true ? { bg: true, by: typeof st.by === 'string' ? st.by : 'main' } : {}),
|
|
1679
|
+
...(typeof mark?.seen === 'number' ? { seen: mark.seen } : {}),
|
|
1680
|
+
};
|
|
1681
|
+
}
|
|
1682
|
+
const isManifest = (m) =>
|
|
1683
|
+
!!m && typeof m === 'object' && m.v === 1 && !!m.files && typeof m.files === 'object';
|
|
1684
|
+
const SETTLE_BATCH = 32; // the studio's CLAIM_MAX_FILES
|
|
1685
|
+
|
|
1686
|
+
/**
|
|
1687
|
+
* #164 — the call returned (or its turn ended): diff the lane manifest taken before it against the lanes
|
|
1688
|
+
* now, and send the files whose bytes changed (with their sha256) to the studio, which claims those
|
|
1689
|
+
* bytes for the run and releases every other write it parked during the window as outside.
|
|
1690
|
+
* Fail closed: a missing / corrupt manifest sends no settle, only the window's close (N1); a studio that does not answer, or
|
|
1691
|
+
* answers anything but 200, binds nothing. An older studio (no settle route: 404) gets today's
|
|
1692
|
+
* binding. `studio` is the one located for the whole Stop, when there is one.
|
|
1693
|
+
*/
|
|
1694
|
+
async function settleCall(ctx, toolUseId, mark, by, studio = undefined) {
|
|
1695
|
+
const statePath = bashStatePath(ctx.root, ctx.session, toolUseId);
|
|
1696
|
+
const st = statePath ? readState(statePath, null) : null;
|
|
1697
|
+
let changed = [];
|
|
1698
|
+
let valid = false;
|
|
1699
|
+
if (st && isManifest(st.manifest)) {
|
|
1700
|
+
try {
|
|
1701
|
+
const now = laneSnapshot(ctx.designRoot, {
|
|
1702
|
+
prev: st.manifest,
|
|
1703
|
+
cache: readState(lanesCachePath(ctx.root)),
|
|
1704
|
+
});
|
|
1705
|
+
changed = laneDiff(st.manifest, now);
|
|
1706
|
+
valid = true;
|
|
1707
|
+
} catch {
|
|
1708
|
+
changed = [];
|
|
1709
|
+
}
|
|
1710
|
+
}
|
|
1711
|
+
if (statePath) removeState(statePath);
|
|
1712
|
+
const named = Array.isArray(mark.files) ? mark.files.filter((f) => typeof f === 'string') : [];
|
|
1713
|
+
// #164 N1 — no valid manifest (corrupt, or already settled by another copy of this hook: the plugin
|
|
1714
|
+
// loaded twice): never a settle — an empty one would end the call with nothing claimed and could win
|
|
1715
|
+
// the race against the real one. Only the window closes; a real settle still finds it within the
|
|
1716
|
+
// studio's wait, and with none its parked writes go out as outside.
|
|
1717
|
+
if (!valid) {
|
|
1718
|
+
if (studio !== null) await bashWindow(ctx, toolUseId, false, named, mark.mode === 'all');
|
|
1719
|
+
return;
|
|
1720
|
+
}
|
|
1721
|
+
// #164 F6 — a `named` call can only have written what its command names (a create included): a
|
|
1722
|
+
// change elsewhere in the root is not sent, so the studio releases it as outside
|
|
1723
|
+
if (mark.mode === 'named') {
|
|
1724
|
+
const cover = new Set(named);
|
|
1725
|
+
changed = changed.filter((c) => cover.has(c.path));
|
|
1726
|
+
}
|
|
1727
|
+
const located =
|
|
1728
|
+
studio === undefined ? await locateStudio(ctx.root, { timeoutMs: LOCATE_MS }) : studio;
|
|
1729
|
+
// no studio: nothing to claim for; the hook still keeps its own record of what the call changed
|
|
1730
|
+
if (!located) {
|
|
1731
|
+
bindTouches(
|
|
1732
|
+
ctx,
|
|
1733
|
+
mark,
|
|
1734
|
+
by,
|
|
1735
|
+
changed.map((c) => c.path)
|
|
1736
|
+
);
|
|
1737
|
+
return;
|
|
1738
|
+
}
|
|
1739
|
+
const batches = [];
|
|
1740
|
+
for (let i = 0; i < Math.max(1, changed.length); i += SETTLE_BATCH)
|
|
1741
|
+
batches.push(changed.slice(i, i + SETTLE_BATCH));
|
|
1742
|
+
const bound = new Set();
|
|
1743
|
+
const person = new Set();
|
|
1744
|
+
let answered = false;
|
|
1745
|
+
for (let i = 0; i < batches.length; i++) {
|
|
1746
|
+
const res = await postStudio(
|
|
1747
|
+
located,
|
|
1748
|
+
'/_api/agent/bash/settle',
|
|
1749
|
+
{
|
|
1750
|
+
...runKey(ctx),
|
|
1751
|
+
toolUseId,
|
|
1752
|
+
changed: batches[i],
|
|
1753
|
+
...(i < batches.length - 1 ? { more: true } : {}),
|
|
1754
|
+
},
|
|
1755
|
+
{ timeoutMs: 2000 }
|
|
1756
|
+
);
|
|
1757
|
+
if (!res) {
|
|
1758
|
+
if (!answered)
|
|
1759
|
+
bindTouches(
|
|
1760
|
+
ctx,
|
|
1761
|
+
mark,
|
|
1762
|
+
by,
|
|
1763
|
+
changed.map((c) => c.path)
|
|
1764
|
+
);
|
|
1765
|
+
return;
|
|
1766
|
+
}
|
|
1767
|
+
if (res.status === 404 && !answered) {
|
|
1768
|
+
// an older studio: the window is claim-taking, and its binding is by file name
|
|
1769
|
+
await bashWindow(ctx, toolUseId, false, named, mark.mode === 'all');
|
|
1770
|
+
await bindBashWrites(ctx, toolUseId, mark, by, mark.at, [
|
|
1771
|
+
...new Set([...named, ...changed.map((c) => c.path)]),
|
|
1772
|
+
]);
|
|
1773
|
+
return;
|
|
1774
|
+
}
|
|
1775
|
+
if (res.status !== 200) {
|
|
1776
|
+
// D2 — refused: nothing is bound, and the window is closed so the studio's 3 s release applies
|
|
1777
|
+
await bashWindow(ctx, toolUseId, false, named, mark.mode === 'all');
|
|
1778
|
+
return;
|
|
1779
|
+
}
|
|
1780
|
+
answered = true;
|
|
1781
|
+
for (const p of Array.isArray(res.body?.bound) ? res.body.bound : []) bound.add(p);
|
|
1782
|
+
for (const p of Array.isArray(res.body?.person) ? res.body.person : []) person.add(p);
|
|
1783
|
+
}
|
|
1784
|
+
const mine = [...bound].filter((p) => typeof p === 'string' && !person.has(p)).sort();
|
|
1785
|
+
if (!mine.length) return;
|
|
1786
|
+
bindTouches(ctx, mark, by, mine);
|
|
1787
|
+
// the studio maps what the run now owns to artboards (run.touch)
|
|
1788
|
+
await postStudio(
|
|
1789
|
+
located,
|
|
1790
|
+
'/_api/agent/edit/touched',
|
|
1791
|
+
{ ...runKey(ctx), toolUseId, via: 'bash', since: mark.at, files: mine },
|
|
1792
|
+
{ timeoutMs: 900 }
|
|
1793
|
+
);
|
|
1794
|
+
}
|
|
1795
|
+
|
|
1796
|
+
/** touched.json for these files (`via: 'bash'`), and no base is taken after the write. */
|
|
1797
|
+
function bindTouches(ctx, mark, by, rels) {
|
|
1798
|
+
for (const rel of rels) {
|
|
1799
|
+
if (!aiMayHaveWritten(mark, rel)) continue;
|
|
1800
|
+
let at;
|
|
1801
|
+
try {
|
|
1802
|
+
at = statSync(join(ctx.designRoot, rel)).mtimeMs;
|
|
1803
|
+
} catch {
|
|
1804
|
+
continue; // gone again
|
|
1805
|
+
}
|
|
1806
|
+
recordTouch(ctx, rel, { by, via: 'bash', artboards: null, at });
|
|
1807
|
+
markShellWrite(ctx, rel); // F4 — no base taken after this write
|
|
1808
|
+
}
|
|
1809
|
+
}
|
|
1810
|
+
|
|
1532
1811
|
/**
|
|
1533
1812
|
* Bind the design files changed since `since` to the run: touched.json (`via: 'bash'`) and the
|
|
1534
|
-
* studio's `edit/touched` for the call's window (from `mark.at`).
|
|
1813
|
+
* studio's `edit/touched` for the call's window (from `mark.at`). `files` (an older studio's
|
|
1814
|
+
* fallback: the canvases the call named plus the ones whose bytes changed) goes to the studio as
|
|
1815
|
+
* the call's file list.
|
|
1535
1816
|
*/
|
|
1536
|
-
async function bindBashWrites(ctx, toolUseId, mark, by, since) {
|
|
1537
|
-
const
|
|
1538
|
-
if (!
|
|
1539
|
-
for (const rel of
|
|
1817
|
+
async function bindBashWrites(ctx, toolUseId, mark, by, since, files = null) {
|
|
1818
|
+
const written = designWritesSince(ctx.designRoot, since);
|
|
1819
|
+
if (!written.length) return;
|
|
1820
|
+
for (const rel of written) {
|
|
1540
1821
|
if (!aiMayHaveWritten(mark, rel)) continue;
|
|
1541
1822
|
let at;
|
|
1542
1823
|
try {
|
|
@@ -1558,9 +1839,14 @@ async function bindBashWrites(ctx, toolUseId, mark, by, since) {
|
|
|
1558
1839
|
via: 'bash',
|
|
1559
1840
|
since: mark.at,
|
|
1560
1841
|
// p8-a1-claims — only claiming verbs wrote: the studio binds what they claimed, nothing else;
|
|
1561
|
-
// a call that cannot claim binds the canvases its command named and
|
|
1562
|
-
//
|
|
1563
|
-
|
|
1842
|
+
// a call that cannot claim binds the canvases its command named and every file whose bytes it
|
|
1843
|
+
// changed (an older studio, `files`) — the studio skips what a person's save landed; a call
|
|
1844
|
+
// whose window is `none` binds only the canvases its verbs snapshotted
|
|
1845
|
+
...(files
|
|
1846
|
+
? { files }
|
|
1847
|
+
: mark.interp
|
|
1848
|
+
? { files: Object.keys(mark.snaps ?? {}), claimedOnly: true }
|
|
1849
|
+
: { claimedOnly: true }),
|
|
1564
1850
|
},
|
|
1565
1851
|
{ timeoutMs: 900 }
|
|
1566
1852
|
);
|
|
@@ -1568,24 +1854,15 @@ async function bindBashWrites(ctx, toolUseId, mark, by, since) {
|
|
|
1568
1854
|
|
|
1569
1855
|
/**
|
|
1570
1856
|
* fix/ds-convert-hooks-cli #11 — may the AI's own call have written `rel`? A call of `maude design`
|
|
1571
|
-
* verbs only (`verbOnly`) wrote, as the AI's, just the canvases
|
|
1572
|
-
* a verb or sync
|
|
1573
|
-
* from taking it as the run's base, so Stop never holds the AI
|
|
1857
|
+
* verbs only (`verbOnly`), or one with no window (#164 `none`), wrote, as the AI's, just the canvases
|
|
1858
|
+
* its verbs snapshotted (`snaps`); the rest a verb or sync (or a person) wrote during it is not bound,
|
|
1859
|
+
* and no shell mark keeps a later edit from taking it as the run's base, so Stop never holds the AI
|
|
1860
|
+
* to it.
|
|
1574
1861
|
*/
|
|
1575
1862
|
const aiMayHaveWritten = (mark, rel) =>
|
|
1576
|
-
mark?.verbOnly !== true ||
|
|
1863
|
+
(mark?.verbOnly !== true && !(mark?.interp === true && !windowedMark(mark))) ||
|
|
1577
1864
|
(!!mark.snaps && typeof mark.snaps === 'object' && Object.hasOwn(mark.snaps, rel));
|
|
1578
1865
|
|
|
1579
|
-
/**
|
|
1580
|
-
* p8-sec2-attrib A1 — what a call that cannot claim may have written: the canvases it named, plus every
|
|
1581
|
-
* canvas lane whose bytes changed against the hashes pre-bash took (none taken: by mtime alone).
|
|
1582
|
-
*/
|
|
1583
|
-
function interpFiles(ctx, mark) {
|
|
1584
|
-
const named = Array.isArray(mark.files) ? mark.files.filter((f) => typeof f === 'string') : [];
|
|
1585
|
-
const hashes = mark.hashes && typeof mark.hashes === 'object' ? mark.hashes : {};
|
|
1586
|
-
return [...new Set([...named, ...changedDesignFiles(ctx.designRoot, hashes, mark.at)])].sort();
|
|
1587
|
-
}
|
|
1588
|
-
|
|
1589
1866
|
/**
|
|
1590
1867
|
* p8-secfix-hook F2 — at the turn's end (Stop / SubagentStop), what every still-running background
|
|
1591
1868
|
* call (`bg` mark) wrote since it was last looked at. A blocked Stop looks again at the next one;
|
|
@@ -1606,16 +1883,38 @@ async function drainBackground(ctx, studio) {
|
|
|
1606
1883
|
const now = Date.now();
|
|
1607
1884
|
const turn = turnStart(ctx, now);
|
|
1608
1885
|
const marks = [];
|
|
1609
|
-
|
|
1886
|
+
// #164 F7 — a background call is also known by its state file outside the project, so a deleted
|
|
1887
|
+
// in-project mark does not leave its window open until the studio times it out
|
|
1888
|
+
const stateSample = bashStatePath(ctx.root, ctx.session, 'x');
|
|
1889
|
+
let stateNames = [];
|
|
1890
|
+
try {
|
|
1891
|
+
if (stateSample) stateNames = readdirSync(dirname(stateSample));
|
|
1892
|
+
} catch {
|
|
1893
|
+
/* no state */
|
|
1894
|
+
}
|
|
1895
|
+
for (const n of new Set([...names, ...stateNames])) {
|
|
1610
1896
|
const toolUseId = n.endsWith('.json') ? hookKey(n.slice(0, -5)) : null;
|
|
1611
1897
|
if (!toolUseId) continue;
|
|
1612
|
-
const m = readJson(join(dir, n), null);
|
|
1898
|
+
const m = effectiveMark(ctx, toolUseId, readJson(join(dir, n), null));
|
|
1613
1899
|
if (!m?.bg) continue;
|
|
1614
|
-
if (!liveMark(m, now, turn))
|
|
1615
|
-
|
|
1900
|
+
if (!liveMark(m, now, turn)) {
|
|
1901
|
+
rmSync(join(dir, n), { force: true });
|
|
1902
|
+
const sp = bashStatePath(ctx.root, ctx.session, toolUseId);
|
|
1903
|
+
if (sp) removeState(sp);
|
|
1904
|
+
} else marks.push({ n, toolUseId, m });
|
|
1616
1905
|
}
|
|
1617
1906
|
marks.sort((a, b) => b.m.at - a.m.at); // newest first
|
|
1618
1907
|
for (const x of marks.splice(BG_MARKS_MAX)) rmSync(join(dir, x.n), { force: true });
|
|
1908
|
+
// #164 — a background call that holds a window settles now, once (a later Stop skips it): the
|
|
1909
|
+
// window closes, and what its process wrote is claimed or released as outside. It is no longer
|
|
1910
|
+
// bound by mtime below.
|
|
1911
|
+
for (const x of marks) {
|
|
1912
|
+
if (!windowedMark(x.m)) continue;
|
|
1913
|
+
if (x.m.settled !== true)
|
|
1914
|
+
await settleCall(ctx, x.toolUseId, x.m, typeof x.m.by === 'string' ? x.m.by : 'main', studio);
|
|
1915
|
+
writeAt(join(dir, x.n), JSON.stringify({ ...x.m, settled: true, seen: Date.now() }));
|
|
1916
|
+
}
|
|
1917
|
+
for (let i = marks.length - 1; i >= 0; i--) if (windowedMark(marks[i].m)) marks.splice(i, 1);
|
|
1619
1918
|
if (!marks.length) return;
|
|
1620
1919
|
const sinceOf = (x) =>
|
|
1621
1920
|
typeof x.m.seen === 'number' && x.m.seen >= x.m.at && x.m.seen <= now ? x.m.seen : x.m.at;
|
|
@@ -1644,7 +1943,13 @@ async function drainBackground(ctx, studio) {
|
|
|
1644
1943
|
toolUseId: oldest.toolUseId,
|
|
1645
1944
|
via: 'bash',
|
|
1646
1945
|
since: oldest.m.at,
|
|
1647
|
-
|
|
1946
|
+
// a window-less (`none`) call binds only the canvases its verbs snapshotted
|
|
1947
|
+
...(marks.every((x) => !x.m.interp)
|
|
1948
|
+
? { claimedOnly: true }
|
|
1949
|
+
: {
|
|
1950
|
+
files: [...new Set(marks.flatMap((x) => Object.keys(x.m.snaps ?? {})))],
|
|
1951
|
+
claimedOnly: true,
|
|
1952
|
+
}),
|
|
1648
1953
|
},
|
|
1649
1954
|
{ timeoutMs: 900 }
|
|
1650
1955
|
);
|
|
@@ -1739,6 +2044,7 @@ async function stop(ctx, input, self) {
|
|
|
1739
2044
|
{ timeoutMs: 600 }
|
|
1740
2045
|
);
|
|
1741
2046
|
rmSync(ctx.run, { recursive: true, force: true });
|
|
2047
|
+
dropRunState(ctx.root, ctx.session); // #168 E1/E3: its snapshot hashes and screenshot record
|
|
1742
2048
|
return null;
|
|
1743
2049
|
}
|
|
1744
2050
|
|