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,132 @@
|
|
|
1
|
+
import { getCachedAuthToken, getCachedServerBaseUrl, loadEEAuthToken, refreshAuthToken } from "./auth.js";
|
|
2
|
+
import { getTenantId } from "./tenant.js";
|
|
3
|
+
import type { CreateEEClientOpts } from "./client.js";
|
|
4
|
+
import { createEEClient } from "./client.js";
|
|
5
|
+
import { emitMatches } from "./render.js";
|
|
6
|
+
import { buildScope } from "./scope.js";
|
|
7
|
+
import type { InterceptRequest, InterceptResponse, Scope } from "./types.js";
|
|
8
|
+
|
|
9
|
+
// ─── Surfaced-state tracking for prompt-stale reconciliation ─────────────────
|
|
10
|
+
let _lastSurfacedIds: string[] = [];
|
|
11
|
+
let _lastSurfacedTimestamp: string | null = null;
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Returns the last surfaced suggestion IDs and timestamp from the most recent
|
|
15
|
+
* intercept call that returned matches. Used by prompt-stale reconciliation
|
|
16
|
+
* callers (compact, clear, session-end).
|
|
17
|
+
*/
|
|
18
|
+
export function getLastSurfacedState(): { surfacedIds: string[]; timestamp: string } {
|
|
19
|
+
return {
|
|
20
|
+
surfacedIds: [..._lastSurfacedIds],
|
|
21
|
+
timestamp: _lastSurfacedTimestamp ?? new Date().toISOString(),
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Allows non-HTTP code paths (e.g. PIL Layer 3 bridge search) to register
|
|
27
|
+
* point IDs they injected into the prompt. These IDs join the HTTP-intercept
|
|
28
|
+
* surfaced IDs for prompt-stale reconciliation.
|
|
29
|
+
*/
|
|
30
|
+
export function updateLastSurfacedState(ids: string[]): void {
|
|
31
|
+
if (ids.length === 0) return;
|
|
32
|
+
_lastSurfacedIds = [...ids];
|
|
33
|
+
_lastSurfacedTimestamp = new Date().toISOString();
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Resets surfaced state to empty. Called after prompt-stale reconciliation
|
|
38
|
+
* dispatches so the same IDs are not re-reported on the next turn.
|
|
39
|
+
*/
|
|
40
|
+
export function resetLastSurfacedState(): void {
|
|
41
|
+
_lastSurfacedIds = [];
|
|
42
|
+
_lastSurfacedTimestamp = null;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Module-level default EE client instance (lazy-initialized on first use).
|
|
47
|
+
* Use setDefaultEEClient() to inject a custom client (e.g. in tests or at boot
|
|
48
|
+
* after loading auth token from config).
|
|
49
|
+
*/
|
|
50
|
+
let _defaultClient: ReturnType<typeof createEEClient> | null = null;
|
|
51
|
+
|
|
52
|
+
export function setDefaultEEClient(c: ReturnType<typeof createEEClient>): void {
|
|
53
|
+
_defaultClient = c;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function getDefaultEEClient(): ReturnType<typeof createEEClient> {
|
|
57
|
+
if (!_defaultClient)
|
|
58
|
+
_defaultClient = createEEClient({
|
|
59
|
+
baseUrl: getCachedServerBaseUrl() ?? undefined,
|
|
60
|
+
authToken: getCachedAuthToken() ?? undefined,
|
|
61
|
+
});
|
|
62
|
+
return _defaultClient;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/**
|
|
66
|
+
* Call the EE intercept endpoint using the default client.
|
|
67
|
+
* Blocks until a decision is received or the timeout elapses (falls back to allow).
|
|
68
|
+
*
|
|
69
|
+
* Phase 1: requires tenantId + scope explicitly.
|
|
70
|
+
* - On 401 (surfaced as reason='auth-required'): refreshes token, rebuilds client, retries once.
|
|
71
|
+
* - On allow + matches[]: emits rendered ⚠ lines via render sink.
|
|
72
|
+
*/
|
|
73
|
+
export async function intercept(req: InterceptRequest, opts?: CreateEEClientOpts): Promise<InterceptResponse> {
|
|
74
|
+
const client = opts ? createEEClient(opts) : getDefaultEEClient();
|
|
75
|
+
let resp = await client.intercept(req);
|
|
76
|
+
|
|
77
|
+
// 401 refresh path: client surfaces 401 as { decision: 'allow', reason: 'auth-required' }
|
|
78
|
+
if ((resp as any).reason === "auth-required") {
|
|
79
|
+
await refreshAuthToken();
|
|
80
|
+
_defaultClient = createEEClient({
|
|
81
|
+
authToken: getCachedAuthToken() ?? undefined,
|
|
82
|
+
});
|
|
83
|
+
resp = await getDefaultEEClient().intercept(req);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// Emit rendered warnings for allow + matches
|
|
87
|
+
if (resp.decision === "allow" && resp.matches) {
|
|
88
|
+
emitMatches(resp.matches);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
// Track surfaced IDs for prompt-stale reconciliation
|
|
92
|
+
if (resp.surfacedIds && resp.surfacedIds.length > 0) {
|
|
93
|
+
_lastSurfacedIds = [...resp.surfacedIds];
|
|
94
|
+
_lastSurfacedTimestamp = new Date().toISOString();
|
|
95
|
+
} else if (resp.matches && resp.matches.length > 0) {
|
|
96
|
+
_lastSurfacedIds = resp.matches.map((m) => m.principle_uuid);
|
|
97
|
+
_lastSurfacedTimestamp = new Date().toISOString();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
return resp;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* @deprecated — pass tenantId + scope explicitly. This helper fills defaults
|
|
105
|
+
* for Phase 0 callers that haven't been migrated yet.
|
|
106
|
+
*
|
|
107
|
+
* Fills tenantId='local' and scope (computed via buildScope({ cwd })) when omitted.
|
|
108
|
+
*/
|
|
109
|
+
export async function interceptWithDefaults(
|
|
110
|
+
req: Omit<InterceptRequest, "tenantId" | "scope"> & Partial<Pick<InterceptRequest, "tenantId" | "scope">>,
|
|
111
|
+
): Promise<InterceptResponse> {
|
|
112
|
+
const tenantId = req.tenantId ?? getTenantId();
|
|
113
|
+
const scope: Scope = req.scope ?? (await buildScope({ cwd: req.cwd }));
|
|
114
|
+
return intercept({
|
|
115
|
+
toolName: req.toolName,
|
|
116
|
+
toolInput: req.toolInput,
|
|
117
|
+
cwd: req.cwd,
|
|
118
|
+
tenantId,
|
|
119
|
+
scope,
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* Bootstrap the EE client with auth token from ~/.experience/config.json.
|
|
125
|
+
* Called once at session boot.
|
|
126
|
+
*/
|
|
127
|
+
export async function bootstrapEEClient(home?: string): Promise<void> {
|
|
128
|
+
await loadEEAuthToken({ home });
|
|
129
|
+
_defaultClient = createEEClient({
|
|
130
|
+
authToken: getCachedAuthToken() ?? undefined,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import { beforeEach, describe, expect, it, vi } from "vitest";
|
|
2
|
+
import { fireFeedback, type JudgeContext, judge } from "./judge.js";
|
|
3
|
+
import type { InterceptMatch } from "./types.js";
|
|
4
|
+
|
|
5
|
+
// Mock the intercept module to control getDefaultEEClient
|
|
6
|
+
const mockFeedback = vi.fn();
|
|
7
|
+
const mockTouch = vi.fn();
|
|
8
|
+
vi.mock("./intercept.js", () => ({
|
|
9
|
+
getDefaultEEClient: () => ({
|
|
10
|
+
feedback: mockFeedback,
|
|
11
|
+
touch: mockTouch,
|
|
12
|
+
}),
|
|
13
|
+
}));
|
|
14
|
+
|
|
15
|
+
function makeMatch(overrides: Partial<InterceptMatch> = {}): InterceptMatch {
|
|
16
|
+
return {
|
|
17
|
+
principle_uuid: "P1",
|
|
18
|
+
embedding_model_version: "v1",
|
|
19
|
+
confidence: 0.9,
|
|
20
|
+
why: "test reason",
|
|
21
|
+
message: "test message",
|
|
22
|
+
scope_label: "global",
|
|
23
|
+
last_matched_at: new Date().toISOString(),
|
|
24
|
+
...overrides,
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function makeCtx(overrides: Partial<JudgeContext> = {}): JudgeContext {
|
|
29
|
+
return {
|
|
30
|
+
warningResponse: {
|
|
31
|
+
decision: "allow",
|
|
32
|
+
matches: [makeMatch()],
|
|
33
|
+
},
|
|
34
|
+
toolName: "Edit",
|
|
35
|
+
outcome: { success: true, durationMs: 50 },
|
|
36
|
+
cwdMatchedAtPretool: true,
|
|
37
|
+
diffPresent: false,
|
|
38
|
+
tenantId: "local",
|
|
39
|
+
...overrides,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
describe("judge() deterministic classifier", () => {
|
|
44
|
+
it("no warningResponse.matches returns IRRELEVANT", () => {
|
|
45
|
+
const ctx = makeCtx({ warningResponse: { decision: "allow" } });
|
|
46
|
+
expect(judge(ctx)).toBe("IRRELEVANT");
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("empty matches array returns IRRELEVANT", () => {
|
|
50
|
+
const ctx = makeCtx({
|
|
51
|
+
warningResponse: { decision: "allow", matches: [] },
|
|
52
|
+
});
|
|
53
|
+
expect(judge(ctx)).toBe("IRRELEVANT");
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
it("cwdMatchedAtPretool=false returns IRRELEVANT", () => {
|
|
57
|
+
const ctx = makeCtx({ cwdMatchedAtPretool: false });
|
|
58
|
+
expect(judge(ctx)).toBe("IRRELEVANT");
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("successful outcome with matches returns FOLLOWED", () => {
|
|
62
|
+
const ctx = makeCtx();
|
|
63
|
+
expect(judge(ctx)).toBe("FOLLOWED");
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
it("failed outcome with matches returns IGNORED", () => {
|
|
67
|
+
const ctx = makeCtx({
|
|
68
|
+
outcome: { success: false, durationMs: 10 },
|
|
69
|
+
});
|
|
70
|
+
expect(judge(ctx)).toBe("IGNORED");
|
|
71
|
+
});
|
|
72
|
+
|
|
73
|
+
it("expectedBehavior=should-not-edit AND diffPresent=true returns IGNORED even with success", () => {
|
|
74
|
+
const ctx = makeCtx({
|
|
75
|
+
warningResponse: {
|
|
76
|
+
decision: "allow",
|
|
77
|
+
matches: [makeMatch({ expectedBehavior: "should-not-edit" })],
|
|
78
|
+
},
|
|
79
|
+
diffPresent: true,
|
|
80
|
+
});
|
|
81
|
+
expect(judge(ctx)).toBe("IGNORED");
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
it("expectedBehavior=should-not-edit AND diffPresent=false returns FOLLOWED", () => {
|
|
85
|
+
const ctx = makeCtx({
|
|
86
|
+
warningResponse: {
|
|
87
|
+
decision: "allow",
|
|
88
|
+
matches: [makeMatch({ expectedBehavior: "should-not-edit" })],
|
|
89
|
+
},
|
|
90
|
+
diffPresent: false,
|
|
91
|
+
});
|
|
92
|
+
expect(judge(ctx)).toBe("FOLLOWED");
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
it("null warningResponse returns IRRELEVANT", () => {
|
|
96
|
+
const ctx = makeCtx({ warningResponse: null });
|
|
97
|
+
expect(judge(ctx)).toBe("IRRELEVANT");
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
describe("fireFeedback()", () => {
|
|
102
|
+
beforeEach(() => {
|
|
103
|
+
mockFeedback.mockClear();
|
|
104
|
+
mockTouch.mockClear();
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
it("FOLLOWED: calls feedback() once per match AND touch() once per match", () => {
|
|
108
|
+
const ctx = makeCtx({
|
|
109
|
+
warningResponse: {
|
|
110
|
+
decision: "allow",
|
|
111
|
+
matches: [makeMatch({ principle_uuid: "P1" })],
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
fireFeedback(ctx);
|
|
115
|
+
expect(mockFeedback).toHaveBeenCalledOnce();
|
|
116
|
+
expect(mockFeedback).toHaveBeenCalledWith(
|
|
117
|
+
expect.objectContaining({
|
|
118
|
+
principle_uuid: "P1",
|
|
119
|
+
classification: "FOLLOWED",
|
|
120
|
+
tool_name: "Edit",
|
|
121
|
+
}),
|
|
122
|
+
);
|
|
123
|
+
expect(mockTouch).toHaveBeenCalledOnce();
|
|
124
|
+
expect(mockTouch).toHaveBeenCalledWith("P1", "local");
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
it("IGNORED: calls feedback() but NOT touch()", () => {
|
|
128
|
+
const ctx = makeCtx({
|
|
129
|
+
outcome: { success: false, durationMs: 10 },
|
|
130
|
+
});
|
|
131
|
+
fireFeedback(ctx);
|
|
132
|
+
expect(mockFeedback).toHaveBeenCalledOnce();
|
|
133
|
+
expect(mockFeedback).toHaveBeenCalledWith(expect.objectContaining({ classification: "IGNORED" }));
|
|
134
|
+
expect(mockTouch).not.toHaveBeenCalled();
|
|
135
|
+
});
|
|
136
|
+
|
|
137
|
+
it("IRRELEVANT (no matches): does not call feedback or touch", () => {
|
|
138
|
+
const ctx = makeCtx({ warningResponse: null });
|
|
139
|
+
fireFeedback(ctx);
|
|
140
|
+
expect(mockFeedback).not.toHaveBeenCalled();
|
|
141
|
+
expect(mockTouch).not.toHaveBeenCalled();
|
|
142
|
+
});
|
|
143
|
+
|
|
144
|
+
it("multiple matches: calls feedback and touch for each", () => {
|
|
145
|
+
const ctx = makeCtx({
|
|
146
|
+
warningResponse: {
|
|
147
|
+
decision: "allow",
|
|
148
|
+
matches: [makeMatch({ principle_uuid: "P1" }), makeMatch({ principle_uuid: "P2" })],
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
fireFeedback(ctx);
|
|
152
|
+
expect(mockFeedback).toHaveBeenCalledTimes(2);
|
|
153
|
+
expect(mockTouch).toHaveBeenCalledTimes(2);
|
|
154
|
+
expect(mockTouch).toHaveBeenCalledWith("P1", "local");
|
|
155
|
+
expect(mockTouch).toHaveBeenCalledWith("P2", "local");
|
|
156
|
+
});
|
|
157
|
+
});
|
package/src/ee/judge.ts
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* src/ee/judge.ts
|
|
3
|
+
*
|
|
4
|
+
* Deterministic auto-judge classifier (EE-09).
|
|
5
|
+
* Classifies every tool call as FOLLOWED | IGNORED | IRRELEVANT using
|
|
6
|
+
* deterministic rules — no LLM involved.
|
|
7
|
+
*
|
|
8
|
+
* fireFeedback() fires /api/feedback fire-and-forget per match, and
|
|
9
|
+
* /api/principle/touch on FOLLOWED matches (EE-10 decay refresh).
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
import { getDefaultEEClient } from "./intercept.js";
|
|
13
|
+
import type { Classification, InterceptResponse, PostToolPayload } from "./types.js";
|
|
14
|
+
|
|
15
|
+
export interface JudgeContext {
|
|
16
|
+
warningResponse: InterceptResponse | null;
|
|
17
|
+
toolName: string;
|
|
18
|
+
outcome: PostToolPayload["outcome"];
|
|
19
|
+
cwdMatchedAtPretool: boolean;
|
|
20
|
+
diffPresent: boolean;
|
|
21
|
+
tenantId: string;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Deterministic classification rules (from RESEARCH Auto-Judge Deterministic Rules):
|
|
26
|
+
*
|
|
27
|
+
* 1. No matches or cwd mismatch → IRRELEVANT
|
|
28
|
+
* 2. Outcome failed → IGNORED
|
|
29
|
+
* 3. Any match has expectedBehavior='should-not-edit' AND diff present → IGNORED
|
|
30
|
+
* 4. Otherwise → FOLLOWED
|
|
31
|
+
*/
|
|
32
|
+
export function judge(ctx: JudgeContext): Classification {
|
|
33
|
+
if (!ctx.warningResponse?.matches?.length || !ctx.cwdMatchedAtPretool) {
|
|
34
|
+
return "IRRELEVANT";
|
|
35
|
+
}
|
|
36
|
+
if (!ctx.outcome.success) {
|
|
37
|
+
return "IGNORED";
|
|
38
|
+
}
|
|
39
|
+
if (ctx.warningResponse.matches.some((m) => m.expectedBehavior === "should-not-edit" && ctx.diffPresent)) {
|
|
40
|
+
return "IGNORED";
|
|
41
|
+
}
|
|
42
|
+
return "FOLLOWED";
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Fire feedback for each match in the warning response.
|
|
47
|
+
* - Always calls /api/feedback per match (fire-and-forget).
|
|
48
|
+
* - On FOLLOWED, also calls /api/principle/touch per match (EE-10 decay refresh).
|
|
49
|
+
*
|
|
50
|
+
* B-4 invariant: returns void synchronously. All HTTP calls are fire-and-forget.
|
|
51
|
+
*/
|
|
52
|
+
export function fireFeedback(ctx: JudgeContext): void {
|
|
53
|
+
const cls = judge(ctx);
|
|
54
|
+
const matches = ctx.warningResponse?.matches ?? [];
|
|
55
|
+
const client = getDefaultEEClient();
|
|
56
|
+
for (const m of matches) {
|
|
57
|
+
client.feedback({
|
|
58
|
+
principle_uuid: m.principle_uuid,
|
|
59
|
+
classification: cls,
|
|
60
|
+
tool_name: ctx.toolName,
|
|
61
|
+
duration_ms: ctx.outcome.durationMs ?? 0,
|
|
62
|
+
tenantId: ctx.tenantId,
|
|
63
|
+
});
|
|
64
|
+
if (cls === "FOLLOWED") {
|
|
65
|
+
client.touch(m.principle_uuid, ctx.tenantId);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
}
|
|
@@ -0,0 +1,351 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Unit + integration tests for offline-queue module.
|
|
3
|
+
*
|
|
4
|
+
* Tests cover all 10 behaviors:
|
|
5
|
+
* 1. enqueue() creates queue directory lazily
|
|
6
|
+
* 2. enqueue() writes correct JSON content
|
|
7
|
+
* 3. enqueue() enforces 100-entry cap by deleting oldest
|
|
8
|
+
* 4. getQueueDir() returns correct path
|
|
9
|
+
* 5. drainQueue() replays entries in FIFO order
|
|
10
|
+
* 6. drainQueue() stops on failure, leaves remaining entries
|
|
11
|
+
* 7. drainQueue() handles non-existent queue directory
|
|
12
|
+
* 8. drainQueue() discards corrupt JSON files
|
|
13
|
+
* 9. Filename format matches /^\d+-[a-z0-9]{4}\.json$/
|
|
14
|
+
* 10. drainQueue() is fire-and-forget (returns void)
|
|
15
|
+
*/
|
|
16
|
+
import { mkdir, readdir, rm, writeFile } from "node:fs/promises";
|
|
17
|
+
import * as os from "node:os";
|
|
18
|
+
import * as path from "node:path";
|
|
19
|
+
import { afterEach, beforeEach, describe, expect, it } from "vitest";
|
|
20
|
+
import { startStubEEServer } from "../__test-stubs__/ee-server.js";
|
|
21
|
+
import {
|
|
22
|
+
drainQueue,
|
|
23
|
+
drainQueueAsync,
|
|
24
|
+
enqueue,
|
|
25
|
+
getQueueDir,
|
|
26
|
+
} from "./offline-queue.js";
|
|
27
|
+
|
|
28
|
+
// ─── Helpers ──────────────────────────────────────────────────────────────────
|
|
29
|
+
|
|
30
|
+
let tmpDir: string;
|
|
31
|
+
|
|
32
|
+
beforeEach(async () => {
|
|
33
|
+
// Create isolated temp directory for each test
|
|
34
|
+
const base = path.join(os.tmpdir(), "queue-test-");
|
|
35
|
+
// Use a unique timestamp+random suffix
|
|
36
|
+
const suffix = `${Date.now()}-${Math.random().toString(36).slice(2, 6)}`;
|
|
37
|
+
tmpDir = base + suffix;
|
|
38
|
+
await mkdir(tmpDir, { recursive: true });
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
afterEach(async () => {
|
|
42
|
+
await rm(tmpDir, { recursive: true, force: true });
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Helper: get the ee-offline-queue dir inside tmpDir.
|
|
47
|
+
*/
|
|
48
|
+
function queueDir(): string {
|
|
49
|
+
return getQueueDir(tmpDir);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Helper: write N pre-populated queue files with sequential timestamps.
|
|
54
|
+
*/
|
|
55
|
+
async function populateQueue(count: number, startTs = 1000): Promise<string[]> {
|
|
56
|
+
const dir = queueDir();
|
|
57
|
+
await mkdir(dir, { recursive: true });
|
|
58
|
+
const filenames: string[] = [];
|
|
59
|
+
for (let i = 0; i < count; i++) {
|
|
60
|
+
const ts = startTs + i;
|
|
61
|
+
const filename = `${ts}-test.json`;
|
|
62
|
+
const entry = {
|
|
63
|
+
endpoint: "/api/feedback",
|
|
64
|
+
body: { i },
|
|
65
|
+
enqueuedAt: ts,
|
|
66
|
+
};
|
|
67
|
+
await writeFile(path.join(dir, filename), JSON.stringify(entry), "utf8");
|
|
68
|
+
filenames.push(filename);
|
|
69
|
+
}
|
|
70
|
+
return filenames;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// ─── Test 1: enqueue() creates queue directory lazily ─────────────────────────
|
|
74
|
+
|
|
75
|
+
describe("enqueue()", () => {
|
|
76
|
+
it("creates the queue directory lazily on first call", async () => {
|
|
77
|
+
// Queue dir should NOT exist before enqueue
|
|
78
|
+
const dir = queueDir();
|
|
79
|
+
const files = await readdir(dir).catch(() => null);
|
|
80
|
+
expect(files).toBeNull(); // dir does not exist yet
|
|
81
|
+
|
|
82
|
+
// Call enqueue — should create dir
|
|
83
|
+
await enqueue(
|
|
84
|
+
{ endpoint: "/api/feedback", body: { test: 1 }, enqueuedAt: 1000 },
|
|
85
|
+
tmpDir,
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
// Dir should now exist
|
|
89
|
+
const filesAfter = await readdir(dir);
|
|
90
|
+
expect(Array.isArray(filesAfter)).toBe(true);
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
// ─── Test 9: Filename format ───────────────────────────────────────────────
|
|
94
|
+
|
|
95
|
+
it("creates exactly 1 file with correct filename pattern after one enqueue", async () => {
|
|
96
|
+
await enqueue(
|
|
97
|
+
{ endpoint: "/api/feedback", body: { test: 1 }, enqueuedAt: 1000 },
|
|
98
|
+
tmpDir,
|
|
99
|
+
);
|
|
100
|
+
|
|
101
|
+
const files = await readdir(queueDir());
|
|
102
|
+
expect(files).toHaveLength(1);
|
|
103
|
+
expect(files[0]).toMatch(/^\d+-[a-z0-9]{4}\.json$/);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
// ─── Test 2: enqueue() writes correct JSON content ────────────────────────
|
|
107
|
+
|
|
108
|
+
it("writes correct JSON content matching the input entry", async () => {
|
|
109
|
+
const entry = {
|
|
110
|
+
endpoint: "/api/feedback",
|
|
111
|
+
body: { test: 1 },
|
|
112
|
+
enqueuedAt: 1000,
|
|
113
|
+
};
|
|
114
|
+
await enqueue(entry, tmpDir);
|
|
115
|
+
|
|
116
|
+
const dir = queueDir();
|
|
117
|
+
const files = await readdir(dir);
|
|
118
|
+
const raw = await import("node:fs/promises").then((fs) =>
|
|
119
|
+
fs.readFile(path.join(dir, files[0]), "utf8"),
|
|
120
|
+
);
|
|
121
|
+
const parsed = JSON.parse(raw);
|
|
122
|
+
|
|
123
|
+
expect(parsed).toEqual(entry);
|
|
124
|
+
});
|
|
125
|
+
|
|
126
|
+
// ─── Test 3: enqueue() enforces 100-entry cap ─────────────────────────────
|
|
127
|
+
|
|
128
|
+
it("enforces 100-entry cap: deletes oldest when queue is at capacity", async () => {
|
|
129
|
+
// Pre-populate with exactly 100 files
|
|
130
|
+
const existing = await populateQueue(100, 1000);
|
|
131
|
+
const oldestFile = existing[0]; // timestamp 1000-test.json
|
|
132
|
+
|
|
133
|
+
// Enqueue one more entry
|
|
134
|
+
await enqueue(
|
|
135
|
+
{
|
|
136
|
+
endpoint: "/api/feedback",
|
|
137
|
+
body: { new: true },
|
|
138
|
+
enqueuedAt: 99999,
|
|
139
|
+
},
|
|
140
|
+
tmpDir,
|
|
141
|
+
);
|
|
142
|
+
|
|
143
|
+
const files = await readdir(queueDir());
|
|
144
|
+
|
|
145
|
+
// Should still have exactly 100 files
|
|
146
|
+
expect(files).toHaveLength(100);
|
|
147
|
+
|
|
148
|
+
// Oldest file should be gone
|
|
149
|
+
expect(files).not.toContain(oldestFile);
|
|
150
|
+
|
|
151
|
+
// New file should exist (it has a fresh timestamp prefix via makeFilename())
|
|
152
|
+
const newFiles = files.filter((f) => !existing.includes(f));
|
|
153
|
+
expect(newFiles).toHaveLength(1);
|
|
154
|
+
});
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
// ─── Test 4: getQueueDir() returns correct path ───────────────────────────────
|
|
158
|
+
|
|
159
|
+
describe("getQueueDir()", () => {
|
|
160
|
+
it("returns path under os.homedir() when no override given", () => {
|
|
161
|
+
const result = getQueueDir();
|
|
162
|
+
expect(result).toBe(
|
|
163
|
+
path.join(os.homedir(), ".muonroi-cli", "ee-offline-queue"),
|
|
164
|
+
);
|
|
165
|
+
});
|
|
166
|
+
|
|
167
|
+
it("returns path under homeOverride when provided", () => {
|
|
168
|
+
const result = getQueueDir("/tmp/test");
|
|
169
|
+
expect(result).toBe(
|
|
170
|
+
path.join("/tmp/test", ".muonroi-cli", "ee-offline-queue"),
|
|
171
|
+
);
|
|
172
|
+
});
|
|
173
|
+
});
|
|
174
|
+
|
|
175
|
+
// ─── Test 5: drainQueue() replays entries in FIFO order ───────────────────────
|
|
176
|
+
|
|
177
|
+
describe("drainQueueAsync()", () => {
|
|
178
|
+
it("replays entries in FIFO order and deletes them after success", async () => {
|
|
179
|
+
// Pre-populate 3 entries with distinct timestamps
|
|
180
|
+
await populateQueue(3, 1000);
|
|
181
|
+
|
|
182
|
+
const stub = await startStubEEServer({ feedback: () => {} });
|
|
183
|
+
|
|
184
|
+
try {
|
|
185
|
+
await drainQueueAsync(
|
|
186
|
+
fetch,
|
|
187
|
+
{ "Content-Type": "application/json" },
|
|
188
|
+
`http://127.0.0.1:${stub.port}`,
|
|
189
|
+
tmpDir,
|
|
190
|
+
);
|
|
191
|
+
|
|
192
|
+
// 3 requests received in order
|
|
193
|
+
expect(stub.calls.feedback).toHaveLength(3);
|
|
194
|
+
expect(stub.calls.feedback[0].enqueuedAt ?? stub.calls.feedback[0].i).toBeDefined();
|
|
195
|
+
|
|
196
|
+
// FIFO: first enqueued (ts=1000) should come first
|
|
197
|
+
const receivedEnqueuedAts = stub.calls.feedback.map((b: any) => b.enqueuedAt ?? b.i);
|
|
198
|
+
expect(receivedEnqueuedAts[0]).toBeLessThan(receivedEnqueuedAts[1]);
|
|
199
|
+
expect(receivedEnqueuedAts[1]).toBeLessThan(receivedEnqueuedAts[2]);
|
|
200
|
+
|
|
201
|
+
// All files deleted after successful replay
|
|
202
|
+
const remainingFiles = await readdir(queueDir()).catch(() => []);
|
|
203
|
+
expect(remainingFiles).toHaveLength(0);
|
|
204
|
+
} finally {
|
|
205
|
+
await stub.stop();
|
|
206
|
+
}
|
|
207
|
+
});
|
|
208
|
+
|
|
209
|
+
// ─── Test 6: drainQueue() stops on failure, leaves remaining ──────────────
|
|
210
|
+
|
|
211
|
+
it("stops on 2nd entry failure and leaves 2nd + 3rd entries on disk", async () => {
|
|
212
|
+
await populateQueue(3, 1000);
|
|
213
|
+
|
|
214
|
+
let callCount = 0;
|
|
215
|
+
const stub = await startStubEEServer({
|
|
216
|
+
feedback: () => {
|
|
217
|
+
callCount++;
|
|
218
|
+
},
|
|
219
|
+
});
|
|
220
|
+
|
|
221
|
+
// Override the server to return 500 on 2nd call
|
|
222
|
+
// We'll track calls and use a custom stub that serves 500 on 2nd request
|
|
223
|
+
await stub.stop();
|
|
224
|
+
|
|
225
|
+
// Build a minimal stub that returns 500 on 2nd POST to /api/feedback
|
|
226
|
+
const { createServer } = await import("node:http");
|
|
227
|
+
let reqCount = 0;
|
|
228
|
+
const customServer = createServer((req, res) => {
|
|
229
|
+
if (req.url === "/api/feedback" && req.method === "POST") {
|
|
230
|
+
reqCount++;
|
|
231
|
+
const chunks: Buffer[] = [];
|
|
232
|
+
req.on("data", (c: Buffer) => chunks.push(c));
|
|
233
|
+
req.on("end", () => {
|
|
234
|
+
if (reqCount === 2) {
|
|
235
|
+
res.writeHead(500);
|
|
236
|
+
res.end("error");
|
|
237
|
+
} else {
|
|
238
|
+
res.writeHead(200);
|
|
239
|
+
res.end("ok");
|
|
240
|
+
}
|
|
241
|
+
});
|
|
242
|
+
} else {
|
|
243
|
+
res.writeHead(404);
|
|
244
|
+
res.end();
|
|
245
|
+
}
|
|
246
|
+
});
|
|
247
|
+
|
|
248
|
+
await new Promise<void>((resolve) =>
|
|
249
|
+
customServer.listen(0, "127.0.0.1", () => resolve()),
|
|
250
|
+
);
|
|
251
|
+
const addr = customServer.address();
|
|
252
|
+
const port =
|
|
253
|
+
typeof addr === "object" && addr ? (addr as { port: number }).port : 0;
|
|
254
|
+
|
|
255
|
+
try {
|
|
256
|
+
await drainQueueAsync(
|
|
257
|
+
fetch,
|
|
258
|
+
{ "Content-Type": "application/json" },
|
|
259
|
+
`http://127.0.0.1:${port}`,
|
|
260
|
+
tmpDir,
|
|
261
|
+
);
|
|
262
|
+
|
|
263
|
+
// 1st success, 2nd failure → should have made 2 requests total
|
|
264
|
+
expect(reqCount).toBe(2);
|
|
265
|
+
|
|
266
|
+
// 2nd and 3rd files remain on disk (1st was deleted on success)
|
|
267
|
+
const remainingFiles = await readdir(queueDir());
|
|
268
|
+
expect(remainingFiles).toHaveLength(2);
|
|
269
|
+
} finally {
|
|
270
|
+
await new Promise<void>((resolve) => customServer.close(() => resolve()));
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
|
|
274
|
+
// ─── Test 7: drainQueue() handles non-existent queue directory ────────────
|
|
275
|
+
|
|
276
|
+
it("returns cleanly when queue directory does not exist", async () => {
|
|
277
|
+
// No queue dir created — just call drainQueueAsync with a fresh tmpDir
|
|
278
|
+
await expect(
|
|
279
|
+
drainQueueAsync(
|
|
280
|
+
fetch,
|
|
281
|
+
{ "Content-Type": "application/json" },
|
|
282
|
+
"http://127.0.0.1:9999",
|
|
283
|
+
tmpDir,
|
|
284
|
+
),
|
|
285
|
+
).resolves.toBeUndefined();
|
|
286
|
+
});
|
|
287
|
+
|
|
288
|
+
// ─── Test 8: drainQueue() discards corrupt JSON files ─────────────────────
|
|
289
|
+
|
|
290
|
+
it("discards corrupt JSON files and replays valid entries after them", async () => {
|
|
291
|
+
const dir = queueDir();
|
|
292
|
+
await mkdir(dir, { recursive: true });
|
|
293
|
+
|
|
294
|
+
// Write corrupt file first (older timestamp)
|
|
295
|
+
const corruptFile = "1000-bad1.json";
|
|
296
|
+
await writeFile(path.join(dir, corruptFile), "NOT VALID JSON {{{{", "utf8");
|
|
297
|
+
|
|
298
|
+
// Write valid entry after (newer timestamp)
|
|
299
|
+
const validEntry = {
|
|
300
|
+
endpoint: "/api/feedback",
|
|
301
|
+
body: { valid: true },
|
|
302
|
+
enqueuedAt: 2000,
|
|
303
|
+
};
|
|
304
|
+
await writeFile(
|
|
305
|
+
path.join(dir, "2000-good.json"),
|
|
306
|
+
JSON.stringify(validEntry),
|
|
307
|
+
"utf8",
|
|
308
|
+
);
|
|
309
|
+
|
|
310
|
+
const stub = await startStubEEServer({ feedback: () => {} });
|
|
311
|
+
|
|
312
|
+
try {
|
|
313
|
+
await drainQueueAsync(
|
|
314
|
+
fetch,
|
|
315
|
+
{ "Content-Type": "application/json" },
|
|
316
|
+
`http://127.0.0.1:${stub.port}`,
|
|
317
|
+
tmpDir,
|
|
318
|
+
);
|
|
319
|
+
|
|
320
|
+
// Corrupt file should be deleted
|
|
321
|
+
const remaining = await readdir(dir);
|
|
322
|
+
expect(remaining).not.toContain(corruptFile);
|
|
323
|
+
|
|
324
|
+
// Valid entry should have been replayed
|
|
325
|
+
expect(stub.calls.feedback).toHaveLength(1);
|
|
326
|
+
expect(stub.calls.feedback[0]).toEqual(validEntry.body);
|
|
327
|
+
|
|
328
|
+
// Valid file should be deleted after replay
|
|
329
|
+
expect(remaining).toHaveLength(0);
|
|
330
|
+
} finally {
|
|
331
|
+
await stub.stop();
|
|
332
|
+
}
|
|
333
|
+
});
|
|
334
|
+
});
|
|
335
|
+
|
|
336
|
+
// ─── Test 10: drainQueue() is fire-and-forget ─────────────────────────────────
|
|
337
|
+
|
|
338
|
+
describe("drainQueue() fire-and-forget wrapper", () => {
|
|
339
|
+
it("returns void (undefined), not a Promise", () => {
|
|
340
|
+
// Call drainQueue (the fire-and-forget wrapper) — should return undefined immediately
|
|
341
|
+
const result = drainQueue(
|
|
342
|
+
fetch,
|
|
343
|
+
{ "Content-Type": "application/json" },
|
|
344
|
+
"http://127.0.0.1:9999",
|
|
345
|
+
tmpDir,
|
|
346
|
+
);
|
|
347
|
+
|
|
348
|
+
// drainQueue() must return void (undefined), not a Promise
|
|
349
|
+
expect(result).toBeUndefined();
|
|
350
|
+
});
|
|
351
|
+
});
|