@oscharko-dev/keiko 0.1.0-beta.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 +202 -0
- package/NOTICE +7 -0
- package/README.md +621 -0
- package/TRADEMARKS.md +41 -0
- package/dist/audit/aggregate.d.ts +5 -0
- package/dist/audit/aggregate.js +25 -0
- package/dist/audit/build.d.ts +2 -0
- package/dist/audit/build.js +224 -0
- package/dist/audit/errors.d.ts +25 -0
- package/dist/audit/errors.js +39 -0
- package/dist/audit/index-api.d.ts +14 -0
- package/dist/audit/index-api.js +131 -0
- package/dist/audit/index.d.ts +12 -0
- package/dist/audit/index.js +17 -0
- package/dist/audit/persist.d.ts +8 -0
- package/dist/audit/persist.js +40 -0
- package/dist/audit/redaction.d.ts +3 -0
- package/dist/audit/redaction.js +61 -0
- package/dist/audit/report.d.ts +18 -0
- package/dist/audit/report.js +50 -0
- package/dist/audit/retention.d.ts +3 -0
- package/dist/audit/retention.js +95 -0
- package/dist/audit/runid.d.ts +1 -0
- package/dist/audit/runid.js +29 -0
- package/dist/audit/side-file.d.ts +12 -0
- package/dist/audit/side-file.js +82 -0
- package/dist/audit/store.d.ts +12 -0
- package/dist/audit/store.js +198 -0
- package/dist/audit/types.d.ts +188 -0
- package/dist/audit/types.js +8 -0
- package/dist/audit/workflow-evidence.d.ts +27 -0
- package/dist/audit/workflow-evidence.js +145 -0
- package/dist/cli/context.d.ts +2 -0
- package/dist/cli/context.js +102 -0
- package/dist/cli/evaluate.d.ts +7 -0
- package/dist/cli/evaluate.js +207 -0
- package/dist/cli/evidence.d.ts +8 -0
- package/dist/cli/evidence.js +88 -0
- package/dist/cli/gateway-config.d.ts +10 -0
- package/dist/cli/gateway-config.js +12 -0
- package/dist/cli/gen-tests.d.ts +7 -0
- package/dist/cli/gen-tests.js +208 -0
- package/dist/cli/index.d.ts +2 -0
- package/dist/cli/index.js +14 -0
- package/dist/cli/investigate.d.ts +8 -0
- package/dist/cli/investigate.js +242 -0
- package/dist/cli/models.d.ts +3 -0
- package/dist/cli/models.js +64 -0
- package/dist/cli/run.d.ts +7 -0
- package/dist/cli/run.js +187 -0
- package/dist/cli/runner.d.ts +6 -0
- package/dist/cli/runner.js +83 -0
- package/dist/cli/ui.d.ts +31 -0
- package/dist/cli/ui.js +240 -0
- package/dist/cli/verify.d.ts +2 -0
- package/dist/cli/verify.js +103 -0
- package/dist/evaluations/fixtures/bug-investigation/happy-path.d.ts +2 -0
- package/dist/evaluations/fixtures/bug-investigation/happy-path.js +66 -0
- package/dist/evaluations/fixtures/bug-investigation/investigation-only.d.ts +2 -0
- package/dist/evaluations/fixtures/bug-investigation/investigation-only.js +39 -0
- package/dist/evaluations/fixtures/bug-investigation/unsafe-action.d.ts +2 -0
- package/dist/evaluations/fixtures/bug-investigation/unsafe-action.js +37 -0
- package/dist/evaluations/fixtures/index.d.ts +7 -0
- package/dist/evaluations/fixtures/index.js +35 -0
- package/dist/evaluations/fixtures/support.d.ts +5 -0
- package/dist/evaluations/fixtures/support.js +42 -0
- package/dist/evaluations/fixtures/unit-tests/happy-path.d.ts +2 -0
- package/dist/evaluations/fixtures/unit-tests/happy-path.js +40 -0
- package/dist/evaluations/fixtures/unit-tests/retry-then-accept.d.ts +2 -0
- package/dist/evaluations/fixtures/unit-tests/retry-then-accept.js +39 -0
- package/dist/evaluations/fixtures/unit-tests/unsafe-action.d.ts +2 -0
- package/dist/evaluations/fixtures/unit-tests/unsafe-action.js +32 -0
- package/dist/evaluations/index.d.ts +12 -0
- package/dist/evaluations/index.js +12 -0
- package/dist/evaluations/manifest-check.d.ts +1 -0
- package/dist/evaluations/manifest-check.js +48 -0
- package/dist/evaluations/model-provider.d.ts +12 -0
- package/dist/evaluations/model-provider.js +26 -0
- package/dist/evaluations/render.d.ts +2 -0
- package/dist/evaluations/render.js +59 -0
- package/dist/evaluations/runner-support.d.ts +27 -0
- package/dist/evaluations/runner-support.js +163 -0
- package/dist/evaluations/runner.d.ts +20 -0
- package/dist/evaluations/runner.js +174 -0
- package/dist/evaluations/scorer.d.ts +14 -0
- package/dist/evaluations/scorer.js +131 -0
- package/dist/evaluations/scripted-model.d.ts +6 -0
- package/dist/evaluations/scripted-model.js +26 -0
- package/dist/evaluations/surface-parity.d.ts +2 -0
- package/dist/evaluations/surface-parity.js +184 -0
- package/dist/evaluations/types.d.ts +74 -0
- package/dist/evaluations/types.js +16 -0
- package/dist/gateway/capabilities.d.ts +11 -0
- package/dist/gateway/capabilities.data.d.ts +2 -0
- package/dist/gateway/capabilities.data.js +203 -0
- package/dist/gateway/capabilities.js +41 -0
- package/dist/gateway/config.d.ts +15 -0
- package/dist/gateway/config.js +154 -0
- package/dist/gateway/errors.d.ts +72 -0
- package/dist/gateway/errors.js +82 -0
- package/dist/gateway/gateway.d.ts +19 -0
- package/dist/gateway/gateway.js +94 -0
- package/dist/gateway/index.d.ts +10 -0
- package/dist/gateway/index.js +11 -0
- package/dist/gateway/model-selection.d.ts +9 -0
- package/dist/gateway/model-selection.js +36 -0
- package/dist/gateway/normalize.d.ts +7 -0
- package/dist/gateway/normalize.js +93 -0
- package/dist/gateway/openai-adapter.d.ts +20 -0
- package/dist/gateway/openai-adapter.js +263 -0
- package/dist/gateway/redaction.d.ts +1 -0
- package/dist/gateway/redaction.js +51 -0
- package/dist/gateway/resilience.d.ts +24 -0
- package/dist/gateway/resilience.js +166 -0
- package/dist/gateway/types.d.ts +108 -0
- package/dist/gateway/types.js +2 -0
- package/dist/harness/adapters.d.ts +23 -0
- package/dist/harness/adapters.js +38 -0
- package/dist/harness/context.d.ts +33 -0
- package/dist/harness/context.js +21 -0
- package/dist/harness/emitter.d.ts +15 -0
- package/dist/harness/emitter.js +72 -0
- package/dist/harness/errors.d.ts +21 -0
- package/dist/harness/errors.js +39 -0
- package/dist/harness/executor.d.ts +3 -0
- package/dist/harness/executor.js +211 -0
- package/dist/harness/fingerprint.d.ts +6 -0
- package/dist/harness/fingerprint.js +43 -0
- package/dist/harness/index.d.ts +9 -0
- package/dist/harness/index.js +13 -0
- package/dist/harness/loop.d.ts +3 -0
- package/dist/harness/loop.js +159 -0
- package/dist/harness/patcher.d.ts +4 -0
- package/dist/harness/patcher.js +49 -0
- package/dist/harness/planner.d.ts +3 -0
- package/dist/harness/planner.js +21 -0
- package/dist/harness/ports.d.ts +61 -0
- package/dist/harness/ports.js +4 -0
- package/dist/harness/session.d.ts +25 -0
- package/dist/harness/session.js +116 -0
- package/dist/harness/sinks.d.ts +30 -0
- package/dist/harness/sinks.js +72 -0
- package/dist/harness/tasks/explain-plan.d.ts +3 -0
- package/dist/harness/tasks/explain-plan.js +29 -0
- package/dist/harness/tasks/generate-unit-tests.d.ts +3 -0
- package/dist/harness/tasks/generate-unit-tests.js +28 -0
- package/dist/harness/tasks/investigate-bug.d.ts +3 -0
- package/dist/harness/tasks/investigate-bug.js +31 -0
- package/dist/harness/tasks/policy.d.ts +11 -0
- package/dist/harness/tasks/policy.js +22 -0
- package/dist/harness/tasks/verify.d.ts +3 -0
- package/dist/harness/tasks/verify.js +16 -0
- package/dist/harness/types.d.ts +270 -0
- package/dist/harness/types.js +33 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +36 -0
- package/dist/sdk/index.d.ts +9 -0
- package/dist/sdk/index.js +37 -0
- package/dist/sdk/run-agent.d.ts +16 -0
- package/dist/sdk/run-agent.js +56 -0
- package/dist/tools/browser/cdp-client.d.ts +35 -0
- package/dist/tools/browser/cdp-client.js +218 -0
- package/dist/tools/browser/errors.d.ts +25 -0
- package/dist/tools/browser/errors.js +55 -0
- package/dist/tools/browser/index.d.ts +5 -0
- package/dist/tools/browser/index.js +6 -0
- package/dist/tools/browser/session.d.ts +44 -0
- package/dist/tools/browser/session.js +748 -0
- package/dist/tools/browser/types.d.ts +48 -0
- package/dist/tools/browser/types.js +2 -0
- package/dist/tools/browser/validators.d.ts +5 -0
- package/dist/tools/browser/validators.js +97 -0
- package/dist/tools/errors.d.ts +59 -0
- package/dist/tools/errors.js +94 -0
- package/dist/tools/exec.d.ts +42 -0
- package/dist/tools/exec.js +327 -0
- package/dist/tools/index.d.ts +11 -0
- package/dist/tools/index.js +14 -0
- package/dist/tools/patch-content.d.ts +10 -0
- package/dist/tools/patch-content.js +126 -0
- package/dist/tools/patch-normalize.d.ts +1 -0
- package/dist/tools/patch-normalize.js +80 -0
- package/dist/tools/patch-parse.d.ts +8 -0
- package/dist/tools/patch-parse.js +201 -0
- package/dist/tools/patch.d.ts +18 -0
- package/dist/tools/patch.js +403 -0
- package/dist/tools/registry.d.ts +36 -0
- package/dist/tools/registry.js +231 -0
- package/dist/tools/sandbox.d.ts +8 -0
- package/dist/tools/sandbox.js +121 -0
- package/dist/tools/schemas.d.ts +2 -0
- package/dist/tools/schemas.js +51 -0
- package/dist/tools/terminal-policy.d.ts +9 -0
- package/dist/tools/terminal-policy.js +313 -0
- package/dist/tools/types.d.ts +99 -0
- package/dist/tools/types.js +103 -0
- package/dist/tools/writer.d.ts +7 -0
- package/dist/tools/writer.js +20 -0
- package/dist/ui/browser.d.ts +10 -0
- package/dist/ui/browser.js +231 -0
- package/dist/ui/chat-handlers.d.ts +4 -0
- package/dist/ui/chat-handlers.js +281 -0
- package/dist/ui/csp-hashes.json +17 -0
- package/dist/ui/csp.d.ts +2 -0
- package/dist/ui/csp.js +66 -0
- package/dist/ui/deps.d.ts +34 -0
- package/dist/ui/deps.js +137 -0
- package/dist/ui/evidence.d.ts +27 -0
- package/dist/ui/evidence.js +142 -0
- package/dist/ui/files-deny.d.ts +2 -0
- package/dist/ui/files-deny.js +12 -0
- package/dist/ui/files.d.ts +65 -0
- package/dist/ui/files.js +492 -0
- package/dist/ui/headers.d.ts +2 -0
- package/dist/ui/headers.js +21 -0
- package/dist/ui/host-check.d.ts +2 -0
- package/dist/ui/host-check.js +58 -0
- package/dist/ui/index.d.ts +20 -0
- package/dist/ui/index.js +23 -0
- package/dist/ui/load-csp.d.ts +1 -0
- package/dist/ui/load-csp.js +28 -0
- package/dist/ui/read-handlers.d.ts +8 -0
- package/dist/ui/read-handlers.js +247 -0
- package/dist/ui/routes.d.ts +36 -0
- package/dist/ui/routes.js +129 -0
- package/dist/ui/run-engine.d.ts +20 -0
- package/dist/ui/run-engine.js +345 -0
- package/dist/ui/run-handlers.d.ts +8 -0
- package/dist/ui/run-handlers.js +431 -0
- package/dist/ui/run-request.d.ts +13 -0
- package/dist/ui/run-request.js +219 -0
- package/dist/ui/runs.d.ts +43 -0
- package/dist/ui/runs.js +92 -0
- package/dist/ui/server.d.ts +11 -0
- package/dist/ui/server.js +143 -0
- package/dist/ui/sink.d.ts +27 -0
- package/dist/ui/sink.js +80 -0
- package/dist/ui/sse.d.ts +7 -0
- package/dist/ui/sse.js +27 -0
- package/dist/ui/static/404.html +1 -0
- package/dist/ui/static/_next/static/ca-A01hy9W98aRvMZKdAw/_buildManifest.js +1 -0
- package/dist/ui/static/_next/static/ca-A01hy9W98aRvMZKdAw/_ssgManifest.js +1 -0
- package/dist/ui/static/_next/static/chunks/255-d47fd57964443afe.js +1 -0
- package/dist/ui/static/_next/static/chunks/4-be1fef693af8e088.js +1 -0
- package/dist/ui/static/_next/static/chunks/4bd1b696-c023c6e3521b1417.js +1 -0
- package/dist/ui/static/_next/static/chunks/app/_not-found/page-75825b09bcecad97.js +1 -0
- package/dist/ui/static/_next/static/chunks/app/launch/page-9c86a13c29884245.js +1 -0
- package/dist/ui/static/_next/static/chunks/app/layout-bdea63fe87947d50.js +1 -0
- package/dist/ui/static/_next/static/chunks/app/page-4168c12c68b7a853.js +1 -0
- package/dist/ui/static/_next/static/chunks/framework-a6e0b7e30f98059a.js +1 -0
- package/dist/ui/static/_next/static/chunks/main-778a50aebff02192.js +1 -0
- package/dist/ui/static/_next/static/chunks/main-app-30679af7240d63e9.js +1 -0
- package/dist/ui/static/_next/static/chunks/pages/_app-7d307437aca18ad4.js +1 -0
- package/dist/ui/static/_next/static/chunks/pages/_error-cb2a52f75f2162e2.js +1 -0
- package/dist/ui/static/_next/static/chunks/polyfills-42372ed130431b0a.js +1 -0
- package/dist/ui/static/_next/static/chunks/webpack-4a462cecab786e93.js +1 -0
- package/dist/ui/static/_next/static/css/be7cb54d5c5673b6.css +1 -0
- package/dist/ui/static/assets/editors/goland.svg +35 -0
- package/dist/ui/static/assets/editors/intellij.svg +39 -0
- package/dist/ui/static/assets/editors/pycharm.svg +58 -0
- package/dist/ui/static/assets/editors/rustrover.svg +19 -0
- package/dist/ui/static/assets/editors/vscode.svg +1 -0
- package/dist/ui/static/assets/editors/webstorm.svg +21 -0
- package/dist/ui/static/assets/icons/anthropic.svg +1 -0
- package/dist/ui/static/assets/icons/brave.svg +1 -0
- package/dist/ui/static/assets/icons/css3.svg +1 -0
- package/dist/ui/static/assets/icons/docker.svg +1 -0
- package/dist/ui/static/assets/icons/git.svg +1 -0
- package/dist/ui/static/assets/icons/github.svg +1 -0
- package/dist/ui/static/assets/icons/go.svg +1 -0
- package/dist/ui/static/assets/icons/gradle.svg +1 -0
- package/dist/ui/static/assets/icons/grafana.svg +1 -0
- package/dist/ui/static/assets/icons/graphql.svg +1 -0
- package/dist/ui/static/assets/icons/html5.svg +1 -0
- package/dist/ui/static/assets/icons/image.svg +1 -0
- package/dist/ui/static/assets/icons/java.svg +1 -0
- package/dist/ui/static/assets/icons/javascript.svg +1 -0
- package/dist/ui/static/assets/icons/json.svg +1 -0
- package/dist/ui/static/assets/icons/kafka.svg +1 -0
- package/dist/ui/static/assets/icons/kubernetes.svg +1 -0
- package/dist/ui/static/assets/icons/linear.svg +1 -0
- package/dist/ui/static/assets/icons/markdown.svg +1 -0
- package/dist/ui/static/assets/icons/nginx.svg +1 -0
- package/dist/ui/static/assets/icons/nodejs.svg +1 -0
- package/dist/ui/static/assets/icons/notion.svg +1 -0
- package/dist/ui/static/assets/icons/openai.svg +1 -0
- package/dist/ui/static/assets/icons/playwright.svg +1 -0
- package/dist/ui/static/assets/icons/postgresql.svg +1 -0
- package/dist/ui/static/assets/icons/prometheus.svg +1 -0
- package/dist/ui/static/assets/icons/properties.svg +1 -0
- package/dist/ui/static/assets/icons/puppeteer.svg +1 -0
- package/dist/ui/static/assets/icons/python.svg +1 -0
- package/dist/ui/static/assets/icons/react.svg +1 -0
- package/dist/ui/static/assets/icons/redis.svg +1 -0
- package/dist/ui/static/assets/icons/rust.svg +1 -0
- package/dist/ui/static/assets/icons/sentry.svg +1 -0
- package/dist/ui/static/assets/icons/slack.svg +1 -0
- package/dist/ui/static/assets/icons/spring.svg +1 -0
- package/dist/ui/static/assets/icons/typescript.svg +1 -0
- package/dist/ui/static/assets/icons/upstash.svg +1 -0
- package/dist/ui/static/assets/icons/yaml.svg +1 -0
- package/dist/ui/static/assets/keiko-logo.svg +10 -0
- package/dist/ui/static/index.html +1 -0
- package/dist/ui/static/index.txt +19 -0
- package/dist/ui/static/keiko-logo.svg +10 -0
- package/dist/ui/static/launch.html +1 -0
- package/dist/ui/static/launch.txt +19 -0
- package/dist/ui/static.d.ts +3 -0
- package/dist/ui/static.js +72 -0
- package/dist/ui/store/chats.d.ts +14 -0
- package/dist/ui/store/chats.js +110 -0
- package/dist/ui/store/db.d.ts +6 -0
- package/dist/ui/store/db.js +182 -0
- package/dist/ui/store/errors.d.ts +12 -0
- package/dist/ui/store/errors.js +30 -0
- package/dist/ui/store/index.d.ts +6 -0
- package/dist/ui/store/index.js +6 -0
- package/dist/ui/store/messages.d.ts +5 -0
- package/dist/ui/store/messages.js +137 -0
- package/dist/ui/store/paths.d.ts +4 -0
- package/dist/ui/store/paths.js +69 -0
- package/dist/ui/store/projects.d.ts +7 -0
- package/dist/ui/store/projects.js +61 -0
- package/dist/ui/store/schema.d.ts +3 -0
- package/dist/ui/store/schema.js +77 -0
- package/dist/ui/store/types.d.ts +80 -0
- package/dist/ui/store/types.js +3 -0
- package/dist/ui/store/validation.d.ts +4 -0
- package/dist/ui/store/validation.js +72 -0
- package/dist/ui/store-handlers.d.ts +16 -0
- package/dist/ui/store-handlers.js +465 -0
- package/dist/ui/terminal-errors.d.ts +21 -0
- package/dist/ui/terminal-errors.js +45 -0
- package/dist/ui/terminal-evidence.d.ts +20 -0
- package/dist/ui/terminal-evidence.js +65 -0
- package/dist/ui/terminal-routes.d.ts +9 -0
- package/dist/ui/terminal-routes.js +219 -0
- package/dist/ui/terminal.d.ts +67 -0
- package/dist/ui/terminal.js +835 -0
- package/dist/verification/classify.d.ts +10 -0
- package/dist/verification/classify.js +53 -0
- package/dist/verification/detect.d.ts +4 -0
- package/dist/verification/detect.js +81 -0
- package/dist/verification/errors.d.ts +11 -0
- package/dist/verification/errors.js +21 -0
- package/dist/verification/index.d.ts +17 -0
- package/dist/verification/index.js +13 -0
- package/dist/verification/limits.d.ts +3 -0
- package/dist/verification/limits.js +40 -0
- package/dist/verification/monitor.d.ts +4 -0
- package/dist/verification/monitor.js +58 -0
- package/dist/verification/orchestrator.d.ts +16 -0
- package/dist/verification/orchestrator.js +363 -0
- package/dist/verification/plan.d.ts +9 -0
- package/dist/verification/plan.js +125 -0
- package/dist/verification/summary.d.ts +40 -0
- package/dist/verification/summary.js +67 -0
- package/dist/verification/types.d.ts +63 -0
- package/dist/verification/types.js +13 -0
- package/dist/workflows/bug-investigation/context.d.ts +7 -0
- package/dist/workflows/bug-investigation/context.js +119 -0
- package/dist/workflows/bug-investigation/descriptor.d.ts +3 -0
- package/dist/workflows/bug-investigation/descriptor.js +46 -0
- package/dist/workflows/bug-investigation/emit.d.ts +12 -0
- package/dist/workflows/bug-investigation/emit.js +35 -0
- package/dist/workflows/bug-investigation/events.d.ts +81 -0
- package/dist/workflows/bug-investigation/events.js +9 -0
- package/dist/workflows/bug-investigation/failure-parse.d.ts +3 -0
- package/dist/workflows/bug-investigation/failure-parse.js +154 -0
- package/dist/workflows/bug-investigation/guard.d.ts +2 -0
- package/dist/workflows/bug-investigation/guard.js +69 -0
- package/dist/workflows/bug-investigation/index.d.ts +7 -0
- package/dist/workflows/bug-investigation/index.js +13 -0
- package/dist/workflows/bug-investigation/internal.d.ts +37 -0
- package/dist/workflows/bug-investigation/internal.js +64 -0
- package/dist/workflows/bug-investigation/model-loop.d.ts +4 -0
- package/dist/workflows/bug-investigation/model-loop.js +223 -0
- package/dist/workflows/bug-investigation/parse.d.ts +3 -0
- package/dist/workflows/bug-investigation/parse.js +123 -0
- package/dist/workflows/bug-investigation/prompt.d.ts +4 -0
- package/dist/workflows/bug-investigation/prompt.js +107 -0
- package/dist/workflows/bug-investigation/report.d.ts +23 -0
- package/dist/workflows/bug-investigation/report.js +151 -0
- package/dist/workflows/bug-investigation/stages.d.ts +13 -0
- package/dist/workflows/bug-investigation/stages.js +242 -0
- package/dist/workflows/bug-investigation/types.d.ts +91 -0
- package/dist/workflows/bug-investigation/types.js +14 -0
- package/dist/workflows/bug-investigation/verify-stage.d.ts +10 -0
- package/dist/workflows/bug-investigation/verify-stage.js +91 -0
- package/dist/workflows/bug-investigation/workflow.d.ts +2 -0
- package/dist/workflows/bug-investigation/workflow.js +74 -0
- package/dist/workflows/descriptor.d.ts +20 -0
- package/dist/workflows/descriptor.js +8 -0
- package/dist/workflows/index.d.ts +3 -0
- package/dist/workflows/index.js +2 -0
- package/dist/workflows/unit-tests/context.d.ts +7 -0
- package/dist/workflows/unit-tests/context.js +129 -0
- package/dist/workflows/unit-tests/conventions.d.ts +4 -0
- package/dist/workflows/unit-tests/conventions.js +87 -0
- package/dist/workflows/unit-tests/descriptor.d.ts +4 -0
- package/dist/workflows/unit-tests/descriptor.js +43 -0
- package/dist/workflows/unit-tests/emit.d.ts +12 -0
- package/dist/workflows/unit-tests/emit.js +35 -0
- package/dist/workflows/unit-tests/events.d.ts +78 -0
- package/dist/workflows/unit-tests/events.js +7 -0
- package/dist/workflows/unit-tests/index.d.ts +6 -0
- package/dist/workflows/unit-tests/index.js +10 -0
- package/dist/workflows/unit-tests/internal.d.ts +35 -0
- package/dist/workflows/unit-tests/internal.js +43 -0
- package/dist/workflows/unit-tests/model-loop.d.ts +4 -0
- package/dist/workflows/unit-tests/model-loop.js +95 -0
- package/dist/workflows/unit-tests/parse.d.ts +6 -0
- package/dist/workflows/unit-tests/parse.js +68 -0
- package/dist/workflows/unit-tests/prompt.d.ts +4 -0
- package/dist/workflows/unit-tests/prompt.js +71 -0
- package/dist/workflows/unit-tests/report.d.ts +21 -0
- package/dist/workflows/unit-tests/report.js +90 -0
- package/dist/workflows/unit-tests/stages.d.ts +9 -0
- package/dist/workflows/unit-tests/stages.js +155 -0
- package/dist/workflows/unit-tests/types.d.ts +70 -0
- package/dist/workflows/unit-tests/types.js +11 -0
- package/dist/workflows/unit-tests/verify-stage.d.ts +9 -0
- package/dist/workflows/unit-tests/verify-stage.js +56 -0
- package/dist/workflows/unit-tests/workflow.d.ts +2 -0
- package/dist/workflows/unit-tests/workflow.js +58 -0
- package/dist/workspace/contextPack.d.ts +9 -0
- package/dist/workspace/contextPack.js +94 -0
- package/dist/workspace/detect.d.ts +3 -0
- package/dist/workspace/detect.js +135 -0
- package/dist/workspace/discovery.d.ts +9 -0
- package/dist/workspace/discovery.js +167 -0
- package/dist/workspace/errors.d.ts +39 -0
- package/dist/workspace/errors.js +66 -0
- package/dist/workspace/fs.d.ts +21 -0
- package/dist/workspace/fs.js +36 -0
- package/dist/workspace/ignore.d.ts +14 -0
- package/dist/workspace/ignore.js +176 -0
- package/dist/workspace/index.d.ts +11 -0
- package/dist/workspace/index.js +13 -0
- package/dist/workspace/paths.d.ts +2 -0
- package/dist/workspace/paths.js +38 -0
- package/dist/workspace/realpath.d.ts +7 -0
- package/dist/workspace/realpath.js +72 -0
- package/dist/workspace/retrieval.d.ts +9 -0
- package/dist/workspace/retrieval.js +74 -0
- package/dist/workspace/summary.d.ts +3 -0
- package/dist/workspace/summary.js +54 -0
- package/dist/workspace/types.d.ts +103 -0
- package/dist/workspace/types.js +27 -0
- package/package.json +58 -0
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
// The six read-only BFF endpoints (ADR-0011 D5 routes 2,3,4,10,11,12). Each returns a redacted JSON
|
|
2
|
+
// projection of already-safe data: config via `toSafeObject` (strips apiKey), the full capability
|
|
3
|
+
// registry, the workflow launch-form descriptors, the workspace summary built from the workspace
|
|
4
|
+
// layer, and evidence list/detail served straight from the store (manifests are redacted-by-
|
|
5
|
+
// construction on disk, served as-is per D9). No secret reaches any response; the config route
|
|
6
|
+
// never leaks the config path even on a load failure (handled upstream in deps.ts, which yields
|
|
7
|
+
// `config: undefined` rather than throwing).
|
|
8
|
+
import { toSafeObject, listCapabilities } from "../gateway/index.js";
|
|
9
|
+
import { UNIT_TEST_WORKFLOW_DESCRIPTOR, BUG_INVESTIGATION_WORKFLOW_DESCRIPTOR, } from "../workflows/index.js";
|
|
10
|
+
import { DEFAULT_LIMITS } from "../harness/index.js";
|
|
11
|
+
import { listEvidence, loadEvidence, assertValidRunId, EvidenceReadError, EvidenceSchemaError, } from "../audit/index.js";
|
|
12
|
+
import { buildContextPackFromFiles, buildWorkspaceSummary, DEFAULT_CONTEXT_REQUEST, detectWorkspace, discoverWithStats, WORKSPACE_CODES, WorkspaceError, } from "../workspace/index.js";
|
|
13
|
+
import { errorBody } from "./routes.js";
|
|
14
|
+
import { validateProjectPath } from "./store/validation.js";
|
|
15
|
+
// Route 2 — resolved config (SafeGatewayConfig, never apiKey/baseUrl) or null when no config was resolved.
|
|
16
|
+
export function handleConfig(_ctx, deps) {
|
|
17
|
+
const config = deps.config === undefined ? null : toSafeObject(deps.config);
|
|
18
|
+
return { status: 200, body: { config, configPresent: deps.configPresent } };
|
|
19
|
+
}
|
|
20
|
+
// Route 3 — models published by the resolved UI gateway config. If no config is resolved, no
|
|
21
|
+
// model-backed run can start, so the endpoint returns an empty list.
|
|
22
|
+
export function handleModels(_ctx, deps) {
|
|
23
|
+
const configured = new Set(deps.config?.providers.map((provider) => provider.modelId) ?? []);
|
|
24
|
+
const models = listCapabilities().filter((model) => configured.has(model.id));
|
|
25
|
+
return { status: 200, body: { models } };
|
|
26
|
+
}
|
|
27
|
+
// Route 4 — launch-form metadata: the workflow descriptors plus the synthesized explain-plan and
|
|
28
|
+
// verify inputs (both are harness tasks with no workflow descriptor — verify is BFF-only and runs
|
|
29
|
+
// the deterministic verification orchestrator).
|
|
30
|
+
export function handleWorkflows() {
|
|
31
|
+
return {
|
|
32
|
+
status: 200,
|
|
33
|
+
body: {
|
|
34
|
+
descriptors: [UNIT_TEST_WORKFLOW_DESCRIPTOR, BUG_INVESTIGATION_WORKFLOW_DESCRIPTOR],
|
|
35
|
+
explainPlan: {
|
|
36
|
+
inputs: [
|
|
37
|
+
{
|
|
38
|
+
name: "filePath",
|
|
39
|
+
type: "string",
|
|
40
|
+
required: true,
|
|
41
|
+
description: "Path to the file to explain (read-only task).",
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
name: "question",
|
|
45
|
+
type: "string",
|
|
46
|
+
required: false,
|
|
47
|
+
description: "Optional focusing question for the explanation.",
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
defaultLimits: DEFAULT_LIMITS,
|
|
51
|
+
},
|
|
52
|
+
verify: {
|
|
53
|
+
inputs: [
|
|
54
|
+
{
|
|
55
|
+
name: "workspaceRoot",
|
|
56
|
+
type: "string",
|
|
57
|
+
required: true,
|
|
58
|
+
description: "Project root to verify.",
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
name: "targetFiles",
|
|
62
|
+
type: "string[]",
|
|
63
|
+
required: false,
|
|
64
|
+
description: "Optional file subset to target tests for.",
|
|
65
|
+
},
|
|
66
|
+
],
|
|
67
|
+
defaultLimits: DEFAULT_LIMITS,
|
|
68
|
+
},
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
function parsePositiveBudget(value) {
|
|
73
|
+
if (value === null) {
|
|
74
|
+
return undefined;
|
|
75
|
+
}
|
|
76
|
+
if (!/^[1-9][0-9]*$/u.test(value)) {
|
|
77
|
+
throw new Error("invalid budget");
|
|
78
|
+
}
|
|
79
|
+
const parsed = Number.parseInt(value, 10);
|
|
80
|
+
if (!Number.isSafeInteger(parsed)) {
|
|
81
|
+
throw new Error("invalid budget");
|
|
82
|
+
}
|
|
83
|
+
return parsed;
|
|
84
|
+
}
|
|
85
|
+
function workspaceErrorResult(error) {
|
|
86
|
+
const status = error.code === WORKSPACE_CODES.NOT_FOUND
|
|
87
|
+
? 404
|
|
88
|
+
: error.code === WORKSPACE_CODES.FILE_TOO_LARGE || error.code === WORKSPACE_CODES.READ_FAILED
|
|
89
|
+
? 422
|
|
90
|
+
: 400;
|
|
91
|
+
return { status, body: errorBody(error.code, workspaceErrorMessage(error.code)) };
|
|
92
|
+
}
|
|
93
|
+
const WORKSPACE_ERROR_MESSAGES = {
|
|
94
|
+
[WORKSPACE_CODES.PATH_ESCAPE]: "The workspace path is outside the registered project.",
|
|
95
|
+
[WORKSPACE_CODES.PATH_DENIED]: "The workspace path is denied by policy.",
|
|
96
|
+
[WORKSPACE_CODES.NOT_FOUND]: "The workspace could not be found.",
|
|
97
|
+
[WORKSPACE_CODES.FILE_TOO_LARGE]: "The workspace file is too large.",
|
|
98
|
+
[WORKSPACE_CODES.READ_FAILED]: "The workspace could not be read.",
|
|
99
|
+
};
|
|
100
|
+
function workspaceErrorMessage(code) {
|
|
101
|
+
return WORKSPACE_ERROR_MESSAGES[code];
|
|
102
|
+
}
|
|
103
|
+
function readWorkspaceRequest(q) {
|
|
104
|
+
let budget;
|
|
105
|
+
try {
|
|
106
|
+
budget = parsePositiveBudget(q.get("budget"));
|
|
107
|
+
}
|
|
108
|
+
catch {
|
|
109
|
+
return {
|
|
110
|
+
status: 400,
|
|
111
|
+
body: errorBody("BAD_REQUEST", "The budget query parameter must be a positive integer."),
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
const dir = q.get("dir");
|
|
115
|
+
if (dir === null) {
|
|
116
|
+
return {
|
|
117
|
+
status: 400,
|
|
118
|
+
body: errorBody("BAD_REQUEST", "The dir query parameter is required."),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
return { dir, task: q.get("task") ?? undefined, budget };
|
|
122
|
+
}
|
|
123
|
+
function workspaceNotRegisteredResult() {
|
|
124
|
+
return {
|
|
125
|
+
status: 403,
|
|
126
|
+
body: errorBody("WORKSPACE_NOT_REGISTERED", "The workspace directory is not a registered project."),
|
|
127
|
+
};
|
|
128
|
+
}
|
|
129
|
+
function resolveRegisteredWorkspace(rawDir, deps) {
|
|
130
|
+
let normalized;
|
|
131
|
+
try {
|
|
132
|
+
normalized = validateProjectPath(rawDir, { mustExist: false });
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
return {
|
|
136
|
+
status: 400,
|
|
137
|
+
body: errorBody("BAD_REQUEST", "The dir query parameter must be a valid local project path."),
|
|
138
|
+
};
|
|
139
|
+
}
|
|
140
|
+
const registered = deps.store.listProjects().some((project) => project.path === normalized);
|
|
141
|
+
if (!registered) {
|
|
142
|
+
return workspaceNotRegisteredResult();
|
|
143
|
+
}
|
|
144
|
+
return { normalized };
|
|
145
|
+
}
|
|
146
|
+
function workspaceSummaryResult(request, registeredRoot, deps) {
|
|
147
|
+
try {
|
|
148
|
+
const workspace = detectWorkspace(registeredRoot);
|
|
149
|
+
if (workspace.root !== registeredRoot) {
|
|
150
|
+
return workspaceNotRegisteredResult();
|
|
151
|
+
}
|
|
152
|
+
const { files, stats } = discoverWithStats(workspace, DEFAULT_CONTEXT_REQUEST.discovery);
|
|
153
|
+
const wantsContext = request.task !== undefined || request.budget !== undefined;
|
|
154
|
+
const pack = wantsContext
|
|
155
|
+
? buildContextPackFromFiles(workspace, {
|
|
156
|
+
...DEFAULT_CONTEXT_REQUEST,
|
|
157
|
+
task: request.task,
|
|
158
|
+
budgetBytes: request.budget ?? DEFAULT_CONTEXT_REQUEST.budgetBytes,
|
|
159
|
+
}, files)
|
|
160
|
+
: undefined;
|
|
161
|
+
const summary = buildWorkspaceSummary(workspace, pack, stats);
|
|
162
|
+
const body = deps.redactor({ summary });
|
|
163
|
+
return { status: 200, body };
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
if (error instanceof WorkspaceError) {
|
|
167
|
+
const result = workspaceErrorResult(error);
|
|
168
|
+
return { status: result.status, body: deps.redactor(result.body) };
|
|
169
|
+
}
|
|
170
|
+
throw error;
|
|
171
|
+
}
|
|
172
|
+
}
|
|
173
|
+
// Route 12 — workspace summary and optional context pack, built by the safe workspace layer.
|
|
174
|
+
export function handleWorkspace(ctx, deps) {
|
|
175
|
+
const request = readWorkspaceRequest(ctx.url.searchParams);
|
|
176
|
+
if ("status" in request) {
|
|
177
|
+
return request;
|
|
178
|
+
}
|
|
179
|
+
const registered = resolveRegisteredWorkspace(request.dir, deps);
|
|
180
|
+
if ("status" in registered) {
|
|
181
|
+
return registered;
|
|
182
|
+
}
|
|
183
|
+
return workspaceSummaryResult(request, registered.normalized, deps);
|
|
184
|
+
}
|
|
185
|
+
function readFilters(url) {
|
|
186
|
+
const q = url.searchParams;
|
|
187
|
+
return {
|
|
188
|
+
workspace: q.get("workspace") ?? undefined,
|
|
189
|
+
date: q.get("date") ?? undefined,
|
|
190
|
+
workflow: q.get("workflow") ?? undefined,
|
|
191
|
+
model: q.get("model") ?? undefined,
|
|
192
|
+
outcome: q.get("outcome") ?? undefined,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
// `EvidenceListEntry.startedAt` is epoch ms; the `date` filter matches the started-at calendar day
|
|
196
|
+
// (UTC `YYYY-MM-DD`). `workspace` is a substring match to support path-fragment filtering, while
|
|
197
|
+
// `model` is an exact model-id match.
|
|
198
|
+
function matchesOptionalFilter(value, filter) {
|
|
199
|
+
return filter === undefined || value === filter;
|
|
200
|
+
}
|
|
201
|
+
function matchesDateFilter(entry, date) {
|
|
202
|
+
return date === undefined || new Date(entry.startedAt).toISOString().slice(0, 10) === date;
|
|
203
|
+
}
|
|
204
|
+
function matchesWorkspaceFilter(entry, workspace) {
|
|
205
|
+
return workspace === undefined || entry.workspaceRoot?.includes(workspace) === true;
|
|
206
|
+
}
|
|
207
|
+
function matchesFilters(entry, filters) {
|
|
208
|
+
return (matchesOptionalFilter(entry.taskType, filters.workflow) &&
|
|
209
|
+
matchesOptionalFilter(entry.outcome, filters.outcome) &&
|
|
210
|
+
matchesDateFilter(entry, filters.date) &&
|
|
211
|
+
matchesOptionalFilter(entry.modelId, filters.model) &&
|
|
212
|
+
matchesWorkspaceFilter(entry, filters.workspace));
|
|
213
|
+
}
|
|
214
|
+
// Route 10 — evidence list header projection, filtered server-side.
|
|
215
|
+
export function handleEvidenceList(ctx, deps) {
|
|
216
|
+
const filters = readFilters(ctx.url);
|
|
217
|
+
const entries = listEvidence(deps.evidenceStore).filter((entry) => matchesFilters(entry, filters));
|
|
218
|
+
return { status: 200, body: { entries } };
|
|
219
|
+
}
|
|
220
|
+
// Route 11 — a single evidence manifest, served as-is (already redacted on disk). Invalid runId →
|
|
221
|
+
// 400; absent → 404; an EvidenceSchemaError → 422; an EvidenceReadError → 422 (safe, pre-redacted
|
|
222
|
+
// `.message`).
|
|
223
|
+
export function handleEvidenceDetail(ctx, deps) {
|
|
224
|
+
const runId = ctx.params.runId ?? "";
|
|
225
|
+
try {
|
|
226
|
+
assertValidRunId(runId);
|
|
227
|
+
}
|
|
228
|
+
catch {
|
|
229
|
+
return { status: 400, body: errorBody("BAD_REQUEST", "The run id is not valid.") };
|
|
230
|
+
}
|
|
231
|
+
try {
|
|
232
|
+
const manifest = loadEvidence(deps.evidenceStore, runId);
|
|
233
|
+
if (manifest === undefined) {
|
|
234
|
+
return { status: 404, body: errorBody("NOT_FOUND", "No evidence for that run id.") };
|
|
235
|
+
}
|
|
236
|
+
return { status: 200, body: { manifest } };
|
|
237
|
+
}
|
|
238
|
+
catch (error) {
|
|
239
|
+
if (error instanceof EvidenceSchemaError) {
|
|
240
|
+
return { status: 422, body: errorBody("EVIDENCE_SCHEMA", error.message) };
|
|
241
|
+
}
|
|
242
|
+
if (error instanceof EvidenceReadError) {
|
|
243
|
+
return { status: 422, body: errorBody("EVIDENCE_READ", error.message) };
|
|
244
|
+
}
|
|
245
|
+
throw error;
|
|
246
|
+
}
|
|
247
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { IncomingMessage, ServerResponse } from "node:http";
|
|
2
|
+
import type { UiHandlerDeps } from "./deps.js";
|
|
3
|
+
export interface ApiError {
|
|
4
|
+
readonly error: {
|
|
5
|
+
readonly code: string;
|
|
6
|
+
readonly message: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
export interface RouteResult {
|
|
10
|
+
readonly status: number;
|
|
11
|
+
readonly body: unknown;
|
|
12
|
+
}
|
|
13
|
+
export declare const STREAMING: unique symbol;
|
|
14
|
+
export type HandlerOutcome = RouteResult | typeof STREAMING;
|
|
15
|
+
export interface RouteContext {
|
|
16
|
+
readonly req: IncomingMessage;
|
|
17
|
+
readonly res: ServerResponse;
|
|
18
|
+
readonly params: Readonly<Record<string, string>>;
|
|
19
|
+
readonly url: URL;
|
|
20
|
+
}
|
|
21
|
+
export type RouteHandler = (ctx: RouteContext, deps: UiHandlerDeps) => HandlerOutcome | Promise<HandlerOutcome>;
|
|
22
|
+
export interface RouteDefinition {
|
|
23
|
+
readonly method: string;
|
|
24
|
+
readonly pattern: string;
|
|
25
|
+
readonly handler: RouteHandler;
|
|
26
|
+
}
|
|
27
|
+
export declare const API_ROUTES: readonly RouteDefinition[];
|
|
28
|
+
export interface RouteMatch {
|
|
29
|
+
readonly definition: RouteDefinition;
|
|
30
|
+
readonly params: Readonly<Record<string, string>>;
|
|
31
|
+
}
|
|
32
|
+
export declare function matchRoute(method: string, pathname: string): RouteMatch | "method-not-allowed" | undefined;
|
|
33
|
+
export declare function isApiPath(pathname: string): boolean;
|
|
34
|
+
export declare function errorBody(code: string, message: string): ApiError;
|
|
35
|
+
export declare function notFoundBody(): ApiError;
|
|
36
|
+
export declare function methodNotAllowedBody(): ApiError;
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
// BFF route dispatch (ADR-0011 D5). The route contract is wired here. The route TABLE
|
|
2
|
+
// (method + pattern) is static and dependency-free; each entry names a handler that receives the
|
|
3
|
+
// request context AND the per-server handler dependencies (resolved config, evidence store, run
|
|
4
|
+
// registry, redactor — see deps.ts). A handler returns a RouteResult (status + JSON body, which the
|
|
5
|
+
// server serializes) OR the STREAMING sentinel, meaning it has taken over the raw ServerResponse
|
|
6
|
+
// (the SSE events route). Non-2xx bodies use the redacted error envelope `{ error: { code, message } }`.
|
|
7
|
+
import { SDK_VERSION } from "../sdk/index.js";
|
|
8
|
+
import { handleConfig, handleModels, handleWorkflows, handleWorkspace, handleEvidenceList, handleEvidenceDetail, } from "./read-handlers.js";
|
|
9
|
+
import { handleCreateRun, handleCreateChatRun, handleRunEvents, handleCancelRun, handleGetRun, handleApplyRun, } from "./run-handlers.js";
|
|
10
|
+
import { handleListProjects, handleCreateProject, handleUpdateProject, handleDeleteProject, handleListChats, handleCreateChat, handleUpdateChat, handleDeleteChat, handleListMessages, handleCreateMessage, handleCreateRunSummaryPair, handleUpdateMessage, } from "./store-handlers.js";
|
|
11
|
+
import { handleCreateDesktopChat, handleSendDesktopChat } from "./chat-handlers.js";
|
|
12
|
+
import { handleCreateTerminalExecution, handleDeleteTerminalExecution, handleTerminalDirectories, handleTerminalEvents, handleTerminalPolicy, } from "./terminal-routes.js";
|
|
13
|
+
import { handleFilesDirectories, handleFilesPreview, handleFilesTree, } from "./files.js";
|
|
14
|
+
import { handleBrowserApplyScreenshot, handleBrowserContent, handleBrowserEvents, handleBrowserNavigate, handleBrowserScreenshot, handleBrowserStatus, handleCreateBrowserSession, handleDeleteBrowserSession, } from "./browser.js";
|
|
15
|
+
export const STREAMING = Symbol("streaming");
|
|
16
|
+
function health() {
|
|
17
|
+
return { status: 200, body: { status: "ok", version: SDK_VERSION } };
|
|
18
|
+
}
|
|
19
|
+
// The full route contract: the twelve original (ADR-0011 D5), the 10 additive UI-store
|
|
20
|
+
// routes (ADR-0013 D7), three Issue #66 run-summary routes, two desktop chat routes,
|
|
21
|
+
// desktop terminal JSON routes, and read-only Files widget routes. Terminal byte I/O
|
|
22
|
+
// uses a token-scoped WebSocket upgrade path.
|
|
23
|
+
export const API_ROUTES = [
|
|
24
|
+
{ method: "GET", pattern: "/api/health", handler: health },
|
|
25
|
+
{ method: "GET", pattern: "/api/config", handler: handleConfig },
|
|
26
|
+
{ method: "GET", pattern: "/api/models", handler: handleModels },
|
|
27
|
+
{ method: "GET", pattern: "/api/workflows", handler: handleWorkflows },
|
|
28
|
+
{ method: "POST", pattern: "/api/runs", handler: handleCreateRun },
|
|
29
|
+
{ method: "GET", pattern: "/api/runs/:runId/events", handler: handleRunEvents },
|
|
30
|
+
{ method: "POST", pattern: "/api/runs/:runId/cancel", handler: handleCancelRun },
|
|
31
|
+
{ method: "GET", pattern: "/api/runs/:runId", handler: handleGetRun },
|
|
32
|
+
{ method: "POST", pattern: "/api/runs/:runId/apply", handler: handleApplyRun },
|
|
33
|
+
{ method: "GET", pattern: "/api/evidence", handler: handleEvidenceList },
|
|
34
|
+
{ method: "GET", pattern: "/api/evidence/:runId", handler: handleEvidenceDetail },
|
|
35
|
+
{ method: "GET", pattern: "/api/workspace", handler: handleWorkspace },
|
|
36
|
+
// ADR-0013 D7 — UI-local persistence routes (additive).
|
|
37
|
+
{ method: "GET", pattern: "/api/projects", handler: handleListProjects },
|
|
38
|
+
{ method: "POST", pattern: "/api/projects", handler: handleCreateProject },
|
|
39
|
+
{ method: "PATCH", pattern: "/api/projects", handler: handleUpdateProject },
|
|
40
|
+
{ method: "DELETE", pattern: "/api/projects", handler: handleDeleteProject },
|
|
41
|
+
{ method: "GET", pattern: "/api/chats", handler: handleListChats },
|
|
42
|
+
{ method: "POST", pattern: "/api/chats", handler: handleCreateChat },
|
|
43
|
+
// Issue #66 — composer launch path: persist chat pair and start the run as one BFF operation.
|
|
44
|
+
{ method: "POST", pattern: "/api/chats/runs", handler: handleCreateChatRun },
|
|
45
|
+
{ method: "PATCH", pattern: "/api/chats", handler: handleUpdateChat },
|
|
46
|
+
{ method: "DELETE", pattern: "/api/chats", handler: handleDeleteChat },
|
|
47
|
+
{ method: "GET", pattern: "/api/chats/messages", handler: handleListMessages },
|
|
48
|
+
{ method: "POST", pattern: "/api/chats/messages", handler: handleCreateMessage },
|
|
49
|
+
// Issue #66 — atomic composer write: exactly one user message plus one run-summary system message.
|
|
50
|
+
{ method: "POST", pattern: "/api/chats/messages/run-summary-pair", handler: handleCreateRunSummaryPair },
|
|
51
|
+
// Issue #66 — PATCH a run-summary message (status/shortResult/taskType).
|
|
52
|
+
{ method: "PATCH", pattern: "/api/chats/messages", handler: handleUpdateMessage },
|
|
53
|
+
// Desktop canvas V1 — real chat against the configured gateway model without new agent scope.
|
|
54
|
+
{ method: "POST", pattern: "/api/desktop/chats", handler: handleCreateDesktopChat },
|
|
55
|
+
{ method: "POST", pattern: "/api/desktop/chat", handler: handleSendDesktopChat },
|
|
56
|
+
// ADR-0018 — bounded permitted-command execution. PTY routes (shells/sessions/WS upgrade) and
|
|
57
|
+
// the WebSocket upgrade handler in server.ts are removed; commands run via synchronous POST.
|
|
58
|
+
{ method: "GET", pattern: "/api/terminal/policy", handler: handleTerminalPolicy },
|
|
59
|
+
{ method: "GET", pattern: "/api/terminal/directories", handler: handleTerminalDirectories },
|
|
60
|
+
{ method: "POST", pattern: "/api/terminal/executions", handler: handleCreateTerminalExecution },
|
|
61
|
+
{ method: "DELETE", pattern: "/api/terminal/executions/:executionId", handler: handleDeleteTerminalExecution },
|
|
62
|
+
{ method: "GET", pattern: "/api/terminal/events", handler: handleTerminalEvents },
|
|
63
|
+
// Desktop files — read-only selected-root browser and preview control plane.
|
|
64
|
+
{ method: "GET", pattern: "/api/files/directories", handler: handleFilesDirectories },
|
|
65
|
+
{ method: "GET", pattern: "/api/files/tree", handler: handleFilesTree },
|
|
66
|
+
{ method: "GET", pattern: "/api/files/preview", handler: handleFilesPreview },
|
|
67
|
+
// ADR-0017 — browser tool (BYO Chrome over CDP).
|
|
68
|
+
{ method: "GET", pattern: "/api/browser/status", handler: handleBrowserStatus },
|
|
69
|
+
{ method: "POST", pattern: "/api/browser/sessions", handler: handleCreateBrowserSession },
|
|
70
|
+
{ method: "DELETE", pattern: "/api/browser/sessions/:sessionId", handler: handleDeleteBrowserSession },
|
|
71
|
+
{ method: "POST", pattern: "/api/browser/sessions/:sessionId/navigate", handler: handleBrowserNavigate },
|
|
72
|
+
{ method: "POST", pattern: "/api/browser/sessions/:sessionId/screenshot", handler: handleBrowserScreenshot },
|
|
73
|
+
{ method: "POST", pattern: "/api/browser/sessions/:sessionId/apply", handler: handleBrowserApplyScreenshot },
|
|
74
|
+
{ method: "POST", pattern: "/api/browser/sessions/:sessionId/content", handler: handleBrowserContent },
|
|
75
|
+
{ method: "GET", pattern: "/api/browser/sessions/:sessionId/events", handler: handleBrowserEvents },
|
|
76
|
+
];
|
|
77
|
+
// Matches a concrete path against a route pattern, capturing `:name` params. Returns the captured
|
|
78
|
+
// params, or undefined when the segment counts differ or a literal segment mismatches.
|
|
79
|
+
function matchPattern(pattern, pathname) {
|
|
80
|
+
const patternParts = pattern.split("/");
|
|
81
|
+
const pathParts = pathname.split("/");
|
|
82
|
+
if (patternParts.length !== pathParts.length) {
|
|
83
|
+
return undefined;
|
|
84
|
+
}
|
|
85
|
+
const params = {};
|
|
86
|
+
for (let i = 0; i < patternParts.length; i++) {
|
|
87
|
+
const p = patternParts[i] ?? "";
|
|
88
|
+
const actual = pathParts[i] ?? "";
|
|
89
|
+
if (p.startsWith(":")) {
|
|
90
|
+
if (actual.length === 0) {
|
|
91
|
+
return undefined;
|
|
92
|
+
}
|
|
93
|
+
params[p.slice(1)] = actual;
|
|
94
|
+
}
|
|
95
|
+
else if (p !== actual) {
|
|
96
|
+
return undefined;
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return params;
|
|
100
|
+
}
|
|
101
|
+
// Resolves a method+path to a route. Returns `{ definition, params }` on a full match, the string
|
|
102
|
+
// `"method-not-allowed"` when the path matches a route of a different method, or undefined when no
|
|
103
|
+
// route path matches at all.
|
|
104
|
+
export function matchRoute(method, pathname) {
|
|
105
|
+
let pathMatchedOtherMethod = false;
|
|
106
|
+
for (const definition of API_ROUTES) {
|
|
107
|
+
const params = matchPattern(definition.pattern, pathname);
|
|
108
|
+
if (params === undefined) {
|
|
109
|
+
continue;
|
|
110
|
+
}
|
|
111
|
+
if (definition.method === method) {
|
|
112
|
+
return { definition, params };
|
|
113
|
+
}
|
|
114
|
+
pathMatchedOtherMethod = true;
|
|
115
|
+
}
|
|
116
|
+
return pathMatchedOtherMethod ? "method-not-allowed" : undefined;
|
|
117
|
+
}
|
|
118
|
+
export function isApiPath(pathname) {
|
|
119
|
+
return pathname === "/api" || pathname.startsWith("/api/");
|
|
120
|
+
}
|
|
121
|
+
export function errorBody(code, message) {
|
|
122
|
+
return { error: { code, message } };
|
|
123
|
+
}
|
|
124
|
+
export function notFoundBody() {
|
|
125
|
+
return errorBody("NOT_FOUND", "The requested resource was not found.");
|
|
126
|
+
}
|
|
127
|
+
export function methodNotAllowedBody() {
|
|
128
|
+
return errorBody("METHOD_NOT_ALLOWED", "The HTTP method is not allowed for this resource.");
|
|
129
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { ModelPort } from "../harness/index.js";
|
|
2
|
+
import type { RunRequest } from "./run-request.js";
|
|
3
|
+
import type { AppliableSnapshot, RunRegistry } from "./runs.js";
|
|
4
|
+
import { type EvidencePersistContext } from "./evidence.js";
|
|
5
|
+
export interface StartRunResult {
|
|
6
|
+
readonly runId: string;
|
|
7
|
+
readonly fingerprint: string;
|
|
8
|
+
}
|
|
9
|
+
export interface StartRunOptions {
|
|
10
|
+
readonly runId?: string;
|
|
11
|
+
}
|
|
12
|
+
interface EngineContext {
|
|
13
|
+
readonly request: RunRequest;
|
|
14
|
+
readonly model: ModelPort;
|
|
15
|
+
readonly registry: RunRegistry;
|
|
16
|
+
readonly evidence?: EvidencePersistContext | undefined;
|
|
17
|
+
}
|
|
18
|
+
export declare function startRun(ctx: EngineContext, redactReport: (value: unknown) => unknown, options?: StartRunOptions): StartRunResult;
|
|
19
|
+
export declare function applyRun(snapshot: AppliableSnapshot, model: ModelPort, modelId: string, redactReport: (value: unknown) => unknown): Promise<unknown>;
|
|
20
|
+
export type { EngineContext };
|