@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,14 @@
|
|
|
1
|
+
export { declarationProblems } from "./declaration.js";
|
|
2
|
+
export { type CreatedIntegrationHost, createIntegrationHost, type IntegrationHostOptions, } from "./host.js";
|
|
3
|
+
export { IntegrationRefusedError, IntegrationTimeoutError, type RefusalCode, } from "@halonicjs/adapters/integration-kit";
|
|
4
|
+
export { leakAttemptCodes } from "./leak-attempt.js";
|
|
5
|
+
export { createLimitedHttpClient, type LimitedHttpOptions, type RequestLimits, } from "./limited-http.js";
|
|
6
|
+
export type { LoadProblem } from "./load-problem.js";
|
|
7
|
+
export { type IntegrationSource, type LoadedIntegration, type LoadIntegrationOptions, loadIntegration, type PreparedIntegration, type PrepareIntegrationOptions, prepareIntegration, providerChoices, type WorkspaceChoices, } from "./loader.js";
|
|
8
|
+
export { pluginLoadProblems } from "./plugin-load.js";
|
|
9
|
+
export { allowedUrl, type DeclaredPlacement, type DeclaredSecret, type IntegrationPolicy, namePattern, } from "./policy.js";
|
|
10
|
+
export { maxRequestBodyBytes } from "./request-body.js";
|
|
11
|
+
export { RequestLog, type RequestLogEntry } from "./request-log.js";
|
|
12
|
+
export { scopedTokens, storedTokenName } from "./scoped-tokens.js";
|
|
13
|
+
export { removeSecrets, removeSecretsFromHeaders, removeSecretsStream, type SecretForms, type SecretOnWire, SecretRemover, secretForms, secretRemoved, } from "./secret-filter.js";
|
|
14
|
+
export { clampWaitMs, integrationWait } from "./wait.js";
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// The host side of @halonicjs/adapter-integration-kit: the loader, the host
|
|
2
|
+
// and its limited client, for Halonic itself. It isn't published; the
|
|
3
|
+
// integration entry (`./integration`) is, as @halonicjs/adapters/integration-kit.
|
|
4
|
+
// The host side takes the error classes from the integration entry, so there
|
|
5
|
+
// is one copy of each. The npm build (tooling/publish) keeps that entry
|
|
6
|
+
// outside the conformance suite's bundle and points it at the published kit;
|
|
7
|
+
// it fails when host code imports a file inside the entry's folder instead
|
|
8
|
+
// of the entry itself. Internal code imports by relative path.
|
|
9
|
+
export { declarationProblems } from "./declaration.js";
|
|
10
|
+
export { createIntegrationHost, } from "./host.js";
|
|
11
|
+
export { IntegrationRefusedError, IntegrationTimeoutError, } from "@halonicjs/adapters/integration-kit";
|
|
12
|
+
export { leakAttemptCodes } from "./leak-attempt.js";
|
|
13
|
+
export { createLimitedHttpClient, } from "./limited-http.js";
|
|
14
|
+
export { loadIntegration, prepareIntegration, providerChoices, } from "./loader.js";
|
|
15
|
+
export { pluginLoadProblems } from "./plugin-load.js";
|
|
16
|
+
export { allowedUrl, namePattern, } from "./policy.js";
|
|
17
|
+
export { maxRequestBodyBytes } from "./request-body.js";
|
|
18
|
+
export { RequestLog } from "./request-log.js";
|
|
19
|
+
export { scopedTokens, storedTokenName } from "./scoped-tokens.js";
|
|
20
|
+
export { removeSecrets, removeSecretsFromHeaders, removeSecretsStream, SecretRemover, secretForms, secretRemoved, } from "./secret-filter.js";
|
|
21
|
+
export { clampWaitMs, integrationWait } from "./wait.js";
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { RefusalCode } from "@halonicjs/adapters/integration-kit";
|
|
2
|
+
/**
|
|
3
|
+
* The refusal codes that mean the integration tried to get a secret out:
|
|
4
|
+
* it carried a secret value in its own request, or it asked the kit to
|
|
5
|
+
* place a secret somewhere its permission sheet doesn't say. A connector
|
|
6
|
+
* that gets one of these should be paused, not just shown the error. Every
|
|
7
|
+
* other code is an ordinary mistake, such as a host the sheet doesn't list
|
|
8
|
+
* or a body that is too large, or comes from the server, such as
|
|
9
|
+
* `secret-in-redirect` for a redirect whose URL holds a secret.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* if (leakAttemptCodes.includes(error.code)) pauseConnector(); // "secret-in-request"
|
|
13
|
+
*/
|
|
14
|
+
export declare const leakAttemptCodes: readonly RefusalCode[];
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The refusal codes that mean the integration tried to get a secret out:
|
|
3
|
+
* it carried a secret value in its own request, or it asked the kit to
|
|
4
|
+
* place a secret somewhere its permission sheet doesn't say. A connector
|
|
5
|
+
* that gets one of these should be paused, not just shown the error. Every
|
|
6
|
+
* other code is an ordinary mistake, such as a host the sheet doesn't list
|
|
7
|
+
* or a body that is too large, or comes from the server, such as
|
|
8
|
+
* `secret-in-redirect` for a redirect whose URL holds a secret.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* if (leakAttemptCodes.includes(error.code)) pauseConnector(); // "secret-in-request"
|
|
12
|
+
*/
|
|
13
|
+
export const leakAttemptCodes = Object.freeze([
|
|
14
|
+
"secret-in-request",
|
|
15
|
+
"placement-not-in-sheet",
|
|
16
|
+
]);
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import type { HttpClient, IntegrationHttpClient, Secrets } from "../../../core/ports/src/index.js";
|
|
2
|
+
import { type IntegrationPolicy } from "./policy.js";
|
|
3
|
+
import type { RequestLog } from "./request-log.js";
|
|
4
|
+
/**
|
|
5
|
+
* Limits on one request. Every field has a default; the loader sets them
|
|
6
|
+
* from the integration's permission sheet, so a model answer streamed for
|
|
7
|
+
* minutes or a large file export can raise them.
|
|
8
|
+
*/
|
|
9
|
+
export interface RequestLimits {
|
|
10
|
+
/** Waiting for the response headers, redirects included. Default 30 seconds. */
|
|
11
|
+
readonly headersTimeoutMs?: number;
|
|
12
|
+
/** Waiting for the next piece of the body. Default 60 seconds. */
|
|
13
|
+
readonly idleTimeoutMs?: number;
|
|
14
|
+
/** The whole request, reading the body included. Default 10 minutes. */
|
|
15
|
+
readonly timeoutMs?: number;
|
|
16
|
+
/** The response body. Default 10 MiB. */
|
|
17
|
+
readonly maxResponseBytes?: number;
|
|
18
|
+
/**
|
|
19
|
+
* The request body, in bytes sent. Default and ceiling 720 KiB
|
|
20
|
+
* (`maxRequestBodyBytes`): it can be lowered, never raised, so an
|
|
21
|
+
* integration behaves the same in-process and in the fenced runner.
|
|
22
|
+
*/
|
|
23
|
+
readonly maxRequestBodyBytes?: number;
|
|
24
|
+
/** Redirects followed before the request fails. Default 5. */
|
|
25
|
+
readonly maxRedirects?: number;
|
|
26
|
+
}
|
|
27
|
+
/** What {@link createLimitedHttpClient} needs. */
|
|
28
|
+
export interface LimitedHttpOptions {
|
|
29
|
+
readonly policy: IntegrationPolicy;
|
|
30
|
+
/** The real transport underneath, such as the runtime's `fetch`. */
|
|
31
|
+
readonly transport: HttpClient;
|
|
32
|
+
/** Where the kit reads the values of the secrets it places. */
|
|
33
|
+
readonly secrets: Secrets;
|
|
34
|
+
readonly log: RequestLog;
|
|
35
|
+
readonly limits?: RequestLimits;
|
|
36
|
+
/** Milliseconds for the request log's timings. Default `Date.now`. */
|
|
37
|
+
readonly now?: () => number;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* The `HttpClient` an integration gets: only the hosts and secrets of its
|
|
41
|
+
* permission sheet, `https` only (plain `http` only to a local host), every
|
|
42
|
+
* redirect hop checked again, with timeouts and a response size limit. Every
|
|
43
|
+
* request goes into the log.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* const http = createLimitedHttpClient({ policy, transport: { fetch }, secrets, log: new RequestLog() });
|
|
47
|
+
* await http.fetch("https://api.example.com/v1", { auth: { secret: "example-key", as: "bearer" } });
|
|
48
|
+
*/
|
|
49
|
+
export declare function createLimitedHttpClient(options: LimitedHttpOptions): IntegrationHttpClient;
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { IntegrationRefusedError, IntegrationTimeoutError } from "@halonicjs/adapters/integration-kit";
|
|
2
|
+
import { copyRequest } from "./own-request.js";
|
|
3
|
+
import { allowedUrl } from "./policy.js";
|
|
4
|
+
import { bodyBytes, checkBody, requestBodyLimit, requestTooLarge, toForm, } from "./request-body.js";
|
|
5
|
+
import { guardBody, untilAborted } from "./response-body.js";
|
|
6
|
+
import { removeSecretsFromError, secretForms } from "./secret-filter.js";
|
|
7
|
+
import { carriedForms, readDeclaredSecrets, refuseCarriedSecrets, refuseRedirectCarryingSecrets, SecretInRequestError, } from "./secret-in-request.js";
|
|
8
|
+
import { checkPlacementHosts, checkPlacements, place, readSecrets } from "./secret-placement.js";
|
|
9
|
+
const redirectStatuses = new Set([301, 302, 303, 307, 308]);
|
|
10
|
+
/** Headers a browser drops when a redirect leaves the origin; the kit does the same. */
|
|
11
|
+
const originBoundHeaders = ["authorization", "cookie", "proxy-authorization"];
|
|
12
|
+
/**
|
|
13
|
+
* The `HttpClient` an integration gets: only the hosts and secrets of its
|
|
14
|
+
* permission sheet, `https` only (plain `http` only to a local host), every
|
|
15
|
+
* redirect hop checked again, with timeouts and a response size limit. Every
|
|
16
|
+
* request goes into the log.
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* const http = createLimitedHttpClient({ policy, transport: { fetch }, secrets, log: new RequestLog() });
|
|
20
|
+
* await http.fetch("https://api.example.com/v1", { auth: { secret: "example-key", as: "bearer" } });
|
|
21
|
+
*/
|
|
22
|
+
export function createLimitedHttpClient(options) {
|
|
23
|
+
const now = options.now ?? Date.now;
|
|
24
|
+
return {
|
|
25
|
+
async fetch(rawUrl, init = {}) {
|
|
26
|
+
const started = now();
|
|
27
|
+
// Until the secret check has passed, the method, host and path may hold a key,
|
|
28
|
+
// so the check runs first: before the URL is parsed and before any other refusal.
|
|
29
|
+
let logged = unchecked;
|
|
30
|
+
try {
|
|
31
|
+
// Before the first `await`: from here on the kit reads only this copy.
|
|
32
|
+
const own = copyRequest(options.policy, rawUrl, init);
|
|
33
|
+
// Needs no secret, so a placement the sheet doesn't allow is refused before any is read.
|
|
34
|
+
checkPlacements(options.policy, own.placements);
|
|
35
|
+
const declared = await readDeclaredSecrets(options.policy, options.secrets);
|
|
36
|
+
const carried = carriedForms(declared.values());
|
|
37
|
+
refuseCarriedSecrets(options.policy, carried, {
|
|
38
|
+
method: own.givenMethod,
|
|
39
|
+
sentMethod: own.method,
|
|
40
|
+
url: own.url ?? "",
|
|
41
|
+
headers: own.headers,
|
|
42
|
+
body: own.body,
|
|
43
|
+
});
|
|
44
|
+
logged = { method: own.method, ...logPlace(own.url) };
|
|
45
|
+
const response = await send(options, own, { declared, carried });
|
|
46
|
+
options.log.add({
|
|
47
|
+
method: own.method,
|
|
48
|
+
...logPlace(response.url),
|
|
49
|
+
status: response.status,
|
|
50
|
+
durationMs: now() - started,
|
|
51
|
+
outcome: "ok",
|
|
52
|
+
});
|
|
53
|
+
return response;
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
const refused = error instanceof IntegrationRefusedError;
|
|
57
|
+
options.log.add({
|
|
58
|
+
...(error instanceof SecretInRequestError ? error.logged : logged),
|
|
59
|
+
durationMs: now() - started,
|
|
60
|
+
outcome: refused ? "refused" : "failed",
|
|
61
|
+
...(refused ? { refusal: error.code } : {}),
|
|
62
|
+
});
|
|
63
|
+
throw error;
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** What the log shows of a request that failed before the secret check passed. */
|
|
69
|
+
const unchecked = { method: "", host: "", path: "" };
|
|
70
|
+
async function send(options, own, { declared, carried }) {
|
|
71
|
+
const { policy, limits = {} } = options;
|
|
72
|
+
// Only the copied method, headers and body reach the transport, which the secret check has
|
|
73
|
+
// read. Every other option is dropped: `referrer` goes out as an unchecked `Referer` header,
|
|
74
|
+
// and Node's `dispatcher` would hand the whole request, placed secrets included, to the
|
|
75
|
+
// integration.
|
|
76
|
+
const { placements, body, signal } = own;
|
|
77
|
+
// After the secret check, which skips a body it can't read, so this refusal logs no key.
|
|
78
|
+
checkBody(policy, body);
|
|
79
|
+
const url = allowedUrl(policy, own.url);
|
|
80
|
+
checkPlacementHosts(policy, placements, url);
|
|
81
|
+
const maxBodyBytes = requestBodyLimit(limits.maxRequestBodyBytes);
|
|
82
|
+
const values = await readSecrets(policy, options.secrets, placements);
|
|
83
|
+
const hop = {
|
|
84
|
+
url,
|
|
85
|
+
method: own.method,
|
|
86
|
+
body,
|
|
87
|
+
form: placements.some((p) => p.as === "form") ? toForm(policy, body) : undefined,
|
|
88
|
+
placements,
|
|
89
|
+
headers: new Headers(own.headers),
|
|
90
|
+
};
|
|
91
|
+
const timers = startTimers(policy, hop, limits, signal);
|
|
92
|
+
const guard = {
|
|
93
|
+
signal: timers.combined,
|
|
94
|
+
idleMs: limits.idleTimeoutMs ?? 60_000,
|
|
95
|
+
maxBytes: limits.maxResponseBytes ?? 10 * 1024 * 1024,
|
|
96
|
+
onIdle: () => timers.stop("no data", limits.idleTimeoutMs ?? 60_000),
|
|
97
|
+
done: () => clearTimeout(timers.total),
|
|
98
|
+
// Every declared secret, not only the placed ones: the bridge filters the same way.
|
|
99
|
+
secrets: secretForms([...declared].map(([secret, value]) => ({
|
|
100
|
+
value,
|
|
101
|
+
placements: placements.filter((placement) => placement.secret === secret),
|
|
102
|
+
}))),
|
|
103
|
+
};
|
|
104
|
+
try {
|
|
105
|
+
return await followHops(options, { hop, values, carried, guard, maxBodyBytes, timers });
|
|
106
|
+
}
|
|
107
|
+
catch (error) {
|
|
108
|
+
clearTimeout(timers.headers);
|
|
109
|
+
clearTimeout(timers.total);
|
|
110
|
+
// Refusals and timeouts name the URL of the hop, which a redirect may have chosen.
|
|
111
|
+
throw removeSecretsFromError(error, guard.secrets);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
function startTimers(policy, hop, limits, signal) {
|
|
115
|
+
const deadline = new AbortController();
|
|
116
|
+
const stop = (what, ms) => deadline.abort(new IntegrationTimeoutError(`${policy.name}: ${what} from ${hop.url.host}${hop.url.pathname} within ${ms} ms`));
|
|
117
|
+
const totalMs = limits.timeoutMs ?? 600_000;
|
|
118
|
+
const headersMs = limits.headersTimeoutMs ?? 30_000;
|
|
119
|
+
return {
|
|
120
|
+
combined: signal ? AbortSignal.any([signal, deadline.signal]) : deadline.signal,
|
|
121
|
+
total: setTimeout(() => stop("no complete response", totalMs), totalMs),
|
|
122
|
+
headers: setTimeout(() => stop("no response headers", headersMs), headersMs),
|
|
123
|
+
stop,
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
/** Sends the request, then each redirect hop, until an answer that isn't one. */
|
|
127
|
+
async function followHops(options, context) {
|
|
128
|
+
const { policy, limits = {} } = options;
|
|
129
|
+
const { hop, values, carried, guard, maxBodyBytes, timers } = context;
|
|
130
|
+
const maxRedirects = limits.maxRedirects ?? 5;
|
|
131
|
+
for (let count = 0;; count++) {
|
|
132
|
+
const headers = new Headers(hop.headers);
|
|
133
|
+
const placedForm = place(policy, hop.placements, values, hop.url, headers, hop.form);
|
|
134
|
+
const body = placedForm ?? hop.body;
|
|
135
|
+
if (bodyBytes(body) > maxBodyBytes)
|
|
136
|
+
throw requestTooLarge(policy, hop.url, maxBodyBytes);
|
|
137
|
+
const response = await untilAborted(options.transport.fetch(hop.url.href, {
|
|
138
|
+
method: hop.method,
|
|
139
|
+
headers,
|
|
140
|
+
body,
|
|
141
|
+
redirect: "manual",
|
|
142
|
+
signal: timers.combined,
|
|
143
|
+
}), timers.combined);
|
|
144
|
+
const location = response.headers.get("location");
|
|
145
|
+
if (!redirectStatuses.has(response.status) || location === null) {
|
|
146
|
+
clearTimeout(timers.headers);
|
|
147
|
+
return guardBody(policy, response, hop.url, guard);
|
|
148
|
+
}
|
|
149
|
+
await response.body?.cancel();
|
|
150
|
+
if (count >= maxRedirects) {
|
|
151
|
+
throw new IntegrationRefusedError("too-many-redirects", `${policy.name}: ${hop.url.host}${hop.url.pathname} redirected more than ${maxRedirects} times`);
|
|
152
|
+
}
|
|
153
|
+
refuseRedirectCarryingSecrets(policy, carried, location, hop.url);
|
|
154
|
+
follow(hop, response.status, allowedUrl(policy, location, hop.url));
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
/** Moves the hop on to an allowed redirect target, the way `fetch` does. */
|
|
158
|
+
function follow(hop, status, next) {
|
|
159
|
+
if (next.origin !== hop.url.origin)
|
|
160
|
+
for (const name of originBoundHeaders)
|
|
161
|
+
hop.headers.delete(name);
|
|
162
|
+
const toGet = status === 303 || ((status === 301 || status === 302) && hop.method === "POST");
|
|
163
|
+
if (toGet) {
|
|
164
|
+
hop.method = hop.method === "HEAD" ? "HEAD" : "GET";
|
|
165
|
+
hop.body = null;
|
|
166
|
+
hop.form = undefined;
|
|
167
|
+
hop.placements = hop.placements.filter((p) => p.as !== "form");
|
|
168
|
+
hop.headers.delete("content-type");
|
|
169
|
+
hop.headers.delete("content-length");
|
|
170
|
+
}
|
|
171
|
+
hop.url = next;
|
|
172
|
+
}
|
|
173
|
+
/** Host and path for the log, without query or fragment. Empty when the URL doesn't parse. */
|
|
174
|
+
function logPlace(raw) {
|
|
175
|
+
try {
|
|
176
|
+
const url = new URL(String(raw));
|
|
177
|
+
return { host: url.host, path: url.pathname };
|
|
178
|
+
}
|
|
179
|
+
catch {
|
|
180
|
+
return { host: "", path: "" };
|
|
181
|
+
}
|
|
182
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why the loader refused an integration: a code from the sheet's schema or
|
|
3
|
+
* checks, from resolving its hosts, or from the loader itself (such as
|
|
4
|
+
* `kit-version`, `tool-differs` or `sheet-not-approved`). The message names
|
|
5
|
+
* the integration and the field, never a secret value. The same goes for the
|
|
6
|
+
* optional `fix`.
|
|
7
|
+
*/
|
|
8
|
+
export interface LoadProblem {
|
|
9
|
+
readonly code: string;
|
|
10
|
+
/** Where in the permission sheet the problem sits; `[]` for the sheet as a whole. */
|
|
11
|
+
readonly path: readonly (string | number)[];
|
|
12
|
+
readonly message: string;
|
|
13
|
+
/**
|
|
14
|
+
* The one next step that fixes it, as its own sentence, kept apart from the
|
|
15
|
+
* message so `halonic validate`, `--json` and Studio can show it on its own
|
|
16
|
+
* line. Left out when there is no step to suggest; nothing shows a fix then,
|
|
17
|
+
* and nothing makes one up.
|
|
18
|
+
*/
|
|
19
|
+
readonly fix?: string;
|
|
20
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { type IntegrationSheet } from "../../../core/format/src/integration/index.js";
|
|
2
|
+
import { type HttpClient, type Integration, type IntegrationHost, type ProviderConfig, type Secrets, type TokenStore } from "../../../core/ports/src/index.js";
|
|
3
|
+
import { type Result } from "../../../core/std/src/index.js";
|
|
4
|
+
import type { LoadProblem } from "./load-problem.js";
|
|
5
|
+
import type { RequestLog } from "./request-log.js";
|
|
6
|
+
import type { SecretOnWire } from "./secret-filter.js";
|
|
7
|
+
/** An integration and its permission sheet, as they were found. */
|
|
8
|
+
export interface IntegrationSource {
|
|
9
|
+
/**
|
|
10
|
+
* `built-in`: from the integrations release this Halonic pins. `local`: from
|
|
11
|
+
* the workspace, such as one the assistant wrote; it loads only with the
|
|
12
|
+
* sheet the user approved.
|
|
13
|
+
*/
|
|
14
|
+
readonly origin: "built-in" | "local";
|
|
15
|
+
/** The permission sheet as data: the JSON the build writes next to the code. */
|
|
16
|
+
readonly sheet: unknown;
|
|
17
|
+
readonly integration: Integration;
|
|
18
|
+
/**
|
|
19
|
+
* For a `local` integration: the sheet as the user approved it in the trust
|
|
20
|
+
* step. The loader refuses it when the sheet has changed since.
|
|
21
|
+
*/
|
|
22
|
+
readonly approvedSheet?: unknown;
|
|
23
|
+
}
|
|
24
|
+
/** What the workspace chose for one integration. */
|
|
25
|
+
export interface WorkspaceChoices {
|
|
26
|
+
/** Its settings, such as the URL a `{ fromSetting }` host reads. Never a secret value. */
|
|
27
|
+
readonly settings?: Readonly<Record<string, unknown>>;
|
|
28
|
+
/**
|
|
29
|
+
* For each secret in the sheet, the workspace secret the user picked for
|
|
30
|
+
* it. A secret left out isn't configured: an optional one is left off the
|
|
31
|
+
* request, any other is refused when a request needs it.
|
|
32
|
+
*/
|
|
33
|
+
readonly secretNames?: Readonly<Record<string, string>>;
|
|
34
|
+
}
|
|
35
|
+
/** What {@link loadIntegration} needs: the integration and the raw ports, which the integration never sees. */
|
|
36
|
+
export interface LoadIntegrationOptions {
|
|
37
|
+
readonly source: IntegrationSource;
|
|
38
|
+
readonly choices?: WorkspaceChoices;
|
|
39
|
+
readonly transport: HttpClient;
|
|
40
|
+
readonly secrets: Secrets;
|
|
41
|
+
readonly tokens: TokenStore;
|
|
42
|
+
/** What this runtime offers beyond HTTP, for the sheet's `needs`, such as `process`. Default none. */
|
|
43
|
+
readonly capabilities?: readonly string[];
|
|
44
|
+
readonly now?: () => number;
|
|
45
|
+
}
|
|
46
|
+
/** An integration ready to connect: its checked sheet, its host and the request log only Halonic reads. */
|
|
47
|
+
export interface LoadedIntegration {
|
|
48
|
+
readonly origin: IntegrationSource["origin"];
|
|
49
|
+
readonly integration: Integration;
|
|
50
|
+
readonly sheet: IntegrationSheet;
|
|
51
|
+
readonly host: IntegrationHost;
|
|
52
|
+
readonly log: RequestLog;
|
|
53
|
+
}
|
|
54
|
+
/** What {@link prepareIntegration} needs: {@link LoadIntegrationOptions} without the code. */
|
|
55
|
+
export interface PrepareIntegrationOptions extends Omit<LoadIntegrationOptions, "source"> {
|
|
56
|
+
readonly source: Omit<IntegrationSource, "integration">;
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* An integration whose sheet and choices are checked and whose host is
|
|
60
|
+
* built, but whose code hasn't been checked against the sheet yet: the code
|
|
61
|
+
* runs somewhere Halonic can't read it directly, such as the runner.
|
|
62
|
+
*/
|
|
63
|
+
export interface PreparedIntegration extends Omit<LoadedIntegration, "integration"> {
|
|
64
|
+
/**
|
|
65
|
+
* Reads the value of each secret the user picked, with the one placement
|
|
66
|
+
* the sheet allows, for a secret filter outside the kit, such as the runner
|
|
67
|
+
* bridge's. Read it again for each runner start, so a changed value is
|
|
68
|
+
* filtered too. Only Halonic's side ever calls it.
|
|
69
|
+
*/
|
|
70
|
+
readonly readSecrets: () => Promise<SecretOnWire[]>;
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Checks an integration against its permission sheet and builds its host. The
|
|
74
|
+
* sheet must pass its schema, the code must be exactly what the sheet
|
|
75
|
+
* declares, a local integration's sheet must be the one the user approved,
|
|
76
|
+
* every need must be available, and the workspace's choices must fit the
|
|
77
|
+
* sheet. Nothing is sent: call `integration.connect(loaded.host)` next.
|
|
78
|
+
*
|
|
79
|
+
* @example
|
|
80
|
+
* const loaded = loadIntegration({ source: { origin: "built-in", sheet, integration: weather }, transport, secrets, tokens });
|
|
81
|
+
* if (loaded.ok) connections.set("weather", loaded.value.integration.connect(loaded.value.host));
|
|
82
|
+
*/
|
|
83
|
+
export declare function loadIntegration(options: LoadIntegrationOptions): Result<LoadedIntegration, LoadProblem[]>;
|
|
84
|
+
/**
|
|
85
|
+
* Does every check {@link loadIntegration} does except the one on the code,
|
|
86
|
+
* and builds the host. The caller checks the code against the sheet itself
|
|
87
|
+
* with {@link declarationProblems} once it knows what the code declares.
|
|
88
|
+
*
|
|
89
|
+
* @example
|
|
90
|
+
* const prepared = prepareIntegration({ source: { origin: "local", sheet, approvedSheet }, transport, secrets, tokens });
|
|
91
|
+
* if (prepared.ok) runner = await startRunner({ http: prepared.value.host.http, ... });
|
|
92
|
+
*/
|
|
93
|
+
export declare function prepareIntegration(options: PrepareIntegrationOptions): Result<PreparedIntegration, LoadProblem[]>;
|
|
94
|
+
/**
|
|
95
|
+
* Maps a workspace's provider entry onto the sheet, so the integration can
|
|
96
|
+
* ignore `ProviderConfig.baseUrl` and `.secret`: the `baseUrl` becomes the
|
|
97
|
+
* setting the sheet's one `{ fromSetting }` host reads, and the workspace
|
|
98
|
+
* secret becomes the sheet's one secret.
|
|
99
|
+
*
|
|
100
|
+
* @example
|
|
101
|
+
* providerChoices(sheet, { id: "local", type: "ollama", baseUrl: "http://localhost:11434", local: true, options: {} });
|
|
102
|
+
* // ok({ settings: { url: "http://localhost:11434" }, secretNames: {} })
|
|
103
|
+
*/
|
|
104
|
+
export declare function providerChoices(sheet: IntegrationSheet, config: ProviderConfig): Result<Required<WorkspaceChoices>, LoadProblem[]>;
|
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
import { integrationPolicy, parseIntegrationSheet, } from "../../../core/format/src/integration/index.js";
|
|
2
|
+
import { workspaceSecrets, } from "../../../core/ports/src/index.js";
|
|
3
|
+
import { deepEqual, err, ok } from "../../../core/std/src/index.js";
|
|
4
|
+
import { declarationProblems } from "./declaration.js";
|
|
5
|
+
import { createIntegrationHost } from "./host.js";
|
|
6
|
+
/**
|
|
7
|
+
* Checks an integration against its permission sheet and builds its host. The
|
|
8
|
+
* sheet must pass its schema, the code must be exactly what the sheet
|
|
9
|
+
* declares, a local integration's sheet must be the one the user approved,
|
|
10
|
+
* every need must be available, and the workspace's choices must fit the
|
|
11
|
+
* sheet. Nothing is sent: call `integration.connect(loaded.host)` next.
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const loaded = loadIntegration({ source: { origin: "built-in", sheet, integration: weather }, transport, secrets, tokens });
|
|
15
|
+
* if (loaded.ok) connections.set("weather", loaded.value.integration.connect(loaded.value.host));
|
|
16
|
+
*/
|
|
17
|
+
export function loadIntegration(options) {
|
|
18
|
+
const { integration } = options.source;
|
|
19
|
+
const prepared = prepare(options, (sheet) => declarationProblems(sheet, integration));
|
|
20
|
+
if (!prepared.ok) {
|
|
21
|
+
return prepared;
|
|
22
|
+
}
|
|
23
|
+
const { readSecrets: _readSecrets, ...loaded } = prepared.value;
|
|
24
|
+
return ok({ ...loaded, integration });
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Does every check {@link loadIntegration} does except the one on the code,
|
|
28
|
+
* and builds the host. The caller checks the code against the sheet itself
|
|
29
|
+
* with {@link declarationProblems} once it knows what the code declares.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* const prepared = prepareIntegration({ source: { origin: "local", sheet, approvedSheet }, transport, secrets, tokens });
|
|
33
|
+
* if (prepared.ok) runner = await startRunner({ http: prepared.value.host.http, ... });
|
|
34
|
+
*/
|
|
35
|
+
export function prepareIntegration(options) {
|
|
36
|
+
return prepare(options, () => []);
|
|
37
|
+
}
|
|
38
|
+
/** The checks both entries share; `codeProblems` checks the code, where there is code to check. */
|
|
39
|
+
function prepare(options, codeProblems) {
|
|
40
|
+
const { source } = options;
|
|
41
|
+
const parsed = parseIntegrationSheet(source.sheet);
|
|
42
|
+
if (!parsed.ok) {
|
|
43
|
+
return err(parsed.error);
|
|
44
|
+
}
|
|
45
|
+
const sheet = parsed.value;
|
|
46
|
+
const settings = options.choices?.settings ?? {};
|
|
47
|
+
const secretNames = options.choices?.secretNames ?? {};
|
|
48
|
+
const problems = [
|
|
49
|
+
...approvalProblems(source, sheet),
|
|
50
|
+
...localTokenProblems(source, sheet),
|
|
51
|
+
...codeProblems(sheet),
|
|
52
|
+
...needProblems(sheet, options.capabilities ?? []),
|
|
53
|
+
...secretChoiceProblems(sheet, secretNames),
|
|
54
|
+
];
|
|
55
|
+
const resolved = integrationPolicy(sheet, settings);
|
|
56
|
+
if (!resolved.ok) {
|
|
57
|
+
problems.push(...resolved.error);
|
|
58
|
+
}
|
|
59
|
+
if (problems.length > 0 || !resolved.ok) {
|
|
60
|
+
return err(problems);
|
|
61
|
+
}
|
|
62
|
+
const secrets = chosenSecrets(options.secrets, secretNames);
|
|
63
|
+
const { host, log } = createIntegrationHost({
|
|
64
|
+
policy: resolved.value.policy,
|
|
65
|
+
transport: options.transport,
|
|
66
|
+
secrets,
|
|
67
|
+
tokens: options.tokens,
|
|
68
|
+
settings,
|
|
69
|
+
...(resolved.value.limits ? { limits: requestLimits(resolved.value.limits) } : {}),
|
|
70
|
+
...(options.now ? { now: options.now } : {}),
|
|
71
|
+
});
|
|
72
|
+
const readSecrets = () => secretsOnWire(sheet, secrets);
|
|
73
|
+
return ok({ origin: source.origin, sheet, host, log, readSecrets });
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Maps a workspace's provider entry onto the sheet, so the integration can
|
|
77
|
+
* ignore `ProviderConfig.baseUrl` and `.secret`: the `baseUrl` becomes the
|
|
78
|
+
* setting the sheet's one `{ fromSetting }` host reads, and the workspace
|
|
79
|
+
* secret becomes the sheet's one secret.
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* providerChoices(sheet, { id: "local", type: "ollama", baseUrl: "http://localhost:11434", local: true, options: {} });
|
|
83
|
+
* // ok({ settings: { url: "http://localhost:11434" }, secretNames: {} })
|
|
84
|
+
*/
|
|
85
|
+
export function providerChoices(sheet, config) {
|
|
86
|
+
const problems = [];
|
|
87
|
+
const settings = {};
|
|
88
|
+
const secretNames = {};
|
|
89
|
+
if (config.baseUrl !== undefined) {
|
|
90
|
+
const fromSettings = [
|
|
91
|
+
...new Set(sheet.hosts.flatMap((host) => (typeof host === "string" ? [] : [host.fromSetting]))),
|
|
92
|
+
];
|
|
93
|
+
const [setting] = fromSettings;
|
|
94
|
+
if (fromSettings.length === 1 && setting !== undefined) {
|
|
95
|
+
settings[setting] = config.baseUrl;
|
|
96
|
+
}
|
|
97
|
+
else {
|
|
98
|
+
problems.push({
|
|
99
|
+
code: "base-url-not-mapped",
|
|
100
|
+
path: ["hosts"],
|
|
101
|
+
message: `${sheet.id}: provider "${config.id}" sets an address, so the sheet needs exactly one { fromSetting } host, not ${fromSettings.length}`,
|
|
102
|
+
});
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
if (config.secret !== undefined) {
|
|
106
|
+
const names = Object.keys(sheet.secrets);
|
|
107
|
+
const [name] = names;
|
|
108
|
+
if (names.length === 1 && name !== undefined) {
|
|
109
|
+
secretNames[name] = config.secret;
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
problems.push({
|
|
113
|
+
code: "secret-not-mapped",
|
|
114
|
+
path: ["secrets"],
|
|
115
|
+
message: `${sheet.id}: provider "${config.id}" picks a secret, so the sheet needs exactly one secret, not ${names.length}`,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
return problems.length > 0 ? err(problems) : ok({ settings, secretNames });
|
|
120
|
+
}
|
|
121
|
+
function approvalProblems(source, sheet) {
|
|
122
|
+
if (source.origin !== "local") {
|
|
123
|
+
return [];
|
|
124
|
+
}
|
|
125
|
+
const approved = source.approvedSheet === undefined ? undefined : parseIntegrationSheet(source.approvedSheet);
|
|
126
|
+
if (approved?.ok && deepEqual(approved.value, sheet)) {
|
|
127
|
+
return [];
|
|
128
|
+
}
|
|
129
|
+
return [
|
|
130
|
+
{
|
|
131
|
+
code: "sheet-not-approved",
|
|
132
|
+
path: [],
|
|
133
|
+
message: `${sheet.id}: this local integration's permission sheet isn't the one you approved; approve it again`,
|
|
134
|
+
},
|
|
135
|
+
];
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* A local integration runs in the runner, and no token value crosses into it
|
|
139
|
+
* (I5 design HAL-958, section 3.5): its sheet can't declare `tokens` (A32).
|
|
140
|
+
* Tokens as handles are the follow-up HAL-984. Built-in ones keep `tokens`.
|
|
141
|
+
*/
|
|
142
|
+
function localTokenProblems(source, sheet) {
|
|
143
|
+
if (source.origin !== "local" || sheet.tokens.length === 0) {
|
|
144
|
+
return [];
|
|
145
|
+
}
|
|
146
|
+
return [
|
|
147
|
+
{
|
|
148
|
+
code: "tokens-not-allowed",
|
|
149
|
+
path: ["tokens"],
|
|
150
|
+
message: `${sheet.id}: an integration you build or change can't hold sign-in secrets yet`,
|
|
151
|
+
fix: "Remove tokens from its sheet and use an API key, or ask for sign-in support.",
|
|
152
|
+
},
|
|
153
|
+
];
|
|
154
|
+
}
|
|
155
|
+
function needProblems(sheet, capabilities) {
|
|
156
|
+
return sheet.needs.flatMap((need, index) => capabilities.includes(need)
|
|
157
|
+
? []
|
|
158
|
+
: [
|
|
159
|
+
{
|
|
160
|
+
code: "need-not-available",
|
|
161
|
+
path: ["needs", index],
|
|
162
|
+
message: `${sheet.id}: needs "${need}", which this Halonic doesn't offer here`,
|
|
163
|
+
},
|
|
164
|
+
]);
|
|
165
|
+
}
|
|
166
|
+
function secretChoiceProblems(sheet, secretNames) {
|
|
167
|
+
return Object.keys(secretNames).flatMap((name) => Object.hasOwn(sheet.secrets, name)
|
|
168
|
+
? []
|
|
169
|
+
: [
|
|
170
|
+
{
|
|
171
|
+
code: "secret-not-declared",
|
|
172
|
+
path: ["secrets"],
|
|
173
|
+
message: `${sheet.id}: a workspace secret was picked for "${name}", which the sheet doesn't declare`,
|
|
174
|
+
},
|
|
175
|
+
]);
|
|
176
|
+
}
|
|
177
|
+
/** The sheet's limits as the kit takes them: only the ones the sheet sets. */
|
|
178
|
+
function requestLimits(limits) {
|
|
179
|
+
return Object.fromEntries(Object.entries(limits).filter((entry) => entry[1] !== undefined));
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* The raw secrets seen through the user's picks: the kit asks by the sheet's
|
|
183
|
+
* name and reads the workspace secret picked for it, or nothing. The workspace
|
|
184
|
+
* chose those names, so they can't reach Halonic's own secrets or tokens.
|
|
185
|
+
*/
|
|
186
|
+
function chosenSecrets(raw, secretNames) {
|
|
187
|
+
const picks = new Map(Object.entries(secretNames));
|
|
188
|
+
const workspace = workspaceSecrets(raw);
|
|
189
|
+
return {
|
|
190
|
+
get: async (name) => {
|
|
191
|
+
const picked = picks.get(name);
|
|
192
|
+
return picked === undefined ? null : await workspace.get(picked);
|
|
193
|
+
},
|
|
194
|
+
};
|
|
195
|
+
}
|
|
196
|
+
/** Each declared secret with a value, and its one placement, as {@link PreparedIntegration.readSecrets} gives them. */
|
|
197
|
+
async function secretsOnWire(sheet, secrets) {
|
|
198
|
+
const read = Object.entries(sheet.secrets).map(async ([name, declared]) => {
|
|
199
|
+
const value = await secrets.get(name);
|
|
200
|
+
return value === null ? [] : [{ value, placements: [placementOf(name, declared)] }];
|
|
201
|
+
});
|
|
202
|
+
return (await Promise.all(read)).flat();
|
|
203
|
+
}
|
|
204
|
+
/** Where the sheet puts one secret, as the request names it. */
|
|
205
|
+
function placementOf(secret, declared) {
|
|
206
|
+
switch (declared.as) {
|
|
207
|
+
case "bearer":
|
|
208
|
+
return { secret, as: "bearer" };
|
|
209
|
+
case "header":
|
|
210
|
+
return {
|
|
211
|
+
secret,
|
|
212
|
+
as: "header",
|
|
213
|
+
header: declared.header,
|
|
214
|
+
...(declared.prefix === undefined ? {} : { prefix: declared.prefix }),
|
|
215
|
+
};
|
|
216
|
+
case "form":
|
|
217
|
+
return { secret, as: "form", field: declared.field };
|
|
218
|
+
}
|
|
219
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Addresses on the user's own machine or network, for the plain `http` hosts
|
|
3
|
+
* a user may choose in a setting. Only literal addresses and
|
|
4
|
+
* `localhost` count: a name can resolve anywhere. Takes `URL.hostname`, which
|
|
5
|
+
* has already normalised the address. The classes come from `http-kit`, so
|
|
6
|
+
* this check and the Node transport's address check can't disagree.
|
|
7
|
+
*/
|
|
8
|
+
/** `localhost`, `127.0.0.0/8` or `::1`: the user's own machine. */
|
|
9
|
+
export declare function isLoopback(hostname: string): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Loopback, or a private network address (`10/8`, `172.16/12`,
|
|
12
|
+
* `192.168/16`, IPv6 `fc00::/7`). Link-local and metadata addresses don't
|
|
13
|
+
* count: `169.254.169.254` is where cloud machines serve their credentials.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isLocalAddress(hostname: string): boolean;
|