orkeon-code 0.0.0-stage → 1.0.0-rc.1
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/.orkeon-version +1 -0
- package/LICENSE.md +21 -0
- package/NOTICE.md +17 -0
- package/README.fr.md +169 -0
- package/README.md +162 -2
- package/config/appsettings.anthropic.example.json +77 -0
- package/config/appsettings.example.json +71 -0
- package/config/appsettings.jev.example.json +128 -0
- package/config/appsettings.kev.example.json +130 -0
- package/config/appsettings.liquid.example.json +129 -0
- package/config/appsettings.ollama-whisper.example.json +92 -0
- package/config/appsettings.ollama.example.json +70 -0
- package/config/appsettings.whisper.example.json +31 -0
- package/mcp/whisper/README.md +293 -0
- package/mcp/whisper/pyproject.toml +32 -0
- package/mcp/whisper/uv.lock +1641 -0
- package/mcp/whisper/whisper_mcp.py +1053 -0
- package/orkeon-code +897 -0
- package/orkeon-code.mjs +71 -0
- package/orkeon-code.ps1 +837 -0
- package/package.json +57 -4
- package/scripts/install.ps1 +156 -0
- package/scripts/install.sh +148 -0
- package/scripts/session-start.ork.ts +90 -0
- package/scripts/session-start.sh +74 -0
- package/scripts/setup-fixture.sh +88 -0
- package/src/commands/.orkeon/orkeon-cli.d.ts +562 -0
- package/src/commands/_lib/args.ts +193 -0
- package/src/commands/_lib/dev/dev-batches.ts +368 -0
- package/src/commands/_lib/dev/dev-implement.ts +188 -0
- package/src/commands/_lib/dev/dev-source.ts +65 -0
- package/src/commands/_lib/dev/dev.ts +344 -0
- package/src/commands/_lib/dev-step.ts +142 -0
- package/src/commands/_lib/dispatch.ts +231 -0
- package/src/commands/_lib/effort.ts +15 -0
- package/src/commands/_lib/git/branch.ts +95 -0
- package/src/commands/_lib/git/commit.ts +94 -0
- package/src/commands/_lib/git/diff.ts +97 -0
- package/src/commands/_lib/git/review.ts +109 -0
- package/src/commands/_lib/memory/memory-admit.ts +150 -0
- package/src/commands/_lib/memory/memory.ts +51 -0
- package/src/commands/_lib/pr-context.ts +32 -0
- package/src/commands/_lib/project/analyze.ts +24 -0
- package/src/commands/_lib/session/export.ts +104 -0
- package/src/commands/_lib/session/resume.ts +160 -0
- package/src/commands/_lib/session/tasks.ts +184 -0
- package/src/commands/_lib/settings/advisor.ts +80 -0
- package/src/commands/_lib/settings/agents.ts +147 -0
- package/src/commands/_lib/settings/config.ts +141 -0
- package/src/commands/_lib/settings/hooks.ts +58 -0
- package/src/commands/_lib/settings/mode.ts +91 -0
- package/src/commands/_lib/settings/model.ts +146 -0
- package/src/commands/_lib/settings/permissions.ts +309 -0
- package/src/commands/_lib/settings/session-config.ts +49 -0
- package/src/commands/_lib/settings/skills.ts +51 -0
- package/src/commands/_lib/speech/say.ts +96 -0
- package/src/commands/_lib/speech/transcribe.ts +130 -0
- package/src/commands/_lib/speech/voice.ts +146 -0
- package/src/commands/_lib/status/cache.ts +31 -0
- package/src/commands/_lib/status/context.ts +57 -0
- package/src/commands/_lib/status/doctor.ts +186 -0
- package/src/commands/_lib/status/meta.ts +45 -0
- package/src/commands/_lib/status/status.ts +129 -0
- package/src/commands/_lib/status/usage-tools.ts +49 -0
- package/src/commands/_lib/status/usage.ts +139 -0
- package/src/commands/_lib/view.ts +29 -0
- package/src/commands/dev/dev-batches.cmd.ts +108 -0
- package/src/commands/dev/dev-learn.cmd.ts +29 -0
- package/src/commands/dev/dev-plan.cmd.ts +52 -0
- package/src/commands/dev/dev-spec.cmd.ts +55 -0
- package/src/commands/dev/dev-status.cmd.ts +16 -0
- package/src/commands/git/branch.cmd.ts +27 -0
- package/src/commands/git/commit.cmd.ts +48 -0
- package/src/commands/git/diff.cmd.ts +26 -0
- package/src/commands/git/review.cmd.ts +36 -0
- package/src/commands/memory/memory.cmd.ts +48 -0
- package/src/commands/project/analyze.cmd.ts +32 -0
- package/src/commands/project/debug-tool-call.cmd.ts +67 -0
- package/src/commands/project/files.cmd.ts +22 -0
- package/src/commands/project/init-verifiers.cmd.ts +14 -0
- package/src/commands/project/init.cmd.ts +14 -0
- package/src/commands/project/verify.cmd.ts +27 -0
- package/src/commands/session/assistant.cmd.ts +40 -0
- package/src/commands/session/btw.cmd.ts +18 -0
- package/src/commands/session/clear.cmd.ts +19 -0
- package/src/commands/session/compact.cmd.ts +16 -0
- package/src/commands/session/copy.cmd.ts +44 -0
- package/src/commands/session/exit.cmd.ts +9 -0
- package/src/commands/session/export.cmd.ts +28 -0
- package/src/commands/session/rename.cmd.ts +17 -0
- package/src/commands/session/resume.cmd.ts +19 -0
- package/src/commands/session/rewind.cmd.ts +26 -0
- package/src/commands/session/summary.cmd.ts +27 -0
- package/src/commands/session/tasks.cmd.ts +44 -0
- package/src/commands/settings/advisor.cmd.ts +38 -0
- package/src/commands/settings/agents.cmd.ts +19 -0
- package/src/commands/settings/config.cmd.ts +17 -0
- package/src/commands/settings/effort.cmd.ts +40 -0
- package/src/commands/settings/fast.cmd.ts +17 -0
- package/src/commands/settings/hooks.cmd.ts +17 -0
- package/src/commands/settings/mode.cmd.ts +20 -0
- package/src/commands/settings/model.cmd.ts +20 -0
- package/src/commands/settings/output-style.cmd.ts +48 -0
- package/src/commands/settings/permissions.cmd.ts +25 -0
- package/src/commands/settings/proactive.cmd.ts +15 -0
- package/src/commands/settings/skills.cmd.ts +17 -0
- package/src/commands/speech/say.cmd.ts +24 -0
- package/src/commands/speech/transcribe.cmd.ts +29 -0
- package/src/commands/speech/voice.cmd.ts +30 -0
- package/src/commands/status/context.cmd.ts +18 -0
- package/src/commands/status/doctor.cmd.ts +27 -0
- package/src/commands/status/release-notes.cmd.ts +9 -0
- package/src/commands/status/status.cmd.ts +25 -0
- package/src/commands/status/usage.cmd.ts +21 -0
- package/src/crews/.orkeon/orkeon.d.ts +3946 -0
- package/src/crews/_probe-shared-memory/domain/probe-verdict.ts +183 -0
- package/src/crews/_probe-shared-memory/probe.ork.ts +98 -0
- package/src/crews/advisor/application/run-advisor.ts +40 -0
- package/src/crews/advisor/crew.ork.ts +43 -0
- package/src/crews/advisor/domain/advice.ts +135 -0
- package/src/crews/agent-run/application/run-agent-run.ts +42 -0
- package/src/crews/agent-run/crew.ork.ts +67 -0
- package/src/crews/analyze/application/run-analyze.ts +118 -0
- package/src/crews/analyze/crew.ork.ts +40 -0
- package/src/crews/analyze/domain/harvest.ts +301 -0
- package/src/crews/code-review/application/prompts.ts +133 -0
- package/src/crews/code-review/application/review.ts +71 -0
- package/src/crews/code-review/application/run-code-review.ts +123 -0
- package/src/crews/code-review/crew.ork.ts +51 -0
- package/src/crews/code-review/domain/lenses.ts +193 -0
- package/src/crews/code-review/domain/report.ts +59 -0
- package/src/crews/code-review/domain/scope.ts +112 -0
- package/src/crews/dev-batches/application/plan-close.ts +181 -0
- package/src/crews/dev-batches/application/run-dev-batches.ts +669 -0
- package/src/crews/dev-batches/application/run-wave.ts +450 -0
- package/src/crews/dev-batches/application/seed-harvest.ts +162 -0
- package/src/crews/dev-batches/crew.ork.ts +143 -0
- package/src/crews/dev-batches/domain/batch-waves.ts +70 -0
- package/src/crews/dev-batches/domain/batches-budget.ts +52 -0
- package/src/crews/dev-batches/domain/batches-log.ts +54 -0
- package/src/crews/dev-batches/domain/wave-order.ts +43 -0
- package/src/crews/dev-change/application/change-prompt.ts +104 -0
- package/src/crews/dev-change/application/evidence.ts +169 -0
- package/src/crews/dev-change/application/run-dev-change.ts +315 -0
- package/src/crews/dev-change/crew.ork.ts +112 -0
- package/src/crews/dev-change/domain/change-answer.ts +159 -0
- package/src/crews/dev-change/domain/change-render.ts +79 -0
- package/src/crews/dev-implement/application/close.ts +183 -0
- package/src/crews/dev-implement/application/count-open-steps.ts +24 -0
- package/src/crews/dev-implement/application/locate-sheet.ts +80 -0
- package/src/crews/dev-implement/application/observe.ts +50 -0
- package/src/crews/dev-implement/application/report-writes.ts +41 -0
- package/src/crews/dev-implement/application/run-dev-implement.ts +811 -0
- package/src/crews/dev-implement/application/run-role.ts +27 -0
- package/src/crews/dev-implement/application/suite-job.ts +118 -0
- package/src/crews/dev-implement/application/touched.ts +74 -0
- package/src/crews/dev-implement/crew.ork.ts +68 -0
- package/src/crews/dev-implement/domain/contracts.ts +256 -0
- package/src/crews/dev-implement/domain/correction.ts +102 -0
- package/src/crews/dev-implement/domain/cycles.ts +35 -0
- package/src/crews/dev-implement/domain/implement-budget.ts +29 -0
- package/src/crews/dev-implement/domain/roles.ts +53 -0
- package/src/crews/dev-implement/domain/sheet-edits.ts +75 -0
- package/src/crews/dev-implement/domain/sheet-ticks.ts +22 -0
- package/src/crews/dev-implement/domain/step-checks.ts +136 -0
- package/src/crews/dev-implement/domain/step-section.ts +127 -0
- package/src/crews/dev-learn/application/learn-backlog.ts +58 -0
- package/src/crews/dev-learn/application/learn-prompt.ts +140 -0
- package/src/crews/dev-learn/application/run-dev-learn.ts +553 -0
- package/src/crews/dev-learn/crew.ork.ts +52 -0
- package/src/crews/dev-learn/domain/learn-answer.ts +235 -0
- package/src/crews/dev-learn/domain/owner-lines.ts +86 -0
- package/src/crews/dev-learn/domain/proposals-render.ts +96 -0
- package/src/crews/dev-plan/application/anchor-paths.ts +76 -0
- package/src/crews/dev-plan/application/inventory.ts +170 -0
- package/src/crews/dev-plan/application/plan-prompt.ts +159 -0
- package/src/crews/dev-plan/application/run-dev-plan.ts +455 -0
- package/src/crews/dev-plan/crew.ork.ts +109 -0
- package/src/crews/dev-plan/domain/inventory-model.ts +95 -0
- package/src/crews/dev-plan/domain/plan-answer.ts +738 -0
- package/src/crews/dev-plan/domain/plan-render.ts +307 -0
- package/src/crews/dev-spec/application/run-dev-spec.ts +206 -0
- package/src/crews/dev-spec/application/spec-prompt.ts +98 -0
- package/src/crews/dev-spec/crew.ork.ts +108 -0
- package/src/crews/dev-spec/domain/spec-answer.ts +253 -0
- package/src/crews/dev-spec/domain/spec-render.ts +76 -0
- package/src/crews/dev-verify/application/audit.ts +259 -0
- package/src/crews/dev-verify/application/auditor-prompt.ts +323 -0
- package/src/crews/dev-verify/application/capture.ts +303 -0
- package/src/crews/dev-verify/application/run-dev-verify.ts +409 -0
- package/src/crews/dev-verify/application/run-gate.ts +202 -0
- package/src/crews/dev-verify/crew.ork.ts +103 -0
- package/src/crews/dev-verify/domain/audit-answer.ts +150 -0
- package/src/crews/dev-verify/domain/auditor-charter.ts +21 -0
- package/src/crews/dev-verify/domain/capture-sections.ts +137 -0
- package/src/crews/dev-verify/domain/commands.ts +103 -0
- package/src/crews/dev-verify/domain/gate.ts +126 -0
- package/src/crews/dev-verify/domain/mechanical-table.ts +163 -0
- package/src/crews/dev-verify/domain/runtime-cut.ts +13 -0
- package/src/crews/dev-verify/domain/sheet-facts.ts +4 -0
- package/src/crews/dev-verify/domain/text.ts +20 -0
- package/src/crews/dev-verify/domain/verdict.ts +127 -0
- package/src/crews/git-commit/application/draft.ts +154 -0
- package/src/crews/git-commit/application/run-git-commit.ts +116 -0
- package/src/crews/git-commit/crew.ork.ts +52 -0
- package/src/crews/git-commit/domain/commit.ts +220 -0
- package/src/crews/init-verifiers/application/authoring.ts +89 -0
- package/src/crews/init-verifiers/application/prompts.ts +103 -0
- package/src/crews/init-verifiers/application/run-init-verifiers.ts +25 -0
- package/src/crews/init-verifiers/crew.ork.ts +34 -0
- package/src/crews/init-verifiers/domain/commands-section.ts +36 -0
- package/src/crews/init-verifiers/domain/readiness.ts +23 -0
- package/src/crews/main-loop/application/auto-compact.ts +77 -0
- package/src/crews/main-loop/application/context-gather.ts +133 -0
- package/src/crews/main-loop/application/run-main-loop.ts +350 -0
- package/src/crews/main-loop/application/turn-prompt.ts +112 -0
- package/src/crews/main-loop/crew.ork.ts +119 -0
- package/src/crews/main-loop/domain/autocompact.ts +27 -0
- package/src/crews/main-loop/domain/prompt-assembly.ts +521 -0
- package/src/crews/main-loop/domain/turn-chains.ts +129 -0
- package/src/crews/project-init/application/detect.ts +122 -0
- package/src/crews/project-init/application/prompts.ts +101 -0
- package/src/crews/project-init/application/run-project-init.ts +31 -0
- package/src/crews/project-init/crew.ork.ts +35 -0
- package/src/crews/project-init/domain/conventions.ts +36 -0
- package/src/crews/project-init/domain/existing-files.ts +63 -0
- package/src/crews/project-init/domain/package-map.ts +73 -0
- package/src/crews/session-compact/crew.ork.ts +55 -0
- package/src/crews/shared-memory-admit/crew.ork.ts +48 -0
- package/src/crews/speech/application/run-speech.ts +25 -0
- package/src/crews/speech/crew.ork.ts +37 -0
- package/src/shared/application/agents/child-agent.ts +255 -0
- package/src/shared/application/agents/run-sub-agent.ts +96 -0
- package/src/shared/application/answer-language.ts +14 -0
- package/src/shared/application/attached-skills.ts +36 -0
- package/src/shared/application/compaction/compact-session.ts +237 -0
- package/src/shared/application/compaction/extract-memories.ts +38 -0
- package/src/shared/application/compaction/restore-context.ts +78 -0
- package/src/shared/application/config-store.ts +123 -0
- package/src/shared/application/dev/brief-inventory.ts +113 -0
- package/src/shared/application/dev/close-batch.ts +83 -0
- package/src/shared/application/dev/find-repo-pack.ts +77 -0
- package/src/shared/application/dev/learn-decision.ts +252 -0
- package/src/shared/application/dev/load-dev-context.ts +266 -0
- package/src/shared/application/dev/measure-access-cost.ts +68 -0
- package/src/shared/application/dev/plan-source.ts +112 -0
- package/src/shared/application/dev/preflight.ts +71 -0
- package/src/shared/application/dev/project-files.ts +17 -0
- package/src/shared/application/dev/question-round.ts +52 -0
- package/src/shared/application/dev/resolve-work-folder.ts +133 -0
- package/src/shared/application/dev/script-tool-slot.ts +27 -0
- package/src/shared/application/dev/settle-questions.ts +55 -0
- package/src/shared/application/dev/source-review.ts +63 -0
- package/src/shared/application/dev/source-step.ts +150 -0
- package/src/shared/application/dev/spend.ts +42 -0
- package/src/shared/application/dev/step-precedents.ts +89 -0
- package/src/shared/application/dev/tool-call-policy.ts +89 -0
- package/src/shared/application/dev/tool-callbacks.ts +215 -0
- package/src/shared/application/dev/tool-trace-recorder.ts +45 -0
- package/src/shared/application/dev/verdict-sources.ts +48 -0
- package/src/shared/application/dev/wrapped-tools.ts +145 -0
- package/src/shared/application/extra-tools.ts +70 -0
- package/src/shared/application/git/batch-worktree.ts +97 -0
- package/src/shared/application/git/commit-files.ts +186 -0
- package/src/shared/application/git/merge-batch.ts +63 -0
- package/src/shared/application/git/open-pull-request.ts +51 -0
- package/src/shared/application/instructions-file.ts +19 -0
- package/src/shared/application/json-file.ts +34 -0
- package/src/shared/application/llm-profile.ts +35 -0
- package/src/shared/application/permission-rules.ts +159 -0
- package/src/shared/application/ports/approvals.ts +20 -0
- package/src/shared/application/ports/clock.ts +5 -0
- package/src/shared/application/ports/code-index.ts +93 -0
- package/src/shared/application/ports/crew.ts +60 -0
- package/src/shared/application/ports/files.ts +21 -0
- package/src/shared/application/ports/human.ts +13 -0
- package/src/shared/application/ports/llm.ts +54 -0
- package/src/shared/application/ports/memory.ts +30 -0
- package/src/shared/application/ports/progress.ts +23 -0
- package/src/shared/application/ports/runtime.ts +15 -0
- package/src/shared/application/ports/session.ts +74 -0
- package/src/shared/application/ports/shared-memory.ts +26 -0
- package/src/shared/application/ports/shell.ts +40 -0
- package/src/shared/application/ports/telemetry.ts +45 -0
- package/src/shared/application/ports/tools.ts +46 -0
- package/src/shared/application/ports/usage.ts +45 -0
- package/src/shared/application/ports.ts +27 -0
- package/src/shared/application/project-manifests.ts +106 -0
- package/src/shared/application/session-io.ts +84 -0
- package/src/shared/application/session-state.ts +36 -0
- package/src/shared/application/shared-memory/admit-entries.ts +177 -0
- package/src/shared/application/shared-memory/harvest-after-gaps.ts +72 -0
- package/src/shared/application/shared-memory/harvest-mistakes.ts +44 -0
- package/src/shared/application/shared-memory/import-agent-memory.ts +117 -0
- package/src/shared/application/shared-memory/memory-files.ts +110 -0
- package/src/shared/application/shared-memory/memory-settings.ts +93 -0
- package/src/shared/application/shared-memory/push-candidate.ts +146 -0
- package/src/shared/application/shared-memory/recall-precedents.ts +69 -0
- package/src/shared/application/state-snapshot.ts +38 -0
- package/src/shared/application/workflow/workflow-state.ts +135 -0
- package/src/shared/domain/agent-policy/behavior-flags.ts +168 -0
- package/src/shared/domain/agent-policy/extra-tools.ts +69 -0
- package/src/shared/domain/agent-policy/memory-categories.ts +6 -0
- package/src/shared/domain/agent-policy/mode-policy.ts +51 -0
- package/src/shared/domain/agent-policy/output-styles.ts +11 -0
- package/src/shared/domain/agent-policy/permission.ts +623 -0
- package/src/shared/domain/agent-policy/rule-sets.ts +412 -0
- package/src/shared/domain/agent-policy/tool-access.ts +77 -0
- package/src/shared/domain/agent-registry.ts +142 -0
- package/src/shared/domain/agents/built-in-charters.ts +43 -0
- package/src/shared/domain/agents/chain.ts +30 -0
- package/src/shared/domain/agents/charter.ts +61 -0
- package/src/shared/domain/agents/exclusive.ts +24 -0
- package/src/shared/domain/agents/instances.ts +249 -0
- package/src/shared/domain/code-intel-contract.ts +356 -0
- package/src/shared/domain/code-intel-routing.ts +113 -0
- package/src/shared/domain/compact-outcome.ts +44 -0
- package/src/shared/domain/compaction-thresholds.ts +161 -0
- package/src/shared/domain/compaction.ts +379 -0
- package/src/shared/domain/config-schema.ts +421 -0
- package/src/shared/domain/dev/access-cost.ts +226 -0
- package/src/shared/domain/dev/artefacts.ts +50 -0
- package/src/shared/domain/dev/batches-concurrency.ts +36 -0
- package/src/shared/domain/dev/batches-state.ts +49 -0
- package/src/shared/domain/dev/build-commands.ts +44 -0
- package/src/shared/domain/dev/call-guard.ts +341 -0
- package/src/shared/domain/dev/carried-text.ts +49 -0
- package/src/shared/domain/dev/design-rules.ts +100 -0
- package/src/shared/domain/dev/learn-proposals.ts +175 -0
- package/src/shared/domain/dev/learn-state.ts +93 -0
- package/src/shared/domain/dev/path-args.ts +42 -0
- package/src/shared/domain/dev/path-rebase.ts +93 -0
- package/src/shared/domain/dev/plan-checks.ts +190 -0
- package/src/shared/domain/dev/plan-format.ts +180 -0
- package/src/shared/domain/dev/project-files.ts +43 -0
- package/src/shared/domain/dev/questions.ts +249 -0
- package/src/shared/domain/dev/reading-rule.ts +41 -0
- package/src/shared/domain/dev/repo-pack.ts +237 -0
- package/src/shared/domain/dev/review-answer.ts +150 -0
- package/src/shared/domain/dev/review-prompt.ts +221 -0
- package/src/shared/domain/dev/reviewer-charter.ts +31 -0
- package/src/shared/domain/dev/sheet-facts.ts +83 -0
- package/src/shared/domain/dev/spec-format.ts +183 -0
- package/src/shared/domain/dev/step-budget.ts +72 -0
- package/src/shared/domain/dev/step-rules.ts +110 -0
- package/src/shared/domain/dev/test-commands.ts +90 -0
- package/src/shared/domain/dev/test-output.ts +33 -0
- package/src/shared/domain/dev/test-paths.ts +40 -0
- package/src/shared/domain/dev/tool-guards.ts +64 -0
- package/src/shared/domain/dev/trait-pattern.ts +83 -0
- package/src/shared/domain/dev/verdict-format.ts +169 -0
- package/src/shared/domain/dev/whitespace.ts +34 -0
- package/src/shared/domain/dev/work-folder.ts +67 -0
- package/src/shared/domain/dev/yaml-subset.ts +403 -0
- package/src/shared/domain/git/close.ts +273 -0
- package/src/shared/domain/git/pull-request.ts +96 -0
- package/src/shared/domain/git/worktree.ts +46 -0
- package/src/shared/domain/index-languages.ts +16 -0
- package/src/shared/domain/instructions-file.ts +18 -0
- package/src/shared/domain/iso-day.ts +4 -0
- package/src/shared/domain/llm-failure.ts +106 -0
- package/src/shared/domain/llm-profile.ts +25 -0
- package/src/shared/domain/marked-message.ts +33 -0
- package/src/shared/domain/model-catalog.ts +86 -0
- package/src/shared/domain/permission-modes.ts +103 -0
- package/src/shared/domain/prelude.ts +92 -0
- package/src/shared/domain/project-manifests.ts +83 -0
- package/src/shared/domain/search-routing.ts +85 -0
- package/src/shared/domain/secret-patterns.ts +45 -0
- package/src/shared/domain/session-keys.ts +85 -0
- package/src/shared/domain/session-start.ts +60 -0
- package/src/shared/domain/session-summary.ts +13 -0
- package/src/shared/domain/severity.ts +72 -0
- package/src/shared/domain/sha1.ts +61 -0
- package/src/shared/domain/shared-memory/agent-memory-import.ts +143 -0
- package/src/shared/domain/shared-memory/candidates.ts +41 -0
- package/src/shared/domain/shared-memory/entry.ts +145 -0
- package/src/shared/domain/shared-memory/front-matter.ts +183 -0
- package/src/shared/domain/shared-memory/gate.ts +44 -0
- package/src/shared/domain/shared-memory/harvest.ts +61 -0
- package/src/shared/domain/shared-memory/layout.ts +187 -0
- package/src/shared/domain/shared-memory/precedents-block.ts +93 -0
- package/src/shared/domain/shared-memory/refused.ts +84 -0
- package/src/shared/domain/shared-memory/verdict-rows.ts +134 -0
- package/src/shared/domain/snip-turns.ts +45 -0
- package/src/shared/domain/speech.ts +20 -0
- package/src/shared/domain/strip.ts +88 -0
- package/src/shared/domain/tool-trace.ts +122 -0
- package/src/shared/domain/types.ts +67 -0
- package/src/shared/domain/verifiers.ts +37 -0
- package/src/shared/domain/vfs.ts +9 -0
- package/src/shared/domain/workflow/state-file.ts +140 -0
- package/src/shared/infrastructure/globals.ts +52 -0
- package/src/shared/infrastructure/orkeon/approvals.ts +24 -0
- package/src/shared/infrastructure/orkeon/child-agents.ts +127 -0
- package/src/shared/infrastructure/orkeon/code-index.ts +120 -0
- package/src/shared/infrastructure/orkeon/crew-host.ts +27 -0
- package/src/shared/infrastructure/orkeon/crew-memory.ts +12 -0
- package/src/shared/infrastructure/orkeon/dev-deps.ts +172 -0
- package/src/shared/infrastructure/orkeon/files.ts +40 -0
- package/src/shared/infrastructure/orkeon/github-pull-requests.ts +29 -0
- package/src/shared/infrastructure/orkeon/host-provider.ts +22 -0
- package/src/shared/infrastructure/orkeon/human-input.ts +59 -0
- package/src/shared/infrastructure/orkeon/llm-profile.ts +38 -0
- package/src/shared/infrastructure/orkeon/llm.ts +109 -0
- package/src/shared/infrastructure/orkeon/memory-store.ts +41 -0
- package/src/shared/infrastructure/orkeon/memory-tools.ts +131 -0
- package/src/shared/infrastructure/orkeon/permission-rules.ts +42 -0
- package/src/shared/infrastructure/orkeon/progress.ts +24 -0
- package/src/shared/infrastructure/orkeon/run-state.ts +17 -0
- package/src/shared/infrastructure/orkeon/runtime-info.ts +30 -0
- package/src/shared/infrastructure/orkeon/runtime-tools.ts +60 -0
- package/src/shared/infrastructure/orkeon/script-tools.ts +134 -0
- package/src/shared/infrastructure/orkeon/session-store.ts +138 -0
- package/src/shared/infrastructure/orkeon/session-switch.ts +23 -0
- package/src/shared/infrastructure/orkeon/shared-memory.ts +61 -0
- package/src/shared/infrastructure/orkeon/shell-jobs.ts +75 -0
- package/src/shared/infrastructure/orkeon/shell.ts +31 -0
- package/src/shared/infrastructure/orkeon/telemetry.ts +63 -0
- package/src/shared/infrastructure/orkeon/tool-catalogue.ts +75 -0
- package/src/shared/infrastructure/orkeon/tool-results.ts +120 -0
- package/src/shared/infrastructure/orkeon/usage.ts +74 -0
- package/src/shared/infrastructure/orkeon/wiring.ts +118 -0
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
// /config (E-1, schema + persistence in B-6) — read/write settings over a
|
|
2
|
+
// DECLARED key space, in two layers (baseline 04 §/config).
|
|
3
|
+
//
|
|
4
|
+
// Before B-6 this was a free-form session map: any key was accepted, a typo was
|
|
5
|
+
// stored and never read, and nothing survived /clear. That mattered as
|
|
6
|
+
// soon as B-2 added `permissions.fallback`, a key whose job is to state the
|
|
7
|
+
// session's permission posture — `/config set permissions.fallbck bypass…`
|
|
8
|
+
// reported success and changed nothing.
|
|
9
|
+
//
|
|
10
|
+
// file /workspace/.orkeon/config.json survives everything
|
|
11
|
+
// session state bag overrides the file until /clear
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
CONFIG_KEYS, configKeySpec, knownConfigKeys, resolveConfigEntry, validateConfigEntry,
|
|
15
|
+
} from "../../../shared/domain/config-schema.ts";
|
|
16
|
+
import { CONFIG_FILE_PATH, USER_CONFIG_FILE_PATH } from "../../../shared/application/config-store.ts";
|
|
17
|
+
import type { ConfigStore } from "../../../shared/application/config-store.ts";
|
|
18
|
+
import type { CommandView } from "../view.ts";
|
|
19
|
+
|
|
20
|
+
export const CONFIG_USAGE =
|
|
21
|
+
"usage: /config [list|keys|get <key>|set [--session] <key> <value>|unset [--session] <key>]";
|
|
22
|
+
|
|
23
|
+
export interface ConfigDeps {
|
|
24
|
+
config: ConfigStore;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** `--session` selects the session layer; the default is the persisted file. */
|
|
28
|
+
function takeSessionFlag(tokens: string[]): { session: boolean; rest: string[] } {
|
|
29
|
+
const rest = tokens.filter((t) => t !== "--session");
|
|
30
|
+
return { session: rest.length !== tokens.length, rest };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** `/config [list|keys|get|set|unset] …`, from the command's raw tokens. */
|
|
34
|
+
export async function runConfig(tokens: string[], deps: ConfigDeps): Promise<CommandView> {
|
|
35
|
+
const { config } = deps;
|
|
36
|
+
const { session: useSession, rest } = takeSessionFlag(tokens);
|
|
37
|
+
const [sub, key, ...valueParts] = rest;
|
|
38
|
+
|
|
39
|
+
switch ((sub ?? "list").toLowerCase()) {
|
|
40
|
+
case "list": {
|
|
41
|
+
const view = await config.readView();
|
|
42
|
+
const notes: string[] = [`file: ${CONFIG_FILE_PATH} — session overrides it until /clear.`];
|
|
43
|
+
if (view.unknown.length > 0) {
|
|
44
|
+
notes.push(
|
|
45
|
+
`⚠ stored but NOT in the key space (pre-B-6 residue, nothing reads them): ${view.unknown.join(", ")}`,
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
if (view.nested.length > 0) {
|
|
49
|
+
notes.push(
|
|
50
|
+
`⚠ written nested, so nothing reads them: ${view.nested.join(", ")} — a settings file holds each key flat ` +
|
|
51
|
+
`("${view.nested[0]}": …).`,
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
if (view.fileMalformed) {
|
|
55
|
+
notes.push(`⚠ ${CONFIG_FILE_PATH} could not be parsed — it is left untouched; fix or delete it.`);
|
|
56
|
+
}
|
|
57
|
+
return {
|
|
58
|
+
table: view.entries.map((e) => ({ key: e.key, value: e.value ?? "(unset)", source: e.source })),
|
|
59
|
+
text: notes.join("\n"),
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
case "keys":
|
|
64
|
+
return {
|
|
65
|
+
table: CONFIG_KEYS.map((s) => ({
|
|
66
|
+
key: s.key,
|
|
67
|
+
allowed: s.allowed ? s.allowed.join(" | ") : "(any)",
|
|
68
|
+
"read by": s.consumedBy,
|
|
69
|
+
})),
|
|
70
|
+
text: "every key names its consumer — a key nothing reads is not settable.",
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
case "get": {
|
|
74
|
+
if (!key) return { text: "usage: /config get <key>" };
|
|
75
|
+
const spec = configKeySpec(key);
|
|
76
|
+
if (!spec) return { text: `unknown config key '${key}'. Valid keys: ${knownConfigKeys().join(", ")}` };
|
|
77
|
+
const view = await config.readView();
|
|
78
|
+
const entry = view.entries.find((e) => e.key === key)!;
|
|
79
|
+
return {
|
|
80
|
+
text: entry.value === undefined
|
|
81
|
+
? `${key} is unset (${spec.description})`
|
|
82
|
+
: `${key} = ${entry.value} [${entry.source}]`,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
case "set": {
|
|
87
|
+
const value = valueParts.join(" ");
|
|
88
|
+
// ACCEPTANCE 1: an unknown key is refused WITH the list.
|
|
89
|
+
const verdict = validateConfigEntry(key, value);
|
|
90
|
+
if (!verdict.ok) return { text: verdict.reason };
|
|
91
|
+
|
|
92
|
+
if (useSession) {
|
|
93
|
+
const map = await config.readSession();
|
|
94
|
+
map[key] = value;
|
|
95
|
+
await config.writeSession(map);
|
|
96
|
+
return { text: `${key} = ${value} [session] — overrides the file until /clear.` };
|
|
97
|
+
}
|
|
98
|
+
const { map, malformed } = await config.readFile();
|
|
99
|
+
if (malformed) {
|
|
100
|
+
return {
|
|
101
|
+
text: `refusing to write: ${CONFIG_FILE_PATH} exists but could not be parsed, and overwriting it ` +
|
|
102
|
+
"would discard whatever it holds. Fix or delete it, then retry.",
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
map[key] = value;
|
|
106
|
+
await config.writeFile(map);
|
|
107
|
+
const persisted = `${key} = ${value} [file] — persisted in ${CONFIG_FILE_PATH}.`;
|
|
108
|
+
// A project file widens nothing past the user settings (LI-6): the value is kept, and said to be set aside.
|
|
109
|
+
const { map: user, malformed: userMalformed } = await config.readUserFile();
|
|
110
|
+
const { ignored } = resolveConfigEntry(key, map, {}, user);
|
|
111
|
+
if (ignored === undefined) return { text: persisted };
|
|
112
|
+
const unread = userMalformed
|
|
113
|
+
? ` The user settings (${USER_CONFIG_FILE_PATH}) could not be parsed: none applies.`
|
|
114
|
+
: "";
|
|
115
|
+
return {
|
|
116
|
+
text: `${persisted}\n↳ ignored: '${ignored.value}': ${ignored.reason}.${unread} A setting of your own goes in ` +
|
|
117
|
+
"the orkeonCode block of the user settings file (the one the launcher reads).",
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
case "unset": {
|
|
122
|
+
if (!key) return { text: "usage: /config unset [--session] <key>" };
|
|
123
|
+
if (useSession) {
|
|
124
|
+
const map = await config.readSession();
|
|
125
|
+
if (!(key in map)) return { text: `${key} has no session override.` };
|
|
126
|
+
delete map[key];
|
|
127
|
+
await config.writeSession(map);
|
|
128
|
+
return { text: `${key} session override removed (the file value applies again).` };
|
|
129
|
+
}
|
|
130
|
+
const { map, malformed } = await config.readFile();
|
|
131
|
+
if (malformed) return { text: `refusing to write: ${CONFIG_FILE_PATH} could not be parsed.` };
|
|
132
|
+
if (!(key in map)) return { text: `${key} is not set in ${CONFIG_FILE_PATH}.` };
|
|
133
|
+
delete map[key];
|
|
134
|
+
await config.writeFile(map);
|
|
135
|
+
return { text: `${key} removed from ${CONFIG_FILE_PATH}.` };
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
default:
|
|
139
|
+
return { text: CONFIG_USAGE };
|
|
140
|
+
}
|
|
141
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// /hooks — the session's hook registry (session state): list, add, remove. The dev steps (/dev-spec, /dev-plan and
|
|
2
|
+
// /dev-batches, and a /tasks repair) hand it to their crew, whose tool callbacks
|
|
3
|
+
// (shared/application/dev/tool-callbacks.ts) run each pre-tool hook before a model's tool call the gate allowed
|
|
4
|
+
// (a failing hook refuses the call) and each post-tool hook after it (a failing one adds a line to the result). The
|
|
5
|
+
// assistant does not run them yet, and nothing runs a stop hook. Not a command file: the loader reads *.cmd.ts only.
|
|
6
|
+
import type { SessionStore } from "../../../shared/application/ports.ts";
|
|
7
|
+
import { readJsonArray, writeJson } from "../../../shared/application/session-state.ts";
|
|
8
|
+
import { shellOperatorIn } from "../../../shared/domain/dev/call-guard.ts";
|
|
9
|
+
import { HOOKS_STATE_KEY } from "../../../shared/domain/session-keys.ts";
|
|
10
|
+
|
|
11
|
+
export const HOOK_EVENTS = ["pre-tool", "post-tool", "stop"] as const;
|
|
12
|
+
|
|
13
|
+
/** Where the hooks run, said on every listing: a populated registry is exactly when someone
|
|
14
|
+
* believes they all run. */
|
|
15
|
+
export const HOOKS_STATUS =
|
|
16
|
+
"pre-tool and post-tool hooks run around each tool call the model makes in the dev steps (/dev-spec, " +
|
|
17
|
+
"/dev-plan, /dev-batches) and a /tasks repair (a failing pre-tool hook refuses the call); " +
|
|
18
|
+
"the assistant does not run " +
|
|
19
|
+
"them yet, and no stop hook runs.";
|
|
20
|
+
|
|
21
|
+
export interface HookRow { n: number; event: string; command: string }
|
|
22
|
+
|
|
23
|
+
/** What /hooks shows: a table of the hooks when it lists some, then its text. */
|
|
24
|
+
export interface HooksOutcome { table?: HookRow[]; text: string }
|
|
25
|
+
|
|
26
|
+
export async function runHooks(tokens: readonly string[], session: Pick<SessionStore, "readState" | "writeState">): Promise<HooksOutcome> {
|
|
27
|
+
const [sub, event, ...rest] = tokens;
|
|
28
|
+
const hooks = (await readJsonArray(session, HOOKS_STATE_KEY)) as Array<{ event: string; command: string }>;
|
|
29
|
+
switch ((sub ?? "list").toLowerCase()) {
|
|
30
|
+
case "list":
|
|
31
|
+
if (hooks.length === 0) return { text: `no hooks configured. usage: /hooks add <pre-tool|post-tool|stop> <command>\n${HOOKS_STATUS}` };
|
|
32
|
+
return { table: hooks.map((h, i) => ({ n: i + 1, event: h.event, command: h.command })), text: HOOKS_STATUS };
|
|
33
|
+
case "add": {
|
|
34
|
+
const command = rest.join(" ");
|
|
35
|
+
if (!(HOOK_EVENTS as readonly string[]).includes(String(event)) || !command) return { text: `usage: /hooks add <${HOOK_EVENTS.join("|")}> <command>` };
|
|
36
|
+
// The shell tool runs one program and its arguments: the hook would fail at every call.
|
|
37
|
+
const operator = shellOperatorIn(command);
|
|
38
|
+
if (operator !== undefined) {
|
|
39
|
+
return {
|
|
40
|
+
text: `refused: the command holds '${operator.replace(/\n/g, "\\n")}', which the shell tool refuses: a hook is one program ` +
|
|
41
|
+
"and its arguments. Put the steps in a script: /hooks add pre-tool node .orkeon/hooks/pre.mjs {tool} {path}",
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
hooks.push({ event, command });
|
|
45
|
+
await writeJson(session, HOOKS_STATE_KEY, hooks);
|
|
46
|
+
return { text: `hook #${hooks.length} added on '${event}' (/clear clears). ${HOOKS_STATUS}` };
|
|
47
|
+
}
|
|
48
|
+
case "remove": {
|
|
49
|
+
const n = Number(event);
|
|
50
|
+
if (!Number.isInteger(n) || n < 1 || n > hooks.length) return { text: `usage: /hooks remove <1-${hooks.length || 1}>` };
|
|
51
|
+
hooks.splice(n - 1, 1);
|
|
52
|
+
await writeJson(session, HOOKS_STATE_KEY, hooks);
|
|
53
|
+
return { text: `hook #${n} removed.` };
|
|
54
|
+
}
|
|
55
|
+
default:
|
|
56
|
+
return { text: "usage: /hooks [list|add <event> <command>|remove <n>]" };
|
|
57
|
+
}
|
|
58
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// The session-default permission mode: the mode a prompt runs in when it carries
|
|
2
|
+
// no explicit "mode:" prefix, persisted in the session state bag (survives crew
|
|
3
|
+
// runs; /clear restores "default"). /mode cycles, shows or sets it; typed by its
|
|
4
|
+
// alias /plan, it toggles it in and out of plan.
|
|
5
|
+
|
|
6
|
+
import type { Logger } from "../../../shared/application/ports.ts";
|
|
7
|
+
import type { SessionIo } from "../../../shared/application/session-io.ts";
|
|
8
|
+
import { PERMISSION_MODES, isPermissionMode, getNextPermissionMode } from "../../../shared/domain/permission-modes.ts";
|
|
9
|
+
import { DEFAULT_MODE_STATE_KEY } from "../../../shared/domain/session-keys.ts";
|
|
10
|
+
import { policyFor } from "../../../shared/domain/agent-policy/mode-policy.ts";
|
|
11
|
+
import type { CommandView } from "../view.ts";
|
|
12
|
+
|
|
13
|
+
export interface ModeDeps {
|
|
14
|
+
session: Pick<SessionIo, "resolveEffectiveSessionMode" | "readState" | "writeState">;
|
|
15
|
+
log: Pick<Logger, "info">;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/** Persist + announce a mode transition; logs the read-only catalogue strip (E-12). */
|
|
19
|
+
async function applyMode(deps: ModeDeps, next: string, how: string): Promise<CommandView> {
|
|
20
|
+
await deps.session.writeState(DEFAULT_MODE_STATE_KEY, next);
|
|
21
|
+
if (policyFor(next).readOnly) {
|
|
22
|
+
deps.log.info(`entering '${next}': the edit, network and shell tools stripped from the catalogue`);
|
|
23
|
+
}
|
|
24
|
+
return {
|
|
25
|
+
text: `session default permission mode ${how} '${next}' ` +
|
|
26
|
+
`(prompts without a "mode:" prefix now run in it; /clear restores 'default').`,
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** `/mode [<mode>|show]`, from the command's raw tokens. No argument CYCLES to the
|
|
31
|
+
* next mode (E-12 — the original's Shift+Tab rotation); `show` displays without
|
|
32
|
+
* changing. Typed by its alias (`typed` "plan"), it toggles plan mode instead. */
|
|
33
|
+
export async function runMode(tokens: string[], deps: ModeDeps, typed = "mode"): Promise<CommandView> {
|
|
34
|
+
if (typed === "plan") return runPlanToggle(deps);
|
|
35
|
+
const requested = (tokens[0] ?? "").trim();
|
|
36
|
+
if (!requested) {
|
|
37
|
+
// E-12: bare /mode cycles default → acceptEdits → plan → bypassPermissions.
|
|
38
|
+
// B-2: cycling starts from the EFFECTIVE mode, fallback included, so the
|
|
39
|
+
// first press moves from what the session is actually running.
|
|
40
|
+
const { mode: current } = await deps.session.resolveEffectiveSessionMode();
|
|
41
|
+
return applyMode(deps, getNextPermissionMode(current), `cycled ${current} →`);
|
|
42
|
+
}
|
|
43
|
+
if (requested === "show") {
|
|
44
|
+
const { mode: current, via } = await deps.session.resolveEffectiveSessionMode();
|
|
45
|
+
return {
|
|
46
|
+
text: `session default permission mode: ${current}\n` +
|
|
47
|
+
` ↳ ${via}\n` +
|
|
48
|
+
`usage: /mode [<${PERMISSION_MODES.join("|")}>|show] — bare /mode cycles; ` +
|
|
49
|
+
`an explicit "mode:" prefix on a prompt still wins.`,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
if (!isPermissionMode(requested)) {
|
|
53
|
+
return { text: `unknown mode '${requested}' — expected one of: ${PERMISSION_MODES.join(", ")}, show.` };
|
|
54
|
+
}
|
|
55
|
+
return applyMode(deps, requested, "set to");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// ── /plan — a TOGGLE, as the baseline specifies ───────────────────────────
|
|
59
|
+
|
|
60
|
+
/** `/plan`: plan mode flipped and persisted, the catalogue strip or the way back logged. */
|
|
61
|
+
async function runPlanToggle(deps: ModeDeps): Promise<CommandView> {
|
|
62
|
+
const current = await deps.session.readState(DEFAULT_MODE_STATE_KEY).catch(() => null);
|
|
63
|
+
const { mode, entering } = togglePlanMode(current);
|
|
64
|
+
await deps.session.writeState(DEFAULT_MODE_STATE_KEY, mode);
|
|
65
|
+
if (entering) {
|
|
66
|
+
deps.log.info("entering 'plan': the edit, network and shell tools stripped from the catalogue");
|
|
67
|
+
return { text: "plan mode ON — prompts without a \"mode:\" prefix now run read-only. /plan again to leave." };
|
|
68
|
+
}
|
|
69
|
+
deps.log.info("leaving 'plan': session default back to 'default' (asks on writes)");
|
|
70
|
+
return {
|
|
71
|
+
text: "plan mode OFF — the session default is 'default' (asks on writes). " +
|
|
72
|
+
"It is NOT restored to whatever it was before /plan: use /mode to pick another.",
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/**
|
|
77
|
+
* `/plan` flips plan mode; it does not only enter it.
|
|
78
|
+
*
|
|
79
|
+
* Baseline 04 §/plan: "Toggle plan mode … flip the boolean, persist the new
|
|
80
|
+
* value". The pre-B-11 handler wrote "plan" unconditionally, so `/plan` twice left
|
|
81
|
+
* the session read-only and the only way out was `/mode` or `/clear` —
|
|
82
|
+
* with the command still reporting success both times.
|
|
83
|
+
*
|
|
84
|
+
* Leaving plan returns to `default`, not to whatever preceded it: the mode before
|
|
85
|
+
* could have been `bypassPermissions`, and silently restoring that on a second
|
|
86
|
+
* `/plan` would hand back write access nobody asked for on that keystroke.
|
|
87
|
+
*/
|
|
88
|
+
export function togglePlanMode(currentMode: unknown): { mode: string; entering: boolean } {
|
|
89
|
+
const entering = String(currentMode ?? "").trim() !== "plan";
|
|
90
|
+
return { mode: entering ? "plan" : "default", entering };
|
|
91
|
+
}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
// /model (E-1, hot-swap since B-10) — show the active model, or switch the model
|
|
2
|
+
// used by subsequent turns WITHOUT relaunching (baseline 04 §/model).
|
|
3
|
+
//
|
|
4
|
+
// How it works, and why the old deviation is gone. The provider still binds at
|
|
5
|
+
// host startup, so there is no second provider to switch to; what changed is that
|
|
6
|
+
// the loop now passes the preference to `ctx.llm.act` as `{ llm: { model } }`,
|
|
7
|
+
// which the scripting facade applies as a PATCH on the provider's own
|
|
8
|
+
// configuration. Credentials, endpoint and timeout are inherited; only the model
|
|
9
|
+
// name changes, for that call.
|
|
10
|
+
//
|
|
11
|
+
// Two limits, stated rather than discovered:
|
|
12
|
+
// - the override travels over the SAME provider, so it can only name a model
|
|
13
|
+
// that provider serves ('claude-…' on a DeepSeek endpoint is a 4xx from the
|
|
14
|
+
// API, not a local error);
|
|
15
|
+
// - the preference is session state, so /clear drops it back to the
|
|
16
|
+
// boot model;
|
|
17
|
+
// - `llm.profile` wins: under a profile the loop does not send the override (the
|
|
18
|
+
// profile names the model, and a decision profile's escalation target would get
|
|
19
|
+
// it too), so `show` names the profile and a switch warns that it is not sent.
|
|
20
|
+
//
|
|
21
|
+
// Framework note (the B-10 verification step): `LlmConfigOverride` — the Domain
|
|
22
|
+
// cascade vehicle — carries ResponseFormat/Temperature/MaxTokens/TopP/Thinking/
|
|
23
|
+
// Cache and NO model field, so it is not the vehicle here. The options bag is,
|
|
24
|
+
// and it needed a framework fix to be usable at all: call-time settings used to
|
|
25
|
+
// be built from LlmConfig.Default() and REPLACE the provider's config wholesale,
|
|
26
|
+
// which dropped the API key. Patched in Orkeon.Scripting (JsLlmFacade.ConfigFrom).
|
|
27
|
+
|
|
28
|
+
import type { Logger, SessionMetadata, SessionStore, Telemetry } from "../../../shared/application/ports.ts";
|
|
29
|
+
import { MODEL_PREFERENCE_STATE_KEY } from "../../../shared/domain/session-keys.ts";
|
|
30
|
+
import type { ConfigStore } from "../../../shared/application/config-store.ts";
|
|
31
|
+
import { readLlmProfile } from "../../../shared/application/llm-profile.ts";
|
|
32
|
+
import {
|
|
33
|
+
judgeModelChoice, renderModelList, NO_CATALOGUE_NOTE,
|
|
34
|
+
} from "../../../shared/domain/model-catalog.ts";
|
|
35
|
+
import type { CommandView } from "../view.ts";
|
|
36
|
+
|
|
37
|
+
export interface ModelDeps {
|
|
38
|
+
session: Pick<SessionStore, "readState" | "writeState">;
|
|
39
|
+
telemetry: Pick<Telemetry, "readMetadata">;
|
|
40
|
+
/** Where the session's `llm.profile` is read: under a profile, the override is not sent. */
|
|
41
|
+
config: Pick<ConfigStore, "readValue" | "readFile">;
|
|
42
|
+
log: Pick<Logger, "warn">;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* What the host reports as the active model, or "" when it reports nothing.
|
|
47
|
+
*
|
|
48
|
+
* `session_store get_metadata` is the ONLY channel a script has for this. It used
|
|
49
|
+
* to be empty in every host: `AddOrkeonSessionTools` registered the buffer as
|
|
50
|
+
* `new InMemorySessionBufferService()` and never passed the constructor's optional
|
|
51
|
+
* model, so `SessionMetadata.Model` was always null. Fixed framework-side; the
|
|
52
|
+
* empty case survives here because a host may still register no provider at all,
|
|
53
|
+
* and that case must be SAID rather than dressed up as a reading — the old
|
|
54
|
+
* "(unknown — reported by provider config)" claimed the provider had been asked.
|
|
55
|
+
*/
|
|
56
|
+
async function readHostModels(telemetry: ModelDeps["telemetry"]): Promise<{ boot: string; declared: string[] }> {
|
|
57
|
+
const md = await telemetry.readMetadata().catch((): SessionMetadata => ({}));
|
|
58
|
+
return {
|
|
59
|
+
boot: (md.model ?? "").trim(),
|
|
60
|
+
// `Llm:AvailableModels` — what this host DECLARES the provider serves.
|
|
61
|
+
declared: md.availableModels ?? [],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export const NO_MODEL_REPORTED =
|
|
66
|
+
"not reported by the host — no LLM provider is registered, or the host predates the " +
|
|
67
|
+
"session-metadata fix. Turns will no-op: check that the settings file has an `Llm` section.";
|
|
68
|
+
|
|
69
|
+
/** `/model [show|list|reset|clear|<name>]`, from the command's raw tokens. */
|
|
70
|
+
export async function runModel(tokens: string[], deps: ModelDeps): Promise<CommandView> {
|
|
71
|
+
const { session, telemetry, config, log } = deps;
|
|
72
|
+
const first = (tokens[0] ?? "").toLowerCase();
|
|
73
|
+
|
|
74
|
+
// `show` is explicit; a bare /model does the same thing.
|
|
75
|
+
if (tokens.length === 0 || first === "show" || first === "list") {
|
|
76
|
+
const [{ boot, declared }, pref, { profile }] = await Promise.all([
|
|
77
|
+
readHostModels(telemetry),
|
|
78
|
+
session.readState(MODEL_PREFERENCE_STATE_KEY).catch(() => null),
|
|
79
|
+
readLlmProfile(config),
|
|
80
|
+
]);
|
|
81
|
+
// Under a profile no declared model of the host is the effective one: the profile names its own.
|
|
82
|
+
const effective = profile === null ? pref || boot : "";
|
|
83
|
+
const catalogue = renderModelList(declared, effective);
|
|
84
|
+
|
|
85
|
+
// `/model list` is the catalogue alone — the question is "what can I pick".
|
|
86
|
+
if (first === "list") {
|
|
87
|
+
return { text: catalogue ? `declared models (* = effective):\n${catalogue}` : NO_CATALOGUE_NOTE };
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
return {
|
|
91
|
+
text: `effective model for the next turn: ${effectiveLine(effective, profile)}\n` +
|
|
92
|
+
` boot model : ${boot || NO_MODEL_REPORTED}\n` +
|
|
93
|
+
` session override: ${pref ? (profile === null ? pref : `${pref} (not sent while llm.profile is set)`) : "(none)"}\n` +
|
|
94
|
+
(catalogue ? `declared models (* = effective):\n${catalogue}\n` : `declared models: ${NO_CATALOGUE_NOTE}\n`) +
|
|
95
|
+
"usage: /model <name> | /model list | /model reset | /model show",
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
if (first === "reset" || first === "clear") {
|
|
100
|
+
await session.writeState(MODEL_PREFERENCE_STATE_KEY, "");
|
|
101
|
+
const { boot } = await readHostModels(telemetry);
|
|
102
|
+
return {
|
|
103
|
+
text: boot
|
|
104
|
+
? `model override cleared — turns go back to ${boot}.`
|
|
105
|
+
: `model override cleared. Boot model: ${NO_MODEL_REPORTED}`,
|
|
106
|
+
};
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
const requested = tokens.join(" ").trim();
|
|
110
|
+
// Checked against the declared list BEFORE writing, and applied either way: the
|
|
111
|
+
// list is a settings-file hint that may lag the provider, so refusing on it would
|
|
112
|
+
// block a model that works. The warning is the whole value here — without it the
|
|
113
|
+
// mistake surfaces one turn later as an API error buried in the log.
|
|
114
|
+
const { declared } = await readHostModels(telemetry);
|
|
115
|
+
const verdict = judgeModelChoice(declared, requested);
|
|
116
|
+
if (verdict.warning) log.warn(verdict.warning);
|
|
117
|
+
await session.writeState(MODEL_PREFERENCE_STATE_KEY, requested);
|
|
118
|
+
const { profile } = await readLlmProfile(config);
|
|
119
|
+
if (profile !== null) {
|
|
120
|
+
// Stored all the same: it applies again once the profile is unset.
|
|
121
|
+
const warning = `llm.profile ${profile} is active: the /model override '${requested}' is stored but not sent ` +
|
|
122
|
+
"while it is set (unset llm.profile to use it)";
|
|
123
|
+
log.warn(warning);
|
|
124
|
+
return { text: `model set to '${requested}' — ⚠ ${warning}.` };
|
|
125
|
+
}
|
|
126
|
+
if (verdict.warning) {
|
|
127
|
+
// Terse inline, full reason in the log: in the split-pane console the two land
|
|
128
|
+
// in different panes, and repeating four lines verbatim next to themselves
|
|
129
|
+
// trains the eye to skip them.
|
|
130
|
+
return {
|
|
131
|
+
text: `model set to '${requested}' — ⚠ NOT among the models this host declares ` +
|
|
132
|
+
`(${declared.join(", ")}). Applied anyway; see the log. /model list to review.`,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
return {
|
|
136
|
+
text: `model set to '${requested}' — it applies from the next /assistant turn, no relaunch.\n` +
|
|
137
|
+
"It travels over the configured provider, so it must be a model that provider serves; " +
|
|
138
|
+
"/clear (or /model reset) returns to the boot model.",
|
|
139
|
+
};
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/** The first line of `show`: the profile when one is set, else the effective model. */
|
|
143
|
+
function effectiveLine(effective: string, profile: string | null): string {
|
|
144
|
+
if (profile !== null) return `the one llm.profile ${profile} names (the /model override does not apply)`;
|
|
145
|
+
return effective || "(none — see below)";
|
|
146
|
+
}
|