avorelo 0.3.8 → 0.4.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/LICENSE +16 -23
- package/README.md +62 -72
- package/bin/avorelo +9 -0
- package/package.json +147 -139
- package/scripts/README.md +40 -0
- package/scripts/avorelo-session-collision-guard.js +540 -0
- package/scripts/avorelo-workstream-preflight.js +918 -0
- package/scripts/cco-dashboard.js +346 -0
- package/scripts/cco-posttooluse.js +504 -0
- package/scripts/cco-pretooluse.js +381 -0
- package/scripts/cco-status.js +540 -0
- package/scripts/cco-stop.js +77 -0
- package/scripts/cco-userprompt-submit.js +83 -0
- package/scripts/lib/activation/account-state.js +37 -0
- package/scripts/lib/activation/activate-command.js +114 -0
- package/scripts/lib/activation/activation-runner.js +607 -0
- package/scripts/lib/activation/activation-self-healing.js +481 -0
- package/scripts/lib/activation/activation-state.js +96 -0
- package/scripts/lib/activation/activation-summary.js +241 -0
- package/scripts/lib/activation/adapters/claude-code.js +77 -0
- package/scripts/lib/activation/adapters/codex-cli.js +52 -0
- package/scripts/lib/activation/adapters/cursor.js +37 -0
- package/scripts/lib/activation/adapters/github-agent.js +39 -0
- package/scripts/lib/activation/adapters/terminal.js +42 -0
- package/scripts/lib/activation/adapters/vscode.js +39 -0
- package/scripts/lib/activation/adapters/windsurf.js +37 -0
- package/scripts/lib/activation/ai-surface-detector.js +151 -0
- package/scripts/lib/activation/connect-account.js +145 -0
- package/scripts/lib/activation/detect-environment.js +75 -0
- package/scripts/lib/activation/detect-hosts.js +62 -0
- package/scripts/lib/activation/format-activation-output.js +109 -0
- package/scripts/lib/activation/next-action.js +43 -0
- package/scripts/lib/activation/repair-engine.js +219 -0
- package/scripts/lib/activation/run-entry.js +346 -0
- package/scripts/lib/activation-distribution-readiness.js +507 -0
- package/scripts/lib/adapter-conformance.js +176 -0
- package/scripts/lib/adapter-readiness.js +428 -0
- package/scripts/lib/adapter-safety-boundaries.js +335 -0
- package/scripts/lib/adapter-technical-readiness-gate.js +205 -0
- package/scripts/lib/agent-access-governance.js +455 -0
- package/scripts/lib/agent-activation-readiness.js +878 -0
- package/scripts/lib/agent-enforcement.js +765 -0
- package/scripts/lib/agent-evolution-loop.js +479 -0
- package/scripts/lib/agent-policy-profile.js +210 -0
- package/scripts/lib/agent-security/action-evaluator.js +507 -0
- package/scripts/lib/agent-security/adapter-registry.js +98 -0
- package/scripts/lib/agent-security/auto-policy.js +139 -0
- package/scripts/lib/agent-security/bounded-scan.js +93 -0
- package/scripts/lib/agent-security/enforcement-adapter.js +174 -0
- package/scripts/lib/agent-security/enforcement-engine.js +1129 -0
- package/scripts/lib/agent-security/file-write-adapter.js +183 -0
- package/scripts/lib/agent-security/file-write-rules.js +178 -0
- package/scripts/lib/agent-security/index.js +3342 -0
- package/scripts/lib/agent-security/instruction-risk.js +181 -0
- package/scripts/lib/agent-security/mcp-action-adapter.js +185 -0
- package/scripts/lib/agent-security/mcp-action-rules.js +184 -0
- package/scripts/lib/agent-security/package-action-adapter.js +175 -0
- package/scripts/lib/agent-security/package-action-rules.js +233 -0
- package/scripts/lib/agent-security/performance.js +148 -0
- package/scripts/lib/agent-security/permission-minimizer.js +403 -0
- package/scripts/lib/agent-security/scan-cache.js +74 -0
- package/scripts/lib/agent-security/source-trust.js +146 -0
- package/scripts/lib/ai-efficiency-dogfood-pack.js +437 -0
- package/scripts/lib/ai-efficiency-eval.js +207 -0
- package/scripts/lib/ai-efficiency-guard-contract.js +209 -0
- package/scripts/lib/ai-efficiency-measured-value.js +106 -0
- package/scripts/lib/ai-install-prompt.js +293 -0
- package/scripts/lib/ai-task-inference.js +155 -0
- package/scripts/lib/ai-value-ledger.js +121 -0
- package/scripts/lib/ai-value-proof-table.js +151 -0
- package/scripts/lib/ai-work-efficiency-routing.js +623 -0
- package/scripts/lib/ai-workspace-hygiene.js +1499 -0
- package/scripts/lib/alpha-activation.js +520 -0
- package/scripts/lib/alpha-feedback.js +263 -0
- package/scripts/lib/alpha-readiness-gate.js +332 -0
- package/scripts/lib/anti-gaming.js +169 -0
- package/scripts/lib/artifact-health.js +431 -0
- package/scripts/lib/artifact-receipt-hygiene.js +619 -0
- package/scripts/lib/attribution.js +180 -0
- package/scripts/lib/audit.js +289 -0
- package/scripts/lib/avorelo-skill-registry.js +810 -0
- package/scripts/lib/batch-jobs.js +71 -0
- package/scripts/lib/brain-pack.js +578 -0
- package/scripts/lib/brand-boundary.js +424 -0
- package/scripts/lib/brand.js +74 -0
- package/scripts/lib/browser-capability.js +1048 -0
- package/scripts/lib/browser-proof-governed-workflow.js +1020 -0
- package/scripts/lib/browser-proof-preflight.js +321 -0
- package/scripts/lib/cache-readiness.js +296 -0
- package/scripts/lib/canonical-reentry.js +162 -0
- package/scripts/lib/capability-contract-validator.js +177 -0
- package/scripts/lib/capability-hygiene.js +504 -0
- package/scripts/lib/capability-intake-quarantine.js +789 -0
- package/scripts/lib/capability-kernel-registry.js +566 -0
- package/scripts/lib/capability-kernel.js +202 -0
- package/scripts/lib/capability-manifest.js +255 -0
- package/scripts/lib/capability-outcome-normalizer.js +104 -0
- package/scripts/lib/capability-packs.js +314 -0
- package/scripts/lib/capability-recommender.js +513 -0
- package/scripts/lib/capability-registry.js +1062 -0
- package/scripts/lib/carry-forward-surfacing.js +194 -0
- package/scripts/lib/ccusage-adapter.js +188 -0
- package/scripts/lib/claude-session-evidence/index.js +1027 -0
- package/scripts/lib/cli-output-sanitizer.js +118 -0
- package/scripts/lib/company-loop.js +1149 -0
- package/scripts/lib/config.js +641 -0
- package/scripts/lib/context-acquisition-plan.js +359 -0
- package/scripts/lib/context-authority-rules.js +138 -0
- package/scripts/lib/context-budget-guard.js +170 -0
- package/scripts/lib/context-budget-scanner.js +257 -0
- package/scripts/lib/context-budget.js +167 -0
- package/scripts/lib/context-claim-safety.js +116 -0
- package/scripts/lib/context-compiler.js +236 -0
- package/scripts/lib/context-optimizer.js +715 -0
- package/scripts/lib/context-packet.js +121 -0
- package/scripts/lib/context-receipt.js +57 -0
- package/scripts/lib/context-reduction-plan.js +179 -0
- package/scripts/lib/context-safety.js +88 -0
- package/scripts/lib/context-savings-engine.js +158 -0
- package/scripts/lib/context-source-registry.js +393 -0
- package/scripts/lib/context-task-profiles.js +147 -0
- package/scripts/lib/cost-abuse-guard.js +975 -0
- package/scripts/lib/cost-evidence.js +287 -0
- package/scripts/lib/cost-to-outcome-signals.js +639 -0
- package/scripts/lib/cross-host-install-plan.js +308 -0
- package/scripts/lib/cross-host-install-readiness.js +242 -0
- package/scripts/lib/cross-host-value-flow.js +268 -0
- package/scripts/lib/dashboard.js +1056 -0
- package/scripts/lib/data-permissions-guard.js +1187 -0
- package/scripts/lib/deployment-environment-guard.js +1236 -0
- package/scripts/lib/design-partner-feedback.js +346 -0
- package/scripts/lib/dogfood-evidence-freshness.js +567 -0
- package/scripts/lib/efficiency-receipt.js +354 -0
- package/scripts/lib/entitlements.js +100 -0
- package/scripts/lib/execution-packet.js +559 -0
- package/scripts/lib/execution-route-governor.js +179 -0
- package/scripts/lib/experimentation-events.js +547 -0
- package/scripts/lib/external-capability-compliance.js +107 -0
- package/scripts/lib/external-readiness/ai-visibility/ai-visibility-runner.js +322 -0
- package/scripts/lib/external-readiness/calibration/benchmark-site-catalog.js +121 -0
- package/scripts/lib/external-readiness/calibration/completion-gate.js +112 -0
- package/scripts/lib/external-readiness/calibration/real-site-benchmark-runner.js +284 -0
- package/scripts/lib/external-readiness/drift-detector.js +100 -0
- package/scripts/lib/external-readiness/endpoint-prober.js +332 -0
- package/scripts/lib/external-readiness/external-readiness-runner.js +112 -0
- package/scripts/lib/external-readiness/full-agent-readiness-scorer.js +220 -0
- package/scripts/lib/external-readiness/golden-path-runner.js +333 -0
- package/scripts/lib/external-readiness/inside-out-runner.js +118 -0
- package/scripts/lib/external-readiness/proof-receipt-writer.js +112 -0
- package/scripts/lib/external-readiness/safe-fix-executor.js +117 -0
- package/scripts/lib/external-readiness/skills/category-boundary-guard.js +30 -0
- package/scripts/lib/external-readiness/skills/pmm-positioning-guard.js +69 -0
- package/scripts/lib/external-readiness/skills/safe-fix-policy.js +35 -0
- package/scripts/lib/external-user-simulation.js +166 -0
- package/scripts/lib/failure-recovery-readiness.js +81 -0
- package/scripts/lib/failure-recovery.js +419 -0
- package/scripts/lib/feedback-intelligence.js +537 -0
- package/scripts/lib/feedback-signals.js +205 -0
- package/scripts/lib/file-integrity.js +68 -0
- package/scripts/lib/fsx.js +129 -0
- package/scripts/lib/full-readiness-gate.js +451 -0
- package/scripts/lib/governed-action-exposure-primitives.js +1514 -0
- package/scripts/lib/governed-exposure-planner.js +186 -0
- package/scripts/lib/governed-workspace-hygiene.js +946 -0
- package/scripts/lib/guard-suite-common.js +412 -0
- package/scripts/lib/guidance-builder.js +174 -0
- package/scripts/lib/hook-apply.js +1075 -0
- package/scripts/lib/hook-baseline.js +310 -0
- package/scripts/lib/hook-config-preview.js +275 -0
- package/scripts/lib/hook-contracts.js +290 -0
- package/scripts/lib/hook-safety-boundary-readiness.js +80 -0
- package/scripts/lib/host-capability-matrix.js +351 -0
- package/scripts/lib/host-support-context.js +254 -0
- package/scripts/lib/http-hook-action.js +538 -0
- package/scripts/lib/install-ai-readiness.js +84 -0
- package/scripts/lib/install-intake-risk.js +1051 -0
- package/scripts/lib/install-journey-intelligence.js +329 -0
- package/scripts/lib/intervention-guidance.js +57 -0
- package/scripts/lib/known-limitations.js +115 -0
- package/scripts/lib/l8-path-truth.js +146 -0
- package/scripts/lib/launch-hardening-gate.js +436 -0
- package/scripts/lib/launch-readiness.js +635 -0
- package/scripts/lib/learning-experimentation-foundation.js +1484 -0
- package/scripts/lib/learning-memory.js +686 -0
- package/scripts/lib/lifecycle-hooks.js +982 -0
- package/scripts/lib/local-package-smoke.js +436 -0
- package/scripts/lib/local-pricing.js +299 -0
- package/scripts/lib/mcp-enforcement.js +311 -0
- package/scripts/lib/mcp-least-privilege-policy.js +303 -0
- package/scripts/lib/mcp-tool-inventory.js +388 -0
- package/scripts/lib/mcp-tool-risk.js +0 -0
- package/scripts/lib/memory.js +335 -0
- package/scripts/lib/metrics.js +699 -0
- package/scripts/lib/micro-proof.js +133 -0
- package/scripts/lib/model-work-class-routing.js +79 -0
- package/scripts/lib/next-run-context.js +436 -0
- package/scripts/lib/next-run-continuity.js +1207 -0
- package/scripts/lib/observability-recovery-guard.js +1030 -0
- package/scripts/lib/operating-value.js +1662 -0
- package/scripts/lib/optimization-v3.js +122 -0
- package/scripts/lib/orchestration/adapters/_shared.js +49 -0
- package/scripts/lib/orchestration/adapters/aider.js +18 -0
- package/scripts/lib/orchestration/adapters/claude-code.js +35 -0
- package/scripts/lib/orchestration/adapters/codex.js +35 -0
- package/scripts/lib/orchestration/adapters/gemini-cli.js +18 -0
- package/scripts/lib/orchestration/adapters/git.js +25 -0
- package/scripts/lib/orchestration/adapters/index.js +31 -0
- package/scripts/lib/orchestration/adapters/lm-studio.js +18 -0
- package/scripts/lib/orchestration/adapters/ollama.js +18 -0
- package/scripts/lib/orchestration/adapters/opencode.js +18 -0
- package/scripts/lib/orchestration/adapters/openrouter.js +18 -0
- package/scripts/lib/orchestration/adapters/test-runner.js +25 -0
- package/scripts/lib/orchestration/cli.js +438 -0
- package/scripts/lib/orchestration/execution-manager.js +279 -0
- package/scripts/lib/orchestration/handoff.js +314 -0
- package/scripts/lib/orchestration/index.js +456 -0
- package/scripts/lib/orchestration/inventory.js +47 -0
- package/scripts/lib/orchestration/model-discovery.js +498 -0
- package/scripts/lib/orchestration/model-profiler.js +170 -0
- package/scripts/lib/orchestration/model-profiles.js +252 -0
- package/scripts/lib/orchestration/model-refresh-policy.js +72 -0
- package/scripts/lib/orchestration/proof-writer.js +349 -0
- package/scripts/lib/orchestration/provider-discovery/aider.js +49 -0
- package/scripts/lib/orchestration/provider-discovery/claude-code.js +56 -0
- package/scripts/lib/orchestration/provider-discovery/codex.js +49 -0
- package/scripts/lib/orchestration/provider-discovery/common.js +186 -0
- package/scripts/lib/orchestration/provider-discovery/gemini.js +106 -0
- package/scripts/lib/orchestration/provider-discovery/lm-studio.js +118 -0
- package/scripts/lib/orchestration/provider-discovery/models-dev.js +12 -0
- package/scripts/lib/orchestration/provider-discovery/ollama.js +100 -0
- package/scripts/lib/orchestration/provider-discovery/opencode.js +47 -0
- package/scripts/lib/orchestration/provider-discovery/openrouter.js +44 -0
- package/scripts/lib/orchestration/risk-classifier.js +130 -0
- package/scripts/lib/orchestration/routing-policy.js +486 -0
- package/scripts/lib/orchestration/settings.js +95 -0
- package/scripts/lib/orchestration/state.js +165 -0
- package/scripts/lib/orchestration/verification-manager.js +138 -0
- package/scripts/lib/outcome-evidence-stack.js +1083 -0
- package/scripts/lib/output-profiles.js +146 -0
- package/scripts/lib/package-content-audit.js +368 -0
- package/scripts/lib/package-runtime.js +278 -0
- package/scripts/lib/plan-surface.js +53 -0
- package/scripts/lib/plans.js +2327 -0
- package/scripts/lib/policy-provider.js +27 -0
- package/scripts/lib/prelaunch-activation-readiness.js +409 -0
- package/scripts/lib/prelaunch-evidence-store.js +816 -0
- package/scripts/lib/prelaunch-intelligence.js +869 -0
- package/scripts/lib/pricing-experiment.js +118 -0
- package/scripts/lib/pro-moment-events.js +77 -0
- package/scripts/lib/pro-moment-state.js +227 -0
- package/scripts/lib/pro-moments.js +1216 -0
- package/scripts/lib/product-home-receipt.js +1790 -0
- package/scripts/lib/product-learning-events.js +696 -0
- package/scripts/lib/production-confidence-control-tower.js +1209 -0
- package/scripts/lib/production-confidence.js +1858 -0
- package/scripts/lib/project-profile.js +555 -0
- package/scripts/lib/prompt-compiler-plan.js +94 -0
- package/scripts/lib/prompt-compiler.js +280 -0
- package/scripts/lib/prompt-lint.js +32 -0
- package/scripts/lib/prompt-suggestions.js +52 -0
- package/scripts/lib/proof-canonical.js +398 -0
- package/scripts/lib/proof-drilldown.js +383 -0
- package/scripts/lib/proof-e2e/promise-completion.js +141 -0
- package/scripts/lib/proof-e2e/promise-dashboard-claims.js +135 -0
- package/scripts/lib/proof-e2e/promise-local-proof.js +156 -0
- package/scripts/lib/proof-e2e/promise-provider-neutral.js +136 -0
- package/scripts/lib/proof-e2e/promise-registry.js +219 -0
- package/scripts/lib/proof-e2e/promise-security-trust.js +141 -0
- package/scripts/lib/proof-e2e/promise-skills-risk.js +163 -0
- package/scripts/lib/proof-e2e/promise-token-savings.js +112 -0
- package/scripts/lib/proof-e2e/promise-work-management.js +126 -0
- package/scripts/lib/proof-events.js +342 -0
- package/scripts/lib/proof-history.js +243 -0
- package/scripts/lib/proof-metrics.js +296 -0
- package/scripts/lib/proof-outcome-evidence.js +134 -0
- package/scripts/lib/proof-receipt.js +335 -0
- package/scripts/lib/proof-record.js +461 -0
- package/scripts/lib/proof-savings-report.js +1549 -0
- package/scripts/lib/public-activation-distribution-gate.js +266 -0
- package/scripts/lib/public-cli.js +5631 -0
- package/scripts/lib/public-distribution-truth.js +211 -0
- package/scripts/lib/public-distribution.js +73 -0
- package/scripts/lib/public-install-claim-checker.js +300 -0
- package/scripts/lib/publish-provenance-readiness.js +287 -0
- package/scripts/lib/readiness-delta.js +218 -0
- package/scripts/lib/readiness-evidence-closure.js +196 -0
- package/scripts/lib/reentry-memory-capture.js +241 -0
- package/scripts/lib/reentry-memory-retrieval.js +302 -0
- package/scripts/lib/reentry-memory-status.js +147 -0
- package/scripts/lib/reentry-memory-store.js +183 -0
- package/scripts/lib/reentry-state.js +66 -0
- package/scripts/lib/release-candidate-bundle.js +166 -0
- package/scripts/lib/remediation.js +81 -0
- package/scripts/lib/repo-map.js +391 -0
- package/scripts/lib/run-action-policy.js +104 -0
- package/scripts/lib/run-contract-receipt.js +48 -0
- package/scripts/lib/run-contract.js +288 -0
- package/scripts/lib/run-cost-to-verified-outcome.js +87 -0
- package/scripts/lib/run-improvements-lifecycle.js +330 -0
- package/scripts/lib/run-improvements.js +789 -0
- package/scripts/lib/run-proof-contract.js +116 -0
- package/scripts/lib/run-risk-classifier.js +131 -0
- package/scripts/lib/run-task-classifier.js +216 -0
- package/scripts/lib/runtime-decision-policy.js +387 -0
- package/scripts/lib/safe-path-engine.js +705 -0
- package/scripts/lib/safe-repair.js +877 -0
- package/scripts/lib/safe-run-controller.js +887 -0
- package/scripts/lib/scope-repair-before-approval.js +865 -0
- package/scripts/lib/score.js +262 -0
- package/scripts/lib/seamless-enforcement.js +329 -0
- package/scripts/lib/seamless-outcome.js +689 -0
- package/scripts/lib/seamless-reality-gate.js +5053 -0
- package/scripts/lib/security-confidence/activation-safety.js +78 -0
- package/scripts/lib/security-confidence/adapters/adapter-contract.js +125 -0
- package/scripts/lib/security-confidence/adapters/mock-claude-bughunter-adapter.js +36 -0
- package/scripts/lib/security-confidence/adapters/mock-decepticon-adapter.js +34 -0
- package/scripts/lib/security-confidence/adapters/mock-mcp-scan-adapter.js +35 -0
- package/scripts/lib/security-confidence/adapters/mock-snyk-agent-scan-adapter.js +35 -0
- package/scripts/lib/security-confidence/adapters/mock-tank-adapter.js +34 -0
- package/scripts/lib/security-confidence/adapters/reference-registry.js +63 -0
- package/scripts/lib/security-confidence/auth-rbac-plan.js +39 -0
- package/scripts/lib/security-confidence/component-inventory.js +151 -0
- package/scripts/lib/security-confidence/constants.js +191 -0
- package/scripts/lib/security-confidence/dependency-script-risk.js +95 -0
- package/scripts/lib/security-confidence/evidence-hygiene.js +127 -0
- package/scripts/lib/security-confidence/feature-impact-classifier.js +80 -0
- package/scripts/lib/security-confidence/file-utils.js +161 -0
- package/scripts/lib/security-confidence/finding-triage.js +90 -0
- package/scripts/lib/security-confidence/findings.js +115 -0
- package/scripts/lib/security-confidence/index.js +29 -0
- package/scripts/lib/security-confidence/permission-budget.js +93 -0
- package/scripts/lib/security-confidence/redaction.js +82 -0
- package/scripts/lib/security-confidence/redteam-fixtures.js +53 -0
- package/scripts/lib/security-confidence/reference-adoption.js +229 -0
- package/scripts/lib/security-confidence/reference-taxonomy.js +155 -0
- package/scripts/lib/security-confidence/report-quality.js +99 -0
- package/scripts/lib/security-confidence/report-writer.js +79 -0
- package/scripts/lib/security-confidence/risk-classifier.js +187 -0
- package/scripts/lib/security-confidence/runner.js +179 -0
- package/scripts/lib/security-confidence/schema.js +188 -0
- package/scripts/lib/security-confidence/secret-safety.js +74 -0
- package/scripts/lib/security-confidence/security-capability-router.js +98 -0
- package/scripts/lib/security-confidence/web-security-smoke-plan.js +46 -0
- package/scripts/lib/security-risk-classifier.js +511 -0
- package/scripts/lib/security-scan.js +396 -0
- package/scripts/lib/session-context-optimizer.js +1211 -0
- package/scripts/lib/session-timing.js +322 -0
- package/scripts/lib/skill-hygiene.js +805 -0
- package/scripts/lib/skill-packs.js +161 -0
- package/scripts/lib/skills-operating-layer-v1.js +1023 -0
- package/scripts/lib/skills-operating-layer.js +629 -0
- package/scripts/lib/smallest-safe-plan.js +214 -0
- package/scripts/lib/smart-routing-plan.js +115 -0
- package/scripts/lib/smart-work-routing.js +768 -0
- package/scripts/lib/source-catalog.js +1022 -0
- package/scripts/lib/status-value-summary.js +32 -0
- package/scripts/lib/supply-chain-dependency-guard.js +1333 -0
- package/scripts/lib/supply-chain-guard.js +219 -0
- package/scripts/lib/support-bundle.js +561 -0
- package/scripts/lib/support-redaction.js +66 -0
- package/scripts/lib/task-continuation.js +440 -0
- package/scripts/lib/test-helpers.js +15 -0
- package/scripts/lib/tier.js +38 -0
- package/scripts/lib/token-context-quality-gate.js +370 -0
- package/scripts/lib/token-cost-capture.js +187 -0
- package/scripts/lib/token-cost-evidence.js +862 -0
- package/scripts/lib/token-cost-intelligence.js +358 -0
- package/scripts/lib/token-efficiency-evidence.js +213 -0
- package/scripts/lib/token-efficiency-map.js +110 -0
- package/scripts/lib/token-evidence.js +703 -0
- package/scripts/lib/tokenish.js +17 -0
- package/scripts/lib/tool-output-sandbox.js +559 -0
- package/scripts/lib/trust-audit.js +136 -0
- package/scripts/lib/unified-events.js +396 -0
- package/scripts/lib/upgrade-interruption-recovery.js +407 -0
- package/scripts/lib/usage-ledger.js +201 -0
- package/scripts/lib/value-ledger.js +130 -0
- package/scripts/lib/value-proof-calibration.js +531 -0
- package/scripts/lib/visual-qa.js +231 -0
- package/scripts/lib/voice-alpha.js +29 -0
- package/scripts/lib/webhook-idempotency-guard.js +990 -0
- package/scripts/lib/work-aware-orchestration.js +976 -0
- package/scripts/lib/work-control-receipts.js +577 -0
- package/scripts/lib/work-ledger.js +1123 -0
- package/scripts/lib/work-panel-preview.js +352 -0
- package/scripts/lib/workflow-discipline.js +280 -0
- package/scripts/lib/workflow-intelligence-radar.js +804 -0
- package/scripts/lib/workflow-signals.js +419 -0
- package/scripts/lib/workspace-map.js +281 -0
- package/scripts/lib/workspace-registry.js +1367 -0
- package/scripts/lib/workspace-resolver.js +542 -0
- package/scripts/wuz-doctor.js +315 -0
- package/bin/avorelo.mjs +0 -7
- package/dist/avorelo.mjs +0 -24678
|
@@ -0,0 +1,765 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
const crypto = require("crypto");
|
|
4
|
+
const fs = require("fs");
|
|
5
|
+
const path = require("path");
|
|
6
|
+
const { ensureCcoDirs, safeReadJson, safeWriteJson, nowIso } = require("./fsx");
|
|
7
|
+
const { canExportReports, getCurrentPlan } = require("./entitlements");
|
|
8
|
+
const { buildTaskContinuation } = require("./task-continuation");
|
|
9
|
+
const { buildPolicyProfile, describePolicyProfile } = require("./agent-policy-profile");
|
|
10
|
+
const {
|
|
11
|
+
buildGovernanceReceipt,
|
|
12
|
+
writeGovernanceReceipt,
|
|
13
|
+
applyGovernanceDecisionFloor,
|
|
14
|
+
buildAgentAccessGovernanceSurface,
|
|
15
|
+
} = require("./agent-access-governance");
|
|
16
|
+
const {
|
|
17
|
+
buildSafePathReceipt,
|
|
18
|
+
writeSafePathReceipt,
|
|
19
|
+
buildSafePathSurface,
|
|
20
|
+
recordSafePathLearningSignals,
|
|
21
|
+
} = require("./safe-path-engine");
|
|
22
|
+
const {
|
|
23
|
+
buildActionIntakeContext,
|
|
24
|
+
LATEST_INSTALL_INTAKE_RECEIPT_REL_PATH,
|
|
25
|
+
} = require("./install-intake-risk");
|
|
26
|
+
const { appendProductLearningEvent } = require("./product-learning-events");
|
|
27
|
+
const {
|
|
28
|
+
maxRisk,
|
|
29
|
+
classifyActionRisk,
|
|
30
|
+
classifyPathRisk,
|
|
31
|
+
classifyCommandRisk,
|
|
32
|
+
classifyToolRisk,
|
|
33
|
+
classifyBrowserRisk,
|
|
34
|
+
classifyInstructionRisk,
|
|
35
|
+
classifyPromptInjectionRisk,
|
|
36
|
+
classifySourceTrustRisk,
|
|
37
|
+
classifyIntentMismatchRisk,
|
|
38
|
+
classifySecretExposureRisk,
|
|
39
|
+
classifyExternalExportRisk,
|
|
40
|
+
} = require("./security-risk-classifier");
|
|
41
|
+
|
|
42
|
+
const DECISIONS = Object.freeze(["allow", "warn", "approval_required", "block"]);
|
|
43
|
+
const EVIDENCE_DIR_REL_PATH = ".claude/cco/evidence/agent-security";
|
|
44
|
+
const LATEST_EVIDENCE_REL_PATH = `${EVIDENCE_DIR_REL_PATH}/latest-enforcement.json`;
|
|
45
|
+
const HISTORY_DIR_REL_PATH = `${EVIDENCE_DIR_REL_PATH}/history`;
|
|
46
|
+
const EVENT_LOG_REL_PATH = ".claude/cco/events/agent-security-enforcement.jsonl";
|
|
47
|
+
const SCHEMA_VERSION = 1;
|
|
48
|
+
|
|
49
|
+
function sha256(value) {
|
|
50
|
+
return crypto.createHash("sha256").update(String(value || "")).digest("hex");
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
function stableStringify(value) {
|
|
54
|
+
if (Array.isArray(value)) {
|
|
55
|
+
return `[${value.map((item) => stableStringify(item)).join(",")}]`;
|
|
56
|
+
}
|
|
57
|
+
if (value && typeof value === "object") {
|
|
58
|
+
return `{${Object.keys(value)
|
|
59
|
+
.sort((left, right) => left.localeCompare(right))
|
|
60
|
+
.map((key) => `${JSON.stringify(key)}:${stableStringify(value[key])}`)
|
|
61
|
+
.join(",")}}`;
|
|
62
|
+
}
|
|
63
|
+
return JSON.stringify(value);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
function unique(values) {
|
|
67
|
+
return [...new Set((values || []).filter(Boolean))];
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function normalizeActionType(value) {
|
|
71
|
+
const actionType = String(value || "unknown").trim().toLowerCase();
|
|
72
|
+
return actionType || "unknown";
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function normalizePathList(value) {
|
|
76
|
+
const list = Array.isArray(value) ? value : value ? [value] : [];
|
|
77
|
+
return list.map((item) => String(item || "").replace(/\\/g, "/").trim()).filter(Boolean);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
function redactSecrets(value) {
|
|
81
|
+
if (Array.isArray(value)) {
|
|
82
|
+
return value.map((item) => redactSecrets(item));
|
|
83
|
+
}
|
|
84
|
+
if (value && typeof value === "object") {
|
|
85
|
+
const out = {};
|
|
86
|
+
Object.keys(value).forEach((key) => {
|
|
87
|
+
out[key] = redactSecrets(value[key]);
|
|
88
|
+
});
|
|
89
|
+
return out;
|
|
90
|
+
}
|
|
91
|
+
if (typeof value !== "string") {
|
|
92
|
+
return value;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
return value
|
|
96
|
+
.replace(/sk-[A-Za-z0-9]{16,}/g, "[redacted-openai-key]")
|
|
97
|
+
.replace(/ghp_[A-Za-z0-9]{20,}/g, "[redacted-github-token]")
|
|
98
|
+
.replace(/AKIA[0-9A-Z]{16}/g, "[redacted-aws-key]")
|
|
99
|
+
.replace(/(bearer\s+)[A-Za-z0-9._-]{8,}/ig, "$1[redacted]")
|
|
100
|
+
.replace(/((?:api[_ -]?key|token|password|secret|authorization)\s*[:=]\s*)([^\s'"]+)/ig, "$1[redacted]")
|
|
101
|
+
.replace(/(-----BEGIN [A-Z ]+-----)[\s\S]{0,4000}?(-----END [A-Z ]+-----)/g, "$1 [redacted] $2");
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function appendJsonl(cwd, relPathValue, entry) {
|
|
105
|
+
const absPath = path.join(cwd, relPathValue);
|
|
106
|
+
fs.mkdirSync(path.dirname(absPath), { recursive: true });
|
|
107
|
+
fs.appendFileSync(absPath, `${JSON.stringify(entry)}\n`, "utf8");
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function buildDecisionId(input, plan) {
|
|
111
|
+
return `guard-${sha256(stableStringify({ plan, input })).slice(0, 12)}`;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
function buildSanitizedInputSummary(input = {}) {
|
|
115
|
+
return redactSecrets({
|
|
116
|
+
actionType: normalizeActionType(input.actionType),
|
|
117
|
+
requestedBy: input.requestedBy || "unknown",
|
|
118
|
+
taskType: input.taskType || null,
|
|
119
|
+
userIntent: input.userIntent || null,
|
|
120
|
+
targetPaths: normalizePathList(input.targetPaths || input.target || []),
|
|
121
|
+
command: input.command || null,
|
|
122
|
+
toolName: input.toolName || null,
|
|
123
|
+
mcpServer: input.mcpServer || null,
|
|
124
|
+
domain: input.domain || null,
|
|
125
|
+
url: input.url || input.target || null,
|
|
126
|
+
skillPackIds: Array.isArray(input.skillPackIds) ? input.skillPackIds : [],
|
|
127
|
+
sourceTrust: input.sourceTrust || null,
|
|
128
|
+
instructionText: input.instructionText ? redactSecrets(String(input.instructionText).slice(0, 300)) : null,
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
function classifyAction(input = {}) {
|
|
133
|
+
const actionType = normalizeActionType(input.actionType);
|
|
134
|
+
const pathRisk = classifyPathRisk(input.targetPaths || input.target || [], input);
|
|
135
|
+
const commandRisk = classifyCommandRisk(input.command || input.target || "");
|
|
136
|
+
const toolRisk = classifyToolRisk({
|
|
137
|
+
toolName: input.toolName,
|
|
138
|
+
mcpServer: input.mcpServer,
|
|
139
|
+
metadata: input.toolMetadata,
|
|
140
|
+
});
|
|
141
|
+
const browserRisk = classifyBrowserRisk({
|
|
142
|
+
url: input.url || input.target,
|
|
143
|
+
domain: input.domain,
|
|
144
|
+
domainBoundaryReady: input.domainBoundaryReady,
|
|
145
|
+
cookieAccess: input.cookieAccess,
|
|
146
|
+
sessionAccess: input.sessionAccess,
|
|
147
|
+
secretAccess: input.secretAccess,
|
|
148
|
+
});
|
|
149
|
+
const instructionRisk = classifyInstructionRisk({
|
|
150
|
+
text: input.instructionText,
|
|
151
|
+
sourceTrust: input.sourceTrust,
|
|
152
|
+
sourceType: input.sourceType,
|
|
153
|
+
});
|
|
154
|
+
const promptInjectionRisk = classifyPromptInjectionRisk({
|
|
155
|
+
text: input.instructionText,
|
|
156
|
+
sourceTrust: input.sourceTrust,
|
|
157
|
+
sourceType: input.sourceType,
|
|
158
|
+
});
|
|
159
|
+
const sourceTrustRisk = classifySourceTrustRisk(input);
|
|
160
|
+
const intentMismatchRisk = classifyIntentMismatchRisk(input);
|
|
161
|
+
const secretExposureRisk = classifySecretExposureRisk(input);
|
|
162
|
+
const externalExportRisk = classifyExternalExportRisk(input);
|
|
163
|
+
const combined = classifyActionRisk(input);
|
|
164
|
+
|
|
165
|
+
return {
|
|
166
|
+
actionType,
|
|
167
|
+
pathRisk,
|
|
168
|
+
commandRisk,
|
|
169
|
+
toolRisk,
|
|
170
|
+
browserRisk,
|
|
171
|
+
instructionRisk,
|
|
172
|
+
promptInjectionRisk,
|
|
173
|
+
sourceTrustRisk,
|
|
174
|
+
intentMismatchRisk,
|
|
175
|
+
secretExposureRisk,
|
|
176
|
+
externalExportRisk,
|
|
177
|
+
combined,
|
|
178
|
+
};
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function getMatchedRules(input = {}, classification, profile) {
|
|
182
|
+
const actionType = classification.actionType;
|
|
183
|
+
const rules = [];
|
|
184
|
+
const risk = classification.combined;
|
|
185
|
+
const reasons = new Set(risk.reasonCodes || []);
|
|
186
|
+
const intakeReasons = new Set(input.intakeContext?.reasonCodes || []);
|
|
187
|
+
const isSensitiveFileWrite = (actionType === "file_write" || actionType === "config_change")
|
|
188
|
+
&& (reasons.has("SENSITIVE_ENV_FILE") || reasons.has("SECRET_LIKE_TARGET") || reasons.has("AUTH_OR_BILLING_SCOPE") || reasons.has("DEPLOYMENT_CONFIG") || reasons.has("CI_CONFIG"));
|
|
189
|
+
const hasPromptInjection = input.hasPromptInjectionSignal === true || reasons.has("PROMPT_INJECTION_SIGNAL");
|
|
190
|
+
const hasIntentMismatch = input.hasIntentMismatchSignal === true || reasons.has("INTENT_MISMATCH") || reasons.has("OUT_OF_SCOPE_FILE_CHANGE");
|
|
191
|
+
const browserExternal = (actionType === "browser_action" || actionType === "visual_qa_run") && reasons.has("BROWSER_EXTERNAL_DOMAIN");
|
|
192
|
+
const browserSecretRisk = reasons.has("BROWSER_COOKIE_OR_SESSION_RISK");
|
|
193
|
+
const unknownTool = reasons.has("UNKNOWN_MCP_TOOL");
|
|
194
|
+
const writeCapableTool = reasons.has("WRITE_CAPABLE_TOOL");
|
|
195
|
+
const destructiveCommand = reasons.has("DESTRUCTIVE_COMMAND") || reasons.has("FORCE_PUSH_OR_HISTORY_REWRITE");
|
|
196
|
+
const externalExport = reasons.has("EXTERNAL_REPO_EXPORT");
|
|
197
|
+
const externalNetwork = reasons.has("EXTERNAL_NETWORK_REQUEST");
|
|
198
|
+
const localhostVisualQa = actionType === "visual_qa_run" && reasons.has("VISUAL_QA_LOCAL_TARGET");
|
|
199
|
+
const secretExposure = actionType === "secret_access" || reasons.has("SECRET_LIKE_TARGET") && (actionType === "network_request" || actionType === "tool_call" || actionType === "mcp_tool_call");
|
|
200
|
+
const blockedIntake = input.intakeContext?.matchedItems?.some((item) => item.reviewStatus === "blocked");
|
|
201
|
+
const riskyInstallIntake =
|
|
202
|
+
intakeReasons.has("UNKNOWN_PACKAGE_INSTALL")
|
|
203
|
+
|| intakeReasons.has("PACKAGE_NON_REGISTRY_SOURCE")
|
|
204
|
+
|| intakeReasons.has("INSTALL_SCRIPT_PRESENT")
|
|
205
|
+
|| intakeReasons.has("NETWORK_SCRIPT_PRESENT")
|
|
206
|
+
|| intakeReasons.has("DESTRUCTIVE_SCRIPT_PRESENT")
|
|
207
|
+
|| intakeReasons.has("UNKNOWN_MCP_SOURCE")
|
|
208
|
+
|| intakeReasons.has("UNKNOWN_EXTENSION_SOURCE");
|
|
209
|
+
|
|
210
|
+
if (actionType === "prompt_compile") {
|
|
211
|
+
rules.push({ id: "safe_prompt_compile_allow", outcome: "allow", summary: "Safe prompt compilation stays local." });
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
if (localhostVisualQa) {
|
|
215
|
+
rules.push({
|
|
216
|
+
id: "local_visual_qa_allow",
|
|
217
|
+
outcome: input.runnerAvailable === false ? "warn" : "allow",
|
|
218
|
+
summary: input.runnerAvailable === false
|
|
219
|
+
? "Local Visual QA target is safe, but the local runner is unavailable."
|
|
220
|
+
: "Local Visual QA target stays inside localhost scope.",
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (isSensitiveFileWrite) {
|
|
225
|
+
rules.push({
|
|
226
|
+
id: "sensitive_file_write_guard",
|
|
227
|
+
outcome: reasons.has("SECRET_LIKE_TARGET") || reasons.has("SENSITIVE_ENV_FILE") ? "approval_required" : "warn",
|
|
228
|
+
summary: "Sensitive file writes need a narrower scope or explicit approval.",
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
if (secretExposure) {
|
|
233
|
+
rules.push({
|
|
234
|
+
id: "secret_exposure_block",
|
|
235
|
+
outcome: "block",
|
|
236
|
+
summary: "Secret access or exposure is not allowed.",
|
|
237
|
+
});
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
if (blockedIntake) {
|
|
241
|
+
rules.push({
|
|
242
|
+
id: "blocked_intake_guard",
|
|
243
|
+
outcome: "block",
|
|
244
|
+
summary: "The requested runtime surface is blocked by local intake review and must not be trusted automatically.",
|
|
245
|
+
});
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
if (hasPromptInjection && (isSensitiveFileWrite || writeCapableTool || externalExport || browserExternal || externalNetwork)) {
|
|
249
|
+
rules.push({
|
|
250
|
+
id: "prompt_injection_sensitive_action_guard",
|
|
251
|
+
outcome: risk.riskLevel === "critical" ? "block" : "approval_required",
|
|
252
|
+
summary: "Prompt-injection signals plus a sensitive action require a hard stop or approval.",
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
if (hasIntentMismatch) {
|
|
257
|
+
rules.push({
|
|
258
|
+
id: "intent_mismatch_guard",
|
|
259
|
+
outcome: profile.plan === "pro" && risk.riskLevel !== "low" ? "approval_required" : "warn",
|
|
260
|
+
summary: "The requested action does not match the user’s stated task.",
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
if (browserExternal) {
|
|
265
|
+
rules.push({
|
|
266
|
+
id: "browser_external_domain_guard",
|
|
267
|
+
outcome: profile.plan === "pro" ? "approval_required" : "warn",
|
|
268
|
+
summary: "External browser targets need a boundary or review before proceeding.",
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
|
|
272
|
+
if (browserSecretRisk) {
|
|
273
|
+
rules.push({
|
|
274
|
+
id: "browser_cookie_session_block",
|
|
275
|
+
outcome: "block",
|
|
276
|
+
summary: "Browser actions touching cookies, sessions, or secrets are blocked.",
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
if (unknownTool) {
|
|
281
|
+
rules.push({
|
|
282
|
+
id: "unknown_tool_guard",
|
|
283
|
+
outcome: profile.plan === "pro" ? "approval_required" : "warn",
|
|
284
|
+
summary: "Unknown tools and MCP targets should not be blindly trusted.",
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
if (riskyInstallIntake) {
|
|
289
|
+
rules.push({
|
|
290
|
+
id: "install_intake_review_guard",
|
|
291
|
+
outcome: profile.plan === "pro" || blockedIntake ? "approval_required" : "warn",
|
|
292
|
+
summary: "Local intake signals show this package, MCP, extension, or guidance surface needs review before normal runtime trust.",
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
if (writeCapableTool) {
|
|
297
|
+
rules.push({
|
|
298
|
+
id: "write_capable_tool_guard",
|
|
299
|
+
outcome: profile.plan === "pro" ? "approval_required" : "warn",
|
|
300
|
+
summary: "Write-capable tools require a narrower reviewed scope.",
|
|
301
|
+
});
|
|
302
|
+
}
|
|
303
|
+
|
|
304
|
+
if (destructiveCommand) {
|
|
305
|
+
rules.push({
|
|
306
|
+
id: "destructive_command_block",
|
|
307
|
+
outcome: "block",
|
|
308
|
+
summary: "Destructive commands are blocked.",
|
|
309
|
+
});
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
if (externalExport) {
|
|
313
|
+
rules.push({
|
|
314
|
+
id: "external_export_guard",
|
|
315
|
+
outcome: "block",
|
|
316
|
+
summary: "External repository export is blocked by default.",
|
|
317
|
+
});
|
|
318
|
+
} else if (externalNetwork) {
|
|
319
|
+
rules.push({
|
|
320
|
+
id: "external_network_guard",
|
|
321
|
+
outcome: profile.plan === "pro" ? "approval_required" : "warn",
|
|
322
|
+
summary: "External network requests need scoped review.",
|
|
323
|
+
});
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
if ((actionType === "tool_call" || actionType === "mcp_tool_call") && !unknownTool && !writeCapableTool && risk.riskLevel === "low") {
|
|
327
|
+
rules.push({
|
|
328
|
+
id: "trusted_tool_allow",
|
|
329
|
+
outcome: "allow",
|
|
330
|
+
summary: "Trusted local tool usage stays within normal scope.",
|
|
331
|
+
});
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
if ((actionType === "file_read" || actionType === "unknown") && risk.riskLevel === "low") {
|
|
335
|
+
rules.push({
|
|
336
|
+
id: "low_risk_local_read_allow",
|
|
337
|
+
outcome: "allow",
|
|
338
|
+
summary: "The action looks like a low-risk local read or inspection.",
|
|
339
|
+
});
|
|
340
|
+
}
|
|
341
|
+
|
|
342
|
+
if (!rules.length && risk.riskLevel === "medium") {
|
|
343
|
+
rules.push({
|
|
344
|
+
id: "medium_risk_default_warn",
|
|
345
|
+
outcome: "warn",
|
|
346
|
+
summary: "The action carries moderate uncertainty and should stay visible.",
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
|
|
350
|
+
if (!rules.length && risk.riskLevel === "high") {
|
|
351
|
+
rules.push({
|
|
352
|
+
id: "high_risk_default_review",
|
|
353
|
+
outcome: profile.plan === "pro" ? "approval_required" : "warn",
|
|
354
|
+
summary: "The action is high risk and should not proceed silently.",
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
if (!rules.length && risk.riskLevel === "critical") {
|
|
359
|
+
rules.push({
|
|
360
|
+
id: "critical_risk_default_block",
|
|
361
|
+
outcome: "block",
|
|
362
|
+
summary: "The action is critically risky and should not proceed.",
|
|
363
|
+
});
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
return rules;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
function decisionSeverity(decision) {
|
|
370
|
+
switch (decision) {
|
|
371
|
+
case "block":
|
|
372
|
+
return 4;
|
|
373
|
+
case "approval_required":
|
|
374
|
+
return 3;
|
|
375
|
+
case "warn":
|
|
376
|
+
return 2;
|
|
377
|
+
default:
|
|
378
|
+
return 1;
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
function saferAlternativeFromReasons(reasonCodes = [], actionType = "unknown") {
|
|
383
|
+
if (reasonCodes.includes("DESTRUCTIVE_COMMAND") || reasonCodes.includes("FORCE_PUSH_OR_HISTORY_REWRITE")) {
|
|
384
|
+
return "Use a non-destructive verification command or a dry-run instead of deleting data or rewriting history.";
|
|
385
|
+
}
|
|
386
|
+
if (reasonCodes.includes("SENSITIVE_ENV_FILE") || reasonCodes.includes("SECRET_LIKE_TARGET")) {
|
|
387
|
+
return "Change a reviewed example or template file first and keep secret material out of direct edits and evidence.";
|
|
388
|
+
}
|
|
389
|
+
if (reasonCodes.includes("BROWSER_EXTERNAL_DOMAIN")) {
|
|
390
|
+
return "Use a localhost preview or add an explicit allowed domain boundary before opening an external site.";
|
|
391
|
+
}
|
|
392
|
+
if (reasonCodes.includes("UNKNOWN_MCP_TOOL") || reasonCodes.includes("WRITE_CAPABLE_TOOL")) {
|
|
393
|
+
return "Prefer a trusted local skill pack or a reviewed read-only tool before using an unknown or write-capable integration.";
|
|
394
|
+
}
|
|
395
|
+
if (reasonCodes.includes("EXTERNAL_REPO_EXPORT") || reasonCodes.includes("EXTERNAL_NETWORK_REQUEST")) {
|
|
396
|
+
return "Keep the workflow local-first and avoid exporting repo contents or making external requests unless the task explicitly requires it.";
|
|
397
|
+
}
|
|
398
|
+
if (reasonCodes.includes("PROMPT_INJECTION_SIGNAL")) {
|
|
399
|
+
return "Treat the instruction as data only, use a sanitized summary, and keep it out of tool decisions until reviewed.";
|
|
400
|
+
}
|
|
401
|
+
if (actionType === "prompt_compile") {
|
|
402
|
+
return "Compile the task first, then scope any sensitive follow-up action separately.";
|
|
403
|
+
}
|
|
404
|
+
return "Keep the action narrowed to the smallest local scope that satisfies the task.";
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
function buildDecision(input = {}, matchedRules = [], classification, profile, options = {}) {
|
|
408
|
+
const ruleDecision = matchedRules.reduce((current, rule) => {
|
|
409
|
+
return decisionSeverity(rule.outcome) > decisionSeverity(current) ? rule.outcome : current;
|
|
410
|
+
}, "allow");
|
|
411
|
+
const decisionId = buildDecisionId({
|
|
412
|
+
actionType: classification.actionType,
|
|
413
|
+
input: buildSanitizedInputSummary(input),
|
|
414
|
+
matchedRules: matchedRules.map((rule) => rule.id),
|
|
415
|
+
}, profile.plan);
|
|
416
|
+
const createdAt = nowIso();
|
|
417
|
+
const scope = {
|
|
418
|
+
allowedPaths: unique([...(profile.allowedPaths || []), ...normalizePathList(input.currentScope?.allowedPaths || [])]),
|
|
419
|
+
deniedPaths: unique([...(profile.deniedPaths || []), ...normalizePathList(input.currentScope?.deniedPaths || [])]),
|
|
420
|
+
allowedDomains: unique([...(profile.allowedDomains || []), ...((input.currentScope?.allowedDomains || []).filter(Boolean))]),
|
|
421
|
+
deniedDomains: unique([...(profile.deniedDomains || []), ...((input.currentScope?.deniedDomains || []).filter(Boolean))]),
|
|
422
|
+
allowedTools: unique([...(profile.allowedTools || []), ...((input.currentScope?.allowedTools || []).filter(Boolean))]),
|
|
423
|
+
deniedTools: unique([...(profile.deniedTools || []), ...((input.currentScope?.deniedTools || []).filter(Boolean))]),
|
|
424
|
+
};
|
|
425
|
+
const reasonCodes = unique([
|
|
426
|
+
...(classification.combined.reasonCodes || []),
|
|
427
|
+
...(input.intakeContext?.reasonCodes || []),
|
|
428
|
+
]);
|
|
429
|
+
const explanation = matchedRules.length
|
|
430
|
+
? matchedRules.map((rule) => rule.summary).join(" ")
|
|
431
|
+
: classification.combined.explanation || "No additional rule explanation was available.";
|
|
432
|
+
|
|
433
|
+
return {
|
|
434
|
+
decisionId,
|
|
435
|
+
decision: DECISIONS.includes(ruleDecision) ? ruleDecision : "warn",
|
|
436
|
+
actionType: classification.actionType,
|
|
437
|
+
riskLevel: classification.combined.riskLevel,
|
|
438
|
+
reasonCodes,
|
|
439
|
+
matchedRules: matchedRules.map((rule) => rule.id),
|
|
440
|
+
explanation,
|
|
441
|
+
saferAlternative: (() => {
|
|
442
|
+
const ruleDecisionFinal = DECISIONS.includes(ruleDecision) ? ruleDecision : "warn";
|
|
443
|
+
const continuation = buildTaskContinuation({
|
|
444
|
+
actionType: classification.actionType,
|
|
445
|
+
target: input.target || input.command || input.url || input.toolName || "",
|
|
446
|
+
task: input.userIntent || input.taskType || "",
|
|
447
|
+
riskLevel: classification.combined.riskLevel,
|
|
448
|
+
decision: ruleDecisionFinal,
|
|
449
|
+
reasonCodes,
|
|
450
|
+
});
|
|
451
|
+
// Task-continuation is primary; fall back to intake action only as a supplement
|
|
452
|
+
const intakeAction = input.intakeContext?.safeNextAction;
|
|
453
|
+
const taskAction = continuation.safeNextAction;
|
|
454
|
+
return sanitizeText(taskAction || intakeAction || "Keep the action narrowed to the smallest local scope.");
|
|
455
|
+
})(),
|
|
456
|
+
requiresApproval: ruleDecision === "approval_required",
|
|
457
|
+
blocked: ruleDecision === "block",
|
|
458
|
+
scope,
|
|
459
|
+
ttlSeconds: ruleDecision === "approval_required" ? Number(profile.ttlSeconds || 0) : null,
|
|
460
|
+
evidencePath: null,
|
|
461
|
+
createdAt,
|
|
462
|
+
plan: profile.plan,
|
|
463
|
+
mode: profile.mode,
|
|
464
|
+
sanitizedInputSummary: buildSanitizedInputSummary(input),
|
|
465
|
+
schemaVersion: SCHEMA_VERSION,
|
|
466
|
+
};
|
|
467
|
+
}
|
|
468
|
+
|
|
469
|
+
function sanitizeText(value) {
|
|
470
|
+
return redactSecrets(String(value || ""));
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
function recordGovernanceLearningSignals(cwd, receipt) {
|
|
474
|
+
const events = [
|
|
475
|
+
{
|
|
476
|
+
eventName: "access_governance_evaluated",
|
|
477
|
+
category: "access_governance",
|
|
478
|
+
status: receipt.decision,
|
|
479
|
+
payload: {
|
|
480
|
+
subjectType: receipt.subjectSummary.type,
|
|
481
|
+
trustStatus: receipt.subjectSummary.trustStatus,
|
|
482
|
+
actionType: receipt.requestedActionSummary.type,
|
|
483
|
+
decision: receipt.decision,
|
|
484
|
+
reasonCodes: receipt.reasonCodes,
|
|
485
|
+
},
|
|
486
|
+
},
|
|
487
|
+
{
|
|
488
|
+
eventName: "access_receipt_written",
|
|
489
|
+
category: "access_governance",
|
|
490
|
+
status: "recorded",
|
|
491
|
+
payload: {
|
|
492
|
+
decisionId: receipt.decisionId,
|
|
493
|
+
subjectType: receipt.subjectSummary.type,
|
|
494
|
+
trustStatus: receipt.subjectSummary.trustStatus,
|
|
495
|
+
},
|
|
496
|
+
},
|
|
497
|
+
];
|
|
498
|
+
|
|
499
|
+
if (receipt.subjectSummary.trustStatus === "unknown") {
|
|
500
|
+
events.push({
|
|
501
|
+
eventName: "access_subject_unknown",
|
|
502
|
+
category: "access_governance",
|
|
503
|
+
status: receipt.decision,
|
|
504
|
+
payload: {
|
|
505
|
+
subjectType: receipt.subjectSummary.type,
|
|
506
|
+
requestedActionType: receipt.requestedActionSummary.type,
|
|
507
|
+
},
|
|
508
|
+
});
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
if (receipt.decision === "approval_required") {
|
|
512
|
+
events.push({
|
|
513
|
+
eventName: "access_scope_requires_approval",
|
|
514
|
+
category: "access_governance",
|
|
515
|
+
status: "approval_required",
|
|
516
|
+
payload: {
|
|
517
|
+
subjectType: receipt.subjectSummary.type,
|
|
518
|
+
requestedActionType: receipt.requestedActionSummary.type,
|
|
519
|
+
},
|
|
520
|
+
});
|
|
521
|
+
}
|
|
522
|
+
|
|
523
|
+
if (receipt.decision === "block") {
|
|
524
|
+
events.push({
|
|
525
|
+
eventName: "access_blocked",
|
|
526
|
+
category: "access_governance",
|
|
527
|
+
status: "blocked",
|
|
528
|
+
payload: {
|
|
529
|
+
subjectType: receipt.subjectSummary.type,
|
|
530
|
+
reasonCodes: receipt.reasonCodes,
|
|
531
|
+
},
|
|
532
|
+
});
|
|
533
|
+
} else if (receipt.decision === "warn") {
|
|
534
|
+
events.push({
|
|
535
|
+
eventName: "access_warned",
|
|
536
|
+
category: "access_governance",
|
|
537
|
+
status: "warned",
|
|
538
|
+
payload: {
|
|
539
|
+
subjectType: receipt.subjectSummary.type,
|
|
540
|
+
reasonCodes: receipt.reasonCodes,
|
|
541
|
+
},
|
|
542
|
+
});
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
events.forEach((event) => {
|
|
546
|
+
try {
|
|
547
|
+
appendProductLearningEvent(cwd, event);
|
|
548
|
+
} catch {}
|
|
549
|
+
});
|
|
550
|
+
}
|
|
551
|
+
|
|
552
|
+
function writeEnforcementEvidence(decision, options = {}) {
|
|
553
|
+
const cwd = path.resolve(options.cwd || process.cwd());
|
|
554
|
+
ensureCcoDirs(cwd);
|
|
555
|
+
|
|
556
|
+
const payload = redactSecrets({
|
|
557
|
+
schemaVersion: SCHEMA_VERSION,
|
|
558
|
+
decisionId: decision.decisionId,
|
|
559
|
+
timestamp: decision.createdAt,
|
|
560
|
+
plan: decision.plan,
|
|
561
|
+
mode: decision.mode,
|
|
562
|
+
actionType: decision.actionType,
|
|
563
|
+
sanitizedInputSummary: decision.sanitizedInputSummary,
|
|
564
|
+
decision: decision.decision,
|
|
565
|
+
riskLevel: decision.riskLevel,
|
|
566
|
+
reasonCodes: decision.reasonCodes,
|
|
567
|
+
matchedRules: decision.matchedRules,
|
|
568
|
+
saferAlternative: decision.saferAlternative,
|
|
569
|
+
source: options.source || decision.sanitizedInputSummary.requestedBy || "cli",
|
|
570
|
+
});
|
|
571
|
+
|
|
572
|
+
safeWriteJson(cwd, LATEST_EVIDENCE_REL_PATH, payload);
|
|
573
|
+
appendJsonl(cwd, EVENT_LOG_REL_PATH, payload);
|
|
574
|
+
|
|
575
|
+
let historyPath = null;
|
|
576
|
+
if (canExportReports(decision.plan)) {
|
|
577
|
+
historyPath = `${HISTORY_DIR_REL_PATH}/${decision.decisionId}.json`;
|
|
578
|
+
safeWriteJson(cwd, historyPath, payload);
|
|
579
|
+
}
|
|
580
|
+
|
|
581
|
+
return historyPath || LATEST_EVIDENCE_REL_PATH;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
function readLatestEnforcementEvidence(cwd) {
|
|
585
|
+
return safeReadJson(cwd, LATEST_EVIDENCE_REL_PATH, null);
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
function summarizeEnforcementEvidence(cwd) {
|
|
589
|
+
try {
|
|
590
|
+
const latest = readLatestEnforcementEvidence(cwd);
|
|
591
|
+
if (!latest) return null;
|
|
592
|
+
return {
|
|
593
|
+
decisionId: latest.decisionId || null,
|
|
594
|
+
decision: latest.decision || null,
|
|
595
|
+
riskLevel: latest.riskLevel || null,
|
|
596
|
+
reasonCodes: Array.isArray(latest.reasonCodes) ? latest.reasonCodes : [],
|
|
597
|
+
matchedRules: Array.isArray(latest.matchedRules) ? latest.matchedRules : [],
|
|
598
|
+
createdAt: latest.timestamp || null,
|
|
599
|
+
summary: latest.decision
|
|
600
|
+
? `${latest.decision} ${latest.actionType || "action"} (${latest.riskLevel || "unknown"} risk)`
|
|
601
|
+
: "Latest enforcement evidence is present.",
|
|
602
|
+
};
|
|
603
|
+
} catch {
|
|
604
|
+
return {
|
|
605
|
+
decisionId: null,
|
|
606
|
+
decision: null,
|
|
607
|
+
riskLevel: null,
|
|
608
|
+
reasonCodes: [],
|
|
609
|
+
matchedRules: [],
|
|
610
|
+
createdAt: null,
|
|
611
|
+
summary: "Latest enforcement evidence is unreadable.",
|
|
612
|
+
};
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
function explainDecision(decision) {
|
|
617
|
+
return `${decision.decision} ${decision.actionType} (${decision.riskLevel} risk): ${decision.explanation}`;
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
function isApprovalRequired(decision) {
|
|
621
|
+
return decision?.decision === "approval_required";
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
function isBlocked(decision) {
|
|
625
|
+
return decision?.decision === "block";
|
|
626
|
+
}
|
|
627
|
+
|
|
628
|
+
function evaluateAgentAction(input = {}, options = {}) {
|
|
629
|
+
const cwd = path.resolve(options.cwd || process.cwd());
|
|
630
|
+
const plan = String(input.plan || options.plan || getCurrentPlan({ cwd })).trim().toLowerCase() === "pro" ? "pro" : "free";
|
|
631
|
+
const profile = buildPolicyProfile({
|
|
632
|
+
cwd,
|
|
633
|
+
plan,
|
|
634
|
+
overrides: options.profileOverrides,
|
|
635
|
+
});
|
|
636
|
+
const intakeContext = buildActionIntakeContext(cwd, input, {
|
|
637
|
+
writeReceipt: options.writeEvidence !== false,
|
|
638
|
+
plan,
|
|
639
|
+
});
|
|
640
|
+
const enrichedInput = {
|
|
641
|
+
...input,
|
|
642
|
+
subject: input.subject || intakeContext.subject || undefined,
|
|
643
|
+
toolMetadata: {
|
|
644
|
+
...(input.toolMetadata || {}),
|
|
645
|
+
...(intakeContext.toolMetadata || {}),
|
|
646
|
+
},
|
|
647
|
+
intakeContext,
|
|
648
|
+
};
|
|
649
|
+
const classification = classifyAction(enrichedInput);
|
|
650
|
+
classification.combined = {
|
|
651
|
+
...classification.combined,
|
|
652
|
+
riskLevel: maxRisk(classification.combined.riskLevel, intakeContext.riskLevel || "low"),
|
|
653
|
+
reasonCodes: unique([
|
|
654
|
+
...(classification.combined.reasonCodes || []),
|
|
655
|
+
...(intakeContext.reasonCodes || []),
|
|
656
|
+
]),
|
|
657
|
+
explanation: [
|
|
658
|
+
classification.combined.explanation,
|
|
659
|
+
intakeContext.reasonCodes?.length ? `Install intake signals: ${(intakeContext.reasonCodes || []).join(", ")}.` : null,
|
|
660
|
+
].filter(Boolean).join(" "),
|
|
661
|
+
recommendedAction: unique([
|
|
662
|
+
classification.combined.recommendedAction,
|
|
663
|
+
intakeContext.safeNextAction,
|
|
664
|
+
]).filter(Boolean).join(" "),
|
|
665
|
+
};
|
|
666
|
+
const matchedRules = getMatchedRules(enrichedInput, classification, profile);
|
|
667
|
+
const initialDecision = buildDecision(enrichedInput, matchedRules, classification, profile, options);
|
|
668
|
+
const initialReceipt = buildGovernanceReceipt(enrichedInput, initialDecision, classification);
|
|
669
|
+
const decision = applyGovernanceDecisionFloor(initialDecision, initialReceipt);
|
|
670
|
+
const governanceReceipt = buildGovernanceReceipt(enrichedInput, decision, classification);
|
|
671
|
+
const safePathReceipt = buildSafePathReceipt(enrichedInput, decision, governanceReceipt, {
|
|
672
|
+
cwd,
|
|
673
|
+
classification,
|
|
674
|
+
profile,
|
|
675
|
+
intakeContext,
|
|
676
|
+
});
|
|
677
|
+
|
|
678
|
+
if (options.writeEvidence !== false) {
|
|
679
|
+
decision.evidencePath = writeEnforcementEvidence(decision, {
|
|
680
|
+
cwd,
|
|
681
|
+
source: input.requestedBy || options.source || "cli",
|
|
682
|
+
});
|
|
683
|
+
governanceReceipt.evidencePath = writeGovernanceReceipt(cwd, governanceReceipt, { plan });
|
|
684
|
+
decision.governanceReceiptPath = governanceReceipt.evidencePath;
|
|
685
|
+
decision.governance = governanceReceipt;
|
|
686
|
+
decision.safePathReceiptPath = writeSafePathReceipt(cwd, safePathReceipt, { plan });
|
|
687
|
+
decision.safePath = safePathReceipt;
|
|
688
|
+
decision.installIntakeReceiptPath = intakeContext.receiptPath || LATEST_INSTALL_INTAKE_RECEIPT_REL_PATH;
|
|
689
|
+
decision.installIntake = {
|
|
690
|
+
summary: intakeContext.receipt.summary,
|
|
691
|
+
matchedItems: intakeContext.matchedItems.map((item) => ({
|
|
692
|
+
id: item.id,
|
|
693
|
+
type: item.type,
|
|
694
|
+
name: item.name,
|
|
695
|
+
reviewStatus: item.reviewStatus,
|
|
696
|
+
riskLevel: item.riskLevel,
|
|
697
|
+
reasonCodes: item.reasonCodes,
|
|
698
|
+
})),
|
|
699
|
+
nextAction: intakeContext.safeNextAction || intakeContext.receipt.nextAction,
|
|
700
|
+
topReasonCodes: intakeContext.receipt.topReasonCodes || [],
|
|
701
|
+
};
|
|
702
|
+
recordGovernanceLearningSignals(cwd, governanceReceipt);
|
|
703
|
+
recordSafePathLearningSignals(cwd, safePathReceipt);
|
|
704
|
+
} else {
|
|
705
|
+
decision.governanceReceiptPath = null;
|
|
706
|
+
decision.governance = governanceReceipt;
|
|
707
|
+
decision.safePathReceiptPath = null;
|
|
708
|
+
decision.safePath = safePathReceipt;
|
|
709
|
+
decision.installIntakeReceiptPath = null;
|
|
710
|
+
decision.installIntake = {
|
|
711
|
+
summary: intakeContext.receipt.summary,
|
|
712
|
+
matchedItems: intakeContext.matchedItems,
|
|
713
|
+
nextAction: intakeContext.safeNextAction || intakeContext.receipt.nextAction,
|
|
714
|
+
topReasonCodes: intakeContext.receipt.topReasonCodes || [],
|
|
715
|
+
};
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
return decision;
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
function buildPlanSecuritySurface(cwd, options = {}) {
|
|
722
|
+
const plan = String(options.plan || getCurrentPlan({ cwd })).trim().toLowerCase() === "pro" ? "pro" : "free";
|
|
723
|
+
const profile = buildPolicyProfile({ cwd, plan });
|
|
724
|
+
const description = describePolicyProfile(profile);
|
|
725
|
+
const latestEvidence = summarizeEnforcementEvidence(cwd);
|
|
726
|
+
|
|
727
|
+
return {
|
|
728
|
+
plan,
|
|
729
|
+
headline: "Powerful AI agents, safer by default.",
|
|
730
|
+
customerPromise: "Avorelo helps protect AI coding workflows with prompt-injection defense, risky-skill detection, destructive-action blocking, and local evidence, while access-reduction paths stay scoped to the surfaces that support them.",
|
|
731
|
+
mode: profile.mode,
|
|
732
|
+
profileId: profile.profileId,
|
|
733
|
+
zeroStandingPermissions: profile.zeroStandingPermissions === true,
|
|
734
|
+
scopedJitStyleAccess: profile.scopedJitStyleAccess === true,
|
|
735
|
+
enforcementAvailability: profile.enforcementAvailable,
|
|
736
|
+
headlineLine: description.headline,
|
|
737
|
+
postureLine: plan === "pro"
|
|
738
|
+
? "Security posture: approve/enforce where supported."
|
|
739
|
+
: "Security posture: visibility and warnings first, with blocks for clearly unsafe actions.",
|
|
740
|
+
summary: description.summary,
|
|
741
|
+
latestEvidence,
|
|
742
|
+
};
|
|
743
|
+
}
|
|
744
|
+
|
|
745
|
+
module.exports = {
|
|
746
|
+
DECISIONS,
|
|
747
|
+
EVIDENCE_DIR_REL_PATH,
|
|
748
|
+
LATEST_EVIDENCE_REL_PATH,
|
|
749
|
+
HISTORY_DIR_REL_PATH,
|
|
750
|
+
EVENT_LOG_REL_PATH,
|
|
751
|
+
redactSecrets,
|
|
752
|
+
classifyAction,
|
|
753
|
+
getMatchedRules,
|
|
754
|
+
buildDecision,
|
|
755
|
+
writeEnforcementEvidence,
|
|
756
|
+
readLatestEnforcementEvidence,
|
|
757
|
+
summarizeEnforcementEvidence,
|
|
758
|
+
explainDecision,
|
|
759
|
+
isApprovalRequired,
|
|
760
|
+
isBlocked,
|
|
761
|
+
evaluateAgentAction,
|
|
762
|
+
buildPlanSecuritySurface,
|
|
763
|
+
buildAgentAccessGovernanceSurface,
|
|
764
|
+
buildSafePathSurface,
|
|
765
|
+
};
|