rvlib-shipkit 2.27.0 → 2.28.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +16 -0
- package/package.json +1 -1
- package/src/agent-time/hooks.ts +10 -3
- package/src/agent-time/live.ts +11 -5
- package/src/agent-time/registry.ts +289 -0
- package/src/agent-time/store.ts +2 -2
- package/src/annex/born.ts +2 -2
- package/src/annex/offload.ts +12 -11
- package/src/asks/ask-after.ts +6 -2
- package/src/asks/ask-bar-fold.ts +57 -0
- package/src/asks/ask-migrate.ts +280 -0
- package/src/asks/ask-steps-fold.ts +166 -0
- package/src/asks/ask-store.ts +586 -0
- package/src/assets/kits/identity-kit.ts +106 -38
- package/src/assets/kits/poster-thumbnail.ts +282 -0
- package/src/checks/SK003-claude-md-shape.check.ts +92 -25
- package/src/checks/SK004-gitignore-policy.check.ts +8 -4
- package/src/checks/SK013-one-way-in-policy.check.ts +10 -0
- package/src/checks/SK026-asks-autoclose.check.ts +9 -23
- package/src/checks/SK038-speaks-as.check.ts +3 -3
- package/src/checks/SK042-post-kinds.check.ts +26 -24
- package/src/checks/SK049-thread-answers-hook.check.ts +81 -0
- package/src/checks/SK050-retired-commands.check.ts +127 -0
- package/src/cli/cmd_Asks.ts +204 -53
- package/src/cli/cmd_Backup.ts +151 -8
- package/src/cli/cmd_Calls.ts +1 -0
- package/src/cli/cmd_Commands.ts +140 -34
- package/src/cli/cmd_Contracts.ts +1 -0
- package/src/cli/cmd_Keys.ts +1 -0
- package/src/cli/cmd_Lanes.ts +15 -4
- package/src/cli/cmd_Messages.ts +152 -1
- package/src/cli/cmd_Needs.ts +1 -0
- package/src/cli/cmd_Review.ts +931 -229
- package/src/cli/cmd_Secret.ts +255 -34
- package/src/cli/cmd_Social.ts +36 -33
- package/src/cli/cmd_SocialDrafts.ts +235 -0
- package/src/cli/cmd_Sound.ts +22 -1
- package/src/cli/cmd_Start.ts +3 -2
- package/src/cli/cmd_ThreadHolds.ts +34 -0
- package/src/cli/cmd_ThreadKinds.ts +146 -0
- package/src/cli/cmd_ThreadReflect.ts +83 -0
- package/src/cli/cmd_ThreadSyncNeeds.ts +62 -0
- package/src/cli/cmd_Vault.ts +1 -1
- package/src/cli/cmd_When.ts +1 -0
- package/src/cli/family-help.ts +2 -2
- package/src/cli/family-pages.ts +1 -1
- package/src/cli/kit/builtins.ts +1 -0
- package/src/cli/kit/verb.ts +6 -2
- package/src/cli/registry.ts +21 -2
- package/src/cli.ts +5 -2
- package/src/collections/actions.ts +25 -74
- package/src/collections/collection-types.ts +9 -5
- package/src/collections/md-body.ts +5 -3
- package/src/collections/pings.ts +13 -6
- package/src/collections/providers.ts +53 -61
- package/src/collections/reflections.ts +9 -4
- package/src/core/discover-checks.ts +18 -3
- package/src/core/git.ts +31 -0
- package/src/core/house-layout.ts +17 -0
- package/src/core/layout.ts +10 -5
- package/src/core/locked-write.ts +4 -1
- package/src/core/machine-db.ts +5 -3
- package/src/core/migrate-layout.ts +8 -10
- package/src/home/activity.ts +8 -15
- package/src/home/daemon-jobs.ts +13 -1
- package/src/home/home-paths.ts +6 -3
- package/src/home/home-routes.ts +8 -0
- package/src/home/inbox-shape.ts +233 -100
- package/src/home/inbox.ts +26 -71
- package/src/home/machine-fold.ts +10 -15
- package/src/home/machine-host.ts +19 -1
- package/src/home/other-macs.ts +2 -2
- package/src/home/serve-web.ts +6 -5
- package/src/home/space-page.ts +1 -1
- package/src/home/vault-page.ts +51 -17
- package/src/home/vault-words.ts +2 -2
- package/src/hooks/one-way-in-guard.ts +24 -2
- package/src/hq/files-send.ts +27 -28
- package/src/hq/hq-db.ts +4 -1
- package/src/hq/hq-local.ts +37 -4
- package/src/hq/hq-routes.ts +10 -2
- package/src/hq/hq-store.ts +6 -2
- package/src/hq/kinds/ask.ts +6 -6
- package/src/hq/outbox.ts +5 -3
- package/src/hq/replica.ts +1 -2
- package/src/hq/vault-route.ts +112 -0
- package/src/identities/collection.ts +2 -2
- package/src/identities/identities.ts +9 -8
- package/src/identities/machine-route.ts +8 -3
- package/src/ledger/db.ts +8 -1
- package/src/media-store/backup/daemon.ts +48 -8
- package/src/media-store/backup/keys.ts +1 -1
- package/src/media-store/backup/manifest.ts +20 -2
- package/src/media-store/backup/prune.ts +365 -0
- package/src/media-store/backup/retention.ts +122 -0
- package/src/media-store/backup/run.ts +14 -8
- package/src/media-store/backup/sources.ts +18 -17
- package/src/media-store/backup/thread-copy.ts +340 -0
- package/src/media-store/copy/config.ts +3 -4
- package/src/media-store/copy/store.ts +2 -2
- package/src/media-store/db.ts +2 -2
- package/src/media-store/forget.ts +118 -0
- package/src/media-store/purge.ts +3 -2
- package/src/media-store/space-listing.ts +20 -4
- package/src/media-store/space.ts +6 -5
- package/src/messages/guard.ts +49 -0
- package/src/messages/model.ts +1 -1
- package/src/messages/objects.ts +201 -0
- package/src/messages/routes.ts +2 -2
- package/src/messages/score.ts +1 -1
- package/src/messages/write.ts +285 -0
- package/src/pages/frame-client.ts +181 -4
- package/src/reflections/reflections-queue.ts +1 -1
- package/src/release/gate-checkout.ts +2 -1
- package/src/release/git-facts.ts +3 -2
- package/src/release/public-clean.ts +3 -2
- package/src/repo-config.ts +40 -18
- package/src/review/anim.ts +1 -1
- package/src/review/answer-kinds.ts +131 -0
- package/src/review/band.ts +53 -0
- package/src/review/branch-hold.ts +84 -0
- package/src/review/card-db.ts +16 -6
- package/src/review/card-rows.ts +4 -3
- package/src/review/cells.ts +297 -65
- package/src/review/close.ts +92 -0
- package/src/review/draft-card.ts +8 -16
- package/src/review/draft-model.ts +2 -2
- package/src/review/events.ts +171 -0
- package/src/review/format.ts +128 -14
- package/src/review/glyphs.ts +63 -0
- package/src/review/gone.ts +1 -1
- package/src/review/holds-sync.ts +62 -0
- package/src/review/holds.ts +85 -0
- package/src/review/house-kind-defs.ts +41 -0
- package/src/review/inbox-hook.ts +22 -9
- package/src/review/inbox-read.ts +201 -0
- package/src/review/instructions.ts +199 -0
- package/src/review/kind-apply.ts +61 -0
- package/src/review/kind-catalog.ts +96 -0
- package/src/review/kinds.ts +278 -0
- package/src/review/lane-ask.ts +109 -0
- package/src/review/model.ts +396 -86
- package/src/review/move.ts +3 -3
- package/src/review/need-address.ts +15 -0
- package/src/review/need-threads.ts +93 -0
- package/src/review/object-card.ts +48 -0
- package/src/review/object-read.ts +31 -0
- package/src/review/owner-verdict.ts +36 -0
- package/src/review/parties.ts +182 -0
- package/src/review/previews.ts +3 -1
- package/src/review/projections.ts +235 -0
- package/src/review/referring.ts +54 -0
- package/src/review/reflection-object.ts +195 -0
- package/src/review/routes.ts +137 -32
- package/src/review/secret-route.ts +80 -0
- package/src/review/snooze.ts +38 -0
- package/src/review/stage-card.ts +4 -4
- package/src/review/store.ts +366 -85
- package/src/review/supersede.ts +116 -0
- package/src/review/take-back.ts +52 -0
- package/src/review/thread-fold.ts +20 -7
- package/src/review/threads.ts +236 -39
- package/src/review/traces.ts +218 -0
- package/src/review/trailer-card.ts +2 -2
- package/src/review/unit.ts +71 -5
- package/src/review/verdict-items.ts +73 -0
- package/src/review/verdict-write.ts +15 -0
- package/src/review/wait.ts +85 -0
- package/src/review/watchers.ts +22 -9
- package/src/scaffold/files/claude-settings-local.json +2 -0
- package/src/secrets/archive-mark.ts +52 -0
- package/src/secrets/archive.ts +83 -0
- package/src/secrets/copy.ts +14 -14
- package/src/secrets/keychain-write.ts +48 -0
- package/src/secrets/keychain.ts +8 -5
- package/src/secrets/lapse-mark.ts +33 -0
- package/src/secrets/lapse.ts +60 -0
- package/src/secrets/list.ts +16 -22
- package/src/secrets/manager.ts +31 -16
- package/src/secrets/read.ts +161 -33
- package/src/secrets/tail.ts +31 -0
- package/src/serve/hub-app/asks-page.tsx +2 -1
- package/src/serve/hub-app/auto-text.tsx +14 -6
- package/src/serve/hub-app/benign-errors.ts +15 -1
- package/src/serve/hub-app/card-head.tsx +49 -0
- package/src/serve/hub-app/check-view.tsx +3 -2
- package/src/serve/hub-app/code-copy.ts +35 -0
- package/src/serve/hub-app/col-card.tsx +31 -40
- package/src/serve/hub-app/col-list-page.tsx +5 -2
- package/src/serve/hub-app/col-tables-view.tsx +7 -4
- package/src/serve/hub-app/col-tables.ts +5 -5
- package/src/serve/hub-app/cols-svc.ts +4 -79
- package/src/serve/hub-app/commands/commands-page.tsx +2 -1
- package/src/serve/hub-app/controls.css +83 -0
- package/src/serve/hub-app/frames-st.ts +17 -1
- package/src/serve/hub-app/git-view.tsx +3 -2
- package/src/serve/hub-app/home-st.ts +57 -6
- package/src/serve/hub-app/home-strip.css +1 -6
- package/src/serve/hub-app/home-strip.tsx +2 -1
- package/src/serve/hub-app/home.html +3 -0
- package/src/serve/hub-app/house-wiki-view.tsx +20 -0
- package/src/serve/hub-app/hub-app.tsx +48 -32
- package/src/serve/hub-app/hub-types.ts +2 -0
- package/src/serve/hub-app/hub.css +50 -61
- package/src/serve/hub-app/icons.tsx +14 -4
- package/src/serve/hub-app/identities-view.tsx +4 -3
- package/src/serve/hub-app/inbox-st.ts +203 -42
- package/src/serve/hub-app/inbox-view.tsx +189 -101
- package/src/serve/hub-app/inbox.css +47 -44
- package/src/serve/hub-app/index.html +3 -0
- package/src/serve/hub-app/instructions.css +30 -0
- package/src/serve/hub-app/keys.ts +5 -3
- package/src/serve/hub-app/machine-st.ts +2 -2
- package/src/serve/hub-app/machines-view.tsx +4 -11
- package/src/serve/hub-app/machines.css +0 -9
- package/src/serve/hub-app/markdown.css +51 -0
- package/src/serve/hub-app/md-copy.tsx +18 -40
- package/src/serve/hub-app/md.ts +25 -9
- package/src/serve/hub-app/media-view.tsx +2 -2
- package/src/serve/hub-app/messages/messages-page.tsx +2 -1
- package/src/serve/hub-app/messages/messages-st.ts +1 -1
- package/src/serve/hub-app/messages.css +0 -1
- package/src/serve/hub-app/objects.css +51 -0
- package/src/serve/hub-app/page-keys.ts +1 -1
- package/src/serve/hub-app/pages-frames.tsx +11 -1
- package/src/serve/hub-app/palette-st.ts +4 -4
- package/src/serve/hub-app/pane-boundary.tsx +72 -0
- package/src/serve/hub-app/pane-errors.ts +54 -0
- package/src/serve/hub-app/plan-view.tsx +3 -2
- package/src/serve/hub-app/planned-view.tsx +3 -3
- package/src/serve/hub-app/planned.css +0 -4
- package/src/serve/hub-app/processes-view.tsx +3 -2
- package/src/serve/hub-app/project-list.css +5 -13
- package/src/serve/hub-app/project-list.tsx +3 -6
- package/src/serve/hub-app/projects-svc.ts +6 -2
- package/src/serve/hub-app/readme.css +9 -15
- package/src/serve/hub-app/reflections-page.tsx +54 -1
- package/src/serve/hub-app/releases/releases-page.tsx +3 -2
- package/src/serve/hub-app/releases.css +0 -1
- package/src/serve/hub-app/review/code-colors.ts +30 -0
- package/src/serve/hub-app/review/diff-view.tsx +75 -0
- package/src/serve/hub-app/review/dock.tsx +104 -0
- package/src/serve/hub-app/review/draft-card.tsx +2 -2
- package/src/serve/hub-app/review/group-block.tsx +209 -0
- package/src/serve/hub-app/review/instructions-view.tsx +116 -0
- package/src/serve/hub-app/review/item-verdict.tsx +38 -0
- package/src/serve/hub-app/review/kind-states.tsx +193 -0
- package/src/serve/hub-app/review/kind-view.tsx +1 -37
- package/src/serve/hub-app/review/kit.tsx +57 -54
- package/src/serve/hub-app/review/lane-bar.tsx +64 -0
- package/src/serve/hub-app/review/object-card.tsx +62 -0
- package/src/serve/hub-app/review/object-panel.tsx +179 -0
- package/src/serve/hub-app/review/question-views.tsx +385 -0
- package/src/serve/hub-app/review/review-cells.tsx +86 -105
- package/src/serve/hub-app/review/review-list.tsx +104 -47
- package/src/serve/hub-app/review/review-page.tsx +5 -4
- package/src/serve/hub-app/review/review-st.ts +68 -28
- package/src/serve/hub-app/review/review-thread.tsx +171 -40
- package/src/serve/hub-app/review/review-views.tsx +35 -31
- package/src/serve/hub-app/review/thread-close.tsx +124 -0
- package/src/serve/hub-app/review/thread-control.tsx +4 -4
- package/src/serve/hub-app/review/thread-st.ts +222 -22
- package/src/serve/hub-app/review/trailer-card.tsx +1 -1
- package/src/serve/hub-app/review/trailer-timeline.tsx +2 -2
- package/src/serve/hub-app/review.css +216 -57
- package/src/serve/hub-app/section-head.tsx +51 -0
- package/src/serve/hub-app/social/calendar.tsx +5 -11
- package/src/serve/hub-app/social/comms-page.tsx +23 -10
- package/src/serve/hub-app/social/kit.tsx +8 -15
- package/src/serve/hub-app/social/next-release.tsx +3 -5
- package/src/serve/hub-app/social/post-card.tsx +3 -0
- package/src/serve/hub-app/social/post-page.tsx +80 -0
- package/src/serve/hub-app/social/problems.tsx +5 -9
- package/src/serve/hub-app/social/social-model.ts +13 -5
- package/src/serve/hub-app/social/social-page.tsx +1 -1
- package/src/serve/hub-app/social/social-st.ts +42 -5
- package/src/serve/hub-app/social.css +7 -17
- package/src/serve/hub-app/space.css +1 -1
- package/src/serve/hub-app/stores/stores-page.tsx +6 -2
- package/src/serve/hub-app/thread-row.tsx +101 -0
- package/src/serve/hub-app/time-ago.tsx +3 -2
- package/src/serve/hub-app/time-view.tsx +2 -1
- package/src/serve/hub-app/time.css +2 -5
- package/src/serve/hub-app/tree-row.tsx +1 -9
- package/src/serve/hub-app/vault-view.tsx +4 -4
- package/src/serve/hub-app/veille/veille-page.tsx +2 -11
- package/src/serve/hub-app/veille.css +0 -1
- package/src/serve/hub-app/waiting-svc.ts +4 -4
- package/src/serve/hub-app/when-view.tsx +6 -3
- package/src/serve/hub-app/wiki-st.ts +30 -4
- package/src/serve/hub-app/wikis-view.tsx +4 -3
- package/src/serve/hub-runtime.ts +20 -6
- package/src/serve/project-gutter-route.ts +16 -6
- package/src/serve/project-gutter.ts +6 -53
- package/src/serve/same-origin.ts +3 -0
- package/src/serve/secret-gate.ts +21 -0
- package/src/serve/serve-hub.ts +29 -20
- package/src/serve/tailnet-caller.ts +117 -0
- package/src/shipkit.ts +2 -2
- package/src/site/desk.ts +2 -2
- package/src/smoke/run-smoke.ts +3 -4
- package/src/social/brands.ts +4 -0
- package/src/social/card-drafts.ts +11 -19
- package/src/social/desk-index.ts +34 -13
- package/src/social/drafts.ts +4 -4
- package/src/social/import-drafts.ts +244 -0
- package/src/social/kind-pages.ts +3 -3
- package/src/social/kinds.ts +1 -1
- package/src/social/load.ts +89 -64
- package/src/social/media-kind.ts +68 -161
- package/src/social/media-of.ts +5 -4
- package/src/social/open.ts +3 -2
- package/src/social/post-object.ts +120 -0
- package/src/social/post-sources.ts +136 -0
- package/src/social/post-text.ts +103 -0
- package/src/social/posts.ts +378 -0
- package/src/social/presence.ts +7 -5
- package/src/social/publish/index.ts +17 -5
- package/src/social/publish/secret.ts +2 -2
- package/src/social/release-stage.ts +58 -57
- package/src/social/routes.ts +64 -24
- package/src/social/stage.ts +42 -57
- package/src/social/text.ts +4 -3
- package/src/social/thumbnail.ts +135 -43
- package/src/social/tracker.ts +1 -1
- package/src/social/writes.ts +12 -29
- package/src/stores/desk.ts +16 -11
- package/src/stores/unit.ts +2 -2
- package/src/trailer/sound/eleven.ts +33 -3
- package/src/urls/rows.ts +1 -1
- package/src/vault/vault-http.ts +11 -3
- package/src/vault/vault-import.ts +6 -1
- package/src/veille/identity.ts +2 -2
- package/src/wiki/graph-pages.ts +13 -1
- package/src/wiki/scan-md.ts +1 -1
- package/src/asks/asks-queue.ts +0 -424
- package/src/messages/suggest.ts +0 -96
- package/src/social/migrate.ts +0 -123
package/src/review/routes.ts
CHANGED
|
@@ -1,32 +1,74 @@
|
|
|
1
1
|
// the hub's review routes (wiki tools/shipkit/threads.md, The hub): the store's list, an item's images and clips, the
|
|
2
2
|
// owner's verdicts, replies and read marks appended to its thread. The trailer view's routes: trailer-routes.ts. Paths are
|
|
3
3
|
// relative to the repo hub's base. null: not a path of these
|
|
4
|
-
import { existsSync, mkdtempSync, rmSync,
|
|
4
|
+
import { existsSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
|
|
5
5
|
import { tmpdir } from 'node:os'
|
|
6
6
|
import { dirname, extname, join } from 'node:path'
|
|
7
7
|
import { isAnimFormat, isAnimLabels, isAnimMode, pairAnimation } from './anim.ts'
|
|
8
8
|
import { startAuto } from './auto.ts'
|
|
9
9
|
import { bad, KEEP, NO_STORE, ranged, tagged, TYPES } from './http.ts'
|
|
10
10
|
import { isStoreRefused } from '../core/machine-db.ts'
|
|
11
|
-
import {
|
|
11
|
+
import { addressOrThrow, canonicalAddress, viewFilesOf, type Rect, type ReviewItem, type Subject } from './model.ts'
|
|
12
12
|
import { stageGet, stagePost } from './stage-routes.ts'
|
|
13
13
|
import { pasteHosts } from './paste.ts'
|
|
14
14
|
import { openReview, partFile, viewOfItem } from './project.ts'
|
|
15
15
|
import { CLIP, isPreviewSize, previewOrRemote, warmPreviews } from './previews.ts'
|
|
16
16
|
import { roleOf } from './role.ts'
|
|
17
|
-
import { addMessage, answerAsk, attachTo, imageFile, mediaDir, itemOfRef, markRead, raiseItem, rateSubject, readAllCached, readItem, reopen, specOf, storeDir, storeStamp, threadImage
|
|
17
|
+
import { addMessage, answerAsk, appendMessage, isWebUrl, readAll, postAction, attachTo, imageFile, mediaDir, itemOfRef, markRead, raiseItem, rateSubject, readAllCached, readItem, reopen, specOf, storeDir, storeStamp, threadImage } from './store.ts'
|
|
18
18
|
import { boardOf, pageOf, queryOf, threadIndex, threadOfId, threadsOfAddress, threadView, type ThreadIndex } from './cells.ts'
|
|
19
|
-
import { membersOf, threadsOf, type Thread } from './threads.ts'
|
|
19
|
+
import { holderOf, membersOf, membersOfItem, threadsOf, type Thread } from './threads.ts'
|
|
20
|
+
import { supersededRefusal } from './supersede.ts'
|
|
20
21
|
import { putMedia } from '../media-store/put.ts'
|
|
21
22
|
import { upKeys } from '../media-store/remote.ts'
|
|
22
23
|
import { ensureLocal, remoteUrl, reviewKey } from './media-read.ts'
|
|
23
24
|
import { hqUnreached } from '../media-store/hq-find.ts'
|
|
24
25
|
import { trailerRoutes } from './trailer-routes.ts'
|
|
26
|
+
import { secretRoutes } from './secret-route.ts'
|
|
27
|
+
import type { TailnetWho } from '../serve/tailnet-caller.ts'
|
|
28
|
+
import { asideAt, snoozeThread } from './snooze.ts'
|
|
29
|
+
import { closeThread, CLOSE_HOWS, rootOfStore } from './close.ts'
|
|
30
|
+
import { ownerVerdict, releaseFollows } from './owner-verdict.ts'
|
|
31
|
+
import { liveHolds } from './holds-sync.ts'
|
|
32
|
+
import { followAskThread } from '../asks/ask-store.ts'
|
|
33
|
+
import type { HeldOf } from '../secrets/held.ts'
|
|
34
|
+
import type { SecretStore } from '../secrets/manager.ts'
|
|
25
35
|
import { specData, type ReviewUnit } from './unit.ts'
|
|
26
36
|
import { liveWatchers } from './watchers.ts'
|
|
37
|
+
import { readParties, readSessionRecords, repoNameOf } from '../agent-time/registry.ts'
|
|
38
|
+
import { objectReaderOf, objectsTag } from './object-read.ts'
|
|
39
|
+
import type { Parties } from './parties.ts'
|
|
40
|
+
import { orchestratorOf } from './lane-ask.ts'
|
|
41
|
+
|
|
42
|
+
/** his « start a lane » on a thread: a request in it, never a process (wiki tools/shipkit/threads-how-it-fits.md, A lane
|
|
43
|
+
* he asks for); it names the orchestrator it waits on now */
|
|
44
|
+
async function askLane(dir: string, id: string, text: unknown): Promise<unknown> {
|
|
45
|
+
const t = threadOfId(id, threadsOf(readAll(dir).items, specOf(dir)))
|
|
46
|
+
if (!t) throw new Error(`no item ${id}`)
|
|
47
|
+
const words = typeof text === 'string' ? text.trim() : ''
|
|
48
|
+
const { repo, parties } = await partiesOfStore(dir)
|
|
49
|
+
const o = orchestratorOf(holderOf(t), parties, repo)
|
|
50
|
+
return appendMessage(dir, t.head.item.id, { who: 'owner', laneAsk: { for: o.label, ...(o.session ? { session: o.session } : {}) }, ...(words ? { text: words } : {}) })
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** a store's parties as the page reads them, read again at most every few seconds: the registry reads transcripts */
|
|
54
|
+
const PARTIES_MS = 4000
|
|
55
|
+
const partiesHeld = new Map<string, { at: number; value: Promise<{ repo: string; parties: Parties }> }>()
|
|
56
|
+
export function partiesOfStore(dir: string, now = Date.now()): Promise<{ repo: string; parties: Parties }> {
|
|
57
|
+
const held = partiesHeld.get(dir)
|
|
58
|
+
if (held && now - held.at < PARTIES_MS) return held.value
|
|
59
|
+
const value = (async () => {
|
|
60
|
+
const items = readAllCached(dir).items
|
|
61
|
+
const ids = new Set(threadsOf(items, specOf(dir)).flatMap((t) => holderOf(t)?.session ?? []))
|
|
62
|
+
// every session that acted in this store: the orchestrators a request for a lane may wait on (review/lane-ask.ts)
|
|
63
|
+
for (const r of readSessionRecords()) if (r.stores.includes(dir)) ids.add(r.session)
|
|
64
|
+
return { repo: repoNameOf(dirname(dirname(dir))), parties: await readParties({ sessions: [...ids], watchers: liveWatchers(dir) }) }
|
|
65
|
+
})()
|
|
66
|
+
partiesHeld.set(dir, { at: now, value })
|
|
67
|
+
return value
|
|
68
|
+
}
|
|
27
69
|
import { autoRulesOf } from '../veille/auto.ts'
|
|
28
70
|
import { draftsOfCard } from '../social/card-drafts.ts'
|
|
29
|
-
import {
|
|
71
|
+
import { cardsDb } from './card-db.ts'
|
|
30
72
|
|
|
31
73
|
// ── each repo's review unit, read again at most every 5 s; its auto rules scheduled in this server while it serves ──
|
|
32
74
|
|
|
@@ -52,17 +94,6 @@ async function project(root: string): Promise<{ dir: string; unit: ReviewUnit |
|
|
|
52
94
|
return { dir, unit }
|
|
53
95
|
}
|
|
54
96
|
|
|
55
|
-
/** next.md follows his answer (releases/from-card.ts), after the request answered; `was` the status before it */
|
|
56
|
-
async function releaseFollows(dir: string, id: string, was: ReviewStatus | null): Promise<void> {
|
|
57
|
-
const { followAnswer } = await import('../releases/from-card.ts')
|
|
58
|
-
await followAnswer(dirname(dirname(dir)), id, was)
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
const statusNow = (dir: string, id: string): ReviewStatus | null => {
|
|
62
|
-
const x = readItem(dir, id)
|
|
63
|
-
return x ? (verdictOf(x)?.status ?? null) : null
|
|
64
|
-
}
|
|
65
|
-
|
|
66
97
|
/** an image the page sent as a data url, written to a scratch file the caller removes */
|
|
67
98
|
function dataUrlFile(url: unknown): { file: string; done(): void } | null {
|
|
68
99
|
if (url === undefined || url === null) return null
|
|
@@ -106,10 +137,11 @@ function indexOf(dir: string): Indexed {
|
|
|
106
137
|
const made: Indexed = { stamp, at: Date.now(), tag: `"${BOOT}.${++builds}"`, ix, threads: threadsOf(all.items), broken: all.broken }
|
|
107
138
|
threadIx.set(dir, made)
|
|
108
139
|
// the cards that need someone open on their previews: made in the background, one stat each once made
|
|
109
|
-
|
|
140
|
+
// nobody awaits it: a preview that fails (its folder gone meanwhile) says so here, never an unhandled rejection
|
|
141
|
+
warmPreviews(
|
|
110
142
|
dir,
|
|
111
143
|
ix.entries.filter((e) => e.row.active).map((e) => e.t.head),
|
|
112
|
-
)
|
|
144
|
+
).catch((e: unknown) => console.error(`WARN: review previews made ahead in ${dir}: ${(e as Error).message}`))
|
|
113
145
|
return made
|
|
114
146
|
}
|
|
115
147
|
|
|
@@ -140,6 +172,22 @@ const unreached = (): Response | null =>
|
|
|
140
172
|
/** a file the disk let go, answered by the Space: the signed URL lives an hour, the browser keeps the redirect half of it */
|
|
141
173
|
const toSpace = (url: string): Response => new Response(null, { status: 302, headers: { Location: url, 'Cache-Control': 'private, max-age=1800' } })
|
|
142
174
|
|
|
175
|
+
/** whether `re` on item `id` is a url question */
|
|
176
|
+
const urlQuestion = (dir: string, id: string, re: string): boolean => readItem(dir, id)?.thread.find((m) => m.id === re)?.ask?.kind === 'url'
|
|
177
|
+
|
|
178
|
+
/** the status a link he gave answers a HEAD with, from this machine with no cookie, 0 when it did not answer; information
|
|
179
|
+
* only: a HEAD spends less of a link that works once than a GET would */
|
|
180
|
+
async function opensWith(value: string): Promise<number> {
|
|
181
|
+
if (!isWebUrl(value.trim())) return 0
|
|
182
|
+
try {
|
|
183
|
+
const r = await fetch(value.trim(), { method: 'HEAD', redirect: 'follow', signal: AbortSignal.timeout(4_000) })
|
|
184
|
+
void r.body?.cancel().catch(() => {})
|
|
185
|
+
return r.status
|
|
186
|
+
} catch {
|
|
187
|
+
return 0
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
|
|
143
191
|
async function reviewRoute(req: Request, path: string, dir: string, unit: ReviewUnit | null): Promise<Response | null> {
|
|
144
192
|
if (path === '/api/review' && req.method === 'GET') {
|
|
145
193
|
// the page polls this list: it is read from disk and sent again only when a file of it changed
|
|
@@ -168,26 +216,26 @@ async function reviewRoute(req: Request, path: string, dir: string, unit: Review
|
|
|
168
216
|
}
|
|
169
217
|
const t = threadOfId(id, x.threads)
|
|
170
218
|
if (!t) return bad(`no item ${ref}`, 404)
|
|
171
|
-
// a draft staged from the card
|
|
172
|
-
const staged =
|
|
173
|
-
|
|
219
|
+
// a draft staged from the card is a group of the posts' projection: its newest write joins the tag
|
|
220
|
+
const staged = (cardsDb().query('select max(last_seq) as s from thread_post_groups').get() as { s: number | null } | null)?.s ?? 0
|
|
221
|
+
const root = dirname(dirname(dir))
|
|
222
|
+
return tagged(req, `${x.tag.slice(0, -1)}.${staged}.${objectsTag(root)}"`, () => {
|
|
174
223
|
const members = membersOf(t)
|
|
175
|
-
return { ...threadView(t, readAllCached(dir).items, x.threads, id), missing: missingOf(dir, members), drafts: draftsOfCard(dirname(dirname(dir)), new Set(members.map((m) => m.item.id))) }
|
|
224
|
+
return { ...threadView(t, readAllCached(dir).items, x.threads, id, new Date(), objectReaderOf(root, repoNameOf(root))), missing: missingOf(dir, members), drafts: draftsOfCard(dirname(dirname(dir)), new Set(members.map((m) => m.item.id))) }
|
|
176
225
|
})
|
|
177
226
|
}
|
|
178
227
|
// the thread control of any object: the threads that name it or a part of it, and the open ones to attach it to
|
|
179
228
|
if (path === '/api/review/of' && req.method === 'GET') {
|
|
180
229
|
const x = indexOf(dir)
|
|
181
230
|
const asked = new URL(req.url).searchParams.getAll('address')
|
|
182
|
-
const wrong = asked.find((a) =>
|
|
231
|
+
const wrong = asked.find((a) => canonicalAddress(a) === null)
|
|
183
232
|
if (asked.length === 0 || wrong !== undefined) return bad(`address: <kind>:<key>${wrong ? `, not ${wrong}` : ''}`)
|
|
184
233
|
return tagged(req, x.tag, () => ({ objects: asked.map((a) => threadsOfAddress(x.ix, x.threads, a)) }))
|
|
185
234
|
}
|
|
186
235
|
if (path === '/api/review/note' && req.method === 'POST') {
|
|
187
236
|
try {
|
|
188
237
|
const b = (await req.json()) as Record<string, unknown>
|
|
189
|
-
const address = typeof b.address === 'string' ? b.address : ''
|
|
190
|
-
if (!ADDRESS_RE.test(address)) throw new Error('address: <kind>:<key>')
|
|
238
|
+
const address = addressOrThrow(typeof b.address === 'string' ? b.address : '')
|
|
191
239
|
if (typeof b.text !== 'string' || b.text.trim() === '') throw new Error('text: the words of the note')
|
|
192
240
|
const name = typeof b.name === 'string' && b.name.trim() !== '' ? b.name.trim() : address
|
|
193
241
|
const from = typeof b.from === 'string' && b.from !== '' ? b.from : 'hub'
|
|
@@ -202,6 +250,8 @@ async function reviewRoute(req: Request, path: string, dir: string, unit: Review
|
|
|
202
250
|
return tagged(req, x.tag, () => ({ role: roleOf(dir), rows: boardOf(readAllCached(dir).items) }))
|
|
203
251
|
}
|
|
204
252
|
if (path === '/api/review/watchers' && req.method === 'GET') return Response.json(liveWatchers(dir), { headers: NO_STORE })
|
|
253
|
+
// who holds each thread and who hears it: the parties its holders name (review/parties.ts), the page draws the light
|
|
254
|
+
if (path === '/api/review/parties' && req.method === 'GET') return Response.json(await partiesOfStore(dir), { headers: NO_STORE })
|
|
205
255
|
// the unit's words, the dispatcher's holder: what the page draws the list's filters, labels and board with
|
|
206
256
|
if (path === '/api/review/spec' && req.method === 'GET') {
|
|
207
257
|
// where a card lives, for the paste that hands it to another agent session; a config that does not load leaves it out
|
|
@@ -269,6 +319,13 @@ async function reviewRoute(req: Request, path: string, dir: string, unit: Review
|
|
|
269
319
|
if (p && CLIP.test(p.file)) return ranged(req, p.file)
|
|
270
320
|
return p ? new Response(Bun.file(p.file), { headers: { 'Content-Type': 'image/webp', ...KEEP } }) : (unreached() ?? bad('no such image or clip', 404))
|
|
271
321
|
}
|
|
322
|
+
// the objects that hold the thread open, each checked now on local state, nothing written (review/holds-sync.ts)
|
|
323
|
+
const hd = /^\/api\/review\/([^/]+)\/holds$/.exec(path)
|
|
324
|
+
if (hd && req.method === 'GET') {
|
|
325
|
+
const t = threadOfId(decodeURIComponent(hd[1] ?? ''), indexOf(dir).threads)
|
|
326
|
+
if (!t) return bad('no such thread', 404)
|
|
327
|
+
return Response.json(await liveHolds(rootOfStore(dir), membersOf(t), specOf(dir)), { headers: NO_STORE })
|
|
328
|
+
}
|
|
272
329
|
const m = /^\/api\/review\/([^/]+)\/([^/]+)$/.exec(path)
|
|
273
330
|
if (!m) return null
|
|
274
331
|
const [, id = '', name = ''] = m
|
|
@@ -277,7 +334,21 @@ async function reviewRoute(req: Request, path: string, dir: string, unit: Review
|
|
|
277
334
|
if (name === 'answer') {
|
|
278
335
|
const b = (await req.json()) as Record<string, unknown>
|
|
279
336
|
if (typeof b.re !== 'string') throw new Error('re: the question or the proposal it answers')
|
|
280
|
-
|
|
337
|
+
const gone = supersededRefusal(membersOfItem(readAll(dir).items), id, b.re)
|
|
338
|
+
if (gone !== null) throw new Error(gone)
|
|
339
|
+
const opens = typeof b.value === 'string' && urlQuestion(dir, id, b.re) ? { opens: await opensWith(b.value) } : {}
|
|
340
|
+
const answer = answerAsk(dir, id, { re: b.re, ...(typeof b.option === 'number' ? { option: b.option } : {}), ...(b.apply === true ? { apply: true } : {}), ...(typeof b.field === 'string' ? { field: b.field } : {}), ...(typeof b.value === 'string' ? { value: b.value } : {}), ...(typeof b.text === 'string' ? { text: b.text } : {}), ...(typeof b.tick === 'boolean' ? { tick: b.tick } : {}), ...(typeof b.pick === 'number' ? { pick: b.pick } : {}), ...opens })
|
|
341
|
+
await (await import('./kind-apply.ts')).applyOnAnswer(rootOfStore(dir), dir, unit, id, answer)
|
|
342
|
+
return Response.json(answer, { headers: NO_STORE })
|
|
343
|
+
}
|
|
344
|
+
if (name === 'action') {
|
|
345
|
+
const b = (await req.json()) as Record<string, unknown>
|
|
346
|
+
if (typeof b.name !== 'string') throw new Error('name: the action he clicked')
|
|
347
|
+
return Response.json(postAction(dir, id, { name: b.name, ...(typeof b.text === 'string' ? { text: b.text } : {}), ...(typeof b.re === 'string' ? { re: b.re } : {}) }), { headers: NO_STORE })
|
|
348
|
+
}
|
|
349
|
+
if (name === 'lane') {
|
|
350
|
+
const b = (await req.json().catch(() => ({}))) as { text?: unknown }
|
|
351
|
+
return Response.json(await askLane(dir, id, b.text), { headers: NO_STORE })
|
|
281
352
|
}
|
|
282
353
|
if (name === 'attach') {
|
|
283
354
|
const b = (await req.json()) as Record<string, unknown>
|
|
@@ -285,15 +356,26 @@ async function reviewRoute(req: Request, path: string, dir: string, unit: Review
|
|
|
285
356
|
return Response.json(attachTo(dir, id, 'owner', b.address), { headers: NO_STORE })
|
|
286
357
|
}
|
|
287
358
|
if (name === 'feedback') {
|
|
288
|
-
const
|
|
289
|
-
const r = writeVerdict(dir, id, await req.json())
|
|
290
|
-
if (r.ok) void releaseFollows(dir, id, was)
|
|
359
|
+
const r = await ownerVerdict(dir, unit, id, await req.json())
|
|
291
360
|
return r.ok ? Response.json(r.message, { headers: NO_STORE }) : Response.json({ error: r.errors.join('\n'), errors: r.errors }, { status: 400, headers: NO_STORE })
|
|
292
361
|
}
|
|
362
|
+
if (name === 'item-verdict') return Response.json((await import('./verdict-write.ts')).writeItemVerdict(dir, id, await req.json()), { headers: NO_STORE })
|
|
293
363
|
// a click on his lit verdict: he takes it back, the card waits for him again (the CLI's reopen, by the owner)
|
|
364
|
+
// his close or reopen of the whole thread, by the verb its head takes (review/close.ts)
|
|
365
|
+
if (name === 'close') {
|
|
366
|
+
const b = (await req.json().catch(() => ({}))) as { how?: unknown; note?: unknown }
|
|
367
|
+
const how = CLOSE_HOWS.find((h) => h === b.how)
|
|
368
|
+
if (how === undefined) return bad(`how: one of ${CLOSE_HOWS.join(', ')}`, 400)
|
|
369
|
+
try {
|
|
370
|
+
const r = await closeThread(dir, id, how, typeof b.note === 'string' ? b.note : undefined, unit)
|
|
371
|
+
return Response.json(r, { headers: NO_STORE })
|
|
372
|
+
} catch (e) {
|
|
373
|
+
return bad((e as Error).message, 400)
|
|
374
|
+
}
|
|
375
|
+
}
|
|
294
376
|
if (name === 'reopen') {
|
|
295
377
|
const v = reopen(dir, id, { who: 'owner' })
|
|
296
|
-
if (!v) return bad(`${id}: no such
|
|
378
|
+
if (!v) return bad(`${id}: no such item, or no answer to take back`, 404)
|
|
297
379
|
void releaseFollows(dir, id, v.status)
|
|
298
380
|
return Response.json({ reopened: v.id }, { headers: NO_STORE })
|
|
299
381
|
}
|
|
@@ -339,6 +421,13 @@ async function reviewRoute(req: Request, path: string, dir: string, unit: Review
|
|
|
339
421
|
return bad(e)
|
|
340
422
|
}
|
|
341
423
|
}
|
|
424
|
+
// one side of a version of an object: the state its kind read when it was posted (threads-how-it-fits.md, The frame keys)
|
|
425
|
+
if (name === 'state') {
|
|
426
|
+
const x = readItem(dir, id)
|
|
427
|
+
const side = new URL(req.url).searchParams.get('side') ?? 'after'
|
|
428
|
+
const st = x?.item.states?.[side === 'before' ? 'before' : 'after']
|
|
429
|
+
return st ? Response.json(st, { headers: { ...NO_STORE, 'access-control-allow-origin': '*' } }) : bad(`${id}: no ${side} state`, 404)
|
|
430
|
+
}
|
|
342
431
|
// a kind's data view of one item, computed here: the page never runs the repo's code
|
|
343
432
|
if (name === 'view') {
|
|
344
433
|
try {
|
|
@@ -381,7 +470,7 @@ async function reviewRoute(req: Request, path: string, dir: string, unit: Review
|
|
|
381
470
|
}
|
|
382
471
|
|
|
383
472
|
/** the review and trailer routes of the repo at `root`; null for any other path */
|
|
384
|
-
export async function reviewRoutes(root: string, req: Request, path: string): Promise<Response | null> {
|
|
473
|
+
export async function reviewRoutes(root: string, req: Request, path: string, o: { storeSecret?: SecretStore; secretHeld?: HeldOf; tailnet?: TailnetWho } = {}): Promise<Response | null> {
|
|
385
474
|
if (!path.startsWith('/api/review') && !path.startsWith('/api/trailer')) return null
|
|
386
475
|
let opened: { dir: string; unit: ReviewUnit | null }
|
|
387
476
|
try {
|
|
@@ -390,7 +479,23 @@ export async function reviewRoutes(root: string, req: Request, path: string): Pr
|
|
|
390
479
|
return bad(`the repo's review unit does not load: ${(e as Error).message}`, 500)
|
|
391
480
|
}
|
|
392
481
|
try {
|
|
393
|
-
|
|
482
|
+
const snooze = /^\/api\/review\/([^/]+)\/snooze$/.exec(path)
|
|
483
|
+
if (snooze != null && req.method === 'POST') {
|
|
484
|
+
const b = (await req.json().catch(() => null)) as { until?: unknown } | null
|
|
485
|
+
const until = b?.until === null ? null : typeof b?.until === 'string' ? asideAt(b.until) : undefined
|
|
486
|
+
if (until === undefined || (b?.until !== null && until === null)) return bad('until: 2h, tomorrow, next-week, a date YYYY-MM-DD[THH:MM], or null to bring it back', 400)
|
|
487
|
+
try {
|
|
488
|
+
return Response.json(snoozeThread(opened.dir, snooze[1]!, { until, who: 'owner' }), { headers: NO_STORE })
|
|
489
|
+
} catch (e) {
|
|
490
|
+
return bad((e as Error).message, 400)
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
const r = (await secretRoutes(root, opened.dir, req, path, { ...(o.storeSecret ? { store: o.storeSecret } : {}), ...(o.secretHeld ? { held: o.secretHeld } : {}), ...(o.tailnet ? { who: o.tailnet } : {}) })) ?? (await reviewRoute(req, path, opened.dir, opened.unit)) ?? (await trailerRoutes(req, path, root, opened.dir))
|
|
494
|
+
// an ask's thread answered in full runs its check, which closes it on a pass (wiki tools/shipkit/threads-asks.md, An
|
|
495
|
+
// ask's thread); the secret route runs it itself, so its answer says the close
|
|
496
|
+
const answered = /^\/api\/review\/([^/]+)\/(answer|reply)$/.exec(path)
|
|
497
|
+
if (answered != null && req.method === 'POST' && r?.ok === true) await followAskThread(root, answered[1]!)
|
|
498
|
+
return r
|
|
394
499
|
} catch (e) {
|
|
395
500
|
// the cards' store refused while a walk of the daemon's file runs: a state the page shows, never an error page
|
|
396
501
|
if (!isStoreRefused(e)) throw e
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
// the secret field of a thread (wiki tools/shipkit/threads-asks.md, The secret field): GET its facts (the name, who
|
|
2
|
+
// reads it, whether a value is held, why this browser may not type it), POST the value once into the house secret
|
|
3
|
+
// manager. The value is read only after the gate, goes to the store command on stdin, and is never written, logged,
|
|
4
|
+
// thrown or answered: the thread keeps « stored as <name> », then an ask's thread answered in full runs its check
|
|
5
|
+
import { followAskThread } from '../asks/ask-store.ts'
|
|
6
|
+
import { accountProblem, storeValue } from '../collections/actions.ts'
|
|
7
|
+
import { heldOfAsks } from '../collections/providers.ts'
|
|
8
|
+
import type { Held, HeldOf } from '../secrets/held.ts'
|
|
9
|
+
import { managerStore, secretsWhere, type SecretStore } from '../secrets/manager.ts'
|
|
10
|
+
import { scopeHouse, whoReadsIn } from '../secrets/who-reads.ts'
|
|
11
|
+
import { secretRefusal } from '../serve/secret-gate.ts'
|
|
12
|
+
import type { TailnetWho } from '../serve/tailnet-caller.ts'
|
|
13
|
+
import { bad, NO_STORE } from './http.ts'
|
|
14
|
+
import { answerSecret, readAll, secretQuestion } from './store.ts'
|
|
15
|
+
import { supersededRefusal } from './supersede.ts'
|
|
16
|
+
import { askStateOf, membersOfItem, threadOfItem, threadsOf } from './threads.ts'
|
|
17
|
+
|
|
18
|
+
const ROUTE = /^\/api\/review\/([^/]+)\/secret$/
|
|
19
|
+
|
|
20
|
+
/** the longest value the field takes: a key, a token, a password; a key of many lines goes through sk secret set */
|
|
21
|
+
const VALUE_MAX = 16_384
|
|
22
|
+
|
|
23
|
+
/** the routes of a thread's secret field, null for any other path; `store` replaces the house secret manager in a test,
|
|
24
|
+
* `held` the store's read of a credential ask's names */
|
|
25
|
+
export async function secretRoutes(root: string, dir: string, req: Request, path: string, o: { store?: SecretStore; who?: TailnetWho; held?: HeldOf } = {}): Promise<Response | null> {
|
|
26
|
+
const m = ROUTE.exec(path)
|
|
27
|
+
if (m == null) return null
|
|
28
|
+
const id = m[1]!
|
|
29
|
+
if (req.method === 'GET') {
|
|
30
|
+
const re = new URL(req.url).searchParams.get('re') ?? ''
|
|
31
|
+
const q = secretQuestion(dir, id, re)
|
|
32
|
+
if ('error' in q) return bad(q.error, 404)
|
|
33
|
+
const [where, house] = await Promise.all([secretsWhere(root).catch(() => null), scopeHouse(root).catch(() => ({ repos: [], identities: [] }))])
|
|
34
|
+
const readers = whoReadsIn(q.name, where?.house?.creds, house)
|
|
35
|
+
const all: Record<string, Held> = await heldOfAsks([q.name], root).catch(() => ({}))
|
|
36
|
+
const held: Held = all[q.name] ?? { held: 'unknown', why: 'the store did not answer' }
|
|
37
|
+
const why = await secretRefusal(req, o.who ? { who: o.who } : {})
|
|
38
|
+
return Response.json({ name: q.name, login: q.login, readers: { words: readers.words, short: readers.short }, held, ...(why != null ? { refused: why } : {}) }, { headers: NO_STORE })
|
|
39
|
+
}
|
|
40
|
+
if (req.method !== 'POST') return bad('the secret field takes a GET of its facts and a POST of its value', 405)
|
|
41
|
+
const why = await secretRefusal(req, o.who ? { who: o.who } : {})
|
|
42
|
+
if (why != null) return bad(why, 403)
|
|
43
|
+
let b: unknown
|
|
44
|
+
try {
|
|
45
|
+
b = JSON.parse(await req.text())
|
|
46
|
+
} catch {
|
|
47
|
+
return bad('the body is no json object', 400)
|
|
48
|
+
}
|
|
49
|
+
if (typeof b !== 'object' || b === null || Array.isArray(b)) return bad('the body is no json object', 400)
|
|
50
|
+
const body = b as Record<string, unknown>
|
|
51
|
+
const re = typeof body.re === 'string' ? body.re : ''
|
|
52
|
+
const q = secretQuestion(dir, id, re)
|
|
53
|
+
if ('error' in q) return bad(q.error, 400)
|
|
54
|
+
const items = readAll(dir).items
|
|
55
|
+
const gone = supersededRefusal(membersOfItem(items), id, re)
|
|
56
|
+
if (gone !== null) return bad(gone, 400)
|
|
57
|
+
const t = threadOfItem(id, threadsOf(items))
|
|
58
|
+
const closed = t === null ? undefined : askStateOf(t)?.state
|
|
59
|
+
if (closed === 'done' || closed === 'declined') return bad(`${q.name}: its ask is ${closed}, nothing stored; reopen it to give a value`, 400)
|
|
60
|
+
const value = typeof body.value === 'string' ? body.value.trim() : ''
|
|
61
|
+
if (value === '') return bad(`${q.name}: an empty value is not stored`, 400)
|
|
62
|
+
if (value.length > VALUE_MAX) return bad(`${q.name}: longer than ${VALUE_MAX} characters; store it with sk secret set ${q.name} < <file>`, 400)
|
|
63
|
+
if (/[\r\n]/.test(value)) return bad(`${q.name}: a value of several lines; store it with sk secret set ${q.name} < <file>`, 400)
|
|
64
|
+
const account = typeof body.account === 'string' ? body.account.trim() : ''
|
|
65
|
+
if (q.login && account === '') return bad(`${q.name} is a login: its account too (the email or user name you sign in with), nothing stored`, 400)
|
|
66
|
+
if (!q.login && account !== '') return bad(`${q.name} is no login: it takes a value alone, nothing stored`, 400)
|
|
67
|
+
const problem = q.login ? accountProblem(account) : null
|
|
68
|
+
if (problem != null) return bad(`${q.name}: the account ${problem}, nothing stored`, 400)
|
|
69
|
+
try {
|
|
70
|
+
await storeValue({ root, name: q.name, value, account: q.login ? account : undefined, store: o.store ?? managerStore(root) })
|
|
71
|
+
} catch (e) {
|
|
72
|
+
// storeValue throws a fixed line that holds no value
|
|
73
|
+
return bad((e as Error).message, 502)
|
|
74
|
+
}
|
|
75
|
+
answerSecret(dir, id, { re })
|
|
76
|
+
// an ask whose every value is now in closes at once (wiki tools/shipkit/threads-asks.md, An ask's thread); its
|
|
77
|
+
// probe's output is never read back here, so a check that prints the value cannot answer it
|
|
78
|
+
const done = await followAskThread(root, id, o.held ? { held: o.held } : {})
|
|
79
|
+
return Response.json({ stored: q.name, ...(done != null ? { closed: done.why ?? 'done' } : {}) }, { headers: NO_STORE })
|
|
80
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
// a thread set aside until a time (wiki tools/shipkit/threads-asks.md, Snooze): his « set aside » from the hub, an
|
|
2
|
+
// agent's later day when it posts. The turn reads it from the clock (threads.ts asideUntil), and an ask whose thread it
|
|
3
|
+
// is reads its later day from the same message (asks/ask-store.ts), so the ask leaves every count until the same time
|
|
4
|
+
import { appendMessage, readAll, readItem } from './store.ts'
|
|
5
|
+
import { threadOfAddress, turnOf } from './threads.ts'
|
|
6
|
+
import type { Message } from './model.ts'
|
|
7
|
+
|
|
8
|
+
/** the moment a « set aside » word names, from `now`, local time: 2h, tomorrow (9:00), next-week (Monday 9:00), a date
|
|
9
|
+
* (9:00) or a date and time; null for a word it does not read */
|
|
10
|
+
export function asideAt(word: string, now = new Date()): Date | null {
|
|
11
|
+
const w = word.trim().toLowerCase()
|
|
12
|
+
const hours = /^(\d+)\s*h$/.exec(w)
|
|
13
|
+
if (hours) return new Date(now.getTime() + Number(hours[1]) * 3_600_000)
|
|
14
|
+
const at9 = (d: Date): Date => new Date(d.getFullYear(), d.getMonth(), d.getDate(), 9, 0, 0, 0)
|
|
15
|
+
if (w === 'tomorrow') return at9(new Date(now.getFullYear(), now.getMonth(), now.getDate() + 1))
|
|
16
|
+
if (w === 'next-week' || w === 'next week') return at9(new Date(now.getFullYear(), now.getMonth(), now.getDate() + (((8 - now.getDay()) % 7) || 7)))
|
|
17
|
+
const day = /^(\d{4})-(\d{2})-(\d{2})(?:[t ](\d{2}):(\d{2}))?$/.exec(w)
|
|
18
|
+
if (day) {
|
|
19
|
+
const d = new Date(Number(day[1]), Number(day[2]) - 1, Number(day[3]), day[4] ? Number(day[4]) : 9, day[5] ? Number(day[5]) : 0)
|
|
20
|
+
return Number.isNaN(d.getTime()) ? null : d
|
|
21
|
+
}
|
|
22
|
+
return null
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** sets the thread of item `id` aside until `until` (null: back now), by `who`; refused on a thread that is not his
|
|
26
|
+
* turn when he sets it aside */
|
|
27
|
+
export function snoozeThread(dir: string, id: string, o: { until: Date | null; who: string; now?: Date }): Message {
|
|
28
|
+
const x = readItem(dir, id)
|
|
29
|
+
if (!x) throw new Error(`no item ${id}`)
|
|
30
|
+
const now = o.now ?? new Date()
|
|
31
|
+
if (o.until !== null && o.until.getTime() <= now.getTime()) throw new Error('set aside until a time still ahead')
|
|
32
|
+
const own = x.item.on ?? ''
|
|
33
|
+
const t = own ? threadOfAddress(own, readAll(dir).items) : null
|
|
34
|
+
if (o.until !== null && o.who === 'owner' && t && turnOf(t, now) !== 'yours' && turnOf(t, now) !== 'aside') throw new Error('only a thread of your turn is set aside: this one waits on an agent')
|
|
35
|
+
const head = t?.head.item.id ?? id
|
|
36
|
+
const m = appendMessage(dir, head, { who: o.who, snooze: { until: o.until === null ? null : o.until.toISOString() } }, { now })
|
|
37
|
+
return m
|
|
38
|
+
}
|
package/src/review/stage-card.ts
CHANGED
|
@@ -145,8 +145,8 @@ const slugWords = (s: string): string => wordsOf(s).join('-').slice(0, 40).repla
|
|
|
145
145
|
/** the thread a card id belongs to, its versions head first */
|
|
146
146
|
function versionsOf(dir: string, id: string): ReviewItem[] {
|
|
147
147
|
const t = threadOfId(id, threadsOf(readAll(dir).items))
|
|
148
|
-
if (t == null) throw new Error(`no
|
|
149
|
-
if (t.head.item.origin.by !== 'agent') throw new Error(`${id} is no agent's
|
|
148
|
+
if (t == null) throw new Error(`no item ${id}`)
|
|
149
|
+
if (t.head.item.origin.by !== 'agent') throw new Error(`${id} is no agent's version: only a version's media is staged`)
|
|
150
150
|
return t.versions
|
|
151
151
|
}
|
|
152
152
|
|
|
@@ -165,7 +165,7 @@ export const mediaTagOf = (label: string): string => label.split(' ')[0]!.replac
|
|
|
165
165
|
export async function stageInputOf(dir: string, id: string, ask: StageAsk, font?: string): Promise<{ input: StageInput; pick: Stageable | null }> {
|
|
166
166
|
const s = stageOfCard(dir, id)
|
|
167
167
|
const pick = ask.pick === undefined ? (s.media[0] ?? null) : (s.media.find((m) => m.key === ask.pick) ?? null)
|
|
168
|
-
if (ask.pick !== undefined && pick == null) throw new Error(`the
|
|
168
|
+
if (ask.pick !== undefined && pick == null) throw new Error(`the version names no media ${ask.pick} (${s.media.map((m) => m.key).join(', ') || 'none'})`)
|
|
169
169
|
const whole = pick ? await stageFileOf(dir, pick, font) : null
|
|
170
170
|
if (ask.passage && pick?.kind !== 'clip') throw new Error('a passage is cut from a clip')
|
|
171
171
|
const file = whole && ask.passage ? cutPassage(whole, ask.passage.from, ask.passage.to) : whole
|
|
@@ -182,7 +182,7 @@ export async function stageInputOf(dir: string, id: string, ask: StageAsk, font?
|
|
|
182
182
|
...(ask.kindWhy ? { kindWhy: ask.kindWhy } : {}),
|
|
183
183
|
...(ask.slot ? { slot: ask.slot } : {}),
|
|
184
184
|
...(ask.tags ? { tags: ask.tags } : {}),
|
|
185
|
-
angle: `Staged from the
|
|
185
|
+
angle: `Staged from the version « ${s.title} » (${s.head})${pick ? `, ${pick.label}` : ''}${ask.passage ? `, ${ask.passage.from.toFixed(2)} s to ${ask.passage.to.toFixed(2)} s` : ''}.`,
|
|
186
186
|
headings: [{ id: 'short' }, ...(ask.place ? [{ id: ask.place.account, place: ask.place.place }] : [])],
|
|
187
187
|
}
|
|
188
188
|
return { input, pick }
|