rvlib-shipkit 2.26.0 → 2.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +36 -0
- package/package.json +1 -1
- package/src/agent-time/diet.ts +77 -0
- package/src/agent-time/family.ts +72 -0
- package/src/agent-time/hooks.ts +16 -7
- package/src/agent-time/limits.ts +44 -0
- package/src/agent-time/live.ts +12 -8
- package/src/agent-time/mask.ts +96 -18
- package/src/agent-time/refused.ts +45 -0
- package/src/agent-time/registry.ts +289 -0
- package/src/agent-time/render.ts +122 -21
- package/src/agent-time/report-cache.ts +57 -0
- package/src/agent-time/report.ts +314 -40
- package/src/agent-time/shape.ts +50 -3
- package/src/agent-time/store.ts +322 -101
- package/src/agent-time/timeline.ts +140 -21
- package/src/agent-time/turns.ts +18 -8
- package/src/annex/born.ts +2 -2
- package/src/annex/offload.ts +29 -17
- package/src/annex/tidy.ts +70 -10
- package/src/asks/ask-after.ts +44 -0
- package/src/asks/ask-bar-fold.ts +57 -0
- package/src/asks/ask-migrate.ts +280 -0
- package/src/asks/ask-steps-fold.ts +166 -0
- package/src/asks/ask-store.ts +586 -0
- package/src/assets/kit-config.ts +7 -3
- package/src/assets/kits/identity-kit.ts +361 -14
- package/src/assets/kits/poster-thumbnail.ts +282 -0
- package/src/check.ts +3 -1
- package/src/checks/SK003-claude-md-shape.check.ts +92 -25
- package/src/checks/SK004-gitignore-policy.check.ts +20 -9
- package/src/checks/SK013-one-way-in-policy.check.ts +18 -3
- package/src/checks/SK026-asks-autoclose.check.ts +9 -23
- package/src/checks/SK028-readme.check.ts +7 -66
- package/src/checks/SK030-cache-audit.check.ts +6 -1
- package/src/checks/SK031-trace-audit.check.ts +2 -0
- package/src/checks/SK033-global-contribution.check.ts +3 -1
- package/src/checks/SK035-public-clean.check.ts +2 -2
- package/src/checks/SK038-speaks-as.check.ts +3 -3
- package/src/checks/SK042-post-kinds.check.ts +26 -24
- package/src/checks/SK043-scratch-on-the-mac.check.ts +59 -4
- package/src/checks/SK047-login-in-description.check.ts +36 -0
- package/src/checks/SK048-one-local-file.check.ts +36 -0
- package/src/checks/SK049-thread-answers-hook.check.ts +81 -0
- package/src/checks/SK050-retired-commands.check.ts +127 -0
- package/src/cli/cmd_Asks.ts +244 -27
- package/src/cli/cmd_Backup.ts +153 -10
- package/src/cli/cmd_Calls.ts +1 -0
- package/src/cli/cmd_Capacity.ts +2 -2
- package/src/cli/cmd_Commands.ts +140 -34
- package/src/cli/cmd_Contracts.ts +1 -0
- package/src/cli/cmd_CrossRepoActivity.ts +5 -4
- package/src/cli/cmd_Db.ts +253 -0
- package/src/cli/cmd_History.ts +212 -0
- package/src/cli/cmd_Home.ts +31 -3
- package/src/cli/cmd_Hq.ts +516 -0
- package/src/cli/cmd_Keys.ts +1 -0
- package/src/cli/cmd_Lanes.ts +15 -4
- package/src/cli/cmd_Machines.ts +36 -0
- package/src/cli/cmd_Media.ts +38 -6
- package/src/cli/cmd_Messages.ts +152 -1
- package/src/cli/cmd_Needs.ts +1 -0
- package/src/cli/cmd_Reflect.ts +23 -2
- package/src/cli/cmd_Review.ts +1357 -223
- package/src/cli/cmd_Secret.ts +295 -24
- package/src/cli/cmd_Social.ts +113 -28
- package/src/cli/cmd_SocialDrafts.ts +235 -0
- package/src/cli/cmd_Sound.ts +22 -1
- package/src/cli/cmd_Space.ts +324 -0
- package/src/cli/cmd_Start.ts +3 -2
- package/src/cli/cmd_ThreadHolds.ts +34 -0
- package/src/cli/cmd_ThreadKinds.ts +146 -0
- package/src/cli/cmd_ThreadReflect.ts +83 -0
- package/src/cli/cmd_ThreadSyncNeeds.ts +62 -0
- package/src/cli/cmd_Time.ts +76 -5
- package/src/cli/cmd_Tmp.ts +28 -4
- package/src/cli/cmd_Trailer.ts +14 -10
- package/src/cli/cmd_Urls.ts +56 -0
- package/src/cli/cmd_Vault.ts +583 -0
- package/src/cli/cmd_When.ts +1 -0
- package/src/cli/family-help.ts +5 -3
- package/src/cli/family-pages.ts +1 -1
- package/src/cli/kit/builtins.ts +1 -0
- package/src/cli/kit/verb.ts +6 -2
- package/src/cli/registry.ts +44 -4
- package/src/cli.ts +5 -2
- package/src/collections/actions.ts +42 -41
- package/src/collections/collection-types.ts +30 -4
- package/src/collections/md-body.ts +5 -3
- package/src/collections/pings.ts +13 -6
- package/src/collections/providers.ts +147 -61
- package/src/collections/reflections.ts +9 -4
- package/src/collections/review.ts +4 -4
- package/src/contracts/contract-manifests.ts +6 -5
- package/src/contracts/contract-types.ts +6 -4
- package/src/contracts/contracts-engine.ts +11 -0
- package/src/contracts/manifests/chrome-web-store.contract.ts +31 -0
- package/src/core/budget.ts +12 -17
- package/src/core/capacity.ts +27 -18
- package/src/core/check-runner.ts +7 -4
- package/src/core/discover-checks.ts +18 -3
- package/src/core/git.ts +31 -0
- package/src/core/house-layout.ts +17 -0
- package/src/core/layout.ts +13 -5
- package/src/core/locked-write.ts +4 -1
- package/src/core/machine-busy.ts +127 -0
- package/src/core/machine-commit.ts +6 -1
- package/src/core/machine-db.ts +370 -20
- package/src/core/machine-layout.ts +137 -0
- package/src/core/machine-read.ts +81 -0
- package/src/core/migrate-layout.ts +9 -11
- package/src/core/one-way-in-policy.ts +64 -7
- package/src/core/polling-policy.ts +27 -0
- package/src/core/retention.ts +16 -2
- package/src/core/scope.ts +107 -14
- package/src/core/slots.ts +5 -4
- package/src/drill/clean.ts +25 -1
- package/src/drill/run.ts +1 -1
- package/src/drill/seal.ts +27 -4
- package/src/home/activity-shape.ts +2 -0
- package/src/home/activity.ts +59 -3
- package/src/home/app-sign.ts +15 -4
- package/src/home/daemon-jobs.ts +161 -7
- package/src/home/database-projects.ts +111 -0
- package/src/home/database-words.ts +203 -0
- package/src/home/databases.ts +460 -0
- package/src/home/global-units.ts +6 -0
- package/src/home/gui-app/ShipkitGui.swift +122 -1
- package/src/home/gui-app.ts +6 -3
- package/src/home/home-move.ts +514 -0
- package/src/home/home-paths.ts +18 -6
- package/src/home/home-routes.ts +76 -0
- package/src/home/inbox-shape.ts +234 -91
- package/src/home/inbox.ts +26 -71
- package/src/home/machine-fold.ts +815 -0
- package/src/home/machine-host.ts +38 -5
- package/src/home/machine-repair.ts +503 -0
- package/src/home/machine-stores.ts +66 -15
- package/src/home/machine-temp.ts +547 -86
- package/src/home/other-macs.ts +2 -2
- package/src/home/resume.ts +79 -0
- package/src/home/run-daemon.ts +25 -4
- package/src/home/run-pm.ts +18 -5
- package/src/home/serve-daemon.ts +18 -3
- package/src/home/serve-web.ts +179 -10
- package/src/home/space-job.ts +115 -0
- package/src/home/space-page.ts +257 -0
- package/src/home/space-route.ts +167 -0
- package/src/home/space-words.ts +103 -0
- package/src/home/time-page-shape.ts +202 -0
- package/src/home/time-page.ts +64 -0
- package/src/home/vault-page.ts +516 -0
- package/src/home/vault-words.ts +132 -0
- package/src/hooks/leak-guard.ts +40 -13
- package/src/hooks/one-way-in-guard.ts +41 -6
- package/src/hq/cards.ts +581 -0
- package/src/hq/door-route.ts +43 -0
- package/src/hq/door.ts +163 -0
- package/src/hq/files-send.ts +347 -0
- package/src/hq/forgotten-log.ts +35 -0
- package/src/hq/history-check.ts +255 -0
- package/src/hq/history-place.ts +146 -0
- package/src/hq/history-send.ts +487 -0
- package/src/hq/hq-db.ts +102 -0
- package/src/hq/hq-local.ts +502 -0
- package/src/hq/hq-routes.ts +204 -0
- package/src/hq/hq-store.ts +603 -0
- package/src/hq/kinds/ask.ts +147 -0
- package/src/hq/kinds/card-gone.ts +83 -0
- package/src/hq/kinds/card-msg.ts +66 -0
- package/src/hq/kinds/card.ts +99 -0
- package/src/hq/kinds/index.ts +21 -0
- package/src/hq/kinds/kind.ts +126 -0
- package/src/hq/kinds/media.ts +125 -0
- package/src/hq/kinds/prompt.ts +219 -0
- package/src/hq/kinds/reflection.ts +128 -0
- package/src/hq/kinds/report.ts +55 -0
- package/src/hq/kinds/time-day.ts +236 -0
- package/src/hq/ledger.ts +473 -0
- package/src/hq/machine-key.ts +44 -0
- package/src/hq/machine-notes.ts +131 -0
- package/src/hq/outbox.ts +374 -0
- package/src/hq/replica.ts +167 -0
- package/src/hq/repo-id.ts +4 -0
- package/src/hq/report-facts.ts +117 -0
- package/src/hq/report.ts +274 -0
- package/src/hq/switch.ts +151 -0
- package/src/hq/vault-grant.ts +92 -0
- package/src/hq/vault-route.ts +112 -0
- package/src/identities/collection.ts +2 -2
- package/src/identities/identities.ts +24 -11
- package/src/identities/machine-route.ts +8 -3
- package/src/identities/steps.ts +31 -0
- package/src/ledger/db.ts +81 -27
- package/src/ledger/gate-checks.ts +6 -2
- package/src/ledger/run-log.ts +11 -3
- package/src/ledger/store.ts +26 -4
- package/src/media-store/backup/daemon.ts +73 -25
- package/src/media-store/backup/kept.ts +241 -0
- package/src/media-store/backup/keys.ts +1 -1
- package/src/media-store/backup/manifest.ts +20 -2
- package/src/media-store/backup/prune.ts +365 -0
- package/src/media-store/backup/restore.ts +14 -4
- package/src/media-store/backup/retention.ts +122 -0
- package/src/media-store/backup/run.ts +25 -19
- package/src/media-store/backup/secret.ts +6 -4
- package/src/media-store/backup/snapshot.ts +4 -2
- package/src/media-store/backup/sources.ts +83 -31
- package/src/media-store/backup/thread-copy.ts +340 -0
- package/src/media-store/copy/config.ts +76 -0
- package/src/media-store/copy/copy.ts +194 -0
- package/src/media-store/copy/lifecycle.ts +43 -0
- package/src/media-store/copy/night.ts +90 -0
- package/src/media-store/copy/proof.ts +151 -0
- package/src/media-store/copy/snapshot.ts +152 -0
- package/src/media-store/copy/store.ts +62 -0
- package/src/media-store/copy/stream.ts +176 -0
- package/src/media-store/daemon.ts +66 -16
- package/src/media-store/db.ts +24 -13
- package/src/media-store/forget.ts +141 -3
- package/src/media-store/hand.ts +4 -3
- package/src/media-store/hq-find.ts +75 -0
- package/src/media-store/hq-send.ts +277 -0
- package/src/media-store/kind.ts +2 -0
- package/src/media-store/purge.ts +21 -17
- package/src/media-store/put.ts +24 -8
- package/src/media-store/remote.ts +16 -7
- package/src/media-store/space-listing.ts +256 -0
- package/src/media-store/space.ts +46 -26
- package/src/media-store/sync.ts +5 -5
- package/src/media-store/tidy.ts +98 -0
- package/src/media-store/upload.ts +3 -3
- package/src/media-store/webp.ts +66 -0
- package/src/messages/guard.ts +49 -0
- package/src/messages/model.ts +16 -7
- package/src/messages/objects.ts +201 -0
- package/src/messages/routes.ts +14 -4
- package/src/messages/score.ts +3 -3
- package/src/messages/write.ts +285 -0
- package/src/pages/frame-client.ts +191 -4
- package/src/plan/planner.ts +28 -17
- package/src/recordings/media-kind.ts +1 -0
- package/src/recordings/model.ts +1 -1
- package/src/recordings/recorder-app/Capture.swift +9 -7
- package/src/reflect/hq-corpus.ts +56 -0
- package/src/reflect/prompt-corpus.ts +3 -1
- package/src/reflect/transcript.ts +129 -37
- package/src/reflections/reflections-queue.ts +1 -1
- package/src/release/gate-checkout.ts +2 -1
- package/src/release/git-facts.ts +3 -2
- package/src/release/machine-words.ts +67 -0
- package/src/release/public-clean.ts +11 -5
- package/src/releases/from-card.ts +1 -1
- package/src/releases/routes.ts +10 -5
- package/src/releases/store.ts +10 -1
- package/src/repo-config.ts +71 -19
- package/src/review/anim.ts +3 -3
- package/src/review/answer-kinds.ts +131 -0
- package/src/review/auto.ts +2 -2
- package/src/review/band.ts +53 -0
- package/src/review/branch-hold.ts +84 -0
- package/src/review/card-db.ts +254 -0
- package/src/review/card-rows.ts +267 -0
- package/src/review/cells.ts +360 -57
- package/src/review/close.ts +92 -0
- package/src/review/draft-card.ts +33 -0
- package/src/review/draft-model.ts +78 -0
- package/src/review/events.ts +171 -0
- package/src/review/format.ts +152 -19
- package/src/review/glyphs.ts +63 -0
- package/src/review/gone.ts +98 -0
- package/src/review/holds-sync.ts +62 -0
- package/src/review/holds.ts +85 -0
- package/src/review/house-kind-defs.ts +41 -0
- package/src/review/inbox-hook.ts +23 -10
- package/src/review/inbox-read.ts +201 -0
- package/src/review/instructions.ts +199 -0
- package/src/review/kind-apply.ts +61 -0
- package/src/review/kind-catalog.ts +96 -0
- package/src/review/kinds.ts +278 -0
- package/src/review/lane-ask.ts +109 -0
- package/src/review/marks.ts +1 -1
- package/src/review/media-kind.ts +7 -5
- package/src/review/media-read.ts +9 -7
- package/src/review/media.ts +32 -5
- package/src/review/model.ts +582 -109
- package/src/review/move.ts +491 -0
- package/src/review/need-address.ts +15 -0
- package/src/review/need-threads.ts +93 -0
- package/src/review/notes.ts +12 -20
- package/src/review/object-card.ts +48 -0
- package/src/review/object-read.ts +31 -0
- package/src/review/owner-verdict.ts +36 -0
- package/src/review/parties.ts +182 -0
- package/src/review/previews.ts +18 -20
- package/src/review/project.ts +1 -1
- package/src/review/projections.ts +235 -0
- package/src/review/referring.ts +54 -0
- package/src/review/reflection-object.ts +195 -0
- package/src/review/rev.ts +8 -0
- package/src/review/role.ts +1 -1
- package/src/review/routes.ts +194 -38
- package/src/review/secret-route.ts +80 -0
- package/src/review/snooze.ts +38 -0
- package/src/review/stage-card.ts +12 -8
- package/src/review/stage-routes.ts +1 -1
- package/src/review/store.ts +851 -124
- package/src/review/supersede.ts +116 -0
- package/src/review/take-back.ts +52 -0
- package/src/review/thread-fold.ts +64 -0
- package/src/review/threads.ts +349 -14
- package/src/review/traces.ts +218 -0
- package/src/review/trailer-auto-mock.ts +63 -0
- package/src/review/trailer-card.ts +6 -6
- package/src/review/trailer-desk.ts +41 -7
- package/src/review/trailer-media.ts +1 -0
- package/src/review/trailer-model.ts +8 -0
- package/src/review/trailer-notes.ts +1 -1
- package/src/review/trailer-routes.ts +9 -1
- package/src/review/unit.ts +77 -11
- package/src/review/verdict-items.ts +73 -0
- package/src/review/verdict-write.ts +15 -0
- package/src/review/wait.ts +85 -0
- package/src/review/watchers.ts +23 -10
- package/src/rules/untrack-generated.ts +92 -8
- package/src/scaffold/files/claude-settings-local.json +2 -0
- package/src/secrets/archive-mark.ts +52 -0
- package/src/secrets/archive.ts +83 -0
- package/src/secrets/copy.ts +14 -14
- package/src/secrets/held.ts +16 -0
- package/src/secrets/keychain-write.ts +48 -0
- package/src/secrets/keychain.ts +116 -0
- package/src/secrets/lapse-mark.ts +33 -0
- package/src/secrets/lapse.ts +60 -0
- package/src/secrets/list.ts +21 -17
- package/src/secrets/manager.ts +55 -26
- package/src/secrets/read.ts +385 -0
- package/src/secrets/tail.ts +31 -0
- package/src/secrets/who-reads.ts +49 -0
- package/src/serve/door-forward.ts +268 -0
- package/src/serve/door-names.ts +47 -0
- package/src/serve/embed.ts +1 -1
- package/src/serve/hub-app/activity-view.tsx +56 -32
- package/src/serve/hub-app/activity.css +7 -1
- package/src/serve/hub-app/asks-page.tsx +49 -0
- package/src/serve/hub-app/asks-st.ts +25 -0
- package/src/serve/hub-app/auto-text.tsx +14 -6
- package/src/serve/hub-app/benign-errors.ts +15 -1
- package/src/serve/hub-app/card-head.tsx +49 -0
- package/src/serve/hub-app/check-view.tsx +3 -2
- package/src/serve/hub-app/clock-svc.ts +1 -2
- package/src/serve/hub-app/code-copy.ts +35 -0
- package/src/serve/hub-app/col-card.tsx +72 -30
- package/src/serve/hub-app/col-list-page.tsx +125 -0
- package/src/serve/hub-app/col-list-st.ts +103 -0
- package/src/serve/hub-app/col-tables-view.tsx +17 -45
- package/src/serve/hub-app/col-tables.ts +76 -8
- package/src/serve/hub-app/cols-svc.ts +18 -39
- package/src/serve/hub-app/commands/commands-page.tsx +2 -1
- package/src/serve/hub-app/controls.css +83 -0
- package/src/serve/hub-app/database-st.ts +260 -0
- package/src/serve/hub-app/database-view.tsx +289 -0
- package/src/serve/hub-app/database.css +32 -0
- package/src/serve/hub-app/entry-bar.css +14 -0
- package/src/serve/hub-app/entry-bar.tsx +33 -0
- package/src/serve/hub-app/entry-pick.ts +31 -0
- package/src/serve/hub-app/floating.tsx +1 -0
- package/src/serve/hub-app/frames-st.ts +17 -1
- package/src/serve/hub-app/git-view.tsx +3 -2
- package/src/serve/hub-app/hash-route.ts +11 -1
- package/src/serve/hub-app/header-bar.tsx +14 -18
- package/src/serve/hub-app/home-st.ts +142 -11
- package/src/serve/hub-app/home-strip.css +6 -25
- package/src/serve/hub-app/home-strip.tsx +60 -93
- package/src/serve/hub-app/home.html +10 -0
- package/src/serve/hub-app/house-wiki-view.tsx +20 -0
- package/src/serve/hub-app/hub-app.tsx +71 -166
- package/src/serve/hub-app/hub-types.ts +5 -1
- package/src/serve/hub-app/hub.css +146 -71
- package/src/serve/hub-app/icons.tsx +32 -5
- package/src/serve/hub-app/identities-st.ts +56 -6
- package/src/serve/hub-app/identities-view.tsx +104 -61
- package/src/serve/hub-app/identities.css +17 -15
- package/src/serve/hub-app/identity-address.ts +5 -0
- package/src/serve/hub-app/inbox-st.ts +227 -49
- package/src/serve/hub-app/inbox-view.tsx +204 -120
- package/src/serve/hub-app/inbox.css +47 -47
- package/src/serve/hub-app/index.html +10 -0
- package/src/serve/hub-app/instructions.css +30 -0
- package/src/serve/hub-app/kept-cols.tsx +7 -0
- package/src/serve/hub-app/keys.ts +32 -17
- package/src/serve/hub-app/later.tsx +26 -0
- package/src/serve/hub-app/list-filter.tsx +14 -0
- package/src/serve/hub-app/list-walk.ts +72 -3
- package/src/serve/hub-app/machine-st.ts +2 -2
- package/src/serve/hub-app/machines-st.ts +251 -0
- package/src/serve/hub-app/machines-view.tsx +217 -0
- package/src/serve/hub-app/machines.css +67 -0
- package/src/serve/hub-app/markdown.css +51 -0
- package/src/serve/hub-app/md-copy.tsx +57 -0
- package/src/serve/hub-app/md.ts +25 -9
- package/src/serve/hub-app/media-view.tsx +4 -2
- package/src/serve/hub-app/messages/messages-page.tsx +81 -8
- package/src/serve/hub-app/messages/messages-st.ts +99 -3
- package/src/serve/hub-app/messages.css +14 -1
- package/src/serve/hub-app/objects.css +51 -0
- package/src/serve/hub-app/page-keys.ts +175 -0
- package/src/serve/hub-app/pages-frames.tsx +21 -3
- package/src/serve/hub-app/palette-st.ts +58 -11
- package/src/serve/hub-app/palette-view.tsx +3 -1
- package/src/serve/hub-app/pane-boundary.tsx +72 -0
- package/src/serve/hub-app/pane-errors.ts +54 -0
- package/src/serve/hub-app/plan-view.tsx +3 -2
- package/src/serve/hub-app/planned-view.tsx +3 -3
- package/src/serve/hub-app/planned.css +0 -4
- package/src/serve/hub-app/processes-view.tsx +3 -2
- package/src/serve/hub-app/project-list.css +46 -8
- package/src/serve/hub-app/project-list.tsx +125 -59
- package/src/serve/hub-app/projects-svc.ts +83 -8
- package/src/serve/hub-app/reader-chips.tsx +13 -0
- package/src/serve/hub-app/readme-view.tsx +2 -3
- package/src/serve/hub-app/readme.css +22 -6
- package/src/serve/hub-app/reflections-page.tsx +95 -0
- package/src/serve/hub-app/reflections-st.ts +17 -0
- package/src/serve/hub-app/releases/releases-page.tsx +28 -4
- package/src/serve/hub-app/releases/releases-st.ts +1 -1
- package/src/serve/hub-app/releases.css +0 -1
- package/src/serve/hub-app/repo-sections.ts +9 -5
- package/src/serve/hub-app/repo-st.ts +35 -8
- package/src/serve/hub-app/review/code-colors.ts +30 -0
- package/src/serve/hub-app/review/diff-view.tsx +75 -0
- package/src/serve/hub-app/review/dock.tsx +104 -0
- package/src/serve/hub-app/review/draft-card.tsx +163 -0
- package/src/serve/hub-app/review/group-block.tsx +209 -0
- package/src/serve/hub-app/review/instructions-view.tsx +116 -0
- package/src/serve/hub-app/review/item-verdict.tsx +38 -0
- package/src/serve/hub-app/review/kind-states.tsx +193 -0
- package/src/serve/hub-app/review/kind-view.tsx +1 -37
- package/src/serve/hub-app/review/kit.tsx +75 -29
- package/src/serve/hub-app/review/lane-bar.tsx +64 -0
- package/src/serve/hub-app/review/note-place.ts +1 -1
- package/src/serve/hub-app/review/object-card.tsx +62 -0
- package/src/serve/hub-app/review/object-panel.tsx +179 -0
- package/src/serve/hub-app/review/question-views.tsx +385 -0
- package/src/serve/hub-app/review/review-board.tsx +2 -2
- package/src/serve/hub-app/review/review-cells.tsx +148 -87
- package/src/serve/hub-app/review/review-kit.ts +27 -1
- package/src/serve/hub-app/review/review-list.tsx +160 -65
- package/src/serve/hub-app/review/review-page.tsx +12 -12
- package/src/serve/hub-app/review/review-st.ts +174 -47
- package/src/serve/hub-app/review/review-thread.tsx +214 -53
- package/src/serve/hub-app/review/review-views.tsx +494 -159
- package/src/serve/hub-app/review/thread-close.tsx +124 -0
- package/src/serve/hub-app/review/thread-control-st.ts +115 -0
- package/src/serve/hub-app/review/thread-control.tsx +74 -0
- package/src/serve/hub-app/review/thread-st.ts +288 -41
- package/src/serve/hub-app/review/trailer-card.tsx +2 -2
- package/src/serve/hub-app/review/trailer-page.tsx +37 -16
- package/src/serve/hub-app/review/trailer-st.ts +41 -7
- package/src/serve/hub-app/review/trailer-timeline.tsx +2 -2
- package/src/serve/hub-app/review.css +462 -97
- package/src/serve/hub-app/section-head.tsx +51 -0
- package/src/serve/hub-app/side-lists.ts +72 -0
- package/src/serve/hub-app/sidebar.tsx +6 -3
- package/src/serve/hub-app/site/site-part.tsx +2 -8
- package/src/serve/hub-app/site/site-st.ts +4 -4
- package/src/serve/hub-app/social/calendar.tsx +5 -11
- package/src/serve/hub-app/social/comms-page.tsx +43 -15
- package/src/serve/hub-app/social/kit.tsx +32 -13
- package/src/serve/hub-app/social/next-release.tsx +3 -5
- package/src/serve/hub-app/social/post-card.tsx +142 -49
- package/src/serve/hub-app/social/post-page.tsx +80 -0
- package/src/serve/hub-app/social/problems.tsx +5 -9
- package/src/serve/hub-app/social/serial-writes.ts +13 -0
- package/src/serve/hub-app/social/social-model.ts +24 -5
- package/src/serve/hub-app/social/social-page.tsx +95 -36
- package/src/serve/hub-app/social/social-st.ts +162 -41
- package/src/serve/hub-app/social/stage-popup.tsx +1 -1
- package/src/serve/hub-app/social/stage-st.ts +1 -1
- package/src/serve/hub-app/social/step-layout.ts +1 -1
- package/src/serve/hub-app/social.css +10 -17
- package/src/serve/hub-app/space-st.ts +209 -0
- package/src/serve/hub-app/space-view.tsx +196 -0
- package/src/serve/hub-app/space.css +27 -0
- package/src/serve/hub-app/stores/stores-page.tsx +97 -25
- package/src/serve/hub-app/stores/stores-st.ts +44 -19
- package/src/serve/hub-app/stores.css +6 -1
- package/src/serve/hub-app/theme-st.ts +22 -9
- package/src/serve/hub-app/thread-row.tsx +101 -0
- package/src/serve/hub-app/time-ago.tsx +3 -2
- package/src/serve/hub-app/time-charts.tsx +291 -0
- package/src/serve/hub-app/time-pages.tsx +749 -0
- package/src/serve/hub-app/time-st.ts +162 -0
- package/src/serve/hub-app/time-view.tsx +77 -0
- package/src/serve/hub-app/time.css +135 -0
- package/src/serve/hub-app/tree-build.ts +52 -42
- package/src/serve/hub-app/tree-row.tsx +3 -11
- package/src/serve/hub-app/tree-svc.ts +18 -9
- package/src/serve/hub-app/urls-svc.ts +154 -0
- package/src/serve/hub-app/urls-view.tsx +117 -0
- package/src/serve/hub-app/urls.css +30 -0
- package/src/serve/hub-app/vault-st.ts +127 -0
- package/src/serve/hub-app/vault-view.tsx +154 -0
- package/src/serve/hub-app/vault.css +38 -0
- package/src/serve/hub-app/veille/veille-page.tsx +2 -11
- package/src/serve/hub-app/veille/veille-st.ts +12 -10
- package/src/serve/hub-app/veille.css +0 -1
- package/src/serve/hub-app/waiting-svc.ts +29 -0
- package/src/serve/hub-app/when-view.tsx +6 -3
- package/src/serve/hub-app/wiki-st.ts +30 -4
- package/src/serve/hub-app/wikis-view.tsx +6 -5
- package/src/serve/hub-runtime.ts +35 -8
- package/src/serve/project-gutter-route.ts +42 -19
- package/src/serve/project-gutter.ts +16 -50
- package/src/serve/same-origin.ts +13 -0
- package/src/serve/secret-gate.ts +21 -0
- package/src/serve/serve-hub.ts +38 -20
- package/src/serve/tailnet-caller.ts +117 -0
- package/src/shipkit-files.ts +16 -2
- package/src/shipkit.ts +3 -3
- package/src/shot/shooter.ts +616 -420
- package/src/shot/shot-ask.ts +246 -155
- package/src/site/desk.ts +4 -4
- package/src/smoke/run-smoke.ts +6 -6
- package/src/social/brands.ts +4 -0
- package/src/social/card-drafts.ts +11 -19
- package/src/social/cover.ts +202 -0
- package/src/social/desk-index.ts +34 -13
- package/src/social/discord-layout.ts +37 -13
- package/src/social/drafts.ts +7 -4
- package/src/social/import-drafts.ts +244 -0
- package/src/social/kind-pages.ts +3 -3
- package/src/social/kinds.ts +1 -1
- package/src/social/load.ts +111 -65
- package/src/social/media-kind.ts +68 -160
- package/src/social/media-of.ts +5 -4
- package/src/social/open.ts +3 -2
- package/src/social/post-object.ts +120 -0
- package/src/social/post-sources.ts +136 -0
- package/src/social/post-text.ts +103 -0
- package/src/social/posts.ts +378 -0
- package/src/social/presence.ts +7 -5
- package/src/social/publish/discord.ts +5 -2
- package/src/social/publish/index.ts +17 -5
- package/src/social/publish/secret.ts +4 -4
- package/src/social/release-stage.ts +79 -63
- package/src/social/routes.ts +89 -24
- package/src/social/stage.ts +43 -58
- package/src/social/stats.ts +12 -9
- package/src/social/strip.ts +4 -1
- package/src/social/text.ts +4 -3
- package/src/social/thumbnail.ts +347 -0
- package/src/social/tracker.ts +1 -1
- package/src/social/writes.ts +12 -29
- package/src/stores/collection.ts +15 -11
- package/src/stores/desk.ts +246 -47
- package/src/stores/model.ts +72 -6
- package/src/stores/routes.ts +37 -12
- package/src/stores/unit.ts +16 -10
- package/src/suite/judge-suites.ts +41 -11
- package/src/suite/select.ts +45 -3
- package/src/suite/suite-cli.ts +16 -10
- package/src/trailer/bed.ts +1 -1
- package/src/trailer/build.ts +134 -21
- package/src/trailer/ffmpeg.ts +7 -0
- package/src/trailer/fonts.ts +3 -2
- package/src/trailer/grammar.ts +201 -2
- package/src/trailer/graph.ts +42 -5
- package/src/trailer/look.ts +21 -0
- package/src/trailer/mock.ts +154 -0
- package/src/trailer/passage.ts +65 -26
- package/src/trailer/score/heard.ts +89 -0
- package/src/trailer/score/sound.ts +14 -8
- package/src/trailer/sound/eleven.ts +33 -3
- package/src/trailer/sound/run.ts +16 -6
- package/src/trailer/stitch.ts +26 -5
- package/src/trailer/titles.ts +82 -19
- package/src/trailer/versions.ts +1 -3
- package/src/trailer/vertical.ts +3 -1
- package/src/urls/frame.ts +195 -0
- package/src/urls/routes.ts +43 -0
- package/src/urls/rows.ts +171 -0
- package/src/urls/unit.ts +73 -0
- package/src/vault/house-keys.ts +42 -0
- package/src/vault/layout.ts +50 -0
- package/src/vault/policy.ts +165 -0
- package/src/vault/vault-audit.ts +276 -0
- package/src/vault/vault-client.ts +40 -0
- package/src/vault/vault-config.ts +159 -0
- package/src/vault/vault-destroy.ts +78 -0
- package/src/vault/vault-handover.ts +305 -0
- package/src/vault/vault-http.ts +360 -0
- package/src/vault/vault-import.ts +213 -0
- package/src/vault/vault-init.ts +328 -0
- package/src/vault/vault-minter.ts +271 -0
- package/src/vault/vault-restore.ts +333 -0
- package/src/vault/vault-serve.ts +342 -0
- package/src/vault/vault-snapshot.ts +281 -0
- package/src/veille/asks.ts +1 -1
- package/src/veille/desk.ts +2 -2
- package/src/veille/identity.ts +2 -2
- package/src/wiki/graph-pages.ts +13 -1
- package/src/wiki/scan-md.ts +1 -1
- package/src/asks/asks-queue.ts +0 -266
- package/src/social/migrate.ts +0 -123
|
@@ -0,0 +1,502 @@
|
|
|
1
|
+
// the daemon's side of the hq (wiki tools/shipkit/hq.md): the hq it carries when it joined no other, the token it
|
|
2
|
+
// keeps, the report it sends. One writer a file: the daemon process holds hq.sqlite, and the report's child holds
|
|
3
|
+
// the outbox and talks to the hq over http like a daemon of another machine
|
|
4
|
+
import { chmodSync, mkdirSync, readFileSync, renameSync, statSync, writeFileSync } from 'fs'
|
|
5
|
+
import { userInfo } from 'os'
|
|
6
|
+
import { join } from 'path'
|
|
7
|
+
import { machineDelete, machineGet, machineSet } from '../core/machine-db.ts'
|
|
8
|
+
import { daemonPort, homeDir, homePort, hqPort } from '../home/home-paths.ts'
|
|
9
|
+
import { REACH_HEADER } from '../serve/same-origin.ts'
|
|
10
|
+
import { machineName, readTailscaleStatus } from '../home/machine-host.ts'
|
|
11
|
+
import { hqDbPath, openHq } from './hq-db.ts'
|
|
12
|
+
import { hqRoute, httpHq, httpJoin } from './hq-routes.ts'
|
|
13
|
+
import { fileForgottenLog, forgottenLogPath } from './forgotten-log.ts'
|
|
14
|
+
import { grantsProblem, HqStore, INVITE_MS, type FeedMark, type Grant, type MachineView, type Refused } from './hq-store.ts'
|
|
15
|
+
import { machineKey } from './machine-key.ts'
|
|
16
|
+
import { machineNotes, type MachineNote } from './machine-notes.ts'
|
|
17
|
+
import { flush, openDaemonDb, Outbox } from './outbox.ts'
|
|
18
|
+
import { buildReport } from './report.ts'
|
|
19
|
+
import type { AskSeen } from './files-send.ts'
|
|
20
|
+
import { markVault, settleVault, vaultDrift, type VaultMinter } from './vault-grant.ts'
|
|
21
|
+
import { vaultReaders, type VaultReader } from './vault-route.ts'
|
|
22
|
+
import { nameProblem } from '../core/scope.ts'
|
|
23
|
+
import { vaultInitialised, vaultPlace, vaultUrl } from '../vault/vault-config.ts'
|
|
24
|
+
import { VaultApi } from '../vault/vault-http.ts'
|
|
25
|
+
import type { CompareSummary } from '../vault/vault-import.ts'
|
|
26
|
+
import { minterOf } from '../vault/vault-minter.ts'
|
|
27
|
+
|
|
28
|
+
/** the machine db row that names an hq on another machine: with none, this daemon carries its own */
|
|
29
|
+
export const HQ_URL = 'hq-url'
|
|
30
|
+
export const HQ_TOKEN_ENV = 'SHIPKIT_HQ_TOKEN'
|
|
31
|
+
|
|
32
|
+
/** the machine db switch of an hq that answers other machines: on, the daemon opens the hq's port (below) */
|
|
33
|
+
export const HQ_OPEN = 'hq-open'
|
|
34
|
+
|
|
35
|
+
export const carriesHq = (): boolean => machineGet<string>(HQ_URL) == null
|
|
36
|
+
export const hqOpen = (): boolean => machineGet<boolean>(HQ_OPEN) === true
|
|
37
|
+
|
|
38
|
+
export const hqUrl = (): string => machineGet<string>(HQ_URL) ?? `http://127.0.0.1:${daemonPort()}`
|
|
39
|
+
|
|
40
|
+
const tokenFile = (): string => join(homeDir(), 'hq-token')
|
|
41
|
+
const vaultTokenFile = (): string => join(homeDir(), 'vault-token')
|
|
42
|
+
export const VAULT_TOKEN_ENV = 'SHIPKIT_VAULT_TOKEN'
|
|
43
|
+
|
|
44
|
+
/** this daemon's token for its hq, null before its join */
|
|
45
|
+
export function readHqToken(): string | null {
|
|
46
|
+
const env = process.env[HQ_TOKEN_ENV]
|
|
47
|
+
if (env) return env
|
|
48
|
+
try {
|
|
49
|
+
return readFileSync(tokenFile(), 'utf8').trim() || null
|
|
50
|
+
} catch {
|
|
51
|
+
return null
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** a token kept for this OS user alone: written beside its place, closed to others, then moved in */
|
|
56
|
+
export function keepPrivateFile(file: string, token: string): void {
|
|
57
|
+
mkdirSync(homeDir(), { recursive: true })
|
|
58
|
+
const tmp = `${file}.tmp-${process.pid}`
|
|
59
|
+
writeFileSync(tmp, `${token}\n`, { mode: 0o600 })
|
|
60
|
+
chmodSync(tmp, 0o600)
|
|
61
|
+
renameSync(tmp, file)
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export const keepHqToken = (token: string): void => keepPrivateFile(tokenFile(), token)
|
|
65
|
+
|
|
66
|
+
/** this daemon's vault token, null before its hq gave one */
|
|
67
|
+
export function readVaultToken(): string | null {
|
|
68
|
+
const env = process.env[VAULT_TOKEN_ENV]
|
|
69
|
+
if (env) return env
|
|
70
|
+
try {
|
|
71
|
+
return readFileSync(vaultTokenFile(), 'utf8').trim() || null
|
|
72
|
+
} catch {
|
|
73
|
+
return null
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
/** a new vault token from this daemon's hq, kept beside the hq token. A token lives a day: a daemon asks again well
|
|
78
|
+
* before (2e's job), and each ask revokes the one it held */
|
|
79
|
+
export async function refreshVaultToken(): Promise<{ expires: number } | Refused> {
|
|
80
|
+
const hq = myHq()
|
|
81
|
+
if ('refused' in hq) return hq
|
|
82
|
+
const r = await hq.vaultToken()
|
|
83
|
+
if ('refused' in r) return r
|
|
84
|
+
keepPrivateFile(vaultTokenFile(), r.token)
|
|
85
|
+
return { expires: r.expires }
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** a vault token lives a day from its mint: the daemon asks a new one once it is this old */
|
|
89
|
+
export const VAULT_TOKEN_AGE_MS = 12 * 3600_000
|
|
90
|
+
|
|
91
|
+
/** the age of the vault token this daemon keeps, null with none (or one given by the environment, never renewed) */
|
|
92
|
+
function vaultTokenAge(now: number): number | null {
|
|
93
|
+
if (process.env[VAULT_TOKEN_ENV]) return 0
|
|
94
|
+
try {
|
|
95
|
+
return now - statSync(vaultTokenFile()).mtimeMs
|
|
96
|
+
} catch {
|
|
97
|
+
return null
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** the vault this daemon reads: the one beside the hq it carries, on loopback, or the master beside the hq it joined
|
|
102
|
+
* on another Mac, through that hq's vault route (vault-route.ts) */
|
|
103
|
+
export const vaultJobDue = (): boolean => (carriesHq() ? vaultInitialised() : readHqToken() != null)
|
|
104
|
+
|
|
105
|
+
/** the master's vault route as this daemon reaches it, with its hq token beside the vault token */
|
|
106
|
+
export const masterVault = (token: string, timeoutMs = 5_000): VaultApi => new VaultApi(`${hqUrl().replace(/\/$/, '')}/hq/vault`, token, timeoutMs, { authorization: `Bearer ${readHqToken() ?? ''}` })
|
|
107
|
+
|
|
108
|
+
/** the vault job's body, in its child: the hq's rows settled (through the daemon, the one writer of its file), then
|
|
109
|
+
* this daemon's vault token asked again when it is half a day old or the vault refuses it. It never touches a keychain */
|
|
110
|
+
export async function vaultJob(o: { print: (l: string) => void; printErr: (l: string) => void; now?: number }): Promise<void> {
|
|
111
|
+
const now = o.now ?? Date.now()
|
|
112
|
+
if (!vaultJobDue()) return
|
|
113
|
+
if (!carriesHq()) return joinedVaultJob(o, now)
|
|
114
|
+
const checked = await askVaultCheck()
|
|
115
|
+
if ('refused' in checked) o.printErr(`WARN vault: the hq's rows were not settled: ${checked.refused}`)
|
|
116
|
+
const age = vaultTokenAge(now)
|
|
117
|
+
const token = readVaultToken()
|
|
118
|
+
const alive = token != null && (await new VaultApi(vaultUrl(vaultPlace()), token).lookupSelf().then(() => true, () => false))
|
|
119
|
+
if (age == null || age >= VAULT_TOKEN_AGE_MS || !alive) {
|
|
120
|
+
const r = await refreshVaultToken()
|
|
121
|
+
if ('refused' in r) o.printErr(`WARN vault: no vault token for this daemon: ${r.refused}`)
|
|
122
|
+
}
|
|
123
|
+
const { vaultSnapshotsOn } = await import('./switch.ts')
|
|
124
|
+
if (vaultSnapshotsOn()) await vaultSnapshotJob(o, now)
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
/** a daemon that joined an hq on another Mac: its vault token asked again through that hq when it is half a day old
|
|
128
|
+
* or the master's vault route refuses it. Quiet while the hq is not reached or runs beside no vault: the reads say
|
|
129
|
+
* the cause loudly, at the moment one is asked */
|
|
130
|
+
async function joinedVaultJob(o: { print: (l: string) => void; printErr: (l: string) => void }, now: number): Promise<void> {
|
|
131
|
+
const age = vaultTokenAge(now)
|
|
132
|
+
const token = readVaultToken()
|
|
133
|
+
const alive = token != null && (await masterVault(token).lookupSelf().then(() => true, () => false))
|
|
134
|
+
if (age != null && age < VAULT_TOKEN_AGE_MS && alive) return
|
|
135
|
+
const r = await refreshVaultToken()
|
|
136
|
+
if (!('refused' in r)) return o.print(`ok: vault: a new vault token from the hq at ${new URL(hqUrl()).host}, for the master's vault route`)
|
|
137
|
+
if (/is not reached|runs beside no vault/.test(r.refused)) return
|
|
138
|
+
o.printErr(`WARN vault: no vault token for this daemon: ${r.refused}`)
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
/** the vault's sealed copy in the Space, once a day and after a change (vault/vault-snapshot.ts) */
|
|
142
|
+
async function vaultSnapshotJob(o: { print: (l: string) => void; printErr: (l: string) => void }, now: number): Promise<void> {
|
|
143
|
+
const { snapshotTick } = await import('../vault/vault-snapshot.ts')
|
|
144
|
+
const { minterOf } = await import('../vault/vault-minter.ts')
|
|
145
|
+
const { baoBin, keychainSeal } = await import('../vault/vault-serve.ts')
|
|
146
|
+
const { minterTokenFile } = await import('../vault/vault-config.ts')
|
|
147
|
+
const { machineSpace } = await import('../media-store/space.ts')
|
|
148
|
+
const { machineName } = await import('../home/machine-host.ts')
|
|
149
|
+
const place = vaultPlace()
|
|
150
|
+
const minter = minterOf(place)
|
|
151
|
+
const bin = baoBin()
|
|
152
|
+
const sealKey = keychainSeal(place).read()
|
|
153
|
+
const { space, why } = await machineSpace()
|
|
154
|
+
if (minter == null || bin == null || sealKey == null || space == null) return o.printErr(`WARN vault: no sealed copy to the Space: ${minter == null ? 'no minter token' : bin == null ? 'no bao' : sealKey == null ? 'no seal key in the keychain' : `no Space (${why})`}`)
|
|
155
|
+
try {
|
|
156
|
+
for (const l of await snapshotTick({ minter, place, space, machine: machineName(), bin, sealKey, minterToken: readFileSync(minterTokenFile(place), 'utf8').trim(), get: machineGet, set: machineSet, now, pruneOn: (await import('./switch.ts')).vaultPruneOn })) o.print(l)
|
|
157
|
+
} catch (e) {
|
|
158
|
+
o.printErr(`WARN vault: the sealed copy to the Space failed: ${(e as Error).message}`)
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
export const comparedFile = (): string => join(homeDir(), 'vault-compared.json')
|
|
163
|
+
/** the counts of the last sk vault compare, names only: what the house check says */
|
|
164
|
+
export const keepCompared = (sum: CompareSummary): void => keepPrivateFile(comparedFile(), JSON.stringify(sum))
|
|
165
|
+
export function lastCompared(): CompareSummary | null {
|
|
166
|
+
try {
|
|
167
|
+
return JSON.parse(readFileSync(comparedFile(), 'utf8')) as CompareSummary
|
|
168
|
+
} catch {
|
|
169
|
+
return null
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** the minter of the vault beside the hq this daemon carries: the vault runs on the hq's machine */
|
|
174
|
+
export const carriedMinter: VaultMinter = () => (vaultInitialised() ? minterOf(vaultPlace()) : null)
|
|
175
|
+
|
|
176
|
+
/** the machine db rows of the feed's mark, one an hq by its file's name. An `hq-` row, so the backup never carries
|
|
177
|
+
* it to another machine: a copy of the file opened there takes a new generation */
|
|
178
|
+
const FEED_MARK = 'hq-feed-mark:'
|
|
179
|
+
|
|
180
|
+
export const machineFeedMark: FeedMark = {
|
|
181
|
+
get: (hq) => machineGet<number>(`${FEED_MARK}${hq}`),
|
|
182
|
+
set: (hq, n) => void machineSet(`${FEED_MARK}${hq}`, n),
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
let carried: HqStore | null | undefined
|
|
186
|
+
|
|
187
|
+
/** the hq this daemon carries, opened once a process; null when its file does not open */
|
|
188
|
+
export function carriedHq(): HqStore | null {
|
|
189
|
+
if (carried === undefined) {
|
|
190
|
+
const db = openHq()
|
|
191
|
+
carried = db == null ? null : new HqStore(db, { mark: machineFeedMark, forgotten: fileForgottenLog(forgottenLogPath(hqDbPath())) })
|
|
192
|
+
}
|
|
193
|
+
return carried
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** forget the open store, for a test that moves the file */
|
|
197
|
+
export const forgetCarriedHq = (): void => {
|
|
198
|
+
try {
|
|
199
|
+
carried?.db.close()
|
|
200
|
+
} catch {
|
|
201
|
+
// already closed
|
|
202
|
+
}
|
|
203
|
+
carried = undefined
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
/** the grant of this machine's own folder in the vault: its name in lowercase, null (said in the log) when that is
|
|
207
|
+
* no safe part of a path */
|
|
208
|
+
function ownMachineGrant(): Grant | null {
|
|
209
|
+
let name: string
|
|
210
|
+
try {
|
|
211
|
+
name = machineName().toLowerCase()
|
|
212
|
+
} catch (e) {
|
|
213
|
+
console.error(`WARN the hq grants this daemon no machine folder in the vault: ${(e as Error).message}`)
|
|
214
|
+
return null
|
|
215
|
+
}
|
|
216
|
+
const problem = nameProblem('machine', name)
|
|
217
|
+
if (problem == null) return { kind: 'machine', name }
|
|
218
|
+
console.error(`WARN the hq grants this daemon no machine folder in the vault: ${problem}`)
|
|
219
|
+
return null
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
/** the daemon that carries an hq is its first node, with the grant `all` and its own machine: joined here, once,
|
|
223
|
+
* with no code typed */
|
|
224
|
+
export function joinCarriedHq(store: HqStore, now: number): { node: string } | Refused {
|
|
225
|
+
const held = readHqToken()
|
|
226
|
+
const live = held == null ? null : store.nodeOf(held)
|
|
227
|
+
const mine = ownMachineGrant()
|
|
228
|
+
if (live != null) {
|
|
229
|
+
// a node made before the kind machine gets its own machine beside all; its vault token follows at the next settle
|
|
230
|
+
if (mine != null && store.addGrant(live.id, mine, now)) markVault(store, live.id)
|
|
231
|
+
return { node: live.id }
|
|
232
|
+
}
|
|
233
|
+
// the token is lost or the hq no longer knows it: it joins as a new node, and only once that holds are the nodes
|
|
234
|
+
// this daemon had here ended (it writes the file itself). A refused join ends nothing and is kept, so the machines
|
|
235
|
+
// page and the hq check say it with its way out
|
|
236
|
+
const machine = { key: machineKey(), name: machineName() }
|
|
237
|
+
// its own machine, named in its own invite: another OS user's daemon may hold a node of it already
|
|
238
|
+
const code = store.invite({ person: store.person('owner', now), grants: [{ kind: 'all' }, ...(mine == null ? [] : [mine])], now, on: machine.key })
|
|
239
|
+
const r = store.join({ code, machine, osUser: userInfo().username, now })
|
|
240
|
+
if ('refused' in r) {
|
|
241
|
+
machineSet(OWN_JOIN, { refused: r.refused, at: now })
|
|
242
|
+
return r
|
|
243
|
+
}
|
|
244
|
+
store.endNodesOf(machine.key, userInfo().username, now, r.node)
|
|
245
|
+
machineDelete(OWN_JOIN)
|
|
246
|
+
keepHqToken(r.token)
|
|
247
|
+
return { node: r.node }
|
|
248
|
+
}
|
|
249
|
+
|
|
250
|
+
/** the machine db row of the hq's own join refused: an `hq-` row, so the backup never carries it */
|
|
251
|
+
const OWN_JOIN = 'hq-own-join'
|
|
252
|
+
|
|
253
|
+
/** why the daemon that carries the hq is no node of it, with the way out; null while it is one */
|
|
254
|
+
export function ownJoinRefused(): string | null {
|
|
255
|
+
const r = machineGet<{ refused: string; at: number }>(OWN_JOIN)
|
|
256
|
+
return r == null ? null : `the hq this machine carries refused its own daemon at its start: ${r.refused}. The way out: sk hq forget <the older machine of that name> (sk machines --json lists them), then sk pm restart daemon`
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
/** a node's door key while the hq's proxy is on; none while it is off, so no door opens to a proxy that is off */
|
|
260
|
+
async function carriedDoorKey(node: string): Promise<string | null> {
|
|
261
|
+
const { doorKeyOf, doorSecret, proxyOn } = await import('./door.ts')
|
|
262
|
+
return proxyOn() ? doorKeyOf(await doorSecret(), node) : null
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
/** the hq's routes on the daemon's own port, while it carries one; null for another path or a daemon that joined
|
|
266
|
+
* an hq elsewhere */
|
|
267
|
+
export async function carriedHqRoute(req: Request, path: string): Promise<Response | null> {
|
|
268
|
+
if (!path.startsWith('/hq/') || !carriesHq()) return null
|
|
269
|
+
const store = carriedHq()
|
|
270
|
+
if (store == null) return Response.json({ refused: 'the hq of this machine does not open its file' }, { status: 503 })
|
|
271
|
+
try {
|
|
272
|
+
const { houseTailnet } = await import('../serve/tailnet-caller.ts')
|
|
273
|
+
return await hqRoute(store, req, path, Date.now, carriedMinter, carriedDoorKey, { who: houseTailnet, ownMachine: machineKey() })
|
|
274
|
+
} catch (e) {
|
|
275
|
+
console.error(`WARN the hq failed ${req.method} ${path}: ${(e as Error).message}`)
|
|
276
|
+
return Response.json({ refused: 'the hq failed this call: the log of its daemon says why' }, { status: 500 })
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** this daemon's link to its hq, or why there is none */
|
|
281
|
+
export function myHq(): ReturnType<typeof httpHq> | Refused {
|
|
282
|
+
const token = readHqToken()
|
|
283
|
+
if (token != null) return httpHq(hqUrl(), token)
|
|
284
|
+
const own = carriesHq() ? ownJoinRefused() : null
|
|
285
|
+
return { refused: own ?? 'this daemon has not joined an hq yet: the daemon joins the one it carries at its start, `sk hq join` joins another' }
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/** the report job's body, in its child: the switch values the hq's machine asked of this node, this machine's report
|
|
289
|
+
* into the outbox, everything the hq lacks, then the asks and the reflections */
|
|
290
|
+
export async function hqReportTick(o: { repos: { name: string; path: string }[]; house: string; print: (l: string) => void; printErr: (l: string) => void; now?: number }): Promise<void> {
|
|
291
|
+
const hq = myHq()
|
|
292
|
+
if ('refused' in hq) return o.printErr(`WARN hq report: ${hq.refused}`)
|
|
293
|
+
const db = openDaemonDb()
|
|
294
|
+
if (db == null) return o.printErr('WARN hq report: the daemon\'s own database does not open, nothing is sent')
|
|
295
|
+
try {
|
|
296
|
+
const now = o.now ?? Date.now()
|
|
297
|
+
const status = readTailscaleStatus()
|
|
298
|
+
const outbox = new Outbox(db, 'report')
|
|
299
|
+
// the switch values the hq's console asked of this node, applied before the report, which then shows them
|
|
300
|
+
const hello = await hq.hello(outbox.epoch())
|
|
301
|
+
if (!('refused' in hello) && hello.wanted != null && hello.wanted.length > 0) {
|
|
302
|
+
const { applyWanted } = await import('./switch.ts')
|
|
303
|
+
for (const l of (await applyWanted(hello.wanted)).lines) (l.startsWith('WARN') ? o.printErr : o.print)(`${l.startsWith('WARN') ? 'WARN hq report: ' : 'ok: hq report: '}${l.replace(/^(WARN|ok:) /, '')}`)
|
|
304
|
+
}
|
|
305
|
+
// the key of this machine's door, which only the hq's home shows, kept as its hash; a hello with none (the
|
|
306
|
+
// hq's proxy is off) ends it, so the key dies with the switch at the next report
|
|
307
|
+
if (!('refused' in hello)) {
|
|
308
|
+
const door = await import('./door.ts')
|
|
309
|
+
if (typeof hello.door === 'string') {
|
|
310
|
+
if (await door.keepDoorKey(hello.door)) o.print('ok: hq report: this machine keeps the key of its door from the hq')
|
|
311
|
+
} else if (door.forgetDoorKey()) o.print("ok: hq report: the hq's proxy is off: this machine forgot the key of its door")
|
|
312
|
+
}
|
|
313
|
+
const waiting = db.query('select count(*) as waiting, min(since) as since from retry').get() as { waiting: number; since: number | null }
|
|
314
|
+
const { machineFacts, realReaders } = await import('./report-facts.ts')
|
|
315
|
+
const { mediaReport } = await import('../media-store/daemon.ts')
|
|
316
|
+
const facts = await machineFacts({ repos: o.repos, now, ...(await realReaders()) })
|
|
317
|
+
outbox.push('report', await buildReport({ repos: o.repos, house: o.house, tailnet: { name: status?.Self?.DNSName?.replace(/\.$/, '') || null, up: status?.BackendState === 'Running' }, diskOf: homeDir(), cards: waiting, media: mediaReport(), ...facts }), now)
|
|
318
|
+
const r = await flush(outbox, hq, now)
|
|
319
|
+
if ('refused' in r) return o.printErr(`WARN hq report: ${r.refused} (${outbox.size()} rows wait in the outbox)`)
|
|
320
|
+
if (r.renamed) o.printErr('WARN hq report: the hq held rows this outbox never made (the outbox is an older copy of itself): it took a new name and sent every row it holds again')
|
|
321
|
+
if (r.gone > 0) o.printErr(`WARN hq report: the hq lacks ${r.gone} rows this outbox no longer holds: it came back from an older copy than the outbox keeps`)
|
|
322
|
+
if (r.overCap > 0) o.printErr(`WARN hq report: ${r.overCap} rows the hq never took left the outbox, over its cap`)
|
|
323
|
+
// then the asks, and the reflections while their switch is on: a look whose folders did not move makes no call
|
|
324
|
+
await (await import('./files-send.ts')).hqFilesTick({ repos: o.repos, link: hq, db, print: o.print, printErr: o.printErr, now })
|
|
325
|
+
} finally {
|
|
326
|
+
db.close()
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
|
|
330
|
+
/** what the hq's port answers: the hq's routes and nothing else, whatever name or header the caller sends */
|
|
331
|
+
export async function hqPortFetch(req: Request): Promise<Response> {
|
|
332
|
+
return (await carriedHqRoute(req, new URL(req.url).pathname)) ?? Response.json({ refused: 'this port answers the hq only' }, { status: 404 })
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
let listener: { stop(closeActiveConnections?: boolean): void } | null = null
|
|
336
|
+
|
|
337
|
+
/** the hq's port: a second local port of the daemon that carries the hq, the only thing `tailscale serve` hands to
|
|
338
|
+
* the other machines. The daemon's own port, with every route of the home, is never handed to anyone: a caller
|
|
339
|
+
* from another machine cannot reach it by a Host header or a path, since the door has no such route */
|
|
340
|
+
export function setHqPort(open: boolean): { open: boolean; port: number } | Refused {
|
|
341
|
+
const port = hqPort()
|
|
342
|
+
if (!open) {
|
|
343
|
+
listener?.stop(true)
|
|
344
|
+
listener = null
|
|
345
|
+
machineSet(HQ_OPEN, false)
|
|
346
|
+
return { open: false, port }
|
|
347
|
+
}
|
|
348
|
+
if (!carriesHq()) return { refused: `this machine joined the hq at ${hqUrl()}: it carries none to open` }
|
|
349
|
+
if (listener == null) {
|
|
350
|
+
try {
|
|
351
|
+
listener = Bun.serve({
|
|
352
|
+
port,
|
|
353
|
+
hostname: '127.0.0.1',
|
|
354
|
+
fetch: hqPortFetch,
|
|
355
|
+
error: (e) => {
|
|
356
|
+
console.error(`WARN the hq's port failed a request: ${e.message}`)
|
|
357
|
+
return Response.json({ refused: 'the hq failed this call: the log of its daemon says why' }, { status: 500 })
|
|
358
|
+
},
|
|
359
|
+
})
|
|
360
|
+
} catch (e) {
|
|
361
|
+
return { refused: `the hq's port does not open on port ${port}: ${(e as Error).message}` }
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
machineSet(HQ_OPEN, true)
|
|
365
|
+
return { open: true, port }
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/** the owner's acts on the hq this daemon carries, asked by `sk hq` over loopback so the daemon stays the one
|
|
369
|
+
* writer of its file: the door opened or closed, a join code for another machine, the end of a node, a prompt
|
|
370
|
+
* forgotten, a switch wanted of another machine */
|
|
371
|
+
export async function hqAdminRoute(req: Request, path: string, now: number = Date.now()): Promise<Response | null> {
|
|
372
|
+
if (!path.startsWith('/api/home/hq/') || req.method !== 'POST') return null
|
|
373
|
+
// the web hands the home's routes to the whole tailnet, and tags each call it forwards with where it came from.
|
|
374
|
+
// A device there that names the web `localhost` gets the tag « local », so the tag proves nothing: a call that
|
|
375
|
+
// carries one came through the web and is refused. `sk hq` asks the daemon's own port, which is loopback only
|
|
376
|
+
if (req.headers.has(REACH_HEADER)) return Response.json({ refused: 'a join code, the end of a node, a forget and a switch are asked on the machine that carries the hq, in its console' }, { status: 403 })
|
|
377
|
+
if (path === '/api/home/hq/open' || path === '/api/home/hq/close') {
|
|
378
|
+
const r = setHqPort(path.endsWith('/open'))
|
|
379
|
+
return Response.json(r, { status: 'refused' in r ? 409 : 200 })
|
|
380
|
+
}
|
|
381
|
+
const store = carriesHq() ? carriedHq() : null
|
|
382
|
+
if (store == null) return Response.json({ refused: 'this daemon carries no hq: it joined one on another machine, ask there' }, { status: 409 })
|
|
383
|
+
const b = (await req.json().catch(() => ({}))) as { grants?: unknown; node?: unknown; kind?: unknown; name?: unknown; machine?: unknown; on?: unknown; onMachine?: unknown; go?: unknown }
|
|
384
|
+
if (path === '/api/home/hq/invite') {
|
|
385
|
+
const asked = Array.isArray(b.grants) ? (b.grants as unknown[]) : []
|
|
386
|
+
const problem = grantsProblem(asked)
|
|
387
|
+
if (problem != null) return Response.json({ refused: problem }, { status: 400 })
|
|
388
|
+
const grants = asked.map((g): Grant => ((g as Grant).kind === 'all' ? { kind: 'all' } : { kind: (g as { kind: 'repo' | 'identity' | 'machine' }).kind, name: (g as { name: string }).name }))
|
|
389
|
+
// a second OS user of a machine the hq knows: the owner names that machine, by its name or its id
|
|
390
|
+
let on: string | undefined
|
|
391
|
+
if (typeof b.onMachine === 'string' && b.onMachine !== '') {
|
|
392
|
+
const m = store.db.query('select id from machines where id = ?1 or name = ?1').all(b.onMachine) as { id: string }[]
|
|
393
|
+
if (m.length !== 1) return Response.json({ refused: m.length === 0 ? `the hq knows no machine ${JSON.stringify(b.onMachine).slice(0, 80)}` : `${m.length} machines are named ${JSON.stringify(b.onMachine).slice(0, 80)}: name it by its id (sk machines --json)` }, { status: 400 })
|
|
394
|
+
on = m[0]!.id
|
|
395
|
+
}
|
|
396
|
+
return Response.json({ code: store.invite({ person: store.person('owner', now), grants, now, ...(on == null ? {} : { on }) }), expires: now + INVITE_MS })
|
|
397
|
+
}
|
|
398
|
+
if (path === '/api/home/hq/end') {
|
|
399
|
+
const ended = typeof b.node === 'string' && store.end(b.node, now)
|
|
400
|
+
if (!ended) return Response.json({ ended })
|
|
401
|
+
const api = carriedMinter()
|
|
402
|
+
if (api == null) return Response.json({ ended, vault: 'no vault runs beside this hq' })
|
|
403
|
+
const { failed } = await settleVault(store, api).catch((e: unknown) => ({ failed: [(e as Error).message] }))
|
|
404
|
+
return Response.json({ ended, vault: failed.length === 0 ? 'its vault token is revoked and its folders closed' : `NOT reached, retried at the next mint or check: ${failed.join('; ')}` })
|
|
405
|
+
}
|
|
406
|
+
// the other Macs bound to read the vault through the hq's vault route, for sk vault status: names and days only
|
|
407
|
+
if (path === '/api/home/hq/vault-readers') return Response.json({ readers: vaultReaders(store) })
|
|
408
|
+
// what differs between the vault and the grants, for the house check: never a value, never a token
|
|
409
|
+
if (path === '/api/home/hq/vault-check') {
|
|
410
|
+
const api = carriedMinter()
|
|
411
|
+
if (api == null) return Response.json({ vault: false })
|
|
412
|
+
try {
|
|
413
|
+
return Response.json({ vault: true, ...(await vaultDrift(store, api)) })
|
|
414
|
+
} catch (e) {
|
|
415
|
+
return Response.json({ vault: true, refused: `the vault did not answer: ${(e as Error).message}` }, { status: 502 })
|
|
416
|
+
}
|
|
417
|
+
}
|
|
418
|
+
// a switch value for one machine's daemons, which they take at their next report (sk hq switch)
|
|
419
|
+
if (path === '/api/home/hq/switch') {
|
|
420
|
+
const r = typeof b.machine === 'string' && typeof b.name === 'string' && typeof b.on === 'boolean' ? store.want(b.machine, b.name, b.on, now) : { refused: 'a switch names its machine, its name and on or off' }
|
|
421
|
+
return Response.json(r, { status: 'refused' in r ? 400 : 200 })
|
|
422
|
+
}
|
|
423
|
+
// a retired machine forgotten: its row and its ended nodes, so its name is free again (sk hq forget)
|
|
424
|
+
if (path === '/api/home/hq/forget-machine') {
|
|
425
|
+
const r = store.forgetMachine({ machine: typeof b.machine === 'string' ? b.machine : '', own: machineKey(), go: b.go === true })
|
|
426
|
+
return Response.json(r, { status: 'refused' in r ? r.status : 200 })
|
|
427
|
+
}
|
|
428
|
+
// a row kept for good removed, once, and refused from any node from then on (sk history forget)
|
|
429
|
+
if (path === '/api/home/hq/forget') {
|
|
430
|
+
const r = store.forget(typeof b.kind === 'string' ? b.kind : '', typeof b.name === 'string' ? b.name : '', now)
|
|
431
|
+
return Response.json(r, { status: 'refused' in r ? 400 : 200 })
|
|
432
|
+
}
|
|
433
|
+
return null
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
/** the readers of this machine's vault on other Macs, asked of its daemon (the one process that opens the hq's
|
|
437
|
+
* file); null when it does not answer */
|
|
438
|
+
export async function askVaultReaders(): Promise<VaultReader[] | null> {
|
|
439
|
+
try {
|
|
440
|
+
const r = await fetch(`http://127.0.0.1:${daemonPort()}/api/home/hq/vault-readers`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: '{}', signal: AbortSignal.timeout(5_000) })
|
|
441
|
+
return r.ok ? ((await r.json()) as { readers: VaultReader[] }).readers : null
|
|
442
|
+
} catch {
|
|
443
|
+
return null
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
export type VaultCheck = { vault: false } | { vault: true; problems: string[]; nodes: number } | Refused
|
|
448
|
+
|
|
449
|
+
/** what differs between this machine's vault and the grants of the hq it carries, asked of its daemon (the one
|
|
450
|
+
* writer of the hq's file) over loopback */
|
|
451
|
+
export async function askVaultCheck(): Promise<VaultCheck> {
|
|
452
|
+
try {
|
|
453
|
+
const r = await fetch(`http://127.0.0.1:${daemonPort()}/api/home/hq/vault-check`, { method: 'POST', headers: { 'content-type': 'application/json' }, body: '{}', signal: AbortSignal.timeout(30_000) })
|
|
454
|
+
return (await r.json()) as VaultCheck
|
|
455
|
+
} catch (e) {
|
|
456
|
+
return { refused: `the daemon of this machine does not answer (${(e as Error).message}): sk pm starts it` }
|
|
457
|
+
}
|
|
458
|
+
}
|
|
459
|
+
|
|
460
|
+
/** this daemon leaves the hq it carries for one on another machine: the join there, the token kept, the url kept */
|
|
461
|
+
export async function joinOtherHq(url: string, code: string): Promise<{ node: string; vault: string } | Refused> {
|
|
462
|
+
const to = url.replace(/\/$/, '')
|
|
463
|
+
// the token this daemon holds goes only to the hq that gave it: a join of that same hq again keeps its node
|
|
464
|
+
const held = machineGet<string>(HQ_URL) === to ? (readHqToken() ?? undefined) : undefined
|
|
465
|
+
const r = await httpJoin(to, { code, machine: { key: machineKey(), name: machineName() }, osUser: userInfo().username }, fetch, held)
|
|
466
|
+
if ('refused' in r) return r
|
|
467
|
+
keepHqToken(r.token)
|
|
468
|
+
machineSet(HQ_URL, to)
|
|
469
|
+
const v = await refreshVaultToken()
|
|
470
|
+
return { node: r.node, vault: 'refused' in v ? `no vault token yet: ${v.refused}` : 'its vault token is kept beside the hq token' }
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
/** back to the hq this daemon carries: its next start joins it again */
|
|
474
|
+
export const leaveOtherHq = (): void => machineDelete(HQ_URL)
|
|
475
|
+
|
|
476
|
+
/** `asks`: the open asks of every machine, once each; absent while the hq does not read them. `door`: the home's port,
|
|
477
|
+
* while this machine carries the hq with its proxy on, so the page links a process through the door */
|
|
478
|
+
export type MachinesPage = { you: string; at: number; machines: (MachineView & { nodes: (MachineView['nodes'][number] & { line: { at: number; free: number }[] })[] })[]; notes: MachineNote[]; asks?: AskSeen[]; door?: { port: number } }
|
|
479
|
+
|
|
480
|
+
/** what the machines page and `sk machines` show: every machine the hq knows, each live node's free disk over
|
|
481
|
+
* `days`, what to look at, and the open asks of every machine */
|
|
482
|
+
export async function machinesPage(days = 30, now = Date.now()): Promise<MachinesPage | Refused> {
|
|
483
|
+
const hq = myHq()
|
|
484
|
+
if ('refused' in hq) return hq
|
|
485
|
+
const r = await hq.machines()
|
|
486
|
+
if ('refused' in r) return r
|
|
487
|
+
const machines = await Promise.all(
|
|
488
|
+
r.machines.map(async (m) => ({
|
|
489
|
+
...m,
|
|
490
|
+
nodes: await Promise.all(
|
|
491
|
+
m.nodes.map(async (n) => {
|
|
492
|
+
const d = n.ended == null ? await hq.disk(n.id, days) : { line: [] }
|
|
493
|
+
return { ...n, line: 'refused' in d ? [] : d.line }
|
|
494
|
+
}),
|
|
495
|
+
),
|
|
496
|
+
})),
|
|
497
|
+
)
|
|
498
|
+
const asks = await (await import('./files-send.ts')).readAsks(hq, r)
|
|
499
|
+
const { proxyOn } = await import('./door.ts')
|
|
500
|
+
const door = carriesHq() && proxyOn() ? { door: { port: homePort() } } : {}
|
|
501
|
+
return { you: r.you, at: now, machines, notes: machineNotes(r.machines, now), ...('refused' in asks ? {} : { asks: asks.asks.filter((a) => a.state === 'open') }), ...door }
|
|
502
|
+
}
|