@north-light/crouter 0.3.348 → 0.3.350
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/bin/crtr-launcher +4 -0
- package/bin/runtime-generation-manifest.mjs +12 -2
- package/dist/api/client.d.ts +50 -7
- package/dist/api/client.js +2 -2
- package/dist/api/command-manifest/schema.js +1 -1
- package/dist/api/dto/analytics.d.ts +184 -0
- package/dist/api/dto/analytics.js +0 -0
- package/dist/api/dto/broker-ops.d.ts +43 -1
- package/dist/api/dto/config.d.ts +11 -0
- package/dist/api/dto/grants.d.ts +14 -0
- package/dist/api/dto/grants.js +0 -0
- package/dist/api/dto/human-requests.d.ts +14 -0
- package/dist/api/dto/memory.d.ts +6 -0
- package/dist/api/dto/modelauth.d.ts +35 -0
- package/dist/api/dto/node-records.d.ts +35 -0
- package/dist/api/dto/node-records.js +0 -0
- package/dist/api/dto/nodes.d.ts +5 -0
- package/dist/api/dto/profiles.d.ts +38 -3
- package/dist/api/dto/worktree.d.ts +11 -0
- package/dist/api/errors.d.ts +23 -1
- package/dist/api/errors.js +1 -1
- package/dist/api/index.d.ts +2 -0
- package/dist/api/index.js +1 -1
- package/dist/api/node-transport.js +1 -1
- package/dist/api/routes.d.ts +22 -0
- package/dist/api/routes.js +1 -1
- package/dist/build-root.d.ts +6 -1
- package/dist/build-root.js +1 -1
- package/dist/builtin-memory/crouter-sdk/client.md +34 -0
- package/dist/builtin-memory/crouter-sdk/errors.md +2 -0
- package/dist/builtin-memory/crouter-sdk/memory.md +2 -2
- package/dist/builtin-memory/crouter-sdk/streaming.md +21 -0
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/claude-plugin-commands.ts +8 -4
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/memory-slash-commands.ts +39 -118
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/provider-rotation.d.ts +6 -1
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/provider-rotation.js +41 -27
- package/dist/builtin-pi-packages/pi-crtr-extensions/extensions/provider-rotation.ts +52 -29
- package/dist/cli.js +9 -8
- package/dist/clients/attach/chrome/inbox-strip.js +1 -1
- package/dist/clients/attach/chrome/roster.js +1 -1
- package/dist/clients/attach/config.js +1 -1
- package/dist/clients/attach/overlays/auth.js +2 -2
- package/dist/clients/attach/overlays/graph.js +1 -1
- package/dist/clients/attach/render/tool-calls.js +3 -3
- package/dist/clients/attach/session/connection.js +1 -1
- package/dist/clients/attach/session/profile-files.js +1 -1
- package/dist/clients/attach/viewer.js +1569 -816
- package/dist/commands/api-client.js +3 -3
- package/dist/commands/broker-permissions.d.ts +2 -0
- package/dist/commands/broker-permissions.js +1 -0
- package/dist/commands/canvas-analytics/chart.d.ts +52 -0
- package/dist/commands/canvas-analytics/chart.js +1 -0
- package/dist/commands/canvas-analytics/drilldown.d.ts +34 -0
- package/dist/commands/canvas-analytics/drilldown.js +1 -0
- package/dist/commands/canvas-analytics/format.d.ts +29 -0
- package/dist/commands/canvas-analytics/format.js +1 -0
- package/dist/commands/canvas-analytics/graph-detail.d.ts +2 -0
- package/dist/commands/canvas-analytics/graph-detail.js +2 -0
- package/dist/commands/canvas-analytics/graphs.d.ts +9 -0
- package/dist/commands/canvas-analytics/graphs.js +1 -0
- package/dist/commands/canvas-analytics/memory.d.ts +2 -0
- package/dist/commands/canvas-analytics/memory.js +1 -0
- package/dist/commands/canvas-analytics/overview.d.ts +2 -0
- package/dist/commands/canvas-analytics/overview.js +1 -0
- package/dist/commands/canvas-analytics/shell.d.ts +60 -0
- package/dist/commands/canvas-analytics/shell.js +2 -0
- package/dist/commands/canvas-analytics/time.d.ts +2 -0
- package/dist/commands/canvas-analytics/time.js +1 -0
- package/dist/commands/canvas-analytics/usage.d.ts +2 -0
- package/dist/commands/canvas-analytics/usage.js +1 -0
- package/dist/commands/canvas-analytics/view.d.ts +85 -0
- package/dist/commands/canvas-analytics/view.js +1 -0
- package/dist/commands/canvas-analytics.d.ts +2 -0
- package/dist/commands/canvas-analytics.js +1 -0
- package/dist/commands/canvas-prune.js +1 -1
- package/dist/commands/canvas.js +1 -1
- package/dist/commands/cron.js +5 -5
- package/dist/commands/human/components.d.ts +2 -0
- package/dist/commands/human/components.js +2 -2
- package/dist/commands/human/prompts.js +1 -1
- package/dist/commands/human/queue.js +1 -1
- package/dist/commands/memory/client.d.ts +11 -0
- package/dist/commands/memory/client.js +1 -0
- package/dist/commands/memory/delete.js +1 -1
- package/dist/commands/memory/edit.js +3 -3
- package/dist/commands/memory/find.js +1 -1
- package/dist/commands/memory/history.js +4 -4
- package/dist/commands/memory/lint.js +1 -1
- package/dist/commands/memory/list.d.ts +0 -2
- package/dist/commands/memory/list.js +1 -1
- package/dist/commands/memory/move.js +1 -1
- package/dist/commands/memory/origin.js +1 -1
- package/dist/commands/memory/read.d.ts +0 -5
- package/dist/commands/memory/read.js +3 -3
- package/dist/commands/memory/shared.d.ts +0 -178
- package/dist/commands/memory/shared.js +1 -12
- package/dist/commands/memory/write.js +5 -5
- package/dist/commands/node/bash.js +5 -5
- package/dist/commands/node/create.d.ts +0 -17
- package/dist/commands/node/create.js +2 -3
- package/dist/commands/node/inspect.js +6 -6
- package/dist/commands/node/lifecycle.js +2 -2
- package/dist/commands/node-context.js +2 -2
- package/dist/commands/node-inspect-artifacts.js +6 -6
- package/dist/commands/pkg/browse/catalog.js +1 -1
- package/dist/commands/pkg/browse/model.d.ts +1 -1
- package/dist/commands/pkg/market-manage.js +1 -1
- package/dist/commands/pkg/plugin-manage.js +10 -10
- package/dist/commands/profile/daemon-profiles.d.ts +13 -0
- package/dist/commands/profile/daemon-profiles.js +4 -0
- package/dist/commands/profile/delete.js +1 -1
- package/dist/commands/profile/env.d.ts +6 -0
- package/dist/commands/profile/env.js +2 -2
- package/dist/commands/profile/kind.js +1 -2
- package/dist/commands/profile/list.js +1 -1
- package/dist/commands/profile/meta.js +1 -1
- package/dist/commands/profile/new.js +1 -1
- package/dist/commands/profile/pause.js +1 -1
- package/dist/commands/profile/project.js +1 -1
- package/dist/commands/profile/rename.js +1 -1
- package/dist/commands/profile/show.js +1 -1
- package/dist/commands/profile.js +1 -1
- package/dist/commands/push.js +3 -3
- package/dist/commands/surface-inspect.js +1 -1
- package/dist/commands/sys/branch.js +1 -1
- package/dist/commands/sys/config.js +1 -1
- package/dist/commands/sys/connect.js +3 -3
- package/dist/commands/sys/context/admin/actions.js +1 -1
- package/dist/commands/sys/context/admin/model.d.ts +1 -0
- package/dist/commands/sys/context/admin/model.js +1 -1
- package/dist/commands/sys/context/admin.js +1 -1
- package/dist/commands/sys/context/expose.js +2 -1
- package/dist/commands/sys/context/prompt-review.js +2 -2
- package/dist/commands/sys/context/resolve.js +7 -7
- package/dist/commands/sys/context/sysprompt.js +1 -1
- package/dist/commands/sys/join.d.ts +1 -0
- package/dist/commands/sys/join.js +1 -0
- package/dist/commands/sys/migrate.js +1 -1
- package/dist/commands/sys/panels/models-panel.js +1 -1
- package/dist/commands/sys/panels/profiles-panel.d.ts +0 -1
- package/dist/commands/sys/panels/profiles-panel.js +1 -1
- package/dist/commands/sys/provider-login.js +6 -6
- package/dist/commands/sys/setup-core.d.ts +1 -1
- package/dist/commands/sys/setup-core.js +6 -6
- package/dist/commands/sys/setup-settings-runner.js +1 -1
- package/dist/commands/sys/setup.js +1 -1
- package/dist/commands/sys/spaces.d.ts +1 -0
- package/dist/commands/sys/spaces.js +2 -0
- package/dist/commands/sys/sync-deps.js +2 -2
- package/dist/commands/sys/sync-project-guidance.js +4 -4
- package/dist/commands/sys/sync-skills.js +2 -2
- package/dist/commands/sys/worktrees.d.ts +1 -0
- package/dist/commands/sys/worktrees.js +1 -1
- package/dist/commands/sys.js +1 -1
- package/dist/core/auth-file.js +2 -2
- package/dist/core/bash-job-supervisor.d.ts +6 -0
- package/dist/core/bash-job-supervisor.js +4 -0
- package/dist/core/bash-jobs.d.ts +13 -6
- package/dist/core/bash-jobs.js +8 -7
- package/dist/core/broker-client/transport-relay.d.ts +6 -3
- package/dist/core/broker-client/transport-relay.js +1 -1
- package/dist/core/broker-client/transport-socket.d.ts +6 -1
- package/dist/core/broker-client/transport-socket.js +1 -1
- package/dist/core/canvas/canvas.d.ts +39 -18
- package/dist/core/canvas/canvas.js +21 -20
- package/dist/core/canvas/context-strip.d.ts +20 -0
- package/dist/core/canvas/context-strip.js +5 -0
- package/dist/core/canvas/crons.d.ts +12 -20
- package/dist/core/canvas/crons.js +15 -13
- package/dist/core/canvas/db.js +2 -2
- package/dist/core/canvas/deliveries.d.ts +4 -1
- package/dist/core/canvas/deliveries.js +1 -1
- package/dist/core/canvas/executions.js +1 -1
- package/dist/core/canvas/history.d.ts +2 -1
- package/dist/core/canvas/history.js +17 -18
- package/dist/core/canvas/memory-reads.d.ts +19 -0
- package/dist/core/canvas/memory-reads.js +1 -0
- package/dist/core/canvas/migrations.d.ts +0 -4
- package/dist/core/canvas/migrations.js +99 -32
- package/dist/core/canvas/nav-render.js +1 -1
- package/dist/core/canvas/node-agent-paths.d.ts +8 -0
- package/dist/core/canvas/node-agent-paths.js +1 -0
- package/dist/core/canvas/node-recap.d.ts +2 -2
- package/dist/core/canvas/node-recap.js +2 -2
- package/dist/core/canvas/node-tokens.d.ts +24 -0
- package/dist/core/canvas/node-tokens.js +5 -0
- package/dist/core/canvas/paths.d.ts +16 -19
- package/dist/core/canvas/paths.js +1 -1
- package/dist/core/canvas/render-source.d.ts +2 -2
- package/dist/core/canvas/render-source.js +6 -9
- package/dist/core/canvas/sessions.d.ts +18 -0
- package/dist/core/canvas/sessions.js +4 -1
- package/dist/core/canvas/types.d.ts +22 -6
- package/dist/core/command-hooks/compose.js +1 -1
- package/dist/core/command-hooks/discovery.d.ts +15 -1
- package/dist/core/command-hooks/discovery.js +1 -1
- package/dist/core/command-hooks/help.d.ts +2 -2
- package/dist/core/command-hooks/lifecycle-create.d.ts +1 -1
- package/dist/core/command-hooks/lifecycle-create.js +1 -1
- package/dist/core/command-hooks/transport/exec-invoke.d.ts +2 -0
- package/dist/core/command-hooks/transport/exec-invoke.js +1 -1
- package/dist/core/command-hooks/transport/exec-lifecycle.d.ts +1 -0
- package/dist/core/command-hooks/transport/exec-lifecycle.js +1 -1
- package/dist/core/command-hooks/transport/plan.d.ts +3 -0
- package/dist/core/command-hooks/transport/plan.js +1 -0
- package/dist/core/command-plugins/discovery.js +1 -1
- package/dist/core/command-plugins/transport/http-invoke.js +2 -2
- package/dist/core/command.d.ts +6 -2
- package/dist/core/command.js +6 -6
- package/dist/core/config.d.ts +8 -5
- package/dist/core/config.js +1 -1
- package/dist/core/conversation-store/client-worker.d.ts +1 -0
- package/dist/core/conversation-store/client-worker.js +1 -0
- package/dist/core/conversation-store/client.d.ts +2 -0
- package/dist/core/conversation-store/client.js +2 -0
- package/dist/core/conversation-store/file-store.d.ts +37 -0
- package/dist/core/conversation-store/file-store.js +9 -0
- package/dist/core/conversation-store/index.d.ts +50 -0
- package/dist/core/conversation-store/index.js +1 -0
- package/dist/core/conversation-store/listener.d.ts +4 -0
- package/dist/core/conversation-store/listener.js +3 -0
- package/dist/core/conversation-store/patch.d.ts +1 -0
- package/dist/core/conversation-store/patch.js +1 -0
- package/dist/core/directory/join.d.ts +27 -0
- package/dist/core/directory/join.js +1 -0
- package/dist/core/disk-usage.d.ts +4 -0
- package/dist/core/disk-usage.js +1 -0
- package/dist/core/events/emit.d.ts +2 -0
- package/dist/core/events/emit.js +3 -1
- package/dist/core/feed/feed.js +4 -4
- package/dist/core/feed/messages.d.ts +3 -0
- package/dist/core/feed/messages.js +6 -6
- package/dist/core/fs-utils.d.ts +2 -0
- package/dist/core/fs-utils.js +3 -3
- package/dist/core/grants/local.d.ts +4 -0
- package/dist/core/grants/local.js +1 -0
- package/dist/core/grants/mirror.d.ts +44 -0
- package/dist/core/grants/mirror.js +4 -0
- package/dist/core/grants/on-sync.d.ts +22 -0
- package/dist/core/grants/on-sync.js +1 -0
- package/dist/core/grants/remove.d.ts +7 -0
- package/dist/core/grants/remove.js +1 -0
- package/dist/core/grants/sandboxes.d.ts +7 -0
- package/dist/core/grants/sandboxes.js +1 -0
- package/dist/core/grants/sync.d.ts +12 -0
- package/dist/core/grants/sync.js +1 -0
- package/dist/core/help/memory-extensions.d.ts +3 -0
- package/dist/core/help/memory-extensions.js +2 -0
- package/dist/core/help.d.ts +14 -0
- package/dist/core/help.js +7 -7
- package/dist/core/host-exports/builtins.js +3 -3
- package/dist/core/host-exports/export.js +3 -3
- package/dist/core/human/action-binding.d.ts +2 -0
- package/dist/core/human/action-binding.js +1 -1
- package/dist/core/human/feedback-companion.d.ts +0 -1
- package/dist/core/human/feedback-companion.js +1 -1
- package/dist/core/human/page-schema.d.ts +1 -1
- package/dist/core/inspector/core.d.ts +2 -0
- package/dist/core/inspector/core.js +1 -1
- package/dist/core/inspector/tui.js +2 -2
- package/dist/core/installed-plugins.js +1 -1
- package/dist/core/io.js +6 -6
- package/dist/core/keybindings/catalog.d.ts +1 -1
- package/dist/core/keybindings/catalog.js +1 -1
- package/dist/core/layout-migrate/index.d.ts +15 -0
- package/dist/core/layout-migrate/index.js +4 -0
- package/dist/core/layout-migrate/paths.d.ts +26 -0
- package/dist/core/layout-migrate/paths.js +1 -0
- package/dist/core/layout-migrate/stored-paths.d.ts +2 -0
- package/dist/core/layout-migrate/stored-paths.js +11 -0
- package/dist/core/layout-migrate/stores.d.ts +17 -0
- package/dist/core/layout-migrate/stores.js +4 -0
- package/dist/core/layout.d.ts +26 -0
- package/dist/core/layout.js +2 -0
- package/dist/core/llm/run.d.ts +60 -0
- package/dist/core/llm/run.js +4 -0
- package/dist/core/memory/cli-selector.d.ts +13 -0
- package/dist/core/memory/cli-selector.js +1 -0
- package/dist/core/memory/history.d.ts +5 -4
- package/dist/core/memory/history.js +6 -6
- package/dist/core/memory/inline-ref-inventory.d.ts +2 -1
- package/dist/core/memory/inline-ref-inventory.js +1 -1
- package/dist/core/memory/lint.js +2 -2
- package/dist/core/memory/mutation-domain.d.ts +2 -2
- package/dist/core/memory/mutation-domain.js +8 -7
- package/dist/core/memory/mutations.js +1 -1
- package/dist/core/memory/service.d.ts +5 -0
- package/dist/core/memory/service.js +2 -2
- package/dist/core/memory-resolver.d.ts +11 -7
- package/dist/core/memory-resolver.js +2 -2
- package/dist/core/model-auth/daemon-login.d.ts +13 -0
- package/dist/core/model-auth/daemon-login.js +1 -0
- package/dist/core/model-auth/flows.d.ts +45 -0
- package/dist/core/model-auth/flows.js +1 -0
- package/dist/core/model-auth/handoff-jti.d.ts +4 -0
- package/dist/core/model-auth/handoff-jti.js +1 -0
- package/dist/core/model-routes.js +1 -1
- package/dist/core/nested-stores.d.ts +2 -1
- package/dist/core/nested-stores.js +1 -2
- package/dist/core/preview-registry.js +2 -2
- package/dist/core/profiles/env-store.js +2 -2
- package/dist/core/profiles/manifest.d.ts +16 -5
- package/dist/core/profiles/manifest.js +1 -1
- package/dist/core/provider-management.js +1 -1
- package/dist/core/review/birth.js +1 -1
- package/dist/core/review/companion.d.ts +0 -2
- package/dist/core/review/companion.js +1 -1
- package/dist/core/review/fork.js +2 -2
- package/dist/core/review/realize.js +1 -1
- package/dist/core/review/stage.d.ts +1 -1
- package/dist/core/review/stage.js +1 -1
- package/dist/core/review/types.d.ts +1 -1
- package/dist/core/runs/events.d.ts +34 -0
- package/dist/core/runs/events.js +1 -0
- package/dist/core/runs/operations.d.ts +43 -0
- package/dist/core/runs/operations.js +12 -0
- package/dist/core/runtime/bearings-render.d.ts +2 -2
- package/dist/core/runtime/bearings-render.js +11 -11
- package/dist/core/runtime/bearings.js +2 -2
- package/dist/core/runtime/broker/cli-relay.d.ts +5 -0
- package/dist/core/runtime/broker/cli-relay.js +1 -0
- package/dist/core/runtime/broker/client-registry.d.ts +0 -5
- package/dist/core/runtime/broker/client-registry.js +1 -1
- package/dist/core/runtime/broker/daemon-ops.d.ts +28 -1
- package/dist/core/runtime/broker/daemon-ops.js +1 -1
- package/dist/core/runtime/broker/engine-drive.d.ts +0 -2
- package/dist/core/runtime/broker/engine-drive.js +1 -1
- package/dist/core/runtime/broker/fault-retry.d.ts +9 -0
- package/dist/core/runtime/broker/fault-retry.js +1 -1
- package/dist/core/runtime/broker/frame-dispatch.d.ts +5 -9
- package/dist/core/runtime/broker/frame-dispatch.js +1 -1
- package/dist/core/runtime/broker/frame-engine-control.d.ts +3 -2
- package/dist/core/runtime/broker/frame-engine-control.js +1 -1
- package/dist/core/runtime/broker/frame-memory-refs.d.ts +4 -3
- package/dist/core/runtime/broker/frame-memory-refs.js +1 -1
- package/dist/core/runtime/broker/frame-read.js +1 -1
- package/dist/core/runtime/broker/frame-session.js +1 -1
- package/dist/core/runtime/broker/held-deferred-inbox.d.ts +3 -1
- package/dist/core/runtime/broker/held-deferred-inbox.js +1 -1
- package/dist/core/runtime/broker/inbox.d.ts +1 -2
- package/dist/core/runtime/broker/inbox.js +7 -10
- package/dist/core/runtime/broker/model-adapter.d.ts +9 -0
- package/dist/core/runtime/broker/model-adapter.js +2 -0
- package/dist/core/runtime/broker/node-token.d.ts +3 -0
- package/dist/core/runtime/broker/node-token.js +1 -0
- package/dist/core/runtime/broker/read-ops.js +1 -1
- package/dist/core/runtime/broker/rebind.d.ts +2 -0
- package/dist/core/runtime/broker/rebind.js +1 -1
- package/dist/core/runtime/broker/tool-groups.js +1 -1
- package/dist/core/runtime/broker/turn-ignition.d.ts +3 -3
- package/dist/core/runtime/broker/turn-ignition.js +1 -1
- package/dist/core/runtime/broker-cli.js +3 -3
- package/dist/core/runtime/broker-extension-render.d.ts +2 -5
- package/dist/core/runtime/broker-extension-render.js +4 -4
- package/dist/core/runtime/broker-persona-guidance.js +3 -3
- package/dist/core/runtime/broker-protocol.d.ts +7 -8
- package/dist/core/runtime/broker.js +1 -1
- package/dist/core/runtime/canvas-extensions.d.ts +1 -0
- package/dist/core/runtime/canvas-extensions.js +1 -1
- package/dist/core/runtime/close.d.ts +9 -0
- package/dist/core/runtime/close.js +1 -1
- package/dist/core/runtime/deliver-live.js +1 -1
- package/dist/core/runtime/fleet.d.ts +1 -1
- package/dist/core/runtime/front-door-login.js +1 -1
- package/dist/core/runtime/front-door.js +2 -2
- package/dist/core/runtime/headless-pi.d.ts +1 -1
- package/dist/core/runtime/headless-pi.js +1 -1
- package/dist/core/runtime/host.d.ts +1 -1
- package/dist/core/runtime/host.js +3 -1
- package/dist/core/runtime/invocation.d.ts +3 -0
- package/dist/core/runtime/kickoff.d.ts +1 -0
- package/dist/core/runtime/kickoff.js +16 -16
- package/dist/core/runtime/launch-target.d.ts +1 -1
- package/dist/core/runtime/launch-target.js +1 -1
- package/dist/core/runtime/launch.d.ts +10 -35
- package/dist/core/runtime/launch.js +1 -1
- package/dist/core/runtime/lifecycle.js +2 -2
- package/dist/core/runtime/memory.d.ts +1 -1
- package/dist/core/runtime/memory.js +1 -1
- package/dist/core/runtime/model-registry.js +1 -1
- package/dist/core/runtime/model-swap.d.ts +17 -19
- package/dist/core/runtime/model-swap.js +1 -1
- package/dist/core/runtime/node-read.js +3 -2
- package/dist/core/runtime/nodes.d.ts +7 -0
- package/dist/core/runtime/nodes.js +1 -1
- package/dist/core/runtime/outcome-document.js +1 -1
- package/dist/core/runtime/package-health.js +2 -2
- package/dist/core/runtime/persona.js +2 -2
- package/dist/core/runtime/pi-vendored.js +1 -1
- package/dist/core/runtime/placement-tmux.d.ts +1 -1
- package/dist/core/runtime/placement-tmux.js +1 -1
- package/dist/core/runtime/placement.js +1 -1
- package/dist/core/runtime/promote.js +1 -1
- package/dist/core/runtime/provider-credential-gate.js +2 -2
- package/dist/core/runtime/recovery-hold.d.ts +2 -0
- package/dist/core/runtime/recovery-hold.js +1 -0
- package/dist/core/runtime/recycle.js +1 -1
- package/dist/core/runtime/reopen.js +1 -1
- package/dist/core/runtime/reset.js +1 -1
- package/dist/core/runtime/revive.d.ts +1 -1
- package/dist/core/runtime/revive.js +2 -3
- package/dist/core/runtime/roadmap.js +4 -4
- package/dist/core/runtime/run-command.d.ts +6 -0
- package/dist/core/runtime/run-command.js +1 -1
- package/dist/core/runtime/session-branch.d.ts +2 -8
- package/dist/core/runtime/session-branch.js +1 -1
- package/dist/core/runtime/session-list-cache.d.ts +6 -22
- package/dist/core/runtime/session-list-cache.js +1 -1
- package/dist/core/runtime/situational-context.js +2 -2
- package/dist/core/runtime/spawn-env.d.ts +6 -6
- package/dist/core/runtime/spawn-env.js +1 -1
- package/dist/core/runtime/spawn.d.ts +5 -0
- package/dist/core/runtime/spawn.js +2 -2
- package/dist/core/runtime/stop-guard.js +2 -2
- package/dist/core/runtime/stop-signals.d.ts +2 -2
- package/dist/core/runtime/stop-signals.js +1 -1
- package/dist/core/runtime/structured-output.d.ts +10 -4
- package/dist/core/runtime/structured-output.js +4 -4
- package/dist/core/runtime/tmux-bindings.js +3 -3
- package/dist/core/runtime/tmux-driver.d.ts +4 -0
- package/dist/core/runtime/tmux-driver.js +7 -7
- package/dist/core/runtime/view-socket.d.ts +9 -2
- package/dist/core/runtime/view-socket.js +1 -1
- package/dist/core/runtime/warm-pool.js +1 -1
- package/dist/core/scope.d.ts +3 -2
- package/dist/core/scope.js +1 -1
- package/dist/core/scoped-state/db.js +1 -1
- package/dist/core/scoped-state/migrate.js +3 -3
- package/dist/core/scoped-state/profiles.d.ts +2 -1
- package/dist/core/scoped-state/profiles.js +1 -1
- package/dist/core/scoped-state/schema.d.ts +2 -1
- package/dist/core/scoped-state/schema.js +4 -4
- package/dist/core/scopes.d.ts +2 -2
- package/dist/core/scopes.js +1 -1
- package/dist/core/secrets.d.ts +1 -0
- package/dist/core/secrets.js +2 -2
- package/dist/core/spaces/mounts.d.ts +32 -0
- package/dist/core/spaces/mounts.js +1 -0
- package/dist/core/spaces/open-beneath.d.ts +71 -0
- package/dist/core/spaces/open-beneath.js +1 -0
- package/dist/core/spaces/permissions.d.ts +46 -0
- package/dist/core/spaces/permissions.js +1 -0
- package/dist/core/spaces/process.d.ts +27 -0
- package/dist/core/spaces/process.js +1 -0
- package/dist/core/spaces/space.d.ts +8 -0
- package/dist/core/spaces/space.js +2 -0
- package/dist/core/spaces/stop.d.ts +8 -0
- package/dist/core/spaces/stop.js +2 -0
- package/dist/core/spaces/users.d.ts +19 -0
- package/dist/core/spaces/users.js +1 -0
- package/dist/core/subscription-state.d.ts +2 -0
- package/dist/core/subscription-state.js +3 -3
- package/dist/core/substrate/frontmatter-validation.js +1 -1
- package/dist/core/substrate/injected-store.d.ts +28 -3
- package/dist/core/substrate/injected-store.js +2 -1
- package/dist/core/substrate/listings.js +1 -1
- package/dist/core/substrate/memory-events.d.ts +6 -0
- package/dist/core/substrate/memory-events.js +1 -0
- package/dist/core/substrate/on-read-node.js +1 -1
- package/dist/core/substrate/on-read.d.ts +6 -6
- package/dist/core/substrate/on-read.js +5 -5
- package/dist/core/substrate/plan.js +1 -1
- package/dist/core/substrate/render-node.js +1 -1
- package/dist/core/substrate/render.d.ts +4 -3
- package/dist/core/substrate/render.js +38 -38
- package/dist/core/substrate/schema.d.ts +6 -0
- package/dist/core/substrate/schema.js +1 -1
- package/dist/core/tui/panel.js +1 -1
- package/dist/core/user-settings.d.ts +12 -0
- package/dist/core/user-settings.js +1 -1
- package/dist/core/worktree-mutation-async.js +5 -5
- package/dist/core/worktree-quarantine.js +1 -1
- package/dist/core/worktree-remove.d.ts +15 -0
- package/dist/core/worktree-remove.js +1 -0
- package/dist/core/worktree-sweep.js +6 -6
- package/dist/daemon/analytics/compute.d.ts +37 -0
- package/dist/daemon/analytics/compute.js +1 -0
- package/dist/daemon/analytics/scan-worker.d.ts +1 -0
- package/dist/daemon/analytics/scan-worker.js +2 -0
- package/dist/daemon/analytics/scan.d.ts +37 -0
- package/dist/daemon/analytics/scan.js +1 -0
- package/dist/daemon/api/app-listener.d.ts +11 -0
- package/dist/daemon/api/app-listener.js +21 -0
- package/dist/daemon/api/bridge.js +5 -5
- package/dist/daemon/api/handlers/analytics.d.ts +2 -0
- package/dist/daemon/api/handlers/analytics.js +1 -0
- package/dist/daemon/api/handlers/attach.js +1 -1
- package/dist/daemon/api/handlers/bash-jobs.js +2 -2
- package/dist/daemon/api/handlers/bash.js +1 -1
- package/dist/daemon/api/handlers/broker-ops.js +1 -1
- package/dist/daemon/api/handlers/canvas.d.ts +1 -1
- package/dist/daemon/api/handlers/canvas.js +6 -6
- package/dist/daemon/api/handlers/crons.js +1 -1
- package/dist/daemon/api/handlers/files.d.ts +1 -1
- package/dist/daemon/api/handlers/files.js +1 -1
- package/dist/daemon/api/handlers/health.js +2 -2
- package/dist/daemon/api/handlers/hook-exec.d.ts +2 -0
- package/dist/daemon/api/handlers/hook-exec.js +1 -0
- package/dist/daemon/api/handlers/human-requests.js +1 -1
- package/dist/daemon/api/handlers/inbox.js +1 -1
- package/dist/daemon/api/handlers/llm.d.ts +2 -0
- package/dist/daemon/api/handlers/llm.js +3 -0
- package/dist/daemon/api/handlers/memory-reads.d.ts +4 -0
- package/dist/daemon/api/handlers/memory-reads.js +1 -0
- package/dist/daemon/api/handlers/memory.js +5 -1
- package/dist/daemon/api/handlers/messages.js +2 -2
- package/dist/daemon/api/handlers/modelauth.js +1 -1
- package/dist/daemon/api/handlers/node-outcomes.js +1 -1
- package/dist/daemon/api/handlers/node-records.d.ts +2 -0
- package/dist/daemon/api/handlers/node-records.js +3 -0
- package/dist/daemon/api/handlers/nodes.d.ts +1 -1
- package/dist/daemon/api/handlers/nodes.js +1 -1
- package/dist/daemon/api/handlers/profiles.d.ts +4 -1
- package/dist/daemon/api/handlers/profiles.js +1 -1
- package/dist/daemon/api/handlers/reports.js +5 -3
- package/dist/daemon/api/handlers/reviews.d.ts +1 -1
- package/dist/daemon/api/handlers/reviews.js +1 -1
- package/dist/daemon/api/handlers/run-routes.d.ts +2 -0
- package/dist/daemon/api/handlers/run-routes.js +1 -0
- package/dist/daemon/api/handlers/runs.d.ts +9 -0
- package/dist/daemon/api/handlers/runs.js +1 -0
- package/dist/daemon/api/handlers/subscriptions.js +1 -1
- package/dist/daemon/api/handlers/worktree.js +1 -1
- package/dist/daemon/api/map.d.ts +10 -4
- package/dist/daemon/api/map.js +2 -2
- package/dist/daemon/api/operations.d.ts +18 -0
- package/dist/daemon/api/operations.js +1 -0
- package/dist/daemon/api/principal.d.ts +42 -0
- package/dist/daemon/api/principal.js +1 -0
- package/dist/daemon/api/router.d.ts +27 -3
- package/dist/daemon/api/router.js +1 -1
- package/dist/daemon/api/server.d.ts +4 -0
- package/dist/daemon/api/server.js +1 -1
- package/dist/daemon/api/vendor-signin.d.ts +7 -0
- package/dist/daemon/api/vendor-signin.js +77 -0
- package/dist/daemon/api/viewer-presence.d.ts +3 -0
- package/dist/daemon/api/viewer-presence.js +1 -0
- package/dist/daemon/cron/armed-context.d.ts +4 -0
- package/dist/daemon/cron/armed-context.js +1 -1
- package/dist/daemon/cron/escalation.js +3 -3
- package/dist/daemon/cron/lease-recovery.js +1 -1
- package/dist/daemon/cron/sinks.js +2 -2
- package/dist/daemon/cron-run.d.ts +5 -5
- package/dist/daemon/cron-run.js +1 -1
- package/dist/daemon/crtrd-cli.js +1 -1
- package/dist/daemon/crtrd.js +8 -7
- package/dist/daemon/delivery/run-delivery.d.ts +4 -0
- package/dist/daemon/delivery/run-delivery.js +1 -1
- package/dist/daemon/fleet.d.ts +1 -1
- package/dist/daemon/fleet.js +6 -6
- package/dist/daemon/http-dispatcher.d.ts +1 -0
- package/dist/daemon/http-dispatcher.js +1 -0
- package/dist/daemon/human/finish.js +7 -7
- package/dist/daemon/joined-owner.d.ts +5 -0
- package/dist/daemon/joined-owner.js +1 -0
- package/dist/daemon/manage.js +2 -2
- package/dist/daemon/messaging/node-message.js +1 -1
- package/dist/daemon/park-activity.js +1 -1
- package/dist/daemon/reconcilers/bash-deadline.js +1 -1
- package/dist/daemon/reconcilers/broker-supervision.d.ts +1 -1
- package/dist/daemon/reconcilers/broker-supervision.js +4 -4
- package/dist/daemon/reconcilers/delivery-lane.js +1 -1
- package/dist/daemon/reconcilers/live-obligation.d.ts +7 -0
- package/dist/daemon/reconcilers/live-obligation.js +1 -1
- package/dist/daemon/reconcilers/node-lifecycle/tick.js +1 -1
- package/dist/daemon/reconcilers/storage-maintenance.d.ts +20 -1
- package/dist/daemon/reconcilers/storage-maintenance.js +1 -1
- package/dist/daemon/runs/append-section.d.ts +6 -0
- package/dist/daemon/runs/append-section.js +2 -0
- package/dist/daemon/runs/observer.d.ts +5 -0
- package/dist/daemon/runs/observer.js +4 -0
- package/dist/launcher/bwrap.d.ts +4 -0
- package/dist/launcher/bwrap.js +2 -0
- package/dist/launcher/client.d.ts +2 -0
- package/dist/launcher/client.js +3 -0
- package/dist/launcher/main.d.ts +1 -0
- package/dist/launcher/main.js +3 -0
- package/dist/launcher/netrule.d.ts +1 -0
- package/dist/launcher/netrule.js +1 -0
- package/dist/launcher/seccomp.d.ts +1 -0
- package/dist/launcher/seccomp.js +1 -0
- package/dist/launcher/spec.d.ts +88 -0
- package/dist/launcher/spec.js +1 -0
- package/dist/launcher/users.d.ts +18 -0
- package/dist/launcher/users.js +7 -0
- package/dist/launcher/validate.d.ts +22 -0
- package/dist/launcher/validate.js +1 -0
- package/dist/migrations/corpus.js +3 -3
- package/dist/migrations/runner.js +1 -1
- package/dist/native/linux/addon.node +0 -0
- package/dist/native/linux.d.ts +29 -0
- package/dist/native/linux.js +1 -0
- package/dist/pi-extensions/broker-local.js +2 -2
- package/dist/pi-extensions/canvas-bash-valve.d.ts +1 -3
- package/dist/pi-extensions/canvas-bash-valve.js +4 -7
- package/dist/pi-extensions/canvas-context-intro.d.ts +1 -2
- package/dist/pi-extensions/canvas-context-intro.js +2 -2
- package/dist/pi-extensions/canvas-doc-substrate.js +6 -6
- package/dist/pi-extensions/canvas-inbox-watcher.d.ts +2 -1
- package/dist/pi-extensions/canvas-inbox-watcher.js +2 -1
- package/dist/pi-extensions/canvas-passive-context.d.ts +1 -1
- package/dist/pi-extensions/canvas-passive-context.js +11 -11
- package/dist/pi-extensions/canvas-recap.js +6 -6
- package/dist/pi-extensions/canvas-stophook.js +1 -1
- package/dist/pi-extensions/canvas-structured-output.js +4 -4
- package/dist/pi-extensions/canvas-tool-guide.js +1 -1
- package/dist/pi-extensions/system-prompt-entry.d.ts +15 -0
- package/dist/pi-extensions/system-prompt-entry.js +1 -0
- package/dist/shared/env.d.ts +5 -1
- package/dist/shared/env.js +1 -1
- package/dist/shared/strip-cd-prefix.d.ts +1 -0
- package/dist/shared/strip-cd-prefix.js +1 -0
- package/dist/types.d.ts +31 -15
- package/docs/cli/memory-and-preferences.md +3 -1
- package/docs/sdk/client.md +34 -0
- package/docs/sdk/errors.md +2 -0
- package/docs/sdk/memory.md +2 -2
- package/docs/sdk/streaming.md +21 -0
- package/package.json +19 -4
- package/packages/crouter-identity/dist/index.d.ts +54 -0
- package/packages/crouter-identity/dist/index.js +166 -0
- package/packages/crouter-identity/package.json +33 -0
- package/runtime.lock.json +44 -8
- package/scripts/build-native-linux.mjs +16 -0
- package/scripts/install-runtime.mjs +9 -7
- package/scripts/lib/isolation-env.mjs +42 -0
- package/scripts/runtime-smoke.mjs +49 -0
- package/src/native/linux/addon.c +249 -0
- package/dist/core/profiles/state-block.d.ts +0 -4
- package/dist/core/profiles/state-block.js +0 -3
- package/dist/core/runtime/broker/auth-reload.d.ts +0 -41
- package/dist/core/runtime/broker/auth-reload.js +0 -1
- package/dist/core/substrate/cli-context-delivery.d.ts +0 -22
- package/dist/core/substrate/cli-context-delivery.js +0 -1
|
@@ -11,7 +11,17 @@ export function runtimeHome() {
|
|
|
11
11
|
export const GENERATION_ID = /^[a-f0-9]{64}$/;
|
|
12
12
|
export const MANIFEST_SCHEMA = 1;
|
|
13
13
|
export const PACKAGE_NAME = '@north-light/crouter';
|
|
14
|
-
export const ENTRY_NAMES = ['broker', 'cli', 'daemon'];
|
|
14
|
+
export const ENTRY_NAMES = ['broker', 'cli', 'daemon', 'launcher'];
|
|
15
|
+
/** Entries every generation carries. Generations installed before the root
|
|
16
|
+
* launcher existed lack `launcher`; a source-linked install moves `bin/` with
|
|
17
|
+
* git while the installed generation stays put, so launching those older
|
|
18
|
+
* generations must keep working for every entry they do carry. */
|
|
19
|
+
const REQUIRED_ENTRY_NAMES = ['broker', 'cli', 'daemon'];
|
|
20
|
+
|
|
21
|
+
function entryNamesSupported(entries) {
|
|
22
|
+
const names = Object.keys(entries);
|
|
23
|
+
return REQUIRED_ENTRY_NAMES.every((name) => names.includes(name)) && names.every((name) => ENTRY_NAMES.includes(name));
|
|
24
|
+
}
|
|
15
25
|
export const MANIFEST_KEYS = ['arch', 'createdAt', 'entries', 'files', 'id', 'nodeVersion', 'packageName', 'packageVersion', 'platform', 'schema'];
|
|
16
26
|
|
|
17
27
|
/** Extract the Node major version number from a `process.version`-shaped
|
|
@@ -254,7 +264,7 @@ export function validateManifestShape(manifest, { id, entryName }) {
|
|
|
254
264
|
error: `runtime generation was built for node ${manifest.nodeVersion}, this is ${process.version} — reinstall the runtime (\`npm run install-runtime\` / reinstall crouter)`,
|
|
255
265
|
};
|
|
256
266
|
}
|
|
257
|
-
if (manifest.schema !== MANIFEST_SCHEMA || manifest.id !== id || !GENERATION_ID.test(manifest.id) || manifest.packageName !== PACKAGE_NAME || typeof manifest.packageVersion !== 'string' || manifest.packageVersion === '' || manifest.platform !== process.platform || manifest.arch !== process.arch || typeof manifest.createdAt !== 'string' || Number.isNaN(Date.parse(manifest.createdAt)) || !manifest.entries || typeof manifest.entries !== 'object' || Array.isArray(manifest.entries) ||
|
|
267
|
+
if (manifest.schema !== MANIFEST_SCHEMA || manifest.id !== id || !GENERATION_ID.test(manifest.id) || manifest.packageName !== PACKAGE_NAME || typeof manifest.packageVersion !== 'string' || manifest.packageVersion === '' || manifest.platform !== process.platform || manifest.arch !== process.arch || typeof manifest.createdAt !== 'string' || Number.isNaN(Date.parse(manifest.createdAt)) || !manifest.entries || typeof manifest.entries !== 'object' || Array.isArray(manifest.entries) || !entryNamesSupported(manifest.entries) || !Array.isArray(manifest.files)) {
|
|
258
268
|
return { ok: false, error: 'generation manifest has an unsupported schema or identity' };
|
|
259
269
|
}
|
|
260
270
|
const entry = manifest.entries[entryName];
|
package/dist/api/client.d.ts
CHANGED
|
@@ -2,28 +2,30 @@ import type { DaemonAdmitDTO, DaemonRestartDTO, HealthDTO, MigrateStateDTO, Migr
|
|
|
2
2
|
import type { BashJobStatusDTO, BashJobStopResultDTO } from './dto/bash-jobs.js';
|
|
3
3
|
import type { ArtifactListDTO, ArtifactsQuery, ContextListDTO, CreateNodeRequest, ListNodesQuery, NodeDetailDTO, NodeMessagesPageDTO, NodeMessagesQuery, NodeSessionDTO, NodeSnapshotDTO, NodeSubjectDTO, NodeSummaryDTO, TranscriptDTO, TranscriptQuery } from './dto/nodes.js';
|
|
4
4
|
import type { NodeOutcomeResponseDTO, OutcomeDeliveryDTO, RegisterOutcomeDeliveryRequest } from './dto/node-outcomes.js';
|
|
5
|
+
import type { AnalyticsDTO, AnalyticsQuery, MemoryReadsRequestDTO } from './dto/analytics.js';
|
|
5
6
|
import type { NodeEventsQuery } from './dto/node-events.js';
|
|
7
|
+
import type { NodeLogAppendRequest, NodeLogAppendResultDTO, NodeTelemetryRecordRequest, NodeRecapRecordRequest, NodeMessageBodyDTO, NodePushedFinalRequest, NodePushedFinalResultDTO } from './dto/node-records.js';
|
|
6
8
|
import type { InterruptResultDTO, MessageResultDTO, SendMessageRequest } from './dto/messages.js';
|
|
7
9
|
import type { PushReportRequest, PushReportResultDTO, ReportDTO, ReportsQuery, SubmitResultDTO, SubmitResultRequest } from './dto/reports.js';
|
|
8
10
|
import type { CloseRequest, CloseResultDTO, PromoteRequest, RelaunchRootResultDTO, ReviveRequest, ReviveResultDTO, WaitRequest, YieldRequest } from './dto/lifecycle.js';
|
|
9
11
|
import type { SubscribeRequest, SubscriptionDTO } from './dto/subscriptions.js';
|
|
10
12
|
import type { FocusDTO, RegisterFocusRequest, SetFocusPaneRequest } from './dto/focus.js';
|
|
11
13
|
import { type ArmCronRequest, type CancelCronQuery, type CronDTO, type CronRunDTO, type CronScopeQuery, type CronShowDTO, type ListCronsQuery, type PokeCronsResult } from './dto/crons.js';
|
|
12
|
-
import type { NodeConfigPatch } from './dto/config.js';
|
|
14
|
+
import type { KindListDTO, NodeConfigPatch } from './dto/config.js';
|
|
13
15
|
import type { AttachEnsureRequest, AttachEnsureResultDTO } from './dto/attach.js';
|
|
14
|
-
import type { DeleteProfileRequest, DeleteProfileResultDTO, EnsureProfileRequest, ProfileDTO, ProfilePauseResultDTO, UpdateProfileMetadataRequest } from './dto/profiles.js';
|
|
16
|
+
import type { CreateProfileRequest, DeleteProfileRequest, DeleteProfileResultDTO, EnsureProfileRequest, ProfileDTO, ProfileEnvChangeDTO, ProfileEnvNamesDTO, ProfilePauseResultDTO, UpdateProfileMetadataRequest, UpdateProfileRequest } from './dto/profiles.js';
|
|
15
17
|
import type { FileEncoding, FileListDTO, FilePeekDTO, FileWriteDTO } from './dto/files.js';
|
|
16
18
|
import type { BashRunDTO, BashRunParams } from './dto/bash.js';
|
|
17
|
-
import type { MemoryDocCreateRequest, MemoryDocDeletedDTO, MemoryDocDTO, MemoryDocMoveRequest, MemoryDocMovedDTO, MemoryDocRefDTO, MemoryDocUpdateRequest, MemoryHistoryDTO, MemoryHistoryQuery, MemoryListDTO, MemoryListQuery, MemoryScope, MemoryDocSummaryDTO, MemorySearchHitDTO, MemorySearchRequest } from './dto/memory.js';
|
|
19
|
+
import type { MemoryDocCreateRequest, MemoryDocDeletedDTO, MemoryDocDTO, MemoryDocMoveRequest, MemoryDocMovedDTO, MemoryOriginConversationDTO, MemoryDocRefDTO, MemoryDocUpdateRequest, MemoryHistoryDTO, MemoryHistoryQuery, MemoryListDTO, MemoryListQuery, MemoryScope, MemoryDocSummaryDTO, MemorySearchHitDTO, MemorySearchRequest } from './dto/memory.js';
|
|
18
20
|
import type { ChatInventoryDTO, ProspectiveChatInventoryDTO, ProspectiveChatInventoryQuery } from './dto/chat-inventory.js';
|
|
19
|
-
import type { CredentialRemovalResultDTO, CredentialResultDTO, InstallCredentialRequest, ModelAuthListDTO, ModelAuthReadinessDTO, ModelAuthReadinessQuery } from './dto/modelauth.js';
|
|
21
|
+
import type { CredentialRemovalResultDTO, CredentialResultDTO, InstallCredentialRequest, CompleteModelAuthFlowRequest, ModelAuthFlowCompletedDTO, ModelAuthFlowDTO, ModelAuthFlowStartedDTO, ModelAuthListDTO, ModelAuthReadinessDTO, ModelAuthReadinessQuery, StartModelAuthFlowRequest } from './dto/modelauth.js';
|
|
20
22
|
import type { CancelReviewRequest, CreateReviewRequest, ListReviewsQuery, ReviewCancelResultDTO, ReviewDocumentBaseDTO, ReviewDTO, ReviewListDTO, ReviewSubmitResultDTO } from './dto/reviews.js';
|
|
21
23
|
import type { CreateReviewCommentRequest, EditReviewCommentRequest, ListReviewCommentsQuery, ReadReviewCommentEventsQuery, ReviewCommentActionRequest, ReviewCommentDetailDTO, ReviewCommentEventsDTO, ReviewCommentForkDTO, ReviewCommentListDTO, ReviewCommentMutationDTO, ReviewCommentRangeBatchRequest, ReviewCommentRangeBatchResultDTO } from './dto/review-comments.js';
|
|
22
24
|
import type { CancelInboxTicketRequest, CanceledTicketResultDTO, InboxListDTO, InboxPageDTO, InboxPageHistoryDTO, InboxPageResponseDTO, InboxTicketIdDTO, PageFeedbackResolutionDTO, PageResponsesDTO, PageTicketResultDTO, RespondInboxPageRequest } from './dto/inbox.js';
|
|
23
|
-
import type { CreateHumanRequestDTO, CreateHumanRequestRequest, HumanRequestDTO, HumanRequestIdDTO, ReplaceHumanRequestRequest, RespondHumanRequestRequest, SettleHumanRequestRequest } from './dto/human-requests.js';
|
|
25
|
+
import type { CreateHumanRequestDTO, CreateHumanRequestRequest, HumanRequestDTO, HumanRequestIdDTO, ReplaceHumanRequestRequest, RespondHumanRequestRequest, SettleHumanRequestRequest, PageComponentListDTO } from './dto/human-requests.js';
|
|
24
26
|
import type { AttentionCountsDTO, AttentionDTO, DashboardDTO, DashboardQuery, HistoryGrepQuery, HistoryGrepResultDTO, HistoryReadQuery, HistoryStatsQuery, HistoryStatsResultDTO, HistoryReadResultDTO, HistorySearchQuery, HistorySearchResultDTO, GraphDTO, PruneRequest, PruneResultDTO, RosterDTO, SnapshotDTO } from './dto/canvas.js';
|
|
25
|
-
import type { AbandonWorktreeRequest, AbandonWorktreeResultDTO, CloseWorktreeResultDTO, QuarantinedWorktreeDTO } from './dto/worktree.js';
|
|
26
|
-
import type { BrokerExtensionStateDTO, BrokerExecutionRequest, BrokerGeneratedNameRequest, BrokerGeneratedNameResultDTO, BrokerModelCommitRequest, BrokerModelCommitResultDTO, BrokerParkActivityResultDTO, BrokerParkCompleteRequest, BrokerPersonaAckRequest, BrokerPersonaAckResultDTO, BrokerSessionBoundRequest, BrokerSessionBoundResultDTO, BrokerSettleDirective, BrokerSettleRequest, BrokerTelemetryRequest } from './dto/broker-ops.js';
|
|
27
|
+
import type { AbandonWorktreeRequest, AbandonWorktreeResultDTO, CloseWorktreeResultDTO, QuarantinedWorktreeDTO, SpaceListDTO } from './dto/worktree.js';
|
|
28
|
+
import type { BrokerExtensionStateDTO, BrokerContextRequest, BrokerContextDTO, BrokerContextCommitRequest, BrokerContextEventRequest, BrokerExecutionRequest, BrokerGeneratedNameRequest, BrokerGeneratedNameResultDTO, BrokerModelCommitRequest, BrokerModelCommitResultDTO, BrokerParkActivityResultDTO, BrokerParkCompleteRequest, BrokerPersonaAckRequest, BrokerPersonaAckResultDTO, BrokerSessionBoundRequest, BrokerSessionBoundResultDTO, BrokerSettleDirective, BrokerSettleRequest, BrokerTelemetryRequest } from './dto/broker-ops.js';
|
|
27
29
|
import type { AcknowledgeMailRequest, AcknowledgeMailResultDTO, ClaimMailRequest, ClaimMailResultDTO } from './dto/mail.js';
|
|
28
30
|
import type { BrokerFaultInputDTO, BrokerFaultRequest, BrokerFaultResultDTO, BrokerProviderRetryRequest, BrokerProviderRetryResultDTO, BrokerTurnRequest, BrokerTurnResultDTO, NodeFaultClearResultDTO, RecoveryStateDTO } from './dto/recovery.js';
|
|
29
31
|
export interface CrtrClientOptions {
|
|
@@ -100,6 +102,12 @@ export declare class CrtrClient {
|
|
|
100
102
|
restartDaemon(): Promise<DaemonRestartDTO>;
|
|
101
103
|
admitDaemon(): Promise<DaemonAdmitDTO>;
|
|
102
104
|
migrateState(req: MigrateStateRequest): Promise<MigrateStateDTO>;
|
|
105
|
+
appendNodeLog(id: string, req: NodeLogAppendRequest): Promise<NodeLogAppendResultDTO>;
|
|
106
|
+
putNodeTelemetry(id: string, req: NodeTelemetryRecordRequest): Promise<void>;
|
|
107
|
+
putNodeRecap(id: string, req: NodeRecapRecordRequest): Promise<void>;
|
|
108
|
+
readNodeInboxReport(id: string, ref: string, executionId: string): Promise<NodeMessageBodyDTO>;
|
|
109
|
+
readNodePassiveMessage(id: string, ref: string): Promise<NodeMessageBodyDTO>;
|
|
110
|
+
nodePushedFinal(id: string, req: NodePushedFinalRequest): Promise<NodePushedFinalResultDTO>;
|
|
103
111
|
createNode(req: CreateNodeRequest): Promise<NodeDetailDTO>;
|
|
104
112
|
/** List canvas nodes with composable row filters. `include: 'activity'` adds
|
|
105
113
|
* latest/canonical reports and pending-human counts in the same response. */
|
|
@@ -149,6 +157,10 @@ export declare class CrtrClient {
|
|
|
149
157
|
}): Promise<NodeFaultClearResultDTO>;
|
|
150
158
|
commitBrokerModel(id: string, req: BrokerModelCommitRequest): Promise<BrokerModelCommitResultDTO>;
|
|
151
159
|
brokerExtensionState(id: string): Promise<BrokerExtensionStateDTO>;
|
|
160
|
+
brokerContext(id: string, req: BrokerContextRequest): Promise<BrokerContextDTO>;
|
|
161
|
+
brokerMemoryRefs(id: string, expectedExecutionId: string): Promise<import('./dto/broker-ops.js').BrokerMemoryRefsDTO>;
|
|
162
|
+
commitBrokerContext(id: string, req: BrokerContextCommitRequest): Promise<void>;
|
|
163
|
+
brokerContextEvent(id: string, req: BrokerContextEventRequest): Promise<BrokerContextDTO>;
|
|
152
164
|
commitBrokerGeneratedName(id: string, req: BrokerGeneratedNameRequest): Promise<BrokerGeneratedNameResultDTO>;
|
|
153
165
|
commitBrokerPersonaAck(id: string, req: BrokerPersonaAckRequest): Promise<BrokerPersonaAckResultDTO>;
|
|
154
166
|
closeNode(id: string, req?: CloseRequest): Promise<CloseResultDTO>;
|
|
@@ -157,6 +169,9 @@ export declare class CrtrClient {
|
|
|
157
169
|
promoteNode(id: string, req: PromoteRequest): Promise<NodeDetailDTO>;
|
|
158
170
|
yieldNode(id: string, req: YieldRequest): Promise<NodeDetailDTO>;
|
|
159
171
|
waitNode(id: string, req: WaitRequest): Promise<NodeDetailDTO>;
|
|
172
|
+
listKinds(): Promise<KindListDTO>;
|
|
173
|
+
/** A model change may first wait up to 30 s for a starting broker's view
|
|
174
|
+
* socket and then 15 s for its ack, so it gets that budget on top. */
|
|
160
175
|
patchConfig(id: string, patch: NodeConfigPatch): Promise<NodeDetailDTO>;
|
|
161
176
|
/** Land + close the node's managed git worktree (spec §6.2). Server-side
|
|
162
177
|
* because it interleaves a canvas WRITE with a git land transaction and
|
|
@@ -164,6 +179,8 @@ export declare class CrtrClient {
|
|
|
164
179
|
closeWorktree(id: string): Promise<CloseWorktreeResultDTO>;
|
|
165
180
|
abandonWorktree(id: string, req: AbandonWorktreeRequest): Promise<AbandonWorktreeResultDTO>;
|
|
166
181
|
listQuarantinedWorktrees(): Promise<QuarantinedWorktreeDTO[]>;
|
|
182
|
+
/** Every space on the runtime with its size (person only). */
|
|
183
|
+
listSpaces(): Promise<SpaceListDTO>;
|
|
167
184
|
subscribe(id: string, req: SubscribeRequest): Promise<SubscriptionDTO>;
|
|
168
185
|
listFocuses(): Promise<FocusDTO[]>;
|
|
169
186
|
focusOf(nodeId: string): Promise<FocusDTO | null>;
|
|
@@ -217,6 +234,7 @@ export declare class CrtrClient {
|
|
|
217
234
|
writeFile(path: string, content: string, encoding?: FileEncoding, options?: CrtrRequestOptions): Promise<FileWriteDTO>;
|
|
218
235
|
listFiles(path: string, limit?: number, options?: CrtrRequestOptions): Promise<FileListDTO>;
|
|
219
236
|
runBash(params: BashRunParams, options?: CrtrRequestOptions): Promise<BashRunDTO>;
|
|
237
|
+
getMemoryOriginConversation(conversationId: string): Promise<MemoryOriginConversationDTO>;
|
|
220
238
|
/** Resolve an exact canonical `[[name]]` memory-document link to the winning
|
|
221
239
|
* document's physical origin for the given node — the node's own precedence
|
|
222
240
|
* chain, not this process's. Pair with `peekFile` to render the document. */
|
|
@@ -235,7 +253,14 @@ export declare class CrtrClient {
|
|
|
235
253
|
* the profile already exists; their directories are only required to exist
|
|
236
254
|
* when this call creates the profile. */
|
|
237
255
|
ensureProfile(name: string, req?: EnsureProfileRequest): Promise<ProfileDTO>;
|
|
256
|
+
/** Create a profile of the caller's app; a name it already holds is refused. */
|
|
257
|
+
createProfile(req: CreateProfileRequest): Promise<ProfileDTO>;
|
|
238
258
|
listProfiles(): Promise<ProfileDTO[]>;
|
|
259
|
+
/** Rename, set the default kind, or add or remove one project. */
|
|
260
|
+
updateProfile(name: string, req: UpdateProfileRequest): Promise<ProfileDTO>;
|
|
261
|
+
listProfileEnv(name: string): Promise<ProfileEnvNamesDTO>;
|
|
262
|
+
setProfileEnv(name: string, variable: string, value: string): Promise<ProfileEnvChangeDTO>;
|
|
263
|
+
removeProfileEnv(name: string, variable: string): Promise<ProfileEnvChangeDTO>;
|
|
239
264
|
getProfile(name: string): Promise<ProfileDTO>;
|
|
240
265
|
pauseProfile(name: string): Promise<ProfilePauseResultDTO>;
|
|
241
266
|
resumeProfile(name: string): Promise<ProfilePauseResultDTO>;
|
|
@@ -247,6 +272,14 @@ export declare class CrtrClient {
|
|
|
247
272
|
getModelAuthReadiness(query?: ModelAuthReadinessQuery): Promise<ModelAuthReadinessDTO>;
|
|
248
273
|
installCredential(provider: string, req: InstallCredentialRequest): Promise<CredentialResultDTO>;
|
|
249
274
|
removeCredential(provider: string): Promise<CredentialRemovalResultDTO>;
|
|
275
|
+
/** `model_auth.start` — the daemon runs the vendor OAuth; the caller only shows `url`. */
|
|
276
|
+
startModelAuth(req: StartModelAuthFlowRequest): Promise<ModelAuthFlowStartedDTO>;
|
|
277
|
+
/** `model_auth.complete` — hand the daemon the code the vendor showed. */
|
|
278
|
+
completeModelAuth(flowId: string, req: CompleteModelAuthFlowRequest): Promise<ModelAuthFlowCompletedDTO>;
|
|
279
|
+
/** `model_auth.cancel` — end an in-flight flow the person gave up on; it writes nothing. */
|
|
280
|
+
cancelModelAuth(flowId: string): Promise<ModelAuthFlowDTO>;
|
|
281
|
+
/** A flow's state; `waitSeconds` (1-25) long-polls until it leaves `pending`. */
|
|
282
|
+
getModelAuthFlow(flowId: string, waitSeconds?: number): Promise<ModelAuthFlowDTO>;
|
|
250
283
|
createReview(req: CreateReviewRequest): Promise<ReviewDTO>;
|
|
251
284
|
listReviews(query?: ListReviewsQuery): Promise<ReviewListDTO>;
|
|
252
285
|
getReview(reviewId: string): Promise<ReviewDTO>;
|
|
@@ -285,6 +318,8 @@ export declare class CrtrClient {
|
|
|
285
318
|
* `action.name` is rejected before the page is published, leaving no inbox
|
|
286
319
|
* row behind. */
|
|
287
320
|
createHumanRequest(request: CreateHumanRequestRequest): Promise<CreateHumanRequestDTO>;
|
|
321
|
+
/** Product page components registered on the runtime (config + enabled plugins). */
|
|
322
|
+
listPageComponents(): Promise<PageComponentListDTO>;
|
|
288
323
|
/** Read one request: its current state, its answer when answered, and the
|
|
289
324
|
* delivery state of its completion action when it bound one. */
|
|
290
325
|
getHumanRequest(requestId: HumanRequestIdDTO): Promise<HumanRequestDTO>;
|
|
@@ -329,6 +364,14 @@ export declare class CrtrClient {
|
|
|
329
364
|
/** The machine-readable browser canvas roster (`crtr canvas snapshot`) —
|
|
330
365
|
* distinct from the per-node `getSnapshot`. */
|
|
331
366
|
canvasSnapshot(): Promise<SnapshotDTO>;
|
|
367
|
+
/** The Analytics page model (`GET /v1/canvas/analytics`, person only). The
|
|
368
|
+
* daemon scans transcripts for the window: a cold 7d scan of ~2 GB of
|
|
369
|
+
* transcripts measured 10 s, and with scan workers capped at 4 a queued
|
|
370
|
+
* request waits about one scan more. 60 s is 3x that worst case; past it the
|
|
371
|
+
* page shows the error instead of computing forever. */
|
|
372
|
+
analytics(q: AnalyticsQuery): Promise<AnalyticsDTO>;
|
|
373
|
+
/** Record memory reads/loads for one node (`POST /v1/nodes/:id/memory-reads`). */
|
|
374
|
+
recordMemoryReads(nodeId: string, body: MemoryReadsRequestDTO): Promise<void>;
|
|
332
375
|
/** The lean, set-based topology roster (`GET /v1/canvas/roster`) — exactly
|
|
333
376
|
* two indexed queries server-side, no per-row enrichment. The recurring
|
|
334
377
|
* poll target for attach/browser topology; use `canvasSnapshot` for the
|
package/dist/api/client.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var p=Object.defineProperty;var d=(n,e)=>p(n,"name",{value:e,configurable:!0});import{ApiError as h,isErrorBody as b}from"./errors.js";import{routes as r}from"./routes.js";import{isSafeNodeId as S}from"./dto/common.js";import{isSafeBashJobId as g}from"./dto/bash-jobs.js";import{isSafeCronId as R}from"./dto/crons.js";const k=3e4,C=Symbol.for("@north-light/crouter-api/local-socket-fetch"),G=1e4,D=200;async function N({windowMs:n,probe:e,initialError:t,pollIntervalMs:s=D,retry:i=d(()=>!0,"retry"),now:a=Date.now,sleep:P=w}){const l=a()+n;let u=t;for(;;){const c=l-a();if(c<=0)throw u??new Error("crtrd availability window expired without a probe failure");try{await e(c);return}catch(f){if(u=f,!i(f))throw f}const m=l-a();if(m<=0)throw u;await P(Math.min(s,m))}}d(N,"waitForDaemonAvailability");class U{static{d(this,"CrtrClient")}baseUrl;fetch;headers;autostart;timeoutMs;maxRetries;localSocketTransport;onColdSocket;coldStartDiagnostic;coldStartPollWindowMs;coldStartAttempted=!1;constructor(e){if(e.baseUrl==="")throw new TypeError("CrtrClient requires baseUrl");this.baseUrl=new URL(e.baseUrl),this.fetch=e.fetch??globalThis.fetch,this.headers={...e.headers},this.autostart=e.autostart??!1,this.timeoutMs=e.timeoutMs??k,this.maxRetries=e.maxRetries??2,this.localSocketTransport=this.fetch[C]===!0,e.onColdSocket!==void 0&&(this.onColdSocket=e.onColdSocket),e.coldStartDiagnostic!==void 0&&(this.coldStartDiagnostic=e.coldStartDiagnostic),this.coldStartPollWindowMs=e.coldStartPollWindowMs??G}healthz(){return this.request("GET",r.healthz())}async probeHealthz(e){const t=await this.transport("GET",r.healthz(),void 0,{timeout:e});if(t.status===503)try{const s=await t.clone().json();if(typeof s.startup_blocked=="string")return s}catch{}return v(t)}status(){return this.request("GET",r.status())}restartDaemon(){return this.request("POST",r.daemonRestart())}admitDaemon(){return this.request("POST",r.daemonAdmit())}migrateState(e){return this.request("POST",r.daemonMigrate(),e)}createNode(e){return this.request("POST",r.nodes(),e)}listNodes(e){return this.request("GET",o(r.nodes(),e))}getNode(e){return this.request("GET",r.node(this.nodePath(e)))}getNodeOutcome(e,{waitSeconds:t}={}){if(t!==void 0&&(!Number.isInteger(t)||t<0||t>25))throw new RangeError("waitSeconds must be an integer between 0 and 25");return this.request("GET",o(r.nodeOutcome(this.nodePath(e)),{wait:t}),void 0,{timeout:(t??0)*1e3+this.timeoutMs})}getNodeEvents(e,t={},s={}){if(t.after!==void 0&&(!Number.isSafeInteger(t.after)||t.after<0))throw new RangeError("after must be a non-negative safe integer");return this.transport("GET",o(r.nodeEvents(this.nodePath(e)),t),void 0,{...s,headers:{accept:"text/event-stream",...s.headers??{}},timeout:0})}registerOutcomeDelivery(e,t){return this.request("PUT",r.nodeOutcomeDelivery(this.nodePath(e)),t)}getOutcomeDelivery(e){return this.request("GET",r.nodeOutcomeDelivery(this.nodePath(e)))}async disarmOutcomeDelivery(e){await this.request("DELETE",r.nodeOutcomeDelivery(this.nodePath(e)))}listBashJobs(e){return this.request("GET",r.nodeJobs(this.nodePath(e)))}stopBashJob(e,t){return this.request("DELETE",r.nodeJob(this.nodePath(e),this.jobPath(t)))}sendMessage(e,t){return this.request("POST",r.nodeMessages(this.nodePath(e)),t)}interruptNode(e){return this.request("POST",r.nodeInterrupt(this.nodePath(e)),{})}pushReport(e,t){return this.request("POST",r.nodeReports(this.nodePath(e)),t)}submitResult(e,t){return this.request("POST",r.nodeResult(this.nodePath(e)),t)}forkNode(e){return this.request("POST",r.nodeFork(this.nodePath(e)),{})}reviveNode(e,t){return this.request("POST",r.nodeRevive(this.nodePath(e)),t??{})}relaunchRoot(e){return this.request("POST",r.nodeRelaunchRoot(this.nodePath(e)),{})}bindBrokerSession(e,t){return this.request("POST",r.nodeBrokerSessionBound(this.nodePath(e)),t)}settleBroker(e,t){return this.request("POST",r.nodeBrokerSettle(this.nodePath(e)),t)}completeBrokerPark(e,t){return this.request("POST",r.nodeBrokerParkComplete(this.nodePath(e)),t)}recordBrokerParkActivity(e,t){return this.request("POST",r.nodeBrokerParkActivity(this.nodePath(e)),t)}async recordBrokerTelemetry(e,t){await this.request("POST",r.nodeBrokerTelemetry(this.nodePath(e)),t)}claimNodeMail(e,t){return this.request("POST",r.nodeMailClaim(this.nodePath(e)),t)}acknowledgeNodeMail(e,t){return this.request("POST",r.nodeMailAcknowledge(this.nodePath(e)),t)}recordBrokerTurn(e,t){return this.request("POST",r.brokerTurn(this.nodePath(e)),t)}mutateBrokerProviderRetry(e,t){return this.request("POST",r.brokerProviderRetry(this.nodePath(e)),t)}mutateBrokerFault(e,t){return this.request("POST",r.brokerFault(this.nodePath(e)),t)}getBrokerRecovery(e,t){return this.request("GET",`${r.brokerRecovery(this.nodePath(e))}?expected_execution_id=${encodeURIComponent(t)}`)}recordNodeFault(e,t){return this.request("POST",r.nodeFault(this.nodePath(e)),t)}clearNodeFault(e,t={}){const s=new URLSearchParams;t.link!==void 0&&s.set("link",t.link),t.preserve_episode!==void 0&&s.set("preserve_episode",String(t.preserve_episode));const i=s.size===0?"":`?${s.toString()}`;return this.request("DELETE",`${r.nodeFault(this.nodePath(e))}${i}`)}commitBrokerModel(e,t){return this.request("POST",r.nodeBrokerModel(this.nodePath(e)),t)}brokerExtensionState(e){return this.request("GET",r.nodeBrokerExtensionState(this.nodePath(e)))}commitBrokerGeneratedName(e,t){return this.request("POST",r.nodeBrokerGeneratedName(this.nodePath(e)),t)}commitBrokerPersonaAck(e,t){return this.request("POST",r.nodeBrokerPersonaAck(this.nodePath(e)),t)}closeNode(e,t){return this.request("POST",r.nodeClose(this.nodePath(e)),t??{})}recycleNode(e){return this.request("POST",r.nodeRecycle(this.nodePath(e)),{})}demoteNode(e){return this.request("POST",r.nodeDemote(this.nodePath(e)),{})}promoteNode(e,t){return this.request("POST",r.nodePromote(this.nodePath(e)),t)}yieldNode(e,t){return this.request("POST",r.nodeYield(this.nodePath(e)),t)}waitNode(e,t){return this.request("POST",r.nodeWait(this.nodePath(e)),t)}patchConfig(e,t){return this.request("PATCH",r.nodeConfig(this.nodePath(e)),t)}closeWorktree(e){return this.request("POST",r.nodeWorktreeClose(this.nodePath(e)),{})}abandonWorktree(e,t){return this.request("POST",r.nodeWorktreeAbandon(this.nodePath(e)),t)}listQuarantinedWorktrees(){return this.request("GET",r.quarantinedWorktrees())}subscribe(e,t){return this.request("POST",r.nodeSubscriptions(this.nodePath(e)),t)}listFocuses(){return this.request("GET",r.focuses())}focusOf(e){return this.request("GET",o(r.focusByNode(),{node_id:e}))}focusByPane(e){return this.request("GET",o(r.focusByPane(),{pane:e}))}registerFocus(e){return this.request("POST",r.focuses(),e)}async setFocusPane(e,t){await this.request("PATCH",r.focus(e),t)}async closeFocus(e){await this.request("DELETE",r.focus(e))}async unsubscribe(e,t){await this.request("DELETE",r.nodeSubscription(this.nodePath(e),this.nodePath(t)))}armCron(e){return this.request("POST",r.crons(),e)}listCrons(e){return this.request("GET",o(r.crons(),e))}showCron(e,t){return this.request("GET",o(r.cron(this.cronPath(e)),t))}pauseCron(e,t){return this.request("POST",o(r.cronPause(this.cronPath(e)),t),{})}resumeCron(e,t){return this.request("POST",o(r.cronResume(this.cronPath(e)),t),{})}runCron(e,t){return this.request("POST",o(r.cronRun(this.cronPath(e)),t),{})}async cancelCron(e,t){await this.request("DELETE",o(r.cron(this.cronPath(e)),t))}pokeCrons(){return this.request("POST",r.cronsPoke(),{})}ensureAttach(e,t){return this.request("POST",r.nodeAttach(this.nodePath(e)),t??{})}getReports(e,t){return this.request("GET",o(r.nodeReports(this.nodePath(e)),t))}getTranscript(e,t){return this.request("GET",o(r.nodeTranscript(this.nodePath(e)),t))}getSnapshot(e){return this.request("GET",r.nodeSnapshot(this.nodePath(e)))}nodeSubject(e){return this.request("GET",r.nodeSubject(this.nodePath(e)))}getNodeMessages(e,t){return this.request("GET",o(r.nodeMessages(this.nodePath(e)),t))}getSession(e){return this.request("GET",r.nodeSession(this.nodePath(e)))}getChatInventory(e){return this.request("GET",r.nodeChatInventory(this.nodePath(e)))}getProspectiveChatInventory(e){return this.request("GET",o(r.prospectiveChatInventory(),e))}getArtifacts(e,t){return this.request("GET",o(r.nodeArtifacts(this.nodePath(e)),t))}getContext(e){return this.request("GET",r.nodeContext(this.nodePath(e)))}peekFile(e,t,s){return this.request("GET",o(r.filePeek(),{path:e,encoding:t}),void 0,s)}writeFile(e,t,s,i){return this.request("POST",r.fileWrite(),{path:e,content:t,encoding:s},i)}listFiles(e,t,s){return this.request("GET",o(r.fileList(),{path:e,limit:t}),void 0,s)}runBash(e,t){return this.request("POST",r.bash(),e,t)}resolveMemoryDoc(e,t={}){return this.request("GET",o(r.memoryResolve(),{name:e,...t}))}listMemoryDocs(e){return this.request("GET",o(r.memoryDocs(),e))}getMemoryDoc(e,t){return this.request("GET",o(r.memoryDoc(e),t))}createMemoryDoc(e){return this.request("POST",r.memoryDocs(),e)}updateMemoryDoc(e,t){return this.request("PATCH",r.memoryDoc(e),t)}deleteMemoryDoc(e,t){return this.request("DELETE",o(r.memoryDoc(e),t))}moveMemoryDoc(e,t){return this.request("POST",r.memoryDocMove(e),t)}searchMemoryDocs(e){return this.request("POST",r.memorySearch(),e)}getMemoryHistory(e,t){return this.request("GET",o(r.memoryDocHistory(e),t))}ensureProfile(e,t){return this.request("PUT",r.profile(e),t??{})}listProfiles(){return this.request("GET",r.profiles())}getProfile(e){return this.request("GET",r.profile(e))}pauseProfile(e){return this.request("POST",r.profilePause(e),{})}resumeProfile(e){return this.request("POST",r.profileResume(e),{})}updateProfileMetadata(e,t){return this.request("PATCH",r.profileMetadata(e),t)}deleteProfile(e,t){return this.request("DELETE",r.profile(e),t)}listModelAuth(){return this.request("GET",r.modelAuths())}getModelAuthReadiness(e){return this.request("GET",o(r.modelAuthReadiness(),e))}installCredential(e,t){return this.request("PUT",r.modelAuth(e),t)}removeCredential(e){return this.request("DELETE",r.modelAuth(e))}createReview(e){return this.request("POST",r.humanReviews(),e)}listReviews(e){return this.request("GET",o(r.humanReviews(),e))}getReview(e){return this.request("GET",r.humanReview(this.reviewPath(e)))}submitReview(e){return this.request("POST",r.humanReviewSubmit(this.reviewPath(e)),{})}cancelReview(e,t={}){return this.request("POST",r.humanReviewCancel(this.reviewPath(e)),t)}getReviewDocumentBase(e){return this.request("GET",r.humanReviewDocument(this.reviewPath(e)))}createReviewComment(e,t){const s=e===void 0?"self":this.reviewPath(e);return this.request("POST",r.humanReviewComments(s),t)}listReviewComments(e,t){const s=e===void 0?"self":this.reviewPath(e);return this.request("GET",o(r.humanReviewComments(s),t))}readReviewCommentEvents(e,t){return this.request("GET",o(r.humanReviewCommentEvents(this.reviewPath(e)),t))}updateReviewCommentRanges(e,t){return this.request("POST",r.humanReviewCommentRanges(this.reviewPath(e)),t)}getReviewComment(e){return this.request("GET",r.humanComment(this.commentPath(e)))}editReviewComment(e,t){return this.request("POST",r.humanCommentEdit(this.commentPath(e)),t)}resolveReviewComment(e,t={}){return this.request("POST",r.humanCommentResolve(this.commentPath(e)),t)}reopenReviewComment(e,t={}){return this.request("POST",r.humanCommentReopen(this.commentPath(e)),t)}deleteReviewComment(e,t={}){return this.request("POST",r.humanCommentDelete(this.commentPath(e)),t)}forkReviewComment(e){return this.request("POST",r.humanCommentFork(this.commentPath(e)),{})}listHumanInbox(){return this.request("GET",r.humanInbox())}getHumanInboxPage(e){return this.request("GET",r.humanInboxTicket(this.ticketId(e)))}getInboxHistory(e){if(e===void 0)return this.request("GET",r.humanInbox()+"/history");if(typeof e!="string"||e==="")throw new TypeError(`invalid node id: ${JSON.stringify(e)}`);return this.request("GET",o(r.humanInbox()+"/history",{node_id:e}))}respondHumanInboxPage(e,t){return this.request("POST",r.humanInboxRespond(this.ticketId(e)),t)}postInboxProgress(e,t){return this.request("POST",r.humanInboxProgress(this.ticketId(e)),{responses:t})}getInboxResponse(e){return this.request("GET",r.humanInboxResponse(this.ticketId(e)))}cancelHumanInboxTicket(e,t){return this.request("POST",r.humanInboxCancel(this.ticketId(e)),t??{})}createHumanRequest(e){return this.request("POST",r.humanRequests(),e)}getHumanRequest(e){return this.request("GET",r.humanRequest(this.requestPath(e)))}replaceHumanRequest(e,t){return this.request("POST",r.humanRequestReplace(this.requestPath(e)),t)}respondHumanRequest(e,t){return this.request("POST",r.humanRequestRespond(this.requestPath(e)),t)}dismissHumanRequest(e,t={}){return this.request("POST",r.humanRequestDismiss(this.requestPath(e)),t)}cancelHumanRequest(e,t={}){return this.request("POST",r.humanRequestCancel(this.requestPath(e)),t)}resolvePageFeedbackComment(e,t,s){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(t))throw new TypeError(`invalid feedback comment id: ${JSON.stringify(t)}`);return this.request("POST",r.humanInboxFeedbackResolve(this.ticketId(e),t),{node_id:s})}async dashboard(e){const t=e?.under!==void 0?{under:e.under}:void 0,[s,i]=await Promise.all([this.listNodes(t),this.status()]);return{nodes:s,counts:i.node_counts,generated_at:new Date().toISOString()}}attention(){return this.request("GET",r.canvasAttention())}attentionCounts(e){const t={node_ids:e};return this.request("POST",r.canvasAttentionCounts(),t)}historySearch(e){return this.request("POST",r.canvasHistorySearch(),e)}historyGrep(e){return this.request("POST",r.canvasHistoryGrep(),e)}historyRead(e){return this.request("GET",o(r.canvasHistoryRead(),e))}historyStats(e){return this.request("POST",r.canvasHistoryStats(),e)}canvasSnapshot(){return this.request("GET",r.canvasSnapshot())}canvasRoster(){return this.request("GET",r.canvasRoster())}canvasGraph(){return this.request("GET",r.canvasGraph())}prune(e){return this.request("POST",r.canvasPrune(),e)}async request(e,t,s,i){try{return await v(await this.send(e,t,s,i))}catch(a){throw T(a,i?.signal)}}async send(e,t,s,i={}){const a=e==="GET"||e==="HEAD"||e==="DELETE",P=i.maxRetries??this.maxRetries;for(let l=0;;l++){let u;try{u=await this.transport(e,t,s,i)}catch(c){if(this.isColdSocketError(c))try{await this.handleColdSocket(c),u=await this.transport(e,t,s,i)}catch(m){throw T(m,i.signal)}else{if(this.isInterruptedSocketError(c)&&this.localSocketTransport&&(!a||l<P))return await this.rideOutInterruptedRequest(e,t,s,i);if(a&&l<P&&!x(c,i.signal)&&(!this.localSocketTransport||!this.isInterruptedSocketError(c))){await w(O(l+1));continue}else throw T(c,i.signal)}}if(a&&l<P&&M(u.status)){await _(u),await w(O(l+1));continue}return u}}nodePath(e){if(!S(e))throw new h(400,"invalid_node_id",`invalid node id: ${JSON.stringify(e)}`);return e}jobPath(e){if(!g(e))throw new h(400,"invalid_job_id",`invalid background job id: ${JSON.stringify(e)}`);return e}cronPath(e){if(!R(e))throw new h(400,"invalid_cron_id",`invalid cron id: ${JSON.stringify(e)}`);return e}requestPath(e){if(!S(e))throw new h(400,"invalid_request_id",`invalid request id: ${JSON.stringify(e)}`);return e}ticketId(e){if(!/^[a-f0-9]{64}$/.test(e))throw new TypeError(`invalid inbox ticket id: ${JSON.stringify(e)}`);return e}reviewPath(e){if(!S(e))throw new h(400,"invalid_review_id",`invalid review id: ${JSON.stringify(e)}`);return e}commentPath(e){if(!/^[a-f0-9]{32}$/.test(e))throw new h(400,"invalid_comment_id",`invalid comment id: ${JSON.stringify(e)}`);return e}transport(e,t,s,i={}){const a=s===void 0?void 0:JSON.stringify(s),P={accept:"application/json",...this.headers,...i.headers};a!==void 0&&(P["content-type"]="application/json");const l=i.timeout??this.timeoutMs,u=new AbortController,c=l>0?setTimeout(()=>u.abort(new DOMException("request timed out","TimeoutError")),l):void 0,m=i.signal,f=d(()=>u.abort(m?.reason),"onExternalAbort");m!==void 0&&(m.aborted?u.abort(m.reason):m.addEventListener("abort",f,{once:!0}));const y=d(()=>{c!==void 0&&clearTimeout(c),m?.removeEventListener("abort",f)},"finish");return this.fetch(new URL(t,this.baseUrl),{method:e,headers:P,body:a,signal:u.signal}).then(q=>this.retainRequestLifetime(q,y,()=>u.signal.aborted?u.signal.reason:void 0),q=>{throw y(),q})}retainRequestLifetime(e,t,s){if(e.body===null)return t(),e;const i=e.body.getReader();let a=!1;const P=d(()=>{a||(a=!0,t())},"close"),l=new ReadableStream({async pull(u){try{const{done:c,value:m}=await i.read();c?(P(),u.close()):u.enqueue(m)}catch(c){P(),u.error(s()??c)}},async cancel(u){P(),await i.cancel(u)}});return new Response(l,{status:e.status,statusText:e.statusText,headers:e.headers})}isColdSocketError(e){const t=E(e);return t==="ECONNREFUSED"||t==="ENOENT"||t==="ENOTSOCK"}isInterruptedSocketError(e){const t=E(e);return t==="ECONNRESET"||t==="EPIPE"}async rideOutInterruptedRequest(e,t,s,i={}){try{await this.awaitAvailability()}catch(a){throw T(a,i.signal)}if(e!=="GET"&&e!=="HEAD")throw new h(503,"daemon_request_interrupted",`crtrd connection ended before this ${e} response; the request may or may not have been applied.`);try{return await this.transport(e,t,s,i)}catch(a){throw T(a,i.signal)}}async awaitAvailability(e){await N({windowMs:this.coldStartPollWindowMs,initialError:e,probe:d(async t=>{const s=await this.transport("GET",r.healthz(),void 0,{timeout:t});if(s.status>=200&&s.status<300)return;const i=await s.text();try{if(typeof JSON.parse(i).startup_blocked=="string")return}catch{}throw new h(s.status,"daemon_health_unavailable",`crtrd health check returned HTTP ${s.status}: ${i.slice(0,500)}`)},"probe")})}async handleColdSocket(e){const t=this.autostart&&this.onColdSocket!==void 0&&!this.coldStartAttempted;t&&(this.coldStartAttempted=!0,await this.onColdSocket());try{await this.awaitAvailability(e)}catch(s){if(t){const i=A(this.coldStartDiagnostic);if(i!==void 0){const a=T(s);throw new h(a.status,a.code,`${a.message}
|
|
2
|
-
${i}`)}}throw s}}}function o(n,e){if(e===void 0)return n;const t=new URLSearchParams;for(const[i,a]of Object.entries(e))a!=null&&t.set(i,String(a));const s=t.toString();return s===""?n:`${n}?${s}`}d(o,"withQuery");async function
|
|
1
|
+
var g=Object.defineProperty;var d=(n,e)=>g(n,"name",{value:e,configurable:!0});import{ApiError as h,isErrorBody as b}from"./errors.js";import{routes as r}from"./routes.js";import{isSafeNodeId as E}from"./dto/common.js";import{isSafeBashJobId as R}from"./dto/bash-jobs.js";import{isSafeCronId as k}from"./dto/crons.js";const C=3e4,G=Symbol.for("@north-light/crouter-api/local-socket-fetch"),M=1e4,D=200;async function _({windowMs:n,probe:e,initialError:t,pollIntervalMs:s=D,retry:i=d(()=>!0,"retry"),now:a=Date.now,sleep:P=w}){const l=a()+n;let u=t;for(;;){const c=l-a();if(c<=0)throw u??new Error("crtrd availability window expired without a probe failure");try{await e(c);return}catch(f){if(u=f,!i(f))throw f}const m=l-a();if(m<=0)throw u;await P(Math.min(s,m))}}d(_,"waitForDaemonAvailability");class U{static{d(this,"CrtrClient")}baseUrl;fetch;headers;autostart;timeoutMs;maxRetries;localSocketTransport;onColdSocket;coldStartDiagnostic;coldStartPollWindowMs;coldStartAttempted=!1;constructor(e){if(e.baseUrl==="")throw new TypeError("CrtrClient requires baseUrl");this.baseUrl=new URL(e.baseUrl),this.fetch=e.fetch??globalThis.fetch,this.headers={...e.headers},this.autostart=e.autostart??!1,this.timeoutMs=e.timeoutMs??C,this.maxRetries=e.maxRetries??2,this.localSocketTransport=this.fetch[G]===!0,e.onColdSocket!==void 0&&(this.onColdSocket=e.onColdSocket),e.coldStartDiagnostic!==void 0&&(this.coldStartDiagnostic=e.coldStartDiagnostic),this.coldStartPollWindowMs=e.coldStartPollWindowMs??M}healthz(){return this.request("GET",r.healthz())}async probeHealthz(e){const t=await this.transport("GET",r.healthz(),void 0,{timeout:e});if(t.status===503)try{const s=await t.clone().json();if(typeof s.startup_blocked=="string")return s}catch{}return p(t)}status(){return this.request("GET",r.status())}restartDaemon(){return this.request("POST",r.daemonRestart())}admitDaemon(){return this.request("POST",r.daemonAdmit())}migrateState(e){return this.request("POST",r.daemonMigrate(),e)}appendNodeLog(e,t){return this.request("POST",r.nodeLog(this.nodePath(e)),t)}async putNodeTelemetry(e,t){await this.request("PUT",r.nodeTelemetry(this.nodePath(e)),t)}async putNodeRecap(e,t){await this.request("PUT",r.nodeRecap(this.nodePath(e)),t)}readNodeInboxReport(e,t,s){return this.request("GET",o(r.nodeInboxReport(this.nodePath(e)),{ref:t,execution_id:s}))}readNodePassiveMessage(e,t){return this.request("GET",o(r.nodePassiveMessage(this.nodePath(e)),{ref:t}))}nodePushedFinal(e,t){return this.request("POST",r.nodePushedFinal(this.nodePath(e)),t)}createNode(e){return this.request("POST",r.nodes(),e)}listNodes(e){return this.request("GET",o(r.nodes(),e))}getNode(e){return this.request("GET",r.node(this.nodePath(e)))}getNodeOutcome(e,{waitSeconds:t}={}){if(t!==void 0&&(!Number.isInteger(t)||t<0||t>25))throw new RangeError("waitSeconds must be an integer between 0 and 25");return this.request("GET",o(r.nodeOutcome(this.nodePath(e)),{wait:t}),void 0,{timeout:(t??0)*1e3+this.timeoutMs})}getNodeEvents(e,t={},s={}){if(t.after!==void 0&&(!Number.isSafeInteger(t.after)||t.after<0))throw new RangeError("after must be a non-negative safe integer");return this.transport("GET",o(r.nodeEvents(this.nodePath(e)),t),void 0,{...s,headers:{accept:"text/event-stream",...s.headers??{}},timeout:0})}registerOutcomeDelivery(e,t){return this.request("PUT",r.nodeOutcomeDelivery(this.nodePath(e)),t)}getOutcomeDelivery(e){return this.request("GET",r.nodeOutcomeDelivery(this.nodePath(e)))}async disarmOutcomeDelivery(e){await this.request("DELETE",r.nodeOutcomeDelivery(this.nodePath(e)))}listBashJobs(e){return this.request("GET",r.nodeJobs(this.nodePath(e)))}stopBashJob(e,t){return this.request("DELETE",r.nodeJob(this.nodePath(e),this.jobPath(t)))}sendMessage(e,t){return this.request("POST",r.nodeMessages(this.nodePath(e)),t)}interruptNode(e){return this.request("POST",r.nodeInterrupt(this.nodePath(e)),{})}pushReport(e,t){return this.request("POST",r.nodeReports(this.nodePath(e)),t)}submitResult(e,t){return this.request("POST",r.nodeResult(this.nodePath(e)),t)}forkNode(e){return this.request("POST",r.nodeFork(this.nodePath(e)),{})}reviveNode(e,t){return this.request("POST",r.nodeRevive(this.nodePath(e)),t??{})}relaunchRoot(e){return this.request("POST",r.nodeRelaunchRoot(this.nodePath(e)),{})}bindBrokerSession(e,t){return this.request("POST",r.nodeBrokerSessionBound(this.nodePath(e)),t)}settleBroker(e,t){return this.request("POST",r.nodeBrokerSettle(this.nodePath(e)),t)}completeBrokerPark(e,t){return this.request("POST",r.nodeBrokerParkComplete(this.nodePath(e)),t)}recordBrokerParkActivity(e,t){return this.request("POST",r.nodeBrokerParkActivity(this.nodePath(e)),t)}async recordBrokerTelemetry(e,t){await this.request("POST",r.nodeBrokerTelemetry(this.nodePath(e)),t)}claimNodeMail(e,t){return this.request("POST",r.nodeMailClaim(this.nodePath(e)),t)}acknowledgeNodeMail(e,t){return this.request("POST",r.nodeMailAcknowledge(this.nodePath(e)),t)}recordBrokerTurn(e,t){return this.request("POST",r.brokerTurn(this.nodePath(e)),t)}mutateBrokerProviderRetry(e,t){return this.request("POST",r.brokerProviderRetry(this.nodePath(e)),t)}mutateBrokerFault(e,t){return this.request("POST",r.brokerFault(this.nodePath(e)),t)}getBrokerRecovery(e,t){return this.request("GET",`${r.brokerRecovery(this.nodePath(e))}?expected_execution_id=${encodeURIComponent(t)}`)}recordNodeFault(e,t){return this.request("POST",r.nodeFault(this.nodePath(e)),t)}clearNodeFault(e,t={}){const s=new URLSearchParams;t.link!==void 0&&s.set("link",t.link),t.preserve_episode!==void 0&&s.set("preserve_episode",String(t.preserve_episode));const i=s.size===0?"":`?${s.toString()}`;return this.request("DELETE",`${r.nodeFault(this.nodePath(e))}${i}`)}commitBrokerModel(e,t){return this.request("POST",r.nodeBrokerModel(this.nodePath(e)),t)}brokerExtensionState(e){return this.request("GET",r.nodeBrokerExtensionState(this.nodePath(e)))}brokerContext(e,t){return this.request("POST",r.nodeBrokerContext(this.nodePath(e)),t)}brokerMemoryRefs(e,t){return this.request("POST",r.nodeBrokerMemoryRefs(this.nodePath(e)),{expected_execution_id:t})}commitBrokerContext(e,t){return this.request("POST",r.nodeBrokerContextCommit(this.nodePath(e)),t)}brokerContextEvent(e,t){return this.request("POST",r.nodeBrokerContextEvent(this.nodePath(e)),t)}commitBrokerGeneratedName(e,t){return this.request("POST",r.nodeBrokerGeneratedName(this.nodePath(e)),t)}commitBrokerPersonaAck(e,t){return this.request("POST",r.nodeBrokerPersonaAck(this.nodePath(e)),t)}closeNode(e,t){return this.request("POST",r.nodeClose(this.nodePath(e)),t??{})}recycleNode(e){return this.request("POST",r.nodeRecycle(this.nodePath(e)),{})}demoteNode(e){return this.request("POST",r.nodeDemote(this.nodePath(e)),{})}promoteNode(e,t){return this.request("POST",r.nodePromote(this.nodePath(e)),t)}yieldNode(e,t){return this.request("POST",r.nodeYield(this.nodePath(e)),t)}waitNode(e,t){return this.request("POST",r.nodeWait(this.nodePath(e)),t)}listKinds(){return this.request("GET",r.kinds())}patchConfig(e,t){return this.request("PATCH",r.nodeConfig(this.nodePath(e)),t,t.model!==void 0?{timeout:45e3+this.timeoutMs}:void 0)}closeWorktree(e){return this.request("POST",r.nodeWorktreeClose(this.nodePath(e)),{})}abandonWorktree(e,t){return this.request("POST",r.nodeWorktreeAbandon(this.nodePath(e)),t)}listQuarantinedWorktrees(){return this.request("GET",r.quarantinedWorktrees())}listSpaces(){return this.request("GET",r.spaces())}subscribe(e,t){return this.request("POST",r.nodeSubscriptions(this.nodePath(e)),t)}listFocuses(){return this.request("GET",r.focuses())}focusOf(e){return this.request("GET",o(r.focusByNode(),{node_id:e}))}focusByPane(e){return this.request("GET",o(r.focusByPane(),{pane:e}))}registerFocus(e){return this.request("POST",r.focuses(),e)}async setFocusPane(e,t){await this.request("PATCH",r.focus(e),t)}async closeFocus(e){await this.request("DELETE",r.focus(e))}async unsubscribe(e,t){await this.request("DELETE",r.nodeSubscription(this.nodePath(e),this.nodePath(t)))}armCron(e){return this.request("POST",r.crons(),e)}listCrons(e){return this.request("GET",o(r.crons(),e))}showCron(e,t){return this.request("GET",o(r.cron(this.cronPath(e)),t))}pauseCron(e,t){return this.request("POST",o(r.cronPause(this.cronPath(e)),t),{})}resumeCron(e,t){return this.request("POST",o(r.cronResume(this.cronPath(e)),t),{})}runCron(e,t){return this.request("POST",o(r.cronRun(this.cronPath(e)),t),{})}async cancelCron(e,t){await this.request("DELETE",o(r.cron(this.cronPath(e)),t))}pokeCrons(){return this.request("POST",r.cronsPoke(),{})}ensureAttach(e,t){return this.request("POST",r.nodeAttach(this.nodePath(e)),t??{})}getReports(e,t){return this.request("GET",o(r.nodeReports(this.nodePath(e)),t))}getTranscript(e,t){return this.request("GET",o(r.nodeTranscript(this.nodePath(e)),t))}getSnapshot(e){return this.request("GET",r.nodeSnapshot(this.nodePath(e)))}nodeSubject(e){return this.request("GET",r.nodeSubject(this.nodePath(e)))}getNodeMessages(e,t){return this.request("GET",o(r.nodeMessages(this.nodePath(e)),t))}getSession(e){return this.request("GET",r.nodeSession(this.nodePath(e)))}getChatInventory(e){return this.request("GET",r.nodeChatInventory(this.nodePath(e)))}getProspectiveChatInventory(e){return this.request("GET",o(r.prospectiveChatInventory(),e))}getArtifacts(e,t){return this.request("GET",o(r.nodeArtifacts(this.nodePath(e)),t))}getContext(e){return this.request("GET",r.nodeContext(this.nodePath(e)))}peekFile(e,t,s){return this.request("GET",o(r.filePeek(),{path:e,encoding:t}),void 0,s)}writeFile(e,t,s,i){return this.request("POST",r.fileWrite(),{path:e,content:t,encoding:s},i)}listFiles(e,t,s){return this.request("GET",o(r.fileList(),{path:e,limit:t}),void 0,s)}runBash(e,t){return this.request("POST",r.bash(),e,t)}getMemoryOriginConversation(e){return this.request("GET",o(r.memoryOrigin(),{conversation_id:e}))}resolveMemoryDoc(e,t={}){return this.request("GET",o(r.memoryResolve(),{name:e,...t}))}listMemoryDocs(e){return this.request("GET",o(r.memoryDocs(),e))}getMemoryDoc(e,t){return this.request("GET",o(r.memoryDoc(e),t))}createMemoryDoc(e){return this.request("POST",r.memoryDocs(),e)}updateMemoryDoc(e,t){return this.request("PATCH",r.memoryDoc(e),t)}deleteMemoryDoc(e,t){return this.request("DELETE",o(r.memoryDoc(e),t))}moveMemoryDoc(e,t){return this.request("POST",r.memoryDocMove(e),t)}searchMemoryDocs(e){return this.request("POST",r.memorySearch(),e)}getMemoryHistory(e,t){return this.request("GET",o(r.memoryDocHistory(e),t))}ensureProfile(e,t){return this.request("PUT",r.profile(e),t??{})}createProfile(e){return this.request("POST",r.profiles(),e)}listProfiles(){return this.request("GET",r.profiles())}updateProfile(e,t){return this.request("PATCH",r.profile(e),t)}listProfileEnv(e){return this.request("GET",r.profileEnv(e))}setProfileEnv(e,t,s){return this.request("PUT",r.profileEnvVar(e,t),{value:s})}removeProfileEnv(e,t){return this.request("DELETE",r.profileEnvVar(e,t))}getProfile(e){return this.request("GET",r.profile(e))}pauseProfile(e){return this.request("POST",r.profilePause(e),{})}resumeProfile(e){return this.request("POST",r.profileResume(e),{})}updateProfileMetadata(e,t){return this.request("PATCH",r.profileMetadata(e),t)}deleteProfile(e,t){return this.request("DELETE",r.profile(e),t)}listModelAuth(){return this.request("GET",r.modelAuths())}getModelAuthReadiness(e){return this.request("GET",o(r.modelAuthReadiness(),e))}installCredential(e,t){return this.request("PUT",r.modelAuth(e),t)}removeCredential(e){return this.request("DELETE",r.modelAuth(e))}startModelAuth(e){return this.request("POST",r.modelAuthFlows(),e,{timeout:3e4+this.timeoutMs})}completeModelAuth(e,t){return this.request("POST",r.modelAuthFlowComplete(e),t,{timeout:35e3+this.timeoutMs})}cancelModelAuth(e){return this.request("POST",r.modelAuthFlowCancel(e),{})}getModelAuthFlow(e,t){return this.request("GET",o(r.modelAuthFlow(e),{wait:t}),void 0,{timeout:(t??0)*1e3+this.timeoutMs})}createReview(e){return this.request("POST",r.humanReviews(),e)}listReviews(e){return this.request("GET",o(r.humanReviews(),e))}getReview(e){return this.request("GET",r.humanReview(this.reviewPath(e)))}submitReview(e){return this.request("POST",r.humanReviewSubmit(this.reviewPath(e)),{})}cancelReview(e,t={}){return this.request("POST",r.humanReviewCancel(this.reviewPath(e)),t)}getReviewDocumentBase(e){return this.request("GET",r.humanReviewDocument(this.reviewPath(e)))}createReviewComment(e,t){const s=e===void 0?"self":this.reviewPath(e);return this.request("POST",r.humanReviewComments(s),t)}listReviewComments(e,t){const s=e===void 0?"self":this.reviewPath(e);return this.request("GET",o(r.humanReviewComments(s),t))}readReviewCommentEvents(e,t){return this.request("GET",o(r.humanReviewCommentEvents(this.reviewPath(e)),t))}updateReviewCommentRanges(e,t){return this.request("POST",r.humanReviewCommentRanges(this.reviewPath(e)),t)}getReviewComment(e){return this.request("GET",r.humanComment(this.commentPath(e)))}editReviewComment(e,t){return this.request("POST",r.humanCommentEdit(this.commentPath(e)),t)}resolveReviewComment(e,t={}){return this.request("POST",r.humanCommentResolve(this.commentPath(e)),t)}reopenReviewComment(e,t={}){return this.request("POST",r.humanCommentReopen(this.commentPath(e)),t)}deleteReviewComment(e,t={}){return this.request("POST",r.humanCommentDelete(this.commentPath(e)),t)}forkReviewComment(e){return this.request("POST",r.humanCommentFork(this.commentPath(e)),{})}listHumanInbox(){return this.request("GET",r.humanInbox())}getHumanInboxPage(e){return this.request("GET",r.humanInboxTicket(this.ticketId(e)))}getInboxHistory(e){if(e===void 0)return this.request("GET",r.humanInbox()+"/history");if(typeof e!="string"||e==="")throw new TypeError(`invalid node id: ${JSON.stringify(e)}`);return this.request("GET",o(r.humanInbox()+"/history",{node_id:e}))}respondHumanInboxPage(e,t){return this.request("POST",r.humanInboxRespond(this.ticketId(e)),t)}postInboxProgress(e,t){return this.request("POST",r.humanInboxProgress(this.ticketId(e)),{responses:t})}getInboxResponse(e){return this.request("GET",r.humanInboxResponse(this.ticketId(e)))}cancelHumanInboxTicket(e,t){return this.request("POST",r.humanInboxCancel(this.ticketId(e)),t??{})}createHumanRequest(e){return this.request("POST",r.humanRequests(),e)}listPageComponents(){return this.request("GET",r.humanComponents())}getHumanRequest(e){return this.request("GET",r.humanRequest(this.requestPath(e)))}replaceHumanRequest(e,t){return this.request("POST",r.humanRequestReplace(this.requestPath(e)),t)}respondHumanRequest(e,t){return this.request("POST",r.humanRequestRespond(this.requestPath(e)),t)}dismissHumanRequest(e,t={}){return this.request("POST",r.humanRequestDismiss(this.requestPath(e)),t)}cancelHumanRequest(e,t={}){return this.request("POST",r.humanRequestCancel(this.requestPath(e)),t)}resolvePageFeedbackComment(e,t,s){if(!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/.test(t))throw new TypeError(`invalid feedback comment id: ${JSON.stringify(t)}`);return this.request("POST",r.humanInboxFeedbackResolve(this.ticketId(e),t),{node_id:s})}async dashboard(e){const t=e?.under!==void 0?{under:e.under}:void 0,[s,i]=await Promise.all([this.listNodes(t),this.status()]);return{nodes:s,counts:i.node_counts,generated_at:new Date().toISOString()}}attention(){return this.request("GET",r.canvasAttention())}attentionCounts(e){const t={node_ids:e};return this.request("POST",r.canvasAttentionCounts(),t)}historySearch(e){return this.request("POST",r.canvasHistorySearch(),e)}historyGrep(e){return this.request("POST",r.canvasHistoryGrep(),e)}historyRead(e){return this.request("GET",o(r.canvasHistoryRead(),e))}historyStats(e){return this.request("POST",r.canvasHistoryStats(),e)}canvasSnapshot(){return this.request("GET",r.canvasSnapshot())}analytics(e){return this.request("GET",o(r.canvasAnalytics(),e),void 0,{timeout:6e4})}async recordMemoryReads(e,t){await this.request("POST",r.nodeMemoryReads(this.nodePath(e)),t)}canvasRoster(){return this.request("GET",r.canvasRoster())}canvasGraph(){return this.request("GET",r.canvasGraph())}prune(e){return this.request("POST",r.canvasPrune(),e)}async request(e,t,s,i){try{return await p(await this.send(e,t,s,i))}catch(a){throw T(a,i?.signal)}}async send(e,t,s,i={}){const a=e==="GET"||e==="HEAD"||e==="DELETE",P=i.maxRetries??this.maxRetries;for(let l=0;;l++){let u;try{u=await this.transport(e,t,s,i)}catch(c){if(this.isColdSocketError(c))try{await this.handleColdSocket(c),u=await this.transport(e,t,s,i)}catch(m){throw T(m,i.signal)}else{if(this.isInterruptedSocketError(c)&&this.localSocketTransport&&(!a||l<P))return await this.rideOutInterruptedRequest(e,t,s,i);if(a&&l<P&&!N(c,i.signal)&&(!this.localSocketTransport||!this.isInterruptedSocketError(c))){await w(O(l+1));continue}else throw T(c,i.signal)}}if(a&&l<P&&x(u.status)){await v(u),await w(O(l+1));continue}return u}}nodePath(e){if(!E(e))throw new h(400,"invalid_node_id",`invalid node id: ${JSON.stringify(e)}`);return e}jobPath(e){if(!R(e))throw new h(400,"invalid_job_id",`invalid background job id: ${JSON.stringify(e)}`);return e}cronPath(e){if(!k(e))throw new h(400,"invalid_cron_id",`invalid cron id: ${JSON.stringify(e)}`);return e}requestPath(e){if(!E(e))throw new h(400,"invalid_request_id",`invalid request id: ${JSON.stringify(e)}`);return e}ticketId(e){if(!/^[a-f0-9]{64}$/.test(e))throw new TypeError(`invalid inbox ticket id: ${JSON.stringify(e)}`);return e}reviewPath(e){if(!E(e))throw new h(400,"invalid_review_id",`invalid review id: ${JSON.stringify(e)}`);return e}commentPath(e){if(!/^[a-f0-9]{32}$/.test(e))throw new h(400,"invalid_comment_id",`invalid comment id: ${JSON.stringify(e)}`);return e}transport(e,t,s,i={}){const a=s===void 0?void 0:JSON.stringify(s),P={accept:"application/json",...this.headers,...i.headers};a!==void 0&&(P["content-type"]="application/json");const l=i.timeout??this.timeoutMs,u=new AbortController,c=l>0?setTimeout(()=>u.abort(new DOMException("request timed out","TimeoutError")),l):void 0,m=i.signal,f=d(()=>u.abort(m?.reason),"onExternalAbort");m!==void 0&&(m.aborted?u.abort(m.reason):m.addEventListener("abort",f,{once:!0}));const y=d(()=>{c!==void 0&&clearTimeout(c),m?.removeEventListener("abort",f)},"finish");return this.fetch(new URL(t,this.baseUrl),{method:e,headers:P,body:a,signal:u.signal}).then(q=>this.retainRequestLifetime(q,y,()=>u.signal.aborted?u.signal.reason:void 0),q=>{throw y(),q})}retainRequestLifetime(e,t,s){if(e.body===null)return t(),e;const i=e.body.getReader();let a=!1;const P=d(()=>{a||(a=!0,t())},"close"),l=new ReadableStream({async pull(u){try{const{done:c,value:m}=await i.read();c?(P(),u.close()):u.enqueue(m)}catch(c){P(),u.error(s()??c)}},async cancel(u){P(),await i.cancel(u)}});return new Response(l,{status:e.status,statusText:e.statusText,headers:e.headers})}isColdSocketError(e){const t=S(e);return t==="ECONNREFUSED"||t==="ENOENT"||t==="ENOTSOCK"}isInterruptedSocketError(e){const t=S(e);return t==="ECONNRESET"||t==="EPIPE"}async rideOutInterruptedRequest(e,t,s,i={}){try{await this.awaitAvailability()}catch(a){throw T(a,i.signal)}if(e!=="GET"&&e!=="HEAD")throw new h(503,"daemon_request_interrupted",`crtrd connection ended before this ${e} response; the request may or may not have been applied.`);try{return await this.transport(e,t,s,i)}catch(a){throw T(a,i.signal)}}async awaitAvailability(e){await _({windowMs:this.coldStartPollWindowMs,initialError:e,probe:d(async t=>{const s=await this.transport("GET",r.healthz(),void 0,{timeout:t});if(s.status>=200&&s.status<300){await v(s);return}const i=await s.text();try{if(typeof JSON.parse(i).startup_blocked=="string")return}catch{}throw new h(s.status,"daemon_health_unavailable",`crtrd health check returned HTTP ${s.status}: ${i.slice(0,500)}`)},"probe")})}async handleColdSocket(e){const t=this.autostart&&this.onColdSocket!==void 0&&!this.coldStartAttempted;t&&(this.coldStartAttempted=!0,await this.onColdSocket());try{await this.awaitAvailability(e)}catch(s){if(t){const i=A(this.coldStartDiagnostic);if(i!==void 0){const a=T(s);throw new h(a.status,a.code,`${a.message}
|
|
2
|
+
${i}`)}}throw s}}}function o(n,e){if(e===void 0)return n;const t=new URLSearchParams;for(const[i,a]of Object.entries(e))a!=null&&t.set(i,String(a));const s=t.toString();return s===""?n:`${n}?${s}`}d(o,"withQuery");async function p(n){const e=n.status>=200&&n.status<300,t=(await n.text()).trim();let s;if(t!=="")try{s=JSON.parse(t)}catch{if(e)return;throw new h(n.status,"invalid_response",t.slice(0,500),void 0,n.headers)}if(e)return s;throw b(s)?new h(n.status,s.error.code,s.error.message,s.error.details,n.headers,s.error):new h(n.status,"internal",`request failed with status ${n.status}`,void 0,n.headers)}d(p,"parse");function x(n){return n===429||n>=500}d(x,"isRetryableStatus");async function v(n){try{await n.body?.cancel()}catch{}}d(v,"drainResponseBody");function O(n){return Math.min(2e3,250*2**(n-1))}d(O,"retryDelayMs");function S(n){if(typeof n!="object"||n===null)return;const e=n.code;if(typeof e=="string")return e;const t=n.cause;if(typeof t=="object"&&t!==null){const s=t.code;if(typeof s=="string")return s}}d(S,"transportErrorCode");function N(n,e){return e?.aborted?!0:n instanceof DOMException&&(n.name==="AbortError"||n.name==="TimeoutError")}d(N,"isAbortError");function T(n,e){if(e?.aborted)return new h(0,"request_aborted","request aborted by caller signal");if(n instanceof h)return n;if(n instanceof DOMException&&n.name==="TimeoutError")return new h(504,"request_timeout",`crtrd request timed out: ${n.message}`);if(n instanceof DOMException&&n.name==="AbortError")return new h(0,"request_aborted","request aborted by caller signal");const t=S(n),s=n instanceof Error?n.message:String(n);return t==="ECONNREFUSED"||t==="ENOENT"||t==="ENOTSOCK"?new h(503,"daemon_unavailable",`crtrd is not reachable: ${s}`):t==="ETIMEDOUT"?new h(504,"request_timeout",`crtrd request timed out: ${s}`):new h(503,"transport_error",s)}d(T,"toTransportApiError");function w(n){return new Promise(e=>setTimeout(e,n))}d(w,"sleepMs");function A(n){if(n!==void 0)try{return n()}catch{return}}d(A,"safeColdStartDiagnostic");export{U as CrtrClient,A as safeColdStartDiagnostic,_ as waitForDaemonAvailability};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var z=Object.defineProperty;var v=(e,o)=>z(e,"name",{value:o,configurable:!0});import{isRecord as x}from"../../shared/predicates.js";const B=new Set(["normal","common","important"]),I=new Set(["string","int","bool","path","enum"]),U=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/,N=new Set(["kind","name","description","whenToUse","tier","rootEntry","extensible","summary","model","children"]),V=new Set([...N,"passthrough"]),Z=new Set(["bin","installHint"]),O=new Set(["kind","name","description","whenToUse","tier","summary","params","output","effects"]),L=new Set([...O,"outputKind"]),W=new Set([...O,"rest"]),X=new Set(["concept","description","whenToUse"]),J=new Set(["text","base64"]),H={positional:new Set(["kind","name","type","required","constraint","repeatable","encoding","defaultFromEnv"]),flag:new Set(["kind","name","type","choices","required","constraint","default","repeatable","encoding","defaultFromEnv"]),stdin:new Set(["kind","name","required","constraint"]),"context-file":new Set(["kind","name","required","constraint","shape"])},Q=new Set(["name","type","required","constraint"]),w=/^[A-Z][A-Z0-9_]*$/;function m(e){return e===null?"null":Array.isArray(e)?"array":typeof e}v(m,"typeName");function R(e,o,t,n){const a=Object.keys(e).filter(l=>!o.has(l));return a.length>0?(n("command_node_invalid","unknown keys",a.join(", "),`only: ${[...o].join(", ")}`,"Remove the unknown keys.",t),!1):!0}v(R,"checkKeys");function ee(e,o,t){if(!x(e))return t("command_node_invalid","rootEntry must be an object",m(e),"a { concept, description, whenToUse } object","Fix rootEntry.",o),null;if(!R(e,X,o,t))return null;for(const n of["concept","description","whenToUse"])if(typeof e[n]!="string"||e[n].length===0)return t("command_node_invalid",`rootEntry.${n} must be a non-empty string`,m(e[n]),"a non-empty string",`Add rootEntry.${n}.`,`${o}.${n}`),null;return{concept:e.concept,description:e.description,whenToUse:e.whenToUse}}v(ee,"validateRootEntry");function ne(e,o,t){if(e===void 0)return[];if(!Array.isArray(e))return t("command_node_invalid","params must be an array",m(e),"an array of params (or omitted)","Fix params.",o),null;const n=[],a=new Set;let l=0;for(let s=0;s<e.length;s++){const r=e[s],d=`${o}[${s}]`;if(!x(r))return t("command_node_invalid","param must be an object",m(r),"a param object","Fix the param.",d),null;const g=r.kind;if(typeof g!="string"||!(g in H))return t("command_node_invalid","param kind must be positional|flag|stdin|context-file",String(g),"positional | flag | stdin | context-file","Fix the param kind.",`${d}.kind`),null;if(!R(r,H[g],d,t))return null;const p=r.name;if(typeof p!="string"||!U.test(p))return t("command_node_invalid","param name must be a kebab-case token",String(p),"a kebab-case token","Rename the param.",`${d}.name`),null;if(a.has(p))return t("command_node_invalid","duplicate param name",p,"unique param names","Rename the duplicate param.",`${d}.name`),null;if(a.add(p),typeof r.required!="boolean")return t("command_node_invalid","param required must be a boolean",m(r.required),"true | false","Set required.",`${d}.required`),null;if(typeof r.constraint!="string")return t("command_node_invalid","param constraint must be a string",m(r.constraint),"an inline constraint string","Add a constraint.",`${d}.constraint`),null;if(g==="positional"){if(l++,l>1)return t("command_node_invalid","a leaf may declare at most one positional","multiple positionals","at most one positional param","Convert extra positionals to flags.",d),null;if(r.type!==void 0&&r.type!=="string"&&r.type!=="path")return t("command_node_invalid","positional type must be string|path",String(r.type),"string | path | omitted","Fix the positional type.",`${d}.type`),null;let y=!1;if(r.repeatable!==void 0){if(typeof r.repeatable!="boolean")return t("command_node_invalid","repeatable must be a boolean",m(r.repeatable),"true | false | omitted","Fix repeatable.",`${d}.repeatable`),null;y=r.repeatable}const _=C(r,d,t);if(_===null)return null;const c=M(r,d,t);if(c===null)return null;if(y&&c!==void 0)return t("command_node_invalid","repeatable positional must not declare defaultFromEnv",p,"no defaultFromEnv on a repeatable positional (values accumulate into an array)","Remove defaultFromEnv, or drop repeatable.",`${d}.defaultFromEnv`),null;n.push({kind:"positional",name:p,...r.type!==void 0?{type:r.type}:{},required:r.required,constraint:r.constraint,...y?{repeatable:!0}:{},..._!==void 0?{encoding:_}:{},...c!==void 0?{defaultFromEnv:c}:{}})}else if(g==="stdin")n.push({kind:"stdin",name:p,required:r.required,constraint:r.constraint});else if(g==="context-file")n.push({kind:"context-file",name:p,required:r.required,constraint:r.constraint,...typeof r.shape=="string"?{shape:r.shape}:{}});else if(g==="flag"){const y=r.type;if(typeof y!="string"||!I.has(y))return t("command_node_invalid","flag type must be string|int|bool|path|enum",String(y),"string | int | bool | path | enum","Fix the flag type.",`${d}.type`),null;let _;if(y==="enum"){const f=r.choices;if(!Array.isArray(f)||f.length===0||!f.every(k=>typeof k=="string"))return t("command_node_invalid","enum flag requires a non-empty string choices array",m(f),"a non-empty array of strings","Declare choices for the enum flag.",`${d}.choices`),null;_=f}else if(r.choices!==void 0)return t("command_node_invalid","choices is only valid on an enum flag","choices","no choices unless type is enum","Remove choices.",`${d}.choices`),null;let c=!1;if(r.repeatable!==void 0){if(typeof r.repeatable!="boolean")return t("command_node_invalid","repeatable must be a boolean",m(r.repeatable),"true | false | omitted","Fix repeatable.",`${d}.repeatable`),null;c=r.repeatable}if(c&&(y==="bool"||y==="path"))return t("command_node_invalid",`repeatable is not valid on a ${y} flag`,`${p}: ${y}`,"repeatable only on string | int | enum flags","Remove repeatable or change the flag type.",`${d}.repeatable`),null;if(c&&r.default!==void 0)return t("command_node_invalid","repeatable flag must not declare a default",p,"no default on a repeatable flag (values accumulate into an array)","Remove the default.",`${d}.default`),null;const $=C(r,d,t);if($===null)return null;const E=M(r,d,t);if(E===null)return null;if(c&&E!==void 0)return t("command_node_invalid","repeatable flag must not declare defaultFromEnv",p,"no defaultFromEnv on a repeatable flag (values accumulate into an array)","Remove defaultFromEnv, or drop repeatable.",`${d}.defaultFromEnv`),null;n.push({kind:"flag",name:p,type:y,..._!==void 0?{choices:_}:{},...$!==void 0?{encoding:$}:{},required:r.required,constraint:r.constraint,...r.default!==void 0?{default:r.default}:{},...c?{repeatable:!0}:{},...E!==void 0?{defaultFromEnv:E}:{}})}}return n}v(ne,"validateParams");function C(e,o,t){const n=e.encoding;if(n!==void 0)return typeof n!="string"||!J.has(n)?(t("command_node_invalid","param encoding must be text|base64",String(n),"text | base64 | omitted","Fix the encoding.",`${o}.encoding`),null):e.type!=="path"?(t("command_node_invalid",'encoding is only valid on a type:"path" param',`type ${String(e.type)}`,'type: "path"','Set the param type to "path", or remove encoding.',`${o}.encoding`),null):n}v(C,"validateFileEncoding");function M(e,o,t){const n=e.defaultFromEnv;if(n===void 0)return;if(typeof n!="string"||!w.test(n))return t("command_node_invalid","defaultFromEnv must name an environment variable in UPPER_SNAKE_CASE",String(n),'e.g. "CRTR_NODE_ID"',"Fix the environment variable name.",`${o}.defaultFromEnv`),null;const a=e.type===void 0&&e.kind==="positional"?"string":e.type;return a!=="string"&&a!=="path"?(t("command_node_invalid","defaultFromEnv is only valid on a string|path param",`type ${String(e.type)}`,'type: "string" | "path"',"Change the param type, or remove defaultFromEnv.",`${o}.defaultFromEnv`),null):e.default!==void 0?(t("command_node_invalid","a param must not declare both default and defaultFromEnv",`${String(e.name)}: default + defaultFromEnv`,"exactly one default source","Remove one \u2014 defaultFromEnv counts as supplied, a static default does not.",`${o}.defaultFromEnv`),null):n}v(M,"validateDefaultFromEnv");function te(e,o,t){if(!Array.isArray(e))return t("command_node_invalid","output must be an array",m(e),"an array of output fields","Declare the leaf output fields.",o),null;const n=[];for(let a=0;a<e.length;a++){const l=e[a],s=`${o}[${a}]`;if(!x(l))return t("command_node_invalid","output field must be an object",m(l),"a { name, type, required, constraint } object","Fix the output field.",s),null;if(!R(l,Q,s,t))return null;if(typeof l.name!="string"||l.name.length===0)return t("command_node_invalid","output field name must be a non-empty string",m(l.name),"a field name","Add a name.",`${s}.name`),null;if(typeof l.type!="string"||l.type.length===0)return t("command_node_invalid","output field type must be a non-empty string",m(l.type),"a type name","Add a type.",`${s}.type`),null;if(typeof l.required!="boolean")return t("command_node_invalid","output field required must be a boolean",m(l.required),"true | false","Set required.",`${s}.required`),null;if(typeof l.constraint!="string")return t("command_node_invalid","output field constraint must be a string",m(l.constraint),"a constraint string","Add a constraint.",`${s}.constraint`),null;n.push({name:l.name,type:l.type,required:l.required,constraint:l.constraint})}return n}v(te,"validateOutput");function G(e,o,t){const n=e.name;return typeof n!="string"||!U.test(n)?(t("command_node_invalid","node name must be a lowercase kebab-case token",String(n),'a kebab-case token like "app" or "list-all"',"Rename the node.",`${o}.name`),!1):typeof e.description!="string"||e.description.length===0?(t("command_node_invalid","node description must be a non-empty string",m(e.description),"a short parent-listing description","Add a description.",`${o}.description`),!1):typeof e.whenToUse!="string"||e.whenToUse.length===0?(t("command_node_invalid","node whenToUse must be a non-empty string",m(e.whenToUse),"a parent selection rubric","Add a whenToUse rubric.",`${o}.whenToUse`),!1):e.tier!==void 0&&!B.has(String(e.tier))?(t("command_node_invalid","node tier must be normal|common|important",String(e.tier),"normal | common | important","Fix or omit tier (external plugins cannot declare hidden commands).",`${o}.tier`),!1):!0}v(G,"checkCommon");function ae(e,o,t,n,a,l={}){const s=o.join(".");if(!x(e))return a("command_node_invalid","node must be an object",m(e),"a branch or leaf node object","Fix the node.",s),null;const r=e.kind;return r==="branch"?oe(e,s,t,n,a,l):r==="leaf"?t&&l.topLevelRootEntry!=="forbidden"?(a("command_node_invalid","top-level node must be a branch","leaf","a branch node with a rootEntry","Wrap the command in a top-level branch (noun) with a rootEntry.",`${s}.kind`),null):ie(e,s,n,a):(a("command_node_invalid",'node kind must be "branch" or "leaf"',String(r),"branch | leaf","Set kind to branch or leaf.",`${s}.kind`),null)}v(ae,"validateCommandNode");function oe(e,o,t,n,a,l){const s=l.allowPassthrough!==!1;if(!R(e,n==="exec"&&s?V:N,o,a)||!G(e,o,a))return null;const d=e.rootEntry!==void 0,g=l.topLevelRootEntry??"required";if(t&&g==="required"&&!d)return a("command_node_invalid","top-level branch requires a rootEntry","(missing)","a rootEntry { concept, description, whenToUse }","Add a rootEntry to the top-level branch.",`${o}.rootEntry`),null;if((!t||g==="forbidden")&&d)return a("command_node_invalid",t?"repository fragment root must not declare a rootEntry":"nested branch must not declare a rootEntry","rootEntry",t?"no rootEntry (the owning plugin branch already has one)":"no rootEntry (only top-level branches carry one)",t?"Remove rootEntry from the repository fragment root.":"Remove rootEntry from the nested branch.",`${o}.rootEntry`),null;const p=e.extensible!==void 0;if(p&&(!t||l.allowExtensible===!1||e.extensible!==!0))return a("command_node_invalid",t?"extensible must be exactly true on a plugin top-level branch":"extensible is valid only on a top-level branch mount",String(e.extensible),t?"extensible: true":"no extensible marker on nested branches",t?"Set extensible to true or remove it.":"Move the marker to the plugin top-level branch or remove it.",`${o}.extensible`),null;let y;if(d){const f=ee(e.rootEntry,`${o}.rootEntry`,a);if(f===null)return null;y=f}if(typeof e.summary!="string"||e.summary.length===0)return a("command_node_invalid","branch summary must be a non-empty string",m(e.summary),"a one-line summary string","Add a summary.",`${o}.summary`),null;if(e.model!==void 0&&typeof e.model!="string")return a("command_node_invalid","branch model must be a string",m(e.model),"a string or omitted","Fix or remove model.",`${o}.model`),null;let _;if(n==="exec"&&e.passthrough!==void 0){const f=re(e.passthrough,`${o}.passthrough`,a);if(f===null)return null;_=f}if(p&&_!==void 0)return a("command_node_invalid","an extensible branch cannot declare passthrough","extensible and passthrough","one branch mode: extensible or passthrough","Remove passthrough or remove extensible.",o),null;const c=e.children;if(_!==void 0){if(!Array.isArray(c)||c.length!==0)return a("command_node_invalid","a passthrough branch must declare children: []",Array.isArray(c)?`${c.length} children`:m(c),"an empty children array","Set children to [] \u2014 a passthrough branch forwards all argv and can own no subcommands.",`${o}.children`),null}else if(!Array.isArray(c))return a("command_node_invalid","branch children must be an array",m(c),"an array of branch/leaf nodes (may be empty for populated by mounts)","Fix children.",`${o}.children`),null;const $=[],E=new Set;for(let f=0;f<c.length;f++){const k=ae(c[f],[...o.split("."),`children[${f}]`],!1,n,a,l);if(k===null)return null;if(E.has(k.name))return a("command_node_invalid","duplicate child name",k.name,"unique child names within a branch","Rename the duplicate child.",`${o}.children[${f}].name`),null;E.add(k.name),$.push(k)}return{kind:"branch",name:e.name,description:e.description,whenToUse:e.whenToUse,...e.tier!==void 0?{tier:e.tier}:{},...y!==void 0?{rootEntry:y}:{},...p?{extensible:!0}:{},summary:e.summary,...e.model!==void 0?{model:e.model}:{},..._!==void 0?{passthrough:_}:{},children:$}}v(oe,"validateBranch");function re(e,o,t){if(!x(e))return t("command_node_invalid","passthrough must be an object",m(e),"an object { bin, installHint }","Fix or remove passthrough.",o),null;if(!R(e,Z,o,t))return null;for(const n of["bin","installHint"])if(typeof e[n]!="string"||e[n].length===0)return t("command_node_invalid",`passthrough ${n} must be a non-empty string`,m(e[n]),n==="bin"?"the external binary name":"a one-line install hint",`Set passthrough.${n}.`,`${o}.${n}`),null;return{bin:e.bin,installHint:e.installHint}}v(re,"validatePassthrough");function ie(e,o,t,n){if(!R(e,t==="exec"?L:W,o,n)||!G(e,o,n))return null;if(typeof e.summary!="string"||e.summary.length===0)return n("command_node_invalid","leaf summary must be a non-empty string",m(e.summary),"a one-line summary string","Add a summary.",`${o}.summary`),null;if(t==="exec"&&e.outputKind!=="object")return n("command_node_invalid",'leaf outputKind must be "object" in v1',String(e.outputKind),'exactly "object"','Set outputKind to "object".',`${o}.outputKind`),null;if(t==="http"&&e.rest===void 0)return n("command_node_invalid","HTTP leaf requires a rest mapping","(missing)","a rest object with method, path, and params","Add a rest mapping.",`${o}.rest`),null;const a=ne(e.params,`${o}.params`,n);if(a===null)return null;const l=te(e.output,`${o}.output`,n);if(l===null)return null;const s=e.effects;if(!Array.isArray(s)||s.length===0||!s.every(g=>typeof g=="string"))return n("command_node_invalid","leaf effects must be a non-empty string array",m(s),'a non-empty array of strings (["None. Read-only."] for read-only leaves)',"Declare every persistent effect.",`${o}.effects`),null;const r={kind:"leaf",name:e.name,description:e.description,whenToUse:e.whenToUse,...e.tier!==void 0?{tier:e.tier}:{},summary:e.summary,params:a,output:l,effects:s};if(t==="exec")return{...r,outputKind:"object"};const d=se(e.rest,o,a,n);return d===null?null:{...r,rest:d}}v(ie,"validateLeaf");const le=new Set(["GET","POST","PUT","PATCH","DELETE"]),de=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,me=new Set(["path","query","body","header"]);function se(e,o,t,n){const a=`${o}.rest`;if(!x(e))return n("command_rest_invalid","rest must be an object",m(e),"{ method, path, streaming?, params }","Provide a valid rest mapping.",a),null;const l=new Set(["method","path","streaming","body","bodyRoot","params"]),s=Object.keys(e).filter(i=>!l.has(i));if(s.length>0)return n("command_rest_invalid","unknown rest keys",s.join(", "),"only: method, path, streaming, body, bodyRoot, params","Remove the unknown keys.",a),null;const r=e.method;if(typeof r!="string"||!le.has(r))return n("command_rest_invalid","method must be GET|POST|PUT|PATCH|DELETE",String(r),"one of the HTTP methods","Set method to a valid HTTP verb.",`${a}.method`),null;const d=e.path;if(typeof d!="string"||!d.startsWith("/"))return n("command_rest_invalid","path must be an absolute path starting with /",String(d),'an absolute path like "/v1/devices/{id}"',"Fix the path.",`${a}.path`),null;const g=new Set,p=/\{([a-z][a-z0-9]*(?:-[a-z0-9]+)*)\}/g;let y;for(;(y=p.exec(d))!==null;)g.add(y[1]);let _=!1;if(e.streaming!==void 0){if(typeof e.streaming!="boolean")return n("command_rest_invalid","streaming must be a boolean",m(e.streaming),"true | false | omitted","Fix streaming.",`${a}.streaming`),null;_=e.streaming}const c=e.params;if(!x(c))return n("command_rest_invalid","params must be an object",m(c),"a mapping of param names to placement specs","Provide params.",`${a}.params`),null;const $=new Map;for(const i of t)$.set(i.name,i);const E={},f=[],k=new Set;for(const[i,h]of Object.entries(c)){if(!$.has(i))return n("command_rest_invalid","rest params key has no matching declared param",i,"a name from the leaf params array","Remove this rest params entry or declare the param.",`${a}.params.${i}`),null;if(k.add(i),!x(h))return n("command_rest_invalid","param mapping must be an object",m(h),"{ in, as? }","Fix the param mapping.",`${a}.params.${i}`),null;const S=new Set(["in","as"]),T=Object.keys(h).filter(F=>!S.has(F));if(T.length>0)return n("command_rest_invalid","unknown param mapping keys",T.join(", "),"only: in, as","Remove the unknown keys.",`${a}.params.${i}`),null;const u=h.in;if(typeof u!="string"||!me.has(u))return n("command_rest_invalid","param placement must be path|query|body|header",String(u),"path | query | body | header","Set in to a valid placement.",`${a}.params.${i}.in`),null;const b=h.as;if(b!==void 0&&(typeof b!="string"||b.length===0))return n("command_rest_invalid","as must be a non-empty string",String(b),"a non-empty string","Fix the as value.",`${a}.params.${i}.as`),null;if(u==="header"){if(typeof b!="string"||b.length===0)return n("command_rest_invalid","header placement requires a non-empty as",String(b),"a header name","Provide an as value for the header name.",`${a}.params.${i}.as`),null;if(!de.test(b))return n("command_rest_invalid",'header "as" must be a legal HTTP header field name',b,"an HTTP token (letters, digits, and !#$%&'*+-.^_`|~)","Fix the header name.",`${a}.params.${i}.as`),null}else if(u==="path"){if(b!==void 0)return n("command_rest_invalid","path placement must not have as","as","no as (placeholder name governs)","Remove as.",`${a}.params.${i}.as`),null;const F=$.get(i);if(F.required!==!0)return n("command_rest_invalid",'in:"path" param must be declared required',`${i}: required ${String(F.required)}`,"required: true",`Set "required": true on the "${i}" param.`,`${a}.params.${i}`),null}const K=$.get(i);if((K.kind==="flag"||K.kind==="positional")&&K.repeatable===!0&&u!=="body")return n("command_rest_invalid","repeatable param must use body placement",`${i}: in "${u}"`,'in: "body" (array values ship as a JSON array)',`Map "${i}" to body placement.`,`${a}.params.${i}.in`),null;if(u==="body"){const D=$.get(i).kind==="stdin",Y=b||i;f.push({name:i,isStdin:D,as:Y})}E[i]={in:u,...b!==void 0?{as:b}:{}}}for(const i of t)if(!k.has(i.name))return n("command_rest_invalid","declared param not in rest mapping",i.name,"an entry in rest.params","Add a rest mapping for this param.",`${a}.params`),null;const A=new Set;for(const[i,h]of Object.entries(E))h.in==="path"&&A.add(i);if(A.size!==g.size||![...g].every(i=>A.has(i)))return n("command_rest_invalid","mismatch between path placeholders and path params",`placeholders: ${[...g].join(", ")} | params: ${[...A].join(", ")}`,'exact bijection between {placeholders} and in:"path" params',"Ensure every placeholder has a matching path param, and vice versa.",`${a}.path and ${a}.params`),null;if(r==="GET"&&f.length>0)return n("command_rest_invalid","GET method cannot have body params",f.map(i=>i.name).join(", "),"no body placement for GET","Move body params to query, or change the method.",`${a}.method or ${a}.params`),null;let j;if(e.body!==void 0){if(r==="GET")return n("command_rest_invalid","GET method cannot have body constants","body","no body for GET","Remove body, or change the method.",`${a}.body`),null;const i=e.body;if(!x(i))return n("command_rest_invalid","body must be an object",m(i),"a map of constant literal body fields (string | number | boolean)","Fix body.",`${a}.body`),null;const h={};for(const[u,b]of Object.entries(i)){if(typeof b!="string"&&typeof b!="number"&&typeof b!="boolean")return n("command_rest_invalid",`body.${u} must be a string, number, or boolean`,m(b),"string | number | boolean",`Fix body.${u}.`,`${a}.body.${u}`),null;h[u]=b}const S=new Set(f.map(u=>u.as)),T=Object.keys(h).filter(u=>S.has(u));if(T.length>0)return n("command_rest_invalid","body constant key collides with a param's body key",T.join(", "),"body constant keys distinct from every param's body key (its as or name)","Rename the colliding body constant or param.",`${a}.body`),null;j=h}let P;if(e.bodyRoot!==void 0){if(r==="GET")return n("command_rest_invalid","GET method cannot have bodyRoot","bodyRoot","no bodyRoot for GET","Remove bodyRoot, or change the method.",`${a}.bodyRoot`),null;const i=e.bodyRoot;if(typeof i!="string"||i.length===0)return n("command_rest_invalid","bodyRoot must be a non-empty string",m(i),"a non-empty string key","Fix bodyRoot.",`${a}.bodyRoot`),null;P=i}for(const[i,h]of Object.entries(E)){const S=$.get(i);if((S.kind==="context-file"||(S.kind==="positional"||S.kind==="flag")&&S.type==="path")&&h.in!=="body"){const u=S.kind==="context-file"?"context-file":`path ${S.kind}`;return n("command_rest_invalid",`file param (${u}) must be placed in body`,`${i}: in "${h.in}"`,'in: "body"',"Move the file param to body.",`${a}.params.${i}.in`),null}}const q=new Map;for(const i of f)q.has(i.as)||q.set(i.as,[]),q.get(i.as).push({name:i.name,isStdin:i.isStdin});for(const[i,h]of q.entries())if(h.length>1){const S=h.filter(u=>u.isStdin).length,T=h.filter(u=>!u.isStdin).length;if(!(S===1&&T===1))return n("command_rest_invalid","invalid body as grouping",h.map(u=>u.name).join(", "),"exactly one stdin param and one non-stdin param may share a body as (for coalesced sources)","Fix the body grouping.",`${a}.params (as: "${i}")`),null}return{method:r,path:d,..._!==!1?{streaming:_}:{},...j!==void 0?{body:j}:{},...P!==void 0?{bodyRoot:P}:{},params:E}}v(se,"validateRestMapping");export{ae as validateCommandNode};
|
|
1
|
+
var z=Object.defineProperty;var v=(e,o)=>z(e,"name",{value:o,configurable:!0});import{isRecord as x}from"../../shared/predicates.js";const B=new Set(["normal","common","important"]),I=new Set(["string","int","bool","path","enum"]),U=/^[a-z][a-z0-9]*(-[a-z0-9]+)*$/,N=new Set(["kind","name","description","whenToUse","tier","rootEntry","extensible","summary","model","children"]),V=new Set([...N,"passthrough"]),L=new Set(["bin","installHint"]),O=new Set(["kind","name","description","whenToUse","tier","summary","params","output","effects"]),Z=new Set([...O,"outputKind"]),W=new Set([...O,"rest"]),X=new Set(["concept","description","whenToUse"]),J=new Set(["text","base64"]),C={positional:new Set(["kind","name","type","required","constraint","repeatable","encoding","defaultFromEnv"]),flag:new Set(["kind","name","type","choices","required","constraint","default","repeatable","encoding","defaultFromEnv"]),stdin:new Set(["kind","name","required","constraint"]),"context-file":new Set(["kind","name","required","constraint","shape"])},Q=new Set(["name","type","required","constraint"]),w=/^[A-Z][A-Z0-9_]*$/;function m(e){return e===null?"null":Array.isArray(e)?"array":typeof e}v(m,"typeName");function R(e,o,t,n){const a=Object.keys(e).filter(l=>!o.has(l));return a.length>0?(n("command_node_invalid","unknown keys",a.join(", "),`only: ${[...o].join(", ")}`,"Remove the unknown keys.",t),!1):!0}v(R,"checkKeys");function ee(e,o,t){if(!x(e))return t("command_node_invalid","rootEntry must be an object",m(e),"a { concept, description, whenToUse } object","Fix rootEntry.",o),null;if(!R(e,X,o,t))return null;for(const n of["concept","description","whenToUse"])if(typeof e[n]!="string"||e[n].length===0)return t("command_node_invalid",`rootEntry.${n} must be a non-empty string`,m(e[n]),"a non-empty string",`Add rootEntry.${n}.`,`${o}.${n}`),null;return{concept:e.concept,description:e.description,whenToUse:e.whenToUse}}v(ee,"validateRootEntry");function ne(e,o,t){if(e===void 0)return[];if(!Array.isArray(e))return t("command_node_invalid","params must be an array",m(e),"an array of params (or omitted)","Fix params.",o),null;const n=[],a=new Set;let l=0;for(let s=0;s<e.length;s++){const r=e[s],d=`${o}[${s}]`;if(!x(r))return t("command_node_invalid","param must be an object",m(r),"a param object","Fix the param.",d),null;const g=r.kind;if(typeof g!="string"||!(g in C))return t("command_node_invalid","param kind must be positional|flag|stdin|context-file",String(g),"positional | flag | stdin | context-file","Fix the param kind.",`${d}.kind`),null;if(!R(r,C[g],d,t))return null;const y=r.name;if(typeof y!="string"||!U.test(y))return t("command_node_invalid","param name must be a kebab-case token",String(y),"a kebab-case token","Rename the param.",`${d}.name`),null;if(a.has(y))return t("command_node_invalid","duplicate param name",y,"unique param names","Rename the duplicate param.",`${d}.name`),null;if(a.add(y),typeof r.required!="boolean")return t("command_node_invalid","param required must be a boolean",m(r.required),"true | false","Set required.",`${d}.required`),null;if(typeof r.constraint!="string")return t("command_node_invalid","param constraint must be a string",m(r.constraint),"an inline constraint string","Add a constraint.",`${d}.constraint`),null;if(g==="positional"){if(l++,l>1)return t("command_node_invalid","a leaf may declare at most one positional","multiple positionals","at most one positional param","Convert extra positionals to flags.",d),null;if(r.type!==void 0&&r.type!=="string"&&r.type!=="path")return t("command_node_invalid","positional type must be string|path",String(r.type),"string | path | omitted","Fix the positional type.",`${d}.type`),null;let h=!1;if(r.repeatable!==void 0){if(typeof r.repeatable!="boolean")return t("command_node_invalid","repeatable must be a boolean",m(r.repeatable),"true | false | omitted","Fix repeatable.",`${d}.repeatable`),null;h=r.repeatable}const _=H(r,d,t);if(_===null)return null;const c=M(r,d,t);if(c===null)return null;if(h&&c!==void 0)return t("command_node_invalid","repeatable positional must not declare defaultFromEnv",y,"no defaultFromEnv on a repeatable positional (values accumulate into an array)","Remove defaultFromEnv, or drop repeatable.",`${d}.defaultFromEnv`),null;n.push({kind:"positional",name:y,...r.type!==void 0?{type:r.type}:{},required:r.required,constraint:r.constraint,...h?{repeatable:!0}:{},..._!==void 0?{encoding:_}:{},...c!==void 0?{defaultFromEnv:c}:{}})}else if(g==="stdin")n.push({kind:"stdin",name:y,required:r.required,constraint:r.constraint});else if(g==="context-file")n.push({kind:"context-file",name:y,required:r.required,constraint:r.constraint,...typeof r.shape=="string"?{shape:r.shape}:{}});else if(g==="flag"){const h=r.type;if(typeof h!="string"||!I.has(h))return t("command_node_invalid","flag type must be string|int|bool|path|enum",String(h),"string | int | bool | path | enum","Fix the flag type.",`${d}.type`),null;let _;if(h==="enum"){const f=r.choices;if(!Array.isArray(f)||f.length===0||!f.every(k=>typeof k=="string"))return t("command_node_invalid","enum flag requires a non-empty string choices array",m(f),"a non-empty array of strings","Declare choices for the enum flag.",`${d}.choices`),null;_=f}else if(r.choices!==void 0)return t("command_node_invalid","choices is only valid on an enum flag","choices","no choices unless type is enum","Remove choices.",`${d}.choices`),null;let c=!1;if(r.repeatable!==void 0){if(typeof r.repeatable!="boolean")return t("command_node_invalid","repeatable must be a boolean",m(r.repeatable),"true | false | omitted","Fix repeatable.",`${d}.repeatable`),null;c=r.repeatable}if(c&&(h==="bool"||h==="path"))return t("command_node_invalid",`repeatable is not valid on a ${h} flag`,`${y}: ${h}`,"repeatable only on string | int | enum flags","Remove repeatable or change the flag type.",`${d}.repeatable`),null;if(c&&r.default!==void 0)return t("command_node_invalid","repeatable flag must not declare a default",y,"no default on a repeatable flag (values accumulate into an array)","Remove the default.",`${d}.default`),null;const $=H(r,d,t);if($===null)return null;const E=M(r,d,t);if(E===null)return null;if(c&&E!==void 0)return t("command_node_invalid","repeatable flag must not declare defaultFromEnv",y,"no defaultFromEnv on a repeatable flag (values accumulate into an array)","Remove defaultFromEnv, or drop repeatable.",`${d}.defaultFromEnv`),null;n.push({kind:"flag",name:y,type:h,..._!==void 0?{choices:_}:{},...$!==void 0?{encoding:$}:{},required:r.required,constraint:r.constraint,...r.default!==void 0?{default:r.default}:{},...c?{repeatable:!0}:{},...E!==void 0?{defaultFromEnv:E}:{}})}}return n}v(ne,"validateParams");function H(e,o,t){const n=e.encoding;if(n!==void 0)return typeof n!="string"||!J.has(n)?(t("command_node_invalid","param encoding must be text|base64",String(n),"text | base64 | omitted","Fix the encoding.",`${o}.encoding`),null):e.type!=="path"?(t("command_node_invalid",'encoding is only valid on a type:"path" param',`type ${String(e.type)}`,'type: "path"','Set the param type to "path", or remove encoding.',`${o}.encoding`),null):n}v(H,"validateFileEncoding");function M(e,o,t){const n=e.defaultFromEnv;if(n===void 0)return;if(typeof n!="string"||!w.test(n))return t("command_node_invalid","defaultFromEnv must name an environment variable in UPPER_SNAKE_CASE",String(n),'e.g. "CRTR_NODE_ID"',"Fix the environment variable name.",`${o}.defaultFromEnv`),null;const a=e.type===void 0&&e.kind==="positional"?"string":e.type;return a!=="string"&&a!=="path"?(t("command_node_invalid","defaultFromEnv is only valid on a string|path param",`type ${String(e.type)}`,'type: "string" | "path"',"Change the param type, or remove defaultFromEnv.",`${o}.defaultFromEnv`),null):e.default!==void 0?(t("command_node_invalid","a param must not declare both default and defaultFromEnv",`${String(e.name)}: default + defaultFromEnv`,"exactly one default source","Remove one \u2014 defaultFromEnv counts as supplied, a static default does not.",`${o}.defaultFromEnv`),null):n}v(M,"validateDefaultFromEnv");function te(e,o,t){if(!Array.isArray(e))return t("command_node_invalid","output must be an array",m(e),"an array of output fields","Declare the leaf output fields.",o),null;const n=[];for(let a=0;a<e.length;a++){const l=e[a],s=`${o}[${a}]`;if(!x(l))return t("command_node_invalid","output field must be an object",m(l),"a { name, type, required, constraint } object","Fix the output field.",s),null;if(!R(l,Q,s,t))return null;if(typeof l.name!="string"||l.name.length===0)return t("command_node_invalid","output field name must be a non-empty string",m(l.name),"a field name","Add a name.",`${s}.name`),null;if(typeof l.type!="string"||l.type.length===0)return t("command_node_invalid","output field type must be a non-empty string",m(l.type),"a type name","Add a type.",`${s}.type`),null;if(typeof l.required!="boolean")return t("command_node_invalid","output field required must be a boolean",m(l.required),"true | false","Set required.",`${s}.required`),null;if(typeof l.constraint!="string")return t("command_node_invalid","output field constraint must be a string",m(l.constraint),"a constraint string","Add a constraint.",`${s}.constraint`),null;n.push({name:l.name,type:l.type,required:l.required,constraint:l.constraint})}return n}v(te,"validateOutput");function G(e,o,t){const n=e.name;return typeof n!="string"||!U.test(n)?(t("command_node_invalid","node name must be a lowercase kebab-case token",String(n),'a kebab-case token like "app" or "list-all"',"Rename the node.",`${o}.name`),!1):typeof e.description!="string"||e.description.length===0?(t("command_node_invalid","node description must be a non-empty string",m(e.description),"a short parent-listing description","Add a description.",`${o}.description`),!1):typeof e.whenToUse!="string"||e.whenToUse.length===0?(t("command_node_invalid","node whenToUse must be a non-empty string",m(e.whenToUse),"a parent selection rubric","Add a whenToUse rubric.",`${o}.whenToUse`),!1):e.tier!==void 0&&!B.has(String(e.tier))?(t("command_node_invalid","node tier must be normal|common|important",String(e.tier),"normal | common | important","Fix or omit tier (external plugins cannot declare hidden commands).",`${o}.tier`),!1):!0}v(G,"checkCommon");function ae(e,o,t,n,a,l={}){const s=o.join(".");if(!x(e))return a("command_node_invalid","node must be an object",m(e),"a branch or leaf node object","Fix the node.",s),null;const r=e.kind;return r==="branch"?oe(e,s,t,n,a,l):r==="leaf"?t&&l.topLevelRootEntry!=="forbidden"?(a("command_node_invalid","top-level node must be a branch","leaf","a branch node with a rootEntry","Wrap the command in a top-level branch (noun) with a rootEntry.",`${s}.kind`),null):ie(e,s,n,a):(a("command_node_invalid",'node kind must be "branch" or "leaf"',String(r),"branch | leaf","Set kind to branch or leaf.",`${s}.kind`),null)}v(ae,"validateCommandNode");function oe(e,o,t,n,a,l){const s=l.allowPassthrough!==!1;if(!R(e,n==="exec"&&s?V:N,o,a)||!G(e,o,a))return null;const d=e.rootEntry!==void 0,g=l.topLevelRootEntry??"required";if(t&&g==="required"&&!d)return a("command_node_invalid","top-level branch requires a rootEntry","(missing)","a rootEntry { concept, description, whenToUse }","Add a rootEntry to the top-level branch.",`${o}.rootEntry`),null;if((!t||g==="forbidden")&&d)return a("command_node_invalid",t?"repository fragment root must not declare a rootEntry":"nested branch must not declare a rootEntry","rootEntry",t?"no rootEntry (the owning plugin branch already has one)":"no rootEntry (only top-level branches carry one)",t?"Remove rootEntry from the repository fragment root.":"Remove rootEntry from the nested branch.",`${o}.rootEntry`),null;const y=e.extensible!==void 0;if(y&&(!t||l.allowExtensible===!1||e.extensible!==!0))return a("command_node_invalid",t?"extensible must be exactly true on a plugin top-level branch":"extensible is valid only on a top-level branch mount",String(e.extensible),t?"extensible: true":"no extensible marker on nested branches",t?"Set extensible to true or remove it.":"Move the marker to the plugin top-level branch or remove it.",`${o}.extensible`),null;let h;if(d){const f=ee(e.rootEntry,`${o}.rootEntry`,a);if(f===null)return null;h=f}if(typeof e.summary!="string"||e.summary.length===0)return a("command_node_invalid","branch summary must be a non-empty string",m(e.summary),"a one-line summary string","Add a summary.",`${o}.summary`),null;if(e.model!==void 0&&typeof e.model!="string")return a("command_node_invalid","branch model must be a string",m(e.model),"a string or omitted","Fix or remove model.",`${o}.model`),null;let _;if(n==="exec"&&e.passthrough!==void 0){const f=re(e.passthrough,`${o}.passthrough`,a);if(f===null)return null;_=f}if(y&&_!==void 0)return a("command_node_invalid","an extensible branch cannot declare passthrough","extensible and passthrough","one branch mode: extensible or passthrough","Remove passthrough or remove extensible.",o),null;const c=e.children;if(_!==void 0){if(!Array.isArray(c)||c.length!==0)return a("command_node_invalid","a passthrough branch must declare children: []",Array.isArray(c)?`${c.length} children`:m(c),"an empty children array","Set children to [] \u2014 a passthrough branch forwards all argv and can own no subcommands.",`${o}.children`),null}else if(!Array.isArray(c))return a("command_node_invalid","branch children must be an array",m(c),"an array of branch/leaf nodes (may be empty for populated by mounts)","Fix children.",`${o}.children`),null;const $=[],E=new Set;for(let f=0;f<c.length;f++){const k=ae(c[f],[...o.split("."),`children[${f}]`],!1,n,a,l);if(k===null)return null;if(E.has(k.name))return a("command_node_invalid","duplicate child name",k.name,"unique child names within a branch","Rename the duplicate child.",`${o}.children[${f}].name`),null;E.add(k.name),$.push(k)}return{kind:"branch",name:e.name,description:e.description,whenToUse:e.whenToUse,...e.tier!==void 0?{tier:e.tier}:{},...h!==void 0?{rootEntry:h}:{},...y?{extensible:!0}:{},summary:e.summary,...e.model!==void 0?{model:e.model}:{},..._!==void 0?{passthrough:_}:{},children:$}}v(oe,"validateBranch");function re(e,o,t){if(!x(e))return t("command_node_invalid","passthrough must be an object",m(e),"an object { bin, installHint }","Fix or remove passthrough.",o),null;if(!R(e,L,o,t))return null;for(const n of["bin","installHint"])if(typeof e[n]!="string"||e[n].length===0)return t("command_node_invalid",`passthrough ${n} must be a non-empty string`,m(e[n]),n==="bin"?"the external binary name":"a one-line install hint",`Set passthrough.${n}.`,`${o}.${n}`),null;return{bin:e.bin,installHint:e.installHint}}v(re,"validatePassthrough");function ie(e,o,t,n){if(!R(e,t==="exec"?Z:W,o,n)||!G(e,o,n))return null;if(typeof e.summary!="string"||e.summary.length===0)return n("command_node_invalid","leaf summary must be a non-empty string",m(e.summary),"a one-line summary string","Add a summary.",`${o}.summary`),null;if(t==="exec"&&e.outputKind!=="object")return n("command_node_invalid",'leaf outputKind must be "object" in v1',String(e.outputKind),'exactly "object"','Set outputKind to "object".',`${o}.outputKind`),null;if(t==="http"&&e.rest===void 0)return n("command_node_invalid","HTTP leaf requires a rest mapping","(missing)","a rest object with method, path, and params","Add a rest mapping.",`${o}.rest`),null;const a=ne(e.params,`${o}.params`,n);if(a===null)return null;const l=te(e.output,`${o}.output`,n);if(l===null)return null;const s=e.effects;if(!Array.isArray(s)||s.length===0||!s.every(g=>typeof g=="string"))return n("command_node_invalid","leaf effects must be a non-empty string array",m(s),'a non-empty array of strings (["None. Read-only."] for read-only leaves)',"Declare every persistent effect.",`${o}.effects`),null;const r={kind:"leaf",name:e.name,description:e.description,whenToUse:e.whenToUse,...e.tier!==void 0?{tier:e.tier}:{},summary:e.summary,params:a,output:l,effects:s};if(t==="exec")return{...r,outputKind:"object"};const d=se(e.rest,o,a,n);return d===null?null:{...r,rest:d}}v(ie,"validateLeaf");const le=new Set(["GET","POST","PUT","PATCH","DELETE"]),de=/^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/,me=new Set(["path","query","body","header"]);function se(e,o,t,n){const a=`${o}.rest`;if(!x(e))return n("command_rest_invalid","rest must be an object",m(e),"{ method, path, streaming?, params }","Provide a valid rest mapping.",a),null;const l=new Set(["method","path","streaming","body","bodyRoot","params"]),s=Object.keys(e).filter(i=>!l.has(i));if(s.length>0)return n("command_rest_invalid","unknown rest keys",s.join(", "),"only: method, path, streaming, body, bodyRoot, params","Remove the unknown keys.",a),null;const r=e.method;if(typeof r!="string"||!le.has(r))return n("command_rest_invalid","method must be GET|POST|PUT|PATCH|DELETE",String(r),"one of the HTTP methods","Set method to a valid HTTP verb.",`${a}.method`),null;const d=e.path;if(typeof d!="string"||!d.startsWith("/"))return n("command_rest_invalid","path must be an absolute path starting with /",String(d),'an absolute path like "/v1/devices/{id}"',"Fix the path.",`${a}.path`),null;const g=new Set,y=/\{([a-z][a-z0-9]*(?:-[a-z0-9]+)*)\}/g;let h;for(;(h=y.exec(d))!==null;)g.add(h[1]);let _=!1;if(e.streaming!==void 0){if(typeof e.streaming!="boolean")return n("command_rest_invalid","streaming must be a boolean",m(e.streaming),"true | false | omitted","Fix streaming.",`${a}.streaming`),null;_=e.streaming}const c=e.params;if(!x(c))return n("command_rest_invalid","params must be an object",m(c),"a mapping of param names to placement specs","Provide params.",`${a}.params`),null;const $=new Map;for(const i of t)$.set(i.name,i);const E={},f=[],k=new Set;for(const[i,b]of Object.entries(c)){if(!$.has(i))return n("command_rest_invalid","rest params key has no matching declared param",i,"a name from the leaf params array","Remove this rest params entry or declare the param.",`${a}.params.${i}`),null;if(k.add(i),!x(b))return n("command_rest_invalid","param mapping must be an object",m(b),"{ in, as? }","Fix the param mapping.",`${a}.params.${i}`),null;const S=new Set(["in","as"]),T=Object.keys(b).filter(F=>!S.has(F));if(T.length>0)return n("command_rest_invalid","unknown param mapping keys",T.join(", "),"only: in, as","Remove the unknown keys.",`${a}.params.${i}`),null;const u=b.in;if(typeof u!="string"||!me.has(u))return n("command_rest_invalid","param placement must be path|query|body|header",String(u),"path | query | body | header","Set in to a valid placement.",`${a}.params.${i}.in`),null;const p=b.as;if(p!==void 0&&(typeof p!="string"||p.length===0))return n("command_rest_invalid","as must be a non-empty string",String(p),"a non-empty string","Fix the as value.",`${a}.params.${i}.as`),null;if(u==="header"){if(typeof p!="string"||p.length===0)return n("command_rest_invalid","header placement requires a non-empty as",String(p),"a header name","Provide an as value for the header name.",`${a}.params.${i}.as`),null;if(!de.test(p))return n("command_rest_invalid",'header "as" must be a legal HTTP header field name',p,"an HTTP token (letters, digits, and !#$%&'*+-.^_`|~)","Fix the header name.",`${a}.params.${i}.as`),null;if(p.toLowerCase()==="crtr-request-id")return n("command_rest_invalid","Crtr-Request-Id is assigned by crtr for each leaf call",p,"a header name other than Crtr-Request-Id","Remove this header mapping.",`${a}.params.${i}.as`),null}else if(u==="path"){if(p!==void 0)return n("command_rest_invalid","path placement must not have as","as","no as (placeholder name governs)","Remove as.",`${a}.params.${i}.as`),null;const F=$.get(i);if(F.required!==!0)return n("command_rest_invalid",'in:"path" param must be declared required',`${i}: required ${String(F.required)}`,"required: true",`Set "required": true on the "${i}" param.`,`${a}.params.${i}`),null}const K=$.get(i);if((K.kind==="flag"||K.kind==="positional")&&K.repeatable===!0&&u!=="body")return n("command_rest_invalid","repeatable param must use body placement",`${i}: in "${u}"`,'in: "body" (array values ship as a JSON array)',`Map "${i}" to body placement.`,`${a}.params.${i}.in`),null;if(u==="body"){const D=$.get(i).kind==="stdin",Y=p||i;f.push({name:i,isStdin:D,as:Y})}E[i]={in:u,...p!==void 0?{as:p}:{}}}for(const i of t)if(!k.has(i.name))return n("command_rest_invalid","declared param not in rest mapping",i.name,"an entry in rest.params","Add a rest mapping for this param.",`${a}.params`),null;const A=new Set;for(const[i,b]of Object.entries(E))b.in==="path"&&A.add(i);if(A.size!==g.size||![...g].every(i=>A.has(i)))return n("command_rest_invalid","mismatch between path placeholders and path params",`placeholders: ${[...g].join(", ")} | params: ${[...A].join(", ")}`,'exact bijection between {placeholders} and in:"path" params',"Ensure every placeholder has a matching path param, and vice versa.",`${a}.path and ${a}.params`),null;if(r==="GET"&&f.length>0)return n("command_rest_invalid","GET method cannot have body params",f.map(i=>i.name).join(", "),"no body placement for GET","Move body params to query, or change the method.",`${a}.method or ${a}.params`),null;let j;if(e.body!==void 0){if(r==="GET")return n("command_rest_invalid","GET method cannot have body constants","body","no body for GET","Remove body, or change the method.",`${a}.body`),null;const i=e.body;if(!x(i))return n("command_rest_invalid","body must be an object",m(i),"a map of constant literal body fields (string | number | boolean)","Fix body.",`${a}.body`),null;const b={};for(const[u,p]of Object.entries(i)){if(typeof p!="string"&&typeof p!="number"&&typeof p!="boolean")return n("command_rest_invalid",`body.${u} must be a string, number, or boolean`,m(p),"string | number | boolean",`Fix body.${u}.`,`${a}.body.${u}`),null;b[u]=p}const S=new Set(f.map(u=>u.as)),T=Object.keys(b).filter(u=>S.has(u));if(T.length>0)return n("command_rest_invalid","body constant key collides with a param's body key",T.join(", "),"body constant keys distinct from every param's body key (its as or name)","Rename the colliding body constant or param.",`${a}.body`),null;j=b}let P;if(e.bodyRoot!==void 0){if(r==="GET")return n("command_rest_invalid","GET method cannot have bodyRoot","bodyRoot","no bodyRoot for GET","Remove bodyRoot, or change the method.",`${a}.bodyRoot`),null;const i=e.bodyRoot;if(typeof i!="string"||i.length===0)return n("command_rest_invalid","bodyRoot must be a non-empty string",m(i),"a non-empty string key","Fix bodyRoot.",`${a}.bodyRoot`),null;P=i}for(const[i,b]of Object.entries(E)){const S=$.get(i);if((S.kind==="context-file"||(S.kind==="positional"||S.kind==="flag")&&S.type==="path")&&b.in!=="body"){const u=S.kind==="context-file"?"context-file":`path ${S.kind}`;return n("command_rest_invalid",`file param (${u}) must be placed in body`,`${i}: in "${b.in}"`,'in: "body"',"Move the file param to body.",`${a}.params.${i}.in`),null}}const q=new Map;for(const i of f)q.has(i.as)||q.set(i.as,[]),q.get(i.as).push({name:i.name,isStdin:i.isStdin});for(const[i,b]of q.entries())if(b.length>1){const S=b.filter(u=>u.isStdin).length,T=b.filter(u=>!u.isStdin).length;if(!(S===1&&T===1))return n("command_rest_invalid","invalid body as grouping",b.map(u=>u.name).join(", "),"exactly one stdin param and one non-stdin param may share a body as (for coalesced sources)","Fix the body grouping.",`${a}.params (as: "${i}")`),null}return{method:r,path:d,..._!==!1?{streaming:_}:{},...j!==void 0?{body:j}:{},...P!==void 0?{bodyRoot:P}:{},params:E}}v(se,"validateRestMapping");export{ae as validateCommandNode};
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
export type AnalyticsWindow = '24h' | '7d';
|
|
2
|
+
export interface AnalyticsQuery {
|
|
3
|
+
as_of: string;
|
|
4
|
+
window: AnalyticsWindow;
|
|
5
|
+
project?: string;
|
|
6
|
+
}
|
|
7
|
+
export type MeasureDTO<T> = {
|
|
8
|
+
ok: true;
|
|
9
|
+
value: T;
|
|
10
|
+
} | {
|
|
11
|
+
ok: false;
|
|
12
|
+
reason: string;
|
|
13
|
+
};
|
|
14
|
+
export interface AnalyticsDTO {
|
|
15
|
+
as_of: string;
|
|
16
|
+
window_start: string;
|
|
17
|
+
window: AnalyticsWindow;
|
|
18
|
+
project: string | null;
|
|
19
|
+
projects: Array<{
|
|
20
|
+
cwd: string;
|
|
21
|
+
api_price_estimate: number;
|
|
22
|
+
}>;
|
|
23
|
+
transcripts: {
|
|
24
|
+
total: number;
|
|
25
|
+
read: number;
|
|
26
|
+
unreadable: Array<{
|
|
27
|
+
node_id: string;
|
|
28
|
+
reason: 'file missing' | 'unreadable' | 'parse error';
|
|
29
|
+
}>;
|
|
30
|
+
} | null;
|
|
31
|
+
unknown_responses: number | null;
|
|
32
|
+
oldest_agent_created: string | null;
|
|
33
|
+
memory_log_started_at: string | null;
|
|
34
|
+
agents: AgentRowDTO[];
|
|
35
|
+
graphs: MeasureDTO<GraphsDTO>;
|
|
36
|
+
time: MeasureDTO<TimeDTO>;
|
|
37
|
+
usage: MeasureDTO<UsageDTO>;
|
|
38
|
+
memory: MeasureDTO<{
|
|
39
|
+
read: MemoryViewDTO;
|
|
40
|
+
loaded: MemoryViewDTO;
|
|
41
|
+
}>;
|
|
42
|
+
}
|
|
43
|
+
export interface AgentRowDTO {
|
|
44
|
+
node_id: string;
|
|
45
|
+
name: string;
|
|
46
|
+
kind: string;
|
|
47
|
+
graph_id: string;
|
|
48
|
+
in_graph_detail: boolean;
|
|
49
|
+
parent: string | null;
|
|
50
|
+
depth: number;
|
|
51
|
+
created: string;
|
|
52
|
+
finalized_at: string | null;
|
|
53
|
+
lifecycle: 'resident' | 'terminal';
|
|
54
|
+
active: boolean;
|
|
55
|
+
spawned_in_window: boolean;
|
|
56
|
+
finished_in_window: boolean;
|
|
57
|
+
agent_time_ms: number | null;
|
|
58
|
+
api_price_estimate: number;
|
|
59
|
+
tokens: number;
|
|
60
|
+
responses: number;
|
|
61
|
+
response_times_ms: number[];
|
|
62
|
+
final_report_ref: string | null;
|
|
63
|
+
}
|
|
64
|
+
export interface GraphRowDTO {
|
|
65
|
+
graph_id: string;
|
|
66
|
+
name: string;
|
|
67
|
+
root_deleted: boolean;
|
|
68
|
+
cwd: string;
|
|
69
|
+
root_kind: string;
|
|
70
|
+
root_lifecycle: 'resident' | 'terminal';
|
|
71
|
+
root_created: string;
|
|
72
|
+
active_agents: number;
|
|
73
|
+
depth: number;
|
|
74
|
+
api_price_estimate: number;
|
|
75
|
+
tokens: number;
|
|
76
|
+
spawned_kinds: string[];
|
|
77
|
+
}
|
|
78
|
+
export interface GraphsDTO {
|
|
79
|
+
count: number;
|
|
80
|
+
spawned: number;
|
|
81
|
+
deepest: number;
|
|
82
|
+
graphs: GraphRowDTO[];
|
|
83
|
+
size_buckets: Array<{
|
|
84
|
+
label: '1' | '2–5' | '6–10' | '11–20' | '21+';
|
|
85
|
+
graphs: number;
|
|
86
|
+
}>;
|
|
87
|
+
spawned_by_kind: Array<{
|
|
88
|
+
kind: string;
|
|
89
|
+
agents: number;
|
|
90
|
+
}>;
|
|
91
|
+
}
|
|
92
|
+
export interface DurationStatsDTO {
|
|
93
|
+
count: number;
|
|
94
|
+
p10_ms: number;
|
|
95
|
+
median_ms: number;
|
|
96
|
+
p90_ms: number;
|
|
97
|
+
max_ms: number;
|
|
98
|
+
}
|
|
99
|
+
export interface TimeDTO {
|
|
100
|
+
all: DurationStatsDTO | null;
|
|
101
|
+
by_kind: Array<{
|
|
102
|
+
kind: string;
|
|
103
|
+
} & DurationStatsDTO>;
|
|
104
|
+
activity: {
|
|
105
|
+
bucket_ms: number;
|
|
106
|
+
buckets: Array<{
|
|
107
|
+
start: string;
|
|
108
|
+
agents: number;
|
|
109
|
+
}>;
|
|
110
|
+
max: number;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
export interface ModelKeyDTO {
|
|
114
|
+
provider: string;
|
|
115
|
+
model: string;
|
|
116
|
+
}
|
|
117
|
+
export interface ModelRowDTO extends ModelKeyDTO {
|
|
118
|
+
responses: number;
|
|
119
|
+
api_price_estimate: number;
|
|
120
|
+
tokens: number;
|
|
121
|
+
tokens_by_type: {
|
|
122
|
+
cache_read: number;
|
|
123
|
+
cache_write: number;
|
|
124
|
+
input: number;
|
|
125
|
+
output: number;
|
|
126
|
+
};
|
|
127
|
+
cache_read_share: number;
|
|
128
|
+
context: {
|
|
129
|
+
median: number;
|
|
130
|
+
p90: number;
|
|
131
|
+
max: number;
|
|
132
|
+
buckets: [number, number, number, number, number];
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
export interface UsageDTO {
|
|
136
|
+
api_price_estimate: number;
|
|
137
|
+
tokens: number;
|
|
138
|
+
median_context: number | null;
|
|
139
|
+
models: ModelRowDTO[];
|
|
140
|
+
legend: ModelKeyDTO[];
|
|
141
|
+
kinds: Array<{
|
|
142
|
+
kind: string;
|
|
143
|
+
api_price_estimate: number;
|
|
144
|
+
tokens: number;
|
|
145
|
+
responses_by_model: Array<ModelKeyDTO & {
|
|
146
|
+
responses: number;
|
|
147
|
+
}>;
|
|
148
|
+
}>;
|
|
149
|
+
}
|
|
150
|
+
export interface MemoryDocRowDTO {
|
|
151
|
+
name: string;
|
|
152
|
+
scope: string;
|
|
153
|
+
reads: number;
|
|
154
|
+
agents: number;
|
|
155
|
+
graphs: number;
|
|
156
|
+
readers_by_kind: Array<{
|
|
157
|
+
kind: string;
|
|
158
|
+
agents: number;
|
|
159
|
+
}>;
|
|
160
|
+
readers: Array<{
|
|
161
|
+
node_id: string;
|
|
162
|
+
kind: string;
|
|
163
|
+
name: string;
|
|
164
|
+
graph_id: string;
|
|
165
|
+
reads: number;
|
|
166
|
+
first_at: string;
|
|
167
|
+
}>;
|
|
168
|
+
}
|
|
169
|
+
export interface MemoryViewDTO {
|
|
170
|
+
entries: number;
|
|
171
|
+
documents: number;
|
|
172
|
+
agents_with_entry: number;
|
|
173
|
+
active_agents: number;
|
|
174
|
+
rows: MemoryDocRowDTO[];
|
|
175
|
+
}
|
|
176
|
+
export interface MemoryReadEventDTO {
|
|
177
|
+
name: string;
|
|
178
|
+
scope: string;
|
|
179
|
+
at: string;
|
|
180
|
+
type: 'read' | 'loaded';
|
|
181
|
+
}
|
|
182
|
+
export interface MemoryReadsRequestDTO {
|
|
183
|
+
events: MemoryReadEventDTO[];
|
|
184
|
+
}
|
|
File without changes
|