@north-light/cli 0.3.529 → 0.3.531
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/dist/api/dto/lifecycle.d.ts +3 -1
- package/dist/api/dto/messages.d.ts +5 -3
- package/dist/builtin-memory/crouter-plugin/bundles-and-memory.md +1 -1
- package/dist/builtin-memory/crouter-plugin/commands.md +1 -1
- package/dist/clients/attach/session/connection.js +1 -1
- package/dist/clients/attach/session/reconnect.js +1 -1
- package/dist/clients/attach/viewer.js +508 -508
- package/dist/commands/node/message.js +1 -1
- package/dist/commands/sys/join.js +1 -1
- package/dist/core/async-array.d.ts +7 -0
- package/dist/core/async-array.js +1 -0
- package/dist/core/audit.d.ts +1 -1
- package/dist/core/audit.js +2 -2
- package/dist/core/canvas/attention.d.ts +4 -4
- package/dist/core/canvas/attention.js +1 -1
- package/dist/core/canvas/boot.d.ts +4 -4
- package/dist/core/canvas/boot.js +1 -1
- package/dist/core/canvas/canvas.d.ts +59 -59
- package/dist/core/canvas/canvas.js +19 -19
- package/dist/core/canvas/context-strip.js +2 -2
- package/dist/core/canvas/crons.d.ts +27 -27
- package/dist/core/canvas/crons.js +11 -11
- package/dist/core/canvas/daemon-actions.d.ts +10 -10
- package/dist/core/canvas/daemon-actions.js +8 -8
- package/dist/core/canvas/daemon-owner.d.ts +3 -3
- package/dist/core/canvas/daemon-owner.js +2 -2
- package/dist/core/canvas/db.d.ts +19 -30
- package/dist/core/canvas/db.js +3 -2
- package/dist/core/canvas/deliveries.d.ts +16 -16
- package/dist/core/canvas/deliveries.js +24 -24
- package/dist/core/canvas/executions.d.ts +8 -8
- package/dist/core/canvas/executions.js +1 -1
- package/dist/core/canvas/focuses.d.ts +8 -8
- package/dist/core/canvas/focuses.js +1 -1
- package/dist/core/canvas/history.d.ts +3 -3
- package/dist/core/canvas/history.js +9 -9
- package/dist/core/canvas/install-id.d.ts +1 -1
- package/dist/core/canvas/install-id.js +1 -1
- package/dist/core/canvas/managed-worktree-sweep-candidates.d.ts +1 -1
- package/dist/core/canvas/managed-worktree-sweep-candidates.js +2 -2
- package/dist/core/canvas/memory-reads.d.ts +6 -6
- package/dist/core/canvas/memory-reads.js +1 -1
- package/dist/core/canvas/nav-model.d.ts +13 -13
- package/dist/core/canvas/nav-model.js +1 -1
- package/dist/core/canvas/node-agent-paths.d.ts +6 -6
- package/dist/core/canvas/node-agent-paths.js +1 -1
- package/dist/core/canvas/node-tokens.d.ts +7 -7
- package/dist/core/canvas/node-tokens.js +3 -3
- package/dist/core/canvas/outcome-actions.d.ts +5 -5
- package/dist/core/canvas/outcome-actions.js +3 -3
- package/dist/core/canvas/recovery.d.ts +26 -26
- package/dist/core/canvas/recovery.js +2 -2
- package/dist/core/canvas/render-source.d.ts +1 -1
- package/dist/core/canvas/render-source.js +1 -1
- package/dist/core/canvas/sessions.d.ts +10 -10
- package/dist/core/canvas/sessions.js +4 -4
- package/dist/core/canvas/source.js +1 -1
- package/dist/core/canvas/structured-requests.d.ts +15 -15
- package/dist/core/canvas/structured-requests.js +5 -5
- package/dist/core/canvas/tree.d.ts +9 -9
- package/dist/core/canvas/tree.js +5 -5
- package/dist/core/canvas/waits.d.ts +13 -13
- package/dist/core/canvas/waits.js +6 -6
- package/dist/core/canvas/worktrees.d.ts +15 -15
- package/dist/core/canvas/worktrees.js +1 -1
- package/dist/core/command-hooks/lifecycle-catalog.d.ts +4 -4
- package/dist/core/command-hooks/lifecycle-catalog.js +1 -1
- package/dist/core/command-hooks/transport/exec-lifecycle.js +1 -1
- package/dist/core/command-plugins/bundle.d.ts +1 -1
- package/dist/core/command-plugins/bundle.js +1 -1
- package/dist/core/conversation-store/file-store.d.ts +7 -7
- package/dist/core/conversation-store/file-store.js +9 -9
- package/dist/core/conversation-store/index.d.ts +16 -14
- package/dist/core/conversation-store/index.js +1 -1
- package/dist/core/conversation-store/listener.js +5 -5
- package/dist/core/conversation-store/patch.d.ts +3 -1
- package/dist/core/conversation-store/patch.js +1 -1
- package/dist/core/directory/join.d.ts +1 -1
- package/dist/core/feed/feed.js +3 -3
- package/dist/core/feed/inbox.d.ts +2 -2
- package/dist/core/feed/inbox.js +1 -1
- package/dist/core/feed/messages.d.ts +11 -12
- package/dist/core/feed/messages.js +5 -5
- package/dist/core/feed/reports.d.ts +4 -4
- package/dist/core/feed/reports.js +2 -2
- package/dist/core/grants/cover.d.ts +1 -1
- package/dist/core/grants/cover.js +1 -1
- package/dist/core/grants/local.d.ts +1 -1
- package/dist/core/grants/local.js +1 -1
- package/dist/core/grants/mirror.d.ts +19 -19
- package/dist/core/grants/mirror.js +2 -2
- package/dist/core/grants/on-sync.d.ts +1 -1
- package/dist/core/grants/on-sync.js +1 -1
- package/dist/core/grants/remove.js +1 -1
- package/dist/core/grants/sync.js +1 -1
- package/dist/core/graph/access.d.ts +17 -17
- package/dist/core/graph/access.js +3 -3
- package/dist/core/graph/custom.d.ts +16 -16
- package/dist/core/graph/custom.js +9 -9
- package/dist/core/graph/deletion.d.ts +3 -7
- package/dist/core/graph/deletion.js +4 -4
- package/dist/core/graph/documents.d.ts +24 -27
- package/dist/core/graph/documents.js +7 -7
- package/dist/core/graph/edges.d.ts +13 -13
- package/dist/core/graph/edges.js +1 -1
- package/dist/core/graph/events.d.ts +7 -9
- package/dist/core/graph/events.js +8 -8
- package/dist/core/graph/exposures.d.ts +6 -6
- package/dist/core/graph/exposures.js +4 -4
- package/dist/core/graph/jobs.d.ts +6 -8
- package/dist/core/graph/jobs.js +2 -2
- package/dist/core/graph/kinds/action.js +1 -1
- package/dist/core/graph/kinds/custom.js +2 -2
- package/dist/core/graph/kinds/document.d.ts +1 -0
- package/dist/core/graph/kinds/document.js +4 -4
- package/dist/core/graph/kinds/dto.d.ts +2 -2
- package/dist/core/graph/kinds/dto.js +1 -1
- package/dist/core/graph/kinds/job.js +2 -2
- package/dist/core/graph/kinds/kind.d.ts +6 -8
- package/dist/core/graph/kinds/kind.js +1 -1
- package/dist/core/graph/kinds/node.js +5 -5
- package/dist/core/graph/kinds/owner.js +2 -2
- package/dist/core/graph/kinds/registry.d.ts +6 -9
- package/dist/core/graph/kinds/registry.js +1 -1
- package/dist/core/graph/names.d.ts +6 -6
- package/dist/core/graph/names.js +3 -3
- package/dist/core/graph/object-waits.d.ts +4 -7
- package/dist/core/graph/object-waits.js +1 -1
- package/dist/core/graph/objects.d.ts +14 -14
- package/dist/core/graph/objects.js +9 -9
- package/dist/core/graph/package-docs.d.ts +2 -7
- package/dist/core/graph/package-docs.js +5 -5
- package/dist/core/graph/package-kinds.d.ts +2 -5
- package/dist/core/graph/package-kinds.js +1 -1
- package/dist/core/graph/package-reconcile.d.ts +2 -5
- package/dist/core/graph/package-reconcile.js +1 -1
- package/dist/core/graph/reader.d.ts +18 -18
- package/dist/core/graph/reader.js +3 -3
- package/dist/core/graph/receivers.d.ts +4 -4
- package/dist/core/graph/receivers.js +5 -5
- package/dist/core/graph/repo-sync/exchange.d.ts +3 -7
- package/dist/core/graph/repo-sync/exchange.js +2 -2
- package/dist/core/graph/repo-sync/repos.d.ts +7 -5
- package/dist/core/graph/repo-sync/repos.js +3 -3
- package/dist/core/graph/repo-sync/sync.d.ts +3 -6
- package/dist/core/graph/repo-sync/sync.js +2 -2
- package/dist/core/graph/rules.d.ts +5 -5
- package/dist/core/graph/rules.js +3 -3
- package/dist/core/graph/spaces/app.js +1 -1
- package/dist/core/graph/spaces/index.d.ts +4 -5
- package/dist/core/graph/spaces/index.js +1 -1
- package/dist/core/graph/spaces/own-memory.d.ts +4 -4
- package/dist/core/graph/spaces/own-memory.js +1 -1
- package/dist/core/graph/spaces/person.js +3 -3
- package/dist/core/graph/spaces/repo.d.ts +1 -1
- package/dist/core/graph/spaces/repo.js +1 -1
- package/dist/core/graph/watches.d.ts +15 -15
- package/dist/core/graph/watches.js +10 -10
- package/dist/core/human/feedback-companion.d.ts +2 -2
- package/dist/core/human/feedback-companion.js +1 -1
- package/dist/core/human/feedback.d.ts +3 -3
- package/dist/core/human/feedback.js +1 -1
- package/dist/core/human/requests.d.ts +34 -33
- package/dist/core/human/requests.js +20 -20
- package/dist/core/human/scan.d.ts +2 -2
- package/dist/core/human/scan.js +1 -1
- package/dist/core/human/tickets.d.ts +9 -9
- package/dist/core/human/tickets.js +1 -1
- package/dist/core/llm/app-rungs.d.ts +1 -1
- package/dist/core/llm/app-rungs.js +1 -1
- package/dist/core/llm/run.js +1 -1
- package/dist/core/peer/directory.d.ts +1 -1
- package/dist/core/peer/directory.js +1 -1
- package/dist/core/peer/envelope.d.ts +3 -3
- package/dist/core/peer/envelope.js +1 -1
- package/dist/core/peer/home.d.ts +7 -7
- package/dist/core/peer/home.js +2 -2
- package/dist/core/peer/ingest.d.ts +6 -6
- package/dist/core/peer/ingest.js +1 -1
- package/dist/core/peer/outbox-store.d.ts +14 -14
- package/dist/core/peer/outbox-store.js +5 -5
- package/dist/core/peer/receiver.d.ts +2 -2
- package/dist/core/peer/receiver.js +1 -1
- package/dist/core/peer/stubs.d.ts +10 -10
- package/dist/core/peer/stubs.js +1 -1
- package/dist/core/providers/approval.d.ts +2 -2
- package/dist/core/providers/approval.js +2 -2
- package/dist/core/providers/audit.d.ts +3 -3
- package/dist/core/providers/audit.js +2 -2
- package/dist/core/providers/bundles.js +2 -2
- package/dist/core/providers/call.d.ts +2 -2
- package/dist/core/providers/call.js +1 -1
- package/dist/core/providers/files.d.ts +1 -1
- package/dist/core/providers/files.js +1 -1
- package/dist/core/providers/mint.js +1 -1
- package/dist/core/providers/receipts.d.ts +1 -1
- package/dist/core/providers/receipts.js +2 -2
- package/dist/core/review/birth.js +1 -1
- package/dist/core/review/comments.d.ts +19 -19
- package/dist/core/review/comments.js +5 -5
- package/dist/core/review/companion.d.ts +1 -1
- package/dist/core/review/companion.js +1 -1
- package/dist/core/review/document.d.ts +3 -3
- package/dist/core/review/document.js +2 -2
- package/dist/core/review/fork.js +2 -2
- package/dist/core/review/realize.js +1 -1
- package/dist/core/review/remap.d.ts +2 -2
- package/dist/core/review/remap.js +4 -4
- package/dist/core/review/stage.d.ts +1 -1
- package/dist/core/review/stage.js +1 -1
- package/dist/core/review/store.d.ts +21 -21
- package/dist/core/review/store.js +1 -1
- package/dist/core/runs/activity.d.ts +1 -1
- package/dist/core/runs/activity.js +5 -5
- package/dist/core/runs/confinement.d.ts +7 -7
- package/dist/core/runs/confinement.js +2 -2
- package/dist/core/runs/events.d.ts +12 -12
- package/dist/core/runs/events.js +4 -4
- package/dist/core/runs/operations.d.ts +11 -11
- package/dist/core/runs/operations.js +5 -5
- package/dist/core/runs/questions.d.ts +10 -10
- package/dist/core/runs/questions.js +3 -3
- package/dist/core/runtime/auth-reload.js +1 -1
- package/dist/core/runtime/bearings.d.ts +5 -5
- package/dist/core/runtime/bearings.js +6 -6
- package/dist/core/runtime/broker-inventory.js +1 -1
- package/dist/core/runtime/broker-request.js +1 -1
- package/dist/core/runtime/broker.js +1 -1
- package/dist/core/runtime/close.d.ts +3 -3
- package/dist/core/runtime/close.js +1 -1
- package/dist/core/runtime/deliver-live.js +1 -1
- package/dist/core/runtime/fleet.d.ts +2 -2
- package/dist/core/runtime/host.d.ts +3 -3
- package/dist/core/runtime/host.js +3 -3
- package/dist/core/runtime/kickoff.d.ts +12 -12
- package/dist/core/runtime/kickoff.js +17 -17
- package/dist/core/runtime/launch-target.d.ts +1 -1
- package/dist/core/runtime/launch-target.js +1 -1
- package/dist/core/runtime/ledger.d.ts +3 -3
- package/dist/core/runtime/ledger.js +3 -3
- package/dist/core/runtime/lifecycle.d.ts +1 -1
- package/dist/core/runtime/lifecycle.js +2 -2
- package/dist/core/runtime/memory-admission.js +1 -1
- package/dist/core/runtime/model-swap.d.ts +2 -2
- package/dist/core/runtime/model-swap.js +1 -1
- package/dist/core/runtime/node-read.d.ts +1 -1
- package/dist/core/runtime/node-read.js +2 -2
- package/dist/core/runtime/nodes.d.ts +6 -6
- package/dist/core/runtime/nodes.js +1 -1
- package/dist/core/runtime/outcome-document.d.ts +1 -1
- package/dist/core/runtime/outcome-document.js +1 -1
- package/dist/core/runtime/persona.d.ts +3 -3
- package/dist/core/runtime/persona.js +2 -2
- package/dist/core/runtime/placement.d.ts +11 -11
- package/dist/core/runtime/placement.js +1 -1
- package/dist/core/runtime/promote.d.ts +3 -3
- package/dist/core/runtime/promote.js +1 -1
- package/dist/core/runtime/recycle.js +1 -1
- package/dist/core/runtime/reopen.d.ts +21 -10
- package/dist/core/runtime/reopen.js +1 -1
- package/dist/core/runtime/reset.d.ts +4 -4
- package/dist/core/runtime/reset.js +1 -1
- package/dist/core/runtime/revive-all.d.ts +2 -2
- package/dist/core/runtime/revive-all.js +1 -1
- package/dist/core/runtime/revive.d.ts +4 -4
- package/dist/core/runtime/revive.js +2 -2
- package/dist/core/runtime/roadmap.d.ts +6 -6
- package/dist/core/runtime/roadmap.js +5 -5
- package/dist/core/runtime/session-branch.d.ts +1 -1
- package/dist/core/runtime/session-branch.js +1 -1
- package/dist/core/runtime/session-list-cache.js +1 -1
- package/dist/core/runtime/situational-live.js +1 -1
- package/dist/core/runtime/spawn.d.ts +2 -2
- package/dist/core/runtime/spawn.js +2 -2
- package/dist/core/runtime/stop-guard.d.ts +2 -2
- package/dist/core/runtime/stop-guard.js +3 -3
- package/dist/core/runtime/warm-pool.d.ts +2 -2
- package/dist/core/runtime/warm-pool.js +1 -1
- package/dist/core/spaces/mounts.d.ts +2 -2
- package/dist/core/spaces/mounts.js +1 -1
- package/dist/core/spaces/permissions.d.ts +1 -1
- package/dist/core/spaces/permissions.js +1 -1
- package/dist/core/spaces/process.d.ts +1 -1
- package/dist/core/spaces/process.js +1 -1
- package/dist/core/spaces/space.js +1 -1
- package/dist/core/spaces/stop.d.ts +3 -3
- package/dist/core/spaces/stop.js +2 -2
- package/dist/core/spaces/users.d.ts +6 -6
- package/dist/core/spaces/users.js +1 -1
- package/dist/core/storage/attachments.d.ts +2 -2
- package/dist/core/storage/attachments.js +1 -1
- package/dist/core/storage/shares.d.ts +2 -2
- package/dist/core/storage/shares.js +1 -1
- package/dist/core/storage/tables.d.ts +21 -21
- package/dist/core/storage/tables.js +3 -3
- package/dist/core/substrate/delivery/corpus.d.ts +5 -8
- package/dist/core/substrate/delivery/corpus.js +3 -3
- package/dist/core/substrate/delivery/deliver.d.ts +10 -15
- package/dist/core/substrate/delivery/deliver.js +3 -3
- package/dist/core/substrate/delivery/plan.d.ts +2 -12
- package/dist/core/substrate/delivery/plan.js +3 -3
- package/dist/core/substrate/delivery/render-boot.d.ts +4 -4
- package/dist/core/substrate/delivery/render-boot.js +18 -18
- package/dist/core/substrate/delivery/render-event.d.ts +7 -14
- package/dist/core/substrate/delivery/render-event.js +4 -4
- package/dist/core/substrate/subject.d.ts +2 -2
- package/dist/core/substrate/subject.js +1 -1
- package/dist/core/usage/ledger.d.ts +6 -6
- package/dist/core/usage/ledger.js +4 -4
- package/dist/core/worktree-close.js +4 -4
- package/dist/core/worktree-mutation-async.js +7 -7
- package/dist/core/worktree-quarantine.js +1 -1
- package/dist/core/worktree-sweep.d.ts +1 -1
- package/dist/core/worktree-sweep.js +6 -6
- package/dist/core/worktree.d.ts +5 -5
- package/dist/core/worktree.js +13 -13
- package/dist/daemon/analytics/compute.d.ts +2 -2
- package/dist/daemon/analytics/compute.js +1 -1
- package/dist/daemon/api/app-listener.d.ts +4 -4
- package/dist/daemon/api/app-listener.js +13 -13
- package/dist/daemon/api/bridge.js +5 -5
- package/dist/daemon/api/document-listener.js +6 -6
- package/dist/daemon/api/handlers/analytics.js +1 -1
- package/dist/daemon/api/handlers/attach.js +1 -1
- package/dist/daemon/api/handlers/bash-jobs.js +1 -1
- package/dist/daemon/api/handlers/bash.js +1 -1
- package/dist/daemon/api/handlers/broker-ops.d.ts +1 -1
- package/dist/daemon/api/handlers/broker-ops.js +1 -1
- package/dist/daemon/api/handlers/broker-recovery.d.ts +1 -1
- package/dist/daemon/api/handlers/broker-recovery.js +1 -1
- package/dist/daemon/api/handlers/broker-signals.d.ts +2 -2
- package/dist/daemon/api/handlers/broker-signals.js +2 -2
- package/dist/daemon/api/handlers/canvas.d.ts +1 -1
- package/dist/daemon/api/handlers/canvas.js +4 -4
- package/dist/daemon/api/handlers/chat-inventory.js +1 -1
- package/dist/daemon/api/handlers/crons.js +1 -1
- package/dist/daemon/api/handlers/custom-objects.d.ts +4 -4
- package/dist/daemon/api/handlers/custom-objects.js +3 -3
- package/dist/daemon/api/handlers/delivery-retry.js +1 -1
- package/dist/daemon/api/handlers/delivery.js +1 -1
- package/dist/daemon/api/handlers/docs.d.ts +4 -4
- package/dist/daemon/api/handlers/docs.js +1 -1
- package/dist/daemon/api/handlers/feedback-comments.js +3 -3
- package/dist/daemon/api/handlers/files.js +1 -1
- package/dist/daemon/api/handlers/focus.js +1 -1
- package/dist/daemon/api/handlers/health.js +3 -3
- package/dist/daemon/api/handlers/hook-exec.js +1 -1
- package/dist/daemon/api/handlers/human-requests.js +1 -1
- package/dist/daemon/api/handlers/inbox-page.d.ts +1 -1
- package/dist/daemon/api/handlers/inbox-page.js +1 -1
- package/dist/daemon/api/handlers/inbox.d.ts +1 -1
- package/dist/daemon/api/handlers/inbox.js +1 -1
- package/dist/daemon/api/handlers/llm.d.ts +1 -1
- package/dist/daemon/api/handlers/llm.js +3 -3
- package/dist/daemon/api/handlers/memory-reads.js +1 -1
- package/dist/daemon/api/handlers/memory.d.ts +5 -5
- package/dist/daemon/api/handlers/memory.js +5 -5
- package/dist/daemon/api/handlers/messages.js +2 -2
- package/dist/daemon/api/handlers/node-events.d.ts +2 -2
- package/dist/daemon/api/handlers/node-events.js +3 -3
- package/dist/daemon/api/handlers/node-outcomes.js +1 -1
- package/dist/daemon/api/handlers/node-records.js +2 -2
- package/dist/daemon/api/handlers/nodes.d.ts +1 -1
- package/dist/daemon/api/handlers/nodes.js +1 -1
- package/dist/daemon/api/handlers/objects.js +3 -3
- package/dist/daemon/api/handlers/package-docs.js +1 -1
- package/dist/daemon/api/handlers/plugin-app-token.d.ts +1 -1
- package/dist/daemon/api/handlers/plugin-app-token.js +1 -1
- package/dist/daemon/api/handlers/profiles.d.ts +3 -3
- package/dist/daemon/api/handlers/profiles.js +1 -1
- package/dist/daemon/api/handlers/providers.d.ts +1 -1
- package/dist/daemon/api/handlers/providers.js +1 -1
- package/dist/daemon/api/handlers/questions.js +1 -1
- package/dist/daemon/api/handlers/reports.d.ts +1 -1
- package/dist/daemon/api/handlers/reports.js +5 -5
- package/dist/daemon/api/handlers/review-comments.js +1 -1
- package/dist/daemon/api/handlers/reviews.js +1 -1
- package/dist/daemon/api/handlers/runs.js +1 -1
- package/dist/daemon/api/handlers/structured-requests.js +1 -1
- package/dist/daemon/api/handlers/subscriptions.js +1 -1
- package/dist/daemon/api/handlers/transfer.js +1 -1
- package/dist/daemon/api/map.d.ts +3 -3
- package/dist/daemon/api/map.js +1 -1
- package/dist/daemon/api/principal.d.ts +1 -1
- package/dist/daemon/api/principal.js +1 -1
- package/dist/daemon/api/reader.d.ts +5 -5
- package/dist/daemon/api/reader.js +1 -1
- package/dist/daemon/api/router.d.ts +5 -5
- package/dist/daemon/api/router.js +1 -1
- package/dist/daemon/api/server.js +1 -1
- package/dist/daemon/broker-signals/bus.d.ts +1 -1
- package/dist/daemon/broker-signals/bus.js +1 -1
- package/dist/daemon/companion-retire.js +1 -1
- package/dist/daemon/cron/armed-context.d.ts +2 -2
- package/dist/daemon/cron/armed-context.js +1 -1
- package/dist/daemon/cron/authority.d.ts +2 -2
- package/dist/daemon/cron/authority.js +1 -1
- package/dist/daemon/cron/disposition.js +1 -1
- package/dist/daemon/cron/ended.d.ts +1 -1
- package/dist/daemon/cron/ended.js +2 -2
- package/dist/daemon/cron/escalation.js +3 -3
- package/dist/daemon/cron/folders.d.ts +1 -1
- package/dist/daemon/cron/folders.js +1 -1
- package/dist/daemon/cron/held.d.ts +1 -1
- package/dist/daemon/cron/held.js +1 -1
- package/dist/daemon/cron/lease-recovery.d.ts +1 -1
- package/dist/daemon/cron/lease-recovery.js +1 -1
- package/dist/daemon/cron/passes.d.ts +2 -2
- package/dist/daemon/cron/passes.js +1 -1
- package/dist/daemon/cron/run-socket.d.ts +1 -1
- package/dist/daemon/cron/run-socket.js +1 -1
- package/dist/daemon/cron/settle.js +1 -1
- package/dist/daemon/cron/sinks.d.ts +1 -1
- package/dist/daemon/cron/sinks.js +2 -2
- package/dist/daemon/cron-run.d.ts +12 -3
- package/dist/daemon/cron-run.js +2 -2
- package/dist/daemon/crtrd.js +6 -6
- package/dist/daemon/delivery/run-delivery.js +1 -1
- package/dist/daemon/due-sources.d.ts +3 -3
- package/dist/daemon/due-sources.js +1 -1
- package/dist/daemon/due.d.ts +3 -3
- package/dist/daemon/due.js +7 -7
- package/dist/daemon/fleet.d.ts +2 -2
- package/dist/daemon/fleet.js +11 -11
- package/dist/daemon/human/finish.js +3 -3
- package/dist/daemon/human/settle.d.ts +1 -1
- package/dist/daemon/human/settle.js +1 -1
- package/dist/daemon/human/sweep.js +1 -1
- package/dist/daemon/joined-owner.d.ts +3 -3
- package/dist/daemon/joined-owner.js +1 -1
- package/dist/daemon/messaging/node-message.js +1 -1
- package/dist/daemon/park-activity.d.ts +2 -2
- package/dist/daemon/park-activity.js +1 -1
- package/dist/daemon/peer/authority.js +1 -1
- package/dist/daemon/peer/forward.d.ts +6 -6
- package/dist/daemon/peer/forward.js +1 -1
- package/dist/daemon/peer/handlers.js +1 -1
- package/dist/daemon/peer/ingress.d.ts +4 -4
- package/dist/daemon/peer/ingress.js +1 -1
- package/dist/daemon/peer/outbox.d.ts +2 -2
- package/dist/daemon/peer/outbox.js +1 -1
- package/dist/daemon/peer/relay-service.js +1 -1
- package/dist/daemon/plugin-objects/read-leaf.d.ts +2 -2
- package/dist/daemon/plugin-objects/read-leaf.js +2 -2
- package/dist/daemon/profile-delete.js +1 -1
- package/dist/daemon/readiness.d.ts +2 -2
- package/dist/daemon/readiness.js +1 -1
- package/dist/daemon/reconcilers/action-lane.d.ts +1 -1
- package/dist/daemon/reconcilers/action-lane.js +1 -1
- package/dist/daemon/reconcilers/bash-deadline.js +2 -2
- package/dist/daemon/reconcilers/broker-supervision.d.ts +1 -1
- package/dist/daemon/reconcilers/broker-supervision.js +4 -4
- package/dist/daemon/reconcilers/controller-death.d.ts +1 -1
- package/dist/daemon/reconcilers/controller-death.js +1 -1
- package/dist/daemon/reconcilers/cron-lane.d.ts +1 -1
- package/dist/daemon/reconcilers/cron-lane.js +1 -1
- package/dist/daemon/reconcilers/delivery-lane.d.ts +1 -1
- package/dist/daemon/reconcilers/delivery-lane.js +2 -2
- package/dist/daemon/reconcilers/fault-retry-backstop.d.ts +3 -3
- package/dist/daemon/reconcilers/fault-retry-backstop.js +1 -1
- package/dist/daemon/reconcilers/grove-instance-sweep.d.ts +2 -2
- package/dist/daemon/reconcilers/grove-instance-sweep.js +1 -1
- package/dist/daemon/reconcilers/live-obligation.d.ts +6 -6
- package/dist/daemon/reconcilers/live-obligation.js +1 -1
- package/dist/daemon/reconcilers/managed-worktree-sweep.js +1 -1
- package/dist/daemon/reconcilers/node-deadline.d.ts +1 -1
- package/dist/daemon/reconcilers/node-deadline.js +1 -1
- package/dist/daemon/reconcilers/node-lifecycle/freeze-lane.js +1 -1
- package/dist/daemon/reconcilers/node-lifecycle/respawn-policy.d.ts +3 -3
- package/dist/daemon/reconcilers/node-lifecycle/respawn-policy.js +1 -1
- package/dist/daemon/reconcilers/node-lifecycle/terminating.js +1 -1
- package/dist/daemon/reconcilers/node-lifecycle/tick.js +1 -1
- package/dist/daemon/reconcilers/node-lifecycle/wants-execution.d.ts +1 -1
- package/dist/daemon/reconcilers/node-lifecycle/wants-execution.js +1 -1
- package/dist/daemon/reconcilers/pending-review-submit.d.ts +1 -1
- package/dist/daemon/reconcilers/pending-review-submit.js +1 -1
- package/dist/daemon/reconcilers/storage-due-work.js +1 -1
- package/dist/daemon/reconcilers/storage-maintenance.d.ts +1 -1
- package/dist/daemon/reconcilers/storage-maintenance.js +2 -2
- package/dist/daemon/reconcilers/structured-request-lane.d.ts +1 -1
- package/dist/daemon/reconcilers/structured-request-lane.js +1 -1
- package/dist/daemon/review/comment-notify.js +2 -2
- package/dist/daemon/review/companion.d.ts +3 -3
- package/dist/daemon/review/companion.js +1 -1
- package/dist/daemon/review/finish.js +1 -1
- package/dist/daemon/review/sweep.js +1 -1
- package/dist/daemon/run-notices.d.ts +4 -4
- package/dist/daemon/run-notices.js +1 -1
- package/dist/daemon/runs/append-section.d.ts +2 -2
- package/dist/daemon/runs/append-section.js +2 -2
- package/dist/daemon/runs/observer.d.ts +2 -2
- package/dist/daemon/runs/observer.js +2 -2
- package/dist/daemon/structured-requests/boot.d.ts +1 -1
- package/dist/daemon/structured-requests/boot.js +1 -1
- package/dist/daemon/structured-requests/effects.js +1 -1
- package/dist/daemon/structured-requests/sidecar.d.ts +1 -1
- package/dist/daemon/structured-requests/sidecar.js +1 -1
- package/dist/launcher/run.js +1 -1
- package/dist/migrations/004-canvas-documents/apply.d.ts +3 -3
- package/dist/migrations/004-canvas-documents/apply.js +1 -1
- package/dist/migrations/004-canvas-documents/index.d.ts +2 -2
- package/dist/migrations/004-canvas-documents/index.js +2 -2
- package/dist/migrations/activation.js +2 -2
- package/docs/plugin/bundles-and-memory.md +1 -1
- package/docs/plugin/commands.md +1 -1
- package/docs/public-api.md +11 -0
- package/package.json +4 -3
- package/packages/crouter-identity/package.json +1 -1
- package/runtime.lock.json +12 -12
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
var
|
|
1
|
+
var y=Object.defineProperty;var o=(e,t)=>y(e,"name",{value:t,configurable:!0});import{canRead as O}from"./access.js";import{receiverForObject as T}from"./receivers.js";import{getByRowid as R}from"./objects.js";import{filterAsync as D,mapAsync as j}from"../async-array.js";const _=["spawn","job-start","ask"],I=["report.final","report.result","notice.>"];function S(e){return JSON.stringify(Object.fromEntries(e.map(t=>[String(t.threshold),t.delivery])))}o(S,"configToJson");function A(e){const t=JSON.parse(e);return Object.entries(t).map(([a,n])=>({threshold:Number(a),delivery:n})).sort((a,n)=>n.threshold-a.threshold)}o(A,"configFromJson");async function u(e,t,a){return await e.prepare("SELECT * FROM watches WHERE watcher = ? AND object = ?").get(t.rowid,a.rowid)}o(u,"watchRow");async function E(e,t){return await e.prepare("SELECT * FROM watch_subscriptions WHERE watch = ? ORDER BY rowid").all(t)}o(E,"subsOf");async function l(e,t){const a=await E(e,t);if(a.length===0){await e.prepare("DELETE FROM watches WHERE rowid = ?").run(t);return}const n=a.some(r=>_.includes(r.started_by))?1:0;await e.prepare("UPDATE watches SET in_tree = ? WHERE rowid = ? AND in_tree != ?").run(n,t,n)}o(l,"settle");function C(e,t){return e==="message"?I:t.patterns?.length?t.patterns:[">"]}o(C,"defaultPatterns");async function H(e,t,a,n,r={}){if(n==="fork")throw new Error("recordWatch: fork watches are made by copyWatchesForFork");if(t.type.includes(".")&&!await T(e,t))throw new Error(`custom object ${t.id} has no receiver`);const c=new Date().toISOString();await e.prepare(`INSERT INTO watches (watcher, object, in_tree, read_heads_key, created_at, link_app) VALUES (?, ?, 0, ?, ?, ?)
|
|
2
2
|
ON CONFLICT (watcher, object) DO UPDATE SET read_heads_key = COALESCE(excluded.read_heads_key, read_heads_key),
|
|
3
|
-
link_app = COALESCE(excluded.link_app, link_app)`).run(t.rowid,
|
|
4
|
-
VALUES (?, ?, ?, ?, ?, ?, ?)`);for(const
|
|
5
|
-
AND watch IN (SELECT rowid FROM watches WHERE object = ?) RETURNING watch`).all(t.rowid):
|
|
6
|
-
AND watch IN (SELECT rowid FROM watches WHERE object = ?) RETURNING watch`).all(`result:${
|
|
3
|
+
link_app = COALESCE(excluded.link_app, link_app)`).run(t.rowid,a.rowid,r.readHeadsKey??null,c,r.linkApp?.rowid??null);const i=await u(e,t,a),s=n==="message"?r.endsOn??"final":null,h=_.includes(n),w=await E(e,i.rowid),d=e.prepare(`INSERT INTO watch_subscriptions (watch, pattern, filter_json, config_json, started_by, ends_on, created_at)
|
|
4
|
+
VALUES (?, ?, ?, ?, ?, ?, ?)`);for(const f of C(n,r))w.some(p=>p.pattern===f&&(p.ends_on===null||p.ends_on===s)&&(!h||_.includes(p.started_by)))||await d.run(i.rowid,f,r.filter===void 0?null:JSON.stringify(r.filter),r.config?S(r.config):null,n,s,c);await l(e,i.rowid)}o(H,"recordWatch");async function M(e,t,a,n){await e.prepare("UPDATE watches SET link_app = ? WHERE watcher = ? AND object = ?").run(n.rowid,t.rowid,a.rowid)}o(M,"markLinkWatch");async function x(e,t,a,n){const r=await u(e,t,a);r&&(n===void 0?await e.prepare("DELETE FROM watch_subscriptions WHERE watch = ?").run(r.rowid):typeof n=="string"?await e.prepare("DELETE FROM watch_subscriptions WHERE watch = ? AND pattern = ?").run(r.rowid,n):await e.prepare("DELETE FROM watch_subscriptions WHERE watch = ? AND started_by = ?").run(r.rowid,n.startedBy),await l(e,r.rowid))}o(x,"unwatch");async function U(e,t,a,n,r){const c=await u(e,t,a),i=c?(await e.prepare("UPDATE watch_subscriptions SET config_json = ? WHERE watch = ? AND pattern = ?").run(r?S(r):null,c.rowid,n)).changes:0;if(Number(i)===0)throw new Error(`${t.id} has no subscription ${n} on ${a.id}`)}o(U,"setSubscriptionConfig");async function J(e,t,a){const n=typeof a=="string"?await e.prepare(`DELETE FROM watch_subscriptions WHERE started_by = 'message'
|
|
5
|
+
AND watch IN (SELECT rowid FROM watches WHERE object = ?) RETURNING watch`).all(t.rowid):await e.prepare(`DELETE FROM watch_subscriptions WHERE started_by = 'message' AND ends_on = ?
|
|
6
|
+
AND watch IN (SELECT rowid FROM watches WHERE object = ?) RETURNING watch`).all(`result:${a.result}`,t.rowid);for(const r of new Set(n.map(c=>c.watch)))await l(e,r)}o(J,"endMessageSubscriptions");async function g(e,t){const a=await R(e,t.watcher),n=await R(e,t.object);return!a||!n?null:{rowid:t.rowid,watcher:a,object:n,in_tree:t.in_tree===1,read_heads_key:t.read_heads_key,created_at:t.created_at,subscriptions:(await E(e,t.rowid)).map(r=>({rowid:r.rowid,pattern:r.pattern,started_by:r.started_by,ends_on:r.ends_on,created_at:r.created_at,filter:r.filter_json===null?null:JSON.parse(r.filter_json),config:r.config_json===null?null:A(r.config_json)}))}}o(g,"hydrate");async function N(e,t,a){const n=(await j(a,async r=>await g(e,r))).filter(r=>r!==null);return await D(n,async r=>await O(e,t,r.watcher)&&await O(e,t,r.object))}o(N,"visible");async function B(e,t,a){return await N(e,t,await e.prepare("SELECT * FROM watches WHERE watcher = ? ORDER BY rowid").all(a.rowid))}o(B,"watchesOf");async function Y(e,t,a){return await N(e,t,await e.prepare("SELECT * FROM watches WHERE object = ? ORDER BY rowid").all(a.rowid))}o(Y,"watchersOf");async function v(e,t){return(await e.prepare("SELECT o.id FROM watches w JOIN objects o ON o.rowid = w.watcher WHERE w.object = ? ORDER BY w.rowid").all(t.rowid)).map(a=>a.id)}o(v,"watcherIdsOf");async function P(e,t){return await e.prepare(`WITH RECURSIVE walk(rowid) AS (
|
|
7
7
|
SELECT ?
|
|
8
8
|
UNION
|
|
9
9
|
SELECT w.object FROM walk CROSS JOIN watches w INDEXED BY watches_tree_down ON w.watcher = walk.rowid AND w.in_tree = 1
|
|
10
10
|
) SELECT o.* FROM walk CROSS JOIN objects o ON o.rowid = walk.rowid
|
|
11
|
-
WHERE o.type = 'node' AND o.rowid != ?`).all(t.rowid,t.rowid)}
|
|
11
|
+
WHERE o.type = 'node' AND o.rowid != ?`).all(t.rowid,t.rowid)}o(P,"descendants");async function V(e,t){return await e.prepare(`WITH RECURSIVE walk(rowid) AS (
|
|
12
12
|
SELECT ?
|
|
13
13
|
UNION
|
|
14
14
|
SELECT w.watcher FROM walk CROSS JOIN watches w INDEXED BY watches_tree_up ON w.object = walk.rowid AND w.in_tree = 1
|
|
15
15
|
) SELECT o.* FROM walk CROSS JOIN objects o ON o.rowid = walk.rowid
|
|
16
|
-
WHERE o.type = 'node' AND o.rowid != ?`).all(t.rowid,t.rowid)}
|
|
17
|
-
WHERE w.object = ? AND w.in_tree = 1 ORDER BY w.rowid`).all(t.rowid)}
|
|
18
|
-
VALUES (?, ?, ?, ?, 'fork', ?, ?)`);for(const
|
|
19
|
-
ON CONFLICT (watcher, object) DO NOTHING`).run(
|
|
16
|
+
WHERE o.type = 'node' AND o.rowid != ?`).all(t.rowid,t.rowid)}o(V,"ancestors");async function $(e,t){return await e.prepare(`SELECT o.* FROM watches w INDEXED BY watches_tree_up CROSS JOIN objects o ON o.rowid = w.watcher
|
|
17
|
+
WHERE w.object = ? AND w.in_tree = 1 ORDER BY w.rowid`).all(t.rowid)}o($,"treeWatchersOf");async function G(e,t,a){const n=new Date().toISOString(),r=await e.prepare("SELECT * FROM watches WHERE watcher = ?").all(t.rowid),c=e.prepare(`INSERT INTO watch_subscriptions (watch, pattern, filter_json, config_json, started_by, ends_on, created_at)
|
|
18
|
+
VALUES (?, ?, ?, ?, 'fork', ?, ?)`);for(const i of r){if(i.object===a.rowid)continue;await e.prepare(`INSERT INTO watches (watcher, object, in_tree, read_heads_key, created_at) VALUES (?, ?, 0, ?, ?)
|
|
19
|
+
ON CONFLICT (watcher, object) DO NOTHING`).run(a.rowid,i.object,i.read_heads_key,n);const s=await u(e,a,{rowid:i.object}),h=await E(e,s.rowid);for(const w of await E(e,i.rowid))h.some(d=>d.pattern===w.pattern&&d.ends_on===w.ends_on)||await c.run(s.rowid,w.pattern,w.filter_json,w.config_json,w.ends_on,n);await l(e,s.rowid)}}o(G,"copyWatchesForFork");export{V as ancestors,A as configFromJson,S as configToJson,G as copyWatchesForFork,P as descendants,J as endMessageSubscriptions,M as markLinkWatch,H as recordWatch,U as setSubscriptionConfig,$ as treeWatchersOf,x as unwatch,v as watcherIdsOf,Y as watchersOf,B as watchesOf};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/** Hex sha256 of the ticket's page document, recorded at first comment so the
|
|
2
2
|
* settle-time completion can say whether the page changed during feedback. */
|
|
3
|
-
export declare function pageDocumentSha256(dir: string): string
|
|
3
|
+
export declare function pageDocumentSha256(dir: string): Promise<string>;
|
|
4
4
|
/** A companion node nothing on the ticket points at must not stay resident:
|
|
5
5
|
* the comment that would have bound it was refused, failed to commit, or lost
|
|
6
6
|
* the first-comment race to a concurrently recorded companion. */
|
|
7
|
-
export declare function discardFeedbackCompanion(nodeId: string): void
|
|
7
|
+
export declare function discardFeedbackCompanion(nodeId: string): Promise<void>;
|
|
8
8
|
/**
|
|
9
9
|
* Fork the sending node's current state into the ticket-bound companion and
|
|
10
10
|
* wait for its durable boundary bind. Throws on any failure — the caller
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var f=Object.defineProperty;var
|
|
1
|
+
var f=Object.defineProperty;var r=(e,o)=>f(e,"name",{value:o,configurable:!0});import{createHash as l}from"node:crypto";import{readFileSync as s}from"node:fs";import{getNode as w}from"../canvas/index.js";import{awaitCompanionBind as u,captureOrigin as h}from"../review/companion.js";import{COMPANION_BIND_DEADLINE_MS as t}from"../review/types.js";import{buildLaunchSpec as _}from"../runtime/launch.js";import{transition as N}from"../runtime/lifecycle.js";import{headlessBrokerHost as k}from"../runtime/host.js";import{spawnNode as b}from"../runtime/nodes.js";import{reviveNode as I}from"../runtime/revive.js";import{materializeSessionBranch as y}from"../runtime/session-branch.js";import{forkNodeLedger as S}from"../runtime/ledger.js";import{pagePath as a}from"./convention.js";import{selectedPageDir as c}from"./tickets.js";async function H(e){return l("sha256").update(s(a(await c(e),"jsx"))).digest("hex")}r(H,"pageDocumentSha256");async function x(e){try{await N(e,"cancel",{reason:"retired"}),k.teardown(e)}catch{}}r(x,"discardFeedbackCompanion");async function q(e){const o=await w(e.senderNodeId);if(o===null)throw new Error(`page sender was not found: ${e.senderNodeId}`);const d=await h(e.senderNodeId),n=await y(d),{launch:m}=_(o.kind,o.mode,{lifecycle:"resident",hasManager:!1,model:d.modelSpec,modelExact:!0,cwd:o.cwd,profileId:o.profile_id??null}),i=await b({kind:o.kind,mode:o.mode,lifecycle:"resident",cwd:o.cwd,profile_id:o.profile_id??null,parent:e.senderNodeId,creator:e.senderNodeId,subscribe:!1,forkFrom:n,forkSourceFile:n,modelOverride:d.modelSpec,reviewBinding:{kind:"page_feedback",review_id:e.ticketId,origin_node_id:e.senderNodeId,branch_file:n,target_file:a(await c(e.dir),"jsx")},name:`Feedback \xB7 ${e.title}`,launch:m});try{if(await S(i.node_id,e.senderNodeId),await I(i.node_id,{resume:!1,capacity:"refuse"}),!await u(i.node_id,t))throw new Error(`feedback companion did not bind within ${t}ms`)}catch(p){throw await x(i.node_id),p}return i.node_id}r(q,"realizeFeedbackCompanion");export{x as discardFeedbackCompanion,H as pageDocumentSha256,q as realizeFeedbackCompanion};
|
|
@@ -34,7 +34,7 @@ declare const pageFeedbackSchema: z.ZodObject<{
|
|
|
34
34
|
export type PageFeedbackComment = z.infer<typeof pageFeedbackCommentSchema>;
|
|
35
35
|
export type PageFeedback = z.infer<typeof pageFeedbackSchema>;
|
|
36
36
|
/** Read page feedback from the request row. */
|
|
37
|
-
export declare function readPageFeedback(dir: string): PageFeedback
|
|
37
|
+
export declare function readPageFeedback(dir: string): Promise<PageFeedback>;
|
|
38
38
|
export interface CreatePageFeedbackCommentInput {
|
|
39
39
|
quote: string;
|
|
40
40
|
context?: string;
|
|
@@ -56,7 +56,7 @@ export declare class PageFeedbackCommentAlreadyResolvedError extends Error {
|
|
|
56
56
|
constructor(commentId: string);
|
|
57
57
|
}
|
|
58
58
|
/** Append feedback in the request transaction; terminal rows reject it. */
|
|
59
|
-
export declare function createPageFeedbackComment(dir: string, input: CreatePageFeedbackCommentInput): PageFeedbackMutation
|
|
59
|
+
export declare function createPageFeedbackComment(dir: string, input: CreatePageFeedbackCommentInput): Promise<PageFeedbackMutation>;
|
|
60
60
|
/** Resolve one feedback comment in the request transaction. */
|
|
61
|
-
export declare function resolvePageFeedbackComment(dir: string, commentId: string): PageFeedbackMutation
|
|
61
|
+
export declare function resolvePageFeedbackComment(dir: string, commentId: string): Promise<PageFeedbackMutation>;
|
|
62
62
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var l=Object.defineProperty;var r=(t,e)=>l(t,"name",{value:e,configurable:!0});import{randomUUID as g}from"node:crypto";import{z as n}from"zod";import{withCanvasWrite as f}from"../canvas/db.js";import{getRequestByDirectory as h}from"./requests.js";const p="crtr.page-feedback/v1";function A(t){return`${t}/feedback-comments.json`}r(A,"pageFeedbackPath");const b=n.object({id:n.string().min(1),quote:n.string().min(1),context:n.string().optional(),note:n.string().min(1),status:n.enum(["open","resolved"]),createdAt:n.string().datetime({offset:!0}),resolvedAt:n.string().datetime({offset:!0}).optional()}).strict(),_=n.object({schema:n.literal(p),companionNodeId:n.string().min(1).optional(),firstCommentedSha256:n.string().min(1).optional(),comments:n.array(b)}).strict();function w(){return{schema:p,comments:[]}}r(w,"emptyFeedback");async function m(t){const e=await h(t);if(e===null||e.kind!=="page")throw new Error(`unknown page request directory: ${t}`);return e}r(m,"requestForDirectory");function u(t){if(t.feedback_json===null)return t.companion_node_id===null?w():{...w(),companionNodeId:t.companion_node_id};try{return _.parse(JSON.parse(t.feedback_json))}catch(e){throw new Error(`page feedback is malformed for ${t.request_id}`,{cause:e})}}r(u,"feedback");async function v(t){return u(await m(t))}r(v,"readPageFeedback");class E extends Error{static{r(this,"PageTicketTerminalError")}constructor(){super("ticket already has a terminal outcome")}}class S extends Error{static{r(this,"UnknownPageFeedbackCommentError")}constructor(e){super(`no feedback comment ${e} on this ticket`)}}class q extends Error{static{r(this,"PageFeedbackCommentAlreadyResolvedError")}constructor(e){super(`feedback comment ${e} is already resolved`)}}async function D(t,e){const a=await m(t);return await f(async d=>{const s=await d.prepare("SELECT * FROM human_requests WHERE request_id = ?").get(a.request_id);if(s===void 0)throw new Error(`human request disappeared: ${a.request_id}`);if(s.state!=="open")throw new E;const c={...a,feedback_json:s.feedback_json,companion_node_id:s.companion_node_id},o=u(c);o.companionNodeId===void 0&&e.companionNodeId!==void 0&&(o.companionNodeId=e.companionNodeId,e.firstCommentedSha256!==void 0&&(o.firstCommentedSha256=e.firstCommentedSha256));const i={id:g(),quote:e.quote,...e.context===void 0?{}:{context:e.context},note:e.note,status:"open",createdAt:new Date().toISOString()};return o.comments.push(i),_.parse(o),await d.prepare("UPDATE human_requests SET feedback_json = ?, companion_node_id = COALESCE(companion_node_id, ?), updated_at = ? WHERE request_id = ?").run(JSON.stringify(o),o.companionNodeId??null,new Date().toISOString(),a.request_id),{comment:i,feedback:o}})}r(D,"createPageFeedbackComment");async function I(t,e){const a=await m(t);return await f(async d=>{const s=await d.prepare("SELECT * FROM human_requests WHERE request_id = ?").get(a.request_id);if(s===void 0)throw new Error(`human request disappeared: ${a.request_id}`);if(s.state!=="open")throw new E;const c={...a,feedback_json:s.feedback_json,companion_node_id:s.companion_node_id},o=u(c),i=o.comments.find(k=>k.id===e);if(i===void 0)throw new S(e);if(i.status==="resolved")throw new q(e);return i.status="resolved",i.resolvedAt=new Date().toISOString(),await d.prepare("UPDATE human_requests SET feedback_json = ?, updated_at = ? WHERE request_id = ?").run(JSON.stringify(o),new Date().toISOString(),a.request_id),{comment:i,feedback:o}})}r(I,"resolvePageFeedbackComment");export{p as PAGE_FEEDBACK_SCHEMA,q as PageFeedbackCommentAlreadyResolvedError,E as PageTicketTerminalError,S as UnknownPageFeedbackCommentError,D as createPageFeedbackComment,A as pageFeedbackPath,v as readPageFeedback,I as resolvePageFeedbackComment};
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { DatabaseSync } from 'node:sqlite';
|
|
2
|
+
import { type CanvasDb } from '../canvas/db.js';
|
|
2
3
|
import { type PreparedPage } from './page-authoring.js';
|
|
3
4
|
import { type PageResponses } from './page-schema.js';
|
|
4
5
|
export type HumanRequestKind = 'page' | 'review';
|
|
@@ -86,52 +87,52 @@ export declare function publishPageRevision(dir: string, prepared: PreparedPage,
|
|
|
86
87
|
/** The SQL-selected page revision. There is no path-based fallback for page reads. */
|
|
87
88
|
export declare function presentationDir(request: HumanRequestRecord): string;
|
|
88
89
|
/** Creates one SQL-authoritative page request. `request_id` is optional for ordinary callers and frozen by cron creation. */
|
|
89
|
-
export declare function createPageRequest(input: CreatePageRequestInput): HumanRequestRecord
|
|
90
|
+
export declare function createPageRequest(input: CreatePageRequestInput): Promise<HumanRequestRecord>;
|
|
90
91
|
/** Claims a review idempotency key before companion realization. */
|
|
91
|
-
export declare function commitBindingRequest(input: NewReviewRequest): {
|
|
92
|
+
export declare function commitBindingRequest(input: NewReviewRequest): Promise<{
|
|
92
93
|
request_id: string;
|
|
93
94
|
won: boolean;
|
|
94
|
-
}
|
|
95
|
-
export declare function getRequest(requestId: string): HumanRequestRecord | null
|
|
96
|
-
export declare function getRequestByInboxTicket(ticketId: string): HumanRequestRecord | null
|
|
97
|
-
export declare function getRequestByDirectory(dir: string): HumanRequestRecord | null
|
|
98
|
-
export declare function getRequestByCompanion(nodeId: string): HumanRequestRecord | null
|
|
99
|
-
export declare function getRequestByIdempotencyKey(key: string): HumanRequestRecord | null
|
|
95
|
+
}>;
|
|
96
|
+
export declare function getRequest(requestId: string): Promise<HumanRequestRecord | null>;
|
|
97
|
+
export declare function getRequestByInboxTicket(ticketId: string): Promise<HumanRequestRecord | null>;
|
|
98
|
+
export declare function getRequestByDirectory(dir: string): Promise<HumanRequestRecord | null>;
|
|
99
|
+
export declare function getRequestByCompanion(nodeId: string): Promise<HumanRequestRecord | null>;
|
|
100
|
+
export declare function getRequestByIdempotencyKey(key: string): Promise<HumanRequestRecord | null>;
|
|
100
101
|
/** SQL for the node a page request belongs to: its requester, else, for a notice only (a page that takes no response
|
|
101
102
|
* and so has no requester), the node that sent it. `alias` is the human_requests table or alias. */
|
|
102
103
|
export declare const askingNodeSql: (alias: string) => string;
|
|
103
104
|
/** A page asked from a run of an app other than the terminal is that app's to show
|
|
104
105
|
* (daemon-operations §question.*: the terminal shows `app:terminal` runs' questions). */
|
|
105
106
|
export declare const NOT_OTHER_APP_QUESTION: string;
|
|
106
|
-
export declare function listOpenInboxRequests(): HumanRequestRecord[]
|
|
107
|
+
export declare function listOpenInboxRequests(): Promise<HumanRequestRecord[]>;
|
|
107
108
|
/** Every open request a person is being asked to act on: the inbox's set (`listOpenInboxRequests`), plus
|
|
108
109
|
* answerable pages kept out of the inbox. This is the set the attach viewer's inbox strip shows. */
|
|
109
|
-
export declare function listPendingAsks(): HumanRequestRecord[]
|
|
110
|
-
export declare function openRequestsByRequester(nodeId: string): HumanRequestRecord[]
|
|
111
|
-
export declare function hasOpenReplyBearingRequestByRequester(nodeId: string): boolean
|
|
110
|
+
export declare function listPendingAsks(): Promise<HumanRequestRecord[]>;
|
|
111
|
+
export declare function openRequestsByRequester(nodeId: string): Promise<HumanRequestRecord[]>;
|
|
112
|
+
export declare function hasOpenReplyBearingRequestByRequester(nodeId: string): Promise<boolean>;
|
|
112
113
|
/** Indexed attention projection: only open inbox-listed requests with a reply target keep a node wakeable. */
|
|
113
|
-
export declare function listOpenReplyBearingRequests(): HumanRequestRecord[]
|
|
114
|
-
export declare function listBindingRequests(): HumanRequestRecord[]
|
|
115
|
-
export declare function listSubmitRequestedRequests(): HumanRequestRecord[]
|
|
116
|
-
export declare function listUnprojectedReviews(): HumanRequestRecord[]
|
|
114
|
+
export declare function listOpenReplyBearingRequests(): Promise<HumanRequestRecord[]>;
|
|
115
|
+
export declare function listBindingRequests(): Promise<HumanRequestRecord[]>;
|
|
116
|
+
export declare function listSubmitRequestedRequests(): Promise<HumanRequestRecord[]>;
|
|
117
|
+
export declare function listUnprojectedReviews(): Promise<HumanRequestRecord[]>;
|
|
117
118
|
export declare function listRequests(filter?: {
|
|
118
119
|
kind?: HumanRequestKind;
|
|
119
120
|
state?: HumanRequestState;
|
|
120
121
|
requester_node_id?: string;
|
|
121
122
|
file?: string;
|
|
122
123
|
page_source_node_id?: string;
|
|
123
|
-
}): HumanRequestRecord[]
|
|
124
|
+
}): Promise<HumanRequestRecord[]>;
|
|
124
125
|
/** An indexed preflight preserves the old map-before-filter error for corrupt page JSON. */
|
|
125
|
-
export declare function hasPageResultException(): boolean
|
|
126
|
-
export declare function firstInvalidPageSpecification(): Pick<HumanRequestRecord, 'request_id' | 'specification_json'> | null
|
|
127
|
-
export declare function openRequest(requestId: string, openedAt: string): boolean
|
|
126
|
+
export declare function hasPageResultException(): Promise<boolean>;
|
|
127
|
+
export declare function firstInvalidPageSpecification(): Promise<Pick<HumanRequestRecord, 'request_id' | 'specification_json'> | null>;
|
|
128
|
+
export declare function openRequest(requestId: string, openedAt: string): Promise<boolean>;
|
|
128
129
|
/** A binding whose immutable branch disappeared never recaptures a new origin. */
|
|
129
|
-
export declare function cancelBindingRequest(requestId: string, at: string, reason: string): boolean
|
|
130
|
-
export declare function requestSubmit(requestId: string, at: string): boolean
|
|
130
|
+
export declare function cancelBindingRequest(requestId: string, at: string, reason: string): Promise<boolean>;
|
|
131
|
+
export declare function requestSubmit(requestId: string, at: string): Promise<boolean>;
|
|
131
132
|
/** The first-writer-wins terminal transition. Callers add obligations in this same `withCanvasWrite` boundary. */
|
|
132
|
-
export declare function settleRequestLocked(db:
|
|
133
|
-
export declare function setSettlementDeliveryMarksLocked(db:
|
|
134
|
-
export declare function setSubmitNoteDeliveryLocked(db:
|
|
133
|
+
export declare function settleRequestLocked(db: CanvasDb, args: SettleRequestArgs): Promise<HumanRequestRecord | null>;
|
|
134
|
+
export declare function setSettlementDeliveryMarksLocked(db: CanvasDb, requestId: string, marks: RequestSettlementMarks): Promise<void>;
|
|
135
|
+
export declare function setSubmitNoteDeliveryLocked(db: CanvasDb, requestId: string, deliveryId: string): Promise<boolean>;
|
|
135
136
|
export declare function revisePageRequest(requestId: string, values: {
|
|
136
137
|
presentation_dir: string;
|
|
137
138
|
specification_json: string;
|
|
@@ -139,14 +140,14 @@ export declare function revisePageRequest(requestId: string, values: {
|
|
|
139
140
|
subtitle: string | null;
|
|
140
141
|
inbox_listed: boolean;
|
|
141
142
|
settleable: boolean;
|
|
142
|
-
}): boolean
|
|
143
|
-
export declare function writeProgress(ticketId: string, responses: PageResponses): boolean
|
|
144
|
-
export declare function markProjected(requestId: string, at: string): void
|
|
145
|
-
export declare function markProjectionError(requestId: string, error: string): void
|
|
146
|
-
export declare function markCompanionRetired(requestId: string, at: string): void
|
|
147
|
-
export declare function readAnchorBase(requestId: string): {
|
|
143
|
+
}): Promise<boolean>;
|
|
144
|
+
export declare function writeProgress(ticketId: string, responses: PageResponses): Promise<boolean>;
|
|
145
|
+
export declare function markProjected(requestId: string, at: string): Promise<void>;
|
|
146
|
+
export declare function markProjectionError(requestId: string, error: string): Promise<void>;
|
|
147
|
+
export declare function markCompanionRetired(requestId: string, at: string): Promise<void>;
|
|
148
|
+
export declare function readAnchorBase(requestId: string): Promise<{
|
|
148
149
|
bytes: Buffer;
|
|
149
150
|
sha256: string;
|
|
150
|
-
} | null
|
|
151
|
-
export declare function replaceAnchorBaseLocked(db:
|
|
151
|
+
} | null>;
|
|
152
|
+
export declare function replaceAnchorBaseLocked(db: CanvasDb, requestId: string, bytes: Buffer, sha256: string): Promise<void>;
|
|
152
153
|
export declare function migrateHumanRequestsState(db: DatabaseSync): void;
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
var ue=Object.defineProperty;var
|
|
2
|
-
`),
|
|
1
|
+
var ue=Object.defineProperty;var r=(e,t)=>ue(e,"name",{value:t,configurable:!0});import{prepared as l}from"../sqlite-statements.js";import{createHash as le,randomBytes as L}from"node:crypto";import{existsSync as y,mkdirSync as D,readFileSync as Y,readdirSync as _e,realpathSync as j,statSync as pe,writeFileSync as me}from"node:fs";import{basename as k,join as _}from"node:path";import{z as d}from"zod";import{crtrHome as V,isSafeNodeId as fe,nodesRoot as b}from"../canvas/paths.js";import{withCanvasWrite as Q,openDb as c}from"../canvas/db.js";import{syncDirectory as Ee,syncFile as ye}from"../fs-utils.js";import{newNodeId as ge}from"../runtime/nodes.js";import{pageManifestPath as Ne,pageModulePath as he,pagePath as qe}from"./convention.js";import{preparePageSource as Te}from"./page-authoring.js";import{pageAwaitsResponse as be,pageDeliverySchema as Se,pageIsNoticeSql as we,validatePageManifest as z}from"./page-schema.js";import{appendWaitingOnUser as Ae}from"../runs/questions.js";function G(e){return e===1||e===!0}r(G,"bool");function Z(e){return{request_id:e.request_id,kind:e.kind,inbox_ticket_id:e.inbox_ticket_id,request_dir:e.request_dir,presentation_dir:e.presentation_dir,requester_node_id:e.requester_node_id,companion_node_id:e.companion_node_id,idempotency_key:e.idempotency_key,state:e.state,outcome:e.outcome,inbox_listed:G(e.inbox_listed),settleable:G(e.settleable),title:e.title,subtitle:e.subtitle,file:e.file,specification_json:e.specification_json,action_json:e.action_json,progress_json:e.progress_json,feedback_json:e.feedback_json,result_json:e.result_json,anchor_base_sha256:e.anchor_base_sha256,anchor_base_bytes:e.anchor_base_bytes===null?null:Buffer.from(e.anchor_base_bytes),created_at:e.created_at,opened_at:e.opened_at,submit_requested_at:e.submit_requested_at,settled_at:e.settled_at,settlement_delivery_id:e.settlement_delivery_id,action_delivery_id:e.action_delivery_id,submit_note_delivery_id:e.submit_note_delivery_id,projected_at:e.projected_at,projection_error:e.projection_error,companion_retired_at:e.companion_retired_at,updated_at:e.updated_at}}r(Z,"recordFromRow");async function h(e,t,...i){const s=await e.prepareUncached(`SELECT * FROM human_requests WHERE ${t}`).get(...i);return s===void 0?null:Z(s)}r(h,"one");async function q(e,t,i=[],s="created_at ASC, request_id ASC"){return(await e.prepareUncached(`SELECT * FROM human_requests WHERE ${t} ORDER BY ${s}`).all(...i)).map(Z)}r(q,"many");function ee(){return _(V(),"requests")}r(ee,"humanRequestsRoot");function C(e){if(!fe(e))throw new TypeError(`request_id must be a safe path segment: ${e}`);const t=ee();return D(t,{recursive:!0,mode:448}),_(j(t),e)}r(C,"requestDir");function U(){return L(32).toString("hex")}r(U,"randomTicketId");function P(e,t){return le("sha256").update(`${j(e)}\0${t}`,"utf8").digest("hex")}r(P,"legacyTicketId");const De={writeFile(e,t){me(e,t,{flag:"wx",mode:384})},syncFile:ye,syncDirectory:Ee};function Re(e){return _(e,"revisions")}r(Re,"revisionRoot");function te(e,t,i=De){D(e,{recursive:!0,mode:448});const s=Re(e);D(s,{recursive:!0,mode:448});const n=_(s,L(16).toString("hex"));D(n,{mode:448});const o=qe(n,t.manifest.dialect);if(i.writeFile(o,t.document),i.syncFile(o),t.manifest.dialect==="jsx"){const a=he(n);i.writeFile(a,t.module),i.syncFile(a)}const u=Ne(n);return i.writeFile(u,`${JSON.stringify(t.manifest,null,2)}
|
|
2
|
+
`),i.syncFile(u),i.syncDirectory(n),i.syncDirectory(s),i.syncDirectory(e),i.syncDirectory(ee()),n}r(te,"publishPageRevision");function it(e){if(e.kind!=="page"||e.presentation_dir===null)throw new Error(`page request has no selected presentation: ${e.request_id}`);return e.presentation_dir}r(it,"presentationDir");async function rt(e){const t=e.request_id??await ge(),i=C(t),s=te(i,e.prepared),n=new Date().toISOString(),o=e.prepared.manifest;return await Q(async u=>{await u.prepare(`
|
|
3
3
|
INSERT INTO human_requests (
|
|
4
4
|
request_id, kind, inbox_ticket_id, request_dir, presentation_dir, requester_node_id, state, inbox_listed,
|
|
5
5
|
settleable, title, subtitle, specification_json, action_json, created_at, updated_at
|
|
6
6
|
) VALUES (?, 'page', ?, ?, ?, ?, 'open', ?, ?, ?, ?, ?, ?, ?, ?)
|
|
7
|
-
`).run(t,e.inbox_ticket_id??U(),
|
|
7
|
+
`).run(t,e.inbox_ticket_id??U(),i,s,e.requester_node_id??null,o.delivery.inbox?1:0,o.delivery.inbox||o.delivery.reply?1:0,o.title,o.subtitle??null,JSON.stringify(o),e.action_json??null,n,n);const a=await h(u,"request_id = ?",t);if(a===null)throw new Error(`page request insert did not produce a row: ${t}`);return await Ae(u,a),a})}r(rt,"createPageRequest");async function st(e){return await Q(async t=>{const i=await t.prepare(`
|
|
8
8
|
INSERT INTO human_requests (
|
|
9
9
|
request_id, kind, inbox_ticket_id, request_dir, requester_node_id, companion_node_id,
|
|
10
10
|
idempotency_key, state, inbox_listed, settleable, title, subtitle, file,
|
|
11
11
|
specification_json, anchor_base_sha256, anchor_base_bytes, created_at, updated_at
|
|
12
12
|
) VALUES (?, 'review', ?, ?, ?, ?, ?, 'binding', ?, 1, ?, ?, ?, ?, ?, ?, ?, ?)
|
|
13
13
|
ON CONFLICT(idempotency_key) DO NOTHING
|
|
14
|
-
`).run(e.request_id,U(),e.request_dir,e.requester_node_id,e.companion_node_id,e.idempotency_key,e.inbox_listed?1:0,e.title??
|
|
15
|
-
AND n.run_id IS NOT NULL AND n.grantee IS NOT NULL AND n.grantee <> 'app:terminal'))`;function lt(){return
|
|
14
|
+
`).run(e.request_id,U(),e.request_dir,e.requester_node_id,e.companion_node_id,e.idempotency_key,e.inbox_listed?1:0,e.title??k(e.file),e.subtitle??null,e.file,JSON.stringify(e.specification),e.anchor_base_sha256,e.anchor_base_bytes,e.created_at,e.created_at),s=await h(t,"idempotency_key = ?",e.idempotency_key);if(s===null)throw new Error(`review binding insert did not produce a row: ${e.idempotency_key}`);return{request_id:s.request_id,won:i.changes>0}})}r(st,"commitBindingRequest");async function ot(e){return await h(await c(),"request_id = ?",e)}r(ot,"getRequest");async function at(e){return await h(await c(),"inbox_ticket_id = ?",e)}r(at,"getRequestByInboxTicket");async function dt(e){let t=e;try{t=j(e)}catch{}return await h(await c(),"request_dir = ?",t)}r(dt,"getRequestByDirectory");async function ct(e){return await h(await c(),"companion_node_id = ? AND state <> 'binding'",e)}r(ct,"getRequestByCompanion");async function ut(e){return await h(await c(),"idempotency_key = ?",e)}r(ut,"getRequestByIdempotencyKey");const ve=r(e=>`COALESCE(${e}.requester_node_id, CASE WHEN ${e}.kind = 'page' AND ${we(`${e}.specification_json`)} THEN json_extract(${e}.specification_json, '$.source.nodeId') END)`,"askingNodeSql"),ne=`NOT (kind = 'page' AND EXISTS (SELECT 1 FROM node_rows n WHERE n.node_id = ${ve("human_requests")}
|
|
15
|
+
AND n.run_id IS NOT NULL AND n.grantee IS NOT NULL AND n.grantee <> 'app:terminal'))`;async function lt(){return await q(await c(),`state = 'open' AND inbox_listed = 1 AND ${ne}`,[],"created_at DESC, request_id DESC")}r(lt,"listOpenInboxRequests");async function _t(){return(await q(await c(),`state = 'open' AND requester_node_id IS NOT NULL AND ((inbox_listed = 1 AND ${ne}) OR (kind = 'page' AND inbox_listed = 0 AND settleable = 1))`,[],"created_at ASC, request_id ASC")).filter(e=>e.inbox_listed||be(JSON.parse(e.specification_json)))}r(_t,"listPendingAsks");async function Oe(e){return await q(await c(),"state = 'open' AND requester_node_id = ?",[e],"created_at DESC, request_id DESC")}r(Oe,"openRequestsByRequester");async function pt(e){return(await Oe(e)).some(t=>t.kind==="review"?!0:JSON.parse(t.specification_json).delivery?.reply===!0)}r(pt,"hasOpenReplyBearingRequestByRequester");async function mt(){return await q(await c(),"state = 'open' AND inbox_listed = 1 AND requester_node_id IS NOT NULL",[],"created_at DESC, request_id DESC")}r(mt,"listOpenReplyBearingRequests");async function ft(){return await q(await c(),"kind = 'review' AND state = 'binding'")}r(ft,"listBindingRequests");async function Et(){return await q(await c(),"kind = 'review' AND state = 'open' AND submit_requested_at IS NOT NULL")}r(Et,"listSubmitRequestedRequests");async function yt(){return await q(await c(),"kind = 'review' AND state = 'settled' AND projected_at IS NULL")}r(yt,"listUnprojectedReviews");async function gt(e={}){const t=["1"],i=[];for(const[s,n]of Object.entries(e))n!==void 0&&(t.push(s==="page_source_node_id"?"CASE WHEN json_valid(specification_json) THEN json_extract(specification_json, '$.source.nodeId') END = ?":`${s} = ?`),i.push(n));return await q(await c(),t.join(" AND "),i)}r(gt,"listRequests");async function Nt(){return await(await c()).prepare(`
|
|
16
16
|
SELECT 1 FROM human_requests INDEXED BY idx_human_requests_page_result_exception
|
|
17
17
|
WHERE kind = 'page' AND result_json IS NOT NULL AND
|
|
18
18
|
CASE WHEN json_valid(result_json) THEN
|
|
@@ -20,37 +20,37 @@ var ue=Object.defineProperty;var i=(e,t)=>ue(e,"name",{value:t,configurable:!0})
|
|
|
20
20
|
AND json_type(result_json, '$.summary') IS NOT 'text'
|
|
21
21
|
ELSE 1 END
|
|
22
22
|
LIMIT 1
|
|
23
|
-
`).get()!==void 0}
|
|
23
|
+
`).get()!==void 0}r(Nt,"hasPageResultException");async function ht(){return await(await c()).prepare(`
|
|
24
24
|
SELECT request_id, specification_json FROM human_requests INDEXED BY idx_human_requests_page_invalid_spec
|
|
25
25
|
WHERE kind = 'page' AND (NOT json_valid(specification_json)
|
|
26
26
|
OR CASE WHEN json_valid(specification_json) THEN json_type(specification_json) != 'object' END)
|
|
27
27
|
ORDER BY created_at ASC, request_id ASC LIMIT 1
|
|
28
|
-
`).get()??null}
|
|
28
|
+
`).get()??null}r(ht,"firstInvalidPageSpecification");async function qt(e,t){return(await(await c()).prepare("UPDATE human_requests SET state = 'open', opened_at = ?, updated_at = ? WHERE request_id = ? AND state = 'binding'").run(t,t,e)).changes>0}r(qt,"openRequest");async function Tt(e,t,i){return(await(await c()).prepare(`
|
|
29
29
|
UPDATE human_requests SET state = 'settled', outcome = 'canceled', result_json = ?, settled_at = ?, updated_at = ?
|
|
30
30
|
WHERE request_id = ? AND kind = 'review' AND state = 'binding'
|
|
31
|
-
`).run(JSON.stringify({schema:"humanloop.cancel/v1",kind:"canceled",canceledAt:t,reason:
|
|
31
|
+
`).run(JSON.stringify({schema:"humanloop.cancel/v1",kind:"canceled",canceledAt:t,reason:i}),t,t,e)).changes>0}r(Tt,"cancelBindingRequest");async function bt(e,t){return(await(await c()).prepare("UPDATE human_requests SET submit_requested_at = ?, updated_at = ? WHERE request_id = ? AND kind = 'review' AND state = 'open' AND submit_requested_at IS NULL").run(t,t,e)).changes>0}r(bt,"requestSubmit");async function St(e,t){return(await e.prepare(`
|
|
32
32
|
UPDATE human_requests SET state = 'settled', outcome = ?, result_json = ?, settled_at = ?,
|
|
33
33
|
progress_json = NULL, updated_at = ?
|
|
34
34
|
WHERE request_id = ? AND state = 'open'
|
|
35
|
-
`).run(t.outcome,t.result_json,t.settled_at,t.settled_at,t.request_id).changes===0?null:
|
|
35
|
+
`).run(t.outcome,t.result_json,t.settled_at,t.settled_at,t.request_id)).changes===0?null:await h(e,"request_id = ?",t.request_id)}r(St,"settleRequestLocked");async function wt(e,t,i){await e.prepare("UPDATE human_requests SET settlement_delivery_id = ?, action_delivery_id = ?, updated_at = ? WHERE request_id = ?").run(i.settlement_delivery_id??null,i.action_delivery_id??null,new Date().toISOString(),t)}r(wt,"setSettlementDeliveryMarksLocked");async function At(e,t,i){return(await e.prepare("UPDATE human_requests SET submit_note_delivery_id = ?, updated_at = ? WHERE request_id = ? AND state = 'open' AND submit_note_delivery_id IS NULL").run(i,new Date().toISOString(),t)).changes>0}r(At,"setSubmitNoteDeliveryLocked");async function Dt(e,t){return(await(await c()).prepare(`
|
|
36
36
|
UPDATE human_requests SET presentation_dir = ?, specification_json = ?, title = ?, subtitle = ?, inbox_listed = ?, settleable = ?, updated_at = ?
|
|
37
37
|
WHERE request_id = ? AND kind = 'page' AND state = 'open'
|
|
38
|
-
`).run(t.presentation_dir,t.specification_json,t.title,t.subtitle,t.inbox_listed?1:0,t.settleable?1:0,new Date().toISOString(),e).changes>0
|
|
38
|
+
`).run(t.presentation_dir,t.specification_json,t.title,t.subtitle,t.inbox_listed?1:0,t.settleable?1:0,new Date().toISOString(),e)).changes>0}r(Dt,"revisePageRequest");async function Rt(e,t){return(await(await c()).prepare(`
|
|
39
39
|
UPDATE human_requests SET progress_json = ?, updated_at = ?
|
|
40
40
|
WHERE inbox_ticket_id = ? AND kind = 'page' AND state = 'open' AND settleable = 1
|
|
41
|
-
`).run(JSON.stringify({kind:"page",responses:t,savedAt:new Date().toISOString()}),new Date().toISOString(),e).changes>0
|
|
41
|
+
`).run(JSON.stringify({kind:"page",responses:t,savedAt:new Date().toISOString()}),new Date().toISOString(),e)).changes>0}r(Rt,"writeProgress");async function vt(e,t){await(await c()).prepare("UPDATE human_requests SET projected_at = ?, projection_error = NULL, updated_at = ? WHERE request_id = ?").run(t,t,e)}r(vt,"markProjected");async function Ot(e,t){await(await c()).prepare("UPDATE human_requests SET projection_error = ?, updated_at = ? WHERE request_id = ? AND projected_at IS NULL").run(t,new Date().toISOString(),e)}r(Ot,"markProjectionError");async function jt(e,t){await(await c()).prepare("UPDATE human_requests SET companion_retired_at = ?, updated_at = ? WHERE request_id = ? AND companion_retired_at IS NULL").run(t,t,e)}r(jt,"markCompanionRetired");async function It(e){const t=await(await c()).prepare("SELECT anchor_base_bytes, anchor_base_sha256 FROM human_requests WHERE request_id = ?").get(e);return t===void 0||t.anchor_base_bytes===null||t.anchor_base_sha256===null?null:{bytes:Buffer.from(t.anchor_base_bytes),sha256:t.anchor_base_sha256}}r(It,"readAnchorBase");async function xt(e,t,i,s){await e.prepare("UPDATE human_requests SET anchor_base_bytes = ?, anchor_base_sha256 = ?, updated_at = ? WHERE request_id = ?").run(i,s,new Date().toISOString(),t)}r(xt,"replaceAnchorBaseLocked");function je(e){if(typeof e!="object"||e===null)throw new Error("result is not an object");const t=e;return t.kind==="canceled"?{outcome:t.disposition==="dismissed"?"dismissed":"canceled",settledAt:String(t.canceledAt)}:{outcome:"answered",settledAt:String(t.completedAt)}}r(je,"legacyPageResult");function A(e){try{return JSON.parse(Y(e,"utf8"))}catch(t){throw new Error(`corrupt required input: ${e}`,{cause:t})}}r(A,"readJson");function H(){return L(16).toString("hex")}r(H,"migrationId");function Ie(e){return Number(l(e,"SELECT COALESCE(MAX(seq), 0) AS seq FROM messages").get().seq)+1}r(Ie,"nextMessageSeq");function xe(e,t,i,s){return(s==="page"?l(e,`SELECT d.delivery_id FROM deliveries d JOIN messages m ON m.message_id = d.message_id
|
|
42
42
|
WHERE d.destination_kind = 'node_inbox' AND d.destination_id = ? AND m.sender_node_id = ?
|
|
43
|
-
AND m.disposition IN ('human-answer', 'human-canceled') LIMIT 1`).get(
|
|
44
|
-
WHERE d.destination_kind = 'node_inbox' AND d.destination_id = ? AND m.body_json LIKE ? LIMIT 1`).get(
|
|
43
|
+
AND m.disposition IN ('human-answer', 'human-canceled') LIMIT 1`).get(i,t):l(e,`SELECT d.delivery_id FROM deliveries d JOIN messages m ON m.message_id = d.message_id
|
|
44
|
+
WHERE d.destination_kind = 'node_inbox' AND d.destination_id = ? AND m.body_json LIKE ? LIMIT 1`).get(i,`%"review_id":"${t}"%`))?.delivery_id??null}r(xe,"importedTerminalDelivery");function ie(e,t,i){if(t===null||i===null)return!1;const s=l(e,"SELECT status, final_report FROM nodes WHERE node_id = ?").get(t);return s?.status==="canceled"||i==="approved"&&s?.status==="done"&&s.final_report!==null}r(ie,"companionRetirementProven");function re(e){if(typeof e!="object"||e===null)return"no reason was given";const t=e.reason;return typeof t=="string"&&t!==""?t:"no reason was given"}r(re,"migratedCancellationReason");function Le(e,t){const i=e.outcome==="canceled"||e.outcome==="dismissed";return[e.kind==="review"?i?`Review ${e.requestId} was canceled \u2014 ${re(t)}.`:`Review ${e.requestId} was approved by the user.`:i?`Human request ${e.requestId} was canceled \u2014 ${re(t)}.`:`Human request ${e.requestId} was answered.`,...e.kind==="review"?[`The review result is at ${e.requestDir}/result.json.`]:[],`Result:
|
|
45
45
|
${JSON.stringify(t,null,2)}`].join(`
|
|
46
46
|
|
|
47
|
-
`)}
|
|
47
|
+
`)}r(Le,"migratedTerminalBody");function ke(e,t){const i=H(),s=H(),n=Date.parse(t.settledAt),o=Number.isFinite(n)?n:0,u=t.outcome==="answered"||t.outcome==="approved"?"human-answer":"human-canceled",a=JSON.parse(t.resultJson),p=Le(t,a);return l(e,`INSERT INTO messages
|
|
48
48
|
(message_id, seq, operation_id, created_at, sender_node_id, sender_name, kind, label, body_ref, body_json, disposition)
|
|
49
|
-
VALUES (?, ?, ?, ?, NULL, 'crtrd', 'completed', ?, NULL, ?, ?)`).run(
|
|
50
|
-
`,1)[0],JSON.stringify({body:p,result:
|
|
49
|
+
VALUES (?, ?, ?, ?, NULL, 'crtrd', 'completed', ?, NULL, ?, ?)`).run(i,Ie(e),H(),t.settledAt,p.split(`
|
|
50
|
+
`,1)[0],JSON.stringify({body:p,result:a}),u),l(e,`INSERT INTO deliveries
|
|
51
51
|
(delivery_id, message_id, destination_kind, destination_id, urgency, wake, state, attempts, created_at, updated_at)
|
|
52
|
-
VALUES (?, ?, 'node_inbox', ?, 'normal', 1, 'pending', 0, ?, ?)`).run(s,
|
|
53
|
-
`}
|
|
52
|
+
VALUES (?, ?, 'node_inbox', ?, 'normal', 1, 'pending', 0, ?, ?)`).run(s,i,t.requesterNodeId,o,o),s}r(ke,"createMigratedTerminalDelivery");function se(e,t){if(t.requesterNodeId===null||t.outcome===null||t.resultJson===null||t.settledAt===null)return null;const i=xe(e,t.requestId,t.requesterNodeId,t.kind);return i!==null?i:t.deliveredAt!==null&&t.deliveredAt!==void 0?null:ke(e,{requestId:t.requestId,requesterNodeId:t.requesterNodeId,kind:t.kind,outcome:t.outcome,resultJson:t.resultJson,settledAt:t.settledAt,requestDir:t.requestDir})}r(se,"terminalDeliveryMark");const Ce=d.object({sessionName:d.string().optional(),askedBy:d.string().optional(),blockedSince:d.string().optional(),profileName:d.string().optional(),nodeId:d.string().optional()}).strict(),Ue=d.object({id:d.string().regex(/^[A-Za-z0-9_-]{1,64}$/).optional(),kind:d.string().min(1),step:d.number().int().nonnegative(),config:d.record(d.string(),d.unknown()),unvalidated:d.literal(!0).optional(),display:d.literal(!0).optional()}).strict(),Pe=d.object({schema:d.literal("crtr.page/v1"),dialect:d.enum(["md","html","jsx"]),title:d.string().trim().min(1),subtitle:d.string().optional(),placement:d.enum(["inline","panel"]),document:d.enum(["page.md","page.html","page.tsx"]),steps:d.number().int().positive(),slots:d.array(Ue),source:Ce.optional()}).strict().superRefine((e,t)=>{const i=e.dialect==="md"?"page.md":e.dialect==="html"?"page.html":"page.tsx";e.document!==i&&t.addIssue({code:"custom",path:["document"],message:"document must agree with dialect"}),e.dialect==="md"&&e.steps!==1&&t.addIssue({code:"custom",path:["steps"],message:"md pages have exactly one step"})});function He(e){if(e.source===void 0)return;const{blockedSince:t,...i}=e.source,s={...i,...t!==void 0&&d.string().datetime({offset:!0}).safeParse(t).success?{emittedAt:t}:{}};return Object.keys(s).length===0?void 0:s}r(He,"legacyPresentationSource");function $e(e,t,i){return`export default function LegacyPage() { return <Page title={${JSON.stringify(e)}}${t===void 0?"":` subtitle={${JSON.stringify(t)}}`}><pre>{${JSON.stringify(i)}}</pre></Page>; }
|
|
53
|
+
`}r($e,"legacyReplayDocument");function oe(e){return Array.isArray(e.slots)?{...e,slots:e.slots.map(t=>{if(typeof t!="object"||t===null||Array.isArray(t))return t;const i=t;if(i.kind!=="text"||typeof i.config!="object"||i.config===null||Array.isArray(i.config))return t;const{editable:s,...n}=i.config;return{...i,config:n}})}:e}r(oe,"withoutLegacyTextEditable");function Xe(e,t){const i=_(e,"page.json"),s=Pe.safeParse(t);if(!s.success)throw new Error(s.error.message);const n=s.data,o=He(n),u={placement:n.placement,inbox:!0,reply:n.source?.blockedSince!==void 0};z(oe({schema:"crtr.page/v2",dialect:"jsx",title:n.title,...n.subtitle===void 0?{}:{subtitle:n.subtitle},delivery:u,document:"page.tsx",steps:n.steps,slots:n.slots,...o===void 0?{}:{source:o}}));const a=_(e,n.document);if(!y(a))throw new Error(`corrupt required input: ${a}`);const p=Y(a,"utf8"),f=Te({dialect:"jsx",document:$e(n.title,n.subtitle,p),source:o,delivery:u});if(o!==void 0)return f;const{source:E,...g}=f.manifest;return{...f,manifest:g}}r(Xe,"migrateLegacyPage");function Lt(e){e.exec(`
|
|
54
54
|
CREATE TABLE human_requests (
|
|
55
55
|
request_id TEXT PRIMARY KEY, kind TEXT NOT NULL CHECK (kind IN ('page','review')),
|
|
56
56
|
inbox_ticket_id TEXT NOT NULL UNIQUE, request_dir TEXT NOT NULL, presentation_dir TEXT,
|
|
@@ -73,10 +73,10 @@ ${JSON.stringify(t,null,2)}`].join(`
|
|
|
73
73
|
CREATE INDEX idx_human_requests_submit ON human_requests(state, submit_requested_at);
|
|
74
74
|
CREATE INDEX idx_human_requests_file ON human_requests(file);
|
|
75
75
|
CREATE INDEX idx_human_requests_requester ON human_requests(requester_node_id);
|
|
76
|
-
`);const t=
|
|
76
|
+
`);const t=l(e,`INSERT INTO human_requests (
|
|
77
77
|
request_id, kind, inbox_ticket_id, request_dir, presentation_dir, requester_node_id, companion_node_id, idempotency_key,
|
|
78
78
|
state, outcome, inbox_listed, settleable, title, subtitle, file, specification_json, action_json,
|
|
79
79
|
progress_json, feedback_json, result_json, anchor_base_sha256, anchor_base_bytes, created_at, opened_at,
|
|
80
80
|
submit_requested_at, settled_at, settlement_delivery_id, action_delivery_id, projected_at, projection_error,
|
|
81
81
|
companion_retired_at, updated_at
|
|
82
|
-
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);if(
|
|
82
|
+
) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`);if(l(e,"SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'reviews'").get()!==void 0){const s=l(e,"SELECT * FROM reviews").all();for(const n of s){const o=n.state,u=o==="approved"||o==="canceled",a=o==="canceled"&&n.result_json===null?JSON.stringify({schema:"humanloop.cancel/v1",kind:"canceled",canceledAt:n.canceled_at,...n.cancel_reason===""||n.cancel_reason===null?{}:{reason:n.cancel_reason},...n.cancel_actor===null?{}:{actor:n.cancel_actor}}):n.result_json;if(u&&a===null)throw new Error(`corrupt required input: reviews/${n.review_id} has no terminal result`);const p=n.bridge_node_id===null?_(V(),"reviews",n.review_id):_(b(),n.bridge_node_id),f={origin_kind:n.origin_kind,bridge_node_id:n.bridge_node_id,origin_session_file:n.origin_session_file,origin_session_id:n.origin_session_id,origin_leaf_id:n.origin_leaf_id,model_spec:n.model_spec,branch_file:n.branch_file,baseline_sha256:n.baseline_sha256,baseline_bytes:n.baseline_bytes,captured_at:n.captured_at,output_path:n.output_path},E=u?o==="approved"?"approved":"canceled":null,g=u?o==="approved"?n.approved_at:n.canceled_at:null,S=se(e,{requestId:n.review_id,requesterNodeId:n.origin_node_id,kind:"review",outcome:E,resultJson:a,settledAt:g,requestDir:p,deliveredAt:n.delivered_at}),R=ie(e,n.companion_node_id,E)?g:null;t.run(n.review_id,"review",n.origin_kind==="ticket"?P(b(),k(p)):U(),p,null,n.origin_node_id,n.companion_node_id,n.idempotency_key,u?"settled":o,E,n.origin_kind==="ticket"?1:0,1,k(n.file),n.subtitle,n.file,JSON.stringify(f),null,null,null,a,n.anchor_base_sha256,n.anchor_base_bytes,n.created,n.opened_at,n.submit_requested_at,g,S,null,n.projected_at,n.projection_error,R,n.created)}e.exec("DROP TABLE reviews")}for(const s of y(b())?_e(b(),{withFileTypes:!0}):[]){if(!s.isDirectory())continue;const n=_(b(),s.name),o=_(n,"page.json"),u=_(n,"review.json");if(!y(o)){if(y(u))continue;continue}if(l(e,"SELECT 1 FROM human_requests WHERE request_id = ?").get(s.name)!==void 0)continue;let a,p,f,E;try{const m=A(o);if(typeof m!="object"||m===null||Array.isArray(m))throw new Error("page manifest must be an object");a=m,a.schema==="crtr.page/v1"?(p=Xe(n,m),a=p.manifest):a.schema==="crtr.page/v2"&&(a=oe(a));const w=Se.safeParse(a.delivery);if(typeof a.title!="string"||!w.success)throw new Error(w.success?"page title must be a string":w.error.message);E=w.data,f=z(a)}catch(m){const w=m instanceof Error&&m.cause instanceof Error?m.cause.message:m instanceof Error?m.message:String(m);console.warn(`skipping legacy page ${o}: ${w}`);continue}let g=j(n);p!==void 0&&(g=te(C(s.name),p));const S=f.source,R=_(n,"response.json"),v=y(R)?A(R):null,N=v===null?null:je(v),ae=l(e,"SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'deliveries'").get()===void 0?null:l(e,"SELECT delivery_id FROM deliveries WHERE idempotency_key = ?").get(`human-action:${P(b(),s.name)}`),$=_(n,"action.json"),X=_(n,"progress.json"),I=_(n,"feedback-comments.json"),x=_(n,"reply-route.json"),T=y(I)?A(I):null;if(T!==null&&(typeof T!="object"||typeof T.companionNodeId<"u"&&typeof T.companionNodeId!="string"))throw new Error(`corrupt required input: ${I}`);const O=y(x)?A(x):null;if(O!==null&&(typeof O!="object"||typeof O.bridge_node_id!="string"))throw new Error(`corrupt required input: ${x}`);const M=O?.bridge_node_id,W=(typeof M!="string"||l(e,"SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'nodes'").get()===void 0?null:l(e,"SELECT parent FROM nodes WHERE node_id = ?").get(M))?.parent??(typeof S?.nodeId=="string"?S.nodeId:null),F=T?.companionNodeId,J=typeof S?.emittedAt=="string"?S.emittedAt:pe(o).mtime.toISOString(),B=v===null?null:JSON.stringify(v),de=se(e,{requestId:s.name,requesterNodeId:W,kind:"page",outcome:N?.outcome??null,resultJson:B,settledAt:N?.settledAt??null,requestDir:n}),ce=ie(e,F??null,N?.outcome??null)?N?.settledAt??null:null,K=C(s.name);D(K,{recursive:!0,mode:448}),t.run(s.name,"page",P(b(),s.name),K,g,W,F??null,null,N===null?"open":"settled",N?.outcome??null,E.inbox?1:0,E.inbox||E.reply?1:0,f.title,f.subtitle??null,null,JSON.stringify(f),y($)?JSON.stringify(A($)):null,y(X)&&N===null?JSON.stringify(A(X)):null,T===null?null:JSON.stringify(T),B,null,null,J,null,null,N?.settledAt??null,de,ae?.delivery_id??null,null,null,ce,J)}const i=l(e,"SELECT request_id FROM human_requests WHERE state = 'settled' AND result_json IS NULL").get();if(i!==void 0)throw new Error(`human request migration produced terminal row without result: ${i.request_id}`);if(l(e,"SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = 'review_comments'").get()!==void 0){const s=l(e,"SELECT review_id FROM review_comments WHERE review_id NOT IN (SELECT request_id FROM human_requests WHERE kind = 'review') LIMIT 1").get();if(s!==void 0)throw new Error(`review comment has no migrated review request: ${s.review_id}`)}}r(Lt,"migrateHumanRequestsState");export{ne as NOT_OTHER_APP_QUESTION,ve as askingNodeSql,Tt as cancelBindingRequest,st as commitBindingRequest,rt as createPageRequest,ht as firstInvalidPageSpecification,ot as getRequest,ct as getRequestByCompanion,dt as getRequestByDirectory,ut as getRequestByIdempotencyKey,at as getRequestByInboxTicket,pt as hasOpenReplyBearingRequestByRequester,Nt as hasPageResultException,ee as humanRequestsRoot,ft as listBindingRequests,lt as listOpenInboxRequests,mt as listOpenReplyBearingRequests,_t as listPendingAsks,gt as listRequests,Et as listSubmitRequestedRequests,yt as listUnprojectedReviews,jt as markCompanionRetired,vt as markProjected,Ot as markProjectionError,Lt as migrateHumanRequestsState,qt as openRequest,Oe as openRequestsByRequester,it as presentationDir,te as publishPageRevision,It as readAnchorBase,xt as replaceAnchorBaseLocked,C as requestDir,bt as requestSubmit,Dt as revisePageRequest,wt as setSettlementDeliveryMarksLocked,At as setSubmitNoteDeliveryLocked,St as settleRequestLocked,Rt as writeProgress};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { PageTicketSummary, TicketSummary } from './types.js';
|
|
2
2
|
/** SQL-backed inbox discovery. Files in request_dir are presentation projections only. */
|
|
3
|
-
export declare function scanInbox(): TicketSummary[]
|
|
3
|
+
export declare function scanInbox(): Promise<TicketSummary[]>;
|
|
4
4
|
export type PageHistoryEntry = PageTicketSummary;
|
|
5
5
|
/** SQL-backed page history, including terminal requests. */
|
|
6
|
-
export declare function scanPageHistory(nodeId?: string): PageHistoryEntry[]
|
|
6
|
+
export declare function scanPageHistory(nodeId?: string): Promise<PageHistoryEntry[]>;
|
package/dist/core/human/scan.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var l=Object.defineProperty;var n=(e,t)=>l(e,"name",{value:t,configurable:!0});import{pageAwaitsResponse as p,pageOverviewActions as u}from"./page-schema.js";import{firstInvalidPageSpecification as m,hasPageResultException as f,listOpenInboxRequests as _,listRequests as g}from"./requests.js";function
|
|
1
|
+
var l=Object.defineProperty;var n=(e,t)=>l(e,"name",{value:t,configurable:!0});import{pageAwaitsResponse as p,pageOverviewActions as u}from"./page-schema.js";import{firstInvalidPageSpecification as m,hasPageResultException as f,listOpenInboxRequests as _,listRequests as g}from"./requests.js";function c(e){try{const t=JSON.parse(e.specification_json);if(typeof t!="object"||t===null)throw new Error("not an object");return t}catch(t){throw new Error(`corrupt human request specification: ${e.request_id}`,{cause:t})}}n(c,"specification");function d(e){const t=c(e),{recommendedOptions:i,fastAction:o}=u(t),a=e.result_json===null?null:JSON.parse(e.result_json),s=e.state!=="settled"?e.settleable?"pending":"passive":e.outcome==="canceled"||e.outcome==="dismissed"?"canceled":"resolved";return{dir:e.request_dir,id:e.request_id,inboxTicketId:e.inbox_ticket_id,kind:"page",title:e.title,subtitle:e.subtitle??"",dialect:t.dialect,placement:t.delivery.placement,inbox:e.inbox_listed,steps:t.steps,slotKinds:t.slots.map(r=>r.kind),awaitsResponse:p(t),source:t.source??{},emittedAt:typeof t.source?.emittedAt=="string"?t.source.emittedAt:e.created_at,recommendedOptions:i,...o===void 0||s!=="pending"?{}:{fastAction:o},state:s,...a?.kind==="page"?{answerDigest:a.summary.replace(/\s+/g," ").trim()}:{}}}n(d,"pageSummary");function k(e){const t=c(e),i={nodeId:e.requester_node_id??void 0};return{dir:e.request_dir,id:e.request_id,inboxTicketId:e.inbox_ticket_id,kind:"review",title:e.title,subtitle:e.subtitle??"",file:e.file??"",output:typeof t.output_path=="string"?t.output_path:`${e.request_dir}/result.json`,source:i,blockedSince:e.created_at}}n(k,"reviewSummary");async function y(){return(await _()).map(e=>e.kind==="page"?d(e):k(e)).sort((e,t)=>(t.kind==="page"?t.emittedAt:t.blockedSince).localeCompare(e.kind==="page"?e.emittedAt:e.blockedSince)||e.id.localeCompare(t.id))}n(y,"scanInbox");async function A(e){const t=e!==void 0&&(await m()!==null||await f());return(await g({kind:"page",page_source_node_id:t?void 0:e})).map(d).filter(i=>!t||i.source.nodeId===e).sort((i,o)=>Date.parse(i.emittedAt)-Date.parse(o.emittedAt)||i.id.localeCompare(o.id))}n(A,"scanPageHistory");export{y as scanInbox,A as scanPageHistory};
|
|
@@ -4,26 +4,26 @@ import { type PageManifest, type PageResponses } from './page-schema.js';
|
|
|
4
4
|
/** Strict decoder for the canonical SQL terminal result. A corrupt result throws
|
|
5
5
|
* rather than being treated as absent, because that would hide data loss from
|
|
6
6
|
* the caller that owns the failure boundary. */
|
|
7
|
-
export declare function readTicketResult(dir: string): TicketResult | null
|
|
7
|
+
export declare function readTicketResult(dir: string): Promise<TicketResult | null>;
|
|
8
8
|
/** Publish an immutable revision, then atomically select it with its matching specification. */
|
|
9
|
-
export declare function publishPage(dir: string, prepared: PreparedPage): {
|
|
9
|
+
export declare function publishPage(dir: string, prepared: PreparedPage): Promise<{
|
|
10
10
|
id: string;
|
|
11
11
|
dir: string;
|
|
12
12
|
kind: 'page';
|
|
13
13
|
manifest: PageManifest;
|
|
14
|
-
}
|
|
14
|
+
}>;
|
|
15
15
|
/** Resolve a stable request directory to the SQL-selected immutable page revision. */
|
|
16
|
-
export declare function selectedPageDir(dir: string): string
|
|
16
|
+
export declare function selectedPageDir(dir: string): Promise<string>;
|
|
17
17
|
/** Validate a final page response against its ticket's reply contract. */
|
|
18
18
|
export declare function validateFinalPageResponses(manifest: PageManifest, responses: unknown): PageResponses;
|
|
19
19
|
/** Validate a page resolution against its SQL-selected immutable revision. */
|
|
20
|
-
export declare function validatePageTicketResponses(dir: string, responses: unknown): PageResponses
|
|
20
|
+
export declare function validatePageTicketResponses(dir: string, responses: unknown): Promise<PageResponses>;
|
|
21
21
|
/** Page state is derived from the SQL request row. */
|
|
22
|
-
export declare function pageTicketState(dir: string): 'pending' | 'resolved' | 'canceled' | 'passive'
|
|
22
|
+
export declare function pageTicketState(dir: string): Promise<'pending' | 'resolved' | 'canceled' | 'passive'>;
|
|
23
23
|
/** Autosave partial page work. Every supplied response is validated; omitted components are permitted. */
|
|
24
|
-
export declare function writePageProgress(dir: string, responses: unknown): PageResponses
|
|
24
|
+
export declare function writePageProgress(dir: string, responses: unknown): Promise<PageResponses>;
|
|
25
25
|
/** Saved partial work from the request row, or null when none exists. */
|
|
26
|
-
export declare function readPageProgress(dir: string): PageResponses | null
|
|
26
|
+
export declare function readPageProgress(dir: string): Promise<PageResponses | null>;
|
|
27
27
|
export interface PageTicket {
|
|
28
28
|
dir: string;
|
|
29
29
|
id: string;
|
|
@@ -36,7 +36,7 @@ export interface PageTicket {
|
|
|
36
36
|
progress: PageResponses | null;
|
|
37
37
|
}
|
|
38
38
|
/** Read one addressable page ticket — pending, resolved or canceled alike. */
|
|
39
|
-
export declare function readPageTicket(dir: string): PageTicket
|
|
39
|
+
export declare function readPageTicket(dir: string): Promise<PageTicket>;
|
|
40
40
|
export interface CompletePageOptions {
|
|
41
41
|
completedAt?: string;
|
|
42
42
|
actor?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var b=Object.defineProperty;var i=(t,e)=>b(t,"name",{value:e,configurable:!0});import{mkdirSync as y,readFileSync as d,realpathSync as q}from"node:fs";import{basename as _,isAbsolute as P,resolve as k}from"node:path";import{z as n}from"zod";import{pageModulePath as R,pagePath as S}from"./convention.js";import{parsePage as p}from"./page.js";import{validatePageResponses as E,validatePartialPageResponses as m}from"./page-schema.js";import{signalInboxActivity as g}from"./root.js";import{createPageRequest as x,getRequestByDirectory as l,presentationDir as f,publishPageRevision as j,revisePageRequest as A,writeProgress as T}from"./requests.js";const $=n.object({id:n.string().min(1),line:n.number().int().positive(),endLine:n.number().int().positive(),quote:n.string().optional(),colStart:n.number().int().nonnegative().optional(),colEnd:n.number().int().nonnegative().optional(),lineText:n.string(),comment:n.string().min(1),createdAt:n.string().min(1)}).strict(),o=n.string().datetime({offset:!0}),I=n.object({file:n.string().min(1).refine(P,"file must be absolute").refine(t=>k(t)===t,"file must be canonical"),submitted:n.literal(!0),approved:n.boolean(),comments:n.array($),submittedAt:o,savedAt:o,reviewId:n.string().optional(),changed:n.boolean().optional(),baselineSha256:n.string().optional(),approvedSha256:n.string().optional(),companionNodeId:n.string().optional(),commentsTotal:n.number().int().nonnegative().optional(),commentsUnresolved:n.number().int().nonnegative().optional()}).strict().superRefine((t,e)=>{t.comments.forEach((r,s)=>{r.endLine<r.line&&e.addIssue({code:"custom",message:"endLine must be >= line",path:["comments",s,"endLine"]}),r.colStart===void 0!=(r.colEnd===void 0)&&e.addIssue({code:"custom",message:"columns must be supplied together",path:["comments",s]}),r.line===r.endLine&&r.colStart!==void 0&&r.colEnd!==void 0&&r.colEnd<=r.colStart&&e.addIssue({code:"custom",message:"colEnd must exceed colStart",path:["comments",s,"colEnd"]})})}),w=n.record(n.string(),n.unknown()),L=n.object({schema:n.literal("crtr.page-response/v1"),kind:n.literal("page"),responses:n.record(n.string(),w),summary:n.string(),completedAt:o,actor:n.string().optional()}).strict(),Z=n.object({kind:n.literal("page"),responses:n.record(n.string(),w),savedAt:o}).strict(),O=n.object({schema:n.literal("humanloop.review-response/v1"),kind:n.literal("review"),result:I,completedAt:o}).strict(),N=n.object({schema:n.literal("humanloop.cancel/v1"),kind:n.literal("canceled"),canceledAt:o,reason:n.string().optional(),actor:n.string().optional(),disposition:n.enum(["canceled","dismissed"]).optional()}).strict();async function ee(t){const e=await l(t);if(e===null)throw new Error(`unknown human request directory: ${t}`);if(e.state!=="settled"||e.result_json===null)return null;let r;try{r=JSON.parse(e.result_json)}catch(v){throw new Error(`corrupt human request result: ${e.request_id}`,{cause:v})}const s=L.safeParse(r);if(s.success)return s.data;const u=O.safeParse(r);if(u.success)return u.data;const a=N.safeParse(r);if(a.success)return a.data;throw new Error(`human request has an invalid terminal result: ${e.request_id}`)}i(ee,"readTicketResult");async function te(t,e){y(t,{recursive:!0,mode:448});const r=q(t),s=await l(r);if(s===null){const a=await x({request_id:_(r),prepared:e});return g(),{id:a.request_id,dir:a.request_dir,kind:"page",manifest:e.manifest}}const u=j(r,e);if(!await A(s.request_id,{presentation_dir:u,specification_json:JSON.stringify(e.manifest),title:e.manifest.title,subtitle:e.manifest.subtitle??null,inbox_listed:e.manifest.delivery.inbox,settleable:e.manifest.delivery.inbox||e.manifest.delivery.reply}))throw new Error(`page request is not open: ${s.request_id}`);return g(),{id:s.request_id,dir:r,kind:"page",manifest:e.manifest}}i(te,"publishPage");async function c(t){const e=await l(t);if(e===null||e.kind!=="page")throw new Error(`unknown page request directory: ${t}`);return e}i(c,"pageRequest");async function D(t){return f(await c(t))}i(D,"selectedPageDir");async function F(t){return p(await D(t))}i(F,"requirePage");async function h(t){const e=await F(t);if(!e.delivery.inbox&&!e.delivery.reply)throw new Error("page_has_no_response_lifecycle");return e}i(h,"requireSettleablePage");function H(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)&&Object.keys(t).length===0}i(H,"isEmptyResponseMap");function J(t,e){return!t.delivery.reply&&H(e)?m(t,e):E(t,e)}i(J,"validateFinalPageResponses");async function C(t,e){return J(await h(t),e)}i(C,"validateFinalPageTicketResponses");async function ne(t,e){return await C(t,e)}i(ne,"validatePageTicketResponses");async function M(t){const e=await c(t);return e.settleable?e.state!=="settled"?"pending":e.outcome==="canceled"||e.outcome==="dismissed"?"canceled":"resolved":"passive"}i(M,"pageTicketState");async function re(t,e){const r=await c(t),s=m(await h(t),e);if(!await T(r.inbox_ticket_id,s))throw new Error(`page request is not open and settleable: ${r.request_id}`);return s}i(re,"writePageProgress");async function z(t){const e=await c(t);if(e.progress_json===null)return null;try{const r=JSON.parse(e.progress_json);if(r.kind!=="page")throw new Error("wrong kind");return r.responses}catch(r){throw new Error(`page progress is malformed for ${e.request_id}`,{cause:r})}}i(z,"readPageProgress");async function se(t){const e=await c(t),r=f(e),s=p(r);return{dir:e.request_dir,id:e.request_id,manifest:s,document:d(S(r,s.dialect),"utf8"),...s.dialect==="jsx"?{module:d(R(r),"utf8")}:{module:void 0},state:await M(e.request_dir),progress:s.delivery.inbox||s.delivery.reply?await z(e.request_dir):null}}i(se,"readPageTicket");function ie(t,e,r,s={}){throw new Error("page completion must use settleHumanRequest")}i(ie,"completePage");function oe(t,e,r,s={}){throw new Error("page completion must use settleHumanRequest")}i(oe,"takeoverAndCompletePage");function ae(t,e={}){throw new Error("page cancellation must use settleHumanRequest")}i(ae,"cancelTicket");function ce(t){throw new Error("review projection must use projectReviewResult")}i(ce,"projectReviewOutput");export{ae as cancelTicket,ie as completePage,M as pageTicketState,ce as projectReviewOutput,te as publishPage,z as readPageProgress,se as readPageTicket,ee as readTicketResult,D as selectedPageDir,oe as takeoverAndCompletePage,J as validateFinalPageResponses,ne as validatePageTicketResponses,re as writePageProgress};
|