orkeon-code 0.0.0-stage → 1.0.0-rc.2
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-runtime +10 -0
- package/.orkeon-version +1 -0
- package/LICENSE.md +21 -0
- package/NOTICE.md +17 -0
- package/README.fr.md +163 -0
- package/README.md +156 -2
- package/config/appsettings.anthropic.example.json +77 -0
- package/config/appsettings.example.json +71 -0
- package/config/appsettings.jev.example.json +131 -0
- package/config/appsettings.kev.example.json +133 -0
- package/config/appsettings.liquid.example.json +132 -0
- package/config/appsettings.ollama-whisper.example.json +93 -0
- package/config/appsettings.ollama.example.json +70 -0
- package/config/appsettings.whisper.example.json +32 -0
- package/mcp/whisper/README.md +294 -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 +1092 -0
- package/orkeon-code.mjs +71 -0
- package/orkeon-code.ps1 +939 -0
- package/package.json +58 -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 +559 -0
- package/src/commands/_lib/args.ts +194 -0
- package/src/commands/_lib/dev/dev-batches.ts +366 -0
- package/src/commands/_lib/dev/dev-implement.ts +185 -0
- package/src/commands/_lib/dev/dev-source.ts +61 -0
- package/src/commands/_lib/dev/dev.ts +341 -0
- package/src/commands/_lib/dev/markers.ts +7 -0
- package/src/commands/_lib/dev/messages.ts +112 -0
- package/src/commands/_lib/dev-step.ts +145 -0
- package/src/commands/_lib/dispatch.ts +254 -0
- package/src/commands/_lib/effort.ts +15 -0
- package/src/commands/_lib/git/branch.ts +94 -0
- package/src/commands/_lib/git/commit.ts +90 -0
- package/src/commands/_lib/git/diff.ts +107 -0
- package/src/commands/_lib/git/messages.ts +54 -0
- package/src/commands/_lib/git/review.ts +108 -0
- package/src/commands/_lib/memory/memory-admit.ts +148 -0
- package/src/commands/_lib/memory/memory.ts +52 -0
- package/src/commands/_lib/memory/messages.ts +32 -0
- package/src/commands/_lib/messages.ts +48 -0
- package/src/commands/_lib/pr-context.ts +32 -0
- package/src/commands/_lib/project/analyze.ts +24 -0
- package/src/commands/_lib/project/messages.ts +8 -0
- package/src/commands/_lib/session/export.ts +105 -0
- package/src/commands/_lib/session/messages.ts +87 -0
- package/src/commands/_lib/session/prompts.ts +4 -0
- package/src/commands/_lib/session/resume.ts +151 -0
- package/src/commands/_lib/session/tasks.ts +181 -0
- package/src/commands/_lib/settings/advisor.ts +75 -0
- package/src/commands/_lib/settings/agents.ts +137 -0
- package/src/commands/_lib/settings/choices.ts +8 -0
- package/src/commands/_lib/settings/config.ts +141 -0
- package/src/commands/_lib/settings/effort.ts +147 -0
- package/src/commands/_lib/settings/hooks.ts +50 -0
- package/src/commands/_lib/settings/messages.ts +408 -0
- package/src/commands/_lib/settings/mode.ts +100 -0
- package/src/commands/_lib/settings/model.ts +181 -0
- package/src/commands/_lib/settings/output-style.ts +39 -0
- package/src/commands/_lib/settings/permissions.ts +287 -0
- package/src/commands/_lib/settings/route.ts +63 -0
- package/src/commands/_lib/settings/session-config.ts +49 -0
- package/src/commands/_lib/settings/skills.ts +93 -0
- package/src/commands/_lib/settings/theme.ts +42 -0
- package/src/commands/_lib/speech/messages.ts +58 -0
- package/src/commands/_lib/speech/prompts.ts +4 -0
- package/src/commands/_lib/speech/say.ts +95 -0
- package/src/commands/_lib/speech/transcribe.ts +121 -0
- package/src/commands/_lib/speech/voice.ts +142 -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 +205 -0
- package/src/commands/_lib/status/messages.ts +100 -0
- package/src/commands/_lib/status/meta.ts +24 -0
- package/src/commands/_lib/status/status.ts +128 -0
- package/src/commands/_lib/status/usage-tools.ts +48 -0
- package/src/commands/_lib/status/usage.ts +128 -0
- package/src/commands/_lib/view.ts +34 -0
- package/src/commands/dev/dev-batches.cmd.ts +109 -0
- package/src/commands/dev/dev-learn.cmd.ts +29 -0
- package/src/commands/dev/dev-plan.cmd.ts +51 -0
- package/src/commands/dev/dev-spec.cmd.ts +54 -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 +62 -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 +45 -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 +18 -0
- package/src/commands/session/resume.cmd.ts +19 -0
- package/src/commands/session/rewind.cmd.ts +25 -0
- package/src/commands/session/summary.cmd.ts +27 -0
- package/src/commands/session/tasks.cmd.ts +46 -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 +19 -0
- package/src/commands/settings/effort.cmd.ts +19 -0
- package/src/commands/settings/fast.cmd.ts +18 -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 +21 -0
- package/src/commands/settings/output-style.cmd.ts +19 -0
- package/src/commands/settings/permissions.cmd.ts +25 -0
- package/src/commands/settings/proactive.cmd.ts +16 -0
- package/src/commands/settings/route.cmd.ts +16 -0
- package/src/commands/settings/skills.cmd.ts +17 -0
- package/src/commands/settings/theme.cmd.ts +14 -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 +4391 -0
- package/src/crews/_probe-shared-memory/domain/messages.ts +54 -0
- package/src/crews/_probe-shared-memory/domain/probe-verdict.ts +188 -0
- package/src/crews/_probe-shared-memory/domain/prompts.ts +5 -0
- package/src/crews/_probe-shared-memory/probe.ork.ts +100 -0
- package/src/crews/advisor/application/messages.ts +4 -0
- package/src/crews/advisor/application/prompts.ts +4 -0
- package/src/crews/advisor/application/run-advisor.ts +41 -0
- package/src/crews/advisor/crew.ork.ts +44 -0
- package/src/crews/advisor/domain/advice.ts +119 -0
- package/src/crews/advisor/domain/messages.ts +8 -0
- package/src/crews/advisor/domain/prompts.ts +26 -0
- package/src/crews/agent-run/application/messages.ts +18 -0
- package/src/crews/agent-run/application/run-agent-run.ts +43 -0
- package/src/crews/agent-run/crew.ork.ts +67 -0
- package/src/crews/analyze/application/messages.ts +27 -0
- package/src/crews/analyze/application/prompts.ts +4 -0
- package/src/crews/analyze/application/run-analyze.ts +120 -0
- package/src/crews/analyze/crew.ork.ts +41 -0
- package/src/crews/analyze/domain/harvest.ts +269 -0
- package/src/crews/analyze/domain/prompts.ts +86 -0
- package/src/crews/code-review/application/lens-material.ts +24 -0
- package/src/crews/code-review/application/messages.ts +17 -0
- package/src/crews/code-review/application/prompts.ts +126 -0
- package/src/crews/code-review/application/review.ts +74 -0
- package/src/crews/code-review/application/run-code-review.ts +121 -0
- package/src/crews/code-review/crew.ork.ts +52 -0
- package/src/crews/code-review/domain/lenses.ts +154 -0
- package/src/crews/code-review/domain/messages.ts +25 -0
- package/src/crews/code-review/domain/prompts.ts +58 -0
- package/src/crews/code-review/domain/report.ts +58 -0
- package/src/crews/code-review/domain/scope.ts +106 -0
- package/src/crews/dev-batches/application/messages.ts +127 -0
- package/src/crews/dev-batches/application/plan-close.ts +181 -0
- package/src/crews/dev-batches/application/prompts.ts +10 -0
- package/src/crews/dev-batches/application/run-dev-batches.ts +676 -0
- package/src/crews/dev-batches/application/run-wave.ts +452 -0
- package/src/crews/dev-batches/application/seed-harvest.ts +163 -0
- package/src/crews/dev-batches/crew.ork.ts +146 -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 +52 -0
- package/src/crews/dev-batches/domain/markers.ts +5 -0
- package/src/crews/dev-batches/domain/messages.ts +6 -0
- package/src/crews/dev-batches/domain/wave-order.ts +44 -0
- package/src/crews/dev-change/application/change-material.ts +44 -0
- package/src/crews/dev-change/application/evidence.ts +172 -0
- package/src/crews/dev-change/application/messages.ts +81 -0
- package/src/crews/dev-change/application/prompts.ts +101 -0
- package/src/crews/dev-change/application/run-dev-change.ts +324 -0
- package/src/crews/dev-change/crew.ork.ts +114 -0
- package/src/crews/dev-change/domain/change-answer.ts +163 -0
- package/src/crews/dev-change/domain/change-render.ts +77 -0
- package/src/crews/dev-change/domain/markers.ts +28 -0
- package/src/crews/dev-change/domain/messages.ts +16 -0
- package/src/crews/dev-implement/application/close.ts +186 -0
- package/src/crews/dev-implement/application/count-open-steps.ts +24 -0
- package/src/crews/dev-implement/application/locate-sheet.ts +82 -0
- package/src/crews/dev-implement/application/messages.ts +161 -0
- package/src/crews/dev-implement/application/observe.ts +52 -0
- package/src/crews/dev-implement/application/prompts.ts +9 -0
- package/src/crews/dev-implement/application/report-writes.ts +46 -0
- package/src/crews/dev-implement/application/run-dev-implement.ts +822 -0
- package/src/crews/dev-implement/application/run-role.ts +27 -0
- package/src/crews/dev-implement/application/suite-job.ts +122 -0
- package/src/crews/dev-implement/application/touched.ts +74 -0
- package/src/crews/dev-implement/crew.ork.ts +69 -0
- package/src/crews/dev-implement/domain/contracts.ts +255 -0
- package/src/crews/dev-implement/domain/correction.ts +103 -0
- package/src/crews/dev-implement/domain/cycles.ts +36 -0
- package/src/crews/dev-implement/domain/implement-budget.ts +29 -0
- package/src/crews/dev-implement/domain/markers.ts +23 -0
- package/src/crews/dev-implement/domain/messages.ts +58 -0
- package/src/crews/dev-implement/domain/prompts.ts +93 -0
- package/src/crews/dev-implement/domain/roles.ts +49 -0
- package/src/crews/dev-implement/domain/sheet-edits.ts +76 -0
- package/src/crews/dev-implement/domain/sheet-ticks.ts +23 -0
- package/src/crews/dev-implement/domain/step-checks.ts +137 -0
- package/src/crews/dev-implement/domain/step-section.ts +129 -0
- package/src/crews/dev-learn/application/learn-backlog.ts +58 -0
- package/src/crews/dev-learn/application/learn-prompt-fit.ts +63 -0
- package/src/crews/dev-learn/application/messages.ts +51 -0
- package/src/crews/dev-learn/application/prompts.ts +99 -0
- package/src/crews/dev-learn/application/run-dev-learn.ts +558 -0
- package/src/crews/dev-learn/crew.ork.ts +53 -0
- package/src/crews/dev-learn/domain/learn-answer.ts +233 -0
- package/src/crews/dev-learn/domain/messages.ts +65 -0
- package/src/crews/dev-learn/domain/owner-lines.ts +89 -0
- package/src/crews/dev-learn/domain/proposals-render.ts +95 -0
- package/src/crews/dev-plan/application/anchor-paths.ts +113 -0
- package/src/crews/dev-plan/application/inventory.ts +174 -0
- package/src/crews/dev-plan/application/messages.ts +88 -0
- package/src/crews/dev-plan/application/plan-prompt-fit.ts +44 -0
- package/src/crews/dev-plan/application/prompts.ts +141 -0
- package/src/crews/dev-plan/application/run-dev-plan.ts +483 -0
- package/src/crews/dev-plan/crew.ork.ts +112 -0
- package/src/crews/dev-plan/domain/inventory-model.ts +95 -0
- package/src/crews/dev-plan/domain/markers.ts +18 -0
- package/src/crews/dev-plan/domain/messages.ts +118 -0
- package/src/crews/dev-plan/domain/plan-answer.ts +753 -0
- package/src/crews/dev-plan/domain/plan-render.ts +306 -0
- package/src/crews/dev-plan/domain/prompts.ts +44 -0
- package/src/crews/dev-spec/application/messages.ts +30 -0
- package/src/crews/dev-spec/application/prompts.ts +93 -0
- package/src/crews/dev-spec/application/run-dev-spec.ts +237 -0
- package/src/crews/dev-spec/application/spec-material.ts +42 -0
- package/src/crews/dev-spec/crew.ork.ts +110 -0
- package/src/crews/dev-spec/domain/markers.ts +30 -0
- package/src/crews/dev-spec/domain/messages.ts +39 -0
- package/src/crews/dev-spec/domain/spec-answer.ts +252 -0
- package/src/crews/dev-spec/domain/spec-render.ts +76 -0
- package/src/crews/dev-verify/application/audit-brief.ts +187 -0
- package/src/crews/dev-verify/application/audit.ts +267 -0
- package/src/crews/dev-verify/application/capture.ts +311 -0
- package/src/crews/dev-verify/application/messages.ts +119 -0
- package/src/crews/dev-verify/application/prompts.ts +209 -0
- package/src/crews/dev-verify/application/run-dev-verify.ts +423 -0
- package/src/crews/dev-verify/application/run-gate.ts +204 -0
- package/src/crews/dev-verify/crew.ork.ts +103 -0
- package/src/crews/dev-verify/domain/audit-answer.ts +154 -0
- package/src/crews/dev-verify/domain/auditor-charter.ts +21 -0
- package/src/crews/dev-verify/domain/capture-sections.ts +138 -0
- package/src/crews/dev-verify/domain/commands.ts +103 -0
- package/src/crews/dev-verify/domain/gate.ts +131 -0
- package/src/crews/dev-verify/domain/markers.ts +16 -0
- package/src/crews/dev-verify/domain/mechanical-table.ts +156 -0
- package/src/crews/dev-verify/domain/messages.ts +92 -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 +133 -0
- package/src/crews/git-commit/application/messages.ts +15 -0
- package/src/crews/git-commit/application/prompts.ts +47 -0
- package/src/crews/git-commit/application/run-git-commit.ts +117 -0
- package/src/crews/git-commit/crew.ork.ts +53 -0
- package/src/crews/git-commit/domain/commit.ts +200 -0
- package/src/crews/git-commit/domain/markers.ts +4 -0
- package/src/crews/git-commit/domain/messages.ts +48 -0
- package/src/crews/init-verifiers/application/authoring.ts +90 -0
- package/src/crews/init-verifiers/application/messages.ts +13 -0
- package/src/crews/init-verifiers/application/prompts.ts +107 -0
- package/src/crews/init-verifiers/application/run-init-verifiers.ts +26 -0
- package/src/crews/init-verifiers/crew.ork.ts +35 -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 +78 -0
- package/src/crews/main-loop/application/context-gather.ts +133 -0
- package/src/crews/main-loop/application/messages.ts +81 -0
- package/src/crews/main-loop/application/prompts.ts +12 -0
- package/src/crews/main-loop/application/run-main-loop.ts +383 -0
- package/src/crews/main-loop/application/turn-context.ts +111 -0
- package/src/crews/main-loop/crew.ork.ts +124 -0
- package/src/crews/main-loop/domain/autocompact.ts +27 -0
- package/src/crews/main-loop/domain/prompt-assembly.ts +338 -0
- package/src/crews/main-loop/domain/prompts.ts +336 -0
- package/src/crews/main-loop/domain/turn-chains.ts +130 -0
- package/src/crews/project-init/application/detect.ts +123 -0
- package/src/crews/project-init/application/messages.ts +15 -0
- package/src/crews/project-init/application/prompts.ts +105 -0
- package/src/crews/project-init/application/run-project-init.ts +31 -0
- package/src/crews/project-init/crew.ork.ts +36 -0
- package/src/crews/project-init/domain/conventions.ts +36 -0
- package/src/crews/project-init/domain/existing-files.ts +65 -0
- package/src/crews/project-init/domain/messages.ts +13 -0
- package/src/crews/project-init/domain/package-map.ts +73 -0
- package/src/crews/project-init/domain/prompts.ts +10 -0
- package/src/crews/session-compact/application/prompts.ts +5 -0
- package/src/crews/session-compact/crew.ork.ts +56 -0
- package/src/crews/shared-memory-admit/application/prompts.ts +5 -0
- package/src/crews/shared-memory-admit/crew.ork.ts +49 -0
- package/src/crews/speech/application/messages.ts +3 -0
- package/src/crews/speech/application/prompts.ts +3 -0
- package/src/crews/speech/application/run-speech.ts +26 -0
- package/src/crews/speech/crew.ork.ts +38 -0
- package/src/shared/application/agents/child-agent.ts +259 -0
- package/src/shared/application/agents/messages.ts +35 -0
- package/src/shared/application/agents/route-agent.ts +115 -0
- package/src/shared/application/agents/run-sub-agent.ts +119 -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 +242 -0
- package/src/shared/application/compaction/extract-memories.ts +38 -0
- package/src/shared/application/compaction/messages.ts +20 -0
- package/src/shared/application/compaction/prune-context.ts +94 -0
- package/src/shared/application/compaction/pruned-llm.ts +35 -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 +115 -0
- package/src/shared/application/dev/close-batch.ts +85 -0
- package/src/shared/application/dev/find-repo-pack.ts +78 -0
- package/src/shared/application/dev/learn-decision.ts +254 -0
- package/src/shared/application/dev/load-dev-context.ts +265 -0
- package/src/shared/application/dev/measure-access-cost.ts +69 -0
- package/src/shared/application/dev/messages.ts +132 -0
- package/src/shared/application/dev/phase-timer.ts +54 -0
- package/src/shared/application/dev/plan-source.ts +116 -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/prompts.ts +34 -0
- package/src/shared/application/dev/question-round.ts +60 -0
- package/src/shared/application/dev/resolve-work-folder.ts +134 -0
- package/src/shared/application/dev/script-tool-slot.ts +27 -0
- package/src/shared/application/dev/settle-questions.ts +57 -0
- package/src/shared/application/dev/source-review.ts +67 -0
- package/src/shared/application/dev/source-step.ts +152 -0
- package/src/shared/application/dev/spend.ts +55 -0
- package/src/shared/application/dev/step-precedents.ts +90 -0
- package/src/shared/application/dev/tool-call-policy.ts +87 -0
- package/src/shared/application/dev/tool-callbacks.ts +262 -0
- package/src/shared/application/dev/tool-trace-recorder.ts +46 -0
- package/src/shared/application/dev/verdict-sources.ts +50 -0
- package/src/shared/application/dev/wrapped-tools.ts +147 -0
- package/src/shared/application/extra-tools.ts +71 -0
- package/src/shared/application/git/batch-worktree.ts +102 -0
- package/src/shared/application/git/commit-files.ts +191 -0
- package/src/shared/application/git/merge-batch.ts +67 -0
- package/src/shared/application/git/messages.ts +75 -0
- package/src/shared/application/git/open-pull-request.ts +52 -0
- package/src/shared/application/host-context.ts +59 -0
- package/src/shared/application/host-layout-store.ts +45 -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 +36 -0
- package/src/shared/application/messages.ts +14 -0
- package/src/shared/application/permission-rules.ts +169 -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/decision.ts +14 -0
- package/src/shared/application/ports/files.ts +21 -0
- package/src/shared/application/ports/human.ts +38 -0
- package/src/shared/application/ports/llm.ts +83 -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/theme.ts +11 -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 +29 -0
- package/src/shared/application/project-manifests.ts +106 -0
- package/src/shared/application/session-io.ts +85 -0
- package/src/shared/application/session-state.ts +36 -0
- package/src/shared/application/shared-memory/admit-entries.ts +179 -0
- package/src/shared/application/shared-memory/harvest-after-gaps.ts +69 -0
- package/src/shared/application/shared-memory/harvest-mistakes.ts +45 -0
- package/src/shared/application/shared-memory/import-agent-memory.ts +119 -0
- package/src/shared/application/shared-memory/memory-files.ts +111 -0
- package/src/shared/application/shared-memory/memory-settings.ts +94 -0
- package/src/shared/application/shared-memory/messages.ts +63 -0
- package/src/shared/application/shared-memory/push-candidate.ts +149 -0
- package/src/shared/application/shared-memory/recall-precedents.ts +70 -0
- package/src/shared/application/skills/messages.ts +4 -0
- package/src/shared/application/skills/suggest-skills.ts +102 -0
- package/src/shared/application/state-snapshot.ts +38 -0
- package/src/shared/application/workflow/messages.ts +8 -0
- package/src/shared/application/workflow/workflow-state.ts +136 -0
- package/src/shared/domain/agent-policy/behavior-flags.ts +162 -0
- package/src/shared/domain/agent-policy/extra-tools.ts +67 -0
- package/src/shared/domain/agent-policy/memory-categories.ts +6 -0
- package/src/shared/domain/agent-policy/messages.ts +66 -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/path-rules.ts +299 -0
- package/src/shared/domain/agent-policy/permission.ts +625 -0
- package/src/shared/domain/agent-policy/prompts.ts +17 -0
- package/src/shared/domain/agent-policy/reasoning.ts +59 -0
- package/src/shared/domain/agent-policy/rule-sets.ts +416 -0
- package/src/shared/domain/agent-policy/tool-access.ts +91 -0
- package/src/shared/domain/agent-registry.ts +143 -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 +64 -0
- package/src/shared/domain/agents/exclusive.ts +25 -0
- package/src/shared/domain/agents/instances.ts +252 -0
- package/src/shared/domain/agents/messages.ts +39 -0
- package/src/shared/domain/agents/model-route.ts +199 -0
- package/src/shared/domain/agents/prompts.ts +20 -0
- package/src/shared/domain/code-intel-contract.ts +357 -0
- package/src/shared/domain/code-intel-routing.ts +60 -0
- package/src/shared/domain/compact-outcome.ts +46 -0
- package/src/shared/domain/compaction-thresholds.ts +162 -0
- package/src/shared/domain/compaction.ts +288 -0
- package/src/shared/domain/config-schema.ts +434 -0
- package/src/shared/domain/context-prune.ts +176 -0
- package/src/shared/domain/decision/questions.ts +102 -0
- package/src/shared/domain/dev/access-cost.ts +230 -0
- package/src/shared/domain/dev/artefacts.ts +50 -0
- package/src/shared/domain/dev/batches-concurrency.ts +35 -0
- package/src/shared/domain/dev/batches-state.ts +49 -0
- package/src/shared/domain/dev/build-commands.ts +45 -0
- package/src/shared/domain/dev/call-guard.ts +342 -0
- package/src/shared/domain/dev/carried-text.ts +47 -0
- package/src/shared/domain/dev/design-rules.ts +100 -0
- package/src/shared/domain/dev/learn-proposals.ts +176 -0
- package/src/shared/domain/dev/learn-state.ts +94 -0
- package/src/shared/domain/dev/markers.ts +107 -0
- package/src/shared/domain/dev/messages.ts +259 -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/phase-timing.ts +50 -0
- package/src/shared/domain/dev/plan-checks.ts +191 -0
- package/src/shared/domain/dev/plan-format.ts +170 -0
- package/src/shared/domain/dev/project-files.ts +29 -0
- package/src/shared/domain/dev/prompts/brief-blocks.ts +20 -0
- package/src/shared/domain/dev/prompts.ts +251 -0
- package/src/shared/domain/dev/questions.ts +267 -0
- package/src/shared/domain/dev/reading-rule.ts +41 -0
- package/src/shared/domain/dev/repo-pack.ts +240 -0
- package/src/shared/domain/dev/review-answer.ts +173 -0
- package/src/shared/domain/dev/review-brief.ts +54 -0
- package/src/shared/domain/dev/reviewer-charter.ts +35 -0
- package/src/shared/domain/dev/sheet-facts.ts +81 -0
- package/src/shared/domain/dev/spec-format.ts +182 -0
- package/src/shared/domain/dev/step-budget.ts +74 -0
- package/src/shared/domain/dev/step-rules.ts +109 -0
- package/src/shared/domain/dev/test-commands.ts +94 -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 +65 -0
- package/src/shared/domain/dev/trait-pattern.ts +87 -0
- package/src/shared/domain/dev/verdict-format.ts +162 -0
- package/src/shared/domain/dev/whitespace.ts +35 -0
- package/src/shared/domain/dev/work-folder.ts +68 -0
- package/src/shared/domain/dev/yaml-subset.ts +385 -0
- package/src/shared/domain/error-text.ts +13 -0
- package/src/shared/domain/git/close.ts +274 -0
- package/src/shared/domain/git/messages.ts +20 -0
- package/src/shared/domain/git/pull-request.ts +96 -0
- package/src/shared/domain/git/worktree.ts +46 -0
- package/src/shared/domain/host-layout.ts +147 -0
- package/src/shared/domain/host-paths.ts +399 -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 +134 -0
- package/src/shared/domain/llm-profile.ts +44 -0
- package/src/shared/domain/marked-message.ts +29 -0
- package/src/shared/domain/markers.ts +30 -0
- package/src/shared/domain/messages.ts +291 -0
- package/src/shared/domain/model-catalog.ts +79 -0
- package/src/shared/domain/permission-modes.ts +99 -0
- package/src/shared/domain/prelude.ts +92 -0
- package/src/shared/domain/project-manifests.ts +84 -0
- package/src/shared/domain/prompts.ts +233 -0
- package/src/shared/domain/search-routing.ts +77 -0
- package/src/shared/domain/secret-patterns.ts +46 -0
- package/src/shared/domain/session-keys.ts +92 -0
- package/src/shared/domain/session-start.ts +61 -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 +145 -0
- package/src/shared/domain/shared-memory/candidates.ts +40 -0
- package/src/shared/domain/shared-memory/entry.ts +151 -0
- package/src/shared/domain/shared-memory/front-matter.ts +187 -0
- package/src/shared/domain/shared-memory/gate.ts +45 -0
- package/src/shared/domain/shared-memory/harvest.ts +64 -0
- package/src/shared/domain/shared-memory/layout.ts +190 -0
- package/src/shared/domain/shared-memory/markers.ts +9 -0
- package/src/shared/domain/shared-memory/messages.ts +66 -0
- package/src/shared/domain/shared-memory/precedents-block.ts +82 -0
- package/src/shared/domain/shared-memory/prompts.ts +28 -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/skills/prompts.ts +4 -0
- package/src/shared/domain/skills/shortlist.ts +149 -0
- package/src/shared/domain/snip-turns.ts +33 -0
- package/src/shared/domain/speech.ts +21 -0
- package/src/shared/domain/strip.ts +88 -0
- package/src/shared/domain/tool-trace.ts +120 -0
- package/src/shared/domain/types.ts +67 -0
- package/src/shared/domain/verifiers.ts +33 -0
- package/src/shared/domain/vfs.ts +16 -0
- package/src/shared/domain/workflow/prompts.ts +15 -0
- package/src/shared/domain/workflow/state-file.ts +142 -0
- package/src/shared/infrastructure/globals.ts +57 -0
- package/src/shared/infrastructure/orkeon/approvals.ts +24 -0
- package/src/shared/infrastructure/orkeon/child-agents.ts +122 -0
- package/src/shared/infrastructure/orkeon/chooser.ts +32 -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/decision-model.ts +31 -0
- package/src/shared/infrastructure/orkeon/dev-deps.ts +179 -0
- package/src/shared/infrastructure/orkeon/files.ts +58 -0
- package/src/shared/infrastructure/orkeon/github-pull-requests.ts +30 -0
- package/src/shared/infrastructure/orkeon/host-context.ts +36 -0
- package/src/shared/infrastructure/orkeon/host-provider.ts +22 -0
- package/src/shared/infrastructure/orkeon/human-input.ts +55 -0
- package/src/shared/infrastructure/orkeon/llm-profile.ts +58 -0
- package/src/shared/infrastructure/orkeon/llm.ts +164 -0
- package/src/shared/infrastructure/orkeon/markers.ts +6 -0
- package/src/shared/infrastructure/orkeon/memory-store.ts +41 -0
- package/src/shared/infrastructure/orkeon/memory-tools.ts +129 -0
- package/src/shared/infrastructure/orkeon/messages.ts +15 -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/prompts.ts +47 -0
- package/src/shared/infrastructure/orkeon/reasoning.ts +40 -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 +129 -0
- package/src/shared/infrastructure/orkeon/session-store.ts +94 -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 +81 -0
- package/src/shared/infrastructure/orkeon/shell.ts +39 -0
- package/src/shared/infrastructure/orkeon/telemetry.ts +63 -0
- package/src/shared/infrastructure/orkeon/tool-catalogue.ts +76 -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 +174 -0
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
// /skills (E-1) — manage skill attachments (baseline 04 §/skills). Skills in
|
|
2
|
+
// Orkeon Code are workspace markdown files whose PATH is registered here; attached
|
|
3
|
+
// skills are restorable context (the post-compaction restore, E-4, re-injects
|
|
4
|
+
// path-mentioned files). Attachment is explicit; `/skills suggest on` adds, turn by turn, the project's skills the
|
|
5
|
+
// host's decision model finds fit for the request (shared/application/skills/suggest-skills.ts, ADR 0027).
|
|
6
|
+
|
|
7
|
+
import type { DecisionModel, Files, SessionStore } from "../../../shared/application/ports.ts";
|
|
8
|
+
import type { ConfigStore } from "../../../shared/application/config-store.ts";
|
|
9
|
+
import { SKILLS_SUGGEST_CONFIG_KEY, suggestOn } from "../../../shared/domain/skills/shortlist.ts";
|
|
10
|
+
import type { SkillPick } from "../../../shared/domain/skills/shortlist.ts";
|
|
11
|
+
import { readJsonArray, writeJson } from "../../../shared/application/session-state.ts";
|
|
12
|
+
import { SKILLS_STATE_KEY, SKILLS_SUGGESTED_STATE_KEY } from "../../../shared/domain/session-keys.ts";
|
|
13
|
+
import type { CommandView } from "../view.ts";
|
|
14
|
+
import {
|
|
15
|
+
NO_SKILLS, NOTHING_SUGGESTED_YET, SKILLS_ATTACH_USAGE, SKILLS_SUGGEST_USAGE, SKILLS_USAGE, cannotAttach, noSkillFit, skillAttached,
|
|
16
|
+
skillDetached, skillsDetachUsage, skillsOffered, suggestSet, suggestStatus, suggestedSkill,
|
|
17
|
+
} from "./messages.ts";
|
|
18
|
+
|
|
19
|
+
export interface SkillsDeps {
|
|
20
|
+
session: Pick<SessionStore, "readState" | "writeState">;
|
|
21
|
+
files: Pick<Files, "read">;
|
|
22
|
+
/** The settings and the decision model `/skills suggest` reads; absent, the sub-command answers its usage. */
|
|
23
|
+
config?: Pick<ConfigStore, "readValue" | "readSession" | "writeSession">;
|
|
24
|
+
decision?: Pick<DecisionModel, "available">;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** What the last turn was suggested, as stored; null when nothing readable is. */
|
|
28
|
+
function lastSuggestion(stored: string | null): { offered: number; picks: SkillPick[] } | null {
|
|
29
|
+
try {
|
|
30
|
+
const raw = JSON.parse(stored ?? "null") as { offered?: unknown; picks?: unknown } | null;
|
|
31
|
+
if (raw === null || typeof raw.offered !== "number" || !Array.isArray(raw.picks)) return null;
|
|
32
|
+
return { offered: raw.offered, picks: raw.picks.filter((p): p is SkillPick => typeof p?.path === "string" && typeof p?.share === "number") };
|
|
33
|
+
} catch {
|
|
34
|
+
return null;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/** `/skills suggest [on|off|why]`. */
|
|
39
|
+
async function runSuggest(word: string, deps: SkillsDeps): Promise<CommandView> {
|
|
40
|
+
const { config, decision } = deps;
|
|
41
|
+
if (config === undefined || decision === undefined) return { text: SKILLS_SUGGEST_USAGE };
|
|
42
|
+
if (word === "") {
|
|
43
|
+
const value = await config.readValue(SKILLS_SUGGEST_CONFIG_KEY).then((read) => read.value).catch(() => undefined);
|
|
44
|
+
return { text: suggestStatus(suggestOn(value), decision.available()) };
|
|
45
|
+
}
|
|
46
|
+
if (word === "why") {
|
|
47
|
+
const last = lastSuggestion(await deps.session.readState(SKILLS_SUGGESTED_STATE_KEY).catch(() => null));
|
|
48
|
+
if (last === null) return { text: NOTHING_SUGGESTED_YET };
|
|
49
|
+
if (last.picks.length === 0) return { text: noSkillFit(last.offered) };
|
|
50
|
+
return { lines: last.picks.map((pick) => suggestedSkill(pick.path, pick.share)), text: skillsOffered(last.offered) };
|
|
51
|
+
}
|
|
52
|
+
if (word !== "on" && word !== "off") return { text: SKILLS_SUGGEST_USAGE };
|
|
53
|
+
await config.writeSession({ ...await config.readSession(), [SKILLS_SUGGEST_CONFIG_KEY]: word });
|
|
54
|
+
return { text: suggestSet(word === "on", decision.available()) };
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** `/skills [list|attach <path>|detach <n>]`, from the command's raw tokens. */
|
|
58
|
+
export async function runSkills(tokens: string[], deps: SkillsDeps): Promise<CommandView> {
|
|
59
|
+
const { session, files } = deps;
|
|
60
|
+
const [sub, arg] = tokens;
|
|
61
|
+
const skills = await readJsonArray(session, SKILLS_STATE_KEY);
|
|
62
|
+
switch ((sub ?? "list").toLowerCase()) {
|
|
63
|
+
case "list":
|
|
64
|
+
if (skills.length === 0) {
|
|
65
|
+
return { text: NO_SKILLS };
|
|
66
|
+
}
|
|
67
|
+
return { table: skills.map((p, i) => ({ n: i + 1, path: String(p) })) };
|
|
68
|
+
case "attach": {
|
|
69
|
+
if (!arg) return { text: SKILLS_ATTACH_USAGE };
|
|
70
|
+
try {
|
|
71
|
+
await files.read(arg, 1);
|
|
72
|
+
} catch {
|
|
73
|
+
return { text: cannotAttach(arg) };
|
|
74
|
+
}
|
|
75
|
+
if (!skills.includes(arg)) skills.push(arg);
|
|
76
|
+
await writeJson(session, SKILLS_STATE_KEY, skills);
|
|
77
|
+
return { text: skillAttached(arg, skills.length) };
|
|
78
|
+
}
|
|
79
|
+
case "detach": {
|
|
80
|
+
const n = Number(arg);
|
|
81
|
+
if (!Number.isInteger(n) || n < 1 || n > skills.length) {
|
|
82
|
+
return { text: skillsDetachUsage(skills.length || 1) };
|
|
83
|
+
}
|
|
84
|
+
const [removed] = skills.splice(n - 1, 1);
|
|
85
|
+
await writeJson(session, SKILLS_STATE_KEY, skills);
|
|
86
|
+
return { text: skillDetached(removed) };
|
|
87
|
+
}
|
|
88
|
+
case "suggest":
|
|
89
|
+
return runSuggest((arg ?? "").toLowerCase(), deps);
|
|
90
|
+
default:
|
|
91
|
+
return { text: SKILLS_USAGE };
|
|
92
|
+
}
|
|
93
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// /theme [<name>|show]: the console's palette for this session. The start palette is the setting Orkeon:Cli:Tui:Theme.
|
|
2
|
+
import type { Chooser, ThemeConsole, ThemeName } from "../../../shared/application/ports.ts";
|
|
3
|
+
import type { CommandView } from "../view.ts";
|
|
4
|
+
import { optionsOf } from "./choices.ts";
|
|
5
|
+
import { NO_PALETTES, THEME_CHOICE, themeSet, themeShown, themeUnchanged, unknownTheme } from "./messages.ts";
|
|
6
|
+
|
|
7
|
+
const THEMES: readonly ThemeName[] = ["dark", "light", "none"];
|
|
8
|
+
|
|
9
|
+
export interface ThemeDeps {
|
|
10
|
+
console: ThemeConsole;
|
|
11
|
+
/** Where a bare /theme opens a panel, when it can. */
|
|
12
|
+
chooser?: Chooser;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const isTheme = (token: string): token is ThemeName => (THEMES as readonly string[]).includes(token);
|
|
16
|
+
|
|
17
|
+
/** `/theme [<name>|show]`, from the command's raw tokens. No argument opens a panel, or without one shows the palette,
|
|
18
|
+
* as `show` does. */
|
|
19
|
+
export async function runTheme(tokens: string[], deps: ThemeDeps): Promise<CommandView> {
|
|
20
|
+
const { console, chooser } = deps;
|
|
21
|
+
const requested = (tokens[0] ?? "").toLowerCase();
|
|
22
|
+
if (requested && requested !== "show" && !isTheme(requested)) {
|
|
23
|
+
return { text: unknownTheme(requested, THEMES) };
|
|
24
|
+
}
|
|
25
|
+
const current = console.theme;
|
|
26
|
+
if (current === null) return { text: NO_PALETTES };
|
|
27
|
+
|
|
28
|
+
if (isTheme(requested)) return setTheme(console, requested);
|
|
29
|
+
if (!requested && chooser?.interactive) {
|
|
30
|
+
const answer = await chooser.choose({
|
|
31
|
+
message: THEME_CHOICE,
|
|
32
|
+
options: optionsOf(THEMES, current),
|
|
33
|
+
});
|
|
34
|
+
return answer ? setTheme(console, answer.value as ThemeName) : { text: themeUnchanged(current) };
|
|
35
|
+
}
|
|
36
|
+
return { text: themeShown(current, THEMES) };
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function setTheme(console: ThemeConsole, name: ThemeName): CommandView {
|
|
40
|
+
if (!console.setTheme(name)) return { text: NO_PALETTES };
|
|
41
|
+
return { text: themeSet(name) };
|
|
42
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
// The text /say, /transcribe and /voice show the user (ADR 0026): their usage, their refusals and what a completion
|
|
2
|
+
// prints. Read by say.ts, transcribe.ts and voice.ts.
|
|
3
|
+
|
|
4
|
+
export const SAY_USAGE = "usage: /say [<text>] [--voice <voice>]\n /say --stop";
|
|
5
|
+
|
|
6
|
+
export const TRANSCRIBE_USAGE =
|
|
7
|
+
'usage: /transcribe <file> [--lang <code>] [--prompt "<words>"] [--then "<instruction>"]\n' +
|
|
8
|
+
" /transcribe --list";
|
|
9
|
+
|
|
10
|
+
export const VOICE_USAGE =
|
|
11
|
+
'usage: /voice [--go] [--lang <code>] [--prompt "<words>"] [--max <seconds>] [--silence <seconds>]\n' +
|
|
12
|
+
" /voice send";
|
|
13
|
+
|
|
14
|
+
// The refusals of a bad line
|
|
15
|
+
export const unknownArgument = (word: string) => `unknown argument ${word}`;
|
|
16
|
+
export const VOICE_NEEDS_NAME = "--voice needs a voice name (fr_FR-siwis-medium, en_US-lessac-medium...)";
|
|
17
|
+
export const STOP_ALONE = "--stop takes nothing else";
|
|
18
|
+
export const NAME_A_FILE = "name a file under /audio (/transcribe --list shows them)";
|
|
19
|
+
export const oneFileAtATime = (file: string, word: string) =>
|
|
20
|
+
`one file at a time (${file}, ${word}): quote a name that holds a space`;
|
|
21
|
+
export const needsLanguageCode = (option: string) => `${option} needs a language code (fr, en...)`;
|
|
22
|
+
export const PROMPT_NEEDS_WORDS = '--prompt needs the words the speech may contain, quoted ("Orkeon, Jint, MCP")';
|
|
23
|
+
export const THEN_NEEDS_INSTRUCTION = "--then needs an instruction";
|
|
24
|
+
export const LIST_ALONE = "--list takes no file and no option";
|
|
25
|
+
export const SEND_ALONE = "send takes no option and no quotes: /voice send sends the last dictation";
|
|
26
|
+
export const secondsBetween = (option: string, min: number, max: number) =>
|
|
27
|
+
`${option} takes seconds between ${min} and ${max}`;
|
|
28
|
+
|
|
29
|
+
/** The line that says what to do when the server's tools are not registered. */
|
|
30
|
+
export function missingToolMessage(tool: string): string {
|
|
31
|
+
return (
|
|
32
|
+
`no registered tool '${tool}': the Whisper MCP server is not connected. Start orkeon-code with ` +
|
|
33
|
+
"ORKEON_CODE_AUDIO_DIR set (docs/configuration.md, Speech-to-text); /debug-tool-call list shows what this host registers."
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// /say
|
|
38
|
+
export const STOPPED = "stopped";
|
|
39
|
+
export const toolFailed = (tool: string, failure: string) => `✗ ${tool}: ${failure}`;
|
|
40
|
+
export const lastAnswerUnreadable = (reason: string) => `cannot read the session's last answer: ${reason}`;
|
|
41
|
+
export const NOTHING_TO_READ = "nothing to read: give a text, or ask the assistant first (/say alone reads its last answer)";
|
|
42
|
+
export const TEXT_READ_ALOUD = "text read aloud";
|
|
43
|
+
export const LAST_ANSWER_READ_ALOUD = "last answer read aloud";
|
|
44
|
+
|
|
45
|
+
// /transcribe
|
|
46
|
+
export const filesUnder = (root: string) => `the files under ${root}`;
|
|
47
|
+
export const transcriptionOf = (path: string) => `transcription of ${path}`;
|
|
48
|
+
|
|
49
|
+
// /voice
|
|
50
|
+
export const recordingLine = (silenceSeconds: number, maxSeconds: number, go: boolean) =>
|
|
51
|
+
`🎙 recording: speak, then stay silent ${silenceSeconds} s to stop (${maxSeconds} s at most)` +
|
|
52
|
+
(go ? "; the text goes straight to the assistant" : "");
|
|
53
|
+
export const noDictationToSend = (file: string) => `no dictation to send: /voice records one (it is kept in ${file})`;
|
|
54
|
+
export const cannotRead = (file: string, reason: string) => `cannot read ${file}: ${reason}`;
|
|
55
|
+
export const voiceFailed = (error: string) => `✗ voice failed: ${error}`;
|
|
56
|
+
export const NOTHING_HEARD = "nothing was heard: /voice records again";
|
|
57
|
+
export const dictationLine = (payload: string) => `🎙 ${payload}`;
|
|
58
|
+
export const DICTATION_NEXT = "send it: /voice send · edit it: /assistant <text> · record again: /voice";
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
// /say: read a text aloud through the speech MCP server (mcp/whisper), or the
|
|
2
|
+
// assistant's last answer when no text is given. The server cleans the Markdown
|
|
3
|
+
// off, synthesizes the text (Piper, OpenAI's API or a compatible server) and
|
|
4
|
+
// plays it on the speaker when the launcher ran with ORKEON_CODE_VOICE=1;
|
|
5
|
+
// otherwise it writes /transcripts/speech.wav and says it played nothing.
|
|
6
|
+
//
|
|
7
|
+
// The reading is the command's call, made by the speech crew: synthesizing a
|
|
8
|
+
// long answer can outlast the 10 s a handler may wait. --stop is a quick call,
|
|
9
|
+
// made here.
|
|
10
|
+
import type { ConfigStore } from "../../../shared/application/config-store.ts";
|
|
11
|
+
import type { ToolCatalogue } from "../../../shared/application/ports.ts";
|
|
12
|
+
import type { SessionIo } from "../../../shared/application/session-io.ts";
|
|
13
|
+
import { errorText } from "../../../shared/domain/prelude.ts";
|
|
14
|
+
import { SPEAK_TOOL } from "../../../shared/domain/speech.ts";
|
|
15
|
+
import { commandLine, isOption, optionValue, splitWords } from "../args.ts";
|
|
16
|
+
import { launchCrew, withLlmProfile } from "../dispatch.ts";
|
|
17
|
+
import type { CommandLog, LaunchDeps, LaunchResult } from "../dispatch.ts";
|
|
18
|
+
import { LAST_ANSWER_READ_ALOUD, NOTHING_TO_READ, SAY_USAGE, STOP_ALONE, STOPPED, TEXT_READ_ALOUD, VOICE_NEEDS_NAME, lastAnswerUnreadable, missingToolMessage, toolFailed } from "./messages.ts";
|
|
19
|
+
import { unknownOption } from "../messages.ts";
|
|
20
|
+
|
|
21
|
+
export const STOP_TOOL = "stop_speaking";
|
|
22
|
+
|
|
23
|
+
export type SayRequest = { kind: "stop" } | { kind: "say"; text: string; voice: string };
|
|
24
|
+
|
|
25
|
+
export type ParsedSay = { ok: true; request: SayRequest } | { ok: false; error: string };
|
|
26
|
+
|
|
27
|
+
/** The arguments of /say: --stop alone, or a text (empty: the last answer; quoted, it may start
|
|
28
|
+
* with --) and a voice. */
|
|
29
|
+
export function parseSayArgs(tokens: readonly string[]): ParsedSay {
|
|
30
|
+
const words = splitWords(commandLine(tokens));
|
|
31
|
+
if (words.length === 1 && isOption(words[0]) && words[0].text === "--stop") return { ok: true, request: { kind: "stop" } };
|
|
32
|
+
const text: string[] = [];
|
|
33
|
+
let voice = "";
|
|
34
|
+
for (let i = 0; i < words.length; i++) {
|
|
35
|
+
const word = words[i].text;
|
|
36
|
+
if (!isOption(words[i])) {
|
|
37
|
+
text.push(word);
|
|
38
|
+
} else if (word === "--voice") {
|
|
39
|
+
const value = optionValue(words, i++);
|
|
40
|
+
if (value === null) return { ok: false, error: VOICE_NEEDS_NAME };
|
|
41
|
+
voice = value;
|
|
42
|
+
} else if (word === "--stop") {
|
|
43
|
+
return { ok: false, error: STOP_ALONE };
|
|
44
|
+
} else {
|
|
45
|
+
return { ok: false, error: unknownOption(word) };
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
return { ok: true, request: { kind: "say", text: text.join(" ").trim(), voice } };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** The content of the assistant's last message in the session, or "" when there is none. */
|
|
52
|
+
export function lastAnswer(messages: ReadonlyArray<{ role: string; content: unknown }>): string {
|
|
53
|
+
for (let i = messages.length - 1; i >= 0; i--) {
|
|
54
|
+
const message = messages[i];
|
|
55
|
+
if (message.role === "assistant" && typeof message.content === "string" && message.content.trim()) return message.content;
|
|
56
|
+
}
|
|
57
|
+
return "";
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** What /say reads and drives: the registered tools, the session (for the last answer), the crew launch. */
|
|
61
|
+
export type SayDeps = LaunchDeps & {
|
|
62
|
+
catalogue: Pick<ToolCatalogue, "find" | "callText">;
|
|
63
|
+
session: Pick<SessionIo, "readMessages">;
|
|
64
|
+
config: Pick<ConfigStore, "readValue" | "readFile">;
|
|
65
|
+
log: Pick<CommandLog, "info" | "warn">;
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
/** Launch the reading and return its ticket, or the message to show when it launches nothing. */
|
|
69
|
+
export async function dispatchSay(tokens: readonly string[], deps: SayDeps): Promise<LaunchResult | { message: string }> {
|
|
70
|
+
const parsed = parseSayArgs(tokens);
|
|
71
|
+
if (!parsed.ok) return { message: `${parsed.error}\n${SAY_USAGE}` };
|
|
72
|
+
const { request } = parsed;
|
|
73
|
+
if (request.kind === "stop") {
|
|
74
|
+
const stop = deps.catalogue.find(STOP_TOOL);
|
|
75
|
+
if (stop === undefined) return { message: missingToolMessage(STOP_TOOL) };
|
|
76
|
+
const outcome = await deps.catalogue.callText(stop, {});
|
|
77
|
+
return { message: outcome.ok ? (outcome.text || STOPPED) : toolFailed(STOP_TOOL, outcome.failure) };
|
|
78
|
+
}
|
|
79
|
+
const speak = deps.catalogue.find(SPEAK_TOOL);
|
|
80
|
+
if (speak === undefined) return { message: missingToolMessage(SPEAK_TOOL) };
|
|
81
|
+
let text = request.text;
|
|
82
|
+
if (!text) {
|
|
83
|
+
try {
|
|
84
|
+
text = lastAnswer((await deps.session.readMessages()).messages);
|
|
85
|
+
} catch (error) {
|
|
86
|
+
return { message: lastAnswerUnreadable(errorText(error)) };
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
if (!text) return { message: NOTHING_TO_READ };
|
|
90
|
+
const args: Record<string, unknown> = { text };
|
|
91
|
+
if (request.voice) args.voice = request.voice;
|
|
92
|
+
return launchCrew(await withLlmProfile(deps, deps.config), "speech", { tool: speak, args, label: request.text ? TEXT_READ_ALOUD : LAST_ANSWER_READ_ALOUD }, {
|
|
93
|
+
characters: text.length, ...(request.voice ? { voice: request.voice } : {}),
|
|
94
|
+
});
|
|
95
|
+
}
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
// /transcribe: speech-to-text through the Whisper MCP server (mcp/whisper),
|
|
2
|
+
// whose tools the launcher declares when ORKEON_CODE_AUDIO_DIR is set.
|
|
3
|
+
//
|
|
4
|
+
// The call is the command's: the gate does not ask, and no `tools.extra` entry is
|
|
5
|
+
// needed. It is made by a crew, never by this command's handler: a transcription
|
|
6
|
+
// lasts minutes, and the engine bounds the promise a handler awaits at 10 s.
|
|
7
|
+
// Without --then, the speech crew makes the call and /transcribe prints its
|
|
8
|
+
// text; with --then, the main loop makes it before the turn (a prelude) and the
|
|
9
|
+
// model reads the instruction, then the transcription.
|
|
10
|
+
import type { ToolCatalogue } from "../../../shared/application/ports.ts";
|
|
11
|
+
import type { PreludeCall } from "../../../shared/domain/prelude.ts";
|
|
12
|
+
import { commandLine, isOption, optionValue, parseAssistantInput, splitWords } from "../args.ts";
|
|
13
|
+
import { launchCrew, launchMainLoop, withLlmProfile } from "../dispatch.ts";
|
|
14
|
+
import type { LaunchResult, MainLoopLaunchDeps } from "../dispatch.ts";
|
|
15
|
+
import { LIST_ALONE, NAME_A_FILE, PROMPT_NEEDS_WORDS, THEN_NEEDS_INSTRUCTION, TRANSCRIBE_USAGE, filesUnder, missingToolMessage, needsLanguageCode, oneFileAtATime, transcriptionOf } from "./messages.ts";
|
|
16
|
+
import { unknownOption } from "../messages.ts";
|
|
17
|
+
import { transcriptionPreludeLabel } from "./prompts.ts";
|
|
18
|
+
|
|
19
|
+
export const TRANSCRIBE_TOOL = "transcribe_audio";
|
|
20
|
+
export const LIST_AUDIO_TOOL = "list_audio";
|
|
21
|
+
export const AUDIO_ROOT = "/audio";
|
|
22
|
+
|
|
23
|
+
/** What /transcribe was asked: the listing of /audio, or one file. */
|
|
24
|
+
export type TranscribeRequest =
|
|
25
|
+
| { kind: "list" }
|
|
26
|
+
| { kind: "file"; path: string; language: string; vocabulary: string; then: string | null };
|
|
27
|
+
|
|
28
|
+
export type ParsedTranscribe = { ok: true; request: TranscribeRequest } | { ok: false; error: string };
|
|
29
|
+
|
|
30
|
+
/** A file name under /audio, or a path given as /audio/<file>, as the virtual path. */
|
|
31
|
+
export function audioPath(file: string): string {
|
|
32
|
+
const trimmed = file.trim();
|
|
33
|
+
return trimmed.startsWith(AUDIO_ROOT + "/") ? trimmed : `${AUDIO_ROOT}/${trimmed.replace(/^\/+/, "")}`;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* The arguments of /transcribe. `--lang` and `--prompt` take one argument (quoted
|
|
38
|
+
* when it holds spaces), `--then` the rest of the line as typed (it comes last); the
|
|
39
|
+
* file is the one argument that is not an option's.
|
|
40
|
+
*/
|
|
41
|
+
export function parseTranscribeArgs(tokens: readonly string[]): ParsedTranscribe {
|
|
42
|
+
const line = commandLine(tokens);
|
|
43
|
+
const words = splitWords(line);
|
|
44
|
+
let list = false;
|
|
45
|
+
let file: string | null = null;
|
|
46
|
+
let language = "";
|
|
47
|
+
let vocabulary = "";
|
|
48
|
+
let then: string | null = null;
|
|
49
|
+
for (let i = 0; i < words.length; i++) {
|
|
50
|
+
const word = words[i].text;
|
|
51
|
+
if (!isOption(words[i])) {
|
|
52
|
+
if (word.trim().length === 0) return { ok: false, error: NAME_A_FILE };
|
|
53
|
+
if (file !== null) return { ok: false, error: oneFileAtATime(file, word) };
|
|
54
|
+
file = word;
|
|
55
|
+
} else if (word === "--list") {
|
|
56
|
+
list = true;
|
|
57
|
+
} else if (word === "--lang" || word === "--language") {
|
|
58
|
+
const value = optionValue(words, i++);
|
|
59
|
+
if (value === null) return { ok: false, error: needsLanguageCode(word) };
|
|
60
|
+
language = value;
|
|
61
|
+
} else if (word === "--prompt") {
|
|
62
|
+
const value = optionValue(words, i++);
|
|
63
|
+
if (value === null) return { ok: false, error: PROMPT_NEEDS_WORDS };
|
|
64
|
+
vocabulary = value;
|
|
65
|
+
} else if (word === "--then") {
|
|
66
|
+
// One quoted instruction loses its quotes; otherwise the rest is kept as typed, quotes included.
|
|
67
|
+
const rest = words.slice(i + 1);
|
|
68
|
+
then = (rest.length === 1 ? rest[0].text : line.slice(words[i].end)).trim();
|
|
69
|
+
if (then.length === 0) return { ok: false, error: THEN_NEEDS_INSTRUCTION };
|
|
70
|
+
break;
|
|
71
|
+
} else {
|
|
72
|
+
return { ok: false, error: unknownOption(word) };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
if (list) {
|
|
76
|
+
if (file !== null || then !== null || language || vocabulary) return { ok: false, error: LIST_ALONE };
|
|
77
|
+
return { ok: true, request: { kind: "list" } };
|
|
78
|
+
}
|
|
79
|
+
if (file === null) return { ok: false, error: NAME_A_FILE };
|
|
80
|
+
return { ok: true, request: { kind: "file", path: audioPath(file), language, vocabulary, then } };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** The arguments of transcribe_audio for a file request (the server's parameter names). */
|
|
84
|
+
export function transcribeCall(registered: string, request: Extract<TranscribeRequest, { kind: "file" }>, label: string): PreludeCall {
|
|
85
|
+
const args: Record<string, unknown> = { path: request.path };
|
|
86
|
+
if (request.language) args.language = request.language;
|
|
87
|
+
if (request.vocabulary) args.vocabulary = request.vocabulary;
|
|
88
|
+
return { tool: registered, args, label };
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** What /transcribe reads and drives: the registered tools, the crew launch and, for --then, the main loop's launch. */
|
|
92
|
+
export type TranscribeDeps = MainLoopLaunchDeps & { catalogue: Pick<ToolCatalogue, "find"> };
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* Launch what the request asks and return the ticket: the speech crew for a
|
|
96
|
+
* listing or a file, the main loop with the transcription as its prelude for
|
|
97
|
+
* --then (a `mode:` prefix in the instruction picks the mode, as for /assistant).
|
|
98
|
+
* A bad line, or a server that is not connected, launches nothing and returns
|
|
99
|
+
* the message the REPL prints.
|
|
100
|
+
*/
|
|
101
|
+
export async function dispatchTranscribe(
|
|
102
|
+
tokens: readonly string[],
|
|
103
|
+
deps: TranscribeDeps,
|
|
104
|
+
): Promise<LaunchResult | { message: string }> {
|
|
105
|
+
const parsed = parseTranscribeArgs(tokens);
|
|
106
|
+
if (!parsed.ok) return { message: `${parsed.error}\n${TRANSCRIBE_USAGE}` };
|
|
107
|
+
const { request } = parsed;
|
|
108
|
+
const wanted = request.kind === "list" ? LIST_AUDIO_TOOL : TRANSCRIBE_TOOL;
|
|
109
|
+
const registered = deps.catalogue.find(wanted);
|
|
110
|
+
if (registered === undefined) return { message: missingToolMessage(wanted) };
|
|
111
|
+
if (request.kind === "list") {
|
|
112
|
+
return launchCrew(await withLlmProfile(deps, deps.config), "speech", { tool: registered, args: {}, label: filesUnder(AUDIO_ROOT) });
|
|
113
|
+
}
|
|
114
|
+
if (request.then === null) {
|
|
115
|
+
const call = transcribeCall(registered, request, transcriptionOf(request.path));
|
|
116
|
+
return launchCrew(await withLlmProfile(deps, deps.config), "speech", { ...call }, call.args);
|
|
117
|
+
}
|
|
118
|
+
const { prompt, permissionMode } = parseAssistantInput(request.then);
|
|
119
|
+
const prelude = transcribeCall(registered, request, transcriptionPreludeLabel(request.path));
|
|
120
|
+
return await launchMainLoop(deps, { prompt, permissionMode, prelude });
|
|
121
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
// /voice: dictate a request. The Whisper MCP server (mcp/whisper) records this
|
|
2
|
+
// machine's microphone until a silence and transcribes it (record_and_transcribe,
|
|
3
|
+
// refused unless the launcher ran with ORKEON_CODE_VOICE=1).
|
|
4
|
+
//
|
|
5
|
+
// Three uses, one dictation at a time:
|
|
6
|
+
// - /voice records and shows the text, which the server keeps as
|
|
7
|
+
// /transcripts/dictation.txt: nothing is sent yet (the confirmation);
|
|
8
|
+
// - /voice send sends that text to the assistant, as /assistant would;
|
|
9
|
+
// - /voice --go records and sends at once: the main loop makes the call before
|
|
10
|
+
// the turn and takes its text as the request (a prelude, `as: "request"`).
|
|
11
|
+
// Recording and transcribing last longer than the 10 s a handler may wait, so
|
|
12
|
+
// the call is made by a crew: the speech crew, or the main loop for --go.
|
|
13
|
+
import type { Files, ToolCatalogue } from "../../../shared/application/ports.ts";
|
|
14
|
+
import { errorText, nothingReturned } from "../../../shared/domain/prelude.ts";
|
|
15
|
+
import { commandLine, isOption, optionValue, parseAssistantInput, splitWords } from "../args.ts";
|
|
16
|
+
import { launchCrew, launchMainLoop, withLlmProfile } from "../dispatch.ts";
|
|
17
|
+
import type { CrewCompletion, LaunchResult, MainLoopLaunchDeps } from "../dispatch.ts";
|
|
18
|
+
import { DICTATION_NEXT, NOTHING_HEARD, PROMPT_NEEDS_WORDS, SEND_ALONE, VOICE_USAGE, cannotRead, dictationLine, missingToolMessage, needsLanguageCode, noDictationToSend, recordingLine, secondsBetween, unknownArgument, voiceFailed } from "./messages.ts";
|
|
19
|
+
import { unknownOption } from "../messages.ts";
|
|
20
|
+
|
|
21
|
+
export const RECORD_TOOL = "record_and_transcribe";
|
|
22
|
+
export const DICTATION_FILE = "/transcripts/dictation.txt";
|
|
23
|
+
const DEFAULT_MAX_SECONDS = 60;
|
|
24
|
+
const DEFAULT_SILENCE_SECONDS = 2;
|
|
25
|
+
|
|
26
|
+
export type VoiceRequest =
|
|
27
|
+
| { kind: "record"; go: boolean; language: string; vocabulary: string; maxSeconds: number; silenceSeconds: number }
|
|
28
|
+
| { kind: "send" };
|
|
29
|
+
|
|
30
|
+
export type ParsedVoice = { ok: true; request: VoiceRequest } | { ok: false; error: string };
|
|
31
|
+
|
|
32
|
+
/** A number option within bounds, or the reason it is not one. */
|
|
33
|
+
function seconds(option: string, value: string | null, min: number, max: number): number | string {
|
|
34
|
+
const n = value === null ? Number.NaN : Number(value);
|
|
35
|
+
if (!Number.isFinite(n) || n < min || n > max) return secondsBetween(option, min, max);
|
|
36
|
+
return n;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/** The arguments of /voice: `send` alone, or the recording options. */
|
|
40
|
+
export function parseVoiceArgs(tokens: readonly string[]): ParsedVoice {
|
|
41
|
+
const words = splitWords(commandLine(tokens));
|
|
42
|
+
if (words.length === 1 && words[0].text === "send" && !words[0].quoted) return { ok: true, request: { kind: "send" } };
|
|
43
|
+
const request = {
|
|
44
|
+
kind: "record" as const, go: false, language: "", vocabulary: "",
|
|
45
|
+
maxSeconds: DEFAULT_MAX_SECONDS, silenceSeconds: DEFAULT_SILENCE_SECONDS,
|
|
46
|
+
};
|
|
47
|
+
for (let i = 0; i < words.length; i++) {
|
|
48
|
+
const word = words[i].text;
|
|
49
|
+
if (!isOption(words[i])) {
|
|
50
|
+
if (word === "send") return { ok: false, error: SEND_ALONE };
|
|
51
|
+
return { ok: false, error: unknownArgument(word) };
|
|
52
|
+
} else if (word === "--go") {
|
|
53
|
+
request.go = true;
|
|
54
|
+
} else if (word === "--lang" || word === "--language") {
|
|
55
|
+
const value = optionValue(words, i++);
|
|
56
|
+
if (value === null) return { ok: false, error: needsLanguageCode(word) };
|
|
57
|
+
request.language = value;
|
|
58
|
+
} else if (word === "--prompt") {
|
|
59
|
+
const value = optionValue(words, i++);
|
|
60
|
+
if (value === null) return { ok: false, error: PROMPT_NEEDS_WORDS };
|
|
61
|
+
request.vocabulary = value;
|
|
62
|
+
} else if (word === "--max" || word === "--silence") {
|
|
63
|
+
const value = optionValue(words, i++);
|
|
64
|
+
const parsed = word === "--max" ? seconds(word, value, 1, 600) : seconds(word, value, 0.5, 10);
|
|
65
|
+
if (typeof parsed === "string") return { ok: false, error: parsed };
|
|
66
|
+
if (word === "--max") request.maxSeconds = parsed;
|
|
67
|
+
else request.silenceSeconds = parsed;
|
|
68
|
+
} else {
|
|
69
|
+
return { ok: false, error: unknownOption(word) };
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return { ok: true, request };
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
/** The arguments of record_and_transcribe (the server's parameter names). */
|
|
76
|
+
export function recordArgs(request: Extract<VoiceRequest, { kind: "record" }>): Record<string, unknown> {
|
|
77
|
+
const args: Record<string, unknown> = { max_seconds: request.maxSeconds, silence_seconds: request.silenceSeconds };
|
|
78
|
+
if (request.language) args.language = request.language;
|
|
79
|
+
if (request.vocabulary) args.vocabulary = request.vocabulary;
|
|
80
|
+
return args;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** The line shown when the microphone opens. */
|
|
84
|
+
export function recordingNotice(request: Extract<VoiceRequest, { kind: "record" }>): string {
|
|
85
|
+
return recordingLine(request.silenceSeconds, request.maxSeconds, request.go);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** What /voice reads and drives: the registered tools, the files (the last dictation, for
|
|
89
|
+
* send), the crew and main-loop launches, and the console for the recording notice. */
|
|
90
|
+
export type VoiceDeps = MainLoopLaunchDeps & {
|
|
91
|
+
catalogue: Pick<ToolCatalogue, "find">;
|
|
92
|
+
files: Pick<Files, "read">;
|
|
93
|
+
out: { writeLine(text: string): void };
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
const NOTHING_TO_SEND = noDictationToSend(DICTATION_FILE);
|
|
97
|
+
|
|
98
|
+
/** Launch what the request asks and return its ticket, or the message to show when it launches nothing. */
|
|
99
|
+
export async function dispatchVoice(tokens: readonly string[], deps: VoiceDeps): Promise<LaunchResult | { message: string }> {
|
|
100
|
+
const parsed = parseVoiceArgs(tokens);
|
|
101
|
+
if (!parsed.ok) return { message: `${parsed.error}\n${VOICE_USAGE}` };
|
|
102
|
+
const { request } = parsed;
|
|
103
|
+
if (request.kind === "send") {
|
|
104
|
+
let text: string;
|
|
105
|
+
try {
|
|
106
|
+
text = (await deps.files.read(DICTATION_FILE)).trim();
|
|
107
|
+
} catch (error) {
|
|
108
|
+
// A missing file is the common case (no dictation yet); the runtime's read says so, as json-file.ts reads it.
|
|
109
|
+
if (/not found|no such|does not exist/i.test(errorText(error))) return { message: NOTHING_TO_SEND };
|
|
110
|
+
return { message: cannotRead(DICTATION_FILE, errorText(error)) };
|
|
111
|
+
}
|
|
112
|
+
if (text.length === 0) return { message: NOTHING_TO_SEND };
|
|
113
|
+
const { prompt, permissionMode } = parseAssistantInput(text);
|
|
114
|
+
return await launchMainLoop(deps, { prompt, permissionMode });
|
|
115
|
+
}
|
|
116
|
+
const registered = deps.catalogue.find(RECORD_TOOL);
|
|
117
|
+
if (registered === undefined) return { message: missingToolMessage(RECORD_TOOL) };
|
|
118
|
+
deps.out.writeLine(recordingNotice(request));
|
|
119
|
+
const args = recordArgs(request);
|
|
120
|
+
if (request.go) {
|
|
121
|
+
return await launchMainLoop(deps, {
|
|
122
|
+
prompt: "", permissionMode: null, prelude: { tool: registered, args, label: "Dictation", as: "request" },
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
return launchCrew(await withLlmProfile(deps, deps.config), "speech", { tool: registered, args, label: "dictation" }, args);
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/**
|
|
129
|
+
* The lines a completion writes: the dictation and what to do with it, or the assistant's answer. The
|
|
130
|
+
* crew that answered is the completion's `intent` (the script host reports every crew as the agent
|
|
131
|
+
* "script-host", and the crew's name as the intent).
|
|
132
|
+
*/
|
|
133
|
+
export function renderVoiceCompletion(result: CrewCompletion & { agent?: string; intent?: string }): string[] {
|
|
134
|
+
if (!result.success) return [voiceFailed(result.error ?? "unknown")];
|
|
135
|
+
const payload = (result.payload ?? "").trim();
|
|
136
|
+
if (result.intent !== "speech") return [payload];
|
|
137
|
+
// The crew names the tool as the host registers it: compared case aside.
|
|
138
|
+
if (payload.length === 0 || payload.toLowerCase() === nothingReturned(RECORD_TOOL).toLowerCase()) {
|
|
139
|
+
return [NOTHING_HEARD];
|
|
140
|
+
}
|
|
141
|
+
return [dictationLine(payload), DICTATION_NEXT];
|
|
142
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
// The prompt-cache columns /usage and /context show (RT-12): the tokens read
|
|
2
|
+
// from the provider's cache and written to it, over every model of the session,
|
|
3
|
+
// `n/a` when no model reported the count (Orkeon #254: not measured, never 0). With the host's usage account they
|
|
4
|
+
// come from it alone, `n/a` for what it did not measure: never one figure from each source.
|
|
5
|
+
// Lives under commands/_lib/ — the loader's SearchPattern is "*.cmd.ts", so this
|
|
6
|
+
// file is never loaded as a command.
|
|
7
|
+
|
|
8
|
+
import type { SessionStats, UsageSpent } from "../../../shared/application/ports.ts";
|
|
9
|
+
|
|
10
|
+
/** What a column shows for a figure nobody reported: never 0, which would read as measured. */
|
|
11
|
+
export const UNREPORTED = "n/a";
|
|
12
|
+
export type Unreported = typeof UNREPORTED;
|
|
13
|
+
|
|
14
|
+
/** A count as a column shows it: the number when measured, 0 included; `n/a` when null or absent. */
|
|
15
|
+
export function shown(count: number | null | undefined): number | Unreported {
|
|
16
|
+
return count ?? UNREPORTED;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface CacheColumns {
|
|
20
|
+
cacheRead: number | Unreported;
|
|
21
|
+
cacheWrite: number | Unreported;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/** The cache columns: from the host's account when it keeps one (`report`), else from the telemetry's sums. */
|
|
25
|
+
export function cacheColumns(
|
|
26
|
+
s: Pick<SessionStats, "cacheHitTokens" | "cacheWriteTokens">,
|
|
27
|
+
report?: Pick<UsageSpent, "cacheHitTokens" | "cacheWriteTokens">,
|
|
28
|
+
): CacheColumns {
|
|
29
|
+
const from = report ?? s;
|
|
30
|
+
return { cacheRead: shown(from.cacheHitTokens), cacheWrite: shown(from.cacheWriteTokens) };
|
|
31
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
// /context — the session's context in one row: metadata, buffer size, the tokens used against the
|
|
2
|
+
// window, the pressure tier, the compaction boundaries, the prompt-cache tokens (from the host's usage
|
|
3
|
+
// account when it keeps one, as /usage takes them), and the tokens by kind of entry when the host reports
|
|
4
|
+
// them (Orkeon #226). A count the host does not report reads `n/a`, never 0. Lives under commands/_lib/ — the loader's
|
|
5
|
+
// SearchPattern is "*.cmd.ts", so this file is never loaded as a command.
|
|
6
|
+
|
|
7
|
+
import type {
|
|
8
|
+
SessionMetadata, SessionStats, SessionStore, Telemetry, TokenBudget, TokenKinds, UsageReader,
|
|
9
|
+
} from "../../../shared/application/ports.ts";
|
|
10
|
+
import { DEFAULT_CONTEXT_WINDOW, percentLeft, pressureTier } from "../../../shared/domain/compaction-thresholds.ts";
|
|
11
|
+
import { countCompactBoundaries } from "../../../shared/domain/compaction.ts";
|
|
12
|
+
import { cacheColumns, shown } from "./cache.ts";
|
|
13
|
+
import type { CommandView } from "../view.ts";
|
|
14
|
+
|
|
15
|
+
export interface ContextDeps {
|
|
16
|
+
session: Pick<SessionStore, "readBudget" | "readMessages">;
|
|
17
|
+
telemetry: Pick<Telemetry, "readMetadata" | "readStats">;
|
|
18
|
+
/** The host's account; when it keeps one, the cache columns come from it alone. */
|
|
19
|
+
usage?: UsageReader;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/** The by-kind columns: one per kind the host reports, none for an older host. */
|
|
23
|
+
export function kindColumns(kinds: TokenKinds | undefined): Record<string, number> {
|
|
24
|
+
if (kinds === undefined) return {};
|
|
25
|
+
return {
|
|
26
|
+
systemTokens: kinds.system,
|
|
27
|
+
userTokens: kinds.user,
|
|
28
|
+
assistantTokens: kinds.assistant,
|
|
29
|
+
toolTokens: kinds.tool,
|
|
30
|
+
otherTokens: kinds.other,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/** `/context`: the one row, each figure read best effort. */
|
|
35
|
+
export async function runContext(deps: ContextDeps): Promise<CommandView> {
|
|
36
|
+
const md = await deps.telemetry.readMetadata().catch((): SessionMetadata => ({}));
|
|
37
|
+
const budget = await deps.session.readBudget().catch((): TokenBudget => ({ used: 0, window: 0 }));
|
|
38
|
+
const stats = await deps.telemetry.readStats().catch((): SessionStats => ({}));
|
|
39
|
+
const boundaries = countCompactBoundaries((await deps.session.readMessages().catch(() => ({ stored: [] }))).stored);
|
|
40
|
+
const { used, window } = budget;
|
|
41
|
+
return {
|
|
42
|
+
table: [{
|
|
43
|
+
title: md.title ?? "(untitled)",
|
|
44
|
+
model: md.model ?? "?",
|
|
45
|
+
messages: shown(md.messageCount),
|
|
46
|
+
estTokens: shown(md.estimatedTokens),
|
|
47
|
+
usedTokens: used,
|
|
48
|
+
window: window || DEFAULT_CONTEXT_WINDOW,
|
|
49
|
+
remaining: Math.max(0, (window || DEFAULT_CONTEXT_WINDOW) - used),
|
|
50
|
+
pressure: pressureTier(used, window),
|
|
51
|
+
percentLeft: percentLeft(used, window) + "%",
|
|
52
|
+
compactions: boundaries,
|
|
53
|
+
...kindColumns(budget.byKind),
|
|
54
|
+
...cacheColumns(stats, deps.usage?.report()),
|
|
55
|
+
}],
|
|
56
|
+
};
|
|
57
|
+
}
|