@north-light/crouter 0.3.353 → 0.3.354
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 +35 -25
- package/dist/api/client.js +2 -2
- package/dist/api/dto/broker-ops.d.ts +2 -36
- package/dist/api/dto/canvas.d.ts +8 -13
- package/dist/api/dto/config.d.ts +4 -0
- package/dist/api/dto/delivery.d.ts +61 -0
- package/dist/api/dto/docs.d.ts +133 -0
- package/dist/api/dto/docs.js +1 -0
- package/dist/api/dto/health.d.ts +26 -79
- package/dist/api/dto/node-outcomes.d.ts +1 -3
- package/dist/api/dto/nodes.d.ts +5 -26
- package/dist/api/dto/objects.d.ts +167 -0
- package/dist/api/dto/objects.js +1 -0
- package/dist/api/dto/profiles.d.ts +14 -8
- package/dist/api/dto/reports.d.ts +9 -7
- package/dist/api/dto/reviews.d.ts +9 -3
- package/dist/api/dto/worktree.d.ts +1 -1
- package/dist/api/index.d.ts +0 -1
- package/dist/api/index.js +1 -1
- package/dist/api/routes.d.ts +14 -12
- package/dist/api/routes.js +1 -1
- package/dist/build-root.js +1 -1
- package/dist/builtin-memory/00-runtime-base/00-authoring.md +10 -5
- package/dist/builtin-memory/04-orchestration-kernel.md +7 -7
- package/dist/builtin-memory/05-kinds/advisor/01-orchestrator.md +1 -1
- package/dist/builtin-memory/05-kinds/explore/00-base.md +2 -2
- package/dist/builtin-memory/05-kinds/explore/01-orchestrator.md +2 -2
- package/dist/builtin-memory/crouter-concepts/INDEX.md +2 -2
- package/dist/builtin-memory/crouter-concepts/lifecycle-and-wakes.md +1 -1
- package/dist/builtin-memory/crouter-concepts/memory.md +15 -15
- package/dist/builtin-memory/crouter-concepts/nodes-and-the-canvas.md +1 -1
- package/dist/builtin-memory/crouter-concepts/profiles-kinds-and-modes.md +5 -5
- package/dist/builtin-memory/crouter-concepts/scopes-and-trust.md +1 -1
- package/dist/builtin-memory/crouter-concepts/why-a-daemon.md +1 -1
- package/dist/builtin-memory/crouter-sdk/INDEX.md +2 -2
- package/dist/builtin-memory/crouter-sdk/README.md +5 -6
- package/dist/builtin-memory/crouter-sdk/errors.md +0 -13
- package/dist/builtin-memory/crouter-sdk/guides/README.md +0 -1
- package/dist/builtin-memory/crouter-sdk/guides/event-driven-assistant.md +2 -2
- package/dist/builtin-memory/crouter-sdk/nodes.md +0 -2
- package/dist/builtin-memory/crouter-sdk/resources.md +0 -1
- package/dist/builtin-memory/explore/exploration-doc.md +4 -4
- package/dist/builtin-memory/insights/capture.md +6 -6
- package/dist/builtin-memory/insights/init.md +14 -14
- package/dist/builtin-memory/internal/INDEX.md +4 -4
- package/dist/builtin-memory/internal/agent-shaping.md +20 -20
- package/dist/builtin-memory/internal/examples/imessage-assistant.md +2 -2
- package/dist/builtin-memory/internal/marketplaces.md +2 -2
- package/dist/builtin-memory/internal/memory-loading.md +31 -30
- package/dist/builtin-memory/internal/nodes-and-canvas.md +1 -1
- package/dist/builtin-memory/internal/plugins.md +16 -14
- package/dist/builtin-memory/internal/storage-tiers.md +4 -4
- package/dist/builtin-memory/memory-read-orientation.md +1 -1
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/memory-slash-commands.ts +32 -40
- package/dist/clients/attach/input/controller.js +1 -1
- package/dist/clients/attach/input/ref-autocomplete.js +1 -1
- package/dist/clients/attach/input/titled-editor.js +1 -1
- package/dist/clients/attach/render/chat-view.js +1 -1
- package/dist/clients/attach/render/crtr-output.d.ts +1 -2
- package/dist/clients/attach/render/crtr-output.js +17 -17
- package/dist/clients/attach/render/group-activity.d.ts +8 -8
- package/dist/clients/attach/render/group-activity.js +2 -2
- package/dist/clients/attach/render/group-recap.js +1 -1
- package/dist/clients/attach/render/tool-calls.d.ts +1 -1
- package/dist/clients/attach/session/profile-files.js +1 -1
- package/dist/clients/attach/slash/dispatch.js +1 -1
- package/dist/clients/attach/viewer.js +806 -1553
- package/dist/commands/api-client.d.ts +2 -0
- package/dist/commands/api-client.js +3 -3
- package/dist/commands/canvas/edges.d.ts +2 -0
- package/dist/commands/canvas/edges.js +2 -0
- package/dist/commands/canvas/list.d.ts +4 -0
- package/dist/commands/canvas/list.js +3 -0
- package/dist/commands/canvas/read.d.ts +8 -0
- package/dist/commands/canvas/read.js +5 -0
- package/dist/commands/canvas/search.d.ts +2 -0
- package/dist/commands/canvas/search.js +3 -0
- package/dist/commands/canvas/unwatch.d.ts +2 -0
- package/dist/commands/canvas/unwatch.js +1 -0
- package/dist/commands/canvas/watch.d.ts +3 -0
- package/dist/commands/canvas/watch.js +1 -0
- package/dist/commands/canvas-analytics.js +1 -1
- package/dist/commands/canvas-history/grep.js +4 -4
- package/dist/commands/canvas-history/read.js +2 -2
- package/dist/commands/canvas-history/search.js +7 -7
- package/dist/commands/canvas-history/shared.d.ts +0 -1
- package/dist/commands/canvas-history/shared.js +1 -1
- package/dist/commands/canvas-history/stats.js +2 -2
- package/dist/commands/canvas-history.js +1 -1
- package/dist/commands/canvas.js +1 -1
- package/dist/commands/doc/delete.d.ts +2 -0
- package/dist/commands/doc/delete.js +1 -0
- package/dist/commands/doc/edit.d.ts +2 -0
- package/dist/commands/doc/edit.js +1 -0
- package/dist/commands/doc/history.d.ts +2 -0
- package/dist/commands/doc/history.js +2 -0
- package/dist/commands/doc/lint.d.ts +2 -0
- package/dist/commands/doc/lint.js +2 -0
- package/dist/commands/doc/list.d.ts +2 -0
- package/dist/commands/doc/list.js +1 -0
- package/dist/commands/doc/move.d.ts +2 -0
- package/dist/commands/doc/move.js +1 -0
- package/dist/commands/doc/read.d.ts +2 -0
- package/dist/commands/doc/read.js +1 -0
- package/dist/commands/doc/shared.d.ts +25 -0
- package/dist/commands/doc/shared.js +2 -0
- package/dist/commands/doc/write.d.ts +2 -0
- package/dist/commands/doc/write.js +1 -0
- package/dist/commands/{memory.d.ts → doc.d.ts} +1 -1
- package/dist/commands/doc.js +1 -0
- package/dist/commands/human/review.js +1 -1
- package/dist/commands/node/bash.js +2 -2
- package/dist/commands/node/create.js +1 -1
- package/dist/commands/node/inspect.js +10 -10
- package/dist/commands/node/lifecycle.js +2 -2
- package/dist/commands/node/outcome.js +1 -1
- package/dist/commands/node/subscription.js +1 -1
- package/dist/commands/node-context.js +2 -2
- package/dist/commands/pkg/browse/catalog.js +1 -1
- package/dist/commands/pkg/browse/doc-view.js +1 -1
- package/dist/commands/pkg/browse/model.d.ts +9 -17
- package/dist/commands/pkg/plugin-inspect.js +1 -1
- package/dist/commands/pkg/plugin-manage.d.ts +4 -8
- package/dist/commands/pkg/plugin-manage.js +15 -17
- package/dist/commands/profile/list.js +1 -1
- package/dist/commands/profile/new.js +1 -1
- package/dist/commands/profile/project.js +1 -1
- package/dist/commands/profile/show.js +1 -1
- package/dist/commands/push.js +3 -3
- package/dist/commands/sys/config.js +1 -1
- package/dist/commands/sys/context/admin/actions.d.ts +18 -43
- package/dist/commands/sys/context/admin/actions.js +1 -2
- package/dist/commands/sys/context/admin/detail-panel.d.ts +17 -25
- package/dist/commands/sys/context/admin/detail-panel.js +2 -1
- package/dist/commands/sys/context/admin/docs-panel.d.ts +7 -6
- package/dist/commands/sys/context/admin/docs-panel.js +1 -1
- package/dist/commands/sys/context/admin/list-view.d.ts +12 -12
- package/dist/commands/sys/context/admin/list-view.js +1 -1
- package/dist/commands/sys/context/admin/model.d.ts +96 -69
- package/dist/commands/sys/context/admin/model.js +1 -1
- package/dist/commands/sys/context/admin/rail-panel.d.ts +7 -5
- package/dist/commands/sys/context/admin/rail-panel.js +1 -1
- package/dist/commands/sys/context/admin/read-view.d.ts +10 -14
- package/dist/commands/sys/context/admin/read-view.js +1 -2
- package/dist/commands/sys/context/admin/shell.d.ts +26 -31
- package/dist/commands/sys/context/admin/shell.js +1 -1
- package/dist/commands/sys/context/admin.js +2 -2
- package/dist/commands/sys/context/doc.js +2 -3
- package/dist/commands/sys/context/expose.js +2 -2
- package/dist/commands/sys/context/prompt-review.js +4 -4
- package/dist/commands/sys/context/resolve.d.ts +92 -65
- package/dist/commands/sys/context/resolve.js +7 -9
- package/dist/commands/sys/context.js +1 -1
- package/dist/commands/sys/doctor.js +1 -1
- package/dist/commands/sys/migrate.js +1 -1
- package/dist/commands/sys/panels/profiles-panel.d.ts +3 -1
- package/dist/commands/sys/panels/profiles-panel.js +1 -1
- package/dist/commands/sys/sync-deps.d.ts +6 -11
- package/dist/commands/sys/sync-deps.js +7 -8
- package/dist/commands/sys/sync-project-guidance.js +5 -4
- package/dist/commands/sys/sync-shared.d.ts +41 -4
- package/dist/commands/sys/sync-shared.js +1 -1
- package/dist/commands/sys/sync-skills.js +2 -2
- package/dist/commands/sys/sync.js +1 -1
- package/dist/core/bash-job-supervisor.d.ts +2 -3
- package/dist/core/bash-job-supervisor.js +3 -3
- package/dist/core/bash-jobs.d.ts +0 -5
- package/dist/core/bash-jobs.js +7 -7
- package/dist/core/bootstrap.js +2 -2
- package/dist/core/canvas/canvas.d.ts +6 -50
- package/dist/core/canvas/canvas.js +16 -21
- package/dist/core/canvas/db.d.ts +4 -1
- package/dist/core/canvas/db.js +2 -2
- package/dist/core/canvas/history.d.ts +11 -39
- package/dist/core/canvas/history.js +9 -20
- package/dist/core/canvas/install-id.d.ts +2 -2
- package/dist/core/canvas/install-id.js +1 -1
- package/dist/core/canvas/memory-reads.d.ts +5 -0
- package/dist/core/canvas/memory-reads.js +1 -1
- package/dist/core/canvas/migrations.js +215 -41
- package/dist/core/canvas/node-agent-paths.js +1 -1
- package/dist/core/canvas/node-tokens.js +1 -1
- package/dist/core/canvas/paths.d.ts +0 -4
- package/dist/core/canvas/paths.js +1 -1
- package/dist/core/canvas/remote-canvas-source.d.ts +0 -1
- package/dist/core/canvas/remote-canvas-source.js +1 -1
- package/dist/core/canvas/render-source.d.ts +9 -6
- package/dist/core/canvas/render-source.js +6 -6
- package/dist/core/canvas/sessions.js +2 -2
- package/dist/core/canvas/source.d.ts +6 -0
- package/dist/core/canvas/tree.d.ts +29 -0
- package/dist/core/canvas/tree.js +12 -0
- package/dist/core/canvas/types.d.ts +0 -20
- package/dist/core/command-plugins/bundle.js +1 -1
- package/dist/core/config.d.ts +1 -1
- package/dist/core/conversation-store/listener.js +4 -2
- package/dist/core/feed/feed.d.ts +9 -7
- package/dist/core/feed/feed.js +3 -7
- package/dist/core/feed/inbox.d.ts +3 -5
- package/dist/core/feed/inbox.js +1 -10
- package/dist/core/feed/messages.d.ts +33 -6
- package/dist/core/feed/messages.js +10 -7
- package/dist/core/feed/reports.d.ts +10 -0
- package/dist/core/feed/reports.js +2 -0
- package/dist/core/grants/remove.js +1 -1
- package/dist/core/graph/access.d.ts +24 -0
- package/dist/core/graph/access.js +8 -0
- package/dist/core/graph/bodies.d.ts +6 -0
- package/dist/core/graph/bodies.js +1 -0
- package/dist/core/graph/deletion.d.ts +9 -0
- package/dist/core/graph/deletion.js +5 -0
- package/dist/core/graph/diff.d.ts +4 -0
- package/dist/core/graph/diff.js +4 -0
- package/dist/core/graph/documents.d.ts +160 -0
- package/dist/core/graph/documents.js +7 -0
- package/dist/core/graph/edges.d.ts +24 -0
- package/dist/core/graph/edges.js +1 -0
- package/dist/core/graph/events.d.ts +26 -0
- package/dist/core/graph/events.js +6 -0
- package/dist/core/graph/exposures.d.ts +53 -0
- package/dist/core/graph/exposures.js +4 -0
- package/dist/core/graph/jobs.d.ts +31 -0
- package/dist/core/graph/jobs.js +2 -0
- package/dist/core/graph/names.d.ts +28 -0
- package/dist/core/graph/names.js +3 -0
- package/dist/core/graph/objects.d.ts +55 -0
- package/dist/core/graph/objects.js +9 -0
- package/dist/core/graph/package-docs.d.ts +31 -0
- package/dist/core/graph/package-docs.js +5 -0
- package/dist/core/graph/package-files.d.ts +20 -0
- package/dist/core/graph/package-files.js +2 -0
- package/dist/core/graph/reader.d.ts +21 -0
- package/dist/core/graph/reader.js +3 -0
- package/dist/core/graph/repo-sync/exchange.d.ts +34 -0
- package/dist/core/graph/repo-sync/exchange.js +2 -0
- package/dist/core/graph/repo-sync/identity.d.ts +30 -0
- package/dist/core/graph/repo-sync/identity.js +1 -0
- package/dist/core/graph/repo-sync/index.d.ts +4 -0
- package/dist/core/graph/repo-sync/index.js +1 -0
- package/dist/core/graph/repo-sync/mirror.d.ts +30 -0
- package/dist/core/graph/repo-sync/mirror.js +6 -0
- package/dist/core/graph/repo-sync/ref-format.d.ts +76 -0
- package/dist/core/graph/repo-sync/ref-format.js +2 -0
- package/dist/core/graph/repo-sync/repos.d.ts +17 -0
- package/dist/core/graph/repo-sync/repos.js +3 -0
- package/dist/core/graph/repo-sync/sync.d.ts +42 -0
- package/dist/core/graph/repo-sync/sync.js +2 -0
- package/dist/core/graph/rules.d.ts +26 -0
- package/dist/core/graph/rules.js +3 -0
- package/dist/core/graph/spaces/app.d.ts +3 -0
- package/dist/core/graph/spaces/app.js +1 -0
- package/dist/core/graph/spaces/index.d.ts +19 -0
- package/dist/core/graph/spaces/index.js +1 -0
- package/dist/core/graph/spaces/person.d.ts +5 -0
- package/dist/core/graph/spaces/person.js +2 -0
- package/dist/core/graph/spaces/repo.d.ts +4 -0
- package/dist/core/graph/spaces/repo.js +1 -0
- package/dist/core/graph/types.d.ts +75 -0
- package/dist/core/graph/types.js +1 -0
- package/dist/core/graph/watches.d.ts +62 -0
- package/dist/core/graph/watches.js +18 -0
- package/dist/core/human/feedback-companion.js +1 -1
- package/dist/core/human/requests.d.ts +3 -1
- package/dist/core/human/requests.js +6 -6
- package/dist/core/inspector/model.js +2 -2
- package/dist/core/io.js +5 -5
- package/dist/core/layout-migrate/index.d.ts +24 -1
- package/dist/core/layout-migrate/index.js +4 -4
- package/dist/core/layout-migrate/paths.d.ts +4 -0
- package/dist/core/layout-migrate/paths.js +1 -1
- package/dist/core/layout-migrate/stored-paths.d.ts +7 -0
- package/dist/core/layout-migrate/stored-paths.js +11 -11
- package/dist/core/layout-migrate/stores.d.ts +19 -6
- package/dist/core/layout-migrate/stores.js +3 -4
- package/dist/core/manifest.d.ts +0 -2
- package/dist/core/manifest.js +1 -1
- package/dist/core/{memory/extensions.d.ts → plugin-extensions.d.ts} +9 -10
- package/dist/core/plugin-extensions.js +1 -0
- package/dist/core/preview-registry.d.ts +1 -1
- package/dist/core/preview-registry.js +3 -2
- package/dist/core/profiles/manifest.d.ts +7 -7
- package/dist/core/profiles/manifest.js +1 -1
- package/dist/core/profiles/select.js +3 -3
- package/dist/core/review/birth.js +1 -1
- package/dist/core/review/companion.js +1 -1
- package/dist/core/review/stage.d.ts +12 -1
- package/dist/core/review/stage.js +1 -1
- package/dist/core/review/store.d.ts +2 -0
- package/dist/core/review/store.js +1 -1
- package/dist/core/review/types.d.ts +7 -1
- package/dist/core/runs/events.js +1 -1
- package/dist/core/runs/operations.js +5 -5
- package/dist/core/runs/questions.js +2 -2
- package/dist/core/runtime/bearings-render.d.ts +13 -7
- package/dist/core/runtime/bearings-render.js +12 -12
- package/dist/core/runtime/bearings.d.ts +8 -18
- package/dist/core/runtime/bearings.js +7 -7
- package/dist/core/runtime/broker/daemon-ops.d.ts +7 -12
- package/dist/core/runtime/broker/daemon-ops.js +1 -1
- package/dist/core/runtime/broker/fault-retry.d.ts +2 -0
- package/dist/core/runtime/broker/fault-retry.js +1 -1
- package/dist/core/runtime/broker/frame-dispatch.d.ts +1 -1
- package/dist/core/runtime/broker/frame-memory-refs.d.ts +7 -2
- package/dist/core/runtime/broker/frame-memory-refs.js +1 -1
- package/dist/core/runtime/broker/inbox.d.ts +1 -4
- package/dist/core/runtime/broker/inbox.js +1 -10
- package/dist/core/runtime/broker/rebind.js +1 -1
- package/dist/core/runtime/broker/retry-card-elision.d.ts +7 -0
- package/dist/core/runtime/broker/retry-card-elision.js +1 -0
- package/dist/core/runtime/broker-extension-render.d.ts +0 -13
- package/dist/core/runtime/broker-extension-render.js +2 -4
- package/dist/core/runtime/broker-persona-guidance.js +3 -3
- package/dist/core/runtime/broker-protocol.d.ts +1 -1
- package/dist/core/runtime/broker.js +1 -1
- package/dist/core/runtime/close.d.ts +9 -4
- package/dist/core/runtime/close.js +1 -1
- package/dist/core/runtime/deliver-live.js +1 -1
- package/dist/core/runtime/kickoff.js +17 -19
- package/dist/core/runtime/launch-target.d.ts +7 -0
- package/dist/core/runtime/launch-target.js +1 -1
- package/dist/core/runtime/ledger.d.ts +10 -0
- package/dist/core/runtime/ledger.js +3 -0
- package/dist/core/runtime/lifecycle.js +2 -2
- package/dist/core/runtime/nodes.d.ts +10 -2
- package/dist/core/runtime/nodes.js +1 -1
- package/dist/core/runtime/outcome-document.d.ts +2 -2
- package/dist/core/runtime/outcome-document.js +1 -1
- package/dist/core/runtime/persona.js +2 -2
- package/dist/core/runtime/placement.js +1 -1
- package/dist/core/runtime/promote.d.ts +2 -2
- package/dist/core/runtime/promote.js +1 -1
- package/dist/core/runtime/prospective-inventory-cli.js +2 -2
- package/dist/core/runtime/recycle.js +1 -1
- package/dist/core/runtime/reopen.js +1 -1
- package/dist/core/runtime/revive.js +2 -2
- package/dist/core/runtime/roadmap.d.ts +17 -9
- package/dist/core/runtime/roadmap.js +4 -4
- package/dist/core/runtime/spawn-env.js +1 -1
- package/dist/core/runtime/spawn.d.ts +5 -3
- package/dist/core/runtime/spawn.js +2 -2
- package/dist/core/runtime/structured-output.d.ts +3 -1
- package/dist/core/runtime/structured-output.js +4 -4
- package/dist/core/scope.d.ts +1 -32
- package/dist/core/scope.js +1 -1
- package/dist/core/scoped-state/db.js +2 -1
- package/dist/core/scoped-state/migrate.js +2 -2
- package/dist/core/scoped-state/profiles.d.ts +11 -0
- package/dist/core/scoped-state/profiles.js +1 -1
- package/dist/core/scoped-state/schema.d.ts +1 -1
- package/dist/core/scoped-state/schema.js +7 -5
- package/dist/core/spaces/permissions.d.ts +0 -14
- package/dist/core/spaces/permissions.js +1 -1
- package/dist/core/spaces/stop.d.ts +13 -0
- package/dist/core/spaces/stop.js +2 -2
- package/dist/core/storage/tables.d.ts +1 -1
- package/dist/core/substrate/delivery/corpus.d.ts +21 -0
- package/dist/core/substrate/delivery/corpus.js +3 -0
- package/dist/core/substrate/delivery/deliver.d.ts +76 -0
- package/dist/core/substrate/delivery/deliver.js +6 -0
- package/dist/core/substrate/delivery/listings.d.ts +27 -0
- package/dist/core/substrate/delivery/listings.js +4 -0
- package/dist/core/substrate/delivery/match.d.ts +28 -0
- package/dist/core/substrate/delivery/match.js +1 -0
- package/dist/core/substrate/delivery/plan.d.ts +67 -0
- package/dist/core/substrate/delivery/plan.js +3 -0
- package/dist/core/substrate/delivery/render-boot.d.ts +20 -0
- package/dist/core/substrate/delivery/render-boot.js +54 -0
- package/dist/core/substrate/delivery/render-event.d.ts +47 -0
- package/dist/core/substrate/delivery/render-event.js +6 -0
- package/dist/core/substrate/delivery/sub-persona-menu.d.ts +2 -0
- package/dist/core/substrate/delivery/sub-persona-menu.js +6 -0
- package/dist/core/substrate/delivery/types.d.ts +30 -0
- package/dist/core/substrate/delivery/types.js +0 -0
- package/dist/core/substrate/gate-explain.d.ts +0 -13
- package/dist/core/substrate/gate-explain.js +1 -1
- package/dist/core/substrate/schema.d.ts +11 -139
- package/dist/core/substrate/schema.js +1 -1
- package/dist/core/substrate/subject-fields.d.ts +3 -0
- package/dist/core/substrate/subject.d.ts +2 -1
- package/dist/core/substrate/subject.js +1 -1
- package/dist/daemon/api/handlers/app-profiles.js +1 -1
- package/dist/daemon/api/handlers/bash-jobs.js +1 -2
- package/dist/daemon/api/handlers/broker-ops.js +1 -1
- package/dist/daemon/api/handlers/canvas.js +5 -5
- package/dist/daemon/api/handlers/daemon.js +1 -1
- package/dist/daemon/api/handlers/delivery.d.ts +2 -0
- package/dist/daemon/api/handlers/delivery.js +1 -0
- package/dist/daemon/api/handlers/{memory.d.ts → docs.d.ts} +1 -1
- package/dist/daemon/api/handlers/docs.js +1 -0
- package/dist/daemon/api/handlers/hook-exec.js +1 -1
- package/dist/daemon/api/handlers/messages.js +2 -2
- package/dist/daemon/api/handlers/node-records.js +2 -2
- package/dist/daemon/api/handlers/nodes.js +1 -1
- package/dist/daemon/api/handlers/objects.d.ts +2 -0
- package/dist/daemon/api/handlers/objects.js +5 -0
- package/dist/daemon/api/handlers/package-docs.d.ts +2 -0
- package/dist/daemon/api/handlers/package-docs.js +1 -0
- package/dist/daemon/api/handlers/profiles.js +1 -1
- package/dist/daemon/api/handlers/reports.d.ts +2 -2
- package/dist/daemon/api/handlers/reports.js +4 -4
- package/dist/daemon/api/handlers/reviews.js +1 -1
- package/dist/daemon/api/map.d.ts +2 -2
- package/dist/daemon/api/map.js +2 -2
- package/dist/daemon/api/operations.d.ts +1 -1
- package/dist/daemon/api/operations.js +1 -1
- package/dist/daemon/api/reader.d.ts +17 -0
- package/dist/daemon/api/reader.js +1 -0
- package/dist/daemon/api/server.js +1 -1
- package/dist/daemon/control.d.ts +2 -3
- package/dist/daemon/crtrd.js +8 -6
- package/dist/daemon/fleet.js +4 -4
- package/dist/daemon/reconcilers/bash-deadline.d.ts +11 -1
- package/dist/daemon/reconcilers/bash-deadline.js +2 -1
- package/dist/daemon/reconcilers/broker-supervision.js +4 -4
- package/dist/daemon/reconcilers/live-obligation.js +1 -1
- package/dist/daemon/reconcilers/node-deadline.js +1 -1
- package/dist/daemon/reconcilers/node-lifecycle/freeze-lane.js +1 -1
- package/dist/daemon/reconcilers/storage-maintenance.d.ts +1 -0
- package/dist/daemon/reconcilers/storage-maintenance.js +1 -1
- package/dist/daemon/review/deliver.js +2 -2
- package/dist/daemon/review/finish.js +1 -1
- package/dist/hook-authoring.d.ts +0 -1
- package/dist/hook-authoring.js +3 -3
- package/dist/migrations/004-canvas-documents/apply.d.ts +10 -0
- package/dist/migrations/004-canvas-documents/apply.js +1 -0
- package/dist/migrations/004-canvas-documents/fields.d.ts +24 -0
- package/dist/migrations/004-canvas-documents/fields.js +2 -0
- package/dist/migrations/004-canvas-documents/index.d.ts +16 -0
- package/dist/migrations/004-canvas-documents/index.js +2 -0
- package/dist/migrations/004-canvas-documents/legacy/discover.d.ts +16 -0
- package/dist/migrations/004-canvas-documents/legacy/discover.js +1 -0
- package/dist/migrations/004-canvas-documents/legacy/history.d.ts +5 -0
- package/dist/migrations/004-canvas-documents/legacy/history.js +2 -0
- package/dist/migrations/004-canvas-documents/legacy/nested.d.ts +7 -0
- package/dist/migrations/004-canvas-documents/legacy/nested.js +1 -0
- package/dist/migrations/004-canvas-documents/legacy/parse.d.ts +14 -0
- package/dist/migrations/004-canvas-documents/legacy/parse.js +1 -0
- package/dist/migrations/004-canvas-documents/legacy/types.d.ts +91 -0
- package/dist/migrations/004-canvas-documents/legacy/types.js +0 -0
- package/dist/migrations/004-canvas-documents/legacy-edges.d.ts +6 -0
- package/dist/migrations/004-canvas-documents/legacy-edges.js +18 -0
- package/dist/migrations/004-canvas-documents/plan.d.ts +102 -0
- package/dist/migrations/004-canvas-documents/plan.js +3 -0
- package/dist/migrations/004-canvas-documents/pointers.d.ts +23 -0
- package/dist/migrations/004-canvas-documents/pointers.js +4 -0
- package/dist/migrations/activation.d.ts +9 -18
- package/dist/migrations/activation.js +2 -2
- package/dist/pi-extensions/broker-local.d.ts +2 -2
- package/dist/pi-extensions/broker-local.js +2 -2
- package/dist/pi-extensions/canvas-bash-valve.js +5 -4
- package/dist/pi-extensions/canvas-context-intro.js +2 -2
- package/dist/pi-extensions/canvas-doc-substrate.d.ts +0 -1
- package/dist/pi-extensions/canvas-doc-substrate.js +6 -6
- package/dist/pi-extensions/canvas-inbox-watcher.js +2 -2
- package/dist/pi-extensions/canvas-passive-context.js +1 -1
- package/dist/pi-extensions/canvas-recap.js +2 -2
- package/dist/pi-extensions/canvas-stophook.d.ts +1 -1
- package/dist/pi-extensions/canvas-stophook.js +1 -1
- package/dist/prompts/review.js +3 -3
- package/dist/shared/env.d.ts +5 -0
- package/dist/shared/env.js +1 -1
- package/dist/shared/generated-context.js +2 -10
- package/dist/shared/inbox-entry-body.d.ts +22 -0
- package/dist/shared/inbox-entry-body.js +10 -0
- package/dist/{core/memory → shared}/inline-ref-guidance.d.ts +2 -2
- package/dist/shared/inline-ref-guidance.js +2 -0
- package/dist/types.d.ts +3 -1
- package/docs/cli/memory-and-preferences.md +12 -14
- package/docs/concepts/README.md +1 -1
- package/docs/concepts/lifecycle-and-wakes.md +1 -1
- package/docs/concepts/memory.md +15 -15
- package/docs/concepts/nodes-and-the-canvas.md +1 -1
- package/docs/concepts/profiles-kinds-and-modes.md +5 -5
- package/docs/concepts/scopes-and-trust.md +1 -1
- package/docs/concepts/why-a-daemon.md +1 -1
- package/docs/sdk/README.md +5 -6
- package/docs/sdk/errors.md +0 -13
- package/docs/sdk/guides/README.md +0 -1
- package/docs/sdk/nodes.md +0 -2
- package/docs/sdk/resources.md +0 -1
- package/package.json +2 -2
- package/packages/crouter-identity/package.json +1 -1
- package/runtime.lock.json +11 -11
- package/dist/api/dto/memory.d.ts +0 -171
- package/dist/api/dto/memory.js +0 -1
- package/dist/builtin-memory/crouter-sdk/guides/app-memory.md +0 -73
- package/dist/builtin-memory/crouter-sdk/memory.md +0 -87
- package/dist/commands/broker-permissions.d.ts +0 -2
- package/dist/commands/broker-permissions.js +0 -1
- package/dist/commands/memory/client.d.ts +0 -11
- package/dist/commands/memory/client.js +0 -1
- package/dist/commands/memory/delete.d.ts +0 -1
- package/dist/commands/memory/delete.js +0 -1
- package/dist/commands/memory/edit.d.ts +0 -1
- package/dist/commands/memory/edit.js +0 -21
- package/dist/commands/memory/find.d.ts +0 -1
- package/dist/commands/memory/find.js +0 -1
- package/dist/commands/memory/history.d.ts +0 -1
- package/dist/commands/memory/history.js +0 -5
- package/dist/commands/memory/lint.d.ts +0 -1
- package/dist/commands/memory/lint.js +0 -1
- package/dist/commands/memory/list.d.ts +0 -1
- package/dist/commands/memory/list.js +0 -1
- package/dist/commands/memory/move.d.ts +0 -1
- package/dist/commands/memory/move.js +0 -1
- package/dist/commands/memory/origin.d.ts +0 -1
- package/dist/commands/memory/origin.js +0 -1
- package/dist/commands/memory/read.d.ts +0 -1
- package/dist/commands/memory/read.js +0 -6
- package/dist/commands/memory/shared.d.ts +0 -22
- package/dist/commands/memory/shared.js +0 -1
- package/dist/commands/memory/write.d.ts +0 -1
- package/dist/commands/memory/write.js +0 -13
- package/dist/commands/memory.js +0 -1
- package/dist/commands/node-inspect-artifacts.d.ts +0 -1
- package/dist/commands/node-inspect-artifacts.js +0 -8
- package/dist/core/help/memory-extensions.d.ts +0 -3
- package/dist/core/help/memory-extensions.js +0 -2
- package/dist/core/memory/cli-selector.d.ts +0 -13
- package/dist/core/memory/cli-selector.js +0 -1
- package/dist/core/memory/doc-link-grammar.d.ts +0 -20
- package/dist/core/memory/doc-link-grammar.js +0 -2
- package/dist/core/memory/extensions.js +0 -1
- package/dist/core/memory/history.d.ts +0 -87
- package/dist/core/memory/history.js +0 -6
- package/dist/core/memory/identity.d.ts +0 -65
- package/dist/core/memory/identity.js +0 -1
- package/dist/core/memory/inline-ref-guidance.js +0 -2
- package/dist/core/memory/inline-ref-inventory.d.ts +0 -9
- package/dist/core/memory/inline-ref-inventory.js +0 -1
- package/dist/core/memory/lint.d.ts +0 -163
- package/dist/core/memory/lint.js +0 -2
- package/dist/core/memory/mutation-domain.d.ts +0 -113
- package/dist/core/memory/mutation-domain.js +0 -12
- package/dist/core/memory/mutations.d.ts +0 -74
- package/dist/core/memory/mutations.js +0 -1
- package/dist/core/memory/project-namespace.d.ts +0 -31
- package/dist/core/memory/project-namespace.js +0 -2
- package/dist/core/memory/repository-association.d.ts +0 -31
- package/dist/core/memory/repository-association.js +0 -1
- package/dist/core/memory/service.d.ts +0 -145
- package/dist/core/memory/service.js +0 -2
- package/dist/core/memory/tree.d.ts +0 -39
- package/dist/core/memory/tree.js +0 -1
- package/dist/core/memory-resolver.d.ts +0 -280
- package/dist/core/memory-resolver.js +0 -2
- package/dist/core/nested-stores.d.ts +0 -18
- package/dist/core/nested-stores.js +0 -1
- package/dist/core/runtime/memory.d.ts +0 -3
- package/dist/core/runtime/memory.js +0 -1
- package/dist/core/substrate/frontmatter-validation.d.ts +0 -11
- package/dist/core/substrate/frontmatter-validation.js +0 -1
- package/dist/core/substrate/gate.d.ts +0 -16
- package/dist/core/substrate/gate.js +0 -1
- package/dist/core/substrate/index.d.ts +0 -18
- package/dist/core/substrate/index.js +0 -1
- package/dist/core/substrate/injected-store.d.ts +0 -75
- package/dist/core/substrate/injected-store.js +0 -2
- package/dist/core/substrate/listings.d.ts +0 -28
- package/dist/core/substrate/listings.js +0 -1
- package/dist/core/substrate/memory-events.d.ts +0 -6
- package/dist/core/substrate/memory-events.js +0 -1
- package/dist/core/substrate/on-read-node.d.ts +0 -6
- package/dist/core/substrate/on-read-node.js +0 -1
- package/dist/core/substrate/on-read.d.ts +0 -101
- package/dist/core/substrate/on-read.js +0 -9
- package/dist/core/substrate/plan.d.ts +0 -94
- package/dist/core/substrate/plan.js +0 -1
- package/dist/core/substrate/render-node.d.ts +0 -12
- package/dist/core/substrate/render-node.js +0 -1
- package/dist/core/substrate/render.d.ts +0 -41
- package/dist/core/substrate/render.js +0 -65
- package/dist/core/substrate/session-cache.d.ts +0 -27
- package/dist/core/substrate/session-cache.js +0 -1
- package/dist/core/substrate/surface-match.d.ts +0 -73
- package/dist/core/substrate/surface-match.js +0 -1
- package/dist/daemon/api/handlers/memory.js +0 -5
- package/dist/migrations/001-surfaces-frontmatter.d.ts +0 -2
- package/dist/migrations/001-surfaces-frontmatter.js +0 -1
- package/dist/migrations/002-profile-project-memory.d.ts +0 -2
- package/dist/migrations/002-profile-project-memory.js +0 -1
- package/dist/migrations/003-repository-root-memory-identity/front-door.d.ts +0 -26
- package/dist/migrations/003-repository-root-memory-identity/front-door.js +0 -11
- package/dist/migrations/003-repository-root-memory-identity/index.d.ts +0 -2
- package/dist/migrations/003-repository-root-memory-identity/index.js +0 -5
- package/dist/migrations/003-repository-root-memory-identity/references.d.ts +0 -95
- package/dist/migrations/003-repository-root-memory-identity/references.js +0 -5
- package/dist/migrations/003-repository-root-memory-identity/repository-facts.d.ts +0 -39
- package/dist/migrations/003-repository-root-memory-identity/repository-facts.js +0 -3
- package/dist/migrations/convergent.d.ts +0 -43
- package/dist/migrations/convergent.js +0 -2
- package/dist/migrations/corpus.d.ts +0 -75
- package/dist/migrations/corpus.js +0 -3
- package/dist/migrations/frontmatter-splice.d.ts +0 -15
- package/dist/migrations/frontmatter-splice.js +0 -8
- package/dist/migrations/profile-manifests.d.ts +0 -30
- package/dist/migrations/profile-manifests.js +0 -2
- package/dist/migrations/registry.d.ts +0 -7
- package/dist/migrations/registry.js +0 -1
- package/dist/migrations/runner.d.ts +0 -43
- package/dist/migrations/runner.js +0 -1
- package/dist/migrations/types.d.ts +0 -211
- package/dist/shared/birth-announcement.d.ts +0 -12
- package/dist/shared/birth-announcement.js +0 -1
- package/docs/sdk/guides/app-memory.md +0 -22
- package/docs/sdk/memory.md +0 -85
- /package/dist/{migrations/types.js → api/dto/delivery.js} +0 -0
- /package/dist/{core/memory → shared}/inline-ref-grammar.d.ts +0 -0
- /package/dist/{core/memory → shared}/inline-ref-grammar.js +0 -0
|
@@ -1,96 +1,123 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
3
|
-
import { type
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* or the store/cap resolution, and changing one re-plans every event. */
|
|
1
|
+
import type { DeliveryRuleDTO } from '../../../../api/dto/docs.js';
|
|
2
|
+
import type { NodeConfigSubject } from '../../../../core/substrate/subject-fields.js';
|
|
3
|
+
import { type ContextSnapshot, type PlanRecord, type PlanRule, type PlannedEvent } from '../resolve.js';
|
|
4
|
+
/** The state an agent-engineer dials. Every axis feeds either the rule `if`
|
|
5
|
+
* subject or the reader (cwd → repos, profile → limits), and changing one
|
|
6
|
+
* re-plans every activity. */
|
|
8
7
|
export interface Snapshot {
|
|
9
8
|
kind: string;
|
|
10
9
|
mode: 'base' | 'orchestrator';
|
|
11
10
|
lifecycle: 'terminal' | 'resident';
|
|
12
11
|
hasManager: boolean;
|
|
12
|
+
/** Profile id; null for no profile. */
|
|
13
13
|
profileId: string | null;
|
|
14
14
|
cwd: string;
|
|
15
|
+
/** The live node the page opened on, or null. */
|
|
15
16
|
nodeId: string | null;
|
|
16
17
|
grantee?: string;
|
|
17
18
|
depth: number;
|
|
18
|
-
event:
|
|
19
|
-
/** `read` payload — the file that was read. */
|
|
19
|
+
event: PlannedEvent;
|
|
20
|
+
/** `file-read` payload — the file that was read. */
|
|
20
21
|
file: string;
|
|
21
|
-
/** `
|
|
22
|
+
/** `document-read` payload — the document read. */
|
|
22
23
|
docName: string;
|
|
23
24
|
/** `command` / `pre-command` payload. */
|
|
24
25
|
command: string;
|
|
26
|
+
/** The live node's own cwd and profile: while the snapshot keeps both, the
|
|
27
|
+
* dry run reads the node itself, so its own documents stay in view. */
|
|
28
|
+
seed: {
|
|
29
|
+
cwd: string;
|
|
30
|
+
profileId: string | null;
|
|
31
|
+
} | null;
|
|
25
32
|
}
|
|
26
|
-
|
|
27
|
-
export
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
/** One profile the rail can cycle through. */
|
|
34
|
+
export interface ProfileChoice {
|
|
35
|
+
id: string;
|
|
36
|
+
name: string;
|
|
37
|
+
}
|
|
38
|
+
/** A rule as the dry run returns it: the row fields over JSON. */
|
|
39
|
+
export interface AdminRule extends PlanRule {
|
|
40
|
+
position?: number;
|
|
41
|
+
}
|
|
42
|
+
/** The delivery document as the dry run serializes it (bodies are not carried). */
|
|
43
|
+
export interface AdminDoc {
|
|
44
|
+
object: {
|
|
45
|
+
id: string;
|
|
46
|
+
type: string;
|
|
47
|
+
name: string;
|
|
48
|
+
};
|
|
49
|
+
owner: {
|
|
50
|
+
id: string;
|
|
51
|
+
type: string;
|
|
52
|
+
name: string;
|
|
53
|
+
};
|
|
54
|
+
ownerHandle: string;
|
|
55
|
+
ownNode: boolean;
|
|
56
|
+
/** A package document: an installed plugin's or crtr's own, read-only here. */
|
|
57
|
+
shipped: boolean;
|
|
58
|
+
kind: 'knowledge' | 'preference';
|
|
59
|
+
name: string;
|
|
60
|
+
displayName: string;
|
|
61
|
+
preview: string;
|
|
62
|
+
unlisted: boolean;
|
|
63
|
+
rules: AdminRule[];
|
|
64
|
+
}
|
|
65
|
+
export type AdminRecord = Omit<PlanRecord, 'doc' | 'shadowedBy'> & {
|
|
66
|
+
doc: AdminDoc;
|
|
67
|
+
shadowedBy: AdminDoc | null;
|
|
68
|
+
};
|
|
69
|
+
export interface AdminPlan {
|
|
70
|
+
subject: NodeConfigSubject | null;
|
|
71
|
+
docs: AdminRecord[];
|
|
72
|
+
}
|
|
73
|
+
/** Which payload axis an activity reads, so the rail offers exactly the one
|
|
74
|
+
* field that can make the current activity match anything. */
|
|
75
|
+
export declare function payloadAxisFor(event: PlannedEvent): 'file' | 'docName' | 'command' | null;
|
|
76
|
+
/** The dry-run request a snapshot stands for: the live node as it is (the
|
|
77
|
+
* subject axes as overrides) while cwd and profile are still the node's own,
|
|
78
|
+
* else a node that does not exist, started from the live node when there is one. */
|
|
79
|
+
export declare function contextSnapshotOf(snapshot: Snapshot): ContextSnapshot;
|
|
80
|
+
/** Every activity's plan for one snapshot, fetched from the daemon. The
|
|
81
|
+
* focused activity is asked for first and the rest follow; a plan that lands
|
|
82
|
+
* after the snapshot changed is dropped. */
|
|
39
83
|
export declare class PlanSet {
|
|
40
84
|
private snapshot;
|
|
85
|
+
private readonly onChange;
|
|
41
86
|
private readonly plans;
|
|
42
|
-
|
|
43
|
-
|
|
87
|
+
/** Plans read for the current documents; a plan outside it is stale and is
|
|
88
|
+
* shown only until its replacement lands. */
|
|
89
|
+
private readonly fresh;
|
|
90
|
+
private readonly pending;
|
|
91
|
+
private generation;
|
|
92
|
+
/** The last dry run's refusal, shown in place of the list. */
|
|
93
|
+
error: string | undefined;
|
|
94
|
+
constructor(snapshot: Snapshot, onChange: () => void);
|
|
44
95
|
setSnapshot(snapshot: Snapshot): void;
|
|
45
|
-
/** Drop every plan —
|
|
46
|
-
* document the corpus was read from. */
|
|
96
|
+
/** Drop every plan — the snapshot changed, so none of them describes it. */
|
|
47
97
|
invalidate(): void;
|
|
98
|
+
/** Re-read every plan after a write changed a document they were read from,
|
|
99
|
+
* keeping the old plans on screen until each replacement lands. */
|
|
100
|
+
refresh(): void;
|
|
48
101
|
dispose(): void;
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
/** The plan for one event only if it is already computed — what the rail's
|
|
54
|
-
* EVENTS counts read, so an unwarmed event draws `…` instead of stalling the
|
|
55
|
-
* frame on five extra corpus loads. */
|
|
56
|
-
peek(event: SurfaceEvent): (DeliveryPlan & {
|
|
57
|
-
docs: EffectiveDeliveryRecord[];
|
|
58
|
-
}) | undefined;
|
|
59
|
-
/** Compute one pending event per macrotask, calling back after each so the
|
|
60
|
-
* rail's counts fill in row by row. */
|
|
61
|
-
warm(onProgress: () => void): void;
|
|
62
|
-
private payload;
|
|
102
|
+
peek(event: PlannedEvent): AdminPlan | undefined;
|
|
103
|
+
/** Fetch the focused activity, then every other one. */
|
|
104
|
+
warm(first: PlannedEvent): void;
|
|
105
|
+
private fetch;
|
|
63
106
|
}
|
|
64
|
-
/** What one document does in one
|
|
107
|
+
/** What one document does in one activity. */
|
|
65
108
|
export type DeliveryState = 'delivers' | 'capped' | 'gated' | 'shadowed' | 'silent';
|
|
66
|
-
export declare function deliveryStateOf(record:
|
|
67
|
-
/** The word the list prints for one document's state, and
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
|
|
72
|
-
* its silence has a name the page can act on — `gated` or `shadowed`. */
|
|
73
|
-
export declare function stateLabel(record: DeliveryRecord | undefined, state: DeliveryState): {
|
|
109
|
+
export declare function deliveryStateOf(record: AdminRecord | undefined): DeliveryState;
|
|
110
|
+
/** The word the list prints for one document's state, and its tone. A delivery
|
|
111
|
+
* names the level it arrives at, warning-toned when the profile limit lowered
|
|
112
|
+
* it; a document that does not load prints nothing unless its silence has a
|
|
113
|
+
* name the page can act on — `gated` or `shadowed`. */
|
|
114
|
+
export declare function stateLabel(record: AdminRecord | undefined, state: DeliveryState): {
|
|
74
115
|
text: string;
|
|
75
116
|
tone: 'success' | 'warning' | 'muted';
|
|
76
117
|
};
|
|
77
|
-
export declare
|
|
78
|
-
/** A
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
export declare function surfaceEntryToFlag(entry: SurfaceEntry): string;
|
|
83
|
-
/** One authored entry as a single readable row. */
|
|
84
|
-
export declare function describeSurfaceEntry(entry: SurfaceEntry): string;
|
|
118
|
+
export declare const DELIVER_LEVELS: ("name" | "preview" | "content")[];
|
|
119
|
+
/** A rule back in the shape `PATCH /v1/docs/:ref` takes. */
|
|
120
|
+
export declare function ruleToDTO(rule: AdminRule): DeliveryRuleDTO;
|
|
121
|
+
/** One rule as a single readable row. */
|
|
122
|
+
export declare function describeRule(rule: AdminRule): string;
|
|
85
123
|
export declare function plural(count: number, one: string, many: string): string;
|
|
86
|
-
/** What one document would cost at each rung, in approximate tokens. The
|
|
87
|
-
* renderers decide the payload: `content` emits the body, `preview` emits the
|
|
88
|
-
* catalog entry plus the routing line, `name` emits the entry alone. The
|
|
89
|
-
* estimate is characters ÷ 4 — it ranks documents correctly and totals
|
|
90
|
-
* approximately, and every place it renders says so. */
|
|
91
|
-
export type RungCosts = Record<Rung, number>;
|
|
92
|
-
export declare function rungCostsOf(record: DeliveryRecord): RungCosts;
|
|
93
|
-
/** What this document actually spends in the event the record belongs to. */
|
|
94
|
-
export declare function deliveredCost(record: DeliveryRecord | undefined): number;
|
|
95
|
-
/** Approximate tokens in at most six columns, always marked as an estimate. */
|
|
96
|
-
export declare function formatCost(count: number): string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var
|
|
1
|
+
var a=Object.defineProperty;var i=(e,n)=>a(e,"name",{value:n,configurable:!0});import{resolve as f}from"node:path";import{RUNGS as o,rungRank as r}from"../../../../core/substrate/schema.js";import{PLANNED_EVENTS as u,dryRun as c}from"../resolve.js";function x(e){return e==="file-read"?"file":e==="document-read"?"docName":e==="command"||e==="pre-command"?"command":null}i(x,"payloadAxisFor");function h(e){const n={kind:e.kind,mode:e.mode,lifecycle:e.lifecycle,hasManager:e.hasManager,orchestration:{depth:e.depth}},t=e.seed;if(e.nodeId!==null&&t!==null&&t.cwd===e.cwd&&t.profileId===e.profileId)return{nodeId:e.nodeId,hypothetical:null,override:n,nodeMissing:!1};const d={cwd:e.cwd,profile:e.profileId,...e.grantee===void 0?{}:{grantee:e.grantee},kind:e.kind,mode:e.mode,lifecycle:e.lifecycle,has_manager:e.hasManager,depth:e.depth};return{nodeId:e.nodeId,hypothetical:d,override:{},nodeMissing:!1}}i(h,"contextSnapshotOf");function s(e,n){if(n==="file-read")return e.file===""?void 0:f(e.cwd,e.file);if(n==="document-read")return e.docName===""?void 0:e.docName;if(n==="command"||n==="pre-command")return e.command===""?void 0:e.command}i(s,"payloadOf");class w{static{i(this,"PlanSet")}snapshot;onChange;plans=new Map;fresh=new Set;pending=new Set;generation=0;error;constructor(n,t){this.snapshot=n,this.onChange=t}setSnapshot(n){this.snapshot=n,this.invalidate()}invalidate(){this.plans.clear(),this.refresh()}refresh(){this.generation+=1,this.fresh.clear(),this.pending.clear(),this.error=void 0}dispose(){this.generation+=1}peek(n){return this.plans.get(n)}warm(n){this.fetch(n);for(const t of u)this.fetch(t)}fetch(n){if(this.fresh.has(n)||this.pending.has(n))return;this.pending.add(n);const t=this.generation;c(h(this.snapshot),n,s(this.snapshot,n)).then(({plan:d})=>{t===this.generation&&(this.pending.delete(n),this.plans.set(n,{subject:d.subject,docs:d.docs}),this.fresh.add(n),this.onChange())},d=>{t===this.generation&&(this.pending.delete(n),this.plans.set(n,{subject:null,docs:[]}),this.fresh.add(n),this.error=d instanceof Error?d.message:String(d),this.onChange())})}}function y(e){return e===void 0?"silent":e.shadowedBy!==null?"shadowed":e.finalRung!=="none"?r(e.finalRung)<r(e.authoredRung)?"capped":"delivers":e.authoredRung!=="none"?"capped":e.matchedRule===null&&e.ruleGate!==null&&!e.ruleGate.pass?"gated":"silent"}i(y,"deliveryStateOf");function R(e,n){return n==="gated"?{text:"gated",tone:"muted"}:n==="shadowed"?{text:"shadowed",tone:"muted"}:e===void 0||e.finalRung==="none"?{text:"",tone:"muted"}:{text:e.finalRung,tone:n==="capped"?"warning":"success"}}i(R,"stateLabel");const S=o.filter(e=>e!=="none");function I(e){return{on:e.on,...e.match===void 0?{}:{match:e.match},...e.matchFrontmatter===void 0?{}:{match_frontmatter:e.matchFrontmatter},...e.if===void 0?{}:{if:e.if},deliver:e.deliver}}i(I,"ruleToDTO");function N(e){const n=[e.on];return e.match!==void 0&&e.match.length>0&&n.push(e.match.join(" | ")),e.matchFrontmatter!==void 0&&n.push(`fm ${JSON.stringify(e.matchFrontmatter)}`),e.if!==void 0&&n.push(`if ${JSON.stringify(e.if)}`),`${n.join(" ")} \u2192 ${e.deliver}`}i(N,"describeRule");function E(e,n,t){return`${e} ${e===1?n:t}`}i(E,"plural");export{S as DELIVER_LEVELS,w as PlanSet,h as contextSnapshotOf,y as deliveryStateOf,N as describeRule,x as payloadAxisFor,E as plural,I as ruleToDTO,R as stateLabel};
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import { type Snapshot } from './model.js';
|
|
3
|
-
import type
|
|
1
|
+
import { type PlannedEvent } from '../resolve.js';
|
|
2
|
+
import { type ProfileChoice, type Snapshot } from './model.js';
|
|
3
|
+
import { type Filters } from './list-view.js';
|
|
4
|
+
type SurfaceEvent = PlannedEvent;
|
|
4
5
|
export type AxisId = 'event' | 'payload' | 'kind' | 'mode' | 'lifecycle' | 'manager' | 'depth' | 'profile' | 'cwd';
|
|
5
6
|
export interface Axis {
|
|
6
7
|
id: AxisId;
|
|
@@ -31,12 +32,12 @@ export declare function axesOf(snapshot: Snapshot, profileName: string): Axis[];
|
|
|
31
32
|
export declare function payloadRowOf(snapshot: Snapshot): Axis | undefined;
|
|
32
33
|
/** Cycle one enum axis, returning the changed snapshot. A typed axis is never
|
|
33
34
|
* cycled — the shell opens a field for it instead. */
|
|
34
|
-
export declare function cycleAxis(snapshot: Snapshot, id: AxisId, delta: number): Snapshot;
|
|
35
|
+
export declare function cycleAxis(snapshot: Snapshot, id: AxisId, delta: number, profiles?: readonly ProfileChoice[]): Snapshot;
|
|
35
36
|
/** Apply a typed axis's submitted value. */
|
|
36
37
|
export declare function setTypedAxis(snapshot: Snapshot, id: AxisId, value: string): Snapshot;
|
|
37
38
|
/** The value a typed axis's field is seeded with. */
|
|
38
39
|
export declare function typedAxisValue(snapshot: Snapshot, id: AxisId): string;
|
|
39
|
-
/** One
|
|
40
|
+
/** One activity as the rail states it: how many documents it delivers, and
|
|
40
41
|
* whether it is the one the page is planning. `delivers` is undefined while
|
|
41
42
|
* that event's plan is still warming. */
|
|
42
43
|
export interface EventRow {
|
|
@@ -80,3 +81,4 @@ export declare function renderRail(opts: {
|
|
|
80
81
|
matched: number;
|
|
81
82
|
total: number;
|
|
82
83
|
}): string[];
|
|
84
|
+
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var _=Object.defineProperty;var c=(e,
|
|
1
|
+
var _=Object.defineProperty;var c=(e,n)=>_(e,"name",{value:n,configurable:!0});import{resolve as L}from"node:path";import{truncateToWidth as $}from"@earendil-works/pi-tui";import{padAnsi as v,theme as s}from"../../../../core/tui/panel.js";import{tildify as q}from"../../../../core/fs-utils.js";import{KINDS as C,RUNGS as D}from"../../../../core/substrate/schema.js";import{PLANNED_EVENTS as P}from"../resolve.js";import{payloadAxisFor as b}from"./model.js";import{OWNER_TYPES as G}from"./list-view.js";const K=["any",...D.filter(e=>e!=="none"),"silent"],V=["any",...G],W=["any",...C],B=["any","delivering","gated","shadowed","no-rule"];function w(e){return[{id:"rung",label:"rung",value:e.rung,typed:!1},{id:"origin",label:"owner",value:e.origin,typed:!1},{id:"kind",label:"doc kind",value:e.kind,typed:!1},{id:"state",label:"state",value:e.state,typed:!1},{id:"query",label:"search",value:e.query===""?"any":e.query,typed:!0}]}c(w,"facetsOf");function ee(e,n,a){const i=c((t,r)=>{const f=t.indexOf(r);return t[(Math.max(0,f)+a+t.length)%t.length]},"step");switch(n){case"rung":return{...e,rung:i(K,e.rung)};case"origin":return{...e,origin:i(V,e.origin)};case"kind":return{...e,kind:i(W,e.kind)};case"state":return{...e,state:i(B,e.state)};case"query":return e}}c(ee,"cycleFacet");function ne(e,n){return[{id:"kind",label:"kind",value:e.kind,typed:!0},{id:"mode",label:"mode",value:e.mode,typed:!1},{id:"lifecycle",label:"lifecycle",value:e.lifecycle,typed:!1},{id:"manager",label:"manager",value:e.hasManager?"yes":"no",typed:!1},{id:"depth",label:"depth",value:String(e.depth),typed:!1},{id:"profile",label:"profile",value:n,typed:!1},{id:"cwd",label:"cwd",value:q(e.cwd),typed:!0}]}c(ne,"axesOf");function te(e){const n=b(e.event);if(n===null)return;const a=n==="file"?e.file:n==="docName"?e.docName:e.command;return{id:"payload",label:n==="file"?"file":n==="docName"?"doc":"command",value:a===""?"(none \u2014 nothing matches)":a,typed:!0}}c(te,"payloadRowOf");function ie(e,n,a,i=[]){const t=c((r,f)=>{const p=r.indexOf(f);return r[(Math.max(0,p)+a+r.length)%r.length]},"step");switch(n){case"event":return{...e,event:t(P,e.event)};case"mode":{const r=t(["base","orchestrator"],e.mode);return{...e,mode:r,lifecycle:r==="orchestrator"?"resident":"terminal"}}case"lifecycle":return{...e,lifecycle:t(["terminal","resident"],e.lifecycle)};case"manager":return{...e,hasManager:!e.hasManager};case"depth":return{...e,depth:Math.max(0,e.depth+a)};case"profile":{const r=[null,...i.map(f=>f.id)];return{...e,profileId:t(r,e.profileId)}}default:return e}}c(ie,"cycleAxis");function de(e,n,a){const i=a.trim();if(n==="kind")return i===""?e:{...e,kind:i};if(n==="cwd")return i===""?e:{...e,cwd:L(i)};if(n!=="payload")return e;const t=b(e.event);return t==="file"?{...e,file:i}:t==="docName"?{...e,docName:i}:t==="command"?{...e,command:i}:e}c(de,"setTypedAxis");function re(e,n){if(n==="kind")return e.kind;if(n==="cwd")return e.cwd;const a=b(e.event);return a==="file"?e.file:a==="docName"?e.docName:a==="command"?e.command:""}c(re,"typedAxisValue");const M=10;function ae(e){return e.kind==="event"?`event:${e.event.event}`:e.kind==="axis"?`axis:${e.axis.id}`:`facet:${e.facet.id}`}c(ae,"railRowKey");function ce(e){return e===void 0?"documents":e.kind==="event"?"dial":e.kind==="axis"?e.axis.typed?"edit":"documents":e.facet.typed?"edit":"documents"}c(ce,"railEnter");function le(e,n,a,i){const t=[];for(const r of e)t.push({kind:"event",event:r}),r.dialled&&n!==void 0&&t.push({kind:"axis",axis:n,indent:!0});for(const r of a)t.push({kind:"axis",axis:r,indent:!1});for(const r of i)t.push({kind:"facet",facet:r});return t}c(le,"railRowsOf");function oe(e){const{rows:n,index:a,width:i,height:t,focused:r,matched:f,total:p}=e,u=[];let N=0;const E=c((d,l,o,g,m)=>{d===a&&(N=u.length),d===a&&r?u.push(s.bg("selectedBg",v(o,i))):d===a||l?u.push(`${s.fg("accent","\u258C")}${v(s.fg("accent",m),i-1)}`):u.push(v(g,i))},"push"),S=c((d,l,o,g)=>{const m=Math.max(1,M-g),y=Math.max(1,i-M-2),x=`${" ".repeat(g)}${v($(l,m),m)}`,k=$(o,y);E(d,!1,` ${x} ${k}`,` ${s.fg("dim",x)} ${k}`,`${x} ${k}`)},"labelled"),O=c((d,l)=>{const o=l.delivers===void 0?"\u2026":String(l.delivers),g=l.delivers===void 0||l.delivers===0?"dim":"success",m=Math.max(1,i-2-o.length),y=v($(l.event,m),m),x=s.fg(g,o);E(d,l.dialled,` ${y} ${x}`,` ${s.fg("dim",y)} ${x}`,`${y} ${o}`)},"evented"),R=c(d=>d.kind==="facet"?"filters":d.kind==="event"||d.indent?"events":"snapshot","sectionOf"),I={events:" EVENTS",snapshot:" SNAPSHOT",filters:` FILTERS \xB7 ${f} of ${p}`};let T;n.forEach((d,l)=>{const o=R(d);o!==T&&(u.length>0&&u.push(""),u.push(s.fg("dim",I[o]),""),T=o),d.kind==="event"?O(l,d.event):d.kind==="axis"?S(l,d.axis.label,d.axis.value,d.indent?2:0):S(l,d.facet.label,d.facet.value,0)});const F=Math.max(0,u.length-t),A=Math.min(Math.max(0,N-Math.floor(t/2)),F),h=u.slice(A,A+t);for(;h.length<t;)h.push("");return h}c(oe,"renderRail");export{ne as axesOf,ie as cycleAxis,ee as cycleFacet,w as facetsOf,te as payloadRowOf,ce as railEnter,ae as railRowKey,le as railRowsOf,oe as renderRail,de as setTypedAxis,re as typedAxisValue};
|
|
@@ -1,31 +1,27 @@
|
|
|
1
|
-
import { type
|
|
2
|
-
import type { EffectiveDeliveryRecord } from '../resolve.js';
|
|
1
|
+
import { type PlannedEvent } from '../resolve.js';
|
|
3
2
|
import type { NodeConfigSubject } from '../../../../core/substrate/subject-fields.js';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export interface CapOwner {
|
|
7
|
-
path: string;
|
|
8
|
-
memory: Rung;
|
|
9
|
-
}
|
|
3
|
+
import { type AdminRecord } from './model.js';
|
|
4
|
+
type SurfaceEvent = PlannedEvent;
|
|
10
5
|
/** What the read face needs beyond the record: the event it is judged against,
|
|
11
6
|
* the sibling events' records, and the two facts the shell resolves. */
|
|
12
7
|
export interface DossierContext {
|
|
13
8
|
event: SurfaceEvent;
|
|
14
|
-
records: Map<SurfaceEvent,
|
|
15
|
-
capOwner: CapOwner | null;
|
|
9
|
+
records: Map<SurfaceEvent, AdminRecord>;
|
|
16
10
|
readOnly: boolean;
|
|
11
|
+
/** The body, once the reader opened it — the plan carries none. */
|
|
12
|
+
body: string | undefined;
|
|
17
13
|
/** The configuration every record here was planned against — what a failed
|
|
18
14
|
* gate is explained against. Null when there is no node config at all. */
|
|
19
15
|
subject: NodeConfigSubject | null;
|
|
20
16
|
}
|
|
21
17
|
/** The resting card, and — when `bodyOpen` — the document's own text beneath
|
|
22
18
|
* it in place of the affordance line that names it. */
|
|
23
|
-
export declare function renderDossierRead(record:
|
|
19
|
+
export declare function renderDossierRead(record: AdminRecord, context: DossierContext, width: number, bodyOpen: boolean): string[];
|
|
24
20
|
/** Identity and routing — what the edit face keeps overhead of its field list,
|
|
25
21
|
* because they are the context a field is being edited against. */
|
|
26
|
-
export declare function renderDossierHeader(record:
|
|
22
|
+
export declare function renderDossierHeader(record: AdminRecord, context: DossierContext, width: number): string[];
|
|
27
23
|
/** Does it load here, what does it cost, and — only when there is one — what
|
|
28
24
|
* interfered. The three questions the old verdict, cost table and event grid
|
|
29
25
|
* each answered a piece of. */
|
|
30
|
-
export declare function renderDossierDelivery(record:
|
|
31
|
-
export
|
|
26
|
+
export declare function renderDossierDelivery(record: AdminRecord, context: DossierContext, width: number): string[];
|
|
27
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
var
|
|
2
|
-
`).length}f(K,"bodyLineCount");function r(n){return n.map(e=>`${p}${e}`)}f(r,"indent");const b=`${p} `;function Q(n,e){const t=Math.max(1,e-2);if(g(n)<=t)return[`${b}${n}`];const s=n.indexOf(j);return s===-1?l(n,t).map(u=>`${b}${u}`):[...l(n.slice(0,s),t).map(u=>`${b}${u}`),...l(n.slice(s+1),Math.max(1,t-2)).map(u=>`${b} ${u}`)]}f(Q,"clauseRows");function l(n,e){const t=n.trim();return t===""?[]:t.split(/\s+/).some(s=>g(s)>e)?W(t,e):F(t,e)}f(l,"wrapped");export{K as bodyLineCount,J as renderDossierDelivery,q as renderDossierHeader,an as renderDossierRead};
|
|
1
|
+
var T=Object.defineProperty;var r=(e,s)=>T(e,"name",{value:s,configurable:!0});import{getMarkdownTheme as A}from"@earendil-works/pi-coding-agent";import{Markdown as L,visibleWidth as g,wrapTextWithAnsi as x}from"@earendil-works/pi-tui";import{theme as i,wrapText as k}from"../../../../core/tui/panel.js";import{rungRank as M}from"../../../../core/substrate/schema.js";import{PLANNED_EVENTS as H}from"../resolve.js";import{CLAUSE_SEPARATOR as O,explainGate as _,formatClause as P}from"../../../../core/substrate/gate-explain.js";import{ownerTypeOf as S}from"./list-view.js";import{plural as j}from"./model.js";const B="\u2298",l=" ";function X(e,s,n,t){const o=Math.max(1,n-l.length),u=C(e,s,n);u.push(...I(e,s,n));const p=s.body;return t&&p!==void 0?(u.push(""),u.push(...d(new L(p,0,0,A()).render(o)))):t?u.push("",...v("reading the body\u2026",n)):u.push("",...v("enter read the body",n)),u}r(X,"renderDossierRead");function v(e,s){const n=Math.max(1,s-l.length);return g(e)<=n?[`${l}${i.fg("dim",e)}`]:d(f(e,n)).map(t=>i.fg("dim",t))}r(v,"dim");function C(e,s,n){const t=Math.max(1,n-l.length),o=G(e,s,t);o.push("",i.fg("dim",`${l}PREVIEW`));const u=e.doc.preview.trim();return o.push(...u===""?[i.fg("dim",`${l}Not declared.`)]:d(f(u,t))),o}r(C,"renderDossierHeader");function G(e,s,n){const t=`${e.doc.kind} \xB7 ${S(e)} ${e.doc.ownerHandle}${e.doc.unlisted?" \xB7 unlisted":""}${s.readOnly?` ${B}`:""}`,o=f(e.doc.displayName,n),u=o.map(h=>`${l}${i.fg("accent",i.bold(h))}`),p=o[o.length-1]??"",$=n-g(p)-g(t);return $>=2?(u[u.length-1]=`${l}${i.fg("accent",i.bold(p))}${" ".repeat($)}${i.fg("dim",t)}`,u):(u.push(...f(t,n).map(h=>`${l}${" ".repeat(Math.max(0,n-g(h)))}${i.fg("dim",h)}`)),u)}r(G,"identityLines");function I(e,s,n){const t=Math.max(1,n-l.length),o=e.finalRung!=="none",u=M(e.cappedRung)<M(e.authoredRung),p=o?e.finalRung:"nothing",$=o?u?"warning":"success":"dim",h=`${s.event} \u2192 `,m=[""];g(h)+g(p)<=t?m.push(`${l}${i.fg("dim",h)}${i.fg($,p)}`):(m.push(...d(f(h,t)).map(a=>i.fg("dim",a))),m.push(...d(f(p,t)).map(a=>i.fg($,a))));const w=r(a=>{m.push(...d(f(a,t)).map(c=>i.fg("warning",c)))},"warn"),b=e.ruleGate;if(e.matchedRule===null&&b!==null&&!b.pass){const a=e.authoredRules.find(R=>!R.gate.pass)?.rule.if,c=a===void 0||s.subject===null?[]:_(a,s.subject);if(c.length===0)w(`rule if fails: ${b.reason}`);else{const R=c.every(E=>E.failure==="mismatch");w(R?"rule if fails":"rule if never matches");for(const E of c)m.push(...W(P(E),t).map(D=>i.fg("warning",D)));R&&m.push(...v("dial the snapshot at left to load it here",n))}}else e.matchedRule===null&&e.authoredRules.length>0&&m.push(...d(f(`${j(e.authoredRules.length,"rule","rules")} for this activity, none matched`,t)).map(a=>i.fg("dim",a)));u&&w(`limited to ${e.cappedRung} by the profile\u2019s delivery limit for ${e.doc.ownerHandle} (authored ${e.authoredRung})`),e.shadowedBy!==null&&m.push(...d(f(`shadowed by ${e.shadowedBy.ownerHandle}/${e.shadowedBy.name}`,t)).map(a=>i.fg("muted",a)));const N=H.filter(a=>a!==s.event).map(a=>({event:a,held:s.records.get(a)})).filter(a=>a.held!==void 0&&a.held.finalRung!=="none").map(a=>`${a.event} \u2192 ${a.held.finalRung}`);return N.length>0&&m.push(...d(f(`also ${N.join(" \xB7 ")}`,t)).map(a=>i.fg("dim",a))),m}r(I,"renderDossierDelivery");function d(e){return e.map(s=>`${l}${s}`)}r(d,"indent");const y=`${l} `;function W(e,s){const n=Math.max(1,s-2);if(g(e)<=n)return[`${y}${e}`];const t=e.indexOf(O);return t===-1?f(e,n).map(o=>`${y}${o}`):[...f(e.slice(0,t),n).map(o=>`${y}${o}`),...f(e.slice(t+1),Math.max(1,n-2)).map(o=>`${y} ${o}`)]}r(W,"clauseRows");function f(e,s){const n=e.trim();return n===""?[]:n.split(/\s+/).some(t=>g(t)>s)?x(n,s):k(n,s)}r(f,"wrapped");export{I as renderDossierDelivery,C as renderDossierHeader,X as renderDossierRead};
|
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
import { type Component, type Focusable, type TUI } from '@earendil-works/pi-tui';
|
|
2
2
|
import { type BindingId, type BindingResolution } from '../../../../core/keybindings/index.js';
|
|
3
|
-
import { type
|
|
4
|
-
import { type Snapshot } from './model.js';
|
|
3
|
+
import { type ProfileChoice, type Snapshot } from './model.js';
|
|
5
4
|
export interface AdminResult {
|
|
6
5
|
edited: string[];
|
|
7
|
-
capChanges: CapChange[];
|
|
8
6
|
}
|
|
9
7
|
export declare class ContextAdminShell implements Component, Focusable {
|
|
10
8
|
private readonly tui;
|
|
11
9
|
private readonly terminalRows;
|
|
12
10
|
private readonly bindings;
|
|
13
11
|
private readonly suspendForChild;
|
|
12
|
+
private readonly profiles;
|
|
14
13
|
private snapshot;
|
|
15
14
|
private plans;
|
|
16
15
|
private zone;
|
|
@@ -25,11 +24,12 @@ export declare class ContextAdminShell implements Component, Focusable {
|
|
|
25
24
|
private notice;
|
|
26
25
|
private busy;
|
|
27
26
|
private readonly edited;
|
|
28
|
-
|
|
27
|
+
/** Bodies the reader opened, by object id — the plan carries none. */
|
|
28
|
+
private readonly bodies;
|
|
29
29
|
private _focused;
|
|
30
30
|
onCancel?: () => void;
|
|
31
31
|
onSubmit?: (result: AdminResult) => void;
|
|
32
|
-
constructor(seed: Snapshot, tui: TUI, terminalRows: () => number, bindings: BindingResolution<BindingId>, suspendForChild: () => () => void);
|
|
32
|
+
constructor(seed: Snapshot, tui: TUI, terminalRows: () => number, bindings: BindingResolution<BindingId>, suspendForChild: () => () => void, profiles: readonly ProfileChoice[]);
|
|
33
33
|
set focused(value: boolean);
|
|
34
34
|
get focused(): boolean;
|
|
35
35
|
/** Required by `Component`. Nothing is cached between frames: a plan can land
|
|
@@ -39,6 +39,7 @@ export declare class ContextAdminShell implements Component, Focusable {
|
|
|
39
39
|
/** Recompute the focused event's plan, refresh the panels from it, and let
|
|
40
40
|
* the remaining events fill in behind it. */
|
|
41
41
|
private rebuild;
|
|
42
|
+
private refreshRows;
|
|
42
43
|
/** A filter never re-plans: it is a question about the plan already computed,
|
|
43
44
|
* which is what keeps a facet change instant on a corpus this size. */
|
|
44
45
|
private setFilters;
|
|
@@ -66,6 +67,7 @@ export declare class ContextAdminShell implements Component, Focusable {
|
|
|
66
67
|
/** The rail's rows: the events, then the snapshot axes, then the filter
|
|
67
68
|
* facets, so one cursor and one gesture drive all three sections. */
|
|
68
69
|
private railRows;
|
|
70
|
+
private profileName;
|
|
69
71
|
private handleRail;
|
|
70
72
|
private handleDocs;
|
|
71
73
|
private openSearch;
|
|
@@ -73,20 +75,20 @@ export declare class ContextAdminShell implements Component, Focusable {
|
|
|
73
75
|
* modal over the rows it is selecting. */
|
|
74
76
|
private handleSearch;
|
|
75
77
|
private handleDetail;
|
|
76
|
-
/** Put the focused document's
|
|
77
|
-
* the document that is misbehaving can
|
|
78
|
-
* retyping it off the screen.
|
|
79
|
-
|
|
80
|
-
* it against home, which is only read. */
|
|
81
|
-
private yankPath;
|
|
78
|
+
/** Put the focused document's object id on the clipboard, so a reader who
|
|
79
|
+
* spotted the document that is misbehaving can read, edit, or pass it along
|
|
80
|
+
* (`crtr canvas read <id>`) without retyping it off the screen. */
|
|
81
|
+
private yankId;
|
|
82
82
|
/** The resting face: reading, and the two gestures that leave it. */
|
|
83
83
|
private handleRead;
|
|
84
|
+
/** Open the body in place, fetching it the first time it is opened. */
|
|
85
|
+
private openBody;
|
|
84
86
|
/** The field list. Every write gesture is resolved before it is started, so a
|
|
85
87
|
* read-only document refuses at the keypress rather than after a modal. */
|
|
86
88
|
private handleEdit;
|
|
87
89
|
/** The write one edit-face key starts, or undefined when the key writes
|
|
88
90
|
* nothing. `document` marks the writes a read-only document refuses — the
|
|
89
|
-
*
|
|
91
|
+
* delivery limit is not one of them; it lives on the profile. */
|
|
90
92
|
private writeGesture;
|
|
91
93
|
/** The refusal a read-only document owes the write just attempted, carried by
|
|
92
94
|
* the same footer channel every other write outcome uses. */
|
|
@@ -96,23 +98,20 @@ export declare class ContextAdminShell implements Component, Focusable {
|
|
|
96
98
|
private activate;
|
|
97
99
|
private get record();
|
|
98
100
|
private apply;
|
|
99
|
-
private
|
|
100
|
-
private
|
|
101
|
-
/**
|
|
102
|
-
* in the order the
|
|
103
|
-
private
|
|
104
|
-
private
|
|
105
|
-
private
|
|
106
|
-
private editRouting;
|
|
107
|
-
private editShortForm;
|
|
101
|
+
private cycleRuleLevel;
|
|
102
|
+
private removeRule;
|
|
103
|
+
/** Activity, then match, then level — the three fields a valid rule needs,
|
|
104
|
+
* asked in the order the rule reads them. */
|
|
105
|
+
private composeRule;
|
|
106
|
+
private flipUnlisted;
|
|
107
|
+
private editPreview;
|
|
108
108
|
/** The one write that leaves the page: the terminal goes to $EDITOR and comes
|
|
109
|
-
* back repainted, and the buffer that returns is saved through
|
|
110
|
-
*
|
|
109
|
+
* back repainted, and the buffer that returns is saved through the same
|
|
110
|
+
* route `crtr doc edit` uses. */
|
|
111
111
|
private editBody;
|
|
112
112
|
private editMove;
|
|
113
|
-
/**
|
|
114
|
-
|
|
115
|
-
private editCap;
|
|
113
|
+
/** Delivery limits belong to the profile, per owner — not to the document. */
|
|
114
|
+
private explainLimit;
|
|
116
115
|
private openAxisField;
|
|
117
116
|
private close;
|
|
118
117
|
private handleModal;
|
|
@@ -122,9 +121,5 @@ export declare class ContextAdminShell implements Component, Focusable {
|
|
|
122
121
|
* opens its dossier. */
|
|
123
122
|
private docsGesture;
|
|
124
123
|
render(width: number): string[];
|
|
125
|
-
/** What the delivering documents spend on this event. An estimate, and a
|
|
126
|
-
* floor on the rendered prompt: boot wraps these documents in its own intro
|
|
127
|
-
* prose and catalog tree. */
|
|
128
|
-
private costMeta;
|
|
129
124
|
}
|
|
130
|
-
export declare function runContextAdmin(seed: Snapshot): Promise<AdminResult | undefined>;
|
|
125
|
+
export declare function runContextAdmin(seed: Snapshot, profiles: readonly ProfileChoice[]): Promise<AdminResult | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var O=Object.defineProperty;var h=(a,e)=>O(a,"name",{value:e,configurable:!0});import{Input as _,matchesKey as i,truncateToWidth as v,visibleWidth as b}from"@earendil-works/pi-tui";import{formatGesture as G,matchesPiTuiInput as q}from"../../../../core/keybindings/index.js";import{writeClipboardTextEverywhere as T}from"../../../../core/clipboard-text.js";import{shortPath as W}from"../../../../core/inspector/model.js";import{runTuiPage as N}from"../../../../core/tui/page-host.js";import{PAGE_CHROME_ROWS as U,columns as x,framed as j,pageFrame as H,theme as d}from"../../../../core/tui/panel.js";import{RUNGS as R,SURFACE_EVENTS as g,SURFACE_RUNGS as y}from"../../../../core/substrate/schema.js";import{profileNameFor as P}from"../../../../core/substrate/subject-fields.js";import{editBufferInEditor as B}from"../../../../clients/inbox/review/roundtrip.js";import{capOwnerFor as k,moveDoc as L,readBody as V,readOnlyReason as I,toggleFlag as J,writeBody as K,writeCap as X,writeGate as Y,writeRoutingLine as Q,writeShortForm as Z,writeSurfaces as w}from"./actions.js";import{axesOf as ee,cycleAxis as $,cycleFacet as te,facetsOf as se,payloadRowOf as ie,railEnter as M,railRowKey as S,railRowsOf as ne,renderRail as re,setTypedAxis as oe,typedAxisValue as he}from"./rail-panel.js";import{ContextDetailPanel as le}from"./detail-panel.js";import{ContextDocsPanel as de,buildRows as D}from"./docs-panel.js";import{NO_FILTERS as ce,costTotals as ae}from"./list-view.js";import{PlanSet as ue,formatCost as C,plural as E}from"./model.js";const u=26,fe=86,pe=112,F=6,me=48,ge=100,ye=.45;function be(a){const e=Math.max(1,a-u-F);return Math.max(me,Math.min(ge,Math.floor(e*ye)))}h(be,"docsWidthFor");class xe{static{h(this,"ContextAdminShell")}tui;terminalRows;bindings;suspendForChild;snapshot;plans;zone="rail";railIndex=0;filters=ce;rows=[];searching=!1;docs;detail=new le;modal;notice;busy;edited=new Set;capChanges=[];_focused=!1;onCancel;onSubmit;constructor(e,t,s,n,r){this.tui=t,this.terminalRows=s,this.bindings=n,this.suspendForChild=r,this.snapshot=e,this.plans=new ue(e),this.docs=new de(()=>this.tui.requestRender()),this.rebuild()}set focused(e){this._focused=e}get focused(){return this._focused}invalidate(){}dispose(){this.plans.dispose()}rebuild(){this.plans.plan(this.snapshot.event),this.rows=D(this.plans,this.snapshot.event),this.docs.setRows(this.rows,this.snapshot.event),this.syncDetail(),this.plans.warm(()=>{this.rows=D(this.plans,this.snapshot.event),this.docs.setRows(this.rows,this.snapshot.event),this.syncDetail(),this.tui.requestRender()})}setFilters(e){this.filters=e,this.docs.setFilters(e),this.syncDetail()}syncDetail(){const e=this.docs.selected,t=e===void 0?null:k(e.anchor,this.snapshot.profileId),s=e===void 0?null:I(e.anchor,this.snapshot.profileId);this.detail.setContext(e,this.snapshot.event,t,s,this.plans.plan(this.snapshot.event).subject)}setSnapshot(e){const t=this.railRows()[this.railIndex];this.snapshot=e,this.plans.setSnapshot(e),this.notice=void 0,this.rebuild(),this.holdRail(t)}holdRail(e){if(e===void 0)return;const t=this.railRows(),s=S(e),n=t.findIndex(r=>S(r)===s);this.railIndex=Math.max(0,n>=0?n:t.findIndex(r=>r.kind==="event"&&r.event.dialled))}matches(e,t){return q(this.bindings,e,t,(s,n)=>i(s,n))}label(e,t){const s=this.bindings.gestures(e);return s.length===0?t:G(s[0].split(" > ").pop())}isDown(e){return i(e,"j")||i(e,"down")||this.matches("crtr.setup.list-down",e)}isUp(e){return i(e,"k")||i(e,"up")||this.matches("crtr.setup.list-up",e)}isDescend(e){return i(e,"l")||i(e,"right")||i(e,"enter")||this.matches("crtr.setup.advance",e)}isAscend(e){return i(e,"h")||i(e,"left")}cyclesEvent(e){const t=i(e,"right")||i(e,"left");return i(e,"tab")||!t&&this.matches("crtr.setup.tab-next",e)?1:i(e,"shift+tab")||!t&&this.matches("crtr.setup.tab-previous",e)?-1:0}handleInput(e){if(this.busy!==void 0)return;if(this.modal!==void 0){this.handleModal(e);return}if(this.searching){this.handleSearch(e);return}const t=this.cyclesEvent(e);if(t!==0){this.setSnapshot($(this.snapshot,"event",t));return}if(!(this.zone==="detail"&&!this.detail.editing&&i(e,"ctrl+d"))&&(i(e,"q")||this.matches("crtr.setup.cancel",e))){this.close();return}this.zone==="rail"?this.handleRail(e):this.zone==="docs"?this.handleDocs(e):this.handleDetail(e)}eventRows(){return g.map(e=>{const t=this.plans.peek(e);return{event:e,delivers:t===void 0?void 0:t.docs.filter(s=>s.finalRung!=="none").length,dialled:e===this.snapshot.event}})}railRows(){return ne(this.eventRows(),ie(this.snapshot),ee(this.snapshot,P(this.snapshot.profileId)??"none"),se(this.filters))}handleRail(e){const t=this.railRows();this.railIndex=Math.max(0,Math.min(this.railIndex,t.length-1));const s=t[this.railIndex],n=h(o=>{s!==void 0&&(s.kind==="event"?this.setSnapshot({...this.snapshot,event:s.event.event}):s.kind==="axis"?s.axis.typed?this.openAxisField(s.axis.id,s.axis.label):this.setSnapshot($(this.snapshot,s.axis.id,o)):s.facet.typed?this.openSearch():this.setFilters(te(this.filters,s.facet.id,o)))},"change"),r=M(s);this.isDown(e)?this.railIndex=Math.min(t.length-1,this.railIndex+1):this.isUp(e)?this.railIndex=Math.max(0,this.railIndex-1):i(e,"space")||this.matches("crtr.setup.toggle",e)?n(1):this.isDescend(e)?i(e,"enter")&&r!=="documents"?n(1):this.zone="docs":i(e,"escape")&&this.close()}handleDocs(e){e==="/"||i(e,"/")?this.openSearch():i(e,"y")?this.yankPath():this.isDown(e)?(this.docs.move(1),this.syncDetail()):this.isUp(e)?(this.docs.move(-1),this.syncDetail()):i(e,"space")||this.matches("crtr.setup.toggle",e)?(this.docs.toggleGroup(),this.syncDetail()):this.isDescend(e)?this.docs.onGroup?(this.docs.toggleGroup(),this.syncDetail()):this.docs.selected!==void 0&&(this.zone="detail"):i(e,"escape")&&this.filters.query!==""?this.setFilters({...this.filters,query:""}):(this.isAscend(e)||i(e,"escape"))&&(this.zone="rail")}openSearch(){this.searching=!0,this.zone="docs",this.tui.requestRender()}handleSearch(e){i(e,"escape")?(this.searching=!1,this.setFilters({...this.filters,query:""})):i(e,"enter")?this.searching=!1:i(e,"backspace")?this.setFilters({...this.filters,query:this.filters.query.slice(0,-1)}):e.length===1&&e.charCodeAt(0)>=32&&this.setFilters({...this.filters,query:this.filters.query+e}),this.tui.requestRender()}handleDetail(e){i(e,"y")?this.yankPath():this.detail.editing?this.handleEdit(e):this.handleRead(e)}yankPath(){const e=this.docs.selected;if(e===void 0)return;const{system:t,tmux:s}=T(e.key);this.notice=t||s?{text:`Copied ${W(e.key)}${t?"":" to the tmux buffer"}`,ok:!0}:{text:"No clipboard tool available \u2014 nothing copied",ok:!1},this.tui.requestRender()}handleRead(e){this.isDown(e)?this.detail.move(1):this.isUp(e)?this.detail.move(-1):i(e,"ctrl+d")?this.detail.page(1):i(e,"ctrl+u")?this.detail.page(-1):e==="G"||i(e,"shift+g")?this.detail.jump("bottom"):e==="g"||i(e,"g")?this.detail.jump("top"):e==="e"||i(e,"e")?this.detail.edit():this.isDescend(e)?this.detail.openBody():(this.isAscend(e)||i(e,"escape"))&&(this.detail.back()||(this.zone="docs"))}handleEdit(e){if(this.isDown(e)){this.detail.move(1);return}if(this.isUp(e)){this.detail.move(-1);return}if(this.isAscend(e)||i(e,"escape")){this.detail.back();return}const t=this.writeGesture(e);t!==void 0&&(t.document&&this.refusesWrite()||t.start())}writeGesture(e){const t=h(s=>({start:s,document:!0}),"doc");if(i(e,"enter")||i(e,"space")||this.matches("crtr.setup.toggle",e)){const s=this.detail.selected;return s===void 0?void 0:s.kind==="cap"?{start:h(()=>this.editCap(),"start"),document:!1}:t(()=>this.activate())}if(i(e,"m"))return{start:h(()=>this.editCap(),"start"),document:!1};if(i(e,"b"))return t(()=>this.editBody());if(i(e,"x"))return t(()=>this.removeEntry());if(i(e,"e"))return t(()=>this.composeEntry());if(i(e,"g"))return t(()=>this.editGate());if(i(e,"u"))return t(()=>this.flip("unlisted"));if(i(e,"s"))return t(()=>this.flip("slash"));if(i(e,"r"))return t(()=>this.editMove());if(i(e,"w"))return t(()=>this.editRouting());if(i(e,"f"))return t(()=>this.editShortForm())}refusesWrite(){const e=this.record;if(e===void 0)return!1;const t=I(e,this.snapshot.profileId);return t===null?!1:(this.notice={text:t,ok:!1},this.tui.requestRender(),!0)}activate(){const e=this.detail.selected;if(e!==void 0)switch(e.kind){case"entry":return this.cycleEntryRung(e.at);case"add-entry":return this.composeEntry();case"gate":return this.editGate();case"unlisted":return this.flip("unlisted");case"slash":return this.flip("slash");case"routing":return this.editRouting();case"short-form":return this.editShortForm();case"body":return this.editBody();case"cap":return this.editCap();case"move":return this.editMove()}}get record(){return this.docs.selected?.anchor}apply(e){this.busy="writing\u2026",this.tui.requestRender(),e.then(t=>{this.busy=void 0,this.notice={text:t.message,ok:t.ok},t.ok&&(t.name!==void 0&&this.edited.add(t.name),this.plans.invalidate(),this.rebuild()),this.tui.requestRender()})}cycleEntryRung(e){const t=this.record,s=t?.doc.surfaces[e];if(t===void 0||s===void 0)return;const n=y[(y.indexOf(s.at)+1)%y.length],r=t.doc.surfaces.map((o,l)=>l===e?{...o,at:n}:o);this.apply(w(t,this.snapshot.profileId,r,`${t.name} now delivers at "${n}" on ${s.on}.`))}removeEntry(){const e=this.record,t=this.detail.selectedEntry;if(e===void 0||t===void 0){this.notice={text:"Select a surface entry to remove.",ok:!1};return}const s=e.doc.surfaces[t],n=e.doc.surfaces.filter((r,o)=>o!==t);this.modal={kind:"confirm",title:"Remove surface entry",message:`${e.name} will stop delivering on ${s.on} at "${s.at}".`,submit:h(()=>this.apply(w(e,this.snapshot.profileId,n,`Removed the ${s.on} entry from ${e.name}.`)),"submit")}}composeEntry(){const e=this.record;e!==void 0&&(this.modal={kind:"choice",title:"New entry \u2014 event",options:[...g],index:g.indexOf(this.snapshot.event),submit:h(t=>{const s=t,n=s!=="boot"&&s!=="workspace-open",r=h(o=>{this.modal={kind:"choice",title:"New entry \u2014 rung",options:[...y],index:0,submit:h(l=>{this.modal=void 0;const m={on:s,...o===""?{}:{match:[o]},at:l};this.apply(w(e,this.snapshot.profileId,[...e.doc.surfaces,m],`${e.name} now delivers on ${s} at "${l}".`))},"submit")}},"chooseRung");if(!n){r("");return}this.modal={kind:"field",title:`New entry \u2014 ${s} match`,hint:s==="read"?"absolute path glob, or ./ for this document\u2019s own directory":"glob over the event\u2019s namespace",input:f(""),submit:h(o=>{const l=o.trim();if(l===""){this.modal=void 0,this.notice={text:`A ${s} entry needs a match glob.`,ok:!1};return}r(l)},"submit")}},"submit")})}editGate(){const e=this.record;e!==void 0&&(this.modal={kind:"field",title:"Document gate",hint:"YAML or JSON predicate over the node config \u2014 empty clears it",input:f(e.doc.gate===void 0?"":JSON.stringify(e.doc.gate)),submit:h(t=>{this.modal=void 0,this.apply(Y(e,this.snapshot.profileId,t))},"submit")})}flip(e){const t=this.record;t!==void 0&&this.apply(J(t,this.snapshot.profileId,e))}editRouting(){const e=this.record;e!==void 0&&(this.modal={kind:"field",title:"Routing line",hint:"When <circumstance>, this <kind> should be read because <payoff>",input:f(e.doc.whenAndWhyToRead),submit:h(t=>{this.modal=void 0,this.apply(Q(e,this.snapshot.profileId,t))},"submit")})}editShortForm(){const e=this.record;e!==void 0&&(this.modal={kind:"field",title:"Short form",hint:"human-facing abbreviation for listings \u2014 empty clears it",input:f(e.doc.shortForm),submit:h(t=>{this.modal=void 0,this.apply(Z(e,this.snapshot.profileId,t))},"submit")})}editBody(){const e=this.record;if(e===void 0)return;let t;try{t=V(e)}catch(r){this.notice={text:r instanceof Error?r.message:String(r),ok:!1};return}const s=this.suspendForChild();let n;try{n=B(t)}finally{s()}if(n.error!==void 0){this.notice={text:n.error,ok:!1};return}if(n.text===t){this.notice={text:`${e.name} came back unchanged \u2014 nothing written.`,ok:!1};return}this.apply(K(e,this.snapshot.profileId,n.text))}editMove(){const e=this.record;e!==void 0&&(this.modal={kind:"field",title:"Move or rename",hint:"the new canonical name inside this document\u2019s own store",input:f(e.name),submit:h(t=>{this.modal=void 0,this.apply(L(e,this.snapshot.profileId,t))},"submit")})}editCap(){const e=this.record,t=this.snapshot.profileId;if(e===void 0)return;const s=t===null?null:k(e,t);if(s===null||t===null){this.notice={text:"No profile project governs this store \u2014 its ceiling is neutral and not editable here.",ok:!1};return}this.modal={kind:"choice",title:`Ceiling for ${s.path}`,options:[...R],index:Math.max(0,R.indexOf(s.memory)),submit:h(n=>{this.modal=void 0;const r=X(t,s.path,n);if(this.notice={text:r.message,ok:r.ok},r.change!==void 0){const o=this.capChanges.findIndex(l=>l.path===r.change.path);o>=0?this.capChanges[o]=r.change:this.capChanges.push(r.change),this.plans.invalidate(),this.rebuild()}},"submit")}}openAxisField(e,t){this.modal={kind:"field",title:t,hint:e==="cwd"?"absolute directory the project stores resolve from":"value the planner should match against",input:f(he(this.snapshot,e)),submit:h(s=>{this.modal=void 0,this.setSnapshot(oe(this.snapshot,e,s))},"submit")}}close(){if(this.edited.size===0&&this.capChanges.length===0){this.onCancel?.();return}this.onSubmit?.({edited:[...this.edited],capChanges:[...this.capChanges]})}handleModal(e){const t=this.modal;if(t!==void 0){if(i(e,"escape")){this.modal=void 0;return}if(t.kind==="choice"){this.isDown(e)?t.index=Math.min(t.options.length-1,t.index+1):this.isUp(e)?t.index=Math.max(0,t.index-1):i(e,"enter")&&t.submit(t.options[t.index]);return}if(t.kind==="confirm"){i(e,"y")||i(e,"enter")?(this.modal=void 0,t.submit()):i(e,"n")&&(this.modal=void 0);return}i(e,"enter")?t.submit(t.input.getValue()):t.input.handleInput(e)}}renderModal(e,t){const s=this.modal;if(s===void 0)return[];let n;s.kind==="choice"?n=[d.fg("accent",d.bold(s.title)),"",...s.options.map((o,l)=>`${l===s.index?d.fg("accent","\u25B6"):" "} ${o}`)]:s.kind==="confirm"?n=[d.fg("warning",d.bold(s.title)),"",...ve(s.message,Math.max(1,e-6))]:n=[d.fg("accent",d.bold(s.title)),d.fg("dim",s.hint),"",s.input.render(Math.max(1,e-6))[0]??""];const r=j(n,e);for(;r.length<t;)r.push("");return r.slice(0,t)}footer(e,t){if(this.busy!==void 0)return d.fg("warning",this.busy);if(this.modal?.kind==="choice")return d.fg("dim","j/k choose \xB7 enter apply \xB7 esc cancel");if(this.modal?.kind==="confirm")return d.fg("dim","y/enter confirm \xB7 n/esc cancel");if(this.modal?.kind==="field")return d.fg("dim","type \xB7 enter apply \xB7 esc cancel");if(this.searching)return d.fg("dim","type to search names \xB7 enter keep \xB7 esc clear");if(this.notice!==void 0)return d.fg(this.notice.ok?"success":"warning",v(this.notice.text,e));const s=`${this.label("crtr.setup.list-down","j")}/${this.label("crtr.setup.list-up","k")}`,n=this.zone==="rail"?`${s} row \xB7 ${we(t)}`:this.zone==="docs"?`${s} row \xB7 ${this.docsGesture()} \xB7 / search \xB7 y path`:this.detail.editing?`${s} field \xB7 enter edit \xB7 e add \xB7 x remove \xB7 g gate \xB7 b body \xB7 u unlisted \xB7 s slash \xB7 m cap \xB7 r rename \xB7 y path \xB7 esc read`:this.detail.bodyOpen?`${s} scroll \xB7 ctrl-d/u page \xB7 g/G ends \xB7 y path \xB7 esc collapse`:`${s} scroll \xB7 enter body \xB7 e edit \xB7 y path \xB7 esc list`,r=`${this.label("crtr.setup.tab-next","tab")} event \xB7 ${this.label("crtr.setup.cancel","q")} close`,o=e-b(n)-b(r);return o>=2?`${d.fg("dim",n)}${" ".repeat(o)}${d.fg("dim",r)}`:d.fg("dim",v(`${n} \xB7 ${this.label("crtr.setup.cancel","q")} close`,e))}docsGesture(){return this.docs.onGroup?"space/enter open":"enter dossier"}render(e){const t=this.terminalRows(),s=Math.max(1,t-U),n=e>=fe,r=this.railRows();this.railIndex=Math.max(0,Math.min(this.railIndex,r.length-1));const o=h(c=>re({rows:r,index:this.railIndex,width:c,height:s,focused:this.zone==="rail",matched:this.docs.visibleCount,total:this.rows.length}),"rail");let l;if(e>=pe){const c=be(e),p=Math.max(1,e-u-c-F),z=x(this.docs.render(c,s,this.zone==="docs"),c,this.modal===void 0?this.detail.render(p,s,this.zone==="detail"):this.renderModal(p,s),p);l=x(o(u),u,z,e-u-3)}else if(n){const c=e-u-3,p=this.modal!==void 0?this.renderModal(c,s):this.zone==="detail"?this.detail.render(c,s,!0):this.docs.render(c,s,this.zone==="docs");l=x(o(u),u,p,c)}else this.modal!==void 0?l=this.renderModal(e,s):this.zone==="rail"?l=o(e):this.zone==="detail"?l=this.detail.render(e,s,!0):l=this.docs.render(e,s,!0);const m=g.filter(c=>this.plans.peek(c)===void 0).length,A=[this.snapshot.event,this.costMeta(),m>0?`${E(m,"event","events")} planning`:"all events planned",this.edited.size>0?`${E(this.edited.size,"doc","docs")} edited`:""].filter(c=>c!=="").join(" \xB7 ");return H({width:e,height:t,title:"crouter context",meta:A,body:l,footer:this.footer(e,r[this.railIndex])})}costMeta(){const{total:e,byRung:t}=ae(this.rows,this.snapshot.event);if(e===0)return"no documents delivered";const s=["content","preview","name"].filter(n=>t[n]>0).map(n=>`${C(t[n]).replace("~","")} ${n}`).join(" \xB7 ");return`docs load ${C(e)} \u2014 ${s}`}}function we(a){switch(M(a)){case"dial":return"space/enter dial \xB7 l documents";case"edit":return"space/enter edit \xB7 l documents";default:return"space change \xB7 enter documents"}}h(we,"railGesture");function f(a){const e=new _;return e.setValue(a),e.handleInput(""),e.focused=!0,e}h(f,"seeded");function ve(a,e){const t=[];let s="";for(const n of a.trim().split(/\s+/)){const r=s===""?n:`${s} ${n}`;b(r)<=e?s=r:(s!==""&&t.push(s),s=n)}return s!==""&&t.push(s),t}h(ve,"wrap");async function Te(a){return N(({tui:e,terminal:t,bindings:s,suspendForChild:n},r)=>{const o=new xe(a,e,()=>t.rows,s,n);return o.onCancel=r.cancel,o.onSubmit=r.submit,o})}h(Te,"runContextAdmin");export{xe as ContextAdminShell,Te as runContextAdmin};
|
|
1
|
+
var z=Object.defineProperty;var l=(u,e)=>z(u,"name",{value:e,configurable:!0});import{Input as A,matchesKey as s,truncateToWidth as b,visibleWidth as w}from"@earendil-works/pi-tui";import{formatGesture as C,matchesPiTuiInput as N}from"../../../../core/keybindings/index.js";import{writeClipboardTextEverywhere as T}from"../../../../core/clipboard-text.js";import{runTuiPage as O}from"../../../../core/tui/page-host.js";import{PAGE_CHROME_ROWS as F,columns as x,framed as W,pageFrame as L,theme as h}from"../../../../core/tui/panel.js";import{editBufferInEditor as G}from"../../../../clients/inbox/review/roundtrip.js";import{PLANNED_EVENTS as m}from"../resolve.js";import{moveDoc as H,readBody as k,readOnlyReason as I,toggleUnlisted as P,writeBody as B,writePreview as U,writeRules as v}from"./actions.js";import{axesOf as j,cycleAxis as $,cycleFacet as V,facetsOf as K,payloadRowOf as X,railEnter as D,railRowKey as M,railRowsOf as J,renderRail as Q,setTypedAxis as Y,typedAxisValue as Z}from"./rail-panel.js";import{ContextDetailPanel as ee}from"./detail-panel.js";import{ContextDocsPanel as te,buildRows as ie}from"./docs-panel.js";import{NO_FILTERS as se}from"./list-view.js";import{DELIVER_LEVELS as g,PlanSet as ne,describeRule as re,plural as S}from"./model.js";function oe(u){return u!=="boot"&&u!=="workspace-open"}l(oe,"needsMatch");const le={boot:"","workspace-open":"","file-read":"absolute path glob, or ./ for this document\u2019s own directory","document-read":"document name glob",command:"command-path glob, e.g. node new","pre-command":"command-path glob, e.g. node new","slash-command":"slash command name glob"},a=26,de=86,he=112,q=6,ce=48,ue=100,ae=.45;function fe(u){const e=Math.max(1,u-a-q);return Math.max(ce,Math.min(ue,Math.floor(e*ae)))}l(fe,"docsWidthFor");class pe{static{l(this,"ContextAdminShell")}tui;terminalRows;bindings;suspendForChild;profiles;snapshot;plans;zone="rail";railIndex=0;filters=se;rows=[];searching=!1;docs;detail=new ee;modal;notice;busy;edited=new Set;bodies=new Map;_focused=!1;onCancel;onSubmit;constructor(e,t,i,n,r,o){this.tui=t,this.terminalRows=i,this.bindings=n,this.suspendForChild=r,this.profiles=o,this.snapshot=e,this.plans=new ne(e,()=>{this.refreshRows(),this.tui.requestRender()}),this.docs=new te(()=>this.tui.requestRender()),this.rebuild()}set focused(e){this._focused=e}get focused(){return this._focused}invalidate(){}dispose(){this.plans.dispose()}rebuild(){this.refreshRows(),this.plans.warm(this.snapshot.event)}refreshRows(){this.rows=ie(this.plans,this.snapshot.event),this.docs.setRows(this.rows,this.snapshot.event),this.syncDetail()}setFilters(e){this.filters=e,this.docs.setFilters(e),this.syncDetail()}syncDetail(){const e=this.docs.selected,t=e===void 0?null:I(e.anchor),i=this.plans.peek(this.snapshot.event)?.subject??null;this.detail.setContext(e,this.snapshot.event,t,i,e===void 0?void 0:this.bodies.get(e.key))}setSnapshot(e){const t=this.railRows()[this.railIndex];this.snapshot=e,this.plans.setSnapshot(e),this.notice=void 0,this.rebuild(),this.holdRail(t)}holdRail(e){if(e===void 0)return;const t=this.railRows(),i=M(e),n=t.findIndex(r=>M(r)===i);this.railIndex=Math.max(0,n>=0?n:t.findIndex(r=>r.kind==="event"&&r.event.dialled))}matches(e,t){return N(this.bindings,e,t,(i,n)=>s(i,n))}label(e,t){const i=this.bindings.gestures(e);return i.length===0?t:C(i[0].split(" > ").pop())}isDown(e){return s(e,"j")||s(e,"down")||this.matches("crtr.setup.list-down",e)}isUp(e){return s(e,"k")||s(e,"up")||this.matches("crtr.setup.list-up",e)}isDescend(e){return s(e,"l")||s(e,"right")||s(e,"enter")||this.matches("crtr.setup.advance",e)}isAscend(e){return s(e,"h")||s(e,"left")}cyclesEvent(e){const t=s(e,"right")||s(e,"left");return s(e,"tab")||!t&&this.matches("crtr.setup.tab-next",e)?1:s(e,"shift+tab")||!t&&this.matches("crtr.setup.tab-previous",e)?-1:0}handleInput(e){if(this.busy!==void 0)return;if(this.modal!==void 0){this.handleModal(e);return}if(this.searching){this.handleSearch(e);return}const t=this.cyclesEvent(e);if(t!==0){this.setSnapshot($(this.snapshot,"event",t,this.profiles));return}if(!(this.zone==="detail"&&!this.detail.editing&&s(e,"ctrl+d"))&&(s(e,"q")||this.matches("crtr.setup.cancel",e))){this.close();return}this.zone==="rail"?this.handleRail(e):this.zone==="docs"?this.handleDocs(e):this.handleDetail(e)}eventRows(){return m.map(e=>{const t=this.plans.peek(e);return{event:e,delivers:t===void 0?void 0:t.docs.filter(i=>i.finalRung!=="none").length,dialled:e===this.snapshot.event}})}railRows(){return J(this.eventRows(),X(this.snapshot),j(this.snapshot,this.profileName()),K(this.filters))}profileName(){const e=this.snapshot.profileId;return e===null?"none":this.profiles.find(t=>t.id===e)?.name??e}handleRail(e){const t=this.railRows();this.railIndex=Math.max(0,Math.min(this.railIndex,t.length-1));const i=t[this.railIndex],n=l(o=>{i!==void 0&&(i.kind==="event"?this.setSnapshot({...this.snapshot,event:i.event.event}):i.kind==="axis"?i.axis.typed?this.openAxisField(i.axis.id,i.axis.label):this.setSnapshot($(this.snapshot,i.axis.id,o,this.profiles)):i.facet.typed?this.openSearch():this.setFilters(V(this.filters,i.facet.id,o)))},"change"),r=D(i);this.isDown(e)?this.railIndex=Math.min(t.length-1,this.railIndex+1):this.isUp(e)?this.railIndex=Math.max(0,this.railIndex-1):s(e,"space")||this.matches("crtr.setup.toggle",e)?n(1):this.isDescend(e)?s(e,"enter")&&r!=="documents"?n(1):this.zone="docs":s(e,"escape")&&this.close()}handleDocs(e){e==="/"||s(e,"/")?this.openSearch():s(e,"y")?this.yankId():this.isDown(e)?(this.docs.move(1),this.syncDetail()):this.isUp(e)?(this.docs.move(-1),this.syncDetail()):s(e,"space")||this.matches("crtr.setup.toggle",e)?(this.docs.toggleGroup(),this.syncDetail()):this.isDescend(e)?this.docs.onGroup?(this.docs.toggleGroup(),this.syncDetail()):this.docs.selected!==void 0&&(this.zone="detail"):s(e,"escape")&&this.filters.query!==""?this.setFilters({...this.filters,query:""}):(this.isAscend(e)||s(e,"escape"))&&(this.zone="rail")}openSearch(){this.searching=!0,this.zone="docs",this.tui.requestRender()}handleSearch(e){s(e,"escape")?(this.searching=!1,this.setFilters({...this.filters,query:""})):s(e,"enter")?this.searching=!1:s(e,"backspace")?this.setFilters({...this.filters,query:this.filters.query.slice(0,-1)}):e.length===1&&e.charCodeAt(0)>=32&&this.setFilters({...this.filters,query:this.filters.query+e}),this.tui.requestRender()}handleDetail(e){s(e,"y")?this.yankId():this.detail.editing?this.handleEdit(e):this.handleRead(e)}yankId(){const e=this.docs.selected;if(e===void 0)return;const{system:t,tmux:i}=T(e.key);this.notice=t||i?{text:`Copied ${e.key}${t?"":" to the tmux buffer"}`,ok:!0}:{text:"No clipboard tool available \u2014 nothing copied",ok:!1},this.tui.requestRender()}handleRead(e){this.isDown(e)?this.detail.move(1):this.isUp(e)?this.detail.move(-1):s(e,"ctrl+d")?this.detail.page(1):s(e,"ctrl+u")?this.detail.page(-1):e==="G"||s(e,"shift+g")?this.detail.jump("bottom"):e==="g"||s(e,"g")?this.detail.jump("top"):e==="e"||s(e,"e")?this.detail.edit():this.isDescend(e)?this.openBody():(this.isAscend(e)||s(e,"escape"))&&(this.detail.back()||(this.zone="docs"))}openBody(){const e=this.docs.selected;if(e===void 0||!this.detail.openBody()||this.bodies.has(e.key))return;const t=e.key;k(e.anchor.doc).then(i=>{this.bodies.set(t,i),this.syncDetail(),this.tui.requestRender()},i=>{this.notice={text:i instanceof Error?i.message:String(i),ok:!1},this.detail.back(),this.tui.requestRender()})}handleEdit(e){if(this.isDown(e)){this.detail.move(1);return}if(this.isUp(e)){this.detail.move(-1);return}if(this.isAscend(e)||s(e,"escape")){this.detail.back();return}const t=this.writeGesture(e);t!==void 0&&(t.document&&this.refusesWrite()||t.start())}writeGesture(e){const t=l(i=>({start:i,document:!0}),"doc");if(s(e,"enter")||s(e,"space")||this.matches("crtr.setup.toggle",e))return this.detail.selected===void 0?void 0:t(()=>this.activate());if(s(e,"m"))return{start:l(()=>this.explainLimit(),"start"),document:!1};if(s(e,"b"))return t(()=>this.editBody());if(s(e,"x"))return t(()=>this.removeRule());if(s(e,"e"))return t(()=>this.composeRule());if(s(e,"u"))return t(()=>this.flipUnlisted());if(s(e,"r"))return t(()=>this.editMove());if(s(e,"w"))return t(()=>this.editPreview())}refusesWrite(){const e=this.record;if(e===void 0)return!1;const t=I(e);return t===null?!1:(this.notice={text:t,ok:!1},this.tui.requestRender(),!0)}activate(){const e=this.detail.selected;if(e!==void 0)switch(e.kind){case"rule":return this.cycleRuleLevel(e.at);case"add-rule":return this.composeRule();case"preview":return this.editPreview();case"unlisted":return this.flipUnlisted();case"body":return this.editBody();case"move":return this.editMove()}}get record(){return this.docs.selected?.anchor}apply(e){this.busy="writing\u2026",this.tui.requestRender(),e.then(t=>{this.busy=void 0,this.notice={text:t.message,ok:t.ok},t.ok&&(t.name!==void 0&&this.edited.add(t.name),this.bodies.clear(),this.plans.refresh(),this.rebuild()),this.tui.requestRender()})}cycleRuleLevel(e){const t=this.record,i=t?.doc.rules[e];if(t===void 0||i===void 0)return;const r=g[(g.indexOf(i.deliver)+1)%g.length],o=t.doc.rules.map((d,p)=>p===e?{...d,deliver:r}:d);this.apply(v(t,o,`${t.doc.displayName} now delivers ${r} on ${i.on}.`))}removeRule(){const e=this.record,t=this.detail.selectedRule;if(e===void 0||t===void 0){this.notice={text:"Select a delivery rule to remove.",ok:!1};return}const i=e.doc.rules[t],n=e.doc.rules.filter((r,o)=>o!==t);this.modal={kind:"confirm",title:"Remove delivery rule",message:`${e.doc.displayName} will stop delivering on ${i.on} (${re(i)}).`,submit:l(()=>this.apply(v(e,n,`Removed the ${i.on} rule from ${e.doc.displayName}.`)),"submit")}}composeRule(){const e=this.record;e!==void 0&&(this.modal={kind:"choice",title:"New rule \u2014 activity",options:[...m],index:m.indexOf(this.snapshot.event),submit:l(t=>{const i=t,n=l(r=>{this.modal={kind:"choice",title:"New rule \u2014 deliver",options:[...g],index:0,submit:l(o=>{this.modal=void 0;const d={on:i,...r===""?{}:{match:[r]},deliver:o};this.apply(v(e,[...e.doc.rules,d],`${e.doc.displayName} now delivers ${o} on ${i}.`))},"submit")}},"chooseLevel");if(!oe(i)){n("");return}this.modal={kind:"field",title:`New rule \u2014 ${i} match`,hint:le[i],input:y(""),submit:l(r=>{const o=r.trim();if(o===""){this.modal=void 0,this.notice={text:`A ${i} rule needs a match glob.`,ok:!1};return}n(o)},"submit")}},"submit")})}flipUnlisted(){const e=this.record;e!==void 0&&this.apply(P(e))}editPreview(){const e=this.record;e!==void 0&&(this.modal={kind:"field",title:"Preview",hint:"the one line a reader decides to open the document on",input:y(e.doc.preview),submit:l(t=>{this.modal=void 0,this.apply(U(e,t))},"submit")})}editBody(){const e=this.record;e!==void 0&&(this.busy="reading the body\u2026",this.tui.requestRender(),k(e.doc).then(t=>{this.busy=void 0;const i=this.suspendForChild();let n;try{n=G(t)}finally{i()}if(n.error!==void 0)this.notice={text:n.error,ok:!1};else if(n.text===t)this.notice={text:`${e.doc.displayName} came back unchanged \u2014 nothing written.`,ok:!1};else{this.apply(B(e,n.text));return}this.tui.requestRender()},t=>{this.busy=void 0,this.notice={text:t instanceof Error?t.message:String(t),ok:!1},this.tui.requestRender()}))}editMove(){const e=this.record;e!==void 0&&(this.modal={kind:"field",title:"Rename",hint:"the new name under this document\u2019s own owner",input:y(e.doc.displayName),submit:l(t=>{this.modal=void 0,this.apply(H(e,t))},"submit")})}explainLimit(){this.notice={text:"Delivery limits are per owner on the profile; set one with `crtr profile project limit`.",ok:!1},this.tui.requestRender()}openAxisField(e,t){this.modal={kind:"field",title:t,hint:e==="cwd"?"absolute directory the project stores resolve from":"value the planner should match against",input:y(Z(this.snapshot,e)),submit:l(i=>{this.modal=void 0,this.setSnapshot(Y(this.snapshot,e,i))},"submit")}}close(){if(this.edited.size===0){this.onCancel?.();return}this.onSubmit?.({edited:[...this.edited]})}handleModal(e){const t=this.modal;if(t!==void 0){if(s(e,"escape")){this.modal=void 0;return}if(t.kind==="choice"){this.isDown(e)?t.index=Math.min(t.options.length-1,t.index+1):this.isUp(e)?t.index=Math.max(0,t.index-1):s(e,"enter")&&t.submit(t.options[t.index]);return}if(t.kind==="confirm"){s(e,"y")||s(e,"enter")?(this.modal=void 0,t.submit()):s(e,"n")&&(this.modal=void 0);return}s(e,"enter")?t.submit(t.input.getValue()):t.input.handleInput(e)}}renderModal(e,t){const i=this.modal;if(i===void 0)return[];let n;i.kind==="choice"?n=[h.fg("accent",h.bold(i.title)),"",...i.options.map((o,d)=>`${d===i.index?h.fg("accent","\u25B6"):" "} ${o}`)]:i.kind==="confirm"?n=[h.fg("warning",h.bold(i.title)),"",...ge(i.message,Math.max(1,e-6))]:n=[h.fg("accent",h.bold(i.title)),h.fg("dim",i.hint),"",i.input.render(Math.max(1,e-6))[0]??""];const r=W(n,e);for(;r.length<t;)r.push("");return r.slice(0,t)}footer(e,t){if(this.busy!==void 0)return h.fg("warning",this.busy);if(this.modal?.kind==="choice")return h.fg("dim","j/k choose \xB7 enter apply \xB7 esc cancel");if(this.modal?.kind==="confirm")return h.fg("dim","y/enter confirm \xB7 n/esc cancel");if(this.modal?.kind==="field")return h.fg("dim","type \xB7 enter apply \xB7 esc cancel");if(this.searching)return h.fg("dim","type to search names \xB7 enter keep \xB7 esc clear");if(this.notice===void 0&&this.plans.error!==void 0)return h.fg("warning",b(`dry run refused: ${this.plans.error}`,e));if(this.notice!==void 0)return h.fg(this.notice.ok?"success":"warning",b(this.notice.text,e));const i=`${this.label("crtr.setup.list-down","j")}/${this.label("crtr.setup.list-up","k")}`,n=this.zone==="rail"?`${i} row \xB7 ${me(t)}`:this.zone==="docs"?`${i} row \xB7 ${this.docsGesture()} \xB7 / search \xB7 y id`:this.detail.editing?`${i} field \xB7 enter edit \xB7 e add \xB7 x remove \xB7 w preview \xB7 b body \xB7 u unlisted \xB7 m limit \xB7 r rename \xB7 y id \xB7 esc read`:this.detail.bodyOpen?`${i} scroll \xB7 ctrl-d/u page \xB7 g/G ends \xB7 y id \xB7 esc collapse`:`${i} scroll \xB7 enter body \xB7 e edit \xB7 y id \xB7 esc list`,r=`${this.label("crtr.setup.tab-next","tab")} event \xB7 ${this.label("crtr.setup.cancel","q")} close`,o=e-w(n)-w(r);return o>=2?`${h.fg("dim",n)}${" ".repeat(o)}${h.fg("dim",r)}`:h.fg("dim",b(`${n} \xB7 ${this.label("crtr.setup.cancel","q")} close`,e))}docsGesture(){return this.docs.onGroup?"space/enter open":"enter dossier"}render(e){const t=this.terminalRows(),i=Math.max(1,t-F),n=e>=de,r=this.railRows();this.railIndex=Math.max(0,Math.min(this.railIndex,r.length-1));const o=l(c=>Q({rows:r,index:this.railIndex,width:c,height:i,focused:this.zone==="rail",matched:this.docs.visibleCount,total:this.rows.length}),"rail");let d;if(e>=he){const c=fe(e),f=Math.max(1,e-a-c-q),_=x(this.docs.render(c,i,this.zone==="docs"),c,this.modal===void 0?this.detail.render(f,i,this.zone==="detail"):this.renderModal(f,i),f);d=x(o(a),a,_,e-a-3)}else if(n){const c=e-a-3,f=this.modal!==void 0?this.renderModal(c,i):this.zone==="detail"?this.detail.render(c,i,!0):this.docs.render(c,i,this.zone==="docs");d=x(o(a),a,f,c)}else this.modal!==void 0?d=this.renderModal(e,i):this.zone==="rail"?d=o(e):this.zone==="detail"?d=this.detail.render(e,i,!0):d=this.docs.render(e,i,!0);const p=m.filter(c=>this.plans.peek(c)===void 0).length,R=this.plans.peek(this.snapshot.event)?.docs.filter(c=>c.finalRung!=="none").length,E=[this.snapshot.event,R===void 0?"":`${R} delivered`,p>0?`${S(p,"event","events")} planning`:"all events planned",this.edited.size>0?`${S(this.edited.size,"doc","docs")} edited`:""].filter(c=>c!=="").join(" \xB7 ");return L({width:e,height:t,title:"crouter context",meta:E,body:d,footer:this.footer(e,r[this.railIndex])})}}function me(u){switch(D(u)){case"dial":return"space/enter dial \xB7 l documents";case"edit":return"space/enter edit \xB7 l documents";default:return"space change \xB7 enter documents"}}l(me,"railGesture");function y(u){const e=new A;return e.setValue(u),e.handleInput(""),e.focused=!0,e}l(y,"seeded");function ge(u,e){const t=[];let i="";for(const n of u.trim().split(/\s+/)){const r=i===""?n:`${i} ${n}`;w(r)<=e?i=r:(i!==""&&t.push(i),i=n)}return i!==""&&t.push(i),t}l(ge,"wrap");async function _e(u,e){return O(({tui:t,terminal:i,bindings:n,suspendForChild:r},o)=>{const d=new pe(u,t,()=>i.rows,n,r,e);return d.onCancel=o.cancel,d.onSubmit=o.submit,d})}l(_e,"runContextAdmin");export{pe as ContextAdminShell,_e as runContextAdmin};
|