@gpustack/loopwright 0.0.0-stage → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +191 -0
- package/README.md +356 -2
- package/bin/loopwright.js +3 -0
- package/node_modules/@loopwright/agent-pi/dist/adapter-v2.d.ts +9 -0
- package/node_modules/@loopwright/agent-pi/dist/adapter-v2.js +122 -0
- package/node_modules/@loopwright/agent-pi/dist/adapter.d.ts +30 -0
- package/node_modules/@loopwright/agent-pi/dist/adapter.js +340 -0
- package/node_modules/@loopwright/agent-pi/dist/admission.d.ts +25 -0
- package/node_modules/@loopwright/agent-pi/dist/admission.js +65 -0
- package/node_modules/@loopwright/agent-pi/dist/artifacts.d.ts +15 -0
- package/node_modules/@loopwright/agent-pi/dist/artifacts.js +76 -0
- package/node_modules/@loopwright/agent-pi/dist/boundary.d.ts +18 -0
- package/node_modules/@loopwright/agent-pi/dist/boundary.js +113 -0
- package/node_modules/@loopwright/agent-pi/dist/broker-channel.d.ts +4 -0
- package/node_modules/@loopwright/agent-pi/dist/broker-channel.js +121 -0
- package/node_modules/@loopwright/agent-pi/dist/candidate.d.ts +96 -0
- package/node_modules/@loopwright/agent-pi/dist/candidate.js +1712 -0
- package/node_modules/@loopwright/agent-pi/dist/capture.d.ts +39 -0
- package/node_modules/@loopwright/agent-pi/dist/capture.js +146 -0
- package/node_modules/@loopwright/agent-pi/dist/cas.d.ts +51 -0
- package/node_modules/@loopwright/agent-pi/dist/cas.js +836 -0
- package/node_modules/@loopwright/agent-pi/dist/catalog-api.d.ts +3 -0
- package/node_modules/@loopwright/agent-pi/dist/catalog-api.js +2 -0
- package/node_modules/@loopwright/agent-pi/dist/catalog.d.ts +39 -0
- package/node_modules/@loopwright/agent-pi/dist/catalog.js +280 -0
- package/node_modules/@loopwright/agent-pi/dist/circuit-breaker-limits.d.ts +9 -0
- package/node_modules/@loopwright/agent-pi/dist/circuit-breaker-limits.js +12 -0
- package/node_modules/@loopwright/agent-pi/dist/containers.d.ts +29 -0
- package/node_modules/@loopwright/agent-pi/dist/containers.js +160 -0
- package/node_modules/@loopwright/agent-pi/dist/context.d.ts +56 -0
- package/node_modules/@loopwright/agent-pi/dist/context.js +351 -0
- package/node_modules/@loopwright/agent-pi/dist/daemon.d.ts +8 -0
- package/node_modules/@loopwright/agent-pi/dist/daemon.js +52 -0
- package/node_modules/@loopwright/agent-pi/dist/deadline.d.ts +6 -0
- package/node_modules/@loopwright/agent-pi/dist/deadline.js +18 -0
- package/node_modules/@loopwright/agent-pi/dist/decode-capture.d.ts +39 -0
- package/node_modules/@loopwright/agent-pi/dist/decode-capture.js +287 -0
- package/node_modules/@loopwright/agent-pi/dist/descriptor.d.ts +12 -0
- package/node_modules/@loopwright/agent-pi/dist/descriptor.js +17 -0
- package/node_modules/@loopwright/agent-pi/dist/docker-absence.d.ts +2 -0
- package/node_modules/@loopwright/agent-pi/dist/docker-absence.js +9 -0
- package/node_modules/@loopwright/agent-pi/dist/errors.d.ts +7 -0
- package/node_modules/@loopwright/agent-pi/dist/errors.js +19 -0
- package/node_modules/@loopwright/agent-pi/dist/event-sequence.d.ts +6 -0
- package/node_modules/@loopwright/agent-pi/dist/event-sequence.js +64 -0
- package/node_modules/@loopwright/agent-pi/dist/events.d.ts +19 -0
- package/node_modules/@loopwright/agent-pi/dist/events.js +132 -0
- package/node_modules/@loopwright/agent-pi/dist/execution-guard.d.ts +9 -0
- package/node_modules/@loopwright/agent-pi/dist/execution-guard.js +25 -0
- package/node_modules/@loopwright/agent-pi/dist/execution-lease.d.ts +24 -0
- package/node_modules/@loopwright/agent-pi/dist/execution-lease.js +316 -0
- package/node_modules/@loopwright/agent-pi/dist/execution.d.ts +32 -0
- package/node_modules/@loopwright/agent-pi/dist/execution.js +476 -0
- package/node_modules/@loopwright/agent-pi/dist/external-mcp.d.ts +87 -0
- package/node_modules/@loopwright/agent-pi/dist/external-mcp.js +526 -0
- package/node_modules/@loopwright/agent-pi/dist/factory-bootstrap.d.ts +15 -0
- package/node_modules/@loopwright/agent-pi/dist/factory-bootstrap.js +74 -0
- package/node_modules/@loopwright/agent-pi/dist/host-session.d.ts +51 -0
- package/node_modules/@loopwright/agent-pi/dist/host-session.js +2083 -0
- package/node_modules/@loopwright/agent-pi/dist/http-mcp.d.ts +32 -0
- package/node_modules/@loopwright/agent-pi/dist/http-mcp.js +353 -0
- package/node_modules/@loopwright/agent-pi/dist/index.d.ts +7 -0
- package/node_modules/@loopwright/agent-pi/dist/index.js +4 -0
- package/node_modules/@loopwright/agent-pi/dist/lifecycle.d.ts +13 -0
- package/node_modules/@loopwright/agent-pi/dist/lifecycle.js +11 -0
- package/node_modules/@loopwright/agent-pi/dist/mcp-process.d.ts +35 -0
- package/node_modules/@loopwright/agent-pi/dist/mcp-process.js +92 -0
- package/node_modules/@loopwright/agent-pi/dist/mcp-transport.d.ts +25 -0
- package/node_modules/@loopwright/agent-pi/dist/mcp-transport.js +63 -0
- package/node_modules/@loopwright/agent-pi/dist/mcp.d.ts +23 -0
- package/node_modules/@loopwright/agent-pi/dist/mcp.js +212 -0
- package/node_modules/@loopwright/agent-pi/dist/operation.d.ts +5 -0
- package/node_modules/@loopwright/agent-pi/dist/operation.js +28 -0
- package/node_modules/@loopwright/agent-pi/dist/policy-v2.d.ts +10 -0
- package/node_modules/@loopwright/agent-pi/dist/policy-v2.js +64 -0
- package/node_modules/@loopwright/agent-pi/dist/policy.d.ts +13 -0
- package/node_modules/@loopwright/agent-pi/dist/policy.js +260 -0
- package/node_modules/@loopwright/agent-pi/dist/preflight.d.ts +60 -0
- package/node_modules/@loopwright/agent-pi/dist/preflight.js +700 -0
- package/node_modules/@loopwright/agent-pi/dist/progress-summary.d.ts +1 -0
- package/node_modules/@loopwright/agent-pi/dist/progress-summary.js +119 -0
- package/node_modules/@loopwright/agent-pi/dist/protocol.d.ts +17 -0
- package/node_modules/@loopwright/agent-pi/dist/protocol.js +131 -0
- package/node_modules/@loopwright/agent-pi/dist/provider.d.ts +62 -0
- package/node_modules/@loopwright/agent-pi/dist/provider.js +217 -0
- package/node_modules/@loopwright/agent-pi/dist/receipt.d.ts +3 -0
- package/node_modules/@loopwright/agent-pi/dist/receipt.js +64 -0
- package/node_modules/@loopwright/agent-pi/dist/recovery.d.ts +6 -0
- package/node_modules/@loopwright/agent-pi/dist/recovery.js +188 -0
- package/node_modules/@loopwright/agent-pi/dist/resources.d.ts +13 -0
- package/node_modules/@loopwright/agent-pi/dist/resources.js +81 -0
- package/node_modules/@loopwright/agent-pi/dist/response.d.ts +20 -0
- package/node_modules/@loopwright/agent-pi/dist/response.js +259 -0
- package/node_modules/@loopwright/agent-pi/dist/runtime-profile.d.ts +6 -0
- package/node_modules/@loopwright/agent-pi/dist/runtime-profile.js +37 -0
- package/node_modules/@loopwright/agent-pi/dist/sdk-worker.d.ts +14 -0
- package/node_modules/@loopwright/agent-pi/dist/sdk-worker.js +633 -0
- package/node_modules/@loopwright/agent-pi/dist/sender.d.ts +46 -0
- package/node_modules/@loopwright/agent-pi/dist/sender.js +553 -0
- package/node_modules/@loopwright/agent-pi/dist/session-host.d.ts +21 -0
- package/node_modules/@loopwright/agent-pi/dist/session-host.js +315 -0
- package/node_modules/@loopwright/agent-pi/dist/snapshot-transfer.d.ts +14 -0
- package/node_modules/@loopwright/agent-pi/dist/snapshot-transfer.js +102 -0
- package/node_modules/@loopwright/agent-pi/dist/snapshot.d.ts +19 -0
- package/node_modules/@loopwright/agent-pi/dist/snapshot.js +121 -0
- package/node_modules/@loopwright/agent-pi/dist/tool-process.d.ts +32 -0
- package/node_modules/@loopwright/agent-pi/dist/tool-process.js +85 -0
- package/node_modules/@loopwright/agent-pi/dist/tool-worker.d.ts +2 -0
- package/node_modules/@loopwright/agent-pi/dist/tool-worker.js +105 -0
- package/node_modules/@loopwright/agent-pi/dist/tools.d.ts +36 -0
- package/node_modules/@loopwright/agent-pi/dist/tools.js +128 -0
- package/node_modules/@loopwright/agent-pi/dist/types-v2.d.ts +71 -0
- package/node_modules/@loopwright/agent-pi/dist/types-v2.js +1 -0
- package/node_modules/@loopwright/agent-pi/dist/types.d.ts +314 -0
- package/node_modules/@loopwright/agent-pi/dist/types.js +1 -0
- package/node_modules/@loopwright/agent-pi/dist/usage.d.ts +18 -0
- package/node_modules/@loopwright/agent-pi/dist/usage.js +314 -0
- package/node_modules/@loopwright/agent-pi/dist/workspace-mcp.d.ts +27 -0
- package/node_modules/@loopwright/agent-pi/dist/workspace-mcp.js +142 -0
- package/node_modules/@loopwright/agent-pi/package.json +24 -0
- package/node_modules/@loopwright/agent-pi/runtime/Dockerfile +8 -0
- package/node_modules/@loopwright/agent-pi/runtime/seccomp.json +1 -0
- package/node_modules/@loopwright/cli/dist/arguments.d.ts +19 -0
- package/node_modules/@loopwright/cli/dist/arguments.js +358 -0
- package/node_modules/@loopwright/cli/dist/closure.d.ts +93 -0
- package/node_modules/@loopwright/cli/dist/closure.js +230 -0
- package/node_modules/@loopwright/cli/dist/draft.d.ts +9 -0
- package/node_modules/@loopwright/cli/dist/draft.js +106 -0
- package/node_modules/@loopwright/cli/dist/failure-matrix.d.ts +9 -0
- package/node_modules/@loopwright/cli/dist/failure-matrix.js +701 -0
- package/node_modules/@loopwright/cli/dist/index.d.ts +6 -0
- package/node_modules/@loopwright/cli/dist/index.js +5 -0
- package/node_modules/@loopwright/cli/dist/main.d.ts +22 -0
- package/node_modules/@loopwright/cli/dist/main.js +1855 -0
- package/node_modules/@loopwright/cli/package.json +16 -0
- package/node_modules/@loopwright/controller/dist/acceptance.d.ts +43 -0
- package/node_modules/@loopwright/controller/dist/acceptance.js +446 -0
- package/node_modules/@loopwright/controller/dist/benchmark-gate.d.ts +273 -0
- package/node_modules/@loopwright/controller/dist/benchmark-gate.js +3147 -0
- package/node_modules/@loopwright/controller/dist/budget-observations.d.ts +25 -0
- package/node_modules/@loopwright/controller/dist/budget-observations.js +139 -0
- package/node_modules/@loopwright/controller/dist/bundle.d.ts +26 -0
- package/node_modules/@loopwright/controller/dist/bundle.js +64 -0
- package/node_modules/@loopwright/controller/dist/capture.d.ts +89 -0
- package/node_modules/@loopwright/controller/dist/capture.js +587 -0
- package/node_modules/@loopwright/controller/dist/compile.d.ts +3 -0
- package/node_modules/@loopwright/controller/dist/compile.js +402 -0
- package/node_modules/@loopwright/controller/dist/config.d.ts +22 -0
- package/node_modules/@loopwright/controller/dist/config.js +255 -0
- package/node_modules/@loopwright/controller/dist/controller.d.ts +177 -0
- package/node_modules/@loopwright/controller/dist/controller.js +2135 -0
- package/node_modules/@loopwright/controller/dist/credentials.d.ts +29 -0
- package/node_modules/@loopwright/controller/dist/credentials.js +189 -0
- package/node_modules/@loopwright/controller/dist/deadlines.d.ts +18 -0
- package/node_modules/@loopwright/controller/dist/deadlines.js +71 -0
- package/node_modules/@loopwright/controller/dist/errors.d.ts +27 -0
- package/node_modules/@loopwright/controller/dist/errors.js +41 -0
- package/node_modules/@loopwright/controller/dist/events.d.ts +52 -0
- package/node_modules/@loopwright/controller/dist/events.js +228 -0
- package/node_modules/@loopwright/controller/dist/files.d.ts +51 -0
- package/node_modules/@loopwright/controller/dist/files.js +386 -0
- package/node_modules/@loopwright/controller/dist/finalize.d.ts +25 -0
- package/node_modules/@loopwright/controller/dist/finalize.js +32 -0
- package/node_modules/@loopwright/controller/dist/gate.d.ts +84 -0
- package/node_modules/@loopwright/controller/dist/gate.js +640 -0
- package/node_modules/@loopwright/controller/dist/git-objects.d.ts +11 -0
- package/node_modules/@loopwright/controller/dist/git-objects.js +59 -0
- package/node_modules/@loopwright/controller/dist/git-reader.d.ts +17 -0
- package/node_modules/@loopwright/controller/dist/git-reader.js +40 -0
- package/node_modules/@loopwright/controller/dist/handlers.d.ts +6 -0
- package/node_modules/@loopwright/controller/dist/handlers.js +45 -0
- package/node_modules/@loopwright/controller/dist/handoff.d.ts +71 -0
- package/node_modules/@loopwright/controller/dist/handoff.js +554 -0
- package/node_modules/@loopwright/controller/dist/index.d.ts +41 -0
- package/node_modules/@loopwright/controller/dist/index.js +21 -0
- package/node_modules/@loopwright/controller/dist/inspect.d.ts +30 -0
- package/node_modules/@loopwright/controller/dist/inspect.js +372 -0
- package/node_modules/@loopwright/controller/dist/interpolation.d.ts +9 -0
- package/node_modules/@loopwright/controller/dist/interpolation.js +79 -0
- package/node_modules/@loopwright/controller/dist/ownership.d.ts +41 -0
- package/node_modules/@loopwright/controller/dist/ownership.js +666 -0
- package/node_modules/@loopwright/controller/dist/parser.d.ts +5 -0
- package/node_modules/@loopwright/controller/dist/parser.js +200 -0
- package/node_modules/@loopwright/controller/dist/progress.d.ts +41 -0
- package/node_modules/@loopwright/controller/dist/progress.js +904 -0
- package/node_modules/@loopwright/controller/dist/publication.d.ts +60 -0
- package/node_modules/@loopwright/controller/dist/publication.js +329 -0
- package/node_modules/@loopwright/controller/dist/reconcile.d.ts +26 -0
- package/node_modules/@loopwright/controller/dist/reconcile.js +1378 -0
- package/node_modules/@loopwright/controller/dist/recovery.d.ts +10 -0
- package/node_modules/@loopwright/controller/dist/recovery.js +315 -0
- package/node_modules/@loopwright/controller/dist/refusal-record.d.ts +43 -0
- package/node_modules/@loopwright/controller/dist/refusal-record.js +150 -0
- package/node_modules/@loopwright/controller/dist/registry.d.ts +6 -0
- package/node_modules/@loopwright/controller/dist/registry.js +374 -0
- package/node_modules/@loopwright/controller/dist/repair.d.ts +31 -0
- package/node_modules/@loopwright/controller/dist/repair.js +102 -0
- package/node_modules/@loopwright/controller/dist/report.d.ts +64 -0
- package/node_modules/@loopwright/controller/dist/report.js +596 -0
- package/node_modules/@loopwright/controller/dist/retained.d.ts +284 -0
- package/node_modules/@loopwright/controller/dist/retained.js +193 -0
- package/node_modules/@loopwright/controller/dist/rules.d.ts +31 -0
- package/node_modules/@loopwright/controller/dist/rules.js +110 -0
- package/node_modules/@loopwright/controller/dist/run-eval.d.ts +115 -0
- package/node_modules/@loopwright/controller/dist/run-eval.js +959 -0
- package/node_modules/@loopwright/controller/dist/scheduler.d.ts +10 -0
- package/node_modules/@loopwright/controller/dist/scheduler.js +41 -0
- package/node_modules/@loopwright/controller/dist/schema.d.ts +17 -0
- package/node_modules/@loopwright/controller/dist/schema.js +78 -0
- package/node_modules/@loopwright/controller/dist/source.d.ts +69 -0
- package/node_modules/@loopwright/controller/dist/source.js +872 -0
- package/node_modules/@loopwright/controller/dist/step.d.ts +38 -0
- package/node_modules/@loopwright/controller/dist/step.js +1776 -0
- package/node_modules/@loopwright/controller/dist/storage.d.ts +90 -0
- package/node_modules/@loopwright/controller/dist/storage.js +1345 -0
- package/node_modules/@loopwright/controller/dist/submission.d.ts +51 -0
- package/node_modules/@loopwright/controller/dist/submission.js +292 -0
- package/node_modules/@loopwright/controller/dist/types.d.ts +585 -0
- package/node_modules/@loopwright/controller/dist/types.js +9 -0
- package/node_modules/@loopwright/controller/dist/verification.d.ts +124 -0
- package/node_modules/@loopwright/controller/dist/verification.js +1308 -0
- package/node_modules/@loopwright/controller/dist/verifier-protocol.d.ts +105 -0
- package/node_modules/@loopwright/controller/dist/verifier-protocol.js +1312 -0
- package/node_modules/@loopwright/controller/dist/verifier-worker.d.ts +1 -0
- package/node_modules/@loopwright/controller/dist/verifier-worker.js +33 -0
- package/node_modules/@loopwright/controller/package.json +12 -0
- package/node_modules/@loopwright/core/dist/acceptance.d.ts +108 -0
- package/node_modules/@loopwright/core/dist/acceptance.js +327 -0
- package/node_modules/@loopwright/core/dist/artifacts.d.ts +63 -0
- package/node_modules/@loopwright/core/dist/artifacts.js +356 -0
- package/node_modules/@loopwright/core/dist/boundary.d.ts +21 -0
- package/node_modules/@loopwright/core/dist/boundary.js +484 -0
- package/node_modules/@loopwright/core/dist/contracts.d.ts +287 -0
- package/node_modules/@loopwright/core/dist/contracts.js +694 -0
- package/node_modules/@loopwright/core/dist/diagnostics.d.ts +21 -0
- package/node_modules/@loopwright/core/dist/diagnostics.js +51 -0
- package/node_modules/@loopwright/core/dist/evidence.d.ts +92 -0
- package/node_modules/@loopwright/core/dist/evidence.js +85 -0
- package/node_modules/@loopwright/core/dist/graph.d.ts +8 -0
- package/node_modules/@loopwright/core/dist/graph.js +44 -0
- package/node_modules/@loopwright/core/dist/identity.d.ts +162 -0
- package/node_modules/@loopwright/core/dist/identity.js +80 -0
- package/node_modules/@loopwright/core/dist/index.d.ts +30 -0
- package/node_modules/@loopwright/core/dist/index.js +39 -0
- package/node_modules/@loopwright/core/dist/limits.d.ts +99 -0
- package/node_modules/@loopwright/core/dist/limits.js +59 -0
- package/node_modules/@loopwright/core/dist/results.d.ts +161 -0
- package/node_modules/@loopwright/core/dist/results.js +98 -0
- package/node_modules/@loopwright/core/dist/scope.d.ts +13 -0
- package/node_modules/@loopwright/core/dist/scope.js +154 -0
- package/node_modules/@loopwright/core/dist/scrubber.d.ts +13 -0
- package/node_modules/@loopwright/core/dist/scrubber.js +63 -0
- package/node_modules/@loopwright/core/dist/usage.d.ts +68 -0
- package/node_modules/@loopwright/core/dist/usage.js +56 -0
- package/node_modules/@loopwright/core/package.json +12 -0
- package/node_modules/@loopwright/decisions/dist/benchmark.d.ts +23 -0
- package/node_modules/@loopwright/decisions/dist/benchmark.js +337 -0
- package/node_modules/@loopwright/decisions/dist/client.d.ts +74 -0
- package/node_modules/@loopwright/decisions/dist/client.js +292 -0
- package/node_modules/@loopwright/decisions/dist/index.d.ts +15 -0
- package/node_modules/@loopwright/decisions/dist/index.js +8 -0
- package/node_modules/@loopwright/decisions/dist/nodes.d.ts +63 -0
- package/node_modules/@loopwright/decisions/dist/nodes.js +282 -0
- package/node_modules/@loopwright/decisions/dist/primitives.d.ts +36 -0
- package/node_modules/@loopwright/decisions/dist/primitives.js +300 -0
- package/node_modules/@loopwright/decisions/dist/redaction.d.ts +23 -0
- package/node_modules/@loopwright/decisions/dist/redaction.js +146 -0
- package/node_modules/@loopwright/decisions/dist/router.d.ts +55 -0
- package/node_modules/@loopwright/decisions/dist/router.js +248 -0
- package/node_modules/@loopwright/decisions/dist/schema.d.ts +25 -0
- package/node_modules/@loopwright/decisions/dist/schema.js +536 -0
- package/node_modules/@loopwright/decisions/dist/types.d.ts +394 -0
- package/node_modules/@loopwright/decisions/dist/types.js +80 -0
- package/node_modules/@loopwright/decisions/package.json +12 -0
- package/node_modules/@loopwright/github-app/dist/action.d.ts +90 -0
- package/node_modules/@loopwright/github-app/dist/action.js +2429 -0
- package/node_modules/@loopwright/github-app/dist/config.d.ts +23 -0
- package/node_modules/@loopwright/github-app/dist/config.js +297 -0
- package/node_modules/@loopwright/github-app/dist/digests.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/digests.js +1 -0
- package/node_modules/@loopwright/github-app/dist/index.d.ts +14 -0
- package/node_modules/@loopwright/github-app/dist/index.js +13 -0
- package/node_modules/@loopwright/github-app/dist/models-config.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/models-config.js +1 -0
- package/node_modules/@loopwright/github-app/dist/output-format.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/output-format.js +1 -0
- package/node_modules/@loopwright/github-app/dist/preflight.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/preflight.js +1 -0
- package/node_modules/@loopwright/github-app/dist/publisher.d.ts +58 -0
- package/node_modules/@loopwright/github-app/dist/publisher.js +1368 -0
- package/node_modules/@loopwright/github-app/dist/qualification.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/qualification.js +1 -0
- package/node_modules/@loopwright/github-app/dist/sandbox.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/sandbox.js +1 -0
- package/node_modules/@loopwright/github-app/dist/schema.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/schema.js +1 -0
- package/node_modules/@loopwright/github-app/dist/service.d.ts +52 -0
- package/node_modules/@loopwright/github-app/dist/service.js +1658 -0
- package/node_modules/@loopwright/github-app/dist/suite-pr-lookup.d.ts +90 -0
- package/node_modules/@loopwright/github-app/dist/suite-pr-lookup.js +392 -0
- package/node_modules/@loopwright/github-app/dist/taskpack.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/taskpack.js +1 -0
- package/node_modules/@loopwright/github-app/dist/tenant-queue.d.ts +44 -0
- package/node_modules/@loopwright/github-app/dist/tenant-queue.js +423 -0
- package/node_modules/@loopwright/github-app/dist/token-broker.d.ts +50 -0
- package/node_modules/@loopwright/github-app/dist/token-broker.js +262 -0
- package/node_modules/@loopwright/github-app/dist/turnkey-memory.d.ts +35 -0
- package/node_modules/@loopwright/github-app/dist/turnkey-memory.js +1654 -0
- package/node_modules/@loopwright/github-app/dist/turnkey.d.ts +16 -0
- package/node_modules/@loopwright/github-app/dist/turnkey.js +34 -0
- package/node_modules/@loopwright/github-app/dist/types.d.ts +220 -0
- package/node_modules/@loopwright/github-app/dist/types.js +14 -0
- package/node_modules/@loopwright/github-app/dist/upstreams.d.ts +13 -0
- package/node_modules/@loopwright/github-app/dist/upstreams.js +65 -0
- package/node_modules/@loopwright/github-app/dist/webhook.d.ts +34 -0
- package/node_modules/@loopwright/github-app/dist/webhook.js +241 -0
- package/node_modules/@loopwright/github-app/dist/yaml.d.ts +1 -0
- package/node_modules/@loopwright/github-app/dist/yaml.js +1 -0
- package/node_modules/@loopwright/github-app/package.json +12 -0
- package/node_modules/@loopwright/hardware-runner/dist/config.d.ts +48 -0
- package/node_modules/@loopwright/hardware-runner/dist/config.js +719 -0
- package/node_modules/@loopwright/hardware-runner/dist/evaluator.d.ts +230 -0
- package/node_modules/@loopwright/hardware-runner/dist/evaluator.js +3178 -0
- package/node_modules/@loopwright/hardware-runner/dist/index.d.ts +13 -0
- package/node_modules/@loopwright/hardware-runner/dist/index.js +9 -0
- package/node_modules/@loopwright/hardware-runner/dist/provenance.d.ts +128 -0
- package/node_modules/@loopwright/hardware-runner/dist/provenance.js +1500 -0
- package/node_modules/@loopwright/hardware-runner/dist/queue.d.ts +81 -0
- package/node_modules/@loopwright/hardware-runner/dist/queue.js +1081 -0
- package/node_modules/@loopwright/hardware-runner/dist/relay-server.d.ts +13 -0
- package/node_modules/@loopwright/hardware-runner/dist/relay-server.js +2997 -0
- package/node_modules/@loopwright/hardware-runner/dist/types.d.ts +239 -0
- package/node_modules/@loopwright/hardware-runner/dist/types.js +12 -0
- package/node_modules/@loopwright/hardware-runner/dist/worker.d.ts +49 -0
- package/node_modules/@loopwright/hardware-runner/dist/worker.js +1646 -0
- package/node_modules/@loopwright/hardware-runner/package.json +12 -0
- package/node_modules/@loopwright/memory/dist/cas.d.ts +21 -0
- package/node_modules/@loopwright/memory/dist/cas.js +510 -0
- package/node_modules/@loopwright/memory/dist/compaction.d.ts +18 -0
- package/node_modules/@loopwright/memory/dist/compaction.js +110 -0
- package/node_modules/@loopwright/memory/dist/finalizer.d.ts +23 -0
- package/node_modules/@loopwright/memory/dist/finalizer.js +538 -0
- package/node_modules/@loopwright/memory/dist/index.d.ts +9 -0
- package/node_modules/@loopwright/memory/dist/index.js +8 -0
- package/node_modules/@loopwright/memory/dist/schema.d.ts +36 -0
- package/node_modules/@loopwright/memory/dist/schema.js +510 -0
- package/node_modules/@loopwright/memory/dist/selector.d.ts +7 -0
- package/node_modules/@loopwright/memory/dist/selector.js +157 -0
- package/node_modules/@loopwright/memory/dist/store.d.ts +51 -0
- package/node_modules/@loopwright/memory/dist/store.js +554 -0
- package/node_modules/@loopwright/memory/dist/types.d.ts +442 -0
- package/node_modules/@loopwright/memory/dist/types.js +8 -0
- package/node_modules/@loopwright/memory/dist/verifier.d.ts +5 -0
- package/node_modules/@loopwright/memory/dist/verifier.js +328 -0
- package/node_modules/@loopwright/memory/package.json +12 -0
- package/node_modules/@loopwright/state/dist/admission.d.ts +321 -0
- package/node_modules/@loopwright/state/dist/admission.js +199 -0
- package/node_modules/@loopwright/state/dist/boundary.d.ts +53 -0
- package/node_modules/@loopwright/state/dist/boundary.js +194 -0
- package/node_modules/@loopwright/state/dist/checkpoint.d.ts +16 -0
- package/node_modules/@loopwright/state/dist/checkpoint.js +84 -0
- package/node_modules/@loopwright/state/dist/clock.d.ts +8 -0
- package/node_modules/@loopwright/state/dist/clock.js +27 -0
- package/node_modules/@loopwright/state/dist/connection.d.ts +55 -0
- package/node_modules/@loopwright/state/dist/connection.js +391 -0
- package/node_modules/@loopwright/state/dist/errors.d.ts +13 -0
- package/node_modules/@loopwright/state/dist/errors.js +34 -0
- package/node_modules/@loopwright/state/dist/index.d.ts +3 -0
- package/node_modules/@loopwright/state/dist/index.js +1 -0
- package/node_modules/@loopwright/state/dist/journal.d.ts +119 -0
- package/node_modules/@loopwright/state/dist/journal.js +72 -0
- package/node_modules/@loopwright/state/dist/model.d.ts +40 -0
- package/node_modules/@loopwright/state/dist/model.js +58 -0
- package/node_modules/@loopwright/state/dist/ownership.d.ts +14 -0
- package/node_modules/@loopwright/state/dist/ownership.js +45 -0
- package/node_modules/@loopwright/state/dist/pages.d.ts +11 -0
- package/node_modules/@loopwright/state/dist/pages.js +41 -0
- package/node_modules/@loopwright/state/dist/receipts.d.ts +33 -0
- package/node_modules/@loopwright/state/dist/receipts.js +97 -0
- package/node_modules/@loopwright/state/dist/schema.d.ts +28 -0
- package/node_modules/@loopwright/state/dist/schema.js +41 -0
- package/node_modules/@loopwright/state/dist/settlement.d.ts +10 -0
- package/node_modules/@loopwright/state/dist/settlement.js +129 -0
- package/node_modules/@loopwright/state/dist/store.d.ts +52 -0
- package/node_modules/@loopwright/state/dist/store.js +100 -0
- package/node_modules/@loopwright/state/dist/types.d.ts +315 -0
- package/node_modules/@loopwright/state/dist/types.js +1 -0
- package/node_modules/@loopwright/state/package.json +12 -0
- package/node_modules/@loopwright/taskpack/dist/baseline-align.d.ts +195 -0
- package/node_modules/@loopwright/taskpack/dist/baseline-align.js +1847 -0
- package/node_modules/@loopwright/taskpack/dist/digests.d.ts +61 -0
- package/node_modules/@loopwright/taskpack/dist/digests.js +715 -0
- package/node_modules/@loopwright/taskpack/dist/index.d.ts +18 -0
- package/node_modules/@loopwright/taskpack/dist/index.js +17 -0
- package/node_modules/@loopwright/taskpack/dist/models-config.d.ts +112 -0
- package/node_modules/@loopwright/taskpack/dist/models-config.js +1026 -0
- package/node_modules/@loopwright/taskpack/dist/output-format.d.ts +28 -0
- package/node_modules/@loopwright/taskpack/dist/output-format.js +157 -0
- package/node_modules/@loopwright/taskpack/dist/preflight.d.ts +130 -0
- package/node_modules/@loopwright/taskpack/dist/preflight.js +1497 -0
- package/node_modules/@loopwright/taskpack/dist/qualification.d.ts +23 -0
- package/node_modules/@loopwright/taskpack/dist/qualification.js +120 -0
- package/node_modules/@loopwright/taskpack/dist/sandbox.d.ts +121 -0
- package/node_modules/@loopwright/taskpack/dist/sandbox.js +2605 -0
- package/node_modules/@loopwright/taskpack/dist/schema.d.ts +197 -0
- package/node_modules/@loopwright/taskpack/dist/schema.js +4189 -0
- package/node_modules/@loopwright/taskpack/dist/scrubber.d.ts +47 -0
- package/node_modules/@loopwright/taskpack/dist/scrubber.js +283 -0
- package/node_modules/@loopwright/taskpack/dist/suite.d.ts +124 -0
- package/node_modules/@loopwright/taskpack/dist/suite.js +3256 -0
- package/node_modules/@loopwright/taskpack/dist/taskpack.d.ts +154 -0
- package/node_modules/@loopwright/taskpack/dist/taskpack.js +3634 -0
- package/node_modules/@loopwright/taskpack/dist/turnkey-memory.d.ts +122 -0
- package/node_modules/@loopwright/taskpack/dist/turnkey-memory.js +483 -0
- package/node_modules/@loopwright/taskpack/dist/turnkey.d.ts +437 -0
- package/node_modules/@loopwright/taskpack/dist/turnkey.js +7313 -0
- package/node_modules/@loopwright/taskpack/dist/types.d.ts +1274 -0
- package/node_modules/@loopwright/taskpack/dist/types.js +99 -0
- package/node_modules/@loopwright/taskpack/dist/upstreams.d.ts +261 -0
- package/node_modules/@loopwright/taskpack/dist/upstreams.js +2242 -0
- package/node_modules/@loopwright/taskpack/dist/yaml.d.ts +18 -0
- package/node_modules/@loopwright/taskpack/dist/yaml.js +167 -0
- package/node_modules/@loopwright/taskpack/package.json +12 -0
- package/node_modules/@loopwright/taskpack-runner/dist/compile-taskpack.d.ts +137 -0
- package/node_modules/@loopwright/taskpack-runner/dist/compile-taskpack.js +474 -0
- package/node_modules/@loopwright/taskpack-runner/dist/corpus.d.ts +8 -0
- package/node_modules/@loopwright/taskpack-runner/dist/corpus.js +129 -0
- package/node_modules/@loopwright/taskpack-runner/dist/index.d.ts +13 -0
- package/node_modules/@loopwright/taskpack-runner/dist/index.js +7 -0
- package/node_modules/@loopwright/taskpack-runner/dist/intake.d.ts +149 -0
- package/node_modules/@loopwright/taskpack-runner/dist/intake.js +135 -0
- package/node_modules/@loopwright/taskpack-runner/dist/parity.d.ts +130 -0
- package/node_modules/@loopwright/taskpack-runner/dist/parity.js +927 -0
- package/node_modules/@loopwright/taskpack-runner/dist/python-bridge.d.ts +68 -0
- package/node_modules/@loopwright/taskpack-runner/dist/python-bridge.js +517 -0
- package/node_modules/@loopwright/taskpack-runner/dist/service.d.ts +149 -0
- package/node_modules/@loopwright/taskpack-runner/dist/service.js +1796 -0
- package/node_modules/@loopwright/taskpack-runner/dist/types.d.ts +29 -0
- package/node_modules/@loopwright/taskpack-runner/dist/types.js +11 -0
- package/node_modules/@loopwright/taskpack-runner/package.json +12 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/README.md +77 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/docs/support-records.md +57 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/docs/supported-runners.md +98 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/manifest.json +205 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/pack/expand_matrix.sh +273 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/pack/matrix.yaml +280 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/pack/resolve_dockerfile.sh +24 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/pyproject.toml +46 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/runtime_runner/runner.py.json +5270 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/fixtures/discovery/legacy-support.md +86 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/fixtures/github/service.py +401 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/fixtures/proposals/analysis.json +95 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/fixtures/proposals/ready.json +109 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_assemble.py +263 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_check_draft.py +333 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_checks.py +1099 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_discovery.py +817 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_proposal.py +658 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_publish.py +987 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tests/auto_sync/test_summary.py +107 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/agent.py +610 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/assemble.py +84 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/check_draft.py +94 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/checks.py +1002 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/discovery.py +789 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/model.py +557 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/progress.py +174 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/prompts/analysis.md +40 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/prompts/proposal.md +65 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/prompts/repair.md +17 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/proposal.py +903 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/publish.py +997 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/summary.py +131 -0
- package/node_modules/@loopwright/taskpack-runner/vendor/runner-auto-sync/tools/auto_sync/tool-versions.json +133 -0
- package/node_modules/package-lock.json +3021 -0
- package/package-lock.json +3021 -0
- package/package.json +52 -4
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import type { ArtifactManifest, ArtifactRef, Digest, TaskLock } from '@loopwright/core';
|
|
2
|
+
import type { Authority, LocalRunStore, Purpose, StateErrorCode } from '@loopwright/state';
|
|
3
|
+
import type { ContextAssessment } from './context.js';
|
|
4
|
+
export type PiContextAssessment = ContextAssessment;
|
|
5
|
+
export interface PiContextRecord {
|
|
6
|
+
readonly version: 1;
|
|
7
|
+
readonly assessmentId: string;
|
|
8
|
+
readonly requestId: string | null;
|
|
9
|
+
readonly decision: 'admitted' | 'refused';
|
|
10
|
+
readonly code: 'CONTEXT_UNSAFE' | null;
|
|
11
|
+
readonly policyDigest: Digest;
|
|
12
|
+
readonly catalogDigest: Digest;
|
|
13
|
+
readonly catalogWindow: number;
|
|
14
|
+
readonly model: AdapterPolicy['selection'];
|
|
15
|
+
readonly assessment: PiContextAssessment | null;
|
|
16
|
+
}
|
|
17
|
+
export type PiErrorCode = 'INPUT_INVALID' | 'BINDING_MISMATCH' | 'RUNTIME_UNSUPPORTED' | 'RUNTIME_MISMATCH' | 'RESOURCE_MISMATCH' | 'MODEL_UNAVAILABLE' | 'THINKING_UNSUPPORTED' | 'CAPABILITY_UNSUPPORTED' | 'EXTENSION_UNSUPPORTED' | 'CONTAINMENT_UNAVAILABLE' | 'CONTAINMENT_MISMATCH' | 'SESSION_BUSY' | 'AUTHORITY_REFUSED' | 'STATE_REFUSED' | 'REQUEST_REFUSED' | 'SEND_PATH_UNSUPPORTED' | 'PAYLOAD_MISMATCH' | 'CONTEXT_UNSAFE' | 'CONTEXT_LIMIT' | 'PROVIDER_RESPONSE_INVALID' | 'RESPONSE_INCOMPLETE' | 'TOOL_DENIED' | 'MCP_FAILED' | 'OUTPUT_LIMIT' | 'EVENT_OVERFLOW' | 'DEADLINE' | 'CANCELLED' | 'RECOVERY_REQUIRED' | 'CLEANUP_FAILED';
|
|
18
|
+
export interface PiError {
|
|
19
|
+
readonly code: PiErrorCode;
|
|
20
|
+
readonly path: string;
|
|
21
|
+
readonly phase: 'preflight' | 'admission' | 'dispatch' | 'tool' | 'session' | 'restore' | 'cleanup';
|
|
22
|
+
readonly retryable: boolean;
|
|
23
|
+
readonly effect: 'none' | 'possible' | 'confirmed';
|
|
24
|
+
readonly requestId: string | null;
|
|
25
|
+
readonly operationId: string | null;
|
|
26
|
+
readonly stateErrorCode: StateErrorCode | null;
|
|
27
|
+
}
|
|
28
|
+
export type PiResult<T> = {
|
|
29
|
+
readonly ok: true;
|
|
30
|
+
readonly value: T;
|
|
31
|
+
} | {
|
|
32
|
+
readonly ok: false;
|
|
33
|
+
readonly error: PiError;
|
|
34
|
+
};
|
|
35
|
+
export interface RuntimeIdentity {
|
|
36
|
+
readonly sdkIntegrity: string;
|
|
37
|
+
readonly graphDigest: Digest;
|
|
38
|
+
readonly imageDigest: string;
|
|
39
|
+
readonly configDigest: Digest;
|
|
40
|
+
readonly profile: 'linux/arm64';
|
|
41
|
+
}
|
|
42
|
+
export interface PiCandidateStreamChecker {
|
|
43
|
+
readonly push: (chunk: Uint8Array) => void;
|
|
44
|
+
readonly finish: () => void;
|
|
45
|
+
}
|
|
46
|
+
/** Trusted construction only: these functions and paths are never accepted from model policy JSON. */
|
|
47
|
+
export interface PiHost {
|
|
48
|
+
readonly store: LocalRunStore;
|
|
49
|
+
readonly authority: Authority;
|
|
50
|
+
readonly directory: string;
|
|
51
|
+
readonly artifactsDirectory: string;
|
|
52
|
+
readonly dockerExecutable: string;
|
|
53
|
+
readonly dockerSocket: string;
|
|
54
|
+
readonly runtime: RuntimeIdentity;
|
|
55
|
+
readonly resolveCredential: (binding: {
|
|
56
|
+
readonly provider: string;
|
|
57
|
+
readonly model: string;
|
|
58
|
+
readonly destination: string;
|
|
59
|
+
readonly purpose: Purpose;
|
|
60
|
+
readonly runId: string;
|
|
61
|
+
readonly roleId: string;
|
|
62
|
+
readonly stepId: string;
|
|
63
|
+
readonly notAfterMonotonicMs: string;
|
|
64
|
+
readonly signal: AbortSignal;
|
|
65
|
+
}) => Promise<{
|
|
66
|
+
readonly bearerToken: string;
|
|
67
|
+
}>;
|
|
68
|
+
readonly createCandidateStreamChecker?: () => PiCandidateStreamChecker;
|
|
69
|
+
}
|
|
70
|
+
export interface ResourceIdentity {
|
|
71
|
+
readonly id: string;
|
|
72
|
+
readonly kind: 'instruction' | 'skill' | 'document';
|
|
73
|
+
readonly path: string;
|
|
74
|
+
readonly digest: Digest;
|
|
75
|
+
}
|
|
76
|
+
export interface PiLimits {
|
|
77
|
+
readonly promptBytes: number;
|
|
78
|
+
readonly diagnosticBytes: number;
|
|
79
|
+
readonly responseBytes: number;
|
|
80
|
+
readonly frameBytes: number;
|
|
81
|
+
readonly eventBytes: number;
|
|
82
|
+
readonly pendingResponseBytes: number;
|
|
83
|
+
readonly eventQueue: number;
|
|
84
|
+
readonly eventQueueBytes: number;
|
|
85
|
+
readonly toolArgsBytes: number;
|
|
86
|
+
readonly toolResultBytes: number;
|
|
87
|
+
readonly sessionBytes: number;
|
|
88
|
+
readonly artifactBytes: number;
|
|
89
|
+
readonly candidateEntries: number;
|
|
90
|
+
readonly fileBytes: number;
|
|
91
|
+
readonly toolWallMs: number;
|
|
92
|
+
readonly requests: number;
|
|
93
|
+
readonly operations: number;
|
|
94
|
+
readonly checkpoints: number;
|
|
95
|
+
}
|
|
96
|
+
export type PiWireApi = 'anthropic-messages' | 'openai-completions' | 'openai-responses';
|
|
97
|
+
export type PiThinkingLevel = 'off' | 'minimal' | 'low' | 'medium' | 'high' | 'xhigh' | 'max';
|
|
98
|
+
export interface PiSamplingParams {
|
|
99
|
+
readonly temperature?: number;
|
|
100
|
+
readonly top_p?: number;
|
|
101
|
+
readonly top_k?: number;
|
|
102
|
+
readonly min_p?: number;
|
|
103
|
+
readonly presence_penalty?: number;
|
|
104
|
+
readonly repetition_penalty?: number;
|
|
105
|
+
}
|
|
106
|
+
export interface PiCustomModelCompat {
|
|
107
|
+
readonly supportsStore?: boolean;
|
|
108
|
+
readonly supportsDeveloperRole?: boolean;
|
|
109
|
+
readonly supportsReasoningEffort?: boolean;
|
|
110
|
+
readonly supportsUsageInStreaming?: boolean;
|
|
111
|
+
readonly maxTokensField?: 'max_completion_tokens' | 'max_tokens';
|
|
112
|
+
readonly requiresToolResultName?: boolean;
|
|
113
|
+
readonly requiresAssistantAfterToolResult?: boolean;
|
|
114
|
+
readonly requiresThinkingAsText?: boolean;
|
|
115
|
+
readonly thinkingFormat?: 'openai' | 'zai' | 'qwen' | 'qwen-chat-template' | 'openrouter' | 'deepseek';
|
|
116
|
+
readonly supportsStrictMode?: boolean;
|
|
117
|
+
readonly zaiToolStream?: boolean;
|
|
118
|
+
}
|
|
119
|
+
export interface PiModelCost {
|
|
120
|
+
readonly input: number;
|
|
121
|
+
readonly output: number;
|
|
122
|
+
readonly cacheRead?: number;
|
|
123
|
+
readonly cacheWrite?: number;
|
|
124
|
+
}
|
|
125
|
+
export interface PiCustomProviderConfig {
|
|
126
|
+
readonly baseUrl: string;
|
|
127
|
+
readonly authHeader?: boolean;
|
|
128
|
+
readonly headers?: Readonly<Record<string, string>>;
|
|
129
|
+
readonly contextWindow: number;
|
|
130
|
+
readonly maxTokens: number;
|
|
131
|
+
readonly reasoning: boolean;
|
|
132
|
+
readonly thinkingLevelMap?: Readonly<Record<string, string | null>>;
|
|
133
|
+
readonly samplingParams?: PiSamplingParams;
|
|
134
|
+
readonly samplingParamsByThinkingLevel?: Readonly<Record<string, PiSamplingParams>>;
|
|
135
|
+
readonly compat?: PiCustomModelCompat;
|
|
136
|
+
readonly cost?: PiModelCost;
|
|
137
|
+
}
|
|
138
|
+
export interface PiModelSelection {
|
|
139
|
+
readonly provider: string;
|
|
140
|
+
readonly model: string;
|
|
141
|
+
readonly thinking: string;
|
|
142
|
+
readonly api: PiWireApi;
|
|
143
|
+
readonly customProvider?: PiCustomProviderConfig;
|
|
144
|
+
}
|
|
145
|
+
export interface AdapterPolicy {
|
|
146
|
+
readonly version: 1;
|
|
147
|
+
readonly policyId: string;
|
|
148
|
+
readonly resourceVersion: string;
|
|
149
|
+
readonly adapterId: 'pi';
|
|
150
|
+
readonly adapterVersion: '0.0.0';
|
|
151
|
+
readonly runtime: RuntimeIdentity;
|
|
152
|
+
readonly selection: PiModelSelection;
|
|
153
|
+
readonly resources: readonly ResourceIdentity[];
|
|
154
|
+
readonly tools: readonly string[];
|
|
155
|
+
readonly mcp: {
|
|
156
|
+
readonly serverId: 'workspace';
|
|
157
|
+
readonly scriptDigest: Digest;
|
|
158
|
+
readonly names: readonly string[];
|
|
159
|
+
readonly effects: readonly 'read_only'[];
|
|
160
|
+
readonly idleTimeoutSeconds: number;
|
|
161
|
+
readonly absoluteTimeoutSeconds: number;
|
|
162
|
+
};
|
|
163
|
+
readonly context: {
|
|
164
|
+
readonly mode?: 'proven_bound' | 'estimated_guard';
|
|
165
|
+
readonly estimator: 'lw-pi-final-json-bytes-v1';
|
|
166
|
+
readonly proofId: null;
|
|
167
|
+
readonly version: 1;
|
|
168
|
+
readonly evidence: 'estimated';
|
|
169
|
+
readonly workingWindowCeiling: number;
|
|
170
|
+
readonly maxRequestBytes: number;
|
|
171
|
+
readonly serviceMargin: number;
|
|
172
|
+
readonly toolReserve: number;
|
|
173
|
+
readonly maxOutputTokens: number;
|
|
174
|
+
};
|
|
175
|
+
readonly accounting: 'soft_only';
|
|
176
|
+
readonly retry: 'sender_only';
|
|
177
|
+
readonly extensions: readonly [];
|
|
178
|
+
readonly privateArtifacts: boolean;
|
|
179
|
+
readonly limits: PiLimits;
|
|
180
|
+
}
|
|
181
|
+
export interface PiBaselineEntry {
|
|
182
|
+
readonly name: string;
|
|
183
|
+
readonly mode: '100644' | '100755';
|
|
184
|
+
readonly oid: string;
|
|
185
|
+
readonly byteLength: number;
|
|
186
|
+
}
|
|
187
|
+
export interface PiCandidateBaseline {
|
|
188
|
+
readonly directory: string;
|
|
189
|
+
readonly entries: readonly PiBaselineEntry[];
|
|
190
|
+
}
|
|
191
|
+
export interface PiCandidateBlobArtifact {
|
|
192
|
+
readonly name: string;
|
|
193
|
+
readonly byteLength: number;
|
|
194
|
+
readonly digest: Digest;
|
|
195
|
+
readonly blobPath: string;
|
|
196
|
+
}
|
|
197
|
+
export type PiCandidateArtifactInput = {
|
|
198
|
+
readonly name: string;
|
|
199
|
+
readonly bytes: Uint8Array;
|
|
200
|
+
} | PiCandidateBlobArtifact;
|
|
201
|
+
export interface PiOpenInput {
|
|
202
|
+
readonly version: 1;
|
|
203
|
+
readonly lock: TaskLock;
|
|
204
|
+
readonly roleId: string;
|
|
205
|
+
readonly stepId: string;
|
|
206
|
+
readonly sessionId: string;
|
|
207
|
+
readonly policy: AdapterPolicy;
|
|
208
|
+
readonly candidate: {
|
|
209
|
+
readonly manifest: ArtifactManifest;
|
|
210
|
+
readonly baseRevision: string;
|
|
211
|
+
readonly sourceRevision: string;
|
|
212
|
+
readonly artifacts: readonly PiCandidateArtifactInput[];
|
|
213
|
+
readonly baseline?: PiCandidateBaseline;
|
|
214
|
+
};
|
|
215
|
+
readonly resources: readonly {
|
|
216
|
+
readonly id: string;
|
|
217
|
+
readonly kind: ResourceIdentity['kind'];
|
|
218
|
+
readonly ref: ArtifactRef;
|
|
219
|
+
readonly bytes: Uint8Array;
|
|
220
|
+
}[];
|
|
221
|
+
readonly restore: null | {
|
|
222
|
+
readonly checkpointId: string;
|
|
223
|
+
readonly workspace: {
|
|
224
|
+
readonly ref: ArtifactRef;
|
|
225
|
+
readonly bytes: Uint8Array;
|
|
226
|
+
};
|
|
227
|
+
readonly session: {
|
|
228
|
+
readonly ref: ArtifactRef;
|
|
229
|
+
readonly bytes: Uint8Array;
|
|
230
|
+
};
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
export interface PiCapabilities {
|
|
234
|
+
readonly version: 1;
|
|
235
|
+
readonly policyDigest: Digest;
|
|
236
|
+
readonly runtime: RuntimeIdentity;
|
|
237
|
+
readonly requested: AdapterPolicy['selection'];
|
|
238
|
+
readonly catalogSupported: AdapterPolicy['selection'];
|
|
239
|
+
readonly sessionEffective: AdapterPolicy['selection'];
|
|
240
|
+
readonly outboundObserved: AdapterPolicy['selection'] | null;
|
|
241
|
+
readonly resources: readonly ResourceIdentity[];
|
|
242
|
+
readonly accounting: 'soft_only';
|
|
243
|
+
readonly contextFit: 'unproven';
|
|
244
|
+
readonly defaultMode: 'proven_bound';
|
|
245
|
+
readonly liveProvenBoundAvailable: false;
|
|
246
|
+
readonly optInMode: 'estimated_guard';
|
|
247
|
+
readonly toolExecution: {
|
|
248
|
+
readonly candidate: 'read_only';
|
|
249
|
+
readonly candidateWrites: 'mediated';
|
|
250
|
+
readonly scratch: 'per_call';
|
|
251
|
+
};
|
|
252
|
+
readonly contextEstimator: {
|
|
253
|
+
readonly id: 'lw-pi-final-json-bytes-v1';
|
|
254
|
+
readonly version: 1;
|
|
255
|
+
readonly provenance: 'estimated';
|
|
256
|
+
};
|
|
257
|
+
}
|
|
258
|
+
export interface PiCommand {
|
|
259
|
+
readonly commandId: string;
|
|
260
|
+
readonly text: string;
|
|
261
|
+
readonly purpose: Purpose;
|
|
262
|
+
readonly repair: 'none' | 'format' | 'implementation';
|
|
263
|
+
}
|
|
264
|
+
export interface PiOutcome {
|
|
265
|
+
readonly status: 'execution_settled' | 'failed' | 'cancelled' | 'blocked' | 'recovery_required';
|
|
266
|
+
readonly requestIds: readonly string[];
|
|
267
|
+
readonly operationIds: readonly string[];
|
|
268
|
+
readonly providerTermination: 'confirmed' | 'unknown' | 'none';
|
|
269
|
+
readonly usage: 'complete' | 'incomplete' | 'none';
|
|
270
|
+
readonly localCleanup: 'complete' | 'pending' | 'failed';
|
|
271
|
+
/** Execution failures are values after a valid command starts; API/preflight refusals remain PiResult errors. */
|
|
272
|
+
readonly error: PiError | null;
|
|
273
|
+
readonly cleanupError: PiError | null;
|
|
274
|
+
}
|
|
275
|
+
export interface PiEvent {
|
|
276
|
+
readonly version: 1;
|
|
277
|
+
readonly sessionId: string;
|
|
278
|
+
readonly runId: string;
|
|
279
|
+
readonly roleId: string;
|
|
280
|
+
readonly stepId: string;
|
|
281
|
+
readonly lockHash: Digest;
|
|
282
|
+
readonly requestId: string | null;
|
|
283
|
+
readonly operationId: string | null;
|
|
284
|
+
readonly attemptId: string | null;
|
|
285
|
+
readonly sequence: number;
|
|
286
|
+
readonly kind: 'resource_identity' | 'context_assessment' | 'request_start' | 'request_receipt' | 'request_uncertain' | 'tool_start' | 'tool_end' | 'retry_wait' | 'cancellation' | 'process_exit' | 'settled';
|
|
287
|
+
readonly code: PiErrorCode | null;
|
|
288
|
+
readonly count: number | null;
|
|
289
|
+
readonly digest: Digest | null;
|
|
290
|
+
readonly context: PiContextRecord | null;
|
|
291
|
+
}
|
|
292
|
+
export interface PiCapture {
|
|
293
|
+
readonly checkpointId: string;
|
|
294
|
+
readonly candidate: ArtifactManifest;
|
|
295
|
+
readonly workspace: ArtifactRef;
|
|
296
|
+
readonly session: ArtifactRef;
|
|
297
|
+
}
|
|
298
|
+
export interface PiAdapter {
|
|
299
|
+
capabilities(): PiCapabilities;
|
|
300
|
+
execute(input: PiCommand): Promise<PiResult<PiOutcome>>;
|
|
301
|
+
compact(input: {
|
|
302
|
+
readonly commandId: string;
|
|
303
|
+
}): Promise<PiResult<PiOutcome>>;
|
|
304
|
+
events(): AsyncIterable<PiEvent>;
|
|
305
|
+
cancel(input: {
|
|
306
|
+
readonly reason: 'operator' | 'deadline' | 'consumer_disconnected';
|
|
307
|
+
}): Promise<PiResult<PiOutcome>>;
|
|
308
|
+
capture(input: {
|
|
309
|
+
readonly checkpointId: string;
|
|
310
|
+
}): Promise<PiResult<PiCapture>>;
|
|
311
|
+
close(): Promise<PiResult<{
|
|
312
|
+
readonly closed: true;
|
|
313
|
+
}>>;
|
|
314
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { RequestUsage, Digest } from '@loopwright/core';
|
|
2
|
+
import { type RawResponseResult } from './response.js';
|
|
3
|
+
import type { PiModelCost, PiWireApi } from './types.js';
|
|
4
|
+
export interface RawToolCall {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly name: string;
|
|
7
|
+
readonly argumentsDigest: Digest;
|
|
8
|
+
}
|
|
9
|
+
export interface RawInspection {
|
|
10
|
+
readonly termination: 'confirmed' | 'unknown';
|
|
11
|
+
readonly rawStop: string | null;
|
|
12
|
+
readonly responseDigest: Digest;
|
|
13
|
+
readonly usage: Omit<RequestUsage, 'requestId'>;
|
|
14
|
+
readonly admission: RawResponseResult;
|
|
15
|
+
readonly toolCalls: readonly RawToolCall[];
|
|
16
|
+
}
|
|
17
|
+
export declare function toolArgumentsDigest(value: unknown): Digest;
|
|
18
|
+
export declare function inspectRawResponse(bytes: Uint8Array, status: number, model: string, api?: PiWireApi, strictModelMatch?: boolean, modelCost?: PiModelCost): RawInspection;
|
|
@@ -0,0 +1,314 @@
|
|
|
1
|
+
import { hasPositiveModelCost } from './catalog.js';
|
|
2
|
+
import { parseBoundedJson } from './context.js';
|
|
3
|
+
import { evaluateRawResponse } from './response.js';
|
|
4
|
+
import { canonical, digest } from './boundary.js';
|
|
5
|
+
const unknown = () => ({ provenance: 'unknown' });
|
|
6
|
+
const number = (value) => Number.isSafeInteger(value) && value >= 0 && !Object.is(value, -0);
|
|
7
|
+
export function toolArgumentsDigest(value) { return digest(Buffer.from('loopwright.dev/tool-arguments/v1\0' + canonical(value))); }
|
|
8
|
+
function estimateOpenAiCost(totalInputTokens, cachedTokens, outputTokens, modelCost) {
|
|
9
|
+
const clampedCached = Math.min(Math.max(0, cachedTokens), totalInputTokens);
|
|
10
|
+
const uncachedInput = Math.max(0, totalInputTokens - clampedCached);
|
|
11
|
+
const cacheReadRate = modelCost.cacheRead ?? modelCost.input;
|
|
12
|
+
const estimated = Math.round(uncachedInput * modelCost.input + clampedCached * cacheReadRate + outputTokens * modelCost.output);
|
|
13
|
+
return Number.isSafeInteger(estimated) && estimated >= 0 ? { provenance: 'estimated', value: estimated } : unknown();
|
|
14
|
+
}
|
|
15
|
+
function inspectOpenAiCompletions(bytes, source, status, admission, modelCost) {
|
|
16
|
+
let termination = 'unknown';
|
|
17
|
+
let rawStop = null;
|
|
18
|
+
const usage = { inputTokens: unknown(), outputTokens: unknown(), costMicrousd: unknown() };
|
|
19
|
+
const toolCalls = [];
|
|
20
|
+
const result = () => ({ termination, rawStop, responseDigest: digest(bytes), usage, admission, toolCalls });
|
|
21
|
+
if (status !== 200) {
|
|
22
|
+
const parsed = parseBoundedJson(source);
|
|
23
|
+
if (parsed && typeof parsed.error === 'object' && parsed.error !== null && [400, 401, 403, 404, 429].includes(status)) {
|
|
24
|
+
termination = 'confirmed';
|
|
25
|
+
}
|
|
26
|
+
return result();
|
|
27
|
+
}
|
|
28
|
+
const normalized = source.replace(/\r\n/g, '\n');
|
|
29
|
+
if (!normalized.endsWith('\n\n'))
|
|
30
|
+
return result();
|
|
31
|
+
let done = false;
|
|
32
|
+
let promptTokens = null;
|
|
33
|
+
let completionTokens = null;
|
|
34
|
+
let cachedTokens = 0;
|
|
35
|
+
let reportedCostMicrousd = null;
|
|
36
|
+
const calls = new Map();
|
|
37
|
+
for (const frame of normalized.split('\n\n').filter(Boolean)) {
|
|
38
|
+
const dataLines = frame.split('\n').filter(line => !line.startsWith(':'));
|
|
39
|
+
if (dataLines.length === 0)
|
|
40
|
+
continue;
|
|
41
|
+
const payload = dataLines.map(line => line.slice(6)).join('\n').trim();
|
|
42
|
+
if (payload === '[DONE]') {
|
|
43
|
+
done = true;
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
const chunk = parseBoundedJson(payload, { nodes: 262144, array: 4096 });
|
|
47
|
+
for (const choice of chunk.choices ?? []) {
|
|
48
|
+
if (typeof choice.finish_reason === 'string' && choice.finish_reason.length > 0)
|
|
49
|
+
rawStop = choice.finish_reason;
|
|
50
|
+
for (const tc of choice.delta?.tool_calls ?? []) {
|
|
51
|
+
if (number(tc.index)) {
|
|
52
|
+
const existing = calls.get(tc.index) ?? { id: '', name: '', arguments: '' };
|
|
53
|
+
if (typeof tc.id === 'string' && tc.id.length > 0)
|
|
54
|
+
existing.id = tc.id;
|
|
55
|
+
if (typeof tc.function?.name === 'string' && tc.function.name.length > 0)
|
|
56
|
+
existing.name += tc.function.name;
|
|
57
|
+
if (typeof tc.function?.arguments === 'string')
|
|
58
|
+
existing.arguments += tc.function.arguments;
|
|
59
|
+
calls.set(tc.index, existing);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
if (chunk.usage && typeof chunk.usage === 'object') {
|
|
64
|
+
if (number(chunk.usage.prompt_tokens))
|
|
65
|
+
promptTokens = chunk.usage.prompt_tokens;
|
|
66
|
+
if (number(chunk.usage.completion_tokens))
|
|
67
|
+
completionTokens = chunk.usage.completion_tokens;
|
|
68
|
+
if (number(chunk.usage.cost_microusd))
|
|
69
|
+
reportedCostMicrousd = chunk.usage.cost_microusd;
|
|
70
|
+
const details = chunk.usage.prompt_tokens_details;
|
|
71
|
+
if (details && typeof details === 'object' && !Array.isArray(details) && number(details.cached_tokens)) {
|
|
72
|
+
cachedTokens = details.cached_tokens;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
if (done && rawStop && ['stop', 'tool_calls', 'length', 'content_filter', 'network_error'].includes(rawStop) && (admission.ok || admission.terminalComplete === true)) {
|
|
77
|
+
termination = 'confirmed';
|
|
78
|
+
if (promptTokens !== null)
|
|
79
|
+
usage.inputTokens = { provenance: 'reported', value: promptTokens };
|
|
80
|
+
if (completionTokens !== null)
|
|
81
|
+
usage.outputTokens = { provenance: 'reported', value: completionTokens };
|
|
82
|
+
if (reportedCostMicrousd !== null) {
|
|
83
|
+
usage.costMicrousd = { provenance: 'reported', value: reportedCostMicrousd };
|
|
84
|
+
}
|
|
85
|
+
else if (usage.inputTokens.provenance === 'reported' &&
|
|
86
|
+
usage.outputTokens.provenance === 'reported' &&
|
|
87
|
+
hasPositiveModelCost(modelCost)) {
|
|
88
|
+
usage.costMicrousd = estimateOpenAiCost(usage.inputTokens.value, cachedTokens, usage.outputTokens.value, modelCost);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (admission.ok) {
|
|
92
|
+
for (const [, entry] of [...calls.entries()].sort((a, b) => a[0] - b[0])) {
|
|
93
|
+
toolCalls.push({ id: entry.id, name: entry.name, argumentsDigest: toolArgumentsDigest(parseBoundedJson(entry.arguments || '{}', { nodes: 262144, array: 4096 })) });
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return result();
|
|
97
|
+
}
|
|
98
|
+
function inspectOpenAiResponses(bytes, source, status, admission, modelCost) {
|
|
99
|
+
let termination = 'unknown';
|
|
100
|
+
let rawStop = null;
|
|
101
|
+
const usage = { inputTokens: unknown(), outputTokens: unknown(), costMicrousd: unknown() };
|
|
102
|
+
const toolCalls = [];
|
|
103
|
+
const result = () => ({ termination, rawStop, responseDigest: digest(bytes), usage, admission, toolCalls });
|
|
104
|
+
if (status !== 200) {
|
|
105
|
+
const parsed = parseBoundedJson(source);
|
|
106
|
+
if (parsed && typeof parsed.error === 'object' && parsed.error !== null && [400, 401, 403, 404, 429].includes(status)) {
|
|
107
|
+
termination = 'confirmed';
|
|
108
|
+
}
|
|
109
|
+
return result();
|
|
110
|
+
}
|
|
111
|
+
const normalized = source.replace(/\r\n/g, '\n');
|
|
112
|
+
if (!normalized.endsWith('\n\n'))
|
|
113
|
+
return result();
|
|
114
|
+
for (const frame of normalized.split('\n\n').filter(Boolean)) {
|
|
115
|
+
const dataLine = frame.split('\n').find(line => line.startsWith('data: '));
|
|
116
|
+
if (!dataLine)
|
|
117
|
+
continue;
|
|
118
|
+
const payload = dataLine.slice(6).trim();
|
|
119
|
+
if (payload === '[DONE]')
|
|
120
|
+
continue;
|
|
121
|
+
const item = parseBoundedJson(payload, { nodes: 262144, array: 4096 });
|
|
122
|
+
if (item.type === 'response.completed' || item.type === 'response.incomplete' || item.type === 'response.failed') {
|
|
123
|
+
rawStop = item.response?.status ?? item.type;
|
|
124
|
+
if (admission.ok || admission.terminalComplete === true) {
|
|
125
|
+
termination = 'confirmed';
|
|
126
|
+
const respUsage = item.response?.usage;
|
|
127
|
+
if (number(respUsage?.input_tokens))
|
|
128
|
+
usage.inputTokens = { provenance: 'reported', value: respUsage.input_tokens };
|
|
129
|
+
if (number(respUsage?.output_tokens))
|
|
130
|
+
usage.outputTokens = { provenance: 'reported', value: respUsage.output_tokens };
|
|
131
|
+
if (number(respUsage?.cost_microusd)) {
|
|
132
|
+
usage.costMicrousd = { provenance: 'reported', value: respUsage.cost_microusd };
|
|
133
|
+
}
|
|
134
|
+
else if (usage.inputTokens.provenance === 'reported' &&
|
|
135
|
+
usage.outputTokens.provenance === 'reported' &&
|
|
136
|
+
hasPositiveModelCost(modelCost)) {
|
|
137
|
+
const details = respUsage?.input_tokens_details;
|
|
138
|
+
const cachedTokens = details && typeof details === 'object' && !Array.isArray(details) && number(details.cached_tokens)
|
|
139
|
+
? details.cached_tokens
|
|
140
|
+
: 0;
|
|
141
|
+
usage.costMicrousd = estimateOpenAiCost(usage.inputTokens.value, cachedTokens, usage.outputTokens.value, modelCost);
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
if (admission.ok && item.type === 'response.completed') {
|
|
145
|
+
for (const out of item.response?.output ?? []) {
|
|
146
|
+
if (out.type === 'function_call') {
|
|
147
|
+
toolCalls.push({
|
|
148
|
+
id: out.call_id ?? out.id ?? '',
|
|
149
|
+
name: out.name ?? '',
|
|
150
|
+
argumentsDigest: toolArgumentsDigest(parseBoundedJson(out.arguments || '{}', { nodes: 262144, array: 4096 })),
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
return result();
|
|
158
|
+
}
|
|
159
|
+
export function inspectRawResponse(bytes, status, model, api = 'anthropic-messages', strictModelMatch = true, modelCost) {
|
|
160
|
+
let admission = evaluateRawResponse(bytes, status, api);
|
|
161
|
+
let termination = 'unknown', rawStop = null;
|
|
162
|
+
const usage = { inputTokens: unknown(), outputTokens: unknown(), costMicrousd: unknown() };
|
|
163
|
+
const toolCalls = [], result = () => ({ termination, rawStop, responseDigest: digest(bytes), usage, admission, toolCalls });
|
|
164
|
+
try {
|
|
165
|
+
if (bytes.byteLength > 67108864)
|
|
166
|
+
return result();
|
|
167
|
+
const source = new TextDecoder('utf-8', { fatal: true, ignoreBOM: true }).decode(bytes);
|
|
168
|
+
if (api === 'openai-completions')
|
|
169
|
+
return inspectOpenAiCompletions(bytes, source, status, admission, modelCost);
|
|
170
|
+
if (api === 'openai-responses')
|
|
171
|
+
return inspectOpenAiResponses(bytes, source, status, admission, modelCost);
|
|
172
|
+
if (status !== 200) {
|
|
173
|
+
const error = parseBoundedJson(source);
|
|
174
|
+
const expected = { 400: 'invalid_request_error', 401: 'authentication_error', 403: 'permission_error', 404: 'not_found_error', 429: 'rate_limit_error' };
|
|
175
|
+
if (error?.type === 'error' && error.error?.type === expected[status] && expected[status])
|
|
176
|
+
termination = 'confirmed';
|
|
177
|
+
return result();
|
|
178
|
+
}
|
|
179
|
+
const normalized = source.replace(/\r\n/g, '\n');
|
|
180
|
+
if (!normalized.endsWith('\n\n'))
|
|
181
|
+
return result();
|
|
182
|
+
const final = Object.create(null);
|
|
183
|
+
let started = false, stopped = false, deltas = 0, malformed = false, finalOutput = false;
|
|
184
|
+
const blocks = new Map();
|
|
185
|
+
const update = (value, finalDelta) => {
|
|
186
|
+
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
187
|
+
malformed = true;
|
|
188
|
+
return;
|
|
189
|
+
}
|
|
190
|
+
const counts = value;
|
|
191
|
+
for (const field of ['input_tokens', 'cache_read_input_tokens', 'cache_creation_input_tokens', 'output_tokens']) {
|
|
192
|
+
if (Object.hasOwn(counts, field)) {
|
|
193
|
+
final[field] = counts[field];
|
|
194
|
+
if (!number(counts[field]))
|
|
195
|
+
malformed = true;
|
|
196
|
+
if (finalDelta && field === 'output_tokens')
|
|
197
|
+
finalOutput = true;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
if (Object.hasOwn(counts, 'cost_microusd')) {
|
|
201
|
+
if (number(counts.cost_microusd))
|
|
202
|
+
final.cost_microusd = counts.cost_microusd;
|
|
203
|
+
else
|
|
204
|
+
malformed = true;
|
|
205
|
+
}
|
|
206
|
+
if (counts.cache_creation && typeof counts.cache_creation === 'object') {
|
|
207
|
+
const breakdown = counts.cache_creation, a = breakdown.ephemeral_5m_input_tokens, b = breakdown.ephemeral_1h_input_tokens;
|
|
208
|
+
if (a !== undefined && !number(a) || b !== undefined && !number(b) || number(a) && number(b) && number(counts.cache_creation_input_tokens) && a + b !== counts.cache_creation_input_tokens)
|
|
209
|
+
malformed = true;
|
|
210
|
+
}
|
|
211
|
+
};
|
|
212
|
+
for (const frame of normalized.split('\n\n').filter(Boolean)) {
|
|
213
|
+
if (Buffer.byteLength(frame) > 16777216 || stopped)
|
|
214
|
+
throw new Error('unsupported frame');
|
|
215
|
+
const lines = frame.split('\n');
|
|
216
|
+
if (lines.length !== 2 || !lines[0].startsWith('event: ') || !lines[1].startsWith('data: '))
|
|
217
|
+
throw new Error('unsupported frame');
|
|
218
|
+
const event = parseBoundedJson(lines[1].slice(6), { nodes: 262144, array: 4096 });
|
|
219
|
+
if (!event || event.type !== lines[0].slice(7))
|
|
220
|
+
throw new Error('event mismatch');
|
|
221
|
+
if (event.type === 'message_start') {
|
|
222
|
+
if (started)
|
|
223
|
+
throw new Error('duplicate start');
|
|
224
|
+
started = true;
|
|
225
|
+
const message = event.message;
|
|
226
|
+
const modelMatches = strictModelMatch ? message?.model === model : typeof message?.model === 'string' && (message.model === model || message.model.startsWith(model + '-'));
|
|
227
|
+
if (!modelMatches || message.role !== 'assistant' || !Array.isArray(message.content) || message.content.length)
|
|
228
|
+
throw new Error('response identity');
|
|
229
|
+
update(message.usage, false);
|
|
230
|
+
}
|
|
231
|
+
else if (event.type === 'message_delta') {
|
|
232
|
+
if (!started || ++deltas !== 1)
|
|
233
|
+
throw new Error('delta');
|
|
234
|
+
rawStop = event.delta?.stop_reason;
|
|
235
|
+
if (typeof rawStop !== 'string')
|
|
236
|
+
throw new Error('stop');
|
|
237
|
+
update(event.usage, true);
|
|
238
|
+
}
|
|
239
|
+
else if (event.type === 'message_stop') {
|
|
240
|
+
if (!started || deltas !== 1)
|
|
241
|
+
throw new Error('stop ordering');
|
|
242
|
+
stopped = true;
|
|
243
|
+
}
|
|
244
|
+
else if (event.type === 'content_block_start') {
|
|
245
|
+
const block = event.content_block;
|
|
246
|
+
if (block?.type === 'tool_use') {
|
|
247
|
+
if (typeof block.id !== 'string' || typeof block.name !== 'string' || !number(event.index) || blocks.has(event.index))
|
|
248
|
+
throw new Error('tool identity');
|
|
249
|
+
blocks.set(event.index, { id: block.id, name: block.name, arguments: '' });
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
else if (event.type === 'content_block_delta') {
|
|
253
|
+
const delta = event.delta;
|
|
254
|
+
if (delta?.type === 'input_json_delta') {
|
|
255
|
+
const block = blocks.get(event.index);
|
|
256
|
+
if (!block || typeof delta.partial_json !== 'string')
|
|
257
|
+
throw new Error('tool arguments');
|
|
258
|
+
block.arguments += delta.partial_json;
|
|
259
|
+
if (Buffer.byteLength(block.arguments) > 4194304)
|
|
260
|
+
throw new Error('arguments limit');
|
|
261
|
+
}
|
|
262
|
+
}
|
|
263
|
+
else if (!['content_block_stop', 'ping'].includes(event.type))
|
|
264
|
+
throw new Error('unknown event');
|
|
265
|
+
}
|
|
266
|
+
const knownStops = ['end_turn', 'tool_use', 'max_tokens', 'model_context_window_exceeded', 'pause_turn', 'stop_sequence', 'refusal', 'sensitive'];
|
|
267
|
+
if (stopped && rawStop && knownStops.includes(rawStop) && (admission.ok || admission.terminalComplete === true))
|
|
268
|
+
termination = 'confirmed';
|
|
269
|
+
if (termination === 'confirmed' && !malformed) {
|
|
270
|
+
const fields = ['input_tokens', 'cache_read_input_tokens', 'cache_creation_input_tokens'];
|
|
271
|
+
if (fields.every(field => number(final[field]))) {
|
|
272
|
+
const sum = fields.reduce((total, field) => total + final[field], 0);
|
|
273
|
+
if (Number.isSafeInteger(sum))
|
|
274
|
+
usage.inputTokens = { provenance: 'reported', value: sum };
|
|
275
|
+
}
|
|
276
|
+
if (finalOutput && number(final.output_tokens))
|
|
277
|
+
usage.outputTokens = { provenance: 'reported', value: final.output_tokens };
|
|
278
|
+
if (number(final.cost_microusd)) {
|
|
279
|
+
usage.costMicrousd = { provenance: 'reported', value: final.cost_microusd };
|
|
280
|
+
}
|
|
281
|
+
else if (usage.inputTokens.provenance === 'reported' &&
|
|
282
|
+
usage.outputTokens.provenance === 'reported' &&
|
|
283
|
+
hasPositiveModelCost(modelCost)) {
|
|
284
|
+
const uncachedInput = final.input_tokens;
|
|
285
|
+
const cacheRead = final.cache_read_input_tokens;
|
|
286
|
+
const cacheWrite = final.cache_creation_input_tokens;
|
|
287
|
+
const outputTokens = final.output_tokens;
|
|
288
|
+
const cacheReadRate = modelCost.cacheRead ?? modelCost.input;
|
|
289
|
+
const cacheWriteRate = modelCost.cacheWrite ?? modelCost.input;
|
|
290
|
+
const estimated = Math.round(uncachedInput * modelCost.input +
|
|
291
|
+
cacheRead * cacheReadRate +
|
|
292
|
+
cacheWrite * cacheWriteRate +
|
|
293
|
+
outputTokens * modelCost.output);
|
|
294
|
+
if (Number.isSafeInteger(estimated) && estimated >= 0) {
|
|
295
|
+
usage.costMicrousd = { provenance: 'estimated', value: estimated };
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
if (malformed)
|
|
300
|
+
admission = { ok: false, code: 'MODEL_FAILED' };
|
|
301
|
+
if (admission.ok)
|
|
302
|
+
for (const block of blocks.values())
|
|
303
|
+
toolCalls.push({ id: block.id, name: block.name, argumentsDigest: toolArgumentsDigest(parseBoundedJson(block.arguments || '{}')) });
|
|
304
|
+
return result();
|
|
305
|
+
}
|
|
306
|
+
catch {
|
|
307
|
+
admission = { ok: false, code: 'MODEL_FAILED' };
|
|
308
|
+
termination = 'unknown';
|
|
309
|
+
usage.inputTokens = unknown();
|
|
310
|
+
usage.outputTokens = unknown();
|
|
311
|
+
usage.costMicrousd = unknown();
|
|
312
|
+
return result();
|
|
313
|
+
}
|
|
314
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export declare const WORKSPACE_TOOL: Readonly<{
|
|
2
|
+
name: "read_file";
|
|
3
|
+
description: "Read one bounded regular UTF-8 candidate file. No symlinks or host paths.";
|
|
4
|
+
inputSchema: {
|
|
5
|
+
type: string;
|
|
6
|
+
properties: {
|
|
7
|
+
path: {
|
|
8
|
+
type: string;
|
|
9
|
+
};
|
|
10
|
+
};
|
|
11
|
+
required: string[];
|
|
12
|
+
additionalProperties: boolean;
|
|
13
|
+
};
|
|
14
|
+
annotations: {
|
|
15
|
+
readOnlyHint: boolean;
|
|
16
|
+
destructiveHint: boolean;
|
|
17
|
+
idempotentHint: boolean;
|
|
18
|
+
openWorldHint: boolean;
|
|
19
|
+
};
|
|
20
|
+
}>;
|
|
21
|
+
export declare function readWorkspace(root: string, path: string, maxBytes: number): Promise<string>;
|
|
22
|
+
/** Constructor injection is used only by separate qualification entrypoints, never by policy JSON. */
|
|
23
|
+
export interface WorkspaceServerPorts {
|
|
24
|
+
readonly call?: (name: string, args: Record<string, unknown>, progress: (value: unknown) => Promise<void>) => Promise<unknown>;
|
|
25
|
+
readonly tools?: readonly unknown[];
|
|
26
|
+
}
|
|
27
|
+
export declare function runWorkspaceServer(ports?: WorkspaceServerPorts): void;
|