@north-light/cli 0.3.668 → 0.3.670
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/broker/bash-job-launch.d.ts +4 -0
- package/dist/core/runtime/broker/bash-job-launch.js +1 -1
- 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/blaxel/runner.js +2 -2
- 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/runtime/runner/types.d.ts +2 -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/messages.js +2 -2
- 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/reconcilers/node-lifecycle/remote-wake.js +2 -1
- 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/dist/pi-extensions/canvas-tool-guide.d.ts +3 -1
- package/dist/pi-extensions/canvas-tool-guide.js +4 -4
- 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 +65 -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/scripts/sandbox-bootstrap.sh +4 -0
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var D=Object.defineProperty;var a=(e,n)=>D(e,"name",{value:n,configurable:!0});import{createHash as $,createHmac as N,createPrivateKey as W,hkdfSync as B,randomBytes as v,randomUUID as M,sign as z,timingSafeEqual as F}from"node:crypto";import{readFileSync as G}from"node:fs";import{JwksCache as K,verifyIdToken as Y}from"@north-light/identity";import{withCanvasWrite as Z}from"../../core/canvas/db.js";import{isCloudRole as Q,runAsPerson as L}from"../../core/canvas/person.js";import{joinByEmail as X}from"../../core/graph/group-invites.js";import{directoryIssuer as q}from"../../core/directory/issuer.js";import{emitEvent as k}from"../../core/events/emit.js";import{ApiError as ee}from"../../api/errors.js";import{boundDaemonControl as ne}from"../control.js";import{loadPersonSettings as te}from"../../core/scoped-state/person-rows.js";import{personHasSnapshot as oe}from"../../core/scoped-state/person-store.js";import{escapeHtml as g}from"./vendor-signin.js";import{cookieValue as I,documentNotFound as ie,documentShell as re,error as _,messagePage as m,resolveDocument as ae,serveDocumentApi as se,setPageHeaders as ce}from"./document-page.js";const S="/auth/callback",de="/join-group",b=12*36e5,j=10*6e4,ue=1e4;let w,O,C;function le(){if(w!==void 0)return w;const e=process.env.CRTR_CANVAS_URL;if(!e)return w=null;const n=new URL(e),t=process.env.CRTR_CANVAS_CLIENT_ID,o=process.env.CRTR_CANVAS_JWK_FILE,r=q();if(!t||!o||r===null)throw new Error("CRTR_CANVAS_URL needs CRTR_CANVAS_CLIENT_ID, CRTR_CANVAS_JWK_FILE and CRTR_DIRECTORY_URL");const i=JSON.parse(G(o,"utf8"));if(i.kty!=="EC"||i.crv!=="P-256"||!i.d)throw new Error("CRTR_CANVAS_JWK_FILE must hold a private P-256 JWK");const s=Buffer.from(B("sha256",i.d,"crtr-canvas","canvas-session-cookies",32));return w={origin:n.origin,host:n.host,secure:n.protocol==="https:",clientId:t,jwk:i,issuer:r,key:s}}a(le,"canvasConfig");function fe(){const e=process.env.CRTR_CANVAS_URL;if(!(!Q()||!e))try{return new URL(e).origin}catch{return}}a(fe,"canvasOrigin");function Ie(e){const n=fe();return n!==void 0&&e.headers.host===new URL(n).host}a(Ie,"isCanvasRequest");const h=a(e=>e.toString("base64url"),"b64");function P(e,n,t,o){const r=h(Buffer.from(JSON.stringify({...t,purpose:n,exp:Date.now()+o})));return`${r}.${h(N("sha256",e.key).update(r).digest())}`}a(P,"seal");function U(e,n,t){if(!t)return null;const[o,r,i]=t.split(".");if(!o||!r||i!==void 0)return null;const s=a(d=>$("sha256").update(d).digest(),"digest");if(!F(s(r),s(h(N("sha256",e.key).update(o).digest()))))return null;try{const d=JSON.parse(Buffer.from(o,"base64url").toString("utf8"));return d.purpose===n&&typeof d.exp=="number"&&d.exp>Date.now()?d:null}catch{return null}}a(U,"open");const R=a((e,n)=>e.secure?`__Host-${n}`:n,"cookieName");function T(e,n,t,o){return`${R(e,n)}=${t}; Path=/; HttpOnly; SameSite=Lax; Max-Age=${Math.floor(o/1e3)}${e.secure?"; Secure":""}`}a(T,"cookie");async function x(e,n){const t=await fetch(e,{...n,signal:AbortSignal.timeout(ue)}),o=await t.json().catch(()=>({}));if(!t.ok)throw new Error(`directory ${new URL(e).pathname} answered ${t.status}: ${String(o.error_description??o.error??"")}`);return o}a(x,"directoryJson");function H(e){return C??=x(`${e.issuer}/.well-known/openid-configuration`).then(n=>{if(typeof n.authorization_endpoint!="string"||typeof n.token_endpoint!="string")throw new Error("directory discovery has no authorization or token endpoint");return n},n=>{throw C=void 0,n}),C}a(H,"discover");function he(e,n){const t=Math.floor(Date.now()/1e3),o=h(Buffer.from(JSON.stringify({alg:"ES256",typ:"JWT",...e.jwk.kid?{kid:e.jwk.kid}:{}}))),r=h(Buffer.from(JSON.stringify({iss:e.clientId,sub:e.clientId,aud:n,iat:t,exp:t+60,jti:M()}))),i=z("sha256",Buffer.from(`${o}.${r}`),{key:W({key:e.jwk,format:"jwk"}),dsaEncoding:"ieee-p1363"});return`${o}.${r}.${h(i)}`}a(he,"clientAssertion");async function J(e,n,t){return await x(n,{method:"POST",headers:{"Content-Type":"application/x-www-form-urlencoded"},body:new URLSearchParams({...t,client_id:e.clientId,client_assertion_type:"urn:ietf:params:oauth:client-assertion-type:jwt-bearer",client_assertion:he(e,n)})})}a(J,"directoryPost");async function V(e,n,t,o=!1){const r=await H(e),i={state:h(v(16)),verifier:h(v(32)),nonce:h(v(32)),next:t,...o?{join:!0}:{}},s=new URL(r.authorization_endpoint);s.search=new URLSearchParams({response_type:"code",client_id:e.clientId,redirect_uri:`${e.origin}${S}`,scope:"openid email",state:i.state,nonce:i.nonce,code_challenge:h($("sha256").update(i.verifier).digest()),code_challenge_method:"S256"}).toString(),n.writeHead(303,{Location:s.href,"Set-Cookie":T(e,`crtr_canvas_login_${i.state}`,P(e,"login",i,j),j),"Cache-Control":"no-store"}),n.end()}a(V,"startSignIn");async function pe(e,n,t,o){const r=o.searchParams.get("state"),i=r!==null&&/^[A-Za-z0-9_-]{22}$/.test(r)?`crtr_canvas_login_${r}`:void 0,s=i===void 0?null:U(e,"login",I(n.headers.cookie,R(e,i))),d=o.searchParams.get("code");if(o.searchParams.get("error")!==null)return m(t,400,"Sign-in did not finish",`Northlight answered <code>${g(o.searchParams.get("error").slice(0,100))}</code>. Open the document link again to retry.`);if(s===null||d===null||r!==s.state)return m(t,400,"Sign-in did not finish","This sign-in started in another browser or expired. Open the document link again.");const l=await H(e),f=await J(e,l.token_endpoint,{grant_type:"authorization_code",code:d,redirect_uri:`${e.origin}${S}`,code_verifier:s.verifier});if(typeof f.refresh_token=="string"&&l.revocation_endpoint!==void 0&&await J(e,l.revocation_endpoint,{token:f.refresh_token,token_type_hint:"refresh_token"}).catch(u=>k({level:"warn",event:"api.canvas.revoke_failed",error:u instanceof Error?u:new Error(String(u))})),typeof f.id_token!="string")throw new Error("the directory token response has no id_token");O??=new K(e.issuer);const c=await Y({token:f.id_token,jwks:O,issuer:e.issuer,audience:e.clientId});if(c.nonce!==s.nonce)return m(t,400,"Sign-in did not finish","The sign-in answer does not match this browser. Open the document link again.");const p=c.email_verified===!0&&typeof c.email=="string"?c.email:null;let y=[],A=!1;if(p!==null)try{y=await L(c.sub,()=>Z(u=>X(u,c.sub,p)))}catch(u){A=!0,k({level:"error",event:"api.canvas.join_failed",error:u instanceof Error?u:new Error(String(u))})}const E=[T(e,"crtr_canvas_session",P(e,"session",{sub:c.sub},b),b),T(e,i,"",0)];if(s.join===!0)return t.setHeader("Set-Cookie",E),A?m(t,500,"Group invite",`The invite for <code>${g(p)}</code> could not be checked. Try the link again in a moment.`):m(t,200,"Group invite",y.length===0?`No invite matched <code>${g(p??"an unverified email")}</code>, the email of the Northlight account you signed in with. Ask the group admin to invite that address, or sign in to Northlight as the invited account and open the link again.`:`You joined ${y.map(u=>`<code>${g(u)}</code>`).join(", ")}.`);t.writeHead(303,{Location:s.next,"Set-Cookie":E,"Cache-Control":"no-store"}),t.end()}a(pe,"finishSignIn");async function be(e,n){try{await me(e,n)}catch(t){k({level:"error",event:"api.canvas.failed",error:t instanceof Error?t:new Error(String(t)),fields:{method:e.method,path:e.url?.split("?")[0]}}),n.headersSent?n.destroy():m(n,500,"Something went wrong","The document could not be opened. Try again in a moment.")}}a(be,"serveCanvas");async function me(e,n){const t=le();if(t===null)throw new Error("CRTR_CANVAS_URL is unset");if(ce(n),ne()?.startupBlock()!=null)return m(n,503,"Starting up","The canvas is starting. Try again in a moment.");const o=new URL(e.url??"/",t.origin);if(e.method==="POST"){if(e.headers.origin!==t.origin)return _(n,403,"forbidden","invalid Origin");if(e.headers["content-type"]!=="application/json")return _(n,415,"unsupported_media_type","Content-Type must be application/json")}if(e.method==="GET"&&o.pathname===S)return await pe(t,e,n,o);if(e.method==="GET"&&o.pathname===de)return await V(t,n,"/",!0);const r=e.method==="GET"&&(o.pathname.startsWith("/r/")||o.pathname.startsWith("/document/")),i=o.pathname.startsWith("/assets/")?null:U(t,"session",I(e.headers.cookie,R(t,"crtr_canvas_session")));if(i===null&&!o.pathname.startsWith("/assets/"))return r?await V(t,n,`${o.pathname}${o.search}`):_(n,401,"unauthorized","your sign-in expired: reload the page to sign in again");const s=i?.sub,d=a(l=>s===void 0?l():L(s,async()=>(oe()||await te(s),await l())),"asPerson");await d(async()=>{if(r){const l=o.pathname.startsWith("/r/")?"/r/":"/document/";let f;try{f=decodeURIComponent(o.pathname.slice(l.length))}catch{return _(n,400,"invalid_request","the address is not valid percent-encoding")}let c;try{c=f===""?null:await ae(f)}catch(p){if(p instanceof ee&&p.code==="ambiguous_name")return m(n,409,"More than one document has this name",g(p.message));throw p}if(c===null||l==="/document/"&&c.id!==f)return ie(n,f);if(l==="/r/"){n.writeHead(303,{Location:`/document/${encodeURIComponent(c.id)}`,"Cache-Control":"no-store"}),n.end();return}return re(n,c.id,c)}if(!await se(e,n,o,d))return e.method==="GET"&&o.pathname==="/"?m(n,404,"Northlight canvas","Open a document from its link in the viewer."):_(n,404,"not_found","route not found")})}a(me,"canvasRequest");export{S as CANVAS_CALLBACK_PATH,de as CANVAS_JOIN_PATH,fe as canvasOrigin,Ie as isCanvasRequest,be as serveCanvas};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
var
|
|
1
|
+
var D=Object.defineProperty;var i=(n,e)=>D(n,"name",{value:e,configurable:!0});import{readFileSync as O}from"node:fs";import{join as x,extname as P}from"node:path";import{fileURLToPath as R}from"node:url";import{withCanvasWrite as p}from"../../core/canvas/db.js";import{ApiError as A}from"../../api/errors.js";import{get as v}from"../../core/graph/bodies.js";import{canChange as E,isShipped as B}from"../../core/graph/access.js";import{documentRecord as T,editDocument as F,heads as $,withCurrentNames as _}from"../../core/graph/documents.js";import{getById as g}from"../../core/graph/objects.js";import{subscribeDocumentEvents as I}from"../../core/graph/events.js";import{emitEvent as J}from"../../core/events/emit.js";import{checkoutsForCwd as L}from"../../core/graph/repo-sync/repos.js";import{canonicalName as U}from"./handlers/docs.js";import{escapeHtml as y}from"./vendor-signin.js";import{readerFor as b,resolveRef as W,warmDocumentWatchers as G}from"./reader.js";import{mergeDocumentLines as z}from"./document-merge.js";import{crtrVersion as M}from"../../shared/crtr-version.js";const V="default-src 'self'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src 'self' data:; connect-src 'self'; object-src 'none'; base-uri 'none'; frame-ancestors 'none'",C={class:"person"},w=encodeURIComponent(M()),S=R(new URL("../../../dist/",import.meta.url));function pe(n){n.setHeader("Content-Security-Policy",V),n.setHeader("X-Content-Type-Options","nosniff")}i(pe,"setPageHeaders");function u(n,e,t,r){n.writeHead(e,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),n.end(JSON.stringify({error:{code:t,message:r}}))}i(u,"error");function we(n,e){for(const t of(n??"").split(";")){const r=t.indexOf("=");if(r!==-1&&t.slice(0,r).trim()===e)return t.slice(r+1).trim()}}i(we,"cookieValue");function H(n,e,t){n.writeHead(e,{"Content-Type":"application/json; charset=utf-8","Cache-Control":"no-store"}),n.end(JSON.stringify(t))}i(H,"json");function X(n,e,t,r){n.writeHead(e,{"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-store"}),n.end(`<!doctype html><html><head><meta charset="utf-8"><title>${y(t)}</title><link rel="icon" href="data:,"></head><body style="font-family:system-ui,sans-serif;max-width:40rem;margin:4rem auto;padding:0 1rem"><h1>${y(t)}</h1><p>${r}</p></body></html>`)}i(X,"messagePage");function ve(n,e){X(n,404,"Document not found",`No document you can read is named <code>${y(e)}</code>.`)}i(ve,"documentNotFound");function _e(n,e,t){n.writeHead(200,{"Content-Type":"text/html; charset=utf-8","Cache-Control":"no-store"}),n.end(`<!doctype html><html><head><meta charset="utf-8"><title>${y(t.name)}</title><link rel="icon" href="data:,"><link rel="stylesheet" href="/assets/${w}/editor.css"></head><body><div id="app" data-ref="${y(e)}"></div><script type="module" src="/assets/${w}/editor.js"><\/script></body></html>`)}i(_e,"documentShell");async function N(n){return await p(async e=>{const t=await g(e,n.id);if(!t||t.deleted_at||t.type!=="document")return null;const r=await b(e,{principal:C}),a=await T(e,t),o=await $(e,t),s=await U(e,t),c=o.length===1&&await E(e,r,t);return{id:t.id,name:s,revision:a.revision,heads_key:a.heads_key,body:o.length===1?await _(e,t,await v(e,o[0].body_hash)):"",editable:c,...c?{}:{readonly_reason:o.length!==1?`has ${o.length} heads and needs a merge`:await B(e,t)?"shipped by a plugin":"you cannot change this document"}}})}i(N,"snapshot");async function k(n){return await p(async e=>{const t=await b(e,{principal:C});try{const r=await W(e,t,n);return"deleted"in r||"remote"in r||r.type!=="document"?null:r}catch(r){if(r instanceof A&&r.code==="not_found")return null;throw r}})}i(k,"resolveDocument");async function Z(n){return await p(async e=>{const t=await g(e,n);return!t||t.type!=="document"||t.deleted_at!==null})}i(Z,"isDeleted");async function q(n){const e=[];let t=0;for await(const r of n){if(t+=r.length,t>2e6)throw new Error("request body exceeds 2 MB");e.push(r)}return JSON.parse(Buffer.concat(e).toString("utf8"))}i(q,"requestBody");async function K(n){return await G(n.id),await p(async t=>{const r=await b(t,{principal:C}),a=await g(t,n.id);if(!a||a.type!=="document"||a.deleted_at)return{status:404,value:{error:{code:"not_found",message:"document not found"}}};const o=await T(t,a),s=await $(t,a);if(s.length!==1||!await E(t,r,a))return{status:403,value:{error:{code:"forbidden",message:"document is read-only"}}};const c=await _(t,a,await v(t,s[0].body_hash)),f=await t.prepareUncached("SELECT body_hash FROM revisions WHERE document = ? AND rev_id = ?").get(a.id,n.base_heads_key);if(!f||await _(t,a,await v(t,f.body_hash))!==n.base_body)return{status:409,value:{saved:!1,conflict:{revision:o.revision,heads_key:o.heads_key,current_body:c,your_body:n.body}}};const h=n.base_heads_key!==o.heads_key,l=h?z(n.base_body,n.body,c):n.body;if(l===null)return{status:409,value:{saved:!1,conflict:{revision:o.revision,heads_key:o.heads_key,current_body:c,your_body:n.body}}};const d=await F(t,r,a,{body:l},n.rationale?.trim()||"edited by the person in the browser",o.heads_key,{},async(m,j)=>await L(t,m,j));return"stale"in d?{status:409,value:{saved:!1,conflict:{revision:d.stale.revision,heads_key:d.stale.heads_key,current_body:c,your_body:n.body}}}:{status:200,value:{saved:!0,revision:d.revision,heads_key:d.heads_key,body:l,merged:h}}})}i(K,"save");async function ge(n,e,t,r){if(n.method==="GET"&&t.pathname==="/api/doc"){const a=t.searchParams.get("ref"),o=a?await k(a):null,s=o&&await N(o);return s?H(e,200,{...s,ref:a}):u(e,404,"not_found","document not found"),!0}if(n.method==="POST"&&t.pathname==="/api/save"){const a=await q(n);if(!a||typeof a!="object"||Array.isArray(a))return u(e,400,"invalid_request","invalid save body"),!0;const o=a;if(typeof o.id!="string"||typeof o.base_heads_key!="string"||typeof o.base_body!="string"||typeof o.body!="string"||o.rationale!==void 0&&typeof o.rationale!="string")return u(e,400,"invalid_request","invalid save body"),!0;const s=await K(o);return H(e,s.status,s.value),!0}if(n.method==="GET"&&t.pathname==="/api/events"){const a=t.searchParams.get("id");if(!a||!await k(a))return u(e,404,"not_found","document not found"),!0;e.writeHead(200,{"Content-Type":"text/event-stream","Cache-Control":"no-store",Connection:"keep-alive","X-Accel-Buffering":"no"}),e.write(`: connected
|
|
2
2
|
|
|
3
|
-
`);const
|
|
3
|
+
`);const o=i(async()=>{const d=await k(a),m=d&&await N(d);if(!e.writableEnded){if(m){e.write(`event: edited
|
|
4
4
|
data: ${JSON.stringify({revision:m.revision,heads_key:m.heads_key})}
|
|
5
5
|
|
|
6
|
-
`);return}await
|
|
6
|
+
`);return}await Z(a)&&e.write(`event: deleted
|
|
7
7
|
data: {}
|
|
8
8
|
|
|
9
|
-
`),e.end()}},"notify");let
|
|
9
|
+
`),e.end()}},"notify");let s=!1,c=!1;const f=i(()=>{if(s){c=!0;return}s=!0,r(o).catch(d=>{J({level:"error",event:"daemon.document_events.notify_failed",error:d}),e.end()}).finally(()=>{s=!1,c&&!e.writableEnded&&(c=!1,f())})},"wake"),h=await I(a,f),l=setInterval(()=>{e.writableEnded||e.write(`: keepalive
|
|
10
10
|
|
|
11
|
-
`)},3e4);return e.on("close",()=>{clearInterval(l),
|
|
11
|
+
`)},3e4);return e.on("close",()=>{clearInterval(l),h()}),!0}if(n.method==="GET"&&t.pathname.startsWith(`/assets/${w}/`)){const a=t.pathname.slice(`/assets/${w}/`.length);if(!/^[a-zA-Z0-9_.-]+$/.test(a))return u(e,404,"not_found","asset not found"),!0;const o=a==="mermaid.js"?x(S,"clients/attach/assets/mermaid.min.js"):x(S,"doc-editor",a);try{const s=O(o);e.writeHead(200,{"Content-Type":P(a)===".css"?"text/css; charset=utf-8":"text/javascript; charset=utf-8","Cache-Control":"public, max-age=31536000, immutable"}),e.end(s)}catch(s){if(s.code==="ENOENT")u(e,404,"not_found","asset not found");else throw s}return!0}return!1}i(ge,"serveDocumentApi");export{we as cookieValue,ve as documentNotFound,_e as documentShell,u as error,X as messagePage,k as resolveDocument,ge as serveDocumentApi,pe as setPageHeaders};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var Y=Object.defineProperty;var a=(t,e)=>Y(t,"name",{value:e,configurable:!0});import{canonicalSessionFile as K,findNodeBySessionFile as z,getNode as v,getNodes as Q,isWarmSpare as X,recordLaunch as Z,recordRespawnAttempt as I,recordSettledTurn as q,setPresence as x,subscriptionsOf as ee,updateNode as _,updateNodeTelemetry as te}from"../../../core/canvas/canvas.js";import{liveExecutionForNode as S,recordExecutionIdle as ne,recordExecutionPid as ie}from"../../../core/canvas/executions.js";import{bindSession as re,readLiveSession as oe,transferSession as ae}from"../../../core/canvas/sessions.js";import{isSafeNodeId as se}from"../../../core/canvas/paths.js";import{isPidAlive as ce}from"../../../core/canvas/pid.js";import{editorLabel as P}from"../../../core/canvas/labels.js";import{assembleNodeSubject as de}from"../../../core/substrate/subject.js";import{openDb as B,withCanvasWrite as m}from"../../../core/canvas/db.js";import{runningJobs as le}from"../../../core/graph/jobs.js";import{notFound as R,usage as l}from"../../../core/errors.js";import{hasUnseenWakeMail as F,releaseExecutionMail as ue}from"../../../core/canvas/deliveries.js";import{clearYieldMessage as pe}from"../../../core/runtime/kickoff.js";import{readRoadmap as fe}from"../../../core/runtime/roadmap.js";import{forkSourceNode as me}from"../../../core/runtime/nodes.js";import{transition as k}from"../../../core/runtime/lifecycle.js";import{confirmViewer as N,probeViewer as T,tearDownNode as C}from"../../../core/runtime/placement.js";import{hasAttachedBrokerViewers as we}from"../viewer-presence.js";import{evaluateStop as ye}from"../../../core/runtime/stop-guard.js";import{readOutputRequest as L}from"../../../core/runtime/output-result.js";import{clearFault as b,readFault as he,recordFault as be}from"../../../core/canvas/recovery.js";import{updateModelRecipe as _e}from"../../../core/runtime/model-swap.js";import{completeCompanionRequestedSubmit as ke}from"../../review/finish.js";import{emitEvent as D}from"../../../core/events/emit.js";import{consumePendingPark as ge,recordPendingParkActivity as ve}from"../../park-pending.js";import{shouldParkAfterSummary as xe}from"../../park-activity.js";import{ownerOnly as Se}from"../router.js";import{situationalContextEnvelope as Pe}from"../../../core/runtime/situational-context.js";import{recoveryState as Re,requireCurrentExecution as p}from"./broker-recovery.js";import{runAttachments as Oe}from"./node-records.js";import{readerForNode as Ee,warmNodeRepos as Ae}from"../../../core/graph/reader.js";import{noteNodeBooting as Be}from"../../../core/graph/repo-sync/index.js";import{checkoutsForCwd as Fe}from"../../../core/graph/repo-sync/repos.js";import{deliver as O}from"../../../core/substrate/delivery/deliver.js";import{ensureRunObserver as Ne}from"../../runs/observer.js";import{parseNodeTelemetryRecord as Te,writeNodeTelemetryRecord as Ce}from"./telemetry-record.js";import{mapAsync as Le}from"../../../core/async-array.js";import{crtrVersion as M}from"../../../shared/crtr-version.js";import{buildPiArgv as De}from"../../../core/runtime/launch.js";import{brokerLaunchJson as Me}from"../../../core/runtime/host.js";import{CYCLE_APPLIED_ENV as Ve,cycleCompatible as $e}from"../../../core/runtime/launch-recipe.js";import{buildReviveKickoff as je,drainBearings as Ue}from"../../../core/runtime/kickoff.js";import{clearNodeLedger as We}from"../../../core/runtime/ledger.js";import{runNodeStartHooks as He}from"../../../core/runtime/revive.js";import{consumeDeadlineOnWake as Je}from"../../../core/feed/messages.js";import{encodeKickoffOrigin as Ge}from"../../../core/runtime/stamp/protocol.js";import{ApiError as Ye}from"../../../api/errors.js";function f(t,e){if(typeof t!="object"||t===null||Array.isArray(t))throw l(`${e} requires a JSON body`);return t}a(f,"objectBody");function V(t){const e=f(t,"broker session-bound");if(typeof e.executionId!="string"||e.executionId==="")throw l("executionId must be a non-empty string");if(typeof e.piSessionId!="string"||e.piSessionId==="")throw l("piSessionId must be a non-empty string");if(e.sessionFile!==null&&typeof e.sessionFile!="string")throw l("sessionFile must be a string or null");if(!Number.isSafeInteger(e.pid)||e.pid<=0)throw l("pid must be a positive safe integer");if(e.reason!==null&&typeof e.reason!="string")throw l("reason must be a string or null");if(!Array.isArray(e.reviewBoundaryIds)||!e.reviewBoundaryIds.every(n=>typeof n=="string"))throw l("reviewBoundaryIds must be an array of strings");return e}a(V,"parseSessionBoundBody");function Ke(t){const e=f(t,"broker settle");if(typeof e.stopReason!="string")throw l("stopReason must be a string");for(const n of["pushedFinal"])if(typeof e[n]!="boolean")throw l(`${n} must be a boolean`);return e}a(Ke,"parseSettleBody");function ze(t){const e=f(t,"broker cycle");if(typeof e.brokerVersion!="string"||e.brokerVersion==="")throw l("brokerVersion must be a non-empty string");return e}a(ze,"parseCycleBody");function Qe(t){const e=f(t,"broker park-complete");if(e.outcome!=="completed"&&e.outcome!=="failed")throw l("outcome must be completed or failed");return e}a(Qe,"parseParkCompleteBody");function Xe(t){const e=f(t,"broker telemetry");if(typeof e.expected_execution_id!="string"||e.expected_execution_id==="")throw l("expected_execution_id must be a non-empty string");const n=Te(e);return{...n,expected_execution_id:e.expected_execution_id,updated_at:new Date(n.updated_at).toISOString()}}a(Xe,"parseTelemetryBody");function Ze(t){const e=f(t,"broker model");if(typeof e.spec!="string"||e.spec.trim()==="")throw l("spec must be a non-empty string");const n=e.intent;if(n!==void 0){const r=n!==null&&typeof n=="object"?n:void 0;if(r===void 0||typeof r.family!="string"||r.family===""||!["ultra","strong","medium","light"].includes(r.strength))throw l("intent must be { family, strength } with strength ultra|strong|medium|light when present")}if(typeof e.userSelected!="boolean")throw l("userSelected must be a boolean");return e}a(Ze,"parseModelCommitBody");async function w(t){const e=await v(t);if(e===null)throw R(`unknown node: ${t}`,{received:t});return e}a(w,"requireNode");async function g(t){return{node_id:t.node_id,grantee:t.grantee,name:t.name,...t.description===void 0?{}:{description:t.description},...t.title===void 0?{}:{title:t.title},...t.icon===void 0?{}:{icon:t.icon},kind:t.kind,mode:t.mode,lifecycle:t.lifecycle,status:t.status,cwd:t.cwd,parent:t.parent??null,fork_from:t.fork_from??null,profile_id:t.profile_id??null,...t.managed_worktree===void 0?{}:{managed_worktree:t.managed_worktree===null?null:{state:t.managed_worktree.state,...t.managed_worktree.cleanup===void 0?{}:{cleanup:t.managed_worktree.cleanup},path:t.managed_worktree.path,branch:t.managed_worktree.branch,base_ref:t.managed_worktree.base_ref,base_sha:t.managed_worktree.base_sha}},...t.review_binding===void 0?{}:{review_binding:t.review_binding??null},intent:t.intent??null,...t.persona_ack===void 0?{}:{persona_ack:t.persona_ack},created:t.created}}a(g,"extensionNode");async function $(t){const e=await w(t),n=[],r=new Set([t]);let i=e.parent??null;for(;i!==null&&i!==""&&!r.has(i);){r.add(i);const d=await v(i);if(d===null)break;n.unshift(await g(d)),i=d.parent??null}const s=await Le((await Q((await ee(t)).map(d=>d.node_id))).filter(d=>d.kind!=="human").sort((d,h)=>d.status===h.status?0:d.status==="active"?-1:h.status==="active"?1:0),g),o=typeof e.fork_source_file=="string"?await me(e.fork_source_file):null,c=await de(t);if(c===null)throw R(`unknown node: ${t}`,{received:t});return{node:await g(e),warm_spare:await X(t),situational_card:await Pe(t),ancestors:n,children:s,fork_source:o===null?null:await g(o),subject:c,roadmap:await fe(t)}}a($,"extensionState");function E(t,e){return t?.kind===e.kind&&t?.mode===e.mode&&t?.lifecycle===e.lifecycle}a(E,"samePersona");function Ie(t){const e=f(t,"broker generated-name");if(e.kind!=="initial"&&e.kind!=="recap")throw l("kind must be initial or recap");if(typeof e.description!="string"||typeof e.title!="string"||typeof e.icon!="string")throw l("description, title, and icon must be strings");if(e.kind==="initial")return e;const n=e.expected;if(typeof n!="object"||n===null||Array.isArray(n)||["name","description","title","icon","kind"].some(r=>typeof n[r]!="string"))throw l("recap expected must contain name, description, title, icon, and kind strings");return e}a(Ie,"parseGeneratedNameBody");function qe(t){const e=f(t,"broker persona-ack"),n=a(r=>{const i=e[r];if(typeof i!="object"||i===null||Array.isArray(i)||typeof i.kind!="string"||i.mode!=="base"&&i.mode!=="orchestrator"||i.lifecycle!=="terminal"&&i.lifecycle!=="resident")throw l(`${r} must be a persona state`);return i},"parse");return{expected_execution_id:e.expected_execution_id,from:n("from"),to:n("to")}}a(qe,"parsePersonaAckBody");async function j(t,e){const n=e.sessionFile===null?null:K(e.sessionFile);return await m(async r=>{await r.prepareUncached("SELECT 1 FROM nodes WHERE node_id = ? FOR UPDATE").get(t);const i=await w(t);if(await ie(e.executionId,t,e.pid)==="shutdown")return{action:"shutdown"};const s=i.review_binding?.review_id;if(s!==void 0&&!e.reviewBoundaryIds.includes(s))return{action:"shutdown"};if(e.reason==="new"&&i.parent==null)return{action:"relaunch_root"};if(e.reason!=="new"&&i.fork_from!=null&&i.pi_session_id==null&&n===null)return{action:"shutdown"};const o=n===null?null:await z(n);if(o!==null&&o.node_id!==t){if(ce(o.pi_pid))return await be(t,{link:"daemon\u2192node",op:"session-file-ownership",kind:"protocol",retry:{disposition:"fatal"},message:`refusing to bind ${n}: it is owned by live node ${o.node_id}`}),{action:"shutdown"};const c=await oe(o.node_id);if(c===null||await ae({fromNodeId:o.node_id,fromBindingId:c.bindingId,toNodeId:t,executionId:e.executionId,sessionId:e.piSessionId,transcriptPath:n})!=="transferred")return{action:"shutdown"}}else if(await re(t,{executionId:e.executionId,sessionId:e.piSessionId,transcriptPath:n})==="shutdown")return{action:"shutdown"};return e.reason!=="new"&&(await pe(t),i.intent==="refresh"&&await k(t,"revive")),{action:"none"}})}a(j,"commitSessionBound");async function et(t){return{status:200,body:await j(t.params.id,V(t.body))}}a(et,"handleSessionBound");function tt(t){const e=V(t);if(e.bearings!=="fresh"&&e.bearings!=="inherited"&&e.bearings!=="present")throw l("bearings must be fresh, inherited or present");return e}a(tt,"parseCycleStartBody");async function nt(t,e,n,r){const i=e.warm_spare||r,s=!i&&n!=="present";return s&&await Be(t),await Ae(await B(),t),await m(async o=>{const c=await Ee(o,t,async y=>await Fe(o,y)),d=await O(o,c,{activity:"names"}),h=s?await O(o,c,{activity:"boot",...n==="inherited"?{inherited:!0}:{}}):void 0,u=i?void 0:await O(o,c,{activity:"system-prompt"});return{names:{refs:d.refs,names:d.names},...h===void 0?{}:{boot:{content:h.content,...h.inherited===!0?{inherited:!0}:{}}},...u===void 0?{}:{system_prompt:u.content}}})}a(nt,"startupDelivery");async function it(t){const e=t.params.id,n=tt(t.body),r=await w(e),i=r.review_binding?.review_id,s=i!==void 0&&!n.reviewBoundaryIds.includes(i),o=s||r.cycle_pending===!0||r.intent==="refresh"||r.pi_session_id==null;if(o)await p(e,n.executionId);else{const{action:u}=await j(e,n);if(u!=="none")return{status:200,body:{action:u}}}const c=await $(e),d=await nt(e,c,n.bearings,s);if(d.boot!==void 0){const u={kind:c.node.kind,mode:c.node.mode,lifecycle:c.node.lifecycle},y=c.node.persona_ack,A=y===void 0?u:{kind:y.kind??c.node.kind,mode:y.mode,lifecycle:y.lifecycle};E(A,u)||await G(e,A,u)}return{status:200,body:{action:"none",...o?{bind_pending:!0}:{},state:c,...d,recovery:await Re(e),attachments:(await Oe(e)).map(({path:u,sha256:y})=>({path:u,sha256:y})),structured_request:await L(e)}}}a(it,"handleCycleStart");async function U(t,e){return e.live!==null||await we(t)||await F(t)}a(U,"isHeldAwake");async function W(t,e){return(await S(t))?.runner==="blaxel"&&!await U(t,e)&&(await le(await B(),t)).length===0}a(W,"residentBlaxelCanIdle");function H(t){return t.inPlaceCycle===!0?{action:"new_cycle"}:{action:"shutdown"}}a(H,"refreshDirective");async function rt(t,e,n){const r=await v(t);if(r===null){if(e.pushedFinal)return{directive:{action:"shutdown"},closePane:!1};throw R(`unknown node: ${t}`,{received:t})}if(await q(t,new Date().toISOString()),(e.stopReason==="stop"||e.stopReason==="length")&&await I(t,{failures:0,notBefore:null}),e.stopReason==="quit"){let c=!1;return(r.status==="active"||r.status==="idle")&&r.intent===null&&(await k(t,"finish"),await b(t),await x(t,{pane:null,tmux_session:null,window:null}),c=!0),{directive:{action:"shutdown"},closePane:c}}if(e.stopReason!=="stop"&&e.stopReason!=="length")return await b(t,{link:"daemon\u2192node"}),r.intent==="refresh"?{directive:H(e),closePane:!1}:e.stopReason==="error"&&e.faultSettled===!0&&(await he(t))?.retry.disposition==="fatal"&&await L(t)===null&&await W(t,n)?{directive:{action:"stay_resident"},closePane:!1}:{directive:{action:"stay_dormant"},closePane:!1};const i={pushedFinal:e.pushedFinal};if(i.pushedFinal||r.status==="done")return await b(t),await x(t,{pane:null,tmux_session:null,window:null}),{directive:{action:"shutdown"},closePane:!0};if(r.intent==="refresh")return await b(t),{directive:H(e),closePane:!1};const s=await ye(t,i);if(await b(t),s.action==="reprompt")return{directive:{action:"reprompt",prompt:s.message},closePane:!1};if(s.reason==="finished")return{directive:await F(t)?{action:"stay_dormant"}:{action:"shutdown"},closePane:!1};const o=await U(t,n);return(await S(t))?.runner==="blaxel"?{directive:await W(t,n)?{action:"stay_resident"}:{action:"stay_dormant"},closePane:!1}:s.reason!=="awaiting"&&s.reason!=="scheduled"?{directive:{action:"stay_dormant"},closePane:!1}:o?{directive:{action:"stay_dormant"},closePane:!1}:(await k(t,"release"),{directive:{action:"shutdown"},closePane:!1})}a(rt,"settleBroker");async function ot(t){const e=t.params.id,n=ze(t.body);await p(e,n.expected_execution_id);const r=await w(e);if(r.intent!=="refresh")throw new Ye(409,"not_yielding",`${e} has no pending yield`);const i=await S(e),s=De(r);return n.brokerVersion===M()&&(i.release===null||i.release===M())&&$e(i.launchJson,await Me(e,s,r.cwd))?{status:200,body:await at(e,r,i.executionId,s.env)}:{status:200,body:{action:"restart"}}}a(ot,"handleCycle");async function at(t,e,n,r){e.cycles=(e.cycles??0)+1,await ue(t,n);const i=await Ue(e,n),s=await je(e,i);await We(t),await He(t,e,!1),await Je(t),await b(t,{preserveEpisode:!0}),await Z(t,new Date().toISOString()),await _(t,{cycles:e.cycles,cycle_pending:!0});const o={};for(const c of Ve)r[c]!==void 0&&(o[c]=r[c]);return o.CRTR_CYCLES=String(e.cycles),{action:"cycle",cycle:e.cycles,prompt:s,origin:Ge({type:"runtime",kind:"revive",cycle:e.cycles}),messageIds:e.run_id?i.unreadMessageIds??[]:[],env:o,...e.launch?.model!==void 0?{model:e.launch.model}:{},modelExact:e.launch?.modelExact===!0,editorLabel:P(e)}}a(at,"startCycleRecord");async function st(t){const e=t.params.id,n=f(t.body,"broker idle");return await p(e,n.expected_execution_id),await ne(n.expected_execution_id),{status:204}}a(st,"handleIdle");async function ct(t){const e=t.params.id,n=Ke(t.body);await p(e,n.expected_execution_id);const r=await T(e),{directive:i,closePane:s}=await m(async()=>await rt(e,n,await N(r)));return s&&await C(e),i.action!=="reprompt"&&ke(e).catch(o=>D({level:"error",event:"api.broker_ops.companion_submit_failed",node_id:e,error:o})),{status:200,body:i}}a(ct,"handleSettle");async function dt(t){const e=t.params.id,n=Qe(t.body);await p(e,n.expected_execution_id);const r=await T(e),i=await m(async()=>{const s=await ge(e);if(s===void 0)return{action:"stay_dormant"};const o=await w(e);return await xe(e,o,s,await N(r))?(await b(e),await k(e,"park"),await x(e,{pane:null,tmux_session:null,window:null}),D({level:n.outcome==="completed"?"info":"warn",event:"broker.park.complete",...se(e)?{node_id:e}:{},outcome:n.outcome==="completed"?"succeeded":"failed"}),{action:"shutdown"}):{action:"stay_dormant"}});return i.action==="shutdown"&&await C(e),{status:200,body:i}}a(dt,"handleParkComplete");async function lt(t){const e=t.params.id;return await p(e,f(t.body,"broker park-activity").expected_execution_id),{status:200,body:await m(async()=>({activity:await ve(e)?"recorded":"none"}))}}a(lt,"handleParkActivity");async function ut(t){const e=t.params.id,n=Xe(t.body);return await p(e,n.expected_execution_id),await m(async()=>{await te(e,{tokensIn:n.tokens_in,contextTokens:n.context_tokens,lastActivity:n.last_activity,updatedAt:n.updated_at}),Ce(e,n)}),{status:204}}a(ut,"handleTelemetry");async function pt(t){const e=t.params.id,n=Ze(t.body);return await p(e,n.expected_execution_id),{status:200,body:{modelOverride:(await m(async()=>await _e(await w(e),n.spec,n.intent,n.userSelected))).model_override}}}a(pt,"handleModelCommit");let J=!0;function ln(t){J=t}a(ln,"setRequestsStartRunObservers");async function ft(t){const e=t.params.id,n=await w(e);return n.run_id&&J&&await Ne(e,n.run_id),{status:200,body:await $(e)}}a(ft,"handleExtensionState");async function mt(t){const e=t.params.id,n=Ie(t.body);return await p(e,n.expected_execution_id),{status:200,body:await m(async i=>{await i.prepareUncached("SELECT 1 FROM nodes WHERE node_id = ? FOR UPDATE").get(e);const s=await w(e);if(n.kind==="initial"){if((s.description??"").trim()!=="")return{applied:!1};const d=await _(e,{description:n.description,...n.title.trim()===""?{}:{title:n.title},...n.icon.trim()===""?{}:{icon:n.icon}});return{applied:!0,editorLabel:P(d),description:d.description??"",title:d.title??"",icon:d.icon??""}}const o=n.expected;if(s.name!==o.name||(s.description??"")!==o.description||(s.title??"")!==o.title||(s.icon??"")!==o.icon||s.kind!==o.kind)return{applied:!1};const c=await _(e,{description:n.description,title:n.title.trim()===""?void 0:n.title,icon:n.icon.trim()===""?void 0:n.icon});return{applied:!0,editorLabel:P(c),description:c.description??"",title:c.title??"",icon:c.icon??""}})}}a(mt,"handleGeneratedName");async function wt(t){const e=t.params.id,n=qe(t.body);return await p(e,n.expected_execution_id),{status:200,body:{applied:await G(e,n.from,n.to)}}}a(wt,"handlePersonaAck");async function G(t,e,n){return await m(async r=>{await r.prepareUncached("SELECT 1 FROM nodes WHERE node_id = ? FOR UPDATE").get(t);const i=await w(t),s={kind:i.kind,mode:i.mode,lifecycle:i.lifecycle},o=i.persona_ack,c=o===void 0?s:{kind:o.kind??i.kind,mode:o.mode,lifecycle:o.lifecycle};return!E(s,n)||!E(c,e)?!1:(await _(t,{persona_ack:n}),!0)})}a(G,"applyPersonaAck");const un=Se([{method:"POST",pattern:"/v1/nodes/:id/broker/session-bound",handler:et},{method:"POST",pattern:"/v1/nodes/:id/broker/cycle-start",handler:it},{method:"POST",pattern:"/v1/nodes/:id/broker/settle",handler:ct},{method:"POST",pattern:"/v1/nodes/:id/broker/cycle",handler:ot},{method:"POST",pattern:"/v1/nodes/:id/broker/idle",handler:st},{method:"POST",pattern:"/v1/nodes/:id/broker/park-complete",handler:dt},{method:"POST",pattern:"/v1/nodes/:id/broker/park-activity",handler:lt},{method:"POST",pattern:"/v1/nodes/:id/broker/telemetry",handler:ut},{method:"POST",pattern:"/v1/nodes/:id/broker/model",handler:pt},{method:"GET",pattern:"/v1/nodes/:id/broker/extension-state",handler:ft},{method:"POST",pattern:"/v1/nodes/:id/broker/generated-name",handler:mt},{method:"POST",pattern:"/v1/nodes/:id/broker/persona-ack",handler:wt}]);export{un as brokerOperationRoutes,g as extensionNode,ln as setRequestsStartRunObservers};
|
|
1
|
+
var Y=Object.defineProperty;var a=(t,e)=>Y(t,"name",{value:e,configurable:!0});import{canonicalSessionFile as K,findNodeBySessionFile as z,getNode as x,getNodes as I,isWarmSpare as Q,recordLaunch as X,recordRespawnAttempt as Z,recordSettledTurn as q,setPresence as S,subscriptionsOf as ee,updateNode as k,updateNodeTelemetry as te}from"../../../core/canvas/canvas.js";import{liveExecutionForNode as P,recordExecutionIdle as ne,recordExecutionPid as ie}from"../../../core/canvas/executions.js";import{bindSession as re,readLiveSession as oe,transferSession as ae}from"../../../core/canvas/sessions.js";import{isSafeNodeId as se}from"../../../core/canvas/paths.js";import{isPidAlive as ce}from"../../../core/canvas/pid.js";import{editorLabel as R}from"../../../core/canvas/labels.js";import{assembleNodeSubject as de}from"../../../core/substrate/subject.js";import{openDb as F,withCanvasWrite as m}from"../../../core/canvas/db.js";import{runningJobs as le}from"../../../core/graph/jobs.js";import{notFound as O,usage as l}from"../../../core/errors.js";import{hasUnseenWakeMail as T,releaseExecutionMail as ue}from"../../../core/canvas/deliveries.js";import{clearYieldMessage as pe}from"../../../core/runtime/kickoff.js";import{readRoadmap as fe}from"../../../core/runtime/roadmap.js";import{forkSourceNode as me}from"../../../core/runtime/nodes.js";import{transition as g}from"../../../core/runtime/lifecycle.js";import{confirmViewer as B,probeViewer as C,tearDownNode as N}from"../../../core/runtime/placement.js";import{hasAttachedBrokerViewers as we}from"../viewer-presence.js";import{evaluateStop as ye}from"../../../core/runtime/stop-guard.js";import{readOutputRequest as L}from"../../../core/runtime/output-result.js";import{clearFault as b,readFault as he,recordFault as be}from"../../../core/canvas/recovery.js";import{updateModelRecipe as _e}from"../../../core/runtime/model-swap.js";import{completeCompanionRequestedSubmit as ke}from"../../review/finish.js";import{emitEvent as D}from"../../../core/events/emit.js";import{consumePendingPark as ge,recordPendingParkActivity as ve}from"../../park-pending.js";import{shouldParkAfterSummary as xe}from"../../park-activity.js";import{ownerOnly as Se}from"../router.js";import{situationalContextEnvelope as Pe}from"../../../core/runtime/situational-context.js";import{recoveryState as Re,requireCurrentExecution as p}from"./broker-recovery.js";import{runAttachments as Oe}from"./node-records.js";import{readerForNode as Ee,warmNodeRepos as Ae}from"../../../core/graph/reader.js";import{checkoutsForCwd as Fe}from"../../../core/graph/repo-sync/repos.js";import{deliver as E}from"../../../core/substrate/delivery/deliver.js";import{ensureRunObserver as Te}from"../../runs/observer.js";import{parseNodeTelemetryRecord as Be,writeNodeTelemetryRecord as Ce}from"./telemetry-record.js";import{mapAsync as Ne}from"../../../core/async-array.js";import{crtrVersion as M}from"../../../shared/crtr-version.js";import{buildPiArgv as Le}from"../../../core/runtime/launch.js";import{brokerLaunchJson as De}from"../../../core/runtime/host.js";import{CYCLE_APPLIED_ENV as Me,cycleCompatible as Ve}from"../../../core/runtime/launch-recipe.js";import{buildReviveKickoff as $e,drainBearings as je}from"../../../core/runtime/kickoff.js";import{clearNodeLedger as Ue}from"../../../core/runtime/ledger.js";import{runNodeStartHooks as We}from"../../../core/runtime/revive.js";import{consumeDeadlineOnWake as He}from"../../../core/feed/messages.js";import{encodeKickoffOrigin as Je}from"../../../core/runtime/stamp/protocol.js";import{ApiError as Ge}from"../../../api/errors.js";function f(t,e){if(typeof t!="object"||t===null||Array.isArray(t))throw l(`${e} requires a JSON body`);return t}a(f,"objectBody");function V(t){const e=f(t,"broker session-bound");if(typeof e.executionId!="string"||e.executionId==="")throw l("executionId must be a non-empty string");if(typeof e.piSessionId!="string"||e.piSessionId==="")throw l("piSessionId must be a non-empty string");if(e.sessionFile!==null&&typeof e.sessionFile!="string")throw l("sessionFile must be a string or null");if(!Number.isSafeInteger(e.pid)||e.pid<=0)throw l("pid must be a positive safe integer");if(e.reason!==null&&typeof e.reason!="string")throw l("reason must be a string or null");if(!Array.isArray(e.reviewBoundaryIds)||!e.reviewBoundaryIds.every(n=>typeof n=="string"))throw l("reviewBoundaryIds must be an array of strings");return e}a(V,"parseSessionBoundBody");function Ye(t){const e=f(t,"broker settle");if(typeof e.stopReason!="string")throw l("stopReason must be a string");for(const n of["pushedFinal"])if(typeof e[n]!="boolean")throw l(`${n} must be a boolean`);return e}a(Ye,"parseSettleBody");function Ke(t){const e=f(t,"broker cycle");if(typeof e.brokerVersion!="string"||e.brokerVersion==="")throw l("brokerVersion must be a non-empty string");return e}a(Ke,"parseCycleBody");function ze(t){const e=f(t,"broker park-complete");if(e.outcome!=="completed"&&e.outcome!=="failed")throw l("outcome must be completed or failed");return e}a(ze,"parseParkCompleteBody");function Ie(t){const e=f(t,"broker telemetry");if(typeof e.expected_execution_id!="string"||e.expected_execution_id==="")throw l("expected_execution_id must be a non-empty string");const n=Be(e);return{...n,expected_execution_id:e.expected_execution_id,updated_at:new Date(n.updated_at).toISOString()}}a(Ie,"parseTelemetryBody");function Qe(t){const e=f(t,"broker model");if(typeof e.spec!="string"||e.spec.trim()==="")throw l("spec must be a non-empty string");const n=e.intent;if(n!==void 0){const r=n!==null&&typeof n=="object"?n:void 0;if(r===void 0||typeof r.family!="string"||r.family===""||!["ultra","strong","medium","light"].includes(r.strength))throw l("intent must be { family, strength } with strength ultra|strong|medium|light when present")}if(typeof e.userSelected!="boolean")throw l("userSelected must be a boolean");return e}a(Qe,"parseModelCommitBody");async function w(t){const e=await x(t);if(e===null)throw O(`unknown node: ${t}`,{received:t});return e}a(w,"requireNode");async function v(t){return{node_id:t.node_id,grantee:t.grantee,name:t.name,...t.description===void 0?{}:{description:t.description},...t.title===void 0?{}:{title:t.title},...t.icon===void 0?{}:{icon:t.icon},kind:t.kind,mode:t.mode,lifecycle:t.lifecycle,status:t.status,cwd:t.cwd,parent:t.parent??null,fork_from:t.fork_from??null,profile_id:t.profile_id??null,...t.managed_worktree===void 0?{}:{managed_worktree:t.managed_worktree===null?null:{state:t.managed_worktree.state,...t.managed_worktree.cleanup===void 0?{}:{cleanup:t.managed_worktree.cleanup},path:t.managed_worktree.path,branch:t.managed_worktree.branch,base_ref:t.managed_worktree.base_ref,base_sha:t.managed_worktree.base_sha}},...t.review_binding===void 0?{}:{review_binding:t.review_binding??null},intent:t.intent??null,...t.persona_ack===void 0?{}:{persona_ack:t.persona_ack},created:t.created}}a(v,"extensionNode");async function $(t){const e=await w(t),n=[],r=new Set([t]);let i=e.parent??null;for(;i!==null&&i!==""&&!r.has(i);){r.add(i);const d=await x(i);if(d===null)break;n.unshift(await v(d)),i=d.parent??null}const s=await Ne((await I((await ee(t)).map(d=>d.node_id))).filter(d=>d.kind!=="human").sort((d,h)=>d.status===h.status?0:d.status==="active"?-1:h.status==="active"?1:0),v),o=typeof e.fork_source_file=="string"?await me(e.fork_source_file):null,c=await de(t);if(c===null)throw O(`unknown node: ${t}`,{received:t});return{node:await v(e),warm_spare:await Q(t),situational_card:await Pe(t),ancestors:n,children:s,fork_source:o===null?null:await v(o),subject:c,roadmap:await fe(t)}}a($,"extensionState");function A(t,e){return t?.kind===e.kind&&t?.mode===e.mode&&t?.lifecycle===e.lifecycle}a(A,"samePersona");function Xe(t){const e=f(t,"broker generated-name");if(e.kind!=="initial"&&e.kind!=="recap")throw l("kind must be initial or recap");if(typeof e.description!="string"||typeof e.title!="string"||typeof e.icon!="string")throw l("description, title, and icon must be strings");if(e.kind==="initial")return e;const n=e.expected;if(typeof n!="object"||n===null||Array.isArray(n)||["name","description","title","icon","kind"].some(r=>typeof n[r]!="string"))throw l("recap expected must contain name, description, title, icon, and kind strings");return e}a(Xe,"parseGeneratedNameBody");function Ze(t){const e=f(t,"broker persona-ack"),n=a(r=>{const i=e[r];if(typeof i!="object"||i===null||Array.isArray(i)||typeof i.kind!="string"||i.mode!=="base"&&i.mode!=="orchestrator"||i.lifecycle!=="terminal"&&i.lifecycle!=="resident")throw l(`${r} must be a persona state`);return i},"parse");return{expected_execution_id:e.expected_execution_id,from:n("from"),to:n("to")}}a(Ze,"parsePersonaAckBody");async function j(t,e){const n=e.sessionFile===null?null:K(e.sessionFile);return await m(async r=>{await r.prepareUncached("SELECT 1 FROM nodes WHERE node_id = ? FOR UPDATE").get(t);const i=await w(t);if(await ie(e.executionId,t,e.pid)==="shutdown")return{action:"shutdown"};const s=i.review_binding?.review_id;if(s!==void 0&&!e.reviewBoundaryIds.includes(s))return{action:"shutdown"};if(e.reason==="new"&&i.parent==null)return{action:"relaunch_root"};if(e.reason!=="new"&&i.fork_from!=null&&i.pi_session_id==null&&n===null)return{action:"shutdown"};const o=n===null?null:await z(n);if(o!==null&&o.node_id!==t){if(ce(o.pi_pid))return await be(t,{link:"daemon\u2192node",op:"session-file-ownership",kind:"protocol",retry:{disposition:"fatal"},message:`refusing to bind ${n}: it is owned by live node ${o.node_id}`}),{action:"shutdown"};const c=await oe(o.node_id);if(c===null||await ae({fromNodeId:o.node_id,fromBindingId:c.bindingId,toNodeId:t,executionId:e.executionId,sessionId:e.piSessionId,transcriptPath:n})!=="transferred")return{action:"shutdown"}}else if(await re(t,{executionId:e.executionId,sessionId:e.piSessionId,transcriptPath:n})==="shutdown")return{action:"shutdown"};return e.reason!=="new"&&(await pe(t),i.intent==="refresh"&&await g(t,"revive")),{action:"none"}})}a(j,"commitSessionBound");async function qe(t){return{status:200,body:await j(t.params.id,V(t.body))}}a(qe,"handleSessionBound");function et(t){const e=V(t);if(e.bearings!=="fresh"&&e.bearings!=="inherited"&&e.bearings!=="present")throw l("bearings must be fresh, inherited or present");return e}a(et,"parseCycleStartBody");async function tt(t,e,n,r){const i=e.warm_spare||r,s=!i&&n!=="present";return await Ae(await F(),t),await m(async o=>{const c=await Ee(o,t,async(y,_)=>await Fe(o,y,_)),d=await E(o,c,{activity:"names"}),h=s?await E(o,c,{activity:"boot",...n==="inherited"?{inherited:!0}:{}}):void 0,u=i?void 0:await E(o,c,{activity:"system-prompt"});return{names:{refs:d.refs,names:d.names},...h===void 0?{}:{boot:{content:h.content,...h.inherited===!0?{inherited:!0}:{}}},...u===void 0?{}:{system_prompt:u.content}}})}a(tt,"startupDelivery");async function nt(t){const e=t.params.id,n=et(t.body),r=await w(e),i=r.review_binding?.review_id,s=i!==void 0&&!n.reviewBoundaryIds.includes(i),o=s||r.cycle_pending===!0||r.intent==="refresh"||r.pi_session_id==null;if(o)await p(e,n.executionId);else{const{action:u}=await j(e,n);if(u!=="none")return{status:200,body:{action:u}}}const c=await $(e),d=await tt(e,c,n.bearings,s);if(d.boot!==void 0){const u={kind:c.node.kind,mode:c.node.mode,lifecycle:c.node.lifecycle},y=c.node.persona_ack,_=y===void 0?u:{kind:y.kind??c.node.kind,mode:y.mode,lifecycle:y.lifecycle};A(_,u)||await G(e,_,u)}return{status:200,body:{action:"none",...o?{bind_pending:!0}:{},state:c,...d,recovery:await Re(e),attachments:(await Oe(e)).map(({path:u,sha256:y})=>({path:u,sha256:y})),structured_request:await L(e)}}}a(nt,"handleCycleStart");async function U(t,e){return e.live!==null||await we(t)||await T(t)}a(U,"isHeldAwake");async function W(t,e){return(await P(t))?.runner==="blaxel"&&!await U(t,e)&&(await le(await F(),t)).length===0}a(W,"residentBlaxelCanIdle");function H(t){return t.inPlaceCycle===!0?{action:"new_cycle"}:{action:"shutdown"}}a(H,"refreshDirective");async function it(t,e,n){const r=await x(t);if(r===null){if(e.pushedFinal)return{directive:{action:"shutdown"},closePane:!1};throw O(`unknown node: ${t}`,{received:t})}if(await q(t,new Date().toISOString()),(e.stopReason==="stop"||e.stopReason==="length")&&await Z(t,{failures:0,notBefore:null}),e.stopReason==="quit"){let c=!1;return(r.status==="active"||r.status==="idle")&&r.intent===null&&(await g(t,"finish"),await b(t),await S(t,{pane:null,tmux_session:null,window:null}),c=!0),{directive:{action:"shutdown"},closePane:c}}if(e.stopReason!=="stop"&&e.stopReason!=="length")return await b(t,{link:"daemon\u2192node"}),r.intent==="refresh"?{directive:H(e),closePane:!1}:e.stopReason==="error"&&e.faultSettled===!0&&(await he(t))?.retry.disposition==="fatal"&&await L(t)===null&&await W(t,n)?{directive:{action:"stay_resident"},closePane:!1}:{directive:{action:"stay_dormant"},closePane:!1};const i={pushedFinal:e.pushedFinal};if(i.pushedFinal||r.status==="done")return await b(t),await S(t,{pane:null,tmux_session:null,window:null}),{directive:{action:"shutdown"},closePane:!0};if(r.intent==="refresh")return await b(t),{directive:H(e),closePane:!1};const s=await ye(t,i);if(await b(t),s.action==="reprompt")return{directive:{action:"reprompt",prompt:s.message},closePane:!1};if(s.reason==="finished")return{directive:await T(t)?{action:"stay_dormant"}:{action:"shutdown"},closePane:!1};const o=await U(t,n);return(await P(t))?.runner==="blaxel"?{directive:await W(t,n)?{action:"stay_resident"}:{action:"stay_dormant"},closePane:!1}:s.reason!=="awaiting"&&s.reason!=="scheduled"?{directive:{action:"stay_dormant"},closePane:!1}:o?{directive:{action:"stay_dormant"},closePane:!1}:(await g(t,"release"),{directive:{action:"shutdown"},closePane:!1})}a(it,"settleBroker");async function rt(t){const e=t.params.id,n=Ke(t.body);await p(e,n.expected_execution_id);const r=await w(e);if(r.intent!=="refresh")throw new Ge(409,"not_yielding",`${e} has no pending yield`);const i=await P(e),s=Le(r);return n.brokerVersion===M()&&(i.release===null||i.release===M())&&Ve(i.launchJson,await De(e,s,r.cwd))?{status:200,body:await ot(e,r,i.executionId,s.env)}:{status:200,body:{action:"restart"}}}a(rt,"handleCycle");async function ot(t,e,n,r){e.cycles=(e.cycles??0)+1,await ue(t,n);const i=await je(e,n),s=await $e(e,i);await Ue(t),await We(t,e,!1),await He(t),await b(t,{preserveEpisode:!0}),await X(t,new Date().toISOString()),await k(t,{cycles:e.cycles,cycle_pending:!0});const o={};for(const c of Me)r[c]!==void 0&&(o[c]=r[c]);return o.CRTR_CYCLES=String(e.cycles),{action:"cycle",cycle:e.cycles,prompt:s,origin:Je({type:"runtime",kind:"revive",cycle:e.cycles}),messageIds:e.run_id?i.unreadMessageIds??[]:[],env:o,...e.launch?.model!==void 0?{model:e.launch.model}:{},modelExact:e.launch?.modelExact===!0,editorLabel:R(e)}}a(ot,"startCycleRecord");async function at(t){const e=t.params.id,n=f(t.body,"broker idle");return await p(e,n.expected_execution_id),await ne(n.expected_execution_id),{status:204}}a(at,"handleIdle");async function st(t){const e=t.params.id,n=Ye(t.body);await p(e,n.expected_execution_id);const r=await C(e),{directive:i,closePane:s}=await m(async()=>await it(e,n,await B(r)));return s&&await N(e),i.action!=="reprompt"&&ke(e).catch(o=>D({level:"error",event:"api.broker_ops.companion_submit_failed",node_id:e,error:o})),{status:200,body:i}}a(st,"handleSettle");async function ct(t){const e=t.params.id,n=ze(t.body);await p(e,n.expected_execution_id);const r=await C(e),i=await m(async()=>{const s=await ge(e);if(s===void 0)return{action:"stay_dormant"};const o=await w(e);return await xe(e,o,s,await B(r))?(await b(e),await g(e,"park"),await S(e,{pane:null,tmux_session:null,window:null}),D({level:n.outcome==="completed"?"info":"warn",event:"broker.park.complete",...se(e)?{node_id:e}:{},outcome:n.outcome==="completed"?"succeeded":"failed"}),{action:"shutdown"}):{action:"stay_dormant"}});return i.action==="shutdown"&&await N(e),{status:200,body:i}}a(ct,"handleParkComplete");async function dt(t){const e=t.params.id;return await p(e,f(t.body,"broker park-activity").expected_execution_id),{status:200,body:await m(async()=>({activity:await ve(e)?"recorded":"none"}))}}a(dt,"handleParkActivity");async function lt(t){const e=t.params.id,n=Ie(t.body);return await p(e,n.expected_execution_id),await m(async()=>{await te(e,{tokensIn:n.tokens_in,contextTokens:n.context_tokens,lastActivity:n.last_activity,updatedAt:n.updated_at}),Ce(e,n)}),{status:204}}a(lt,"handleTelemetry");async function ut(t){const e=t.params.id,n=Qe(t.body);return await p(e,n.expected_execution_id),{status:200,body:{modelOverride:(await m(async()=>await _e(await w(e),n.spec,n.intent,n.userSelected))).model_override}}}a(ut,"handleModelCommit");let J=!0;function cn(t){J=t}a(cn,"setRequestsStartRunObservers");async function pt(t){const e=t.params.id,n=await w(e);return n.run_id&&J&&await Te(e,n.run_id),{status:200,body:await $(e)}}a(pt,"handleExtensionState");async function ft(t){const e=t.params.id,n=Xe(t.body);return await p(e,n.expected_execution_id),{status:200,body:await m(async i=>{await i.prepareUncached("SELECT 1 FROM nodes WHERE node_id = ? FOR UPDATE").get(e);const s=await w(e);if(n.kind==="initial"){if((s.description??"").trim()!=="")return{applied:!1};const d=await k(e,{description:n.description,...n.title.trim()===""?{}:{title:n.title},...n.icon.trim()===""?{}:{icon:n.icon}});return{applied:!0,editorLabel:R(d),description:d.description??"",title:d.title??"",icon:d.icon??""}}const o=n.expected;if(s.name!==o.name||(s.description??"")!==o.description||(s.title??"")!==o.title||(s.icon??"")!==o.icon||s.kind!==o.kind)return{applied:!1};const c=await k(e,{description:n.description,title:n.title.trim()===""?void 0:n.title,icon:n.icon.trim()===""?void 0:n.icon});return{applied:!0,editorLabel:R(c),description:c.description??"",title:c.title??"",icon:c.icon??""}})}}a(ft,"handleGeneratedName");async function mt(t){const e=t.params.id,n=Ze(t.body);return await p(e,n.expected_execution_id),{status:200,body:{applied:await G(e,n.from,n.to)}}}a(mt,"handlePersonaAck");async function G(t,e,n){return await m(async r=>{await r.prepareUncached("SELECT 1 FROM nodes WHERE node_id = ? FOR UPDATE").get(t);const i=await w(t),s={kind:i.kind,mode:i.mode,lifecycle:i.lifecycle},o=i.persona_ack,c=o===void 0?s:{kind:o.kind??i.kind,mode:o.mode,lifecycle:o.lifecycle};return!A(s,n)||!A(c,e)?!1:(await k(t,{persona_ack:n}),!0)})}a(G,"applyPersonaAck");const dn=Se([{method:"POST",pattern:"/v1/nodes/:id/broker/session-bound",handler:qe},{method:"POST",pattern:"/v1/nodes/:id/broker/cycle-start",handler:nt},{method:"POST",pattern:"/v1/nodes/:id/broker/settle",handler:st},{method:"POST",pattern:"/v1/nodes/:id/broker/cycle",handler:rt},{method:"POST",pattern:"/v1/nodes/:id/broker/idle",handler:at},{method:"POST",pattern:"/v1/nodes/:id/broker/park-complete",handler:ct},{method:"POST",pattern:"/v1/nodes/:id/broker/park-activity",handler:dt},{method:"POST",pattern:"/v1/nodes/:id/broker/telemetry",handler:lt},{method:"POST",pattern:"/v1/nodes/:id/broker/model",handler:ut},{method:"GET",pattern:"/v1/nodes/:id/broker/extension-state",handler:pt},{method:"POST",pattern:"/v1/nodes/:id/broker/generated-name",handler:ft},{method:"POST",pattern:"/v1/nodes/:id/broker/persona-ack",handler:mt}]);export{dn as brokerOperationRoutes,v as extensionNode,cn as setRequestsStartRunObservers};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var _=Object.defineProperty;var c=(e,
|
|
1
|
+
var _=Object.defineProperty;var c=(e,i)=>_(e,"name",{value:i,configurable:!0});import{ApiError as r}from"../../../api/errors.js";import{dirname as k}from"node:path";import{openDb as A,withCanvasWrite as l}from"../../../core/canvas/db.js";import{readerForNode as h,warmNodeDirs as m,warmNodeRepos as N}from"../../../core/graph/reader.js";import{checkoutsForCwd as p}from"../../../core/graph/repo-sync/repos.js";import{DRY_RUN_ONLY as q,deliver as D,hypotheticalFrom as R,hypotheticalReader as C,inspect as y}from"../../../core/substrate/delivery/deliver.js";import{actsAsPerson as O}from"../router.js";import{requireCurrentExecution as S}from"./broker-recovery.js";const P=["boot","system-prompt","compact","persona","file-read","command","pre-command","slash-command","names",...q];function b(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new r(400,"usage","delivery requires a JSON body");const i=e;if(!P.includes(i.activity))throw new r(400,"usage",`invalid delivery activity: ${String(i.activity)}`);if(i.subject!==void 0&&typeof i.subject!="string")throw new r(400,"usage","delivery subject must be a string");return i}c(b,"parse");function g(e){if(!O(e.principal)&&e.principal.class!=="broker")throw new r(403,"permission_error","a delivery dry run is available to a person or a node only")}c(g,"requirePerson");function T(e){if(typeof e!="object"||e===null||Array.isArray(e))throw new r(400,"usage","hypothetical must be an object");const i=c((o,s)=>{if(o!==void 0){if(typeof o!="string"||o==="")throw new r(400,"usage",`hypothetical.${s} must be a non-empty string`);return o}},"str"),n=i(e.cwd,"cwd");if(n!==void 0&&!n.startsWith("/"))throw new r(400,"usage","hypothetical.cwd must be an absolute path");if(e.mode!==void 0&&e.mode!=="base"&&e.mode!=="orchestrator")throw new r(400,"usage","hypothetical.mode must be base or orchestrator");if(e.lifecycle!==void 0&&e.lifecycle!=="terminal"&&e.lifecycle!=="resident")throw new r(400,"usage","hypothetical.lifecycle must be terminal or resident");if(e.has_manager!==void 0&&typeof e.has_manager!="boolean")throw new r(400,"usage","hypothetical.has_manager must be a boolean");if(e.depth!==void 0&&(!Number.isInteger(e.depth)||e.depth<0))throw new r(400,"usage","hypothetical.depth must be a non-negative integer");const t={};n!==void 0&&(t.cwd=n),e.profile!==void 0&&(t.profile=e.profile===null?null:i(e.profile,"profile"));const d=i(e.grantee,"grantee");d!==void 0&&(t.grantee=d);const a=i(e.kind,"kind");return a!==void 0&&(t.kind=a),e.mode!==void 0&&(t.mode=e.mode),e.lifecycle!==void 0&&(t.lifecycle=e.lifecycle),e.has_manager!==void 0&&(t.hasManager=e.has_manager),e.depth!==void 0&&(t.depth=e.depth),t}c(T,"hypotheticalOf");async function w(e,i,n){const t=await A();e!==void 0&&await N(t,e),i&&await m(t,e,[i]),n!==void 0&&n.startsWith("/")&&await m(t,e,[k(n)])}c(w,"warmDeliveryCwds");async function E(e){g(e);const i=b(e.body);if(i.node!==void 0&&typeof i.node!="string")throw new r(400,"usage","node must be a node id");const n={activity:i.activity,...i.subject!==void 0?{subject:i.subject}:{}};await w(i.node,i.hypothetical?.cwd,i.activity==="file-read"?i.subject:void 0);const{result:t,plan:d}=await l(async a=>{if(i.hypothetical===void 0){if(i.node===void 0)throw new r(400,"usage","a delivery dry run names a node, a hypothetical node, or both");return await y(a,await h(a,i.node,async(v,j)=>await p(a,v,j)),n,i.subject_override)}const o=T(i.hypothetical),s=i.node!==void 0?await R(i.node,o):{...o,cwd:o.cwd??""};if(s.cwd==="")throw new r(400,"usage","a hypothetical node needs a cwd");const{reader:u,subject:f}=await C(a,s);return await y(a,u,n,i.subject_override,f)},{rollback:!0});return{status:200,body:{...t,plan:d}}}c(E,"handleDryRun");async function F(e){const i=e.params.id,n=b(e.body),t={activity:n.activity,...n.subject!==void 0?{subject:n.subject}:{},...n.inherited===!0?{inherited:!0}:{}};if(n.dry_run===!0){g(e),await w(i,void 0,n.activity==="file-read"?n.subject:void 0);const{result:a,plan:o}=await l(async s=>await y(s,await h(s,i,async(u,f)=>await p(s,u,f)),t,n.subject_override),{rollback:!0});return{status:200,body:{...a,plan:o}}}if(e.principal.class==="broker"&&e.principal.node!==i)throw new r(403,"permission_error","delivery is performed by the node's own broker");return await S(i,n.expected_execution_id),await w(i,void 0,n.activity==="file-read"?n.subject:void 0),{status:200,body:await l(async a=>await D(a,await h(a,i,async(o,s)=>await p(a,o,s)),t))}}c(F,"handleDelivery");const z=[{method:"POST",pattern:"/v1/nodes/:id/delivery",handler:F},{method:"POST",pattern:"/v1/delivery/dry-run",handler:E}];export{z as deliveryRoutes};
|
|
@@ -1,16 +1,5 @@
|
|
|
1
1
|
import { type CanvasDb } from '../../../core/canvas/db.js';
|
|
2
|
-
import type { ObjectRow
|
|
2
|
+
import type { ObjectRow } from '../../../core/graph/types.js';
|
|
3
3
|
import type { RouteTable } from '../router.js';
|
|
4
4
|
export declare function canonicalName(db: CanvasDb, o: ObjectRow): Promise<string>;
|
|
5
|
-
/** A committed change to a repo-owned document starts that repo's sync. */
|
|
6
|
-
export interface RepoChange {
|
|
7
|
-
repos: ObjectRow[];
|
|
8
|
-
dirs: string[];
|
|
9
|
-
}
|
|
10
|
-
/** The repos among `owners` and the directories that may hold a checkout of them (the caller's cwd,
|
|
11
|
-
* a node's own else the request's, and the checkouts its view reaches), captured inside the write
|
|
12
|
-
* transaction and acted on after it commits. */
|
|
13
|
-
export declare function repoChange(db: CanvasDb, reader: Reader, owners: ObjectRow[], requestCwd?: string): Promise<RepoChange>;
|
|
14
|
-
/** The change is committed; a sync that cannot start is reported as an event, never as a failed write. */
|
|
15
|
-
export declare function syncChanged(change: RepoChange): Promise<void>;
|
|
16
5
|
export declare const docRoutes: RouteTable;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var
|
|
1
|
+
var ae=Object.defineProperty;var u=(n,e)=>ae(n,"name",{value:e,configurable:!0});import{ApiError as E}from"../../../api/errors.js";import{DOC_KINDS as H,DOC_UNSET_FIELDS as q}from"../../../api/dto/docs.js";import{PRIVACY_LEVELS_DTO as P}from"../../../api/dto/objects.js";import{openDb as se,withCanvasWrite as k}from"../../../core/canvas/db.js";import{CrtrError as ce}from"../../../core/errors.js";import{canChange as de,spaceOf as ue}from"../../../core/graph/access.js";import{get as U,getMany as V}from"../../../core/graph/bodies.js";import{deleteDocument as fe,documentRecord as N,editDocument as le,heads as L,history as me,linksIn as G,moveDocument as pe,readBase as he,setDocumentRecord as we,withCurrentNames as ye,writeDocument as ge}from"../../../core/graph/documents.js";import{resolveName as K}from"../../../core/graph/names.js";import{getById as M}from"../../../core/graph/objects.js";import{checkoutsForCwd as _e}from"../../../core/graph/repo-sync/repos.js";import{lintRules as ve,rulesOf as X}from"../../../core/graph/rules.js";import{unifiedDiff as be}from"../../../core/graph/diff.js";import{ownerForGrantee as Ee}from"../../../core/graph/objects.js";import{stubOf as ke}from"../../../core/peer/stubs.js";import{forwarding as Ae}from"../../peer/forward.js";import{resolvedLocally as Oe}from"./objects.js";import{ownerFromFlag as W,readerFor as A,resolveRef as z,warmReaderRepos as O}from"../reader.js";import{appCaller as J,asApiError as $e,requireOwnNamespace as je}from"./schemas.js";import{filterAsync as Re}from"../../../core/async-array.js";function y(n,e,t,o,r={}){return new E(n,e,t,{...r,error:e,message:t,next:o})}u(y,"refuse");const b=u((n,e)=>new E(400,"invalid_request",n,e),"invalid");function S(n){const e=n.body;if(e===void 0)return{};if(typeof e!="object"||e===null||Array.isArray(e))throw b("the request body must be a JSON object");return e}u(S,"bodyOf");const T=u(async n=>async(e,t)=>await _e(n,e,t),"reposFnFor");function I(n,e){if(n instanceof ce){const t=n.details;if(n.code==="read_first")throw y(409,"read_first",n.message,`Read it first with \`crtr canvas read ${e?.id??"<ref>"}\`, then rerun the edit.`,t??{});if(n.code==="conflict")throw new E(409,"name_taken",n.message,t);if(n.code==="forbidden")throw typeof t?.next=="string"?y(403,"forbidden",n.message,t.next,t):new E(403,"forbidden",n.message,t);if(n.code==="scope_missing")throw y(403,"scope_missing",n.message,`Launch the run with \`${String(t?.scope)}\` in its scopes list.`,t??{});if(t?.rule==="repo-public-only")throw y(422,"repo_documents_are_public",n.message,'Own it as `user` and add a rule with `if: {"repo": "<handle>"}` so it loads only in that repo.')}throw $e(n)}u(I,"mapGraphError");async function B(n,e,t){const o=await z(n,e,decodeURIComponent(t));if("remote"in o)throw y(404,"not_found",Z(o.remote),"Check the name with `crtr canvas search`.");if("deleted"in o)throw new E(404,"not_found",`${o.deleted.name} is deleted`,{id:o.deleted.id,deleted:!0});if(o.type!=="document")throw b(`${t} is a ${o.type}, not a document`);return o}u(B,"refDocument");async function Y(n){const{stub:e}=await Oe(decodeURIComponent(n.params.ref),n);if(e===null)return;const t=await ke(await se(),e);if(t.object.type!=="document")return;const o=await Ae.current.label(t.home_machine);throw y(404,"not_here",`this document lives on runtime ${o.name}; edit it (or read its history) from a node there`,`Run the command from a node on ${o.name}.`,{id:t.object.id,home_machine:o.id})}u(Y,"refuseRemoteDocument");function Z(n){return`no object named ${n} on this runtime; it may be on another runtime, or the name may be misspelled`}u(Z,"remoteMessage");async function De(n,e){const t=e.owner===null?null:await M(n,e.owner);return t?t.type==="node"?t.id:t.name:""}u(De,"ownerHandle");async function R(n,e){const t=await De(n,e);return t?`${t}/${e.name}`:e.name}u(R,"canonicalName");async function Ne(n,e){const t=e.owner===null?null:await M(n,e.owner),o=t?{id:t.id,type:t.type,handle:t.type==="node"?t.id:t.name}:null;return{id:e.id,type:e.type,kind:e.kind,owner:o,privacy:e.privacy,name:e.name,preview:e.preview??"",created_at:e.created_at,deleted_at:e.deleted_at,...e.type==="document"?{schema_type:e.schema_type??null}:{}}}u(Ne,"objectDTO");const x=/^[A-Za-z0-9_-]+(\/[A-Za-z0-9_-]+)*$/;function Se(n,e){if(n===void 0)return;if(!Array.isArray(n)){e.push("`rules` must be a list");return}const t=n.map(r=>{if(typeof r!="object"||r===null||Array.isArray(r))return r;const{match_frontmatter:c,...a}=r;return"matchFrontmatter"in a?{...a,match_frontmatter:a.matchFrontmatter}:c===void 0?a:{...a,matchFrontmatter:c}}),o=ve(t);if(o){e.push(o.replaceAll("matchFrontmatter","match_frontmatter"));return}return t}u(Se,"rulesFromDTO");function Q(n,e){const t={},o=u(s=>{const d=n[s];if(d!==void 0){if(typeof d!="string"){e.push(`\`${s}\` must be a string`);return}return d}},"str"),r=o("preview");r!==void 0&&(r.trim()===""||/[\r\n]/.test(r)?e.push("`preview` must be one non-empty line"):t.preview=r);const c=o("summary");c!==void 0&&(t.summary=c);const a=o("why_it_exists");if(a!==void 0&&(t.whyItExists=a),n.privacy!==void 0&&(P.includes(n.privacy)?t.privacy=n.privacy:e.push(`\`privacy\` must be one of ${P.join(", ")}`)),n.unlisted!==void 0&&(typeof n.unlisted!="boolean"?e.push("`unlisted` must be a boolean"):t.unlisted=n.unlisted),n.lint_ignore!==void 0){const s=n.lint_ignore;!Array.isArray(s)||s.some(d=>typeof d!="string")?e.push("`lint_ignore` must be a list of strings"):t.lintIgnore=s}if(n.extensions!==void 0){const s=n.extensions;typeof s!="object"||s===null||Array.isArray(s)||Object.values(s).some(d=>typeof d!="object"||d===null||Array.isArray(d))?e.push("`extensions` must map each plugin to an object of fields"):t.extensions=s}const m=Se(n.rules,e);return m!==void 0&&(t.rules=m),t}u(Q,"fieldsFrom");function ee(n){if(n.length>0)throw b(n.join("; "),{errors:n})}u(ee,"failOn");async function te(n,e,t,o){const r=await Re(G(t),async c=>"remote"in await K(n,e,c));return{...o.length>0?{unresolved_links:o}:{},...r.length>0?{remote_links:r}:{}}}u(te,"linkReport");async function C(n,e,t){if(t?.includes("unreached")||e.schema_type!=null||e.owner===null)return!1;const o=await M(n,e.owner);return!o||o.type==="node"||(await X(n,e)).length>0?!1:await n.prepare(`SELECT 1 FROM edges e JOIN objects s ON s.id = e.src
|
|
2
2
|
WHERE e.type = 'links-to' AND e.dst = ? AND e.src != e.dst AND s.deleted_at IS NULL
|
|
3
|
-
AND EXISTS (SELECT 1 FROM rules r WHERE r.object = s.id) LIMIT 1`).get(e.id)===void 0}u(B,"unreached");const Be="no rule delivers this document and no document with a rule links to it, so no agent will be routed to it; give it a rule, link it from a document that loads, or accept it with lint-ignore `unreached`";async function He(n){const e=I(n),t=[],o=e.name;(typeof o!="string"||!ne.test(o))&&t.push("`name` must be segments of letters, digits, `_` or `-` joined by `/`"),typeof e.body!="string"&&t.push("`body` must be a string"),typeof e.preview!="string"&&t.push("`preview` is required");const a=e.kind??"knowledge";V.includes(a)||t.push(a==="report"?"reports are written only by `crtr push`":`\`kind\` must be one of ${V.join(", ")}`);const c=oe(e,t);e.cwd!==void 0&&typeof e.cwd!="string"&&t.push("`cwd` must be a string");const s=e.schema_type;s!==void 0&&typeof s!="string"&&t.push("`schema_type` must be a string");const f=e.relations;f!==void 0&&(!Array.isArray(f)||f.some(i=>typeof i!="object"||i===null||typeof i.relation!="string"||typeof i.subject!="string"))&&t.push("`relations` must be a list of {relation, subject} strings"),ie(t);const r=e;await j(n.principal,r.cwd);const{dto:d,change:l}=await O(async i=>{const m=await $(i,n);r.schema_type!==void 0?await Ce(i,Q(n).app,r.schema_type):r.relations!==void 0&&Q(n);const p=r.owner==="user"&&m.class==="app"&&m.sub!==void 0?await je(i,m.sub.startsWith("user:")?m.sub:`user:${m.sub}`):await q(i,m,r.owner,r.cwd);try{const{object:w,unresolved:g}=await Ee(i,m,{...c,owner:p,name:r.name,kind:a,preview:c.preview,privacy:c.privacy??"public",...r.schema_type!==void 0?{schemaType:r.schema_type}:{},...r.relations!==void 0?{relations:r.relations}:{}},r.body,await F(i));return{dto:{id:w.id,name:await N(i,w),...await re(i,m,r.body,g),...await B(i,w,c.lintIgnore??null)?{unreached:!0}:{}},change:await M(i,m,[w],r.cwd)}}catch(w){L(w)}});return await W(l),d}u(He,"write");function qe(n,e){let t=n;e.forEach(({old:o,new:a},c)=>{const s=o===""?-1:t.indexOf(o);if(s<0)throw y(422,"replace_no_match",`replace[${c}]: old text not found in the revision you read`,"Copy the old text exactly from your last read and rerun.",{index:c});if(t.indexOf(o,s+1)>=0)throw y(422,"replace_ambiguous",`replace[${c}]: old text occurs more than once`,"Include more surrounding text so the old text matches once, and rerun.",{index:c});t=t.slice(0,s)+a+t.slice(s+o.length)})}u(qe,"checkReplacements");async function Pe(n){const e=I(n),t=[],o=e.body!==void 0,a=e.replace!==void 0;o&&a&&t.push("give `body` or `replace`, not both"),o&&typeof e.body!="string"&&t.push("`body` must be a string");const c=e.replace;a&&(!Array.isArray(c)||c.length===0||c.some(i=>typeof i!="object"||i===null||typeof i.old!="string"||typeof i.new!="string"))&&t.push("`replace` must be a non-empty list of {old, new} strings"),(typeof e.rationale!="string"||e.rationale.trim()==="")&&t.push("`rationale` is required"),e.verbatim!==void 0&&typeof e.verbatim!="boolean"&&t.push("`verbatim` must be a boolean"),e.base!==void 0&&(typeof e.base!="string"||e.base==="")&&t.push("`base` must be a non-empty heads key"),e.base!==void 0&&!o&&!a&&t.push("`base` applies only to a `body` or `replace` edit");const s=oe(e,t),f=e.unset??[];if(!Array.isArray(f)||f.some(i=>!x.includes(i)))t.push(`\`unset\` takes only ${x.join(", ")}`);else for(const i of f)i==="summary"&&(s.summary=null),i==="why_it_exists"&&(s.whyItExists=null),i==="unlisted"&&(s.unlisted=!1),i==="lint_ignore"&&(s.lintIgnore=null),i==="extensions"&&(s.extensions=null),i==="rules"&&(s.rules=[]);t.length===0&&!o&&!a&&Object.keys(s).length===0&&t.push("nothing to change: give `body`, `replace`, or a field"),ie(t);const r=e;await ee(n),await j(n.principal);const{dto:d,synced:l}=await O(async i=>{const m=await $(i,n),p=await P(i,m,n.params.ref),w=await N(i,p),g=await M(i,m,[p]);try{if(!o&&!a){await ve(i,m,p,s,r.rationale);const E=await C(i,p);return{dto:{id:p.id,name:w,revision:E.revision,...await B(i,p,E.lint_ignore)?{unreached:!0}:{}},synced:g}}const _=r.base??await _e(i,m,p);if(a&&_!==null){const E=await C(i,p),U=await H(i,p);E.source_path===null&&E.heads_key===_&&U.length===1&&qe(await be(i,p,await K(i,U[0].body_hash)),r.replace)}const D=r.verbatim===!0,S=o?{body:r.body,verbatim:D}:{replace:r.replace,verbatim:D},v=await we(i,m,p,S,r.rationale,_,s,await F(i));if("stale"in v)throw y(409,"stale_revision",`${w} changed after your read; it is now at revision ${v.stale.revision}`,`Read it again with \`crtr canvas read ${w}\`, then redo your change on the current text.`,{stale:v.stale});const h=await K(i,(await H(i,p))[0].body_hash),b=await C(i,p);return{dto:{id:p.id,name:w,revision:v.revision,...await re(i,m,h,v.unresolved),...await B(i,p,b.lint_ignore)?{unreached:!0}:{}},synced:g}}catch(_){L(_,p)}});return await W(l),d}u(Pe,"edit");async function Ue(n){const e=I(n);if(e.new_name===void 0&&e.owner===void 0)throw k("give a new name, an owner, or both");if(e.new_name!==void 0&&(typeof e.new_name!="string"||!ne.test(e.new_name)))throw k("`new_name` must be segments of letters, digits, `_` or `-` joined by `/`");await j(n.principal,e.cwd);const{dto:t,change:o}=await O(async a=>{const c=await $(a,n),s=await P(a,c,n.params.ref),f=e.owner===void 0?void 0:await q(a,c,e.owner,e.cwd);try{const r=await ge(a,c,s,{...e.new_name!==void 0?{name:e.new_name}:{},...f?{owner:f}:{}},await F(a));return{dto:{id:r.id,name:await N(a,r)},change:await M(a,c,[s,r],e.cwd)}}catch(r){L(r,s)}});return await W(o),t}u(Ue,"move");async function Ve(n){await j(n.principal);const{dto:e,change:t}=await O(async o=>{const a=await $(o,n),c=await P(o,a,n.params.ref),s=await N(o,c),f=await M(o,a,[c]);try{await he(o,a,c,await F(o))}catch(r){L(r,c)}return{dto:{id:c.id,name:s},change:f}});return await W(t),e}u(Ve,"remove");async function xe(n){const e=n.query.get("diff"),t=e===null?void 0:Number(e);if(t!==void 0&&!(Number.isInteger(t)&&t>0))throw k("`diff` must be a revision number");return await ee(n),await j(n.principal),await O(async o=>{const a=await $(o,n),c=await Z(o,a,decodeURIComponent(n.params.ref));if("remote"in c)throw y(404,"not_found",te(c.remote),"Check the name with `crtr canvas search`.");const s="deleted"in c?c.deleted:c;if(s.type!=="document")throw k(`${s.name} is a ${s.type}, not a document`);const f=await ye(o,a,s),r={object:await Le(o,s),revisions:f.map(d=>({rev_id:d.rev_id,number:d.number,author_id:d.author,rationale:d.rationale,verbatim:d.verbatim,created_at:d.created_at,parents:d.parents,acting_app:d.acting_app,acting_for:d.acting_for}))};if(t!==void 0){const d=f.find(m=>m.number===t);if(!d)throw new A(404,"not_found",`${s.name} has no revision ${t}`);const l=d.parents[0]===void 0?void 0:f.find(m=>m.rev_id===d.parents[0]),i=await X(o,l?[l.body_hash,d.body_hash]:[d.body_hash]);r.diff=$e(l?i.get(l.body_hash):"",i.get(d.body_hash))}return r})}u(xe,"revisionHistory");const ae=1e3,se=1e3,ce=3e3,Ge=/^When\b.+\bbecause\b.+/,Ke=u(n=>{const e=n.trim();return e===""?0:e.split(/\s+/).length},"words");function Xe(n,e){if(n.some(o=>o.on==="boot"&&o.deliver==="content")&&e>ae)return`body is ${e} words, over the ${ae}-word cap for a boot rule at content (the whole body enters every node's context). Keep the core here and move separate subjects into [[linked]] documents.`;const t=[...new Set(n.filter(o=>o.on!=="boot"&&o.deliver==="content").map(o=>o.on))];return t.length>0&&e>se?`body is ${e} words, over the ${se}-word cap for a content rule on ${t.join("/")}. Keep the core here and move separate subjects into [[linked]] documents.`:n.some(o=>o.on==="boot"&&o.deliver==="preview")&&e>ce?`body is ${e} words, over the ${ce}-word cap for a boot rule at preview. Keep the core here and move separate subjects into [[linked]] documents.`:null}u(Xe,"lengthFinding");async function ze(n){const e=I(n);return await j(n.principal,e.cwd),await O(async t=>{const o=await $(t,n),a=e.owner===void 0?null:await q(t,o,e.owner,e.cwd),c=await t.prepare("SELECT * FROM objects WHERE type = 'document' AND deleted_at IS NULL AND home_machine IS NULL AND kind != 'report' ORDER BY name").all(),s=[],f=new Map,r=[];for(const l of c)a&&l.owner!==a.id||await me(t,o,l)&&r.push({doc:l,head:(await H(t,l))[0]});const d=await X(t,r.flatMap(l=>l.head?[l.head.body_hash]:[]));for(const{doc:l,head:i}of r){const m=await C(t,l),p=new Set(m.lint_ignore??[]),w=await N(t,l),g=u((h,b,E)=>{p.has(h)||s.push({name:w,severity:b,rule:h,message:E})},"add"),_=await Y(t,l),D=i?d.get(i.body_hash):"",S=Xe(_,Ke(D));S&&g("length","error",S),_.some(h=>h.deliver==="preview")&&!Ge.test(l.preview??"")&&g("preview-shape","error",`a rule delivers this document at preview, so the preview must read "When <situation in the reader's work>, read this because <what the reader gains>"`);const v=new Set((await t.prepare("SELECT written_as FROM edges WHERE type = 'links-to' AND src = ?").all(l.id)).map(h=>h.written_as));for(const h of z(D)){if(v.has(h))continue;const b=await J(t,o,h);"remote"in b||"object"in b||"deleted"in b||g("links","warning",`[[${h}]] names no object in your view`)}if(await B(t,l,m.lint_ignore)&&g("unreached","warning",Be),_.some(h=>h.on==="workspace-open"&&h.deliver==="content")){const h=await pe(t,l);h.type==="repo"&&!p.has("workspace-open")&&f.set(h.name,[...f.get(h.name)??[],w])}}for(const[l,i]of f)if(!(i.length<2))for(const m of i)s.push({name:m,severity:"warning",rule:"workspace-open",message:`repo ${l} has ${i.length} documents delivered at content on workspace-open (${i.join(", ")}); keep one and link the rest from it`});return{findings:s}})}u(ze,"lint");const R=u((n,e=200)=>async t=>({status:e,body:await n(t)}),"ok"),_t=[{method:"POST",pattern:"/v1/docs",handler:R(He,201)},{method:"PATCH",pattern:"/v1/docs/:ref",handler:R(Pe)},{method:"POST",pattern:"/v1/docs/:ref/move",handler:R(Ue)},{method:"DELETE",pattern:"/v1/docs/:ref",handler:R(Ve)},{method:"GET",pattern:"/v1/docs/:ref/history",handler:R(xe)},{method:"POST",pattern:"/v1/docs/lint",handler:R(ze)}];export{N as canonicalName,_t as docRoutes,M as repoChange,W as syncChanged};
|
|
3
|
+
AND EXISTS (SELECT 1 FROM rules r WHERE r.object = s.id) LIMIT 1`).get(e.id)===void 0}u(C,"unreached");const Te="no rule delivers this document and no document with a rule links to it, so no agent will be routed to it; give it a rule, link it from a document that loads, or accept it with lint-ignore `unreached`";async function Ie(n){const e=S(n),t=[],o=e.name;(typeof o!="string"||!x.test(o))&&t.push("`name` must be segments of letters, digits, `_` or `-` joined by `/`"),typeof e.body!="string"&&t.push("`body` must be a string"),typeof e.preview!="string"&&t.push("`preview` is required");const r=e.kind??"knowledge";H.includes(r)||t.push(r==="report"?"reports are written only by `crtr push`":`\`kind\` must be one of ${H.join(", ")}`);const c=Q(e,t);e.cwd!==void 0&&typeof e.cwd!="string"&&t.push("`cwd` must be a string");const a=e.schema_type;a!==void 0&&typeof a!="string"&&t.push("`schema_type` must be a string");const m=e.relations;m!==void 0&&(!Array.isArray(m)||m.some(i=>typeof i!="object"||i===null||typeof i.relation!="string"||typeof i.subject!="string"))&&t.push("`relations` must be a list of {relation, subject} strings"),ee(t);const s=e;return await O(n.principal,s.cwd),await k(async i=>{const l=await A(i,n);s.schema_type!==void 0?await je(i,J(n).app,s.schema_type):s.relations!==void 0&&J(n);const f=s.owner==="user"&&l.class==="app"&&l.sub!==void 0?await Ee(i,l.sub.startsWith("user:")?l.sub:`user:${l.sub}`):await W(i,l,s.owner,s.cwd);try{const{object:h,unresolved:w}=await ge(i,l,{...c,owner:f,name:s.name,kind:r,preview:c.preview,privacy:c.privacy??"public",...s.schema_type!==void 0?{schemaType:s.schema_type}:{},...s.relations!==void 0?{relations:s.relations}:{}},s.body,await T(i));return{id:h.id,name:await R(i,h),...await te(i,l,s.body,w),...await C(i,h,c.lintIgnore??null)?{unreached:!0}:{}}}catch(h){I(h)}})}u(Ie,"write");function Ce(n,e){let t=n;e.forEach(({old:o,new:r},c)=>{const a=o===""?-1:t.indexOf(o);if(a<0)throw y(422,"replace_no_match",`replace[${c}]: old text not found in the revision you read`,"Copy the old text exactly from your last read and rerun.",{index:c});if(t.indexOf(o,a+1)>=0)throw y(422,"replace_ambiguous",`replace[${c}]: old text occurs more than once`,"Include more surrounding text so the old text matches once, and rerun.",{index:c});t=t.slice(0,a)+r+t.slice(a+o.length)})}u(Ce,"checkReplacements");async function Fe(n){const e=S(n),t=[],o=e.body!==void 0,r=e.replace!==void 0;o&&r&&t.push("give `body` or `replace`, not both"),o&&typeof e.body!="string"&&t.push("`body` must be a string");const c=e.replace;r&&(!Array.isArray(c)||c.length===0||c.some(i=>typeof i!="object"||i===null||typeof i.old!="string"||typeof i.new!="string"))&&t.push("`replace` must be a non-empty list of {old, new} strings"),(typeof e.rationale!="string"||e.rationale.trim()==="")&&t.push("`rationale` is required"),e.verbatim!==void 0&&typeof e.verbatim!="boolean"&&t.push("`verbatim` must be a boolean"),e.base!==void 0&&(typeof e.base!="string"||e.base==="")&&t.push("`base` must be a non-empty heads key"),e.base!==void 0&&!o&&!r&&t.push("`base` applies only to a `body` or `replace` edit");const a=Q(e,t),m=e.unset??[];if(!Array.isArray(m)||m.some(i=>!q.includes(i)))t.push(`\`unset\` takes only ${q.join(", ")}`);else for(const i of m)i==="summary"&&(a.summary=null),i==="why_it_exists"&&(a.whyItExists=null),i==="unlisted"&&(a.unlisted=!1),i==="lint_ignore"&&(a.lintIgnore=null),i==="extensions"&&(a.extensions=null),i==="rules"&&(a.rules=[]);t.length===0&&!o&&!r&&Object.keys(a).length===0&&t.push("nothing to change: give `body`, `replace`, or a field"),ee(t);const s=e;return await Y(n),await O(n.principal),await k(async i=>{const l=await A(i,n),f=await B(i,l,n.params.ref),h=await R(i,f);try{if(!o&&!r){await we(i,l,f,a,s.rationale);const p=await N(i,f);return{id:f.id,name:h,revision:p.revision,...await C(i,f,p.lint_ignore)?{unreached:!0}:{}}}const w=s.base??await he(i,l,f);if(r&&w!==null){const p=await N(i,f),_=await L(i,f);p.source_path===null&&p.heads_key===w&&_.length===1&&Ce(await ye(i,f,await U(i,_[0].body_hash)),s.replace)}const v=s.verbatim===!0,j=o?{body:s.body,verbatim:v}:{replace:s.replace,verbatim:v},g=await le(i,l,f,j,s.rationale,w,a,await T(i));if("stale"in g)throw y(409,"stale_revision",`${h} changed after your read; it is now at revision ${g.stale.revision}`,`Read it again with \`crtr canvas read ${h}\`, then redo your change on the current text.`,{stale:g.stale});const D=await U(i,(await L(i,f))[0].body_hash),F=await N(i,f);return{id:f.id,name:h,revision:g.revision,...await te(i,l,D,g.unresolved),...await C(i,f,F.lint_ignore)?{unreached:!0}:{}}}catch(w){I(w,f)}})}u(Fe,"edit");async function Le(n){const e=S(n);if(e.new_name===void 0&&e.owner===void 0)throw b("give a new name, an owner, or both");if(e.new_name!==void 0&&(typeof e.new_name!="string"||!x.test(e.new_name)))throw b("`new_name` must be segments of letters, digits, `_` or `-` joined by `/`");return await O(n.principal,e.cwd),await k(async o=>{const r=await A(o,n),c=await B(o,r,n.params.ref),a=e.owner===void 0?void 0:await W(o,r,e.owner,e.cwd);try{const m=await pe(o,r,c,{...e.new_name!==void 0?{name:e.new_name}:{},...a?{owner:a}:{}},await T(o));return{id:m.id,name:await R(o,m)}}catch(m){I(m,c)}})}u(Le,"move");async function Me(n){return await O(n.principal),await k(async t=>{const o=await A(t,n),r=await B(t,o,n.params.ref),c=await R(t,r);try{await fe(t,o,r,await T(t))}catch(a){I(a,r)}return{id:r.id,name:c}})}u(Me,"remove");async function We(n){const e=n.query.get("diff"),t=e===null?void 0:Number(e);if(t!==void 0&&!(Number.isInteger(t)&&t>0))throw b("`diff` must be a revision number");return await Y(n),await O(n.principal),await k(async o=>{const r=await A(o,n),c=await z(o,r,decodeURIComponent(n.params.ref));if("remote"in c)throw y(404,"not_found",Z(c.remote),"Check the name with `crtr canvas search`.");const a="deleted"in c?c.deleted:c;if(a.type!=="document")throw b(`${a.name} is a ${a.type}, not a document`);const m=await me(o,r,a),s={object:await Ne(o,a),revisions:m.map(d=>({rev_id:d.rev_id,number:d.number,author_id:d.author,rationale:d.rationale,verbatim:d.verbatim,created_at:d.created_at,parents:d.parents,acting_app:d.acting_app,acting_for:d.acting_for}))};if(t!==void 0){const d=m.find(f=>f.number===t);if(!d)throw new E(404,"not_found",`${a.name} has no revision ${t}`);const i=d.parents[0]===void 0?void 0:m.find(f=>f.rev_id===d.parents[0]),l=await V(o,i?[i.body_hash,d.body_hash]:[d.body_hash]);s.diff=be(i?l.get(i.body_hash):"",l.get(d.body_hash))}return s})}u(We,"revisionHistory");const ne=1e3,oe=1e3,ie=3e3,Be=/^When\b.+\bbecause\b.+/,He=u(n=>{const e=n.trim();return e===""?0:e.split(/\s+/).length},"words");function qe(n,e){if(n.some(o=>o.on==="boot"&&o.deliver==="content")&&e>ne)return`body is ${e} words, over the ${ne}-word cap for a boot rule at content (the whole body enters every node's context). Keep the core here and move separate subjects into [[linked]] documents.`;const t=[...new Set(n.filter(o=>o.on!=="boot"&&o.deliver==="content").map(o=>o.on))];return t.length>0&&e>oe?`body is ${e} words, over the ${oe}-word cap for a content rule on ${t.join("/")}. Keep the core here and move separate subjects into [[linked]] documents.`:n.some(o=>o.on==="boot"&&o.deliver==="preview")&&e>ie?`body is ${e} words, over the ${ie}-word cap for a boot rule at preview. Keep the core here and move separate subjects into [[linked]] documents.`:null}u(qe,"lengthFinding");async function Pe(n){const e=S(n);return await O(n.principal,e.cwd),await k(async t=>{const o=await A(t,n),r=e.owner===void 0?null:await W(t,o,e.owner,e.cwd),c=await t.prepare("SELECT * FROM objects WHERE type = 'document' AND deleted_at IS NULL AND home_machine IS NULL AND kind != 'report' ORDER BY name").all(),a=[],m=new Map,s=[];for(const i of c)r&&i.owner!==r.id||await de(t,o,i)&&s.push({doc:i,head:(await L(t,i))[0]});const d=await V(t,s.flatMap(i=>i.head?[i.head.body_hash]:[]));for(const{doc:i,head:l}of s){const f=await N(t,i),h=new Set(f.lint_ignore??[]),w=await R(t,i),v=u((p,_,re)=>{h.has(p)||a.push({name:w,severity:_,rule:p,message:re})},"add"),j=await X(t,i),g=l?d.get(l.body_hash):"",D=qe(j,He(g));D&&v("length","error",D),j.some(p=>p.deliver==="preview")&&!Be.test(i.preview??"")&&v("preview-shape","error",`a rule delivers this document at preview, so the preview must read "When <situation in the reader's work>, read this because <what the reader gains>"`);const F=new Set((await t.prepare("SELECT written_as FROM edges WHERE type = 'links-to' AND src = ?").all(i.id)).map(p=>p.written_as));for(const p of G(g)){if(F.has(p))continue;const _=await K(t,o,p);"remote"in _||"object"in _||"deleted"in _||v("links","warning",`[[${p}]] names no object in your view`)}if(await C(t,i,f.lint_ignore)&&v("unreached","warning",Te),j.some(p=>p.on==="workspace-open"&&p.deliver==="content")){const p=await ue(t,i);p.type==="repo"&&!h.has("workspace-open")&&m.set(p.name,[...m.get(p.name)??[],w])}}for(const[i,l]of m)if(!(l.length<2))for(const f of l)a.push({name:f,severity:"warning",rule:"workspace-open",message:`repo ${i} has ${l.length} documents delivered at content on workspace-open (${l.join(", ")}); keep one and link the rest from it`});return{findings:a}})}u(Pe,"lint");const $=u((n,e=200)=>async t=>({status:e,body:await n(t)}),"ok"),ut=[{method:"POST",pattern:"/v1/docs",handler:$(Ie,201)},{method:"PATCH",pattern:"/v1/docs/:ref",handler:$(Fe)},{method:"POST",pattern:"/v1/docs/:ref/move",handler:$(Le)},{method:"DELETE",pattern:"/v1/docs/:ref",handler:$(Me)},{method:"GET",pattern:"/v1/docs/:ref/history",handler:$(We)},{method:"POST",pattern:"/v1/docs/lint",handler:$(Pe)}];export{R as canonicalName,ut as docRoutes};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var x=Object.defineProperty;var r=(e,t)=>x(e,"name",{value:t,configurable:!0});import{createHash as T}from"node:crypto";import{withCanvasWrite as g}from"../../../core/canvas/db.js";import{canRead as k}from"../../../core/graph/access.js";import{permits as M}from"../../../core/permissions/evaluator.js";import{get as b}from"../../../core/graph/bodies.js";import{ownerForGrantee as C}from"../../../core/graph/objects.js";import{readerFor as F}from"../../../core/graph/reader.js";import{checkoutsForCwd as H}from"../../../core/graph/repo-sync/repos.js";import{RunError as h}from"../../../core/runs/operations.js";import{mapAsync as j}from"../../../core/async-array.js";import{personId as B}from"../../../core/canvas/person.js";const ut=new Set(["memory.list","memory.get"]),W=1024*1024,w=/^[A-Za-z0-9_-]+(\/[A-Za-z0-9_-]+)*$/,N=["knowledge","preference"],i=r((e,t)=>new h(400,"invalid_request",e,t),"invalid"),O=r(()=>new h(404,"not_found","no memory document by that name"),"notFound");function _(e){const t=e.get("store");if(t===null)throw i("store is required","store");if(t!=="user")throw i('store must be "user"',"store")}r(_,"store");function J(e){const t=e.get("kind");if(t===null)return null;if(!N.includes(t))throw i("kind must be knowledge or preference","kind");return t}r(J,"kindOf");function Y(e){const t=e.get("limit");if(t===null)return 50;if(!/^(0|[1-9]\d*)$/.test(t)||Number(t)<1||Number(t)>100)throw i("limit must be an integer from 1 to 100","limit");return Number(t)}r(Y,"limitOf");function U(e,t){return T("sha256").update(JSON.stringify(["user",e,t])).digest("base64url").slice(0,16)}r(U,"filterHash");function $(e,t){return Buffer.from(JSON.stringify({n:e,f:t}),"utf8").toString("base64url")}r($,"encodeCursor");function z(e,t){if(e===null)return null;try{if(!/^[A-Za-z0-9_-]+$/.test(e))throw new Error("not base64url");const n=JSON.parse(Buffer.from(e,"base64url").toString("utf8"));if(typeof n.n=="string"&&w.test(n.n)&&n.f===t)return n.n}catch{}throw i("cursor is not the next_cursor of a previous page with the same store, path and kind","cursor")}r(z,"decodeCursor");async function R(e){return await C(e,B())}r(R,"personObject");async function v(e,t){return await F(e,t,async
|
|
1
|
+
var x=Object.defineProperty;var r=(e,t)=>x(e,"name",{value:t,configurable:!0});import{createHash as T}from"node:crypto";import{withCanvasWrite as g}from"../../../core/canvas/db.js";import{canRead as k}from"../../../core/graph/access.js";import{permits as M}from"../../../core/permissions/evaluator.js";import{get as b}from"../../../core/graph/bodies.js";import{ownerForGrantee as C}from"../../../core/graph/objects.js";import{readerFor as F}from"../../../core/graph/reader.js";import{checkoutsForCwd as H}from"../../../core/graph/repo-sync/repos.js";import{RunError as h}from"../../../core/runs/operations.js";import{mapAsync as j}from"../../../core/async-array.js";import{personId as B}from"../../../core/canvas/person.js";const ut=new Set(["memory.list","memory.get"]),W=1024*1024,w=/^[A-Za-z0-9_-]+(\/[A-Za-z0-9_-]+)*$/,N=["knowledge","preference"],i=r((e,t)=>new h(400,"invalid_request",e,t),"invalid"),O=r(()=>new h(404,"not_found","no memory document by that name"),"notFound");function _(e){const t=e.get("store");if(t===null)throw i("store is required","store");if(t!=="user")throw i('store must be "user"',"store")}r(_,"store");function J(e){const t=e.get("kind");if(t===null)return null;if(!N.includes(t))throw i("kind must be knowledge or preference","kind");return t}r(J,"kindOf");function Y(e){const t=e.get("limit");if(t===null)return 50;if(!/^(0|[1-9]\d*)$/.test(t)||Number(t)<1||Number(t)>100)throw i("limit must be an integer from 1 to 100","limit");return Number(t)}r(Y,"limitOf");function U(e,t){return T("sha256").update(JSON.stringify(["user",e,t])).digest("base64url").slice(0,16)}r(U,"filterHash");function $(e,t){return Buffer.from(JSON.stringify({n:e,f:t}),"utf8").toString("base64url")}r($,"encodeCursor");function z(e,t){if(e===null)return null;try{if(!/^[A-Za-z0-9_-]+$/.test(e))throw new Error("not base64url");const n=JSON.parse(Buffer.from(e,"base64url").toString("utf8"));if(typeof n.n=="string"&&w.test(n.n)&&n.f===t)return n.n}catch{}throw i("cursor is not the next_cursor of a previous page with the same store, path and kind","cursor")}r(z,"decodeCursor");async function R(e){return await C(e,B())}r(R,"personObject");async function v(e,t){return await F(e,t,async(n,o)=>await H(e,n,o))}r(v,"graphReader");async function S(e,t){const n=await e.prepare(`SELECT r.body_hash, r.created_at FROM revisions r WHERE r.document = ?
|
|
2
2
|
AND NOT EXISTS (SELECT 1 FROM revision_parents p WHERE p.parent = r.rev_id) ORDER BY r.number DESC, r.rev_id LIMIT 1`).get(t.id),o=await e.prepare("SELECT created_at, author FROM revisions WHERE document = ? ORDER BY number, created_at LIMIT 1").get(t.id);if(!n||!o)throw O();return{head:n,first:o}}r(S,"revisions");async function A(e,t){const{head:n,first:o}=await S(e,t),a=t.name.lastIndexOf("/");return{name:t.name,folder:a<0?"":t.name.slice(0,a),kind:t.kind,preview:t.preview,summary:t.summary,privacy:t.privacy,revision:t.revision,created_at:o.created_at,updated_at:n.created_at}}r(A,"item");async function G(e,t){return t===null?null:(await e.prepare(`SELECT i.external_id FROM objects a LEFT JOIN nodes n ON n.node_id = a.id
|
|
3
3
|
JOIN identities i ON i.object = CASE WHEN a.type = 'node' THEN n.app ELSE a.id END AND i.scheme = 'app'
|
|
4
4
|
WHERE a.id = ?`).get(t))?.external_id??null}r(G,"granteeOf");function Z(e,t){if(e.length<=t)return e;let n=t;for(;n>0&&(e[n]&192)===128;)n--;return e.subarray(0,n)}r(Z,"utf8Prefix");async function P(e,t){_(t);const n=t.get("path");if(n!==null&&!w.test(n))throw i("path must be name segments of letters, digits, `_` or `-` joined by `/`","path");const o=J(t),a=Y(t),d=U(n,o),s=z(t.get("cursor"),d);return await g(async u=>{const l=await v(u,e),c=await R(u),m=n===null?null:`${n}/`,f=o===null?N:[o],y=await M(u,l,"read"),E=await u.prepareUncached(`SELECT o.*, d.summary, d.revision, d.source_path FROM objects o JOIN documents d ON d.object = o.id
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var ce=Object.defineProperty;var u=(t,e)=>ce(t,"name",{value:e,configurable:!0});import{randomBytes as ue}from"node:crypto";import{claimNodeMail as le,acknowledgeNodeMail as fe}from"../../../core/canvas/deliveries.js";import{nodeMailEntry as me}from"../../../core/feed/inbox.js";import{enqueueNodeMail as D,cancelPendingNodeMail as pe}from"../../../core/feed/messages.js";import{assertRecordedCwdExists as ye,reviveNode as L}from"../../../core/runtime/revive.js";import{BrokerUnreachableError as U}from"../../../core/runtime/broker-request.js";import{isBrokerLive as
|
|
2
|
-
`)[0].slice(0,120)}u(Ge,"label");function ie(t,e){return e===null?"":Y("reopen-final-report",{report:`${t}/${e}`},"This node previously completed work. Read this final report before acting on the new instruction.")}u(ie,"previousFinalReportCard");async function He(t,e,a){if(a!==null&&a!=="human"&&(await G(t,a))?.type==="node"){const o=await F(t,a);return{actor:o,senderNode:o}}if(a==="human")return{actor:await ve(t,
|
|
1
|
+
var ce=Object.defineProperty;var u=(t,e)=>ce(t,"name",{value:e,configurable:!0});import{randomBytes as ue}from"node:crypto";import{claimNodeMail as le,acknowledgeNodeMail as fe}from"../../../core/canvas/deliveries.js";import{nodeMailEntry as me}from"../../../core/feed/inbox.js";import{enqueueNodeMail as D,cancelPendingNodeMail as pe}from"../../../core/feed/messages.js";import{assertRecordedCwdExists as ye,reviveNode as L}from"../../../core/runtime/revive.js";import{BrokerUnreachableError as U}from"../../../core/runtime/broker-request.js";import{isBrokerLive as q}from"../../../core/runtime/model-swap.js";import{deliverLive as he,interruptLive as we}from"../../../core/runtime/interactive-deliver.js";import{isProfilePaused as be}from"../../../core/profiles/manifest.js";import{getNode as C,withFreshTerminalGuard as ge}from"../../../core/canvas/canvas.js";import{getById as G,nodeObject as F,ownerForGrantee as ve}from"../../../core/graph/objects.js";import{recordActedOn as _e}from"../../../core/graph/edges.js";import{recordWatch as H}from"../../../core/graph/watches.js";import{publish as V}from"../../../core/graph/events.js";import{readerFor as K}from"../reader.js";import{canRead as ke}from"../../../core/graph/access.js";import{withCanvasWrite as k}from"../../../core/canvas/db.js";import{getPendingStructuredRequestForNode as Q}from"../../../core/canvas/structured-requests.js";import{consumeDeadlineOnWake as X}from"../../../core/feed/messages.js";import{assertNotFinalized as M,assertFinalizedForReopen as Se,commitReopenResident as E}from"../../../core/runtime/reopen.js";import{admitLegacyStructuredOutput as $e}from"../../structured-requests/sidecar.js";import{assertOutputSchemaAccepted as Ne}from"../../../core/runtime/structured-output.js";import{appendSituationalContext as P,formatSituationalProse as je}from"../../../core/runtime/situational-context.js";import{formatDataCard as Y}from"../../../shared/generated-context.js";import{hasNoNaturalCycle as Ae}from"../../../core/runtime/revive-all.js";import{recordPendingParkActivity as Oe}from"../../park-pending.js";import{wantsExecution as qe}from"../../reconcilers/node-lifecycle/wants-execution.js";import{hasFreshGroundState as Ce}from"../../../core/runtime/revive.js";import{CrtrError as xe,notFound as x,usage as d}from"../../../core/errors.js";import{isStartRefusal as Re}from"../../../core/runtime/start-check.js";import{emitEvent as Fe}from"../../../core/events/emit.js";import{assertScope as Me}from"../../../core/scopes.js";import{InputError as I}from"../../../core/io.js";import{ApiError as Ee}from"../../../api/index.js";import{describeObject as Pe,stubOf as Ie}from"../../../core/peer/stubs.js";import{machineNameOf as Z}from"../../../core/peer/names.js";import{callerNode as Te,callerStub as Be,forwardVerb as ee,relayError as te,remoteStub as ze,unknownError as re,withMachine as ne}from"../../peer/forward.js";import{ownerOnly as Je}from"../router.js";import{personId as We}from"../../../core/canvas/person.js";const De=["critical","urgent","normal","deferred"];function oe(t,e){if(typeof t!="object"||t===null||Array.isArray(t))throw d(`${e} must be an object { kind, facts?, body? }`);const a=t,n=a.kind;if(typeof n!="string"||n.trim()==="")throw d(`${e}.kind is required`);if(!n.includes(":"))throw d(`${e}.kind must be namespaced (contain ':'): ${n}`);const r={kind:n},o=a.facts;if(o!==void 0){if(typeof o!="object"||o===null||Array.isArray(o))throw d(`${e}.facts must be an object of string or number values`);const c={};for(const[l,m]of Object.entries(o)){if(typeof m!="string"&&typeof m!="number")throw d(`${e}.facts.${l} must be a string or number`);c[l]=m}r.facts=c}const i=a.body;if(i!==void 0){if(typeof i!="string")throw d(`${e}.body must be a string`);r.body=i}return r}u(oe,"parseCardRequest");function ae(t,e){try{return Y(t.kind,t.facts??{},t.body??"")}catch(a){throw d(`${e}: ${a instanceof Error?a.message:String(a)}`)}}u(ae,"renderCard");function Le(t){if(typeof t!="object"||t===null)throw d("a message requires a JSON body { body, tier?, fresh? }");const e=t,a=e.body,n=e.fresh===!0,r=e.tier,o=e.situational_context,i=e.output_schema;if(i!=null&&typeof i!="string")throw d("output_schema must be a JSON schema string");const c=typeof a=="string"&&a.trim()!=="",l=typeof o=="string"&&o.trim()!=="",m=typeof i=="string"&&i.trim()!=="",v=e.situational_card,S=e.context_cards,b=v===void 0?void 0:oe(v,"situational_card");if(S!==void 0&&!Array.isArray(S))throw d("context_cards must be an array of { kind, facts?, body? }");const p=S?.map((N,$)=>oe(N,`context_cards[${$}]`));if(b!==void 0&&typeof o=="string"&&o!=="")throw d("situational_card and situational_context are mutually exclusive");const w=b!==void 0||p!==void 0&&p.length>0;if(!n&&!c&&!l&&!m&&!w)throw d("a message requires a non-empty body (or fresh: true, situational_context, a runtime card, or output_schema)");if(n&&p!==void 0&&p.length>0)throw d("context_cards cannot ride a fresh revive (no inbox entry carries them)");if(r!==void 0&&!De.includes(r))throw d(`invalid tier: ${String(r)} (expected critical|urgent|normal|deferred)`);const f={body:typeof a=="string"?a:""};r!==void 0&&(f.tier=r),n&&(f.fresh=!0),e.reopen===!0&&(f.reopen=!0),typeof o=="string"&&(f.situational_context=o),b!==void 0&&(f.situational_card=b),p!==void 0&&(f.context_cards=p),typeof i=="string"&&(f.output_schema=i),typeof e.from=="string"&&(f.from=e.from);const y=e.delivery;if(y!==void 0&&y!=="interactive")throw d(`invalid delivery: ${String(y)} (expected interactive)`);if(y==="interactive"){if(n||f.situational_context!==void 0||f.output_schema!==void 0)throw d("interactive delivery supports a body, runtime cards, and reopen only (no fresh, situational_context, or output_schema)");if(!c)throw d("interactive delivery requires a non-empty body");if(f.tier==="deferred")throw d("interactive delivery cannot be deferred");f.delivery="interactive"}return f}u(Le,"parseSendBody");function Ue(t){let e;try{e=JSON.parse(t)}catch{throw d("output_schema must be a JSON schema string")}if(typeof e!="object"||e===null||Array.isArray(e))throw d("output_schema must be a JSON schema object");return e}u(Ue,"parseSchema");function Ge(t){return t.split(`
|
|
2
|
+
`)[0].slice(0,120)}u(Ge,"label");function ie(t,e){return e===null?"":Y("reopen-final-report",{report:`${t}/${e}`},"This node previously completed work. Read this final report before acting on the new instruction.")}u(ie,"previousFinalReportCard");async function He(t,e,a){if(a!==null&&a!=="human"&&(await G(t,a))?.type==="node"){const o=await F(t,a);return{actor:o,senderNode:o}}if(a==="human")return{actor:await ve(t,We()),senderNode:null};const n=await K(t,e);return{actor:n.class==="person"?n.person:n.class==="app"?n.app:n.node,senderNode:n.class==="node"?n.node:null}}u(He,"messageActor");async function se(t,e,a,n,r,o){const i=await F(t,a),{actor:c,senderNode:l}=await He(t,e,n),m=r===null?{}:{pointer:r};await _e(t,c,i),l!==null&&l.id!==i.id&&await H(t,l,i,"message",{endsOn:o&&r!==null?`result:${r}`:"final"}),await V(t,{event:"messaged",object:i,actor:c,attrs:{},...m}),l!==null&&await V(t,{event:"sent",object:l,actor:l,attrs:{to:i.id},...m})}u(se,"recordMessage");function Ve(t,e){return new I({error:"deferred_no_natural_cycle",message:`${t} is ${e} with no natural next cycle ahead of it \u2014 a deferred message would never be delivered.`,next:"Use --tier normal, urgent, or critical to wake it now, or --reopen (with a body or --fresh) to re-task it first."})}u(Ve,"deferredNoNaturalCycle");async function Ke(t){if(!await Ce(t))throw new Ee(422,"unprocessable",`node ${t} has no goal/roadmap on disk \u2014 a fresh revive would resume amnesiac.`)}u(Ke,"assertRecoverableForFresh");function Qe(t,e){return t instanceof I?{error:t.payload.error,message:t.payload.message,next:t.payload.next,message_id:e}:t instanceof xe?{error:t.code,message:t.message,message_id:e}:Re(t)?{error:t.code,message:t.message,message_id:e}:{error:"wake_failed",message:"the target could not be woken; see the daemon log",message_id:e}}u(Qe,"wakeFailure");async function Xe(t,e){const a=typeof t.body=="object"&&t.body!==null&&!Array.isArray(t.body)?{...t.body}:t.body;typeof a=="object"&&a!==null&&delete a.from;const n=await ee(t,e,{method:"POST",path:`/v1/nodes/${encodeURIComponent(e)}/messages`,body:a});if(n.kind==="local")return null;if(n.kind==="unknown")throw re(e,n.unreachable);if(n.status>=400)throw te(n.status,n.body);return await k(async r=>{const o=await Te(r,t);if(o===null)return;const i=n.body?.object,c=await ze(r,e,"node",n.machine.id,i);await H(r,o,c,"message",{endsOn:"final"})}),{status:n.status,body:ne(n.body,n.machine)}}u(Xe,"forwardMessage");async function Ye(t){const e=await Ze(t);if(t.principal.class!=="forwarded"||typeof e.body!="object"||e.body===null)return e;const a=await k(async n=>{const r=await F(n,t.params.id);return await ke(n,await K(n,t),r)?await Pe(n,r):{id:r.id,type:r.type,kind:null,name:r.id,owner:null}});return{...e,body:{...e.body,object:a}}}u(Ye,"handleMessage");async function Ze(t){const e=t.params.id,a=await Xe(t,e);if(a!==null)return a;const n=await C(e);if(n===null)throw x(`unknown node: ${e}`,{received:e});const r=Le(t.body),o=r.tier??"normal",i=be(n.profile_id);r.reopen&&!i&&!q(n)&&await ye(e,n);const c=t.principal.class==="forwarded"?await k(async s=>(await Be(s,t))?.id??null):r.from??null;if(c!==null){const s=await C(c);s!==null&&Me(s,"crtr:act")}const l=c===null?null:await k(async s=>{const h=await G(s,c);return h===null?null:(await Ie(s,h))?.home_machine??null}),m=l===null?void 0:`${c} on ${Z(l)}`,v=t.principal.class==="broker"?t.principal.node:null,S=l===null?{}:{from_machine:Z(l)},b=r.body.trim()!=="",p=r.situational_card!==void 0?ae(r.situational_card,"situational_card"):r.situational_context!==void 0?je(r.situational_context.trim()):"",w=p!=="",f=(r.context_cards??[]).map((s,h)=>ae(s,`context_cards[${h}]`)),y=r.output_schema!==void 0&&r.output_schema.trim()!==""?Ue(r.output_schema):null;y!==null&&await Ne(y);let N=!1;const $=u(async s=>{if(!(y===null||N)){if(await Q(e)!==null)throw new I({error:"structured_request_conflict",message:`node ${e} already has a pending structured request`,next:"Wait for the current request to settle before requesting another structured result."});await $e(e,"oneoff",y,s),N=!0}},"ensureSchema");if(r.fresh){const s=r.reopen?await Se(e):null;r.reopen||await M(e),await Ke(e),await $(),w&&await P(e,p),r.reopen&&await E(e,s,v);const h=await L(e,{resume:!1,capacity:"refuse"});return{status:201,body:{node_id:e,delivered:!1,revived:h.launch!==void 0}}}r.delivery==="interactive"&&!r.reopen&&await M(e);let T=!1,_="";if(r.delivery==="interactive"&&r.reopen&&(_=ie(e,await E(e,void 0,v)),T=!0),r.delivery==="interactive"&&await $(),r.delivery==="interactive"&&!i&&!n.run_id&&q(n))try{return w&&await P(e,p),await he(e,r.body,{cards:[..._===""?[]:[_],...w?[p]:[],...f],origin:c==="human"?{type:"human"}:{type:"runtime",kind:"inbox",entries:[{...c===null?{}:{from:c},...m===void 0?{}:{fromName:m},kind:"message",tier:o}]}}),await k(async h=>await se(h,t,e,c,null,!1)),await X(e),{status:201,body:{node_id:e,delivered:!0,revived:!1,delivered_via:"engine"}}}catch(s){if(!(s instanceof U))throw s}const B=u(async()=>{r.reopen||await M(e);const s=ue(16).toString("hex"),h=u(async O=>await se(O,t,e,c,s,y!==null),"withinEnqueue");await $(s),w&&await P(e,p),r.reopen&&!T&&(_=ie(e,await E(e,void 0,v)));const R=[..._===""?[]:[_],...f],W=R.length>0?{cards:R}:{};if(b||y!==null){const O=b?r.body:`A one-off structured-output request has been granted. Submit a result matching the requested schema with the \`submit_result\` tool (\`request_id: "${(await Q(e))?.request_id??"<request-id>"}"\`) before you stop; after it is accepted, continue normally.`;return await D(e,{senderNodeId:c,...m===void 0?{}:{senderName:m},urgency:o,wake:1,kind:"message",messageId:s,withinEnqueue:h,label:Ge(O),bodyJson:{body:O,...S,...w?{situational:!0}:{},...W}})}return await D(e,{senderNodeId:c,...m===void 0?{}:{senderName:m},urgency:o,wake:1,kind:"message",messageId:s,withinEnqueue:h,label:w?"(ambient context updated)":"(context delivered)",bodyJson:{...w?{situational:!0}:{},situationalOnly:!0,...W}})},"deliverImmediate"),g=await u(async()=>{if(o==="deferred"){const s=await ge(e,Ae,B);if(s.kind==="missing")throw x(`unknown node: ${e}`,{received:e});if(s.kind==="terminal")throw Ve(e,s.status);return s.result}return await B()},"deliver")();g.urgency!=="deferred"&&await k(async()=>Oe(e));const j=await C(e);if(j===null)throw x(`unknown node: ${e}`,{received:e});n.frozen_at!==null&&await X(e);let z=!1,J=!1,A;if((r.reopen||j.lifecycle==="terminal"||!await qe(j))&&g.urgency!=="deferred"&&!i&&!q(j))try{const s=await L(e,{resume:!0,capacity:"freeze"});z=s.launch!==void 0,J=s.outcome==="frozen"}catch(s){A=Qe(s,g.messageId),Fe({level:"error",event:"message.wake_failed",node_id:e,error:s,fields:{message_id:g.messageId,error_code:A.error}})}return{status:201,body:{node_id:e,delivered:!0,revived:z,...J?{not_revived_reason:"capacity_frozen"}:{},...A===void 0?{}:{wake_failed:A},delivered_at:g.createdAt,...g.urgency===o?{}:{delivered_tier:g.urgency},...r.delivery==="interactive"?{delivered_via:"inbox"}:{}}}}u(Ze,"handleMessageHere");async function et(t){const e=t.params.id,a=await ee(t,e,{method:"POST",path:`/v1/nodes/${encodeURIComponent(e)}/interrupt`,body:t.body});if(a.kind==="unknown")throw re(e,a.unreachable);if(a.kind==="remote"){if(a.status>=400)throw te(a.status,a.body);return{status:a.status,body:ne(a.body,a.machine)}}const n=await C(e);if(n===null)throw x(`unknown node: ${e}`,{received:e});const r=await pe(e,{senderNodeId:"human",kind:"message"});let o=!1;if(q(n))try{o=await we(e)!=="idle"}catch(c){if(!(c instanceof U))throw c}return{status:200,body:{node_id:e,outcome:o?"aborted_turn":r.length>0?"canceled_pending":"idle",aborted_turn:o,canceled_pending:r.length}}}u(et,"handleInterrupt");function de(t){if(typeof t.body!="object"||t.body===null||Array.isArray(t.body))throw d("mail requires an object body");const e=t.body;if(typeof e.execution_id!="string"||e.execution_id.trim()==="")throw d("execution_id is required");return e}u(de,"mailBody");async function tt(t){const e=de(t),a=e.channel;if(a!=="wake"&&a!=="passive"&&a!=="deferred_run")throw d("channel must be wake, passive, or deferred_run");const n=await le(t.params.id,e.execution_id,a);return{status:200,body:{action:n.action,deliveries:n.deliveries.map(o=>({delivery_id:o.deliveryId,attempts:o.attempts,handoff:o.handoff,entry:{...me(o),seq:o.message.seq}}))}}}u(tt,"handleMailClaim");async function rt(t){const e=de(t);if(!Array.isArray(e.deliveries))throw d("deliveries must be an array");const a=e.deliveries.map(o=>{if(typeof o!="object"||o===null||Array.isArray(o))throw d("each delivery must be an object");const i=o;if(typeof i.delivery_id!="string"||i.delivery_id==="")throw d("delivery_id is required");if(!Number.isSafeInteger(i.attempts)||i.attempts<1)throw d("attempts must be a positive integer");if(i.disposition!=="acknowledged"&&i.disposition!=="released")throw d("disposition must be acknowledged or released");return{delivery_id:i.delivery_id,attempts:i.attempts,disposition:i.disposition}}),n=await fe(t.params.id,e.execution_id,a.map(o=>({deliveryId:o.delivery_id,attempts:o.attempts,disposition:o.disposition})));return{status:200,body:{action:n.action,results:n.results.map(o=>({delivery_id:o.deliveryId,outcome:o.outcome}))}}}u(rt,"handleMailAcknowledge");const Gt=Je([{method:"POST",pattern:"/v1/nodes/:id/mail/claim",handler:tt},{method:"POST",pattern:"/v1/nodes/:id/mail/acknowledge",handler:rt}]),Ht=[{method:"POST",pattern:"/v1/nodes/:id/messages",scope:"crtr:act",handler:Ye},{method:"POST",pattern:"/v1/nodes/:id/interrupt",scope:"crtr:act",handler:et}];export{Gt as brokerMailRoutes,Ye as handleMessage,Ht as messageRoutes};
|