@north-light/cli 0.3.668 → 0.3.669
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/client.d.ts +8 -0
- package/dist/api/client.js +3 -3
- package/dist/api/contract.d.ts +1 -1
- package/dist/api/contract.js +1 -1
- package/dist/api/dto/docs.d.ts +1 -1
- package/dist/api/dto/imports.d.ts +5 -1
- package/dist/api/dto/objects.d.ts +2 -2
- package/dist/api/dto/profiles.d.ts +6 -2
- package/dist/api/dto/profiles.js +1 -1
- package/dist/api/dto/repo-import.d.ts +25 -0
- package/dist/api/dto/repo-import.js +0 -0
- package/dist/api/routes.d.ts +2 -0
- package/dist/api/routes.js +1 -1
- package/dist/builtin-memory/crouter-concepts/documents.md +1 -1
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/claude-plugin-commands.ts +2 -1
- package/dist/clients/attach/session/profile-files.js +1 -1
- package/dist/clients/attach/viewer.js +479 -479
- package/dist/clients/dashboard/app.js +2 -2
- package/dist/commands/canvas/share.js +2 -2
- package/dist/commands/doc/shared.d.ts +1 -1
- package/dist/commands/doc/shared.js +1 -1
- package/dist/commands/node-lifecycle-revive.d.ts +10 -0
- package/dist/commands/node-lifecycle-revive.js +1 -1
- package/dist/commands/pkg/plugin-inspect.js +1 -1
- package/dist/commands/profile/list.js +1 -1
- package/dist/commands/profile/project.js +1 -1
- package/dist/commands/profile/show.js +1 -1
- package/dist/commands/sys/panels/profiles-panel.js +1 -1
- package/dist/commands/sys/repo-docs.d.ts +1 -0
- package/dist/commands/sys/repo-docs.js +2 -0
- package/dist/commands/sys/sync-project-guidance.js +5 -5
- package/dist/commands/sys.js +1 -1
- package/dist/core/broker-client/transport-relay.d.ts +3 -0
- package/dist/core/broker-client/transport-relay.js +1 -1
- package/dist/core/canvas/db.js +4 -4
- package/dist/core/canvas/export-sqlite.js +1 -1
- package/dist/core/canvas/schema-pg/021-repo-docs.sql +38 -0
- package/dist/core/canvas/schema-version.d.ts +1 -1
- package/dist/core/canvas/schema-version.js +1 -1
- package/dist/core/checkout-identities.d.ts +15 -0
- package/dist/core/checkout-identities.js +3 -0
- package/dist/core/graph/bodies-boot-copy.d.ts +1 -1
- package/dist/core/graph/bodies-boot-copy.js +1 -1
- package/dist/core/graph/custom.js +9 -9
- package/dist/core/graph/documents.d.ts +1 -1
- package/dist/core/graph/documents.js +11 -11
- package/dist/core/graph/events.js +1 -1
- package/dist/core/graph/group-invites.d.ts +10 -0
- package/dist/core/graph/group-invites.js +1 -0
- package/dist/core/graph/groups.d.ts +27 -0
- package/dist/core/graph/groups.js +3 -0
- package/dist/core/graph/kinds/owner.js +2 -2
- package/dist/core/graph/names.d.ts +2 -2
- package/dist/core/graph/names.js +10 -10
- package/dist/core/graph/objects.d.ts +4 -1
- package/dist/core/graph/objects.js +10 -10
- package/dist/core/graph/package-publish.js +3 -3
- package/dist/core/graph/package-reconcile.js +2 -2
- package/dist/core/graph/reader.d.ts +19 -8
- package/dist/core/graph/reader.js +3 -3
- package/dist/core/graph/repo-sync/exchange.d.ts +0 -11
- package/dist/core/graph/repo-sync/exchange.js +1 -2
- package/dist/core/graph/repo-sync/identity.d.ts +4 -0
- package/dist/core/graph/repo-sync/ref-format.d.ts +0 -29
- package/dist/core/graph/repo-sync/ref-format.js +1 -2
- package/dist/core/graph/repo-sync/repos.d.ts +12 -2
- package/dist/core/graph/repo-sync/repos.js +4 -3
- package/dist/core/graph/types.d.ts +2 -2
- package/dist/core/human/page-schema.d.ts +1 -1
- package/dist/core/import/export/stores.js +4 -1
- package/dist/core/import/load/stores.js +2 -2
- package/dist/core/peer/stubs.d.ts +1 -1
- package/dist/core/peer/stubs.js +1 -1
- package/dist/core/permissions/builtin.d.ts +1 -1
- package/dist/core/permissions/builtin.js +4 -2
- package/dist/core/permissions/ceiling.js +9 -9
- package/dist/core/profiles/manifest.d.ts +7 -2
- package/dist/core/profiles/manifest.js +1 -1
- package/dist/core/profiles/select.js +21 -21
- package/dist/core/runtime/bearings-render.js +8 -8
- package/dist/core/runtime/deliver-live.js +1 -1
- package/dist/core/runtime/resume-root.d.ts +1 -0
- package/dist/core/runtime/resume-root.js +7 -7
- package/dist/core/runtime/runner/machine/call.js +2 -2
- package/dist/core/runtime/runner/machine/executor.d.ts +1 -1
- package/dist/core/runtime/runner/machine/ops.d.ts +11 -1
- package/dist/core/runtime/runner/machine/ops.js +1 -1
- package/dist/core/scope.js +1 -1
- package/dist/core/scoped-state/db.js +2 -2
- package/dist/core/scoped-state/legacy-profiles.js +2 -1
- package/dist/core/scoped-state/person-rows.js +6 -3
- package/dist/core/scoped-state/schema.d.ts +4 -0
- package/dist/core/scoped-state/schema.js +5 -4
- package/dist/core/substrate/delivery/deliver.js +2 -2
- package/dist/core/substrate/delivery/plan.js +2 -3
- package/dist/core/substrate/subject.js +1 -1
- package/dist/daemon/api/canvas-host.d.ts +1 -0
- package/dist/daemon/api/canvas-host.js +1 -1
- package/dist/daemon/api/document-page.js +5 -5
- package/dist/daemon/api/handlers/broker-ops.js +1 -1
- package/dist/daemon/api/handlers/delivery.js +1 -1
- package/dist/daemon/api/handlers/docs.d.ts +1 -12
- package/dist/daemon/api/handlers/docs.js +2 -2
- package/dist/daemon/api/handlers/memory.js +1 -1
- package/dist/daemon/api/handlers/objects.js +1 -1
- package/dist/daemon/api/handlers/profiles.d.ts +1 -1
- package/dist/daemon/api/handlers/profiles.js +1 -1
- package/dist/daemon/api/handlers/repo-import.d.ts +2 -0
- package/dist/daemon/api/handlers/repo-import.js +2 -0
- package/dist/daemon/api/handlers/reviews.js +1 -1
- package/dist/daemon/api/handlers/shares.js +1 -1
- package/dist/daemon/api/operations.js +1 -1
- package/dist/daemon/api/reader.js +1 -1
- package/dist/daemon/api/repo-plugin.d.ts +12 -0
- package/dist/daemon/api/repo-plugin.js +1 -0
- package/dist/daemon/api/server.js +1 -1
- package/dist/daemon/boot-migrations.js +1 -1
- package/dist/daemon/crtrd.js +13 -13
- package/dist/daemon/due-sources.d.ts +1 -1
- package/dist/daemon/due-sources.js +1 -1
- package/dist/daemon/due.js +7 -7
- package/dist/daemon/machine-daemon.js +1 -1
- package/dist/daemon/reconcilers/group-invite-expiry.d.ts +9 -0
- package/dist/daemon/reconcilers/group-invite-expiry.js +1 -0
- package/dist/daemon/review/finish.js +1 -1
- package/dist/migrations/004-canvas-documents/index.js +2 -2
- package/dist/pi-extensions/canvas-structured-output.js +6 -6
- package/docs/concepts/documents.md +1 -1
- package/package.json +10 -2
- package/packages/crouter-api/dist/api/client.js +1585 -0
- package/packages/crouter-api/dist/api/command-manifest/index.js +4 -0
- package/packages/crouter-api/dist/api/command-manifest/manifest.js +332 -0
- package/packages/crouter-api/dist/api/command-manifest/object-kinds.js +100 -0
- package/packages/crouter-api/dist/api/command-manifest/result.js +166 -0
- package/packages/crouter-api/dist/api/command-manifest/schema.js +934 -0
- package/packages/crouter-api/dist/api/contract.js +57 -0
- package/packages/crouter-api/dist/api/dto/analytics.js +3 -0
- package/packages/crouter-api/dist/api/dto/attach.js +13 -0
- package/packages/crouter-api/dist/api/dto/bash-jobs.js +11 -0
- package/packages/crouter-api/dist/api/dto/bash.js +1 -0
- package/packages/crouter-api/dist/api/dto/broker-ops.js +6 -0
- package/packages/crouter-api/dist/api/dto/broker-signals.js +1 -0
- package/packages/crouter-api/dist/api/dto/broker.js +20 -0
- package/packages/crouter-api/dist/api/dto/canvas.js +2 -0
- package/packages/crouter-api/dist/api/dto/charges.js +4 -0
- package/packages/crouter-api/dist/api/dto/chat-inventory.js +11 -0
- package/packages/crouter-api/dist/api/dto/common.js +15 -0
- package/packages/crouter-api/dist/api/dto/config.js +3 -0
- package/packages/crouter-api/dist/api/dto/crons.js +10 -0
- package/packages/crouter-api/dist/api/dto/custom-objects.js +1 -0
- package/packages/crouter-api/dist/api/dto/delivery.js +7 -0
- package/packages/crouter-api/dist/api/dto/docs.js +8 -0
- package/packages/crouter-api/dist/api/dto/environments.js +2 -0
- package/packages/crouter-api/dist/api/dto/exec.js +1 -0
- package/packages/crouter-api/dist/api/dto/execution-start.js +2 -0
- package/packages/crouter-api/dist/api/dto/files.js +1 -0
- package/packages/crouter-api/dist/api/dto/focus.js +10 -0
- package/packages/crouter-api/dist/api/dto/grants.js +1 -0
- package/packages/crouter-api/dist/api/dto/health.js +2 -0
- package/packages/crouter-api/dist/api/dto/human-requests.js +4 -0
- package/packages/crouter-api/dist/api/dto/human.js +4 -0
- package/packages/crouter-api/dist/api/dto/imports.js +2 -0
- package/packages/crouter-api/dist/api/dto/inbox.js +4 -0
- package/packages/crouter-api/dist/api/dto/lifecycle.js +3 -0
- package/packages/crouter-api/dist/api/dto/limits.js +2 -0
- package/packages/crouter-api/dist/api/dto/mail.js +1 -0
- package/packages/crouter-api/dist/api/dto/messages.js +2 -0
- package/packages/crouter-api/dist/api/dto/model-config.js +1 -0
- package/packages/crouter-api/dist/api/dto/modelauth.js +4 -0
- package/packages/crouter-api/dist/api/dto/node-events.js +4 -0
- package/packages/crouter-api/dist/api/dto/node-outcomes.js +2 -0
- package/packages/crouter-api/dist/api/dto/node-records.js +5 -0
- package/packages/crouter-api/dist/api/dto/nodes.js +3 -0
- package/packages/crouter-api/dist/api/dto/objects.js +5 -0
- package/packages/crouter-api/dist/api/dto/permissions.js +5 -0
- package/packages/crouter-api/dist/api/dto/plugins.js +5 -0
- package/packages/crouter-api/dist/api/dto/profiles.js +8 -0
- package/packages/crouter-api/dist/api/dto/recovery.js +1 -0
- package/packages/crouter-api/dist/api/dto/repo-import.js +5 -0
- package/packages/crouter-api/dist/api/dto/reports.js +2 -0
- package/packages/crouter-api/dist/api/dto/review-comments.js +5 -0
- package/packages/crouter-api/dist/api/dto/reviews.js +5 -0
- package/packages/crouter-api/dist/api/dto/run-events.js +6 -0
- package/packages/crouter-api/dist/api/dto/settings.js +4 -0
- package/packages/crouter-api/dist/api/dto/structured-requests.js +5 -0
- package/packages/crouter-api/dist/api/dto/subscriptions.js +2 -0
- package/packages/crouter-api/dist/api/dto/usage.js +1 -0
- package/packages/crouter-api/dist/api/dto/worktree.js +6 -0
- package/packages/crouter-api/dist/api/error-codes.js +86 -0
- package/packages/crouter-api/dist/api/errors.js +72 -0
- package/packages/crouter-api/dist/api/index.js +55 -0
- package/packages/crouter-api/dist/api/long-poll.js +67 -0
- package/packages/crouter-api/dist/api/node-transport.js +105 -0
- package/packages/crouter-api/dist/api/plugin-manifest-schema.js +23 -0
- package/packages/crouter-api/dist/api/routes.js +233 -0
- package/packages/crouter-api/dist/api/runtime-version.js +50 -0
- package/packages/crouter-api/dist/build-root.js +411 -0
- package/packages/crouter-api/dist/clients/attach/ansi-cells.js +137 -0
- package/packages/crouter-api/dist/clients/attach/chrome/bash-jobs.js +34 -0
- package/packages/crouter-api/dist/clients/attach/chrome/canvas-panels.js +267 -0
- package/packages/crouter-api/dist/clients/attach/chrome/completion-bell.js +89 -0
- package/packages/crouter-api/dist/clients/attach/chrome/cron-wait.js +34 -0
- package/packages/crouter-api/dist/clients/attach/chrome/git-info.js +44 -0
- package/packages/crouter-api/dist/clients/attach/chrome/header.js +30 -0
- package/packages/crouter-api/dist/clients/attach/chrome/inbox-strip.js +219 -0
- package/packages/crouter-api/dist/clients/attach/chrome/key-hint.js +16 -0
- package/packages/crouter-api/dist/clients/attach/chrome/object-wait.js +24 -0
- package/packages/crouter-api/dist/clients/attach/chrome/recap.js +19 -0
- package/packages/crouter-api/dist/clients/attach/chrome/review-wait.js +22 -0
- package/packages/crouter-api/dist/clients/attach/chrome/roster.js +293 -0
- package/packages/crouter-api/dist/clients/attach/chrome/status-line.js +127 -0
- package/packages/crouter-api/dist/clients/attach/chrome/ticket-panel.js +261 -0
- package/packages/crouter-api/dist/clients/attach/chrome/widgets.js +51 -0
- package/packages/crouter-api/dist/clients/attach/command.js +107 -0
- package/packages/crouter-api/dist/clients/attach/config.js +275 -0
- package/packages/crouter-api/dist/clients/attach/input/capabilities.js +112 -0
- package/packages/crouter-api/dist/clients/attach/input/clipboard-image.js +237 -0
- package/packages/crouter-api/dist/clients/attach/input/completion-frecency.js +141 -0
- package/packages/crouter-api/dist/clients/attach/input/controller.js +383 -0
- package/packages/crouter-api/dist/clients/attach/input/overlay-owner.js +199 -0
- package/packages/crouter-api/dist/clients/attach/input/ref-autocomplete.js +176 -0
- package/packages/crouter-api/dist/clients/attach/input/titled-editor.js +859 -0
- package/packages/crouter-api/dist/clients/attach/overlays/auth.js +247 -0
- package/packages/crouter-api/dist/clients/attach/overlays/dialogs.js +102 -0
- package/packages/crouter-api/dist/clients/attach/overlays/file-review.js +146 -0
- package/packages/crouter-api/dist/clients/attach/overlays/graph.js +725 -0
- package/packages/crouter-api/dist/clients/attach/overlays/help.js +214 -0
- package/packages/crouter-api/dist/clients/attach/overlays/mcp.js +302 -0
- package/packages/crouter-api/dist/clients/attach/overlays/pickers.js +163 -0
- package/packages/crouter-api/dist/clients/attach/render/activity-slot.js +13 -0
- package/packages/crouter-api/dist/clients/attach/render/assistant-message.js +56 -0
- package/packages/crouter-api/dist/clients/attach/render/card-presentation.js +232 -0
- package/packages/crouter-api/dist/clients/attach/render/chat-view.js +2091 -0
- package/packages/crouter-api/dist/clients/attach/render/condensed-history.js +60 -0
- package/packages/crouter-api/dist/clients/attach/render/context-message.js +63 -0
- package/packages/crouter-api/dist/clients/attach/render/crtr-output.js +721 -0
- package/packages/crouter-api/dist/clients/attach/render/diagram.js +111 -0
- package/packages/crouter-api/dist/clients/attach/render/doc-links.js +78 -0
- package/packages/crouter-api/dist/clients/attach/render/edit-diff.js +304 -0
- package/packages/crouter-api/dist/clients/attach/render/glyph-codepoints.js +42 -0
- package/packages/crouter-api/dist/clients/attach/render/group-activity.js +276 -0
- package/packages/crouter-api/dist/clients/attach/render/group-recap.js +146 -0
- package/packages/crouter-api/dist/clients/attach/render/markdown-source.js +279 -0
- package/packages/crouter-api/dist/clients/attach/render/measured-container.js +322 -0
- package/packages/crouter-api/dist/clients/attach/render/page-block.js +187 -0
- package/packages/crouter-api/dist/clients/attach/render/scroll-animation.js +80 -0
- package/packages/crouter-api/dist/clients/attach/render/tool-calls.js +350 -0
- package/packages/crouter-api/dist/clients/attach/render/transcript-copy.js +81 -0
- package/packages/crouter-api/dist/clients/attach/render/transcript-search.js +152 -0
- package/packages/crouter-api/dist/clients/attach/render/viewport.js +184 -0
- package/packages/crouter-api/dist/clients/attach/session/banner.js +33 -0
- package/packages/crouter-api/dist/clients/attach/session/bindings.js +72 -0
- package/packages/crouter-api/dist/clients/attach/session/chrome-refresh.js +154 -0
- package/packages/crouter-api/dist/clients/attach/session/connection.js +204 -0
- package/packages/crouter-api/dist/clients/attach/session/context.js +16 -0
- package/packages/crouter-api/dist/clients/attach/session/document-links.js +48 -0
- package/packages/crouter-api/dist/clients/attach/session/editor-frame.js +142 -0
- package/packages/crouter-api/dist/clients/attach/session/editor-inventory.js +156 -0
- package/packages/crouter-api/dist/clients/attach/session/file-links.js +73 -0
- package/packages/crouter-api/dist/clients/attach/session/focus-events.js +12 -0
- package/packages/crouter-api/dist/clients/attach/session/frame.js +214 -0
- package/packages/crouter-api/dist/clients/attach/session/frames.js +203 -0
- package/packages/crouter-api/dist/clients/attach/session/identity.js +26 -0
- package/packages/crouter-api/dist/clients/attach/session/input-wiring.js +150 -0
- package/packages/crouter-api/dist/clients/attach/session/invariant.js +15 -0
- package/packages/crouter-api/dist/clients/attach/session/keys.js +77 -0
- package/packages/crouter-api/dist/clients/attach/session/layout.js +59 -0
- package/packages/crouter-api/dist/clients/attach/session/mouse.js +78 -0
- package/packages/crouter-api/dist/clients/attach/session/pane-focus.js +42 -0
- package/packages/crouter-api/dist/clients/attach/session/pane-tag.js +112 -0
- package/packages/crouter-api/dist/clients/attach/session/pi-assets.js +24 -0
- package/packages/crouter-api/dist/clients/attach/session/pi-oauth-flows.js +21 -0
- package/packages/crouter-api/dist/clients/attach/session/profile-files.js +208 -0
- package/packages/crouter-api/dist/clients/attach/session/readonly-popup.js +25 -0
- package/packages/crouter-api/dist/clients/attach/session/reconnect.js +195 -0
- package/packages/crouter-api/dist/clients/attach/session/selection.js +108 -0
- package/packages/crouter-api/dist/clients/attach/session/state-sync.js +67 -0
- package/packages/crouter-api/dist/clients/attach/session/surface-frame.js +73 -0
- package/packages/crouter-api/dist/clients/attach/session/surface-host.js +256 -0
- package/packages/crouter-api/dist/clients/attach/session/teardown.js +94 -0
- package/packages/crouter-api/dist/clients/attach/session/transcript-search.js +151 -0
- package/packages/crouter-api/dist/clients/attach/session/whip-achievements.js +145 -0
- package/packages/crouter-api/dist/clients/attach/session/whip.js +362 -0
- package/packages/crouter-api/dist/clients/attach/slash/dispatch.js +747 -0
- package/packages/crouter-api/dist/clients/attach/slash/prompt-preview.js +121 -0
- package/packages/crouter-api/dist/clients/attach/viewer.js +881 -0
- package/packages/crouter-api/dist/clients/conversation/projection.js +324 -0
- package/packages/crouter-api/dist/clients/conversation/submit.js +51 -0
- package/packages/crouter-api/dist/clients/dashboard/app.js +439 -0
- package/packages/crouter-api/dist/clients/dashboard/model.js +77 -0
- package/packages/crouter-api/dist/clients/dashboard/render.js +148 -0
- package/packages/crouter-api/dist/clients/inbox/controller.js +791 -0
- package/packages/crouter-api/dist/clients/inbox/dto-adapt.js +93 -0
- package/packages/crouter-api/dist/clients/inbox/layout.js +9 -0
- package/packages/crouter-api/dist/clients/inbox/page-adapter.js +56 -0
- package/packages/crouter-api/dist/clients/inbox/resolve.js +35 -0
- package/packages/crouter-api/dist/clients/inbox/review/anchors.js +89 -0
- package/packages/crouter-api/dist/clients/inbox/review/comments-client.js +103 -0
- package/packages/crouter-api/dist/clients/inbox/review/companion-pane.js +109 -0
- package/packages/crouter-api/dist/clients/inbox/review/document-surface.js +1268 -0
- package/packages/crouter-api/dist/clients/inbox/review/frame.js +309 -0
- package/packages/crouter-api/dist/clients/inbox/review/keys.js +133 -0
- package/packages/crouter-api/dist/clients/inbox/review/launch.js +170 -0
- package/packages/crouter-api/dist/clients/inbox/review/live-source.js +160 -0
- package/packages/crouter-api/dist/clients/inbox/review/nvim.js +43 -0
- package/packages/crouter-api/dist/clients/inbox/review/remap.js +157 -0
- package/packages/crouter-api/dist/clients/inbox/review/review-client.js +123 -0
- package/packages/crouter-api/dist/clients/inbox/review/roundtrip.js +41 -0
- package/packages/crouter-api/dist/clients/inbox/review/state.js +315 -0
- package/packages/crouter-api/dist/clients/inbox/review-adapter.js +43 -0
- package/packages/crouter-api/dist/clients/inbox/surface.js +190 -0
- package/packages/crouter-api/dist/clients/inbox/tui/ansi.js +321 -0
- package/packages/crouter-api/dist/clients/inbox/tui/input.js +392 -0
- package/packages/crouter-api/dist/clients/inbox/tui/keys.js +104 -0
- package/packages/crouter-api/dist/clients/inbox/tui/page-body.js +69 -0
- package/packages/crouter-api/dist/clients/inbox/tui/panel.js +92 -0
- package/packages/crouter-api/dist/clients/inbox/tui/render.js +389 -0
- package/packages/crouter-api/dist/clients/inbox/tui/slots.js +134 -0
- package/packages/crouter-api/dist/clients/inbox/tui/types.js +1 -0
- package/packages/crouter-api/dist/clients/inbox/tui.js +91 -0
- package/packages/crouter-api/dist/clients/surfaces/host.js +1 -0
- package/packages/crouter-api/dist/commands/api-client.js +438 -0
- package/packages/crouter-api/dist/commands/attention.js +215 -0
- package/packages/crouter-api/dist/commands/canvas/edges.js +41 -0
- package/packages/crouter-api/dist/commands/canvas/list.js +79 -0
- package/packages/crouter-api/dist/commands/canvas/read.js +95 -0
- package/packages/crouter-api/dist/commands/canvas/search.js +49 -0
- package/packages/crouter-api/dist/commands/canvas/share.js +80 -0
- package/packages/crouter-api/dist/commands/canvas/unwatch.js +42 -0
- package/packages/crouter-api/dist/commands/canvas/watch.js +63 -0
- package/packages/crouter-api/dist/commands/canvas-analytics/chart.js +124 -0
- package/packages/crouter-api/dist/commands/canvas-analytics/drilldown.js +96 -0
- package/packages/crouter-api/dist/commands/canvas-analytics/format.js +106 -0
- package/packages/crouter-api/dist/commands/canvas-analytics/graph-detail.js +307 -0
- package/packages/crouter-api/dist/commands/canvas-analytics/graphs.js +365 -0
- package/packages/crouter-api/dist/commands/canvas-analytics/memory.js +211 -0
- package/packages/crouter-api/dist/commands/canvas-analytics/overview.js +189 -0
- package/packages/crouter-api/dist/commands/canvas-analytics/shell.js +416 -0
- package/packages/crouter-api/dist/commands/canvas-analytics/time.js +228 -0
- package/packages/crouter-api/dist/commands/canvas-analytics/usage.js +305 -0
- package/packages/crouter-api/dist/commands/canvas-analytics/view.js +102 -0
- package/packages/crouter-api/dist/commands/canvas-analytics.js +28 -0
- package/packages/crouter-api/dist/commands/canvas-browse.js +71 -0
- package/packages/crouter-api/dist/commands/canvas-config.js +192 -0
- package/packages/crouter-api/dist/commands/canvas-history/grep.js +85 -0
- package/packages/crouter-api/dist/commands/canvas-history/read.js +48 -0
- package/packages/crouter-api/dist/commands/canvas-history/search.js +99 -0
- package/packages/crouter-api/dist/commands/canvas-history/shared.js +135 -0
- package/packages/crouter-api/dist/commands/canvas-history/stats.js +68 -0
- package/packages/crouter-api/dist/commands/canvas-history.js +29 -0
- package/packages/crouter-api/dist/commands/canvas-issue.js +148 -0
- package/packages/crouter-api/dist/commands/canvas-prune.js +111 -0
- package/packages/crouter-api/dist/commands/canvas-roster.js +69 -0
- package/packages/crouter-api/dist/commands/canvas-snapshot.js +34 -0
- package/packages/crouter-api/dist/commands/canvas-use.js +61 -0
- package/packages/crouter-api/dist/commands/canvas.js +57 -0
- package/packages/crouter-api/dist/commands/chord.js +242 -0
- package/packages/crouter-api/dist/commands/cron.js +541 -0
- package/packages/crouter-api/dist/commands/custom-object/ack.js +30 -0
- package/packages/crouter-api/dist/commands/custom-object/publish.js +39 -0
- package/packages/crouter-api/dist/commands/custom-object/receive.js +69 -0
- package/packages/crouter-api/dist/commands/custom-object/register.js +69 -0
- package/packages/crouter-api/dist/commands/custom-object/shared.js +14 -0
- package/packages/crouter-api/dist/commands/custom-object/unregister.js +26 -0
- package/packages/crouter-api/dist/commands/custom-object.js +21 -0
- package/packages/crouter-api/dist/commands/dashboard.js +86 -0
- package/packages/crouter-api/dist/commands/doc/delete.js +30 -0
- package/packages/crouter-api/dist/commands/doc/edit.js +83 -0
- package/packages/crouter-api/dist/commands/doc/history.js +38 -0
- package/packages/crouter-api/dist/commands/doc/lint.js +36 -0
- package/packages/crouter-api/dist/commands/doc/list.js +19 -0
- package/packages/crouter-api/dist/commands/doc/move.js +37 -0
- package/packages/crouter-api/dist/commands/doc/read.js +19 -0
- package/packages/crouter-api/dist/commands/doc/replace-blocks.js +40 -0
- package/packages/crouter-api/dist/commands/doc/shared.js +156 -0
- package/packages/crouter-api/dist/commands/doc/write.js +53 -0
- package/packages/crouter-api/dist/commands/doc.js +27 -0
- package/packages/crouter-api/dist/commands/human/components.js +78 -0
- package/packages/crouter-api/dist/commands/human/feedback.js +112 -0
- package/packages/crouter-api/dist/commands/human/prompts.js +326 -0
- package/packages/crouter-api/dist/commands/human/queue.js +191 -0
- package/packages/crouter-api/dist/commands/human/request.js +266 -0
- package/packages/crouter-api/dist/commands/human/review.js +288 -0
- package/packages/crouter-api/dist/commands/human/shared.js +67 -0
- package/packages/crouter-api/dist/commands/human.js +63 -0
- package/packages/crouter-api/dist/commands/node/bash.js +395 -0
- package/packages/crouter-api/dist/commands/node/create.js +363 -0
- package/packages/crouter-api/dist/commands/node/inspect.js +288 -0
- package/packages/crouter-api/dist/commands/node/lifecycle.js +577 -0
- package/packages/crouter-api/dist/commands/node/message.js +170 -0
- package/packages/crouter-api/dist/commands/node/outcome.js +133 -0
- package/packages/crouter-api/dist/commands/node/pyramid.js +79 -0
- package/packages/crouter-api/dist/commands/node/subscription.js +78 -0
- package/packages/crouter-api/dist/commands/node/wait.js +165 -0
- package/packages/crouter-api/dist/commands/node-context.js +145 -0
- package/packages/crouter-api/dist/commands/node-lifecycle-revive.js +224 -0
- package/packages/crouter-api/dist/commands/node-snapshot.js +37 -0
- package/packages/crouter-api/dist/commands/node-transcript.js +59 -0
- package/packages/crouter-api/dist/commands/node-worktree.js +138 -0
- package/packages/crouter-api/dist/commands/node.js +29 -0
- package/packages/crouter-api/dist/commands/person-settings.js +23 -0
- package/packages/crouter-api/dist/commands/pkg/app-installs.js +125 -0
- package/packages/crouter-api/dist/commands/pkg/browse/actions.js +198 -0
- package/packages/crouter-api/dist/commands/pkg/browse/catalog.js +461 -0
- package/packages/crouter-api/dist/commands/pkg/browse/command-view.js +217 -0
- package/packages/crouter-api/dist/commands/pkg/browse/detail-panel.js +402 -0
- package/packages/crouter-api/dist/commands/pkg/browse/doc-view.js +84 -0
- package/packages/crouter-api/dist/commands/pkg/browse/list-panel.js +168 -0
- package/packages/crouter-api/dist/commands/pkg/browse/model.js +36 -0
- package/packages/crouter-api/dist/commands/pkg/browse/shell.js +640 -0
- package/packages/crouter-api/dist/commands/pkg/browse.js +27 -0
- package/packages/crouter-api/dist/commands/pkg/market-inspect.js +145 -0
- package/packages/crouter-api/dist/commands/pkg/market-manage.js +340 -0
- package/packages/crouter-api/dist/commands/pkg/market.js +14 -0
- package/packages/crouter-api/dist/commands/pkg/plugin-env.js +65 -0
- package/packages/crouter-api/dist/commands/pkg/plugin-inspect.js +178 -0
- package/packages/crouter-api/dist/commands/pkg/plugin-manage.js +1039 -0
- package/packages/crouter-api/dist/commands/pkg/plugin.js +14 -0
- package/packages/crouter-api/dist/commands/pkg/shared.js +62 -0
- package/packages/crouter-api/dist/commands/pkg.js +21 -0
- package/packages/crouter-api/dist/commands/profile/daemon-profiles.js +38 -0
- package/packages/crouter-api/dist/commands/profile/default.js +183 -0
- package/packages/crouter-api/dist/commands/profile/delete.js +66 -0
- package/packages/crouter-api/dist/commands/profile/env.js +188 -0
- package/packages/crouter-api/dist/commands/profile/environment.js +88 -0
- package/packages/crouter-api/dist/commands/profile/kind.js +27 -0
- package/packages/crouter-api/dist/commands/profile/list.js +45 -0
- package/packages/crouter-api/dist/commands/profile/meta.js +65 -0
- package/packages/crouter-api/dist/commands/profile/new.js +107 -0
- package/packages/crouter-api/dist/commands/profile/pause.js +59 -0
- package/packages/crouter-api/dist/commands/profile/project.js +146 -0
- package/packages/crouter-api/dist/commands/profile/rename.js +41 -0
- package/packages/crouter-api/dist/commands/profile/show.js +55 -0
- package/packages/crouter-api/dist/commands/profile.js +36 -0
- package/packages/crouter-api/dist/commands/push.js +357 -0
- package/packages/crouter-api/dist/commands/revive.js +183 -0
- package/packages/crouter-api/dist/commands/surface/node/cycle.js +83 -0
- package/packages/crouter-api/dist/commands/surface/node/focus.js +60 -0
- package/packages/crouter-api/dist/commands/surface/node/id.js +38 -0
- package/packages/crouter-api/dist/commands/surface/node/pin.js +42 -0
- package/packages/crouter-api/dist/commands/surface/node/placement.js +49 -0
- package/packages/crouter-api/dist/commands/surface-dashboard.js +138 -0
- package/packages/crouter-api/dist/commands/surface-edit.js +157 -0
- package/packages/crouter-api/dist/commands/surface-inbox.js +98 -0
- package/packages/crouter-api/dist/commands/surface-inspect.js +41 -0
- package/packages/crouter-api/dist/commands/surface-node.js +19 -0
- package/packages/crouter-api/dist/commands/surface-reload.js +129 -0
- package/packages/crouter-api/dist/commands/surface-tmux-spread.js +214 -0
- package/packages/crouter-api/dist/commands/surface.js +29 -0
- package/packages/crouter-api/dist/commands/sys/branch.js +19 -0
- package/packages/crouter-api/dist/commands/sys/config.js +353 -0
- package/packages/crouter-api/dist/commands/sys/connect.js +185 -0
- package/packages/crouter-api/dist/commands/sys/context/admin/actions.js +89 -0
- package/packages/crouter-api/dist/commands/sys/context/admin/detail-panel.js +233 -0
- package/packages/crouter-api/dist/commands/sys/context/admin/docs-panel.js +185 -0
- package/packages/crouter-api/dist/commands/sys/context/admin/list-view.js +170 -0
- package/packages/crouter-api/dist/commands/sys/context/admin/model.js +179 -0
- package/packages/crouter-api/dist/commands/sys/context/admin/rail-panel.js +229 -0
- package/packages/crouter-api/dist/commands/sys/context/admin/read-view.js +172 -0
- package/packages/crouter-api/dist/commands/sys/context/admin/shell.js +870 -0
- package/packages/crouter-api/dist/commands/sys/context/admin.js +148 -0
- package/packages/crouter-api/dist/commands/sys/context/doc.js +126 -0
- package/packages/crouter-api/dist/commands/sys/context/expose.js +66 -0
- package/packages/crouter-api/dist/commands/sys/context/prompt-review.js +244 -0
- package/packages/crouter-api/dist/commands/sys/context/resolve.js +326 -0
- package/packages/crouter-api/dist/commands/sys/context/sysprompt.js +95 -0
- package/packages/crouter-api/dist/commands/sys/context.js +21 -0
- package/packages/crouter-api/dist/commands/sys/daemon.js +351 -0
- package/packages/crouter-api/dist/commands/sys/db.js +69 -0
- package/packages/crouter-api/dist/commands/sys/desktop.js +201 -0
- package/packages/crouter-api/dist/commands/sys/doctor.js +633 -0
- package/packages/crouter-api/dist/commands/sys/env.js +39 -0
- package/packages/crouter-api/dist/commands/sys/feedback.js +228 -0
- package/packages/crouter-api/dist/commands/sys/import/move.js +393 -0
- package/packages/crouter-api/dist/commands/sys/import/resume.js +23 -0
- package/packages/crouter-api/dist/commands/sys/import/start.js +92 -0
- package/packages/crouter-api/dist/commands/sys/join.js +85 -0
- package/packages/crouter-api/dist/commands/sys/limits.js +133 -0
- package/packages/crouter-api/dist/commands/sys/logs.js +129 -0
- package/packages/crouter-api/dist/commands/sys/machine/rotate.js +49 -0
- package/packages/crouter-api/dist/commands/sys/migrate.js +79 -0
- package/packages/crouter-api/dist/commands/sys/panels/broker-limits-panel.js +110 -0
- package/packages/crouter-api/dist/commands/sys/panels/dependencies-panel.js +80 -0
- package/packages/crouter-api/dist/commands/sys/panels/keybindings-panel.js +703 -0
- package/packages/crouter-api/dist/commands/sys/panels/models-panel.js +1160 -0
- package/packages/crouter-api/dist/commands/sys/panels/plugin-env-panel.js +70 -0
- package/packages/crouter-api/dist/commands/sys/panels/plugins-panel.js +87 -0
- package/packages/crouter-api/dist/commands/sys/panels/prefs-panel.js +97 -0
- package/packages/crouter-api/dist/commands/sys/panels/profiles-panel.js +656 -0
- package/packages/crouter-api/dist/commands/sys/panels/provider-panel.js +534 -0
- package/packages/crouter-api/dist/commands/sys/panels/terminal-panel.js +67 -0
- package/packages/crouter-api/dist/commands/sys/provider-login.js +99 -0
- package/packages/crouter-api/dist/commands/sys/repo-docs.js +96 -0
- package/packages/crouter-api/dist/commands/sys/retry-delivery.js +33 -0
- package/packages/crouter-api/dist/commands/sys/settings-shell.js +400 -0
- package/packages/crouter-api/dist/commands/sys/settings.js +46 -0
- package/packages/crouter-api/dist/commands/sys/setup-core.js +890 -0
- package/packages/crouter-api/dist/commands/sys/setup-settings-runner.js +15 -0
- package/packages/crouter-api/dist/commands/sys/setup-wizard.js +351 -0
- package/packages/crouter-api/dist/commands/sys/setup.js +41 -0
- package/packages/crouter-api/dist/commands/sys/shared.js +81 -0
- package/packages/crouter-api/dist/commands/sys/signin.js +149 -0
- package/packages/crouter-api/dist/commands/sys/spaces.js +22 -0
- package/packages/crouter-api/dist/commands/sys/spend.js +144 -0
- package/packages/crouter-api/dist/commands/sys/support/prepare.js +239 -0
- package/packages/crouter-api/dist/commands/sys/support/submit.js +524 -0
- package/packages/crouter-api/dist/commands/sys/support.js +18 -0
- package/packages/crouter-api/dist/commands/sys/sync-deps.js +445 -0
- package/packages/crouter-api/dist/commands/sys/sync-project-guidance.js +320 -0
- package/packages/crouter-api/dist/commands/sys/sync-shared.js +139 -0
- package/packages/crouter-api/dist/commands/sys/sync-skills.js +297 -0
- package/packages/crouter-api/dist/commands/sys/sync.js +17 -0
- package/packages/crouter-api/dist/commands/sys/terminal-option.js +542 -0
- package/packages/crouter-api/dist/commands/sys/tutorial/branch.js +15 -0
- package/packages/crouter-api/dist/commands/sys/tutorial/lessons.js +107 -0
- package/packages/crouter-api/dist/commands/sys/tutorial/scenario.js +431 -0
- package/packages/crouter-api/dist/commands/sys/tutorial/tracks.js +96 -0
- package/packages/crouter-api/dist/commands/sys/update.js +157 -0
- package/packages/crouter-api/dist/commands/sys/worktrees.js +53 -0
- package/packages/crouter-api/dist/commands/sys.js +32 -0
- package/packages/crouter-api/dist/core/activity-signal.js +38 -0
- package/packages/crouter-api/dist/core/asset-root.js +18 -0
- package/packages/crouter-api/dist/core/async-array.js +48 -0
- package/packages/crouter-api/dist/core/auth-file.js +89 -0
- package/packages/crouter-api/dist/core/auth-interaction.js +94 -0
- package/packages/crouter-api/dist/core/bash-guard.js +527 -0
- package/packages/crouter-api/dist/core/bash-job-supervisor.js +157 -0
- package/packages/crouter-api/dist/core/bash-jobs.js +460 -0
- package/packages/crouter-api/dist/core/blobs/directory.js +264 -0
- package/packages/crouter-api/dist/core/blobs/fault.js +6 -0
- package/packages/crouter-api/dist/core/blobs/index.js +30 -0
- package/packages/crouter-api/dist/core/blobs/r2.js +169 -0
- package/packages/crouter-api/dist/core/broker-client/client.js +184 -0
- package/packages/crouter-api/dist/core/broker-client/index.js +14 -0
- package/packages/crouter-api/dist/core/broker-client/transport-relay.js +186 -0
- package/packages/crouter-api/dist/core/broker-client/transport-socket.js +187 -0
- package/packages/crouter-api/dist/core/broker-client/transport.js +40 -0
- package/packages/crouter-api/dist/core/canvas/app-run.js +4 -0
- package/packages/crouter-api/dist/core/canvas/attention.js +47 -0
- package/packages/crouter-api/dist/core/canvas/boot-id.js +26 -0
- package/packages/crouter-api/dist/core/canvas/browse/app.js +1050 -0
- package/packages/crouter-api/dist/core/canvas/browse/model.js +477 -0
- package/packages/crouter-api/dist/core/canvas/browse/pins.js +29 -0
- package/packages/crouter-api/dist/core/canvas/browse/render.js +1058 -0
- package/packages/crouter-api/dist/core/canvas/canvas.js +1225 -0
- package/packages/crouter-api/dist/core/canvas/crons.js +541 -0
- package/packages/crouter-api/dist/core/canvas/daemon-actions.js +98 -0
- package/packages/crouter-api/dist/core/canvas/db.js +429 -0
- package/packages/crouter-api/dist/core/canvas/deliveries.js +398 -0
- package/packages/crouter-api/dist/core/canvas/delivery-contract.js +30 -0
- package/packages/crouter-api/dist/core/canvas/executions.js +279 -0
- package/packages/crouter-api/dist/core/canvas/extensions.js +90 -0
- package/packages/crouter-api/dist/core/canvas/focuses.js +82 -0
- package/packages/crouter-api/dist/core/canvas/history.js +480 -0
- package/packages/crouter-api/dist/core/canvas/index.js +16 -0
- package/packages/crouter-api/dist/core/canvas/install-id.js +64 -0
- package/packages/crouter-api/dist/core/canvas/labels.js +43 -0
- package/packages/crouter-api/dist/core/canvas/legacy-person.js +4 -0
- package/packages/crouter-api/dist/core/canvas/memory-reads.js +37 -0
- package/packages/crouter-api/dist/core/canvas/meta-file.js +89 -0
- package/packages/crouter-api/dist/core/canvas/nav-render.js +224 -0
- package/packages/crouter-api/dist/core/canvas/node-agent-paths.js +30 -0
- package/packages/crouter-api/dist/core/canvas/node-order.js +37 -0
- package/packages/crouter-api/dist/core/canvas/node-recap.js +62 -0
- package/packages/crouter-api/dist/core/canvas/node-tokens.js +53 -0
- package/packages/crouter-api/dist/core/canvas/outcome-actions.js +71 -0
- package/packages/crouter-api/dist/core/canvas/paths.js +167 -0
- package/packages/crouter-api/dist/core/canvas/person-state.js +41 -0
- package/packages/crouter-api/dist/core/canvas/person.js +251 -0
- package/packages/crouter-api/dist/core/canvas/pid.js +977 -0
- package/packages/crouter-api/dist/core/canvas/reconciler-leases.js +40 -0
- package/packages/crouter-api/dist/core/canvas/recovery.js +715 -0
- package/packages/crouter-api/dist/core/canvas/remote-canvas-source.js +290 -0
- package/packages/crouter-api/dist/core/canvas/remote-transport.js +57 -0
- package/packages/crouter-api/dist/core/canvas/render-source.js +518 -0
- package/packages/crouter-api/dist/core/canvas/schema-chain.js +110 -0
- package/packages/crouter-api/dist/core/canvas/schema-version.js +58 -0
- package/packages/crouter-api/dist/core/canvas/sessions.js +128 -0
- package/packages/crouter-api/dist/core/canvas/source.js +57 -0
- package/packages/crouter-api/dist/core/canvas/status-glyph.js +132 -0
- package/packages/crouter-api/dist/core/canvas/structured-requests.js +176 -0
- package/packages/crouter-api/dist/core/canvas/telemetry.js +35 -0
- package/packages/crouter-api/dist/core/canvas/tree.js +128 -0
- package/packages/crouter-api/dist/core/canvas/types.js +6 -0
- package/packages/crouter-api/dist/core/canvas/waits.js +113 -0
- package/packages/crouter-api/dist/core/canvas/worktrees.js +97 -0
- package/packages/crouter-api/dist/core/checkout-identities.js +88 -0
- package/packages/crouter-api/dist/core/clipboard-text.js +57 -0
- package/packages/crouter-api/dist/core/command-hooks/artifact.js +145 -0
- package/packages/crouter-api/dist/core/command-hooks/catalog.js +38 -0
- package/packages/crouter-api/dist/core/command-hooks/compose.js +101 -0
- package/packages/crouter-api/dist/core/command-hooks/discovery.js +246 -0
- package/packages/crouter-api/dist/core/command-hooks/help.js +18 -0
- package/packages/crouter-api/dist/core/command-hooks/lifecycle-catalog.js +9 -0
- package/packages/crouter-api/dist/core/command-hooks/lifecycle-create.js +51 -0
- package/packages/crouter-api/dist/core/command-hooks/report.js +28 -0
- package/packages/crouter-api/dist/core/command-hooks/schema.js +157 -0
- package/packages/crouter-api/dist/core/command-hooks/transport/exec-invoke.js +315 -0
- package/packages/crouter-api/dist/core/command-hooks/transport/exec-lifecycle.js +248 -0
- package/packages/crouter-api/dist/core/command-hooks/transport/plan.js +30 -0
- package/packages/crouter-api/dist/core/command-manifests/registry.js +118 -0
- package/packages/crouter-api/dist/core/command-plugins/bundle.js +604 -0
- package/packages/crouter-api/dist/core/command-plugins/caller-header.js +15 -0
- package/packages/crouter-api/dist/core/command-plugins/compose.js +243 -0
- package/packages/crouter-api/dist/core/command-plugins/discovery.js +240 -0
- package/packages/crouter-api/dist/core/command-plugins/endpoint.js +60 -0
- package/packages/crouter-api/dist/core/command-plugins/extensions.js +166 -0
- package/packages/crouter-api/dist/core/command-plugins/help-addenda.js +55 -0
- package/packages/crouter-api/dist/core/command-plugins/presence.js +36 -0
- package/packages/crouter-api/dist/core/command-plugins/transport/exec-invoke.js +138 -0
- package/packages/crouter-api/dist/core/command-plugins/transport/http-fetch.js +68 -0
- package/packages/crouter-api/dist/core/command-plugins/transport/http-invoke.js +333 -0
- package/packages/crouter-api/dist/core/command-plugins/transport/http-plan.js +349 -0
- package/packages/crouter-api/dist/core/command-plugins/transport/sign.js +115 -0
- package/packages/crouter-api/dist/core/command.js +848 -0
- package/packages/crouter-api/dist/core/config.js +1154 -0
- package/packages/crouter-api/dist/core/conversation-store/client.js +111 -0
- package/packages/crouter-api/dist/core/conversation-store/index.js +62 -0
- package/packages/crouter-api/dist/core/conversation-store/patch.js +192 -0
- package/packages/crouter-api/dist/core/conversation-store/repair.js +84 -0
- package/packages/crouter-api/dist/core/conversation-store/row-store.js +365 -0
- package/packages/crouter-api/dist/core/directory/issuer.js +15 -0
- package/packages/crouter-api/dist/core/directory/join-lock.js +61 -0
- package/packages/crouter-api/dist/core/directory/join.js +218 -0
- package/packages/crouter-api/dist/core/directory/person-credential.js +220 -0
- package/packages/crouter-api/dist/core/directory/reach.js +19 -0
- package/packages/crouter-api/dist/core/document-lines.js +6 -0
- package/packages/crouter-api/dist/core/editor-resolver.js +77 -0
- package/packages/crouter-api/dist/core/env-name.js +25 -0
- package/packages/crouter-api/dist/core/environment-recipe.js +59 -0
- package/packages/crouter-api/dist/core/environments.js +59 -0
- package/packages/crouter-api/dist/core/errors.js +90 -0
- package/packages/crouter-api/dist/core/events/emit.js +44 -0
- package/packages/crouter-api/dist/core/events/envelope.js +84 -0
- package/packages/crouter-api/dist/core/events/errors.js +69 -0
- package/packages/crouter-api/dist/core/events/operation-id.js +24 -0
- package/packages/crouter-api/dist/core/events/outbound.js +92 -0
- package/packages/crouter-api/dist/core/events/read.js +625 -0
- package/packages/crouter-api/dist/core/events/serialize.js +199 -0
- package/packages/crouter-api/dist/core/events/source.js +31 -0
- package/packages/crouter-api/dist/core/events/types.js +11 -0
- package/packages/crouter-api/dist/core/exclusive-lock.js +197 -0
- package/packages/crouter-api/dist/core/fault-classifier.js +101 -0
- package/packages/crouter-api/dist/core/feed/feed.js +190 -0
- package/packages/crouter-api/dist/core/feed/inbox.js +93 -0
- package/packages/crouter-api/dist/core/feed/messages.js +219 -0
- package/packages/crouter-api/dist/core/feed/reports.js +58 -0
- package/packages/crouter-api/dist/core/frontmatter.js +35 -0
- package/packages/crouter-api/dist/core/fs-utils.js +263 -0
- package/packages/crouter-api/dist/core/git.js +103 -0
- package/packages/crouter-api/dist/core/grants/cover.js +66 -0
- package/packages/crouter-api/dist/core/grants/hosted-endpoint.js +70 -0
- package/packages/crouter-api/dist/core/grants/local.js +26 -0
- package/packages/crouter-api/dist/core/grants/mirror.js +464 -0
- package/packages/crouter-api/dist/core/grants/on-sync.js +163 -0
- package/packages/crouter-api/dist/core/grants/sandboxes.js +24 -0
- package/packages/crouter-api/dist/core/grants/sync.js +216 -0
- package/packages/crouter-api/dist/core/grants/terminal.js +25 -0
- package/packages/crouter-api/dist/core/graph/access.js +37 -0
- package/packages/crouter-api/dist/core/graph/bodies.js +68 -0
- package/packages/crouter-api/dist/core/graph/custom.js +298 -0
- package/packages/crouter-api/dist/core/graph/deletion.js +115 -0
- package/packages/crouter-api/dist/core/graph/documents.js +675 -0
- package/packages/crouter-api/dist/core/graph/edges.js +83 -0
- package/packages/crouter-api/dist/core/graph/events.js +432 -0
- package/packages/crouter-api/dist/core/graph/exposures.js +164 -0
- package/packages/crouter-api/dist/core/graph/jobs.js +184 -0
- package/packages/crouter-api/dist/core/graph/kinds/action.js +20 -0
- package/packages/crouter-api/dist/core/graph/kinds/custom.js +25 -0
- package/packages/crouter-api/dist/core/graph/kinds/document.js +132 -0
- package/packages/crouter-api/dist/core/graph/kinds/dto.js +20 -0
- package/packages/crouter-api/dist/core/graph/kinds/environment.js +21 -0
- package/packages/crouter-api/dist/core/graph/kinds/job.js +24 -0
- package/packages/crouter-api/dist/core/graph/kinds/kind.js +15 -0
- package/packages/crouter-api/dist/core/graph/kinds/live-read.js +11 -0
- package/packages/crouter-api/dist/core/graph/kinds/node.js +87 -0
- package/packages/crouter-api/dist/core/graph/kinds/owner.js +26 -0
- package/packages/crouter-api/dist/core/graph/kinds/registry.js +58 -0
- package/packages/crouter-api/dist/core/graph/kinds/render.js +17 -0
- package/packages/crouter-api/dist/core/graph/names.js +239 -0
- package/packages/crouter-api/dist/core/graph/objects.js +292 -0
- package/packages/crouter-api/dist/core/graph/package-docs.js +148 -0
- package/packages/crouter-api/dist/core/graph/package-files.js +146 -0
- package/packages/crouter-api/dist/core/graph/package-publish.js +158 -0
- package/packages/crouter-api/dist/core/graph/package-reconcile.js +99 -0
- package/packages/crouter-api/dist/core/graph/reader.js +284 -0
- package/packages/crouter-api/dist/core/graph/receiver-url.js +83 -0
- package/packages/crouter-api/dist/core/graph/receivers.js +66 -0
- package/packages/crouter-api/dist/core/graph/repo-sync/identity.js +147 -0
- package/packages/crouter-api/dist/core/graph/repo-sync/repos.js +94 -0
- package/packages/crouter-api/dist/core/graph/rules.js +144 -0
- package/packages/crouter-api/dist/core/graph/types.js +10 -0
- package/packages/crouter-api/dist/core/graph/watches.js +223 -0
- package/packages/crouter-api/dist/core/help.js +445 -0
- package/packages/crouter-api/dist/core/human/action-binding.js +41 -0
- package/packages/crouter-api/dist/core/human/answer-text.js +100 -0
- package/packages/crouter-api/dist/core/human/answer.js +119 -0
- package/packages/crouter-api/dist/core/human/completion.js +27 -0
- package/packages/crouter-api/dist/core/human/component-docs.js +442 -0
- package/packages/crouter-api/dist/core/human/convention.js +75 -0
- package/packages/crouter-api/dist/core/human/feedback-companion.js +92 -0
- package/packages/crouter-api/dist/core/human/feedback.js +88 -0
- package/packages/crouter-api/dist/core/human/page-authoring.js +19 -0
- package/packages/crouter-api/dist/core/human/page-catalog.js +172 -0
- package/packages/crouter-api/dist/core/human/page-errors.js +14 -0
- package/packages/crouter-api/dist/core/human/page-eval.js +125 -0
- package/packages/crouter-api/dist/core/human/page-html-markdown.js +260 -0
- package/packages/crouter-api/dist/core/human/page-markdown.js +295 -0
- package/packages/crouter-api/dist/core/human/page-schema.js +381 -0
- package/packages/crouter-api/dist/core/human/page.js +251 -0
- package/packages/crouter-api/dist/core/human/request-files.js +54 -0
- package/packages/crouter-api/dist/core/human/requests.js +647 -0
- package/packages/crouter-api/dist/core/human/root.js +11 -0
- package/packages/crouter-api/dist/core/human/summary.js +5 -0
- package/packages/crouter-api/dist/core/human/tickets.js +175 -0
- package/packages/crouter-api/dist/core/human/types.js +1 -0
- package/packages/crouter-api/dist/core/human/visible-paths.js +74 -0
- package/packages/crouter-api/dist/core/human-actions.js +101 -0
- package/packages/crouter-api/dist/core/import/bundle/blob-keys.js +25 -0
- package/packages/crouter-api/dist/core/import/bundle/layout.js +111 -0
- package/packages/crouter-api/dist/core/import/export/archive.js +22 -0
- package/packages/crouter-api/dist/core/import/export/cloud.js +164 -0
- package/packages/crouter-api/dist/core/import/export/dump.js +245 -0
- package/packages/crouter-api/dist/core/import/export/files.js +169 -0
- package/packages/crouter-api/dist/core/import/export/inline.js +15 -0
- package/packages/crouter-api/dist/core/import/export/source.js +5 -0
- package/packages/crouter-api/dist/core/import/export/stores.js +73 -0
- package/packages/crouter-api/dist/core/import/load/catalog.js +70 -0
- package/packages/crouter-api/dist/core/import/load/copy.js +132 -0
- package/packages/crouter-api/dist/core/import/load/prepare.js +211 -0
- package/packages/crouter-api/dist/core/import/load/rewrite.js +310 -0
- package/packages/crouter-api/dist/core/import/load/stage.js +99 -0
- package/packages/crouter-api/dist/core/inspector/chrome.js +14 -0
- package/packages/crouter-api/dist/core/inspector/contract.js +1 -0
- package/packages/crouter-api/dist/core/inspector/core.js +296 -0
- package/packages/crouter-api/dist/core/inspector/host.js +538 -0
- package/packages/crouter-api/dist/core/inspector/model.js +225 -0
- package/packages/crouter-api/dist/core/inspector/text.js +45 -0
- package/packages/crouter-api/dist/core/inspector/transport.js +36 -0
- package/packages/crouter-api/dist/core/inspector/tui.js +295 -0
- package/packages/crouter-api/dist/core/installed-plugins.js +82 -0
- package/packages/crouter-api/dist/core/io.js +470 -0
- package/packages/crouter-api/dist/core/keybindings/attach-control.js +42 -0
- package/packages/crouter-api/dist/core/keybindings/background-bash.js +33 -0
- package/packages/crouter-api/dist/core/keybindings/catalog.js +288 -0
- package/packages/crouter-api/dist/core/keybindings/inbox.js +25 -0
- package/packages/crouter-api/dist/core/keybindings/index.js +7 -0
- package/packages/crouter-api/dist/core/keybindings/match.js +146 -0
- package/packages/crouter-api/dist/core/keybindings/persistence.js +49 -0
- package/packages/crouter-api/dist/core/keybindings/resolve.js +348 -0
- package/packages/crouter-api/dist/core/keybindings/types.js +1 -0
- package/packages/crouter-api/dist/core/layout-migrate/index.js +523 -0
- package/packages/crouter-api/dist/core/layout-migrate/paths.js +118 -0
- package/packages/crouter-api/dist/core/layout-migrate/stored-paths.js +424 -0
- package/packages/crouter-api/dist/core/layout-migrate/stores.js +543 -0
- package/packages/crouter-api/dist/core/layout.js +143 -0
- package/packages/crouter-api/dist/core/ledger/account.js +13 -0
- package/packages/crouter-api/dist/core/ledger/charges.js +44 -0
- package/packages/crouter-api/dist/core/ledger/check.js +40 -0
- package/packages/crouter-api/dist/core/ledger/chunks.js +43 -0
- package/packages/crouter-api/dist/core/ledger/index.js +10 -0
- package/packages/crouter-api/dist/core/ledger/infra-allowance.js +31 -0
- package/packages/crouter-api/dist/core/ledger/limits.js +35 -0
- package/packages/crouter-api/dist/core/ledger/months.js +19 -0
- package/packages/crouter-api/dist/core/ledger/payer.js +14 -0
- package/packages/crouter-api/dist/core/ledger/rates.js +64 -0
- package/packages/crouter-api/dist/core/ledger/read.js +194 -0
- package/packages/crouter-api/dist/core/ledger/totals.js +34 -0
- package/packages/crouter-api/dist/core/ledger/types.js +2 -0
- package/packages/crouter-api/dist/core/llm/app-rungs.js +64 -0
- package/packages/crouter-api/dist/core/llm/body-limits.js +7 -0
- package/packages/crouter-api/dist/core/llm/owner-candidates.js +79 -0
- package/packages/crouter-api/dist/core/llm/refusal.js +22 -0
- package/packages/crouter-api/dist/core/llm/run.js +558 -0
- package/packages/crouter-api/dist/core/locked-file.js +121 -0
- package/packages/crouter-api/dist/core/log.js +91 -0
- package/packages/crouter-api/dist/core/managed-providers.js +61 -0
- package/packages/crouter-api/dist/core/manifest-stale.js +39 -0
- package/packages/crouter-api/dist/core/manifest.js +37 -0
- package/packages/crouter-api/dist/core/model-auth/api-credential-store.js +49 -0
- package/packages/crouter-api/dist/core/model-auth/daemon-login.js +156 -0
- package/packages/crouter-api/dist/core/model-auth/readiness.js +83 -0
- package/packages/crouter-api/dist/core/model-routes-pool.js +57 -0
- package/packages/crouter-api/dist/core/model-routes.js +212 -0
- package/packages/crouter-api/dist/core/northlight/previews.js +87 -0
- package/packages/crouter-api/dist/core/nvim-launch.js +45 -0
- package/packages/crouter-api/dist/core/output.js +99 -0
- package/packages/crouter-api/dist/core/packages/eligibility.js +34 -0
- package/packages/crouter-api/dist/core/packages/launch-kinds.js +20 -0
- package/packages/crouter-api/dist/core/packages/source-url.js +17 -0
- package/packages/crouter-api/dist/core/pagination.js +88 -0
- package/packages/crouter-api/dist/core/peer/client.js +168 -0
- package/packages/crouter-api/dist/core/peer/directory.js +193 -0
- package/packages/crouter-api/dist/core/peer/envelope.js +98 -0
- package/packages/crouter-api/dist/core/peer/names.js +8 -0
- package/packages/crouter-api/dist/core/peer/outbox-store.js +84 -0
- package/packages/crouter-api/dist/core/peer/receiver.js +54 -0
- package/packages/crouter-api/dist/core/peer/stubs.js +208 -0
- package/packages/crouter-api/dist/core/peer/token.js +30 -0
- package/packages/crouter-api/dist/core/peer/version.js +23 -0
- package/packages/crouter-api/dist/core/permissions/builtin.js +29 -0
- package/packages/crouter-api/dist/core/permissions/ceiling.js +332 -0
- package/packages/crouter-api/dist/core/permissions/compile.js +175 -0
- package/packages/crouter-api/dist/core/permissions/errors.js +13 -0
- package/packages/crouter-api/dist/core/permissions/evaluator.js +98 -0
- package/packages/crouter-api/dist/core/permissions/facts.js +102 -0
- package/packages/crouter-api/dist/core/permissions/schema-parser.js +151 -0
- package/packages/crouter-api/dist/core/permissions/schemas.js +83 -0
- package/packages/crouter-api/dist/core/permissions/sql.js +31 -0
- package/packages/crouter-api/dist/core/plugin-app.js +58 -0
- package/packages/crouter-api/dist/core/plugin-env.js +30 -0
- package/packages/crouter-api/dist/core/plugin-extensions.js +191 -0
- package/packages/crouter-api/dist/core/plugin-objects-manifest.js +86 -0
- package/packages/crouter-api/dist/core/plugin-quarantine.js +70 -0
- package/packages/crouter-api/dist/core/plugin-swap-lock.js +31 -0
- package/packages/crouter-api/dist/core/pool-credential-store.js +116 -0
- package/packages/crouter-api/dist/core/predicate.js +191 -0
- package/packages/crouter-api/dist/core/preview-registry.js +403 -0
- package/packages/crouter-api/dist/core/preview-result-path.js +26 -0
- package/packages/crouter-api/dist/core/profiles/default-binding.js +29 -0
- package/packages/crouter-api/dist/core/profiles/deletion-reservation.js +42 -0
- package/packages/crouter-api/dist/core/profiles/fuzzy-match.js +92 -0
- package/packages/crouter-api/dist/core/profiles/manifest.js +574 -0
- package/packages/crouter-api/dist/core/profiles/select.js +740 -0
- package/packages/crouter-api/dist/core/provider-credential.js +17 -0
- package/packages/crouter-api/dist/core/provider-error-recognition.js +82 -0
- package/packages/crouter-api/dist/core/provider-failure.js +157 -0
- package/packages/crouter-api/dist/core/provider-management.js +9 -0
- package/packages/crouter-api/dist/core/providers/approval.js +146 -0
- package/packages/crouter-api/dist/core/providers/audit.js +52 -0
- package/packages/crouter-api/dist/core/providers/bundles.js +643 -0
- package/packages/crouter-api/dist/core/providers/call.js +497 -0
- package/packages/crouter-api/dist/core/providers/description.js +1 -0
- package/packages/crouter-api/dist/core/providers/device-libs.js +202 -0
- package/packages/crouter-api/dist/core/providers/device.js +95 -0
- package/packages/crouter-api/dist/core/providers/errors.js +136 -0
- package/packages/crouter-api/dist/core/providers/files.js +390 -0
- package/packages/crouter-api/dist/core/providers/inflight.js +14 -0
- package/packages/crouter-api/dist/core/providers/mint.js +219 -0
- package/packages/crouter-api/dist/core/providers/receipts.js +61 -0
- package/packages/crouter-api/dist/core/providers/request.js +173 -0
- package/packages/crouter-api/dist/core/providers/roots.js +118 -0
- package/packages/crouter-api/dist/core/providers/token-cache.js +203 -0
- package/packages/crouter-api/dist/core/rate-limit-scope.js +64 -0
- package/packages/crouter-api/dist/core/remote-canvas-target.js +30 -0
- package/packages/crouter-api/dist/core/render.js +146 -0
- package/packages/crouter-api/dist/core/resolver.js +111 -0
- package/packages/crouter-api/dist/core/review/comments.js +296 -0
- package/packages/crouter-api/dist/core/review/companion.js +211 -0
- package/packages/crouter-api/dist/core/review/signal.js +12 -0
- package/packages/crouter-api/dist/core/review/store.js +178 -0
- package/packages/crouter-api/dist/core/review/types.js +23 -0
- package/packages/crouter-api/dist/core/runs/activity.js +57 -0
- package/packages/crouter-api/dist/core/runs/events.js +179 -0
- package/packages/crouter-api/dist/core/runs/initial-input.js +27 -0
- package/packages/crouter-api/dist/core/runs/operations.js +793 -0
- package/packages/crouter-api/dist/core/runs/questions.js +151 -0
- package/packages/crouter-api/dist/core/runtime/banner.js +53 -0
- package/packages/crouter-api/dist/core/runtime/bearings-render.js +273 -0
- package/packages/crouter-api/dist/core/runtime/bearings.js +199 -0
- package/packages/crouter-api/dist/core/runtime/bin-contributions.js +186 -0
- package/packages/crouter-api/dist/core/runtime/blaxel-environment.js +17 -0
- package/packages/crouter-api/dist/core/runtime/branded-host.js +485 -0
- package/packages/crouter-api/dist/core/runtime/broker/attachments-fetch.js +20 -0
- package/packages/crouter-api/dist/core/runtime/broker/bash-job-launch.js +66 -0
- package/packages/crouter-api/dist/core/runtime/broker/daemon-ops.js +232 -0
- package/packages/crouter-api/dist/core/runtime/broker/model-adapter.js +431 -0
- package/packages/crouter-api/dist/core/runtime/broker/node-token.js +16 -0
- package/packages/crouter-api/dist/core/runtime/broker/read-ops.js +173 -0
- package/packages/crouter-api/dist/core/runtime/broker/signal-stream.js +149 -0
- package/packages/crouter-api/dist/core/runtime/broker/turn-cause.js +44 -0
- package/packages/crouter-api/dist/core/runtime/broker-protocol.js +152 -0
- package/packages/crouter-api/dist/core/runtime/broker-request.js +86 -0
- package/packages/crouter-api/dist/core/runtime/broker-sdk.js +130 -0
- package/packages/crouter-api/dist/core/runtime/canvas-extensions.js +100 -0
- package/packages/crouter-api/dist/core/runtime/close.js +266 -0
- package/packages/crouter-api/dist/core/runtime/command-expansion.js +104 -0
- package/packages/crouter-api/dist/core/runtime/command-surface.js +117 -0
- package/packages/crouter-api/dist/core/runtime/crtr-theme.js +146 -0
- package/packages/crouter-api/dist/core/runtime/deliver-live.js +84 -0
- package/packages/crouter-api/dist/core/runtime/fault-recovery.js +83 -0
- package/packages/crouter-api/dist/core/runtime/fault.js +17 -0
- package/packages/crouter-api/dist/core/runtime/fleet.js +75 -0
- package/packages/crouter-api/dist/core/runtime/focus-viewer.js +151 -0
- package/packages/crouter-api/dist/core/runtime/front-door-env.js +16 -0
- package/packages/crouter-api/dist/core/runtime/headless-pi.js +176 -0
- package/packages/crouter-api/dist/core/runtime/host.js +701 -0
- package/packages/crouter-api/dist/core/runtime/interactive-deliver.js +51 -0
- package/packages/crouter-api/dist/core/runtime/invocation.js +10 -0
- package/packages/crouter-api/dist/core/runtime/kickoff.js +263 -0
- package/packages/crouter-api/dist/core/runtime/launch-prompt.js +13 -0
- package/packages/crouter-api/dist/core/runtime/launch-target.js +87 -0
- package/packages/crouter-api/dist/core/runtime/launch.js +505 -0
- package/packages/crouter-api/dist/core/runtime/ledger.js +55 -0
- package/packages/crouter-api/dist/core/runtime/lifecycle.js +283 -0
- package/packages/crouter-api/dist/core/runtime/managed-provider-cooling.js +62 -0
- package/packages/crouter-api/dist/core/runtime/memory-admission.js +68 -0
- package/packages/crouter-api/dist/core/runtime/model-registry.js +13 -0
- package/packages/crouter-api/dist/core/runtime/model-selection.js +135 -0
- package/packages/crouter-api/dist/core/runtime/model-swap.js +75 -0
- package/packages/crouter-api/dist/core/runtime/naming.js +300 -0
- package/packages/crouter-api/dist/core/runtime/nerd-font.js +162 -0
- package/packages/crouter-api/dist/core/runtime/nodes.js +506 -0
- package/packages/crouter-api/dist/core/runtime/outcome-document.js +86 -0
- package/packages/crouter-api/dist/core/runtime/output-result.js +32 -0
- package/packages/crouter-api/dist/core/runtime/output-schema-refs.js +100 -0
- package/packages/crouter-api/dist/core/runtime/package-health.js +100 -0
- package/packages/crouter-api/dist/core/runtime/persona.js +54 -0
- package/packages/crouter-api/dist/core/runtime/pi-cli.js +65 -0
- package/packages/crouter-api/dist/core/runtime/pi-vendored.js +63 -0
- package/packages/crouter-api/dist/core/runtime/placement-tmux.js +81 -0
- package/packages/crouter-api/dist/core/runtime/placement.js +418 -0
- package/packages/crouter-api/dist/core/runtime/progress-bar.js +50 -0
- package/packages/crouter-api/dist/core/runtime/provider-credential-gate.js +48 -0
- package/packages/crouter-api/dist/core/runtime/recovery-hold.js +46 -0
- package/packages/crouter-api/dist/core/runtime/reopen.js +160 -0
- package/packages/crouter-api/dist/core/runtime/revive.js +748 -0
- package/packages/crouter-api/dist/core/runtime/roadmap.js +86 -0
- package/packages/crouter-api/dist/core/runtime/runner/blaxel/client.js +140 -0
- package/packages/crouter-api/dist/core/runtime/runner/blaxel/image-build.js +233 -0
- package/packages/crouter-api/dist/core/runtime/runner/delete-sandboxes.js +24 -0
- package/packages/crouter-api/dist/core/runtime/runner/index.js +37 -0
- package/packages/crouter-api/dist/core/runtime/runner/machine/call.js +94 -0
- package/packages/crouter-api/dist/core/runtime/runner/machine/environment.js +7 -0
- package/packages/crouter-api/dist/core/runtime/runner/machine/ops.js +42 -0
- package/packages/crouter-api/dist/core/runtime/runner/machine/runner.js +90 -0
- package/packages/crouter-api/dist/core/runtime/runner/process.js +70 -0
- package/packages/crouter-api/dist/core/runtime/runner/types.js +16 -0
- package/packages/crouter-api/dist/core/runtime/session-branch.js +16 -0
- package/packages/crouter-api/dist/core/runtime/session-cycles.js +110 -0
- package/packages/crouter-api/dist/core/runtime/session-list-cache.js +302 -0
- package/packages/crouter-api/dist/core/runtime/session-visibility.js +99 -0
- package/packages/crouter-api/dist/core/runtime/setup-marker.js +46 -0
- package/packages/crouter-api/dist/core/runtime/situational-context.js +54 -0
- package/packages/crouter-api/dist/core/runtime/situational-live.js +41 -0
- package/packages/crouter-api/dist/core/runtime/spawn-env-rows.js +15 -0
- package/packages/crouter-api/dist/core/runtime/spawn-env.js +260 -0
- package/packages/crouter-api/dist/core/runtime/spawn.js +717 -0
- package/packages/crouter-api/dist/core/runtime/stamp/protocol.js +113 -0
- package/packages/crouter-api/dist/core/runtime/start-check.js +43 -0
- package/packages/crouter-api/dist/core/runtime/stop-guard.js +150 -0
- package/packages/crouter-api/dist/core/runtime/structured-output.js +112 -0
- package/packages/crouter-api/dist/core/runtime/surface-bg.js +85 -0
- package/packages/crouter-api/dist/core/runtime/tmux-bindings.js +743 -0
- package/packages/crouter-api/dist/core/runtime/tmux-chrome.js +5 -0
- package/packages/crouter-api/dist/core/runtime/tmux-driver.js +713 -0
- package/packages/crouter-api/dist/core/runtime/unsandboxed.js +18 -0
- package/packages/crouter-api/dist/core/runtime/view-socket.js +195 -0
- package/packages/crouter-api/dist/core/runtime/warm-pool.js +479 -0
- package/packages/crouter-api/dist/core/scope.js +184 -0
- package/packages/crouter-api/dist/core/scoped-state/db.js +271 -0
- package/packages/crouter-api/dist/core/scoped-state/legacy-profiles.js +65 -0
- package/packages/crouter-api/dist/core/scoped-state/migrate.js +332 -0
- package/packages/crouter-api/dist/core/scoped-state/paths.js +27 -0
- package/packages/crouter-api/dist/core/scoped-state/person-rows.js +185 -0
- package/packages/crouter-api/dist/core/scoped-state/person-store.js +116 -0
- package/packages/crouter-api/dist/core/scoped-state/schema.js +52 -0
- package/packages/crouter-api/dist/core/scopes.js +48 -0
- package/packages/crouter-api/dist/core/secrets/env-rows.js +40 -0
- package/packages/crouter-api/dist/core/secrets/environment-owner.js +31 -0
- package/packages/crouter-api/dist/core/secrets/environment-secrets.js +14 -0
- package/packages/crouter-api/dist/core/secrets/index.js +2 -0
- package/packages/crouter-api/dist/core/secrets/key.js +33 -0
- package/packages/crouter-api/dist/core/secrets/seal.js +43 -0
- package/packages/crouter-api/dist/core/secrets.js +147 -0
- package/packages/crouter-api/dist/core/self-update.js +77 -0
- package/packages/crouter-api/dist/core/session-model/session-state.js +180 -0
- package/packages/crouter-api/dist/core/shell-segments.js +169 -0
- package/packages/crouter-api/dist/core/spaces/cache-env.js +15 -0
- package/packages/crouter-api/dist/core/spaces/file-root.js +68 -0
- package/packages/crouter-api/dist/core/spaces/mounts.js +126 -0
- package/packages/crouter-api/dist/core/spaces/open-beneath.js +581 -0
- package/packages/crouter-api/dist/core/spaces/permissions.js +77 -0
- package/packages/crouter-api/dist/core/spaces/process.js +172 -0
- package/packages/crouter-api/dist/core/spaces/runtime-home.js +8 -0
- package/packages/crouter-api/dist/core/spaces/space.js +58 -0
- package/packages/crouter-api/dist/core/spaces/stop.js +138 -0
- package/packages/crouter-api/dist/core/spaces/users.js +43 -0
- package/packages/crouter-api/dist/core/sqlite-statements.js +17 -0
- package/packages/crouter-api/dist/core/statements.js +81 -0
- package/packages/crouter-api/dist/core/storage/attachments.js +141 -0
- package/packages/crouter-api/dist/core/storage/caller-file.js +84 -0
- package/packages/crouter-api/dist/core/storage/client.js +220 -0
- package/packages/crouter-api/dist/core/storage/media-types.js +22 -0
- package/packages/crouter-api/dist/core/storage/purge.js +55 -0
- package/packages/crouter-api/dist/core/storage/tables.js +129 -0
- package/packages/crouter-api/dist/core/subscription-state.js +449 -0
- package/packages/crouter-api/dist/core/substrate/delivery/corpus.js +206 -0
- package/packages/crouter-api/dist/core/substrate/delivery/deliver.js +336 -0
- package/packages/crouter-api/dist/core/substrate/delivery/listings.js +75 -0
- package/packages/crouter-api/dist/core/substrate/delivery/match.js +146 -0
- package/packages/crouter-api/dist/core/substrate/delivery/plan.js +130 -0
- package/packages/crouter-api/dist/core/substrate/delivery/render-boot.js +330 -0
- package/packages/crouter-api/dist/core/substrate/delivery/render-event.js +186 -0
- package/packages/crouter-api/dist/core/substrate/delivery/sub-persona-menu.js +24 -0
- package/packages/crouter-api/dist/core/substrate/delivery/types.js +1 -0
- package/packages/crouter-api/dist/core/substrate/gate-explain.js +397 -0
- package/packages/crouter-api/dist/core/substrate/schema.js +81 -0
- package/packages/crouter-api/dist/core/substrate/subject-fields.js +39 -0
- package/packages/crouter-api/dist/core/substrate/subject.js +60 -0
- package/packages/crouter-api/dist/core/termrender/code-doc.js +92 -0
- package/packages/crouter-api/dist/core/termrender/display.js +56 -0
- package/packages/crouter-api/dist/core/termrender/termrender.js +719 -0
- package/packages/crouter-api/dist/core/termrender/version.js +1 -0
- package/packages/crouter-api/dist/core/timing.js +94 -0
- package/packages/crouter-api/dist/core/tui/draw.js +378 -0
- package/packages/crouter-api/dist/core/tui/fuzzy.js +38 -0
- package/packages/crouter-api/dist/core/tui/markdown.js +407 -0
- package/packages/crouter-api/dist/core/tui/page-host.js +74 -0
- package/packages/crouter-api/dist/core/tui/panel.js +142 -0
- package/packages/crouter-api/dist/core/tui/terminal.js +100 -0
- package/packages/crouter-api/dist/core/user-settings.js +478 -0
- package/packages/crouter-api/dist/core/wake.js +296 -0
- package/packages/crouter-api/dist/core/worktree-close.js +251 -0
- package/packages/crouter-api/dist/core/worktree-containment.js +48 -0
- package/packages/crouter-api/dist/core/worktree-landing.js +56 -0
- package/packages/crouter-api/dist/core/worktree-machine.js +92 -0
- package/packages/crouter-api/dist/core/worktree-mutation-async.js +385 -0
- package/packages/crouter-api/dist/core/worktree-remove.js +84 -0
- package/packages/crouter-api/dist/core/worktree.js +909 -0
- package/packages/crouter-api/dist/daemon/api/deferred-head.js +117 -0
- package/packages/crouter-api/dist/daemon/api/environment-of.js +64 -0
- package/packages/crouter-api/dist/daemon/api/handlers/bash-jobs.js +341 -0
- package/packages/crouter-api/dist/daemon/api/handlers/broker-recovery.js +266 -0
- package/packages/crouter-api/dist/daemon/api/handlers/git-credential.js +64 -0
- package/packages/crouter-api/dist/daemon/api/handlers/providers.js +284 -0
- package/packages/crouter-api/dist/daemon/api/handlers/validate.js +58 -0
- package/packages/crouter-api/dist/daemon/api/map.js +768 -0
- package/packages/crouter-api/dist/daemon/api/operations.js +316 -0
- package/packages/crouter-api/dist/daemon/api/principal.js +147 -0
- package/packages/crouter-api/dist/daemon/api/reader.js +125 -0
- package/packages/crouter-api/dist/daemon/api/router.js +542 -0
- package/packages/crouter-api/dist/daemon/api/sync-notice.js +46 -0
- package/packages/crouter-api/dist/daemon/api/viewer-presence.js +100 -0
- package/packages/crouter-api/dist/daemon/broker-signals/bus.js +203 -0
- package/packages/crouter-api/dist/daemon/companion-retire.js +44 -0
- package/packages/crouter-api/dist/daemon/control.js +22 -0
- package/packages/crouter-api/dist/daemon/cron/authority.js +101 -0
- package/packages/crouter-api/dist/daemon/cron/live-runs.js +66 -0
- package/packages/crouter-api/dist/daemon/cron/run-socket.js +170 -0
- package/packages/crouter-api/dist/daemon/drain.js +76 -0
- package/packages/crouter-api/dist/daemon/http-dispatcher.js +37 -0
- package/packages/crouter-api/dist/daemon/human/finish.js +178 -0
- package/packages/crouter-api/dist/daemon/human/settle.js +103 -0
- package/packages/crouter-api/dist/daemon/machine-link/config.js +63 -0
- package/packages/crouter-api/dist/daemon/machine-link/credential.js +24 -0
- package/packages/crouter-api/dist/daemon/machine-link/forward.js +181 -0
- package/packages/crouter-api/dist/daemon/machine-link/frames.js +29 -0
- package/packages/crouter-api/dist/daemon/machine-link/holder.js +317 -0
- package/packages/crouter-api/dist/daemon/machine-link/move-notify.js +15 -0
- package/packages/crouter-api/dist/daemon/manage.js +736 -0
- package/packages/crouter-api/dist/daemon/park-activity.js +33 -0
- package/packages/crouter-api/dist/daemon/park-pending.js +76 -0
- package/packages/crouter-api/dist/daemon/pidfile.js +37 -0
- package/packages/crouter-api/dist/daemon/postgres/binary.js +193 -0
- package/packages/crouter-api/dist/daemon/postgres/cluster.js +111 -0
- package/packages/crouter-api/dist/daemon/postgres/pins.js +16 -0
- package/packages/crouter-api/dist/daemon/postgres/supervisor.js +177 -0
- package/packages/crouter-api/dist/daemon/readiness.js +37 -0
- package/packages/crouter-api/dist/daemon/reconcilers/broker-supervision.js +846 -0
- package/packages/crouter-api/dist/daemon/reconcilers/ledger-sandbox.js +249 -0
- package/packages/crouter-api/dist/daemon/reconcilers/live-obligation.js +125 -0
- package/packages/crouter-api/dist/daemon/reconcilers/node-lifecycle/launch-failure.js +8 -0
- package/packages/crouter-api/dist/daemon/reconcilers/node-lifecycle/node-person.js +40 -0
- package/packages/crouter-api/dist/daemon/reconcilers/node-lifecycle/remote-wake.js +151 -0
- package/packages/crouter-api/dist/daemon/reconcilers/node-lifecycle/respawn-policy.js +59 -0
- package/packages/crouter-api/dist/daemon/reconcilers/recipe-image.js +196 -0
- package/packages/crouter-api/dist/daemon/reconcilers/throttled-lane.js +63 -0
- package/packages/crouter-api/dist/daemon/runs/append-section.js +135 -0
- package/packages/crouter-api/dist/daemon/runs/observer.js +441 -0
- package/packages/crouter-api/dist/daemon/runs/view-transport.js +81 -0
- package/packages/crouter-api/dist/daemon/startup-policy.js +1 -0
- package/packages/crouter-api/dist/daemon/structured-requests/sidecar.js +5 -0
- package/packages/crouter-api/dist/hook-authoring.js +447 -0
- package/packages/crouter-api/dist/hook-process.js +34 -0
- package/packages/crouter-api/dist/launcher/client.js +52 -0
- package/packages/crouter-api/dist/launcher/limits/policy.js +142 -0
- package/packages/crouter-api/dist/launcher/limits/settings.js +94 -0
- package/packages/crouter-api/dist/launcher/spec.js +10 -0
- package/packages/crouter-api/dist/migrations/004-canvas-documents/apply.js +113 -0
- package/packages/crouter-api/dist/migrations/004-canvas-documents/fields.js +52 -0
- package/packages/crouter-api/dist/migrations/004-canvas-documents/index.js +89 -0
- package/packages/crouter-api/dist/migrations/004-canvas-documents/legacy/discover.js +251 -0
- package/packages/crouter-api/dist/migrations/004-canvas-documents/legacy/history.js +37 -0
- package/packages/crouter-api/dist/migrations/004-canvas-documents/legacy/nested.js +37 -0
- package/packages/crouter-api/dist/migrations/004-canvas-documents/legacy/parse.js +24 -0
- package/packages/crouter-api/dist/migrations/004-canvas-documents/legacy/types.js +3 -0
- package/packages/crouter-api/dist/migrations/004-canvas-documents/plan.js +410 -0
- package/packages/crouter-api/dist/migrations/004-canvas-documents/pointers.js +95 -0
- package/packages/crouter-api/dist/migrations/activation.js +46 -0
- package/packages/crouter-api/dist/native/linux.js +20 -0
- package/packages/crouter-api/dist/shared/crtr-version.js +18 -0
- package/packages/crouter-api/dist/shared/env.js +335 -0
- package/packages/crouter-api/dist/shared/generated-context.js +240 -0
- package/packages/crouter-api/dist/shared/inbox-entry-body.js +124 -0
- package/packages/crouter-api/dist/shared/inline-ref-grammar.js +99 -0
- package/packages/crouter-api/dist/shared/predicates.js +4 -0
- package/packages/crouter-api/dist/shared/shell-quote.js +5 -0
- package/packages/crouter-api/dist/shared/strip-cd-prefix.js +13 -0
- package/packages/crouter-api/dist/shared/tool-groups.js +64 -0
- package/packages/crouter-api/dist/shared/traceparent.js +28 -0
- package/packages/crouter-api/dist/shared/turn-replies.js +71 -0
- package/packages/crouter-api/dist/shared/working-activity.js +27 -0
- package/packages/crouter-api/dist/types.js +193 -0
- package/packages/crouter-api/package.json +49 -0
- package/packages/crouter-identity/package.json +1 -1
- package/packages/crouter-plugin/dist/approval.js +12 -0
- package/packages/crouter-plugin/dist/bundle.js +203 -0
- package/packages/crouter-plugin/dist/caller.js +23 -0
- package/packages/crouter-plugin/dist/client/index.js +338 -0
- package/packages/crouter-plugin/dist/compare.js +314 -0
- package/packages/crouter-plugin/dist/define.js +531 -0
- package/packages/crouter-plugin/dist/errors.js +150 -0
- package/packages/crouter-plugin/dist/fields.js +83 -0
- package/packages/crouter-plugin/dist/index.js +15 -0
- package/packages/crouter-plugin/dist/manifest.js +111 -0
- package/packages/crouter-plugin/dist/node.js +153 -0
- package/packages/crouter-plugin/dist/params.js +85 -0
- package/packages/crouter-plugin/dist/receipts.js +234 -0
- package/packages/crouter-plugin/dist/serve.js +630 -0
- package/packages/crouter-plugin/dist/verify.js +84 -0
- package/packages/crouter-plugin/dist/watchable.js +14 -0
- package/packages/crouter-plugin/package.json +42 -0
- package/runtime.lock.json +14 -13
- package/dist/core/graph/repo-sync/index.d.ts +0 -4
- package/dist/core/graph/repo-sync/index.js +0 -1
- package/dist/core/graph/repo-sync/mirror.d.ts +0 -30
- package/dist/core/graph/repo-sync/mirror.js +0 -6
- package/dist/core/graph/repo-sync/sync.d.ts +0 -40
- package/dist/core/graph/repo-sync/sync.js +0 -2
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
import { createPrivateKey, randomUUID, sign } from 'node:crypto';
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
import { join } from 'node:path';
|
|
4
|
+
import { crtrHome } from '../canvas/paths.js';
|
|
5
|
+
import { withCanvasWrite } from '../canvas/db.js';
|
|
6
|
+
import { isUnsandboxedMachine } from '../runtime/unsandboxed.js';
|
|
7
|
+
import { emitEvent } from '../events/emit.js';
|
|
8
|
+
import { describeOutboundFailure, outboundFetch, outboundJson, outboundRefusal } from '../events/outbound.js';
|
|
9
|
+
import { dependenciesOf, inferenceEndpointOf, replaceGrants, teamsOf } from './mirror.js';
|
|
10
|
+
import { onGrantSync } from './on-sync.js';
|
|
11
|
+
import { hostedEndpointOf, paymentSetupUrlOf, storeHostedEndpoint } from './hosted-endpoint.js';
|
|
12
|
+
import { adoptInstallPerson } from '../scoped-state/migrate.js';
|
|
13
|
+
import { PersonOutsideRequestError, PersonUnresolvedError, personId, resolvePerson, retireLocalPerson, setPersonId } from '../canvas/person.js';
|
|
14
|
+
export const GRANT_SYNC_INTERVAL_S = 300;
|
|
15
|
+
/** A `private_key_jwt` client assertion for `endpoint` (the directory's token endpoint), signed by the runtime client key. */
|
|
16
|
+
export function assertion(client, endpoint) {
|
|
17
|
+
const now = Math.floor(Date.now() / 1000);
|
|
18
|
+
const header = Buffer.from(JSON.stringify({ alg: 'ES256', typ: 'JWT', kid: client.kid })).toString('base64url');
|
|
19
|
+
const payload = Buffer.from(JSON.stringify({ iss: client.client_id, sub: client.client_id, aud: endpoint,
|
|
20
|
+
iat: now, exp: now + 300, jti: randomUUID() })).toString('base64url');
|
|
21
|
+
const input = `${header}.${payload}`;
|
|
22
|
+
const signature = sign('sha256', Buffer.from(input), { key: createPrivateKey({ key: client.jwk, format: 'jwk' }), dsaEncoding: 'ieee-p1363' });
|
|
23
|
+
return `${input}.${signature.toString('base64url')}`;
|
|
24
|
+
}
|
|
25
|
+
export function runtimeClient() {
|
|
26
|
+
const client = JSON.parse(readFileSync(join(crtrHome(), 'secrets', 'runtime-client.json'), 'utf8'));
|
|
27
|
+
if (!client.jwk || client.alg !== 'ES256' || !client.kid || !client.client_id || !client.runtime ||
|
|
28
|
+
client.jwk.kid !== client.kid || client.jwk.kty !== 'EC' || client.jwk.crv !== 'P-256' || !client.jwk.d) {
|
|
29
|
+
throw new TypeError('invalid runtime client key');
|
|
30
|
+
}
|
|
31
|
+
return client;
|
|
32
|
+
}
|
|
33
|
+
/** The runtime's id as storage names it: the directory principal id without `runtime:`. */
|
|
34
|
+
export function runtimeId(client = runtimeClient()) {
|
|
35
|
+
return client.runtime.startsWith('runtime:') ? client.runtime.slice('runtime:'.length) : client.runtime;
|
|
36
|
+
}
|
|
37
|
+
/** The text a person sees when the directory no longer recognises this machine. */
|
|
38
|
+
export function machineRevokedMessage(issuer) {
|
|
39
|
+
return `This machine was removed from your Northlight account. To use it again, create a join token at ${issuer.replace(/\/$/, '')}/account/machines, and run \`crtr sys join\` from a plain terminal.`;
|
|
40
|
+
}
|
|
41
|
+
/** The directory answered `invalid_client` to this runtime's key: the machine was revoked. */
|
|
42
|
+
export class MachineRevokedError extends Error {
|
|
43
|
+
constructor(issuer) { super(machineRevokedMessage(issuer)); this.name = 'MachineRevokedError'; }
|
|
44
|
+
}
|
|
45
|
+
/** A `client_credentials` token for the runtime client. With `audience`, the
|
|
46
|
+
* directory issues it for that audience (the storage service); without, for
|
|
47
|
+
* the directory's own `/v1`. `expires_at` is epoch ms. */
|
|
48
|
+
/** A token from the directory's `/token` for this runtime: its `/v1` token with no `audience`, else a token for `audience`. A shared
|
|
49
|
+
* (cloud-role) runtime names the person with `sub`; the directory grants it only for an account whose default runtime it is. */
|
|
50
|
+
export async function mintDirectoryToken(issuer, audience, sub) {
|
|
51
|
+
const client = runtimeClient();
|
|
52
|
+
const tokenEndpoint = `${issuer.replace(/\/$/, '')}/token`;
|
|
53
|
+
const body = new URLSearchParams({ grant_type: 'client_credentials',
|
|
54
|
+
client_id: client.client_id,
|
|
55
|
+
client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
|
|
56
|
+
client_assertion: assertion(client, tokenEndpoint),
|
|
57
|
+
...(audience === undefined ? {} : { audience }),
|
|
58
|
+
...(sub === undefined ? {} : { sub }) });
|
|
59
|
+
const tokenResponse = await outboundFetch('directory_token', tokenEndpoint, { method: 'POST', body, signal: AbortSignal.timeout(10_000) });
|
|
60
|
+
if (!tokenResponse.ok) {
|
|
61
|
+
if (tokenResponse.status === 401 && isUnsandboxedMachine() && await isInvalidClient(tokenResponse))
|
|
62
|
+
throw new MachineRevokedError(issuer);
|
|
63
|
+
throw outboundRefusal('directory_token', tokenEndpoint, `directory token request failed: ${tokenResponse.status}`);
|
|
64
|
+
}
|
|
65
|
+
const token = await outboundJson('directory_token', tokenEndpoint, tokenResponse);
|
|
66
|
+
if (typeof token.access_token !== 'string')
|
|
67
|
+
throw new TypeError('directory token response has no access_token');
|
|
68
|
+
return { access_token: token.access_token, expires_at: tokenExpiry(token.access_token, token.expires_in) };
|
|
69
|
+
}
|
|
70
|
+
async function isInvalidClient(response) {
|
|
71
|
+
try {
|
|
72
|
+
return (await response.json()).error === 'invalid_client';
|
|
73
|
+
}
|
|
74
|
+
catch {
|
|
75
|
+
return false;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function tokenExpiry(accessToken, expiresIn) {
|
|
79
|
+
if (typeof expiresIn === 'number' && Number.isFinite(expiresIn) && expiresIn > 0)
|
|
80
|
+
return Date.now() + expiresIn * 1000;
|
|
81
|
+
try {
|
|
82
|
+
const payload = JSON.parse(Buffer.from(accessToken.split('.')[1] ?? '', 'base64url').toString('utf8'));
|
|
83
|
+
if (typeof payload.exp === 'number')
|
|
84
|
+
return payload.exp * 1000;
|
|
85
|
+
}
|
|
86
|
+
catch { /* an opaque token: fall through */ }
|
|
87
|
+
return Date.now() + 300_000;
|
|
88
|
+
}
|
|
89
|
+
/** An unsandboxed machine's answer also carries the account's hosted-runtime app
|
|
90
|
+
* grants (`runtime` = the hosted runtime), mirrored read-only. A sandboxed or
|
|
91
|
+
* hosted runtime accepts only its own runtime's records. */
|
|
92
|
+
function responseGrant(value, client) {
|
|
93
|
+
if (!value || typeof value !== 'object')
|
|
94
|
+
throw new TypeError('invalid grant sync response');
|
|
95
|
+
const grant = value;
|
|
96
|
+
const own = client.runtime.startsWith('runtime:') ? client.runtime : `runtime:${client.runtime}`;
|
|
97
|
+
// Another runtime's `app:terminal` grant is never mirrored: `terminalGrant(person)` must find only this runtime's.
|
|
98
|
+
const runtimeOk = grant.runtime === own ||
|
|
99
|
+
(isUnsandboxedMachine() && typeof grant.runtime === 'string' && grant.runtime.startsWith('runtime:') && grant.grantee !== 'app:terminal');
|
|
100
|
+
if (!runtimeOk || typeof grant.id !== 'string' || typeof grant.sub !== 'string' ||
|
|
101
|
+
typeof grant.grantee !== 'string' || !Number.isInteger(grant.rev) ||
|
|
102
|
+
!Array.isArray(grant.scopes) || !Array.isArray(grant.resolved_scopes) ||
|
|
103
|
+
!['active', 'revoked', 'removed'].includes(grant.status ?? '') || typeof grant.synced_at !== 'string') {
|
|
104
|
+
throw new TypeError('invalid grant sync response');
|
|
105
|
+
}
|
|
106
|
+
const revisions = value.revisions;
|
|
107
|
+
const approvedAt = revisions?.find((revision) => revision.rev === grant.rev)?.approved_at;
|
|
108
|
+
if (typeof approvedAt !== 'string')
|
|
109
|
+
throw new TypeError('grant revision has no approval time');
|
|
110
|
+
// An absent or unrecognised payer is `user` (an older directory sends none); the endpoint rides only an app-paid grant.
|
|
111
|
+
const payer = grant.payer === 'app' ? 'app' : 'user';
|
|
112
|
+
return { ...grant, spend_cap: grant.spend_cap ?? null, expires_at: grant.expires_at ?? null,
|
|
113
|
+
revoked_at: grant.revoked_at ?? null, approved_at: approvedAt, payer, dependencies: dependenciesOf(grant.dependencies),
|
|
114
|
+
inference_endpoint: payer === 'app' ? inferenceEndpointOf(grant.inference_endpoint) : null,
|
|
115
|
+
run_notice_url: typeof grant.run_notice_url === 'string' && grant.run_notice_url !== '' ? grant.run_notice_url : null };
|
|
116
|
+
}
|
|
117
|
+
/** The person this pull serves: the bound one, else (a hosted first boot has none until its first snapshot commits) the one
|
|
118
|
+
* resolved from the mirror, which must already hold the answer's grants. Null for a cloud role outside a request, or when the
|
|
119
|
+
* mirror names no single person yet. `late` is the resolution still to bind once the transaction commits. */
|
|
120
|
+
async function pullPerson() {
|
|
121
|
+
try {
|
|
122
|
+
return { id: personId(), late: null };
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
if (error instanceof PersonOutsideRequestError)
|
|
126
|
+
return null;
|
|
127
|
+
if (!(error instanceof PersonUnresolvedError))
|
|
128
|
+
throw error;
|
|
129
|
+
}
|
|
130
|
+
const resolved = await resolvePerson();
|
|
131
|
+
return resolved === null ? null : { id: resolved.id, late: resolved };
|
|
132
|
+
}
|
|
133
|
+
/** Bind a person resolved on a hosted first boot and run the boot one-shot. */
|
|
134
|
+
async function bindLatePerson(resolved) {
|
|
135
|
+
setPersonId(resolved.id);
|
|
136
|
+
await adoptInstallPerson(resolved.id);
|
|
137
|
+
const result = await retireLocalPerson();
|
|
138
|
+
emitEvent({ level: 'info', event: 'daemon.person.resolved', fields: { person_id: resolved.id, source: resolved.source } });
|
|
139
|
+
emitEvent({ level: 'info', event: 'daemon.person.retired', fields: { person_id: result.person, retired: result.retired, columns: result.columns } });
|
|
140
|
+
}
|
|
141
|
+
let current;
|
|
142
|
+
/** Ask the daemon's grant sync (the latest `createGrantSync`) for a pull; a
|
|
143
|
+
* no-op where none exists (v0, a process that is not the daemon). */
|
|
144
|
+
export function requestGrantSync(options) {
|
|
145
|
+
return current ? current(options) : Promise.resolve();
|
|
146
|
+
}
|
|
147
|
+
/** Calls share one in-flight pull, including the start, periodic, and
|
|
148
|
+
* unknown-grant triggers. A `fresh` call (a directory sync notice) needs a pull
|
|
149
|
+
* that started after it arrived: while one is in flight it queues exactly one
|
|
150
|
+
* more, which every later fresh call shares. A pull resolves once the mirror is
|
|
151
|
+
* committed and the R26 stops have started; stop completion and removal
|
|
152
|
+
* cascades run as `detach`ed work. */
|
|
153
|
+
export function createGrantSync(issuer, detach = (work) => { void work; }) {
|
|
154
|
+
let inFlight;
|
|
155
|
+
const base = issuer.replace(/\/$/, '');
|
|
156
|
+
const run = async () => {
|
|
157
|
+
const client = runtimeClient();
|
|
158
|
+
const token = await mintDirectoryToken(base);
|
|
159
|
+
const response = await outboundFetch('grant_sync', `${base}/v1/runtime/grants`, { headers: { Authorization: `Bearer ${token.access_token}` }, signal: AbortSignal.timeout(10_000) });
|
|
160
|
+
if (!response.ok)
|
|
161
|
+
throw outboundRefusal('grant_sync', `${base}/v1/runtime/grants`, `directory grant sync failed: ${response.status}`);
|
|
162
|
+
const payload = await outboundJson('grant_sync', `${base}/v1/runtime/grants`, response);
|
|
163
|
+
if (!Array.isArray(payload.grants) || typeof payload.synced_at !== 'string')
|
|
164
|
+
throw new TypeError('invalid grant sync response');
|
|
165
|
+
// An older directory sends neither field: the stored ones are left as they are.
|
|
166
|
+
const hosted = 'hosted_endpoint' in payload || 'payment_setup_url' in payload
|
|
167
|
+
? { hosted_endpoint: hostedEndpointOf(payload.hosted_endpoint ?? null), payment_setup_url: paymentSetupUrlOf(payload.payment_setup_url ?? null), synced_at: payload.synced_at }
|
|
168
|
+
: undefined;
|
|
169
|
+
const syncedAt = payload.synced_at;
|
|
170
|
+
const grants = payload.grants.map((grant) => responseGrant(grant, client));
|
|
171
|
+
// One transaction: the grants and the person's hosted fields land together, so no reader sees the new grants with the old fields.
|
|
172
|
+
const person = await withCanvasWrite(async () => {
|
|
173
|
+
await replaceGrants(grants, syncedAt, base, teamsOf(payload.teams));
|
|
174
|
+
const pulled = await pullPerson();
|
|
175
|
+
if (hosted && pulled)
|
|
176
|
+
await storeHostedEndpoint(hosted, pulled.id);
|
|
177
|
+
return pulled;
|
|
178
|
+
});
|
|
179
|
+
emitEvent({ level: 'info', event: 'daemon.grants.synced', fields: { grants: grants.length, synced_at: payload.synced_at } });
|
|
180
|
+
if (person?.late)
|
|
181
|
+
await bindLatePerson(person.late);
|
|
182
|
+
// The mirror is committed; stops start inside this pull, removals continue detached.
|
|
183
|
+
try {
|
|
184
|
+
await onGrantSync(detach);
|
|
185
|
+
}
|
|
186
|
+
catch (error) {
|
|
187
|
+
emitEvent({ level: 'error', event: 'daemon.grants.on_sync_failed', error });
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
let queued;
|
|
191
|
+
const start = () => {
|
|
192
|
+
const job = run().catch((error) => {
|
|
193
|
+
// The mirror is kept: nothing is deleted locally when the machine is removed.
|
|
194
|
+
if (error instanceof MachineRevokedError)
|
|
195
|
+
emitEvent({ level: 'error', event: 'daemon.grants.machine_revoked', error });
|
|
196
|
+
else
|
|
197
|
+
emitEvent({ level: 'error', event: 'daemon.grants.sync_failed', error, fields: describeOutboundFailure(error) });
|
|
198
|
+
throw error;
|
|
199
|
+
}).finally(() => { if (inFlight === job)
|
|
200
|
+
inFlight = undefined; });
|
|
201
|
+
inFlight = job;
|
|
202
|
+
return job;
|
|
203
|
+
};
|
|
204
|
+
const sync = (options = {}) => {
|
|
205
|
+
if (!inFlight)
|
|
206
|
+
return start();
|
|
207
|
+
if (!options.fresh)
|
|
208
|
+
return inFlight;
|
|
209
|
+
// The running pull may have fetched before the change this caller announces.
|
|
210
|
+
// A pull another caller started after this point is just as fresh; share it.
|
|
211
|
+
queued ??= inFlight.catch(() => { }).then(() => { queued = undefined; return inFlight ?? start(); });
|
|
212
|
+
return queued;
|
|
213
|
+
};
|
|
214
|
+
current = sync;
|
|
215
|
+
return sync;
|
|
216
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Which person a terminal-app call is for, and that person's terminal grant. One runtime serves many people on the fleet,
|
|
2
|
+
// so no caller asks for "the" terminal grant: it asks for a person's.
|
|
3
|
+
import { PersonOutsideRequestError, PersonUnresolvedError, personIdAsync } from '../canvas/person.js';
|
|
4
|
+
import { terminalGrant } from './mirror.js';
|
|
5
|
+
/** The request's person, or on a Mac the install's person. Null when there is none: a hosted first boot before its first grant snapshot, or a cloud
|
|
6
|
+
* role outside a request (a lane there works for the person on the row it claimed; it never borrows "the only grant"). */
|
|
7
|
+
export async function callerPerson() {
|
|
8
|
+
try {
|
|
9
|
+
return await personIdAsync();
|
|
10
|
+
}
|
|
11
|
+
catch (error) {
|
|
12
|
+
if (error instanceof PersonUnresolvedError || error instanceof PersonOutsideRequestError)
|
|
13
|
+
return null;
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
/** The terminal grant of the request person (or, on a Mac, the install's person); null when the call has no person. */
|
|
18
|
+
export async function callerTerminalGrant() {
|
|
19
|
+
const person = await callerPerson();
|
|
20
|
+
return person === null ? null : await terminalGrant(person);
|
|
21
|
+
}
|
|
22
|
+
/** The terminal grant of the person a node row belongs to: its own `sub`, else (a node born before its person was known) the caller's. */
|
|
23
|
+
export async function nodeTerminalGrant(node) {
|
|
24
|
+
return node.sub ? await terminalGrant(node.sub) : await callerTerminalGrant();
|
|
25
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { check, resolveReader } from '../permissions/evaluator.js';
|
|
2
|
+
/** The top of the object's owner chain (the object itself when it has no owner): its app, person or repo. */
|
|
3
|
+
export async function spaceOf(db, object) {
|
|
4
|
+
const top = await db.prepare(`WITH RECURSIVE chain(id, owner, depth) AS (
|
|
5
|
+
SELECT id, owner, 0 FROM objects WHERE id = ?
|
|
6
|
+
UNION ALL
|
|
7
|
+
SELECT o.id, o.owner, c.depth + 1 FROM objects o JOIN chain c ON o.id = c.owner WHERE c.depth < 12
|
|
8
|
+
) SELECT o.* FROM chain c JOIN objects o ON o.id = c.id ORDER BY c.depth DESC LIMIT 1`).get(object.id);
|
|
9
|
+
return top ?? object;
|
|
10
|
+
}
|
|
11
|
+
/** A shipped document: one a package reconciler owns (`documents.source_path` is set, as provenance and the shipped marker). Only the reconciler writes it. */
|
|
12
|
+
export async function isShipped(db, object) {
|
|
13
|
+
if (object.type !== 'document')
|
|
14
|
+
return false;
|
|
15
|
+
const row = await db.prepare('SELECT source_path FROM documents WHERE object = ?').get(object.id);
|
|
16
|
+
return row?.source_path != null;
|
|
17
|
+
}
|
|
18
|
+
/** Callers turn `false` into `not_found`. */
|
|
19
|
+
export async function canRead(db, reader, object) {
|
|
20
|
+
return await check(db, reader, 'read', object.id);
|
|
21
|
+
}
|
|
22
|
+
/** A shipped document is changed by nobody, its own app included: only the package reconciler writes it, and it asks no reader. A repo owns only
|
|
23
|
+
* public documents, so a non-public one under a repo is never changed, whoever asks. */
|
|
24
|
+
export async function canChange(db, reader, object) {
|
|
25
|
+
if (await isShipped(db, object))
|
|
26
|
+
return false;
|
|
27
|
+
if (object.privacy !== 'public' && (await spaceOf(db, object)).type === 'repo' && object.owner !== null)
|
|
28
|
+
return false;
|
|
29
|
+
return await check(db, reader, 'edit', object.id);
|
|
30
|
+
}
|
|
31
|
+
/** Whether a non-person reader reaches `object` through `crtr:objects:<verb>:<target>`: the ceiling for that verb, then the schema. A person holds no scope. */
|
|
32
|
+
export async function holdsObjectsScope(db, reader, verb, object) {
|
|
33
|
+
if (reader.class === 'person')
|
|
34
|
+
return false;
|
|
35
|
+
const ev = await resolveReader(db, reader);
|
|
36
|
+
return verb === 'write' ? await check(db, ev, 'edit', object.id) : await check(db, ev, 'read', object.id, verb === 'read' ? {} : { verb });
|
|
37
|
+
}
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import { createHash } from 'node:crypto';
|
|
2
|
+
import { notFound } from '../errors.js';
|
|
3
|
+
/** Content-addressed document text: the `bodies` table, `hash` = sha256 of the text (hex). A revision names its text by `body_hash`.
|
|
4
|
+
* Rows are immutable; only the boot repair removes a proven invalid old-key duplicate left by #822. */
|
|
5
|
+
const HASH = /^[0-9a-f]{64}$/;
|
|
6
|
+
function checked(hash) {
|
|
7
|
+
if (!HASH.test(hash))
|
|
8
|
+
throw new Error(`invalid body hash: ${hash}`);
|
|
9
|
+
return hash;
|
|
10
|
+
}
|
|
11
|
+
export function hashOf(body) {
|
|
12
|
+
return createHash('sha256').update(body, 'utf8').digest('hex');
|
|
13
|
+
}
|
|
14
|
+
/** Postgres `text` cannot hold U+0000, so each NUL is stored as U+FFFD. The one rule for a new write, the Mac boot copy and repo sync. */
|
|
15
|
+
export function storable(text) {
|
|
16
|
+
return text.replaceAll('\u0000', '\uFFFD');
|
|
17
|
+
}
|
|
18
|
+
/** The pair a body is stored and exchanged as: the text `storable` makes of `original` and the hash of that text.
|
|
19
|
+
* A `suppliedHash` is the hash `original` arrived with (a repo ref, a retained file); it is checked against `original`, never used as the key. */
|
|
20
|
+
export function canonical(original, suppliedHash) {
|
|
21
|
+
if (suppliedHash !== undefined && hashOf(original) !== checked(suppliedHash))
|
|
22
|
+
throw new Error(`body does not match its hash ${suppliedHash}`);
|
|
23
|
+
const text = storable(original);
|
|
24
|
+
return { text, hash: hashOf(text) };
|
|
25
|
+
}
|
|
26
|
+
/** Insert `text` under `hash`, or confirm the row already there holds exactly that text: a different text under a key is corruption, not a duplicate.
|
|
27
|
+
* Returns whether a row was added. */
|
|
28
|
+
export async function store(db, hash, text) {
|
|
29
|
+
if ((await db.prepare('INSERT INTO bodies (hash, text) VALUES (?, ?) ON CONFLICT (hash) DO NOTHING').run(checked(hash), text)).changes === 1)
|
|
30
|
+
return true;
|
|
31
|
+
const held = await db.prepare('SELECT text FROM bodies WHERE hash = ?').get(hash);
|
|
32
|
+
if (held === undefined || held.text !== text)
|
|
33
|
+
throw new Error(`body ${hash} already holds different text`);
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
/** Store a body and return its hash, which is the hash of the text as stored (see `canonical`). Call inside the transaction that writes the
|
|
37
|
+
* revision naming it, so a rolled-back write leaves neither.
|
|
38
|
+
* `suppliedHash` is for text that arrives with the hash its source named (repo sync): it must be the hash of `body` as given; the row is keyed by the hash of the stored text. */
|
|
39
|
+
export async function put(db, body, suppliedHash) {
|
|
40
|
+
const { text, hash } = canonical(body, suppliedHash);
|
|
41
|
+
await store(db, hash, text);
|
|
42
|
+
return hash;
|
|
43
|
+
}
|
|
44
|
+
export async function get(db, hash) {
|
|
45
|
+
const row = await db.prepare('SELECT text FROM bodies WHERE hash = ?').get(checked(hash));
|
|
46
|
+
if (row === undefined)
|
|
47
|
+
throw notFound(`no body ${hash}`);
|
|
48
|
+
return row.text;
|
|
49
|
+
}
|
|
50
|
+
/** The bodies that exist among `hashes`, in one query. A hash with no row is absent from the map. */
|
|
51
|
+
export async function findMany(db, hashes) {
|
|
52
|
+
const wanted = [...new Set(hashes)].map(checked);
|
|
53
|
+
const out = new Map();
|
|
54
|
+
if (wanted.length === 0)
|
|
55
|
+
return out;
|
|
56
|
+
const rows = await db.prepare('SELECT hash, text FROM bodies WHERE hash = ANY(?::text[])').all(wanted);
|
|
57
|
+
for (const row of rows)
|
|
58
|
+
out.set(row.hash, row.text);
|
|
59
|
+
return out;
|
|
60
|
+
}
|
|
61
|
+
/** Several bodies in one query. A hash with no row is `no body <hash>`, as for `get`. */
|
|
62
|
+
export async function getMany(db, hashes) {
|
|
63
|
+
const out = await findMany(db, hashes);
|
|
64
|
+
for (const hash of hashes)
|
|
65
|
+
if (!out.has(hash))
|
|
66
|
+
throw notFound(`no body ${hash}`);
|
|
67
|
+
return out;
|
|
68
|
+
}
|
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { createHash, randomBytes, timingSafeEqual } from 'node:crypto';
|
|
2
|
+
import { CrtrError, usage } from '../errors.js';
|
|
3
|
+
import { ExitCode } from '../../types.js';
|
|
4
|
+
import { createObject, liveDocumentNamed } from './objects.js';
|
|
5
|
+
import { invalidateCustomKind } from './kinds/registry.js';
|
|
6
|
+
import { publish, HOP_LIMIT, HopLimitError } from './events.js';
|
|
7
|
+
import { checkoutsForCwd } from './repo-sync/repos.js';
|
|
8
|
+
import { onQueueSignal, signalQueue } from './receivers.js';
|
|
9
|
+
import { receiverEndpoint, isPublicReceiverAddress } from './receiver-url.js';
|
|
10
|
+
import { isIP } from 'node:net';
|
|
11
|
+
import { KIND, LOCAL, MAX_KIND_EVENTS, RESERVED_KIND_ROOTS, eventCatalogReasons } from '../plugin-objects-manifest.js';
|
|
12
|
+
import { check } from '../permissions/evaluator.js';
|
|
13
|
+
import { userOf } from '../permissions/evaluator.js';
|
|
14
|
+
import { nodePlace } from '../permissions/ceiling.js';
|
|
15
|
+
import { PermissionError } from '../permissions/errors.js';
|
|
16
|
+
import { writeActsFor } from '../permissions/facts.js';
|
|
17
|
+
/** Whether this reader may register, publish or watch as an object owned by `owner`. */
|
|
18
|
+
export async function mayActAs(db, reader, owner) {
|
|
19
|
+
// An app (a root shared by every account) carries no `acts_for`, so no user holds `edit` on it; its own server and runs act as it.
|
|
20
|
+
if (reader.class !== 'person' && reader.app.id === owner.id)
|
|
21
|
+
return true;
|
|
22
|
+
return await check(db, reader, 'edit', owner.id);
|
|
23
|
+
}
|
|
24
|
+
/** Whether the reader reaches the custom object: it may read it. */
|
|
25
|
+
export async function customReachable(db, reader, object) {
|
|
26
|
+
return await check(db, reader, 'read', object.id);
|
|
27
|
+
}
|
|
28
|
+
export { onQueueSignal };
|
|
29
|
+
const PRIVACY = ['public', 'private'];
|
|
30
|
+
function conflict(code, message) { throw new CrtrError(code, message, ExitCode.GENERAL); }
|
|
31
|
+
function hash(token) { return createHash('sha256').update(token).digest('hex'); }
|
|
32
|
+
function issueToken() { return `crtr_pub_${randomBytes(32).toString('base64url')}`; }
|
|
33
|
+
function receiverJson(receiver) {
|
|
34
|
+
if (receiver == null)
|
|
35
|
+
return null;
|
|
36
|
+
if (receiver === 'queue')
|
|
37
|
+
return JSON.stringify(receiver);
|
|
38
|
+
if (typeof receiver !== 'object' || Array.isArray(receiver))
|
|
39
|
+
throw usage('invalid custom receiver; expected queue, an https url, or argv and absolute cwd');
|
|
40
|
+
if ('url' in receiver && typeof receiver.url === 'string') {
|
|
41
|
+
try {
|
|
42
|
+
const url = receiverEndpoint(receiver.url);
|
|
43
|
+
const literal = url.hostname.replace(/^\[|\]$/g, '');
|
|
44
|
+
if (isIP(literal) && !isPublicReceiverAddress(literal))
|
|
45
|
+
throw new Error('non-public IP address');
|
|
46
|
+
return JSON.stringify({ url: receiver.url });
|
|
47
|
+
}
|
|
48
|
+
catch (error) {
|
|
49
|
+
throw usage(`invalid custom receiver: ${String(error)}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
if ('argv' in receiver && Array.isArray(receiver.argv) && receiver.argv.length > 0 &&
|
|
53
|
+
receiver.argv.every((arg) => typeof arg === 'string') && typeof receiver.cwd === 'string' && receiver.cwd.startsWith('/'))
|
|
54
|
+
return JSON.stringify(receiver);
|
|
55
|
+
throw usage('invalid custom receiver; url must be https and argv requires a command and absolute cwd');
|
|
56
|
+
}
|
|
57
|
+
/** Whether the reader is a node of an isolated run, or an app call or stub reader carrying an isolated run place. */
|
|
58
|
+
async function inIsolatedRun(db, reader) {
|
|
59
|
+
if (reader.class === 'node')
|
|
60
|
+
return (await nodePlace(db, reader.node.id))?.isolated === true;
|
|
61
|
+
if (reader.class === 'app' || reader.class === 'object')
|
|
62
|
+
return reader.place?.isolated === true;
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
/** Register a kind and a named instance in the caller's write transaction. */
|
|
66
|
+
export async function registerCustomObject(db, reader, input) {
|
|
67
|
+
const { kind, name, owner, description, events, receiver, rotateToken, privacy } = input;
|
|
68
|
+
if (privacy !== undefined && !PRIVACY.includes(privacy))
|
|
69
|
+
throw usage(`invalid privacy ${JSON.stringify(privacy)}`);
|
|
70
|
+
if (!await mayActAs(db, reader, owner))
|
|
71
|
+
conflict('forbidden', `cannot act as ${owner.id}`);
|
|
72
|
+
if (await inIsolatedRun(db, reader))
|
|
73
|
+
throw new PermissionError(403, 'isolated_run', 'a custom object cannot be registered from an isolated run');
|
|
74
|
+
if (!KIND.test(kind) || RESERVED_KIND_ROOTS.includes(kind.split('.')[0]))
|
|
75
|
+
throw usage(`invalid or reserved kind ${kind}`);
|
|
76
|
+
if (!name.trim() || name !== name.trim() || name.includes('\0'))
|
|
77
|
+
throw usage(`invalid object name ${JSON.stringify(name)}`);
|
|
78
|
+
const json = receiverJson(receiver);
|
|
79
|
+
if (receiver !== 'queue' && receiver !== null && receiver !== undefined && 'argv' in receiver && reader.class !== 'person' && reader.class !== 'node')
|
|
80
|
+
conflict('argv_forbidden', 'argv receiver requires a person or node principal');
|
|
81
|
+
if (events === undefined) {
|
|
82
|
+
const declared = await db.prepare('SELECT source FROM object_kinds WHERE name = ?').get(kind);
|
|
83
|
+
if (declared?.source !== 'manifest' && declared?.source !== 'peer')
|
|
84
|
+
throw usage('events is required unless the kind is declared by an installed plugin');
|
|
85
|
+
}
|
|
86
|
+
else if (Object.keys(events).length > MAX_KIND_EVENTS || Object.entries(events).some(([local, spec]) => !LOCAL.test(local) || !Number.isInteger(spec?.level) || spec.level < 1 || spec.level > 10 ||
|
|
87
|
+
(spec.supersedes !== undefined && typeof spec.supersedes !== 'boolean') ||
|
|
88
|
+
(spec.ends_wait !== undefined && typeof spec.ends_wait !== 'boolean')))
|
|
89
|
+
throw usage('invalid custom event catalog');
|
|
90
|
+
const holder = await liveDocumentNamed(db, owner.id, name);
|
|
91
|
+
if (holder && !await customReachable(db, reader, holder))
|
|
92
|
+
conflict('forbidden', `cannot act as ${owner.id}`);
|
|
93
|
+
if (holder && reader.class !== 'person' && reader.class !== 'node') {
|
|
94
|
+
const prior = (await db.prepare('SELECT receiver_json FROM custom_objects WHERE object = ?').get(holder.id))?.receiver_json;
|
|
95
|
+
if (prior && typeof JSON.parse(prior) === 'object' && 'argv' in JSON.parse(prior))
|
|
96
|
+
conflict('argv_forbidden', 'argv receiver requires a person or node principal');
|
|
97
|
+
}
|
|
98
|
+
if (holder && holder.type !== kind)
|
|
99
|
+
conflict('name_taken', `${owner.name}/${name} is already held by ${holder.id}`);
|
|
100
|
+
const upserted = events === undefined ? null : await upsertKind(db, { name: kind, owner, description, events, read: null, source: 'register' });
|
|
101
|
+
if (!holder) {
|
|
102
|
+
const object = await createObject(db, { type: kind, kind: null, owner: owner.id, privacy: privacy ?? 'public', name, preview: '' });
|
|
103
|
+
if (owner.type === 'app')
|
|
104
|
+
await writeActsFor(db, object.id, await userOf(db, reader));
|
|
105
|
+
const token = issueToken();
|
|
106
|
+
await db.prepare(`INSERT INTO custom_objects (object, description, receiver_json, token_hash)
|
|
107
|
+
VALUES (?, ?, ?, ?)`).run(object.id, description, json, hash(token));
|
|
108
|
+
// A custom object a node registers reads from that node's run (Silas, 2026-09-30).
|
|
109
|
+
if (reader.class === 'node')
|
|
110
|
+
await db.prepare('UPDATE custom_objects SET registered_by = ? WHERE object = ?').run(reader.node.id, object.id);
|
|
111
|
+
if (json !== null)
|
|
112
|
+
await db.prepare('UPDATE objects SET reception = 2 WHERE id = ?').run(object.id);
|
|
113
|
+
await publish(db, { event: 'created', object, actor: reader.class === 'object' ? reader.object : reader.class === 'person' ? reader.person : reader.class === 'app' ? reader.app : reader.node, attrs: {} }, async (cwd, person) => await checkoutsForCwd(db, cwd, person));
|
|
114
|
+
return { object, token, created: true, changed: [] };
|
|
115
|
+
}
|
|
116
|
+
const current = await db.prepare('SELECT description, receiver_json FROM custom_objects WHERE object = ?').get(holder.id);
|
|
117
|
+
if (!current)
|
|
118
|
+
conflict('name_taken', `${owner.name}/${name} is not a custom object`);
|
|
119
|
+
const changed = [];
|
|
120
|
+
if (current.description !== description)
|
|
121
|
+
changed.push('description');
|
|
122
|
+
if (current.receiver_json !== json)
|
|
123
|
+
changed.push('receiver');
|
|
124
|
+
if (upserted?.changed.includes('events'))
|
|
125
|
+
changed.push('events');
|
|
126
|
+
if (upserted?.changed.includes('description') && !changed.includes('description'))
|
|
127
|
+
changed.push('description');
|
|
128
|
+
if (privacy !== undefined && holder.privacy !== privacy)
|
|
129
|
+
changed.push('privacy');
|
|
130
|
+
if (rotateToken)
|
|
131
|
+
changed.push('token');
|
|
132
|
+
if (changed.length === 0)
|
|
133
|
+
return { object: holder, created: false, changed };
|
|
134
|
+
const token = rotateToken ? issueToken() : undefined;
|
|
135
|
+
const object = changed.includes('privacy') ? { ...holder, privacy: privacy } : holder;
|
|
136
|
+
if (object !== holder)
|
|
137
|
+
await db.prepare('UPDATE objects SET privacy = ? WHERE id = ?').run(privacy, holder.id);
|
|
138
|
+
await db.prepare('UPDATE custom_objects SET description = ?, receiver_json = ?, token_hash = COALESCE(?, token_hash) WHERE object = ?')
|
|
139
|
+
.run(description, json, token === undefined ? null : hash(token), holder.id);
|
|
140
|
+
await db.prepare('UPDATE objects SET reception = ? WHERE id = ?').run(json === null ? 0 : 2, holder.id);
|
|
141
|
+
if (current.receiver_json !== json) {
|
|
142
|
+
const nowMs = Date.now();
|
|
143
|
+
if (json === null) {
|
|
144
|
+
const canceled = await db.prepare(`UPDATE deliveries SET canceled_at = ?, updated_at = ?
|
|
145
|
+
WHERE destination_id = ? AND state = 'pending' AND canceled_at IS NULL`).run(nowMs, nowMs, holder.id);
|
|
146
|
+
await db.prepare('UPDATE custom_objects SET dropped = dropped + ? WHERE object = ?').run(canceled.changes, holder.id);
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
await db.prepare(`UPDATE deliveries SET next_attempt_at = ?, updated_at = ?
|
|
150
|
+
WHERE destination_id = ? AND state = 'pending' AND canceled_at IS NULL`)
|
|
151
|
+
.run(json === '"queue"' ? null : nowMs, nowMs, holder.id);
|
|
152
|
+
}
|
|
153
|
+
signalQueue(holder.id);
|
|
154
|
+
}
|
|
155
|
+
if (rotateToken)
|
|
156
|
+
signalQueue(holder.id);
|
|
157
|
+
await publish(db, { event: 'configured', object, actor: reader.class === 'object' ? reader.object : reader.class === 'person' ? reader.person : reader.class === 'app' ? reader.app : reader.node, attrs: { changed: changed.join(',') } }, async (cwd, person) => await checkoutsForCwd(db, cwd, person));
|
|
158
|
+
return { object, ...(token === undefined ? {} : { token }), created: false, changed };
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* The only writer of `object_kinds`. `source` says who is writing: an app's `register` call, an installed plugin's
|
|
162
|
+
* manifest, or a declaration that crossed from another machine (`peer`). Precedence: `manifest` and `register` rows
|
|
163
|
+
* are never overwritten by `peer`; a `manifest` write takes over a row it already owns and replaces a `peer` row;
|
|
164
|
+
* a `register` write leaves a `manifest` row alone (`skipped`) and replaces a `peer` row; another owner's
|
|
165
|
+
* `manifest` or `register` row is `kind_owned`. `read_json` is written only by `manifest`. A catalog is replaced,
|
|
166
|
+
* never merged. Runs in the caller's write transaction.
|
|
167
|
+
*/
|
|
168
|
+
export async function upsertKind(db, input) {
|
|
169
|
+
const { name, owner, description, events, read, source } = input;
|
|
170
|
+
if (!KIND.test(name))
|
|
171
|
+
throw usage(`invalid kind ${name}`);
|
|
172
|
+
if (eventCatalogReasons(events, name).length > 0)
|
|
173
|
+
throw usage('invalid custom event catalog');
|
|
174
|
+
// Concurrent writers of one new kind take turns: the later waits for the earlier commit, then updates instead of failing on the primary key.
|
|
175
|
+
await db.prepare('SELECT pg_advisory_xact_lock(hashtext(?))').get(`kind:${name}`);
|
|
176
|
+
const existing = await db.prepare('SELECT owner, description, events_json, read_json, source, declared FROM object_kinds WHERE name = ?').get(name);
|
|
177
|
+
const catalog = canonicalEvents(events);
|
|
178
|
+
const readJson = source === 'manifest' && read !== null ? JSON.stringify({ command: read.command }) : null;
|
|
179
|
+
const now = new Date().toISOString();
|
|
180
|
+
if (!existing) {
|
|
181
|
+
await db.prepare(`INSERT INTO object_kinds (name, owner, description, events_json, created_at, updated_at, read_json, source, declared)
|
|
182
|
+
VALUES (?, ?, ?, ?, ?, ?, ?, ?, 1)`).run(name, owner.id, description, catalog, now, now, readJson, source);
|
|
183
|
+
invalidateCustomKind(db, name);
|
|
184
|
+
return { outcome: 'inserted', changed: [] };
|
|
185
|
+
}
|
|
186
|
+
const sameOwner = existing.owner === owner.id;
|
|
187
|
+
if (source === 'peer') {
|
|
188
|
+
if (existing.source !== 'peer')
|
|
189
|
+
return { outcome: 'skipped', changed: [] };
|
|
190
|
+
}
|
|
191
|
+
else if (existing.source !== 'peer') {
|
|
192
|
+
if (!sameOwner)
|
|
193
|
+
conflict('kind_owned', `${name} belongs to another owner`);
|
|
194
|
+
if (source === 'register' && existing.source === 'manifest')
|
|
195
|
+
return { outcome: 'skipped', changed: [] };
|
|
196
|
+
}
|
|
197
|
+
const changed = [];
|
|
198
|
+
if (canonicalEvents(JSON.parse(existing.events_json)) !== catalog)
|
|
199
|
+
changed.push('events');
|
|
200
|
+
if (existing.description !== description)
|
|
201
|
+
changed.push('description');
|
|
202
|
+
if ((existing.read_json ?? null) !== readJson)
|
|
203
|
+
changed.push('read');
|
|
204
|
+
if (changed.length === 0 && sameOwner && existing.source === source && existing.declared === 1)
|
|
205
|
+
return { outcome: 'unchanged', changed };
|
|
206
|
+
await db.prepare('UPDATE object_kinds SET owner = ?, description = ?, events_json = ?, read_json = ?, source = ?, declared = 1, updated_at = ? WHERE name = ?')
|
|
207
|
+
.run(owner.id, description, catalog, readJson, source, now, name);
|
|
208
|
+
invalidateCustomKind(db, name);
|
|
209
|
+
return { outcome: 'updated', changed };
|
|
210
|
+
}
|
|
211
|
+
export async function publishCustom(db, object, actor, input) {
|
|
212
|
+
const kind = await db.prepare('SELECT events_json FROM object_kinds WHERE name = ?').get(object.type);
|
|
213
|
+
if (!kind || object.deleted_at !== null)
|
|
214
|
+
throw usage(`${object.id} is not a live custom object`);
|
|
215
|
+
const declared = JSON.parse(kind.events_json);
|
|
216
|
+
if (!LOCAL.test(input.event) || !Object.hasOwn(declared, input.event))
|
|
217
|
+
throw new CrtrError('unknown_event', `${object.type} declares ${Object.keys(declared).join(', ')}, not ${input.event}`, ExitCode.USAGE, { declared: Object.keys(declared), event: input.event });
|
|
218
|
+
if (typeof input.summary !== 'string')
|
|
219
|
+
throw usage('summary must be text');
|
|
220
|
+
const state = input.state === undefined ? null : JSON.stringify(input.state);
|
|
221
|
+
if (input.state !== undefined && state === undefined)
|
|
222
|
+
throw usage('state must be JSON-serializable');
|
|
223
|
+
if (Buffer.byteLength(JSON.stringify({ summary: input.summary, ...(input.state === undefined ? {} : { state: input.state }) })) > 64 * 1024)
|
|
224
|
+
throw new CrtrError('body_too_large', 'custom event summary and state exceed 64 KiB', ExitCode.USAGE);
|
|
225
|
+
if (state !== null && Buffer.byteLength(state) > 64 * 1024)
|
|
226
|
+
throw usage('state exceeds 64 KiB');
|
|
227
|
+
// Validate cause/hop before mutating the object's current value. Only a named cause carries depth.
|
|
228
|
+
const cause = input.cause ?? null;
|
|
229
|
+
const parent = cause === null ? null : await db.prepare(`SELECT depth FROM messages WHERE message_id = ?
|
|
230
|
+
UNION ALL SELECT depth FROM message_causes WHERE message_id = ? LIMIT 1`).get(cause, cause);
|
|
231
|
+
if (cause !== null && parent === undefined)
|
|
232
|
+
throw new CrtrError('unknown_cause', `no message ${cause}`, ExitCode.USAGE);
|
|
233
|
+
if (parent && parent.depth >= HOP_LIMIT)
|
|
234
|
+
throw new HopLimitError(parent.depth + 1);
|
|
235
|
+
const now = new Date().toISOString();
|
|
236
|
+
await db.prepare('UPDATE custom_objects SET summary = ?, state_json = ?, published_at = ? WHERE object = ?').run(input.summary, state, now, object.id);
|
|
237
|
+
await db.prepare('UPDATE objects SET preview = ? WHERE id = ?').run(input.summary.split('\n')[0], object.id);
|
|
238
|
+
return await publish(db, { event: `${object.type}.${input.event}`, object, actor, attrs: {}, messageBody: { summary: input.summary, ...(input.state === undefined ? {} : { state: input.state }) }, ...(input.cause === undefined ? {} : { cause: input.cause }) }, async (cwd, person) => await checkoutsForCwd(db, cwd, person));
|
|
239
|
+
}
|
|
240
|
+
export async function unregisterCustomObject(db, object, actor) {
|
|
241
|
+
if (object.deleted_at !== null)
|
|
242
|
+
return;
|
|
243
|
+
await publish(db, { event: 'deleted', object, actor, attrs: {} }, async (cwd, person) => await checkoutsForCwd(db, cwd, person));
|
|
244
|
+
const now = new Date().toISOString();
|
|
245
|
+
await db.prepare('UPDATE objects SET deleted_at = ?, reception = 0 WHERE id = ?').run(now, object.id);
|
|
246
|
+
await db.prepare("UPDATE deliveries SET canceled_at = ?, updated_at = ? WHERE destination_id = ? AND state = 'pending' AND canceled_at IS NULL")
|
|
247
|
+
.run(Date.now(), Date.now(), object.id);
|
|
248
|
+
signalQueue(object.id);
|
|
249
|
+
}
|
|
250
|
+
function canonicalEvents(events) {
|
|
251
|
+
return JSON.stringify(Object.fromEntries(Object.entries(events).sort(([a], [b]) => a.localeCompare(b))
|
|
252
|
+
.map(([name, spec]) => [name, { level: spec.level, ...(spec.supersedes === undefined ? {} : { supersedes: spec.supersedes }), ...(spec.ends_wait === undefined ? {} : { ends_wait: spec.ends_wait }) }])));
|
|
253
|
+
}
|
|
254
|
+
export async function pendingFor(db, object, afterSeq = 0) {
|
|
255
|
+
return await queueLines(db, object.id, afterSeq, 'pending');
|
|
256
|
+
}
|
|
257
|
+
/** A claimed push delivery has the identical document as a pending queue delivery. */
|
|
258
|
+
export async function pushLineFor(db, deliveryId) {
|
|
259
|
+
const row = await db.prepare('SELECT destination_id FROM deliveries WHERE delivery_id = ?').get(deliveryId);
|
|
260
|
+
if (!row)
|
|
261
|
+
return null;
|
|
262
|
+
return (await queueLines(db, row.destination_id, -1, 'handed_off')).find((line) => line.delivery_id === deliveryId) ?? null;
|
|
263
|
+
}
|
|
264
|
+
async function queueLines(db, destinationId, afterSeq, state) {
|
|
265
|
+
const rows = await db.prepare(`SELECT d.delivery_id, m.message_id, m.seq, m.event, m.level, m.object_id, m.actor_id, m.body_json, m.body_ref, m.depth, m.created_at,
|
|
266
|
+
o.type, o.name, owner.id AS owner_id
|
|
267
|
+
FROM deliveries d JOIN messages m ON m.message_id = d.message_id JOIN objects o ON o.id = m.object_id
|
|
268
|
+
LEFT JOIN objects owner ON owner.id = o.owner
|
|
269
|
+
WHERE d.destination_id = ? AND d.state = ? AND d.canceled_at IS NULL AND m.seq > ? ORDER BY m.seq`).all(destinationId, state, afterSeq);
|
|
270
|
+
return rows.map((row) => {
|
|
271
|
+
const body = row.body_json ? JSON.parse(row.body_json) : {};
|
|
272
|
+
return { delivery_id: row.delivery_id, message_id: row.message_id, seq: row.seq, event: row.event, level: row.level,
|
|
273
|
+
object: { id: row.object_id, type: row.type, name: row.name, owner: row.owner_id }, actor: row.actor_id,
|
|
274
|
+
attrs: body.push?.attrs ?? {}, ...(body.summary === undefined ? {} : { summary: body.summary }),
|
|
275
|
+
...(body.state === undefined ? {} : { state: body.state }), ...(body.push?.pointer === undefined ? {} : { pointer: body.push.pointer }),
|
|
276
|
+
depth: row.depth, created_at: row.created_at };
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
export async function acknowledge(db, object, deliveryIds) {
|
|
280
|
+
const now = Date.now();
|
|
281
|
+
const unknown = [];
|
|
282
|
+
let acknowledged = 0;
|
|
283
|
+
for (const id of deliveryIds) {
|
|
284
|
+
const changed = await db.prepare(`UPDATE deliveries SET state = 'acknowledged', acknowledged_at = ?, updated_at = ?
|
|
285
|
+
WHERE delivery_id = ? AND destination_id = ? AND state = 'pending' AND canceled_at IS NULL`).run(now, now, id, object.id);
|
|
286
|
+
if (Number(changed.changes))
|
|
287
|
+
acknowledged++;
|
|
288
|
+
else
|
|
289
|
+
unknown.push(id);
|
|
290
|
+
}
|
|
291
|
+
return { acknowledged, ...(unknown.length ? { unknown } : {}) };
|
|
292
|
+
}
|
|
293
|
+
export async function verifyPublishToken(db, object, token) {
|
|
294
|
+
const row = await db.prepare('SELECT token_hash FROM custom_objects WHERE object = ?').get(object.id);
|
|
295
|
+
const expected = Buffer.from(row?.token_hash ?? ''.padEnd(64, '0'), 'hex');
|
|
296
|
+
const actual = Buffer.from(hash(token), 'hex');
|
|
297
|
+
return token.startsWith('crtr_pub_') && object.deleted_at === null && expected.length === actual.length && timingSafeEqual(expected, actual) && row?.token_hash != null;
|
|
298
|
+
}
|