@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,174 @@
|
|
|
1
|
+
import { deepEqual } from "../../std/src/index.js";
|
|
2
|
+
import { isMap, isScalar, isSeq } from "yaml";
|
|
3
|
+
import { applyEditToData } from "./edit-data.js";
|
|
4
|
+
import { lineEndingOf } from "./edit-text.js";
|
|
5
|
+
import { addPair, deleteEntry, flowAncestor, insertItem, isFilledFlow, nodeAt, parse, replaceFlow, replaceScalar, replaceValue, } from "./splice-node.js";
|
|
6
|
+
/**
|
|
7
|
+
* Applies one edit by changing only the text of what it touches, so comments,
|
|
8
|
+
* key order, quoting and blank lines elsewhere stay byte for byte. Expects an
|
|
9
|
+
* edit that `applyEditToData` accepted on this text's data.
|
|
10
|
+
*
|
|
11
|
+
* New lines get the text's line ending and indent style. An edit inside a
|
|
12
|
+
* flow collection like `[a, b]` writes that collection again on its line.
|
|
13
|
+
*
|
|
14
|
+
* @returns the new text, or `undefined` for a layout it doesn't handle yet
|
|
15
|
+
* (a flow collection over several lines, or a text that mixes line endings)
|
|
16
|
+
*/
|
|
17
|
+
export function spliceEdit(text, edit) {
|
|
18
|
+
switch (lineEndingOf(text)) {
|
|
19
|
+
case "\n":
|
|
20
|
+
return spliceLines(text, edit);
|
|
21
|
+
case "\r\n":
|
|
22
|
+
// Every line break is `\r\n`, so this round trip is exact.
|
|
23
|
+
return spliceLines(text.replaceAll("\r\n", "\n"), edit)?.replaceAll("\n", "\r\n");
|
|
24
|
+
default:
|
|
25
|
+
// New lines would have to pick one of the endings.
|
|
26
|
+
return undefined;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
/** `spliceEdit` for a text whose line breaks are all `\n`. */
|
|
30
|
+
function spliceLines(text, edit) {
|
|
31
|
+
const parsed = parse(text);
|
|
32
|
+
const flow = flowAncestor(parsed, edit.path);
|
|
33
|
+
if (flow !== undefined) {
|
|
34
|
+
return spliceInFlow(parsed, edit, flow);
|
|
35
|
+
}
|
|
36
|
+
switch (edit.kind) {
|
|
37
|
+
case "set":
|
|
38
|
+
return spliceSet(parsed, edit.path, edit.value, edit.after);
|
|
39
|
+
case "delete":
|
|
40
|
+
return nodeAt(parsed, edit.path) === undefined ? text : deleteEntry(parsed, edit.path);
|
|
41
|
+
case "insert":
|
|
42
|
+
return insertItem(parsed, edit.path.slice(0, -1), edit.path[edit.path.length - 1], edit.value);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* An edit inside the flow collection at `edit.path.slice(0, length)`. A set
|
|
47
|
+
* of one scalar changes only its characters, when that reads back right;
|
|
48
|
+
* anything else writes the whole collection again.
|
|
49
|
+
*/
|
|
50
|
+
function spliceInFlow(parsed, edit, length) {
|
|
51
|
+
const flowPath = edit.path.slice(0, length);
|
|
52
|
+
const flow = nodeAt(parsed, flowPath);
|
|
53
|
+
if (!isFilledFlow(flow)) {
|
|
54
|
+
return undefined;
|
|
55
|
+
}
|
|
56
|
+
const value = applyEditToData(flow.toJS(parsed.document), {
|
|
57
|
+
...edit,
|
|
58
|
+
path: edit.path.slice(length),
|
|
59
|
+
});
|
|
60
|
+
if (!value.ok) {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
const target = nodeAt(parsed, edit.path);
|
|
64
|
+
if (edit.kind === "set" && isScalar(target) && !isCollectionValue(edit.value)) {
|
|
65
|
+
// In flow style `,` and brackets end a plain text, so check the result.
|
|
66
|
+
const spliced = replaceScalar(parsed, target, edit.value);
|
|
67
|
+
const after = spliced === undefined ? undefined : nodeAt(parse(spliced), flowPath);
|
|
68
|
+
if (after != null && deepEqual(after.toJS(parsed.document), value.value)) {
|
|
69
|
+
return spliced;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
return replaceFlow(parsed, flow, value.value);
|
|
73
|
+
}
|
|
74
|
+
/** Sets an existing value, or adds the first missing key with the maps under it. */
|
|
75
|
+
function spliceSet(parsed, path, value, after) {
|
|
76
|
+
for (let length = 0; length <= path.length; length++) {
|
|
77
|
+
const prefix = path.slice(0, length);
|
|
78
|
+
const node = nodeAt(parsed, prefix);
|
|
79
|
+
const nested = nest(path.slice(length), value);
|
|
80
|
+
if (node === undefined) {
|
|
81
|
+
// `after` names a sibling of the last key, so it only counts when that key is the new one.
|
|
82
|
+
const place = length === path.length ? after : undefined;
|
|
83
|
+
return addPair(parsed, prefix.slice(0, -1), String(path[length - 1]), nested, place);
|
|
84
|
+
}
|
|
85
|
+
if (length === path.length || isEmpty(node)) {
|
|
86
|
+
return setNode(parsed, prefix, node, nested);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return undefined;
|
|
90
|
+
}
|
|
91
|
+
function setNode(parsed, path, node, value) {
|
|
92
|
+
const current = node === null ? null : node.toJS(parsed.document);
|
|
93
|
+
if (deepEqual(current, value)) {
|
|
94
|
+
return parsed.text;
|
|
95
|
+
}
|
|
96
|
+
if (isMap(node) && node.flow !== true && isFilledRecord(value) && node.items.length > 0) {
|
|
97
|
+
return applyAll(parsed.text, mapChanges(path, current, value));
|
|
98
|
+
}
|
|
99
|
+
if (isSeq(node) && node.flow !== true && isFilledList(value) && node.items.length > 0) {
|
|
100
|
+
return applyAll(parsed.text, listChanges(path, current, value));
|
|
101
|
+
}
|
|
102
|
+
if (isFilledFlow(node) && isCollectionValue(value)) {
|
|
103
|
+
return replaceFlow(parsed, node, value);
|
|
104
|
+
}
|
|
105
|
+
if (isScalar(node) && !isCollectionValue(value)) {
|
|
106
|
+
const spliced = replaceScalar(parsed, node, value);
|
|
107
|
+
if (spliced !== undefined) {
|
|
108
|
+
return spliced;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
return replaceValue(parsed, path, value);
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* A whole-map set as key edits: changed keys are set (and diffed further),
|
|
115
|
+
* new keys are added at the end, and keys the new map lacks are deleted.
|
|
116
|
+
*/
|
|
117
|
+
function mapChanges(path, current, value) {
|
|
118
|
+
const sets = Object.entries(value)
|
|
119
|
+
.filter(([key, child]) => !(Object.hasOwn(current, key) && deepEqual(current[key], child)))
|
|
120
|
+
.map(([key, child]) => ({ kind: "set", path: [...path, key], value: child }));
|
|
121
|
+
const deletes = Object.keys(current)
|
|
122
|
+
.filter((key) => !Object.hasOwn(value, key))
|
|
123
|
+
.map((key) => ({ kind: "delete", path: [...path, key] }));
|
|
124
|
+
// Sets first, so a map never empties out on the way and turns into `{}`.
|
|
125
|
+
return [...sets, ...deletes];
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* A whole-list set as item edits, compared index by index: the shared
|
|
129
|
+
* indexes are set, then new items are added at the end or extra ones
|
|
130
|
+
* deleted from the end.
|
|
131
|
+
*/
|
|
132
|
+
function listChanges(path, current, value) {
|
|
133
|
+
const changes = [];
|
|
134
|
+
const shared = Math.min(current.length, value.length);
|
|
135
|
+
for (let index = 0; index < shared; index++) {
|
|
136
|
+
if (!deepEqual(current[index], value[index])) {
|
|
137
|
+
changes.push({ kind: "set", path: [...path, index], value: value[index] });
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
for (let index = shared; index < value.length; index++) {
|
|
141
|
+
changes.push({ kind: "insert", path: [...path, index], value: value[index] });
|
|
142
|
+
}
|
|
143
|
+
for (let index = current.length - 1; index >= value.length; index--) {
|
|
144
|
+
changes.push({ kind: "delete", path: [...path, index] });
|
|
145
|
+
}
|
|
146
|
+
return changes;
|
|
147
|
+
}
|
|
148
|
+
function applyAll(text, edits) {
|
|
149
|
+
let current = text;
|
|
150
|
+
for (const edit of edits) {
|
|
151
|
+
current = spliceLines(current, edit);
|
|
152
|
+
if (current === undefined) {
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
return current;
|
|
157
|
+
}
|
|
158
|
+
/** `value` under the keys of `path`, as maps: `["a", "b"], 1` gives `{ a: { b: 1 } }`. */
|
|
159
|
+
function nest(path, value) {
|
|
160
|
+
return path.reduceRight((inner, key) => Object.fromEntries([[key, inner]]), value);
|
|
161
|
+
}
|
|
162
|
+
/** An empty document or a `key:` with no value: `set` builds the maps below it. */
|
|
163
|
+
function isEmpty(node) {
|
|
164
|
+
return node === null || (isScalar(node) && node.value === null);
|
|
165
|
+
}
|
|
166
|
+
function isCollectionValue(value) {
|
|
167
|
+
return typeof value === "object" && value !== null;
|
|
168
|
+
}
|
|
169
|
+
function isFilledRecord(value) {
|
|
170
|
+
return (isCollectionValue(value) && !Array.isArray(value) && Object.keys(value).length > 0);
|
|
171
|
+
}
|
|
172
|
+
function isFilledList(value) {
|
|
173
|
+
return Array.isArray(value) && value.length > 0;
|
|
174
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { type Node } from "yaml";
|
|
2
|
+
import type { YamlProblemKind } from "./problem.js";
|
|
3
|
+
/** What `findUnsupported` reports: the node at fault and why. */
|
|
4
|
+
export interface UnsupportedNode {
|
|
5
|
+
readonly node: Node;
|
|
6
|
+
readonly kind: Extract<YamlProblemKind, "unsupported" | "too-deep">;
|
|
7
|
+
readonly message: string;
|
|
8
|
+
}
|
|
9
|
+
/** Explains each YAML feature that workspace files may not use. */
|
|
10
|
+
export declare const unsupportedMessages: {
|
|
11
|
+
readonly anchor: "Anchors (&name) are not supported in workspace files. Write the value out in full.";
|
|
12
|
+
readonly alias: "Aliases (*name) are not supported in workspace files. Write the value out in full.";
|
|
13
|
+
readonly tag: 'Tags such as "!!str" are not supported in workspace files. Remove the tag, and quote the value if it must stay text.';
|
|
14
|
+
readonly collectionKey: "Lists and maps are not supported as keys in workspace files. Use a plain key.";
|
|
15
|
+
readonly multipleDocuments: 'Workspace files hold one YAML document. Remove the second "---" or split the file.';
|
|
16
|
+
};
|
|
17
|
+
/** Explains that the lists and maps nest deeper than `maxDepth`. */
|
|
18
|
+
export declare function tooDeepMessage(maxDepth: number): string;
|
|
19
|
+
/**
|
|
20
|
+
* Walks the parsed nodes in document order and returns the first one that
|
|
21
|
+
* uses an unsupported feature or nests deeper than `maxDepth`.
|
|
22
|
+
*
|
|
23
|
+
* The walk keeps its own stack instead of recursing, so a hostile file
|
|
24
|
+
* cannot overflow the call stack.
|
|
25
|
+
*/
|
|
26
|
+
export declare function findUnsupported(root: unknown, maxDepth: number): UnsupportedNode | undefined;
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { isAlias, isCollection, isMap, isNode, isPair, isSeq } from "yaml";
|
|
2
|
+
/** Explains each YAML feature that workspace files may not use. */
|
|
3
|
+
export const unsupportedMessages = {
|
|
4
|
+
anchor: "Anchors (&name) are not supported in workspace files. Write the value out in full.",
|
|
5
|
+
alias: "Aliases (*name) are not supported in workspace files. Write the value out in full.",
|
|
6
|
+
tag: 'Tags such as "!!str" are not supported in workspace files. Remove the tag, and quote the value if it must stay text.',
|
|
7
|
+
collectionKey: "Lists and maps are not supported as keys in workspace files. Use a plain key.",
|
|
8
|
+
multipleDocuments: 'Workspace files hold one YAML document. Remove the second "---" or split the file.',
|
|
9
|
+
};
|
|
10
|
+
/** Explains that the lists and maps nest deeper than `maxDepth`. */
|
|
11
|
+
export function tooDeepMessage(maxDepth) {
|
|
12
|
+
return `Lists and maps nest more than ${maxDepth} levels deep. Workspace files never need that many; look for a runaway structure.`;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Walks the parsed nodes in document order and returns the first one that
|
|
16
|
+
* uses an unsupported feature or nests deeper than `maxDepth`.
|
|
17
|
+
*
|
|
18
|
+
* The walk keeps its own stack instead of recursing, so a hostile file
|
|
19
|
+
* cannot overflow the call stack.
|
|
20
|
+
*/
|
|
21
|
+
export function findUnsupported(root, maxDepth) {
|
|
22
|
+
const stack = [{ node: root, depth: 0 }];
|
|
23
|
+
for (let next = stack.pop(); next !== undefined; next = stack.pop()) {
|
|
24
|
+
const { node, depth } = next;
|
|
25
|
+
if (!isNode(node)) {
|
|
26
|
+
continue;
|
|
27
|
+
}
|
|
28
|
+
const problem = problemWith(node, depth, maxDepth);
|
|
29
|
+
if (problem !== undefined) {
|
|
30
|
+
return problem;
|
|
31
|
+
}
|
|
32
|
+
// Push in reverse, so the first child comes off the stack first.
|
|
33
|
+
for (const child of childrenOf(node).reverse()) {
|
|
34
|
+
stack.push({ node: child, depth: depth + 1 });
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
return undefined;
|
|
38
|
+
}
|
|
39
|
+
function problemWith(node, depth, maxDepth) {
|
|
40
|
+
if (isAlias(node)) {
|
|
41
|
+
return { node, kind: "unsupported", message: unsupportedMessages.alias };
|
|
42
|
+
}
|
|
43
|
+
if (node.anchor !== undefined) {
|
|
44
|
+
return { node, kind: "unsupported", message: unsupportedMessages.anchor };
|
|
45
|
+
}
|
|
46
|
+
if (node.tag !== undefined) {
|
|
47
|
+
return { node, kind: "unsupported", message: unsupportedMessages.tag };
|
|
48
|
+
}
|
|
49
|
+
if (isCollection(node) && depth >= maxDepth) {
|
|
50
|
+
return { node, kind: "too-deep", message: tooDeepMessage(maxDepth) };
|
|
51
|
+
}
|
|
52
|
+
if (isMap(node)) {
|
|
53
|
+
const collectionKey = node.items.find((pair) => isCollection(pair.key));
|
|
54
|
+
if (collectionKey !== undefined) {
|
|
55
|
+
return {
|
|
56
|
+
node: collectionKey.key,
|
|
57
|
+
kind: "unsupported",
|
|
58
|
+
message: unsupportedMessages.collectionKey,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
return undefined;
|
|
63
|
+
}
|
|
64
|
+
/** The keys and values inside a list or map, in document order. */
|
|
65
|
+
function childrenOf(node) {
|
|
66
|
+
if (!isMap(node) && !isSeq(node)) {
|
|
67
|
+
return [];
|
|
68
|
+
}
|
|
69
|
+
return node.items.flatMap((item) => (isPair(item) ? [item.key, item.value] : [item]));
|
|
70
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writes data as a workspace YAML file, with exactly the text the old app
|
|
3
|
+
* wrote (`stringify(value, { lineWidth: 100 })` in 784f78d), so the first
|
|
4
|
+
* save in the new Studio doesn't rewrite every file.
|
|
5
|
+
*
|
|
6
|
+
* It writes what it is given: dropping empty values first is up to the caller.
|
|
7
|
+
*
|
|
8
|
+
* @param value - plain data: objects, arrays, strings, numbers, booleans, `null`
|
|
9
|
+
* @returns the YAML text, ending in a newline
|
|
10
|
+
* @throws AssertionError when `value` has no YAML form, such as `undefined`
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* writeYamlFile({ name: "Billing", enabled: "yes" });
|
|
14
|
+
* // 'name: Billing\nenabled: "yes"\n'
|
|
15
|
+
*/
|
|
16
|
+
export declare function writeYamlFile(value: unknown): string;
|
|
17
|
+
/** The two fields the old app wrote into the front matter of a `SKILL.md`. */
|
|
18
|
+
export interface FrontMatterFields {
|
|
19
|
+
readonly name: string;
|
|
20
|
+
readonly description: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Writes the fields of a Markdown front matter block, with exactly the text
|
|
24
|
+
* the old app wrote for `SKILL.md` (`stringify(fields).trim()` in 784f78d:
|
|
25
|
+
* the default line width of 80, no trailing newline). Adding the `---` lines
|
|
26
|
+
* around it is up to the caller.
|
|
27
|
+
*
|
|
28
|
+
* @param fields - the front matter fields
|
|
29
|
+
* @returns the YAML text, without a trailing newline
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* writeFrontMatter({ name: "invoice-style", description: "How invoices read" });
|
|
33
|
+
* // 'name: invoice-style\ndescription: How invoices read'
|
|
34
|
+
*/
|
|
35
|
+
export declare function writeFrontMatter(fields: FrontMatterFields): string;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { assert } from "../../std/src/index.js";
|
|
2
|
+
import { stringify } from "yaml";
|
|
3
|
+
/** The line width the old app wrote workspace files with. */
|
|
4
|
+
const fileLineWidth = 100;
|
|
5
|
+
/**
|
|
6
|
+
* Writes data as a workspace YAML file, with exactly the text the old app
|
|
7
|
+
* wrote (`stringify(value, { lineWidth: 100 })` in 784f78d), so the first
|
|
8
|
+
* save in the new Studio doesn't rewrite every file.
|
|
9
|
+
*
|
|
10
|
+
* It writes what it is given: dropping empty values first is up to the caller.
|
|
11
|
+
*
|
|
12
|
+
* @param value - plain data: objects, arrays, strings, numbers, booleans, `null`
|
|
13
|
+
* @returns the YAML text, ending in a newline
|
|
14
|
+
* @throws AssertionError when `value` has no YAML form, such as `undefined`
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* writeYamlFile({ name: "Billing", enabled: "yes" });
|
|
18
|
+
* // 'name: Billing\nenabled: "yes"\n'
|
|
19
|
+
*/
|
|
20
|
+
export function writeYamlFile(value) {
|
|
21
|
+
return stringifyOrThrow(value, { lineWidth: fileLineWidth });
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Writes the fields of a Markdown front matter block, with exactly the text
|
|
25
|
+
* the old app wrote for `SKILL.md` (`stringify(fields).trim()` in 784f78d:
|
|
26
|
+
* the default line width of 80, no trailing newline). Adding the `---` lines
|
|
27
|
+
* around it is up to the caller.
|
|
28
|
+
*
|
|
29
|
+
* @param fields - the front matter fields
|
|
30
|
+
* @returns the YAML text, without a trailing newline
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* writeFrontMatter({ name: "invoice-style", description: "How invoices read" });
|
|
34
|
+
* // 'name: invoice-style\ndescription: How invoices read'
|
|
35
|
+
*/
|
|
36
|
+
export function writeFrontMatter(fields) {
|
|
37
|
+
return stringifyOrThrow(fields).trim();
|
|
38
|
+
}
|
|
39
|
+
function stringifyOrThrow(value, options) {
|
|
40
|
+
// `stringify` returns undefined, not text, for undefined and functions.
|
|
41
|
+
const text = stringify(value, options);
|
|
42
|
+
assert(text !== undefined, `Expected data that YAML can hold, but got ${typeof value}.`);
|
|
43
|
+
return text;
|
|
44
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Secrets } from "../../../core/ports/src/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* The fake value the suite configures for a secret. A check fails when a
|
|
4
|
+
* canary shows up anywhere but the place the kit put it: a tool result, an
|
|
5
|
+
* error, the request log, or a request to a host the secret may not go to.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* canaryFor("openai-key"); // "CANARY-openai-key-5f1d"
|
|
9
|
+
*/
|
|
10
|
+
export declare function canaryFor(secret: string): string;
|
|
11
|
+
/** Every canary starts with this, so one search finds them all. */
|
|
12
|
+
export declare const canaryMark = "CANARY-";
|
|
13
|
+
/** A `Secrets` port that answers every name with its canary. */
|
|
14
|
+
export declare const canarySecrets: Secrets;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The fake value the suite configures for a secret. A check fails when a
|
|
3
|
+
* canary shows up anywhere but the place the kit put it: a tool result, an
|
|
4
|
+
* error, the request log, or a request to a host the secret may not go to.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* canaryFor("openai-key"); // "CANARY-openai-key-5f1d"
|
|
8
|
+
*/
|
|
9
|
+
export function canaryFor(secret) {
|
|
10
|
+
return `CANARY-${secret}-5f1d`;
|
|
11
|
+
}
|
|
12
|
+
/** Every canary starts with this, so one search finds them all. */
|
|
13
|
+
export const canaryMark = "CANARY-";
|
|
14
|
+
/** A `Secrets` port that answers every name with its canary. */
|
|
15
|
+
export const canarySecrets = {
|
|
16
|
+
get: async (name) => canaryFor(name),
|
|
17
|
+
};
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { type ConformanceSubject, type ToolCase } from "./run.js";
|
|
2
|
+
/**
|
|
3
|
+
* The sheet passes its schema, and the integration is exactly what it says:
|
|
4
|
+
* kit version, name, version, and each tool's text, arguments, `risk` and
|
|
5
|
+
* `untrusted`, as the kit's loader checks them. Every case calls a declared
|
|
6
|
+
* tool, and every recording is a valid `halonic.recording/1` file of this
|
|
7
|
+
* integration.
|
|
8
|
+
*/
|
|
9
|
+
export declare function checkDeclaration(subject: ConformanceSubject): void;
|
|
10
|
+
/**
|
|
11
|
+
* Every host in the sheet resolves with the subject's settings: a
|
|
12
|
+
* `{ fromSetting }` host has a URL, plain `http` goes only to a local
|
|
13
|
+
* address, and a secret goes over it only to this machine.
|
|
14
|
+
*/
|
|
15
|
+
export declare function checkPolicy(subject: ConformanceSubject): void;
|
|
16
|
+
/** Connecting sends nothing, and closing twice is safe. */
|
|
17
|
+
export declare function checkConnectIsQuiet(subject: ConformanceSubject): Promise<void>;
|
|
18
|
+
/**
|
|
19
|
+
* The tool answers from the recordings, only through its host, with no
|
|
20
|
+
* refused request and no secret anywhere it doesn't belong.
|
|
21
|
+
*/
|
|
22
|
+
export declare function checkCase(subject: ConformanceSubject, toolCase: ToolCase): Promise<string>;
|
|
23
|
+
/** An aborted call rejects. */
|
|
24
|
+
export declare function checkAbort(subject: ConformanceSubject, toolCase: ToolCase): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* When the provider answers with an error, the tool fails or answers
|
|
27
|
+
* without passing the provider's body through.
|
|
28
|
+
*/
|
|
29
|
+
export declare function checkProviderErrors(subject: ConformanceSubject, toolCase: ToolCase): Promise<void>;
|
|
30
|
+
/**
|
|
31
|
+
* The host's `wait`, real and fake alike, waits at most 30 s and rejects
|
|
32
|
+
* with the signal's reason when the signal is already aborted or aborts
|
|
33
|
+
* during the wait.
|
|
34
|
+
*/
|
|
35
|
+
export declare function checkHostWait(subject: ConformanceSubject): Promise<void>;
|
|
36
|
+
/** The source uses nothing that reaches past its host. */
|
|
37
|
+
export declare function checkSources(subject: ConformanceSubject): void;
|
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
import { clampWaitMs, declarationProblems } from "../../../adapters/integration-kit/src/index.js";
|
|
2
|
+
import { recordingFileSchema } from "../../../core/format/src/recording/index.js";
|
|
3
|
+
import { maxIntegrationWaitMs } from "../../../core/ports/src/index.js";
|
|
4
|
+
import { parse } from "../../../core/schema-kit/src/index.js";
|
|
5
|
+
import { canaryFor, canaryMark } from "./canaries.js";
|
|
6
|
+
import { fail } from "./failure.js";
|
|
7
|
+
import { fakeWait } from "./fake-wait.js";
|
|
8
|
+
import { loadSubject, policyOf, sheetOf } from "./load.js";
|
|
9
|
+
import { replayTransport } from "./recording.js";
|
|
10
|
+
import { runCase, scenarioOf, } from "./run.js";
|
|
11
|
+
import { scanIntegrationSource } from "./source-scan.js";
|
|
12
|
+
/**
|
|
13
|
+
* The sheet passes its schema, and the integration is exactly what it says:
|
|
14
|
+
* kit version, name, version, and each tool's text, arguments, `risk` and
|
|
15
|
+
* `untrusted`, as the kit's loader checks them. Every case calls a declared
|
|
16
|
+
* tool, and every recording is a valid `halonic.recording/1` file of this
|
|
17
|
+
* integration.
|
|
18
|
+
*/
|
|
19
|
+
export function checkDeclaration(subject) {
|
|
20
|
+
const sheet = sheetOf(subject);
|
|
21
|
+
const problems = declarationProblems(sheet, subject.integration);
|
|
22
|
+
if (problems.length > 0)
|
|
23
|
+
fail(problems.map((problem) => problem.message).join("\n"));
|
|
24
|
+
checkRecordings(subject);
|
|
25
|
+
const tools = new Set(sheet.tools.map((tool) => tool.name));
|
|
26
|
+
for (const toolCase of subject.cases) {
|
|
27
|
+
if (!tools.has(toolCase.tool))
|
|
28
|
+
fail(`a case calls "${toolCase.tool}", which isn't declared`);
|
|
29
|
+
if (scenarioOf(subject, toolCase) === undefined)
|
|
30
|
+
fail(`a case replays the scenario "${toolCase.scenario}", which has no recording`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
/** Every recording passes the format's schema and belongs to this integration. */
|
|
34
|
+
function checkRecordings(subject) {
|
|
35
|
+
for (const [index, recording] of subject.recordings.entries()) {
|
|
36
|
+
const parsed = parse(recordingFileSchema, recording);
|
|
37
|
+
if (!parsed.ok) {
|
|
38
|
+
const issues = parsed.error.map((issue) => `${issue.path.join(".")}: ${issue.message}`);
|
|
39
|
+
fail(`recording ${index + 1} isn't a valid halonic.recording/1 file:\n${issues.join("\n")}`);
|
|
40
|
+
}
|
|
41
|
+
if (recording.integration !== subject.integration.name)
|
|
42
|
+
fail(`the recording "${recording.scenario}" is for "${recording.integration}"`);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Every host in the sheet resolves with the subject's settings: a
|
|
47
|
+
* `{ fromSetting }` host has a URL, plain `http` goes only to a local
|
|
48
|
+
* address, and a secret goes over it only to this machine.
|
|
49
|
+
*/
|
|
50
|
+
export function checkPolicy(subject) {
|
|
51
|
+
policyOf(subject);
|
|
52
|
+
}
|
|
53
|
+
/** Connecting sends nothing, and closing twice is safe. */
|
|
54
|
+
export async function checkConnectIsQuiet(subject) {
|
|
55
|
+
const replay = replayTransport(undefined);
|
|
56
|
+
const { host } = loadSubject(subject, replay.transport);
|
|
57
|
+
const connection = subject.integration.connect(host);
|
|
58
|
+
await connection.close();
|
|
59
|
+
await connection.close();
|
|
60
|
+
if (replay.seen.length > 0)
|
|
61
|
+
fail(`connecting sent ${replay.seen.length} request(s); wait for the first call`);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The tool answers from the recordings, only through its host, with no
|
|
65
|
+
* refused request and no secret anywhere it doesn't belong.
|
|
66
|
+
*/
|
|
67
|
+
export async function checkCase(subject, toolCase) {
|
|
68
|
+
const run = await runCase(subject, toolCase);
|
|
69
|
+
checkNoBypass(run);
|
|
70
|
+
checkNoLeak(subject, run);
|
|
71
|
+
if (run.error !== undefined)
|
|
72
|
+
fail(`"${toolCase.tool}" failed: ${messageOf(run.error)}`);
|
|
73
|
+
const result = run.result ?? fail(`"${toolCase.tool}" returned nothing`);
|
|
74
|
+
if (run.unusedExchanges > 0) {
|
|
75
|
+
fail(`"${toolCase.tool}" made ${run.unusedExchanges} request(s) fewer than the recording "${toolCase.scenario}" has`);
|
|
76
|
+
}
|
|
77
|
+
if (toolCase.waits !== undefined && run.waits.join() !== toolCase.waits.join()) {
|
|
78
|
+
fail(`"${toolCase.tool}" waited [${run.waits.join(", ")}] ms, the case expects [${toolCase.waits.join(", ")}]`);
|
|
79
|
+
}
|
|
80
|
+
toolCase.check?.(result);
|
|
81
|
+
return result;
|
|
82
|
+
}
|
|
83
|
+
/** An aborted call rejects. */
|
|
84
|
+
export async function checkAbort(subject, toolCase) {
|
|
85
|
+
const run = await runCase(subject, toolCase, {
|
|
86
|
+
signal: AbortSignal.abort(new Error("aborted by the suite")),
|
|
87
|
+
});
|
|
88
|
+
checkNoBypass(run);
|
|
89
|
+
if (run.error === undefined)
|
|
90
|
+
fail(`"${toolCase.tool}" ignored an aborted signal`);
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* When the provider answers with an error, the tool fails or answers
|
|
94
|
+
* without passing the provider's body through.
|
|
95
|
+
*/
|
|
96
|
+
export async function checkProviderErrors(subject, toolCase) {
|
|
97
|
+
const providerBody = `PROVIDER-BODY ${Object.keys(sheetOf(subject).secrets).map(canaryFor).join(" ")}`;
|
|
98
|
+
const recorded = scenarioOf(subject, toolCase);
|
|
99
|
+
const recording = recorded && {
|
|
100
|
+
...recorded,
|
|
101
|
+
exchanges: recorded.exchanges.map((exchange) => ({
|
|
102
|
+
...exchange,
|
|
103
|
+
response: {
|
|
104
|
+
status: 500,
|
|
105
|
+
headers: {},
|
|
106
|
+
body: { kind: "text", contentType: "text/plain", value: providerBody },
|
|
107
|
+
},
|
|
108
|
+
})),
|
|
109
|
+
};
|
|
110
|
+
const run = await runCase(subject, toolCase, recording ? { recording } : {});
|
|
111
|
+
checkNoBypass(run);
|
|
112
|
+
const shown = `${run.result ?? ""} ${run.error === undefined ? "" : messageOf(run.error)}`;
|
|
113
|
+
if (shown.includes("PROVIDER-BODY") || shown.includes(canaryMark)) {
|
|
114
|
+
fail(`"${toolCase.tool}" passed the provider's error body through`);
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
* The host's `wait`, real and fake alike, waits at most 30 s and rejects
|
|
119
|
+
* with the signal's reason when the signal is already aborted or aborts
|
|
120
|
+
* during the wait.
|
|
121
|
+
*/
|
|
122
|
+
export async function checkHostWait(subject) {
|
|
123
|
+
const clamps = [
|
|
124
|
+
[Number.NaN, 0],
|
|
125
|
+
[-1, 0],
|
|
126
|
+
[2_000, 2_000],
|
|
127
|
+
[Number.POSITIVE_INFINITY, maxIntegrationWaitMs],
|
|
128
|
+
];
|
|
129
|
+
const fake = fakeWait();
|
|
130
|
+
for (const [ms] of clamps)
|
|
131
|
+
await fake.wait(ms);
|
|
132
|
+
for (const [index, [ms, expected]] of clamps.entries()) {
|
|
133
|
+
if (clampWaitMs(ms) !== expected || fake.waits[index] !== expected)
|
|
134
|
+
fail(`wait(${ms}) must wait ${expected} ms`);
|
|
135
|
+
}
|
|
136
|
+
const { host } = loadSubject(subject, replayTransport(undefined).transport);
|
|
137
|
+
for (const wait of [host.wait, fake.wait]) {
|
|
138
|
+
const already = new Error("aborted before the wait");
|
|
139
|
+
await expectRejection(wait(maxIntegrationWaitMs, AbortSignal.abort(already)), already);
|
|
140
|
+
}
|
|
141
|
+
const controller = new AbortController();
|
|
142
|
+
const during = new Error("aborted during the wait");
|
|
143
|
+
const waiting = host.wait(maxIntegrationWaitMs, controller.signal);
|
|
144
|
+
controller.abort(during);
|
|
145
|
+
await expectRejection(waiting, during);
|
|
146
|
+
}
|
|
147
|
+
async function expectRejection(waiting, reason) {
|
|
148
|
+
const outcome = await waiting.then(() => "resolved", (thrown) => (thrown === reason ? "rejected" : `rejected with ${messageOf(thrown)}`));
|
|
149
|
+
if (outcome !== "rejected")
|
|
150
|
+
fail(`wait must reject with the signal's reason ("${reason.message}") but ${outcome}`);
|
|
151
|
+
}
|
|
152
|
+
/** The source uses nothing that reaches past its host. */
|
|
153
|
+
export function checkSources(subject) {
|
|
154
|
+
const findings = scanIntegrationSource(subject.sources ?? {});
|
|
155
|
+
if (findings.length > 0) {
|
|
156
|
+
fail(findings.map((f) => `${f.file}:${f.line}: ${f.rule}`).join("\n"));
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
function checkNoBypass(run) {
|
|
160
|
+
if (run.globalCalls.length > 0)
|
|
161
|
+
fail(`the integration used the global ${run.globalCalls.join(", ")}; use host.http`);
|
|
162
|
+
const refused = run.log.filter((entry) => entry.outcome === "refused");
|
|
163
|
+
if (refused.length > 0) {
|
|
164
|
+
fail(refused.map((e) => `the kit refused ${refusedRequest(e)}: ${e.refusal}`).join("\n"));
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* The method, host and path of a refused request. The kit logs none of them
|
|
169
|
+
* for a refusal that comes before its secret check, since they may hold a key.
|
|
170
|
+
*/
|
|
171
|
+
function refusedRequest(entry) {
|
|
172
|
+
return entry.host === "" ? "a request" : `${entry.method} ${entry.host}${entry.path}`;
|
|
173
|
+
}
|
|
174
|
+
function checkNoLeak(subject, run) {
|
|
175
|
+
const policy = policyOf(subject);
|
|
176
|
+
const shown = `${run.result ?? ""}\n${run.error === undefined ? "" : messageOf(run.error)}`;
|
|
177
|
+
if (shown.includes(canaryMark))
|
|
178
|
+
fail("a secret value appears in the tool's result or error");
|
|
179
|
+
if (JSON.stringify(run.log).includes(canaryMark))
|
|
180
|
+
fail("a secret value appears in the request log");
|
|
181
|
+
for (const request of run.seen) {
|
|
182
|
+
const url = new URL(request.url);
|
|
183
|
+
if (request.url.includes(canaryMark))
|
|
184
|
+
fail(`a secret value was put in the URL of ${url.host}${url.pathname}`);
|
|
185
|
+
const carried = `${JSON.stringify(request.headers)}\n${request.body ?? ""}`;
|
|
186
|
+
for (const [secret, { hosts }] of Object.entries(policy.secrets)) {
|
|
187
|
+
if (carried.includes(canaryFor(secret)) && !hosts.includes(url.host)) {
|
|
188
|
+
fail(`the secret "${secret}" went to ${url.host}, which it may not go to`);
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
function messageOf(error) {
|
|
194
|
+
return error instanceof Error ? error.message : String(error);
|
|
195
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { type PluginConformanceSubject } from "./plugin.js";
|
|
2
|
+
import type { ConformanceSubject } from "./run.js";
|
|
3
|
+
/**
|
|
4
|
+
* Registers the conformance suite for one integration with Vitest. Every
|
|
5
|
+
* integration package calls it once from a test file.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* describeIntegrationConformance({
|
|
9
|
+
* integration: weather,
|
|
10
|
+
* sheet: JSON.parse(readFileSync("integration.json", "utf8")), // the sheet the build writes
|
|
11
|
+
* recordings: [forecastGhent],
|
|
12
|
+
* cases: [{ tool: "forecast", scenario: "forecast-ghent", args: { city: "Ghent" } }],
|
|
13
|
+
* sources: { "src/index.ts": readFileSync("src/index.ts", "utf8") },
|
|
14
|
+
* });
|
|
15
|
+
*/
|
|
16
|
+
export declare function describeIntegrationConformance(subject: ConformanceSubject): void;
|
|
17
|
+
/**
|
|
18
|
+
* Registers the conformance suite for one plugin folder with Vitest: its
|
|
19
|
+
* manifest, then every integration check on its backend, if it has one.
|
|
20
|
+
* Every plugin calls it once from a test file.
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* describePluginConformance({
|
|
24
|
+
* folder: fileURLToPath(new URL("..", import.meta.url)),
|
|
25
|
+
* backend: weather, // what backend/index.js exports
|
|
26
|
+
* recordings: [forecastGhent],
|
|
27
|
+
* cases: [{ tool: "forecast", scenario: "forecast-ghent", args: { place: "Ghent" } }],
|
|
28
|
+
* });
|
|
29
|
+
*/
|
|
30
|
+
export declare function describePluginConformance(subject: PluginConformanceSubject): void;
|
|
31
|
+
/**
|
|
32
|
+
* Runs one check as an assertion, so the test counts it (a test without an
|
|
33
|
+
* assertion fails) and a failed check still shows its own message.
|
|
34
|
+
*/
|
|
35
|
+
export declare function passes(check: () => unknown): Promise<void>;
|