@halonicjs/testing 0.0.0 → 0.1.1
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 +5 -0
- package/README.md +41 -1
- package/dist/adapters/http-kit/src/address-checking.d.ts +19 -0
- package/dist/adapters/http-kit/src/address-checking.js +1 -0
- 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 +3 -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/auth-placement.d.ts +40 -0
- package/dist/adapters/integration-kit/src/auth-placement.js +102 -0
- package/dist/adapters/integration-kit/src/current-secret-forms.d.ts +28 -0
- package/dist/adapters/integration-kit/src/current-secret-forms.js +60 -0
- package/dist/adapters/integration-kit/src/declaration.d.ts +15 -0
- package/dist/adapters/integration-kit/src/declaration.js +78 -0
- package/dist/adapters/integration-kit/src/host.d.ts +34 -0
- package/dist/adapters/integration-kit/src/host.js +31 -0
- package/dist/adapters/integration-kit/src/index.d.ts +16 -0
- package/dist/adapters/integration-kit/src/index.js +22 -0
- package/dist/adapters/integration-kit/src/leak-attempt.d.ts +16 -0
- package/dist/adapters/integration-kit/src/leak-attempt.js +19 -0
- package/dist/adapters/integration-kit/src/limited-http.d.ts +55 -0
- package/dist/adapters/integration-kit/src/limited-http.js +225 -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 +131 -0
- package/dist/adapters/integration-kit/src/loader.js +251 -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 +83 -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 +27 -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 +220 -0
- package/dist/adapters/integration-kit/src/secret-in-request.d.ts +62 -0
- package/dist/adapters/integration-kit/src/secret-in-request.js +139 -0
- package/dist/adapters/integration-kit/src/secret-placement.d.ts +46 -0
- package/dist/adapters/integration-kit/src/secret-placement.js +160 -0
- package/dist/adapters/integration-kit/src/sign-in-placement.d.ts +29 -0
- package/dist/adapters/integration-kit/src/sign-in-placement.js +92 -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/blocked-sites.d.ts +57 -0
- package/dist/core/events/src/blocked-sites.js +89 -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 +17 -0
- package/dist/core/events/src/index.js +10 -0
- package/dist/core/events/src/run-basics.d.ts +228 -0
- package/dist/core/events/src/run-basics.js +1 -0
- package/dist/core/events/src/run-event.d.ts +478 -0
- package/dist/core/events/src/run-event.js +1 -0
- package/dist/core/events/src/run-reads.d.ts +25 -0
- package/dist/core/events/src/run-reads.js +44 -0
- package/dist/core/events/src/run-sends.d.ts +47 -0
- package/dist/core/events/src/run-sends.js +68 -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 +192 -0
- package/dist/core/events/src/timeline-entry.d.ts +21 -0
- package/dist/core/events/src/timeline-entry.js +106 -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 +39 -0
- package/dist/core/format/src/index.js +25 -0
- package/dist/core/format/src/integration/index.d.ts +7 -0
- package/dist/core/format/src/integration/index.js +10 -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 +99 -0
- package/dist/core/format/src/kinds/agent/sandbox-fields.js +216 -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 +218 -0
- package/dist/core/format/src/kinds/connector/schema.d.ts +74 -0
- package/dist/core/format/src/kinds/connector/schema.js +143 -0
- package/dist/core/format/src/kinds/deployments/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/deployments/kind.js +49 -0
- package/dist/core/format/src/kinds/deployments/schema.d.ts +77 -0
- package/dist/core/format/src/kinds/deployments/schema.js +94 -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/approved-sign-ins.d.ts +62 -0
- package/dist/core/format/src/kinds/integration/approved-sign-ins.js +125 -0
- package/dist/core/format/src/kinds/integration/host-key.d.ts +7 -0
- package/dist/core/format/src/kinds/integration/host-key.js +8 -0
- package/dist/core/format/src/kinds/integration/kind.d.ts +18 -0
- package/dist/core/format/src/kinds/integration/kind.js +175 -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 +112 -0
- package/dist/core/format/src/kinds/integration/policy.js +327 -0
- package/dist/core/format/src/kinds/integration/schema.d.ts +410 -0
- package/dist/core/format/src/kinds/integration/schema.js +359 -0
- package/dist/core/format/src/kinds/integration/sign-in-checks.d.ts +13 -0
- package/dist/core/format/src/kinds/integration/sign-in-checks.js +120 -0
- package/dist/core/format/src/kinds/integration/sign-in-urls.d.ts +19 -0
- package/dist/core/format/src/kinds/integration/sign-in-urls.js +47 -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 +137 -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 +672 -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 +85 -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 +62 -0
- package/dist/core/format/src/kinds/routine/schema.d.ts +94 -0
- package/dist/core/format/src/kinds/routine/schema.js +115 -0
- package/dist/core/format/src/kinds/routine/webhook-headers.d.ts +9 -0
- package/dist/core/format/src/kinds/routine/webhook-headers.js +26 -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 +34 -0
- package/dist/core/format/src/shared/fields.js +74 -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/agent-runs-not-available.d.ts +21 -0
- package/dist/core/ports/src/agent-runs-not-available.js +25 -0
- package/dist/core/ports/src/blob-store.d.ts +45 -0
- package/dist/core/ports/src/blob-store.js +24 -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 +303 -0
- package/dist/core/ports/src/connector-client.js +19 -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 +229 -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 +198 -0
- package/dist/core/ports/src/harness-bridge-server.js +37 -0
- package/dist/core/ports/src/harness-sign-in-command.d.ts +27 -0
- package/dist/core/ports/src/harness-sign-in-command.js +31 -0
- package/dist/core/ports/src/harness.d.ts +283 -0
- package/dist/core/ports/src/harness.js +45 -0
- package/dist/core/ports/src/host-settings-store.d.ts +116 -0
- package/dist/core/ports/src/host-settings-store.js +106 -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 +45 -0
- package/dist/core/ports/src/index.js +44 -0
- package/dist/core/ports/src/instruction-trust-store.d.ts +81 -0
- package/dist/core/ports/src/instruction-trust-store.js +43 -0
- package/dist/core/ports/src/integration.d.ts +242 -0
- package/dist/core/ports/src/integration.js +31 -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 +186 -0
- package/dist/core/ports/src/llm-provider.js +139 -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 +63 -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 +47 -0
- package/dist/core/ports/src/port-versions.js +80 -0
- package/dist/core/ports/src/program-probe.d.ts +69 -0
- package/dist/core/ports/src/program-probe.js +2 -0
- package/dist/core/ports/src/provider-default-base-url.d.ts +10 -0
- package/dist/core/ports/src/provider-default-base-url.js +18 -0
- package/dist/core/ports/src/record-store.d.ts +79 -0
- package/dist/core/ports/src/record-store.js +108 -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 +303 -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/run-target-not-found.d.ts +34 -0
- package/dist/core/ports/src/run-target-not-found.js +41 -0
- package/dist/core/ports/src/sandbox-setting-store.d.ts +68 -0
- package/dist/core/ports/src/sandbox-setting-store.js +33 -0
- package/dist/core/ports/src/sandbox.d.ts +364 -0
- package/dist/core/ports/src/sandbox.js +70 -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 +201 -0
- package/dist/core/ports/src/secrets.js +200 -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 +253 -0
- package/dist/core/ports/src/tool-approval-store.js +116 -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-status.d.ts +8 -0
- package/dist/core/ports/src/vcs-status.js +90 -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/amount.d.ts +13 -0
- package/dist/core/std/src/amount.js +22 -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/hidden-characters.d.ts +19 -0
- package/dist/core/std/src/hidden-characters.js +54 -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 +30 -0
- package/dist/core/std/src/index.js +31 -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/public-suffixes.generated.d.ts +9 -0
- package/dist/core/std/src/public-suffixes.generated.js +10429 -0
- package/dist/core/std/src/registrable-domain.d.ts +10 -0
- package/dist/core/std/src/registrable-domain.js +62 -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/secret-variable-name.d.ts +12 -0
- package/dist/core/std/src/secret-variable-name.js +34 -0
- package/dist/core/std/src/site-name.d.ts +35 -0
- package/dist/core/std/src/site-name.js +111 -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/url-host.d.ts +35 -0
- package/dist/core/std/src/url-host.js +170 -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 +47 -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 +34 -3
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { checkPlacementHosts, checkPlacements, isSecretPlacement, isSignInPlacement, place, } from "./auth-placement.js";
|
|
2
|
+
import { IntegrationRefusedError, IntegrationTimeoutError } from "@halonicjs/adapters/integration-kit";
|
|
3
|
+
import { copyRequest } from "./own-request.js";
|
|
4
|
+
import { allowedUrl } from "./policy.js";
|
|
5
|
+
import { bodyBytes, checkBody, requestBodyLimit, requestTooLarge, toForm, } from "./request-body.js";
|
|
6
|
+
import { guardBody, untilAborted } from "./response-body.js";
|
|
7
|
+
import { removeSecretsFromError, secretForms } from "./secret-filter.js";
|
|
8
|
+
import { carriedForms, readDeclaredSecrets, refuseCarriedSecrets, refuseRedirectCarryingSecrets, SecretInRequestError, } from "./secret-in-request.js";
|
|
9
|
+
import { readSecrets } from "./secret-placement.js";
|
|
10
|
+
import { readTokens, reportRejected } from "./sign-in-placement.js";
|
|
11
|
+
const redirectStatuses = new Set([301, 302, 303, 307, 308]);
|
|
12
|
+
/** Headers a browser drops when a redirect leaves the origin; the kit does the same. */
|
|
13
|
+
const originBoundHeaders = ["authorization", "cookie", "proxy-authorization"];
|
|
14
|
+
/**
|
|
15
|
+
* The `HttpClient` an integration gets: only the hosts and secrets of its
|
|
16
|
+
* permission sheet, `https` only (plain `http` only to a local host), every
|
|
17
|
+
* redirect hop checked again, with timeouts and a response size limit. Every
|
|
18
|
+
* request goes into the log.
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* const http = createLimitedHttpClient({ policy, transport: { fetch }, secrets, log: new RequestLog() });
|
|
22
|
+
* await http.fetch("https://api.example.com/v1", { auth: { secret: "example-key", as: "bearer" } });
|
|
23
|
+
*/
|
|
24
|
+
export function createLimitedHttpClient(options) {
|
|
25
|
+
const now = options.now ?? Date.now;
|
|
26
|
+
return {
|
|
27
|
+
async fetch(rawUrl, init = {}) {
|
|
28
|
+
const started = now();
|
|
29
|
+
// Until the secret check has passed, the method, host and path may hold a key,
|
|
30
|
+
// so the check runs first: before the URL is parsed and before any other refusal.
|
|
31
|
+
let logged = unchecked;
|
|
32
|
+
try {
|
|
33
|
+
// Before the first `await`: from here on the kit reads only this copy.
|
|
34
|
+
const own = copyRequest(options.policy, rawUrl, init);
|
|
35
|
+
// Needs no secret, so a placement the sheet doesn't allow is refused before any is read.
|
|
36
|
+
checkPlacements(options.policy, own.placements);
|
|
37
|
+
const declared = await readDeclaredSecrets(options.policy, options.secrets);
|
|
38
|
+
const carried = carriedForms([...declared.values(), ...signInValues(options)]);
|
|
39
|
+
refuseCarriedSecrets(options.policy, carried, {
|
|
40
|
+
method: own.givenMethod,
|
|
41
|
+
sentMethod: own.method,
|
|
42
|
+
url: own.url ?? "",
|
|
43
|
+
headers: own.headers,
|
|
44
|
+
body: own.body,
|
|
45
|
+
});
|
|
46
|
+
logged = { method: own.method, ...logPlace(own.url) };
|
|
47
|
+
const response = await send(options, own, { declared, carried });
|
|
48
|
+
options.log.add({
|
|
49
|
+
method: own.method,
|
|
50
|
+
...logPlace(response.url),
|
|
51
|
+
status: response.status,
|
|
52
|
+
durationMs: now() - started,
|
|
53
|
+
outcome: "ok",
|
|
54
|
+
});
|
|
55
|
+
return response;
|
|
56
|
+
}
|
|
57
|
+
catch (error) {
|
|
58
|
+
const refused = error instanceof IntegrationRefusedError;
|
|
59
|
+
options.log.add({
|
|
60
|
+
...(error instanceof SecretInRequestError ? error.logged : logged),
|
|
61
|
+
durationMs: now() - started,
|
|
62
|
+
outcome: refused ? "refused" : "failed",
|
|
63
|
+
...(refused ? { refusal: error.code } : {}),
|
|
64
|
+
});
|
|
65
|
+
throw error;
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/** Every value the sign-ins' tokens say the filter must remove: tokens not yet expired, refresh tokens, client secrets. */
|
|
71
|
+
function signInValues(options) {
|
|
72
|
+
return options.signInTokens?.filterValues() ?? [];
|
|
73
|
+
}
|
|
74
|
+
/** What the log shows of a request that failed before the secret check passed. */
|
|
75
|
+
const unchecked = { method: "", host: "", path: "" };
|
|
76
|
+
async function send(options, own, { declared, carried }) {
|
|
77
|
+
const { policy, limits = {} } = options;
|
|
78
|
+
// Only the copied method, headers and body reach the transport, which the secret check has
|
|
79
|
+
// read. Every other option is dropped: `referrer` goes out as an unchecked `Referer` header,
|
|
80
|
+
// and Node's `dispatcher` would hand the whole request, placed secrets included, to the
|
|
81
|
+
// integration.
|
|
82
|
+
const { placements, body, signal } = own;
|
|
83
|
+
// After the secret check, which skips a body it can't read, so this refusal logs no key.
|
|
84
|
+
checkBody(policy, body);
|
|
85
|
+
const url = allowedUrl(policy, own.url);
|
|
86
|
+
checkPlacementHosts(policy, placements, url);
|
|
87
|
+
const maxBodyBytes = requestBodyLimit(limits.maxRequestBodyBytes);
|
|
88
|
+
const values = await readSecrets(policy, options.secrets, placements);
|
|
89
|
+
const hop = {
|
|
90
|
+
url,
|
|
91
|
+
method: own.method,
|
|
92
|
+
body,
|
|
93
|
+
form: placements.some((p) => p.as === "form") ? toForm(policy, body) : undefined,
|
|
94
|
+
placements,
|
|
95
|
+
headers: new Headers(own.headers),
|
|
96
|
+
};
|
|
97
|
+
const timers = startTimers(policy, hop, limits, signal);
|
|
98
|
+
const guard = {
|
|
99
|
+
signal: timers.combined,
|
|
100
|
+
idleMs: limits.idleTimeoutMs ?? 60_000,
|
|
101
|
+
maxBytes: limits.maxResponseBytes ?? 10 * 1024 * 1024,
|
|
102
|
+
onIdle: () => timers.stop("no data", limits.idleTimeoutMs ?? 60_000),
|
|
103
|
+
done: () => clearTimeout(timers.total),
|
|
104
|
+
// Every declared secret, not only the placed ones: the bridge filters the same way.
|
|
105
|
+
secrets: filterForms(options, placements, declared, new Map()),
|
|
106
|
+
};
|
|
107
|
+
try {
|
|
108
|
+
return await followHops(options, {
|
|
109
|
+
hop,
|
|
110
|
+
values,
|
|
111
|
+
declared,
|
|
112
|
+
carried,
|
|
113
|
+
guard,
|
|
114
|
+
maxBodyBytes,
|
|
115
|
+
timers,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
catch (error) {
|
|
119
|
+
clearTimeout(timers.headers);
|
|
120
|
+
clearTimeout(timers.total);
|
|
121
|
+
// Refusals and timeouts name the URL of the hop, which a redirect may have chosen.
|
|
122
|
+
throw removeSecretsFromError(error, guard.secrets);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
function startTimers(policy, hop, limits, signal) {
|
|
126
|
+
const deadline = new AbortController();
|
|
127
|
+
const stop = (what, ms) => deadline.abort(new IntegrationTimeoutError(`${policy.name}: ${what} from ${hop.url.host}${hop.url.pathname} within ${ms} ms`));
|
|
128
|
+
const totalMs = limits.timeoutMs ?? 600_000;
|
|
129
|
+
const headersMs = limits.headersTimeoutMs ?? 30_000;
|
|
130
|
+
return {
|
|
131
|
+
combined: signal ? AbortSignal.any([signal, deadline.signal]) : deadline.signal,
|
|
132
|
+
total: setTimeout(() => stop("no complete response", totalMs), totalMs),
|
|
133
|
+
headers: setTimeout(() => stop("no response headers", headersMs), headersMs),
|
|
134
|
+
stop,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Every form of the values that must not reach the integration or leave in
|
|
139
|
+
* its own requests: the declared secrets (with where this request places
|
|
140
|
+
* them), the sign-ins' filter values, and the tokens this hop places.
|
|
141
|
+
*/
|
|
142
|
+
function filterForms(options, placements, declared, tokens) {
|
|
143
|
+
const placedAs = (name, isPlaced) => placements.filter((placement) => isPlaced(placement) && placementName(placement) === name);
|
|
144
|
+
return secretForms([
|
|
145
|
+
...[...declared].map(([secret, value]) => ({
|
|
146
|
+
value,
|
|
147
|
+
placements: placedAs(secret, isSecretPlacement),
|
|
148
|
+
})),
|
|
149
|
+
...signInValues(options).map((value) => ({ value })),
|
|
150
|
+
...[...tokens].map(([signIn, value]) => ({
|
|
151
|
+
value,
|
|
152
|
+
placements: placedAs(signIn, isSignInPlacement),
|
|
153
|
+
})),
|
|
154
|
+
]);
|
|
155
|
+
}
|
|
156
|
+
/** The name of the secret or sign-in a placement is for. */
|
|
157
|
+
function placementName(placement) {
|
|
158
|
+
return isSecretPlacement(placement) ? placement.secret : placement.signIn;
|
|
159
|
+
}
|
|
160
|
+
/** Sends the request, then each redirect hop, until an answer that isn't one. */
|
|
161
|
+
async function followHops(options, context) {
|
|
162
|
+
const { policy, limits = {} } = options;
|
|
163
|
+
const { hop, values, declared, guard, maxBodyBytes, timers } = context;
|
|
164
|
+
const maxRedirects = limits.maxRedirects ?? 5;
|
|
165
|
+
for (let count = 0;; count++) {
|
|
166
|
+
const tokens = await readTokens(policy, options.signInTokens, hop.placements.filter(isSignInPlacement), hop.url, timers.combined);
|
|
167
|
+
if (hop.placements.some(isSignInPlacement)) {
|
|
168
|
+
// A refresh may have issued a token the filter didn't know when the request started.
|
|
169
|
+
guard.secrets = filterForms(options, hop.placements, declared, tokens);
|
|
170
|
+
context.carried = carriedForms([...declared.values(), ...signInValues(options)]);
|
|
171
|
+
}
|
|
172
|
+
const headers = new Headers(hop.headers);
|
|
173
|
+
const placedForm = place(policy, hop.placements, { secrets: values, tokens }, hop.url, headers, hop.form);
|
|
174
|
+
const body = placedForm ?? hop.body;
|
|
175
|
+
if (bodyBytes(body) > maxBodyBytes)
|
|
176
|
+
throw requestTooLarge(policy, hop.url, maxBodyBytes);
|
|
177
|
+
const response = await untilAborted(options.transport.fetch(hop.url.href, {
|
|
178
|
+
method: hop.method,
|
|
179
|
+
headers,
|
|
180
|
+
body,
|
|
181
|
+
redirect: "manual",
|
|
182
|
+
signal: timers.combined,
|
|
183
|
+
}), timers.combined);
|
|
184
|
+
// Only for a token this hop placed: a 401 from any other hop says nothing about it.
|
|
185
|
+
if (response.status === 401)
|
|
186
|
+
reportRejected(options.signInTokens, tokens);
|
|
187
|
+
const location = response.headers.get("location");
|
|
188
|
+
if (!redirectStatuses.has(response.status) || location === null) {
|
|
189
|
+
clearTimeout(timers.headers);
|
|
190
|
+
return guardBody(policy, response, hop.url, guard);
|
|
191
|
+
}
|
|
192
|
+
await response.body?.cancel();
|
|
193
|
+
if (count >= maxRedirects) {
|
|
194
|
+
throw new IntegrationRefusedError("too-many-redirects", `${policy.name}: ${hop.url.host}${hop.url.pathname} redirected more than ${maxRedirects} times`);
|
|
195
|
+
}
|
|
196
|
+
refuseRedirectCarryingSecrets(policy, context.carried, location, hop.url);
|
|
197
|
+
follow(hop, response.status, allowedUrl(policy, location, hop.url));
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
/** Moves the hop on to an allowed redirect target, the way `fetch` does. */
|
|
201
|
+
function follow(hop, status, next) {
|
|
202
|
+
if (next.origin !== hop.url.origin)
|
|
203
|
+
for (const name of originBoundHeaders)
|
|
204
|
+
hop.headers.delete(name);
|
|
205
|
+
const toGet = status === 303 || ((status === 301 || status === 302) && hop.method === "POST");
|
|
206
|
+
if (toGet) {
|
|
207
|
+
hop.method = hop.method === "HEAD" ? "HEAD" : "GET";
|
|
208
|
+
hop.body = null;
|
|
209
|
+
hop.form = undefined;
|
|
210
|
+
hop.placements = hop.placements.filter((p) => p.as !== "form");
|
|
211
|
+
hop.headers.delete("content-type");
|
|
212
|
+
hop.headers.delete("content-length");
|
|
213
|
+
}
|
|
214
|
+
hop.url = next;
|
|
215
|
+
}
|
|
216
|
+
/** Host and path for the log, without query or fragment. Empty when the URL doesn't parse. */
|
|
217
|
+
function logPlace(raw) {
|
|
218
|
+
try {
|
|
219
|
+
const url = new URL(String(raw));
|
|
220
|
+
return { host: url.host, path: url.pathname };
|
|
221
|
+
}
|
|
222
|
+
catch {
|
|
223
|
+
return { host: "", path: "" };
|
|
224
|
+
}
|
|
225
|
+
}
|
|
@@ -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,131 @@
|
|
|
1
|
+
import type { AddressCheckingHttpClient } from "../../http-kit/src/index.js";
|
|
2
|
+
import { type IntegrationSheet } from "../../../core/format/src/integration/index.js";
|
|
3
|
+
import { type Integration, type IntegrationHost, type ProviderConfig, type Secrets, type SignInTokens, type TokenStore } from "../../../core/ports/src/index.js";
|
|
4
|
+
import { type Result } from "../../../core/std/src/index.js";
|
|
5
|
+
import { type CurrentSecretForms } from "./current-secret-forms.js";
|
|
6
|
+
import type { LoadProblem } from "./load-problem.js";
|
|
7
|
+
import type { RequestLog } from "./request-log.js";
|
|
8
|
+
import type { SecretOnWire } from "./secret-filter.js";
|
|
9
|
+
/** An integration and its permission sheet, as they were found. */
|
|
10
|
+
export interface IntegrationSource {
|
|
11
|
+
/**
|
|
12
|
+
* `built-in`: from the integrations release this Halonic pins. `local`: from
|
|
13
|
+
* the workspace, such as one the assistant wrote; it loads only with the
|
|
14
|
+
* sheet the user approved.
|
|
15
|
+
*/
|
|
16
|
+
readonly origin: "built-in" | "local";
|
|
17
|
+
/** The permission sheet as data: the JSON the build writes next to the code. */
|
|
18
|
+
readonly sheet: unknown;
|
|
19
|
+
readonly integration: Integration;
|
|
20
|
+
/**
|
|
21
|
+
* For a `local` integration: the sheet as the user approved it in the trust
|
|
22
|
+
* step. The loader refuses it when the sheet has changed since.
|
|
23
|
+
*/
|
|
24
|
+
readonly approvedSheet?: unknown;
|
|
25
|
+
/**
|
|
26
|
+
* `true` for a plugin's backend, whose sheet's id is the plugin's. The
|
|
27
|
+
* secrets it picks are then read as that plugin's own, `plugin__<id>__<name>`,
|
|
28
|
+
* and only those, never as a workspace's picks, which can't name a plugin's.
|
|
29
|
+
* The names come from the plugin's manifest, never from a workspace.
|
|
30
|
+
*/
|
|
31
|
+
readonly plugin?: boolean;
|
|
32
|
+
}
|
|
33
|
+
/** What the workspace chose for one integration. */
|
|
34
|
+
export interface WorkspaceChoices {
|
|
35
|
+
/** Its settings, such as the URL a `{ fromSetting }` host reads. Never a secret value. */
|
|
36
|
+
readonly settings?: Readonly<Record<string, unknown>>;
|
|
37
|
+
/**
|
|
38
|
+
* For each secret in the sheet, the workspace secret the user picked for
|
|
39
|
+
* it. A secret left out isn't configured: an optional one is left off the
|
|
40
|
+
* request, any other is refused when a request needs it.
|
|
41
|
+
*/
|
|
42
|
+
readonly secretNames?: Readonly<Record<string, string>>;
|
|
43
|
+
}
|
|
44
|
+
/** What {@link loadIntegration} needs: the integration and the raw ports, which the integration never sees. */
|
|
45
|
+
export interface LoadIntegrationOptions {
|
|
46
|
+
readonly source: IntegrationSource;
|
|
47
|
+
readonly choices?: WorkspaceChoices;
|
|
48
|
+
/**
|
|
49
|
+
* What sends the requests. The sheet names hosts only, so it must check
|
|
50
|
+
* the addresses a name resolves to itself: the Node one from
|
|
51
|
+
* `createNodeHttpClient`, never a plain `fetch` wrapper.
|
|
52
|
+
*/
|
|
53
|
+
readonly transport: AddressCheckingHttpClient;
|
|
54
|
+
readonly secrets: Secrets;
|
|
55
|
+
readonly tokens: TokenStore;
|
|
56
|
+
/**
|
|
57
|
+
* The access tokens of the sheet's sign-ins, from the host's
|
|
58
|
+
* `createIntegrationSignIns`. Without it a request that places a sign-in's
|
|
59
|
+
* token is refused as `sign-in-needed`. The integration never sees it.
|
|
60
|
+
*/
|
|
61
|
+
readonly signInTokens?: SignInTokens;
|
|
62
|
+
/** What this runtime offers beyond HTTP, for the sheet's `needs`, such as `process`. Default none. */
|
|
63
|
+
readonly capabilities?: readonly string[];
|
|
64
|
+
readonly now?: () => number;
|
|
65
|
+
}
|
|
66
|
+
/** An integration ready to connect: its checked sheet, its host and the request log only Halonic reads. */
|
|
67
|
+
export interface LoadedIntegration {
|
|
68
|
+
readonly origin: IntegrationSource["origin"];
|
|
69
|
+
readonly integration: Integration;
|
|
70
|
+
readonly sheet: IntegrationSheet;
|
|
71
|
+
readonly host: IntegrationHost;
|
|
72
|
+
readonly log: RequestLog;
|
|
73
|
+
}
|
|
74
|
+
/** What {@link prepareIntegration} needs: {@link LoadIntegrationOptions} without the code. */
|
|
75
|
+
export interface PrepareIntegrationOptions extends Omit<LoadIntegrationOptions, "source"> {
|
|
76
|
+
readonly source: Omit<IntegrationSource, "integration">;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* An integration whose sheet and choices are checked and whose host is
|
|
80
|
+
* built, but whose code hasn't been checked against the sheet yet: the code
|
|
81
|
+
* runs somewhere Halonic can't read it directly, such as the runner.
|
|
82
|
+
*/
|
|
83
|
+
export interface PreparedIntegration extends Omit<LoadedIntegration, "integration"> {
|
|
84
|
+
/**
|
|
85
|
+
* Reads the value of each secret the user picked, with the one placement
|
|
86
|
+
* the sheet allows, for a secret filter outside the kit, such as the runner
|
|
87
|
+
* bridge's. Read it again for each runner start, so a changed value is
|
|
88
|
+
* filtered too. Only Halonic's side ever calls it.
|
|
89
|
+
*/
|
|
90
|
+
readonly readSecrets: () => Promise<SecretOnWire[]>;
|
|
91
|
+
/**
|
|
92
|
+
* What the runner bridge filters with: the picked secrets read now, and
|
|
93
|
+
* every value the sign-in tokens list, read again each time the filter is
|
|
94
|
+
* used, so a token a refresh issues later is removed too. Call it for each
|
|
95
|
+
* runner start, like {@link PreparedIntegration.readSecrets}.
|
|
96
|
+
*/
|
|
97
|
+
readonly currentSecretForms: () => Promise<CurrentSecretForms>;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Checks an integration against its permission sheet and builds its host. The
|
|
101
|
+
* sheet must pass its schema, the code must be exactly what the sheet
|
|
102
|
+
* declares, a local integration's sheet must be the one the user approved,
|
|
103
|
+
* every need must be available, and the workspace's choices must fit the
|
|
104
|
+
* sheet. Nothing is sent: call `integration.connect(loaded.host)` next.
|
|
105
|
+
*
|
|
106
|
+
* @example
|
|
107
|
+
* const loaded = loadIntegration({ source: { origin: "built-in", sheet, integration: weather }, transport, secrets, tokens });
|
|
108
|
+
* if (loaded.ok) connections.set("weather", loaded.value.integration.connect(loaded.value.host));
|
|
109
|
+
*/
|
|
110
|
+
export declare function loadIntegration(options: LoadIntegrationOptions): Result<LoadedIntegration, LoadProblem[]>;
|
|
111
|
+
/**
|
|
112
|
+
* Does every check {@link loadIntegration} does except the one on the code,
|
|
113
|
+
* and builds the host. The caller checks the code against the sheet itself
|
|
114
|
+
* with {@link declarationProblems} once it knows what the code declares.
|
|
115
|
+
*
|
|
116
|
+
* @example
|
|
117
|
+
* const prepared = prepareIntegration({ source: { origin: "local", sheet, approvedSheet }, transport, secrets, tokens });
|
|
118
|
+
* if (prepared.ok) runner = await startRunner({ http: prepared.value.host.http, ... });
|
|
119
|
+
*/
|
|
120
|
+
export declare function prepareIntegration(options: PrepareIntegrationOptions): Result<PreparedIntegration, LoadProblem[]>;
|
|
121
|
+
/**
|
|
122
|
+
* Maps a workspace's provider entry onto the sheet, so the integration can
|
|
123
|
+
* ignore `ProviderConfig.baseUrl` and `.secret`: the `baseUrl` becomes the
|
|
124
|
+
* setting the sheet's one `{ fromSetting }` host reads, and the workspace
|
|
125
|
+
* secret becomes the sheet's one secret.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* providerChoices(sheet, { id: "local", type: "ollama", baseUrl: "http://localhost:11434", local: true, options: {} });
|
|
129
|
+
* // ok({ settings: { url: "http://localhost:11434" }, secretNames: {} })
|
|
130
|
+
*/
|
|
131
|
+
export declare function providerChoices(sheet: IntegrationSheet, config: ProviderConfig): Result<Required<WorkspaceChoices>, LoadProblem[]>;
|
|
@@ -0,0 +1,251 @@
|
|
|
1
|
+
import { integrationPolicy, isPlacedSecret, parseIntegrationSheet, } from "../../../core/format/src/integration/index.js";
|
|
2
|
+
import { pluginSecrets, workspaceSecrets, } from "../../../core/ports/src/index.js";
|
|
3
|
+
import { deepEqual, err, ok } from "../../../core/std/src/index.js";
|
|
4
|
+
import { currentSecretForms } from "./current-secret-forms.js";
|
|
5
|
+
import { declarationProblems } from "./declaration.js";
|
|
6
|
+
import { createIntegrationHost } from "./host.js";
|
|
7
|
+
import { checkSecretLength } from "./secret-placement.js";
|
|
8
|
+
/**
|
|
9
|
+
* Checks an integration against its permission sheet and builds its host. The
|
|
10
|
+
* sheet must pass its schema, the code must be exactly what the sheet
|
|
11
|
+
* declares, a local integration's sheet must be the one the user approved,
|
|
12
|
+
* every need must be available, and the workspace's choices must fit the
|
|
13
|
+
* sheet. Nothing is sent: call `integration.connect(loaded.host)` next.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const loaded = loadIntegration({ source: { origin: "built-in", sheet, integration: weather }, transport, secrets, tokens });
|
|
17
|
+
* if (loaded.ok) connections.set("weather", loaded.value.integration.connect(loaded.value.host));
|
|
18
|
+
*/
|
|
19
|
+
export function loadIntegration(options) {
|
|
20
|
+
const { integration } = options.source;
|
|
21
|
+
const prepared = prepare(options, (sheet) => declarationProblems(sheet, integration));
|
|
22
|
+
if (!prepared.ok) {
|
|
23
|
+
return prepared;
|
|
24
|
+
}
|
|
25
|
+
const { readSecrets: _readSecrets, currentSecretForms: _forms, ...loaded } = prepared.value;
|
|
26
|
+
return ok({ ...loaded, integration });
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Does every check {@link loadIntegration} does except the one on the code,
|
|
30
|
+
* and builds the host. The caller checks the code against the sheet itself
|
|
31
|
+
* with {@link declarationProblems} once it knows what the code declares.
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* const prepared = prepareIntegration({ source: { origin: "local", sheet, approvedSheet }, transport, secrets, tokens });
|
|
35
|
+
* if (prepared.ok) runner = await startRunner({ http: prepared.value.host.http, ... });
|
|
36
|
+
*/
|
|
37
|
+
export function prepareIntegration(options) {
|
|
38
|
+
return prepare(options, () => []);
|
|
39
|
+
}
|
|
40
|
+
/** The checks both entries share; `codeProblems` checks the code, where there is code to check. */
|
|
41
|
+
function prepare(options, codeProblems) {
|
|
42
|
+
const { source } = options;
|
|
43
|
+
const parsed = parseIntegrationSheet(source.sheet);
|
|
44
|
+
if (!parsed.ok) {
|
|
45
|
+
return err(parsed.error);
|
|
46
|
+
}
|
|
47
|
+
const sheet = parsed.value;
|
|
48
|
+
const settings = options.choices?.settings ?? {};
|
|
49
|
+
const secretNames = options.choices?.secretNames ?? {};
|
|
50
|
+
const problems = [
|
|
51
|
+
...approvalProblems(source, sheet),
|
|
52
|
+
...localTokenProblems(source, sheet),
|
|
53
|
+
...localSignInProblems(source, sheet),
|
|
54
|
+
...codeProblems(sheet),
|
|
55
|
+
...needProblems(sheet, options.capabilities ?? []),
|
|
56
|
+
...secretChoiceProblems(sheet, secretNames),
|
|
57
|
+
];
|
|
58
|
+
const resolved = integrationPolicy(sheet, settings);
|
|
59
|
+
if (!resolved.ok) {
|
|
60
|
+
problems.push(...resolved.error);
|
|
61
|
+
}
|
|
62
|
+
if (problems.length > 0 || !resolved.ok) {
|
|
63
|
+
return err(problems);
|
|
64
|
+
}
|
|
65
|
+
const secrets = chosenSecrets(options.secrets, secretNames, source.plugin ? sheet.id : undefined);
|
|
66
|
+
const { host, log } = createIntegrationHost({
|
|
67
|
+
policy: resolved.value.policy,
|
|
68
|
+
transport: options.transport,
|
|
69
|
+
secrets,
|
|
70
|
+
tokens: options.tokens,
|
|
71
|
+
...(options.signInTokens ? { signInTokens: options.signInTokens } : {}),
|
|
72
|
+
settings,
|
|
73
|
+
...(resolved.value.limits ? { limits: requestLimits(resolved.value.limits) } : {}),
|
|
74
|
+
...(options.now ? { now: options.now } : {}),
|
|
75
|
+
});
|
|
76
|
+
const readSecrets = () => secretsOnWire(sheet, secrets);
|
|
77
|
+
const forms = async () => currentSecretForms(await readSecrets(), options.signInTokens);
|
|
78
|
+
return ok({ origin: source.origin, sheet, host, log, readSecrets, currentSecretForms: forms });
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Maps a workspace's provider entry onto the sheet, so the integration can
|
|
82
|
+
* ignore `ProviderConfig.baseUrl` and `.secret`: the `baseUrl` becomes the
|
|
83
|
+
* setting the sheet's one `{ fromSetting }` host reads, and the workspace
|
|
84
|
+
* secret becomes the sheet's one secret.
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* providerChoices(sheet, { id: "local", type: "ollama", baseUrl: "http://localhost:11434", local: true, options: {} });
|
|
88
|
+
* // ok({ settings: { url: "http://localhost:11434" }, secretNames: {} })
|
|
89
|
+
*/
|
|
90
|
+
export function providerChoices(sheet, config) {
|
|
91
|
+
const problems = [];
|
|
92
|
+
const settings = {};
|
|
93
|
+
const secretNames = {};
|
|
94
|
+
if (config.baseUrl !== undefined) {
|
|
95
|
+
const fromSettings = [
|
|
96
|
+
...new Set(sheet.hosts.flatMap((host) => (typeof host === "string" ? [] : [host.fromSetting]))),
|
|
97
|
+
];
|
|
98
|
+
const [setting] = fromSettings;
|
|
99
|
+
if (fromSettings.length === 1 && setting !== undefined) {
|
|
100
|
+
settings[setting] = config.baseUrl;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
problems.push({
|
|
104
|
+
code: "base-url-not-mapped",
|
|
105
|
+
path: ["hosts"],
|
|
106
|
+
message: `${sheet.id}: provider "${config.id}" sets an address, so the sheet needs exactly one { fromSetting } host, not ${fromSettings.length}`,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
if (config.secret !== undefined) {
|
|
111
|
+
const names = Object.keys(sheet.secrets);
|
|
112
|
+
const [name] = names;
|
|
113
|
+
if (names.length === 1 && name !== undefined) {
|
|
114
|
+
secretNames[name] = config.secret;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
problems.push({
|
|
118
|
+
code: "secret-not-mapped",
|
|
119
|
+
path: ["secrets"],
|
|
120
|
+
message: `${sheet.id}: provider "${config.id}" picks a secret, so the sheet needs exactly one secret, not ${names.length}`,
|
|
121
|
+
});
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
return problems.length > 0 ? err(problems) : ok({ settings, secretNames });
|
|
125
|
+
}
|
|
126
|
+
function approvalProblems(source, sheet) {
|
|
127
|
+
if (source.origin !== "local") {
|
|
128
|
+
return [];
|
|
129
|
+
}
|
|
130
|
+
const approved = source.approvedSheet === undefined ? undefined : parseIntegrationSheet(source.approvedSheet);
|
|
131
|
+
if (approved?.ok && deepEqual(approved.value, sheet)) {
|
|
132
|
+
return [];
|
|
133
|
+
}
|
|
134
|
+
return [
|
|
135
|
+
{
|
|
136
|
+
code: "sheet-not-approved",
|
|
137
|
+
path: [],
|
|
138
|
+
message: `${sheet.id}: this local integration's permission sheet isn't the one you approved; approve it again`,
|
|
139
|
+
},
|
|
140
|
+
];
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* A local integration runs in the runner, and no token value crosses into it
|
|
144
|
+
* (I5 design HAL-958, section 3.5): its sheet can't declare `tokens` (A32).
|
|
145
|
+
* Tokens as handles are the follow-up HAL-984. Built-in ones keep `tokens`.
|
|
146
|
+
*/
|
|
147
|
+
function localTokenProblems(source, sheet) {
|
|
148
|
+
if (source.origin !== "local" || sheet.tokens.length === 0) {
|
|
149
|
+
return [];
|
|
150
|
+
}
|
|
151
|
+
return [
|
|
152
|
+
{
|
|
153
|
+
code: "tokens-not-allowed",
|
|
154
|
+
path: ["tokens"],
|
|
155
|
+
message: `${sheet.id}: an integration you build or change can't hold sign-in secrets yet`,
|
|
156
|
+
fix: "Remove tokens from its sheet and use an API key, or ask for sign-in support.",
|
|
157
|
+
},
|
|
158
|
+
];
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* A local integration can't declare `signIns` until the trust content shows
|
|
162
|
+
* them: the client secret leaves `secrets`, and the token, revoke and
|
|
163
|
+
* authorize hosts needn't be in `hosts`, so the person approving would never
|
|
164
|
+
* see where the code and the client secret go.
|
|
165
|
+
*/
|
|
166
|
+
function localSignInProblems(source, sheet) {
|
|
167
|
+
if (source.origin !== "local") {
|
|
168
|
+
return [];
|
|
169
|
+
}
|
|
170
|
+
return Object.keys(sheet.signIns).map((name) => ({
|
|
171
|
+
code: "sign-ins-not-allowed",
|
|
172
|
+
path: ["signIns", name],
|
|
173
|
+
message: `${sheet.id}: an integration you build or change can't declare the sign-in ${name} yet`,
|
|
174
|
+
fix: "Remove signIns from its sheet and use an API key, or ask for sign-in support.",
|
|
175
|
+
}));
|
|
176
|
+
}
|
|
177
|
+
function needProblems(sheet, capabilities) {
|
|
178
|
+
return sheet.needs.flatMap((need, index) => capabilities.includes(need)
|
|
179
|
+
? []
|
|
180
|
+
: [
|
|
181
|
+
{
|
|
182
|
+
code: "need-not-available",
|
|
183
|
+
path: ["needs", index],
|
|
184
|
+
message: `${sheet.id}: needs "${need}", which this Halonic doesn't offer here`,
|
|
185
|
+
},
|
|
186
|
+
]);
|
|
187
|
+
}
|
|
188
|
+
function secretChoiceProblems(sheet, secretNames) {
|
|
189
|
+
return Object.keys(secretNames).flatMap((name) => Object.hasOwn(sheet.secrets, name)
|
|
190
|
+
? []
|
|
191
|
+
: [
|
|
192
|
+
{
|
|
193
|
+
code: "secret-not-declared",
|
|
194
|
+
path: ["secrets"],
|
|
195
|
+
message: `${sheet.id}: a workspace secret was picked for "${name}", which the sheet doesn't declare`,
|
|
196
|
+
},
|
|
197
|
+
]);
|
|
198
|
+
}
|
|
199
|
+
/** The sheet's limits as the kit takes them: only the ones the sheet sets. */
|
|
200
|
+
function requestLimits(limits) {
|
|
201
|
+
return Object.fromEntries(Object.entries(limits).filter((entry) => entry[1] !== undefined));
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* The raw secrets seen through the user's picks: the kit asks by the sheet's
|
|
205
|
+
* name and reads the secret picked for it, or nothing. A workspace chose
|
|
206
|
+
* those names, so they can't reach Halonic's own secrets, tokens or a
|
|
207
|
+
* plugin's. A plugin's backend's names come from its manifest and can reach
|
|
208
|
+
* only that plugin's own secrets (`plugin`).
|
|
209
|
+
*/
|
|
210
|
+
function chosenSecrets(raw, secretNames, plugin) {
|
|
211
|
+
const picks = new Map(Object.entries(secretNames));
|
|
212
|
+
const readable = plugin === undefined ? workspaceSecrets(raw) : pluginSecrets(raw, plugin);
|
|
213
|
+
return {
|
|
214
|
+
get: async (name) => {
|
|
215
|
+
const picked = picks.get(name);
|
|
216
|
+
return picked === undefined ? null : await readable.get(picked);
|
|
217
|
+
},
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Each declared secret with a value, and its one placement, as {@link PreparedIntegration.readSecrets} gives them.
|
|
222
|
+
*
|
|
223
|
+
* @throws {IntegrationRefusedError} `secret-too-short` for a value the filter can't safely remove
|
|
224
|
+
*/
|
|
225
|
+
async function secretsOnWire(sheet, secrets) {
|
|
226
|
+
const read = Object.entries(sheet.secrets).map(async ([name, declared]) => {
|
|
227
|
+
const value = await secrets.get(name);
|
|
228
|
+
if (value === null)
|
|
229
|
+
return [];
|
|
230
|
+
checkSecretLength(sheet.id, name, value);
|
|
231
|
+
// A client secret is never placed by the integration, but a server could still echo it.
|
|
232
|
+
return [{ value, placements: isPlacedSecret(declared) ? [placementOf(name, declared)] : [] }];
|
|
233
|
+
});
|
|
234
|
+
return (await Promise.all(read)).flat();
|
|
235
|
+
}
|
|
236
|
+
/** Where the sheet puts one secret, as the request names it. */
|
|
237
|
+
function placementOf(secret, declared) {
|
|
238
|
+
switch (declared.as) {
|
|
239
|
+
case "bearer":
|
|
240
|
+
return { secret, as: "bearer" };
|
|
241
|
+
case "header":
|
|
242
|
+
return {
|
|
243
|
+
secret,
|
|
244
|
+
as: "header",
|
|
245
|
+
header: declared.header,
|
|
246
|
+
...(declared.prefix === undefined ? {} : { prefix: declared.prefix }),
|
|
247
|
+
};
|
|
248
|
+
case "form":
|
|
249
|
+
return { secret, as: "form", field: declared.field };
|
|
250
|
+
}
|
|
251
|
+
}
|
|
@@ -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;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { classifyAddress, parseIpAddress } from "../../http-kit/src/index.js";
|
|
2
|
+
/**
|
|
3
|
+
* Addresses on the user's own machine or network, for the plain `http` hosts
|
|
4
|
+
* a user may choose in a setting. Only literal addresses and
|
|
5
|
+
* `localhost` count: a name can resolve anywhere. Takes `URL.hostname`, which
|
|
6
|
+
* has already normalised the address. The classes come from `http-kit`, so
|
|
7
|
+
* this check and the Node transport's address check can't disagree.
|
|
8
|
+
*/
|
|
9
|
+
/** `localhost`, `127.0.0.0/8` or `::1`: the user's own machine. */
|
|
10
|
+
export function isLoopback(hostname) {
|
|
11
|
+
const host = hostname.toLowerCase();
|
|
12
|
+
return host === "localhost" || literalClass(host) === "loopback";
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Loopback, or a private network address (`10/8`, `172.16/12`,
|
|
16
|
+
* `192.168/16`, IPv6 `fc00::/7`). Link-local and metadata addresses don't
|
|
17
|
+
* count: `169.254.169.254` is where cloud machines serve their credentials.
|
|
18
|
+
*/
|
|
19
|
+
export function isLocalAddress(hostname) {
|
|
20
|
+
return isLoopback(hostname) || literalClass(hostname.toLowerCase()) === "private";
|
|
21
|
+
}
|
|
22
|
+
/** The class of an IP address literal; undefined for a name. */
|
|
23
|
+
function literalClass(host) {
|
|
24
|
+
return parseIpAddress(host) === undefined ? undefined : classifyAddress(host);
|
|
25
|
+
}
|