@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 +0,0 @@
|
|
|
1
|
-
import{KINDS as t,isDocKind as o,RUNGS as n,rungRank as a,rungAtLeast as s,SURFACE_EVENTS as p,SURFACE_RUNGS as c,parseSubstrateFrontmatter as m,parseSubstrateDoc as u,previewLine as x,normalizeNameSegment as i,normalizeDocName as d,resolveDocName as S}from"./schema.js";import{lintSubstrateFrontmatter as f,lintSubstrateSchema as l,lintSubstrateSurfaces as D,parsedSubstrateSurfaces as g}from"./frontmatter-validation.js";import{matchesReadEntry as b,matchesMemoryReadEntry as y,matchesCommandEntry as C,readDeliveryRung as F,workspaceOpenRung as O,memoryReadDeliveryRung as N,commandDeliveryRung as h,matchingSurfaceEntry as v,surfaceEntryParticipates as k,owningRootOf as w,underOwningRoot as A}from"./surface-match.js";import{planDelivery as P,bootPartitionOf as K}from"./plan.js";import{dirDedupKey as T,docsByName as U,isDirName as B,ancestorDirsOf as L,renderDirListing as G}from"./listings.js";import{clearContextExposureState as W,cloneContextExposureState as _,cloneTranscriptExposureState as q,contentExposureIdentity as M,contextExposureStatesEqual as V,documentExposedAtOrAbove as H,emptyContextExposureState as J,exposedAtOrAbove as Q,exposureTarget as X,freezePreferenceSnapshot as Y,hasTranscriptExposure as Z,initializeForkContextExposure as $,loadContextExposureState as ee,mergeContextExposureState as re,registerDocumentExposure as te,registerExposure as oe,replaceContextExposureState as ne,saveContextExposureState as ae,sharedContextExposureState as se}from"./injected-store.js";import{scopeForCwd as ce,profileNameFor as me}from"./subject-fields.js";import{spineDepth as xe,assembleNodeSubject as ie}from"./subject.js";import{gatePasses as Se}from"./gate.js";import{renderPreferencesForSubject as fe,renderKnowledgeForSubject as le}from"./render.js";import{renderPreferencesSection as ge,renderKnowledgeBlock as Re}from"./render-node.js";import{renderOnReadDocsForSubject as ye,renderWorkspaceOpenDocsForSubject as Ce,renderOnCommandDocsForSubject as Fe,memoryReadDocBlocks as Oe}from"./on-read.js";import{renderOnReadDocs as he,renderWorkspaceOpenDocs as ve}from"./on-read-node.js";export{t as KINDS,n as RUNGS,p as SURFACE_EVENTS,c as SURFACE_RUNGS,L as ancestorDirsOf,ie as assembleNodeSubject,K as bootPartitionOf,W as clearContextExposureState,_ as cloneContextExposureState,q as cloneTranscriptExposureState,h as commandDeliveryRung,M as contentExposureIdentity,V as contextExposureStatesEqual,T as dirDedupKey,U as docsByName,H as documentExposedAtOrAbove,J as emptyContextExposureState,Q as exposedAtOrAbove,X as exposureTarget,Y as freezePreferenceSnapshot,Se as gatePasses,Z as hasTranscriptExposure,$ as initializeForkContextExposure,B as isDirName,o as isDocKind,f as lintSubstrateFrontmatter,l as lintSubstrateSchema,D as lintSubstrateSurfaces,ee as loadContextExposureState,C as matchesCommandEntry,y as matchesMemoryReadEntry,b as matchesReadEntry,v as matchingSurfaceEntry,N as memoryReadDeliveryRung,Oe as memoryReadDocBlocks,re as mergeContextExposureState,d as normalizeDocName,i as normalizeNameSegment,w as owningRootOf,u as parseSubstrateDoc,m as parseSubstrateFrontmatter,g as parsedSubstrateSurfaces,P as planDelivery,x as previewLine,me as profileNameFor,F as readDeliveryRung,te as registerDocumentExposure,oe as registerExposure,G as renderDirListing,Re as renderKnowledgeBlock,le as renderKnowledgeForSubject,Fe as renderOnCommandDocsForSubject,he as renderOnReadDocs,ye as renderOnReadDocsForSubject,fe as renderPreferencesForSubject,ge as renderPreferencesSection,ve as renderWorkspaceOpenDocs,Ce as renderWorkspaceOpenDocsForSubject,ne as replaceContextExposureState,S as resolveDocName,s as rungAtLeast,a as rungRank,ae as saveContextExposureState,ce as scopeForCwd,se as sharedContextExposureState,xe as spineDepth,k as surfaceEntryParticipates,A as underOwningRoot,O as workspaceOpenRung};
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { type Rung } from './schema.js';
|
|
2
|
-
export type ExposureSource = 'system' | 'transcript';
|
|
3
|
-
interface ExposureRanks {
|
|
4
|
-
system?: number;
|
|
5
|
-
transcript?: number;
|
|
6
|
-
}
|
|
7
|
-
/** Memory visible to the currently loaded LLM context. */
|
|
8
|
-
export interface ContextExposureState {
|
|
9
|
-
/** Byte-stable preference splice for this context. */
|
|
10
|
-
preferenceSnapshot: string | null;
|
|
11
|
-
/** Canonical identity → ranks loaded from the system and transcript snapshots. */
|
|
12
|
-
exposures: Map<string, ExposureRanks>;
|
|
13
|
-
}
|
|
14
|
-
/** One full document body that entered a context — the analytics memory log's
|
|
15
|
-
* `loaded` event, before it is timestamped and sent. */
|
|
16
|
-
export interface MemoryLoad {
|
|
17
|
-
name: string;
|
|
18
|
-
scope: string;
|
|
19
|
-
}
|
|
20
|
-
export interface ExposureTarget {
|
|
21
|
-
state: ContextExposureState;
|
|
22
|
-
source: ExposureSource;
|
|
23
|
-
/** Present only at real delivery sites; diagnostic renders pass none. */
|
|
24
|
-
loads?: MemoryLoad[];
|
|
25
|
-
}
|
|
26
|
-
/** JSON form exchanged with the daemon after Pi has materialized a baseline. */
|
|
27
|
-
export interface ContextExposureSnapshot {
|
|
28
|
-
preferenceSnapshot: string | null;
|
|
29
|
-
exposures: Record<string, {
|
|
30
|
-
system?: number;
|
|
31
|
-
transcript?: number;
|
|
32
|
-
}>;
|
|
33
|
-
}
|
|
34
|
-
export declare function snapshotContextExposure(state: ContextExposureState): ContextExposureSnapshot;
|
|
35
|
-
export declare function restoreContextExposure(value: ContextExposureSnapshot): ContextExposureState;
|
|
36
|
-
export declare function emptyContextExposureState(): ContextExposureState;
|
|
37
|
-
export declare function exposureTarget(state: ContextExposureState, source: ExposureSource, loads?: MemoryLoad[]): ExposureTarget;
|
|
38
|
-
export declare function exposedAtOrAbove(state: ContextExposureState, identity: string, rung: Rung): boolean;
|
|
39
|
-
/** The sole delivery mutation: max-fold one loaded identity into its source rank. */
|
|
40
|
-
export declare function registerExposure(target: ExposureTarget, identity: string, rung: Rung): void;
|
|
41
|
-
export declare function contentExposureIdentity(body: string): string | null;
|
|
42
|
-
export declare function documentExposedAtOrAbove(state: ContextExposureState, path: string, body: string, rung: Rung): boolean;
|
|
43
|
-
/** Register both the physical document and its non-empty content alias. A
|
|
44
|
-
* `content` registration of a body the context did not already hold is a full
|
|
45
|
-
* body entering the context, so it lands in the target's collector. */
|
|
46
|
-
export declare function registerDocumentExposure(target: ExposureTarget, doc: {
|
|
47
|
-
path: string;
|
|
48
|
-
body: string;
|
|
49
|
-
name: string;
|
|
50
|
-
scope: string;
|
|
51
|
-
}, rung: Rung): void;
|
|
52
|
-
/** Forget that a document was delivered into the TRANSCRIPT — both its physical
|
|
53
|
-
* identity and its content alias — while leaving any `system` rank intact,
|
|
54
|
-
* because the system prompt is rebuilt on every agent run and survives
|
|
55
|
-
* compaction. This is what re-arms a `pre-command` hold for guidance that
|
|
56
|
-
* compaction dropped out of the transcript. */
|
|
57
|
-
export declare function demoteDocumentTranscriptExposure(state: ContextExposureState, path: string, body: string): void;
|
|
58
|
-
export declare function freezePreferenceSnapshot(state: ContextExposureState, rendered: string): string;
|
|
59
|
-
export declare function cloneContextExposureState(source: ContextExposureState): ContextExposureState;
|
|
60
|
-
export declare function hasTranscriptExposure(state: ContextExposureState): boolean;
|
|
61
|
-
/** The context copied into a fork excludes the source's system snapshot. */
|
|
62
|
-
export declare function cloneTranscriptExposureState(source: ContextExposureState): ContextExposureState;
|
|
63
|
-
export declare function replaceContextExposureState(target: ContextExposureState, source: ContextExposureState): void;
|
|
64
|
-
export declare function contextExposureStatesEqual(left: ContextExposureState, right: ContextExposureState): boolean;
|
|
65
|
-
/** Fold state written by another process into the live context state. */
|
|
66
|
-
export declare function mergeContextExposureState(target: ContextExposureState, source: ContextExposureState): void;
|
|
67
|
-
export declare function sharedContextExposureState(nodeId: string): ContextExposureState;
|
|
68
|
-
/** v1/v2 ranks predate provenance and conservatively become transcript exposure. */
|
|
69
|
-
export declare function loadContextExposureState(nodeId: string): ContextExposureState;
|
|
70
|
-
export declare function saveContextExposureState(nodeId: string, state: ContextExposureState): void;
|
|
71
|
-
/** Clear in place so every extension closure observes the new context boundary. */
|
|
72
|
-
export declare function clearContextExposureState(nodeId: string): void;
|
|
73
|
-
/** Seed a fork with only context copied in the source transcript. */
|
|
74
|
-
export declare function initializeForkContextExposure(destinationNodeId: string, sourceNodeId: string | null): void;
|
|
75
|
-
export {};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
var T=Object.defineProperty;var s=(e,t)=>T(e,"name",{value:t,configurable:!0});import{createHash as M}from"node:crypto";import{injectedDocsPath as S,nodeRunDir as d}from"../canvas/paths.js";import{realpathOrSelf as w}from"../fs-utils.js";import{existsBeneath as g,readFileBeneath as B,setModeBeneath as R,statBeneath as z,unlinkBeneath as D,writeFileBeneath as N}from"../spaces/open-beneath.js";import{rungRank as v}from"./schema.js";function V(e){return{preferenceSnapshot:e.preferenceSnapshot,exposures:Object.fromEntries(e.exposures)}}s(V,"snapshotContextExposure");function W(e){if(e===null||typeof e!="object"||e.preferenceSnapshot!==null&&typeof e.preferenceSnapshot!="string"||e.exposures===null||typeof e.exposures!="object"||Array.isArray(e.exposures))throw new Error("invalid context exposure snapshot");const t=x();t.preferenceSnapshot=e.preferenceSnapshot;for(const[r,n]of Object.entries(e.exposures)){if(n===null||typeof n!="object"||Array.isArray(n)||n.system===void 0&&n.transcript===void 0||n.system!==void 0&&!u(n.system)||n.transcript!==void 0&&!u(n.transcript))throw new Error(`invalid context exposure ranks for '${r}'`);t.exposures.set(r,{...n})}return t}s(W,"restoreContextExposure");const F=v("content"),a=new Map;function x(){return{preferenceSnapshot:null,exposures:new Map}}s(x,"emptyContextExposureState");function $(e,t,r){return r===void 0?{state:e,source:t}:{state:e,source:t,loads:r}}s($,"exposureTarget");function u(e){return typeof e=="number"&&Number.isInteger(e)&&e>=1&&e<=F}s(u,"validRank");function J(e){return Math.max(e?.system??0,e?.transcript??0)}s(J,"activeRank");function O(e,t,r){return J(e.exposures.get(t))>=v(r)}s(O,"exposedAtOrAbove");function y(e,t,r){const n=v(r);if(n===0)return;const o=e.state.exposures.get(t)??{};(o[e.source]??0)>=n||e.state.exposures.set(t,{...o,[e.source]:n})}s(y,"registerExposure");function b(e){const t=e.trim();return t===""?null:`content-sha256:${M("sha256").update(t).digest("hex")}`}s(b,"contentExposureIdentity");function P(e,t,r,n){if(O(e,w(t),n))return!0;const o=b(r);return o!==null&&O(e,o,n)}s(P,"documentExposedAtOrAbove");function X(e,t,r){const{path:n,body:o}=t;r==="content"&&e.loads!==void 0&&!P(e.state,n,o,"content")&&e.loads.push({name:t.name,scope:t.scope}),y(e,w(n),r);const p=b(o);p!==null&&y(e,p,r)}s(X,"registerDocumentExposure");function j(e,t){const r=e.exposures.get(t);r!==void 0&&(u(r.system)?e.exposures.set(t,{system:r.system}):e.exposures.delete(t))}s(j,"dropTranscriptExposure");function Y(e,t,r){j(e,w(t));const n=b(r);n!==null&&j(e,n)}s(Y,"demoteDocumentTranscriptExposure");function Z(e,t){return e.preferenceSnapshot===null&&(e.preferenceSnapshot=t),e.preferenceSnapshot}s(Z,"freezePreferenceSnapshot");function I(e){return{preferenceSnapshot:e.preferenceSnapshot,exposures:new Map([...e.exposures].map(([t,r])=>[t,{...r}]))}}s(I,"cloneContextExposureState");function ee(e){return[...e.exposures.values()].some(t=>u(t.transcript))}s(ee,"hasTranscriptExposure");function q(e){const t=x(),r=$(t,"transcript");for(const[n,o]of e.exposures){const p=o.transcript;u(p)&&y(r,n,p===1?"name":p===2?"preview":"content")}return t}s(q,"cloneTranscriptExposureState");function k(e,t){e.preferenceSnapshot=t.preferenceSnapshot,e.exposures.clear();for(const[r,n]of t.exposures)e.exposures.set(r,{...n})}s(k,"replaceContextExposureState");function te(e,t){if(e.preferenceSnapshot!==t.preferenceSnapshot||e.exposures.size!==t.exposures.size)return!1;for(const[r,n]of e.exposures){const o=t.exposures.get(r);if(n.system!==o?.system||n.transcript!==o?.transcript)return!1}return!0}s(te,"contextExposureStatesEqual");function re(e,t){if(e.preferenceSnapshot!==null&&t.preferenceSnapshot!==null&&e.preferenceSnapshot!==t.preferenceSnapshot)throw new Error("context exposure state contains conflicting preference snapshots");e.preferenceSnapshot===null&&t.preferenceSnapshot!==null&&(e.preferenceSnapshot=t.preferenceSnapshot);for(const[r,n]of t.exposures){const o=e.exposures.get(r)??{},p=Math.max(o.system??0,n.system??0),i=Math.max(o.transcript??0,n.transcript??0);e.exposures.set(r,{...p>0?{system:p}:{},...i>0?{transcript:i}:{}})}}s(re,"mergeContextExposureState");function ne(e){let t=a.get(e);return t===void 0&&(t=x(),a.set(e,t)),t}s(ne,"sharedContextExposureState");function C(e){const t=S(e);let r;try{r=JSON.parse(B(d(e),t).toString("utf8"))}catch(c){if(c.code==="ENOENT")return x();throw new Error(`failed to read context exposure state at ${t}: ${c instanceof Error?c.message:String(c)}`)}const n=x(),o=$(n,"transcript");if(Array.isArray(r)){for(const c of r){if(typeof c!="string")throw new Error(`invalid v1 context exposure state at ${t}`);y(o,c,"content")}return n}if(r===null||typeof r!="object")throw new Error(`invalid context exposure state at ${t}`);const p=r;if(p.v===3){const c=p.preferenceSnapshot,f=p.exposures;if(c!==null&&typeof c!="string"||f===null||typeof f!="object"||Array.isArray(f))throw new Error(`invalid v3 context exposure state at ${t}`);n.preferenceSnapshot=c;for(const[E,m]of Object.entries(f)){if(m===null||typeof m!="object"||Array.isArray(m))throw new Error(`invalid v3 exposure entry '${E}' at ${t}`);const A=m,h=A.system,l=A.transcript;if(h!==void 0&&!u(h)||l!==void 0&&!u(l)||h===void 0&&l===void 0)throw new Error(`invalid v3 exposure ranks for '${E}' at ${t}`);n.exposures.set(E,{...u(h)?{system:h}:{},...u(l)?{transcript:l}:{}})}return n}if(p.v!==2)throw new Error(`unsupported context exposure state at ${t}`);const i=p.docs;if(i===null||typeof i!="object"||Array.isArray(i))throw new Error(`invalid v2 context exposure state at ${t}`);for(const[c,f]of Object.entries(i)){if(!u(f))throw new Error(`invalid v2 exposure rank for '${c}' at ${t}`);y(o,c,f===1?"name":f===2?"preview":"content")}return n}s(C,"loadContextExposureState");function H(e,t){const r=d(e),n=S(e);let o=384;try{o=z(r,n).mode&511}catch(i){if(i.code!=="ENOENT")throw i}const p=`${JSON.stringify({v:3,preferenceSnapshot:t.preferenceSnapshot,exposures:Object.fromEntries(t.exposures)},null,2)}
|
|
2
|
-
`;N(r,n,p,{atomic:!0,mode:o}),R(r,n,o)}s(H,"saveContextExposureState");function oe(e){const t=a.get(e);t!==void 0&&k(t,x());try{D(d(e),S(e))}catch(r){if(r.code!=="ENOENT")throw r}}s(oe,"clearContextExposureState");function se(e,t){if(g(d(e),S(e))){const o=C(e),p=a.get(e);p===void 0?a.set(e,o):k(p,o);return}const r=t===null?x():q(C(t)),n=a.get(e);n===void 0?a.set(e,r):k(n,r),H(e,r)}s(se,"initializeForkContextExposure");export{oe as clearContextExposureState,I as cloneContextExposureState,q as cloneTranscriptExposureState,b as contentExposureIdentity,te as contextExposureStatesEqual,Y as demoteDocumentTranscriptExposure,P as documentExposedAtOrAbove,x as emptyContextExposureState,O as exposedAtOrAbove,$ as exposureTarget,Z as freezePreferenceSnapshot,ee as hasTranscriptExposure,se as initializeForkContextExposure,C as loadContextExposureState,re as mergeContextExposureState,X as registerDocumentExposure,y as registerExposure,k as replaceContextExposureState,W as restoreContextExposure,H as saveContextExposureState,ne as sharedContextExposureState,V as snapshotContextExposure};
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import type { MemoryDoc } from '../memory-resolver.js';
|
|
2
|
-
import { type ExposureTarget } from './injected-store.js';
|
|
3
|
-
/** Exposure identity for a whole directory listing. Realpath identities start
|
|
4
|
-
* with `/`, so the scheme prefix never collides with a document. */
|
|
5
|
-
export declare function dirDedupKey(dir: string): string;
|
|
6
|
-
/** First-occurrence-wins name map over a precedence-ordered corpus: the doc
|
|
7
|
-
* that renders a name's line is the doc a read of that name would return. */
|
|
8
|
-
export declare function docsByName(corpus: readonly MemoryDoc[]): Map<string, MemoryDoc>;
|
|
9
|
-
/** Is `name` a directory in the merged name tree — i.e. does it have members?
|
|
10
|
-
* A doc that fronts a directory answers true here and still returns its own
|
|
11
|
-
* body, because one node carries both. The corpus root ('') is never a
|
|
12
|
-
* directory here: store roots merge into the whole catalog, which
|
|
13
|
-
* `memory list` owns. */
|
|
14
|
-
export declare function isDirName(byName: ReadonlyMap<string, MemoryDoc>, name: string): boolean;
|
|
15
|
-
/** The dirs a doc read discloses: the doc's own directory, then each ancestor
|
|
16
|
-
* walking up, the root excluded. `a/b/c` → `['a/b', 'a']`. */
|
|
17
|
-
export declare function ancestorDirsOf(name: string): string[];
|
|
18
|
-
/** The listings a read of `name` discloses, in render order: the node's own
|
|
19
|
-
* listing first when it has members (a directory document's members belong
|
|
20
|
-
* with its body), then each ancestor walking up. */
|
|
21
|
-
export declare function docListingDirs(byName: ReadonlyMap<string, MemoryDoc>, name: string): string[];
|
|
22
|
-
/** Render one directory's listing lines: `[[name]]: <when-and-why>` per member
|
|
23
|
-
* (bare `[[name]]` when it carries no routing line), childless members first
|
|
24
|
-
* and subdirectories after. `unlisted` members are omitted always;
|
|
25
|
-
* `filterDelivered` additionally drops members already exposed at preview rank
|
|
26
|
-
* or higher. A subdirectory always keeps its row — it advertises a subtree, so
|
|
27
|
-
* an omitted preview leaves the bare name. */
|
|
28
|
-
export declare function renderDirListing(byName: ReadonlyMap<string, MemoryDoc>, dir: string, target: ExposureTarget | null, filterDelivered: boolean, onPreview?: (doc: MemoryDoc) => void): string[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var h=Object.defineProperty;var o=(e,n)=>h(e,"name",{value:n,configurable:!0});import{buildMemoryTree as x}from"../memory/tree.js";import{parseSubstrateDoc as D,previewLine as a}from"./schema.js";import{documentExposedAtOrAbove as b,registerDocumentExposure as w}from"./injected-store.js";function A(e){return`dir://${e}`}o(A,"dirDedupKey");function E(e){const n=new Map;for(const t of e)n.has(t.name)||n.set(t.name,t);return n}o(E,"docsByName");const f=new WeakMap;function p(e){const n=f.get(e);if(n!==void 0)return n;const t=x([...e.values()]);return f.set(e,t),t}o(p,"treeFor");function v(e,n){return n!==""&&p(e).isDirectory(n)}o(v,"isDirName");function y(e){const n=[],t=e.split("/");for(let r=t.length-1;r>=1;r--)n.push(t.slice(0,r).join("/"));return n}o(y,"ancestorDirsOf");function O(e,n){return[...v(e,n)?[n]:[],...y(n)]}o(O,"docListingDirs");function d(e,n,t){const r=D(e);return r?.unlisted||t&&n!==null&&b(n.state,e.path,e.body,"preview")?null:(n!==null&&w(n,e,"preview"),r===null?"":a(r))}o(d,"previewSuffix");function m(e,n){return n===null||n===""?`[[${e}]]`:`[[${e}]]: ${n}`}o(m,"line");function S(e,n,t,r,l){const s=p(e).node(n);if(s===null)return[];const c=[];for(const u of s.childDocuments){const i=d(u.document,t,r);i!==null&&(l?.(u.document),c.push(m(u.name,i)))}for(const u of s.childDirectories){const i=u.document===null?null:d(u.document,t,r);u.document!==null&&i!==null&&l?.(u.document),c.push(m(u.name,i))}return c}o(S,"renderDirListing");export{y as ancestorDirsOf,A as dirDedupKey,O as docListingDirs,E as docsByName,v as isDirName,S as renderDirListing};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import type { MemoryReadEventDTO } from '../../api/dto/analytics.js';
|
|
2
|
-
import type { MemoryLoad } from './injected-store.js';
|
|
3
|
-
export declare function memoryEvents(loads: readonly MemoryLoad[], type: MemoryReadEventDTO['type'], at?: string): MemoryReadEventDTO[];
|
|
4
|
-
/** One POST for all of `events`; resolves (never rejects) whether or not crtrd
|
|
5
|
-
* recorded them. Sends nothing when there is nothing to record. */
|
|
6
|
-
export declare function sendMemoryEvents(nodeId: string, events: MemoryReadEventDTO[]): Promise<void>;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var i=Object.defineProperty;var r=(o,t)=>i(o,"name",{value:t,configurable:!0});import{localClient as c}from"../../api/node-transport.js";function s(o,t,e=new Date().toISOString()){return o.map(({name:n,scope:a})=>({name:n,scope:a,at:e,type:t}))}r(s,"memoryEvents");async function u(o,t){if(t.length!==0)try{await c({autostart:!1,coldStartPollWindowMs:0,timeoutMs:500}).recordMemoryReads(o,{events:t})}catch{}}r(u,"sendMemoryEvents");export{s as memoryEvents,u as sendMemoryEvents};
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type ExposureTarget } from './injected-store.js';
|
|
2
|
-
/** Surface docs matched by a successful read tool call. An unknown node id or
|
|
3
|
-
* an unreadable canvas renders nothing. */
|
|
4
|
-
export declare function renderOnReadDocs(nodeId: string, readFilePath: string, target?: ExposureTarget): string;
|
|
5
|
-
/** Surface matching workspace-open docs from the node's mounted project stores. */
|
|
6
|
-
export declare function renderWorkspaceOpenDocs(nodeId: string, target?: ExposureTarget): string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var i=Object.defineProperty;var n=(e,t)=>i(e,"name",{value:t,configurable:!0});import{getNode as m}from"../canvas/index.js";import{appForNode as s}from"../canvas/node-agent-paths.js";import{automaticMemoryTarget as a}from"../spaces/permissions.js";import{emptyContextExposureState as c,exposureTarget as p}from"./injected-store.js";import{assembleNodeSubject as u}from"./subject.js";import{renderOnReadDocsForSubject as f,renderWorkspaceOpenDocsForSubject as l}from"./on-read.js";function S(e,t,o=p(c(),"transcript")){let r;try{r=u(e)}catch{return""}return r===null?"":f(r,t,o)}n(S,"renderOnReadDocs");function y(e,t=p(c(),"transcript")){const o=u(e),r=m(e);return o===null||r===null?"":l(o,r.cwd,r.profile_id??null,t,void 0,a({...r,grantee:s(e)}))}n(y,"renderWorkspaceOpenDocs");export{S as renderOnReadDocs,y as renderWorkspaceOpenDocs};
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { type MemoryDoc, type MemoryTarget } from '../memory-resolver.js';
|
|
2
|
-
import { type ContextExposureState, type ExposureTarget } from './injected-store.js';
|
|
3
|
-
import { type Rung, type SubstrateDoc } from './schema.js';
|
|
4
|
-
import type { NodeConfigSubject } from './subject-fields.js';
|
|
5
|
-
export type DeliveryCause = 'directory listing attached to content delivery' | 'memory-read companion of content delivery';
|
|
6
|
-
export interface AccountedDelivery {
|
|
7
|
-
rung: Rung;
|
|
8
|
-
cause?: DeliveryCause;
|
|
9
|
-
/** Resolver descriptor for accounting-only attachment rows. */
|
|
10
|
-
source?: MemoryDoc;
|
|
11
|
-
}
|
|
12
|
-
/** The renderer's structured delivery ledger. It records precisely the document
|
|
13
|
-
* envelopes and listing lines that rendered, so diagnostics can report the
|
|
14
|
-
* same attachment fixpoint without parsing its text or recreating it. */
|
|
15
|
-
export interface DeliveryAccounting {
|
|
16
|
-
deliveries: Map<string, AccountedDelivery>;
|
|
17
|
-
}
|
|
18
|
-
export declare function deliveryAccounting(): DeliveryAccounting;
|
|
19
|
-
export declare function accountDelivery(accounting: DeliveryAccounting | undefined, doc: Pick<SubstrateDoc, 'path'>, rung: Rung, cause?: DeliveryCause, source?: MemoryDoc): void;
|
|
20
|
-
/** How one content delivery's attachments render, and the ledger + corpus the
|
|
21
|
-
* whole fixpoint runs against. ONE options object flows through every nested
|
|
22
|
-
* companion delivery, so `dirs` accumulates across the fixpoint and a
|
|
23
|
-
* companion inherits its parent's listing mode and memory target. */
|
|
24
|
-
export interface ContentAttachmentOptions {
|
|
25
|
-
/** Subject for companion `memory-read` gate evaluation. */
|
|
26
|
-
subject: NodeConfigSubject | null;
|
|
27
|
-
/** The one exposure ledger this fixpoint reads and registers against. */
|
|
28
|
-
target: ExposureTarget;
|
|
29
|
-
/** The corpus every directory question answers from — the caller's own
|
|
30
|
-
* listing corpus, never an ambient re-resolution. */
|
|
31
|
-
byName: ReadonlyMap<string, MemoryDoc>;
|
|
32
|
-
/** What companion `memory-read` routes plan against. Absent = the ambient
|
|
33
|
-
* cwd/profile target and this session's cached event corpus. */
|
|
34
|
-
memoryTarget?: MemoryTarget;
|
|
35
|
-
/** `blocks` attaches each disclosed listing as its own `<memory-listing>`.
|
|
36
|
-
* `tree` attaches none and accumulates the disclosed directories into
|
|
37
|
-
* `dirs` instead, for a caller that renders those members itself (the boot
|
|
38
|
-
* catalog tree) and registers them as it renders. */
|
|
39
|
-
listings: 'blocks' | 'tree';
|
|
40
|
-
/** Accumulator for `tree` mode: every directory this fixpoint disclosed. */
|
|
41
|
-
dirs?: string[];
|
|
42
|
-
/** An explicit `crtr memory read`: the read doc's OWN directory renders
|
|
43
|
-
* unfiltered and returns as `listing` rather than attaching as a block. */
|
|
44
|
-
explicit?: boolean;
|
|
45
|
-
/** Optional structured mirror of the actual emitted document deliveries. */
|
|
46
|
-
accounting?: DeliveryAccounting;
|
|
47
|
-
/** Why this winner was reached through the current content attachment walk. */
|
|
48
|
-
deliveryCause?: DeliveryCause;
|
|
49
|
-
}
|
|
50
|
-
/** The attachment semantics of a content delivery. Content is read-equivalent:
|
|
51
|
-
* it exposes its own/enclosing directory listings and fires memory-read routes.
|
|
52
|
-
* The exposure ledger makes this finite even when companion routes cycle. */
|
|
53
|
-
export declare function contentReadAttachments(doc: Pick<SubstrateDoc, 'name' | 'path' | 'body'>, opts: ContentAttachmentOptions): {
|
|
54
|
-
blocks: string[];
|
|
55
|
-
listing?: string[];
|
|
56
|
-
};
|
|
57
|
-
export declare function renderAutoLoadedContext(blocks: readonly string[]): string;
|
|
58
|
-
/** Surface docs whose `read` entries match a successfully read file, using
|
|
59
|
-
* the caller-supplied daemon snapshot subject. */
|
|
60
|
-
export declare function renderOnReadDocBlocksForSubject(subject: NodeConfigSubject, readFilePath: string, target?: ExposureTarget, accounting?: DeliveryAccounting, memoryTarget?: MemoryTarget): string[];
|
|
61
|
-
export declare function renderOnReadDocsForSubject(subject: NodeConfigSubject, readFilePath: string, target?: ExposureTarget, accounting?: DeliveryAccounting, memoryTarget?: MemoryTarget): string;
|
|
62
|
-
/** Workspace boot docs using the snapshot's cwd/profile instead of a canvas
|
|
63
|
-
* lookup. The shared exposure target prevents a later read from repeating a
|
|
64
|
-
* document already loaded here.
|
|
65
|
-
*
|
|
66
|
-
* Each candidate's authored rung is clamped to its project's profile
|
|
67
|
-
* relationship cap BEFORE filtering, ordering, rendering, and exposure
|
|
68
|
-
* registration. A later explicit `crtr memory read` can still raise a document
|
|
69
|
-
* that workspace-open disclosed at a lower rung. */
|
|
70
|
-
export declare function renderWorkspaceOpenDocsForSubject(subject: NodeConfigSubject, cwd: string, profileId: string | null, target?: ExposureTarget, accounting?: DeliveryAccounting, memoryTarget?: MemoryTarget): string;
|
|
71
|
-
/** Inner `<memory>` blocks for the memory-read event: docs whose
|
|
72
|
-
* `memory-read` entries match the doc a `crtr memory read` just resolved
|
|
73
|
-
* (known by its exact canonical `name` — no mount-stripped or other alias;
|
|
74
|
-
* `excludeRealpath` keeps the resolved doc from delivering itself). Returns
|
|
75
|
-
* unwrapped blocks — the read leaf composes one `<auto-loaded-context>`
|
|
76
|
-
* envelope from these plus the directory listings. */
|
|
77
|
-
export declare function memoryReadDocBlocks(excludeRealpath: string, name: string, opts: Omit<ContentAttachmentOptions, 'byName'> & {
|
|
78
|
-
byName?: ReadonlyMap<string, MemoryDoc>;
|
|
79
|
-
}): string[];
|
|
80
|
-
/** Surface docs whose `command` entries match an executed bash command.
|
|
81
|
-
* The corpus is the resolved cwd/profile set; a command has no file from which
|
|
82
|
-
* to discover enclosing project stores. */
|
|
83
|
-
export declare function renderOnCommandDocsForSubject(subject: NodeConfigSubject, command: string, target?: ExposureTarget, accounting?: DeliveryAccounting, memoryTarget?: MemoryTarget): string;
|
|
84
|
-
/** Surface docs whose `pre-command` entries match a bash command that has NOT
|
|
85
|
-
* run yet. The exact twin of the post-execution renderer above, and its empty
|
|
86
|
-
* string is load-bearing: `''` means every matching doc is already exposed at
|
|
87
|
-
* its matching rung or above, which is the release — the caller lets the
|
|
88
|
-
* command through. */
|
|
89
|
-
export declare function renderPreCommandDocsForSubject(subject: NodeConfigSubject, command: string, target?: ExposureTarget, accounting?: DeliveryAccounting, memoryTarget?: MemoryTarget): string;
|
|
90
|
-
/** Whether this command matches a `command` surface before its node-config
|
|
91
|
-
* gate is evaluated. A matching gate still requires a subject lookup. */
|
|
92
|
-
export declare function corpusHasCommandSurfaceForCommand(command: string): boolean;
|
|
93
|
-
/** Whether this command matches a `pre-command` surface before its node-config
|
|
94
|
-
* gate is evaluated. A matching gate still requires a subject lookup. */
|
|
95
|
-
export declare function corpusHasPreCommandSurfaceForCommand(command: string): boolean;
|
|
96
|
-
/** Forget the transcript exposure of every `pre-command` doc, re-arming their
|
|
97
|
-
* holds. Compaction drops delivered guidance out of the transcript while the
|
|
98
|
-
* ledger still claims it was delivered, so without this pass a doc could be
|
|
99
|
-
* held once and then silently absent for the rest of the session. Lives here
|
|
100
|
-
* rather than in the extension because the corpus accessor is private. */
|
|
101
|
-
export declare function demotePreCommandExposures(state: ContextExposureState, memoryTarget?: MemoryTarget): void;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
var P=Object.defineProperty;var i=(e,n)=>P(e,"name",{value:n,configurable:!0});import{sep as w}from"node:path";import{realpathOrSelf as E}from"../fs-utils.js";import{ambientMemoryTarget as j,listAllMemoryDocs as L,loadMemoryTargetView as S}from"../memory-resolver.js";import{commandEntryMatches as W,owningRootOf as O,preCommandEntryMatches as q}from"./surface-match.js";import{demoteDocumentTranscriptExposure as T,documentExposedAtOrAbove as H,emptyContextExposureState as I,exposedAtOrAbove as K,exposureTarget as V,registerDocumentExposure as z,registerExposure as G}from"./injected-store.js";import{planDelivery as C}from"./plan.js";import{parseSubstrateDoc as A,previewLine as J,rungRank as F}from"./schema.js";import{dirDedupKey as R,docListingDirs as Q,docsByName as $,isDirName as U,renderDirListing as X}from"./listings.js";import{cachedEventCorpusInclusive as Y}from"./session-cache.js";function g(e){return e.replace(/&/g,"&").replace(/"/g,""").replace(/</g,"<").replace(/>/g,">")}i(g,"attr");function D(){try{return Y(L,A)}catch{return[]}}i(D,"resolvedDocs");function Z(e,n){if(n==="none")return null;let t=`kind="${g(e.kind)}" name="${g(e.name)}"`;if(n==="content"){const r=e.body.trim();if(r!=="")return`<memory ${t}>
|
|
2
|
-
${r}
|
|
3
|
-
</memory>`}else if(n==="preview"){const r=J(e);r!==""&&(t+=` readWhen="${g(r)}"`)}return`<memory ${t} />`}i(Z,"renderDocEnvelope");function p(e){return e.docs.filter(n=>n.winner).map(n=>({doc:n.doc,rung:n.finalRung,source:n.source}))}i(p,"planWinners");function N(e){return $(e.docs.map(({source:n})=>n))}i(N,"planListingCorpus");function _(e,n){return`<memory-listing dir="${g(e)}">
|
|
4
|
-
${n.join(`
|
|
5
|
-
`)}
|
|
6
|
-
</memory-listing>`}i(_,"listingBlock");function fe(){return{deliveries:new Map}}i(fe,"deliveryAccounting");function B(e,n,t,r,o){if(e===void 0||t==="none")return;const c=E(n.path),a=e.deliveries.get(c);a!==void 0&&F(a.rung)>=F(t)||e.deliveries.set(c,{rung:t,...r===void 0?{}:{cause:r},...o===void 0?{}:{source:o}})}i(B,"accountDelivery");function ee(e,n){const{target:t,byName:r}=n,o=Q(r,e.name),c=o[0]===e.name,a=[];let s;for(const[h,u]of o.entries()){if(!U(r,u))continue;const m=c&&h===0;if(!m&&K(t.state,R(u),"preview"))continue;if(n.listings==="tree"){n.dirs?.push(u);continue}const l=m&&n.explicit===!0,d=X(r,u,t,!l,b=>B(n.accounting,b,"preview","directory listing attached to content delivery",b));d.length!==0&&(G(t,R(u),"preview"),l?s=d:a.push(_(u,d)))}return a.push(...re(E(e.path),e.name,{...n,deliveryCause:"memory-read companion of content delivery"})),{blocks:a,...s===void 0?{}:{listing:s}}}i(ee,"contentReadAttachments");function f(e,n){const{target:t}=n,r=[];for(const{doc:o,rung:c,source:a}of e){if(H(t.state,o.path,o.body,c))continue;const s=Z(o,c);s!==null&&(z(t,o,c),B(n.accounting,o,c,n.deliveryCause,a),c==="content"&&r.push(...ee(o,{...n,deliveryCause:"memory-read companion of content delivery"}).blocks),r.push(s))}return r}i(f,"renderWinnerBlocks");function k(e,n,t,r,o){return{subject:e,target:n,byName:N(t),listings:"blocks",accounting:r,memoryTarget:o}}i(k,"eventAttachmentOptions");function y(){return V(I(),"transcript")}i(y,"transientTranscriptTarget");function x(e){return e.length===0?"":`<auto-loaded-context>
|
|
7
|
-
${e.join(`
|
|
8
|
-
`)}
|
|
9
|
-
</auto-loaded-context>`}i(x,"renderAutoLoadedContext");function v(e,n,t,r){return r===void 0?C(e,j(),n,t,D()):C(e,r,n,t)}i(v,"eventPlan");function ne(e,n,t=y(),r,o){const c=v(e,"read",{absoluteFile:n},o);return f(p(c),k(c.subject,t,c,r,o))}i(ne,"renderOnReadDocBlocksForSubject");function ye(e,n,t=y(),r,o){return x(ne(e,n,t,r,o))}i(ye,"renderOnReadDocsForSubject");function he(e,n,t,r=y(),o,c){const a=c===void 0?{cwd:n,profileId:t,nodeId:null}:{...c,cwd:n,profileId:t,nodeId:null};let s,h;try{s=p(C(e,a,"workspace-open")),h=$(S(a,{quiet:!0}).docs)}catch{return""}return s.sort((u,m)=>{const l=O(u.doc)??"",d=O(m.doc)??"";return l.split(w).filter(Boolean).length-d.split(w).filter(Boolean).length||l.localeCompare(d)||u.doc.path.localeCompare(m.doc.path)}),x(f(s,{subject:e,target:r,byName:h,memoryTarget:a,listings:"blocks",accounting:o}))}i(he,"renderWorkspaceOpenDocsForSubject");function re(e,n,t){const r=v(t.subject,"memory-read",{resolvedCanonicalName:n,resolvedDocPath:e},t.memoryTarget);return f(p(r),{...t,byName:t.byName??N(r)})}i(re,"memoryReadDocBlocks");function ge(e,n,t=y(),r,o){const c=v(e,"command",{command:n},o);return x(f(p(c),k(e,t,c,r,o)))}i(ge,"renderOnCommandDocsForSubject");function xe(e,n,t=y(),r,o){const c=v(e,"pre-command",{command:n},o);return x(f(p(c),k(e,t,c,r,o)))}i(xe,"renderPreCommandDocsForSubject");function te(e){return e.surfaces.some(n=>n.on==="pre-command")}i(te,"carriesPreCommandEntry");function M(e,n){const t=n==="command"?W:q;return D().some(({doc:r})=>r.surfaces.some(o=>t(o,e)))}i(M,"hasCommandSurfaceForCommand");function ve(e){return M(e,"command")}i(ve,"corpusHasCommandSurfaceForCommand");function be(e){return M(e,"pre-command")}i(be,"corpusHasPreCommandSurfaceForCommand");function Ce(e,n){const t=n===void 0?D():S(n,{quiet:!0}).docs.map(r=>({doc:A(r)})).filter(r=>r.doc!==null);for(const{doc:r}of t)te(r)&&T(e,r.path,r.body)}i(Ce,"demotePreCommandExposures");export{B as accountDelivery,ee as contentReadAttachments,ve as corpusHasCommandSurfaceForCommand,be as corpusHasPreCommandSurfaceForCommand,fe as deliveryAccounting,Ce as demotePreCommandExposures,re as memoryReadDocBlocks,x as renderAutoLoadedContext,ge as renderOnCommandDocsForSubject,ne as renderOnReadDocBlocksForSubject,ye as renderOnReadDocsForSubject,xe as renderPreCommandDocsForSubject,he as renderWorkspaceOpenDocsForSubject};
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
import { type MemoryDoc, type MemoryScope, type MemoryTarget } from '../memory-resolver.js';
|
|
2
|
-
import { type DocKind, type Rung, type SubstrateDoc, type SurfaceEntry, type SurfaceEvent } from './schema.js';
|
|
3
|
-
import type { EventCorpusDoc } from './session-cache.js';
|
|
4
|
-
import type { NodeConfigSubject } from './subject-fields.js';
|
|
5
|
-
/** What the event exposes to match against. Every field is optional: an event
|
|
6
|
-
* invoked without its payload matches nothing rather than throwing. */
|
|
7
|
-
export interface DeliveryPayload {
|
|
8
|
-
/** `read`: the file that was read. Realpathed by the planner. */
|
|
9
|
-
absoluteFile?: string;
|
|
10
|
-
/** `read`: the read file's own frontmatter. Parsed from the file when omitted. */
|
|
11
|
-
readFrontmatter?: Record<string, unknown>;
|
|
12
|
-
/** `memory-read`: the exact canonical name the read resolved to. */
|
|
13
|
-
resolvedCanonicalName?: string;
|
|
14
|
-
/** `memory-read`: realpath of the resolved document, which never delivers to
|
|
15
|
-
* itself. */
|
|
16
|
-
resolvedDocPath?: string;
|
|
17
|
-
/** `command` / `pre-command`: the command string. */
|
|
18
|
-
command?: string;
|
|
19
|
-
}
|
|
20
|
-
/** A gate verdict with the reason a failure carries. */
|
|
21
|
-
export type GateOutcome = {
|
|
22
|
-
pass: true;
|
|
23
|
-
} | {
|
|
24
|
-
pass: false;
|
|
25
|
-
reason: string;
|
|
26
|
-
};
|
|
27
|
-
/** One authored surface entry of this event and how it fared. `matched` folds
|
|
28
|
-
* the entry's constraints AND its own gate; `gate` isolates the gate so a
|
|
29
|
-
* reader can tell "did not fit" from "excluded by this node's config". */
|
|
30
|
-
export interface EntryDecision {
|
|
31
|
-
entry: SurfaceEntry;
|
|
32
|
-
matched: boolean;
|
|
33
|
-
gate: GateOutcome;
|
|
34
|
-
}
|
|
35
|
-
/** One document's delivery decision for one event. */
|
|
36
|
-
export interface DeliveryRecord {
|
|
37
|
-
/** Canonical name — the identity dedup resolves. */
|
|
38
|
-
name: string;
|
|
39
|
-
kind: DocKind;
|
|
40
|
-
scope: MemoryScope;
|
|
41
|
-
/** Absolute path to the document file. */
|
|
42
|
-
storePath: string;
|
|
43
|
-
/** From the node's own store, which is floored rather than capped at boot. */
|
|
44
|
-
nodeLocal: boolean;
|
|
45
|
-
/** Every entry the document authored for this event. */
|
|
46
|
-
authoredEntries: EntryDecision[];
|
|
47
|
-
/** The highest-rung entry that matched, or null when none did. */
|
|
48
|
-
matchedEntry: SurfaceEntry | null;
|
|
49
|
-
/** The matched entry's rung — what the author asked for, before the cap. */
|
|
50
|
-
authoredRung: Rung;
|
|
51
|
-
/** The profile relationship's cap on this document's store, or null when the
|
|
52
|
-
* event is uncapped or the document is node-local. */
|
|
53
|
-
projectMemoryCap: Rung | null;
|
|
54
|
-
/** `minRung(authoredRung, projectMemoryCap)`. */
|
|
55
|
-
cappedRung: Rung;
|
|
56
|
-
docGate: GateOutcome;
|
|
57
|
-
/** The matched entry's gate, or the verdict that excluded every authored
|
|
58
|
-
* entry; null when the document authored no entry for this event. */
|
|
59
|
-
entryGate: GateOutcome | null;
|
|
60
|
-
/** What this document delivers at after gates, cap, and the boot node-local
|
|
61
|
-
* floor. `none` = delivers nothing. */
|
|
62
|
-
finalRung: Rung;
|
|
63
|
-
/** This document is the one its canonical name resolves to for this event. */
|
|
64
|
-
winner: boolean;
|
|
65
|
-
/** The document that took this one's name, when it lost the dedup. */
|
|
66
|
-
shadowedBy: {
|
|
67
|
-
name: string;
|
|
68
|
-
scope: MemoryScope;
|
|
69
|
-
path: string;
|
|
70
|
-
} | null;
|
|
71
|
-
/** The parsed document — the renderers' input. */
|
|
72
|
-
doc: SubstrateDoc;
|
|
73
|
-
/** The resolver descriptor behind it: physical path, representation, and the
|
|
74
|
-
* routing anchor a `./` memory-read glob matches against. */
|
|
75
|
-
source: MemoryDoc;
|
|
76
|
-
}
|
|
77
|
-
/** Every document considered for one event, in corpus (precedence) order. */
|
|
78
|
-
export interface DeliveryPlan {
|
|
79
|
-
event: SurfaceEvent;
|
|
80
|
-
subject: NodeConfigSubject | null;
|
|
81
|
-
target: MemoryTarget;
|
|
82
|
-
docs: DeliveryRecord[];
|
|
83
|
-
}
|
|
84
|
-
/** Which boot block a record belongs to. The node's own store is the catch-all
|
|
85
|
-
* this-node store and rides into the knowledge block whatever its kind, so a
|
|
86
|
-
* record's kind alone does not answer this. */
|
|
87
|
-
export declare function bootPartitionOf(record: Pick<DeliveryRecord, 'kind' | 'nodeLocal'>): DocKind;
|
|
88
|
-
/** Plan one event's delivery.
|
|
89
|
-
*
|
|
90
|
-
* `corpus` is the already-loaded document set. The live renderers pass their
|
|
91
|
-
* session cache (the corpus is scanned and parsed once per session); an
|
|
92
|
-
* inspection caller omits it and the planner loads the event's corpus from
|
|
93
|
-
* `target`. Either way the planner writes nothing. */
|
|
94
|
-
export declare function planDelivery(subject: NodeConfigSubject | null, target: MemoryTarget, event: SurfaceEvent, payload?: DeliveryPayload, corpus?: readonly EventCorpusDoc[]): DeliveryPlan;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var b=Object.defineProperty;var c=(e,t)=>b(e,"name",{value:t,configurable:!0});import{homedir as k}from"node:os";import{dirname as F,parse as R,sep as D}from"node:path";import{parseFrontmatterGeneric as G}from"../frontmatter.js";import{readText as E,realpathOrSelf as l}from"../fs-utils.js";import{loadMemoryTargetView as S,loadStoreMemoryDocs as M,openProjectMemoryStore as x}from"../memory-resolver.js";import{userScopeRoot as C}from"../scope.js";import{gatePasses as O,surfaceEntryGatePasses as A}from"./gate.js";import{minRung as $,parseSubstrateDoc as y,rungAtLeast as P}from"./schema.js";import{matchingSurfaceEntry as L,surfaceEntryParticipates as N}from"./surface-match.js";function j(e){return e.nodeLocal?"knowledge":e.kind}c(j,"bootPartitionOf");function ae(e,t,o,n={},r){const s=q(o,n),a=J(o,r??K(t,o),s,t).map(({doc:u,source:i})=>U(u,i,e,o,s));return Q(o,a),{event:o,subject:e,target:t,docs:a}}c(ae,"planDelivery");function q(e,t){if(e!=="read"||t.absoluteFile===void 0)return{...t,readFrontmatter:t.readFrontmatter??{}};const o=l(t.absoluteFile);return{...t,absoluteFile:o,readFrontmatter:t.readFrontmatter??B(o)}}c(q,"resolvePayload");function B(e){if(!/\.(md|mdx|markdown)$/i.test(e))return{};try{return G(E(e)).data??{}}catch{return{}}}c(B,"readFileFrontmatter");function J(e,t,o,n){if(e==="read"){const r=o.absoluteFile;return r===void 0?[...t]:[...I(r,n),...t].filter(({doc:s})=>l(s.path)!==r)}if(e==="memory-read"&&o.resolvedDocPath!==void 0){const r=o.resolvedDocPath;return t.filter(({doc:s})=>l(s.path)!==r)}return[...t]}c(J,"considerFor");const T=new Set(["node_modules",".git","dist","build",".next",".cache",".yalc"]);function _(e){return e.split(D).some(t=>T.has(t))}c(_,"isJunkAncestor");function I(e,t){const o=[],n=new Set,r=l(k()),s=l(C()),m=R(e).root;let a=F(e);for(;;){if(a!==r&&a!==s&&!_(a)){const i=x(a);if(i.mountStatus==="ready"&&!n.has(i.storeRoot)&&t.allowsProject?.(i.repositoryRoot??i.ownerDir??i.storeRoot)!==!1&&t.allowsStore?.(i)!==!1){n.add(i.storeRoot);for(const f of M(i,!0)){if(t.allowsStore?.(i,f.name)===!1)continue;const p=y(f);p!==null&&o.push({doc:p,source:f})}}}if(a===r||a===m)break;const u=F(a);if(u===a)break;a=u}return o}c(I,"enclosingProjectDocs");function K(e,t){const o=t==="workspace-open"?S(e,{quiet:!0,scope:"project"}).docs:S(e,{quiet:!0}).docs,n=[];for(const r of o){const s=y(r);s!==null&&n.push({doc:s,source:r})}return t!=="boot"?n:[...n.filter(r=>r.doc.scope!=="node"),...n.filter(r=>r.doc.scope==="node")]}c(K,"loadEventCorpus");function U(e,t,o,n,r){const s={absoluteFile:r.absoluteFile,readFrontmatter:r.readFrontmatter,resolvedCanonicalName:r.resolvedCanonicalName,routingAnchor:t.routingAnchor,command:r.command},m=V(e,o),a=e.surfaces.filter(d=>d.on===n).map(d=>({entry:d,matched:N(d,e,o,n,s),gate:W(d,o)})),u=L(e,o,n,s),i=u?.at??"none",f=e.scope==="node",h=(n==="boot"||n==="workspace-open")&&!f?e.projectMemory:null,w=h===null?i:$(i,h);let g=m.pass?w:"none";return n==="boot"&&f&&m.pass&&!P(g,"name")&&!e.surfaces.some(d=>d.on==="boot")&&(g="name"),{name:e.name,kind:e.kind,scope:e.scope,storePath:e.path,nodeLocal:f,authoredEntries:a,matchedEntry:u,authoredRung:i,projectMemoryCap:h,cappedRung:w,docGate:m,entryGate:z(a,u),finalRung:g,winner:!1,shadowedBy:null,doc:e,source:t}}c(U,"decide");function V(e,t){if(e.gate===void 0)return{pass:!0};if(t===null)return{pass:!1,reason:"gated document with no node config to match"};try{return O(e,t)?{pass:!0}:{pass:!1,reason:"document gate does not match this node config"}}catch(o){return{pass:!1,reason:`document gate failed to evaluate: ${String(o)}`}}}c(V,"documentGateOutcome");function W(e,t){return e.gate===void 0?{pass:!0}:A(e,t)?{pass:!0}:{pass:!1,reason:"entry gate does not match this node config"}}c(W,"entryGateOutcome");function z(e,t){if(e.length===0)return null;if(t!==null)return{pass:!0};const o=e.find(n=>!n.gate.pass);return o===void 0?{pass:!0}:o.gate}c(z,"recordEntryGate");function H(e,t){return e.docGate.pass?t==="boot"?e.projectMemoryCap!=="none":P(e.finalRung,"name"):!1}c(H,"participates");function Q(e,t){const o=new Map;for(const n of t){if(!H(n,e))continue;const r=e==="boot"?`${j(n)}:${n.name}`:n.name,s=o.get(r);if(s===void 0){o.set(r,n),n.winner=!0;continue}n.shadowedBy={name:s.name,scope:s.scope,path:s.storePath}}}c(Q,"resolveWinners");export{j as bootPartitionOf,ae as planDelivery};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type ExposureTarget } from './injected-store.js';
|
|
2
|
-
/** The system-prompt substrate splice for `nodeId` — shipped-layer protocol
|
|
3
|
-
* prose followed by the `<memory kind="preference">` block: assemble
|
|
4
|
-
* the node's subject from the canvas-db, render the pure splice, then swap the
|
|
5
|
-
* literal `$CRTR_CONTEXT_DIR` env-var token for the node's real absolute path
|
|
6
|
-
* so agents don't paste it into the non-expanding Write tool (see
|
|
7
|
-
* interpolateNodePaths). A null subject (unknown id) still renders the
|
|
8
|
-
* always-present memory-usage guidance frame. */
|
|
9
|
-
export declare function renderPreferencesSection(nodeId: string): string;
|
|
10
|
-
/** The first-message `<memory kind="knowledge">` block for `nodeId`. Rendered
|
|
11
|
-
* documents register at their displayed rung through `target`. */
|
|
12
|
-
export declare function renderKnowledgeBlock(nodeId: string, target?: ExposureTarget): string;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var m=Object.defineProperty;var t=(e,r)=>m(e,"name",{value:r,configurable:!0});import{appForNode as n,interpolateNodePaths as p}from"../canvas/node-agent-paths.js";import{getNode as u}from"../canvas/canvas.js";import{automaticMemoryTarget as i}from"../spaces/permissions.js";import{assembleNodeSubject as c}from"./subject.js";import{emptyContextExposureState as f,exposureTarget as s}from"./injected-store.js";import{renderPreferencesForSubject as a,renderKnowledgeForSubject as l}from"./render.js";function P(e){const r=c(e);return p(a(r).block,e)}t(P,"renderPreferencesSection");function d(e,r=s(f(),"transcript")){const o=c(e);return o===null?"":l(o,e,r,void 0,n(e),i({...u(e),grantee:n(e)}))}t(d,"renderKnowledgeBlock");export{d as renderKnowledgeBlock,P as renderPreferencesSection};
|
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
import { type MemoryTarget } from '../memory-resolver.js';
|
|
2
|
-
import { type ExposureTarget } from './injected-store.js';
|
|
3
|
-
import { type SubstrateDoc } from './schema.js';
|
|
4
|
-
import type { NodeConfigSubject } from './subject-fields.js';
|
|
5
|
-
import { type DeliveryAccounting } from './on-read.js';
|
|
6
|
-
/** The computed "sub-personas you may spawn" menu for a subject's kind — the
|
|
7
|
-
* live restoration of the old `personas/resolve.ts` static menu, now derived
|
|
8
|
-
* at render time from the merged kind registry (`subKindsAvailableTo`) so it
|
|
9
|
-
* can never drift from `sys context prompt-review --list`'s `subPersonas` metadata.
|
|
10
|
-
* Returns '' when the kind has zero available sub-kinds (no dangling empty
|
|
11
|
-
* header). Emitted for BOTH base and orchestrator modes per the CTO's ruling —
|
|
12
|
-
* mode is irrelevant to which sub-kinds are spawnable. */
|
|
13
|
-
export declare function buildSubPersonaMenu(kind: string): string;
|
|
14
|
-
export declare function renderPreferencesForSubject(subject: NodeConfigSubject | null, target?: ExposureTarget, accounting?: DeliveryAccounting, memoryTarget?: MemoryTarget): {
|
|
15
|
-
block: string;
|
|
16
|
-
contentDocs: SubstrateDoc[];
|
|
17
|
-
tree: string;
|
|
18
|
-
};
|
|
19
|
-
/** The `<memory kind="knowledge">` block embedded in the session_start bearings
|
|
20
|
-
* message (bearings.ts pushes it as a SIBLING of `<crtr-bearings>`, or drops it
|
|
21
|
-
* when ''). The consultable catalog: every eligible `kind: knowledge` resolver
|
|
22
|
-
* doc PLUS the node-local memory docs (any kind) — resolver docs win
|
|
23
|
-
* first-wins dedup over a same-named node-local doc. GROUPED by rung exactly
|
|
24
|
-
* like the preference block: content prose first (general→specific,
|
|
25
|
-
* node-local last), then the preview/name catalog tree. A bootless node-local
|
|
26
|
-
* doc arrives floored to `name`, so it surfaces as a bare-name tree entry
|
|
27
|
-
* rather than collapsing into a `[+N more]` count (its body still never
|
|
28
|
-
* renders: floored docs never reach the `content` rung). Procedural guidance and factual
|
|
29
|
-
* references both live here as `knowledge`. Returns '' when nothing is
|
|
30
|
-
* eligible. */
|
|
31
|
-
export declare function renderKnowledgeForSubject(subject: NodeConfigSubject, nodeId: string, target?: ExposureTarget, accounting?: DeliveryAccounting, grantee?: string, memoryTarget?: MemoryTarget): string;
|
|
32
|
-
/** What a node's configuration change newly exposes, rendered as up to three
|
|
33
|
-
* blocks in one string: the shipped protocol prose, a `<memory kind="preference">`
|
|
34
|
-
* block, and a `<memory kind="knowledge">` block — each dropped when empty, ''
|
|
35
|
-
* when the change exposes nothing.
|
|
36
|
-
*
|
|
37
|
-
* Both kinds use the current subject's ordinary winner assembly, then compare
|
|
38
|
-
* against the active exposure maximum. A lower rung or removal yields nothing
|
|
39
|
-
* because content already loaded into this context cannot be withdrawn.
|
|
40
|
-
* Rendered deltas register as transcript exposure through `target`. */
|
|
41
|
-
export declare function renderConfigChangeDelta(subject: NodeConfigSubject, nodeId: string, target: ExposureTarget, grantee?: string, memoryTarget?: MemoryTarget): string;
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
var J=Object.defineProperty;var l=(e,o)=>J(e,"name",{value:o,configurable:!0});import{sep as Q}from"node:path";import{interpolateNodePaths as M}from"../canvas/paths.js";import{ambientMemoryTarget as X,listAllMemoryDocs as Z,loadMemoryTargetView as N,resolveMemoryDoc as ee}from"../memory-resolver.js";import{buildMemoryTree as S}from"../memory/tree.js";import{subKindsAvailableTo as ne}from"../config.js";import{projectScopeRoots as te}from"../scope.js";import{documentExposedAtOrAbove as R,emptyContextExposureState as oe,exposureTarget as re,registerDocumentExposure as T,registerExposure as se}from"./injected-store.js";import{bootPartitionOf as ie,planDelivery as ce}from"./plan.js";import{parseSubstrateDoc as D,previewLine as ae,rungAtLeast as A,rungRank as _}from"./schema.js";import{accountDelivery as B,contentReadAttachments as ue}from"./on-read.js";import{dirDedupKey as le,docsByName as fe}from"./listings.js";import{cachedEventCorpusInclusive as de}from"./session-cache.js";function j(e,o,n){if(e===null)return[];let r;try{r=N({...n??{cwd:process.cwd(),profileId:null},nodeId:e,grantee:o},{scope:"node",quiet:!0}).docs}catch{return[]}const t=[];for(const s of r){const a=D(s);a!==null&&t.push({doc:a,source:s})}return t}l(j,"nodeStoreCorpus");function pe(e,o,n){let r;try{r=(n===void 0?de(Z,D):N({...n,nodeId:null},{quiet:!0}).docs.map(t=>({source:t,doc:D(t)})).filter(t=>t.doc!==null)).filter(t=>t.doc.scope!=="node")}catch{return j(e,o,n)}return[...r,...j(e,o,n)]}l(pe,"bootCorpus");function x(e,o,n,r){return ce(e,{...r??X(),nodeId:o,grantee:n},"boot",{},pe(o,n,r))}l(x,"bootPlan");function g(e,o){return e.docs.filter(n=>n.winner&&ie(n)===o).map(n=>({...n.doc,source:n.source,bootRung:n.finalRung}))}l(g,"bootWinners");function C(e){return O(e.bootRung)&&(e.bootRung!=="content"||e.body.trim()!=="")}l(C,"rendersAtBoot");function L(e){if(e.scope==="node")return 1e3;if(e.scope==="builtin")return 0;if(e.scope==="user")return 1;if(e.scope==="profile")return 2;const o=te();if(o.length===0)return 3;const n=o.findIndex(t=>e.path.startsWith(t+Q)),r=n===-1?0:n;return 3+(o.length-1-r)}l(L,"scopeGeneralityRank");function I(e){const o=e.source.physicalRelativePath.replace(/\.md$/i,"").split("/");return e.source.representation==="directory-index"&&o.pop(),o}l(I,"physicalSegments");function me(e,o){const n=I(e),r=I(o),t=Math.min(n.length,r.length);for(let s=0;s<t;s++){const a=n[s].localeCompare(r[s]);if(a!==0)return a}return n.length-r.length}l(me,"compareTreePosition");function k(e){return e.scope!=="builtin"&&e.plugin===void 0}l(k,"isAgentEditable");function he(e,o,n){if(o.length===0)return[];const r=new Map(e.map(a=>[a.path,a])),t=S(e.map(a=>a.source)),s=new Map;for(const a of o){const c=t.node(a);if(c===null)continue;let f=!1;const h=[...c.childDocuments.map(p=>p.document),...c.childDirectories.flatMap(p=>p.document===null?[]:[p.document])];for(const p of h){const d=r.get(p.path);d===void 0||s.has(d.path)||d.bootRung==="content"||A(d.bootRung,"preview")||d.unlisted||A(d.projectMemory,"preview")&&(R(n.state,d.path,d.body,"preview")||(s.set(d.path,{...d,bootRung:"preview"}),f=!0))}f&&se(n,le(a),"preview")}return[...s.values()]}l(he,"exposedDirEntries");function $(e,o,n,r,t=e,s,a){const c=r??re(oe(),"transcript"),f=[],h=[];for(const i of e)i.bootRung==="content"?f.push(i):h.push(i);f.sort((i,E)=>L(i)-L(E)||me(i,E)||i.name.localeCompare(E.name));const p=f.filter(i=>!R(c.state,i.path,i.body,"content")),d=p.map(i=>i.body.trim()).filter(i=>i!=="").join(`
|
|
2
|
-
|
|
3
|
-
`);for(const i of p)C(i)&&(T(c,i,i.bootRung),B(s,i,i.bootRung,void 0,i.source));const y={subject:n??null,target:c,byName:fe(t.map(i=>i.source)),memoryTarget:a,listings:"tree",dirs:[],accounting:s},w=p.flatMap(i=>ue(i,y).blocks),m=he(t,y.dirs??[],c),u=new Map(m.map(i=>[i.path,i])),b=new Set(h.map(i=>i.path)),P=[...h.map(i=>u.get(i.path)??i),...m.filter(i=>!b.has(i.path))];for(const i of P)C(i)&&(T(c,i,i.bootRung),B(s,i,i.bootRung,u.has(i.path)?"directory listing attached to content delivery":void 0,i.source));return{contentProse:d,tree:ye(P,o),contentDocs:p,attachmentBlocks:w}}l($,"renderGrouped");function G(e){const o=e.lastIndexOf("/");return o===-1?e:e.slice(o+1)}l(G,"leafSegment");function O(e){return _(e)>=_("name")}l(O,"isVisible");function K(e,o){const n=e.childDirectories.map(c=>K(c,o)),r=[];let t=0;for(const c of e.childDocuments){const f=o.get(c.document.path);f!==void 0&&(O(f.bootRung)?r.push({name:c.name,order:c.order,doc:f}):t+=1)}const s=e.document===null?null:o.get(e.document.path)??null;let a=null;return s!==null&&(O(s.bootRung)?a=s:t+=1),{name:e.name,segment:G(e.name),order:e.order,own:a,children:n,leaves:r,hiddenHere:t,renders:!1,ownCount:0}}l(K,"planDir");function F(e,o){let n=e.hiddenHere;for(const s of e.children)n+=F(s,e.name==="");const r=e.own!==null||e.leaves.length>0,t=e.children.some(s=>s.renders);return e.renders=r||t||o||e.name==="",e.ownCount=e.renders?n:0,e.renders?0:n}l(F,"resolveDir");function W(e){return e.kind==="dir"?e.node.order:e.kind==="leaf"?e.entry.order:""}l(W,"itemOrder");function U(e){return e.kind==="dir"?e.node.name:e.kind==="leaf"?e.entry.name:""}l(U,"itemName");function Y(e,o,n,r){const t=e.bootRung==="preview"?ae(e):"";r.push(t===""?`${n}${o}`:`${n}${o} # read when: ${t}`)}l(Y,"renderDocEntry");function q(e,o,n){const r=[];for(const t of e.children)t.renders&&r.push({kind:"dir",node:t});for(const t of e.leaves)r.push({kind:"leaf",entry:t});r.sort((t,s)=>W(t).localeCompare(W(s))||U(t).localeCompare(U(s))),e.ownCount>0&&r.push({kind:"more",count:e.ownCount}),r.forEach((t,s)=>{const a=s===r.length-1,c=o+(a?"\u2514\u2500 ":"\u251C\u2500 "),f=o+(a?" ":"\u2502 ");switch(t.kind){case"more":n.push(`${c}[+${t.count} more]`);break;case"dir":{const h=`${t.node.segment}/`;t.node.own===null?n.push(`${c}${h}`):Y(t.node.own,h,c,n),q(t.node,f,n);break}case"leaf":Y(t.entry.doc,G(t.entry.name),c,n);break}})}l(q,"renderChildren");function ye(e,o){if(e.length===0)return"";const n=new Map;for(const s of e)n.has(s.path)||n.set(s.path,s);const r=K(S(e.map(s=>s.source)).root,n);F(r,!1);const t=[o];return q(r,"",t),t.join(`
|
|
4
|
-
`)}l(ye,"buildTree");const v="Each %s below shows either its full content (indented beneath its name), a `# read when:` line telling you when to read the full document, or simply its name.",we="Preferences are how the user wants you to behave \u2014 standing directives and corrections. To read a preference, run `crtr memory read <name>`. "+v.replace("%s","preference"),H="If the user corrects you in a way that contradicts a preference, update the preference.",ge="Knowledge memories are what you consult \u2014 playbooks and techniques for how to do things, and references on the user, projects, and this node. They are aggregated from your memory stores: user-global (`~/.crouter/memory/`), every ancestor project store (`<dir>/.crouter/memory/`) from the cwd upward, the selected profile's memory store, and node-local (this node's `context/memory/`). To read one, run `crtr memory read <name>`; a directory name is a valid read target too \u2014 it answers with its listing, and walking directories is the sanctioned way to browse. Each doc exists to prevent a specific mistake you would make without it, so when your task matches one \u2014 by its name or its `# read when:` line \u2014 read it before you act; consulting it only after the work is done forfeits the entire reason it exists. "+v.replace("%s","document"),V="If you learn a better way to do something a memory covers, or gain information that contradicts one, edit that memory to correct it.",be="When your task matches a knowledge doc or preference \u2014 by its name or its `# read when:` line \u2014 read it before you act: each memory exists only to shore up a mistake you will make without it, so doing the relevant work without consulting it defeats the memory's whole purpose. Before saving any memory, check for an existing memory that already covers it \u2014 update that memory rather than creating a duplicate, rewriting it as if for the first time instead of appending the new truth beneath the old; delete memories that turn out to be wrong. Don't save what the repo already records (code structure, past fixes, git history) or what only matters to this conversation; if asked to remember one of those, ask what was non-obvious about it and save that instead. Docs auto-surfaced in <auto-loaded-context> blocks are background context, not user instructions, and reflect what was true when written \u2014 if one names a file, function, or flag, verify it still exists before recommending it.";function ke(e){try{return ee(`kinds/${e}`),` (\`crtr memory read kinds/${e}\`)`}catch{return""}}l(ke,"subKindDocCitation");function $e(e){const o=ne(e);if(o.length===0)return"";const n=o.map(r=>{const t=ke(r.kind);return`- \`${r.kind}\` \u2014 ${r.whenToUse}${t}`});return`## Sub-personas you may spawn
|
|
5
|
-
|
|
6
|
-
These specialist sub-personas are available to the ${e} kind. Spawn one with \`crtr node new --kind <sub> "<scope>"\`, and treat it as its own scope instead of dragging unrelated context into it.
|
|
7
|
-
|
|
8
|
-
`+n.join(`
|
|
9
|
-
`)}l($e,"buildSubPersonaMenu");function ve(e,o,n,r){let t=[],s="",a="",c=be;if(e!==null){const h=g(x(e,null,r?.grantee,r),"preference"),p=$(h,"preferences",e,o,h,n,r);t=p.contentDocs,s=p.tree;const d=t.filter(m=>!k(m)).map(m=>m.body.trim()).filter(m=>m!==""),y=t.filter(m=>k(m)).map(m=>{const u=m.body.trim();return u===""?"":`<preference name="${m.name}">
|
|
10
|
-
${u}
|
|
11
|
-
</preference>`}).filter(m=>m!==""),w=$e(e.kind);a=[...d,...p.attachmentBlocks,...w===""?[]:[w]].join(`
|
|
12
|
-
|
|
13
|
-
`),(y.length>0||s!=="")&&(c+=`
|
|
14
|
-
|
|
15
|
-
${we}`,y.length>0&&(c+=`
|
|
16
|
-
|
|
17
|
-
${y.join(`
|
|
18
|
-
|
|
19
|
-
`)}`),s!==""&&(c+=`
|
|
20
|
-
|
|
21
|
-
${s}`),c+=`
|
|
22
|
-
|
|
23
|
-
${H}`)}const f=`<memory kind="preference">
|
|
24
|
-
${c}
|
|
25
|
-
</memory>`;return{block:a===""?f:`${a}
|
|
26
|
-
|
|
27
|
-
${f}`,contentDocs:t,tree:s}}l(ve,"buildPreferencesBlock");function Ie(e,o,n,r){return ve(e,o,n,r)}l(Ie,"renderPreferencesForSubject");function Ge(e,o,n,r,t,s){const a=g(x(e,o,t,s),"knowledge"),{contentProse:c,tree:f,attachmentBlocks:h}=$(a,"knowledge",e,n,a,r,s),p=[c,...h].filter(y=>y!=="").join(`
|
|
28
|
-
|
|
29
|
-
`);if(p===""&&f==="")return"";let d=ge;return p!==""&&(d+=`
|
|
30
|
-
|
|
31
|
-
${p}`),f!==""&&(d+=`
|
|
32
|
-
|
|
33
|
-
${f}`),d+=`
|
|
34
|
-
|
|
35
|
-
${V}`,M(`<memory kind="knowledge">
|
|
36
|
-
${d}
|
|
37
|
-
</memory>`,o,t)}l(Ge,"renderKnowledgeForSubject");const Ee="Your node configuration changed. This operating protocol is in force for you now:",Re="Your new configuration puts these preferences in force \u2014 standing directives and corrections from the user. To read one, run `crtr memory read <name>`. "+v.replace("%s","preference"),De="Your new configuration exposes these knowledge documents \u2014 consult them exactly like the rest of your catalog (`crtr memory read <name>`). "+v.replace("%s","document");function z(e,o){return o.filter(n=>C(n)&&!R(e.state,n.path,n.body,n.bootRung))}l(z,"undelivered");function Ke(e,o,n,r,t){const s=x(e,o,r,t),a=z(n,g(s,"preference")),{contentDocs:c,tree:f,attachmentBlocks:h}=$(a,"preferences",e,n,g(s,"preference"),void 0,t),p=c.filter(u=>!k(u)).map(u=>u.body.trim()).filter(u=>u!==""),d=c.filter(u=>k(u)).map(u=>{const b=u.body.trim();return b===""?"":`<preference name="${u.name}">
|
|
38
|
-
${b}
|
|
39
|
-
</preference>`}).filter(u=>u!==""),y=[];if((p.length>0||h.length>0)&&y.push(`${Ee}
|
|
40
|
-
|
|
41
|
-
${[...p,...h].join(`
|
|
42
|
-
|
|
43
|
-
`)}`),d.length>0||f!==""){let u=Re;d.length>0&&(u+=`
|
|
44
|
-
|
|
45
|
-
${d.join(`
|
|
46
|
-
|
|
47
|
-
`)}`),f!==""&&(u+=`
|
|
48
|
-
|
|
49
|
-
${f}`),u+=`
|
|
50
|
-
|
|
51
|
-
${H}`,y.push(`<memory kind="preference">
|
|
52
|
-
${u}
|
|
53
|
-
</memory>`)}const w=$(z(n,g(s,"knowledge")),"knowledge",e,n,g(s,"knowledge"),void 0,t),m=[w.contentProse,...w.attachmentBlocks].filter(u=>u!=="").join(`
|
|
54
|
-
|
|
55
|
-
`);if(m!==""||w.tree!==""){let u=De;m!==""&&(u+=`
|
|
56
|
-
|
|
57
|
-
${m}`),w.tree!==""&&(u+=`
|
|
58
|
-
|
|
59
|
-
${w.tree}`),u+=`
|
|
60
|
-
|
|
61
|
-
${V}`,y.push(`<memory kind="knowledge">
|
|
62
|
-
${u}
|
|
63
|
-
</memory>`)}return y.length===0?"":M(y.join(`
|
|
64
|
-
|
|
65
|
-
`),o,r)}l(Ke,"renderConfigChangeDelta");export{$e as buildSubPersonaMenu,Ke as renderConfigChangeDelta,Ge as renderKnowledgeForSubject,Ie as renderPreferencesForSubject};
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import type { MemoryDoc } from '../memory-resolver.js';
|
|
2
|
-
import type { SubstrateDoc } from './schema.js';
|
|
3
|
-
type ListAllMemoryDocsFn = () => MemoryDoc[];
|
|
4
|
-
type ParseSubstrateDocFn = (doc: MemoryDoc) => SubstrateDoc | null;
|
|
5
|
-
/** A parsed substrate document with the resolver descriptor it came from. The
|
|
6
|
-
* parsed doc carries canonical identity but not the physical form behind it,
|
|
7
|
-
* so the descriptor is what supplies the routing anchor a `./` memory-read
|
|
8
|
-
* glob matches against. */
|
|
9
|
-
export interface EventCorpusDoc {
|
|
10
|
-
doc: SubstrateDoc;
|
|
11
|
-
source: MemoryDoc;
|
|
12
|
-
}
|
|
13
|
-
/** Called by canvas-doc-substrate.ts on every `session_start`.
|
|
14
|
-
* Resets all cached values so the next access triggers a fresh scan. */
|
|
15
|
-
export declare function clearSessionCache(): void;
|
|
16
|
-
/** The FULL corpus (listAllMemoryDocs()), INCLUDING node scope, scanned at
|
|
17
|
-
* most once per session. `listFn` is injected by the caller to avoid
|
|
18
|
-
* circular imports at module init. This is the single filesystem walk the
|
|
19
|
-
* whole module performs — every other entry derives from this result rather
|
|
20
|
-
* than re-scanning. */
|
|
21
|
-
export declare function cachedAllMemoryDocsInclusive(listFn: ListAllMemoryDocsFn): MemoryDoc[];
|
|
22
|
-
/** allMemoryDocsInclusive parsed and paired with its descriptors, INCLUDING
|
|
23
|
-
* node scope — the event corpus, and the module's only parse pass. */
|
|
24
|
-
export declare function cachedEventCorpusInclusive(listFn: ListAllMemoryDocsFn, parseFn: ParseSubstrateDocFn): EventCorpusDoc[];
|
|
25
|
-
/** The parsed docs of the inclusive event corpus, without their descriptors. */
|
|
26
|
-
export declare function cachedSubstrateDocsInclusive(listFn: ListAllMemoryDocsFn, parseFn: ParseSubstrateDocFn): SubstrateDoc[];
|
|
27
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var t=Object.defineProperty;var l=(s,c)=>t(s,"name",{value:c,configurable:!0});const e={allMemoryDocsInclusive:null,eventCorpusInclusive:null,substrateDocsInclusive:null};function a(){e.allMemoryDocsInclusive=null,e.eventCorpusInclusive=null,e.substrateDocsInclusive=null}l(a,"clearSessionCache");function r(s){return e.allMemoryDocsInclusive===null&&(e.allMemoryDocsInclusive=s()),e.allMemoryDocsInclusive}l(r,"cachedAllMemoryDocsInclusive");function i(s,c){if(e.eventCorpusInclusive===null){const n=[];for(const u of r(s)){const o=c(u);o!==null&&n.push({doc:o,source:u})}e.eventCorpusInclusive=n}return e.eventCorpusInclusive}l(i,"cachedEventCorpusInclusive");function I(s,c){return e.substrateDocsInclusive===null&&(e.substrateDocsInclusive=i(s,c).map(n=>n.doc)),e.substrateDocsInclusive}l(I,"cachedSubstrateDocsInclusive");export{r as cachedAllMemoryDocsInclusive,i as cachedEventCorpusInclusive,I as cachedSubstrateDocsInclusive,a as clearSessionCache};
|