rvlib-shipkit 2.31.0 → 2.33.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 +51 -0
- package/package.json +1 -1
- package/src/advisors/acts.ts +16 -15
- package/src/advisors/advice.ts +56 -102
- package/src/advisors/advisor-view.ts +122 -76
- package/src/advisors/app-graph.ts +1 -1
- package/src/advisors/app.ts +3 -11
- package/src/advisors/cf-api.ts +1 -1
- package/src/advisors/dir-bucket.ts +4 -3
- package/src/advisors/edge/api.ts +20 -221
- package/src/advisors/edge/bucket.ts +2 -2
- package/src/advisors/edge/handler.ts +13 -155
- package/src/advisors/edge/here.ts +5 -5
- package/src/advisors/edge/pages.ts +12 -9
- package/src/advisors/edge/shell.ts +6 -5
- package/src/advisors/edge/sign-in.ts +101 -36
- package/src/advisors/edge/status.ts +19 -6
- package/src/advisors/edge/types.ts +36 -60
- package/src/advisors/expose.ts +29 -29
- package/src/advisors/here.ts +12 -12
- package/src/advisors/invite-send.ts +79 -35
- package/src/advisors/invite.ts +31 -8
- package/src/advisors/job.ts +24 -16
- package/src/advisors/login.ts +40 -15
- package/src/advisors/owner-store.ts +46 -22
- package/src/advisors/photos.ts +3 -3
- package/src/advisors/project.ts +27 -25
- package/src/advisors/reach.ts +89 -0
- package/src/advisors/rights.ts +1 -1
- package/src/advisors/routes.ts +55 -74
- package/src/advisors/scan.ts +0 -4
- package/src/advisors/setup-run.ts +14 -14
- package/src/advisors/share-trace.ts +3 -3
- package/src/advisors/{door-probe.ts → sign-in-probe.ts} +7 -6
- package/src/advisors/speaks.ts +29 -0
- package/src/advisors/sync.ts +97 -183
- package/src/advisors/tunnel.ts +6 -5
- package/src/advisors/users-listen.ts +92 -0
- package/src/advisors/users-router.ts +261 -87
- package/src/advisors/users-store.ts +81 -0
- package/src/agent-time/blocked-scan.ts +181 -0
- package/src/agent-time/registry.ts +12 -5
- package/src/agent-time/store.ts +9 -109
- package/src/asks/ask-bar-fold.ts +2 -1
- package/src/asks/ask-close.ts +2 -1
- package/src/asks/ask-doc.ts +2 -1
- package/src/asks/ask-migrate.ts +3 -2
- package/src/asks/ask-steps-fold.ts +2 -1
- package/src/asks/ask-store.ts +4 -3
- package/src/check.ts +3 -43
- package/src/checks/SK001-package-json-shape.check.ts +4 -55
- package/src/checks/SK004-gitignore-policy.check.ts +24 -69
- package/src/checks/SK013-one-way-in-policy.check.ts +3 -7
- package/src/checks/SK017-vscode-hub-task.check.ts +4 -4
- package/src/checks/SK019-tests-run-in-units.check.ts +3 -14
- package/src/checks/SK020-self-spawning-check.check.ts +5 -7
- package/src/checks/SK035-public-clean.check.ts +1 -1
- package/src/checks/SK039-vscode-watch-generated.check.ts +1 -1
- package/src/checks/SK042-post-kinds.check.ts +5 -14
- package/src/checks/SK054-agent-allow-list.check.ts +5 -74
- package/src/checks/SK055-retired-config-keys.check.ts +45 -0
- package/src/cli/cmd_Advisors.ts +11 -45
- package/src/cli/cmd_Asks.ts +3 -10
- package/src/cli/cmd_Backup.ts +25 -127
- package/src/cli/cmd_BackupTargets.ts +1 -1
- package/src/cli/cmd_Capacity.ts +6 -2
- package/src/cli/cmd_Checks.ts +0 -14
- package/src/cli/cmd_Ci.ts +2 -1
- package/src/cli/cmd_Db.ts +3 -82
- package/src/cli/cmd_Home.ts +4 -32
- package/src/cli/cmd_Hq.ts +0 -17
- package/src/cli/cmd_Releases.ts +57 -4
- package/src/cli/cmd_Review.ts +333 -354
- package/src/cli/cmd_Shot.ts +26 -4
- package/src/cli/cmd_SocialDrafts.ts +6 -13
- package/src/cli/cmd_ThreadSyncNeeds.ts +6 -2
- package/src/cli/cmd_Time.ts +1 -1
- package/src/cli/cmd_Trailer.ts +1 -1
- package/src/cli/inbox-hook-run.ts +5 -23
- package/src/cli/registry-heads.ts +5 -55
- package/src/cli/registry.ts +1 -5
- package/src/cli/review-here.ts +1 -1
- package/src/cli.ts +15 -4
- package/src/collections/collection-types.ts +1 -1
- package/src/collections/review.ts +5 -4
- package/src/core/admission.ts +268 -0
- package/src/core/agent-allow-policy.ts +32 -2
- package/src/core/agent-env.ts +8 -0
- package/src/core/allow-rows.ts +74 -0
- package/src/core/check-file-names.ts +19 -106
- package/src/core/code-lines.ts +36 -21
- package/src/core/footprint.ts +17 -13
- package/src/core/identities-root.ts +1 -4
- package/src/core/layout.ts +1 -2
- package/src/core/machine-db.ts +33 -208
- package/src/core/machine-layout.ts +14 -127
- package/src/core/machine-read.ts +5 -2
- package/src/core/mask-source.ts +60 -0
- package/src/core/memory-watch.ts +17 -14
- package/src/core/motherhome.ts +8 -35
- package/src/core/one-way-in-policy.ts +0 -3
- package/src/core/peer-sk.ts +8 -0
- package/src/core/repo-walk.ts +0 -9
- package/src/core/retention.ts +1 -9
- package/src/core/retired-checks.ts +2 -0
- package/src/core/tmux-policy.ts +1 -1
- package/src/core/tree-watch.ts +2 -2
- package/src/core/when.ts +7 -45
- package/src/gate/admit-heavy.ts +150 -0
- package/src/gate/check-runner.ts +6 -0
- package/src/gate/discover-checks.ts +42 -32
- package/src/gate/gate-checks.ts +21 -131
- package/src/gate/head-gate.ts +1 -1
- package/src/gate/job-run.ts +2 -1
- package/src/gate/pre-commit-discovery.ts +22 -28
- package/src/gate/run-check.ts +3 -4
- package/src/gate/run-ci.ts +4 -0
- package/src/gate/run-fix.ts +5 -17
- package/src/gate/run-fixers.ts +6 -42
- package/src/home/app-sign.ts +2 -2
- package/src/home/backup-status.ts +52 -92
- package/src/home/backup-verdict.ts +2 -2
- package/src/home/daemon-jobs.ts +51 -95
- package/src/home/database-words.ts +1 -2
- package/src/home/databases.ts +9 -25
- package/src/home/home-launchd.ts +0 -6
- package/src/home/home-paths.ts +8 -4
- package/src/home/home-routes.ts +3 -10
- package/src/home/home-state.ts +2 -14
- package/src/home/inbox-shape.ts +14 -15
- package/src/home/inbox.ts +1 -1
- package/src/home/machine-repair.ts +102 -103
- package/src/home/resume.ts +1 -15
- package/src/home/run-daemon.ts +7 -12
- package/src/home/space-page.ts +3 -2
- package/src/home/supervise.ts +3 -7
- package/src/hooks/commit-msg-run.ts +61 -0
- package/src/hooks/commit-run.ts +16 -166
- package/src/hooks/gate-outcome.ts +108 -0
- package/src/hooks/git-hook.ts +9 -9
- package/src/hooks/hook-config.ts +8 -8
- package/src/hooks/leak-guard.ts +1 -1
- package/src/hooks/pre-commit-checks.ts +1 -1
- package/src/hooks/run-hooks.ts +2 -6
- package/src/hooks/shared-file.ts +3 -2
- package/src/hq/daemon-db.ts +8 -8
- package/src/hq/door.ts +3 -16
- package/src/hq/hq-db.ts +4 -3
- package/src/hq/hq-local.ts +1 -2
- package/src/hq/hq-store.ts +0 -15
- package/src/hq/item-direct.ts +8 -10
- package/src/hq/item-fill.ts +37 -0
- package/src/hq/kinds/item-gone.ts +7 -10
- package/src/hq/kinds/item-msg.ts +12 -18
- package/src/hq/kinds/item.ts +13 -19
- package/src/hq/kinds/report.ts +3 -4
- package/src/hq/owner-switch.ts +3 -3
- package/src/hq/report.ts +5 -9
- package/src/hq/switch.ts +2 -11
- package/src/hq/thread-sync.ts +5 -17
- package/src/hq/{shapes-words.ts → threads-words.ts} +2 -12
- package/src/http/owner-word.ts +1 -1
- package/src/identities/machine.ts +16 -0
- package/src/init-repo.ts +0 -1
- package/src/ledger/check-stats.ts +6 -5
- package/src/ledger/db.ts +2 -4
- package/src/ledger/record-kept.ts +117 -48
- package/src/ledger/run-log.ts +21 -2
- package/src/ledger/slow-tests.ts +96 -0
- package/src/ledger/store.ts +3 -86
- package/src/ledger/suite-log.ts +8 -2
- package/src/media-store/backup/facts.ts +3 -37
- package/src/media-store/backup/keys.ts +1 -8
- package/src/media-store/backup/manifest.ts +6 -67
- package/src/media-store/backup/restore.ts +4 -13
- package/src/media-store/backup/retention.ts +13 -1
- package/src/media-store/backup/run.ts +6 -267
- package/src/media-store/backup/snapshot.ts +2 -38
- package/src/media-store/backup/sources.ts +3 -113
- package/src/media-store/backup/target-send.ts +5 -29
- package/src/media-store/db.ts +8 -7
- package/src/media-store/forget-one.ts +1 -1
- package/src/media-store/forget.ts +1 -80
- package/src/orchestrator/guards.ts +0 -1
- package/src/orchestrator/presence.ts +2 -2
- package/src/orchestrator/routes.ts +1 -1
- package/src/orchestrator/started.ts +0 -9
- package/src/orchestrator/talk-key.ts +3 -4
- package/src/orchestrator/unheard.ts +1 -1
- package/src/plan/planner.ts +3 -2
- package/src/recordings/edit.ts +3 -3
- package/src/recordings/marks-draw.ts +17 -6
- package/src/recordings/marks.ts +120 -9
- package/src/reflections/reflections-queue.ts +3 -10
- package/src/release/notes.ts +1 -1
- package/src/release/public-clean.ts +66 -6
- package/src/release/run-bump.ts +11 -0
- package/src/release/run-release.ts +4 -0
- package/src/releases/from-thread.ts +3 -3
- package/src/releases/model.ts +186 -36
- package/src/releases/store.ts +13 -3
- package/src/releases/validate.ts +83 -0
- package/src/repo-config.ts +36 -64
- package/src/review/answer-kinds.ts +63 -4
- package/src/review/blocked-guard.ts +11 -0
- package/src/review/blocked-object.ts +298 -0
- package/src/review/cells.ts +144 -230
- package/src/review/close.ts +39 -1
- package/src/review/doc-save.ts +3 -2
- package/src/review/draft-item.ts +1 -1
- package/src/review/events.ts +3 -7
- package/src/review/expect.ts +23 -39
- package/src/review/format.ts +79 -46
- package/src/review/glyphs.ts +1 -0
- package/src/review/hand-over.ts +3 -3
- package/src/review/heard.ts +1 -1
- package/src/review/holds-sync.ts +2 -1
- package/src/review/inbox-hook.ts +2 -2
- package/src/review/inbox-read.ts +39 -33
- package/src/review/instruction-guards.ts +12 -0
- package/src/review/instructions.ts +0 -1
- package/src/review/item-db.ts +13 -43
- package/src/review/item-hq.ts +2 -2
- package/src/review/item-rows.ts +3 -14
- package/src/review/kind-catalog.ts +3 -1
- package/src/review/kinds.ts +18 -8
- package/src/review/live-view.ts +3 -0
- package/src/review/media-kind.ts +1 -1
- package/src/review/mentions.ts +1 -2
- package/src/review/model.ts +158 -114
- package/src/review/move.ts +149 -0
- package/src/review/need-threads.ts +3 -2
- package/src/review/object-card.ts +11 -0
- package/src/review/object-read.ts +6 -1
- package/src/review/one-block.ts +1 -1
- package/src/review/owner-read.ts +1 -1
- package/src/review/phone-push.ts +10 -9
- package/src/review/previews.ts +32 -4
- package/src/review/push.ts +2 -2
- package/src/review/recap.ts +129 -0
- package/src/review/referring.ts +6 -3
- package/src/review/reflection-object.ts +4 -3
- package/src/review/routes.ts +51 -47
- package/src/review/secret-route.ts +3 -2
- package/src/review/settle.ts +0 -6
- package/src/review/snooze.ts +5 -3
- package/src/review/speaker.ts +68 -0
- package/src/review/start-title.ts +19 -0
- package/src/review/store-parties.ts +28 -0
- package/src/review/store.ts +94 -59
- package/src/review/{wakes.ts → thread-events.ts} +92 -7
- package/src/review/thread-md.ts +35 -14
- package/src/review/thread-state.ts +804 -0
- package/src/review/threads.ts +29 -347
- package/src/review/traces.ts +104 -7
- package/src/review/trailer-item.ts +1 -1
- package/src/review/unit.ts +7 -9
- package/src/review/verdict-items.ts +12 -10
- package/src/review/view-layout.ts +25 -1
- package/src/review/watch-feed.ts +1 -2
- package/src/review/working-guards.ts +2 -3
- package/src/rules/untrack-generated.ts +1 -15
- package/src/secrets/copy.ts +4 -4
- package/src/secrets/lapse.ts +2 -1
- package/src/serve/hub-app/advisor-app.tsx +4 -4
- package/src/serve/hub-app/advisor-face.tsx +9 -3
- package/src/serve/hub-app/advisor-host.ts +27 -27
- package/src/serve/hub-app/advisors-model.ts +17 -8
- package/src/serve/hub-app/advisors-rights.tsx +1 -1
- package/src/serve/hub-app/advisors-st.ts +15 -14
- package/src/serve/hub-app/advisors-view.tsx +13 -11
- package/src/serve/hub-app/app-bridge.ts +23 -3
- package/src/serve/hub-app/asks-page.tsx +1 -1
- package/src/serve/hub-app/auto-text.tsx +71 -16
- package/src/serve/hub-app/check-view.tsx +0 -8
- package/src/serve/hub-app/controls.css +14 -3
- package/src/serve/hub-app/database-view.tsx +1 -2
- package/src/serve/hub-app/dock-st.ts +1 -1
- package/src/serve/hub-app/git-view.tsx +3 -1
- package/src/serve/hub-app/hub.css +12 -5
- package/src/serve/hub-app/icons.tsx +1 -1
- package/src/serve/hub-app/inbox-view.tsx +1 -2
- package/src/serve/hub-app/live-sources.ts +2 -2
- package/src/serve/hub-app/main-panel.tsx +2 -1
- package/src/serve/hub-app/panel-repo.ts +0 -9
- package/src/serve/hub-app/pic.tsx +29 -12
- package/src/serve/hub-app/polled.ts +16 -2
- package/src/serve/hub-app/recordings-st.ts +23 -2
- package/src/serve/hub-app/recordings-view.tsx +68 -10
- package/src/serve/hub-app/ref-pill.ts +1 -1
- package/src/serve/hub-app/repo-st.ts +1 -2
- package/src/serve/hub-app/review/advisor-add.tsx +1 -1
- package/src/serve/hub-app/review/advisor-invite.tsx +1 -1
- package/src/serve/hub-app/review/draft-body.tsx +2 -2
- package/src/serve/hub-app/review/heard-line.tsx +1 -1
- package/src/serve/hub-app/review/instructions-view.tsx +1 -8
- package/src/serve/hub-app/review/kind-states.tsx +14 -9
- package/src/serve/hub-app/review/kit.tsx +4 -11
- package/src/serve/hub-app/review/lane-bar.tsx +3 -3
- package/src/serve/hub-app/review/lightbox.tsx +15 -11
- package/src/serve/hub-app/review/line-window.ts +4 -1
- package/src/serve/hub-app/review/live-bar-st.ts +2 -2
- package/src/serve/hub-app/review/live-view.tsx +57 -1
- package/src/serve/hub-app/review/object-panel.tsx +20 -8
- package/src/serve/hub-app/review/question-views.tsx +191 -53
- package/src/serve/hub-app/review/recap-bar.tsx +40 -0
- package/src/serve/hub-app/review/request-cell.tsx +48 -0
- package/src/serve/hub-app/review/review-cells.tsx +154 -96
- package/src/serve/hub-app/review/review-host.ts +8 -4
- package/src/serve/hub-app/review/review-kit.ts +17 -11
- package/src/serve/hub-app/review/review-list.tsx +30 -35
- package/src/serve/hub-app/review/review-st.ts +32 -42
- package/src/serve/hub-app/review/review-thread.tsx +139 -85
- package/src/serve/hub-app/review/review-views.tsx +127 -68
- package/src/serve/hub-app/review/share-lines.tsx +4 -4
- package/src/serve/hub-app/review/start-st.ts +2 -5
- package/src/serve/hub-app/review/superseded-runs.ts +4 -3
- package/src/serve/hub-app/review/thread-close.tsx +10 -7
- package/src/serve/hub-app/review/thread-st.ts +381 -202
- package/src/serve/hub-app/review/tone-bar.tsx +129 -0
- package/src/serve/hub-app/review/tones.ts +53 -0
- package/src/serve/hub-app/review/trailer-body.tsx +2 -2
- package/src/serve/hub-app/review/trailer-st.ts +3 -2
- package/src/serve/hub-app/review/trailer-voices-st.ts +3 -2
- package/src/serve/hub-app/review.css +189 -106
- package/src/serve/hub-app/search-view.tsx +1 -1
- package/src/serve/hub-app/social/social-model.ts +0 -4
- package/src/serve/hub-app/source-acts.ts +2 -1
- package/src/serve/hub-app/stores/stores-page.tsx +2 -2
- package/src/serve/hub-app/terminal-sources.tsx +2 -1
- package/src/serve/hub-app/thread-row.tsx +3 -4
- package/src/serve/hub-app/tree-build.ts +0 -4
- package/src/serve/hub-app/urls-view.tsx +2 -1
- package/src/serve/hub-app/view-layout.css +13 -3
- package/src/serve/hub-app/wikis-view.tsx +5 -2
- package/src/serve/hub-runtime.ts +7 -37
- package/src/serve/project-gutter-route.ts +6 -2
- package/src/serve/read-thread.ts +20 -2
- package/src/serve/read-worker.ts +9 -1
- package/src/serve/record-pages.ts +46 -0
- package/src/serve/serve-hub.ts +2 -2
- package/src/serve/terminal-host.ts +1 -1
- package/src/serve/terminal-route.ts +1 -3
- package/src/serve/tracked-watch.ts +1 -3
- package/src/setup-house.ts +2 -2
- package/src/shipkit-files.ts +1 -1
- package/src/shipkit.ts +1 -6
- package/src/shot/client.ts +2 -1
- package/src/shot/film-box.ts +0 -20
- package/src/shot/on-place.ts +141 -0
- package/src/social/drafts.ts +1 -1
- package/src/social/kinds.ts +6 -29
- package/src/social/load.ts +2 -2
- package/src/social/post-object.ts +3 -2
- package/src/social/release-stage.ts +1 -1
- package/src/social/stage.ts +2 -2
- package/src/stores/model.ts +4 -0
- package/src/stores/routes.ts +11 -3
- package/src/suite/judge-suites.ts +58 -0
- package/src/suite/red-alone.ts +54 -18
- package/src/suite/runner-shapes.ts +2 -2
- package/src/suite/suite-cli.ts +67 -14
- package/src/suite/test-units.ts +2 -1
- package/src/urls/fill.ts +1 -1
- package/src/urls/places.ts +1 -2
- package/src/vault/vault-config.ts +2 -2
- package/src/vault/vault-init.ts +1 -5
- package/src/wiki/graph-page.ts +14 -2
- package/src/advisors/copy-truth.ts +0 -49
- package/src/advisors/door-child.ts +0 -112
- package/src/advisors/door-serve.ts +0 -52
- package/src/advisors/door.ts +0 -118
- package/src/checks/SK016-legacy-check-shapes.check.ts +0 -189
- package/src/checks/SK029-explicit-check-files.check.ts +0 -112
- package/src/checks/SK048-one-local-file.check.ts +0 -36
- package/src/core/config-rewrite.ts +0 -111
- package/src/core/daemon-port.ts +0 -10
- package/src/core/legacy-shapes.ts +0 -263
- package/src/core/migrate-layout.ts +0 -638
- package/src/core/port-check-cli.ts +0 -52
- package/src/core/port-check-file.ts +0 -295
- package/src/core/port-check-files.ts +0 -31
- package/src/gate/discover-legacy-checks.ts +0 -26
- package/src/home/home-move.ts +0 -527
- package/src/home/machine-fold.ts +0 -810
- package/src/hq/item-shapes.ts +0 -54
- package/src/hq/kinds/items-read.ts +0 -4
- package/src/media-store/backup/daemon.ts +0 -220
- package/src/media-store/backup/kept.ts +0 -241
- package/src/media-store/backup/prune.ts +0 -359
- package/src/media-store/backup/secret.ts +0 -88
- package/src/media-store/backup/ssh-space.ts +0 -202
- package/src/media-store/backup/watch.ts +0 -117
- package/src/review/band.ts +0 -182
- package/src/review/folders.ts +0 -216
- package/src/review/hook-ask.ts +0 -58
- package/src/review/role.ts +0 -48
- package/src/review/thread-fold.ts +0 -64
- package/src/review/wait.ts +0 -91
- package/src/rules/rule.ts +0 -43
- package/src/serve/hook-thread.ts +0 -37
- package/src/serve/hook-work.ts +0 -92
- package/src/serve/hook-worker.ts +0 -57
- package/src/serve/hub-app/review/dock.tsx +0 -147
- package/src/serve/hub-app/review/faces.tsx +0 -18
- package/src/serve/hub-app/review/item-verdict.tsx +0 -112
- package/src/serve/hub-app/review/review-board.tsx +0 -48
- /package/src/{scaffold → core}/jsonc-spans.ts +0 -0
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// the advisors' state on the Mac (wiki tools/shipkit/advisors.md): the people (profiles that grant nothing), the grants
|
|
2
|
-
// (a thread's share, a project's access), the rights over layers, the images
|
|
3
|
-
// and the threads they propose, waiting for
|
|
4
|
-
// watch or hook reads this file. One json file under a lock, written beside and renamed; an older
|
|
5
|
-
// its first read, the old file kept beside as `owner.json.before-v<n>`; the
|
|
2
|
+
// (a thread's share, a project's access), the rights over layers, the images the owner confirmed for each person, the
|
|
3
|
+
// advice and the threads they propose, waiting for the owner. What waits lives here alone, never in a thread store: no
|
|
4
|
+
// agent's inbox, watch or hook reads this file. One json file under a lock, written beside and renamed; an older
|
|
5
|
+
// version moves up at its first read, the old file kept beside as `owner.json.before-v<n>`; the users' port reads it at
|
|
6
|
+
// each request and writes it only where a person's act lands (advice.ts, users-store.ts markSpent)
|
|
6
7
|
import { createHash } from 'node:crypto'
|
|
7
8
|
import { copyFileSync, existsSync, mkdirSync, readFileSync, renameSync, rmSync, statSync } from 'node:fs'
|
|
8
9
|
import { join } from 'node:path'
|
|
@@ -30,19 +31,42 @@ export interface Advisor {
|
|
|
30
31
|
lastInvited?: string
|
|
31
32
|
/** the last try that did not go, kept until one goes */
|
|
32
33
|
inviteFailed?: { at: string; why: string }
|
|
33
|
-
/** their sign in
|
|
34
|
+
/** their sign in on the advisors page (advisors/login.ts), minted with their first live grant */
|
|
34
35
|
login?: Login
|
|
36
|
+
/** the password resets they asked, the newest last, the last RESETS_KEPT: his hub's line on them */
|
|
37
|
+
resets?: ResetAsked[]
|
|
35
38
|
}
|
|
36
39
|
|
|
40
|
+
export const RESETS_KEPT = 5
|
|
41
|
+
|
|
37
42
|
/** a person's sign in: its generation (a new code is the next one, which ends the password and the sessions of the
|
|
38
|
-
* last), the one time code the invite carries (the
|
|
39
|
-
* says it set a password */
|
|
43
|
+
* last), the one time code the invite carries (the sign in reads its hash), until when it works, and whether the users'
|
|
44
|
+
* port says it set a password */
|
|
40
45
|
export interface Login {
|
|
41
46
|
gen: number
|
|
42
47
|
code: string
|
|
43
48
|
codeUntil: string
|
|
44
49
|
at: string
|
|
45
50
|
used?: true
|
|
51
|
+
/** the next generation a reset the person asked parks here, its code for 30 minutes (login.ts parkReset): it
|
|
52
|
+
* becomes the login once its code signs in, so a stranger who asks one ends nothing */
|
|
53
|
+
reset?: Omit<Login, 'reset'>
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
/** a reset the person asked at the sign in: when, when its mail left (marked before it leaves, so one pass sends it),
|
|
57
|
+
* or why it did not go */
|
|
58
|
+
export interface ResetAsked {
|
|
59
|
+
at: string
|
|
60
|
+
sent?: string
|
|
61
|
+
why?: string
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** a reset whose mail waits: the newest ask, no mail tried yet, a code parked and live (a new one, or the one an earlier
|
|
65
|
+
* ask mailed, sent again) */
|
|
66
|
+
export const resetWaits = (a: Advisor, now: Date): boolean => {
|
|
67
|
+
const r = a.resets?.at(-1)
|
|
68
|
+
const p = a.login?.reset
|
|
69
|
+
return r !== undefined && p !== undefined && r.sent === undefined && r.why === undefined && Date.parse(p.codeUntil) > now.getTime()
|
|
46
70
|
}
|
|
47
71
|
|
|
48
72
|
/** a profile photo: the hash of its 64 px webp (the bucket's key, the hub's cache key) and when it was set */
|
|
@@ -103,19 +127,20 @@ export interface Share {
|
|
|
103
127
|
deferred: boolean
|
|
104
128
|
include: Record<string, Include>
|
|
105
129
|
revoked?: string
|
|
106
|
-
/**
|
|
130
|
+
/** fields no pass writes: each pass drops them */
|
|
107
131
|
held?: Held[]
|
|
108
132
|
waiting?: ImageWait[]
|
|
109
133
|
/** the entries the last pass sent with strings masked (a credential, a secret's name, a private word) */
|
|
110
134
|
masked?: Masked[]
|
|
111
|
-
/** the thread's versions as the last
|
|
135
|
+
/** the thread's versions as the last pass counted them, and how many of them the person sees */
|
|
112
136
|
parts?: { versions: number; shown: number }
|
|
113
|
-
/** the last
|
|
137
|
+
/** the last pass's word on this share: whether it reaches its person, else why */
|
|
114
138
|
reach?: { ok: boolean; at: string; why?: string }
|
|
115
|
-
/** the hash of the
|
|
139
|
+
/** the hash of the share's view and manifest at the last pass that prepared it: set once it reached its person
|
|
140
|
+
* (share-trace.ts) */
|
|
116
141
|
pushed?: string
|
|
117
|
-
/** where the person's reading stands, as the
|
|
118
|
-
* covers
|
|
142
|
+
/** where the person's reading stands, as the users' port wrote it and the pass pulled it: when, up to which time of
|
|
143
|
+
* the view, and whether that covers the owner's newest word (the owner's hub then reads « seen by <name> », as for an agent) */
|
|
119
144
|
read?: ShareRead
|
|
120
145
|
}
|
|
121
146
|
|
|
@@ -149,7 +174,7 @@ export interface Advice {
|
|
|
149
174
|
option?: number
|
|
150
175
|
qhash?: string
|
|
151
176
|
text?: string
|
|
152
|
-
/** the
|
|
177
|
+
/** the entry it came in (`<ms>-<random>`): its files wait under it */
|
|
153
178
|
entry?: string
|
|
154
179
|
files?: PendingFile[]
|
|
155
180
|
state: AdviceState
|
|
@@ -167,7 +192,7 @@ export interface Proposal {
|
|
|
167
192
|
advisor: string
|
|
168
193
|
repo: string
|
|
169
194
|
root: string
|
|
170
|
-
/** the
|
|
195
|
+
/** the start place's id it came by (startPlacesOf), and its entry: its files wait under `upload/p/<propose>/<entry>/` */
|
|
171
196
|
propose: string
|
|
172
197
|
entry: string
|
|
173
198
|
at: string
|
|
@@ -187,7 +212,7 @@ export interface OwnerState {
|
|
|
187
212
|
v: typeof STATE_VERSION
|
|
188
213
|
/** the id of the identity the house speaks as, kept by the pass: the name advisors read when he set none */
|
|
189
214
|
owner: string
|
|
190
|
-
/** the
|
|
215
|
+
/** the advisors page's host once it is set up (`advisors.<domain>`) */
|
|
191
216
|
host: string | null
|
|
192
217
|
/** the people: profiles, his and the ones an agent prepared */
|
|
193
218
|
advisors: Advisor[]
|
|
@@ -215,7 +240,7 @@ export interface SetupRun {
|
|
|
215
240
|
/** the last mark a pass looked at: the setup token written after it starts a run; an agent's refusal leaves it.
|
|
216
241
|
* Absent from a run older than the rule: its `mark` stands for it */
|
|
217
242
|
seen?: number
|
|
218
|
-
/**
|
|
243
|
+
/** the owner's « set the advisors page up now » on the advisors page started it */
|
|
219
244
|
asked?: true
|
|
220
245
|
at: string
|
|
221
246
|
state: 'running' | 'done' | 'failed'
|
|
@@ -237,8 +262,6 @@ export interface OwnerNames {
|
|
|
237
262
|
export const EMPTY: OwnerState = { v: STATE_VERSION, owner: 'the owner', host: null, advisors: [], shares: [], access: [], rights: [], advice: [], proposals: [], images: {} }
|
|
238
263
|
|
|
239
264
|
/** the folder of the advisors' state: SHIPKIT_ADVISORS_DIR, else the machine's `~/.shipkit/advisors` */
|
|
240
|
-
/** the door's folder: what its server reads, beside the advisors' state */
|
|
241
|
-
export const doorDir = (dir = advisorsDir()): string => join(dir, 'door')
|
|
242
265
|
export const advisorsDir = (): string => process.env.SHIPKIT_ADVISORS_DIR?.trim() || machinePath('advisors')
|
|
243
266
|
|
|
244
267
|
const fileOf = (dir: string): string => join(dir, 'owner.json')
|
|
@@ -372,7 +395,7 @@ export interface StartPlace {
|
|
|
372
395
|
}
|
|
373
396
|
|
|
374
397
|
/** where each person may start a thread: `startThreads` resolves per person and project, on a project they have, that
|
|
375
|
-
* is a live access there, else a live share there. An access's
|
|
398
|
+
* is a live access there, else a live share there. An access's place is its id; a share's is derived from the oldest
|
|
376
399
|
* live one, so it holds while that share does and ends with the last */
|
|
377
400
|
export function startPlacesOf(s: OwnerState, now: Date): StartPlace[] {
|
|
378
401
|
const out = new Map<string, StartPlace>()
|
|
@@ -387,8 +410,9 @@ export function startPlacesOf(s: OwnerState, now: Date): StartPlace[] {
|
|
|
387
410
|
return [...out.values()]
|
|
388
411
|
}
|
|
389
412
|
|
|
390
|
-
/** the shares the
|
|
391
|
-
* who still has a profile. The
|
|
413
|
+
/** the shares the users' port lets in now: live (the owner's share, or an agent's the owner confirmed, not ended, not
|
|
414
|
+
* expired) and of a person who still has a profile. The port serves these alone (users-router.ts callerOf), so its
|
|
415
|
+
* routes open exactly these */
|
|
392
416
|
export const servedShares = (s: OwnerState, now: Date): Share[] => s.shares.filter((x) => isLive(x, now) && s.advisors.some((a) => a.id === x.advisor))
|
|
393
417
|
|
|
394
418
|
/** who can open one thread now, by person id: the people of its served shares */
|
package/src/advisors/photos.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// a person's profile photo (wiki tools/shipkit/advisors.md, A face for each
|
|
2
|
-
//
|
|
3
|
-
// alone, through the
|
|
1
|
+
// a person's profile photo (wiki tools/shipkit/advisors.md, A face for each advisor): one square picture re-encoded to two webps, 256 px for the hub and 64 px for the small faces and the
|
|
2
|
+
// advisors page, kept in `photos/` beside owner.json, never in git. Setting one grants nothing: it reaches the advisor's
|
|
3
|
+
// own page alone, through the users' port (users-router.ts, `/api/advisor/photo`), and the owner's hub
|
|
4
4
|
// the one constraint a reader breaks first: every byte that becomes a photo passes `squareWebps` (a picture by its first
|
|
5
5
|
// bytes, its pixels capped, its metadata dropped); a url is https, an image type and a size cap before a byte is kept
|
|
6
6
|
import { createHash } from 'node:crypto'
|
package/src/advisors/project.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
// what an advisor sees of a thread (wiki tools/shipkit/advisors.md, What the advisor sees): a projection to the hub's own
|
|
2
|
-
// items by a WHITELIST of fields, every part of a thread
|
|
3
|
-
// private words masked in place. Pure:
|
|
4
|
-
// (advisor-view.ts)
|
|
5
|
-
// the one constraint a reader breaks first: a field of the store reaches the
|
|
2
|
+
// items by a WHITELIST of fields, every part of a thread the owner shared going out, a credential, a secret's name and
|
|
3
|
+
// the owner's private words masked in place. Pure: sync.ts prepare names each picture and runs the hub's builders on
|
|
4
|
+
// the result (advisor-view.ts)
|
|
5
|
+
// the one constraint a reader breaks first: a field of the store reaches the view only when this file names it
|
|
6
6
|
import { createHash } from 'node:crypto'
|
|
7
|
-
import { isGallery, partyOf, type Item, type Message, type ReviewItem, type ReviewView } from '../review/model.ts'
|
|
7
|
+
import { isGallery, partyOf, STATUSES, type Item, type Message, type ReviewItem, type ReviewView } from '../review/model.ts'
|
|
8
8
|
import { membersOf, threadTitle, type Thread } from '../review/threads.ts'
|
|
9
9
|
import { mask, maskHits, type HitKind, type ScanContext } from './scan.ts'
|
|
10
10
|
|
|
@@ -35,7 +35,7 @@ export interface Masked {
|
|
|
35
35
|
title?: string
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
/** an entry
|
|
38
|
+
/** an entry of the stale `held` field a share may carry: no pass writes it, each pass drops it */
|
|
39
39
|
export interface Held {
|
|
40
40
|
key: string
|
|
41
41
|
hash: string
|
|
@@ -46,7 +46,7 @@ export interface Held {
|
|
|
46
46
|
|
|
47
47
|
const PICTURE = /\.(png|jpe?g|webp)$/i
|
|
48
48
|
|
|
49
|
-
const VERDICTS = new Set(
|
|
49
|
+
const VERDICTS = new Set<string>(STATUSES)
|
|
50
50
|
|
|
51
51
|
/** a message's files of a view: an image, or a pair; a clip, a sound and a gallery's other kinds never leave */
|
|
52
52
|
function viewFiles(v: ReviewView): string[] {
|
|
@@ -89,16 +89,16 @@ function passes(m: Message): boolean {
|
|
|
89
89
|
|
|
90
90
|
// ── the projection as the hub's own items: the advisor's page draws them with the hub's builders and components ──
|
|
91
91
|
|
|
92
|
-
/** a store id as the share's
|
|
93
|
-
* store id, and the
|
|
92
|
+
/** a store id as the share's view names it: the share's id, then a hash of the store's id. The advisor never reads a
|
|
93
|
+
* store id, and the users' port finds the share of any id by its prefix */
|
|
94
94
|
export const opaqueItem = (share: string, id: string): string => `${share}.${createHash('sha256').update(`${share}|${id}`).digest('hex').slice(0, 12)}`
|
|
95
95
|
export const opaqueMessage = (share: string, id: string): string => `m${createHash('sha256').update(`${share}|m|${id}`).digest('hex').slice(0, 12)}`
|
|
96
|
-
/** the one address every item of the
|
|
96
|
+
/** the one address every item of the view is on: its notes join its versions as they do in the store */
|
|
97
97
|
export const sharedAddress = (share: string): string => `shared:${share}`
|
|
98
98
|
|
|
99
99
|
export interface ItemsInput extends Pick<ProjectInput, 'thread' | 'answers' | 'scan' | 'include'> {
|
|
100
100
|
share: string
|
|
101
|
-
/** the advisor the
|
|
101
|
+
/** the advisor the view is for: the owner's words that name them read « asks you » there, shown even when the other answers are not */
|
|
102
102
|
advisor?: string
|
|
103
103
|
/** a picture of the thread as the advisor gets it: its served name, null when it does not leave (his eyes first, a
|
|
104
104
|
* file gone, a clip or a sound) */
|
|
@@ -107,21 +107,21 @@ export interface ItemsInput extends Pick<ProjectInput, 'thread' | 'answers' | 's
|
|
|
107
107
|
|
|
108
108
|
export interface ProjectedItems {
|
|
109
109
|
items: ReviewItem[]
|
|
110
|
-
/** the head of the thread, as the
|
|
110
|
+
/** the head of the thread, as the view names it */
|
|
111
111
|
head: string
|
|
112
112
|
/** the entries that went out with strings masked */
|
|
113
113
|
masked: Masked[]
|
|
114
|
-
/** each id of the
|
|
114
|
+
/** each id of the view and the store's id it stands for: an advice names the view's */
|
|
115
115
|
ids: Map<string, string>
|
|
116
|
-
/** the thread's
|
|
117
|
-
* never
|
|
116
|
+
/** the thread's name as the owner's hub says it (review/threads.ts threadTitle), its hits masked: one name on both
|
|
117
|
+
* sides, never a version's own caption */
|
|
118
118
|
title: string
|
|
119
|
-
/** each version of the
|
|
119
|
+
/** each version of the view by its id and the thread's own number of it: v3 reads « v3 » whatever the view holds before it */
|
|
120
120
|
numbers: Map<string, number>
|
|
121
|
-
/** the thread's versions, and how many of them the
|
|
121
|
+
/** the thread's versions, and how many of them the view shows */
|
|
122
122
|
versions: number
|
|
123
123
|
shown: number
|
|
124
|
-
/** whether the thread's newest version is in the
|
|
124
|
+
/** whether the thread's newest version is in the view: when not, the view's head is an older one */
|
|
125
125
|
headKept: boolean
|
|
126
126
|
}
|
|
127
127
|
|
|
@@ -163,7 +163,7 @@ export function projectItems(input: ItemsInput): ProjectedItems {
|
|
|
163
163
|
const numbers = new Map<string, number>()
|
|
164
164
|
const kept = new Set<string>()
|
|
165
165
|
const items: ReviewItem[] = []
|
|
166
|
-
/** the nearest version this one follows that the
|
|
166
|
+
/** the nearest version this one follows that the view keeps */
|
|
167
167
|
const keptAncestor = (id: string | undefined): string | undefined => {
|
|
168
168
|
for (let at = id; at !== undefined; at = byId.get(at)?.item.supersedes) if (kept.has(at)) return opaqueItem(share, at)
|
|
169
169
|
return undefined
|
|
@@ -217,7 +217,7 @@ export function projectItems(input: ItemsInput): ProjectedItems {
|
|
|
217
217
|
const headKept = kept.has(headId)
|
|
218
218
|
const head = headKept ? opaqueItem(share, headId) : (items.at(-1)?.item.id ?? opaqueItem(share, headId))
|
|
219
219
|
const own = threadTitle(input.thread)
|
|
220
|
-
const title =
|
|
220
|
+
const title = mask(own, maskHits(own, input.scan))
|
|
221
221
|
const shown = input.thread.versions.filter((x) => kept.has(x.item.id)).length
|
|
222
222
|
return { items, head, masked, ids, title, numbers, versions: input.thread.versions.length, shown, headKept }
|
|
223
223
|
}
|
|
@@ -239,7 +239,7 @@ function projectItemMessages(x: ReviewItem, input: ItemsInput, masked: Masked[],
|
|
|
239
239
|
left.add(m.id)
|
|
240
240
|
out.push(built)
|
|
241
241
|
}
|
|
242
|
-
// the person's own words in the store: their
|
|
242
|
+
// the person's own words in the store: their view draws them from their advice (sync.ts), and a read of them is theirs
|
|
243
243
|
const own = new Set(x.thread.filter((m) => m.who === 'player' && input.advisor !== undefined && m.advisor?.id === input.advisor).map((m) => m.id))
|
|
244
244
|
for (const m of x.thread) {
|
|
245
245
|
const act = agentAct(m, input, left, own, (id) => (own.has(id) ? opaqueMessage(share, id) : mid(id)), masked, of)
|
|
@@ -247,8 +247,8 @@ function projectItemMessages(x: ReviewItem, input: ItemsInput, masked: Masked[],
|
|
|
247
247
|
if (act !== null) push(m, act)
|
|
248
248
|
continue
|
|
249
249
|
}
|
|
250
|
-
// a player's report is a stranger's words: never under
|
|
251
|
-
// their own pick is the question's answer, their own verdict the version's: it leaves, so their
|
|
250
|
+
// a player's report is a stranger's words: never under the owner's name on the advisors page, and never shared on
|
|
251
|
+
// their own pick is the question's answer, their own verdict the version's: it leaves, so their view draws it
|
|
252
252
|
const ownPick = own.has(m.id) && m.answer !== undefined
|
|
253
253
|
const ownVerdict = own.has(m.id) && m.verdict !== undefined && VERDICTS.has(m.verdict)
|
|
254
254
|
if (!passes(m) || (m.who === 'player' && !ownPick && !ownVerdict)) continue
|
|
@@ -259,6 +259,7 @@ function projectItemMessages(x: ReviewItem, input: ItemsInput, masked: Masked[],
|
|
|
259
259
|
if (labels === undefined || replaced.has(m.id)) continue
|
|
260
260
|
const fields: Record<string, string | undefined> = { text: m.text ?? '' }
|
|
261
261
|
labels.forEach((l, i) => (fields[`o${i}`] = l))
|
|
262
|
+
if (m.ask.row !== undefined) fields.row = m.ask.row.label
|
|
262
263
|
push(m, gate(m.id, fields, (f): Message => ({
|
|
263
264
|
...base,
|
|
264
265
|
...(m.op !== undefined ? { op: m.op } : {}),
|
|
@@ -267,6 +268,7 @@ function projectItemMessages(x: ReviewItem, input: ItemsInput, masked: Masked[],
|
|
|
267
268
|
options: labels.map((_, i) => f[`o${i}`] ?? ''),
|
|
268
269
|
...(m.ask!.pick !== undefined ? { pick: m.ask!.pick } : {}),
|
|
269
270
|
...(m.ask!.views !== undefined ? { views: m.ask!.views.map((v) => (v === null ? null : (viewMap.get(v) ?? null))) } : {}),
|
|
271
|
+
...(m.ask!.row !== undefined ? { row: { ...m.ask!.row, label: f.row ?? '' } } : {}),
|
|
270
272
|
},
|
|
271
273
|
...(m.asksVerdict === true ? { asksVerdict: true as const } : {}),
|
|
272
274
|
}), { input, masked, where: 'message', of }))
|
|
@@ -332,7 +334,7 @@ function projectItemMessages(x: ReviewItem, input: ItemsInput, masked: Masked[],
|
|
|
332
334
|
|
|
333
335
|
/** an agent's act the hub draws as a trace line between the words (review/traces.ts): a read of words that left or of
|
|
334
336
|
* the person's own, its « on it » line masked like any agent word, a take with nothing of its own. `undefined`: not
|
|
335
|
-
* such an act; `null`: one that leaves nothing (no other answers shown, a read of nothing the
|
|
337
|
+
* such an act; `null`: one that leaves nothing (no other answers shown, a read of nothing the view holds) */
|
|
336
338
|
function agentAct(m: Message, input: ItemsInput, left: ReadonlySet<string>, own: ReadonlySet<string>, idOf: (id: string) => string, masked: Masked[], of: { n?: number; title: string }): Message | null | undefined {
|
|
337
339
|
if (partyOf(m.who) !== 'agent' || (m.op !== 'seen' && m.op !== 'working' && m.op !== 'take')) return undefined
|
|
338
340
|
if (!input.answers) return null
|
|
@@ -343,7 +345,7 @@ function agentAct(m: Message, input: ItemsInput, left: ReadonlySet<string>, own:
|
|
|
343
345
|
return read.length === 0 ? null : { ...base, op: 'seen', of: read.map(idOf) }
|
|
344
346
|
}
|
|
345
347
|
|
|
346
|
-
/** every picture of the thread the
|
|
348
|
+
/** every picture of the thread the view may name, where it is: each view's image, pair or gallery tile, each message's
|
|
347
349
|
* picture; clips and sounds never */
|
|
348
350
|
export function picturesOf(thread: Thread): { itemId: string; name: string; of: 'view' | 'message' }[] {
|
|
349
351
|
const out: { itemId: string; name: string; of: 'view' | 'message' }[] = []
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
// the reach of the advisors page as the owner's hub reads it (wiki tools/shipkit/advisors.md, Who calls: the
|
|
2
|
+
// users' port): its name, the name the house config gives it, and in one line whether advisors reach this Mac now (set up,
|
|
3
|
+
// this Mac carries the hq, the tunnel's token stored, the users' port answers). Never a value of a secret: its presence only
|
|
4
|
+
import { hostname } from 'node:os'
|
|
5
|
+
import { heldHere } from '../secrets/read.ts'
|
|
6
|
+
import { ownAddressOf } from '../review/model.ts'
|
|
7
|
+
import { readAll, storeDir } from '../review/store.ts'
|
|
8
|
+
import { threadsOf } from '../review/threads.ts'
|
|
9
|
+
import { houseHost } from './speaks.ts'
|
|
10
|
+
import { usersPort } from './users-store.ts'
|
|
11
|
+
import type { SetupRun } from './owner-store.ts'
|
|
12
|
+
|
|
13
|
+
// sk-disable-next-line RV045 -- the tunnel's runner reads the house's own tunnel token by this name
|
|
14
|
+
export const TUNNEL_TOKEN = 'rv/cloudflare/advisors-tunnel'
|
|
15
|
+
|
|
16
|
+
export interface ReachFacts {
|
|
17
|
+
/** the advisors page's name once the owner's setup ran, null before */
|
|
18
|
+
host: string | null
|
|
19
|
+
/** the name it opens at: the house config's `serve.advisorsHost`, else the one set up */
|
|
20
|
+
want: string | null
|
|
21
|
+
/** advisors reach this Mac now */
|
|
22
|
+
ok: boolean
|
|
23
|
+
/** the reach in one line: « advisors reach <mac> at <host> », or what is wrong */
|
|
24
|
+
words: string
|
|
25
|
+
/** the ask that opens the advisors page, its thread in the house */
|
|
26
|
+
ask: { repo: string; head: string; address: string } | null
|
|
27
|
+
/** what his terminal runs to set it up */
|
|
28
|
+
command: string | null
|
|
29
|
+
/** the setup the daemon runs by itself once his token landed (setup-run.ts): while it runs, after it failed, or for
|
|
30
|
+
* an hour after it ended */
|
|
31
|
+
run?: SetupRun | null
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const RUN_SHOWN_MS = 3_600_000
|
|
35
|
+
/** the setup run the foot shows, null once it ended well over an hour ago */
|
|
36
|
+
export const shownRun = (r: SetupRun | undefined, now: Date): SetupRun | null =>
|
|
37
|
+
r === undefined || (r.state === 'done' && now.getTime() - Date.parse(r.ended ?? r.at) > RUN_SHOWN_MS) || (r.state === 'done' && r.lines.length === 0) ? null : r
|
|
38
|
+
|
|
39
|
+
/** the ask's address: `ask:<n>-open-the-advisors-door` */
|
|
40
|
+
export const SETUP_ASK = /^ask:\d+-open-the-advisors-door$/
|
|
41
|
+
|
|
42
|
+
const HOST_RE = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)+$/
|
|
43
|
+
|
|
44
|
+
export const exposeCommand = (host: string): string | null => (HOST_RE.test(host) ? `sk advisors expose --host ${host}` : null)
|
|
45
|
+
|
|
46
|
+
/** what the line reads; each the real one by default, a test passes its own */
|
|
47
|
+
export interface ReachLooks {
|
|
48
|
+
carries?: () => boolean
|
|
49
|
+
tunnel?: () => Promise<'stored' | 'missing' | 'unknown'>
|
|
50
|
+
serves?: (host: string) => Promise<boolean>
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** the users' port answers its own name on this Mac */
|
|
54
|
+
async function serves(host: string): Promise<boolean> {
|
|
55
|
+
try {
|
|
56
|
+
const r = await fetch(`http://127.0.0.1:${usersPort()}/health`, { headers: { host }, signal: AbortSignal.timeout(500) })
|
|
57
|
+
return r.ok
|
|
58
|
+
} catch {
|
|
59
|
+
return false
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** the reach in one line, worst first */
|
|
64
|
+
export async function reachLine(host: string | null, house: string, l: ReachLooks = {}): Promise<{ ok: boolean; words: string }> {
|
|
65
|
+
// the page names the ask, never a command: the ask's steps hold the one run in his terminal
|
|
66
|
+
if (host === null) return { ok: false, words: 'not set up yet: the ask that opens the advisors page' }
|
|
67
|
+
const carries = l.carries ?? (await import('../hq/hq-role.ts')).carriesHq
|
|
68
|
+
if (!carries()) return { ok: false, words: `the advisors page runs on the Mac that carries the hq, not this one` }
|
|
69
|
+
const tunnel = await (l.tunnel ?? (async () => (await heldHere({ names: [TUNNEL_TOKEN], cwd: house }))[TUNNEL_TOKEN]?.held ?? 'unknown'))().catch(() => 'unknown' as const)
|
|
70
|
+
if (tunnel === 'missing') return { ok: false, words: "the tunnel's token is not stored: the ask that opens the advisors page" }
|
|
71
|
+
if (!(await (l.serves ?? serves)(host))) return { ok: false, words: "the advisors page's server does not answer on this Mac: the daemon starts it" }
|
|
72
|
+
return { ok: true, words: `advisors reach ${hostname().replace(/\.local$/, '')} at ${host}` }
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export async function reachFacts(o: { house: string; houseRepo: string | null; host: string | null; looks?: ReachLooks }): Promise<ReachFacts> {
|
|
76
|
+
// the house config's name, else the name set up, or none
|
|
77
|
+
const want = (await houseHost(o.house)) ?? o.host
|
|
78
|
+
let ask: ReachFacts['ask'] = null
|
|
79
|
+
try {
|
|
80
|
+
for (const t of threadsOf(readAll(storeDir(o.house)).items)) {
|
|
81
|
+
const address = ownAddressOf(t.head.item)
|
|
82
|
+
if (address !== null && SETUP_ASK.test(address)) ask = { repo: o.houseRepo ?? '', head: t.head.item.id, address }
|
|
83
|
+
}
|
|
84
|
+
} catch {
|
|
85
|
+
// the house store does not read now: no link, the words still say what is missing
|
|
86
|
+
}
|
|
87
|
+
const command = want === null ? null : exposeCommand(want)
|
|
88
|
+
return { host: o.host, want, ...(await reachLine(o.host, o.house, o.looks)), ask, command }
|
|
89
|
+
}
|
package/src/advisors/rights.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// what a person may do, resolved over layers (wiki tools/shipkit/advisors.md,
|
|
1
|
+
// what a person may do, resolved over layers (wiki tools/shipkit/advisors.md, The model: people, grants, rights): the house's defaults, then his
|
|
2
2
|
// default for a project, his default for the person, the person on a project, the person on one thread; the most
|
|
3
3
|
// specific layer that sets a right wins. Only the owner writes a layer (acts.ts setRights)
|
|
4
4
|
// the one constraint a reader breaks first: an unset right falls through to the layer below, never to « allowed »; the
|