muonroi-cli 1.2.0
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 +21 -0
- package/README.md +380 -0
- package/dist/__test-stubs__/ee-server.d.ts +27 -0
- package/dist/__test-stubs__/ee-server.js +138 -0
- package/dist/__test-stubs__/ee-server.js.map +1 -0
- package/dist/billing/index.d.ts +5 -0
- package/dist/billing/index.js +2 -0
- package/dist/billing/index.js.map +1 -0
- package/dist/cloud/index.d.ts +5 -0
- package/dist/cloud/index.js +2 -0
- package/dist/cloud/index.js.map +1 -0
- package/dist/daemon/scheduler.d.ts +15 -0
- package/dist/daemon/scheduler.js +126 -0
- package/dist/daemon/scheduler.js.map +1 -0
- package/dist/daemon/scheduler.test.d.ts +1 -0
- package/dist/daemon/scheduler.test.js +103 -0
- package/dist/daemon/scheduler.test.js.map +1 -0
- package/dist/ee/__tests__/pipeline.integration.test.d.ts +14 -0
- package/dist/ee/__tests__/pipeline.integration.test.js +151 -0
- package/dist/ee/__tests__/pipeline.integration.test.js.map +1 -0
- package/dist/ee/auth.d.ts +19 -0
- package/dist/ee/auth.js +48 -0
- package/dist/ee/auth.js.map +1 -0
- package/dist/ee/auth.test.d.ts +1 -0
- package/dist/ee/auth.test.js +59 -0
- package/dist/ee/auth.test.js.map +1 -0
- package/dist/ee/bridge.d.ts +68 -0
- package/dist/ee/bridge.js +177 -0
- package/dist/ee/bridge.js.map +1 -0
- package/dist/ee/bridge.test.d.ts +1 -0
- package/dist/ee/bridge.test.js +231 -0
- package/dist/ee/bridge.test.js.map +1 -0
- package/dist/ee/client.d.ts +22 -0
- package/dist/ee/client.js +464 -0
- package/dist/ee/client.js.map +1 -0
- package/dist/ee/client.test.d.ts +1 -0
- package/dist/ee/client.test.js +151 -0
- package/dist/ee/client.test.js.map +1 -0
- package/dist/ee/embedding-cache.d.ts +7 -0
- package/dist/ee/embedding-cache.js +33 -0
- package/dist/ee/embedding-cache.js.map +1 -0
- package/dist/ee/extract-session.d.ts +17 -0
- package/dist/ee/extract-session.js +53 -0
- package/dist/ee/extract-session.js.map +1 -0
- package/dist/ee/extract-session.test.d.ts +1 -0
- package/dist/ee/extract-session.test.js +197 -0
- package/dist/ee/extract-session.test.js.map +1 -0
- package/dist/ee/health.d.ts +29 -0
- package/dist/ee/health.js +64 -0
- package/dist/ee/health.js.map +1 -0
- package/dist/ee/index.d.ts +10 -0
- package/dist/ee/index.js +9 -0
- package/dist/ee/index.js.map +1 -0
- package/dist/ee/intercept.d.ts +46 -0
- package/dist/ee/intercept.js +117 -0
- package/dist/ee/intercept.js.map +1 -0
- package/dist/ee/intercept.test.d.ts +1 -0
- package/dist/ee/intercept.test.js +170 -0
- package/dist/ee/intercept.test.js.map +1 -0
- package/dist/ee/judge.d.ts +36 -0
- package/dist/ee/judge.js +56 -0
- package/dist/ee/judge.js.map +1 -0
- package/dist/ee/judge.test.d.ts +1 -0
- package/dist/ee/judge.test.js +139 -0
- package/dist/ee/judge.test.js.map +1 -0
- package/dist/ee/offline-queue.d.ts +37 -0
- package/dist/ee/offline-queue.js +163 -0
- package/dist/ee/offline-queue.js.map +1 -0
- package/dist/ee/offline-queue.test.d.ts +1 -0
- package/dist/ee/offline-queue.test.js +246 -0
- package/dist/ee/offline-queue.test.js.map +1 -0
- package/dist/ee/posttool.d.ts +11 -0
- package/dist/ee/posttool.js +16 -0
- package/dist/ee/posttool.js.map +1 -0
- package/dist/ee/posttool.test.d.ts +1 -0
- package/dist/ee/posttool.test.js +70 -0
- package/dist/ee/posttool.test.js.map +1 -0
- package/dist/ee/prompt-stale.d.ts +20 -0
- package/dist/ee/prompt-stale.js +37 -0
- package/dist/ee/prompt-stale.js.map +1 -0
- package/dist/ee/prompt-stale.test.d.ts +8 -0
- package/dist/ee/prompt-stale.test.js +76 -0
- package/dist/ee/prompt-stale.test.js.map +1 -0
- package/dist/ee/render.d.ts +20 -0
- package/dist/ee/render.js +30 -0
- package/dist/ee/render.js.map +1 -0
- package/dist/ee/render.test.d.ts +1 -0
- package/dist/ee/render.test.js +61 -0
- package/dist/ee/render.test.js.map +1 -0
- package/dist/ee/scope.d.ts +6 -0
- package/dist/ee/scope.js +92 -0
- package/dist/ee/scope.js.map +1 -0
- package/dist/ee/scope.test.d.ts +1 -0
- package/dist/ee/scope.test.js +97 -0
- package/dist/ee/scope.test.js.map +1 -0
- package/dist/ee/tenant.d.ts +2 -0
- package/dist/ee/tenant.js +13 -0
- package/dist/ee/tenant.js.map +1 -0
- package/dist/ee/touch.test.d.ts +1 -0
- package/dist/ee/touch.test.js +60 -0
- package/dist/ee/touch.test.js.map +1 -0
- package/dist/ee/types.d.ts +300 -0
- package/dist/ee/types.js +14 -0
- package/dist/ee/types.js.map +1 -0
- package/dist/flow/__tests__/migration.test.d.ts +1 -0
- package/dist/flow/__tests__/migration.test.js +105 -0
- package/dist/flow/__tests__/migration.test.js.map +1 -0
- package/dist/flow/__tests__/parser.test.d.ts +1 -0
- package/dist/flow/__tests__/parser.test.js +68 -0
- package/dist/flow/__tests__/parser.test.js.map +1 -0
- package/dist/flow/__tests__/run-manager.test.d.ts +1 -0
- package/dist/flow/__tests__/run-manager.test.js +83 -0
- package/dist/flow/__tests__/run-manager.test.js.map +1 -0
- package/dist/flow/__tests__/scaffold.test.d.ts +1 -0
- package/dist/flow/__tests__/scaffold.test.js +47 -0
- package/dist/flow/__tests__/scaffold.test.js.map +1 -0
- package/dist/flow/__tests__/warning-persist.test.d.ts +5 -0
- package/dist/flow/__tests__/warning-persist.test.js +96 -0
- package/dist/flow/__tests__/warning-persist.test.js.map +1 -0
- package/dist/flow/artifact-io.d.ts +16 -0
- package/dist/flow/artifact-io.js +35 -0
- package/dist/flow/artifact-io.js.map +1 -0
- package/dist/flow/compaction/__tests__/compress.test.d.ts +1 -0
- package/dist/flow/compaction/__tests__/compress.test.js +63 -0
- package/dist/flow/compaction/__tests__/compress.test.js.map +1 -0
- package/dist/flow/compaction/__tests__/extract.test.d.ts +1 -0
- package/dist/flow/compaction/__tests__/extract.test.js +66 -0
- package/dist/flow/compaction/__tests__/extract.test.js.map +1 -0
- package/dist/flow/compaction/__tests__/preserve.test.d.ts +1 -0
- package/dist/flow/compaction/__tests__/preserve.test.js +62 -0
- package/dist/flow/compaction/__tests__/preserve.test.js.map +1 -0
- package/dist/flow/compaction/compress.d.ts +22 -0
- package/dist/flow/compaction/compress.js +47 -0
- package/dist/flow/compaction/compress.js.map +1 -0
- package/dist/flow/compaction/extract.d.ts +23 -0
- package/dist/flow/compaction/extract.js +46 -0
- package/dist/flow/compaction/extract.js.map +1 -0
- package/dist/flow/compaction/index.d.ts +23 -0
- package/dist/flow/compaction/index.js +63 -0
- package/dist/flow/compaction/index.js.map +1 -0
- package/dist/flow/compaction/preserve.d.ts +24 -0
- package/dist/flow/compaction/preserve.js +35 -0
- package/dist/flow/compaction/preserve.js.map +1 -0
- package/dist/flow/index.d.ts +12 -0
- package/dist/flow/index.js +16 -0
- package/dist/flow/index.js.map +1 -0
- package/dist/flow/migration.d.ts +23 -0
- package/dist/flow/migration.js +126 -0
- package/dist/flow/migration.js.map +1 -0
- package/dist/flow/parser.d.ts +27 -0
- package/dist/flow/parser.js +68 -0
- package/dist/flow/parser.js.map +1 -0
- package/dist/flow/run-manager.d.ts +36 -0
- package/dist/flow/run-manager.js +110 -0
- package/dist/flow/run-manager.js.map +1 -0
- package/dist/flow/scaffold.d.ts +22 -0
- package/dist/flow/scaffold.js +47 -0
- package/dist/flow/scaffold.js.map +1 -0
- package/dist/flow/warning-persist.d.ts +9 -0
- package/dist/flow/warning-persist.js +75 -0
- package/dist/flow/warning-persist.js.map +1 -0
- package/dist/gsd/__tests__/types.test.d.ts +1 -0
- package/dist/gsd/__tests__/types.test.js +65 -0
- package/dist/gsd/__tests__/types.test.js.map +1 -0
- package/dist/gsd/index.d.ts +1 -0
- package/dist/gsd/index.js +2 -0
- package/dist/gsd/index.js.map +1 -0
- package/dist/gsd/types.d.ts +4 -0
- package/dist/gsd/types.js +39 -0
- package/dist/gsd/types.js.map +1 -0
- package/dist/headless/output.d.ts +68 -0
- package/dist/headless/output.js +206 -0
- package/dist/headless/output.js.map +1 -0
- package/dist/headless/output.test.d.ts +1 -0
- package/dist/headless/output.test.js +178 -0
- package/dist/headless/output.test.js.map +1 -0
- package/dist/hooks/config.d.ts +18 -0
- package/dist/hooks/config.js +39 -0
- package/dist/hooks/config.js.map +1 -0
- package/dist/hooks/index.d.ts +44 -0
- package/dist/hooks/index.js +187 -0
- package/dist/hooks/index.js.map +1 -0
- package/dist/hooks/types.d.ts +130 -0
- package/dist/hooks/types.js +47 -0
- package/dist/hooks/types.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +512 -0
- package/dist/index.js.map +1 -0
- package/dist/lsp/builtins.d.ts +9 -0
- package/dist/lsp/builtins.js +351 -0
- package/dist/lsp/builtins.js.map +1 -0
- package/dist/lsp/builtins.test.d.ts +1 -0
- package/dist/lsp/builtins.test.js +91 -0
- package/dist/lsp/builtins.test.js.map +1 -0
- package/dist/lsp/client.d.ts +20 -0
- package/dist/lsp/client.js +290 -0
- package/dist/lsp/client.js.map +1 -0
- package/dist/lsp/manager.d.ts +20 -0
- package/dist/lsp/manager.js +235 -0
- package/dist/lsp/manager.js.map +1 -0
- package/dist/lsp/manager.test.d.ts +1 -0
- package/dist/lsp/manager.test.js +133 -0
- package/dist/lsp/manager.test.js.map +1 -0
- package/dist/lsp/npm-cache.d.ts +2 -0
- package/dist/lsp/npm-cache.js +105 -0
- package/dist/lsp/npm-cache.js.map +1 -0
- package/dist/lsp/npm-cache.test.d.ts +1 -0
- package/dist/lsp/npm-cache.test.js +53 -0
- package/dist/lsp/npm-cache.test.js.map +1 -0
- package/dist/lsp/runtime.d.ts +6 -0
- package/dist/lsp/runtime.js +53 -0
- package/dist/lsp/runtime.js.map +1 -0
- package/dist/lsp/smoke.test.d.ts +1 -0
- package/dist/lsp/smoke.test.js +56 -0
- package/dist/lsp/smoke.test.js.map +1 -0
- package/dist/lsp/types.d.ts +83 -0
- package/dist/lsp/types.js +12 -0
- package/dist/lsp/types.js.map +1 -0
- package/dist/mcp/auto-setup.d.ts +2 -0
- package/dist/mcp/auto-setup.js +76 -0
- package/dist/mcp/auto-setup.js.map +1 -0
- package/dist/mcp/catalog.d.ts +10 -0
- package/dist/mcp/catalog.js +121 -0
- package/dist/mcp/catalog.js.map +1 -0
- package/dist/mcp/oauth-callback.d.ts +9 -0
- package/dist/mcp/oauth-callback.js +49 -0
- package/dist/mcp/oauth-callback.js.map +1 -0
- package/dist/mcp/oauth-provider.d.ts +33 -0
- package/dist/mcp/oauth-provider.js +94 -0
- package/dist/mcp/oauth-provider.js.map +1 -0
- package/dist/mcp/parse-headers.d.ts +2 -0
- package/dist/mcp/parse-headers.js +33 -0
- package/dist/mcp/parse-headers.js.map +1 -0
- package/dist/mcp/parse-headers.test.d.ts +1 -0
- package/dist/mcp/parse-headers.test.js +43 -0
- package/dist/mcp/parse-headers.test.js.map +1 -0
- package/dist/mcp/runtime.d.ts +11 -0
- package/dist/mcp/runtime.js +81 -0
- package/dist/mcp/runtime.js.map +1 -0
- package/dist/mcp/smoke.test.d.ts +1 -0
- package/dist/mcp/smoke.test.js +159 -0
- package/dist/mcp/smoke.test.js.map +1 -0
- package/dist/mcp/validate.d.ts +9 -0
- package/dist/mcp/validate.js +39 -0
- package/dist/mcp/validate.js.map +1 -0
- package/dist/models/__tests__/registry.test.d.ts +1 -0
- package/dist/models/__tests__/registry.test.js +74 -0
- package/dist/models/__tests__/registry.test.js.map +1 -0
- package/dist/models/catalog-client.d.ts +21 -0
- package/dist/models/catalog-client.js +53 -0
- package/dist/models/catalog-client.js.map +1 -0
- package/dist/models/classify-tier.d.ts +2 -0
- package/dist/models/classify-tier.js +34 -0
- package/dist/models/classify-tier.js.map +1 -0
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.js +2 -0
- package/dist/models/index.js.map +1 -0
- package/dist/models/registry.d.ts +19 -0
- package/dist/models/registry.js +65 -0
- package/dist/models/registry.js.map +1 -0
- package/dist/ops/bug-report.d.ts +28 -0
- package/dist/ops/bug-report.js +67 -0
- package/dist/ops/bug-report.js.map +1 -0
- package/dist/ops/bug-report.test.d.ts +1 -0
- package/dist/ops/bug-report.test.js +148 -0
- package/dist/ops/bug-report.test.js.map +1 -0
- package/dist/ops/doctor.d.ts +16 -0
- package/dist/ops/doctor.js +162 -0
- package/dist/ops/doctor.js.map +1 -0
- package/dist/ops/doctor.test.d.ts +1 -0
- package/dist/ops/doctor.test.js +95 -0
- package/dist/ops/doctor.test.js.map +1 -0
- package/dist/orchestrator/__tests__/flow-resume.test.d.ts +5 -0
- package/dist/orchestrator/__tests__/flow-resume.test.js +61 -0
- package/dist/orchestrator/__tests__/flow-resume.test.js.map +1 -0
- package/dist/orchestrator/__tests__/route-feedback.test.d.ts +1 -0
- package/dist/orchestrator/__tests__/route-feedback.test.js +47 -0
- package/dist/orchestrator/__tests__/route-feedback.test.js.map +1 -0
- package/dist/orchestrator/abort.d.ts +29 -0
- package/dist/orchestrator/abort.js +31 -0
- package/dist/orchestrator/abort.js.map +1 -0
- package/dist/orchestrator/abort.test.d.ts +1 -0
- package/dist/orchestrator/abort.test.js +34 -0
- package/dist/orchestrator/abort.test.js.map +1 -0
- package/dist/orchestrator/agent.test.d.ts +1 -0
- package/dist/orchestrator/agent.test.js +126 -0
- package/dist/orchestrator/agent.test.js.map +1 -0
- package/dist/orchestrator/cleanup.test.d.ts +1 -0
- package/dist/orchestrator/cleanup.test.js +67 -0
- package/dist/orchestrator/cleanup.test.js.map +1 -0
- package/dist/orchestrator/compaction.d.ts +36 -0
- package/dist/orchestrator/compaction.js +375 -0
- package/dist/orchestrator/compaction.js.map +1 -0
- package/dist/orchestrator/compaction.test.d.ts +1 -0
- package/dist/orchestrator/compaction.test.js +105 -0
- package/dist/orchestrator/compaction.test.js.map +1 -0
- package/dist/orchestrator/delegations.d.ts +49 -0
- package/dist/orchestrator/delegations.js +283 -0
- package/dist/orchestrator/delegations.js.map +1 -0
- package/dist/orchestrator/delegations.test.d.ts +1 -0
- package/dist/orchestrator/delegations.test.js +107 -0
- package/dist/orchestrator/delegations.test.js.map +1 -0
- package/dist/orchestrator/flow-resume.d.ts +25 -0
- package/dist/orchestrator/flow-resume.js +53 -0
- package/dist/orchestrator/flow-resume.js.map +1 -0
- package/dist/orchestrator/orchestrator.d.ts +239 -0
- package/dist/orchestrator/orchestrator.js +3209 -0
- package/dist/orchestrator/orchestrator.js.map +1 -0
- package/dist/orchestrator/pending-calls.d.ts +75 -0
- package/dist/orchestrator/pending-calls.js +178 -0
- package/dist/orchestrator/pending-calls.js.map +1 -0
- package/dist/orchestrator/pending-calls.test.d.ts +1 -0
- package/dist/orchestrator/pending-calls.test.js +188 -0
- package/dist/orchestrator/pending-calls.test.js.map +1 -0
- package/dist/orchestrator/reasoning.d.ts +3 -0
- package/dist/orchestrator/reasoning.js +53 -0
- package/dist/orchestrator/reasoning.js.map +1 -0
- package/dist/orchestrator/reasoning.test.d.ts +1 -0
- package/dist/orchestrator/reasoning.test.js +26 -0
- package/dist/orchestrator/reasoning.test.js.map +1 -0
- package/dist/orchestrator/sandbox.test.d.ts +1 -0
- package/dist/orchestrator/sandbox.test.js +94 -0
- package/dist/orchestrator/sandbox.test.js.map +1 -0
- package/dist/pil/__tests__/budget.test.d.ts +1 -0
- package/dist/pil/__tests__/budget.test.js +33 -0
- package/dist/pil/__tests__/budget.test.js.map +1 -0
- package/dist/pil/__tests__/layer1-intent.test.d.ts +1 -0
- package/dist/pil/__tests__/layer1-intent.test.js +199 -0
- package/dist/pil/__tests__/layer1-intent.test.js.map +1 -0
- package/dist/pil/__tests__/layer2-personality.test.d.ts +1 -0
- package/dist/pil/__tests__/layer2-personality.test.js +57 -0
- package/dist/pil/__tests__/layer2-personality.test.js.map +1 -0
- package/dist/pil/__tests__/layer3-ee-injection.test.d.ts +1 -0
- package/dist/pil/__tests__/layer3-ee-injection.test.js +96 -0
- package/dist/pil/__tests__/layer3-ee-injection.test.js.map +1 -0
- package/dist/pil/__tests__/layer4-gsd.test.d.ts +1 -0
- package/dist/pil/__tests__/layer4-gsd.test.js +68 -0
- package/dist/pil/__tests__/layer4-gsd.test.js.map +1 -0
- package/dist/pil/__tests__/layer5-context.test.d.ts +1 -0
- package/dist/pil/__tests__/layer5-context.test.js +100 -0
- package/dist/pil/__tests__/layer5-context.test.js.map +1 -0
- package/dist/pil/__tests__/layer6-output.test.d.ts +1 -0
- package/dist/pil/__tests__/layer6-output.test.js +115 -0
- package/dist/pil/__tests__/layer6-output.test.js.map +1 -0
- package/dist/pil/__tests__/ollama-classify.test.d.ts +1 -0
- package/dist/pil/__tests__/ollama-classify.test.js +68 -0
- package/dist/pil/__tests__/ollama-classify.test.js.map +1 -0
- package/dist/pil/__tests__/orchestrator-integration.test.d.ts +10 -0
- package/dist/pil/__tests__/orchestrator-integration.test.js +98 -0
- package/dist/pil/__tests__/orchestrator-integration.test.js.map +1 -0
- package/dist/pil/__tests__/pipeline.test.d.ts +1 -0
- package/dist/pil/__tests__/pipeline.test.js +150 -0
- package/dist/pil/__tests__/pipeline.test.js.map +1 -0
- package/dist/pil/__tests__/response-tools.test.d.ts +1 -0
- package/dist/pil/__tests__/response-tools.test.js +133 -0
- package/dist/pil/__tests__/response-tools.test.js.map +1 -0
- package/dist/pil/__tests__/schema.test.d.ts +1 -0
- package/dist/pil/__tests__/schema.test.js +112 -0
- package/dist/pil/__tests__/schema.test.js.map +1 -0
- package/dist/pil/__tests__/store.test.d.ts +1 -0
- package/dist/pil/__tests__/store.test.js +44 -0
- package/dist/pil/__tests__/store.test.js.map +1 -0
- package/dist/pil/__tests__/task-tier-map.test.d.ts +1 -0
- package/dist/pil/__tests__/task-tier-map.test.js +33 -0
- package/dist/pil/__tests__/task-tier-map.test.js.map +1 -0
- package/dist/pil/budget.d.ts +8 -0
- package/dist/pil/budget.js +17 -0
- package/dist/pil/budget.js.map +1 -0
- package/dist/pil/index.d.ts +11 -0
- package/dist/pil/index.js +11 -0
- package/dist/pil/index.js.map +1 -0
- package/dist/pil/layer1-intent.d.ts +13 -0
- package/dist/pil/layer1-intent.js +142 -0
- package/dist/pil/layer1-intent.js.map +1 -0
- package/dist/pil/layer2-personality.d.ts +2 -0
- package/dist/pil/layer2-personality.js +29 -0
- package/dist/pil/layer2-personality.js.map +1 -0
- package/dist/pil/layer3-ee-injection.d.ts +10 -0
- package/dist/pil/layer3-ee-injection.js +72 -0
- package/dist/pil/layer3-ee-injection.js.map +1 -0
- package/dist/pil/layer4-gsd.d.ts +2 -0
- package/dist/pil/layer4-gsd.js +64 -0
- package/dist/pil/layer4-gsd.js.map +1 -0
- package/dist/pil/layer5-context.d.ts +2 -0
- package/dist/pil/layer5-context.js +124 -0
- package/dist/pil/layer5-context.js.map +1 -0
- package/dist/pil/layer6-output.d.ts +18 -0
- package/dist/pil/layer6-output.js +105 -0
- package/dist/pil/layer6-output.js.map +1 -0
- package/dist/pil/ollama-classify.d.ts +13 -0
- package/dist/pil/ollama-classify.js +38 -0
- package/dist/pil/ollama-classify.js.map +1 -0
- package/dist/pil/pipeline.d.ts +16 -0
- package/dist/pil/pipeline.js +96 -0
- package/dist/pil/pipeline.js.map +1 -0
- package/dist/pil/response-tools.d.ts +63 -0
- package/dist/pil/response-tools.js +87 -0
- package/dist/pil/response-tools.js.map +1 -0
- package/dist/pil/schema.d.ts +80 -0
- package/dist/pil/schema.js +43 -0
- package/dist/pil/schema.js.map +1 -0
- package/dist/pil/store.d.ts +12 -0
- package/dist/pil/store.js +21 -0
- package/dist/pil/store.js.map +1 -0
- package/dist/pil/task-tier-map.d.ts +30 -0
- package/dist/pil/task-tier-map.js +83 -0
- package/dist/pil/task-tier-map.js.map +1 -0
- package/dist/pil/timeout.d.ts +7 -0
- package/dist/pil/timeout.js +10 -0
- package/dist/pil/timeout.js.map +1 -0
- package/dist/pil/types.d.ts +39 -0
- package/dist/pil/types.js +7 -0
- package/dist/pil/types.js.map +1 -0
- package/dist/providers/__test-utils__/load-fixture.d.ts +9 -0
- package/dist/providers/__test-utils__/load-fixture.js +34 -0
- package/dist/providers/__test-utils__/load-fixture.js.map +1 -0
- package/dist/providers/__tests__/runtime-integration.test.d.ts +1 -0
- package/dist/providers/__tests__/runtime-integration.test.js +71 -0
- package/dist/providers/__tests__/runtime-integration.test.js.map +1 -0
- package/dist/providers/__tests__/runtime.test.d.ts +1 -0
- package/dist/providers/__tests__/runtime.test.js +76 -0
- package/dist/providers/__tests__/runtime.test.js.map +1 -0
- package/dist/providers/adapter.d.ts +15 -0
- package/dist/providers/adapter.js +45 -0
- package/dist/providers/adapter.js.map +1 -0
- package/dist/providers/adapter.test.d.ts +1 -0
- package/dist/providers/adapter.test.js +19 -0
- package/dist/providers/adapter.test.js.map +1 -0
- package/dist/providers/anthropic.d.ts +53 -0
- package/dist/providers/anthropic.js +141 -0
- package/dist/providers/anthropic.js.map +1 -0
- package/dist/providers/errors.d.ts +18 -0
- package/dist/providers/errors.js +36 -0
- package/dist/providers/errors.js.map +1 -0
- package/dist/providers/errors.test.d.ts +1 -0
- package/dist/providers/errors.test.js +66 -0
- package/dist/providers/errors.test.js.map +1 -0
- package/dist/providers/gemini.d.ts +11 -0
- package/dist/providers/gemini.js +33 -0
- package/dist/providers/gemini.js.map +1 -0
- package/dist/providers/gemini.test.d.ts +1 -0
- package/dist/providers/gemini.test.js +37 -0
- package/dist/providers/gemini.test.js.map +1 -0
- package/dist/providers/index.d.ts +11 -0
- package/dist/providers/index.js +15 -0
- package/dist/providers/index.js.map +1 -0
- package/dist/providers/keychain.d.ts +32 -0
- package/dist/providers/keychain.js +127 -0
- package/dist/providers/keychain.js.map +1 -0
- package/dist/providers/keychain.test.d.ts +1 -0
- package/dist/providers/keychain.test.js +80 -0
- package/dist/providers/keychain.test.js.map +1 -0
- package/dist/providers/ollama.d.ts +13 -0
- package/dist/providers/ollama.js +33 -0
- package/dist/providers/ollama.js.map +1 -0
- package/dist/providers/ollama.test.d.ts +1 -0
- package/dist/providers/ollama.test.js +37 -0
- package/dist/providers/ollama.test.js.map +1 -0
- package/dist/providers/openai-compatible.d.ts +15 -0
- package/dist/providers/openai-compatible.js +45 -0
- package/dist/providers/openai-compatible.js.map +1 -0
- package/dist/providers/openai-compatible.test.d.ts +1 -0
- package/dist/providers/openai-compatible.test.js +53 -0
- package/dist/providers/openai-compatible.test.js.map +1 -0
- package/dist/providers/openai.d.ts +11 -0
- package/dist/providers/openai.js +33 -0
- package/dist/providers/openai.js.map +1 -0
- package/dist/providers/openai.test.d.ts +1 -0
- package/dist/providers/openai.test.js +53 -0
- package/dist/providers/openai.test.js.map +1 -0
- package/dist/providers/patch-zod-schema.d.ts +24 -0
- package/dist/providers/patch-zod-schema.js +121 -0
- package/dist/providers/patch-zod-schema.js.map +1 -0
- package/dist/providers/pricing.d.ts +21 -0
- package/dist/providers/pricing.js +50 -0
- package/dist/providers/pricing.js.map +1 -0
- package/dist/providers/pricing.test.d.ts +1 -0
- package/dist/providers/pricing.test.js +47 -0
- package/dist/providers/pricing.test.js.map +1 -0
- package/dist/providers/runtime.d.ts +21 -0
- package/dist/providers/runtime.js +83 -0
- package/dist/providers/runtime.js.map +1 -0
- package/dist/providers/stream-loop.d.ts +16 -0
- package/dist/providers/stream-loop.js +63 -0
- package/dist/providers/stream-loop.js.map +1 -0
- package/dist/providers/types.d.ts +106 -0
- package/dist/providers/types.js +12 -0
- package/dist/providers/types.js.map +1 -0
- package/dist/providers/vision-proxy.d.ts +23 -0
- package/dist/providers/vision-proxy.js +152 -0
- package/dist/providers/vision-proxy.js.map +1 -0
- package/dist/providers/vision-proxy.test.d.ts +1 -0
- package/dist/providers/vision-proxy.test.js +136 -0
- package/dist/providers/vision-proxy.test.js.map +1 -0
- package/dist/router/classifier/grammars.d.ts +3 -0
- package/dist/router/classifier/grammars.js +14 -0
- package/dist/router/classifier/grammars.js.map +1 -0
- package/dist/router/classifier/index.d.ts +3 -0
- package/dist/router/classifier/index.js +19 -0
- package/dist/router/classifier/index.js.map +1 -0
- package/dist/router/classifier/index.test.d.ts +1 -0
- package/dist/router/classifier/index.test.js +29 -0
- package/dist/router/classifier/index.test.js.map +1 -0
- package/dist/router/classifier/regex.d.ts +2 -0
- package/dist/router/classifier/regex.js +45 -0
- package/dist/router/classifier/regex.js.map +1 -0
- package/dist/router/classifier/regex.test.d.ts +1 -0
- package/dist/router/classifier/regex.test.js +42 -0
- package/dist/router/classifier/regex.test.js.map +1 -0
- package/dist/router/classifier/tree-sitter.d.ts +5 -0
- package/dist/router/classifier/tree-sitter.js +84 -0
- package/dist/router/classifier/tree-sitter.js.map +1 -0
- package/dist/router/classifier/tree-sitter.test.d.ts +1 -0
- package/dist/router/classifier/tree-sitter.test.js +23 -0
- package/dist/router/classifier/tree-sitter.test.js.map +1 -0
- package/dist/router/cold.d.ts +7 -0
- package/dist/router/cold.js +21 -0
- package/dist/router/cold.js.map +1 -0
- package/dist/router/cold.test.d.ts +1 -0
- package/dist/router/cold.test.js +56 -0
- package/dist/router/cold.test.js.map +1 -0
- package/dist/router/decide.d.ts +42 -0
- package/dist/router/decide.js +300 -0
- package/dist/router/decide.js.map +1 -0
- package/dist/router/decide.test.d.ts +1 -0
- package/dist/router/decide.test.js +116 -0
- package/dist/router/decide.test.js.map +1 -0
- package/dist/router/health.d.ts +10 -0
- package/dist/router/health.js +44 -0
- package/dist/router/health.js.map +1 -0
- package/dist/router/health.test.d.ts +1 -0
- package/dist/router/health.test.js +52 -0
- package/dist/router/health.test.js.map +1 -0
- package/dist/router/store.d.ts +24 -0
- package/dist/router/store.js +27 -0
- package/dist/router/store.js.map +1 -0
- package/dist/router/types.d.ts +18 -0
- package/dist/router/types.js +2 -0
- package/dist/router/types.js.map +1 -0
- package/dist/router/warm.d.ts +7 -0
- package/dist/router/warm.js +40 -0
- package/dist/router/warm.js.map +1 -0
- package/dist/router/warm.test.d.ts +1 -0
- package/dist/router/warm.test.js +144 -0
- package/dist/router/warm.test.js.map +1 -0
- package/dist/storage/__tests__/migrations.test.d.ts +12 -0
- package/dist/storage/__tests__/migrations.test.js +357 -0
- package/dist/storage/__tests__/migrations.test.js.map +1 -0
- package/dist/storage/atomic-io.d.ts +18 -0
- package/dist/storage/atomic-io.js +65 -0
- package/dist/storage/atomic-io.js.map +1 -0
- package/dist/storage/atomic-io.test.d.ts +1 -0
- package/dist/storage/atomic-io.test.js +49 -0
- package/dist/storage/atomic-io.test.js.map +1 -0
- package/dist/storage/config.d.ts +22 -0
- package/dist/storage/config.js +35 -0
- package/dist/storage/config.js.map +1 -0
- package/dist/storage/config.test.d.ts +1 -0
- package/dist/storage/config.test.js +29 -0
- package/dist/storage/config.test.js.map +1 -0
- package/dist/storage/db.d.ts +18 -0
- package/dist/storage/db.js +71 -0
- package/dist/storage/db.js.map +1 -0
- package/dist/storage/index.d.ts +8 -0
- package/dist/storage/index.js +10 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/storage/migrations.d.ts +2 -0
- package/dist/storage/migrations.js +138 -0
- package/dist/storage/migrations.js.map +1 -0
- package/dist/storage/session-dir.d.ts +27 -0
- package/dist/storage/session-dir.js +36 -0
- package/dist/storage/session-dir.js.map +1 -0
- package/dist/storage/sessions.d.ts +16 -0
- package/dist/storage/sessions.js +142 -0
- package/dist/storage/sessions.js.map +1 -0
- package/dist/storage/tool-results.d.ts +4 -0
- package/dist/storage/tool-results.js +50 -0
- package/dist/storage/tool-results.js.map +1 -0
- package/dist/storage/transcript-view.d.ts +14 -0
- package/dist/storage/transcript-view.js +23 -0
- package/dist/storage/transcript-view.js.map +1 -0
- package/dist/storage/transcript.d.ts +12 -0
- package/dist/storage/transcript.js +269 -0
- package/dist/storage/transcript.js.map +1 -0
- package/dist/storage/transcript.test.d.ts +1 -0
- package/dist/storage/transcript.test.js +22 -0
- package/dist/storage/transcript.test.js.map +1 -0
- package/dist/storage/usage-cap.d.ts +34 -0
- package/dist/storage/usage-cap.js +54 -0
- package/dist/storage/usage-cap.js.map +1 -0
- package/dist/storage/usage-cap.test.d.ts +1 -0
- package/dist/storage/usage-cap.test.js +51 -0
- package/dist/storage/usage-cap.test.js.map +1 -0
- package/dist/storage/usage.d.ts +11 -0
- package/dist/storage/usage.js +65 -0
- package/dist/storage/usage.js.map +1 -0
- package/dist/storage/workspaces.d.ts +9 -0
- package/dist/storage/workspaces.js +60 -0
- package/dist/storage/workspaces.js.map +1 -0
- package/dist/tools/bash.d.ts +46 -0
- package/dist/tools/bash.js +541 -0
- package/dist/tools/bash.js.map +1 -0
- package/dist/tools/bash.test.d.ts +1 -0
- package/dist/tools/bash.test.js +240 -0
- package/dist/tools/bash.test.js.map +1 -0
- package/dist/tools/computer.d.ts +88 -0
- package/dist/tools/computer.js +443 -0
- package/dist/tools/computer.js.map +1 -0
- package/dist/tools/computer.test.d.ts +1 -0
- package/dist/tools/computer.test.js +142 -0
- package/dist/tools/computer.test.js.map +1 -0
- package/dist/tools/file.d.ts +17 -0
- package/dist/tools/file.js +101 -0
- package/dist/tools/file.js.map +1 -0
- package/dist/tools/file.test.d.ts +1 -0
- package/dist/tools/file.test.js +58 -0
- package/dist/tools/file.test.js.map +1 -0
- package/dist/tools/grep.d.ts +8 -0
- package/dist/tools/grep.js +144 -0
- package/dist/tools/grep.js.map +1 -0
- package/dist/tools/registry.d.ts +19 -0
- package/dist/tools/registry.js +245 -0
- package/dist/tools/registry.js.map +1 -0
- package/dist/tools/schedule.d.ts +85 -0
- package/dist/tools/schedule.js +498 -0
- package/dist/tools/schedule.js.map +1 -0
- package/dist/tools/schedule.test.d.ts +1 -0
- package/dist/tools/schedule.test.js +118 -0
- package/dist/tools/schedule.test.js.map +1 -0
- package/dist/types/index.d.ts +279 -0
- package/dist/types/index.js +6 -0
- package/dist/types/index.js.map +1 -0
- package/dist/ui/agents-modal.d.ts +36 -0
- package/dist/ui/agents-modal.js +54 -0
- package/dist/ui/agents-modal.js.map +1 -0
- package/dist/ui/app.d.ts +31 -0
- package/dist/ui/app.js +3957 -0
- package/dist/ui/app.js.map +1 -0
- package/dist/ui/components/SuggestionOverlay.d.ts +6 -0
- package/dist/ui/components/SuggestionOverlay.js +12 -0
- package/dist/ui/components/SuggestionOverlay.js.map +1 -0
- package/dist/ui/components/btw-overlay.d.ts +11 -0
- package/dist/ui/components/btw-overlay.js +16 -0
- package/dist/ui/components/btw-overlay.js.map +1 -0
- package/dist/ui/hooks/useTypeahead.d.ts +18 -0
- package/dist/ui/hooks/useTypeahead.js +111 -0
- package/dist/ui/hooks/useTypeahead.js.map +1 -0
- package/dist/ui/markdown.d.ts +5 -0
- package/dist/ui/markdown.js +38 -0
- package/dist/ui/markdown.js.map +1 -0
- package/dist/ui/mcp-modal-types.d.ts +24 -0
- package/dist/ui/mcp-modal-types.js +13 -0
- package/dist/ui/mcp-modal-types.js.map +1 -0
- package/dist/ui/mcp-modal.d.ts +33 -0
- package/dist/ui/mcp-modal.js +94 -0
- package/dist/ui/mcp-modal.js.map +1 -0
- package/dist/ui/plan.d.ts +24 -0
- package/dist/ui/plan.js +122 -0
- package/dist/ui/plan.js.map +1 -0
- package/dist/ui/schedule-modal.d.ts +15 -0
- package/dist/ui/schedule-modal.js +36 -0
- package/dist/ui/schedule-modal.js.map +1 -0
- package/dist/ui/slash/__tests__/clear.test.d.ts +1 -0
- package/dist/ui/slash/__tests__/clear.test.js +58 -0
- package/dist/ui/slash/__tests__/clear.test.js.map +1 -0
- package/dist/ui/slash/__tests__/compact.test.d.ts +1 -0
- package/dist/ui/slash/__tests__/compact.test.js +43 -0
- package/dist/ui/slash/__tests__/compact.test.js.map +1 -0
- package/dist/ui/slash/__tests__/cost.test.d.ts +1 -0
- package/dist/ui/slash/__tests__/cost.test.js +54 -0
- package/dist/ui/slash/__tests__/cost.test.js.map +1 -0
- package/dist/ui/slash/__tests__/discuss.test.d.ts +1 -0
- package/dist/ui/slash/__tests__/discuss.test.js +83 -0
- package/dist/ui/slash/__tests__/discuss.test.js.map +1 -0
- package/dist/ui/slash/__tests__/execute.test.d.ts +1 -0
- package/dist/ui/slash/__tests__/execute.test.js +71 -0
- package/dist/ui/slash/__tests__/execute.test.js.map +1 -0
- package/dist/ui/slash/__tests__/expand.test.d.ts +1 -0
- package/dist/ui/slash/__tests__/expand.test.js +67 -0
- package/dist/ui/slash/__tests__/expand.test.js.map +1 -0
- package/dist/ui/slash/__tests__/optimize.test.d.ts +1 -0
- package/dist/ui/slash/__tests__/optimize.test.js +130 -0
- package/dist/ui/slash/__tests__/optimize.test.js.map +1 -0
- package/dist/ui/slash/__tests__/plan.test.d.ts +1 -0
- package/dist/ui/slash/__tests__/plan.test.js +79 -0
- package/dist/ui/slash/__tests__/plan.test.js.map +1 -0
- package/dist/ui/slash/clear.d.ts +11 -0
- package/dist/ui/slash/clear.js +77 -0
- package/dist/ui/slash/clear.js.map +1 -0
- package/dist/ui/slash/compact.d.ts +11 -0
- package/dist/ui/slash/compact.js +40 -0
- package/dist/ui/slash/compact.js.map +1 -0
- package/dist/ui/slash/cost.d.ts +11 -0
- package/dist/ui/slash/cost.js +55 -0
- package/dist/ui/slash/cost.js.map +1 -0
- package/dist/ui/slash/council.d.ts +2 -0
- package/dist/ui/slash/council.js +22 -0
- package/dist/ui/slash/council.js.map +1 -0
- package/dist/ui/slash/debug.d.ts +45 -0
- package/dist/ui/slash/debug.js +111 -0
- package/dist/ui/slash/debug.js.map +1 -0
- package/dist/ui/slash/discuss.d.ts +11 -0
- package/dist/ui/slash/discuss.js +59 -0
- package/dist/ui/slash/discuss.js.map +1 -0
- package/dist/ui/slash/ee.d.ts +10 -0
- package/dist/ui/slash/ee.js +247 -0
- package/dist/ui/slash/ee.js.map +1 -0
- package/dist/ui/slash/execute.d.ts +12 -0
- package/dist/ui/slash/execute.js +36 -0
- package/dist/ui/slash/execute.js.map +1 -0
- package/dist/ui/slash/expand.d.ts +11 -0
- package/dist/ui/slash/expand.js +42 -0
- package/dist/ui/slash/expand.js.map +1 -0
- package/dist/ui/slash/optimize.d.ts +12 -0
- package/dist/ui/slash/optimize.js +37 -0
- package/dist/ui/slash/optimize.js.map +1 -0
- package/dist/ui/slash/plan.d.ts +11 -0
- package/dist/ui/slash/plan.js +48 -0
- package/dist/ui/slash/plan.js.map +1 -0
- package/dist/ui/slash/registry.d.ts +23 -0
- package/dist/ui/slash/registry.js +26 -0
- package/dist/ui/slash/registry.js.map +1 -0
- package/dist/ui/slash/route.d.ts +12 -0
- package/dist/ui/slash/route.js +35 -0
- package/dist/ui/slash/route.js.map +1 -0
- package/dist/ui/slash/route.test.d.ts +1 -0
- package/dist/ui/slash/route.test.js +70 -0
- package/dist/ui/slash/route.test.js.map +1 -0
- package/dist/ui/status-bar/index.d.ts +14 -0
- package/dist/ui/status-bar/index.js +74 -0
- package/dist/ui/status-bar/index.js.map +1 -0
- package/dist/ui/status-bar/index.test.d.ts +1 -0
- package/dist/ui/status-bar/index.test.js +80 -0
- package/dist/ui/status-bar/index.test.js.map +1 -0
- package/dist/ui/status-bar/store.d.ts +38 -0
- package/dist/ui/status-bar/store.js +144 -0
- package/dist/ui/status-bar/store.js.map +1 -0
- package/dist/ui/status-bar/store.test.d.ts +1 -0
- package/dist/ui/status-bar/store.test.js +116 -0
- package/dist/ui/status-bar/store.test.js.map +1 -0
- package/dist/ui/status-bar/tier-badge.d.ts +11 -0
- package/dist/ui/status-bar/tier-badge.js +19 -0
- package/dist/ui/status-bar/tier-badge.js.map +1 -0
- package/dist/ui/status-bar/tier-badge.test.d.ts +1 -0
- package/dist/ui/status-bar/tier-badge.test.js +34 -0
- package/dist/ui/status-bar/tier-badge.test.js.map +1 -0
- package/dist/ui/status-bar/usd-meter.d.ts +13 -0
- package/dist/ui/status-bar/usd-meter.js +13 -0
- package/dist/ui/status-bar/usd-meter.js.map +1 -0
- package/dist/ui/status-bar/usd-meter.test.d.ts +1 -0
- package/dist/ui/status-bar/usd-meter.test.js +32 -0
- package/dist/ui/status-bar/usd-meter.test.js.map +1 -0
- package/dist/ui/terminal-selection-text.d.ts +23 -0
- package/dist/ui/terminal-selection-text.js +59 -0
- package/dist/ui/terminal-selection-text.js.map +1 -0
- package/dist/ui/theme.d.ts +53 -0
- package/dist/ui/theme.js +53 -0
- package/dist/ui/theme.js.map +1 -0
- package/dist/usage/downgrade.d.ts +37 -0
- package/dist/usage/downgrade.js +49 -0
- package/dist/usage/downgrade.js.map +1 -0
- package/dist/usage/downgrade.test.d.ts +1 -0
- package/dist/usage/downgrade.test.js +67 -0
- package/dist/usage/downgrade.test.js.map +1 -0
- package/dist/usage/estimator.d.ts +17 -0
- package/dist/usage/estimator.js +28 -0
- package/dist/usage/estimator.js.map +1 -0
- package/dist/usage/estimator.test.d.ts +1 -0
- package/dist/usage/estimator.test.js +38 -0
- package/dist/usage/estimator.test.js.map +1 -0
- package/dist/usage/ledger.d.ts +42 -0
- package/dist/usage/ledger.js +181 -0
- package/dist/usage/ledger.js.map +1 -0
- package/dist/usage/ledger.test.d.ts +1 -0
- package/dist/usage/ledger.test.js +171 -0
- package/dist/usage/ledger.test.js.map +1 -0
- package/dist/usage/midstream.d.ts +24 -0
- package/dist/usage/midstream.js +45 -0
- package/dist/usage/midstream.js.map +1 -0
- package/dist/usage/midstream.test.d.ts +1 -0
- package/dist/usage/midstream.test.js +47 -0
- package/dist/usage/midstream.test.js.map +1 -0
- package/dist/usage/thresholds.d.ts +38 -0
- package/dist/usage/thresholds.js +54 -0
- package/dist/usage/thresholds.js.map +1 -0
- package/dist/usage/thresholds.test.d.ts +1 -0
- package/dist/usage/thresholds.test.js +77 -0
- package/dist/usage/thresholds.test.js.map +1 -0
- package/dist/usage/types.d.ts +30 -0
- package/dist/usage/types.js +21 -0
- package/dist/usage/types.js.map +1 -0
- package/dist/utils/at-mentions.d.ts +12 -0
- package/dist/utils/at-mentions.js +92 -0
- package/dist/utils/at-mentions.js.map +1 -0
- package/dist/utils/clipboard-image.d.ts +13 -0
- package/dist/utils/clipboard-image.js +121 -0
- package/dist/utils/clipboard-image.js.map +1 -0
- package/dist/utils/file-index.d.ts +13 -0
- package/dist/utils/file-index.js +143 -0
- package/dist/utils/file-index.js.map +1 -0
- package/dist/utils/git-root.d.ts +1 -0
- package/dist/utils/git-root.js +16 -0
- package/dist/utils/git-root.js.map +1 -0
- package/dist/utils/host-clipboard.d.ts +4 -0
- package/dist/utils/host-clipboard.js +32 -0
- package/dist/utils/host-clipboard.js.map +1 -0
- package/dist/utils/install-manager.d.ts +56 -0
- package/dist/utils/install-manager.js +340 -0
- package/dist/utils/install-manager.js.map +1 -0
- package/dist/utils/install-manager.test.d.ts +1 -0
- package/dist/utils/install-manager.test.js +127 -0
- package/dist/utils/install-manager.test.js.map +1 -0
- package/dist/utils/instructions.d.ts +3 -0
- package/dist/utils/instructions.js +107 -0
- package/dist/utils/instructions.js.map +1 -0
- package/dist/utils/instructions.test.d.ts +1 -0
- package/dist/utils/instructions.test.js +68 -0
- package/dist/utils/instructions.test.js.map +1 -0
- package/dist/utils/permission-mode.d.ts +24 -0
- package/dist/utils/permission-mode.js +29 -0
- package/dist/utils/permission-mode.js.map +1 -0
- package/dist/utils/permission-mode.test.d.ts +1 -0
- package/dist/utils/permission-mode.test.js +97 -0
- package/dist/utils/permission-mode.test.js.map +1 -0
- package/dist/utils/redactor.d.ts +57 -0
- package/dist/utils/redactor.js +179 -0
- package/dist/utils/redactor.js.map +1 -0
- package/dist/utils/redactor.test.d.ts +1 -0
- package/dist/utils/redactor.test.js +84 -0
- package/dist/utils/redactor.test.js.map +1 -0
- package/dist/utils/settings.d.ts +179 -0
- package/dist/utils/settings.js +579 -0
- package/dist/utils/settings.js.map +1 -0
- package/dist/utils/settings.test.d.ts +1 -0
- package/dist/utils/settings.test.js +160 -0
- package/dist/utils/settings.test.js.map +1 -0
- package/dist/utils/side-question.d.ts +10 -0
- package/dist/utils/side-question.js +24 -0
- package/dist/utils/side-question.js.map +1 -0
- package/dist/utils/skills.d.ts +20 -0
- package/dist/utils/skills.js +194 -0
- package/dist/utils/skills.js.map +1 -0
- package/dist/utils/skills.test.d.ts +1 -0
- package/dist/utils/skills.test.js +45 -0
- package/dist/utils/skills.test.js.map +1 -0
- package/dist/utils/subagent-display.d.ts +1 -0
- package/dist/utils/subagent-display.js +20 -0
- package/dist/utils/subagent-display.js.map +1 -0
- package/dist/utils/subagent-display.test.d.ts +1 -0
- package/dist/utils/subagent-display.test.js +21 -0
- package/dist/utils/subagent-display.test.js.map +1 -0
- package/dist/utils/subagents-settings.test.d.ts +1 -0
- package/dist/utils/subagents-settings.test.js +58 -0
- package/dist/utils/subagents-settings.test.js.map +1 -0
- package/dist/utils/telegram-audio-settings.test.d.ts +1 -0
- package/dist/utils/telegram-audio-settings.test.js +39 -0
- package/dist/utils/telegram-audio-settings.test.js.map +1 -0
- package/dist/utils/update-checker.d.ts +11 -0
- package/dist/utils/update-checker.js +22 -0
- package/dist/utils/update-checker.js.map +1 -0
- package/dist/utils/update-checker.test.d.ts +1 -0
- package/dist/utils/update-checker.test.js +125 -0
- package/dist/utils/update-checker.test.js.map +1 -0
- package/dist/verify/checkpoint.d.ts +11 -0
- package/dist/verify/checkpoint.js +202 -0
- package/dist/verify/checkpoint.js.map +1 -0
- package/dist/verify/checkpoint.test.d.ts +1 -0
- package/dist/verify/checkpoint.test.js +160 -0
- package/dist/verify/checkpoint.test.js.map +1 -0
- package/dist/verify/entrypoint.d.ts +30 -0
- package/dist/verify/entrypoint.js +349 -0
- package/dist/verify/entrypoint.js.map +1 -0
- package/dist/verify/entrypoint.test.d.ts +1 -0
- package/dist/verify/entrypoint.test.js +233 -0
- package/dist/verify/entrypoint.test.js.map +1 -0
- package/dist/verify/environment.d.ts +9 -0
- package/dist/verify/environment.js +116 -0
- package/dist/verify/environment.js.map +1 -0
- package/dist/verify/environment.test.d.ts +1 -0
- package/dist/verify/environment.test.js +94 -0
- package/dist/verify/environment.test.js.map +1 -0
- package/dist/verify/evidence.d.ts +10 -0
- package/dist/verify/evidence.js +94 -0
- package/dist/verify/evidence.js.map +1 -0
- package/dist/verify/orchestrator.d.ts +25 -0
- package/dist/verify/orchestrator.js +87 -0
- package/dist/verify/orchestrator.js.map +1 -0
- package/dist/verify/orchestrator.test.d.ts +1 -0
- package/dist/verify/orchestrator.test.js +126 -0
- package/dist/verify/orchestrator.test.js.map +1 -0
- package/dist/verify/recipes.d.ts +20 -0
- package/dist/verify/recipes.js +451 -0
- package/dist/verify/recipes.js.map +1 -0
- package/dist/verify/retry.d.ts +4 -0
- package/dist/verify/retry.js +50 -0
- package/dist/verify/retry.js.map +1 -0
- package/dist/verify/runtime-prep.test.d.ts +1 -0
- package/dist/verify/runtime-prep.test.js +38 -0
- package/dist/verify/runtime-prep.test.js.map +1 -0
- package/package.json +93 -0
- package/src/__test-stubs__/ee-server.ts +173 -0
- package/src/billing/index.ts +5 -0
- package/src/bun-sqlite.d.ts +15 -0
- package/src/cloud/index.ts +5 -0
- package/src/daemon/scheduler.test.ts +128 -0
- package/src/daemon/scheduler.ts +152 -0
- package/src/ee/.gitkeep +0 -0
- package/src/ee/__tests__/pipeline.integration.test.ts +193 -0
- package/src/ee/auth.test.ts +76 -0
- package/src/ee/auth.ts +59 -0
- package/src/ee/bridge.test.ts +290 -0
- package/src/ee/bridge.ts +254 -0
- package/src/ee/client.test.ts +171 -0
- package/src/ee/client.ts +512 -0
- package/src/ee/embedding-cache.ts +42 -0
- package/src/ee/extract-session.test.ts +236 -0
- package/src/ee/extract-session.ts +69 -0
- package/src/ee/health.ts +83 -0
- package/src/ee/index.ts +32 -0
- package/src/ee/intercept.test.ts +191 -0
- package/src/ee/intercept.ts +132 -0
- package/src/ee/judge.test.ts +157 -0
- package/src/ee/judge.ts +68 -0
- package/src/ee/offline-queue.test.ts +351 -0
- package/src/ee/offline-queue.ts +212 -0
- package/src/ee/posttool.test.ts +81 -0
- package/src/ee/posttool.ts +16 -0
- package/src/ee/prompt-stale.test.ts +87 -0
- package/src/ee/prompt-stale.ts +39 -0
- package/src/ee/render.test.ts +71 -0
- package/src/ee/render.ts +47 -0
- package/src/ee/scope.test.ts +112 -0
- package/src/ee/scope.ts +93 -0
- package/src/ee/tenant.ts +14 -0
- package/src/ee/touch.test.ts +71 -0
- package/src/ee/types.ts +322 -0
- package/src/flow/.gitkeep +0 -0
- package/src/flow/__tests__/migration.test.ts +133 -0
- package/src/flow/__tests__/parser.test.ts +77 -0
- package/src/flow/__tests__/run-manager.test.ts +95 -0
- package/src/flow/__tests__/scaffold.test.ts +57 -0
- package/src/flow/__tests__/warning-persist.test.ts +112 -0
- package/src/flow/artifact-io.ts +41 -0
- package/src/flow/compaction/__tests__/compress.test.ts +69 -0
- package/src/flow/compaction/__tests__/extract.test.ts +74 -0
- package/src/flow/compaction/__tests__/preserve.test.ts +69 -0
- package/src/flow/compaction/compress.ts +67 -0
- package/src/flow/compaction/extract.ts +60 -0
- package/src/flow/compaction/index.ts +86 -0
- package/src/flow/compaction/preserve.ts +48 -0
- package/src/flow/index.ts +18 -0
- package/src/flow/migration.ts +139 -0
- package/src/flow/parser.ts +78 -0
- package/src/flow/run-manager.ts +129 -0
- package/src/flow/scaffold.ts +52 -0
- package/src/flow/warning-persist.ts +84 -0
- package/src/gsd/.gitkeep +0 -0
- package/src/gsd/__tests__/types.test.ts +77 -0
- package/src/gsd/index.ts +1 -0
- package/src/gsd/types.ts +47 -0
- package/src/headless/output.test.ts +201 -0
- package/src/headless/output.ts +312 -0
- package/src/hooks/config.ts +41 -0
- package/src/hooks/index.ts +250 -0
- package/src/hooks/types.ts +221 -0
- package/src/index.ts +655 -0
- package/src/lsp/builtins.test.ts +104 -0
- package/src/lsp/builtins.ts +409 -0
- package/src/lsp/client.ts +342 -0
- package/src/lsp/manager.test.ts +164 -0
- package/src/lsp/manager.ts +293 -0
- package/src/lsp/npm-cache.test.ts +68 -0
- package/src/lsp/npm-cache.ts +108 -0
- package/src/lsp/runtime.ts +70 -0
- package/src/lsp/smoke.test.ts +72 -0
- package/src/lsp/types.ts +116 -0
- package/src/mcp/auto-setup.ts +80 -0
- package/src/mcp/catalog.ts +138 -0
- package/src/mcp/oauth-callback.ts +63 -0
- package/src/mcp/oauth-provider.ts +130 -0
- package/src/mcp/parse-headers.test.ts +54 -0
- package/src/mcp/parse-headers.ts +35 -0
- package/src/mcp/runtime.ts +113 -0
- package/src/mcp/smoke.test.ts +170 -0
- package/src/mcp/validate.ts +48 -0
- package/src/models/__tests__/registry.test.ts +95 -0
- package/src/models/catalog-client.ts +83 -0
- package/src/models/catalog.json +314 -0
- package/src/models/classify-tier.ts +37 -0
- package/src/models/index.ts +9 -0
- package/src/models/registry.ts +73 -0
- package/src/ops/bug-report.test.ts +172 -0
- package/src/ops/bug-report.ts +80 -0
- package/src/ops/doctor.test.ts +107 -0
- package/src/ops/doctor.ts +172 -0
- package/src/orchestrator/__tests__/flow-resume.test.ts +71 -0
- package/src/orchestrator/__tests__/route-feedback.test.ts +55 -0
- package/src/orchestrator/abort.test.ts +37 -0
- package/src/orchestrator/abort.ts +51 -0
- package/src/orchestrator/agent.test.ts +138 -0
- package/src/orchestrator/cleanup.test.ts +88 -0
- package/src/orchestrator/compaction.test.ts +134 -0
- package/src/orchestrator/compaction.ts +487 -0
- package/src/orchestrator/delegations.test.ts +145 -0
- package/src/orchestrator/delegations.ts +364 -0
- package/src/orchestrator/flow-resume.ts +55 -0
- package/src/orchestrator/orchestrator.ts +3965 -0
- package/src/orchestrator/pending-calls.test.ts +226 -0
- package/src/orchestrator/pending-calls.ts +240 -0
- package/src/orchestrator/reasoning.test.ts +29 -0
- package/src/orchestrator/reasoning.ts +64 -0
- package/src/orchestrator/sandbox.test.ts +115 -0
- package/src/pil/__tests__/budget.test.ts +39 -0
- package/src/pil/__tests__/layer1-intent.test.ts +243 -0
- package/src/pil/__tests__/layer2-personality.test.ts +63 -0
- package/src/pil/__tests__/layer3-ee-injection.test.ts +117 -0
- package/src/pil/__tests__/layer4-gsd.test.ts +76 -0
- package/src/pil/__tests__/layer5-context.test.ts +116 -0
- package/src/pil/__tests__/layer6-output.test.ts +139 -0
- package/src/pil/__tests__/ollama-classify.test.ts +81 -0
- package/src/pil/__tests__/orchestrator-integration.test.ts +107 -0
- package/src/pil/__tests__/pipeline.test.ts +173 -0
- package/src/pil/__tests__/response-tools.test.ts +165 -0
- package/src/pil/__tests__/schema.test.ts +128 -0
- package/src/pil/__tests__/store.test.ts +49 -0
- package/src/pil/__tests__/task-tier-map.test.ts +41 -0
- package/src/pil/budget.ts +18 -0
- package/src/pil/index.ts +12 -0
- package/src/pil/layer1-intent.ts +155 -0
- package/src/pil/layer2-personality.ts +37 -0
- package/src/pil/layer3-ee-injection.ts +79 -0
- package/src/pil/layer4-gsd.ts +77 -0
- package/src/pil/layer5-context.ts +125 -0
- package/src/pil/layer6-output.ts +113 -0
- package/src/pil/ollama-classify.ts +49 -0
- package/src/pil/pipeline.ts +112 -0
- package/src/pil/response-tools.ts +110 -0
- package/src/pil/schema.ts +49 -0
- package/src/pil/store.ts +29 -0
- package/src/pil/task-tier-map.ts +90 -0
- package/src/pil/timeout.ts +10 -0
- package/src/pil/types.ts +42 -0
- package/src/providers/.gitkeep +0 -0
- package/src/providers/__test-utils__/load-fixture.ts +36 -0
- package/src/providers/__tests__/runtime-integration.test.ts +80 -0
- package/src/providers/__tests__/runtime.test.ts +86 -0
- package/src/providers/adapter.test.ts +21 -0
- package/src/providers/adapter.ts +48 -0
- package/src/providers/anthropic.ts +169 -0
- package/src/providers/errors.test.ts +76 -0
- package/src/providers/errors.ts +46 -0
- package/src/providers/gemini.test.ts +46 -0
- package/src/providers/gemini.ts +37 -0
- package/src/providers/index.ts +32 -0
- package/src/providers/keychain.test.ts +95 -0
- package/src/providers/keychain.ts +133 -0
- package/src/providers/ollama.test.ts +46 -0
- package/src/providers/ollama.ts +36 -0
- package/src/providers/openai-compatible.test.ts +63 -0
- package/src/providers/openai-compatible.ts +50 -0
- package/src/providers/openai.test.ts +65 -0
- package/src/providers/openai.ts +37 -0
- package/src/providers/patch-zod-schema.ts +129 -0
- package/src/providers/pricing.test.ts +56 -0
- package/src/providers/pricing.ts +55 -0
- package/src/providers/runtime.ts +111 -0
- package/src/providers/stream-loop.ts +69 -0
- package/src/providers/types.ts +111 -0
- package/src/providers/vision-proxy.test.ts +167 -0
- package/src/providers/vision-proxy.ts +209 -0
- package/src/router/.gitkeep +0 -0
- package/src/router/classifier/grammars.ts +17 -0
- package/src/router/classifier/index.test.ts +33 -0
- package/src/router/classifier/index.ts +21 -0
- package/src/router/classifier/regex.test.ts +47 -0
- package/src/router/classifier/regex.ts +54 -0
- package/src/router/classifier/tree-sitter.test.ts +26 -0
- package/src/router/classifier/tree-sitter.ts +87 -0
- package/src/router/cold.test.ts +62 -0
- package/src/router/cold.ts +27 -0
- package/src/router/decide.test.ts +135 -0
- package/src/router/decide.ts +354 -0
- package/src/router/health.test.ts +59 -0
- package/src/router/health.ts +49 -0
- package/src/router/store.ts +47 -0
- package/src/router/types.ts +20 -0
- package/src/router/warm.test.ts +167 -0
- package/src/router/warm.ts +47 -0
- package/src/storage/__tests__/migrations.test.ts +395 -0
- package/src/storage/atomic-io.test.ts +61 -0
- package/src/storage/atomic-io.ts +62 -0
- package/src/storage/config.test.ts +33 -0
- package/src/storage/config.ts +49 -0
- package/src/storage/db.ts +95 -0
- package/src/storage/index.ts +19 -0
- package/src/storage/migrations.ts +143 -0
- package/src/storage/session-dir.ts +37 -0
- package/src/storage/sessions.ts +178 -0
- package/src/storage/tool-results.ts +56 -0
- package/src/storage/transcript-view.ts +45 -0
- package/src/storage/transcript.test.ts +24 -0
- package/src/storage/transcript.ts +358 -0
- package/src/storage/usage-cap.test.ts +59 -0
- package/src/storage/usage-cap.ts +81 -0
- package/src/storage/usage.ts +115 -0
- package/src/storage/workspaces.ts +84 -0
- package/src/tools/bash.test.ts +336 -0
- package/src/tools/bash.ts +612 -0
- package/src/tools/computer.test.ts +187 -0
- package/src/tools/computer.ts +632 -0
- package/src/tools/file.test.ts +95 -0
- package/src/tools/file.ts +128 -0
- package/src/tools/grep.ts +187 -0
- package/src/tools/registry.ts +282 -0
- package/src/tools/schedule.test.ts +143 -0
- package/src/tools/schedule.ts +610 -0
- package/src/types/index.ts +311 -0
- package/src/ui/agents-modal.tsx +272 -0
- package/src/ui/app.tsx +6277 -0
- package/src/ui/components/SuggestionOverlay.tsx +38 -0
- package/src/ui/components/btw-overlay.tsx +66 -0
- package/src/ui/hooks/useTypeahead.ts +146 -0
- package/src/ui/markdown.tsx +49 -0
- package/src/ui/mcp-modal-types.ts +33 -0
- package/src/ui/mcp-modal.tsx +456 -0
- package/src/ui/plan.tsx +346 -0
- package/src/ui/schedule-modal.tsx +126 -0
- package/src/ui/slash/__tests__/clear.test.ts +86 -0
- package/src/ui/slash/__tests__/compact.test.ts +56 -0
- package/src/ui/slash/__tests__/cost.test.ts +62 -0
- package/src/ui/slash/__tests__/discuss.test.ts +101 -0
- package/src/ui/slash/__tests__/execute.test.ts +86 -0
- package/src/ui/slash/__tests__/expand.test.ts +86 -0
- package/src/ui/slash/__tests__/optimize.test.ts +155 -0
- package/src/ui/slash/__tests__/plan.test.ts +95 -0
- package/src/ui/slash/clear.ts +89 -0
- package/src/ui/slash/compact.ts +46 -0
- package/src/ui/slash/cost.ts +59 -0
- package/src/ui/slash/council.ts +27 -0
- package/src/ui/slash/debug.ts +153 -0
- package/src/ui/slash/discuss.ts +71 -0
- package/src/ui/slash/ee.ts +271 -0
- package/src/ui/slash/execute.ts +44 -0
- package/src/ui/slash/expand.ts +51 -0
- package/src/ui/slash/optimize.ts +47 -0
- package/src/ui/slash/plan.ts +62 -0
- package/src/ui/slash/registry.ts +38 -0
- package/src/ui/slash/route.test.ts +82 -0
- package/src/ui/slash/route.ts +43 -0
- package/src/ui/status-bar/index.test.tsx +90 -0
- package/src/ui/status-bar/index.tsx +94 -0
- package/src/ui/status-bar/store.test.ts +131 -0
- package/src/ui/status-bar/store.ts +166 -0
- package/src/ui/status-bar/tier-badge.test.tsx +38 -0
- package/src/ui/status-bar/tier-badge.tsx +29 -0
- package/src/ui/status-bar/usd-meter.test.tsx +37 -0
- package/src/ui/status-bar/usd-meter.tsx +22 -0
- package/src/ui/terminal-selection-text.ts +72 -0
- package/src/ui/theme.ts +54 -0
- package/src/usage/.gitkeep +0 -0
- package/src/usage/downgrade.test.ts +82 -0
- package/src/usage/downgrade.ts +70 -0
- package/src/usage/estimator.test.ts +43 -0
- package/src/usage/estimator.ts +34 -0
- package/src/usage/ledger.test.ts +200 -0
- package/src/usage/ledger.ts +213 -0
- package/src/usage/midstream.test.ts +55 -0
- package/src/usage/midstream.ts +51 -0
- package/src/usage/thresholds.test.ts +83 -0
- package/src/usage/thresholds.ts +74 -0
- package/src/usage/types.ts +40 -0
- package/src/utils/at-mentions.ts +120 -0
- package/src/utils/clipboard-image.ts +114 -0
- package/src/utils/file-index.ts +152 -0
- package/src/utils/git-root.ts +17 -0
- package/src/utils/host-clipboard.ts +30 -0
- package/src/utils/install-manager.test.ts +167 -0
- package/src/utils/install-manager.ts +429 -0
- package/src/utils/instructions.test.ts +84 -0
- package/src/utils/instructions.ts +116 -0
- package/src/utils/permission-mode.test.ts +121 -0
- package/src/utils/permission-mode.ts +37 -0
- package/src/utils/redactor.test.ts +100 -0
- package/src/utils/redactor.ts +223 -0
- package/src/utils/settings.test.ts +181 -0
- package/src/utils/settings.ts +787 -0
- package/src/utils/side-question.ts +39 -0
- package/src/utils/skills.test.ts +58 -0
- package/src/utils/skills.ts +207 -0
- package/src/utils/subagent-display.test.ts +23 -0
- package/src/utils/subagent-display.ts +11 -0
- package/src/utils/subagents-settings.test.ts +77 -0
- package/src/utils/telegram-audio-settings.test.ts +44 -0
- package/src/utils/update-checker.test.ts +182 -0
- package/src/utils/update-checker.ts +33 -0
- package/src/verify/checkpoint.test.ts +186 -0
- package/src/verify/checkpoint.ts +239 -0
- package/src/verify/entrypoint.test.ts +293 -0
- package/src/verify/entrypoint.ts +439 -0
- package/src/verify/environment.test.ts +119 -0
- package/src/verify/environment.ts +115 -0
- package/src/verify/evidence.ts +104 -0
- package/src/verify/orchestrator.test.ts +159 -0
- package/src/verify/orchestrator.ts +129 -0
- package/src/verify/recipes.ts +516 -0
- package/src/verify/retry.ts +62 -0
- package/src/verify/runtime-prep.test.ts +47 -0
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Offline queue module for Experience Engine write operations.
|
|
3
|
+
*
|
|
4
|
+
* Persists failed EE requests (feedback, extract, prompt-stale) to disk so they
|
|
5
|
+
* survive process restarts and are replayed when EE recovers.
|
|
6
|
+
*
|
|
7
|
+
* Design decisions (from CONTEXT.md):
|
|
8
|
+
* - D-01: One JSON file per entry in ~/.muonroi-cli/ee-offline-queue/
|
|
9
|
+
* - D-02: Timestamp-based filenames for natural FIFO ordering
|
|
10
|
+
* - D-03: Each entry stores endpoint, body, enqueuedAt
|
|
11
|
+
* - D-04: Cap at 100 entries; oldest deleted before writing new
|
|
12
|
+
* - D-08: drainQueue() is fire-and-forget (returns void)
|
|
13
|
+
* - D-11: Queue directory created lazily on first enqueue
|
|
14
|
+
*
|
|
15
|
+
* NO imports from client.ts or intercept.ts (prevents circular deps).
|
|
16
|
+
* fetchImpl and headers are passed as parameters.
|
|
17
|
+
*/
|
|
18
|
+
import { promises as fs } from "node:fs";
|
|
19
|
+
import * as os from "node:os";
|
|
20
|
+
import * as path from "node:path";
|
|
21
|
+
|
|
22
|
+
// ─── Constants ────────────────────────────────────────────────────────────────
|
|
23
|
+
|
|
24
|
+
const MAX_QUEUE_SIZE = 100;
|
|
25
|
+
const QUEUE_DIR_NAME = "ee-offline-queue";
|
|
26
|
+
|
|
27
|
+
// ─── Types ────────────────────────────────────────────────────────────────────
|
|
28
|
+
|
|
29
|
+
/** Queue entry shape — self-contained, no external type deps. */
|
|
30
|
+
export interface QueueEntry {
|
|
31
|
+
endpoint: string; // e.g. "/api/feedback", "/api/extract", "/api/prompt-stale"
|
|
32
|
+
body: unknown; // original request payload verbatim
|
|
33
|
+
enqueuedAt: number; // Date.now() at enqueue time
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ─── Path helpers ─────────────────────────────────────────────────────────────
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* Returns the absolute path to the offline queue directory.
|
|
40
|
+
* Consistent with auth.ts homeOverride pattern.
|
|
41
|
+
*/
|
|
42
|
+
export function getQueueDir(homeOverride?: string): string {
|
|
43
|
+
return path.join(homeOverride ?? os.homedir(), ".muonroi-cli", QUEUE_DIR_NAME);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// ─── Internal helpers ─────────────────────────────────────────────────────────
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Generate a unique filename for a new queue entry.
|
|
50
|
+
* Format: `{Date.now()}-{random4}.json` (D-02)
|
|
51
|
+
* The timestamp prefix ensures natural FIFO ordering on readdir + sort.
|
|
52
|
+
*/
|
|
53
|
+
function makeFilename(): string {
|
|
54
|
+
const ts = Date.now();
|
|
55
|
+
const rnd = Math.random().toString(36).slice(2, 6);
|
|
56
|
+
return `${ts}-${rnd}.json`;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Returns sorted list of .json filenames in the queue directory.
|
|
61
|
+
* Lexicographic sort on timestamp-prefixed names = chronological FIFO order.
|
|
62
|
+
*
|
|
63
|
+
* Throws ENOENT if directory does not exist — callers handle this.
|
|
64
|
+
*/
|
|
65
|
+
async function getSortedFiles(dir: string): Promise<string[]> {
|
|
66
|
+
const entries = await fs.readdir(dir);
|
|
67
|
+
return entries.filter((f) => f.endsWith(".json")).sort();
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
// ─── Public API ───────────────────────────────────────────────────────────────
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* Persists a failed EE request to the local queue.
|
|
74
|
+
*
|
|
75
|
+
* Creates queue directory lazily (D-11).
|
|
76
|
+
* Enforces MAX_QUEUE_SIZE cap by deleting oldest entry (D-04).
|
|
77
|
+
*/
|
|
78
|
+
export async function enqueue(entry: QueueEntry, homeOverride?: string): Promise<void> {
|
|
79
|
+
const dir = getQueueDir(homeOverride);
|
|
80
|
+
|
|
81
|
+
// D-11: lazy init — create dir only when needed
|
|
82
|
+
await fs.mkdir(dir, { recursive: true });
|
|
83
|
+
|
|
84
|
+
const files = await getSortedFiles(dir);
|
|
85
|
+
|
|
86
|
+
// D-04: cap enforcement — drop oldest before writing new
|
|
87
|
+
if (files.length >= MAX_QUEUE_SIZE) {
|
|
88
|
+
await fs.unlink(path.join(dir, files[0])).catch(() => {
|
|
89
|
+
/* ignore if already gone */
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const filename = makeFilename();
|
|
94
|
+
await fs.writeFile(path.join(dir, filename), JSON.stringify(entry), "utf8");
|
|
95
|
+
|
|
96
|
+
if (process.env.MUONROI_DEBUG) {
|
|
97
|
+
console.debug(
|
|
98
|
+
"[muonroi-cli] EE offline queue: enqueued %s (cap=%d)",
|
|
99
|
+
entry.endpoint,
|
|
100
|
+
MAX_QUEUE_SIZE,
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Internal async implementation shared by drainQueue (fire-and-forget)
|
|
107
|
+
* and drainQueueAsync (awaitable, for tests).
|
|
108
|
+
*
|
|
109
|
+
* Sequential replay (D-06):
|
|
110
|
+
* - Reads sorted queue files in FIFO order
|
|
111
|
+
* - POSTs each entry to baseUrl + entry.endpoint
|
|
112
|
+
* - Deletes file on HTTP success (resp.ok)
|
|
113
|
+
* - Discards corrupt (unparseable) files silently
|
|
114
|
+
* - Stops on HTTP failure or network error (D-07) — leaves file + remaining
|
|
115
|
+
*
|
|
116
|
+
* D-11: If queue directory doesn't exist yet, returns early (no error).
|
|
117
|
+
*/
|
|
118
|
+
async function drainQueueInternal(
|
|
119
|
+
fetchImpl: typeof fetch,
|
|
120
|
+
headers: Record<string, string>,
|
|
121
|
+
baseUrl: string,
|
|
122
|
+
homeOverride?: string,
|
|
123
|
+
): Promise<void> {
|
|
124
|
+
const dir = getQueueDir(homeOverride);
|
|
125
|
+
|
|
126
|
+
let files: string[];
|
|
127
|
+
try {
|
|
128
|
+
files = await getSortedFiles(dir);
|
|
129
|
+
} catch {
|
|
130
|
+
// ENOENT — queue dir never created (no entries ever queued). Normal path.
|
|
131
|
+
return;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
for (const file of files) {
|
|
135
|
+
const filePath = path.join(dir, file);
|
|
136
|
+
|
|
137
|
+
// Parse entry — discard corrupt files
|
|
138
|
+
let entry: QueueEntry;
|
|
139
|
+
try {
|
|
140
|
+
const raw = await fs.readFile(filePath, "utf8");
|
|
141
|
+
entry = JSON.parse(raw) as QueueEntry;
|
|
142
|
+
} catch {
|
|
143
|
+
// Corrupt JSON — delete silently and continue
|
|
144
|
+
await fs.unlink(filePath).catch(() => {});
|
|
145
|
+
continue;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// Replay the entry
|
|
149
|
+
try {
|
|
150
|
+
const resp = await fetchImpl(`${baseUrl}${entry.endpoint}`, {
|
|
151
|
+
method: "POST",
|
|
152
|
+
headers,
|
|
153
|
+
body: JSON.stringify(entry.body),
|
|
154
|
+
signal: AbortSignal.timeout(5000),
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
if (resp.ok) {
|
|
158
|
+
// Success — delete file and continue to next
|
|
159
|
+
await fs.unlink(filePath).catch(() => {});
|
|
160
|
+
|
|
161
|
+
if (process.env.MUONROI_DEBUG) {
|
|
162
|
+
console.debug(
|
|
163
|
+
"[muonroi-cli] EE offline queue: replayed %s",
|
|
164
|
+
entry.endpoint,
|
|
165
|
+
);
|
|
166
|
+
}
|
|
167
|
+
} else {
|
|
168
|
+
// D-07: server returned error — stop drain, leave file + remaining
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
} catch {
|
|
172
|
+
// D-07: network failure — stop drain, leave file + remaining
|
|
173
|
+
break;
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* Replays queued EE requests in FIFO order.
|
|
180
|
+
*
|
|
181
|
+
* Fire-and-forget wrapper (D-08) — returns void immediately.
|
|
182
|
+
* The caller (recordCircuitSuccess in client.ts) must NOT await this.
|
|
183
|
+
*
|
|
184
|
+
* @param fetchImpl - fetch implementation (injectable for tests)
|
|
185
|
+
* @param headers - HTTP headers to include (Content-Type + optional auth)
|
|
186
|
+
* @param baseUrl - EE base URL (e.g. "http://localhost:8082")
|
|
187
|
+
* @param homeOverride - Optional home dir override (for tests)
|
|
188
|
+
*/
|
|
189
|
+
export function drainQueue(
|
|
190
|
+
fetchImpl: typeof fetch,
|
|
191
|
+
headers: Record<string, string>,
|
|
192
|
+
baseUrl: string,
|
|
193
|
+
homeOverride?: string,
|
|
194
|
+
): void {
|
|
195
|
+
// D-08: fire-and-forget — the returned Promise is intentionally not awaited
|
|
196
|
+
void drainQueueInternal(fetchImpl, headers, baseUrl, homeOverride);
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Awaitable version of drainQueue — for tests only.
|
|
201
|
+
*
|
|
202
|
+
* Production code must use drainQueue() (void).
|
|
203
|
+
* Tests use drainQueueAsync() to await completion before asserting.
|
|
204
|
+
*/
|
|
205
|
+
export async function drainQueueAsync(
|
|
206
|
+
fetchImpl: typeof fetch,
|
|
207
|
+
headers: Record<string, string>,
|
|
208
|
+
baseUrl: string,
|
|
209
|
+
homeOverride?: string,
|
|
210
|
+
): Promise<void> {
|
|
211
|
+
await drainQueueInternal(fetchImpl, headers, baseUrl, homeOverride);
|
|
212
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from "vitest";
|
|
2
|
+
import type { JudgeContext } from "./judge.js";
|
|
3
|
+
import type { PostToolPayload } from "./types.js";
|
|
4
|
+
|
|
5
|
+
// Mock both intercept and judge modules
|
|
6
|
+
// posttool is now async — mock must return a Promise so await works correctly
|
|
7
|
+
const mockPosttool = vi.fn().mockResolvedValue(undefined);
|
|
8
|
+
|
|
9
|
+
vi.mock("./intercept.js", () => ({
|
|
10
|
+
getDefaultEEClient: () => ({
|
|
11
|
+
posttool: mockPosttool,
|
|
12
|
+
}),
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
vi.mock("./judge.js", async (importOriginal) => {
|
|
16
|
+
const actual = await importOriginal<typeof import("./judge.js")>();
|
|
17
|
+
return {
|
|
18
|
+
...actual,
|
|
19
|
+
fireFeedback: vi.fn(),
|
|
20
|
+
};
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
const mockPayload: PostToolPayload = {
|
|
24
|
+
toolName: "bash",
|
|
25
|
+
toolInput: { command: "ls" },
|
|
26
|
+
outcome: { success: true, exitCode: 0, durationMs: 10 },
|
|
27
|
+
cwd: "/tmp",
|
|
28
|
+
tenantId: "local",
|
|
29
|
+
scope: { kind: "global" },
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
describe("posttool() wrapper", () => {
|
|
33
|
+
it("calls client.posttool with payload", async () => {
|
|
34
|
+
mockPosttool.mockClear();
|
|
35
|
+
const { posttool } = await import("./posttool.js");
|
|
36
|
+
await posttool(mockPayload);
|
|
37
|
+
expect(mockPosttool).toHaveBeenCalledOnce();
|
|
38
|
+
expect(mockPosttool).toHaveBeenCalledWith(mockPayload);
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
it("calls fireFeedback when judgeCtx provided", async () => {
|
|
42
|
+
mockPosttool.mockClear();
|
|
43
|
+
const { posttool } = await import("./posttool.js");
|
|
44
|
+
const { fireFeedback } = await import("./judge.js");
|
|
45
|
+
const mockFF = fireFeedback as unknown as ReturnType<typeof vi.fn>;
|
|
46
|
+
mockFF.mockClear();
|
|
47
|
+
|
|
48
|
+
const ctx: JudgeContext = {
|
|
49
|
+
warningResponse: { decision: "allow", matches: [] },
|
|
50
|
+
toolName: "bash",
|
|
51
|
+
outcome: { success: true, durationMs: 10 },
|
|
52
|
+
cwdMatchedAtPretool: true,
|
|
53
|
+
diffPresent: false,
|
|
54
|
+
tenantId: "local",
|
|
55
|
+
};
|
|
56
|
+
await posttool(mockPayload, ctx);
|
|
57
|
+
expect(mockPosttool).toHaveBeenCalledOnce();
|
|
58
|
+
expect(mockFF).toHaveBeenCalledOnce();
|
|
59
|
+
expect(mockFF).toHaveBeenCalledWith(ctx);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("does not call fireFeedback when judgeCtx is undefined", async () => {
|
|
63
|
+
mockPosttool.mockClear();
|
|
64
|
+
const { posttool } = await import("./posttool.js");
|
|
65
|
+
const { fireFeedback } = await import("./judge.js");
|
|
66
|
+
const mockFF = fireFeedback as unknown as ReturnType<typeof vi.fn>;
|
|
67
|
+
mockFF.mockClear();
|
|
68
|
+
|
|
69
|
+
await posttool(mockPayload);
|
|
70
|
+
expect(mockPosttool).toHaveBeenCalledOnce();
|
|
71
|
+
expect(mockFF).not.toHaveBeenCalled();
|
|
72
|
+
});
|
|
73
|
+
|
|
74
|
+
it("returns Promise<void> (async — awaitable by PostToolUse handler)", async () => {
|
|
75
|
+
mockPosttool.mockClear();
|
|
76
|
+
const { posttool } = await import("./posttool.js");
|
|
77
|
+
const result = posttool(mockPayload);
|
|
78
|
+
expect(result).toBeInstanceOf(Promise);
|
|
79
|
+
await result; // resolves to undefined
|
|
80
|
+
});
|
|
81
|
+
});
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { getDefaultEEClient } from "./intercept.js";
|
|
2
|
+
import { fireFeedback, type JudgeContext } from "./judge.js";
|
|
3
|
+
import type { PostToolPayload } from "./types.js";
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Call the EE posttool endpoint using the default client.
|
|
7
|
+
* Returns Promise<void> — awaitable by the PostToolUse hook handler.
|
|
8
|
+
* Errors are swallowed (fire-and-forget semantics preserved inside client).
|
|
9
|
+
*
|
|
10
|
+
* When judgeCtx is provided, also fires deterministic feedback (EE-09)
|
|
11
|
+
* and touch on FOLLOWED matches (EE-10). fireFeedback stays synchronous (B-4 preserved).
|
|
12
|
+
*/
|
|
13
|
+
export async function posttool(payload: PostToolPayload, judgeCtx?: JudgeContext): Promise<void> {
|
|
14
|
+
await getDefaultEEClient().posttool(payload);
|
|
15
|
+
if (judgeCtx) fireFeedback(judgeCtx);
|
|
16
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/ee/prompt-stale.test.ts
|
|
3
|
+
*
|
|
4
|
+
* Unit tests for reconcilePromptStale() fire-and-forget module.
|
|
5
|
+
* Tests use vi.mock for getDefaultEEClient to inject mockPromptStale,
|
|
6
|
+
* while using real updateLastSurfacedState/resetLastSurfacedState from intercept.ts.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
10
|
+
|
|
11
|
+
// Mock getDefaultEEClient to inject a controllable mockPromptStale
|
|
12
|
+
vi.mock("./intercept.js", async (importOriginal) => {
|
|
13
|
+
const actual = await importOriginal<typeof import("./intercept.js")>();
|
|
14
|
+
return {
|
|
15
|
+
...actual,
|
|
16
|
+
getDefaultEEClient: vi.fn(),
|
|
17
|
+
};
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
import { getDefaultEEClient, getLastSurfacedState, resetLastSurfacedState, updateLastSurfacedState } from "./intercept.js";
|
|
21
|
+
import { reconcilePromptStale } from "./prompt-stale.js";
|
|
22
|
+
|
|
23
|
+
describe("reconcilePromptStale", () => {
|
|
24
|
+
let mockPromptStale: ReturnType<typeof vi.fn>;
|
|
25
|
+
|
|
26
|
+
beforeEach(() => {
|
|
27
|
+
mockPromptStale = vi.fn().mockResolvedValue({ ok: true, unused: [], irrelevant: [], expired: [] });
|
|
28
|
+
vi.mocked(getDefaultEEClient).mockReturnValue({
|
|
29
|
+
promptStale: mockPromptStale,
|
|
30
|
+
} as any);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
afterEach(() => {
|
|
34
|
+
resetLastSurfacedState();
|
|
35
|
+
vi.clearAllMocks();
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("is a no-op when no surfaced IDs exist (does not call promptStale)", async () => {
|
|
39
|
+
// No call to updateLastSurfacedState — surfacedIds should be []
|
|
40
|
+
const result = reconcilePromptStale("/tmp");
|
|
41
|
+
// Flush microtasks
|
|
42
|
+
await new Promise((r) => setTimeout(r, 0));
|
|
43
|
+
expect(result).toBeUndefined();
|
|
44
|
+
expect(mockPromptStale).not.toHaveBeenCalled();
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it("calls promptStale with correct payload when IDs are surfaced", async () => {
|
|
48
|
+
updateLastSurfacedState(["id-1", "id-2"]);
|
|
49
|
+
reconcilePromptStale("/tmp");
|
|
50
|
+
// Flush microtasks
|
|
51
|
+
await new Promise((r) => setTimeout(r, 0));
|
|
52
|
+
|
|
53
|
+
expect(mockPromptStale).toHaveBeenCalledTimes(1);
|
|
54
|
+
const [req] = mockPromptStale.mock.calls[0];
|
|
55
|
+
expect(req.state.surfacedIds).toEqual(["id-1", "id-2"]);
|
|
56
|
+
expect(typeof req.state.timestamp).toBe("string");
|
|
57
|
+
expect(req.nextPromptMeta.trigger).toBe("auto-compact");
|
|
58
|
+
expect(req.nextPromptMeta.cwd).toBe("/tmp");
|
|
59
|
+
expect(req.nextPromptMeta.tenantId).toBe("local");
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("returns undefined (void, not a Promise)", () => {
|
|
63
|
+
updateLastSurfacedState(["id-1"]);
|
|
64
|
+
const result = reconcilePromptStale("/tmp");
|
|
65
|
+
expect(result).toBeUndefined();
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
it("resets surfaced state BEFORE dispatching async HTTP call", async () => {
|
|
69
|
+
updateLastSurfacedState(["id-1", "id-2"]);
|
|
70
|
+
reconcilePromptStale("/tmp");
|
|
71
|
+
// Surfaced state should be reset synchronously before async dispatch
|
|
72
|
+
expect(getLastSurfacedState().surfacedIds).toEqual([]);
|
|
73
|
+
// HTTP call still dispatched (can verify via flush)
|
|
74
|
+
await new Promise((r) => setTimeout(r, 0));
|
|
75
|
+
expect(mockPromptStale).toHaveBeenCalledTimes(1);
|
|
76
|
+
});
|
|
77
|
+
|
|
78
|
+
it("swallows errors from rejected promptStale promise (fire-and-forget)", async () => {
|
|
79
|
+
mockPromptStale.mockRejectedValue(new Error("network error"));
|
|
80
|
+
updateLastSurfacedState(["id-1"]);
|
|
81
|
+
// Should not throw
|
|
82
|
+
expect(() => reconcilePromptStale("/tmp")).not.toThrow();
|
|
83
|
+
// Allow the rejected promise to settle — should not produce unhandled rejection
|
|
84
|
+
await new Promise((r) => setTimeout(r, 10));
|
|
85
|
+
expect(mockPromptStale).toHaveBeenCalledTimes(1);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/ee/prompt-stale.ts
|
|
3
|
+
*
|
|
4
|
+
* Per-turn prompt-stale reconciliation. Called fire-and-forget from PostToolUse
|
|
5
|
+
* hook to report surfaced EE suggestions that the agent did not explicitly
|
|
6
|
+
* acknowledge via feedback(). Uses "auto-compact" trigger to avoid cross-repo
|
|
7
|
+
* server dependency (see 10-RESEARCH.md Pitfall 3).
|
|
8
|
+
*
|
|
9
|
+
* STALE-02: calls /api/prompt-stale for surfaced IDs
|
|
10
|
+
* STALE-03: fire-and-forget — returns void, never blocks
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import { getDefaultEEClient, getLastSurfacedState, resetLastSurfacedState } from "./intercept.js";
|
|
14
|
+
import { getTenantId } from "./tenant.js";
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Fire-and-forget prompt-stale reconciliation.
|
|
18
|
+
* Called from PostToolUse hook after each tool-use turn.
|
|
19
|
+
*
|
|
20
|
+
* Returns void — caller must NOT await (B-4 budget constraint).
|
|
21
|
+
* Resets surfaced state BEFORE dispatching the async HTTP call
|
|
22
|
+
* to prevent double-reporting on rapid sequential PostToolUse events.
|
|
23
|
+
*/
|
|
24
|
+
export function reconcilePromptStale(cwd: string, tenantId = getTenantId()): void {
|
|
25
|
+
const { surfacedIds, timestamp } = getLastSurfacedState();
|
|
26
|
+
if (surfacedIds.length === 0) return;
|
|
27
|
+
|
|
28
|
+
// Reset before async dispatch to avoid double-report (see 10-RESEARCH.md Pitfall 2)
|
|
29
|
+
resetLastSurfacedState();
|
|
30
|
+
|
|
31
|
+
getDefaultEEClient()
|
|
32
|
+
.promptStale({
|
|
33
|
+
state: { surfacedIds, timestamp },
|
|
34
|
+
nextPromptMeta: { trigger: "auto-compact", cwd, tenantId },
|
|
35
|
+
})
|
|
36
|
+
.catch(() => {
|
|
37
|
+
// Errors swallowed — fire-and-forget (B-4)
|
|
38
|
+
});
|
|
39
|
+
}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it } from "vitest";
|
|
2
|
+
import { emitMatches, renderInterceptWarning, setRenderSink } from "./render.js";
|
|
3
|
+
import type { InterceptMatch } from "./types.js";
|
|
4
|
+
|
|
5
|
+
const baseMatch: InterceptMatch = {
|
|
6
|
+
principle_uuid: "test-uuid-1234",
|
|
7
|
+
embedding_model_version: "nomic-embed-text-v1.5",
|
|
8
|
+
confidence: 0.85,
|
|
9
|
+
why: "It causes Y",
|
|
10
|
+
message: "Avoid editing X",
|
|
11
|
+
scope_label: "repo:foo/bar",
|
|
12
|
+
last_matched_at: "2026-04-30T00:00:00Z",
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
describe("renderInterceptWarning", () => {
|
|
16
|
+
it("renders 5-line boxed warning with confidence%, message, why, scope", () => {
|
|
17
|
+
const result = renderInterceptWarning(baseMatch);
|
|
18
|
+
const lines = result.split("\n");
|
|
19
|
+
expect(lines).toHaveLength(5);
|
|
20
|
+
expect(lines[0]).toContain("⚠ Experience Warning");
|
|
21
|
+
expect(lines[1]).toContain("85%");
|
|
22
|
+
expect(lines[1]).toContain("Avoid editing X");
|
|
23
|
+
expect(lines[2]).toContain("It causes Y");
|
|
24
|
+
expect(lines[3]).toContain("repo:foo/bar");
|
|
25
|
+
expect(lines[4]).toContain("└");
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it("renders confidence as integer percentage (85% not 0.85)", () => {
|
|
29
|
+
expect(renderInterceptWarning(baseMatch)).toContain("85%");
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
it("renders confidence=1 as 100%", () => {
|
|
33
|
+
const match: InterceptMatch = { ...baseMatch, confidence: 1 };
|
|
34
|
+
expect(renderInterceptWarning(match)).toContain("100%");
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("renders confidence=0 as 0%", () => {
|
|
38
|
+
const match: InterceptMatch = { ...baseMatch, confidence: 0 };
|
|
39
|
+
expect(renderInterceptWarning(match)).toContain("[0%]");
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
describe("emitMatches + setRenderSink", () => {
|
|
44
|
+
let captured: string[];
|
|
45
|
+
|
|
46
|
+
beforeEach(() => {
|
|
47
|
+
captured = [];
|
|
48
|
+
setRenderSink((line) => captured.push(line));
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("emits each match via the sink", () => {
|
|
52
|
+
const matches: InterceptMatch[] = [
|
|
53
|
+
baseMatch,
|
|
54
|
+
{ ...baseMatch, message: "Do not delete Z", why: "It breaks Q", confidence: 0.92 },
|
|
55
|
+
];
|
|
56
|
+
emitMatches(matches);
|
|
57
|
+
expect(captured).toHaveLength(2);
|
|
58
|
+
expect(captured[0]).toContain("Avoid editing X");
|
|
59
|
+
expect(captured[1]).toContain("Do not delete Z");
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it("does nothing for undefined matches", () => {
|
|
63
|
+
emitMatches(undefined);
|
|
64
|
+
expect(captured).toHaveLength(0);
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it("does nothing for empty matches", () => {
|
|
68
|
+
emitMatches([]);
|
|
69
|
+
expect(captured).toHaveLength(0);
|
|
70
|
+
});
|
|
71
|
+
});
|
package/src/ee/render.ts
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* EE PreToolUse inline warning renderer.
|
|
3
|
+
*
|
|
4
|
+
* EE-02: decision='allow' with matches[] emits ⚠ [Experience] lines
|
|
5
|
+
* via a pluggable render sink (default: console.warn).
|
|
6
|
+
*
|
|
7
|
+
* Format per match (5 lines with visual border):
|
|
8
|
+
* ┌─ ⚠ Experience Warning ──────────────────────┐
|
|
9
|
+
* │ [{confidence}] {message}
|
|
10
|
+
* │ Why: {why}
|
|
11
|
+
* │ Scope: {scope_label}
|
|
12
|
+
* └──────────────────────────────────────────────┘
|
|
13
|
+
*/
|
|
14
|
+
import type { InterceptMatch } from "./types.js";
|
|
15
|
+
|
|
16
|
+
const BORDER_WIDTH = 46;
|
|
17
|
+
const TOP_BORDER = `┌─ ⚠ Experience Warning ${"─".repeat(BORDER_WIDTH - 22)}┐`;
|
|
18
|
+
const BOTTOM_BORDER = `└${"─".repeat(BORDER_WIDTH - 1)}┘`;
|
|
19
|
+
|
|
20
|
+
type RenderSink = (line: string) => void;
|
|
21
|
+
let _sink: RenderSink = (line) => {
|
|
22
|
+
console.warn(line);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export function setRenderSink(fn: RenderSink): void {
|
|
26
|
+
_sink = fn;
|
|
27
|
+
}
|
|
28
|
+
export function getRenderSink(): RenderSink {
|
|
29
|
+
return _sink;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function renderInterceptWarning(m: InterceptMatch): string {
|
|
33
|
+
const conf = (m.confidence * 100).toFixed(0);
|
|
34
|
+
const lines = [
|
|
35
|
+
TOP_BORDER,
|
|
36
|
+
`│ [${conf}%] ${m.message}`,
|
|
37
|
+
`│ Why: ${m.why}`,
|
|
38
|
+
`│ Scope: ${m.scope_label}`,
|
|
39
|
+
BOTTOM_BORDER,
|
|
40
|
+
];
|
|
41
|
+
return lines.join("\n");
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function emitMatches(matches: InterceptMatch[] | undefined): void {
|
|
45
|
+
if (!matches?.length) return;
|
|
46
|
+
for (const m of matches) _sink(renderInterceptWarning(m));
|
|
47
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { promises as fs } from "node:fs";
|
|
2
|
+
import * as os from "node:os";
|
|
3
|
+
import * as path from "node:path";
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
5
|
+
|
|
6
|
+
// We test the module under test after creating it
|
|
7
|
+
import { buildScope, resetScopeCache, scopeLabel } from "./scope.js";
|
|
8
|
+
|
|
9
|
+
describe("buildScope", () => {
|
|
10
|
+
let tmpDir: string;
|
|
11
|
+
|
|
12
|
+
beforeEach(async () => {
|
|
13
|
+
resetScopeCache();
|
|
14
|
+
tmpDir = await fs.mkdtemp(path.join(os.tmpdir(), "scope-test-"));
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
afterEach(async () => {
|
|
18
|
+
await fs.rm(tmpDir, { recursive: true, force: true }).catch(() => {});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it("returns { kind: 'global' } for a directory without .git", async () => {
|
|
22
|
+
const scope = await buildScope({ cwd: tmpDir });
|
|
23
|
+
expect(scope).toEqual({ kind: "global" });
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("returns { kind: 'repo', remote } on detached HEAD with remote origin", async () => {
|
|
27
|
+
const gitDir = path.join(tmpDir, ".git");
|
|
28
|
+
await fs.mkdir(gitDir, { recursive: true });
|
|
29
|
+
await fs.writeFile(path.join(gitDir, "HEAD"), "abc123deadbeef\n");
|
|
30
|
+
await fs.writeFile(path.join(gitDir, "config"), '[remote "origin"]\n\turl = https://github.com/foo/bar.git\n');
|
|
31
|
+
const scope = await buildScope({ cwd: tmpDir });
|
|
32
|
+
expect(scope).toEqual({
|
|
33
|
+
kind: "repo",
|
|
34
|
+
remote: "https://github.com/foo/bar.git",
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
it("returns { kind: 'branch', remote, branch } when HEAD points to ref", async () => {
|
|
39
|
+
const gitDir = path.join(tmpDir, ".git");
|
|
40
|
+
await fs.mkdir(gitDir, { recursive: true });
|
|
41
|
+
await fs.writeFile(path.join(gitDir, "HEAD"), "ref: refs/heads/main\n");
|
|
42
|
+
await fs.writeFile(path.join(gitDir, "config"), '[remote "origin"]\n\turl = https://github.com/foo/bar.git\n');
|
|
43
|
+
const scope = await buildScope({ cwd: tmpDir });
|
|
44
|
+
expect(scope).toEqual({
|
|
45
|
+
kind: "branch",
|
|
46
|
+
remote: "https://github.com/foo/bar.git",
|
|
47
|
+
branch: "main",
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("reads .git/HEAD + .git/config via fs (no child_process spawn)", async () => {
|
|
52
|
+
// Verify the module source does not import child_process
|
|
53
|
+
const source = await fs.readFile(path.join(process.cwd(), "src/ee/scope.ts"), "utf8");
|
|
54
|
+
// Check for import/require of child_process (not just mentions in comments)
|
|
55
|
+
expect(source).not.toMatch(/import.*child_process/);
|
|
56
|
+
expect(source).not.toMatch(/require.*child_process/);
|
|
57
|
+
expect(source).not.toMatch(/import.*\bspawn\b/);
|
|
58
|
+
expect(source).not.toMatch(/import.*\bexec\b/);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("caches: second call returns same object reference", async () => {
|
|
62
|
+
const gitDir = path.join(tmpDir, ".git");
|
|
63
|
+
await fs.mkdir(gitDir, { recursive: true });
|
|
64
|
+
await fs.writeFile(path.join(gitDir, "HEAD"), "ref: refs/heads/dev\n");
|
|
65
|
+
await fs.writeFile(path.join(gitDir, "config"), '[remote "origin"]\n\turl = https://github.com/a/b.git\n');
|
|
66
|
+
const first = await buildScope({ cwd: tmpDir });
|
|
67
|
+
const second = await buildScope({ cwd: tmpDir });
|
|
68
|
+
expect(first).toBe(second); // same reference
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
it("resetScopeCache forces re-read", async () => {
|
|
72
|
+
const gitDir = path.join(tmpDir, ".git");
|
|
73
|
+
await fs.mkdir(gitDir, { recursive: true });
|
|
74
|
+
await fs.writeFile(path.join(gitDir, "HEAD"), "ref: refs/heads/dev\n");
|
|
75
|
+
await fs.writeFile(path.join(gitDir, "config"), '[remote "origin"]\n\turl = https://github.com/a/b.git\n');
|
|
76
|
+
const first = await buildScope({ cwd: tmpDir });
|
|
77
|
+
resetScopeCache();
|
|
78
|
+
// Change the branch
|
|
79
|
+
await fs.writeFile(path.join(gitDir, "HEAD"), "ref: refs/heads/feature\n");
|
|
80
|
+
const second = await buildScope({ cwd: tmpDir });
|
|
81
|
+
expect(first).not.toBe(second);
|
|
82
|
+
expect(second).toEqual({
|
|
83
|
+
kind: "branch",
|
|
84
|
+
remote: "https://github.com/a/b.git",
|
|
85
|
+
branch: "feature",
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
describe("scopeLabel", () => {
|
|
91
|
+
it("formats global scope", () => {
|
|
92
|
+
expect(scopeLabel({ kind: "global" })).toBe("global");
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("formats ecosystem scope", () => {
|
|
96
|
+
expect(scopeLabel({ kind: "ecosystem", name: "muonroi" })).toBe("ecosystem:muonroi");
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
it("formats repo scope", () => {
|
|
100
|
+
expect(scopeLabel({ kind: "repo", remote: "https://github.com/x/y" })).toBe("repo:https://github.com/x/y");
|
|
101
|
+
});
|
|
102
|
+
|
|
103
|
+
it("formats branch scope", () => {
|
|
104
|
+
expect(
|
|
105
|
+
scopeLabel({
|
|
106
|
+
kind: "branch",
|
|
107
|
+
remote: "https://github.com/x/y",
|
|
108
|
+
branch: "main",
|
|
109
|
+
}),
|
|
110
|
+
).toBe("branch:https://github.com/x/y#main");
|
|
111
|
+
});
|
|
112
|
+
});
|