@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
|
@@ -13,4 +13,4 @@ export declare function resolveAppRung(endpoint: InferenceEndpoint, requested: s
|
|
|
13
13
|
export declare function appCandidates(endpoint: InferenceEndpoint, requested: string | undefined, exact?: boolean): AppRung[];
|
|
14
14
|
/** The rung an app-paid grant's node runs on for `requested` (RT-RTE-24), or null when the grant is user-paid or
|
|
15
15
|
* absent. Every path that chooses a node's model (spawn, `node config --model`) resolves through here. */
|
|
16
|
-
export declare function appRungForGrant(grantId: string | null | undefined, requested: string | undefined, exact?: boolean): AppRung | null
|
|
16
|
+
export declare function appRungForGrant(grantId: string | null | undefined, requested: string | undefined, exact?: boolean): Promise<AppRung | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var h=Object.defineProperty;var
|
|
1
|
+
var h=Object.defineProperty;var s=(e,r)=>h(e,"name",{value:r,configurable:!0});import{defaultModelLaddersConfig as x}from"../../types.js";import{MODEL_STRENGTHS as b,stripThinkingSuffix as p}from"../runtime/model-selection.js";import{modelTokenStrength as w}from"../runtime/launch.js";import{RunError as u}from"../runs/operations.js";import{grantRecord as O}from"../grants/mirror.js";const o=b;function l(e,r){const t=o.indexOf(r);return o.filter(n=>e.rungs[n]!==void 0).sort((n,i)=>Math.abs(o.indexOf(n)-t)-Math.abs(o.indexOf(i)-t)||o.indexOf(n)-o.indexOf(i)).map(n=>({strength:n,model:e.rungs[n]}))}s(l,"rungsByDistance");function d(e,r){const t=l(e,r)[0];if(t===void 0)throw new u(404,"model_unavailable","the app's inference endpoint declares no rung");return t}s(d,"rungAt");function g(e,r,t=!1){if(r===void 0||r==="")return d(e,"strong");const n=w(r)??void 0;if(n!==void 0)return d(e,n);const i=p(r),f=o.find(a=>e.rungs[a]===i);if(f!==void 0)return{strength:f,model:e.rungs[f]};if(t)throw new u(400,"substitution_refused",`model '${r}' is not one of this app's inference rungs`);const c=x(),m=[...Object.entries(c.anthropic),...Object.entries(c.openai)].find(([,a])=>p(a)===i);return d(e,m?.[0]??"strong")}s(g,"resolveAppRung");function v(e,r,t=!1){const n=g(e,r,t);if(t)return[n];const i=l(e,n.strength).filter(f=>f.strength!==n.strength);return[n,...i]}s(v,"appCandidates");async function y(e,r,t=!1){const n=e?await O(e):null;if(n?.payer!=="app")return null;if(!n.inference_endpoint)throw new u(404,"model_unavailable",`${n.grantee} is app-paid but its grant carries no inference endpoint`);return g(n.inference_endpoint,r,t)}s(y,"appRungForGrant");export{v as appCandidates,y as appRungForGrant,g as resolveAppRung,d as rungAt};
|
package/dist/core/llm/run.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
var be=Object.defineProperty;var u=(e,t)=>be(e,"name",{value:t,configurable:!0});import{randomUUID as ve}from"node:crypto";import{streamSimple as we}from"@earendil-works/pi-ai/compat";import{expandModelCandidates as ie,parseModelSpec as se,probeRouteAvailability as xe}from"../model-routes.js";import{readMergedLaunchConfig as ae}from"../config.js";import{openModelRegistry as ke}from"../runtime/model-registry.js";import{MAX_RATE_LIMIT_COOLDOWN_MS as de,coolingUntilFor as le,isManagedProvider as H,markSubscriptionRateLimited as je,markSubscriptionSuccess as Me,readSubscriptionPool as Ae,retryAfterMsFromHeaders as K,retryAfterMsFromError as qe,refreshSubscriptionCredential as $e,subscriptionNeedsSuccessWrite as Re}from"../subscription-state.js";import{classifyRateLimit as Ie,describeRateLimitScope as ce,rateLimitHeaders as Ce}from"../rate-limit-scope.js";import{RunError as i}from"../runs/operations.js";import{recognizeProviderError as Y}from"../provider-error-recognition.js";import{isSafetyRefusal as Se}from"./refusal.js";import{assertUnderCap as Oe,recordModelUsage as ue}from"../usage/ledger.js";import{outboundToken as Le}from"../providers/mint.js";import{discardFile as Ee}from"../providers/token-cache.js";import{ProviderError as Ne}from"../providers/errors.js";import{appCandidates as De}from"./app-rungs.js";function Fe(e){return typeof e=="string"||e===null||Array.isArray(e)&&e.every(t=>t&&typeof t=="object"&&(t.type==="text"&&typeof t.text=="string"||t.type==="image_url"&&typeof t.image_url?.url=="string"&&/^data:image\/(png|jpeg|gif|webp);base64,[A-Za-z0-9+/]+={0,2}$/.test(t.image_url.url)))}u(Fe,"validContent");function fe(e){return Array.isArray(e)?e.map(t=>{if(t.type==="text")return t;const[,n,r]=/^data:(image\/(?:png|jpeg|gif|webp));base64,(.*)$/.exec(t.image_url.url);return{type:"image",mimeType:n,data:r}}):e??""}u(fe,"imageContent");function Te(e,t){const n=(e instanceof Error?e.message:String(e)).split("; stack=",1)[0],r=Y({message:n}).kind;return r!=="connection"&&r!=="connection-only"?e:new i(503,"upstream_model_unavailable",n.slice(0,500),void 0,{served_model:t})}u(Te,"refreshFailure");function lt(e){if(!e||typeof e!="object"||Array.isArray(e))throw new i(400,"invalid_request","body must be an object");const t=e;if(!Array.isArray(t.messages)||!t.messages.every(n=>n&&typeof n=="object"&&["system","user","assistant","tool"].includes(n.role)&&Fe(n.content)))throw new i(400,"invalid_request","messages must be chat messages","messages");if(t.messages.some(n=>["system","assistant"].includes(n.role)&&typeof n.content!="string"&&n.content!==null))throw new i(400,"invalid_request","system and assistant content must be text","messages");if(t.model!==void 0&&typeof t.model!="string")throw new i(400,"invalid_request","model must be a string","model");if(t.model_policy!==void 0&&!["exact","substitute"].includes(t.model_policy))throw new i(400,"invalid_request","invalid model_policy","model_policy");if(t.payer!==void 0&&!["user","app"].includes(t.payer))throw new i(400,"invalid_request","invalid payer","payer");if(t.reasoning_effort!==void 0&&!["minimal","low","medium","high","xhigh","max"].includes(t.reasoning_effort))throw new i(400,"invalid_request","invalid reasoning_effort","reasoning_effort");if(t.stream!==void 0&&typeof t.stream!="boolean")throw new i(400,"invalid_request","stream must be boolean","stream");if(t.tools!==void 0&&(!Array.isArray(t.tools)||!t.tools.every(n=>n?.type==="function"&&typeof n.function?.name=="string"&&n.function.name.length>0&&(n.function.description===void 0||typeof n.function.description=="string")&&(n.function.parameters===void 0||n.function.parameters!==null&&typeof n.function.parameters=="object"&&!Array.isArray(n.function.parameters)&&n.function.parameters.type==="object"))))throw new i(400,"invalid_request","invalid tools","tools");if(t.tool_choice!==void 0&&t.tool_choice!=="auto"&&t.tool_choice!=="none"&&t.tool_choice!=="required"&&(typeof t.tool_choice!="object"||t.tool_choice===null||t.tool_choice.type!=="function"||typeof t.tool_choice.function?.name!="string"))throw new i(400,"invalid_request","invalid tool_choice","tool_choice");if(t.messages.some(n=>n.role==="assistant"&&n.tool_calls!==void 0&&(!Array.isArray(n.tool_calls)||!n.tool_calls.every(r=>r&&typeof r.id=="string"&&typeof r.function?.name=="string"&&typeof r.function.arguments=="string"&&Pe(r.function.arguments)))))throw new i(400,"invalid_request","invalid assistant tool_calls","messages");if(t.stop!==void 0&&!(typeof t.stop=="string"||Array.isArray(t.stop)&&t.stop.every(n=>typeof n=="string")))throw new i(400,"invalid_request","invalid stop","stop");if(t.seed!==void 0&&!Number.isSafeInteger(t.seed))throw new i(400,"invalid_request","invalid seed","seed");for(const[n,r]of[["temperature",t.temperature],["top_p",t.top_p],["max_tokens",t.max_tokens]])if(r!==void 0&&(typeof r!="number"||!Number.isFinite(r)||n==="temperature"&&(r<0||r>2)||n==="top_p"&&(r<0||r>1)||n==="max_tokens"&&(!Number.isSafeInteger(r)||r<1)))throw new i(400,"invalid_request",`invalid ${n}`,n);if(t.response_format!==void 0){const n=t.response_format;if(!n||typeof n!="object"||Array.isArray(n)||!["text","json_object","json_schema"].includes(n.type)||n.type==="json_schema"&&(typeof n.json_schema?.name!="string"||!n.json_schema.name||!n.json_schema.schema||typeof n.json_schema.schema!="object"||Array.isArray(n.json_schema.schema)))throw new i(400,"invalid_request","invalid response_format","response_format")}if(t.metadata!==void 0&&Buffer.byteLength(JSON.stringify(t.metadata)??"")>4096)throw new i(400,"invalid_request","metadata exceeds 4 KB","metadata");return t}u(lt,"parseLlmRequest");function Pe(e){try{const t=JSON.parse(e);return t!==null&&typeof t=="object"&&!Array.isArray(t)}catch{return!1}}u(Pe,"isJsonObject");function Ue(e){const t=Date.now(),n=e.messages.map(s=>s.role==="system"?{role:"system",content:s.content??"",timestamp:t}:s.role==="tool"?{role:"toolResult",toolCallId:s.tool_call_id??"",toolName:"",content:typeof s.content=="string"||s.content===null?[{type:"text",text:s.content??""}]:fe(s.content),isError:!1,timestamp:t}:s.role==="assistant"?{role:"assistant",content:[...s.content?[{type:"text",text:s.content}]:[],...(s.tool_calls??[]).map(g=>({type:"toolCall",id:g.id,name:g.function.name,arguments:JSON.parse(g.function.arguments)}))],api:"openai-completions",provider:"openai",model:e.model??"",usage:{input:0,output:0,cacheRead:0,cacheWrite:0,totalTokens:0,cost:{input:0,output:0,cacheRead:0,cacheWrite:0,total:0}},stopReason:"stop",timestamp:t}:{role:"user",content:fe(s.content),timestamp:t}),r=n.findIndex(s=>s.role!=="system"),w=n.slice(0,r<0?n.length:r).map(s=>s.content),y=w.join(`
|
|
2
2
|
|
|
3
|
-
`),l=e.tools?.map(({function:s})=>({name:s.name,description:s.description??"",parameters:s.parameters??{type:"object",properties:{}}}));return{...y?{systemPrompt:y}:{},messages:n.slice(w.length),...l?{tools:l}:{}}}u(Ue,"contextOf");function me(e,t,n,r){if(!e){const y=ae(n,r),l=Object.values({...y.modelRoutes??{},...y.legacyModelRoutes??{}}),s=l.length?[y.modelLadders.defaultProvider,...y.modelRouting?.familyOrder??[],...l.map(g=>g.family)].find(g=>l.some(E=>E.family===g)):y.modelLadders.defaultProvider??"anthropic";return{kind:"logical",family:s,strength:"strong",spec:`${s}/strong`}}const w=/^([^/]+)\/(ultra|strong|medium|light)$/.exec(e);return w?{kind:"logical",family:w[1],strength:w[2],spec:e}:{kind:t==="exact"?"exact":"concrete",spec:e}}u(me,"requestFor");function Je(e,t){const{input:n,output:r,cacheRead:w,cacheWrite:y}=e.cost;return n===0&&r===0&&w===0&&y===0?null:Number.isFinite(t)&&t>=0?t:null}u(Je,"usdEquivalent");function We(e,t){return e.compat?.allowedFallbackModels?.find(r=>r.provider===e.provider&&r.model===t)}u(We,"allowedFallback");function ct(e){return e?{payer:e.payer??"user",sub:e.sub,grantee:e.grantee,inference_endpoint:e.inference_endpoint??null}:void 0}u(ct,"llmCallerOf");function He(e){return e instanceof Ne?e.code==="server_error"?new i(503,"upstream_model_unavailable",e.message):new i(404,"model_unavailable",e.message):e}u(He,"mintFailure");const Ke=/\bmodel is not supported when using Codex with a ChatGPT account\b/i;function ze(e,t,n){if(!(e!=="openai-codex"||t===void 0||!Ke.test(t)))return new i(404,"model_unavailable",t,void 0,{served_model:n})}u(ze,"codexAccountModelRejection");async function ut(e,t,n,r,w,y){const l=y?.payer==="app"?y:void 0;if(e.payer==="app"&&!l)throw new i(403,"payer_not_app","this grant is not app-paid");if(e.payer==="user"&&l)throw new i(400,"invalid_request","this grant is app-paid; payer cannot be user","payer");if(l&&!l.inference_endpoint)throw new i(404,"model_unavailable",`${l.grantee} is app-paid but its grant carries no inference endpoint`);const s=l?.inference_endpoint??void 0;l||Oe(w);const g=await ke(),E=u(c=>c.routeId!=="concrete"&&c.routeId!=="exact","configured"),ee=u(c=>{const h=g.find(c.providerId,c.modelId);return h!==void 0&&(!e.reasoning_effort||h.reasoning)&&(e.seed===void 0&&e.response_format===void 0||h.api==="openai-completions")&&(e.stop===void 0||["openai-completions","anthropic-messages"].includes(h.api))},"matchesFeatures"),pe=u(()=>{const c=me(e.model,e.model_policy,r?.cwd,r?.profileId),h=ie(c.kind==="exact"?{kind:"concrete",spec:c.spec}:c,r?.cwd,r?.profileId).filter(E);let a;if(c.kind==="logical")a=e.model_policy==="exact"?h.filter(m=>m.family===c.family&&m.strength===c.strength).slice(0,1):h;else{const m=se(c.spec),q=h.filter(j=>j.providerId===m?.providerId&&j.modelId===m.modelId&&(e.model_policy!=="exact"||j.thinkingLevel===m.thinkingLevel)&&ee(j));if(e.model_policy==="exact")a=q.slice(0,1);else if(q.length)a=q;else{const j=ae(r?.cwd,r?.profileId),x=[...Object.values(j.modelRoutes??{}).flatMap(v=>Object.entries(v.models)),...[j.modelLadders.anthropic,j.modelLadders.openai].flatMap(v=>Object.entries(v))].find(([,v])=>v===c.spec)?.[0],f=me(void 0,"substitute",r?.cwd,r?.profileId);a=x&&f.kind==="logical"?ie({...f,strength:x,spec:c.spec},r?.cwd,r?.profileId).filter(v=>E(v)&&v.strength===x):[]}}return a},"ownerCandidates");let R;if(s?R=De(s,e.model,e.model_policy==="exact").flatMap((c,h)=>{const a=se(c.model);return a?[{routeId:"app",credentialSource:"app",family:"app",strength:c.strength,...a,rank:h}]:[]}):R=pe(),R=R.filter(ee),R.length===0)throw e.model_policy==="exact"?new i(400,"substitution_refused","no eligible model route is configured"):new i(404,"model_unavailable","no eligible model route is configured");const te=`chatcmpl-${ve()}`;let I=1/0,b,z;for(const c of R){if(!l&&!xe(c,g).authenticated)continue;const h=g.find(c.providerId,c.modelId);if(!h)continue;const a=s?{...h,baseUrl:`${s.base_url}/${h.provider}`}:h,m=c.providerId,q=!l&&H(m)?Ae(m).filter(x=>!x.authFailure):[],j=q.filter(x=>le(x,a.id)<=Date.now());if(q.length&&!j.length){const x=Math.min(...q.map(f=>le(f,a.id)));x<I&&(I=x,z=`${a.provider}/${a.id}`);continue}const oe=l?[void 0,void 0]:q.length?j:[void 0];for(const[x,f]of oe.entries()){const v=Date.now();let ne=f?.access;if(f&&f.expires<=Date.now()&&H(m)){const o=g.getProvider(m)?.auth.oauth;if(!o)throw new i(503,"upstream_model_unavailable",`no OAuth refresh for ${m}`,void 0,{served_model:`${a.provider}/${a.id}`});ne=(await $e(m,f.label,async(k,re)=>{const W=await o.refresh({type:"oauth",refresh:k,access:"",expires:0,...re?{clientId:re}:{}},t??new AbortController().signal).catch(ge=>{throw Te(ge,`${a.provider}/${a.id}`)}),V=W.clientId;return{refresh:W.refresh,access:W.access,expires:W.expires,...typeof V=="string"&&V?{clientId:V}:{}}})).access}const he=Ue(e);let N;if(l&&s)try{N=await Le({audience:s.base_url,sub:l.sub,grantee:l.grantee,initiating_app:l.grantee,scope:["crtr:llm"]},{signal:t})}catch(o){throw He(o)}const C=f||l?void 0:await g.getApiKeyAndHeaders(a);if(C&&!C.ok)continue;const p=`${a.provider}/${a.id}`,S=e.model??p;let A=!1,L,M=3e4,$;const B=[],X=[],D=[];let d,F;const T=u((o,_=null)=>({id:te,object:"chat.completion.chunk",created:Math.floor(v/1e3),model:p,served_model:p,requested_model:S,substituted:S!==p&&!/^([^/]+)\/(ultra|strong|medium|light)$/.test(S),choices:[{index:0,delta:o,finish_reason:_}]}),"chunk"),P=u(o=>{B.push(o),n?.(o)},"emit"),_e=we(a,he,{apiKey:N?.access_token??ne??(C?.ok?C.apiKey:void 0),...C?.ok?{headers:C.headers}:{},signal:t,reasoning:e.reasoning_effort??c.thinkingLevel,...e.temperature!==void 0?{temperature:e.temperature}:{},...e.max_tokens!==void 0?{maxTokens:e.max_tokens}:{},...e.top_p!==void 0?{samplingParams:{top_p:e.top_p}}:{},...e.tool_choice==="none"?{toolChoice:"none"}:{},onPayload:u(o=>{if(!o||typeof o!="object")return;const _=e.tool_choice,k=_==="required"?a.api==="anthropic-messages"?{type:"any"}:"required":typeof _=="object"&&_!==null?a.api==="anthropic-messages"?{type:"tool",name:_.function.name}:_:void 0;return{...o,...k?{tool_choice:k}:{},...e.stop!==void 0?{[a.api==="anthropic-messages"?"stop_sequences":"stop"]:typeof e.stop=="string"?[e.stop]:e.stop}:{},...e.seed!==void 0?{seed:e.seed}:{},...e.response_format!==void 0?{response_format:e.response_format}:{}}},"onPayload"),fetch:u(async(o,_)=>{const k=await fetch(o,_);return L=k.status,k.status===429&&(A=!0,$=k.headers,M=K(k.headers)??15e3),k},"fetch"),onResponse:u(o=>{o.status===429&&(A=!0,$=o.headers,M=K(o.headers)??15e3)},"onResponse")});try{for await(const o of _e)o.type==="text_delta"&&(X.push(o.delta),P(T({content:o.delta}))),o.type==="thinking_delta"&&(D.push(o.delta),P(T({reasoning_content:o.delta}))),o.type==="done"&&(d=o.message),o.type==="error"&&(d=o.error)}catch(o){const _=qe(o);$===void 0&&o&&typeof o=="object"&&"headers"in o&&Object.keys(Ce(o.headers)).length&&($=o.headers);const k=Y({status:o&&typeof o=="object"&&"status"in o?o.status:void 0,message:o instanceof Error?o.message:String(o)});if(l)F=o;else{if(!A&&k.kind!=="rate-limit")throw B.length?new i(503,"upstream_model_unavailable",o instanceof Error?o.message:String(o),void 0,{served_model:p}):o;A=!0,M=_??M}}if(l){if(L===401){if(N&&Ee(N.key),x===0)continue;throw new i(404,"model_unavailable",`${s.base_url} refuses this runtime's tokens`,void 0,{served_model:p})}if(A&&K($)===void 0)throw new i(503,"upstream_model_unavailable",`${p} was rate-limited without a retry-after`,void 0,{served_model:p});if(!A&&(F!==void 0||L!==void 0&&L>=500))throw new i(503,"upstream_model_unavailable",F instanceof Error?F.message:d?.errorMessage??"inference endpoint failed",void 0,{served_model:p})}if(!A&&d?.stopReason==="error"&&Y({message:d.errorMessage}).kind==="rate-limit"&&(A=!0,M=15e3),A){const o=Ie($,a.id);if(K($)===void 0&&o.resetAt!==void 0&&(M=Math.max(M,o.resetAt-Date.now())),b={provider:m,model:a.id,...f?{account:f.label}:{},observation:o},console.error(`[llm] 429 from ${p}${f?` account "${f.label}"`:""}: scope=${ce(o.scope)} retry_after_ms=${M} headers=${JSON.stringify(o.headers)}`),f&&H(m)&&await je(m,f.label,M,v,Date.now(),o.scope),Date.now()+Math.min(M,de)<I&&(I=Date.now()+Math.min(M,de),z=p),X.length||D.length)throw new i(503,"service_unavailable","vendor rate limit after output began",void 0,{served_model:p});if(l)break;continue}const U=Se(d);if(L===400&&e.tool_choice!==void 0&&e.tool_choice!=="auto"&&e.tool_choice!=="none"&&/\btool[_ ]choice\b/i.test(d?.errorMessage??"")&&/not supported|does not support|unsupported|cannot|must be auto/i.test(d?.errorMessage??""))throw new i(400,"invalid_request",d.errorMessage,"tool_choice",{served_model:p});if(d?.stopReason==="error"){const o=ze(a.provider,d.errorMessage,p);if(o)throw o}if(!d||d.stopReason==="error"&&!U||d.stopReason==="aborted")throw new i(503,"upstream_model_unavailable",d?.errorMessage??"model request failed",void 0,{served_model:p});f&&H(m)&&Re(f,a.id)&&await Me(m,f.label,v,a.id);const G=d.content.filter(o=>o.type==="toolCall").map(o=>({id:o.id,type:"function",function:{name:o.name,arguments:JSON.stringify(o.arguments)}})),Z=U?"content_filter":d.stopReason==="toolUse"?"tool_calls":d.stopReason==="length"?"length":"stop",Q=d.responseModel?We(a,d.responseModel):void 0,O=Q?`${a.provider}/${Q.model}`:p,J={prompt_tokens:d.usage.input,completion_tokens:d.usage.output,total_tokens:d.usage.totalTokens,cache_read_tokens:d.usage.cacheRead,cache_write_tokens:d.usage.cacheWrite,usd_equivalent:Je(Q??a,d.usage.cost.total),served_model:O};l?ue(l.grantee,"app",O,d.usage,J.usd_equivalent):w&&ue(w.grantee,"user",O,d.usage,J.usd_equivalent);const ye={id:te,object:"chat.completion",created:Math.floor(v/1e3),model:O,served_model:O,requested_model:S,substituted:S!==O&&!/^([^/]+)\/(ultra|strong|medium|light)$/.test(S),choices:[{index:0,message:{role:"assistant",content:X.join("")||null,...D.length?{reasoning_content:D.join("")}:{},...G.length?{tool_calls:G}:{},...U?{refusal:d.errorMessage??"Content filtered"}:{}},finish_reason:Z}],usage:J,...e.metadata!==void 0?{metadata:e.metadata}:{}};for(const[o,_]of G.entries())P(T({tool_calls:[{index:o,..._}]}));return P({...T({},Z),...U?{choices:[{index:0,delta:{},finish_reason:Z,message:{refusal:d.errorMessage??"Content filtered"}}]}:{},usage:J}),{completion:ye,chunks:B}}}throw I!==1/0?new i(429,"all_routes_exhausted","all eligible model routes are rate-limited",void 0,{retry_after_s:Math.max(1,Math.ceil((I-Date.now())/1e3)),served_model:b?`${b.provider}/${b.model}`:z,...b?{rate_limit:{provider:b.provider,model:b.model,...b.account?{account:b.account}:{},scope:ce(b.observation.scope),...b.observation.claim?{claim:b.observation.claim}:{},headers:b.observation.headers}}:{}},void 0,!0):e.model_policy==="exact"?new i(400,"substitution_refused","the requested model is unavailable"):new i(404,"model_unavailable","no usable model route is available")}u(ut,"runLlm");export{ct as llmCallerOf,lt as parseLlmRequest,ut as runLlm};
|
|
3
|
+
`),l=e.tools?.map(({function:s})=>({name:s.name,description:s.description??"",parameters:s.parameters??{type:"object",properties:{}}}));return{...y?{systemPrompt:y}:{},messages:n.slice(w.length),...l?{tools:l}:{}}}u(Ue,"contextOf");function me(e,t,n,r){if(!e){const y=ae(n,r),l=Object.values({...y.modelRoutes??{},...y.legacyModelRoutes??{}}),s=l.length?[y.modelLadders.defaultProvider,...y.modelRouting?.familyOrder??[],...l.map(g=>g.family)].find(g=>l.some(E=>E.family===g)):y.modelLadders.defaultProvider??"anthropic";return{kind:"logical",family:s,strength:"strong",spec:`${s}/strong`}}const w=/^([^/]+)\/(ultra|strong|medium|light)$/.exec(e);return w?{kind:"logical",family:w[1],strength:w[2],spec:e}:{kind:t==="exact"?"exact":"concrete",spec:e}}u(me,"requestFor");function Je(e,t){const{input:n,output:r,cacheRead:w,cacheWrite:y}=e.cost;return n===0&&r===0&&w===0&&y===0?null:Number.isFinite(t)&&t>=0?t:null}u(Je,"usdEquivalent");function We(e,t){return e.compat?.allowedFallbackModels?.find(r=>r.provider===e.provider&&r.model===t)}u(We,"allowedFallback");function ct(e){return e?{payer:e.payer??"user",sub:e.sub,grantee:e.grantee,inference_endpoint:e.inference_endpoint??null}:void 0}u(ct,"llmCallerOf");function He(e){return e instanceof Ne?e.code==="server_error"?new i(503,"upstream_model_unavailable",e.message):new i(404,"model_unavailable",e.message):e}u(He,"mintFailure");const Ke=/\bmodel is not supported when using Codex with a ChatGPT account\b/i;function ze(e,t,n){if(!(e!=="openai-codex"||t===void 0||!Ke.test(t)))return new i(404,"model_unavailable",t,void 0,{served_model:n})}u(ze,"codexAccountModelRejection");async function ut(e,t,n,r,w,y){const l=y?.payer==="app"?y:void 0;if(e.payer==="app"&&!l)throw new i(403,"payer_not_app","this grant is not app-paid");if(e.payer==="user"&&l)throw new i(400,"invalid_request","this grant is app-paid; payer cannot be user","payer");if(l&&!l.inference_endpoint)throw new i(404,"model_unavailable",`${l.grantee} is app-paid but its grant carries no inference endpoint`);const s=l?.inference_endpoint??void 0;l||await Oe(w);const g=await ke(),E=u(c=>c.routeId!=="concrete"&&c.routeId!=="exact","configured"),ee=u(c=>{const h=g.find(c.providerId,c.modelId);return h!==void 0&&(!e.reasoning_effort||h.reasoning)&&(e.seed===void 0&&e.response_format===void 0||h.api==="openai-completions")&&(e.stop===void 0||["openai-completions","anthropic-messages"].includes(h.api))},"matchesFeatures"),pe=u(()=>{const c=me(e.model,e.model_policy,r?.cwd,r?.profileId),h=ie(c.kind==="exact"?{kind:"concrete",spec:c.spec}:c,r?.cwd,r?.profileId).filter(E);let a;if(c.kind==="logical")a=e.model_policy==="exact"?h.filter(m=>m.family===c.family&&m.strength===c.strength).slice(0,1):h;else{const m=se(c.spec),q=h.filter(j=>j.providerId===m?.providerId&&j.modelId===m.modelId&&(e.model_policy!=="exact"||j.thinkingLevel===m.thinkingLevel)&&ee(j));if(e.model_policy==="exact")a=q.slice(0,1);else if(q.length)a=q;else{const j=ae(r?.cwd,r?.profileId),x=[...Object.values(j.modelRoutes??{}).flatMap(v=>Object.entries(v.models)),...[j.modelLadders.anthropic,j.modelLadders.openai].flatMap(v=>Object.entries(v))].find(([,v])=>v===c.spec)?.[0],f=me(void 0,"substitute",r?.cwd,r?.profileId);a=x&&f.kind==="logical"?ie({...f,strength:x,spec:c.spec},r?.cwd,r?.profileId).filter(v=>E(v)&&v.strength===x):[]}}return a},"ownerCandidates");let R;if(s?R=De(s,e.model,e.model_policy==="exact").flatMap((c,h)=>{const a=se(c.model);return a?[{routeId:"app",credentialSource:"app",family:"app",strength:c.strength,...a,rank:h}]:[]}):R=pe(),R=R.filter(ee),R.length===0)throw e.model_policy==="exact"?new i(400,"substitution_refused","no eligible model route is configured"):new i(404,"model_unavailable","no eligible model route is configured");const te=`chatcmpl-${ve()}`;let I=1/0,b,z;for(const c of R){if(!l&&!xe(c,g).authenticated)continue;const h=g.find(c.providerId,c.modelId);if(!h)continue;const a=s?{...h,baseUrl:`${s.base_url}/${h.provider}`}:h,m=c.providerId,q=!l&&H(m)?Ae(m).filter(x=>!x.authFailure):[],j=q.filter(x=>le(x,a.id)<=Date.now());if(q.length&&!j.length){const x=Math.min(...q.map(f=>le(f,a.id)));x<I&&(I=x,z=`${a.provider}/${a.id}`);continue}const oe=l?[void 0,void 0]:q.length?j:[void 0];for(const[x,f]of oe.entries()){const v=Date.now();let ne=f?.access;if(f&&f.expires<=Date.now()&&H(m)){const o=g.getProvider(m)?.auth.oauth;if(!o)throw new i(503,"upstream_model_unavailable",`no OAuth refresh for ${m}`,void 0,{served_model:`${a.provider}/${a.id}`});ne=(await $e(m,f.label,async(k,re)=>{const W=await o.refresh({type:"oauth",refresh:k,access:"",expires:0,...re?{clientId:re}:{}},t??new AbortController().signal).catch(ge=>{throw Te(ge,`${a.provider}/${a.id}`)}),V=W.clientId;return{refresh:W.refresh,access:W.access,expires:W.expires,...typeof V=="string"&&V?{clientId:V}:{}}})).access}const he=Ue(e);let N;if(l&&s)try{N=await Le({audience:s.base_url,sub:l.sub,grantee:l.grantee,initiating_app:l.grantee,scope:["crtr:llm"]},{signal:t})}catch(o){throw He(o)}const C=f||l?void 0:await g.getApiKeyAndHeaders(a);if(C&&!C.ok)continue;const p=`${a.provider}/${a.id}`,S=e.model??p;let A=!1,L,M=3e4,$;const B=[],X=[],D=[];let d,F;const T=u((o,_=null)=>({id:te,object:"chat.completion.chunk",created:Math.floor(v/1e3),model:p,served_model:p,requested_model:S,substituted:S!==p&&!/^([^/]+)\/(ultra|strong|medium|light)$/.test(S),choices:[{index:0,delta:o,finish_reason:_}]}),"chunk"),P=u(o=>{B.push(o),n?.(o)},"emit"),_e=we(a,he,{apiKey:N?.access_token??ne??(C?.ok?C.apiKey:void 0),...C?.ok?{headers:C.headers}:{},signal:t,reasoning:e.reasoning_effort??c.thinkingLevel,...e.temperature!==void 0?{temperature:e.temperature}:{},...e.max_tokens!==void 0?{maxTokens:e.max_tokens}:{},...e.top_p!==void 0?{samplingParams:{top_p:e.top_p}}:{},...e.tool_choice==="none"?{toolChoice:"none"}:{},onPayload:u(o=>{if(!o||typeof o!="object")return;const _=e.tool_choice,k=_==="required"?a.api==="anthropic-messages"?{type:"any"}:"required":typeof _=="object"&&_!==null?a.api==="anthropic-messages"?{type:"tool",name:_.function.name}:_:void 0;return{...o,...k?{tool_choice:k}:{},...e.stop!==void 0?{[a.api==="anthropic-messages"?"stop_sequences":"stop"]:typeof e.stop=="string"?[e.stop]:e.stop}:{},...e.seed!==void 0?{seed:e.seed}:{},...e.response_format!==void 0?{response_format:e.response_format}:{}}},"onPayload"),fetch:u(async(o,_)=>{const k=await fetch(o,_);return L=k.status,k.status===429&&(A=!0,$=k.headers,M=K(k.headers)??15e3),k},"fetch"),onResponse:u(o=>{o.status===429&&(A=!0,$=o.headers,M=K(o.headers)??15e3)},"onResponse")});try{for await(const o of _e)o.type==="text_delta"&&(X.push(o.delta),P(T({content:o.delta}))),o.type==="thinking_delta"&&(D.push(o.delta),P(T({reasoning_content:o.delta}))),o.type==="done"&&(d=o.message),o.type==="error"&&(d=o.error)}catch(o){const _=qe(o);$===void 0&&o&&typeof o=="object"&&"headers"in o&&Object.keys(Ce(o.headers)).length&&($=o.headers);const k=Y({status:o&&typeof o=="object"&&"status"in o?o.status:void 0,message:o instanceof Error?o.message:String(o)});if(l)F=o;else{if(!A&&k.kind!=="rate-limit")throw B.length?new i(503,"upstream_model_unavailable",o instanceof Error?o.message:String(o),void 0,{served_model:p}):o;A=!0,M=_??M}}if(l){if(L===401){if(N&&Ee(N.key),x===0)continue;throw new i(404,"model_unavailable",`${s.base_url} refuses this runtime's tokens`,void 0,{served_model:p})}if(A&&K($)===void 0)throw new i(503,"upstream_model_unavailable",`${p} was rate-limited without a retry-after`,void 0,{served_model:p});if(!A&&(F!==void 0||L!==void 0&&L>=500))throw new i(503,"upstream_model_unavailable",F instanceof Error?F.message:d?.errorMessage??"inference endpoint failed",void 0,{served_model:p})}if(!A&&d?.stopReason==="error"&&Y({message:d.errorMessage}).kind==="rate-limit"&&(A=!0,M=15e3),A){const o=Ie($,a.id);if(K($)===void 0&&o.resetAt!==void 0&&(M=Math.max(M,o.resetAt-Date.now())),b={provider:m,model:a.id,...f?{account:f.label}:{},observation:o},console.error(`[llm] 429 from ${p}${f?` account "${f.label}"`:""}: scope=${ce(o.scope)} retry_after_ms=${M} headers=${JSON.stringify(o.headers)}`),f&&H(m)&&await je(m,f.label,M,v,Date.now(),o.scope),Date.now()+Math.min(M,de)<I&&(I=Date.now()+Math.min(M,de),z=p),X.length||D.length)throw new i(503,"service_unavailable","vendor rate limit after output began",void 0,{served_model:p});if(l)break;continue}const U=Se(d);if(L===400&&e.tool_choice!==void 0&&e.tool_choice!=="auto"&&e.tool_choice!=="none"&&/\btool[_ ]choice\b/i.test(d?.errorMessage??"")&&/not supported|does not support|unsupported|cannot|must be auto/i.test(d?.errorMessage??""))throw new i(400,"invalid_request",d.errorMessage,"tool_choice",{served_model:p});if(d?.stopReason==="error"){const o=ze(a.provider,d.errorMessage,p);if(o)throw o}if(!d||d.stopReason==="error"&&!U||d.stopReason==="aborted")throw new i(503,"upstream_model_unavailable",d?.errorMessage??"model request failed",void 0,{served_model:p});f&&H(m)&&Re(f,a.id)&&await Me(m,f.label,v,a.id);const G=d.content.filter(o=>o.type==="toolCall").map(o=>({id:o.id,type:"function",function:{name:o.name,arguments:JSON.stringify(o.arguments)}})),Z=U?"content_filter":d.stopReason==="toolUse"?"tool_calls":d.stopReason==="length"?"length":"stop",Q=d.responseModel?We(a,d.responseModel):void 0,O=Q?`${a.provider}/${Q.model}`:p,J={prompt_tokens:d.usage.input,completion_tokens:d.usage.output,total_tokens:d.usage.totalTokens,cache_read_tokens:d.usage.cacheRead,cache_write_tokens:d.usage.cacheWrite,usd_equivalent:Je(Q??a,d.usage.cost.total),served_model:O};l?await ue(l.grantee,"app",O,d.usage,J.usd_equivalent):w&&await ue(w.grantee,"user",O,d.usage,J.usd_equivalent);const ye={id:te,object:"chat.completion",created:Math.floor(v/1e3),model:O,served_model:O,requested_model:S,substituted:S!==O&&!/^([^/]+)\/(ultra|strong|medium|light)$/.test(S),choices:[{index:0,message:{role:"assistant",content:X.join("")||null,...D.length?{reasoning_content:D.join("")}:{},...G.length?{tool_calls:G}:{},...U?{refusal:d.errorMessage??"Content filtered"}:{}},finish_reason:Z}],usage:J,...e.metadata!==void 0?{metadata:e.metadata}:{}};for(const[o,_]of G.entries())P(T({tool_calls:[{index:o,..._}]}));return P({...T({},Z),...U?{choices:[{index:0,delta:{},finish_reason:Z,message:{refusal:d.errorMessage??"Content filtered"}}]}:{},usage:J}),{completion:ye,chunks:B}}}throw I!==1/0?new i(429,"all_routes_exhausted","all eligible model routes are rate-limited",void 0,{retry_after_s:Math.max(1,Math.ceil((I-Date.now())/1e3)),served_model:b?`${b.provider}/${b.model}`:z,...b?{rate_limit:{provider:b.provider,model:b.model,...b.account?{account:b.account}:{},scope:ce(b.observation.scope),...b.observation.claim?{claim:b.observation.claim}:{},headers:b.observation.headers}}:{}},void 0,!0):e.model_policy==="exact"?new i(400,"substitution_refused","the requested model is unavailable"):new i(404,"model_unavailable","no usable model route is available")}u(ut,"runLlm");export{ct as llmCallerOf,lt as parseLlmRequest,ut as runLlm};
|
|
@@ -67,7 +67,7 @@ export declare const directory: DirectoryClient;
|
|
|
67
67
|
export declare const listMachines: () => Promise<Machine[]>;
|
|
68
68
|
export declare const machineReach: (machineId: string) => Promise<Machine | null>;
|
|
69
69
|
/** The URL peers call this machine at, as the directory last reported it from a status call; null before the first one. */
|
|
70
|
-
export declare function machineUrl(): string | null
|
|
70
|
+
export declare function machineUrl(): Promise<string | null>;
|
|
71
71
|
/** Tell the directory this machine is up (its plugins and crtr version) and store the URL it answers with as `machine_url`.
|
|
72
72
|
* Returns the stored URL, or null when this daemon has no directory identity. Throws `DirectoryError` when the directory fails. */
|
|
73
73
|
export declare function reportMachineStatus(client?: DirectoryClient): Promise<MachineStatus | null>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var v=Object.defineProperty;var o=(t,e)=>v(t,"name",{value:e,configurable:!0});import{normalizeMachineId as m,rememberMachineName as p}from"./names.js";import{openDb as _}from"../canvas/db.js";import{readConfig as M}from"../config.js";import{runtimeClient as g}from"../grants/sync.js";import{crtrVersion as C}from"../../shared/crtr-version.js";import{installedPluginIds as I}from"../directory/join.js";import{peerTokens as R}from"./token.js";const S=5*6e4,A=1e4;class c extends Error{static{o(this,"DirectoryError")}status;constructor(e,i){super(i),this.status=e,this.name="DirectoryError"}}function E(t){if(!t||typeof t!="object")return null;const{kind:e,relay:i}=t;return e==="stable"?{kind:"stable"}:e==="relay"&&typeof i=="string"?{kind:"relay",relay:i}:null}o(E,"asReach");function T(t){const e=t,i=E(e?.reach);if(!e||typeof e.machine_id!="string"||typeof e.url!="string"||i===null)throw new c(502,"the directory answered a machine record with a missing machine_id, url or reach");return{machine_id:e.machine_id,name:typeof e.name=="string"?e.name:e.machine_id,url:e.url.replace(/\/$/,""),reach:i,crtr_version:typeof e.crtr_version=="string"?e.crtr_version:null,last_seen:typeof e.last_seen=="string"?e.last_seen:null,kind:e.kind==="device"?"device":"runtime",plugins:Array.isArray(e.plugins)?e.plugins.filter(u=>typeof u=="string"):[],...typeof e.is_default=="boolean"?{is_default:e.is_default}:{}}}o(T,"asMachine");function b(t,e){const i=new Map;let u=null;async function f(s,a,r){const n=t.issuer();if(n===null)throw new c(0,"this daemon has no directory");const d=n.replace(/\/$/,"");for(let y=0;;y++){let l;try{const h=await t.tokens.get(d);l=await t.fetch(`${d}${a}`,{method:s,headers:{authorization:`Bearer ${h}`,...r===void 0?{}:{"content-type":"application/json"}},...r===void 0?{}:{body:JSON.stringify(r)},signal:AbortSignal.timeout(A)})}catch(h){throw new c(0,`the directory could not be reached: ${h instanceof Error?h.message:String(h)}`)}if(l.status===401&&y===0){t.tokens.drop(d);continue}if(!l.ok)throw new c(l.status,`directory ${s} ${a} answered ${l.status}`);try{return await l.json()}catch{throw new c(502,`directory ${s} ${a} answered a body that is not JSON`)}}}return o(f,"call"),{async list(){const s=await f("GET","/v1/machines");if(!Array.isArray(s))throw new c(502,"the directory answered a machine list that is not an array");const a=s.map(T),r=t.now();for(const n of a)i.set(n.machine_id,{machine:n,at:r}),p(n.machine_id,n.name);return u={machines:a,at:r},a},lastList(){return u===null?null:u.machines},async reach(s){const a=m(s),r=i.get(a);if(r&&t.now()-r.at<S)return r.machine;try{const n=T(await f("GET",`/v1/machines/${encodeURIComponent(a)}/reach`));return i.set(a,{machine:n,at:t.now()}),p(n.machine_id,n.name),n}catch(n){if(n instanceof c&&n.status===404)return i.delete(a),null;if(r&&n instanceof c&&n.status===0)return r.machine;throw n}},async status(s){const a=e(),r=await f("PUT",`/v1/machines/${encodeURIComponent(a)}/status`,s);if(!r||typeof r.machine_id!="string"||typeof r.url!="string")throw new c(502,"the directory answered a status record with a missing machine_id or url");return{machine_id:r.machine_id,url:r.url.replace(/\/$/,""),reach:E(r.reach)}},invalidate(s){s===void 0?(i.clear(),u=null):i.delete(m(s))}}}o(b,"createDirectoryClient");function k(){return m(g().runtime)}o(k,"ownMachineId");function x(){return M("user").runtime?.issuer??null}o(x,"directoryIssuer");const w=b({issuer:x,tokens:R,fetch:o((t,e)=>fetch(t,e),"fetch"),now:Date.now},k),F=o(()=>w.list(),"listMachines"),G=o(t=>w.reach(t),"machineReach"),$="machine_url";async function J(){return(await(await _()).prepare("SELECT value FROM runtime_state WHERE key = ?").get($))?.value??null}o(J,"machineUrl");async function O(t){await(await _()).prepare("INSERT INTO runtime_state (key, value) VALUES (?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value").run($,t)}o(O,"storeMachineUrl");async function V(t=w){if(x()===null)return null;try{g()}catch{return null}const e=await t.status({plugins:I(),crtr_version:C()});if(e.machine_id!==k())throw new c(502,"the directory answered a status for another machine");return await O(e.url),e}o(V,"reportMachineStatus");export{A as DIRECTORY_CALL_TIMEOUT_MS,c as DirectoryError,S as REACH_TTL_MS,b as createDirectoryClient,w as directory,x as directoryIssuer,F as listMachines,G as machineReach,J as machineUrl,m as normalizeMachineId,k as ownMachineId,V as reportMachineStatus};
|
|
@@ -31,14 +31,14 @@ export interface EnvelopeContext {
|
|
|
31
31
|
/** This machine's id (`runtime:<id>`). */
|
|
32
32
|
via?: string;
|
|
33
33
|
/** A node's run place. */
|
|
34
|
-
placeOf?: (nodeId: string) => RunPlace | null
|
|
34
|
+
placeOf?: (nodeId: string) => Promise<RunPlace | null>;
|
|
35
35
|
}
|
|
36
36
|
/** The envelope for a call made by `principal` on this machine. Broker → its app, node, stored scopes and run place; cron → its app, anchor node
|
|
37
37
|
* (null when unanchored), stored scopes and origin run; person → no inner `act`. */
|
|
38
|
-
export declare function envelopeFor(principal: EnvelopeCaller, context?: EnvelopeContext): Envelope
|
|
38
|
+
export declare function envelopeFor(principal: EnvelopeCaller, context?: EnvelopeContext): Promise<Envelope>;
|
|
39
39
|
export declare function encodeEnvelope(envelope: Envelope): string;
|
|
40
40
|
/** Parse and validate a `Crtr-Envelope` header value. Throws `EnvelopeError` for anything that is not the documented shape. */
|
|
41
41
|
export declare function decodeEnvelope(header: string): Envelope;
|
|
42
42
|
/** The envelope for a `provider.call` made by `caller` to a device machine: the account owner (`sub`), this machine, and the calling app and node
|
|
43
43
|
* (a person has no inner `act`). The device shows it in its recent-activity list and checks nothing in it. */
|
|
44
|
-
export declare function envelopeForProviderCaller(caller: ProviderCaller, sub: string, context?: Pick<EnvelopeContext, 'via' | 'placeOf'>): Envelope
|
|
44
|
+
export declare function envelopeForProviderCaller(caller: ProviderCaller, sub: string, context?: Pick<EnvelopeContext, 'via' | 'placeOf'>): Promise<Envelope>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var p=Object.defineProperty;var
|
|
1
|
+
var p=Object.defineProperty;var c=(e,o)=>p(e,"name",{value:o,configurable:!0});import{joinedOwner as b}from"../directory/join.js";import{runPlace as d}from"../runs/confinement.js";import{ownMachineId as f}from"./directory.js";const y="Crtr-Envelope",h=16*1024;class r extends Error{static{c(this,"EnvelopeError")}constructor(o){super(o),this.name="EnvelopeError"}}async function _(e,o={}){const n=o.via??f(),s=e.class==="person"?"":e.sub,t=o.owner??(s.startsWith("user:")?s:b());if(t==null)throw new r("this machine has no account owner to make a peer call for");if(e.class==="person")return{sub:t,act:{sub:n}};if(e.class==="broker"){const a=await(o.placeOf??(async u=>await d(u)))(e.node);return{sub:t,act:{sub:n,act:{sub:e.app,node:e.node,node_scopes:e.scopes===null?null:[...e.scopes],place:a}}}}return{sub:t,act:{sub:n,act:{sub:e.app,node:e.anchor,node_scopes:e.scopes===null?null:[...e.scopes],place:{run:e.origin_run??"",isolated:e.isolated}}}}}c(_,"envelopeFor");function g(e){return Buffer.from(JSON.stringify(e),"utf8").toString("base64url")}c(g,"encodeEnvelope");const l=c(e=>typeof e=="string"&&e!=="","isString"),i=c(e=>typeof e=="object"&&e!==null&&!Array.isArray(e),"isRecord");function S(e){if(e.length>h)throw new r("the envelope is too large");if(!/^[A-Za-z0-9_-]+$/.test(e))throw new r("the envelope is not base64url");let o;try{o=JSON.parse(Buffer.from(e,"base64url").toString("utf8"))}catch{throw new r("the envelope is not JSON")}if(!i(o)||!l(o.sub)||!o.sub.startsWith("user:"))throw new r("the envelope names no user");const n=o.act;if(!i(n)||!l(n.sub)||!n.sub.startsWith("runtime:"))throw new r("the envelope names no calling machine");const s=n.act;if(s===void 0)return{sub:o.sub,act:{sub:n.sub}};if(!i(s)||!l(s.sub)||!s.sub.startsWith("app:"))throw new r("the envelope names no calling app");const{node:t,node_scopes:a,place:u}=s;if(t!==null&&!l(t))throw new r("the envelope node is not a node id");if(a!==null&&!(Array.isArray(a)&&a.every(l)))throw new r("the envelope node_scopes is not a list of scopes");if(u!==null&&!(i(u)&&typeof u.run=="string"&&typeof u.isolated=="boolean"))throw new r("the envelope place is malformed");return{sub:o.sub,act:{sub:n.sub,act:{sub:s.sub,node:t,node_scopes:a,place:u===null?null:{run:u.run,isolated:u.isolated}}}}}c(S,"decodeEnvelope");async function O(e,o,n={}){const s=n.via??f();if(e.class==="person"||e.grantee===null)return{sub:o,act:{sub:s}};const t=e.node_id===null?null:await(n.placeOf??(async a=>await d(a)))(e.node_id);return{sub:o,act:{sub:s,act:{sub:e.grantee,node:e.node_id,node_scopes:e.nodeScopes===null?null:[...e.nodeScopes],place:t}}}}c(O,"envelopeForProviderCaller");export{y as ENVELOPE_HEADER,r as EnvelopeError,h as MAX_ENVELOPE_BYTES,S as decodeEnvelope,g as encodeEnvelope,_ as envelopeFor,O as envelopeForProviderCaller};
|
package/dist/core/peer/home.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { DatabaseSync } from 'node:sqlite';
|
|
2
1
|
import { type PeerRequest, type PeerResult } from './client.js';
|
|
3
2
|
import { type Machine } from './directory.js';
|
|
3
|
+
import type { CanvasDb } from '../canvas/db.js';
|
|
4
4
|
export type HomeAnswer = {
|
|
5
5
|
where: 'here';
|
|
6
6
|
} | {
|
|
@@ -26,15 +26,15 @@ export interface HomeDeps {
|
|
|
26
26
|
joined(): boolean;
|
|
27
27
|
}
|
|
28
28
|
export declare const defaultHomeDeps: HomeDeps;
|
|
29
|
-
export declare function cachedLocation(db:
|
|
30
|
-
export declare function rememberLocation(db:
|
|
31
|
-
export declare function dropLocation(db:
|
|
29
|
+
export declare function cachedLocation(db: CanvasDb, id: string): Promise<string | null>;
|
|
30
|
+
export declare function rememberLocation(db: CanvasDb, id: string, machine: string, now?: number): Promise<void>;
|
|
31
|
+
export declare function dropLocation(db: CanvasDb, id: string): Promise<void>;
|
|
32
32
|
/** Ask every other machine "do you hold `id`?". First `here`/`moved` wins; unreachable machines are listed. */
|
|
33
|
-
export declare function locate(db:
|
|
33
|
+
export declare function locate(db: CanvasDb, id: string, deps?: HomeDeps, skip?: string): Promise<HomeAnswer>;
|
|
34
34
|
/** Where `id` lives. `hint` is the machine the request names (`?machine=`). */
|
|
35
|
-
export declare function homeOf(db:
|
|
35
|
+
export declare function homeOf(db: CanvasDb, id: string, opts?: {
|
|
36
36
|
hint?: string | null;
|
|
37
37
|
deps?: HomeDeps;
|
|
38
38
|
}): Promise<HomeAnswer>;
|
|
39
39
|
/** A cached or hinted machine said `404 not_here`: forget it and ask everyone else. */
|
|
40
|
-
export declare function relocate(db:
|
|
40
|
+
export declare function relocate(db: CanvasDb, id: string, wrong: string, deps?: HomeDeps): Promise<HomeAnswer>;
|
package/dist/core/peer/home.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var
|
|
2
|
-
ON CONFLICT(id) DO UPDATE SET machine_id = excluded.machine_id, learned_at = excluded.learned_at`).run(r,
|
|
1
|
+
var _=Object.defineProperty;var t=(n,a)=>_(n,"name",{value:a,configurable:!0});import{getById as y}from"../graph/objects.js";import{isUnreachable as E,peerCall as b}from"./client.js";import{directoryIssuer as x,listMachines as O,normalizeMachineId as d,ownMachineId as T}from"./directory.js";import{stubOf as I}from"./stubs.js";const l={call:t((n,a)=>b(n,a),"call"),machines:O,self:T,now:Date.now,joined:t(()=>x()!==null,"joined")};async function L(n,a){return(await n.prepare("SELECT machine_id FROM peer_locations WHERE id = ?").get(a))?.machine_id??null}t(L,"cachedLocation");async function g(n,a,r,i=Date.now()){await n.prepare(`INSERT INTO peer_locations (id, machine_id, learned_at) VALUES (?, ?, ?)
|
|
2
|
+
ON CONFLICT(id) DO UPDATE SET machine_id = excluded.machine_id, learned_at = excluded.learned_at`).run(a,r,i)}t(g,"rememberLocation");async function D(n,a){await n.prepare("DELETE FROM peer_locations WHERE id = ?").run(a)}t(D,"dropLocation");async function f(n,a,r=l,i){if(!r.joined())return{where:"nowhere"};let c;try{c=await r.machines()}catch(e){return{where:"unknown",unreachable:[`directory (${e instanceof Error?e.message:String(e)})`]}}const s=r.self(),p=c.filter(e=>e.machine_id!==s&&e.machine_id!==i&&e.kind!=="device"),m=await Promise.all(p.map(async e=>{const o=await r.call(e.machine_id,{method:"POST",path:"/v1/peer/locate",body:{id:a}});if(E(o))return{m:e,state:"unreachable"};const h=o.body;return o.status===200&&h?.answer==="here"?{m:e,state:"here",machine:e.machine_id}:o.status===200&&h?.answer==="moved"&&typeof h.machine=="string"?{m:e,state:"here",machine:d(h.machine)}:o.status===200&&h?.answer==="no"?{m:e,state:"no"}:{m:e,state:"unreachable"}})),u=m.find(e=>e.state==="here");if(u&&"machine"in u)return await g(n,a,u.machine,r.now()),{where:"machine",machine:u.machine,source:"locate"};const w=m.filter(e=>e.state==="unreachable").map(e=>e.m.name||e.m.machine_id);return w.length>0?{where:"unknown",unreachable:w}:{where:"nowhere"}}t(f,"locate");async function j(n,a,r={}){const i=await y(n,a);if(i!==null){const s=await I(n,i);return s===null?{where:"here"}:{where:"machine",machine:s.home_machine,source:"stub"}}if(!(r.deps??l).joined())return{where:"nowhere"};if(r.hint)return{where:"machine",machine:d(r.hint),source:"hint"};const c=await L(n,a);return c!==null?{where:"machine",machine:c,source:"cache"}:f(n,a,r.deps)}t(j,"homeOf");async function k(n,a,r,i=l){return await D(n,a),f(n,a,i,r)}t(k,"relocate");export{L as cachedLocation,l as defaultHomeDeps,D as dropLocation,j as homeOf,f as locate,k as relocate,g as rememberLocation};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { DatabaseSync } from 'node:sqlite';
|
|
2
1
|
import type { ObjectRow } from '../graph/types.js';
|
|
3
2
|
import { type ClaimedRow, type PeerEventPayload } from './outbox-store.js';
|
|
3
|
+
import { type CanvasDb } from '../canvas/db.js';
|
|
4
4
|
/** Most events one `peer.events` call carries. */
|
|
5
5
|
export declare const MAX_EVENTS_PER_CALL = 100;
|
|
6
6
|
export interface IngestResult {
|
|
@@ -25,11 +25,11 @@ export declare const ingestKey: (via: string, messageId: string) => string;
|
|
|
25
25
|
* an app-made watch of a remote node's object is recorded here as the destination's own watch of the stub (start `act`, all events,
|
|
26
26
|
* never changing a watch that exists), and a row whose message was already applied for another destination is published once more to
|
|
27
27
|
* that destination alone. The delivery key `peer:<via>:<message_id>:<destination>` keeps each destination to one delivery. */
|
|
28
|
-
export declare function ingestPeerEvents(db:
|
|
28
|
+
export declare function ingestPeerEvents(db: CanvasDb, via: string, events: readonly PeerEventPayload[]): Promise<IngestResult>;
|
|
29
29
|
/** Whether `object` is a stub of `machine` (a sender may only describe what it homes). */
|
|
30
|
-
export declare const isStubOf: (db:
|
|
31
|
-
export declare const claimFor: (db:
|
|
32
|
-
export declare const ackFor: (db:
|
|
30
|
+
export declare const isStubOf: (db: CanvasDb, object: ObjectRow, machine: string) => Promise<boolean>;
|
|
31
|
+
export declare const claimFor: (db: CanvasDb, via: string, limit: number) => Promise<ClaimedRow[]>;
|
|
32
|
+
export declare const ackFor: (db: CanvasDb, via: string, acks: ReadonlyArray<{
|
|
33
33
|
key: string;
|
|
34
34
|
claim_token: string;
|
|
35
|
-
}>) => string[]
|
|
35
|
+
}>) => Promise<string[]>;
|
package/dist/core/peer/ingest.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var g=Object.defineProperty;var o=(e,t)=>g(e,"name",{value:t,configurable:!0});import{CrtrError as _}from"../errors.js";import{getById as k,getByRowid as R}from"../graph/objects.js";import{publish as O}from"../graph/events.js";import{markLinkWatch as h,recordWatch as S}from"../graph/watches.js";import{armObjectWaitForWatch as L}from"../graph/object-waits.js";import{ackRows as $,claimRows as T}from"./outbox-store.js";import{ensureStub as u,localOwnerActor as W,stubOf as w}from"./stubs.js";import{withCanvasWrite as x}from"../canvas/db.js";const P=100,U=o(e=>e==="unknown_event"||e==="unknown_kind","isCatalogLag"),y=o((e,t)=>`peer:${e}:${t}`,"ingestKey");async function A(e,t){return await e.prepare("SELECT 1 FROM peer_ingested WHERE key = ?").get(t)!==void 0?!0:await e.prepare("SELECT 1 FROM deliveries WHERE idempotency_key >= ? AND idempotency_key < ? LIMIT 1").get(`${t}:`,`${t};`)!==void 0}o(A,"applied");const f=o(async(e,t,n)=>{await e.prepare("INSERT OR IGNORE INTO peer_ingested_destinations (key, ingested_at) VALUES (?, ?)").run(`${t}:${n}`,Date.now())},"markDestination");async function C(e,t,n){return await e.prepare("SELECT 1 FROM peer_ingested_destinations WHERE key = ?").get(`${t}:${n}`)!==void 0||await e.prepare("SELECT 1 FROM deliveries WHERE idempotency_key = ?").get(`${t}:${n}`)!==void 0}o(C,"destinationDone");async function F(e,t,n){return await W(e,t)??await u(e,t.id,t.type,n,void 0,t)}o(F,"actorFor");async function E(e,t,n,r,a){const c=n.actor===null?null:await F(e,n.actor,t),l=n.body_text,i=n.body===void 0&&l===void 0?void 0:{...n.body??{},...l===void 0?{}:{body:l}};await O(e,{event:n.event,object:r,actor:c,level:n.level,attrs:n.attrs,...i===void 0?{}:{messageBody:i},idempotencyKey:y(t,n.message_id),...a===void 0?{}:{onlyWatchers:a}})}o(E,"apply");async function N(e,t){const n=`ev:${t.message_id}:`;if(!t.key.startsWith(n)||t.key.length===n.length)return null;const r=await k(e,t.key.slice(n.length));return r!==null&&r.type==="node"&&r.deleted_at===null&&await w(e,r)===null?r:null}o(N,"localDestination");async function X(e,t,n){const r={accepted:[],rejected:[]};for(const a of n){const c=y(t,a.message_id),l=await A(e,c);try{await x(async()=>{const i=await N(e,a);if(l&&i===null)return;const s=await u(e,a.object.id,a.object.type,t,void 0,a.object),d=a.linked===!0&&i!==null&&s.owner!==null?await R(e,s.owner):null,p=d!==null&&d.type==="app"?d:null;if(i!==null&&await e.prepare("SELECT 1 FROM watches WHERE watcher = ? AND object = ?").get(i.rowid,s.rowid)===void 0?(await S(e,i,s,"act",{patterns:[">"],...p===null?{}:{linkApp:p}}),await L(e,i,s)):i!==null&&p!==null&&await h(e,i,s,p),l)await C(e,c,i.id)||await E(e,t,a,s,[i.id]);else{await E(e,t,a,s),await e.prepare("INSERT OR IGNORE INTO peer_ingested (key, ingested_at) VALUES (?, ?)").run(c,Date.now());for(const m of await e.prepare("SELECT destination_id FROM deliveries WHERE idempotency_key >= ? AND idempotency_key < ?").all(`${c}:`,`${c};`))await f(e,c,m.destination_id)}i!==null&&await f(e,c,i.id)},{savepoint:!0}),r.accepted.push(a.key)}catch(i){const s=i instanceof _?i.code:"invalid_event";r.rejected.push({key:a.key,code:s,message:i instanceof Error?i.message:String(i)})}}return r}o(X,"ingestPeerEvents");const q=o(async(e,t,n)=>(await w(e,t))?.home_machine===n,"isStubOf"),v=o(async(e,t,n)=>await T(e,t,n),"claimFor"),z=o(async(e,t,n)=>await $(e,t,n),"ackFor");export{P as MAX_EVENTS_PER_CALL,z as ackFor,v as claimFor,y as ingestKey,X as ingestPeerEvents,U as isCatalogLag,q as isStubOf};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { DatabaseSync } from 'node:sqlite';
|
|
2
1
|
import type { ObjectRef } from './stubs.js';
|
|
2
|
+
import type { CanvasDb } from '../canvas/db.js';
|
|
3
3
|
export type OutboxState = 'pending' | 'waiting' | 'claimed' | 'done' | 'expired';
|
|
4
4
|
/** What one event looks like on the wire, in both directions (`peer.events` body, `peer.outbox.claim` rows). */
|
|
5
5
|
export interface PeerEventPayload {
|
|
@@ -42,20 +42,20 @@ export declare const CATALOG_LAG_RETRY_MS: number;
|
|
|
42
42
|
/** Subscribe to enqueues (the delivery lane pushes a relay peer's row at once). Returns the unsubscribe. */
|
|
43
43
|
export declare function onPeerEnqueued(listener: (peer: string) => void): () => void;
|
|
44
44
|
/** Write one row; a key already present adds nothing. Returns whether a row was added. Runs in the caller's transaction. */
|
|
45
|
-
export declare function enqueuePeerRow(db:
|
|
45
|
+
export declare function enqueuePeerRow(db: CanvasDb, row: {
|
|
46
46
|
peer: string;
|
|
47
47
|
kind: string;
|
|
48
48
|
key: string;
|
|
49
49
|
payload: unknown;
|
|
50
|
-
}, now?: number): boolean
|
|
50
|
+
}, now?: number): Promise<boolean>;
|
|
51
51
|
/** Rows the lane may push now: pending and due. */
|
|
52
|
-
export declare function dueRows(db:
|
|
52
|
+
export declare function dueRows(db: CanvasDb, now: number, limit?: number): Promise<OutboxRow[]>;
|
|
53
53
|
/** Pending rows to one peer that are new or due (a relay peer's push at enqueue; a row that already failed waits for its backoff). */
|
|
54
|
-
export declare function pendingFor(db:
|
|
55
|
-
export declare const markDone: (db:
|
|
56
|
-
export declare const markWaiting: (db:
|
|
57
|
-
export declare const markRetry: (db:
|
|
58
|
-
export declare const markExpired: (db:
|
|
54
|
+
export declare function pendingFor(db: CanvasDb, peer: string, now: number, limit?: number): Promise<OutboxRow[]>;
|
|
55
|
+
export declare const markDone: (db: CanvasDb, id: number) => Promise<void>;
|
|
56
|
+
export declare const markWaiting: (db: CanvasDb, id: number, attempts: number) => Promise<void>;
|
|
57
|
+
export declare const markRetry: (db: CanvasDb, id: number, attempts: number, nextAt: number, firstFailedAt: number) => Promise<void>;
|
|
58
|
+
export declare const markExpired: (db: CanvasDb, id: number) => Promise<void>;
|
|
59
59
|
export interface ClaimedRow {
|
|
60
60
|
key: string;
|
|
61
61
|
claim_token: string;
|
|
@@ -63,14 +63,14 @@ export interface ClaimedRow {
|
|
|
63
63
|
}
|
|
64
64
|
/** The calling machine's own rows (`peer = via`, never another's), fenced with a fresh token. Takes pending and waiting rows
|
|
65
65
|
* and claims whose lease ran out; a row still under a live lease is left alone. */
|
|
66
|
-
export declare function claimRows(db:
|
|
66
|
+
export declare function claimRows(db: CanvasDb, via: string, limit: number, now?: number): Promise<ClaimedRow[]>;
|
|
67
67
|
/** Mark done the rows the caller still holds: `peer = via`, the same token, still `claimed`. Returns the keys acked. */
|
|
68
|
-
export declare function ackRows(db:
|
|
68
|
+
export declare function ackRows(db: CanvasDb, via: string, acks: ReadonlyArray<{
|
|
69
69
|
key: string;
|
|
70
70
|
claim_token: string;
|
|
71
|
-
}>): string[]
|
|
71
|
+
}>): Promise<string[]>;
|
|
72
72
|
/** Retire rows done long ago, so the table stays small. */
|
|
73
|
-
export declare function pruneOutbox(db:
|
|
73
|
+
export declare function pruneOutbox(db: CanvasDb, now: number, keepMs?: number): Promise<void>;
|
|
74
74
|
/** Give up on rows older than `OUTBOX_MAX_AGE_MS` that were never delivered, and on rows whose claim lapsed unacked (the receiver
|
|
75
75
|
* refused them as catalog lag and left them to be claimed again) once they are older than `CATALOG_LAG_RETRY_MS`. Returns how many. */
|
|
76
|
-
export declare function expireOld(db:
|
|
76
|
+
export declare function expireOld(db: CanvasDb, now: number): Promise<number>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var
|
|
2
|
-
VALUES (?, ?, ?, ?, 'pending', 0, ?, ?) ON CONFLICT (idempotency_key) DO NOTHING`).run(e.peer,e.kind,JSON.stringify(e.payload),e.key,
|
|
3
|
-
AND (state IN ('pending', 'waiting') OR (state = 'claimed' AND claimed_at <= ?)) ORDER BY id LIMIT ?`).all(e,
|
|
4
|
-
AND state = 'claimed' AND claimed_by = ?`);return
|
|
5
|
-
WHERE (state IN ('pending', 'waiting') AND created_at < ?) OR (state = 'claimed' AND claimed_at <= ? AND created_at < ?)`).run(e-
|
|
1
|
+
var _=Object.defineProperty;var n=(t,e)=>_(t,"name",{value:e,configurable:!0});import{randomBytes as u}from"node:crypto";import{filterAsync as x,mapAsync as m}from"../async-array.js";const c=10*6e4,y=720*60*6e4,N=1440*6e4,o=new Set;function l(t){return o.add(t),()=>{o.delete(t)}}n(l,"onPeerEnqueued");async function L(t,e,a=Date.now()){const r=await t.prepare(`INSERT INTO peer_outbox (peer, kind, payload_json, idempotency_key, state, attempts, next_at, created_at)
|
|
2
|
+
VALUES (?, ?, ?, ?, 'pending', 0, ?, ?) ON CONFLICT (idempotency_key) DO NOTHING`).run(e.peer,e.kind,JSON.stringify(e.payload),e.key,a,a);return Number(r.changes)===0?!1:(setImmediate(()=>{for(const i of[...o])try{i(e.peer)}catch{}}),!0)}n(L,"enqueuePeerRow");async function T(t,e,a=200){return await t.prepare("SELECT * FROM peer_outbox WHERE state = 'pending' AND next_at <= ? ORDER BY id LIMIT ?").all(e,a)}n(T,"dueRows");async function O(t,e,a,r=50){return await t.prepare("SELECT * FROM peer_outbox WHERE state = 'pending' AND peer = ? AND (attempts = 0 OR next_at <= ?) ORDER BY id LIMIT ?").all(e,a,r)}n(O,"pendingFor");const g=n(async(t,e)=>{await t.prepare("UPDATE peer_outbox SET state = 'done', claimed_by = NULL, next_at = NULL WHERE id = ? AND state IN ('pending', 'waiting')").run(e)},"markDone"),S=n(async(t,e,a)=>{await t.prepare("UPDATE peer_outbox SET state = 'waiting', attempts = ?, next_at = NULL WHERE id = ? AND state = 'pending'").run(a,e)},"markWaiting"),b=n(async(t,e,a,r,i)=>{await t.prepare("UPDATE peer_outbox SET attempts = ?, next_at = ?, first_failed_at = ? WHERE id = ? AND state = 'pending'").run(a,r,i,e)},"markRetry"),f=n(async(t,e)=>{await t.prepare("UPDATE peer_outbox SET state = 'expired', next_at = NULL WHERE id = ? AND state IN ('pending', 'waiting')").run(e)},"markExpired");async function k(t,e,a,r=Date.now()){const i=Math.max(1,Math.min(a,100)),d=await t.prepare(`SELECT * FROM peer_outbox WHERE peer = ?
|
|
3
|
+
AND (state IN ('pending', 'waiting') OR (state = 'claimed' AND claimed_at <= ?)) ORDER BY id LIMIT ?`).all(e,r-c,i),s=u(16).toString("hex"),E=t.prepare("UPDATE peer_outbox SET state = 'claimed', claimed_by = ?, claimed_at = ?, next_at = NULL WHERE id = ?");return await m(d,async p=>(await E.run(s,r,p.id),{key:p.idempotency_key,claim_token:s,payload:JSON.parse(p.payload_json)}))}n(k,"claimRows");async function w(t,e,a){const r=t.prepare(`UPDATE peer_outbox SET state = 'done', claimed_by = NULL WHERE idempotency_key = ? AND peer = ?
|
|
4
|
+
AND state = 'claimed' AND claimed_by = ?`);return(await x(a,async i=>Number((await r.run(i.key,e,i.claim_token)).changes)>0)).map(i=>i.key)}n(w,"ackRows");async function I(t,e,a=1440*6e4){await t.prepare("DELETE FROM peer_outbox WHERE state IN ('done', 'expired') AND created_at < ?").run(e-a)}n(I,"pruneOutbox");async function U(t,e){return Number((await t.prepare(`UPDATE peer_outbox SET state = 'expired', next_at = NULL
|
|
5
|
+
WHERE (state IN ('pending', 'waiting') AND created_at < ?) OR (state = 'claimed' AND claimed_at <= ? AND created_at < ?)`).run(e-y,e-c,e-N)).changes)}n(U,"expireOld");export{N as CATALOG_LAG_RETRY_MS,c as CLAIM_LEASE_MS,y as OUTBOX_MAX_AGE_MS,w as ackRows,k as claimRows,T as dueRows,L as enqueuePeerRow,U as expireOld,g as markDone,f as markExpired,b as markRetry,S as markWaiting,l as onPeerEnqueued,O as pendingFor,I as pruneOutbox};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { DatabaseSync } from 'node:sqlite';
|
|
2
1
|
import type { Receiver } from '../graph/receivers.js';
|
|
3
2
|
import { type PeerEventPayload } from './outbox-store.js';
|
|
3
|
+
import type { CanvasDb } from '../canvas/db.js';
|
|
4
4
|
/** The outbox key of one event to one destination stub. */
|
|
5
5
|
export declare const eventKey: (messageId: string, destination: string) => string;
|
|
6
6
|
/** The event as it crosses the wire: the object and actor by identity, the attributes, and the body inline. */
|
|
7
|
-
export declare function payloadFor(db:
|
|
7
|
+
export declare function payloadFor(db: CanvasDb, messageId: string, key: string): Promise<PeerEventPayload>;
|
|
8
8
|
export declare const peerReceiver: Receiver;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var p=Object.defineProperty;var
|
|
1
|
+
var p=Object.defineProperty;var a=(t,n)=>p(t,"name",{value:n,configurable:!0});import{heads as y}from"../graph/documents.js";import{bodyOf as _}from"../graph/bodies.js";import{getById as s}from"../graph/objects.js";import{enqueuePeerRow as m}from"./outbox-store.js";import{describeObject as l,stubOf as w}from"./stubs.js";const b=a((t,n)=>`ev:${t}:${n}`,"eventKey");async function j(t,n){const i=typeof n?.pointer=="string"?n.pointer:void 0,e=i===void 0?null:await s(t,i);if(e===null||e.type!=="document"||e.deleted_at!==null)return;const o=(await y(t,e))[0];if(o===void 0)return;const r=await t.prepare("SELECT source_path FROM documents WHERE object = ?").get(e.rowid);return _(o.body_hash,r?.source_path??null)}a(j,"reportText");async function g(t,n,i){const e=await t.prepare("SELECT message_id, event, object_id, level, actor_id, body_ref, body_json FROM messages WHERE message_id = ?").get(n);if(e===void 0)throw new Error(`no message ${n}`);const o=await s(t,e.object_id);if(o===null)throw new Error(`no object ${e.object_id}`);const r=e.actor_id===null?null:await s(t,e.actor_id),f=e.body_json===null?{}:JSON.parse(e.body_json),{push:d,bodyRef:h,...c}=f,u=e.body_ref===null?void 0:await j(t,d);return{key:i,message_id:e.message_id,event:e.event,level:e.level,object:await l(t,o),actor:r===null?null:await l(t,r),attrs:d?.attrs??{},...Object.keys(c).length>0?{body:c}:{},...u===void 0?{}:{body_text:u}}}a(g,"payloadFor");const T={bodyOwner:a(()=>null,"bodyOwner"),async enqueue(t,n,i){for(const e of i){const o=await w(t,e.id);if(o===null)continue;const r=b(n.messageId,e.id);await m(t,{peer:o.home_machine,kind:"event",key:r,payload:{...await g(t,n.messageId,r),...e.linked?{linked:!0}:{}}})}}};export{b as eventKey,g as payloadFor,T as peerReceiver};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import type { DatabaseSync } from 'node:sqlite';
|
|
2
1
|
import type { ObjectRow, Privacy } from '../graph/types.js';
|
|
3
2
|
import { type CustomEvents } from '../graph/custom.js';
|
|
4
3
|
import type { ObjectDTO } from '../../api/dto/objects.js';
|
|
5
4
|
import type { Envelope } from './envelope.js';
|
|
5
|
+
import type { CanvasDb } from '../canvas/db.js';
|
|
6
6
|
/** The part of an envelope a stub stores: who the remote watcher is, never what it may do. */
|
|
7
7
|
export interface StubIdentity {
|
|
8
8
|
sub: string;
|
|
@@ -50,12 +50,12 @@ export interface StubRecord {
|
|
|
50
50
|
identity: StubIdentity | null;
|
|
51
51
|
}
|
|
52
52
|
export declare const identityOfEnvelope: (envelope: Envelope) => StubIdentity;
|
|
53
|
-
export declare function stubOf(db:
|
|
54
|
-
export declare const isStub: (db:
|
|
53
|
+
export declare function stubOf(db: CanvasDb, object: ObjectRow | string): Promise<StubRecord | null>;
|
|
54
|
+
export declare const isStub: (db: CanvasDb, object: ObjectRow) => Promise<boolean>;
|
|
55
55
|
/** The local object for an app or person the other machine names as an event's actor, or null for any other type. An app or person is an
|
|
56
56
|
* owner, not a thing that lives on one machine: it is the same object here as there, so it is never given a stub (a stub would collide
|
|
57
57
|
* with the local owner object of the same handle, as with an installed plugin's app). */
|
|
58
|
-
export declare function localOwnerActor(db:
|
|
58
|
+
export declare function localOwnerActor(db: CanvasDb, ref: ObjectRef): Promise<ObjectRow | null>;
|
|
59
59
|
/**
|
|
60
60
|
* The stub of the object `id` that lives on `machine`, created on first sight. Idempotent: a second
|
|
61
61
|
* call returns the same row and, given an `envelope`, replaces the identity it stores. Refuses
|
|
@@ -63,7 +63,7 @@ export declare function localOwnerActor(db: DatabaseSync, ref: ObjectRef): Objec
|
|
|
63
63
|
* local app (or person) object of the remote owner, so the stub sits in a space the access rules
|
|
64
64
|
* understand. No `nodes` row is written.
|
|
65
65
|
*/
|
|
66
|
-
export declare function ensureStub(db:
|
|
66
|
+
export declare function ensureStub(db: CanvasDb, id: string, type: string, machine: string, envelope?: Envelope, ref?: ObjectRef): Promise<ObjectRow>;
|
|
67
67
|
/**
|
|
68
68
|
* The stub of the node `nodeId` that lives on `machine`, as a watcher: created on first sight with no envelope
|
|
69
69
|
* identity, owned by the local person, and marked `reception = 2` so `publish` considers it and the node
|
|
@@ -71,12 +71,12 @@ export declare function ensureStub(db: DatabaseSync, id: string, type: string, m
|
|
|
71
71
|
* identity on the same row (`ensureStub` with an envelope). Refuses (`conflict`) an id that is a real local
|
|
72
72
|
* object or a stub of another machine. Writes no `nodes` row.
|
|
73
73
|
*/
|
|
74
|
-
export declare function ensureNodeStub(db:
|
|
74
|
+
export declare function ensureNodeStub(db: CanvasDb, nodeId: string, machine: string): Promise<ObjectRow>;
|
|
75
75
|
/** The object moved: the machine that answered for it is now its home. A no-op for a local object or a stub already homed there. */
|
|
76
|
-
export declare function rehomeStub(db:
|
|
76
|
+
export declare function rehomeStub(db: CanvasDb, id: string, machine: string): Promise<void>;
|
|
77
77
|
/** How `o` is described to another machine. */
|
|
78
|
-
export declare function describeObject(db:
|
|
78
|
+
export declare function describeObject(db: CanvasDb, o: ObjectRow): Promise<ObjectRef>;
|
|
79
79
|
/** The declaration of the custom kind `type`, or null for a built-in (no `object_kinds` row). Carries no `read` leaf. */
|
|
80
|
-
export declare function kindDeclarationOf(db:
|
|
80
|
+
export declare function kindDeclarationOf(db: CanvasDb, type: string): Promise<KindDeclaration | null>;
|
|
81
81
|
/** `dto` with the declaration of its object's kind, when the kind is custom. */
|
|
82
|
-
export declare function withKindDecl(db:
|
|
82
|
+
export declare function withKindDecl(db: CanvasDb, row: ObjectRow, dto: ObjectDTO): Promise<ObjectDTO>;
|
package/dist/core/peer/stubs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var O=Object.defineProperty;var i=(n,e)=>O(n,"name",{value:e,configurable:!0});import{createObject as x,ensureOwner as y,getById as _,getByRowid as u}from"../graph/objects.js";import{upsertKind as A}from"../graph/custom.js";import{CrtrError as d}from"../errors.js";import{ExitCode as E}from"../../types.js";import{normalizeMachineId as b}from"./names.js";const H=["public","friends","private"],N=i(n=>{const e=n.act.act;return e===void 0?{sub:n.sub,app:null,node:null,node_scopes:null,place:null}:{sub:n.sub,app:e.sub,node:e.node,node_scopes:e.node_scopes,place:e.place}},"identityOfEnvelope");async function h(n,e){const r=typeof e=="string"?await _(n,e):e;if(r===null)return null;const t=await n.prepare("SELECT home_machine, envelope_json FROM peer_stubs WHERE object = ?").get(r.rowid);return t?{object:r,home_machine:t.home_machine,identity:t.envelope_json===null?null:JSON.parse(t.envelope_json)}:null}i(h,"stubOf");const U=i(async(n,e)=>await n.prepare("SELECT 1 FROM peer_stubs WHERE object = ?").get(e.rowid)!==void 0,"isStub");async function l(n){return await y(n,"person","local-user","user:local","user")}i(l,"localPerson");async function f(n,e){return e==="user:local"?await l(n):await y(n,"app","app",e,e.replace(/^app:/,""))}i(f,"localApp");async function C(n,e){return e.type==="app"?await f(n,`app:${e.name}`):e.type==="person"?await l(n):null}i(C,"localOwnerActor");async function v(n,e,r){if(e!==null)return e.app===null?await l(n):await f(n,e.app);const t=r?.owner;return t?.type==="app"?await f(n,t.external_id??`app:${t.handle}`):await l(n)}i(v,"ownerFor");async function W(n,e,r,t,m,a){const c=m===void 0?null:N(m),p=a?.privacy??"public";if(!H.includes(p))throw new d("invalid_event",`invalid privacy ${JSON.stringify(p)}`,E.GENERAL,{id:e});const o=await _(n,e);if(o!==null){const s=await h(n,o);if(s===null)throw new d("conflict",`${e} is a local ${o.type}, not a stub of ${t}`,E.GENERAL,{id:e});if(s.home_machine!==t)throw new d("conflict",`${e} is already a stub of ${s.home_machine}, not ${t}`,E.GENERAL,{id:e,home_machine:s.home_machine});return c!==null&&(await n.prepare("UPDATE peer_stubs SET envelope_json = ? WHERE object = ?").run(JSON.stringify(c),o.rowid),await n.prepare("UPDATE objects SET reception = 2 WHERE rowid = ?").run(o.rowid)),a!==void 0&&(await S(n,r,a),a.privacy!==void 0&&o.privacy!==p)?(await n.prepare("UPDATE objects SET privacy = ? WHERE rowid = ?").run(p,o.rowid),await u(n,o.rowid)):o}const T=await v(n,c,a);await S(n,r,a);const w=await x(n,{id:e,type:r,kind:a?.kind??null,owner:T.rowid,privacy:p,name:a?.name??e,preview:a?.preview??"",home_machine:t});return await n.prepare("INSERT INTO peer_stubs (object, home_machine, envelope_json, created_at) VALUES (?, ?, ?, ?)").run(w.rowid,t,c===null?null:JSON.stringify(c),new Date().toISOString()),c!==null&&await n.prepare("UPDATE objects SET reception = 2 WHERE rowid = ?").run(w.rowid),await u(n,w.rowid)}i(W,"ensureStub");async function S(n,e,r){const t=r?.kind_decl;t===void 0||t.name!==e||await A(n,{name:t.name,owner:await v(n,null,{...r,owner:t.owner}),description:t.description,events:t.events,read:null,source:"peer"})}i(S,"holdKind");async function I(n,e,r){const t=await W(n,e,"node",b(r));return await n.prepare("UPDATE objects SET reception = 2 WHERE rowid = ?").run(t.rowid),await u(n,t.rowid)}i(I,"ensureNodeStub");async function F(n,e,r){const t=await h(n,e);t===null||t.home_machine===r||(await n.prepare("UPDATE peer_stubs SET home_machine = ? WHERE object = ?").run(r,t.object.rowid),await n.prepare("UPDATE objects SET home_machine = ? WHERE rowid = ?").run(r,t.object.rowid))}i(F,"rehomeStub");async function J(n,e){const r=await R(n,e.owner===null?null:await u(n,e.owner)),t=await j(n,e.type);return{id:e.id,type:e.type,kind:e.kind,name:e.name,preview:e.preview,owner:r,privacy:e.privacy,...t===null?{}:{kind_decl:t}}}i(J,"describeObject");async function R(n,e){if(e===null||e.type!=="person"&&e.type!=="app"&&e.type!=="repo"&&e.type!=="profile")return null;const r=await n.prepare("SELECT scheme, external_id FROM identities WHERE object = ?").get(e.rowid);return{id:e.id,type:e.type,scheme:r?.scheme??null,external_id:r?.external_id??null,handle:e.name}}i(R,"ownerRefOf");async function j(n,e){const r=await n.prepare("SELECT owner, description, events_json FROM object_kinds WHERE name = ?").get(e),t=r===void 0?null:await R(n,await u(n,r.owner));return r===void 0||t===null?null:{name:e,description:r.description,events:JSON.parse(r.events_json),owner:t}}i(j,"kindDeclarationOf");async function M(n,e,r){const t=await j(n,e.type);return t===null?r:{...r,kind_decl:t}}i(M,"withKindDecl");export{J as describeObject,I as ensureNodeStub,W as ensureStub,N as identityOfEnvelope,U as isStub,j as kindDeclarationOf,C as localOwnerActor,F as rehomeStub,h as stubOf,M as withKindDecl};
|
|
@@ -9,11 +9,11 @@ export interface ApprovalQuestion {
|
|
|
9
9
|
}>;
|
|
10
10
|
}
|
|
11
11
|
/** A runless repeat consumes an answer exactly once, before any provider request. */
|
|
12
|
-
export declare function consumeApproval(caller: ProviderCaller, input: ProviderCallInput, callShape: string): {
|
|
12
|
+
export declare function consumeApproval(caller: ProviderCaller, input: ProviderCallInput, callShape: string): Promise<{
|
|
13
13
|
option: string;
|
|
14
14
|
requestId: string;
|
|
15
15
|
prepared: PreparedFileCall | null;
|
|
16
|
-
}
|
|
16
|
+
}>;
|
|
17
17
|
/** Called when the human ticket settles (answer or cancel), in the settlement transaction. */
|
|
18
18
|
export declare function notifyProviderApproval(questionId: string): void;
|
|
19
19
|
/** Create a page and either suspend a run or return its durable id to an app. */
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var g=Object.defineProperty;var a=(r,e)=>g(r,"name",{value:e,configurable:!0});import{createHash as b}from"node:crypto";import{openDb as f}from"../canvas/db.js";import{newNodeId as q}from"../runtime/nodes.js";import{createPageRequest as E,getRequest as A}from"../human/requests.js";import{providerApprovalPage as S}from"../runs/questions.js";import{ProviderError as c}from"./errors.js";function h(r){return Array.isArray(r)?r.map(h):r!==null&&typeof r=="object"?Object.fromEntries(Object.entries(r).sort(([e],[i])=>e.localeCompare(i)).map(([e,i])=>[e,h(i)])):r}a(h,"canonical");function m(r){return b("sha256").update(JSON.stringify(h(r))).digest("hex")}a(m,"hashArgs");function w(){return new c("invalid_request","approval is not an answered question for this call",{param:"approval"})}a(w,"invalidApproval");function s(){return new c("user_denied","the user did not approve this call")}a(s,"denied");function N(r){if(r.aborted)throw s()}a(N,"canceled");async function v(r){return await(await f()).prepare("SELECT * FROM provider_approvals WHERE question_id = ?").get(r)}a(v,"row");async function x(r,e,i){const o=e.approval;if(!o||r.run_id!==null||r.grantee===null||r.sub===null)throw w();const t=await v(o);if(!t||t.grantee!==r.grantee||t.sub!==r.sub||t.provider!==e.provider||t.tool!==e.tool||t.version!==(e.version??null)||t.args_hash!==m(e.arguments)||t.call_shape!==i)throw w();const p=await A(o);if(!p||p.state!=="settled"||p.outcome!=="answered"||t.status!=="answered")throw w();const n=t.option_id;if(!n||(await(await f()).prepare("UPDATE provider_approvals SET status = 'consumed' WHERE question_id = ? AND status = 'answered'").run(o)).changes!==1)throw w();if(n==="deny")throw s();return{option:n,requestId:t.request_id,prepared:t.prepared_files?JSON.parse(t.prepared_files):null}}a(x,"consumeApproval");function O(r){if(!r||typeof r!="object"||Array.isArray(r))throw new c("provider_error","provider approval question is invalid",{origin:"provider"});const e=r,i=e.options;if(typeof e.title!="string"||!e.title.trim()||typeof e.body!="string"||!Array.isArray(i)||i.length===0||i.some(o=>!o||typeof o!="object"||typeof o.option_id!="string"||!/^[A-Za-z0-9_-]{1,64}$/.test(o.option_id)||o.option_id==="deny"||typeof o.label!="string"||!o.label.trim())||new Set(i.map(o=>o.option_id)).size!==i.length)throw new c("provider_error","provider approval question is invalid",{origin:"provider"});return e}a(O,"validateQuestion");const l=new Map;function M(r){for(const e of l.get(r)??[])queueMicrotask(e)}a(M,"notifyProviderApproval");async function R(r,e){const i=a(async()=>{const t=await v(r);if(!t||t.status==="canceled")throw s();return t.status==="answered"?t.option_id:null},"read");if(e.aborted)throw s();let o=await i();if(o==="deny")throw s();if(o!==null)return o;if(await new Promise(async t=>{const p=l.get(r)??new Set,n=a(()=>{e.removeEventListener("abort",n),p.delete(n),p.size||l.delete(r),t()},"wake");p.add(n),l.set(r,p),e.addEventListener("abort",n,{once:!0}),(e.aborted||(await v(r))?.status!=="open")&&n()}),e.aborted||(o=await i(),o===null||o==="deny"))throw s();return o}a(R,"waitForApproval");async function z(r,e,i,o,t,p,n){const _=O(o);if(!r.sub||!r.grantee)throw new c("grant_revoked","caller has no active grant");N(t);const d=await q();await(await f()).prepare(`INSERT INTO provider_approvals
|
|
2
2
|
(question_id, grantee, sub, provider, tool, version, args_hash, request_id, status, call_shape, prepared_files)
|
|
3
|
-
VALUES (?, ?, ?, ?, ?, ?, ?, ?, 'open', ?, ?)`).run(d,r.grantee,r.sub,e.provider,e.tool,e.version??null,
|
|
3
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, 'open', ?, ?)`).run(d,r.grantee,r.sub,e.provider,e.tool,e.version??null,m(e.arguments),i,p??null,n&&(n.copies.length||n.upload)?JSON.stringify(n):null);try{await E({request_id:d,requester_node_id:r.run_id?r.node_id:null,prepared:S(_)})}catch(u){throw await(await f()).prepare("DELETE FROM provider_approvals WHERE question_id = ? AND status = 'open'").run(d),u}if(!r.run_id){if(t.aborted){const{cancelHumanTicket:u}=await import("../../daemon/human/finish.js");throw await u(d,{reason:"the provider call was canceled"}),s()}throw new c("approval_pending","the provider requires the user to answer a question",{question_id:d})}try{const u=await R(d,t);if(t.aborted)throw s();return{option:u,questionId:d}}catch(u){if(t.aborted){const{cancelHumanTicket:y}=await import("../../daemon/human/finish.js");throw await y(d,{reason:"the provider call was canceled"}),s()}throw u}}a(z,"requireProviderApproval");export{x as consumeApproval,M as notifyProviderApproval,z as requireProviderApproval};
|
|
@@ -12,7 +12,7 @@ export interface ProviderAudit {
|
|
|
12
12
|
question_id?: string;
|
|
13
13
|
}
|
|
14
14
|
/** One row per authorization, including refusals before a token is minted. */
|
|
15
|
-
export declare function writeProviderAudit(row: ProviderAudit): void
|
|
15
|
+
export declare function writeProviderAudit(row: ProviderAudit): Promise<void>;
|
|
16
16
|
export interface AuditFilters {
|
|
17
17
|
after?: number;
|
|
18
18
|
limit: number;
|
|
@@ -22,7 +22,7 @@ export interface AuditFilters {
|
|
|
22
22
|
since?: string;
|
|
23
23
|
until?: string;
|
|
24
24
|
}
|
|
25
|
-
export declare function listAudit(grantee: string | null, filters: AuditFilters): {
|
|
25
|
+
export declare function listAudit(grantee: string | null, filters: AuditFilters): Promise<{
|
|
26
26
|
rows: Record<string, unknown>[];
|
|
27
27
|
next: string | null;
|
|
28
|
-
}
|
|
28
|
+
}>;
|