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,59 @@
|
|
|
1
|
+
// What a model takes for reasoning and what becomes of an effort asked, as the runtime judges them (Orkeon #359,
|
|
2
|
+
// #360): the capability table of the host, the provider's own levels, the model's entry. Nothing here repeats that
|
|
3
|
+
// rule: these are the shapes the runtime answers with, read from whatever object it hands over. Pure.
|
|
4
|
+
import { isEffortLevel } from "./behavior-flags.ts";
|
|
5
|
+
import type { EffortLevel } from "./behavior-flags.ts";
|
|
6
|
+
|
|
7
|
+
/** What the session's turns run on: the session's `llm.profile`, else the /model override, else the host's own
|
|
8
|
+
* model. A profile wins over the model, as it does in the main loop. */
|
|
9
|
+
export interface ReasoningTarget {
|
|
10
|
+
profile: string | null;
|
|
11
|
+
model: string;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/** What a provider and one of its models take for reasoning. */
|
|
15
|
+
export interface ReasoningCapabilities {
|
|
16
|
+
model: string;
|
|
17
|
+
/** Whether the capability table knows the model; when it does not, an effort is sent unchecked. */
|
|
18
|
+
known: boolean;
|
|
19
|
+
/** The levels sent as asked, in order; empty when the model takes no effort. */
|
|
20
|
+
efforts: readonly EffortLevel[];
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export const EFFORT_NOTICES = ["lowered", "dropped", "unchecked"] as const;
|
|
24
|
+
export type EffortNotice = (typeof EFFORT_NOTICES)[number];
|
|
25
|
+
|
|
26
|
+
/** What the runtime does with an effort asked. */
|
|
27
|
+
export interface EffortReport {
|
|
28
|
+
model: string;
|
|
29
|
+
asked: EffortLevel;
|
|
30
|
+
/** What the provider receives; null when no effort goes out. */
|
|
31
|
+
sent: string | null;
|
|
32
|
+
/** Null when the effort goes as asked on a model the table knows. */
|
|
33
|
+
notice: EffortNotice | null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function fieldsOf(raw: unknown): Record<string, unknown> | null {
|
|
37
|
+
return raw !== null && typeof raw === "object" ? (raw as Record<string, unknown>) : null;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** The capabilities the runtime answered; null when it answered none, or something that names no model. */
|
|
41
|
+
export function capabilitiesOf(raw: unknown): ReasoningCapabilities | null {
|
|
42
|
+
const fields = fieldsOf(raw);
|
|
43
|
+
if (fields === null || typeof fields.model !== "string") return null;
|
|
44
|
+
const efforts = Array.isArray(fields.efforts) ? fields.efforts.filter((level): level is EffortLevel => isEffortLevel(level)) : [];
|
|
45
|
+
return { model: fields.model, known: fields.known === true, efforts };
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** The report the runtime answered; null when it answered none (no effort asked, no provider), or one whose asked
|
|
49
|
+
* level is not a level. */
|
|
50
|
+
export function effortReportOf(raw: unknown): EffortReport | null {
|
|
51
|
+
const fields = fieldsOf(raw);
|
|
52
|
+
if (fields === null || typeof fields.model !== "string" || !isEffortLevel(fields.asked)) return null;
|
|
53
|
+
return {
|
|
54
|
+
model: fields.model,
|
|
55
|
+
asked: fields.asked,
|
|
56
|
+
sent: typeof fields.sent === "string" ? fields.sent : null,
|
|
57
|
+
notice: EFFORT_NOTICES.find((notice) => notice === fields.notice) ?? null,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
@@ -0,0 +1,416 @@
|
|
|
1
|
+
// The rule sets Orkeon Code ships — pure data, no IO. Each set is a list of deny rules in the
|
|
2
|
+
// /permissions syntax, handed to the host gate by the commands that run a dev step
|
|
3
|
+
// (shared/domain/dev/step-rules.ts says which step gets which set), and checked again by the dev crews'
|
|
4
|
+
// onToolCall (shared/domain/dev/call-guard.ts), the only check of them under `orkeon run`. Both see the
|
|
5
|
+
// model's calls only; a call made from Orkeon Code's own code is not checked (docs/permissions.md).
|
|
6
|
+
// Every rule here names an argument but the whole-tool denies of the writing tools whose paths sit in an
|
|
7
|
+
// array the gate cannot read (UNSCOPED_WRITE_TOOLS): those remove their tool from the catalogue. edit_batch is
|
|
8
|
+
// not one of them: the crews' callback checks each of its operations as the editor it stands for (call-guard.ts).
|
|
9
|
+
|
|
10
|
+
import { gateLine, sameCalls } from "./permission.ts";
|
|
11
|
+
import type { PermissionRule } from "./permission.ts";
|
|
12
|
+
import { WORKSPACE, workspaceRelative } from "../vfs.ts";
|
|
13
|
+
import {
|
|
14
|
+
GIT_READONLY_TITLE, INLINE_INTERPRETERS_TITLE, patternClimbsOut, patternOutside, patternWholeProject,
|
|
15
|
+
READ_NOISE_TITLE, rootClimbsOut, rootHoldsStar, rootOutside, rootWholeProject, SECRETS_TITLE, STATE_FILES_TITLE,
|
|
16
|
+
} from "./messages.ts";
|
|
17
|
+
|
|
18
|
+
export type RuleSetId = "git-readonly" | "inline-interpreters" | "read-noise" | "secrets" | "state-files";
|
|
19
|
+
|
|
20
|
+
export interface RuleSet {
|
|
21
|
+
id: RuleSetId;
|
|
22
|
+
/** One line, for /permissions and the docs. */
|
|
23
|
+
title: string;
|
|
24
|
+
rules: readonly PermissionRule[];
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/** Every set, in this order (listing order, step order). */
|
|
28
|
+
export const RULE_SET_IDS: readonly RuleSetId[] = [
|
|
29
|
+
"git-readonly", "inline-interpreters", "read-noise", "secrets", "state-files",
|
|
30
|
+
];
|
|
31
|
+
|
|
32
|
+
/** A git verb that changes the repository; `bareLists` when the verb alone only lists (git branch, git tag);
|
|
33
|
+
* `subcommands` when only some of its subcommands change something (git stash pop, git remote add), so that
|
|
34
|
+
* the listing ones (git stash list, git remote -v) still run. */
|
|
35
|
+
export interface GitVerb { verb: string; bareLists: boolean; subcommands?: readonly string[] }
|
|
36
|
+
|
|
37
|
+
const LISTING_VERBS = new Set(["branch", "notes", "reflog", "remote", "replace", "submodule", "tag"]);
|
|
38
|
+
const VERB_SUBCOMMANDS: Readonly<Record<string, readonly string[]>> = {
|
|
39
|
+
// The options and subcommands that change the file. A key then a value (git config user.name x) sets one too,
|
|
40
|
+
// but a glob cannot tell it from a read whose file name holds a dot (git config --file a.cfg --list): the code
|
|
41
|
+
// reads that one (gitConfigSets). `--get a.b`, `-l`, `a.b` alone and `get` only read.
|
|
42
|
+
config: [
|
|
43
|
+
"--add", "--unset", "--replace-all", "--rename-section", "--remove-section", "--edit", "-e",
|
|
44
|
+
"set", "unset", "rename-section", "remove-section", "edit",
|
|
45
|
+
],
|
|
46
|
+
remote: ["add", "remove", "rm", "rename", "set-url", "set-head", "set-branches", "prune", "update"],
|
|
47
|
+
// `-*`: a push given by its options alone (git stash -u).
|
|
48
|
+
stash: ["push", "pop", "apply", "drop", "clear", "save", "store", "branch", "-*"],
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
export const GIT_MUTATING_VERBS: readonly GitVerb[] = [
|
|
52
|
+
"add", "am", "apply", "branch", "checkout", "checkout-index", "cherry-pick", "clean", "clone", "commit",
|
|
53
|
+
"commit-tree", "config", "fast-import", "fetch", "filter-branch", "gc", "init", "maintenance", "merge", "mktag",
|
|
54
|
+
"mktree", "mv", "notes", "prune", "pull", "push", "read-tree", "rebase", "reflog", "remote", "repack", "replace",
|
|
55
|
+
"reset", "restore", "revert", "rm", "stash", "submodule", "switch", "symbolic-ref", "tag", "update-index",
|
|
56
|
+
"update-ref", "update-server-info", "worktree", "write-tree",
|
|
57
|
+
].map((verb) => {
|
|
58
|
+
const subcommands = VERB_SUBCOMMANDS[verb];
|
|
59
|
+
const entry: GitVerb = { verb, bareLists: LISTING_VERBS.has(verb) };
|
|
60
|
+
return subcommands === undefined ? entry : { ...entry, subcommands };
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
/** The git global options that take the next word as their value (`git -C /x config`). */
|
|
64
|
+
const GIT_VALUE_OPTIONS = new Set(["-C", "-c", "--git-dir", "--work-tree", "--namespace", "--super-prefix", "--config-env", "--exec-path"]);
|
|
65
|
+
/** The git config options that take the next word as their value (`--file a.cfg`). */
|
|
66
|
+
const CONFIG_VALUE_OPTIONS = new Set(["-f", "--file", "--blob", "-t", "--type", "--default", "--comment", "--value"]);
|
|
67
|
+
/** The git config actions that only read; `get` and `list` are the subcommand forms. */
|
|
68
|
+
const CONFIG_READS = /^(--get(-all|-regexp|-urlmatch|-color|-colorbool)?|--list|-l|get|list)$/;
|
|
69
|
+
/** The git config options and subcommands that change the file, wherever they stand after `config`. */
|
|
70
|
+
const CONFIG_WRITES = /^(--add|--unset(-all)?|--replace-all|--rename-section|--remove-section|--edit|-e|set|unset|rename-section|remove-section|edit)$/;
|
|
71
|
+
/** The characters that start another command outside quotes: a chain, a pipe, a subshell, a group, a substitution. */
|
|
72
|
+
const COMMAND_BREAKS = new Set([";", "&", "|", "(", ")", "`", "{", "}", "\n"]);
|
|
73
|
+
|
|
74
|
+
/** What deny rule a git config that sets a value stands under, in a refusal: no gate pattern holds it. */
|
|
75
|
+
export const GIT_CONFIG_SET_RULE: PermissionRule = {
|
|
76
|
+
effect: "deny", tool: "shell_command", argument: "command", pattern: "*git config <key> <value>*",
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
/** The rule of git-readonly the code's reading of git config goes with: a list of rules that holds it holds the set. */
|
|
80
|
+
const GIT_CONFIG_ADD_PATTERN = "*git config --add*";
|
|
81
|
+
|
|
82
|
+
/** Whether these rules hold git-readonly, whose git config reading is the code's (gitConfigSets). */
|
|
83
|
+
export function holdsGitReadonly(rules: readonly PermissionRule[]): boolean {
|
|
84
|
+
return rules.some((r) => r.effect === "deny" && r.tool === "shell_command" && r.pattern === GIT_CONFIG_ADD_PATTERN);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
/**
|
|
88
|
+
* The commands of a shell line, each as the words its program receives: quotes dropped, backslash escapes resolved,
|
|
89
|
+
* a new command at each break outside single quotes (`;`, `&`, `|`, `(`, `)`, `{`, `}`, a backtick, a line break; a
|
|
90
|
+
* `$(` or a backtick inside double quotes too). A quoted value keeps its breaks (`';evil'` stays one word), and a word
|
|
91
|
+
* that holds a blank is read again as a line of its own (`eval 'git config a b'`): more commands, never fewer.
|
|
92
|
+
*/
|
|
93
|
+
function shellCommandsOf(line: string, depth = 0): string[][] {
|
|
94
|
+
const commands: string[][] = [[]];
|
|
95
|
+
let word = "";
|
|
96
|
+
let quoted = false;
|
|
97
|
+
let quote: "'" | "\"" | null = null;
|
|
98
|
+
const end = (): void => {
|
|
99
|
+
if (word !== "" || quoted) commands[commands.length - 1].push(word);
|
|
100
|
+
word = "";
|
|
101
|
+
quoted = false;
|
|
102
|
+
};
|
|
103
|
+
const breakHere = (): void => { end(); commands.push([]); };
|
|
104
|
+
for (let i = 0; i < line.length; i++) {
|
|
105
|
+
const c = line[i];
|
|
106
|
+
if (quote === "'") { if (c === "'") quote = null; else word += c; continue; }
|
|
107
|
+
if (c === "\\" && i + 1 < line.length) { word += line[++i]; continue; }
|
|
108
|
+
if (quote === "\"") {
|
|
109
|
+
if (c === "\"") quote = null;
|
|
110
|
+
else if (c === "$" && line[i + 1] === "(") { breakHere(); i++; }
|
|
111
|
+
else if (c === "`" || c === ")") breakHere();
|
|
112
|
+
else word += c;
|
|
113
|
+
continue;
|
|
114
|
+
}
|
|
115
|
+
if (c === "'" || c === "\"") { quote = c; quoted = true; continue; }
|
|
116
|
+
if (/\s/.test(c) && c !== "\n") { end(); continue; }
|
|
117
|
+
if (COMMAND_BREAKS.has(c)) { breakHere(); continue; }
|
|
118
|
+
word += c;
|
|
119
|
+
}
|
|
120
|
+
end();
|
|
121
|
+
const nested = depth >= 3 ? [] : commands.flat().filter((w) => /\s/.test(w)).flatMap((w) => shellCommandsOf(w, depth + 1));
|
|
122
|
+
return [...commands.filter((c) => c.length > 0), ...nested];
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Whether one of the commands of a shell line is a git config that changes the file: a changing option or
|
|
127
|
+
* subcommand anywhere after `config` (git config --global --unset a.b), or two words or more after its options
|
|
128
|
+
* with no reading action before them (git config user.name x, whatever file `--file` names). `git config --file
|
|
129
|
+
* a.cfg --list` and `git config a.b` read. The gate's own patterns hold the changing options right after `config`,
|
|
130
|
+
* and `git -c`. Each command of a chain, a subshell, a group or a substitution is read apart (shellCommandsOf).
|
|
131
|
+
*/
|
|
132
|
+
export function gitConfigSets(command: string): boolean {
|
|
133
|
+
return shellCommandsOf(command).some(configSets);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
/** Whether a command's words, from any `git` among them (`env git`, `/usr/bin/git`, `xargs git`), run a git config
|
|
137
|
+
* that changes the file. */
|
|
138
|
+
function configSets(words: readonly string[]): boolean {
|
|
139
|
+
return words.some((w, i) => (w === "git" || w.endsWith("/git")) && gitConfigWrites(words, i + 1));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
function gitConfigWrites(words: readonly string[], from: number): boolean {
|
|
143
|
+
let at = from;
|
|
144
|
+
for (; at < words.length && words[at].startsWith("-"); at++) {
|
|
145
|
+
if (GIT_VALUE_OPTIONS.has(words[at])) at++;
|
|
146
|
+
}
|
|
147
|
+
if (words[at] !== "config") return false;
|
|
148
|
+
const positionals: string[] = [];
|
|
149
|
+
for (let i = at + 1; i < words.length; i++) {
|
|
150
|
+
const w = words[i];
|
|
151
|
+
if (CONFIG_WRITES.test(w) && (w.startsWith("-") || positionals.length === 0)) return true;
|
|
152
|
+
// A reading action counts before the key only: what follows a key may be read as its value.
|
|
153
|
+
if (positionals.length === 0 && CONFIG_READS.test(w)) return false;
|
|
154
|
+
if (CONFIG_VALUE_OPTIONS.has(w)) i++;
|
|
155
|
+
else if (!w.startsWith("-") || w === "-" || positionals.length > 0) positionals.push(w);
|
|
156
|
+
}
|
|
157
|
+
return positionals.length >= 2;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
/** A word and the same word with arguments after it; a word that already ends with `*` stands alone. */
|
|
161
|
+
function withArguments(head: string): string[] {
|
|
162
|
+
return head.endsWith("*") ? [head] : [head, `${head} *`];
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
/** The leads of every git pattern: `*` before the word admits a path, an `env`, an assignment or a chain
|
|
166
|
+
* (`/usr/bin/git`, `GIT_DIR=x git`, `cd x && git`); the gate's `*` also matches nothing (plain `git push`). */
|
|
167
|
+
const GIT_LEADS = ["*git", "*git *"] as const;
|
|
168
|
+
|
|
169
|
+
/** The patterns of one verb. Directly after `git`, the verb and whatever follows it are one prefix pattern
|
|
170
|
+
* (`*git push*`: `git push;`, `git push&&ls`, `git commit` then a line break), unless the verb alone only lists.
|
|
171
|
+
* Behind global options (`git -C /x …`) the verb is bounded by spaces, since `*git * am*` would also match
|
|
172
|
+
* `git log -- amend.md`. For a verb with subcommands, only those (and the bare verb when it changes something). */
|
|
173
|
+
function gitPatterns({ verb, bareLists, subcommands }: GitVerb): string[] {
|
|
174
|
+
const prefixed = (head: string): string => (head.endsWith("*") ? `*git ${head}` : `*git ${head}*`);
|
|
175
|
+
const bare = bareLists ? [] : [verb];
|
|
176
|
+
if (subcommands === undefined) {
|
|
177
|
+
const direct = bareLists ? `*git ${verb} *` : prefixed(verb);
|
|
178
|
+
return [direct, ...bare.map((v) => `*git * ${v}`), `*git * ${verb} *`];
|
|
179
|
+
}
|
|
180
|
+
const heads = subcommands.map((sub) => `${verb} ${sub}`);
|
|
181
|
+
return [
|
|
182
|
+
...bare.map((v) => `*git ${v}`), ...heads.map(prefixed),
|
|
183
|
+
...bare.map((v) => `*git * ${v}`), ...heads.flatMap((head) => withArguments(`*git * ${head}`)),
|
|
184
|
+
];
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function denyAll(tool: string, argument: string, patterns: readonly string[]): PermissionRule[] {
|
|
188
|
+
return patterns.map((pattern): PermissionRule => ({ effect: "deny", tool, argument, pattern }));
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/** The tools that read one file or folder named by `path`. */
|
|
192
|
+
export const PATH_READ_TOOLS: readonly string[] = [
|
|
193
|
+
"file_read", "glob", "grep", "node_outline", "node_read", "count_pattern", "documents_of", "directory_search",
|
|
194
|
+
];
|
|
195
|
+
/** The tools of PATH_READ_TOOLS whose `path` may name a folder, the denied root itself included. */
|
|
196
|
+
export const FOLDER_READ_TOOLS: readonly string[] = ["glob", "grep", "count_pattern", "directory_search"];
|
|
197
|
+
/** The reading tools that name no path the gate could match (a pattern over the project, a symbol's fqn): denied
|
|
198
|
+
* whole once a root is closed to reading. */
|
|
199
|
+
export const UNSCOPED_READ_TOOLS: readonly string[] = ["structural_search", "symbol_source"];
|
|
200
|
+
/** The tools that write one file named by `path`. */
|
|
201
|
+
export const PATH_WRITE_TOOLS: readonly string[] = ["file_write", "edit_file", "node_replace", "node_insert", "node_ensure"];
|
|
202
|
+
/** The written text of each writing tool that takes it as one string. */
|
|
203
|
+
export const WRITTEN_TEXT: ReadonlyArray<readonly [tool: string, argument: string]> = [
|
|
204
|
+
["file_write", "content"], ["edit_file", "new_string"], ["node_replace", "text"], ["node_insert", "text"],
|
|
205
|
+
["node_ensure", "text"], ["node_ensure", "name"], ["node_ensure", "module"], ["structural_rewrite", "fix"],
|
|
206
|
+
];
|
|
207
|
+
/** Writing tools whose paths sit in an array the gate reads as its type name, never an element: denied whole
|
|
208
|
+
* where paths are protected. */
|
|
209
|
+
export const UNSCOPED_WRITE_TOOLS: readonly string[] = ["structural_rewrite"];
|
|
210
|
+
/** The writing tool whose paths and texts sit in its `operations`: the gate cannot read them, the dev crews'
|
|
211
|
+
* callback reads each operation as the editor of OPERATION_TOOLS it stands for and applies the rules of that
|
|
212
|
+
* editor to it. Every call of it runs under that callback during a step, so no set denies it whole. */
|
|
213
|
+
export const OPERATIONS_TOOL = "edit_batch";
|
|
214
|
+
/** The editor each `kind` of an edit_batch operation stands for: the intent operations are node_ensure's. */
|
|
215
|
+
export const OPERATION_TOOLS: Readonly<Record<string, string>> = {
|
|
216
|
+
node_replace: "node_replace", node_insert: "node_insert",
|
|
217
|
+
ensure_using: "node_ensure", ensure_import: "node_ensure", ensure_field: "node_ensure", ensure_member: "node_ensure",
|
|
218
|
+
ensure_section: "node_ensure", insert_under_heading: "node_ensure", replace_mermaid: "node_ensure",
|
|
219
|
+
};
|
|
220
|
+
|
|
221
|
+
/** A deny on every call of each tool. */
|
|
222
|
+
export function denyWhole(tools: readonly string[]): PermissionRule[] {
|
|
223
|
+
return tools.map((tool): PermissionRule => ({ effect: "deny", tool }));
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
/** The same patterns on `argument` of each tool, tool by tool. */
|
|
227
|
+
/** The entries of `.orkeon/` that Orkeon Code's code or the runtime write, each as the start of a name: every one
|
|
228
|
+
* but `worktrees/`, where a parallel /dev-batches runs each batch, its writes those of a project (the state seeded
|
|
229
|
+
* in a worktree stays refused: its path holds `.orkeon/dev` again). A `*` spans `/`, so no pattern can refuse
|
|
230
|
+
* `.orkeon/*` and spare `worktrees/`: a new entry of the folder is named here. `*.orkeon/` covers the path in and
|
|
231
|
+
* out of the project's root. */
|
|
232
|
+
const STATE_ENTRIES: readonly string[] = [
|
|
233
|
+
"dev", "memory", "agent", "sessions", "hooks", "shared", "repo", "config", "state", "orkeon", "ORKEON_", "forge", "rag",
|
|
234
|
+
];
|
|
235
|
+
|
|
236
|
+
export function denyEach(tools: readonly string[], argument: string, patterns: readonly string[]): PermissionRule[] {
|
|
237
|
+
return tools.flatMap((tool) => denyAll(tool, argument, patterns));
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
export const RULE_SETS: Readonly<Record<RuleSetId, RuleSet>> = {
|
|
241
|
+
"git-readonly": {
|
|
242
|
+
id: "git-readonly",
|
|
243
|
+
title: GIT_READONLY_TITLE,
|
|
244
|
+
rules: denyAll("shell_command", "command", [
|
|
245
|
+
...GIT_MUTATING_VERBS.flatMap(gitPatterns),
|
|
246
|
+
// `-c key=value` sets a config for one command, and core.pager or core.sshCommand run a program.
|
|
247
|
+
...GIT_LEADS.map((lead) => `${lead} -c *`),
|
|
248
|
+
]),
|
|
249
|
+
},
|
|
250
|
+
"inline-interpreters": {
|
|
251
|
+
id: "inline-interpreters",
|
|
252
|
+
title: INLINE_INTERPRETERS_TITLE,
|
|
253
|
+
// `*sh -c*` covers bash, sh, zsh, dash, ksh and fish behind a path or an `env`; `*sh -*c *` a flag cluster
|
|
254
|
+
// (bash -xc), `*sh -* -c*` a flag before `-c`; the same for the other interpreters. `ssh -c <cipher>` is
|
|
255
|
+
// refused too, a side effect of matching any word ending with `sh`. `python3.*` names a versioned python
|
|
256
|
+
// (python3.12). The dev crews' callback also matches the command as the program receives it, quotes and
|
|
257
|
+
// repeated spaces gone and option clusters split (python3 -Ic, perl -we): shellCommandForms.
|
|
258
|
+
rules: denyAll("shell_command", "command", [
|
|
259
|
+
"*sh -c*", "*sh -*c *", "*sh -* -c*",
|
|
260
|
+
"*node -e*", "*node --eval*", "*node -p*", "*node --print*", "*node -* -e*", "*node -* -p*", "*node --input-type*",
|
|
261
|
+
"*python -c*", "*python3 -c*", "*python3.* -c*", "*python -* -c*", "*python3 -* -c*", "*python3.* -* -c*",
|
|
262
|
+
"*perl -e*", "*perl -E*", "*perl -* -e*", "*perl -* -E*", "*ruby -e*", "*ruby -* -e*", "*php -r*",
|
|
263
|
+
"*tsx -e*", "*tsx --eval*", "*ts-node -e*", "*deno eval*", "*bun -e*",
|
|
264
|
+
]),
|
|
265
|
+
},
|
|
266
|
+
"read-noise": {
|
|
267
|
+
id: "read-noise",
|
|
268
|
+
title: READ_NOISE_TITLE,
|
|
269
|
+
// Each folder twice: inside a path, and as the start of a path relative to the project.
|
|
270
|
+
rules: denyEach(PATH_READ_TOOLS, "path", [
|
|
271
|
+
"*/bin/*", "bin/*", "*/obj/*", "obj/*", "*/.git/*", ".git/*", "*/node_modules/*", "node_modules/*",
|
|
272
|
+
]),
|
|
273
|
+
},
|
|
274
|
+
secrets: {
|
|
275
|
+
id: "secrets",
|
|
276
|
+
title: SECRETS_TITLE,
|
|
277
|
+
// The prefixes of SECRET_PATTERNS (secret-patterns.ts) a whole-content pattern can hold without refusing
|
|
278
|
+
// ordinary text; the others need a check of the content itself. edit_batch's texts sit in its
|
|
279
|
+
// operations, which the crews' callback reads as node_replace, node_insert or node_ensure texts.
|
|
280
|
+
rules: WRITTEN_TEXT.flatMap(([tool, argument]) => denyAll(tool, argument, [
|
|
281
|
+
"*-----BEGIN *PRIVATE KEY-----*",
|
|
282
|
+
"*ghp_*", "*gho_*", "*ghu_*", "*ghs_*", "*ghr_*", "*github_pat_*",
|
|
283
|
+
"*xoxa-*", "*xoxb-*", "*xoxp-*", "*xoxo-*", "*xoxs-*", "*xoxr-*",
|
|
284
|
+
"*AKIA*",
|
|
285
|
+
"*AIza*",
|
|
286
|
+
"*sk-ant-*",
|
|
287
|
+
])),
|
|
288
|
+
},
|
|
289
|
+
"state-files": {
|
|
290
|
+
id: "state-files",
|
|
291
|
+
title: STATE_FILES_TITLE,
|
|
292
|
+
// Batch logs, batch states, verdicts and audit captures; the state folder's entries; the harness's deployed files.
|
|
293
|
+
rules: [
|
|
294
|
+
...denyEach(PATH_WRITE_TOOLS, "path", [
|
|
295
|
+
"*-BATCHES-STATE.md", "*-STATE-F*.md", "*-VERIFY-F*.md", "*/capture-F*/*",
|
|
296
|
+
...STATE_ENTRIES.map((entry) => `*.orkeon/${entry}*`), "*/.claude/*", ".claude/*",
|
|
297
|
+
]),
|
|
298
|
+
...denyWhole(UNSCOPED_WRITE_TOOLS),
|
|
299
|
+
],
|
|
300
|
+
},
|
|
301
|
+
};
|
|
302
|
+
|
|
303
|
+
/** The rules of `ids`, in that order, each set's in its own order; a rule on the same calls with the same
|
|
304
|
+
* effect as an earlier one is kept once. */
|
|
305
|
+
export function rulesOf(ids: readonly RuleSetId[]): PermissionRule[] {
|
|
306
|
+
const out: PermissionRule[] = [];
|
|
307
|
+
for (const rule of ids.flatMap((id) => RULE_SETS[id].rules)) {
|
|
308
|
+
if (!out.some((kept) => kept.effect === rule.effect && sameCalls(kept, rule))) out.push(rule);
|
|
309
|
+
}
|
|
310
|
+
return out;
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/** Deny rules on the folders `roots` for the tools of one access, and why a root got none. */
|
|
314
|
+
export interface PathRules { rules: PermissionRule[]; problems: string[] }
|
|
315
|
+
|
|
316
|
+
/** A root as a path relative to the project: no `/workspace/` or `./` in front, no `/` behind. */
|
|
317
|
+
function normaliseRoot(raw: string): string {
|
|
318
|
+
let root = raw.trim();
|
|
319
|
+
if (root === WORKSPACE) root = "";
|
|
320
|
+
root = workspaceRelative(root);
|
|
321
|
+
while (root.startsWith("./")) root = root.slice(2);
|
|
322
|
+
while (root.endsWith("/")) root = root.slice(0, -1);
|
|
323
|
+
return root;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
function rootProblem(raw: string, root: string): string | undefined {
|
|
327
|
+
if (root === "") return rootWholeProject(raw);
|
|
328
|
+
if (root.startsWith("/")) return rootOutside(raw, WORKSPACE);
|
|
329
|
+
if (root.split("/").includes("..")) return rootClimbsOut(raw);
|
|
330
|
+
if (root.includes("*")) return rootHoldsStar(raw);
|
|
331
|
+
return undefined;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
/** For each kept root, two rules (absolute, relative) per tool of PATH_READ_TOOLS or PATH_WRITE_TOOLS, and for
|
|
335
|
+
* `read` two more per tool of FOLDER_READ_TOOLS on the root itself (`<root>/*` does not match `<root>`); then,
|
|
336
|
+
* once a root is kept, a deny on the tools whose paths the gate cannot read: UNSCOPED_READ_TOOLS for `read`,
|
|
337
|
+
* UNSCOPED_WRITE_TOOLS for `write` (edit_batch's operations are checked one by one, as their editors). */
|
|
338
|
+
export function pathRules(access: "read" | "write", roots: readonly string[]): PathRules {
|
|
339
|
+
const tools = access === "read" ? PATH_READ_TOOLS : PATH_WRITE_TOOLS;
|
|
340
|
+
const rules: PermissionRule[] = [];
|
|
341
|
+
const problems: string[] = [];
|
|
342
|
+
const seen = new Set<string>();
|
|
343
|
+
for (const raw of roots) {
|
|
344
|
+
const root = normaliseRoot(raw);
|
|
345
|
+
const problem = rootProblem(raw, root);
|
|
346
|
+
if (problem !== undefined) {
|
|
347
|
+
problems.push(problem);
|
|
348
|
+
continue;
|
|
349
|
+
}
|
|
350
|
+
if (seen.has(root)) continue;
|
|
351
|
+
seen.add(root);
|
|
352
|
+
rules.push(...denyEach(tools, "path", [`${WORKSPACE}/${root}/*`, `${root}/*`]));
|
|
353
|
+
if (access === "read") rules.push(...denyEach(FOLDER_READ_TOOLS, "path", [`${WORKSPACE}/${root}`, root]));
|
|
354
|
+
}
|
|
355
|
+
if (seen.size > 0) rules.push(...denyWhole(access === "read" ? UNSCOPED_READ_TOOLS : UNSCOPED_WRITE_TOOLS));
|
|
356
|
+
return { rules, problems };
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
/** The tool the rewrite rule denies: a whole write of a file. */
|
|
360
|
+
export const REWRITE_TOOL = "file_write";
|
|
361
|
+
|
|
362
|
+
/** The rewrite rule of a writing role: `file_write` denied (absolute and relative) under every kept root and on every
|
|
363
|
+
* kept file pattern, so that an existing source file is changed by node or with edit_file, never written whole. The
|
|
364
|
+
* dev crews' callback lifts it for a file that does not exist yet (call-guard.ts): a new file is still created.
|
|
365
|
+
* What a root or a pattern gets no rule for is said by pathRules and patternWriteRules already. */
|
|
366
|
+
export function rewriteRules(roots: readonly string[], patterns: readonly string[]): PermissionRule[] {
|
|
367
|
+
const kept = new Set<string>();
|
|
368
|
+
for (const raw of roots) {
|
|
369
|
+
const root = normaliseRoot(raw);
|
|
370
|
+
if (rootProblem(raw, root) === undefined) kept.add(`${root}/*`);
|
|
371
|
+
}
|
|
372
|
+
for (const raw of patterns) {
|
|
373
|
+
const pattern = normaliseRoot(raw);
|
|
374
|
+
if (pattern !== "" && pattern !== "*" && !pattern.startsWith("/") && !pattern.split("/").includes("..")) kept.add(pattern);
|
|
375
|
+
}
|
|
376
|
+
return [...kept].flatMap((p) => denyAll(REWRITE_TOOL, "path", [`${WORKSPACE}/${p}`, p]));
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
/** Write denies on file patterns rather than folders (a pack's `layout.test_files`, `*` spanning folders): two rules
|
|
380
|
+
* (absolute, relative) per tool of PATH_WRITE_TOOLS for each kept pattern, then the deny on UNSCOPED_WRITE_TOOLS.
|
|
381
|
+
* A pattern that is empty, outside the project or climbing out with `..` gets no rule. */
|
|
382
|
+
export function patternWriteRules(patterns: readonly string[]): PathRules {
|
|
383
|
+
const rules: PermissionRule[] = [];
|
|
384
|
+
const problems: string[] = [];
|
|
385
|
+
const seen = new Set<string>();
|
|
386
|
+
for (const raw of patterns) {
|
|
387
|
+
const pattern = normaliseRoot(raw);
|
|
388
|
+
if (pattern === "" || pattern === "*") { problems.push(patternWholeProject(raw)); continue; }
|
|
389
|
+
if (pattern.startsWith("/")) { problems.push(patternOutside(raw, WORKSPACE)); continue; }
|
|
390
|
+
if (pattern.split("/").includes("..")) { problems.push(patternClimbsOut(raw)); continue; }
|
|
391
|
+
if (seen.has(pattern)) continue;
|
|
392
|
+
seen.add(pattern);
|
|
393
|
+
rules.push(...denyEach(PATH_WRITE_TOOLS, "path", [`${WORKSPACE}/${pattern}`, pattern]));
|
|
394
|
+
}
|
|
395
|
+
if (seen.size > 0) rules.push(...denyWhole(UNSCOPED_WRITE_TOOLS));
|
|
396
|
+
return { rules, problems };
|
|
397
|
+
}
|
|
398
|
+
|
|
399
|
+
/** The gate's lines that belong to a built-in set, counted per set (RULE_SET_IDS order, sets with
|
|
400
|
+
* count 0 left out), and the lines that belong to none, in their order. */
|
|
401
|
+
export interface HeldSets { sets: Array<{ id: RuleSetId; count: number }>; rest: string[] }
|
|
402
|
+
|
|
403
|
+
export function heldRuleSets(lines: readonly string[]): HeldSets {
|
|
404
|
+
const counts = new Map<RuleSetId, number>();
|
|
405
|
+
const rest: string[] = [];
|
|
406
|
+
for (const line of lines) {
|
|
407
|
+
const id = RULE_SET_IDS.find((set) => RULE_SETS[set].rules.some((rule) => gateLine(rule) === line));
|
|
408
|
+
if (id === undefined) rest.push(line);
|
|
409
|
+
else counts.set(id, (counts.get(id) ?? 0) + 1);
|
|
410
|
+
}
|
|
411
|
+
const sets = RULE_SET_IDS.flatMap((id) => {
|
|
412
|
+
const count = counts.get(id) ?? 0;
|
|
413
|
+
return count === 0 ? [] : [{ id, count }];
|
|
414
|
+
});
|
|
415
|
+
return { sets, rest };
|
|
416
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// The access a tool declares to Orkeon's permission gate for one call, where it depends on the arguments or
|
|
2
|
+
// differs from the class the catalogue files the tool under (Orkeon #219 and #223, `IBaseTool.AccessFor`): `github`
|
|
3
|
+
// reads for `list_issues`, `get_pr`, `search_repos` and `get_repo`, executes for `create_issue`, `create_pr` and an
|
|
4
|
+
// unknown or missing action; `http_api` reads for `GET`, `HEAD`, `OPTIONS` and a missing method, executes for any
|
|
5
|
+
// other method and for a read method that carries a body or a method-override header; `web_search` reads whatever
|
|
6
|
+
// the call; `firefox` reads for the actions that only look (FIREFOX_READ_ACTIONS), executes for any other and for a
|
|
7
|
+
// missing one, its `screenshot` included: Orkeon declares that one an edit, which this table has no word for, and
|
|
8
|
+
// execute is the answer that lets no more through. The arguments are read as Orkeon reads them: a key matched case aside (`Method`, `BODY`), the action
|
|
9
|
+
// trimmed and compared case aside, the method compared case aside (an empty one is no read method), a body present
|
|
10
|
+
// whatever its content, an empty string included, and the headers' names taken from an object or from a JSON string
|
|
11
|
+
// holding one. `rag_eval` declares an edit whatever the call (it ingests its corpus and writes its reports), the
|
|
12
|
+
// class the catalogue already files it under, so it has no line here. The gate runs a read without asking in every
|
|
13
|
+
// mode where the catalogue offers the tool; the gateless fallback of the dev crews (dev/call-guard.ts) reads this
|
|
14
|
+
// table so that it lets the same calls through. The catalogue's own classes (permission.ts TOOLS_BY_CLASS) are a
|
|
15
|
+
// different question, which modes see the tool at all: `http_api` stays out of `plan` and `dontAsk`, since a GET is
|
|
16
|
+
// an outbound request (mode-policy.ts). Pure.
|
|
17
|
+
|
|
18
|
+
export type ToolAccess = "read" | "execute";
|
|
19
|
+
|
|
20
|
+
/** The `github` actions Orkeon reads for. */
|
|
21
|
+
export const GITHUB_READ_ACTIONS: readonly string[] = ["list_issues", "get_pr", "search_repos", "get_repo"];
|
|
22
|
+
|
|
23
|
+
/** The `firefox` actions Orkeon reads for. */
|
|
24
|
+
export const FIREFOX_READ_ACTIONS: readonly string[] = [
|
|
25
|
+
"navigate", "back", "snapshot", "read", "find", "search", "tabs", "new_tab", "switch_tab",
|
|
26
|
+
];
|
|
27
|
+
|
|
28
|
+
/** The `http_api` methods Orkeon reads for; a missing method is a GET. */
|
|
29
|
+
export const HTTP_READ_METHODS: readonly string[] = ["GET", "HEAD", "OPTIONS"];
|
|
30
|
+
|
|
31
|
+
/** The headers that turn a read method of `http_api` into an execute, whatever their case: a server may run
|
|
32
|
+
* the method they name instead of the one sent (Orkeon #223). */
|
|
33
|
+
export const METHOD_OVERRIDE_HEADERS: readonly string[] = ["X-HTTP-Method-Override", "X-HTTP-Method", "X-Method-Override"];
|
|
34
|
+
|
|
35
|
+
/** The tools that declare a read whatever the call, though the catalogue files them elsewhere. */
|
|
36
|
+
const READ_WHATEVER_THE_CALL: readonly string[] = ["web_search"];
|
|
37
|
+
|
|
38
|
+
const isPlainObject = (value: unknown): value is Record<string, unknown> =>
|
|
39
|
+
value !== null && typeof value === "object" && !Array.isArray(value);
|
|
40
|
+
|
|
41
|
+
/** The argument named `name`, its key matched case aside, as Orkeon matches it; undefined when absent. */
|
|
42
|
+
const field = (input: unknown, name: string): unknown => {
|
|
43
|
+
if (!isPlainObject(input)) return undefined;
|
|
44
|
+
const key = Object.keys(input).find((k) => k.toLowerCase() === name.toLowerCase());
|
|
45
|
+
return key === undefined ? undefined : input[key];
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
/** Whether the call carries a body: any value but an absent or null one, an empty string included. */
|
|
49
|
+
const carriesBody = (body: unknown): boolean => body !== undefined && body !== null;
|
|
50
|
+
|
|
51
|
+
/** The names of the call's headers: the keys of an object, or of the object a JSON string holds; none otherwise. */
|
|
52
|
+
const headerNames = (headers: unknown): string[] => {
|
|
53
|
+
if (isPlainObject(headers)) return Object.keys(headers);
|
|
54
|
+
if (typeof headers !== "string" || headers.trim() === "") return [];
|
|
55
|
+
try {
|
|
56
|
+
const parsed: unknown = JSON.parse(headers);
|
|
57
|
+
return isPlainObject(parsed) ? Object.keys(parsed) : [];
|
|
58
|
+
} catch {
|
|
59
|
+
return [];
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
/** Whether the call's headers name a method-override header, case aside. */
|
|
64
|
+
const carriesMethodOverride = (headers: unknown): boolean => {
|
|
65
|
+
const overrides = METHOD_OVERRIDE_HEADERS.map((h) => h.toLowerCase());
|
|
66
|
+
return headerNames(headers).some((name) => overrides.includes(name.toLowerCase()));
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
/** The tools whose access follows their `action`, with the actions that read. */
|
|
70
|
+
const READ_ACTIONS_OF: Readonly<Record<string, readonly string[]>> = {
|
|
71
|
+
github: GITHUB_READ_ACTIONS,
|
|
72
|
+
firefox: FIREFOX_READ_ACTIONS,
|
|
73
|
+
};
|
|
74
|
+
|
|
75
|
+
/** The access Orkeon declares for this call; null when the tool declares one access whatever the call, as its class says. */
|
|
76
|
+
export function declaredAccess(tool: string, input: unknown): ToolAccess | null {
|
|
77
|
+
if (READ_WHATEVER_THE_CALL.includes(tool)) return "read";
|
|
78
|
+
const readActions = READ_ACTIONS_OF[tool];
|
|
79
|
+
if (readActions) {
|
|
80
|
+
const action = field(input, "action");
|
|
81
|
+
return typeof action === "string" && readActions.includes(action.trim().toLowerCase()) ? "read" : "execute";
|
|
82
|
+
}
|
|
83
|
+
if (tool === "http_api") {
|
|
84
|
+
const method = field(input, "method");
|
|
85
|
+
const readMethod = method === undefined || method === null
|
|
86
|
+
|| (typeof method === "string" && HTTP_READ_METHODS.includes(method.toUpperCase()));
|
|
87
|
+
if (!readMethod) return "execute";
|
|
88
|
+
return carriesBody(field(input, "body")) || carriesMethodOverride(field(input, "headers")) ? "execute" : "read";
|
|
89
|
+
}
|
|
90
|
+
return null;
|
|
91
|
+
}
|