@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,219 @@
|
|
|
1
|
+
// ADR-0018 D8 — five /api/terminal/* BFF route handlers. CSRF is enforced by the server's
|
|
2
|
+
// state-changing-request gate (POST/DELETE flow through it); GET routes are read-only and exempt.
|
|
3
|
+
// SSE framing mirrors /api/browser/*/events.
|
|
4
|
+
import { TerminalToolError } from "./terminal-errors.js";
|
|
5
|
+
import { buildTerminalPolicySummary, listDirectories, } from "./terminal.js";
|
|
6
|
+
import { SSE_HEADERS, readyMessage } from "./sse.js";
|
|
7
|
+
import { errorBody, STREAMING, } from "./routes.js";
|
|
8
|
+
const MAX_TERMINAL_BODY_BYTES = 64_000;
|
|
9
|
+
class BodyTooLargeError extends Error {
|
|
10
|
+
constructor() {
|
|
11
|
+
super("terminal request body too large");
|
|
12
|
+
this.name = "BodyTooLargeError";
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function noTerminalDeps() {
|
|
16
|
+
return {
|
|
17
|
+
status: 503,
|
|
18
|
+
body: errorBody("TERMINAL_UNAVAILABLE", "Terminal tool is not configured for this BFF."),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
function requireTerminal(deps) {
|
|
22
|
+
return deps.terminal ?? noTerminalDeps();
|
|
23
|
+
}
|
|
24
|
+
function isRouteResult(value) {
|
|
25
|
+
return typeof value.status === "number";
|
|
26
|
+
}
|
|
27
|
+
function toRouteResult(error) {
|
|
28
|
+
return { status: error.status, body: errorBody(error.code, error.message) };
|
|
29
|
+
}
|
|
30
|
+
function readBody(req) {
|
|
31
|
+
return new Promise((resolve, reject) => {
|
|
32
|
+
const chunks = [];
|
|
33
|
+
let total = 0;
|
|
34
|
+
let capped = false;
|
|
35
|
+
req.on("data", (chunk) => {
|
|
36
|
+
total += chunk.length;
|
|
37
|
+
if (total > MAX_TERMINAL_BODY_BYTES) {
|
|
38
|
+
if (!capped) {
|
|
39
|
+
capped = true;
|
|
40
|
+
chunks.length = 0;
|
|
41
|
+
reject(new BodyTooLargeError());
|
|
42
|
+
req.resume();
|
|
43
|
+
}
|
|
44
|
+
return;
|
|
45
|
+
}
|
|
46
|
+
chunks.push(chunk);
|
|
47
|
+
});
|
|
48
|
+
req.on("end", () => {
|
|
49
|
+
if (!capped)
|
|
50
|
+
resolve(Buffer.concat(chunks).toString("utf8"));
|
|
51
|
+
});
|
|
52
|
+
req.on("error", reject);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
async function readJsonObject(req) {
|
|
56
|
+
const raw = await readBody(req);
|
|
57
|
+
if (raw.length === 0)
|
|
58
|
+
return {};
|
|
59
|
+
let parsed;
|
|
60
|
+
try {
|
|
61
|
+
parsed = JSON.parse(raw);
|
|
62
|
+
}
|
|
63
|
+
catch {
|
|
64
|
+
throw new TerminalToolError("BAD_REQUEST", "Request body is not valid JSON.");
|
|
65
|
+
}
|
|
66
|
+
if (typeof parsed !== "object" || parsed === null || Array.isArray(parsed)) {
|
|
67
|
+
throw new TerminalToolError("BAD_REQUEST", "Request body must be a JSON object.");
|
|
68
|
+
}
|
|
69
|
+
return parsed;
|
|
70
|
+
}
|
|
71
|
+
function requireString(body, key) {
|
|
72
|
+
const value = body[key];
|
|
73
|
+
if (typeof value !== "string" || value.length === 0) {
|
|
74
|
+
throw new TerminalToolError("BAD_REQUEST", `Field "${key}" must be a non-empty string.`);
|
|
75
|
+
}
|
|
76
|
+
return value;
|
|
77
|
+
}
|
|
78
|
+
function optionalString(body, key) {
|
|
79
|
+
const value = body[key];
|
|
80
|
+
if (value === undefined)
|
|
81
|
+
return undefined;
|
|
82
|
+
if (typeof value !== "string") {
|
|
83
|
+
throw new TerminalToolError("BAD_REQUEST", `Field "${key}" must be a string.`);
|
|
84
|
+
}
|
|
85
|
+
return value;
|
|
86
|
+
}
|
|
87
|
+
function optionalNumber(body, key) {
|
|
88
|
+
const value = body[key];
|
|
89
|
+
if (value === undefined)
|
|
90
|
+
return undefined;
|
|
91
|
+
if (typeof value !== "number" || !Number.isFinite(value)) {
|
|
92
|
+
throw new TerminalToolError("BAD_REQUEST", `Field "${key}" must be a finite number.`);
|
|
93
|
+
}
|
|
94
|
+
return value;
|
|
95
|
+
}
|
|
96
|
+
function requireStringArray(body, key) {
|
|
97
|
+
const value = body[key];
|
|
98
|
+
if (value === undefined)
|
|
99
|
+
return [];
|
|
100
|
+
if (!Array.isArray(value)) {
|
|
101
|
+
throw new TerminalToolError("BAD_REQUEST", `Field "${key}" must be an array of strings.`);
|
|
102
|
+
}
|
|
103
|
+
for (const item of value) {
|
|
104
|
+
if (typeof item !== "string") {
|
|
105
|
+
throw new TerminalToolError("BAD_REQUEST", `Field "${key}" must be an array of strings.`);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
return value;
|
|
109
|
+
}
|
|
110
|
+
async function runHandler(work) {
|
|
111
|
+
try {
|
|
112
|
+
return await work();
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
if (error instanceof BodyTooLargeError) {
|
|
116
|
+
return {
|
|
117
|
+
status: 413,
|
|
118
|
+
body: errorBody("PAYLOAD_TOO_LARGE", "Request body exceeds the size limit."),
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
if (error instanceof TerminalToolError)
|
|
122
|
+
return toRouteResult(error);
|
|
123
|
+
throw error;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
// GET /api/terminal/policy — static allowlist + limits. No deps required; safe even if the
|
|
127
|
+
// execution manager has not been wired (a deployment-misconfiguration case).
|
|
128
|
+
export function handleTerminalPolicy(_ctx, _deps) {
|
|
129
|
+
return { status: 200, body: buildTerminalPolicySummary() };
|
|
130
|
+
}
|
|
131
|
+
export async function handleTerminalDirectories(ctx, deps) {
|
|
132
|
+
return runHandler(async () => {
|
|
133
|
+
const projectId = ctx.url.searchParams.get("projectId");
|
|
134
|
+
if (projectId === null || projectId.length === 0) {
|
|
135
|
+
throw new TerminalToolError("BAD_REQUEST", "Query parameter 'projectId' is required.");
|
|
136
|
+
}
|
|
137
|
+
const requestedPath = ctx.url.searchParams.get("path") ?? undefined;
|
|
138
|
+
const listing = await listDirectories(deps.store, projectId, requestedPath);
|
|
139
|
+
return { status: 200, body: listing };
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
export async function handleCreateTerminalExecution(ctx, deps) {
|
|
143
|
+
const guard = requireTerminal(deps);
|
|
144
|
+
if (isRouteResult(guard))
|
|
145
|
+
return guard;
|
|
146
|
+
return runHandler(async () => {
|
|
147
|
+
const body = await readJsonObject(ctx.req);
|
|
148
|
+
const projectId = requireString(body, "projectId");
|
|
149
|
+
const command = requireString(body, "command");
|
|
150
|
+
const args = requireStringArray(body, "args");
|
|
151
|
+
const cwd = optionalString(body, "cwd");
|
|
152
|
+
const timeoutMs = optionalNumber(body, "timeoutMs");
|
|
153
|
+
const requestId = optionalString(body, "requestId");
|
|
154
|
+
const input = {
|
|
155
|
+
projectId,
|
|
156
|
+
command,
|
|
157
|
+
args,
|
|
158
|
+
...(cwd === undefined ? {} : { cwd }),
|
|
159
|
+
...(timeoutMs === undefined ? {} : { timeoutMs }),
|
|
160
|
+
...(requestId === undefined ? {} : { requestId }),
|
|
161
|
+
};
|
|
162
|
+
const raw = await guard.execute(input);
|
|
163
|
+
// A4 (M3) — Layer-2 redaction on the synchronous POST response body. runCommand already
|
|
164
|
+
// applied Layer-1 env-value redaction; this pass catches structural patterns (Bearer tokens,
|
|
165
|
+
// sk-* keys, PEM markers) via the audit redactor before the output reaches the browser.
|
|
166
|
+
const redactStr = (s) => {
|
|
167
|
+
const v = deps.redactor(s);
|
|
168
|
+
return typeof v === "string" ? v : s;
|
|
169
|
+
};
|
|
170
|
+
const result = { ...raw, stdout: redactStr(raw.stdout), stderr: redactStr(raw.stderr) };
|
|
171
|
+
return { status: 200, body: result };
|
|
172
|
+
});
|
|
173
|
+
}
|
|
174
|
+
export function handleDeleteTerminalExecution(ctx, deps) {
|
|
175
|
+
const guard = requireTerminal(deps);
|
|
176
|
+
if (isRouteResult(guard))
|
|
177
|
+
return guard;
|
|
178
|
+
const executionId = ctx.params.executionId ?? "";
|
|
179
|
+
const cancelled = guard.abort(executionId);
|
|
180
|
+
if (!cancelled) {
|
|
181
|
+
return {
|
|
182
|
+
status: 404,
|
|
183
|
+
body: errorBody("EXECUTION_NOT_FOUND", "Terminal execution not found."),
|
|
184
|
+
};
|
|
185
|
+
}
|
|
186
|
+
return { status: 200, body: { ok: true } };
|
|
187
|
+
}
|
|
188
|
+
// SSE — one terminal event becomes one message with `event: terminal:<kind>` and a JSON payload.
|
|
189
|
+
// A synthetic `ready` is emitted first so the client can transition from connecting to live.
|
|
190
|
+
export function handleTerminalEvents(ctx, deps) {
|
|
191
|
+
const guard = requireTerminal(deps);
|
|
192
|
+
if (isRouteResult(guard))
|
|
193
|
+
return guard;
|
|
194
|
+
openTerminalSseStream(ctx.res, guard, deps.redactor);
|
|
195
|
+
ctx.req.on("close", () => {
|
|
196
|
+
ctx.res.end();
|
|
197
|
+
});
|
|
198
|
+
return STREAMING;
|
|
199
|
+
}
|
|
200
|
+
function openTerminalSseStream(res, manager, redactor) {
|
|
201
|
+
res.writeHead(200, SSE_HEADERS);
|
|
202
|
+
let seq = 0;
|
|
203
|
+
const unsubscribe = manager.subscribe((event) => {
|
|
204
|
+
seq += 1;
|
|
205
|
+
writeTerminalEvent(res, event, seq, redactor);
|
|
206
|
+
});
|
|
207
|
+
res.write(readyMessage());
|
|
208
|
+
res.on("close", () => {
|
|
209
|
+
unsubscribe();
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
function writeTerminalEvent(res, event, seq, redactor) {
|
|
213
|
+
const redacted = redactor(event);
|
|
214
|
+
const data = JSON.stringify(redacted);
|
|
215
|
+
const frame = `id: ${String(seq)}\nevent: terminal:${event.kind}\ndata: ${data}\n\n`;
|
|
216
|
+
if (!res.write(frame)) {
|
|
217
|
+
res.destroy();
|
|
218
|
+
}
|
|
219
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { type RunCommandDeps } from "../tools/exec.js";
|
|
2
|
+
import { type SandboxPolicy } from "../tools/types.js";
|
|
3
|
+
import type { EvidenceStore } from "../audit/store.js";
|
|
4
|
+
import type { UiStore } from "./store/index.js";
|
|
5
|
+
export interface TerminalExecutionInput {
|
|
6
|
+
readonly projectId: string;
|
|
7
|
+
readonly command: string;
|
|
8
|
+
readonly args: readonly string[];
|
|
9
|
+
readonly cwd?: string | undefined;
|
|
10
|
+
readonly timeoutMs?: number | undefined;
|
|
11
|
+
readonly requestId?: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
export interface TerminalExecutionResult {
|
|
14
|
+
readonly executionId: string;
|
|
15
|
+
readonly exitCode: number | null;
|
|
16
|
+
readonly stdout: string;
|
|
17
|
+
readonly stderr: string;
|
|
18
|
+
readonly durationMs: number;
|
|
19
|
+
readonly truncated: boolean;
|
|
20
|
+
readonly timedOut: boolean;
|
|
21
|
+
}
|
|
22
|
+
export type TerminalEventKind = "execution-started" | "execution-completed" | "execution-failed" | "execution-cancelled";
|
|
23
|
+
export interface TerminalEventEnvelope {
|
|
24
|
+
readonly kind: TerminalEventKind;
|
|
25
|
+
readonly executionId: string;
|
|
26
|
+
readonly payload: Readonly<Record<string, unknown>>;
|
|
27
|
+
}
|
|
28
|
+
export type TerminalEventEmitter = (event: TerminalEventEnvelope) => void;
|
|
29
|
+
export interface TerminalExecutionManager {
|
|
30
|
+
readonly execute: (input: TerminalExecutionInput) => Promise<TerminalExecutionResult>;
|
|
31
|
+
readonly abort: (executionId: string) => boolean;
|
|
32
|
+
readonly subscribe: (listener: TerminalEventEmitter) => () => void;
|
|
33
|
+
readonly inFlightCount: () => number;
|
|
34
|
+
}
|
|
35
|
+
export interface TerminalDirectoryEntry {
|
|
36
|
+
readonly name: string;
|
|
37
|
+
readonly path: string;
|
|
38
|
+
}
|
|
39
|
+
export interface TerminalDirectoryRoot {
|
|
40
|
+
readonly label: string;
|
|
41
|
+
readonly path: string;
|
|
42
|
+
}
|
|
43
|
+
export interface TerminalDirectoryListing {
|
|
44
|
+
readonly path: string;
|
|
45
|
+
readonly parent: string | null;
|
|
46
|
+
readonly entries: readonly TerminalDirectoryEntry[];
|
|
47
|
+
readonly roots: readonly TerminalDirectoryRoot[];
|
|
48
|
+
}
|
|
49
|
+
export interface TerminalPolicySummary {
|
|
50
|
+
readonly commands: readonly string[];
|
|
51
|
+
readonly limits: {
|
|
52
|
+
readonly maxOutputBytes: number;
|
|
53
|
+
readonly defaultTimeoutMs: number;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export interface TerminalExecutionManagerOptions {
|
|
57
|
+
readonly store: UiStore;
|
|
58
|
+
readonly evidenceStore?: EvidenceStore | undefined;
|
|
59
|
+
readonly policy?: SandboxPolicy | undefined;
|
|
60
|
+
readonly processEnv?: NodeJS.ProcessEnv | undefined;
|
|
61
|
+
readonly redactor?: ((input: string) => string) | undefined;
|
|
62
|
+
readonly runDeps?: Partial<RunCommandDeps> | undefined;
|
|
63
|
+
readonly now?: (() => number) | undefined;
|
|
64
|
+
}
|
|
65
|
+
export declare function createTerminalExecutionManager(opts: TerminalExecutionManagerOptions): TerminalExecutionManager;
|
|
66
|
+
export declare function buildTerminalPolicySummary(policy?: SandboxPolicy): TerminalPolicySummary;
|
|
67
|
+
export declare function listDirectories(store: UiStore, projectId: string, pathInput: string | undefined): Promise<TerminalDirectoryListing>;
|