@gpustack/loopwright 0.0.0-stage → 0.0.3
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 +2094 -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 +1648 -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 +2642 -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 +7335 -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 +3025 -0
- package/package-lock.json +3025 -0
- package/package.json +52 -4
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import { type JsonRpcMessage } from '@earendil-works/pi-mcp';
|
|
3
|
+
import type { McpDispatchContext, McpProcessPort } from './mcp-process.js';
|
|
4
|
+
import type { PiHost, PiOpenInput } from './types.js';
|
|
5
|
+
import type { HttpMcpPolicy, PiErrorV2, PiHostV2 } from './types-v2.js';
|
|
6
|
+
/** Private qualification ports. Public factories supply no trust/connection override. */
|
|
7
|
+
export interface HttpMcpPorts {
|
|
8
|
+
readonly ca?: readonly string[];
|
|
9
|
+
readonly selectAddress?: (approved: readonly string[]) => string;
|
|
10
|
+
readonly observeDial?: (address: string) => void;
|
|
11
|
+
readonly beforeWrite?: (context: McpDispatchContext) => void;
|
|
12
|
+
readonly observePeer?: (actual: string | undefined) => string | undefined;
|
|
13
|
+
}
|
|
14
|
+
export declare class HttpMcpFailure extends Error {
|
|
15
|
+
readonly detail: PiErrorV2;
|
|
16
|
+
readonly authStatus: number | null;
|
|
17
|
+
constructor(detail: PiErrorV2, authStatus?: number | null);
|
|
18
|
+
}
|
|
19
|
+
/** The native HTTP transport is host-side; the SDK still uses its real owner-mediated MCP client. */
|
|
20
|
+
export declare class HttpMcpProcess extends EventEmitter implements McpProcessPort {
|
|
21
|
+
#private;
|
|
22
|
+
readonly host: PiHost;
|
|
23
|
+
readonly input: PiOpenInput;
|
|
24
|
+
readonly policy: HttpMcpPolicy;
|
|
25
|
+
readonly resolveCredential: PiHostV2['resolveMcpCredential'];
|
|
26
|
+
readonly onFailure: (error: PiErrorV2) => void;
|
|
27
|
+
readonly ports: HttpMcpPorts;
|
|
28
|
+
constructor(host: PiHost, input: PiOpenInput, policy: HttpMcpPolicy, resolveCredential: PiHostV2['resolveMcpCredential'], onFailure: (error: PiErrorV2) => void, ports?: HttpMcpPorts);
|
|
29
|
+
ready(signal: AbortSignal): Promise<void>;
|
|
30
|
+
send(message: JsonRpcMessage, guard: () => void, context?: McpDispatchContext): Promise<void>;
|
|
31
|
+
close(): Promise<null>;
|
|
32
|
+
}
|
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import http from 'node:http';
|
|
3
|
+
import https from 'node:https';
|
|
4
|
+
import { checkServerIdentity, rootCertificates } from 'node:tls';
|
|
5
|
+
import { isIP } from 'node:net';
|
|
6
|
+
import { randomBytes } from 'node:crypto';
|
|
7
|
+
import { StreamableHttpTransport, parseJsonRpcMessage } from '@earendil-works/pi-mcp';
|
|
8
|
+
import { canonical, digest, object } from './boundary.js';
|
|
9
|
+
import { parseBoundedJson } from './context.js';
|
|
10
|
+
import { stateValue } from './admission.js';
|
|
11
|
+
import { guardLocalOperation, recordLocalOperation } from './operation.js';
|
|
12
|
+
import { sameIdentity } from './policy.js';
|
|
13
|
+
import { validateHttpEndpoint } from './policy-v2.js';
|
|
14
|
+
import { WORKSPACE_TOOL } from './workspace-mcp.js';
|
|
15
|
+
import { PiFailure } from './errors.js';
|
|
16
|
+
export class HttpMcpFailure extends Error {
|
|
17
|
+
detail;
|
|
18
|
+
authStatus;
|
|
19
|
+
constructor(detail, authStatus = null) {
|
|
20
|
+
super(detail.code);
|
|
21
|
+
this.detail = detail;
|
|
22
|
+
this.authStatus = authStatus;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
function failure(code, effect = 'possible', authStatus = null) {
|
|
26
|
+
return new HttpMcpFailure({ code, path: '/policy/mcp', phase: 'tool', retryable: false, effect,
|
|
27
|
+
requestId: null, operationId: null, stateErrorCode: null }, authStatus);
|
|
28
|
+
}
|
|
29
|
+
const key = (value) => 'id' in value ? typeof value.id + ':' + String(value.id) : 'notification:' + value.method;
|
|
30
|
+
/** The native HTTP transport is host-side; the SDK still uses its real owner-mediated MCP client. */
|
|
31
|
+
export class HttpMcpProcess extends EventEmitter {
|
|
32
|
+
host;
|
|
33
|
+
input;
|
|
34
|
+
policy;
|
|
35
|
+
resolveCredential;
|
|
36
|
+
onFailure;
|
|
37
|
+
ports;
|
|
38
|
+
#transport;
|
|
39
|
+
#pending = new Map();
|
|
40
|
+
#used = new Set();
|
|
41
|
+
#sending = new Set();
|
|
42
|
+
#connections = new Set();
|
|
43
|
+
#abort = new AbortController();
|
|
44
|
+
#instance = randomBytes(16).toString('hex');
|
|
45
|
+
#tail = Promise.resolve();
|
|
46
|
+
#closed = false;
|
|
47
|
+
#failed = false;
|
|
48
|
+
#closing = null;
|
|
49
|
+
constructor(host, input, policy, resolveCredential, onFailure, ports = {}) {
|
|
50
|
+
super();
|
|
51
|
+
this.host = host;
|
|
52
|
+
this.input = input;
|
|
53
|
+
this.policy = policy;
|
|
54
|
+
this.resolveCredential = resolveCredential;
|
|
55
|
+
this.onFailure = onFailure;
|
|
56
|
+
this.ports = ports;
|
|
57
|
+
validateHttpEndpoint(policy.endpoint, policy.approvedAddresses);
|
|
58
|
+
this.#transport = new StreamableHttpTransport({ url: policy.endpoint, openGetStream: false, maxMessageBytes: 65536,
|
|
59
|
+
reconnect: { maxRetries: 0 }, fetch: (url, options) => this.#fetch(url, options) });
|
|
60
|
+
this.#transport.onMessage(message => {
|
|
61
|
+
const exchange = this.#pending.get(key(message));
|
|
62
|
+
if (!exchange || exchange.received || !exchange.posted) {
|
|
63
|
+
this.#fault(failure('MCP_FAILED'));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
exchange.received = true;
|
|
67
|
+
exchange.delivery = this.#receive(message, exchange);
|
|
68
|
+
void exchange.delivery.catch(error => this.#fault(error));
|
|
69
|
+
});
|
|
70
|
+
this.#transport.onError(error => this.#fault(error));
|
|
71
|
+
}
|
|
72
|
+
#fault(error) {
|
|
73
|
+
if (this.#closed || this.#failed)
|
|
74
|
+
return;
|
|
75
|
+
this.#failed = true;
|
|
76
|
+
this.onFailure(error instanceof HttpMcpFailure ? error.detail : failure('MCP_FAILED').detail);
|
|
77
|
+
}
|
|
78
|
+
async ready(signal) { signal.throwIfAborted(); if (this.#closed || this.#failed)
|
|
79
|
+
throw failure('MCP_FAILED'); await this.#transport.start(); }
|
|
80
|
+
#check(exchange) {
|
|
81
|
+
if (this.#closed || this.#failed || exchange.signal.aborted)
|
|
82
|
+
throw failure('CANCELLED', exchange.posted ? 'possible' : 'none');
|
|
83
|
+
exchange.context.assertCurrent();
|
|
84
|
+
guardLocalOperation(this.host, exchange.operation, exchange.permit, exchange.signal, this.#closed);
|
|
85
|
+
if (exchange.operation.intent.effect !== 'read_only' || exchange.operation.intent.nodeId !== this.input.stepId)
|
|
86
|
+
throw failure('TOOL_DENIED', 'none');
|
|
87
|
+
const identity = exchange.context.identity;
|
|
88
|
+
if (!identity) {
|
|
89
|
+
if (!exchange.management || exchange.operation.intent.targetIdentity !== this.policy.endpoint)
|
|
90
|
+
throw failure('TOOL_DENIED', 'none');
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
if (identity.name !== 'mcp__workspace__read_file' || !this.policy.names.includes(identity.name) || !exchange.context.before)
|
|
94
|
+
throw failure('TOOL_DENIED', 'none');
|
|
95
|
+
if (exchange.operation.intent.targetIdentity !== 'candidate:' + exchange.context.before.name)
|
|
96
|
+
throw failure('TOOL_DENIED', 'none');
|
|
97
|
+
const parent = stateValue(this.host.store.getRequest(identity.parentRequestId), 'tool');
|
|
98
|
+
if (parent.state !== 'observed' || parent.initialObservation?.termination !== 'confirmed' || parent.initialObservation.outcome !== 'succeeded'
|
|
99
|
+
|| parent.admission.roleId !== this.input.roleId || parent.admission.nodeId !== this.input.stepId)
|
|
100
|
+
throw failure('TOOL_DENIED', 'none');
|
|
101
|
+
const expected = digest(Buffer.from('loopwright.dev/pi-mcp/v1\0' + canonical({ identity: { ...identity, slot: digest(Buffer.from(identity.slot)) },
|
|
102
|
+
wire: exchange.message, before: exchange.context.before, policy: digest(Buffer.from(canonical(this.input.policy))), runtime: this.input.policy.runtime, lock: this.input.lock.spec.lockHash })));
|
|
103
|
+
if (!sameIdentity(exchange.operation.intent.requestDigest, expected))
|
|
104
|
+
throw failure('PAYLOAD_MISMATCH', 'none');
|
|
105
|
+
}
|
|
106
|
+
send(message, guard, context) {
|
|
107
|
+
const work = this.#tail.then(() => this.#send(message, guard, context));
|
|
108
|
+
this.#tail = work.catch(() => { });
|
|
109
|
+
this.#sending.add(work);
|
|
110
|
+
void work.then(() => this.#sending.delete(work), () => this.#sending.delete(work));
|
|
111
|
+
return work;
|
|
112
|
+
}
|
|
113
|
+
async #send(message, guard, context) {
|
|
114
|
+
if (!context || this.#closed || this.#failed || this.#pending.size >= 32 || this.#used.size >= this.input.policy.limits.operations
|
|
115
|
+
|| !('method' in message) || !['initialize', 'tools/list', 'tools/call', 'notifications/initialized'].includes(message.method))
|
|
116
|
+
throw failure('MCP_FAILED', 'none');
|
|
117
|
+
const rpcKey = key(message);
|
|
118
|
+
if (this.#used.has(rpcKey))
|
|
119
|
+
throw failure('RECOVERY_REQUIRED', 'none');
|
|
120
|
+
this.#used.add(rpcKey);
|
|
121
|
+
context.assertCurrent();
|
|
122
|
+
const management = message.method !== 'tools/call';
|
|
123
|
+
let operation = context.operation, permit = context.permit;
|
|
124
|
+
if (management) {
|
|
125
|
+
if (context.identity || operation || permit)
|
|
126
|
+
throw failure('TOOL_DENIED', 'none');
|
|
127
|
+
const operationId = 'mcp-http-' + digest(Buffer.from(canonical({ instance: this.#instance, session: this.input.sessionId, message }))).hex.slice(0, 40);
|
|
128
|
+
const intent = { operationId, nodeId: this.input.stepId, attemptId: 'mcp-http-' + this.#instance, effect: 'read_only',
|
|
129
|
+
requestDigest: digest(Buffer.from(canonical({ message, policy: this.policy, lock: this.input.lock.spec.lockHash }))), targetIdentity: this.policy.endpoint };
|
|
130
|
+
const created = stateValue(this.host.store.putIntent(this.host.authority, intent), 'tool');
|
|
131
|
+
if (created.kind !== 'created')
|
|
132
|
+
throw failure('RECOVERY_REQUIRED', 'none');
|
|
133
|
+
const granted = stateValue(this.host.store.authorizeOperationDispatch(this.host.authority, operationId), 'tool');
|
|
134
|
+
if (granted.kind !== 'new_dispatch')
|
|
135
|
+
throw failure('RECOVERY_REQUIRED', 'none');
|
|
136
|
+
operation = granted.record;
|
|
137
|
+
permit = granted.permit;
|
|
138
|
+
}
|
|
139
|
+
if (!operation || !permit)
|
|
140
|
+
throw failure('TOOL_DENIED', 'none');
|
|
141
|
+
const signal = AbortSignal.any([context.signal, this.#abort.signal, AbortSignal.timeout(this.policy.absoluteTimeoutSeconds * 1000)]);
|
|
142
|
+
const exchange = { message, context, guard, operation, permit, management, signal, posted: false, received: false, recorded: false, delivery: null };
|
|
143
|
+
this.#pending.set(rpcKey, exchange);
|
|
144
|
+
try {
|
|
145
|
+
this.#check(exchange);
|
|
146
|
+
await this.#transport.send(message, { signal });
|
|
147
|
+
if (exchange.delivery)
|
|
148
|
+
await exchange.delivery;
|
|
149
|
+
if (!('id' in message)) {
|
|
150
|
+
await recordLocalOperation(this.host, operation, 'succeeded', { transport: 'sessionless-http-json-v1', method: message.method, endpoint: this.policy.endpoint });
|
|
151
|
+
exchange.recorded = true;
|
|
152
|
+
}
|
|
153
|
+
else if (!exchange.received)
|
|
154
|
+
throw failure('MCP_FAILED');
|
|
155
|
+
}
|
|
156
|
+
catch (error) {
|
|
157
|
+
const detail = error instanceof HttpMcpFailure ? error : error instanceof PiFailure ? new HttpMcpFailure(error.detail) : failure(signal.aborted ? 'CANCELLED' : 'MCP_FAILED', exchange.posted ? 'possible' : 'none');
|
|
158
|
+
this.onFailure(detail.detail);
|
|
159
|
+
if (!exchange.recorded) {
|
|
160
|
+
if (detail.authStatus !== null && 'id' in message && !management) {
|
|
161
|
+
await context.receive({ jsonrpc: '2.0', id: message.id, error: { code: -32001, message: 'MCP_AUTHENTICATION_REQUIRED' } });
|
|
162
|
+
exchange.recorded = true;
|
|
163
|
+
}
|
|
164
|
+
else if (!exchange.posted || detail.authStatus !== null) {
|
|
165
|
+
await recordLocalOperation(this.host, operation, exchange.posted ? 'failed' : 'not_executed', { transport: 'sessionless-http-json-v1', code: detail.detail.code, status: detail.authStatus });
|
|
166
|
+
exchange.recorded = true;
|
|
167
|
+
}
|
|
168
|
+
else
|
|
169
|
+
this.host.store.markOperationUnresolved(this.host.authority, operation.intent.operationId, signal.aborted ? 'cancellation' : 'connection_lost');
|
|
170
|
+
}
|
|
171
|
+
this.#failed = true;
|
|
172
|
+
this.#abort.abort();
|
|
173
|
+
throw detail;
|
|
174
|
+
}
|
|
175
|
+
finally {
|
|
176
|
+
this.#pending.delete(rpcKey);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
async #receive(message, exchange) {
|
|
180
|
+
if ('method' in message)
|
|
181
|
+
throw failure('MCP_TRANSPORT_UNSUPPORTED');
|
|
182
|
+
if ('result' in message && 'method' in exchange.message) {
|
|
183
|
+
if (exchange.message.method === 'initialize') {
|
|
184
|
+
const init = object(message.result, ['protocolVersion', 'capabilities', 'serverInfo']);
|
|
185
|
+
if (init.protocolVersion !== '2025-06-18' || canonical(init.capabilities) !== '{"tools":{}}')
|
|
186
|
+
throw failure('MCP_TRANSPORT_UNSUPPORTED');
|
|
187
|
+
const info = object(init.serverInfo, ['name', 'version']);
|
|
188
|
+
if (typeof info.name !== 'string' || info.name.length > 64 || typeof info.version !== 'string' || info.version.length > 32)
|
|
189
|
+
throw failure('MCP_FAILED');
|
|
190
|
+
this.#transport.setProtocolVersion(init.protocolVersion);
|
|
191
|
+
}
|
|
192
|
+
if (exchange.message.method === 'tools/list' && canonical(message.result) !== canonical({ tools: [WORKSPACE_TOOL] }))
|
|
193
|
+
throw failure('MCP_TRANSPORT_UNSUPPORTED');
|
|
194
|
+
}
|
|
195
|
+
if (exchange.management) {
|
|
196
|
+
await recordLocalOperation(this.host, exchange.operation, 'error' in message ? 'failed' : 'succeeded', {
|
|
197
|
+
transport: 'sessionless-http-json-v1', endpoint: this.policy.endpoint, resultDigest: digest(Buffer.from(canonical(message))),
|
|
198
|
+
});
|
|
199
|
+
exchange.recorded = true;
|
|
200
|
+
}
|
|
201
|
+
await exchange.context.receive(message);
|
|
202
|
+
if (!exchange.management)
|
|
203
|
+
exchange.recorded = true;
|
|
204
|
+
}
|
|
205
|
+
async #token(exchange) {
|
|
206
|
+
this.#check(exchange);
|
|
207
|
+
const parent = exchange.context.identity ? stateValue(this.host.store.getRequest(exchange.context.identity.parentRequestId), 'tool') : null;
|
|
208
|
+
const signal = AbortSignal.any([exchange.signal, AbortSignal.timeout(1000)]);
|
|
209
|
+
signal.throwIfAborted();
|
|
210
|
+
const binding = { serverId: 'workspace', transport: this.policy.transport, destinationRef: this.policy.destinationRef,
|
|
211
|
+
endpoint: this.policy.endpoint, method: 'POST', credentialRef: this.policy.credentialRef, runId: this.input.lock.spec.runId, roleId: this.input.roleId,
|
|
212
|
+
stepId: this.input.stepId, purpose: parent?.admission.purpose ?? null, parentRequestId: parent?.admission.requestId ?? null,
|
|
213
|
+
managementOperationId: exchange.management ? exchange.operation.intent.operationId : null, notAfterMonotonicMs: exchange.permit.notAfterMonotonicMs, signal };
|
|
214
|
+
const value = await new Promise((resolve, reject) => {
|
|
215
|
+
const abort = () => reject(failure('MCP_AUTHENTICATION_REQUIRED', 'none'));
|
|
216
|
+
signal.addEventListener('abort', abort, { once: true });
|
|
217
|
+
Promise.resolve().then(() => this.resolveCredential(binding)).then(resolve, () => reject(failure('MCP_AUTHENTICATION_REQUIRED', 'none'))).finally(() => signal.removeEventListener('abort', abort));
|
|
218
|
+
});
|
|
219
|
+
signal.throwIfAborted();
|
|
220
|
+
this.#check(exchange);
|
|
221
|
+
const fields = object(value, ['bearerToken']);
|
|
222
|
+
if (typeof fields.bearerToken !== 'string' || fields.bearerToken.length > 4096 || !/^[A-Za-z0-9._~+/-]+=*$/.test(fields.bearerToken))
|
|
223
|
+
throw failure('MCP_AUTHENTICATION_REQUIRED', 'none');
|
|
224
|
+
return fields.bearerToken;
|
|
225
|
+
}
|
|
226
|
+
async #fetch(url, options) {
|
|
227
|
+
const target = url instanceof Request ? url.url : String(url);
|
|
228
|
+
if (target !== this.policy.endpoint || options?.method !== 'POST' || typeof options.body !== 'string' || Buffer.byteLength(options.body) > 65536)
|
|
229
|
+
throw failure('MCP_TRANSPORT_UNSUPPORTED', 'none');
|
|
230
|
+
const body = Buffer.from(options.body), message = parseJsonRpcMessage(parseBoundedJson(body.toString()));
|
|
231
|
+
const exchange = this.#pending.get(key(message));
|
|
232
|
+
if (!exchange || canonical(message) !== canonical(exchange.message) || exchange.posted)
|
|
233
|
+
throw failure('PAYLOAD_MISMATCH', 'none');
|
|
234
|
+
const endpoint = validateHttpEndpoint(target, this.policy.approvedAddresses);
|
|
235
|
+
const address = this.ports.selectAddress?.(this.policy.approvedAddresses) ?? this.policy.approvedAddresses[0];
|
|
236
|
+
if (!this.policy.approvedAddresses.includes(address))
|
|
237
|
+
throw failure('TOOL_DENIED', 'none');
|
|
238
|
+
const token = await this.#token(exchange);
|
|
239
|
+
const headers = new Headers(options.headers);
|
|
240
|
+
for (const [name, value] of headers)
|
|
241
|
+
if (!['accept', 'content-type', 'mcp-protocol-version'].includes(name) || /[\r\n]/.test(value))
|
|
242
|
+
throw failure('MCP_TRANSPORT_UNSUPPORTED', 'none');
|
|
243
|
+
this.#check(exchange);
|
|
244
|
+
const signal = AbortSignal.any([exchange.signal, ...(options.signal ? [options.signal] : [])]);
|
|
245
|
+
return this.#request(endpoint, address, headers, body, token, signal, exchange);
|
|
246
|
+
}
|
|
247
|
+
#request(endpoint, address, headers, body, token, signal, exchange) {
|
|
248
|
+
return new Promise((resolve, reject) => {
|
|
249
|
+
this.ports.observeDial?.(address);
|
|
250
|
+
let ended = false, idle;
|
|
251
|
+
const fail = (error) => { if (ended)
|
|
252
|
+
return; ended = true; clearTimeout(idle); request.destroy(); reject(error instanceof HttpMcpFailure ? error : error instanceof PiFailure ? new HttpMcpFailure(error.detail) : failure(signal.aborted ? 'CANCELLED' : 'MCP_FAILED', exchange.posted ? 'possible' : 'none')); };
|
|
253
|
+
const rearm = () => { clearTimeout(idle); idle = setTimeout(() => fail(failure('DEADLINE')), this.policy.idleTimeoutSeconds * 1000); };
|
|
254
|
+
const request = (endpoint.protocol === 'https:' ? https : http).request({ protocol: endpoint.protocol, hostname: endpoint.hostname, port: endpoint.port,
|
|
255
|
+
path: endpoint.pathname, method: 'POST', agent: false, family: isIP(address), maxHeaderSize: 8192, signal,
|
|
256
|
+
lookup: (_hostname, _options, callback) => callback(null, address, isIP(address)), headers: Object.fromEntries(headers),
|
|
257
|
+
...(endpoint.protocol === 'https:' ? { rejectUnauthorized: true, servername: endpoint.hostname, checkServerIdentity,
|
|
258
|
+
ca: this.ports.ca ? [...this.ports.ca] : [...rootCertificates] } : {}) }, response => {
|
|
259
|
+
const status = response.statusCode;
|
|
260
|
+
rearm();
|
|
261
|
+
if (status === 401 || status === 403) {
|
|
262
|
+
response.destroy();
|
|
263
|
+
fail(failure('MCP_AUTHENTICATION_REQUIRED', 'confirmed', status));
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
if (status !== 200 && status !== 202 || response.headers['mcp-session-id'] || response.headers.location
|
|
267
|
+
|| status === 200 && response.headers['content-type']?.split(';')[0]?.trim() !== 'application/json') {
|
|
268
|
+
response.destroy();
|
|
269
|
+
fail(failure('MCP_TRANSPORT_UNSUPPORTED'));
|
|
270
|
+
return;
|
|
271
|
+
}
|
|
272
|
+
const chunks = [];
|
|
273
|
+
let size = 0;
|
|
274
|
+
response.on('data', (part) => { rearm(); if ((size += part.length) > 65536) {
|
|
275
|
+
response.destroy();
|
|
276
|
+
fail(failure('OUTPUT_LIMIT'));
|
|
277
|
+
}
|
|
278
|
+
else
|
|
279
|
+
chunks.push(part); });
|
|
280
|
+
response.on('error', fail);
|
|
281
|
+
response.on('end', () => {
|
|
282
|
+
try {
|
|
283
|
+
if (ended)
|
|
284
|
+
return;
|
|
285
|
+
const bytes = Buffer.concat(chunks, size);
|
|
286
|
+
const decoded = new TextDecoder('utf-8', { fatal: true }).decode(bytes);
|
|
287
|
+
const forms = new Set([token, JSON.stringify(token).slice(1, -1), encodeURIComponent(token), Buffer.from(token).toString('base64')]);
|
|
288
|
+
if ([...forms].some(value => decoded.includes(value))) {
|
|
289
|
+
fail(failure('MCP_FAILED'));
|
|
290
|
+
return;
|
|
291
|
+
}
|
|
292
|
+
if (status === 202 && bytes.length) {
|
|
293
|
+
fail(failure('MCP_TRANSPORT_UNSUPPORTED'));
|
|
294
|
+
return;
|
|
295
|
+
}
|
|
296
|
+
if (status === 200) {
|
|
297
|
+
const parsed = parseJsonRpcMessage(parseBoundedJson(decoded));
|
|
298
|
+
if ('method' in parsed || !('id' in exchange.message) || key(parsed) !== key(exchange.message)) {
|
|
299
|
+
fail(failure('PAYLOAD_MISMATCH'));
|
|
300
|
+
return;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
const reply = new Response(status === 202 ? null : bytes, { status: status, headers: status === 200 ? { 'content-type': 'application/json' } : {} });
|
|
304
|
+
ended = true;
|
|
305
|
+
clearTimeout(idle);
|
|
306
|
+
resolve(reply);
|
|
307
|
+
}
|
|
308
|
+
catch (error) {
|
|
309
|
+
fail(error);
|
|
310
|
+
}
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
const disconnected = new Promise(resolve => request.once('close', resolve));
|
|
314
|
+
this.#connections.add(disconnected);
|
|
315
|
+
void disconnected.then(() => this.#connections.delete(disconnected));
|
|
316
|
+
request.on('error', fail);
|
|
317
|
+
rearm();
|
|
318
|
+
request.once('socket', socket => {
|
|
319
|
+
socket.once(endpoint.protocol === 'https:' ? 'secureConnect' : 'connect', () => {
|
|
320
|
+
try {
|
|
321
|
+
const peer = this.ports.observePeer ? this.ports.observePeer(socket.remoteAddress) : socket.remoteAddress;
|
|
322
|
+
if (!this.policy.approvedAddresses.includes(peer ?? ''))
|
|
323
|
+
throw failure('TOOL_DENIED', 'none');
|
|
324
|
+
this.ports.beforeWrite?.(exchange.context);
|
|
325
|
+
this.#check(exchange);
|
|
326
|
+
exchange.guard();
|
|
327
|
+
request.setHeader('authorization', 'Bearer ' + token);
|
|
328
|
+
exchange.posted = true;
|
|
329
|
+
request.end(body);
|
|
330
|
+
}
|
|
331
|
+
catch (error) {
|
|
332
|
+
fail(error);
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
close() {
|
|
339
|
+
return this.#closing ??= (async () => {
|
|
340
|
+
this.#closed = true;
|
|
341
|
+
this.#abort.abort();
|
|
342
|
+
await this.#transport.close();
|
|
343
|
+
let timer;
|
|
344
|
+
try {
|
|
345
|
+
await Promise.race([Promise.allSettled([...this.#sending, ...this.#connections]), new Promise((_resolve, reject) => { timer = setTimeout(() => reject(failure('CLEANUP_FAILED')), 1000); })]);
|
|
346
|
+
}
|
|
347
|
+
finally {
|
|
348
|
+
clearTimeout(timer);
|
|
349
|
+
}
|
|
350
|
+
return null;
|
|
351
|
+
})();
|
|
352
|
+
}
|
|
353
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { openPiAdapter } from './adapter.js';
|
|
2
|
+
export { openPiAdapterV2 } from './adapter-v2.js';
|
|
3
|
+
export type { AdapterPolicyV2, HttpMcpPolicy, McpCredentialBinding, PiHostV2, PiOpenInputV2, PiErrorV2, PiResultV2, PiOutcomeV2, PiCapabilitiesV2, PiAdapterV2 } from './types-v2.js';
|
|
4
|
+
export { describePiAdapterFiles, type PiAdapterFiles } from './descriptor.js';
|
|
5
|
+
export { decodePiCapture, type PiCaptureDecodeInput, type PiDecodedCapture } from './decode-capture.js';
|
|
6
|
+
export type { CallExternalMcpToolOptions, ConnectHostMcpOptions, ConnectedMcpServerSummary, ExternalMcpHttpServerConfig, ExternalMcpServerConfig, ExternalMcpStdioServerConfig, ExternalMcpToolSchema, } from './external-mcp.js';
|
|
7
|
+
export type { AdapterPolicy, PiAdapter, PiBaselineEntry, PiCandidateArtifactInput, PiCandidateBaseline, PiCandidateBlobArtifact, PiCandidateStreamChecker, PiCapabilities, PiCapture, PiCommand, PiCustomModelCompat, PiCustomProviderConfig, PiError, PiErrorCode, PiEvent, PiContextRecord, PiContextAssessment, PiHost, PiLimits, PiModelCost, PiModelSelection, PiOpenInput, PiOutcome, PiResult, PiSamplingParams, PiThinkingLevel, PiWireApi, ResourceIdentity, RuntimeIdentity, } from './types.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface NativeCompletion {
|
|
2
|
+
readonly agentEnds: number;
|
|
3
|
+
readonly agentSettles: number;
|
|
4
|
+
readonly aborted: boolean;
|
|
5
|
+
readonly compactionEnds: number;
|
|
6
|
+
readonly compacted: boolean;
|
|
7
|
+
readonly idle: boolean;
|
|
8
|
+
readonly invocations: number;
|
|
9
|
+
readonly parserAcks: number;
|
|
10
|
+
readonly pending: number;
|
|
11
|
+
}
|
|
12
|
+
/** The native turn barrier is separate from raw provider termination and manual compaction. */
|
|
13
|
+
export declare function verifyNativeCompletion(value: unknown, kind: 'execute' | 'compact'): void;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { refuse } from './errors.js';
|
|
2
|
+
import { object, integer } from './boundary.js';
|
|
3
|
+
/** The native turn barrier is separate from raw provider termination and manual compaction. */
|
|
4
|
+
export function verifyNativeCompletion(value, kind) {
|
|
5
|
+
const native = object(value, ['agentEnds', 'agentSettles', 'aborted', 'compactionEnds', 'compacted', 'idle', 'invocations', 'parserAcks', 'pending']);
|
|
6
|
+
for (const key of ['agentEnds', 'agentSettles', 'compactionEnds', 'invocations', 'parserAcks', 'pending'])
|
|
7
|
+
integer(native[key], 0, 2048, '/native/' + key);
|
|
8
|
+
if (native.aborted !== false || native.idle !== true || native.pending !== 0 || native.invocations === 0 || native.parserAcks !== native.invocations
|
|
9
|
+
|| typeof native.compacted !== 'boolean' || (kind === 'execute' ? native.agentSettles < 1 : native.compactionEnds !== 1 || native.compacted !== true))
|
|
10
|
+
refuse('RECOVERY_REQUIRED', '', { phase: 'session', effect: 'possible' });
|
|
11
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import { type JsonRpcMessage } from '@earendil-works/pi-mcp';
|
|
3
|
+
import { OwnedContainer, type ContainerExit } from './containers.js';
|
|
4
|
+
import type { PiHost, PiOpenInput } from './types.js';
|
|
5
|
+
import type { ArtifactRef } from '@loopwright/core';
|
|
6
|
+
import type { DispatchPermit, OperationRecord } from '@loopwright/state';
|
|
7
|
+
import type { ToolIdentity } from './tools.js';
|
|
8
|
+
export interface McpDispatchContext {
|
|
9
|
+
readonly identity: (ToolIdentity & {
|
|
10
|
+
readonly parentRequestId: string;
|
|
11
|
+
}) | null;
|
|
12
|
+
readonly operation: OperationRecord | null;
|
|
13
|
+
readonly permit: DispatchPermit | null;
|
|
14
|
+
readonly before: ArtifactRef | null;
|
|
15
|
+
readonly signal: AbortSignal;
|
|
16
|
+
readonly assertCurrent: () => void;
|
|
17
|
+
readonly receive: (message: JsonRpcMessage) => Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
export interface McpProcessPort {
|
|
20
|
+
on(event: 'message', listener: (message: JsonRpcMessage) => void): this;
|
|
21
|
+
on(event: 'failed', listener: () => void): this;
|
|
22
|
+
ready(signal: AbortSignal): Promise<void>;
|
|
23
|
+
send(message: JsonRpcMessage, guard: () => void, context?: McpDispatchContext): Promise<void>;
|
|
24
|
+
close(): Promise<ContainerExit | null>;
|
|
25
|
+
}
|
|
26
|
+
/** Raw stdio JSON-RPC belongs only to the separate, owned, read-only MCP role. */
|
|
27
|
+
export declare class McpProcess extends EventEmitter implements McpProcessPort {
|
|
28
|
+
#private;
|
|
29
|
+
readonly input: PiOpenInput;
|
|
30
|
+
readonly container: OwnedContainer;
|
|
31
|
+
constructor(host: PiHost, input: PiOpenInput, directory: string, candidate: string);
|
|
32
|
+
ready(signal: AbortSignal): Promise<void>;
|
|
33
|
+
send(message: JsonRpcMessage, guard: () => void): Promise<void>;
|
|
34
|
+
close(): Promise<ContainerExit | null>;
|
|
35
|
+
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { EventEmitter } from 'node:events';
|
|
2
|
+
import { parseJsonRpcMessage } from '@earendil-works/pi-mcp';
|
|
3
|
+
import { OwnedContainer } from './containers.js';
|
|
4
|
+
import { canonical } from './boundary.js';
|
|
5
|
+
import { parseBoundedJson } from './context.js';
|
|
6
|
+
import { refuse } from './errors.js';
|
|
7
|
+
/** Raw stdio JSON-RPC belongs only to the separate, owned, read-only MCP role. */
|
|
8
|
+
export class McpProcess extends EventEmitter {
|
|
9
|
+
input;
|
|
10
|
+
container;
|
|
11
|
+
#input = Buffer.alloc(0);
|
|
12
|
+
#closed = false;
|
|
13
|
+
#failed = false;
|
|
14
|
+
#ready = null;
|
|
15
|
+
#child = null;
|
|
16
|
+
#tail = Promise.resolve();
|
|
17
|
+
#pending = 0;
|
|
18
|
+
#queuedBytes = 0;
|
|
19
|
+
constructor(host, input, directory, candidate) {
|
|
20
|
+
super();
|
|
21
|
+
this.input = input;
|
|
22
|
+
this.container = new OwnedContainer(host, input, directory, candidate, 'mcp', 'mcp-workspace');
|
|
23
|
+
}
|
|
24
|
+
#fail() { if (!this.#closed && !this.#failed) {
|
|
25
|
+
this.#failed = true;
|
|
26
|
+
this.emit('failed');
|
|
27
|
+
} }
|
|
28
|
+
ready(signal) {
|
|
29
|
+
if (this.#ready)
|
|
30
|
+
return this.#ready;
|
|
31
|
+
const started = (async () => {
|
|
32
|
+
const child = await this.container.start(signal);
|
|
33
|
+
this.#child = child;
|
|
34
|
+
let stderr = 0;
|
|
35
|
+
child.stderr.on('data', (bytes) => { stderr += bytes.length; if (stderr > this.input.policy.limits.diagnosticBytes)
|
|
36
|
+
this.#fail(); });
|
|
37
|
+
child.once('exit', () => this.#fail());
|
|
38
|
+
child.once('error', () => this.#fail());
|
|
39
|
+
child.stdout.once('end', () => this.#fail());
|
|
40
|
+
child.stdout.once('error', () => this.#fail());
|
|
41
|
+
child.stdin.once('error', () => this.#fail());
|
|
42
|
+
child.stdout.on('data', (chunk) => {
|
|
43
|
+
if (this.#closed || this.#failed)
|
|
44
|
+
return;
|
|
45
|
+
try {
|
|
46
|
+
let offset = 0;
|
|
47
|
+
while (offset < chunk.length) {
|
|
48
|
+
const end = chunk.indexOf(10, offset), bytes = chunk.subarray(offset, end < 0 ? chunk.length : end);
|
|
49
|
+
if (this.#input.length + bytes.length > 65536)
|
|
50
|
+
throw new Error('MCP frame bound');
|
|
51
|
+
this.#input = Buffer.concat([this.#input, bytes]);
|
|
52
|
+
offset += bytes.length + (end < 0 ? 0 : 1);
|
|
53
|
+
if (end < 0)
|
|
54
|
+
break;
|
|
55
|
+
const message = parseJsonRpcMessage(parseBoundedJson(new TextDecoder('utf-8', { fatal: true }).decode(this.#input)));
|
|
56
|
+
this.#input = Buffer.alloc(0);
|
|
57
|
+
this.emit('message', message);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
catch {
|
|
61
|
+
this.#fail();
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
})();
|
|
65
|
+
this.#ready = started;
|
|
66
|
+
return started;
|
|
67
|
+
}
|
|
68
|
+
async send(message, guard) {
|
|
69
|
+
if (this.#closed || this.#failed || !this.#child || this.#pending >= 32)
|
|
70
|
+
refuse('MCP_FAILED', '', { phase: 'tool' });
|
|
71
|
+
const bytes = Buffer.from(canonical(message) + '\n');
|
|
72
|
+
if (bytes.length > 65536 || this.#queuedBytes + bytes.length > this.input.policy.limits.pendingResponseBytes)
|
|
73
|
+
refuse('OUTPUT_LIMIT', '', { phase: 'tool' });
|
|
74
|
+
this.#pending++;
|
|
75
|
+
this.#queuedBytes += bytes.length;
|
|
76
|
+
const sent = this.#tail.then(async () => {
|
|
77
|
+
if (this.#closed || this.#failed || this.#child.stdin.writableLength + bytes.length > 262144)
|
|
78
|
+
refuse('MCP_FAILED', '', { phase: 'tool' });
|
|
79
|
+
guard();
|
|
80
|
+
await new Promise((resolve, reject) => this.#child.stdin.write(bytes, error => error ? reject(error) : resolve()));
|
|
81
|
+
});
|
|
82
|
+
this.#tail = sent.catch(() => { });
|
|
83
|
+
try {
|
|
84
|
+
await sent;
|
|
85
|
+
}
|
|
86
|
+
finally {
|
|
87
|
+
this.#pending--;
|
|
88
|
+
this.#queuedBytes -= bytes.length;
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
async close() { this.#closed = true; await this.#ready?.catch(() => { }); return this.container.close(); }
|
|
92
|
+
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { type ExtensionFactory } from '@earendil-works/pi-coding-agent';
|
|
2
|
+
import type { McpTransport, JsonRpcMessage, McpTransportSendOptions } from '@earendil-works/pi-mcp';
|
|
3
|
+
import type { AdapterPolicy } from './types.js';
|
|
4
|
+
import type { ToolIdentity } from './tools.js';
|
|
5
|
+
import type { Channel } from './protocol.js';
|
|
6
|
+
/** An actual native client transport over the existing inherited owner channel. */
|
|
7
|
+
export declare class OwnerMcpTransport implements McpTransport {
|
|
8
|
+
#private;
|
|
9
|
+
readonly channel: Channel;
|
|
10
|
+
readonly fail: () => void;
|
|
11
|
+
constructor(channel: Channel, fail: () => void);
|
|
12
|
+
admit(identity: ToolIdentity, args: unknown): void;
|
|
13
|
+
start(): Promise<void>;
|
|
14
|
+
send(message: JsonRpcMessage, options?: McpTransportSendOptions): Promise<void>;
|
|
15
|
+
receive(message: JsonRpcMessage): void;
|
|
16
|
+
refused(): void;
|
|
17
|
+
close(): Promise<void>;
|
|
18
|
+
onMessage(listener: (message: JsonRpcMessage) => void): () => void;
|
|
19
|
+
onError(listener: (error: Error) => void): () => void;
|
|
20
|
+
onClose(listener: () => void): () => void;
|
|
21
|
+
}
|
|
22
|
+
export declare function nativeMcpFactories(policy: Pick<AdapterPolicy, 'tools' | 'mcp'>, transport: OwnerMcpTransport): readonly {
|
|
23
|
+
name: 'loopwright-mcp' | 'loopwright-codemode';
|
|
24
|
+
factory: ExtensionFactory;
|
|
25
|
+
}[];
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { createMcpExtension, createCodemodeExtension } from '@earendil-works/pi-coding-agent';
|
|
2
|
+
import { EventEmitter } from 'node:events';
|
|
3
|
+
import { canonical } from './boundary.js';
|
|
4
|
+
import { toolArgumentsDigest } from './usage.js';
|
|
5
|
+
/** An actual native client transport over the existing inherited owner channel. */
|
|
6
|
+
export class OwnerMcpTransport {
|
|
7
|
+
channel;
|
|
8
|
+
fail;
|
|
9
|
+
#events = new EventEmitter();
|
|
10
|
+
#closed = false;
|
|
11
|
+
#proposals = [];
|
|
12
|
+
constructor(channel, fail) {
|
|
13
|
+
this.channel = channel;
|
|
14
|
+
this.fail = fail;
|
|
15
|
+
}
|
|
16
|
+
admit(identity, args) { if (this.#closed || this.#proposals.length >= 32)
|
|
17
|
+
throw new Error('MCP proposal bound'); this.#proposals.push({ identity, digest: canonical(toolArgumentsDigest(args)) }); }
|
|
18
|
+
async start() { if (this.#closed)
|
|
19
|
+
throw new Error('Closed MCP transport'); }
|
|
20
|
+
async send(message, options) {
|
|
21
|
+
if (this.#closed || options?.signal?.aborted)
|
|
22
|
+
throw new Error('Closed MCP request');
|
|
23
|
+
let identity = null;
|
|
24
|
+
if ('method' in message && message.method === 'tools/call') {
|
|
25
|
+
const params = message.params, fingerprint = canonical(toolArgumentsDigest(params.arguments));
|
|
26
|
+
const index = this.#proposals.findIndex(proposal => proposal.identity.name === 'mcp__workspace__' + String(params.name) && proposal.digest === fingerprint);
|
|
27
|
+
if (index < 0) {
|
|
28
|
+
this.fail();
|
|
29
|
+
throw new Error('No bound MCP proposal');
|
|
30
|
+
}
|
|
31
|
+
identity = this.#proposals.splice(index, 1)[0].identity;
|
|
32
|
+
}
|
|
33
|
+
const abort = () => { if ('id' in message)
|
|
34
|
+
void this.channel.send('mcp-cancel', { id: message.id }).catch(this.fail); };
|
|
35
|
+
options?.signal?.addEventListener('abort', abort, { once: true });
|
|
36
|
+
// The native client aborts this send signal after either its final response or cancellation.
|
|
37
|
+
const bytes = Buffer.from(canonical(message));
|
|
38
|
+
if (bytes.length > 65536) {
|
|
39
|
+
this.fail();
|
|
40
|
+
throw new Error('MCP frame bound');
|
|
41
|
+
}
|
|
42
|
+
await this.channel.sendBytes('mcp', { identity }, bytes);
|
|
43
|
+
}
|
|
44
|
+
receive(message) { if (!this.#closed)
|
|
45
|
+
this.#events.emit('message', message); }
|
|
46
|
+
refused() { if (!this.#closed) {
|
|
47
|
+
this.#events.emit('failed', new Error('Owner refused MCP'));
|
|
48
|
+
this.#events.emit('closed');
|
|
49
|
+
this.#closed = true;
|
|
50
|
+
} }
|
|
51
|
+
async close() { if (this.#closed)
|
|
52
|
+
return; this.#closed = true; this.#proposals.length = 0; this.#events.emit('closed'); await this.channel.send('mcp-close', null); }
|
|
53
|
+
onMessage(listener) { this.#events.on('message', listener); return () => { this.#events.off('message', listener); }; }
|
|
54
|
+
onError(listener) { this.#events.on('failed', listener); return () => { this.#events.off('failed', listener); }; }
|
|
55
|
+
onClose(listener) { this.#events.on('closed', listener); return () => { this.#events.off('closed', listener); }; }
|
|
56
|
+
}
|
|
57
|
+
export function nativeMcpFactories(policy, transport) {
|
|
58
|
+
const mcp = createMcpExtension({ loadConfig: () => ({ errors: [], autoEnableCodemode: false, servers: policy.mcp.names.length ? [{ name: 'workspace', source: '/tmp/loopwright-owned-mcp-config', scope: 'extension', config: { command: 'owner-stdio-only', timeout: policy.mcp.idleTimeoutSeconds, exposure: 'hidden', toolExposure: { read_file: 'direct' }, description: 'Bounded read-only candidate files' } }] : [] }),
|
|
59
|
+
createTransport: (entry, cwd, auth) => { if (entry.name !== 'workspace' || cwd !== '/workspace/candidate' || auth !== undefined)
|
|
60
|
+
throw new Error('Unapproved MCP transport'); return transport; },
|
|
61
|
+
logPath: '/tmp/loopwright-mcp.log', updateConfig: () => { throw new Error('Frozen MCP configuration'); }, openUrl: () => { throw new Error('MCP authentication unsupported'); }, startupWaitMs: 10000 });
|
|
62
|
+
return [{ name: 'loopwright-mcp', factory: mcp }, { name: 'loopwright-codemode', factory: createCodemodeExtension({ models: false }) }];
|
|
63
|
+
}
|