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,41 @@
|
|
|
1
|
+
// MemoryStore adapter over memory_store, its results read whatever their casing
|
|
2
|
+
// (`entries` or `Entries`, `id` or `Id`, `content` or `Content`...).
|
|
3
|
+
|
|
4
|
+
import type { MemoryStore } from "../../application/ports.ts";
|
|
5
|
+
import type { MemoryStoreInput } from "./runtime-tools.ts";
|
|
6
|
+
import { pick } from "./tool-results.ts";
|
|
7
|
+
|
|
8
|
+
/** A reported number; null and absent both read as unreported. */
|
|
9
|
+
const num = (v: unknown): number | undefined => (v == null ? undefined : Number(v));
|
|
10
|
+
/** A reported string; null and absent both read as unreported. */
|
|
11
|
+
const str = (v: unknown): string | undefined => (v == null ? undefined : String(v));
|
|
12
|
+
|
|
13
|
+
export function createMemoryStore(tools: Pick<OrkeonTools, "memoryStore">): MemoryStore {
|
|
14
|
+
// One shape per operation (runtime-tools.ts): a misspelled operation fails here.
|
|
15
|
+
const memoryStore = (input: MemoryStoreInput) => tools.memoryStore(input);
|
|
16
|
+
return {
|
|
17
|
+
async list(category, options) {
|
|
18
|
+
// newest_first is sent only when asked: the input of a plain list stays what a release before #286 takes.
|
|
19
|
+
const order = options?.newestFirst ? { newest_first: true } : {};
|
|
20
|
+
const resp = await memoryStore({ operation: "list", category, ...order });
|
|
21
|
+
const entries: any[] = pick(resp, "entries", "Entries") ?? [];
|
|
22
|
+
return entries.map((e) => ({
|
|
23
|
+
id: num(pick(e, "id", "Id")),
|
|
24
|
+
category: str(pick(e, "category", "Category")),
|
|
25
|
+
content: String(pick(e, "content", "Content") ?? ""),
|
|
26
|
+
}));
|
|
27
|
+
},
|
|
28
|
+
async add(category, content) {
|
|
29
|
+
return String(pick(await memoryStore({ operation: "add", category, content }), "id", "Id"));
|
|
30
|
+
},
|
|
31
|
+
async get(id) {
|
|
32
|
+
return pick(await memoryStore({ operation: "get", id }), "entry", "Entry", "error");
|
|
33
|
+
},
|
|
34
|
+
async remove(id) {
|
|
35
|
+
return Boolean(pick(await memoryStore({ operation: "delete", id }), "success", "Success"));
|
|
36
|
+
},
|
|
37
|
+
async replace(id, content) {
|
|
38
|
+
return Boolean(pick(await memoryStore({ operation: "replace", id, content }), "success", "Success"));
|
|
39
|
+
},
|
|
40
|
+
};
|
|
41
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
/// <reference path="../../../crews/.orkeon/orkeon.d.ts" />
|
|
2
|
+
// memory_recall and memory_push (temp/05 § 5): the shared memory offered to the model as two of
|
|
3
|
+
// Orkeon Code's own tools, built with scriptTool and attached with `withAutonomousTool`. The recall
|
|
4
|
+
// reads (every mode); the push writes a candidate file, never entries/ (an edit: not offered in
|
|
5
|
+
// plan or dontAsk, asked in default). The gate decides from the declared access; the push also
|
|
6
|
+
// refuses by itself in a read-only mode. Their ports are built when the model calls them, from the
|
|
7
|
+
// wiring: `ctx` is undefined in a tool's execute. Under a batch's working root, the recall's
|
|
8
|
+
// file paths go out on the root (scriptTool's `root`).
|
|
9
|
+
|
|
10
|
+
import { ENTRY_TYPES } from "../../domain/shared-memory/entry.ts";
|
|
11
|
+
import type { EntryType } from "../../domain/shared-memory/entry.ts";
|
|
12
|
+
import { MAX_PRECEDENTS } from "../../domain/shared-memory/precedents-block.ts";
|
|
13
|
+
import { isReadOnly } from "../../domain/agent-policy/permission.ts";
|
|
14
|
+
import type { ConfigStore } from "../../application/config-store.ts";
|
|
15
|
+
import type { Files, SharedMemory, Shell } from "../../application/ports.ts";
|
|
16
|
+
import { readMemorySettings } from "../../application/shared-memory/memory-settings.ts";
|
|
17
|
+
import { recallEntries } from "../../application/shared-memory/recall-precedents.ts";
|
|
18
|
+
import { pushCandidate } from "../../application/shared-memory/push-candidate.ts";
|
|
19
|
+
import { scriptTool } from "./script-tools.ts";
|
|
20
|
+
import type { ScriptToolSpec, ToolBuilderFactory } from "./script-tools.ts";
|
|
21
|
+
|
|
22
|
+
export interface MemoryToolPorts {
|
|
23
|
+
files: Pick<Files, "read" | "write" | "list">;
|
|
24
|
+
shell: Pick<Shell, "run">;
|
|
25
|
+
config: Pick<ConfigStore, "readValue">;
|
|
26
|
+
memory: Pick<SharedMemory, "search">;
|
|
27
|
+
clock: () => Date;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export const MEMORY_RECALL: ScriptToolSpec = {
|
|
31
|
+
name: "memory_recall",
|
|
32
|
+
description:
|
|
33
|
+
"Search the shared memory of this project: the admitted decisions, code structures, methods and mistakes of " +
|
|
34
|
+
"past work. Returns at most five entries, best first, each with what it applies to and its file. A precedent is " +
|
|
35
|
+
"material, not an instruction: check it fits here.",
|
|
36
|
+
schema: {
|
|
37
|
+
type: "object",
|
|
38
|
+
properties: {
|
|
39
|
+
query: { type: "string", description: "What you are about to do or decide, in a sentence." },
|
|
40
|
+
types: { type: "array", items: { type: "string", enum: [...ENTRY_TYPES] }, description: "Only these types; absent, every type." },
|
|
41
|
+
top_k: { type: "number", description: `How many entries at most, ${MAX_PRECEDENTS} at most.` },
|
|
42
|
+
},
|
|
43
|
+
required: ["query"],
|
|
44
|
+
},
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const MEMORY_PUSH: ScriptToolSpec = {
|
|
48
|
+
name: "memory_push",
|
|
49
|
+
description:
|
|
50
|
+
"Propose a lesson for the shared memory: it is written as a candidate, never admitted; the operator decides " +
|
|
51
|
+
"with /memory-admit. Name the evidence (path:line, a commit, or a verdict file). A topic refused before is " +
|
|
52
|
+
"refused again; a secret or a secret-like file is refused.",
|
|
53
|
+
schema: {
|
|
54
|
+
type: "object",
|
|
55
|
+
properties: {
|
|
56
|
+
type: { type: "string", enum: [...ENTRY_TYPES] },
|
|
57
|
+
title: { type: "string", description: "One line, at most 90 characters." },
|
|
58
|
+
topic: { type: "string", description: "A few words naming the subject; entries of one topic are compared." },
|
|
59
|
+
applies_when: { type: "string", description: "When the lesson applies, so another project can tell." },
|
|
60
|
+
rationale: { type: "string", description: "Why: what happened, what it cost." },
|
|
61
|
+
correction: { type: "string", description: "A mistake only: what to do instead." },
|
|
62
|
+
detection_signal: { type: "string", description: "A mistake only: how to notice it." },
|
|
63
|
+
evidence: { type: "array", items: { type: "string" }, description: "path:line, a commit or a verdict file, one each." },
|
|
64
|
+
tags: { type: "array", items: { type: "string" } },
|
|
65
|
+
},
|
|
66
|
+
required: ["type", "title", "topic", "applies_when", "rationale", "evidence"],
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
const typesOf = (value: unknown): EntryType[] =>
|
|
71
|
+
Array.isArray(value) ? value.filter((t): t is EntryType => (ENTRY_TYPES as readonly unknown[]).includes(t)) : [];
|
|
72
|
+
|
|
73
|
+
export function memoryRecallTool(builder: ToolBuilderFactory, ports: () => MemoryToolPorts, root?: string): Tool<unknown, unknown> {
|
|
74
|
+
return scriptTool(builder, MEMORY_RECALL, async (input) => {
|
|
75
|
+
const raw = (input !== null && typeof input === "object" ? input : {}) as Record<string, unknown>;
|
|
76
|
+
const query = typeof raw.query === "string" ? raw.query.trim() : "";
|
|
77
|
+
if (query === "") return { ok: false, refused: "'query' is required" };
|
|
78
|
+
const p = ports();
|
|
79
|
+
const settings = await readMemorySettings(p);
|
|
80
|
+
const max = typeof raw.top_k === "number" && Number.isFinite(raw.top_k) ? raw.top_k : MAX_PRECEDENTS;
|
|
81
|
+
const recall = await recallEntries(p, { memory: settings, query, types: typesOf(raw.types), max });
|
|
82
|
+
return {
|
|
83
|
+
entries: recall.precedents.map(({ entry: e, path, score }) => ({
|
|
84
|
+
id: e.id, type: e.type, project: e.project, date: e.date, status: e.status, title: e.title,
|
|
85
|
+
applies_when: e.appliesWhen, rationale: e.rationale,
|
|
86
|
+
...(e.correction === undefined ? {} : { correction: e.correction }),
|
|
87
|
+
...(e.detectionSignal === undefined ? {} : { detection_signal: e.detectionSignal }),
|
|
88
|
+
path, score,
|
|
89
|
+
})),
|
|
90
|
+
truncated: recall.truncated,
|
|
91
|
+
};
|
|
92
|
+
}, root);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export function memoryPushTool(builder: ToolBuilderFactory, ports: () => MemoryToolPorts, mode: string): Tool<unknown, unknown> {
|
|
96
|
+
return scriptTool(builder, MEMORY_PUSH, async (input) => {
|
|
97
|
+
if (isReadOnly(mode)) return { ok: false, refused: `memory_push writes a candidate file: mode '${mode}' writes nothing` };
|
|
98
|
+
const p = ports();
|
|
99
|
+
const settings = await readMemorySettings(p);
|
|
100
|
+
const pushed = await pushCandidate(p, settings, input);
|
|
101
|
+
return pushed.ok
|
|
102
|
+
? { candidate_path: pushed.path, id: pushed.id, status: "candidate", ...(pushed.warnings.length > 0 ? { warnings: pushed.warnings } : {}) }
|
|
103
|
+
: { refused: pushed.refused };
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** The memory tools among `names` (what scriptToolsFor offered the mode), built; any other name is left out. */
|
|
108
|
+
export function memoryTools(
|
|
109
|
+
builder: ToolBuilderFactory, ports: () => MemoryToolPorts, mode: string, names: readonly string[],
|
|
110
|
+
): Array<Tool<unknown, unknown>> {
|
|
111
|
+
return names.flatMap((name) => name === MEMORY_RECALL.name ? [memoryRecallTool(builder, ports)]
|
|
112
|
+
: name === MEMORY_PUSH.name ? [memoryPushTool(builder, ports, mode)] : []);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** A dev crew attaches memory_recall unless its command said a session rule denies every call of it
|
|
116
|
+
* (`memoryRecall: false` in the input): the gate would refuse each call the agent tried. */
|
|
117
|
+
export function memoryRecallOn(input: unknown): boolean {
|
|
118
|
+
return !(input !== null && typeof input === "object" && (input as { memoryRecall?: unknown }).memoryRecall === false);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
/** memory_recall for a dev agent's `withAutonomousTools`, none when it is off. */
|
|
122
|
+
export function memoryRecallTools(
|
|
123
|
+
builder: ToolBuilderFactory, ports: () => MemoryToolPorts, on: boolean, root?: string,
|
|
124
|
+
): Array<Tool<unknown, unknown>> {
|
|
125
|
+
return on ? [memoryRecallTool(builder, ports, root)] : [];
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** The read tools a dev agent's callbacks let through on a host without a gate: memory_recall when it is on. */
|
|
129
|
+
export function memoryReadTools(on: boolean): string[] {
|
|
130
|
+
return on ? [MEMORY_RECALL.name] : [];
|
|
131
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// PermissionRules adapter over orkeon-repl's `permissions` service
|
|
2
|
+
// (PermissionRulesFacade). Like the script-host, the service is reached through
|
|
3
|
+
// the command context the runtime hands each command (`ctx.services`), so the
|
|
4
|
+
// adapter takes the context's service locator as a parameter rather than being
|
|
5
|
+
// bound in wiring.ts.
|
|
6
|
+
|
|
7
|
+
import type { PermissionRules } from "../../application/ports.ts";
|
|
8
|
+
import type { PermissionRulesFacade, ServiceLocator } from "../../../commands/.orkeon/orkeon-cli.d.ts";
|
|
9
|
+
|
|
10
|
+
/** The service name; orkeon-repl registers it, a host that keeps no rules does not. */
|
|
11
|
+
const PERMISSIONS = "permissions";
|
|
12
|
+
|
|
13
|
+
export function createPermissionRules(services: Pick<ServiceLocator, "get" | "has">): PermissionRules {
|
|
14
|
+
const facade = () => services.get<PermissionRulesFacade>(PERMISSIONS);
|
|
15
|
+
return {
|
|
16
|
+
available() {
|
|
17
|
+
return services.has(PERMISSIONS);
|
|
18
|
+
},
|
|
19
|
+
enabled() {
|
|
20
|
+
return services.has(PERMISSIONS) ? facade().enabled : undefined;
|
|
21
|
+
},
|
|
22
|
+
add(rule) {
|
|
23
|
+
const rules = facade();
|
|
24
|
+
// A rule over every call passes the tool alone: the facade reads an absent
|
|
25
|
+
// argument as "every call".
|
|
26
|
+
if (rule.argument === undefined) {
|
|
27
|
+
if (rule.effect === "allow") rules.allow(rule.tool);
|
|
28
|
+
else rules.deny(rule.tool);
|
|
29
|
+
} else if (rule.effect === "allow") {
|
|
30
|
+
rules.allow(rule.tool, rule.argument, rule.pattern);
|
|
31
|
+
} else {
|
|
32
|
+
rules.deny(rule.tool, rule.argument, rule.pattern);
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
clear() {
|
|
36
|
+
facade().clear();
|
|
37
|
+
},
|
|
38
|
+
list() {
|
|
39
|
+
return [...facade().list()].map(String);
|
|
40
|
+
},
|
|
41
|
+
};
|
|
42
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
// Progress adapter: the host progress channel (the `progress_report` tool →
|
|
2
|
+
// ProgressBroker → TUI status-line bar; also stamped on the owning command
|
|
3
|
+
// instance for ps/inspect and the agents pane).
|
|
4
|
+
//
|
|
5
|
+
// Best-effort BY CONTRACT: progress is decoration, and no long operation may
|
|
6
|
+
// fail because the host it runs on (an older orkeon-repl, a bare test harness)
|
|
7
|
+
// does not expose the tool. Every call degrades to a silent no-op.
|
|
8
|
+
|
|
9
|
+
import type { Progress } from "../../application/ports.ts";
|
|
10
|
+
import type { ProgressReportInput } from "./runtime-tools.ts";
|
|
11
|
+
|
|
12
|
+
/** `progressReport` is optional: the host may not register it. */
|
|
13
|
+
export function createProgress(tools: Partial<Pick<OrkeonTools, "progressReport">>): Progress {
|
|
14
|
+
const send = async (input: ProgressReportInput): Promise<void> => {
|
|
15
|
+
try {
|
|
16
|
+
if (typeof tools.progressReport !== "function") return;
|
|
17
|
+
await tools.progressReport(input);
|
|
18
|
+
} catch { /* progress is decoration — never fail the operation for it */ }
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
report: (spec) => send(spec),
|
|
22
|
+
done: (label) => send({ label, done: true }),
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/// <reference path="../../../crews/.orkeon/orkeon.d.ts" />
|
|
2
|
+
// RunState adapter over the running agent's state (`ctx.state`). The state is
|
|
3
|
+
// read from the context at every call, never kept, so a read sees the last
|
|
4
|
+
// mutation. `ctx.state.with` is the runtime's only mutation path (a direct
|
|
5
|
+
// assignment throws), and it replaces the whole state, so a write carries the
|
|
6
|
+
// other fields over.
|
|
7
|
+
|
|
8
|
+
import type { RunState } from "../../application/ports.ts";
|
|
9
|
+
|
|
10
|
+
export function createRunState(ctx: Pick<AgentContext<Record<string, unknown>>, "state">): RunState {
|
|
11
|
+
return {
|
|
12
|
+
read: (field) => (ctx.state as Record<string, unknown> | undefined)?.[field],
|
|
13
|
+
async write(field, value) {
|
|
14
|
+
await ctx.state.with((s) => ({ ...s, [field]: value }));
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// RuntimeInfoReader adapter over the command context's `runtime` service (Orkeon #225): the
|
|
2
|
+
// release with its build metadata removed, the commit that metadata carried, the install channel.
|
|
3
|
+
// Like the provider's name, it is reached through the service locator each command receives,
|
|
4
|
+
// so the adapter takes it as a parameter. Jint keeps the CLR member names on a host object, so
|
|
5
|
+
// both casings are read.
|
|
6
|
+
|
|
7
|
+
import type { RuntimeInfo, RuntimeInfoReader } from "../../application/ports.ts";
|
|
8
|
+
import type { RuntimeInfo as HostRuntimeInfo, ServiceLocator } from "../../../commands/.orkeon/orkeon-cli.d.ts";
|
|
9
|
+
import { pick } from "./tool-results.ts";
|
|
10
|
+
|
|
11
|
+
/** The service name; always registered by orkeon-repl, a bare host answers its entry assembly. */
|
|
12
|
+
const RUNTIME = "runtime";
|
|
13
|
+
|
|
14
|
+
export function createRuntimeInfo(services: Pick<ServiceLocator, "get" | "has">): RuntimeInfoReader {
|
|
15
|
+
return {
|
|
16
|
+
read(): RuntimeInfo | undefined {
|
|
17
|
+
try {
|
|
18
|
+
if (!services.has(RUNTIME)) return undefined;
|
|
19
|
+
const info = services.get<HostRuntimeInfo>(RUNTIME);
|
|
20
|
+
const version = String(pick(info, "version", "Version") ?? "").trim();
|
|
21
|
+
if (version.length === 0) return undefined;
|
|
22
|
+
const commit = pick(info, "commit", "Commit");
|
|
23
|
+
const channel = String(pick(info, "channel", "Channel") ?? "").trim();
|
|
24
|
+
return { version, commit: commit == null ? null : String(commit), channel: channel || "unknown" };
|
|
25
|
+
} catch {
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
/// <reference path="../../../crews/.orkeon/orkeon.d.ts" />
|
|
2
|
+
// The runtime's `tools` global as this code calls it.
|
|
3
|
+
//
|
|
4
|
+
// Every built-in tool is declared by the generated typings (crews/.orkeon/orkeon.d.ts,
|
|
5
|
+
// `OrkeonBuiltInTools`, which `OrkeonTools` extends — Orkeon #125): the input the tool
|
|
6
|
+
// deserializes and the result it hands back, in the tool's own snake_case. The adapters
|
|
7
|
+
// of this folder take `Pick<OrkeonTools, ...>`. This file keeps only the shapes this
|
|
8
|
+
// code passes that are STRICTER than the generated input: one union member per
|
|
9
|
+
// operation where the tool declares a bare `operation?: string`, so a misspelled
|
|
10
|
+
// operation fails at the call. Each shape is declared through `Fits`, which refuses
|
|
11
|
+
// it at `tsc` when a key is not one the tool declares (renamed on the .NET side) or a
|
|
12
|
+
// type does not fit; an operation VALUE is not checked (the tool declares none).
|
|
13
|
+
// Results are still read through tool-results.ts: see there for the casing.
|
|
14
|
+
|
|
15
|
+
/** The input the generated typings declare for a built-in tool. */
|
|
16
|
+
type Input<K extends keyof OrkeonBuiltInTools> = NonNullable<Parameters<OrkeonBuiltInTools[K]>[0]>;
|
|
17
|
+
|
|
18
|
+
/** The keys of every member of a union, not only the common ones. */
|
|
19
|
+
type Keys<T> = T extends unknown ? keyof T : never;
|
|
20
|
+
|
|
21
|
+
/** The generated input of `K`, where a key `T` names that the tool does not declare takes `never`. */
|
|
22
|
+
type Exact<K extends keyof OrkeonBuiltInTools, T> =
|
|
23
|
+
Input<K> & { [P in Exclude<Keys<T>, keyof Input<K>>]: never };
|
|
24
|
+
|
|
25
|
+
/** A local shape of the input of tool `K`, refused at its declaration when it stops fitting the generated one. */
|
|
26
|
+
type Fits<T extends Exact<K, T>, K extends keyof OrkeonBuiltInTools> = T;
|
|
27
|
+
|
|
28
|
+
/** session_store, one input shape per operation this code sends. */
|
|
29
|
+
export type SessionStoreInput = Fits<
|
|
30
|
+
| { operation: "read_messages" | "get_metadata" | "reset" }
|
|
31
|
+
| { operation: "write_messages"; messages: readonly unknown[] }
|
|
32
|
+
| { operation: "append_message"; role: string; content: string }
|
|
33
|
+
| { operation: "get_state"; key: string }
|
|
34
|
+
| { operation: "get_state"; keys: readonly string[] }
|
|
35
|
+
| { operation: "set_state"; key: string; value: string | null }
|
|
36
|
+
| { operation: "set_title"; title: string },
|
|
37
|
+
"sessionStore"
|
|
38
|
+
>;
|
|
39
|
+
|
|
40
|
+
/** memory_store, one input shape per operation this code sends. */
|
|
41
|
+
export type MemoryStoreInput = Fits<
|
|
42
|
+
| { operation: "list"; category?: string; newest_first?: boolean }
|
|
43
|
+
| { operation: "add"; category: string; content: string }
|
|
44
|
+
| { operation: "get" | "delete"; id: number }
|
|
45
|
+
| { operation: "replace"; id: number; content: string },
|
|
46
|
+
"memoryStore"
|
|
47
|
+
>;
|
|
48
|
+
|
|
49
|
+
/** progress_report: a progress line, or the release of its slot (`done`). */
|
|
50
|
+
export type ProgressReportInput = Fits<{
|
|
51
|
+
label: string;
|
|
52
|
+
step?: number;
|
|
53
|
+
total?: number;
|
|
54
|
+
percent?: number;
|
|
55
|
+
message?: string;
|
|
56
|
+
done?: boolean;
|
|
57
|
+
}, "progressReport">;
|
|
58
|
+
|
|
59
|
+
/** batch_anchors, the closure of a set of anchors by FQN. */
|
|
60
|
+
export type BatchAnchorsClosureInput = Fits<{ action: "closure"; fqns: readonly string[] }, "batchAnchors">;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/// <reference path="../../../crews/.orkeon/orkeon.d.ts" />
|
|
2
|
+
// The tools Orkeon Code defines itself, built with the runtime's toolBuilder and attached to an
|
|
3
|
+
// agent with `withAutonomousTool` (never named in `.tools([...])`): run_validation for the auditor,
|
|
4
|
+
// run_tests and run_build for a writing role. The host gate is asked once per model call, from the
|
|
5
|
+
// access each declares (permission.ts SCRIPT_TOOLS: undeclared would be a write); the shell
|
|
6
|
+
// commands the body runs are not asked again, so each body runs the guard chain first
|
|
7
|
+
// (application/dev/wrapped-tools.ts, dev-verify's audit.ts). A body never throws to the model:
|
|
8
|
+
// a throw comes back as `{ok: false, refused}`, the tool's result.
|
|
9
|
+
//
|
|
10
|
+
// A crew builds its tools before its agent's body runs, and the body is where the pack and the
|
|
11
|
+
// step's rules are known: each tool reads what it calls from a slot the body fills (bind), and
|
|
12
|
+
// refuses while the slot is empty. A slot belongs to the crew script that built it; the body releases
|
|
13
|
+
// it when its run ends. Two runs of one crew bound at once would mix their calls, so the slot then
|
|
14
|
+
// refuses until one of them releases it.
|
|
15
|
+
//
|
|
16
|
+
// Given a batch's working root (a parallel /dev-batches), a tool's input comes back from the root to the logical
|
|
17
|
+
// `/workspace` its body names, and its result goes out with each `/workspace` path on the root: the model, held to
|
|
18
|
+
// its root, is never handed a path it may not touch (shared/domain/dev/path-rebase.ts).
|
|
19
|
+
|
|
20
|
+
import { scriptToolAccess } from "../../domain/agent-policy/permission.ts";
|
|
21
|
+
import { mapStrings, textFromRoot, textToRoot } from "../../domain/dev/path-rebase.ts";
|
|
22
|
+
import type { WrappedRun, WrappedTools } from "../../application/dev/wrapped-tools.ts";
|
|
23
|
+
import type { ScriptToolSlot } from "../../application/dev/script-tool-slot.ts";
|
|
24
|
+
|
|
25
|
+
export { scriptToolSlot } from "../../application/dev/script-tool-slot.ts";
|
|
26
|
+
export type { ScriptToolSlot } from "../../application/dev/script-tool-slot.ts";
|
|
27
|
+
|
|
28
|
+
/** The runtime's `toolBuilder`, or a test's. */
|
|
29
|
+
export type ToolBuilderFactory = () => ToolBuilder<unknown, unknown>;
|
|
30
|
+
|
|
31
|
+
export interface ScriptToolSpec {
|
|
32
|
+
/** One of SCRIPT_TOOLS: its access comes from there. */
|
|
33
|
+
name: string;
|
|
34
|
+
description: string;
|
|
35
|
+
schema: JsonSchema;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
const firstLine = (error: unknown): string => (error instanceof Error ? error.message : String(error)).split("\n")[0];
|
|
39
|
+
|
|
40
|
+
/** The tool `spec` describes, its body `handler`; a throw of the handler is the tool's refusal. Under `root`,
|
|
41
|
+
* the input is read back on `/workspace` and the result's paths go out on the root. */
|
|
42
|
+
export function scriptTool(
|
|
43
|
+
builder: ToolBuilderFactory, spec: ScriptToolSpec, handler: (input: unknown) => Promise<unknown>, root?: string,
|
|
44
|
+
): Tool<unknown, unknown> {
|
|
45
|
+
const access = scriptToolAccess(spec.name);
|
|
46
|
+
if (access === undefined) throw new Error(`'${spec.name}' is not one of Orkeon Code's tools (SCRIPT_TOOLS)`);
|
|
47
|
+
return builder()
|
|
48
|
+
.name(spec.name)
|
|
49
|
+
.description(spec.description)
|
|
50
|
+
.withSchema(spec.schema)
|
|
51
|
+
.access(access)
|
|
52
|
+
.execute(async (input: unknown) => {
|
|
53
|
+
try {
|
|
54
|
+
const result = await handler(mapStrings(input, (t) => textFromRoot(t, root)));
|
|
55
|
+
return mapStrings(result, (t) => textToRoot(t, root));
|
|
56
|
+
} catch (error) {
|
|
57
|
+
return { ok: false, refused: `${spec.name} failed: ${firstLine(error)}` };
|
|
58
|
+
}
|
|
59
|
+
})
|
|
60
|
+
.build();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const notReady = (name: string) => ({
|
|
64
|
+
ok: false, refused: `${name} is not set up for this run (not bound yet, or two runs at once): name the command in your answer instead`,
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
const commandSchema = (what: string): JsonSchema => ({
|
|
68
|
+
type: "object",
|
|
69
|
+
properties: { command: { type: "string", description: what } },
|
|
70
|
+
required: ["command"],
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
/** What run_validation calls: dev-verify's recording runner (audit.ts), seen by its shape. */
|
|
74
|
+
export interface ValidationCalls {
|
|
75
|
+
run(command: string): Promise<{ report: { command: string; outcome: string; tail: string }; line: string | null }>;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
export const RUN_VALIDATION: ScriptToolSpec = {
|
|
79
|
+
name: "run_validation",
|
|
80
|
+
description:
|
|
81
|
+
"Run one narrow test command of the repository pack (one test class, one test project, or the integration " +
|
|
82
|
+
"tests narrowed by a filter, exactly as the brief lists them, each <placeholder> filled with one plain value) " +
|
|
83
|
+
"and return its exit code and the tail of its output. Three per audit at most; never a whole suite, a build or " +
|
|
84
|
+
"an option of your own.",
|
|
85
|
+
schema: commandSchema("The command, one of the brief's validation commands with its placeholders filled."),
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
export function runValidationTool(builder: ToolBuilderFactory, slot: ScriptToolSlot<ValidationCalls>, root?: string): Tool<unknown, unknown> {
|
|
89
|
+
return scriptTool(builder, RUN_VALIDATION, async (input) => {
|
|
90
|
+
const runner = slot.get();
|
|
91
|
+
if (runner === undefined) return notReady(RUN_VALIDATION.name);
|
|
92
|
+
const command = (input as { command?: unknown } | null)?.command;
|
|
93
|
+
if (typeof command !== "string" || command.trim() === "") return { ok: false, refused: "'command' is required" };
|
|
94
|
+
const { report, line } = await runner.run(command);
|
|
95
|
+
return { ok: line !== null, command: report.command, outcome: report.outcome, tail: report.tail };
|
|
96
|
+
}, root);
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
export const RUN_TESTS: ScriptToolSpec = {
|
|
100
|
+
name: "run_tests",
|
|
101
|
+
description:
|
|
102
|
+
"Run one narrow test command of the repository pack (test_class, test_project, or test_integration with its " +
|
|
103
|
+
"filter), each <placeholder> filled with one plain relative value. Returns the exit code, the tail of the output " +
|
|
104
|
+
"and the path of the whole log. Never a whole suite, never a restore.",
|
|
105
|
+
schema: commandSchema("The pack's test command with its placeholders filled."),
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
export const RUN_BUILD: ScriptToolSpec = {
|
|
109
|
+
name: "run_build",
|
|
110
|
+
description:
|
|
111
|
+
"Build with the repository pack's command: without project, commands.build; with project, commands.build_test " +
|
|
112
|
+
"for that test project. Never restores, except once on a tree that was never restored. Returns the exit code, " +
|
|
113
|
+
"whether it restored, the tail of the output and the path of the whole log.",
|
|
114
|
+
schema: {
|
|
115
|
+
type: "object",
|
|
116
|
+
properties: { project: { type: "string", description: "The test project to build, a plain relative path; absent, the whole build." } },
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
function wrapped(
|
|
121
|
+
builder: ToolBuilderFactory, spec: ScriptToolSpec, slot: ScriptToolSlot<WrappedTools>,
|
|
122
|
+
call: (tools: WrappedTools, input: unknown) => Promise<WrappedRun>, root?: string,
|
|
123
|
+
): Tool<unknown, unknown> {
|
|
124
|
+
return scriptTool(builder, spec, async (input) => {
|
|
125
|
+
const tools = slot.get();
|
|
126
|
+
return tools === undefined ? notReady(spec.name) : call(tools, input);
|
|
127
|
+
}, root);
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
export const runTestsTool = (builder: ToolBuilderFactory, slot: ScriptToolSlot<WrappedTools>, root?: string): Tool<unknown, unknown> =>
|
|
131
|
+
wrapped(builder, RUN_TESTS, slot, (tools, input) => tools.runTests(input), root);
|
|
132
|
+
|
|
133
|
+
export const runBuildTool = (builder: ToolBuilderFactory, slot: ScriptToolSlot<WrappedTools>, root?: string): Tool<unknown, unknown> =>
|
|
134
|
+
wrapped(builder, RUN_BUILD, slot, (tools, input) => tools.runBuild(input), root);
|
|
@@ -0,0 +1,138 @@
|
|
|
1
|
+
// Session adapter over session_store (buffer, state bag and title), session_snip
|
|
2
|
+
// and token_budget.
|
|
3
|
+
// The runtime hands back either casing (`messages` or `Messages`, `role` or
|
|
4
|
+
// `Role`...); this is the one place that reads them. A failed read is rethrown with
|
|
5
|
+
// the tool's own message, the runtime's wrapping gone (withToolMessage).
|
|
6
|
+
|
|
7
|
+
import type { SessionMsg } from "../../domain/types.ts";
|
|
8
|
+
import { messagesOfLastTurns } from "../../domain/snip-turns.ts";
|
|
9
|
+
import type { SessionStore, StoredMessage, TokenBudget, TokenKinds } from "../../application/ports.ts";
|
|
10
|
+
import type { SessionStoreInput } from "./runtime-tools.ts";
|
|
11
|
+
import { asArray, pick, withToolMessage } from "./tool-results.ts";
|
|
12
|
+
|
|
13
|
+
/** The `{ role, content }` view of stored entries, for transcripts and history. */
|
|
14
|
+
function normalizeMessages(stored: StoredMessage[]): SessionMsg[] {
|
|
15
|
+
return stored.map((m) => ({
|
|
16
|
+
role: String(pick(m, "role", "Role") ?? ""),
|
|
17
|
+
content: String(pick(m, "content", "Content") ?? ""),
|
|
18
|
+
}));
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** What a runtime before Orkeon #263 (the rc.6 release) throws for append_message: its session_store answers an
|
|
22
|
+
* unknown operation `{ success: false }` with no error, which the tool binding reports as
|
|
23
|
+
* `tools.sessionStore failed: (no error message provided)`. */
|
|
24
|
+
const UNKNOWN_OPERATION = "(no error message provided)";
|
|
25
|
+
|
|
26
|
+
function isUnknownOperation(error: unknown): boolean {
|
|
27
|
+
return (error instanceof Error ? error.message : String(error)).includes(UNKNOWN_OPERATION);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Whether session_snip counts turns (Orkeon #287). It came in the same merge as edge_list (#281), which the rc.6
|
|
31
|
+
* release, the tool and docker modes, lacks: there `retain_count` counts the messages kept after the head. A runtime
|
|
32
|
+
* at the pin with no code-index tools registered reads as a release, and keeps more turns than asked, never fewer. */
|
|
33
|
+
function snipCountsTurns(tools: { edgeList?: unknown }): boolean {
|
|
34
|
+
return typeof tools.edgeList === "function";
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** A reported count, as a number; absent reads as 0. */
|
|
38
|
+
const count = (r: unknown, ...names: string[]): number => Number(pick(r, ...names) ?? 0);
|
|
39
|
+
|
|
40
|
+
export function createSessionStore(
|
|
41
|
+
tools: Pick<OrkeonTools, "sessionStore" | "sessionSnip" | "tokenBudget"> & { edgeList?: unknown },
|
|
42
|
+
): SessionStore {
|
|
43
|
+
// One shape per operation (runtime-tools.ts): a misspelled operation fails here.
|
|
44
|
+
const sessionStore = (input: SessionStoreInput) => tools.sessionStore(input);
|
|
45
|
+
// Set at the first append_message the runtime does not know: the next appends read and rewrite the buffer at once.
|
|
46
|
+
let appendMissing = false;
|
|
47
|
+
return {
|
|
48
|
+
async readMessages() {
|
|
49
|
+
const resp = await withToolMessage(() => sessionStore({ operation: "read_messages" }));
|
|
50
|
+
// A buffer that is not a list holds no message: the compaction skips it and
|
|
51
|
+
// the commands show an empty session, rather than failing on it.
|
|
52
|
+
const stored: StoredMessage[] = asArray(pick(resp, "messages", "Messages"));
|
|
53
|
+
return { stored, messages: normalizeMessages(stored) };
|
|
54
|
+
},
|
|
55
|
+
async writeMessages(messages) {
|
|
56
|
+
await sessionStore({ operation: "write_messages", messages });
|
|
57
|
+
},
|
|
58
|
+
async appendMessage(role, content) {
|
|
59
|
+
if (!appendMissing) {
|
|
60
|
+
let resp: unknown;
|
|
61
|
+
try {
|
|
62
|
+
resp = await sessionStore({ operation: "append_message", role, content });
|
|
63
|
+
} catch (e) {
|
|
64
|
+
// A blank role is refused by every runtime, and any failure but an unknown operation's is the store's own:
|
|
65
|
+
// both are rethrown, never hidden behind a rewrite of the buffer.
|
|
66
|
+
if (role.trim() === "" || !isUnknownOperation(e)) throw e;
|
|
67
|
+
appendMissing = true;
|
|
68
|
+
}
|
|
69
|
+
if (!appendMissing) {
|
|
70
|
+
// A refused append (a blank role) says so, as a failed write would.
|
|
71
|
+
if (pick(resp, "success", "Success") === false) throw new Error(`session_store refused to append a '${role}' message`);
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
// A runtime before Orkeon #263 (the rc.6 release, the tool and docker modes) has no append_message: the message is
|
|
76
|
+
// added by reading and rewriting the buffer, as before #263, and this store does not ask for append_message again.
|
|
77
|
+
if (role.trim() === "") throw new Error(`session_store refused to append a '${role}' message`);
|
|
78
|
+
const stored = asArray(pick(await sessionStore({ operation: "read_messages" }), "messages", "Messages"));
|
|
79
|
+
await sessionStore({ operation: "write_messages", messages: [...stored, { role, content }] });
|
|
80
|
+
},
|
|
81
|
+
async reset() {
|
|
82
|
+
return count(await sessionStore({ operation: "reset" }), "removed_count", "removedCount", "RemovedCount");
|
|
83
|
+
},
|
|
84
|
+
async snip(turns) {
|
|
85
|
+
// retain_count counts turns since Orkeon #287; kept_from (where the kept tail began) is not read: nothing uses it.
|
|
86
|
+
// Before #287 it counts messages: the tail those turns hold is measured on the buffer, so the same tail is kept.
|
|
87
|
+
let retain = turns;
|
|
88
|
+
if (!snipCountsTurns(tools)) {
|
|
89
|
+
const stored = asArray(pick(await withToolMessage(() => sessionStore({ operation: "read_messages" })), "messages", "Messages"));
|
|
90
|
+
const tail = messagesOfLastTurns(normalizeMessages(stored), turns);
|
|
91
|
+
if (tail === null) return { removed: 0, retained: stored.length };
|
|
92
|
+
retain = tail;
|
|
93
|
+
}
|
|
94
|
+
const resp = await tools.sessionSnip({ retain_count: retain });
|
|
95
|
+
return {
|
|
96
|
+
removed: count(resp, "removed_count", "removedCount", "RemovedCount"),
|
|
97
|
+
retained: count(resp, "retained_count", "retainedCount", "RetainedCount"),
|
|
98
|
+
};
|
|
99
|
+
},
|
|
100
|
+
async setTitle(title) {
|
|
101
|
+
await sessionStore({ operation: "set_title", title });
|
|
102
|
+
},
|
|
103
|
+
async readState(key) {
|
|
104
|
+
const resp = await withToolMessage(() => sessionStore({ operation: "get_state", key }));
|
|
105
|
+
const v = pick(resp, "value", "Value");
|
|
106
|
+
return v == null ? null : String(v);
|
|
107
|
+
},
|
|
108
|
+
async readStates(keys) {
|
|
109
|
+
if (keys.length === 0) return {};
|
|
110
|
+
const resp = await withToolMessage(() => sessionStore({ operation: "get_state", keys }));
|
|
111
|
+
// A key never set is absent from `values` (the tool pipeline drops nulls): null here.
|
|
112
|
+
const values = pick(resp, "values", "Values");
|
|
113
|
+
const out: Record<string, string | null> = {};
|
|
114
|
+
for (const key of keys) {
|
|
115
|
+
const v = values !== null && typeof values === "object" ? (values as Record<string, unknown>)[key] : undefined;
|
|
116
|
+
out[key] = v == null ? null : String(v);
|
|
117
|
+
}
|
|
118
|
+
return out;
|
|
119
|
+
},
|
|
120
|
+
async writeState(key, value) {
|
|
121
|
+
await sessionStore({ operation: "set_state", key, value });
|
|
122
|
+
},
|
|
123
|
+
async readBudget() {
|
|
124
|
+
const b = await tools.tokenBudget();
|
|
125
|
+
const budget: TokenBudget = {
|
|
126
|
+
used: count(b, "used_tokens", "usedTokens"),
|
|
127
|
+
window: count(b, "context_window_tokens", "contextWindowTokens"),
|
|
128
|
+
};
|
|
129
|
+
// By kind since Orkeon #226; an older host reports none.
|
|
130
|
+
const kinds = pick(b, "used_tokens_by_kind", "usedTokensByKind");
|
|
131
|
+
if (kinds !== undefined && kinds !== null && typeof kinds === "object") {
|
|
132
|
+
const kind = (name: keyof TokenKinds) => count(kinds, name, name[0].toUpperCase() + name.slice(1));
|
|
133
|
+
budget.byKind = { system: kind("system"), user: kind("user"), assistant: kind("assistant"), tool: kind("tool"), other: kind("other") };
|
|
134
|
+
}
|
|
135
|
+
return budget;
|
|
136
|
+
},
|
|
137
|
+
};
|
|
138
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// SessionSwitch adapter over the command context's `session` service (Orkeon #227): the session
|
|
2
|
+
// saved now, a saved one loaded in place. The service is there while orkeon-repl persists the session
|
|
3
|
+
// per project (Orkeon:Cli:Session:Persist, its default); a host without it leaves the reader nothing to
|
|
4
|
+
// hand out, and /resume says so. Reached through the service locator each command receives.
|
|
5
|
+
|
|
6
|
+
import type { SessionSwitch } from "../../application/ports.ts";
|
|
7
|
+
import type { SessionFacade, ServiceLocator } from "../../../commands/.orkeon/orkeon-cli.d.ts";
|
|
8
|
+
|
|
9
|
+
/** The service name; orkeon-repl registers it while the session is persisted. */
|
|
10
|
+
const SESSION = "session";
|
|
11
|
+
|
|
12
|
+
export function createSessionSwitch(services: Pick<ServiceLocator, "get" | "has">): SessionSwitch | undefined {
|
|
13
|
+
if (!services.has(SESSION)) return undefined;
|
|
14
|
+
const facade = services.get<SessionFacade>(SESSION);
|
|
15
|
+
return {
|
|
16
|
+
async save(path?: string) {
|
|
17
|
+
return String(await (path === undefined ? facade.save() : facade.save(path)));
|
|
18
|
+
},
|
|
19
|
+
async load(path: string) {
|
|
20
|
+
return Number(await facade.load(path));
|
|
21
|
+
},
|
|
22
|
+
};
|
|
23
|
+
}
|