@halonicjs/testing 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +1 -0
- package/README.md +40 -2
- package/dist/adapters/http-kit/src/address-class.d.ts +34 -0
- package/dist/adapters/http-kit/src/address-class.js +109 -0
- package/dist/adapters/http-kit/src/index.d.ts +2 -0
- package/dist/adapters/http-kit/src/index.js +2 -0
- package/dist/adapters/http-kit/src/ip-address.d.ts +23 -0
- package/dist/adapters/http-kit/src/ip-address.js +89 -0
- package/dist/adapters/integration-kit/src/declaration.d.ts +14 -0
- package/dist/adapters/integration-kit/src/declaration.js +77 -0
- package/dist/adapters/integration-kit/src/host.d.ts +28 -0
- package/dist/adapters/integration-kit/src/host.js +30 -0
- package/dist/adapters/integration-kit/src/index.d.ts +14 -0
- package/dist/adapters/integration-kit/src/index.js +21 -0
- package/dist/adapters/integration-kit/src/leak-attempt.d.ts +14 -0
- package/dist/adapters/integration-kit/src/leak-attempt.js +16 -0
- package/dist/adapters/integration-kit/src/limited-http.d.ts +49 -0
- package/dist/adapters/integration-kit/src/limited-http.js +182 -0
- package/dist/adapters/integration-kit/src/load-problem.d.ts +20 -0
- package/dist/adapters/integration-kit/src/load-problem.js +1 -0
- package/dist/adapters/integration-kit/src/loader.d.ts +104 -0
- package/dist/adapters/integration-kit/src/loader.js +219 -0
- package/dist/adapters/integration-kit/src/local-address.d.ts +15 -0
- package/dist/adapters/integration-kit/src/local-address.js +25 -0
- package/dist/adapters/integration-kit/src/own-request.d.ts +33 -0
- package/dist/adapters/integration-kit/src/own-request.js +36 -0
- package/dist/adapters/integration-kit/src/plugin-load.d.ts +14 -0
- package/dist/adapters/integration-kit/src/plugin-load.js +58 -0
- package/dist/adapters/integration-kit/src/policy.d.ts +55 -0
- package/dist/adapters/integration-kit/src/policy.js +37 -0
- package/dist/adapters/integration-kit/src/request-body.d.ts +38 -0
- package/dist/adapters/integration-kit/src/request-body.js +68 -0
- package/dist/adapters/integration-kit/src/request-log.d.ts +25 -0
- package/dist/adapters/integration-kit/src/request-log.js +17 -0
- package/dist/adapters/integration-kit/src/response-body.d.ts +23 -0
- package/dist/adapters/integration-kit/src/response-body.js +117 -0
- package/dist/adapters/integration-kit/src/scoped-tokens.d.ts +14 -0
- package/dist/adapters/integration-kit/src/scoped-tokens.js +27 -0
- package/dist/adapters/integration-kit/src/secret-filter.d.ts +84 -0
- package/dist/adapters/integration-kit/src/secret-filter.js +205 -0
- package/dist/adapters/integration-kit/src/secret-in-request.d.ts +59 -0
- package/dist/adapters/integration-kit/src/secret-in-request.js +133 -0
- package/dist/adapters/integration-kit/src/secret-placement.d.ts +36 -0
- package/dist/adapters/integration-kit/src/secret-placement.js +190 -0
- package/dist/adapters/integration-kit/src/wait.d.ts +16 -0
- package/dist/adapters/integration-kit/src/wait.js +35 -0
- package/dist/core/events/src/add-usage.d.ts +10 -0
- package/dist/core/events/src/add-usage.js +27 -0
- package/dist/core/events/src/agent-resume.d.ts +24 -0
- package/dist/core/events/src/agent-resume.js +1 -0
- package/dist/core/events/src/home-path.d.ts +13 -0
- package/dist/core/events/src/home-path.js +26 -0
- package/dist/core/events/src/index.d.ts +13 -0
- package/dist/core/events/src/index.js +7 -0
- package/dist/core/events/src/run-basics.d.ts +205 -0
- package/dist/core/events/src/run-basics.js +1 -0
- package/dist/core/events/src/run-event.d.ts +434 -0
- package/dist/core/events/src/run-event.js +1 -0
- package/dist/core/events/src/run-summary.d.ts +108 -0
- package/dist/core/events/src/run-summary.js +1 -0
- package/dist/core/events/src/sandbox-blocked.d.ts +42 -0
- package/dist/core/events/src/sandbox-blocked.js +26 -0
- package/dist/core/events/src/sandbox-opened-read.d.ts +17 -0
- package/dist/core/events/src/sandbox-opened-read.js +63 -0
- package/dist/core/events/src/sandbox-opened.d.ts +94 -0
- package/dist/core/events/src/sandbox-opened.js +52 -0
- package/dist/core/events/src/summarize.d.ts +14 -0
- package/dist/core/events/src/summarize.js +188 -0
- package/dist/core/events/src/timeline-entry.d.ts +21 -0
- package/dist/core/events/src/timeline-entry.js +105 -0
- package/dist/core/events/src/upgrade.d.ts +23 -0
- package/dist/core/events/src/upgrade.js +49 -0
- package/dist/core/format/src/compact.d.ts +30 -0
- package/dist/core/format/src/compact.js +72 -0
- package/dist/core/format/src/index.d.ts +37 -0
- package/dist/core/format/src/index.js +23 -0
- package/dist/core/format/src/integration/index.d.ts +6 -0
- package/dist/core/format/src/integration/index.js +9 -0
- package/dist/core/format/src/json-schema.d.ts +26 -0
- package/dist/core/format/src/json-schema.js +48 -0
- package/dist/core/format/src/kind.d.ts +65 -0
- package/dist/core/format/src/kind.js +1 -0
- package/dist/core/format/src/kinds/agent/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/agent/kind.js +10 -0
- package/dist/core/format/src/kinds/agent/sandbox-fields.d.ts +89 -0
- package/dist/core/format/src/kinds/agent/sandbox-fields.js +197 -0
- package/dist/core/format/src/kinds/agent/schema.d.ts +147 -0
- package/dist/core/format/src/kinds/agent/schema.js +107 -0
- package/dist/core/format/src/kinds/agent/working-folder-start.d.ts +74 -0
- package/dist/core/format/src/kinds/agent/working-folder-start.js +312 -0
- package/dist/core/format/src/kinds/collection/kind.d.ts +8 -0
- package/dist/core/format/src/kinds/collection/kind.js +14 -0
- package/dist/core/format/src/kinds/collection/schema.d.ts +89 -0
- package/dist/core/format/src/kinds/collection/schema.js +90 -0
- package/dist/core/format/src/kinds/connector/is-local.d.ts +10 -0
- package/dist/core/format/src/kinds/connector/is-local.js +43 -0
- package/dist/core/format/src/kinds/connector/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/connector/kind.js +119 -0
- package/dist/core/format/src/kinds/connector/schema.d.ts +50 -0
- package/dist/core/format/src/kinds/connector/schema.js +92 -0
- package/dist/core/format/src/kinds/deployments/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/deployments/kind.js +25 -0
- package/dist/core/format/src/kinds/deployments/schema.d.ts +37 -0
- package/dist/core/format/src/kinds/deployments/schema.js +42 -0
- package/dist/core/format/src/kinds/hub/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/hub/kind.js +10 -0
- package/dist/core/format/src/kinds/hub/schema.d.ts +54 -0
- package/dist/core/format/src/kinds/hub/schema.js +34 -0
- package/dist/core/format/src/kinds/integration/kind.d.ts +16 -0
- package/dist/core/format/src/kinds/integration/kind.js +138 -0
- package/dist/core/format/src/kinds/integration/parse-sheet.d.ts +19 -0
- package/dist/core/format/src/kinds/integration/parse-sheet.js +24 -0
- package/dist/core/format/src/kinds/integration/policy.d.ts +67 -0
- package/dist/core/format/src/kinds/integration/policy.js +268 -0
- package/dist/core/format/src/kinds/integration/schema.d.ts +233 -0
- package/dist/core/format/src/kinds/integration/schema.js +233 -0
- package/dist/core/format/src/kinds/knowledge/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/knowledge/kind.js +13 -0
- package/dist/core/format/src/kinds/knowledge/schema.d.ts +18 -0
- package/dist/core/format/src/kinds/knowledge/schema.js +25 -0
- package/dist/core/format/src/kinds/models/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/models/kind.js +10 -0
- package/dist/core/format/src/kinds/models/schema.d.ts +92 -0
- package/dist/core/format/src/kinds/models/schema.js +38 -0
- package/dist/core/format/src/kinds/plugin/backend.d.ts +22 -0
- package/dist/core/format/src/kinds/plugin/backend.js +31 -0
- package/dist/core/format/src/kinds/plugin/checks.d.ts +13 -0
- package/dist/core/format/src/kinds/plugin/checks.js +131 -0
- package/dist/core/format/src/kinds/plugin/kind.d.ts +8 -0
- package/dist/core/format/src/kinds/plugin/kind.js +16 -0
- package/dist/core/format/src/kinds/plugin/problems.d.ts +24 -0
- package/dist/core/format/src/kinds/plugin/problems.js +65 -0
- package/dist/core/format/src/kinds/plugin/schema.d.ts +542 -0
- package/dist/core/format/src/kinds/plugin/schema.js +261 -0
- package/dist/core/format/src/kinds/plugin/setting-values.d.ts +17 -0
- package/dist/core/format/src/kinds/plugin/setting-values.js +38 -0
- package/dist/core/format/src/kinds/plugin/ui-checks.d.ts +8 -0
- package/dist/core/format/src/kinds/plugin/ui-checks.js +94 -0
- package/dist/core/format/src/kinds/provider/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/provider/kind.js +24 -0
- package/dist/core/format/src/kinds/provider/schema.d.ts +17 -0
- package/dist/core/format/src/kinds/provider/schema.js +22 -0
- package/dist/core/format/src/kinds/routine/kind.d.ts +8 -0
- package/dist/core/format/src/kinds/routine/kind.js +25 -0
- package/dist/core/format/src/kinds/routine/schema.d.ts +84 -0
- package/dist/core/format/src/kinds/routine/schema.js +93 -0
- package/dist/core/format/src/kinds/runtime/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/runtime/kind.js +13 -0
- package/dist/core/format/src/kinds/runtime/schema.d.ts +10 -0
- package/dist/core/format/src/kinds/runtime/schema.js +12 -0
- package/dist/core/format/src/kinds/skill/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/skill/kind.js +10 -0
- package/dist/core/format/src/kinds/skill/schema.d.ts +17 -0
- package/dist/core/format/src/kinds/skill/schema.js +17 -0
- package/dist/core/format/src/kinds/skill/scripts-folder.d.ts +27 -0
- package/dist/core/format/src/kinds/skill/scripts-folder.js +37 -0
- package/dist/core/format/src/kinds/workflow/kind.d.ts +8 -0
- package/dist/core/format/src/kinds/workflow/kind.js +14 -0
- package/dist/core/format/src/kinds/workflow/schema.d.ts +162 -0
- package/dist/core/format/src/kinds/workflow/schema.js +106 -0
- package/dist/core/format/src/kinds/workflow-test/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/workflow-test/kind.js +14 -0
- package/dist/core/format/src/kinds/workflow-test/schema.d.ts +67 -0
- package/dist/core/format/src/kinds/workflow-test/schema.js +59 -0
- package/dist/core/format/src/kinds/workspace/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/workspace/kind.js +10 -0
- package/dist/core/format/src/kinds/workspace/schema.d.ts +72 -0
- package/dist/core/format/src/kinds/workspace/schema.js +66 -0
- package/dist/core/format/src/parse-file.d.ts +69 -0
- package/dist/core/format/src/parse-file.js +105 -0
- package/dist/core/format/src/recording/format.d.ts +81 -0
- package/dist/core/format/src/recording/format.js +102 -0
- package/dist/core/format/src/recording/index.d.ts +1 -0
- package/dist/core/format/src/recording/index.js +3 -0
- package/dist/core/format/src/registry.d.ts +64 -0
- package/dist/core/format/src/registry.js +61 -0
- package/dist/core/format/src/reserved.d.ts +20 -0
- package/dist/core/format/src/reserved.js +30 -0
- package/dist/core/format/src/shared/fields.d.ts +37 -0
- package/dist/core/format/src/shared/fields.js +54 -0
- package/dist/core/format/src/shared/guard.d.ts +32 -0
- package/dist/core/format/src/shared/guard.js +16 -0
- package/dist/core/format/src/shared/key-in-value.d.ts +28 -0
- package/dist/core/format/src/shared/key-in-value.js +82 -0
- package/dist/core/format/src/shared/legacy-keys.d.ts +8 -0
- package/dist/core/format/src/shared/legacy-keys.js +17 -0
- package/dist/core/format/src/shared/program-start.d.ts +60 -0
- package/dist/core/format/src/shared/program-start.js +99 -0
- package/dist/core/format/src/shared/relative-path.d.ts +29 -0
- package/dist/core/format/src/shared/relative-path.js +50 -0
- package/dist/core/format/src/shared/secret-name.d.ts +24 -0
- package/dist/core/format/src/shared/secret-name.js +107 -0
- package/dist/core/format/src/source.d.ts +16 -0
- package/dist/core/format/src/source.js +73 -0
- package/dist/core/ports/src/agent-placement-store.d.ts +74 -0
- package/dist/core/ports/src/agent-placement-store.js +27 -0
- package/dist/core/ports/src/blob-store.d.ts +33 -0
- package/dist/core/ports/src/blob-store.js +2 -0
- package/dist/core/ports/src/cant-try-error.d.ts +35 -0
- package/dist/core/ports/src/cant-try-error.js +44 -0
- package/dist/core/ports/src/chat.d.ts +127 -0
- package/dist/core/ports/src/chat.js +1 -0
- package/dist/core/ports/src/clock.d.ts +7 -0
- package/dist/core/ports/src/clock.js +2 -0
- package/dist/core/ports/src/connection-settings-store.d.ts +57 -0
- package/dist/core/ports/src/connection-settings-store.js +2 -0
- package/dist/core/ports/src/connector-client.d.ts +259 -0
- package/dist/core/ports/src/connector-client.js +2 -0
- package/dist/core/ports/src/coordination.d.ts +84 -0
- package/dist/core/ports/src/coordination.js +2 -0
- package/dist/core/ports/src/definition-store.d.ts +208 -0
- package/dist/core/ports/src/definition-store.js +122 -0
- package/dist/core/ports/src/digest.d.ts +14 -0
- package/dist/core/ports/src/digest.js +2 -0
- package/dist/core/ports/src/folder-reader.d.ts +89 -0
- package/dist/core/ports/src/folder-reader.js +2 -0
- package/dist/core/ports/src/harness-bridge-server.d.ts +189 -0
- package/dist/core/ports/src/harness-bridge-server.js +37 -0
- package/dist/core/ports/src/harness.d.ts +250 -0
- package/dist/core/ports/src/harness.js +45 -0
- package/dist/core/ports/src/http-client.d.ts +27 -0
- package/dist/core/ports/src/http-client.js +2 -0
- package/dist/core/ports/src/id-generator.d.ts +14 -0
- package/dist/core/ports/src/id-generator.js +2 -0
- package/dist/core/ports/src/index.d.ts +37 -0
- package/dist/core/ports/src/index.js +36 -0
- package/dist/core/ports/src/integration.d.ts +178 -0
- package/dist/core/ports/src/integration.js +13 -0
- package/dist/core/ports/src/knowledge-provider.d.ts +65 -0
- package/dist/core/ports/src/knowledge-provider.js +2 -0
- package/dist/core/ports/src/llm-cache.d.ts +13 -0
- package/dist/core/ports/src/llm-cache.js +2 -0
- package/dist/core/ports/src/llm-provider.d.ts +184 -0
- package/dist/core/ports/src/llm-provider.js +136 -0
- package/dist/core/ports/src/model-price.d.ts +34 -0
- package/dist/core/ports/src/model-price.js +25 -0
- package/dist/core/ports/src/password-hasher.d.ts +47 -0
- package/dist/core/ports/src/password-hasher.js +2 -0
- package/dist/core/ports/src/plugin-folder-writer.d.ts +104 -0
- package/dist/core/ports/src/plugin-folder-writer.js +95 -0
- package/dist/core/ports/src/port-versions.d.ts +44 -0
- package/dist/core/ports/src/port-versions.js +74 -0
- package/dist/core/ports/src/program-probe.d.ts +46 -0
- package/dist/core/ports/src/program-probe.js +2 -0
- package/dist/core/ports/src/record-store.d.ts +62 -0
- package/dist/core/ports/src/record-store.js +38 -0
- package/dist/core/ports/src/resource-probe.d.ts +59 -0
- package/dist/core/ports/src/resource-probe.js +2 -0
- package/dist/core/ports/src/run-executor.d.ts +302 -0
- package/dist/core/ports/src/run-executor.js +2 -0
- package/dist/core/ports/src/run-failure-error.d.ts +49 -0
- package/dist/core/ports/src/run-failure-error.js +47 -0
- package/dist/core/ports/src/run-store.d.ts +194 -0
- package/dist/core/ports/src/run-store.js +131 -0
- package/dist/core/ports/src/sandbox.d.ts +247 -0
- package/dist/core/ports/src/sandbox.js +34 -0
- package/dist/core/ports/src/scheduler.d.ts +85 -0
- package/dist/core/ports/src/scheduler.js +2 -0
- package/dist/core/ports/src/secrets.d.ts +128 -0
- package/dist/core/ports/src/secrets.js +144 -0
- package/dist/core/ports/src/token-store.d.ts +19 -0
- package/dist/core/ports/src/token-store.js +2 -0
- package/dist/core/ports/src/tool-approval-store.d.ts +211 -0
- package/dist/core/ports/src/tool-approval-store.js +57 -0
- package/dist/core/ports/src/trust-store.d.ts +72 -0
- package/dist/core/ports/src/trust-store.js +2 -0
- package/dist/core/ports/src/unfenced-run-consent-store.d.ts +43 -0
- package/dist/core/ports/src/unfenced-run-consent-store.js +2 -0
- package/dist/core/ports/src/vcs.d.ts +394 -0
- package/dist/core/ports/src/vcs.js +48 -0
- package/dist/core/schema-kit/src/builders.d.ts +50 -0
- package/dist/core/schema-kit/src/builders.js +72 -0
- package/dist/core/schema-kit/src/depth.d.ts +15 -0
- package/dist/core/schema-kit/src/depth.js +37 -0
- package/dist/core/schema-kit/src/index.d.ts +6 -0
- package/dist/core/schema-kit/src/index.js +6 -0
- package/dist/core/schema-kit/src/issue.d.ts +22 -0
- package/dist/core/schema-kit/src/issue.js +23 -0
- package/dist/core/schema-kit/src/json-schema.d.ts +23 -0
- package/dist/core/schema-kit/src/json-schema.js +22 -0
- package/dist/core/schema-kit/src/parse.d.ts +17 -0
- package/dist/core/schema-kit/src/parse.js +25 -0
- package/dist/core/schema-kit/src/schema.d.ts +12 -0
- package/dist/core/schema-kit/src/schema.js +1 -0
- package/dist/core/std/src/ascii-host.d.ts +18 -0
- package/dist/core/std/src/ascii-host.js +110 -0
- package/dist/core/std/src/assert.d.ts +39 -0
- package/dist/core/std/src/assert.js +59 -0
- package/dist/core/std/src/base64url.d.ts +23 -0
- package/dist/core/std/src/base64url.js +65 -0
- package/dist/core/std/src/canonical-json.d.ts +18 -0
- package/dist/core/std/src/canonical-json.js +56 -0
- package/dist/core/std/src/clock.d.ts +27 -0
- package/dist/core/std/src/clock.js +33 -0
- package/dist/core/std/src/constant-time.d.ts +16 -0
- package/dist/core/std/src/constant-time.js +26 -0
- package/dist/core/std/src/content-digest.d.ts +24 -0
- package/dist/core/std/src/content-digest.js +28 -0
- package/dist/core/std/src/deep-clone.d.ts +15 -0
- package/dist/core/std/src/deep-clone.js +59 -0
- package/dist/core/std/src/deep-equal.d.ts +23 -0
- package/dist/core/std/src/deep-equal.js +64 -0
- package/dist/core/std/src/emitter.d.ts +42 -0
- package/dist/core/std/src/emitter.js +74 -0
- package/dist/core/std/src/error-kind.d.ts +88 -0
- package/dist/core/std/src/error-kind.js +98 -0
- package/dist/core/std/src/hex.d.ts +10 -0
- package/dist/core/std/src/hex.js +16 -0
- package/dist/core/std/src/ids.d.ts +45 -0
- package/dist/core/std/src/ids.js +49 -0
- package/dist/core/std/src/index.d.ts +25 -0
- package/dist/core/std/src/index.js +26 -0
- package/dist/core/std/src/keyed-queue.d.ts +18 -0
- package/dist/core/std/src/keyed-queue.js +32 -0
- package/dist/core/std/src/line-diff.d.ts +83 -0
- package/dist/core/std/src/line-diff.js +179 -0
- package/dist/core/std/src/line-merge.d.ts +63 -0
- package/dist/core/std/src/line-merge.js +138 -0
- package/dist/core/std/src/plain-data.d.ts +32 -0
- package/dist/core/std/src/plain-data.js +57 -0
- package/dist/core/std/src/posix-path.d.ts +61 -0
- package/dist/core/std/src/posix-path.js +121 -0
- package/dist/core/std/src/result.d.ts +55 -0
- package/dist/core/std/src/result.js +52 -0
- package/dist/core/std/src/secret-scrubber.d.ts +54 -0
- package/dist/core/std/src/secret-scrubber.js +124 -0
- package/dist/core/std/src/secret-shape.d.ts +20 -0
- package/dist/core/std/src/secret-shape.js +53 -0
- package/dist/core/std/src/stop-signal.d.ts +44 -0
- package/dist/core/std/src/stop-signal.js +77 -0
- package/dist/core/std/src/text.d.ts +28 -0
- package/dist/core/std/src/text.js +54 -0
- package/dist/core/std/src/utf8.d.ts +23 -0
- package/dist/core/std/src/utf8.js +110 -0
- package/dist/core/std/src/version.d.ts +48 -0
- package/dist/core/std/src/version.js +103 -0
- package/dist/core/yaml/src/depth.d.ts +14 -0
- package/dist/core/yaml/src/depth.js +140 -0
- package/dist/core/yaml/src/edit-data.d.ts +47 -0
- package/dist/core/yaml/src/edit-data.js +286 -0
- package/dist/core/yaml/src/edit-text.d.ts +92 -0
- package/dist/core/yaml/src/edit-text.js +267 -0
- package/dist/core/yaml/src/edit.d.ts +47 -0
- package/dist/core/yaml/src/edit.js +198 -0
- package/dist/core/yaml/src/index.d.ts +5 -0
- package/dist/core/yaml/src/index.js +4 -0
- package/dist/core/yaml/src/problem.d.ts +20 -0
- package/dist/core/yaml/src/problem.js +1 -0
- package/dist/core/yaml/src/read.d.ts +47 -0
- package/dist/core/yaml/src/read.js +130 -0
- package/dist/core/yaml/src/splice-node.d.ts +47 -0
- package/dist/core/yaml/src/splice-node.js +333 -0
- package/dist/core/yaml/src/splice.d.ts +13 -0
- package/dist/core/yaml/src/splice.js +174 -0
- package/dist/core/yaml/src/unsupported.d.ts +26 -0
- package/dist/core/yaml/src/unsupported.js +70 -0
- package/dist/core/yaml/src/write.d.ts +35 -0
- package/dist/core/yaml/src/write.js +44 -0
- package/dist/testing/integration/src/canaries.d.ts +14 -0
- package/dist/testing/integration/src/canaries.js +17 -0
- package/dist/testing/integration/src/checks.d.ts +37 -0
- package/dist/testing/integration/src/checks.js +195 -0
- package/dist/testing/integration/src/describe.d.ts +35 -0
- package/dist/testing/integration/src/describe.js +74 -0
- package/dist/testing/integration/src/failure.d.ts +6 -0
- package/dist/testing/integration/src/failure.js +8 -0
- package/dist/testing/integration/src/fake-wait.d.ts +18 -0
- package/dist/testing/integration/src/fake-wait.js +21 -0
- package/dist/testing/integration/src/index.d.ts +10 -0
- package/dist/testing/integration/src/index.js +11 -0
- package/dist/testing/integration/src/load.d.ts +14 -0
- package/dist/testing/integration/src/load.js +45 -0
- package/dist/testing/integration/src/plugin-folder.d.ts +23 -0
- package/dist/testing/integration/src/plugin-folder.js +59 -0
- package/dist/testing/integration/src/plugin.d.ts +32 -0
- package/dist/testing/integration/src/plugin.js +57 -0
- package/dist/testing/integration/src/recording.d.ts +84 -0
- package/dist/testing/integration/src/recording.js +164 -0
- package/dist/testing/integration/src/run.d.ts +60 -0
- package/dist/testing/integration/src/run.js +81 -0
- package/dist/testing/integration/src/source-scan.d.ts +16 -0
- package/dist/testing/integration/src/source-scan.js +40 -0
- package/package.json +35 -4
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
import { type RunEvent, type RunKind, type RunStatus, type RunSummary } from "../../events/src/index.js";
|
|
2
|
+
/** Version of the {@link RunStore} port. A breaking change bumps it and comes with an ADR. */
|
|
3
|
+
export declare const runStoreVersion = 1;
|
|
4
|
+
/** Which runs {@link RunStore.list} returns. Every field narrows the list; none means all runs. */
|
|
5
|
+
export interface RunFilter {
|
|
6
|
+
hubId?: string;
|
|
7
|
+
workflowId?: string;
|
|
8
|
+
kind?: RunKind;
|
|
9
|
+
/**
|
|
10
|
+
* One status or any of several, such as `["running", "waiting"]` for the
|
|
11
|
+
* watchdog. An empty list is no status filter, the same as leaving it out.
|
|
12
|
+
*/
|
|
13
|
+
status?: RunStatus | readonly RunStatus[];
|
|
14
|
+
/**
|
|
15
|
+
* An ISO time: only runs that started at or after it. A store that keeps
|
|
16
|
+
* each run in its own log can then skip a log by its first line, so a
|
|
17
|
+
* month's runs cost a read of that month's logs, not of every log.
|
|
18
|
+
*/
|
|
19
|
+
startedSince?: string;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* What {@link RunStore.append} did. `lastSeq` is the sequence number of the
|
|
23
|
+
* run's last stored event afterwards, so a writer that lost the race knows
|
|
24
|
+
* where the log is now.
|
|
25
|
+
*
|
|
26
|
+
* A lost race is the error kind `conflict` from `@halonicjs/std`, so a surface
|
|
27
|
+
* that reports it responds the same way as to any other conflict. The ports
|
|
28
|
+
* may not import std (docs/adr/2026-11-09-api-types-stand-alone.md), so the
|
|
29
|
+
* run-store contract in `@halonicjs/testing-contracts` checks that the two
|
|
30
|
+
* stay the same.
|
|
31
|
+
*/
|
|
32
|
+
export type AppendResult = {
|
|
33
|
+
ok: true;
|
|
34
|
+
lastSeq: number;
|
|
35
|
+
} | {
|
|
36
|
+
ok: false;
|
|
37
|
+
reason: "conflict";
|
|
38
|
+
lastSeq: number;
|
|
39
|
+
};
|
|
40
|
+
/** Options for {@link RunStore.append}. */
|
|
41
|
+
export interface AppendOptions {
|
|
42
|
+
/**
|
|
43
|
+
* The engine's state after these events, as plain JSON data, so the next
|
|
44
|
+
* step starts from it instead of replaying the whole log. It is a cache:
|
|
45
|
+
* an adapter may store the events and drop the snapshot, and `snapshot()`
|
|
46
|
+
* then gives an older one or `null`.
|
|
47
|
+
*/
|
|
48
|
+
snapshot?: unknown;
|
|
49
|
+
}
|
|
50
|
+
/** The latest state snapshot of a run, and the sequence number of the last event it includes. */
|
|
51
|
+
export interface RunSnapshot {
|
|
52
|
+
seq: number;
|
|
53
|
+
state: unknown;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* The append-only run event logs and the run list. The log is the truth and
|
|
57
|
+
* the list is a copy of it, worked out with `summarize`
|
|
58
|
+
* from `@halonicjs/events`.
|
|
59
|
+
*/
|
|
60
|
+
export interface RunStore {
|
|
61
|
+
/**
|
|
62
|
+
* Appends events to a run's log, but only if its last stored event is
|
|
63
|
+
* `expectedSeq` (0 for a new run), so two writers can never both win.
|
|
64
|
+
* The events are stored together or not at all: an append that fails or
|
|
65
|
+
* gives a conflict stores none of them. Only a crash of the program in the
|
|
66
|
+
* middle of an append may leave the first events stored, in an adapter
|
|
67
|
+
* that writes to disk; its readme says so.
|
|
68
|
+
*
|
|
69
|
+
* @param runId - the run the events belong to; every event carries it too
|
|
70
|
+
* @param expectedSeq - the sequence number of the last event the writer saw
|
|
71
|
+
* @param events - at least one, numbered `expectedSeq + 1`, `expectedSeq + 2` …
|
|
72
|
+
* @returns `ok: false` with reason "conflict" when the log has moved on
|
|
73
|
+
* @throws RangeError when `events` is empty, misnumbered, or carries another
|
|
74
|
+
* run id, or `expectedSeq` isn't a whole number of 0 or more. These are the
|
|
75
|
+
* caller's bugs and are never reported as a conflict.
|
|
76
|
+
*/
|
|
77
|
+
append(runId: string, expectedSeq: number, events: readonly RunEvent[], options?: AppendOptions): Promise<AppendResult>;
|
|
78
|
+
/** A run's events, oldest first; with `afterSeq`, only those after it. Empty for an unknown run. */
|
|
79
|
+
events(runId: string, afterSeq?: number): Promise<RunEvent[]>;
|
|
80
|
+
/** The run's latest snapshot, or `null` when it has none or the run is unknown. */
|
|
81
|
+
snapshot(runId: string): Promise<RunSnapshot | null>;
|
|
82
|
+
/** A run's summary, or `null` for an unknown run. Always up to date with the log. */
|
|
83
|
+
get(runId: string): Promise<RunSummary | null>;
|
|
84
|
+
/**
|
|
85
|
+
* The summaries of the runs that match the filter, newest start time first.
|
|
86
|
+
* The list may lag the log for a short time (on Cloudflare it is filled
|
|
87
|
+
* from an outbox); use {@link RunStore.get} when one run must be current.
|
|
88
|
+
*/
|
|
89
|
+
list(filter?: RunFilter): Promise<RunSummary[]>;
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* What a file-system adapter writes into `<runId>.lock`, next to the run's
|
|
93
|
+
* log, while it appends to the run. The Node and Tauri adapters share this
|
|
94
|
+
* format and these rules, so a CLI and a desktop app writing to one
|
|
95
|
+
* workspace exclude each other, and one of them gets `conflict` instead of
|
|
96
|
+
* both winning.
|
|
97
|
+
*
|
|
98
|
+
* - **Taking the lock:** create `<runId>.lock` with an exclusive create that
|
|
99
|
+
* fails when the file is already there (`wx` in Node, `create_new` in
|
|
100
|
+
* Rust), and write this record into it as JSON.
|
|
101
|
+
* - **Appending:** with the lock held, read the log, return `conflict` when
|
|
102
|
+
* its last event isn't `expectedSeq`, otherwise write the events.
|
|
103
|
+
* - **Releasing:** remove the lock file, but only while it still holds the
|
|
104
|
+
* record this writer wrote.
|
|
105
|
+
* - **Waiting:** when the lock is held, try again a few milliseconds later.
|
|
106
|
+
* - **Stale locks:** a crashed writer leaves its lock behind. Another writer
|
|
107
|
+
* may remove it when the lock's `host` is this computer and no process
|
|
108
|
+
* `pid` runs here any more, or when `takenAt` is more than
|
|
109
|
+
* {@link runLockStaleAfterMs} ago. The age limit also covers a process id
|
|
110
|
+
* that was reused, and a lock taken on another computer of a shared
|
|
111
|
+
* folder. A lock file that can't be read as a record (a crash between
|
|
112
|
+
* creating and writing it) counts its age from the file's change time.
|
|
113
|
+
* - **Removing a stale lock:** only one writer removes a lock at a time,
|
|
114
|
+
* the one that creates `<runId>.lock.takeover` with an exclusive create.
|
|
115
|
+
* Holding it, the writer reads the lock again and removes it only while
|
|
116
|
+
* it still holds the same stale text, then removes the takeover file. A
|
|
117
|
+
* lock that isn't stale is never moved or removed. A writer that finds
|
|
118
|
+
* the takeover file there waits and tries again; one older than
|
|
119
|
+
* {@link runLockTakeoverStaleAfterMs} was left by a remover that crashed,
|
|
120
|
+
* and any writer may remove it.
|
|
121
|
+
* - **A link at the lock's path:** when the exclusive create finds the file
|
|
122
|
+
* there but reading it finds none, and the path is a symbolic link to a
|
|
123
|
+
* file that isn't there, fail with an error instead of trying again.
|
|
124
|
+
*/
|
|
125
|
+
export interface RunLockRecord {
|
|
126
|
+
/** The format version, {@link runLockFormat}. */
|
|
127
|
+
version: number;
|
|
128
|
+
/** The process id of the writer holding the lock. */
|
|
129
|
+
pid: number;
|
|
130
|
+
/** The host name of the computer the writer runs on. */
|
|
131
|
+
host: string;
|
|
132
|
+
/** When the lock was taken, as an ISO 8601 time in UTC. */
|
|
133
|
+
takenAt: string;
|
|
134
|
+
}
|
|
135
|
+
/** The format version of {@link RunLockRecord} that adapters write today. */
|
|
136
|
+
export declare const runLockFormat = 1;
|
|
137
|
+
/**
|
|
138
|
+
* How old a run lock may get before any writer may remove it. An append holds
|
|
139
|
+
* the lock for milliseconds, so this is far longer than any append takes.
|
|
140
|
+
*/
|
|
141
|
+
export declare const runLockStaleAfterMs = 10000;
|
|
142
|
+
/**
|
|
143
|
+
* How old a lock's takeover file may get before any writer may remove it.
|
|
144
|
+
* Removing a stale lock takes milliseconds, and up to 2 seconds a step on
|
|
145
|
+
* Windows while a file is busy, so a takeover file this old was left by a
|
|
146
|
+
* writer that crashed while removing a lock.
|
|
147
|
+
*/
|
|
148
|
+
export declare const runLockTakeoverStaleAfterMs = 5000;
|
|
149
|
+
/**
|
|
150
|
+
* Refuses an append that is the caller's bug, as {@link RunStore.append}
|
|
151
|
+
* says: `expectedSeq` that isn't a whole number of 0 or more, no events,
|
|
152
|
+
* an event of another run, or events not numbered from `expectedSeq + 1`.
|
|
153
|
+
*
|
|
154
|
+
* @throws RangeError naming what is wrong
|
|
155
|
+
*/
|
|
156
|
+
export declare function checkRunAppend(runId: string, expectedSeq: number, events: readonly RunEvent[]): void;
|
|
157
|
+
/** Whether a summary matches every field of a {@link RunFilter}. An empty status list is no status filter. */
|
|
158
|
+
export declare function matchesRunFilter(summary: RunSummary, filter: RunFilter): boolean;
|
|
159
|
+
/**
|
|
160
|
+
* Whether a run that started at `startedAt` is in a list filtered by
|
|
161
|
+
* `startedSince`. Both are ISO times; they are compared as times, so an
|
|
162
|
+
* offset or a missing fraction of a second doesn't change the answer.
|
|
163
|
+
*/
|
|
164
|
+
export declare function startedAtOrAfter(startedAt: string, since: string): boolean;
|
|
165
|
+
/** Orders summaries as {@link RunStore.list} returns them: newest start time first, then by run id. */
|
|
166
|
+
export declare function compareRunSummaries(a: RunSummary, b: RunSummary): number;
|
|
167
|
+
/** Writes events as run log lines: one JSON event per line, each ending in a line break. */
|
|
168
|
+
export declare function formatLogLines(events: readonly RunEvent[]): string;
|
|
169
|
+
/**
|
|
170
|
+
* Reads a run log's whole lines back into events. Every line must hold the
|
|
171
|
+
* run's next event, numbered from 1. Pass only whole lines, each ending in
|
|
172
|
+
* a line break: a torn last line, from a crash, is the adapter's to leave
|
|
173
|
+
* out first.
|
|
174
|
+
*
|
|
175
|
+
* @param lines - the log's whole lines, or `""` for an empty log
|
|
176
|
+
* @param runId - the run the log belongs to
|
|
177
|
+
* @param file - the log's name, for the error message
|
|
178
|
+
* @returns the events, in order
|
|
179
|
+
* @throws Error naming the file and line when a line is broken
|
|
180
|
+
*/
|
|
181
|
+
export declare function parseLogLines(lines: string, runId: string, file: string): RunEvent[];
|
|
182
|
+
/**
|
|
183
|
+
* Whether a run id can be a plain file name in the run folder: 1 to 128
|
|
184
|
+
* letters, digits, `_`, `-` or `.`, not starting with a dot, and not a name
|
|
185
|
+
* Windows keeps for a device.
|
|
186
|
+
*/
|
|
187
|
+
export declare function isRunId(runId: string): boolean;
|
|
188
|
+
/**
|
|
189
|
+
* Refuses a run id that couldn't be a plain file name in the run folder:
|
|
190
|
+
* `..`, a separator, an absolute path, a name Windows keeps for a device.
|
|
191
|
+
*
|
|
192
|
+
* @throws RangeError naming the run id
|
|
193
|
+
*/
|
|
194
|
+
export declare function checkRunId(runId: string): void;
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { parseEventLine, } from "../../events/src/index.js";
|
|
2
|
+
/** Version of the {@link RunStore} port. A breaking change bumps it and comes with an ADR. */
|
|
3
|
+
export const runStoreVersion = 1;
|
|
4
|
+
/** The format version of {@link RunLockRecord} that adapters write today. */
|
|
5
|
+
export const runLockFormat = 1;
|
|
6
|
+
/**
|
|
7
|
+
* How old a run lock may get before any writer may remove it. An append holds
|
|
8
|
+
* the lock for milliseconds, so this is far longer than any append takes.
|
|
9
|
+
*/
|
|
10
|
+
export const runLockStaleAfterMs = 10_000;
|
|
11
|
+
/**
|
|
12
|
+
* How old a lock's takeover file may get before any writer may remove it.
|
|
13
|
+
* Removing a stale lock takes milliseconds, and up to 2 seconds a step on
|
|
14
|
+
* Windows while a file is busy, so a takeover file this old was left by a
|
|
15
|
+
* writer that crashed while removing a lock.
|
|
16
|
+
*/
|
|
17
|
+
export const runLockTakeoverStaleAfterMs = 5_000;
|
|
18
|
+
// The rules above, as code, so every adapter checks appends and filters runs the same way.
|
|
19
|
+
/**
|
|
20
|
+
* Refuses an append that is the caller's bug, as {@link RunStore.append}
|
|
21
|
+
* says: `expectedSeq` that isn't a whole number of 0 or more, no events,
|
|
22
|
+
* an event of another run, or events not numbered from `expectedSeq + 1`.
|
|
23
|
+
*
|
|
24
|
+
* @throws RangeError naming what is wrong
|
|
25
|
+
*/
|
|
26
|
+
export function checkRunAppend(runId, expectedSeq, events) {
|
|
27
|
+
if (!Number.isSafeInteger(expectedSeq) || expectedSeq < 0) {
|
|
28
|
+
throw new RangeError(`expectedSeq must be a whole number of 0 or more, not ${expectedSeq}.`);
|
|
29
|
+
}
|
|
30
|
+
if (events.length === 0) {
|
|
31
|
+
throw new RangeError("append needs at least one event.");
|
|
32
|
+
}
|
|
33
|
+
events.forEach((event, index) => {
|
|
34
|
+
if (event.runId !== runId) {
|
|
35
|
+
throw new RangeError(`Event ${event.seq} belongs to run ${event.runId}, not ${runId}.`);
|
|
36
|
+
}
|
|
37
|
+
if (event.seq !== expectedSeq + index + 1) {
|
|
38
|
+
throw new RangeError(`Event ${index} has seq ${event.seq}, not ${expectedSeq + index + 1}.`);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
/** Whether a summary matches every field of a {@link RunFilter}. An empty status list is no status filter. */
|
|
43
|
+
export function matchesRunFilter(summary, filter) {
|
|
44
|
+
const statuses = filter.status === undefined ? [] : [filter.status].flat();
|
|
45
|
+
return ((filter.hubId === undefined || summary.hubId === filter.hubId) &&
|
|
46
|
+
(filter.workflowId === undefined || summary.workflowId === filter.workflowId) &&
|
|
47
|
+
(filter.kind === undefined || summary.kind === filter.kind) &&
|
|
48
|
+
(statuses.length === 0 || statuses.includes(summary.status)) &&
|
|
49
|
+
(filter.startedSince === undefined || startedAtOrAfter(summary.startedAt, filter.startedSince)));
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Whether a run that started at `startedAt` is in a list filtered by
|
|
53
|
+
* `startedSince`. Both are ISO times; they are compared as times, so an
|
|
54
|
+
* offset or a missing fraction of a second doesn't change the answer.
|
|
55
|
+
*/
|
|
56
|
+
export function startedAtOrAfter(startedAt, since) {
|
|
57
|
+
return Date.parse(startedAt) >= Date.parse(since);
|
|
58
|
+
}
|
|
59
|
+
/** Orders summaries as {@link RunStore.list} returns them: newest start time first, then by run id. */
|
|
60
|
+
export function compareRunSummaries(a, b) {
|
|
61
|
+
return b.startedAt.localeCompare(a.startedAt) || a.id.localeCompare(b.id);
|
|
62
|
+
}
|
|
63
|
+
// The run folder's file rules, which every adapter that keeps runs as files
|
|
64
|
+
// in a folder applies: the CLI's `FolderRunStore` in `fs-node` and the
|
|
65
|
+
// desktop app's store in `fs-tauri`, whose shell writes the same files. Bytes
|
|
66
|
+
// stay with the adapters: each finds the log's whole lines and decodes them
|
|
67
|
+
// its own way, then reads them here (HAL-2701).
|
|
68
|
+
/** Letters, digits, `_`, `-` and `.`, not starting with a dot, at most 128 characters: a safe file name everywhere. */
|
|
69
|
+
const runIdPattern = /^[A-Za-z0-9_-][A-Za-z0-9_.-]{0,127}$/u;
|
|
70
|
+
/** Names Windows opens as a device whatever the extension, such as `NUL.jsonl`. */
|
|
71
|
+
const windowsDeviceName = /^(con|prn|aux|nul|com\d|lpt\d)(\.|$)/iu;
|
|
72
|
+
/** Writes events as run log lines: one JSON event per line, each ending in a line break. */
|
|
73
|
+
export function formatLogLines(events) {
|
|
74
|
+
return events.map((event) => `${JSON.stringify(event)}\n`).join("");
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Reads a run log's whole lines back into events. Every line must hold the
|
|
78
|
+
* run's next event, numbered from 1. Pass only whole lines, each ending in
|
|
79
|
+
* a line break: a torn last line, from a crash, is the adapter's to leave
|
|
80
|
+
* out first.
|
|
81
|
+
*
|
|
82
|
+
* @param lines - the log's whole lines, or `""` for an empty log
|
|
83
|
+
* @param runId - the run the log belongs to
|
|
84
|
+
* @param file - the log's name, for the error message
|
|
85
|
+
* @returns the events, in order
|
|
86
|
+
* @throws Error naming the file and line when a line is broken
|
|
87
|
+
*/
|
|
88
|
+
export function parseLogLines(lines, runId, file) {
|
|
89
|
+
if (lines === "") {
|
|
90
|
+
return [];
|
|
91
|
+
}
|
|
92
|
+
if (!lines.endsWith("\n")) {
|
|
93
|
+
throw new RangeError(`Only whole lines of run log ${file} can be read.`);
|
|
94
|
+
}
|
|
95
|
+
return lines
|
|
96
|
+
.slice(0, -1)
|
|
97
|
+
.split("\n")
|
|
98
|
+
.map((line, index) => parseLine(line, index + 1, runId, file));
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Whether a run id can be a plain file name in the run folder: 1 to 128
|
|
102
|
+
* letters, digits, `_`, `-` or `.`, not starting with a dot, and not a name
|
|
103
|
+
* Windows keeps for a device.
|
|
104
|
+
*/
|
|
105
|
+
export function isRunId(runId) {
|
|
106
|
+
return runIdPattern.test(runId) && !windowsDeviceName.test(runId);
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Refuses a run id that couldn't be a plain file name in the run folder:
|
|
110
|
+
* `..`, a separator, an absolute path, a name Windows keeps for a device.
|
|
111
|
+
*
|
|
112
|
+
* @throws RangeError naming the run id
|
|
113
|
+
*/
|
|
114
|
+
export function checkRunId(runId) {
|
|
115
|
+
if (!isRunId(runId)) {
|
|
116
|
+
throw new RangeError(`Unsafe run id ${JSON.stringify(runId)}: use 1 to 128 letters, digits, "_", "-" or ".", not starting with ".".`);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
function parseLine(line, seq, runId, file) {
|
|
120
|
+
let event;
|
|
121
|
+
try {
|
|
122
|
+
event = parseEventLine(line);
|
|
123
|
+
}
|
|
124
|
+
catch (error) {
|
|
125
|
+
throw new Error(`Broken run log ${file}, line ${seq}: ${error.message}`);
|
|
126
|
+
}
|
|
127
|
+
if (event.runId !== runId || event.seq !== seq) {
|
|
128
|
+
throw new Error(`Broken run log ${file}, line ${seq}: it holds event ${event.seq} of run ${event.runId}.`);
|
|
129
|
+
}
|
|
130
|
+
return event;
|
|
131
|
+
}
|
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Version of the {@link Sandbox} port. A breaking change bumps it and comes with an ADR.
|
|
3
|
+
*
|
|
4
|
+
* 2: {@link SandboxSession.fence} proves the fence before anything runs
|
|
5
|
+
* (docs/adr/2026-11-09-sandbox-fence-proof.md).
|
|
6
|
+
* 3: `SandboxCheck.reason` says why the sandbox can't start, as a listed code
|
|
7
|
+
* (docs/adr/2026-11-09-sandbox-check-reason-codes.md).
|
|
8
|
+
* 4: {@link SandboxNetwork.bridge} may be `null`: a session with no network
|
|
9
|
+
* but its listed sites (docs/adr/2026-11-10-sandbox-optional-bridge.md).
|
|
10
|
+
* 5: strength `none` and the fence proof `off`, for the launcher that starts
|
|
11
|
+
* programs without a fence (docs/adr/2026-11-11-sandbox-without-fence.md).
|
|
12
|
+
*/
|
|
13
|
+
export declare const sandboxVersion = 5;
|
|
14
|
+
/**
|
|
15
|
+
* How files reach the sandbox. `shared`: the program sees the same folders as
|
|
16
|
+
* Halonic, so nothing is copied (a sandbox on this computer). `copied`: the
|
|
17
|
+
* sandbox has its own file system, and the adapter syncs the working folder
|
|
18
|
+
* in before a run and out after it (a VM or Halonic Cloud).
|
|
19
|
+
*/
|
|
20
|
+
export type SandboxFileAccess = "shared" | "copied";
|
|
21
|
+
/**
|
|
22
|
+
* How strong the fence is. `os`: the operating system confines the program
|
|
23
|
+
* (kernel escapes are not covered). `vm`: a micro-VM, with its own kernel.
|
|
24
|
+
* `remote`: another machine. `none`: no fence at all, only the launcher
|
|
25
|
+
* (`sandbox-host`), for runs the user confirmed without the sandbox.
|
|
26
|
+
*/
|
|
27
|
+
export type SandboxStrength = "os" | "vm" | "remote" | "none";
|
|
28
|
+
/** What a sandbox adapter can do. */
|
|
29
|
+
export interface SandboxCapabilities {
|
|
30
|
+
/** How files reach the sandbox. */
|
|
31
|
+
files: SandboxFileAccess;
|
|
32
|
+
/** How strong the fence is. */
|
|
33
|
+
strength: SandboxStrength;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Every reason a sandbox can't start on this machine. The list is closed: an
|
|
37
|
+
* adapter returns only these, and a new reason is a port change. Studio and
|
|
38
|
+
* the CLI turn each one into the words a person reads and the fix; the
|
|
39
|
+
* adapter never words it.
|
|
40
|
+
*
|
|
41
|
+
* - `windows`: plain Windows, outside WSL2.
|
|
42
|
+
* - `container`: Halonic itself runs inside a container (such as Docker), which won't nest the fence.
|
|
43
|
+
* - `user-namespaces-restricted`: the system doesn't let programs create user namespaces, as Ubuntu 24.04 does by default.
|
|
44
|
+
* - `bubblewrap-missing`: bubblewrap (`bwrap`) is not installed.
|
|
45
|
+
* - `linux-tools-missing`: `socat` or ripgrep (`rg`), which srt starts next to bubblewrap, is not installed.
|
|
46
|
+
* - `other`: none of the above; `SandboxCheck.missing` says what.
|
|
47
|
+
*/
|
|
48
|
+
export declare const sandboxUnavailableReasons: readonly ["windows", "container", "user-namespaces-restricted", "bubblewrap-missing", "linux-tools-missing", "other"];
|
|
49
|
+
/** Why a sandbox can't start on this machine: one of {@link sandboxUnavailableReasons}. */
|
|
50
|
+
export type SandboxUnavailableReason = (typeof sandboxUnavailableReasons)[number];
|
|
51
|
+
/**
|
|
52
|
+
* Whether a sandbox works on this machine. `ok` is true when
|
|
53
|
+
* {@link Sandbox.open} can be expected to work; then there is no reason and
|
|
54
|
+
* nothing missing. Otherwise:
|
|
55
|
+
*
|
|
56
|
+
* - `reason` says why it can't start (since version 3). When more than one
|
|
57
|
+
* reason applies, the first in {@link sandboxUnavailableReasons}, because
|
|
58
|
+
* its fix comes first.
|
|
59
|
+
* - `missing` says what is missing, one plain sentence each, such as
|
|
60
|
+
* "bubblewrap is not installed". For logs and support, not for people:
|
|
61
|
+
* Studio words the refusal from `reason`.
|
|
62
|
+
*/
|
|
63
|
+
export type SandboxCheck = {
|
|
64
|
+
ok: true;
|
|
65
|
+
reason: null;
|
|
66
|
+
missing: [];
|
|
67
|
+
} | {
|
|
68
|
+
ok: false;
|
|
69
|
+
reason: SandboxUnavailableReason;
|
|
70
|
+
missing: string[];
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* What a program in the sandbox may reach. Halonic builds it from the
|
|
74
|
+
* person's profile and the trusted workspace, and the agent can't change it.
|
|
75
|
+
* Every path is absolute, in the host's notation.
|
|
76
|
+
*
|
|
77
|
+
* The profile is Halonic's own format, not that of a particular sandbox
|
|
78
|
+
* library, so an adapter for a VM or for Halonic Cloud reads the same one.
|
|
79
|
+
* It is a plain type and not a schema: Halonic builds it in process and never
|
|
80
|
+
* reads it from data, and a port may not import the schema package. An
|
|
81
|
+
* adapter that takes one from outside must check it itself.
|
|
82
|
+
*/
|
|
83
|
+
export interface SandboxProfile {
|
|
84
|
+
/** The one folder the program writes to, and where it starts. */
|
|
85
|
+
workingFolder: string;
|
|
86
|
+
/** A private temp folder, writable. A fresh one per session; the adapter doesn't clean it up. */
|
|
87
|
+
tempFolder: string;
|
|
88
|
+
/**
|
|
89
|
+
* The agent's own settings folder inside Halonic's data (such as
|
|
90
|
+
* `CLAUDE_CONFIG_DIR`), writable, never the person's own. `null` when the
|
|
91
|
+
* program needs none.
|
|
92
|
+
*/
|
|
93
|
+
settingsFolder: string | null;
|
|
94
|
+
/** Paths the program may read but not change, such as the workspace's definition files. */
|
|
95
|
+
readOnlyPaths: string[];
|
|
96
|
+
/** Paths the program may not read or write, such as SSH keys and Halonic's own data. Wins over every other list. */
|
|
97
|
+
deniedPaths: string[];
|
|
98
|
+
/**
|
|
99
|
+
* The only environment variables the program gets, by name and value. The
|
|
100
|
+
* host's own environment is never passed on.
|
|
101
|
+
*/
|
|
102
|
+
env: Readonly<Record<string, string>>;
|
|
103
|
+
/** The network. Everything not named here is blocked. */
|
|
104
|
+
network: SandboxNetwork;
|
|
105
|
+
/** How long the whole run may last, in milliseconds, counted from {@link Sandbox.open}. */
|
|
106
|
+
timeLimitMs: number;
|
|
107
|
+
}
|
|
108
|
+
/** The network a {@link SandboxProfile} allows. */
|
|
109
|
+
export interface SandboxNetwork {
|
|
110
|
+
/**
|
|
111
|
+
* The Halonic bridge: the one loopback address the program can reach. An
|
|
112
|
+
* adapter rejects a host that is not a loopback address (`127.0.0.1`, `::1`
|
|
113
|
+
* or `localhost`) when {@link Sandbox.open} is called.
|
|
114
|
+
*
|
|
115
|
+
* `null` means no bridge: the program reaches no loopback address at all,
|
|
116
|
+
* only the allowed sites. The integration runner uses it, because it talks
|
|
117
|
+
* to Halonic over its standard input and output, not the network. The field
|
|
118
|
+
* is never optional, so leaving it out can't mean "the whole network".
|
|
119
|
+
*/
|
|
120
|
+
bridge: {
|
|
121
|
+
host: string;
|
|
122
|
+
port: number;
|
|
123
|
+
} | null;
|
|
124
|
+
/**
|
|
125
|
+
* Further sites, by host name such as "registry.npmjs.org" or with a
|
|
126
|
+
* leading "*." for every subdomain. Empty by default.
|
|
127
|
+
*/
|
|
128
|
+
allowedSites: string[];
|
|
129
|
+
}
|
|
130
|
+
/** What to start in a session. */
|
|
131
|
+
export interface SandboxCommand {
|
|
132
|
+
/** The program, by name or path. */
|
|
133
|
+
program: string;
|
|
134
|
+
/** Its arguments, passed as they are, never through a shell. */
|
|
135
|
+
args: string[];
|
|
136
|
+
/** Where it starts: the working folder or a folder inside it. Absent means the working folder. */
|
|
137
|
+
cwd?: string;
|
|
138
|
+
}
|
|
139
|
+
/** How a started program ended. */
|
|
140
|
+
export interface SandboxExit {
|
|
141
|
+
/**
|
|
142
|
+
* The exit code, or `null` when a signal ended it. A program the fence can't
|
|
143
|
+
* find or run ends with a non-zero code, not `null`.
|
|
144
|
+
*/
|
|
145
|
+
code: number | null;
|
|
146
|
+
/** The signal that ended it, such as "SIGKILL", or `null`. */
|
|
147
|
+
signal: string | null;
|
|
148
|
+
/** Why: it finished by itself, it was stopped (`kill`, `close`, cancel), or the time limit ran out. */
|
|
149
|
+
reason: "exited" | "stopped" | "timeout";
|
|
150
|
+
}
|
|
151
|
+
/** A program a session started. */
|
|
152
|
+
export interface SandboxProcess {
|
|
153
|
+
/** Writes to the program's standard input. Close it to end the input. */
|
|
154
|
+
stdin: WritableStream<Uint8Array>;
|
|
155
|
+
/** The program's standard output, as bytes. */
|
|
156
|
+
stdout: ReadableStream<Uint8Array>;
|
|
157
|
+
/** The program's standard error, as bytes. */
|
|
158
|
+
stderr: ReadableStream<Uint8Array>;
|
|
159
|
+
/** Settles when the program and everything it started has ended. Never rejects. */
|
|
160
|
+
exited: Promise<SandboxExit>;
|
|
161
|
+
/** Stops the program and everything it started. Safe to call twice. */
|
|
162
|
+
kill(): Promise<void>;
|
|
163
|
+
}
|
|
164
|
+
/** An access the sandbox refused. It becomes the run's `sandbox.blocked` event. */
|
|
165
|
+
export type SandboxBlock = {
|
|
166
|
+
kind: "file";
|
|
167
|
+
path: string;
|
|
168
|
+
access: "read" | "write";
|
|
169
|
+
} | {
|
|
170
|
+
kind: "network";
|
|
171
|
+
host: string;
|
|
172
|
+
port: number | null;
|
|
173
|
+
};
|
|
174
|
+
/** Hears the session's blocked accesses. */
|
|
175
|
+
export type SandboxBlockListener = (block: SandboxBlock) => void;
|
|
176
|
+
/**
|
|
177
|
+
* Whether the fence is really around the session. Before a session starts any
|
|
178
|
+
* program, the adapter runs its own probes (a file the fence hides, and a
|
|
179
|
+
* loopback port the fence blocks) and reports what it found.
|
|
180
|
+
*
|
|
181
|
+
* `fenced`: the probes were refused, so programs run inside the fence.
|
|
182
|
+
* `not-fenced`: a probe got through, or could not run; `reason` says which, in
|
|
183
|
+
* one plain sentence, and {@link SandboxSession.start} throws.
|
|
184
|
+
* `off`: the adapter has no fence by design (strength `none`), so there is
|
|
185
|
+
* nothing to prove and programs start without one. Only the launcher reports
|
|
186
|
+
* it; a fenced adapter whose fence fails reports `not-fenced`, never `off`.
|
|
187
|
+
* `stopped`: the session is closed.
|
|
188
|
+
*/
|
|
189
|
+
export type SandboxFence = {
|
|
190
|
+
state: "fenced";
|
|
191
|
+
} | {
|
|
192
|
+
state: "not-fenced";
|
|
193
|
+
reason: string;
|
|
194
|
+
} | {
|
|
195
|
+
state: "off";
|
|
196
|
+
} | {
|
|
197
|
+
state: "stopped";
|
|
198
|
+
};
|
|
199
|
+
/** One run's sandbox: the programs it started, the fence they are in and the time limit. */
|
|
200
|
+
export interface SandboxSession {
|
|
201
|
+
/** The profile the session was opened with. */
|
|
202
|
+
readonly profile: SandboxProfile;
|
|
203
|
+
/**
|
|
204
|
+
* The fence proof. It is settled before {@link Sandbox.open} returns, so no
|
|
205
|
+
* untrusted code has loaded when it is read, and it becomes `stopped` after
|
|
206
|
+
* {@link SandboxSession.close}.
|
|
207
|
+
*/
|
|
208
|
+
readonly fence: SandboxFence;
|
|
209
|
+
/**
|
|
210
|
+
* Starts a program inside the fence.
|
|
211
|
+
*
|
|
212
|
+
* @throws when the session is closed, the fence proof is `not-fenced`, or the sandbox can't launch anything.
|
|
213
|
+
* A program that is missing inside the fence doesn't throw: it ends with a
|
|
214
|
+
* non-zero {@link SandboxExit.code}.
|
|
215
|
+
*/
|
|
216
|
+
start(command: SandboxCommand): Promise<SandboxProcess>;
|
|
217
|
+
/** Reports each blocked access from now on. Returns a function that stops the reports. */
|
|
218
|
+
onBlocked(listener: SandboxBlockListener): () => void;
|
|
219
|
+
/**
|
|
220
|
+
* Stops every program the session started, and everything they started, and
|
|
221
|
+
* resolves when they have ended. The session does this by itself when the
|
|
222
|
+
* time limit runs out or the signal given to {@link Sandbox.open} aborts.
|
|
223
|
+
* Safe to call twice.
|
|
224
|
+
*/
|
|
225
|
+
close(): Promise<void>;
|
|
226
|
+
}
|
|
227
|
+
/** Runs programs inside a fence: a sandbox on this computer today, a VM or Halonic Cloud later. */
|
|
228
|
+
export interface Sandbox {
|
|
229
|
+
/**
|
|
230
|
+
* Whether it works on this machine, and if not, why and what is missing.
|
|
231
|
+
* Never throws. When it isn't `ok`, Halonic doesn't run the step: it never
|
|
232
|
+
* falls back to running a program without the fence by itself. Only the
|
|
233
|
+
* user's saved yes for that reason sends a start to the launcher instead.
|
|
234
|
+
*/
|
|
235
|
+
check(): Promise<SandboxCheck>;
|
|
236
|
+
/** How files reach it and how strong the fence is. */
|
|
237
|
+
capabilities(): SandboxCapabilities;
|
|
238
|
+
/**
|
|
239
|
+
* Opens a session for one run. Cancelling the run, by aborting `signal`,
|
|
240
|
+
* closes the session.
|
|
241
|
+
*
|
|
242
|
+
* @throws when the sandbox doesn't work here (see {@link Sandbox.check}) or the profile can't be applied, including a bridge that is not a loopback address
|
|
243
|
+
*/
|
|
244
|
+
open(profile: SandboxProfile, options?: {
|
|
245
|
+
signal?: AbortSignal;
|
|
246
|
+
}): Promise<SandboxSession>;
|
|
247
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Version of the {@link Sandbox} port. A breaking change bumps it and comes with an ADR.
|
|
3
|
+
*
|
|
4
|
+
* 2: {@link SandboxSession.fence} proves the fence before anything runs
|
|
5
|
+
* (docs/adr/2026-11-09-sandbox-fence-proof.md).
|
|
6
|
+
* 3: `SandboxCheck.reason` says why the sandbox can't start, as a listed code
|
|
7
|
+
* (docs/adr/2026-11-09-sandbox-check-reason-codes.md).
|
|
8
|
+
* 4: {@link SandboxNetwork.bridge} may be `null`: a session with no network
|
|
9
|
+
* but its listed sites (docs/adr/2026-11-10-sandbox-optional-bridge.md).
|
|
10
|
+
* 5: strength `none` and the fence proof `off`, for the launcher that starts
|
|
11
|
+
* programs without a fence (docs/adr/2026-11-11-sandbox-without-fence.md).
|
|
12
|
+
*/
|
|
13
|
+
export const sandboxVersion = 5;
|
|
14
|
+
/**
|
|
15
|
+
* Every reason a sandbox can't start on this machine. The list is closed: an
|
|
16
|
+
* adapter returns only these, and a new reason is a port change. Studio and
|
|
17
|
+
* the CLI turn each one into the words a person reads and the fix; the
|
|
18
|
+
* adapter never words it.
|
|
19
|
+
*
|
|
20
|
+
* - `windows`: plain Windows, outside WSL2.
|
|
21
|
+
* - `container`: Halonic itself runs inside a container (such as Docker), which won't nest the fence.
|
|
22
|
+
* - `user-namespaces-restricted`: the system doesn't let programs create user namespaces, as Ubuntu 24.04 does by default.
|
|
23
|
+
* - `bubblewrap-missing`: bubblewrap (`bwrap`) is not installed.
|
|
24
|
+
* - `linux-tools-missing`: `socat` or ripgrep (`rg`), which srt starts next to bubblewrap, is not installed.
|
|
25
|
+
* - `other`: none of the above; `SandboxCheck.missing` says what.
|
|
26
|
+
*/
|
|
27
|
+
export const sandboxUnavailableReasons = [
|
|
28
|
+
"windows",
|
|
29
|
+
"container",
|
|
30
|
+
"user-namespaces-restricted",
|
|
31
|
+
"bubblewrap-missing",
|
|
32
|
+
"linux-tools-missing",
|
|
33
|
+
"other",
|
|
34
|
+
];
|