rvlib-shipkit 2.31.0 → 2.32.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 +31 -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 +98 -73
- 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 +26 -198
- 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 +25 -23
- 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 +92 -182
- package/src/advisors/tunnel.ts +6 -5
- package/src/advisors/users-listen.ts +92 -0
- package/src/advisors/users-router.ts +257 -85
- 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_Checks.ts +0 -14
- 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_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 +2 -2
- package/src/collections/collection-types.ts +1 -1
- package/src/collections/review.ts +5 -4
- 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/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/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/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/discover-checks.ts +42 -32
- package/src/gate/gate-checks.ts +21 -131
- package/src/gate/pre-commit-discovery.ts +16 -25
- package/src/gate/run-check.ts +0 -4
- 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 +4 -11
- package/src/home/space-page.ts +3 -2
- package/src/home/supervise.ts +3 -7
- package/src/hooks/hook-config.ts +6 -7
- package/src/hooks/leak-guard.ts +1 -1
- package/src/hooks/run-hooks.ts +0 -5
- 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/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 +29 -64
- package/src/review/answer-kinds.ts +61 -4
- package/src/review/blocked-guard.ts +11 -0
- package/src/review/blocked-object.ts +298 -0
- package/src/review/cells.ts +116 -229
- 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 +49 -19
- 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.ts +86 -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 +798 -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/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/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 +181 -54
- 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 +2 -2
- package/src/serve/hub-app/review/review-kit.ts +17 -11
- package/src/serve/hub-app/review/review-list.tsx +23 -31
- package/src/serve/hub-app/review/review-st.ts +30 -40
- package/src/serve/hub-app/review/review-thread.tsx +139 -85
- package/src/serve/hub-app/review/review-views.tsx +124 -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 +372 -201
- package/src/serve/hub-app/review/tone-bar.tsx +126 -0
- package/src/serve/hub-app/review/tones.ts +35 -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 +180 -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/film-box.ts +0 -20
- 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
package/src/advisors/routes.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
// the hub's advisors api on the daemon (wiki tools/shipkit/advisors.md, What he does): the page's state, a thread's
|
|
2
|
-
// bar, each of
|
|
3
|
-
// projection, every image shown, the
|
|
2
|
+
// bar, each of the owner's acts followed by one owner's pass, and the owner's preview: the advisor's own page drawn
|
|
3
|
+
// from the same projection, every image shown, the masked entries listed. The owner's routes, behind the hub's own gate
|
|
4
4
|
import { randomBytes } from 'node:crypto'
|
|
5
|
-
import { existsSync, readFileSync } from 'node:fs'
|
|
6
5
|
import { readAll, storeDir } from '../review/store.ts'
|
|
7
|
-
import {
|
|
6
|
+
import { membersOf, threadOfAddress, threadOfItem, threadsOf, type Thread } from '../review/threads.ts'
|
|
8
7
|
import { ownAddressOf } from '../review/model.ts'
|
|
9
8
|
import { REFUSED_KINDS, addAdvisor, sendPhoto, confirmPending, deferredTo, endAccess, giveAccess, include, removeAdvisor, renew, revokeAdvisor, revokeAll, setOwner, setRights, share, shareFromHead, unshare } from './acts.ts'
|
|
10
9
|
import { HOUSE_RIGHTS, rightsOf } from './rights.ts'
|
|
@@ -17,22 +16,25 @@ import { openAsks } from '../asks/ask-store.ts'
|
|
|
17
16
|
import { acceptProposal, confirmWithFiles, declineProposal, foldedPending, overrideAdvice, staleWhy } from './advice.ts'
|
|
18
17
|
import type { Bucket } from './edge/bucket.ts'
|
|
19
18
|
import { KEYS } from './edge/types.ts'
|
|
20
|
-
import {
|
|
19
|
+
import { reachFacts, shownRun, type ReachFacts, type ReachLooks } from './reach.ts'
|
|
20
|
+
import { identityOfRoot } from './speaks.ts'
|
|
21
21
|
import { ensureLogin, renewLogin } from './login.ts'
|
|
22
22
|
import { ownerNameOf, setOwnerName } from './owner-name.ts'
|
|
23
|
-
import { copyApi } from './edge/api.ts'
|
|
24
23
|
import { MemoryBucket } from './edge/bucket.ts'
|
|
25
24
|
import { APP_CSP, appShell } from './edge/shell.ts'
|
|
26
25
|
import { pageResponse } from './edge/status.ts'
|
|
27
26
|
import { advisorBundle, type AppBundle } from './app.ts'
|
|
28
|
-
import { advisorsPass,
|
|
27
|
+
import { advisorsPass, setupAsked, usersBucket } from './job.ts'
|
|
29
28
|
import { hereOf, type HereRow } from './here.ts'
|
|
30
29
|
import { setupRunning } from './setup-run.ts'
|
|
31
30
|
import type { TunnelStart } from './tunnel.ts'
|
|
32
|
-
import { advisorsDir,
|
|
31
|
+
import { advisorsDir, isLive, readState, withState, type Access, type OwnerState, type PendingFile, type Share } from './owner-store.ts'
|
|
33
32
|
import type { HitKind } from './scan.ts'
|
|
34
33
|
import { prepare, privateWords, sharpWebp } from './sync.ts'
|
|
34
|
+
import { liveAnswer, type Caller } from './users-router.ts'
|
|
35
|
+
import { usersDir } from './users-store.ts'
|
|
35
36
|
import { photoBytes, pictureType, PHOTO_FILE_MAX, removePhoto, setPhoto } from './photos.ts'
|
|
37
|
+
import { threadState } from '../review/thread-state.ts'
|
|
36
38
|
|
|
37
39
|
export interface AdvisorsDeps {
|
|
38
40
|
house: string
|
|
@@ -41,26 +43,24 @@ export interface AdvisorsDeps {
|
|
|
41
43
|
now?: () => Date
|
|
42
44
|
/** the pass after an act; tests run it inline */
|
|
43
45
|
pass?: () => Promise<unknown>
|
|
44
|
-
/** what the
|
|
45
|
-
looks?:
|
|
46
|
-
/** the
|
|
46
|
+
/** what the advisors page's line reads (reach.ts reachLine); tests fix it */
|
|
47
|
+
looks?: ReachLooks
|
|
48
|
+
/** the users' port's folder, where what they sent waits; tests pass one in memory */
|
|
47
49
|
bucket?: () => Promise<Bucket | null>
|
|
48
|
-
/** the advisors' page
|
|
50
|
+
/** the advisors' page the owner's preview frames; tests pass a small one */
|
|
49
51
|
app?: () => Promise<AppBundle>
|
|
50
52
|
/** the invite's Brevo key, its presence, the send; tests pass a stand in fetch and key */
|
|
51
53
|
mail?: InviteMailer
|
|
52
|
-
/** cloudflared for the
|
|
54
|
+
/** cloudflared for the advisors page's setup, from the surface that reaches pm (home/advisors-tunnel-start.ts) */
|
|
53
55
|
tunnel?: TunnelStart
|
|
54
|
-
/**
|
|
56
|
+
/** the owner's « set the advisors page up now »; tests pass a stand in */
|
|
55
57
|
setup?: (tunnel: TunnelStart | undefined) => ReturnType<typeof setupAsked>
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
/** the
|
|
59
|
-
const
|
|
60
|
+
/** the advisors page's reach read at most every 30 s: a presence check of the vault is no read for a 15 s poll */
|
|
61
|
+
const REACH_MS = 30_000
|
|
60
62
|
|
|
61
63
|
const NO_STORE = { 'cache-control': 'no-store' }
|
|
62
|
-
/** his preview's copy of a share is built again after this long */
|
|
63
|
-
const PREVIEW_MS = 5_000
|
|
64
64
|
/** how long a preview's ticket opens it: the frame is answered for a page of his hub that minted one, never for a share id */
|
|
65
65
|
const TICKET_MS = 30 * 60_000
|
|
66
66
|
const bad = (why: string, status = 400): Response => Response.json({ error: why }, { status, headers: NO_STORE })
|
|
@@ -87,11 +87,11 @@ export interface ShareRow {
|
|
|
87
87
|
/** the thread's versions as the last pass counted them, and how many the person sees; null before the first */
|
|
88
88
|
parts: { versions: number; shown: number } | null
|
|
89
89
|
reach: NonNullable<Share['reach']> | null
|
|
90
|
-
/** its thread is closed (settled, fixed, dropped, withdrawn: review/
|
|
90
|
+
/** its thread is closed (settled, fixed, dropped, withdrawn: review/thread-state.ts ThreadState closed); absent from a daemon
|
|
91
91
|
* older than the counts */
|
|
92
92
|
closed?: boolean
|
|
93
|
-
/** a live share
|
|
94
|
-
* messenger, its code while unused (advisors/invite.ts), what
|
|
93
|
+
/** a live share on a set up advisors page: the page's address of the thread, and the invite in two lines for any
|
|
94
|
+
* messenger, its code while unused (advisors/invite.ts), what the owner's copy buttons put on the clipboard; null otherwise */
|
|
95
95
|
copy?: { link: string; text: string } | null
|
|
96
96
|
}
|
|
97
97
|
|
|
@@ -133,7 +133,7 @@ export interface KnownRow {
|
|
|
133
133
|
}
|
|
134
134
|
|
|
135
135
|
/** a person's invite: `due` when a share sends it (never sent, or over a week ago), `sent` when the last one went,
|
|
136
|
-
* `failed` the last try that did not go, `text` its words for this thread (null with no
|
|
136
|
+
* `failed` the last try that did not go, `text` its words for this thread (null with no advisors page), for « copy invite » */
|
|
137
137
|
export interface InviteRow {
|
|
138
138
|
due: boolean
|
|
139
139
|
sent: string | null
|
|
@@ -155,7 +155,7 @@ export interface ThreadPerson {
|
|
|
155
155
|
share: string
|
|
156
156
|
state: Share['state']
|
|
157
157
|
expires: string
|
|
158
|
-
/** their read cursor as the
|
|
158
|
+
/** their read cursor as the last pass pulled it: when, and whether it covers the owner's newest word */
|
|
159
159
|
read: { at: string; seen: boolean } | null
|
|
160
160
|
}
|
|
161
161
|
|
|
@@ -187,7 +187,7 @@ const photoOf = (s: OwnerState, advisor: string): string | null => s.advisors.fi
|
|
|
187
187
|
|
|
188
188
|
const accessRow = (s: OwnerState, x: Access, now: Date): AccessRow => ({ id: x.id, advisor: x.advisor, name: s.advisors.find((a) => a.id === x.advisor)?.name ?? '?', repo: x.repo, expires: x.expires, live: isLive(x, now) })
|
|
189
189
|
|
|
190
|
-
/** each share's thread by its store and address, read once per answer: a share's link names its
|
|
190
|
+
/** each share's thread by its store and address, read once per answer: a share's link names its view's head, its row
|
|
191
191
|
* says whether the thread is closed */
|
|
192
192
|
type Heads = (x: Pick<Share, 'root' | 'address'>) => Thread | null
|
|
193
193
|
function headsOf(): Heads {
|
|
@@ -209,7 +209,7 @@ function headsOf(): Heads {
|
|
|
209
209
|
/** each project's identity, by repo name: his name for advisors per project (owner-name.ts) */
|
|
210
210
|
type Speaks = ReadonlyMap<string, string | null>
|
|
211
211
|
|
|
212
|
-
/** the invite of a live share
|
|
212
|
+
/** the invite of a live share on a set up advisors page: its link opens the person's view on this thread */
|
|
213
213
|
function copyOf(s: OwnerState, x: Share, now: Date, heads: Heads, words: readonly string[], speaks: Speaks): ShareRow['copy'] {
|
|
214
214
|
if (s.host === null || !isLive(x, now)) return null
|
|
215
215
|
const a = s.advisors.find((y) => y.id === x.advisor)
|
|
@@ -237,7 +237,7 @@ function shareRow(s: OwnerState, x: Share, now: Date, heads: Heads = headsOf(),
|
|
|
237
237
|
masked: (x.masked ?? []).map((h) => ({ key: h.key, kinds: h.kinds, where: h.where, n: h.n ?? null, title: h.title ?? null })),
|
|
238
238
|
parts: x.parts ?? null,
|
|
239
239
|
reach: x.reach ?? null,
|
|
240
|
-
closed: t !== null &&
|
|
240
|
+
closed: t !== null && (threadState(t).closed !== null),
|
|
241
241
|
copy: copyOf(s, x, now, heads, words, speaks),
|
|
242
242
|
}
|
|
243
243
|
}
|
|
@@ -308,13 +308,13 @@ export function advisorsRoutes(d: AdvisorsDeps) {
|
|
|
308
308
|
const dir = (): string => d.dir ?? advisorsDir()
|
|
309
309
|
const now = (): Date => d.now?.() ?? new Date()
|
|
310
310
|
const words = (): string[] => privateWords(d.house)
|
|
311
|
-
let
|
|
312
|
-
const doorNow = async (host: string | null): Promise<
|
|
311
|
+
let reach: { at: number; host: string | null; facts: ReachFacts } | null = null
|
|
312
|
+
const doorNow = async (host: string | null): Promise<ReachFacts> => {
|
|
313
313
|
const t = Date.now()
|
|
314
|
-
if (
|
|
314
|
+
if (reach !== null && reach.host === host && t - reach.at < REACH_MS) return reach.facts
|
|
315
315
|
const houseRepo = d.repos.find((r) => r.path === d.house)?.name ?? null
|
|
316
|
-
const facts = await
|
|
317
|
-
|
|
316
|
+
const facts = await reachFacts({ house: d.house, houseRepo, host, ...(d.looks !== undefined ? { looks: d.looks } : {}) })
|
|
317
|
+
reach = { at: t, host, facts }
|
|
318
318
|
return facts
|
|
319
319
|
}
|
|
320
320
|
/** a person's sign in, minted as his act makes a grant of theirs live: the copy buttons carry its code at once */
|
|
@@ -333,7 +333,7 @@ export function advisorsRoutes(d: AdvisorsDeps) {
|
|
|
333
333
|
const x = s.shares.find((y) => y.id === id)
|
|
334
334
|
if (x === undefined) throw new Error(`no share ${id}`)
|
|
335
335
|
if (isLive(x, now())) {
|
|
336
|
-
const p = await prepare(s, x, { words: words(),
|
|
336
|
+
const p = await prepare(s, x, { words: words(), now: now() })
|
|
337
337
|
if (p !== null)
|
|
338
338
|
withState(dir(), (st) => {
|
|
339
339
|
const y = st.shares.find((z) => z.id === id)!
|
|
@@ -347,7 +347,7 @@ export function advisorsRoutes(d: AdvisorsDeps) {
|
|
|
347
347
|
return shareRow(st, st.shares.find((y) => y.id === id)!, now(), headsOf(), words(), await speaksNow())
|
|
348
348
|
}
|
|
349
349
|
const mailer: InviteMailer = { ...houseMailer(d.house), ...d.mail }
|
|
350
|
-
/** each project's identity: read once per process (
|
|
350
|
+
/** each project's identity: read once per process (speaks.ts identityOfRoot) */
|
|
351
351
|
const speaksNow = async (): Promise<Speaks> => new Map(await Promise.all(d.repos.map(async (r) => [r.name, await identityOfRoot(r.path)] as const)))
|
|
352
352
|
/** the invite of a share he just made live, when one is due: a failure is its words, never a failed share */
|
|
353
353
|
const inviteOnShare = (id: string, n: Date): Promise<InviteSent | null> =>
|
|
@@ -355,7 +355,7 @@ export function advisorsRoutes(d: AdvisorsDeps) {
|
|
|
355
355
|
let mail: { at: number; facts: MailFacts } | null = null
|
|
356
356
|
const mailNow = async (): Promise<MailFacts> => {
|
|
357
357
|
const t = Date.now()
|
|
358
|
-
if (mail !== null && t - mail.at <
|
|
358
|
+
if (mail !== null && t - mail.at < REACH_MS) return mail.facts
|
|
359
359
|
const key = await (mailer.held ?? (async () => 'unknown' as const))().catch(() => 'unknown' as const)
|
|
360
360
|
let ask: MailFacts['ask'] = null
|
|
361
361
|
const houseRepo = d.repos.find((r) => r.path === d.house)?.name ?? null
|
|
@@ -401,31 +401,12 @@ export function advisorsRoutes(d: AdvisorsDeps) {
|
|
|
401
401
|
if (confirmed.length === 0) throw new Error(failed.join('; '))
|
|
402
402
|
return { confirmed, failed, invite }
|
|
403
403
|
}
|
|
404
|
-
/** his
|
|
405
|
-
*
|
|
406
|
-
*
|
|
407
|
-
const
|
|
408
|
-
const previewCopy = (id: string): Promise<{ bucket: MemoryBucket; owner: string } | null> => {
|
|
409
|
-
const held = previews.get(id)
|
|
410
|
-
if (held !== undefined && Date.now() - held.at < PREVIEW_MS) return held.bucket
|
|
411
|
-
const bucket = (async () => {
|
|
412
|
-
const s = readState(dir())
|
|
413
|
-
const x = s.shares.find((y) => y.id === id)
|
|
414
|
-
if (x === undefined) return null
|
|
415
|
-
const p = await prepare(s, x, { words: words(), encode: sharpWebp, now: now(), preview: true })
|
|
416
|
-
if (p === null || p.copy === null || p.manifest === null) return null
|
|
417
|
-
const b = new MemoryBucket()
|
|
418
|
-
await b.put(KEYS.view(id), JSON.stringify(p.copy.view), 'application/json')
|
|
419
|
-
await b.put(KEYS.row(id), JSON.stringify(p.copy.row), 'application/json')
|
|
420
|
-
await b.put(KEYS.files(id), JSON.stringify(p.manifest), 'application/json')
|
|
421
|
-
for (const f of p.all) if (p.manifest.images.includes(f.sha) && existsSync(f.path)) await b.put(KEYS.media(f.sha), new Uint8Array(readFileSync(f.path)))
|
|
422
|
-
return { bucket: b, owner: p.owner }
|
|
423
|
-
})()
|
|
424
|
-
previews.set(id, { at: Date.now(), bucket })
|
|
425
|
-
return bucket
|
|
426
|
-
}
|
|
404
|
+
/** his « view as <name> »: the advisors' app itself, framed with no origin of its own, every read answered as that
|
|
405
|
+
* person's own on the users' port (users-router.ts liveAnswer: the same builders, whitelist and mask), on this one
|
|
406
|
+
* share; it takes no answer */
|
|
407
|
+
const asThem = (x: Share, email: string): Caller => ({ kind: 'user', email, login: '', shares: [x], places: [] })
|
|
427
408
|
// the frame has no origin of its own, so any site's frame looks the same to the hub: the preview answers a ticket his
|
|
428
|
-
// page minted by a same origin POST, never a share id (which the advisor reads in every id of their
|
|
409
|
+
// page minted by a same origin POST, never a share id (which the advisor reads in every id of their view)
|
|
429
410
|
const tickets = new Map<string, { share: string; until: number }>()
|
|
430
411
|
const open = (x: Share | undefined, n: Date): x is Share => x !== undefined && (x.state === 'pending' || isLive(x, n))
|
|
431
412
|
const mintTicket = (id: string, n: Date): { path: string } | null => {
|
|
@@ -468,14 +449,15 @@ export function advisorsRoutes(d: AdvisorsDeps) {
|
|
|
468
449
|
if (file.sha !== f[1]) return bad('no such file of the page', 404)
|
|
469
450
|
return new Response(file.bytes, { headers: { ...headers, 'content-type': f[2] === 'js' ? 'text/javascript; charset=utf-8' : 'text/css; charset=utf-8' } })
|
|
470
451
|
}
|
|
471
|
-
|
|
472
|
-
if (
|
|
473
|
-
|
|
474
|
-
const
|
|
475
|
-
|
|
452
|
+
if (req.method !== 'GET' && req.method !== 'HEAD') return bad('the preview takes no answer: this is what the advisor sees', 403)
|
|
453
|
+
if (!sub.startsWith('/api/review/') || who === undefined) return bad('no such route', 404)
|
|
454
|
+
// no cursor of theirs, no session, no key: what they read, never what they did
|
|
455
|
+
const env = { bucket: new MemoryBucket(), host: null, dir: dir(), words, encode: sharpWebp, now: () => now().getTime(), ...(d.app ? { app: d.app } : {}) }
|
|
456
|
+
const r = await liveAnswer(new Request(new URL(sub + new URL(req.url).search, 'https://view-as.invalid'), { method: req.method }), asThem(x, who.email), env)
|
|
457
|
+
return new Response(r.body, { status: r.status, headers: { ...Object.fromEntries(r.headers), ...headers } })
|
|
476
458
|
}
|
|
477
459
|
const rootOf = (repo: string): string | null => d.repos.find((r) => r.name === repo)?.path ?? null
|
|
478
|
-
const bucket = (): Promise<Bucket | null> => (d.bucket ?? (async () =>
|
|
460
|
+
const bucket = (): Promise<Bucket | null> => (d.bucket ?? (async () => usersBucket(dir())))()
|
|
479
461
|
|
|
480
462
|
return async (req: Request, path: string): Promise<Response | null> => {
|
|
481
463
|
if (!path.startsWith('/api/home/advisors')) return null
|
|
@@ -502,7 +484,7 @@ export function advisorsRoutes(d: AdvisorsDeps) {
|
|
|
502
484
|
advice: adviceRows(s, () => true),
|
|
503
485
|
proposals: proposalRows(s),
|
|
504
486
|
repos: d.repos.map((r) => r.name),
|
|
505
|
-
|
|
487
|
+
reach: { ...facts, run: shownRun(s.setupRun, n) },
|
|
506
488
|
})
|
|
507
489
|
}
|
|
508
490
|
if (req.method === 'GET' && rest === '/thread') {
|
|
@@ -525,7 +507,7 @@ export function advisorsRoutes(d: AdvisorsDeps) {
|
|
|
525
507
|
const host = facts.want ?? s.host
|
|
526
508
|
const title = t?.head.item.title ?? ''
|
|
527
509
|
const w = words()
|
|
528
|
-
// this thread's head is known: the share's link names its
|
|
510
|
+
// this thread's head is known: the share's link names its view's head without another read
|
|
529
511
|
const heads: Heads = (x) => (t !== null && x.address === address ? t : null)
|
|
530
512
|
// every person, his and the ones an agent prepared: a profile grants nothing, his pick shares
|
|
531
513
|
const speaks = await speaksNow()
|
|
@@ -545,14 +527,14 @@ export function advisorsRoutes(d: AdvisorsDeps) {
|
|
|
545
527
|
here,
|
|
546
528
|
known,
|
|
547
529
|
people,
|
|
548
|
-
|
|
530
|
+
setUp: s.host !== null,
|
|
549
531
|
// whether a share mails the invite by itself: the Brevo key's presence, and its ask while missing
|
|
550
532
|
mail: await mailNow(),
|
|
551
533
|
shares: s.shares.filter((x) => mine(x) && (x.state === 'pending' || isLive(x, n))).map((x) => shareRow(s, x, n, heads, w, speaks)),
|
|
552
534
|
advice: adviceRows(s, mine),
|
|
553
535
|
// the thread's shares as lines of its timeline, every share it ever had (advisors/share-trace.ts)
|
|
554
536
|
trace: shareEvents(s, mine, 'you', n),
|
|
555
|
-
|
|
537
|
+
reach: { ...facts, run: shownRun(s.setupRun, n) },
|
|
556
538
|
deferredTo: t === null ? null : (deferredTo(s, { repo, address, thread: t }, n)?.name ?? null),
|
|
557
539
|
})
|
|
558
540
|
}
|
|
@@ -587,12 +569,12 @@ export function advisorsRoutes(d: AdvisorsDeps) {
|
|
|
587
569
|
return ok(s.advisors.map((a) => ({ id: a.id, name: a.name, photo: photoOf(s, a.id) })))
|
|
588
570
|
}
|
|
589
571
|
if (req.method === 'GET' && rest === '/here') {
|
|
590
|
-
// where each person is
|
|
572
|
+
// where each person is on the advisors page: the thread on now, or when they were last on each (advisors/here.ts)
|
|
591
573
|
const s = readState(dir())
|
|
592
574
|
const n = now()
|
|
593
575
|
const heads = headsOf()
|
|
594
576
|
const out: (Omit<HereRow, 'root' | 'share'> & { head: string; title: string })[] = []
|
|
595
|
-
for (const r of hereOf(s,
|
|
577
|
+
for (const r of hereOf(s, usersDir(dir()), n)) {
|
|
596
578
|
const t = heads(r)
|
|
597
579
|
if (t !== null) out.push({ advisor: r.advisor, repo: r.repo, address: r.address, on: r.on, at: r.at, head: t.head.item.id, title: t.head.item.title })
|
|
598
580
|
}
|
|
@@ -673,8 +655,7 @@ export function advisorsRoutes(d: AdvisorsDeps) {
|
|
|
673
655
|
out = accessRow(readState(dir()), giveAccess(dir(), { advisor: str(b, 'advisor'), repo: str(b, 'repo'), root, ...(typeof b['days'] === 'number' ? { days: b['days'] } : {}) }, 'owner', n), n)
|
|
674
656
|
} else if (acc !== null) out = endAccess(dir(), acc[1]!, n)
|
|
675
657
|
else if (rest === '/share') {
|
|
676
|
-
// from the thread's head: a known person, or a new one by `name` and `email
|
|
677
|
-
// picker is read and ignored, a share needs no other step
|
|
658
|
+
// from the thread's head: a known person, or a new one by `name` and `email`
|
|
678
659
|
const repo = str(b, 'repo')
|
|
679
660
|
const root = rootOf(repo)
|
|
680
661
|
if (root === null) return bad(`no repo ${repo}`)
|
|
@@ -707,8 +688,8 @@ export function advisorsRoutes(d: AdvisorsDeps) {
|
|
|
707
688
|
include(dir(), { share: id, key: str(b, 'key'), how }, 'owner')
|
|
708
689
|
out = await refreshOne(id)
|
|
709
690
|
}
|
|
710
|
-
} else if (rest === '/
|
|
711
|
-
//
|
|
691
|
+
} else if (rest === '/setup') {
|
|
692
|
+
// the owner's « set the advisors page up now »: one run at a time, its lines on the foot as they end, the minutes it
|
|
712
693
|
// takes never held by this answer
|
|
713
694
|
if (setupRunning(readState(dir()), n)) return bad("the advisors page's setup runs now: its lines show at the foot", 409)
|
|
714
695
|
const r = await (d.setup ?? ((t) => setupAsked(dir(), d.house, t)))(d.tunnel)
|
package/src/advisors/scan.ts
CHANGED
|
@@ -158,10 +158,6 @@ function merge(hits: Hit[]): Hit[] {
|
|
|
158
158
|
return out
|
|
159
159
|
}
|
|
160
160
|
|
|
161
|
-
/** the kinds masked in place in what a person reads of a thread the owner shared: a credential in a known format, a
|
|
162
|
-
* secret's name or ref, one of his private words. Every other kind goes as written: he shared the thread whole */
|
|
163
|
-
export const MASK_KINDS: readonly HitKind[] = ['key', 'secret name', 'private word']
|
|
164
|
-
|
|
165
161
|
/** a secret ref as a page writes it, `[[secret:<name>]]`: masked whole */
|
|
166
162
|
const SECRET_REF_RE = /\[\[secret:[A-Za-z0-9][A-Za-z0-9._@/-]*\]\]/g
|
|
167
163
|
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
// the
|
|
2
|
-
// tools/shipkit/advisors.md,
|
|
3
|
-
// mark (secrets/changed-mark.ts) move while the
|
|
1
|
+
// the advisors page's setup, by itself once the owner stored the setup token, or on the owner's « set the advisors page
|
|
2
|
+
// up now » (wiki tools/shipkit/advisors.md, Who calls: the users' port): the daemon of the machine that carries
|
|
3
|
+
// the hq sees the « a secret landed » mark (secrets/changed-mark.ts) move while the page is not on its tunnel, and runs the setup only when the setup
|
|
4
4
|
// token itself was written since the last look: another secret's write starts nothing. The run is the same
|
|
5
|
-
// `
|
|
5
|
+
// `exposeAdvisors` as `sk advisors expose`, then the check from outside, then each person with a live grant mailed their
|
|
6
6
|
// code. Each line lands on the advisors page's foot as it ends, and the end in the ask's thread. The one constraint a
|
|
7
|
-
// reader breaks first: a daemon an agent's shell started never reads the setup token; it says so where
|
|
8
|
-
import { AGENT_ENV } from '../
|
|
9
|
-
import {
|
|
7
|
+
// reader breaks first: a daemon an agent's shell started never reads the setup token; it says so where the owner looks
|
|
8
|
+
import { AGENT_ENV } from '../core/agent-env.ts'
|
|
9
|
+
import { checkAdvisors, SetupError, exposeAdvisors, SETUP_SECRET, type Fetch, type SetupInput } from './expose.ts'
|
|
10
10
|
import { granted, readState, withState, type OwnerState, type SetupRun } from './owner-store.ts'
|
|
11
11
|
import { NO_TUNNEL_START, type TunnelStart } from './tunnel.ts'
|
|
12
12
|
|
|
13
13
|
export type { SetupRun }
|
|
14
14
|
|
|
15
|
-
/** whether a pass looks at the setup: the mark moved since the last look, and the
|
|
15
|
+
/** whether a pass looks at the setup: the mark moved since the last look, and the page is not on its tunnel yet. Cheap:
|
|
16
16
|
* the token's own write time is read only then */
|
|
17
17
|
export function setupDue(s: Pick<OwnerState, 'tunnel' | 'setupRun'>, mark: number | null): boolean {
|
|
18
18
|
return mark !== null && s.tunnel === undefined && (s.setupRun === undefined || s.setupRun.mark < mark || s.setupRun.kind === 'agent')
|
|
@@ -107,14 +107,14 @@ export async function setupOnToken(o: { dir: string; house: string; host: string
|
|
|
107
107
|
const token = await read(SETUP_SECRET).catch(() => null)
|
|
108
108
|
if (token === null) return end(`the setup token ${SETUP_SECRET} is not stored: store a fresh one in the ask that opens the advisors page`)
|
|
109
109
|
try {
|
|
110
|
-
await
|
|
110
|
+
await exposeAdvisors({ dir: o.dir, cwd: o.house, host: o.host, say }, { tunnel: d.tunnel ?? NO_TUNNEL_START, read, ...(d.store ? { store: d.store } : {}), ...(d.fetch ? { fetch: d.fetch } : {}), ...(d.wait ? { wait: d.wait } : {}), now })
|
|
111
111
|
} catch (e) {
|
|
112
|
-
return end(`${(e as Error).message}${e instanceof
|
|
112
|
+
return end(`${(e as Error).message}${e instanceof SetupError && e.kind === 'local' ? '' : '. Store a fresh setup token in the ask, or « set the advisors page up now » at the foot, to run it again'}`)
|
|
113
113
|
}
|
|
114
|
-
const fails = await (d.check ?? ((h: string) =>
|
|
114
|
+
const fails = await (d.check ?? ((h: string) => checkAdvisors(h)))(o.host).catch((e: Error) => [`the check did not run: ${e.message}`])
|
|
115
115
|
for (const f of fails) say(`WARN ${f}`)
|
|
116
116
|
if (fails.length === 0) say(`checked from outside: the public pages open, the advisor routes want a session, nothing else answers`)
|
|
117
|
-
//
|
|
117
|
+
// each person with a live grant gets their code once, to sign in on the page just set up
|
|
118
118
|
const people = [...granted(readState(o.dir), now())]
|
|
119
119
|
for (const p of people) {
|
|
120
120
|
const said = await (d.mail ?? (async () => null))(p).catch((e: Error) => e.message)
|
|
@@ -127,6 +127,6 @@ export async function setupOnToken(o: { dir: string; house: string; host: string
|
|
|
127
127
|
return end(fails.length === 0 ? null : `the name answers what it should not yet (${fails.length}): it may need a minute; the foot says when advisors reach this Mac`)
|
|
128
128
|
}
|
|
129
129
|
|
|
130
|
-
/** every failure of the check is this Mac failing to look the name up (a name pointed a minute ago): the
|
|
131
|
-
* the check only did not reach it from here */
|
|
130
|
+
/** every failure of the check is this Mac failing to look the name up (a name pointed a minute ago): the page may
|
|
131
|
+
* stand, the check only did not reach it from here */
|
|
132
132
|
export const lookupOnly = (fails: readonly string[]): boolean => fails.length > 0 && fails.every((f) => /: unreachable \((getaddrinfo )?(ENOTFOUND|EAI_AGAIN)\b/.test(f))
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// a thread's shares as lines of its timeline (wiki tools/shipkit/advisors.md,
|
|
1
|
+
// a thread's shares as lines of its timeline (wiki tools/shipkit/advisors.md, What he does, one click each): shared with a person
|
|
2
2
|
// and for how long, an agent's ask and his confirm, each renew, the end by an unshare or at the expiry. Derived at read
|
|
3
3
|
// time from the shares of the advisors' store, never copied into a thread store: the store is the one source, and no
|
|
4
4
|
// agent's inbox, watch or hook reads this file's input (the cli's `sk thread show` prints the lines on demand).
|
|
@@ -23,7 +23,7 @@ export interface ShareEvent {
|
|
|
23
23
|
who: string
|
|
24
24
|
/** the line, its subject first: « you shared it with Ada, for 14 days » */
|
|
25
25
|
words: string
|
|
26
|
-
/** the share's newest line while it is live: the line its acts sit on (copy the invite, the
|
|
26
|
+
/** the share's newest line while it is live: the line its acts sit on (copy the invite, the advisors page) */
|
|
27
27
|
live?: true
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -44,7 +44,7 @@ export function eventsOfShare(x: Share, name: string, you: string, now: Date): S
|
|
|
44
44
|
else push({ at: x.created, act: 'shared', who: 'owner', words: `${you} shared it with ${name}${forDays(days(x.created))}` })
|
|
45
45
|
if (x.confirmed !== undefined) push({ at: x.confirmed, act: 'confirmed', who: 'owner', words: `${you} confirmed the share with ${name}${forDays(days(x.confirmed))}` })
|
|
46
46
|
for (const r of renewals) push({ at: r.at, act: 'renewed', who: 'owner', words: `${you} renewed the share with ${name}${forDays(daysOf(r.at, r.until))}` })
|
|
47
|
-
// an agent's ask never confirmed and never pushed was never live: it ends as dropped, never at an expiry
|
|
47
|
+
// an agent's ask never confirmed and never prepared by a pass (`pushed`) was never live: it ends as dropped, never at an expiry
|
|
48
48
|
const never = agent && x.state !== 'live' && x.confirmed === undefined && x.pushed === undefined
|
|
49
49
|
if (!never && x.state !== 'pending' && Date.parse(x.expires) <= now.getTime() && (x.revoked === undefined || x.expires < x.revoked)) push({ at: x.expires, act: 'expired', who: 'machine', words: `the share with ${name} ended at its expiry` })
|
|
50
50
|
else if (x.revoked !== undefined) push({ at: x.revoked, act: never ? 'dropped' : 'ended', who: 'owner', words: never ? `the share with ${name} was dropped: ${name} never got it` : `the share with ${name} ended: unshared` })
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// the
|
|
1
|
+
// the advisors page's sign in as a person's browser sends it (wiki tools/shipkit/advisors.md, The commands): a headless Chrome
|
|
2
2
|
// loads `https://<host>/in`, fills its form with a login nobody has and lets the form post itself, so the request
|
|
3
3
|
// carries what a browser really puts on it (its Origin under the page's referrer policy), never headers typed by hand.
|
|
4
4
|
// The one constraint a reader breaks first: ONE try a run, with an email no person has, so it counts against that email
|
|
@@ -13,11 +13,12 @@ const PROBE_PASSWORD = 'not-a-real-password-of-anyone'
|
|
|
13
13
|
|
|
14
14
|
export type Probe = { ok: string } | { warn: string } | { fail: string }
|
|
15
15
|
|
|
16
|
-
/** what the page after the post says: the
|
|
17
|
-
*
|
|
16
|
+
/** what the page after the post says: the users' port's own « check your email and password » is a pass (« does not
|
|
17
|
+
* match » from a daemon that runs the words before them); « Forbidden » is the port refusing its own form; anything
|
|
18
|
+
* else is no sign in page */
|
|
18
19
|
export function probeVerdict(title: string, words: string): Probe {
|
|
19
20
|
const w = words.replace(/\s+/g, ' ').trim()
|
|
20
|
-
if (/does not match/i.test(w)) return { ok: 'the sign in form posts as the advisors page expects: a login nobody has gets «
|
|
21
|
+
if (/check your email and password|does not match/i.test(w)) return { ok: 'the sign in form posts as the advisors page expects: a login nobody has gets « check your email and password »' }
|
|
21
22
|
if (/too many tries/i.test(w)) return { warn: 'the form passed the origin check, but the advisors page counts too many tries from this address now: run it again in 10 minutes' }
|
|
22
23
|
if (/forbidden/i.test(title) || /not sent from the sign in page/i.test(w)) return { fail: `the advisors page refuses its own sign in form as sent from elsewhere: nobody can sign in (« ${w.slice(0, 120)} »)` }
|
|
23
24
|
return { fail: `after the form's post the page is not the sign in page: « ${title} » « ${w.slice(0, 120) || 'a blank page'} »` }
|
|
@@ -26,8 +27,8 @@ export function probeVerdict(title: string, words: string): Probe {
|
|
|
26
27
|
export const chromeAt = (): string | null =>
|
|
27
28
|
[process.env.CHROME, '/Applications/Google Chrome.app/Contents/MacOS/Google Chrome', join(homedir(), 'Applications', 'Google Chrome.app', 'Contents', 'MacOS', 'Google Chrome')].find((p): p is string => p !== undefined && p !== '' && existsSync(p)) ?? null
|
|
28
29
|
|
|
29
|
-
/** one try of the sign in, through the live
|
|
30
|
-
/** `args`: Chrome flags of a browser check that runs this against a local
|
|
30
|
+
/** one try of the sign in, through the live advisors page, in a headless Chrome of its own; a WARN with no Chrome */
|
|
31
|
+
/** `args`: Chrome flags of a browser check that runs this against a local users' port (its name mapped to a port) */
|
|
31
32
|
export async function probeSignIn(host: string, o: { chrome?: string | null; timeoutMs?: number; args?: readonly string[] } = {}): Promise<Probe> {
|
|
32
33
|
const exe = o.chrome === undefined ? chromeAt() : o.chrome
|
|
33
34
|
if (exe === null) return { warn: 'no Chrome on this machine: the sign in form was not tried in a real browser (set CHROME to its binary)' }
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
// who the owner speaks as, for the advisors page (wiki tools/shipkit/advisors.md, His name on the advisors page): the
|
|
2
|
+
// identity a repo speaks as, and the facts the public pages print. The one constraint a reader breaks first: the
|
|
3
|
+
// users' port imports it, so it reads repo configs and identity folders only, never a secret
|
|
4
|
+
import { loadIdentities, speakerOf } from '../identities/identities.ts'
|
|
5
|
+
import { loadRepoConfig } from '../repo-config.ts'
|
|
6
|
+
import { factsOf, type PageFacts } from './edge/pages.ts'
|
|
7
|
+
|
|
8
|
+
/** the identity the house's repo config speaks as: its id (the name advisors read when he set none) and its contact */
|
|
9
|
+
export async function housePageFacts(house: string | null): Promise<{ facts: PageFacts; id: string | null; warn?: string }> {
|
|
10
|
+
const speaker = house === null ? null : speakerOf((await loadRepoConfig(house)).speaksAs, await loadIdentities({ cwd: house }))
|
|
11
|
+
const facts = factsOf(speaker?.id, speaker?.rows.find((r) => r.field === 'email')?.value)
|
|
12
|
+
const id = speaker?.id ?? null
|
|
13
|
+
if (facts.contact !== null) return { facts, id }
|
|
14
|
+
return { facts, id, warn: `the privacy page names no contact: ${speaker === null ? 'no identity speaks for the house' : `the identity ${speaker.id} has no email row in its identity.md profile`}` }
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const speaks = new Map<string, Promise<string | null>>()
|
|
18
|
+
/** the identity a repo speaks as (its config's `speaksAs`), read once per process: his name for advisors there
|
|
19
|
+
* (owner-name.ts) */
|
|
20
|
+
export function identityOfRoot(root: string): Promise<string | null> {
|
|
21
|
+
if (!speaks.has(root)) speaks.set(root, loadRepoConfig(root).then((c) => c.speaksAs ?? null, () => null))
|
|
22
|
+
return speaks.get(root)!
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** the name the advisors page opens at: the house config's `serve.advisorsHost`, null when it names none */
|
|
26
|
+
export async function houseHost(house: string): Promise<string | null> {
|
|
27
|
+
const h = await loadRepoConfig(house).then((c) => c.serve?.advisorsHost?.trim().toLowerCase() ?? '', () => '')
|
|
28
|
+
return h === '' ? null : h
|
|
29
|
+
}
|