@monoes/monomindcli 2.16.12 → 2.16.14
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/.claude/agents/core/coder.md +1 -1
- package/.claude/agents/engineering/engineering-devops-automator.md +1 -1
- package/.claude/agents/github/repo-architect.md +1 -1
- package/.claude/agents/testing/production-validator.md +1 -1
- package/.claude/agents/testing/testing-tool-evaluator.md +1 -1
- package/.claude/commands/github/pr-manager.md +1 -1
- package/.claude/helpers/pick-rank.cjs +34 -4
- package/.claude/skills/monolean-audit/SKILL.md +1 -1
- package/README.md +1 -1
- package/dist/src/commands/cleanup-data.d.ts +30 -0
- package/dist/src/commands/cleanup-data.d.ts.map +1 -0
- package/dist/src/commands/cleanup-data.js +138 -0
- package/dist/src/commands/cleanup-data.js.map +1 -0
- package/dist/src/commands/cleanup-scratch.d.ts +43 -0
- package/dist/src/commands/cleanup-scratch.d.ts.map +1 -0
- package/dist/src/commands/cleanup-scratch.js +125 -0
- package/dist/src/commands/cleanup-scratch.js.map +1 -0
- package/dist/src/commands/cleanup.d.ts +2 -39
- package/dist/src/commands/cleanup.d.ts.map +1 -1
- package/dist/src/commands/cleanup.js +5 -247
- package/dist/src/commands/cleanup.js.map +1 -1
- package/dist/src/commands/doctor-gitignore-checks.d.ts +10 -0
- package/dist/src/commands/doctor-gitignore-checks.d.ts.map +1 -0
- package/dist/src/commands/doctor-gitignore-checks.js +141 -0
- package/dist/src/commands/doctor-gitignore-checks.js.map +1 -0
- package/dist/src/commands/doctor-helpers-checks.d.ts +10 -0
- package/dist/src/commands/doctor-helpers-checks.d.ts.map +1 -0
- package/dist/src/commands/doctor-helpers-checks.js +292 -0
- package/dist/src/commands/doctor-helpers-checks.js.map +1 -0
- package/dist/src/commands/doctor-memory-checks.d.ts +47 -0
- package/dist/src/commands/doctor-memory-checks.d.ts.map +1 -0
- package/dist/src/commands/doctor-memory-checks.js +298 -0
- package/dist/src/commands/doctor-memory-checks.js.map +1 -0
- package/dist/src/commands/doctor-monograph-checks.d.ts +9 -0
- package/dist/src/commands/doctor-monograph-checks.d.ts.map +1 -0
- package/dist/src/commands/doctor-monograph-checks.js +331 -0
- package/dist/src/commands/doctor-monograph-checks.js.map +1 -0
- package/dist/src/commands/doctor-project-checks.d.ts +7 -66
- package/dist/src/commands/doctor-project-checks.d.ts.map +1 -1
- package/dist/src/commands/doctor-project-checks.js +10 -1331
- package/dist/src/commands/doctor-project-checks.js.map +1 -1
- package/dist/src/commands/doctor-routing-checks.d.ts +10 -0
- package/dist/src/commands/doctor-routing-checks.d.ts.map +1 -0
- package/dist/src/commands/doctor-routing-checks.js +194 -0
- package/dist/src/commands/doctor-routing-checks.js.map +1 -0
- package/dist/src/commands/doctor-worker-checks.d.ts +17 -0
- package/dist/src/commands/doctor-worker-checks.d.ts.map +1 -0
- package/dist/src/commands/doctor-worker-checks.js +122 -0
- package/dist/src/commands/doctor-worker-checks.js.map +1 -0
- package/dist/src/commands/hooks-routing-commands.js +1 -1
- package/dist/src/commands/hooks-routing-commands.js.map +1 -1
- package/dist/src/commands/init.d.ts.map +1 -1
- package/dist/src/commands/init.js +6 -15
- package/dist/src/commands/init.js.map +1 -1
- package/dist/src/commands/org-control.d.ts +117 -0
- package/dist/src/commands/org-control.d.ts.map +1 -0
- package/dist/src/commands/org-control.js +274 -0
- package/dist/src/commands/org-control.js.map +1 -0
- package/dist/src/commands/org-lifecycle.d.ts +7 -0
- package/dist/src/commands/org-lifecycle.d.ts.map +1 -0
- package/dist/src/commands/org-lifecycle.js +298 -0
- package/dist/src/commands/org-lifecycle.js.map +1 -0
- package/dist/src/commands/org-manage.d.ts +7 -0
- package/dist/src/commands/org-manage.d.ts.map +1 -0
- package/dist/src/commands/org-manage.js +357 -0
- package/dist/src/commands/org-manage.js.map +1 -0
- package/dist/src/commands/org-memory-command.d.ts +3 -0
- package/dist/src/commands/org-memory-command.d.ts.map +1 -0
- package/dist/src/commands/org-memory-command.js +178 -0
- package/dist/src/commands/org-memory-command.js.map +1 -0
- package/dist/src/commands/org-observe-approvals.d.ts +8 -0
- package/dist/src/commands/org-observe-approvals.d.ts.map +1 -0
- package/dist/src/commands/org-observe-approvals.js +211 -0
- package/dist/src/commands/org-observe-approvals.js.map +1 -0
- package/dist/src/commands/org-observe-checkpoint.d.ts +26 -0
- package/dist/src/commands/org-observe-checkpoint.d.ts.map +1 -0
- package/dist/src/commands/org-observe-checkpoint.js +180 -0
- package/dist/src/commands/org-observe-checkpoint.js.map +1 -0
- package/dist/src/commands/org-observe-config.d.ts +8 -0
- package/dist/src/commands/org-observe-config.d.ts.map +1 -0
- package/dist/src/commands/org-observe-config.js +160 -0
- package/dist/src/commands/org-observe-config.js.map +1 -0
- package/dist/src/commands/org-observe-gates.d.ts +4 -0
- package/dist/src/commands/org-observe-gates.d.ts.map +1 -0
- package/dist/src/commands/org-observe-gates.js +182 -0
- package/dist/src/commands/org-observe-gates.js.map +1 -0
- package/dist/src/commands/org-observe-inbox.d.ts +18 -0
- package/dist/src/commands/org-observe-inbox.d.ts.map +1 -0
- package/dist/src/commands/org-observe-inbox.js +154 -0
- package/dist/src/commands/org-observe-inbox.js.map +1 -0
- package/dist/src/commands/org-observe-logs.d.ts +31 -0
- package/dist/src/commands/org-observe-logs.d.ts.map +1 -0
- package/dist/src/commands/org-observe-logs.js +272 -0
- package/dist/src/commands/org-observe-logs.js.map +1 -0
- package/dist/src/commands/org-observe-questions.d.ts +8 -0
- package/dist/src/commands/org-observe-questions.d.ts.map +1 -0
- package/dist/src/commands/org-observe-questions.js +201 -0
- package/dist/src/commands/org-observe-questions.js.map +1 -0
- package/dist/src/commands/org-observe-report.d.ts +8 -0
- package/dist/src/commands/org-observe-report.d.ts.map +1 -0
- package/dist/src/commands/org-observe-report.js +366 -0
- package/dist/src/commands/org-observe-report.js.map +1 -0
- package/dist/src/commands/org-observe-shared.d.ts +20 -0
- package/dist/src/commands/org-observe-shared.d.ts.map +1 -0
- package/dist/src/commands/org-observe-shared.js +55 -0
- package/dist/src/commands/org-observe-shared.js.map +1 -0
- package/dist/src/commands/org-observe.d.ts +9 -101
- package/dist/src/commands/org-observe.d.ts.map +1 -1
- package/dist/src/commands/org-observe.js +12 -1675
- package/dist/src/commands/org-observe.js.map +1 -1
- package/dist/src/commands/org-poll.d.ts +57 -0
- package/dist/src/commands/org-poll.d.ts.map +1 -0
- package/dist/src/commands/org-poll.js +194 -0
- package/dist/src/commands/org-poll.js.map +1 -0
- package/dist/src/commands/org-run.d.ts +3 -0
- package/dist/src/commands/org-run.d.ts.map +1 -0
- package/dist/src/commands/org-run.js +449 -0
- package/dist/src/commands/org-run.js.map +1 -0
- package/dist/src/commands/org-serve.d.ts +19 -0
- package/dist/src/commands/org-serve.d.ts.map +1 -0
- package/dist/src/commands/org-serve.js +395 -0
- package/dist/src/commands/org-serve.js.map +1 -0
- package/dist/src/commands/org-subcommands-config.d.ts +8 -0
- package/dist/src/commands/org-subcommands-config.d.ts.map +1 -0
- package/dist/src/commands/org-subcommands-config.js +93 -0
- package/dist/src/commands/org-subcommands-config.js.map +1 -0
- package/dist/src/commands/org-subcommands-hil.d.ts +11 -0
- package/dist/src/commands/org-subcommands-hil.d.ts.map +1 -0
- package/dist/src/commands/org-subcommands-hil.js +216 -0
- package/dist/src/commands/org-subcommands-hil.js.map +1 -0
- package/dist/src/commands/org-subcommands-observe.d.ts +12 -0
- package/dist/src/commands/org-subcommands-observe.d.ts.map +1 -0
- package/dist/src/commands/org-subcommands-observe.js +249 -0
- package/dist/src/commands/org-subcommands-observe.js.map +1 -0
- package/dist/src/commands/org-subcommands-runtime.d.ts +12 -0
- package/dist/src/commands/org-subcommands-runtime.d.ts.map +1 -0
- package/dist/src/commands/org-subcommands-runtime.js +163 -0
- package/dist/src/commands/org-subcommands-runtime.js.map +1 -0
- package/dist/src/commands/org.d.ts +3 -151
- package/dist/src/commands/org.d.ts.map +1 -1
- package/dist/src/commands/org.js +43 -2735
- package/dist/src/commands/org.js.map +1 -1
- package/dist/src/index.js +2 -2
- package/dist/src/index.js.map +1 -1
- package/dist/src/init/never-commit.d.ts +3 -3
- package/dist/src/init/types.d.ts +1 -1
- package/dist/src/init/types.js +1 -1
- package/dist/src/knowledge/document-store.js +1 -1
- package/dist/src/knowledge/document-store.js.map +1 -1
- package/dist/src/mcp-tools/hooks-edit-command.d.ts +10 -0
- package/dist/src/mcp-tools/hooks-edit-command.d.ts.map +1 -0
- package/dist/src/mcp-tools/hooks-edit-command.js +247 -0
- package/dist/src/mcp-tools/hooks-edit-command.js.map +1 -0
- package/dist/src/mcp-tools/hooks-learning.d.ts +9 -0
- package/dist/src/mcp-tools/hooks-learning.d.ts.map +1 -0
- package/dist/src/mcp-tools/hooks-learning.js +408 -0
- package/dist/src/mcp-tools/hooks-learning.js.map +1 -0
- package/dist/src/mcp-tools/hooks-metrics-list.d.ts +8 -0
- package/dist/src/mcp-tools/hooks-metrics-list.d.ts.map +1 -0
- package/dist/src/mcp-tools/hooks-metrics-list.js +205 -0
- package/dist/src/mcp-tools/hooks-metrics-list.js.map +1 -0
- package/dist/src/mcp-tools/hooks-route.d.ts +12 -0
- package/dist/src/mcp-tools/hooks-route.d.ts.map +1 -0
- package/dist/src/mcp-tools/hooks-route.js +251 -0
- package/dist/src/mcp-tools/hooks-route.js.map +1 -0
- package/dist/src/mcp-tools/hooks-routing.d.ts +6 -27
- package/dist/src/mcp-tools/hooks-routing.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-routing.js +6 -1727
- package/dist/src/mcp-tools/hooks-routing.js.map +1 -1
- package/dist/src/mcp-tools/hooks-session.d.ts +9 -0
- package/dist/src/mcp-tools/hooks-session.d.ts.map +1 -0
- package/dist/src/mcp-tools/hooks-session.js +243 -0
- package/dist/src/mcp-tools/hooks-session.js.map +1 -0
- package/dist/src/mcp-tools/hooks-task.d.ts +17 -0
- package/dist/src/mcp-tools/hooks-task.d.ts.map +1 -0
- package/dist/src/mcp-tools/hooks-task.js +427 -0
- package/dist/src/mcp-tools/hooks-task.js.map +1 -0
- package/dist/src/mcp-tools/hooks-tools.d.ts +2 -1
- package/dist/src/mcp-tools/hooks-tools.d.ts.map +1 -1
- package/dist/src/mcp-tools/hooks-tools.js +2 -1
- package/dist/src/mcp-tools/hooks-tools.js.map +1 -1
- package/dist/src/mcp-tools/memory-tools.js +1 -1
- package/dist/src/mcp-tools/memory-tools.js.map +1 -1
- package/dist/src/memory/bm25-index.d.ts +2 -2
- package/dist/src/memory/bm25-index.js +2 -2
- package/dist/src/memory/embedding-operations.js +2 -2
- package/dist/src/memory/embedding-operations.js.map +1 -1
- package/dist/src/memory/entity-name-key.d.ts +1 -1
- package/dist/src/memory/entity-name-key.js +1 -1
- package/dist/src/memory/hnsw-operations.d.ts +1 -1
- package/dist/src/memory/hnsw-operations.js +1 -1
- package/dist/src/memory/memory-bridge-backend.d.ts +43 -0
- package/dist/src/memory/memory-bridge-backend.d.ts.map +1 -0
- package/dist/src/memory/memory-bridge-backend.js +363 -0
- package/dist/src/memory/memory-bridge-backend.js.map +1 -0
- package/dist/src/memory/memory-bridge-core.d.ts +42 -0
- package/dist/src/memory/memory-bridge-core.d.ts.map +1 -0
- package/dist/src/memory/memory-bridge-core.js +126 -0
- package/dist/src/memory/memory-bridge-core.js.map +1 -0
- package/dist/src/memory/memory-bridge-entries.d.ts +131 -0
- package/dist/src/memory/memory-bridge-entries.d.ts.map +1 -0
- package/dist/src/memory/memory-bridge-entries.js +227 -0
- package/dist/src/memory/memory-bridge-entries.js.map +1 -0
- package/dist/src/memory/memory-bridge-feedback.d.ts +60 -0
- package/dist/src/memory/memory-bridge-feedback.d.ts.map +1 -0
- package/dist/src/memory/memory-bridge-feedback.js +118 -0
- package/dist/src/memory/memory-bridge-feedback.js.map +1 -0
- package/dist/src/memory/memory-bridge-paths.d.ts +123 -0
- package/dist/src/memory/memory-bridge-paths.d.ts.map +1 -0
- package/dist/src/memory/memory-bridge-paths.js +335 -0
- package/dist/src/memory/memory-bridge-paths.js.map +1 -0
- package/dist/src/memory/memory-bridge-search.d.ts +48 -0
- package/dist/src/memory/memory-bridge-search.d.ts.map +1 -0
- package/dist/src/memory/memory-bridge-search.js +383 -0
- package/dist/src/memory/memory-bridge-search.js.map +1 -0
- package/dist/src/memory/memory-bridge-sessions.d.ts +38 -0
- package/dist/src/memory/memory-bridge-sessions.d.ts.map +1 -0
- package/dist/src/memory/memory-bridge-sessions.js +109 -0
- package/dist/src/memory/memory-bridge-sessions.js.map +1 -0
- package/dist/src/memory/memory-bridge-store.d.ts +58 -0
- package/dist/src/memory/memory-bridge-store.d.ts.map +1 -0
- package/dist/src/memory/memory-bridge-store.js +201 -0
- package/dist/src/memory/memory-bridge-store.js.map +1 -0
- package/dist/src/memory/memory-bridge.d.ts +10 -438
- package/dist/src/memory/memory-bridge.d.ts.map +1 -1
- package/dist/src/memory/memory-bridge.js +14 -1787
- package/dist/src/memory/memory-bridge.js.map +1 -1
- package/dist/src/memory/memory-kg-claims.d.ts +52 -0
- package/dist/src/memory/memory-kg-claims.d.ts.map +1 -0
- package/dist/src/memory/memory-kg-claims.js +99 -0
- package/dist/src/memory/memory-kg-claims.js.map +1 -0
- package/dist/src/memory/memory-kg-index.d.ts +86 -0
- package/dist/src/memory/memory-kg-index.d.ts.map +1 -0
- package/dist/src/memory/memory-kg-index.js +256 -0
- package/dist/src/memory/memory-kg-index.js.map +1 -0
- package/dist/src/memory/memory-kg-ingest.d.ts +44 -0
- package/dist/src/memory/memory-kg-ingest.d.ts.map +1 -0
- package/dist/src/memory/memory-kg-ingest.js +361 -0
- package/dist/src/memory/memory-kg-ingest.js.map +1 -0
- package/dist/src/memory/memory-kg-model.d.ts +168 -0
- package/dist/src/memory/memory-kg-model.d.ts.map +1 -0
- package/dist/src/memory/memory-kg-model.js +158 -0
- package/dist/src/memory/memory-kg-model.js.map +1 -0
- package/dist/src/memory/memory-kg-names.d.ts +64 -0
- package/dist/src/memory/memory-kg-names.d.ts.map +1 -0
- package/dist/src/memory/memory-kg-names.js +187 -0
- package/dist/src/memory/memory-kg-names.js.map +1 -0
- package/dist/src/memory/memory-kg-promote.d.ts +79 -0
- package/dist/src/memory/memory-kg-promote.d.ts.map +1 -0
- package/dist/src/memory/memory-kg-promote.js +248 -0
- package/dist/src/memory/memory-kg-promote.js.map +1 -0
- package/dist/src/memory/memory-kg-rebuild.d.ts +77 -0
- package/dist/src/memory/memory-kg-rebuild.d.ts.map +1 -0
- package/dist/src/memory/memory-kg-rebuild.js +299 -0
- package/dist/src/memory/memory-kg-rebuild.js.map +1 -0
- package/dist/src/memory/memory-kg-rollback.d.ts +47 -0
- package/dist/src/memory/memory-kg-rollback.d.ts.map +1 -0
- package/dist/src/memory/memory-kg-rollback.js +193 -0
- package/dist/src/memory/memory-kg-rollback.js.map +1 -0
- package/dist/src/memory/memory-kg-rules.d.ts +64 -0
- package/dist/src/memory/memory-kg-rules.d.ts.map +1 -0
- package/dist/src/memory/memory-kg-rules.js +251 -0
- package/dist/src/memory/memory-kg-rules.js.map +1 -0
- package/dist/src/memory/memory-kg-scan.d.ts +118 -0
- package/dist/src/memory/memory-kg-scan.d.ts.map +1 -0
- package/dist/src/memory/memory-kg-scan.js +209 -0
- package/dist/src/memory/memory-kg-scan.js.map +1 -0
- package/dist/src/memory/memory-kg-search.d.ts +80 -0
- package/dist/src/memory/memory-kg-search.d.ts.map +1 -0
- package/dist/src/memory/memory-kg-search.js +239 -0
- package/dist/src/memory/memory-kg-search.js.map +1 -0
- package/dist/src/memory/memory-kg.d.ts +19 -547
- package/dist/src/memory/memory-kg.d.ts.map +1 -1
- package/dist/src/memory/memory-kg.js +10 -2389
- package/dist/src/memory/memory-kg.js.map +1 -1
- package/dist/src/orgrt/daemon-types.d.ts +196 -0
- package/dist/src/orgrt/daemon-types.d.ts.map +1 -0
- package/dist/src/orgrt/daemon-types.js +38 -0
- package/dist/src/orgrt/daemon-types.js.map +1 -0
- package/dist/src/orgrt/daemon.d.ts +70 -300
- package/dist/src/orgrt/daemon.d.ts.map +1 -1
- package/dist/src/orgrt/daemon.js +41 -2536
- package/dist/src/orgrt/daemon.js.map +1 -1
- package/dist/src/orgrt/idle-watchdog.d.ts +39 -0
- package/dist/src/orgrt/idle-watchdog.d.ts.map +1 -0
- package/dist/src/orgrt/idle-watchdog.js +289 -0
- package/dist/src/orgrt/idle-watchdog.js.map +1 -0
- package/dist/src/orgrt/org-reload.d.ts +7 -0
- package/dist/src/orgrt/org-reload.d.ts.map +1 -0
- package/dist/src/orgrt/org-reload.js +111 -0
- package/dist/src/orgrt/org-reload.js.map +1 -0
- package/dist/src/orgrt/org-start-steps.d.ts +21 -0
- package/dist/src/orgrt/org-start-steps.d.ts.map +1 -0
- package/dist/src/orgrt/org-start-steps.js +305 -0
- package/dist/src/orgrt/org-start-steps.js.map +1 -0
- package/dist/src/orgrt/org-start.d.ts +7 -0
- package/dist/src/orgrt/org-start.d.ts.map +1 -0
- package/dist/src/orgrt/org-start.js +435 -0
- package/dist/src/orgrt/org-start.js.map +1 -0
- package/dist/src/orgrt/org-state-file.d.ts +8 -0
- package/dist/src/orgrt/org-state-file.d.ts.map +1 -0
- package/dist/src/orgrt/org-state-file.js +116 -0
- package/dist/src/orgrt/org-state-file.js.map +1 -0
- package/dist/src/orgrt/org-stop.d.ts +6 -0
- package/dist/src/orgrt/org-stop.d.ts.map +1 -0
- package/dist/src/orgrt/org-stop.js +332 -0
- package/dist/src/orgrt/org-stop.js.map +1 -0
- package/dist/src/orgrt/org-tools.d.ts +11 -0
- package/dist/src/orgrt/org-tools.d.ts.map +1 -0
- package/dist/src/orgrt/org-tools.js +305 -0
- package/dist/src/orgrt/org-tools.js.map +1 -0
- package/dist/src/orgrt/role-incarnation.d.ts +18 -0
- package/dist/src/orgrt/role-incarnation.d.ts.map +1 -0
- package/dist/src/orgrt/role-incarnation.js +374 -0
- package/dist/src/orgrt/role-incarnation.js.map +1 -0
- package/dist/src/orgrt/role-respawn.d.ts +7 -0
- package/dist/src/orgrt/role-respawn.d.ts.map +1 -0
- package/dist/src/orgrt/role-respawn.js +318 -0
- package/dist/src/orgrt/role-respawn.js.map +1 -0
- package/dist/src/orgrt/role-session-opts.d.ts +389 -0
- package/dist/src/orgrt/role-session-opts.d.ts.map +1 -0
- package/dist/src/orgrt/role-session-opts.js +289 -0
- package/dist/src/orgrt/role-session-opts.js.map +1 -0
- package/dist/src/orgrt/runner-resolve.d.ts +43 -0
- package/dist/src/orgrt/runner-resolve.d.ts.map +1 -0
- package/dist/src/orgrt/runner-resolve.js +77 -0
- package/dist/src/orgrt/runner-resolve.js.map +1 -0
- package/dist/src/orgrt/session-gate.d.ts +34 -0
- package/dist/src/orgrt/session-gate.d.ts.map +1 -0
- package/dist/src/orgrt/session-gate.js +74 -0
- package/dist/src/orgrt/session-gate.js.map +1 -0
- package/dist/src/orgrt/session-prompt.d.ts +31 -0
- package/dist/src/orgrt/session-prompt.d.ts.map +1 -0
- package/dist/src/orgrt/session-prompt.js +115 -0
- package/dist/src/orgrt/session-prompt.js.map +1 -0
- package/dist/src/orgrt/session-run.d.ts +18 -0
- package/dist/src/orgrt/session-run.d.ts.map +1 -0
- package/dist/src/orgrt/session-run.js +429 -0
- package/dist/src/orgrt/session-run.js.map +1 -0
- package/dist/src/orgrt/session-stream.d.ts +21 -0
- package/dist/src/orgrt/session-stream.d.ts.map +1 -0
- package/dist/src/orgrt/session-stream.js +173 -0
- package/dist/src/orgrt/session-stream.js.map +1 -0
- package/dist/src/orgrt/session-types.d.ts +219 -0
- package/dist/src/orgrt/session-types.d.ts.map +1 -0
- package/dist/src/orgrt/session-types.js +2 -0
- package/dist/src/orgrt/session-types.js.map +1 -0
- package/dist/src/orgrt/session-usage.d.ts +29 -0
- package/dist/src/orgrt/session-usage.d.ts.map +1 -0
- package/dist/src/orgrt/session-usage.js +64 -0
- package/dist/src/orgrt/session-usage.js.map +1 -0
- package/dist/src/orgrt/session.d.ts +5 -281
- package/dist/src/orgrt/session.d.ts.map +1 -1
- package/dist/src/orgrt/session.js +8 -1117
- package/dist/src/orgrt/session.js.map +1 -1
- package/dist/src/ui/org-hil.mjs +1 -1
- package/dist/src/ui/routes-org-agents.mjs +318 -0
- package/dist/src/ui/routes-org-approvals.mjs +133 -0
- package/dist/src/ui/routes-org-config.mjs +459 -0
- package/dist/src/ui/routes-org-control.mjs +300 -0
- package/dist/src/ui/routes-org-files.mjs +172 -0
- package/dist/src/ui/routes-org-helpers.mjs +84 -0
- package/dist/src/ui/routes-org-knowledge.mjs +262 -0
- package/dist/src/ui/routes-org-lifecycle.mjs +224 -0
- package/dist/src/ui/routes-org-live.mjs +278 -0
- package/dist/src/ui/routes-org-mastermind.mjs +346 -0
- package/dist/src/ui/routes-org-planning.mjs +398 -0
- package/dist/src/ui/routes-org-runs.mjs +430 -0
- package/dist/src/ui/routes-org-status.mjs +342 -0
- package/dist/src/ui/routes-org-workflows.mjs +212 -0
- package/dist/src/ui/routes-org.mjs +26 -3847
- package/dist/src/ui/server.mjs +1 -1
- package/dist/src/utils/native-error.d.ts +1 -1
- package/dist/src/utils/native-error.js +1 -1
- package/dist/src/utils/paths.d.ts +2 -1
- package/dist/src/utils/paths.d.ts.map +1 -1
- package/dist/src/utils/paths.js +2 -1
- package/dist/src/utils/paths.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/org-skills/adversarial-reviewer/SKILL.md +1 -1
- package/org-skills/board-deck-builder/SKILL.md +1 -1
- package/org-skills/code-reviewer/SKILL.md +1 -1
- package/org-skills/debugging-wizard/SKILL.md +1 -1
- package/org-skills/scientific-thinking-literature-review/SKILL.md +1 -1
- package/org-skills/scientific-thinking-scholar-evaluation/SKILL.md +1 -1
- package/package.json +5 -5
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
// packages/@monomind/cli/src/orgrt/session-stream.ts
|
|
2
|
+
// Extracted from session-run.ts — opening one role session's runner stream:
|
|
3
|
+
// the AgentRunner.run() arguments and the silent-first-pull guard.
|
|
4
|
+
import { join } from 'node:path';
|
|
5
|
+
import { ClaudeAgentRunner } from './agent-runner.js';
|
|
6
|
+
import { CLAUDE_SANDBOX_CWD_ENV, claudeBashTimeoutEnv, claudeSandboxCwdNote, } from './bash-timeout.js';
|
|
7
|
+
import { resolveProviderEnv } from './provider.js';
|
|
8
|
+
import { gatedCanUseTool } from './session-gate.js';
|
|
9
|
+
import { rolePromptFor } from './session-prompt.js';
|
|
10
|
+
/** How long an SDK stream may stay open with zero messages before we say so.
|
|
11
|
+
* Comfortably longer than a slow first turn, shorter than the idle watchdog's
|
|
12
|
+
* 10-minute window so the specific cause is reported before the generic
|
|
13
|
+
* "boss appears hung". */
|
|
14
|
+
const SILENT_SESSION_MS = 4 * 60_000;
|
|
15
|
+
/** The AgentRunner.run() arguments for one session, built by runOneSession. */
|
|
16
|
+
export function sessionRunArgs(opts, s) {
|
|
17
|
+
const { org, role, policy, mailbox, cwd } = opts;
|
|
18
|
+
const { runner, tools, streamOpts, gitEnforcement, model, tier, prov, resume, authorityMask, abort, } = s;
|
|
19
|
+
return {
|
|
20
|
+
tools,
|
|
21
|
+
// No options = the pre-D3 stream, exactly.
|
|
22
|
+
prompt: streamOpts ? mailbox.stream('', streamOpts) : mailbox.stream(),
|
|
23
|
+
systemPrompt: gitEnforcement.claudeRestrictions?.sandbox
|
|
24
|
+
? `${rolePromptFor(opts)}\n\n${claudeSandboxCwdNote(cwd)}`
|
|
25
|
+
: rolePromptFor(opts),
|
|
26
|
+
model,
|
|
27
|
+
cwd,
|
|
28
|
+
effort: tier?.effort,
|
|
29
|
+
env: {
|
|
30
|
+
...resolveProviderEnv(prov.cfg),
|
|
31
|
+
// D8: how a NON-Claude provider expresses the tier's effort level.
|
|
32
|
+
// Empty for Claude (handled natively by ClaudeAgentRunner) and for a
|
|
33
|
+
// provider that declares no mechanism — which simply ignores effort.
|
|
34
|
+
...(tier?.env ?? {}),
|
|
35
|
+
// Claude Code's 2-minute Bash default is too short for org work.
|
|
36
|
+
...(runner instanceof ClaudeAgentRunner
|
|
37
|
+
? claudeBashTimeoutEnv(opts.def?.run_config?.bash_timeout_ms)
|
|
38
|
+
: {}),
|
|
39
|
+
// Custom-endpoint providers (named-provider path): pin the engine's
|
|
40
|
+
// model env so background/haiku tasks also route to the endpoint's
|
|
41
|
+
// model instead of erroring on an Anthropic-only default.
|
|
42
|
+
...(prov.cfg?.authToken ? { ANTHROPIC_MODEL: model, ANTHROPIC_SMALL_FAST_MODEL: model } : {}),
|
|
43
|
+
...gitEnforcement.env,
|
|
44
|
+
...(gitEnforcement.claudeRestrictions?.sandbox ? CLAUDE_SANDBOX_CWD_ENV : {}),
|
|
45
|
+
// No MONOMIND_HOOK_QUIET / MONOMIND_GRAPH_GATE / MONOMIND_SDK_AGENT
|
|
46
|
+
// here (#249): every CLI hands this env to its shell tool, so they
|
|
47
|
+
// reached every command the role ran and silently muted monomind's
|
|
48
|
+
// own hooks, graph gate and tests inside the role. ClaudeAgentRunner
|
|
49
|
+
// loads no filesystem hooks (settingSources: []). The codex/kimi/
|
|
50
|
+
// opencode hook bridges generated by `monomind init` read the
|
|
51
|
+
// MONOMIND_ORG_ROLE marker below and set the quieting vars on the
|
|
52
|
+
// hook-handler process they spawn — hooks stay quiet, commands don't.
|
|
53
|
+
//
|
|
54
|
+
// Per-role scoping for runners that persist state under the org dir
|
|
55
|
+
// (VercelAgentRunner session files). Without these, session files would
|
|
56
|
+
// land in args.cwd (project root for workspace:'repo') under the literal
|
|
57
|
+
// 'default' roleId, polluting the repo and making files unattributable.
|
|
58
|
+
MONOMIND_ORG_DIR: opts.orgDir ?? opts.cwd,
|
|
59
|
+
MONOMIND_ROLE_ID: role.id,
|
|
60
|
+
// M1: attribution for anything the role runs (C-16).
|
|
61
|
+
MONOMIND_ORG_NAME: org,
|
|
62
|
+
MONOMIND_ORG_ROLE: role.id,
|
|
63
|
+
...(opts.run ? { MONOMIND_ORG_RUN: opts.run } : {}),
|
|
64
|
+
...(opts.orgRoot ? { MONOMIND_ORG_ROOT: opts.orgRoot } : {}),
|
|
65
|
+
},
|
|
66
|
+
maxTurns: opts.maxTurns ?? 30,
|
|
67
|
+
maxToolRounds: role.max_tool_rounds ?? opts.def?.run_config?.max_tool_rounds,
|
|
68
|
+
resume,
|
|
69
|
+
claudeRestrictions: gitEnforcement.claudeRestrictions,
|
|
70
|
+
authorityMask,
|
|
71
|
+
// ADR-O001 D2: tool results are 76% of a role's context mass and nothing
|
|
72
|
+
// bounded them. Under the ORG STATE dir (never the workspace cwd, which
|
|
73
|
+
// may be the repo), and under orgRoot — which file-roots.ts already
|
|
74
|
+
// makes readable to the role's file tools and role-sandbox.ts already
|
|
75
|
+
// makes readable to Bash — so the path in the digest actually resolves
|
|
76
|
+
// when the role decides it needs the full text.
|
|
77
|
+
toolSpillDir: join(opts.orgDir ?? opts.cwd, 'tool-results', role.id.replace(/[^a-zA-Z0-9_.-]/g, '_')),
|
|
78
|
+
canUseTool: gatedCanUseTool(policy, opts.beforeTool, role.id, opts.fence, opts.onDecision
|
|
79
|
+
? (toolName, _input, decision, kind) => opts.onDecision?.(role.id, toolName, decision.message ?? 'denied', kind)
|
|
80
|
+
: undefined, opts.hasPendingGate),
|
|
81
|
+
// test seam forwarded through extras: lets the scripted fake SDK
|
|
82
|
+
// (test-loop.ts) drive org_send and tool calls through the real
|
|
83
|
+
// deliver/policy paths; the real SDK ignores it.
|
|
84
|
+
extras: opts.runner
|
|
85
|
+
? undefined
|
|
86
|
+
: {
|
|
87
|
+
_orgTest: {
|
|
88
|
+
deliver: (to, subject, body) => opts.deliver(role.id, to, subject, body),
|
|
89
|
+
callTool: (name, input) => policy.decide(name, input),
|
|
90
|
+
},
|
|
91
|
+
},
|
|
92
|
+
signal: abort.signal,
|
|
93
|
+
// VercelAgentRunner-only fields — ignored by other runners.
|
|
94
|
+
vendor: role.provider?.vendor,
|
|
95
|
+
providerConfig: role.provider,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
// A silent session is its own failure mode, and until now an unnameable
|
|
99
|
+
// one: nine consecutive cycles of a scheduled org opened all seven streams
|
|
100
|
+
// and yielded NOTHING - no assistant message, no result, no error, and no
|
|
101
|
+
// stream end. The only symptom was the idle watchdog reporting the boss
|
|
102
|
+
// "appears hung" twenty minutes later, which described neither the scope
|
|
103
|
+
// (every role) nor the cause.
|
|
104
|
+
//
|
|
105
|
+
// Naming it used to be all this did: log an audit event at 4 minutes and
|
|
106
|
+
// then keep waiting on the same stuck `for await`, so recovery still
|
|
107
|
+
// depended on the org-wide idle watchdog (10m nudge + 10m stop = 20m of
|
|
108
|
+
// dead time per cycle - and it kills the WHOLE run, not just the stuck
|
|
109
|
+
// session). Only the FIRST pull from the stream is raced against the
|
|
110
|
+
// timeout: once any message has arrived the session is demonstrably
|
|
111
|
+
// alive, so a slow-but-working tool call is never mistaken for a stall.
|
|
112
|
+
// On silence, abandon this attempt (best-effort iterator.return() to
|
|
113
|
+
// signal the SDK) and throw - the caller's crash-retry-with-backoff loop
|
|
114
|
+
// (daemon.ts's `runtime.done`) already knows how to retry a failed
|
|
115
|
+
// session with a fresh query() call and, for the boss, escalate to a
|
|
116
|
+
// whole-org restart if it keeps failing. That gives the SDK several
|
|
117
|
+
// fresh attempts within a single cycle instead of one silent attempt
|
|
118
|
+
// followed by twenty minutes of nothing.
|
|
119
|
+
export async function openSessionStream(opts, stream, abort) {
|
|
120
|
+
const { org, role, bus } = opts;
|
|
121
|
+
const openedAt = Date.now();
|
|
122
|
+
const iterator = stream[Symbol.asyncIterator]();
|
|
123
|
+
const SILENT = Symbol('silent');
|
|
124
|
+
let silentTimer;
|
|
125
|
+
const silentMs = opts.silentSessionMs ?? SILENT_SESSION_MS;
|
|
126
|
+
const firstPull = await Promise.race([
|
|
127
|
+
iterator.next(),
|
|
128
|
+
new Promise((resolve) => {
|
|
129
|
+
silentTimer = setTimeout(() => resolve(SILENT), silentMs);
|
|
130
|
+
silentTimer.unref?.();
|
|
131
|
+
}),
|
|
132
|
+
]);
|
|
133
|
+
clearTimeout(silentTimer);
|
|
134
|
+
if (firstPull === SILENT) {
|
|
135
|
+
bus.emit({
|
|
136
|
+
type: 'audit',
|
|
137
|
+
from: role.id,
|
|
138
|
+
reason: 'session-silent',
|
|
139
|
+
msg: `SDK stream open ${Math.round((Date.now() - openedAt) / 1000)}s with zero messages - aborting this attempt and retrying. Set MONOMIND_DEBUG=1 to log raw message types.`,
|
|
140
|
+
});
|
|
141
|
+
// Kill the runner's subprocess FIRST: iterator.return() below cannot
|
|
142
|
+
// reach a runner blocked in its stdout loop, and the retry would
|
|
143
|
+
// otherwise spawn a second CLI next to the still-running first one.
|
|
144
|
+
abort.abort();
|
|
145
|
+
try {
|
|
146
|
+
await Promise.race([
|
|
147
|
+
iterator.return?.(undefined) ?? Promise.resolve(),
|
|
148
|
+
new Promise((r) => {
|
|
149
|
+
const t = setTimeout(() => r(), 2_000);
|
|
150
|
+
t.unref?.();
|
|
151
|
+
}),
|
|
152
|
+
]);
|
|
153
|
+
}
|
|
154
|
+
catch {
|
|
155
|
+
/* best-effort */
|
|
156
|
+
}
|
|
157
|
+
throw new Error(`org "${org}" role "${role.id}": SDK stream silent for ${Math.round(silentMs / 1000)}s with zero messages`);
|
|
158
|
+
}
|
|
159
|
+
const first = firstPull;
|
|
160
|
+
// Replay the first pulled message, then continue draining normally.
|
|
161
|
+
async function* rest() {
|
|
162
|
+
if (!first.done)
|
|
163
|
+
yield first.value;
|
|
164
|
+
while (true) {
|
|
165
|
+
const r = await iterator.next();
|
|
166
|
+
if (r.done)
|
|
167
|
+
return;
|
|
168
|
+
yield r.value;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
return rest();
|
|
172
|
+
}
|
|
173
|
+
//# sourceMappingURL=session-stream.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-stream.js","sourceRoot":"","sources":["../../../src/orgrt/session-stream.ts"],"names":[],"mappings":"AAAA,qDAAqD;AACrD,4EAA4E;AAC5E,mEAAmE;AACnE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAA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E,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import type { query } from '@anthropic-ai/claude-agent-sdk';
|
|
2
|
+
import type { AgentRunner, OrgToolDef } from './agent-runner.js';
|
|
3
|
+
import type { OrgBus } from './bus.js';
|
|
4
|
+
import type { TaskEvidence } from './completion-gate.js';
|
|
5
|
+
import type { RoleFence } from './fence.js';
|
|
6
|
+
import type { LoadoutSummary, ResolvedLoadout } from './loadouts.js';
|
|
7
|
+
import type { Mailbox } from './mailbox.js';
|
|
8
|
+
import type { PolicyEngine } from './policy.js';
|
|
9
|
+
import type { SessionLedger } from './session-ledger.js';
|
|
10
|
+
import type { TaskProcesses } from './task-cancel.js';
|
|
11
|
+
import type { RolePick, TaskPick } from './task-match.js';
|
|
12
|
+
import type { DecisionKind, OrgDef, OrgRole } from './types.js';
|
|
13
|
+
export type DeliverFn = (from: string, to: string, subject: string, body: string) => Promise<string>;
|
|
14
|
+
export interface SessionOpts {
|
|
15
|
+
org: string;
|
|
16
|
+
role: OrgRole;
|
|
17
|
+
bus: OrgBus;
|
|
18
|
+
policy: PolicyEngine;
|
|
19
|
+
mailbox: Mailbox;
|
|
20
|
+
cwd: string;
|
|
21
|
+
/** Org state directory (`.monomind/orgs/<name>`). Used to pass
|
|
22
|
+
* MONOMIND_ORG_DIR to runners that persist per-role state (VercelAgentRunner
|
|
23
|
+
* stores session history under `<orgDir>/sessions/`). */
|
|
24
|
+
orgDir?: string;
|
|
25
|
+
/** Project root for resolving `adapter_config.provider` named providers
|
|
26
|
+
* (config search must start at the project root even when the role's
|
|
27
|
+
* workspace cwd is an isolated scratch dir). Defaults to opts.cwd. */
|
|
28
|
+
orgRoot?: string;
|
|
29
|
+
/** Run id of the org run this session belongs to (MONOMIND_ORG_RUN). */
|
|
30
|
+
run?: string;
|
|
31
|
+
/** M1: build this session's tool-provider tools (role `tool_providers`).
|
|
32
|
+
* Called once per session start; the returned set is closed (provider
|
|
33
|
+
* processes killed) when the session ends. */
|
|
34
|
+
buildProviderTools?: () => Promise<{
|
|
35
|
+
tools: OrgToolDef[];
|
|
36
|
+
close(): void;
|
|
37
|
+
} | undefined>;
|
|
38
|
+
deliver: DeliverFn;
|
|
39
|
+
askHuman?: (role: string, question: string, blocking?: boolean) => Promise<string>;
|
|
40
|
+
/** Coordinator-only: records the run's outcome (daemon persists it to run
|
|
41
|
+
* history) — #302: the daemon gathers the facts, calls the completion
|
|
42
|
+
* gate, and returns a refusal string instead of recording anything when
|
|
43
|
+
* the call is unsatisfiable; `null`/`undefined` means allowed. */
|
|
44
|
+
onComplete?: (role: string, outcome: 'achieved' | 'partial' | 'failed', summary: string, blocker?: 'budget' | 'human' | 'external' | 'time', blockerDetail?: string) => string | null | undefined;
|
|
45
|
+
/** Present only for the selected coordinator (same gating pattern as
|
|
46
|
+
* onComplete) — mid-run role replacement. Returns the JSON-shaped
|
|
47
|
+
* RespawnReceipt (see role-slot.ts). */
|
|
48
|
+
onRespawnRole?: (callerId: string, args: {
|
|
49
|
+
roleId: string;
|
|
50
|
+
runtime?: string;
|
|
51
|
+
model?: string;
|
|
52
|
+
providerName?: string;
|
|
53
|
+
budgetTokens?: number;
|
|
54
|
+
reason: string;
|
|
55
|
+
briefing: string;
|
|
56
|
+
}) => Promise<unknown>;
|
|
57
|
+
/** Present only for the selected coordinator. Returns the JSON-shaped
|
|
58
|
+
* runtime/named-provider listing (see runtime-options.ts). */
|
|
59
|
+
onListRuntimeOptions?: () => Promise<unknown>;
|
|
60
|
+
/** Search the org's accumulated cross-run memory (memory_namespace). */
|
|
61
|
+
recall?: (role: string, query: string) => Promise<string>;
|
|
62
|
+
/** Write a memory deliberately: scope 'org' (shared, default) or 'agent' (private to this role). */
|
|
63
|
+
remember?: (role: string, content: string, scope: 'org' | 'agent') => Promise<string>;
|
|
64
|
+
/** Persist extracted entities/relations/rules into the org's knowledge graph. */
|
|
65
|
+
learn?: (role: string, payload: {
|
|
66
|
+
nodes?: {
|
|
67
|
+
name: string;
|
|
68
|
+
type?: string;
|
|
69
|
+
description?: string;
|
|
70
|
+
}[];
|
|
71
|
+
edges?: {
|
|
72
|
+
source: string;
|
|
73
|
+
target: string;
|
|
74
|
+
relation: string;
|
|
75
|
+
description?: string;
|
|
76
|
+
}[];
|
|
77
|
+
rules?: {
|
|
78
|
+
rule: string;
|
|
79
|
+
context?: string;
|
|
80
|
+
}[];
|
|
81
|
+
}) => Promise<string>;
|
|
82
|
+
/** Top existing KG entity names - injected into the coordinator prompt so
|
|
83
|
+
* extraction reuses canonical names instead of minting near-duplicates. */
|
|
84
|
+
glossary?: string[];
|
|
85
|
+
/** Search the user's Second Brain (project documents + personal global brain). */
|
|
86
|
+
searchKnowledge?: (role: string, query: string) => Promise<string>;
|
|
87
|
+
/** Guardrail beforeTool hook: checks if a tool call requires approval before execution.
|
|
88
|
+
* `input` is the tool's actual call arguments — required so the approval cache can
|
|
89
|
+
* key on what's actually being called (e.g. the Bash command, the WebFetch url),
|
|
90
|
+
* not just the tool name; see approvals.ts's checkApproval for why. */
|
|
91
|
+
beforeTool?: (role: string, toolName: string, input: Record<string, unknown>) => Promise<boolean | null>;
|
|
92
|
+
/** Called whenever gatedCanUseTool denies a tool call — wired to daemon.recordDecision()
|
|
93
|
+
* so those denials show up in `org decisions` traces. `kind` (#290) says which
|
|
94
|
+
* deny path fired, so the trace is machine-readable rather than prose-only. */
|
|
95
|
+
onDecision?: (role: string, toolName: string, message: string, kind: DecisionKind) => void;
|
|
96
|
+
/** ORG-9: reports whether this role currently has a pending decision gate —
|
|
97
|
+
* wired to daemon.listGates(org, 'pending'). When true, gatedCanUseTool
|
|
98
|
+
* denies every tool call until the gate is resolved. */
|
|
99
|
+
hasPendingGate?: () => boolean;
|
|
100
|
+
def?: OrgDef;
|
|
101
|
+
maxTurns?: number;
|
|
102
|
+
queryFn?: typeof query;
|
|
103
|
+
/** Provider-agnostic runner. Takes precedence over queryFn. When unset,
|
|
104
|
+
* session.ts builds a ClaudeAgentRunner from queryFn (or the default),
|
|
105
|
+
* preserving the previous Claude-only behaviour exactly. */
|
|
106
|
+
runner?: AgentRunner;
|
|
107
|
+
/** Caller-owned cancellation handle for THIS incarnation. Every session
|
|
108
|
+
* attempt runs on its own AbortController linked to this one: aborting it
|
|
109
|
+
* aborts the in-flight attempt, which lets the daemon force-stop a specific
|
|
110
|
+
* incarnation (org stop, mid-run role replacement's forced-stop step)
|
|
111
|
+
* without reaching into runAgentSession's internals. An attempt's own abort
|
|
112
|
+
* (the silent-stream kill) never propagates back to it (#256). */
|
|
113
|
+
externalAbort?: AbortController;
|
|
114
|
+
/** Lets org_task_cancel end this role's task-scoped process for the
|
|
115
|
+
* cancelled task (task-cancel.ts). */
|
|
116
|
+
taskProcesses?: TaskProcesses;
|
|
117
|
+
/** Override how long a session's first stream pull may stay silent before
|
|
118
|
+
* the attempt is aborted and retried (tests only; default 4 minutes). */
|
|
119
|
+
silentSessionMs?: number;
|
|
120
|
+
/** ID of the last message received by this agent (for threading responses). Function to ensure live reading. */
|
|
121
|
+
lastMessageId?: () => string | undefined;
|
|
122
|
+
/** Callback for each output line — feeds ScrollbackBuffer. */
|
|
123
|
+
onOutput?: (line: string) => void;
|
|
124
|
+
/** Callback when the SDK assigns a session ID — enables checkpoint resume (P2-13). */
|
|
125
|
+
onSessionId?: (id: string) => void;
|
|
126
|
+
/** Called once per finished turn (the runner's `result` message), so the
|
|
127
|
+
* daemon can check what the role left open before its session parks. */
|
|
128
|
+
onTurnEnd?: () => void;
|
|
129
|
+
/** SDK session ID persisted in a checkpoint from a prior run — when set, the
|
|
130
|
+
* first query() call resumes it instead of starting a fresh conversation
|
|
131
|
+
* (P2-13: this is what actually makes checkpoint resume resume). */
|
|
132
|
+
resumeSessionId?: string;
|
|
133
|
+
/** ADR-O001 D3: the run's task-keyed session records. Every session run is
|
|
134
|
+
* recorded here (sessionIdBefore/After) in every scope; only
|
|
135
|
+
* `session_scope: 'task'` resumes from it. Omitted = in-memory. */
|
|
136
|
+
sessionLedger?: SessionLedger;
|
|
137
|
+
/** Circuit breaker config for this role. */
|
|
138
|
+
circuitBreaker?: {
|
|
139
|
+
threshold: number;
|
|
140
|
+
state: {
|
|
141
|
+
failures: number;
|
|
142
|
+
tripped: boolean;
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
/** Called when the coordinator's context window is exhausted. */
|
|
146
|
+
onContextLimit?: () => void;
|
|
147
|
+
/** MonoFence guardrail instance for this role. */
|
|
148
|
+
fence?: RoleFence;
|
|
149
|
+
/** Decision gate: creates a hard-blocking human-approval checkpoint. */
|
|
150
|
+
onGate?: (role: string, name: string, description: string) => Promise<string>;
|
|
151
|
+
/** Task DAG: create a task with dependencies. `loadout` (ADR-O001 D7) is
|
|
152
|
+
* the catalog entry the caller selected; only offered when the org has a
|
|
153
|
+
* catalog (`loadoutCatalog`). */
|
|
154
|
+
createTask?: (role: string, title: string, assignee: string, deps: string[], loadout?: string, brief?: string, pick?: TaskPick) => string;
|
|
155
|
+
/** Resolves `assignee: "auto"` on org_task from the title and brief: the
|
|
156
|
+
* decision model (or, without one, a keyword match over role titles and
|
|
157
|
+
* responsibilities) picks among the agent roles other than `caller`.
|
|
158
|
+
* `role: null` = no role fits (or the best ones tie); the caller must name
|
|
159
|
+
* one. The pick is recorded on the task (OrgTask.pick). */
|
|
160
|
+
pickAssignee?: (title: string, brief: string | undefined, caller: string) => Promise<RolePick>;
|
|
161
|
+
/** Called after org_skill_load served one of the role's skills, so the
|
|
162
|
+
* daemon can record it against a task that suggested it. */
|
|
163
|
+
onSkillLoad?: (role: string, name: string) => void;
|
|
164
|
+
/** ADR-O001 D7: the org's loadout catalog. Set only when the org declares
|
|
165
|
+
* one; it adds the optional `loadout` argument to org_task/org_plan_graph.
|
|
166
|
+
* Unset, those tools are byte-identical to before (same gating idea as
|
|
167
|
+
* `requireTaskEvidence`). Identical for every role and every loadout, so
|
|
168
|
+
* the tool list — prefix position 0 — never varies with the loadout. */
|
|
169
|
+
loadoutCatalog?: LoadoutSummary[];
|
|
170
|
+
/** ADR-O001 D7: the loadout THIS session's system prompt is built with.
|
|
171
|
+
* Plain data resolved by the caller before the session starts, so it is
|
|
172
|
+
* fixed for the session's whole life — every maxTurns/crash restart
|
|
173
|
+
* rebuilds the identical prompt, and nothing can edit it mid-session.
|
|
174
|
+
* D3 hook: a task-keyed session for (role, taskKey) passes
|
|
175
|
+
* `resolveLoadout(def, task.loadout, root)` here. */
|
|
176
|
+
loadout?: ResolvedLoadout;
|
|
177
|
+
/** ADR-O001 D3 x D7: in task scope each task's session is built with that
|
|
178
|
+
* task's recorded loadout (undefined = none selected) instead of the
|
|
179
|
+
* incarnation's `loadout`, which then only serves untagged mail. */
|
|
180
|
+
loadoutFor?: (taskId: string) => ResolvedLoadout | undefined;
|
|
181
|
+
/** Task DAG: mark a task as completed. `evidence` is ADR-O001 D5's
|
|
182
|
+
* machine-checkable proof — acceptance commands with their real exit
|
|
183
|
+
* codes, pinned to a commit sha. Only demanded when the org sets
|
|
184
|
+
* run_config.completion_evidence (see `requireTaskEvidence`). */
|
|
185
|
+
completeTask?: (role: string, taskId: string, result?: string, evidence?: TaskEvidence) => string;
|
|
186
|
+
/** run_config.completion_evidence: when true, org_task_done advertises the
|
|
187
|
+
* evidence argument as required. Off by default, so a role in an org that
|
|
188
|
+
* has not opted in sees a byte-identical tool description (D7: the tool
|
|
189
|
+
* list is prefix position 0 — changing it for every org would invalidate
|
|
190
|
+
* every cached prompt). */
|
|
191
|
+
requireTaskEvidence?: boolean;
|
|
192
|
+
/** ADR-O001 D6: request an artifact-only review. Set only when the org has
|
|
193
|
+
* a role with review_input: 'artifact-only'; otherwise org_review is not
|
|
194
|
+
* registered and the tool list is unchanged. */
|
|
195
|
+
requestReview?: (role: string, taskId: string, reviewer: string, base?: string) => string;
|
|
196
|
+
/** Task DAG: list all tasks, or just `taskId`. */
|
|
197
|
+
listTasks?: (taskId?: string) => string;
|
|
198
|
+
splitTask?: (role: string, parentId: string, children: {
|
|
199
|
+
title: string;
|
|
200
|
+
assignee: string;
|
|
201
|
+
}[]) => string;
|
|
202
|
+
mergeTask?: (role: string, sourceId: string, targetId: string) => string;
|
|
203
|
+
cancelTask?: (role: string, taskId: string, reason?: string) => string;
|
|
204
|
+
/** Task DAG: mark a 'running' task as waiting on a real-world time (not a
|
|
205
|
+
* dependency) — e.g. a scheduled soak test, a CI run, a human-set
|
|
206
|
+
* deadline. The idle watchdog skips nudging while any task is actively
|
|
207
|
+
* blocked, auto-resumes (re-dispatches) it once the time passes, and
|
|
208
|
+
* wakes its assignee to re-check it every recheckAfterMinutes (#329). */
|
|
209
|
+
blockTask?: (role: string, taskId: string, untilIso: string, reason?: string, recheckAfterMinutes?: number) => string;
|
|
210
|
+
planGraph?: (role: string, specs: {
|
|
211
|
+
name: string;
|
|
212
|
+
title: string;
|
|
213
|
+
assignee: string;
|
|
214
|
+
after?: string[];
|
|
215
|
+
loadout?: string;
|
|
216
|
+
brief?: string;
|
|
217
|
+
}[]) => string;
|
|
218
|
+
}
|
|
219
|
+
//# sourceMappingURL=session-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-types.d.ts","sourceRoot":"","sources":["../../../src/orgrt/session-types.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,gCAAgC,CAAC;AAC5D,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACzD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAC5C,OAAO,KAAK,EAAE,cAAc,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AACrE,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;A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EACf,mBAAmB,CAAC,EAAE,MAAM,KACzB,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,CACV,IAAI,EAAE,MAAM,EACZ,KAAK,EAAE;QACL,IAAI,EAAE,MAAM,CAAC;QACb,KAAK,EAAE,MAAM,CAAC;QACd,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;QACjB,OAAO,CAAC,EAAE,MAAM,CAAC;QACjB,KAAK,CAAC,EAAE,MAAM,CAAC;KAChB,EAAE,KACA,MAAM,CAAC;CACb"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-types.js","sourceRoot":"","sources":["../../../src/orgrt/session-types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { AgentMessage } from './agent-runner.js';
|
|
2
|
+
import type { OrgBus } from './bus.js';
|
|
3
|
+
import type { CumulativeMeter } from './cumulative-meter.js';
|
|
4
|
+
import type { TokenUsage } from './policy.js';
|
|
5
|
+
/** ADR-O001 D1 — token-metering helpers.
|
|
6
|
+
*
|
|
7
|
+
* `cache_read_input_tokens` and `cache_creation_input_tokens` are siblings
|
|
8
|
+
* of `input_tokens` in the Anthropic API, not subsets of it, and both are
|
|
9
|
+
* billable. Everything below therefore sums all four. */
|
|
10
|
+
export declare function totalTokens(u: TokenUsage): number;
|
|
11
|
+
export declare function addTo(target: TokenUsage, add: TokenUsage): void;
|
|
12
|
+
/** One model turn's own usage, off an 'assistant' (or per-turn 'result')
|
|
13
|
+
* message. */
|
|
14
|
+
export declare function turnBreakdown(m: AgentMessage): TokenUsage;
|
|
15
|
+
/** What a 'result' message says this mailbox message consumed.
|
|
16
|
+
*
|
|
17
|
+
* When the runner reports `cumulative_tokens` (the Claude SDK's whole-pipeline
|
|
18
|
+
* `modelUsage`, which unlike `usage` includes Task subagents and sidechains),
|
|
19
|
+
* that value is CUMULATIVE per session — the same lifecycle as
|
|
20
|
+
* `total_cost_usd` — so it is converted to a delta by the meter (see
|
|
21
|
+
* cumulative-meter.ts). Without `cumulative_tokens` the per-turn fields are
|
|
22
|
+
* used as before. */
|
|
23
|
+
export declare function resultBreakdown(m: AgentMessage, tokenTotals: CumulativeMeter<TokenUsage> | undefined, sid: string): TokenUsage;
|
|
24
|
+
/** ADR-O001 D1: the four quantities travel separately so every downstream
|
|
25
|
+
* consumer (forwarder → dashboard state.json, reporting, `org costs`) can
|
|
26
|
+
* record real values instead of the 0s they used to persist. `tokens` stays
|
|
27
|
+
* the single billable total. */
|
|
28
|
+
export declare function emitUsage(bus: OrgBus, from: string, t: TokenUsage, costUsd: number | undefined, subtype: string | undefined): void;
|
|
29
|
+
//# sourceMappingURL=session-usage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-usage.d.ts","sourceRoot":"","sources":["../../../src/orgrt/session-usage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtD,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE9C;;;;0DAI0D;AAC1D,wBAAgB,WAAW,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,CAEjD;AAED,wBAAgB,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,UAAU,GAAG,IAAI,CAK/D;AAED;eACe;AACf,wBAAgB,aAAa,CAAC,CAAC,EAAE,YAAY,GAAG,UAAU,CAOzD;AAED;;;;;;;sBAOsB;AACtB,wBAAgB,eAAe,CAC7B,CAAC,EAAE,YAAY,EACf,WAAW,EAAE,eAAe,CAAC,UAAU,CAAC,GAAG,SAAS,EACpD,GAAG,EAAE,MAAM,GACV,UAAU,CAUZ;AAED;;;iCAGiC;AACjC,wBAAgB,SAAS,CACvB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,EACZ,CAAC,EAAE,UAAU,EACb,OAAO,EAAE,MAAM,GAAG,SAAS,EAC3B,OAAO,EAAE,MAAM,GAAG,SAAS,GAC1B,IAAI,CAcN"}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/** ADR-O001 D1 — token-metering helpers.
|
|
2
|
+
*
|
|
3
|
+
* `cache_read_input_tokens` and `cache_creation_input_tokens` are siblings
|
|
4
|
+
* of `input_tokens` in the Anthropic API, not subsets of it, and both are
|
|
5
|
+
* billable. Everything below therefore sums all four. */
|
|
6
|
+
export function totalTokens(u) {
|
|
7
|
+
return u.input + u.output + u.cacheRead + u.cacheCreation;
|
|
8
|
+
}
|
|
9
|
+
export function addTo(target, add) {
|
|
10
|
+
target.input += add.input;
|
|
11
|
+
target.output += add.output;
|
|
12
|
+
target.cacheRead += add.cacheRead;
|
|
13
|
+
target.cacheCreation += add.cacheCreation;
|
|
14
|
+
}
|
|
15
|
+
/** One model turn's own usage, off an 'assistant' (or per-turn 'result')
|
|
16
|
+
* message. */
|
|
17
|
+
export function turnBreakdown(m) {
|
|
18
|
+
return {
|
|
19
|
+
input: m.input_tokens ?? 0,
|
|
20
|
+
output: m.output_tokens ?? 0,
|
|
21
|
+
cacheRead: m.cache_read_input_tokens ?? 0,
|
|
22
|
+
cacheCreation: m.cache_creation_input_tokens ?? 0,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/** What a 'result' message says this mailbox message consumed.
|
|
26
|
+
*
|
|
27
|
+
* When the runner reports `cumulative_tokens` (the Claude SDK's whole-pipeline
|
|
28
|
+
* `modelUsage`, which unlike `usage` includes Task subagents and sidechains),
|
|
29
|
+
* that value is CUMULATIVE per session — the same lifecycle as
|
|
30
|
+
* `total_cost_usd` — so it is converted to a delta by the meter (see
|
|
31
|
+
* cumulative-meter.ts). Without `cumulative_tokens` the per-turn fields are
|
|
32
|
+
* used as before. */
|
|
33
|
+
export function resultBreakdown(m, tokenTotals, sid) {
|
|
34
|
+
const cum = m.cumulative_tokens;
|
|
35
|
+
if (!cum)
|
|
36
|
+
return turnBreakdown(m);
|
|
37
|
+
const now = {
|
|
38
|
+
input: cum.input,
|
|
39
|
+
output: cum.output,
|
|
40
|
+
cacheRead: cum.cache_read,
|
|
41
|
+
cacheCreation: cum.cache_creation,
|
|
42
|
+
};
|
|
43
|
+
return tokenTotals ? tokenTotals.delta(sid, now) : now;
|
|
44
|
+
}
|
|
45
|
+
/** ADR-O001 D1: the four quantities travel separately so every downstream
|
|
46
|
+
* consumer (forwarder → dashboard state.json, reporting, `org costs`) can
|
|
47
|
+
* record real values instead of the 0s they used to persist. `tokens` stays
|
|
48
|
+
* the single billable total. */
|
|
49
|
+
export function emitUsage(bus, from, t, costUsd, subtype) {
|
|
50
|
+
bus.emit({
|
|
51
|
+
type: 'usage',
|
|
52
|
+
from,
|
|
53
|
+
data: {
|
|
54
|
+
tokens: totalTokens(t),
|
|
55
|
+
cost_usd: costUsd,
|
|
56
|
+
subtype,
|
|
57
|
+
tokens_in: t.input,
|
|
58
|
+
tokens_out: t.output,
|
|
59
|
+
cache_read: t.cacheRead,
|
|
60
|
+
cache_creation: t.cacheCreation,
|
|
61
|
+
},
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=session-usage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"session-usage.js","sourceRoot":"","sources":["../../../src/orgrt/session-usage.ts"],"names":[],"mappings":"AAOA;;;;0DAI0D;AAC1D,MAAM,UAAU,WAAW,CAAC,CAAa;IACvC,OAAO,CAAC,CAAC,KAAK,GAAG,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,SAAS,GAAG,CAAC,CAAC,aAAa,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,MAAkB,EAAE,GAAe;IACvD,MAAM,CAAC,KAAK,IAAI,GAAG,CAAC,KAAK,CAAC;IAC1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