@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,10 @@
|
|
|
1
|
+
import { Hub } from "./schema.js";
|
|
2
|
+
/** `hub.yaml` in each `hubs/<id>/` folder; the folder name is the hub's id when the file has none. */
|
|
3
|
+
export const hubKind = {
|
|
4
|
+
name: "hub",
|
|
5
|
+
about: "A hub: a group of agents and workflows with its own defaults.",
|
|
6
|
+
syntax: "yaml",
|
|
7
|
+
schema: Hub,
|
|
8
|
+
places: [{ scope: "hub", folder: "", name: "hub.yaml" }],
|
|
9
|
+
idFromPlace: "fallback",
|
|
10
|
+
};
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { type Infer } from "../../../../schema-kit/src/index.js";
|
|
2
|
+
/** The shared items a hub takes from its workspace, by kind. */
|
|
3
|
+
export declare const HubUses: import("zod").ZodObject<{
|
|
4
|
+
connectors: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
|
|
5
|
+
skills: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
|
|
6
|
+
knowledge: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
|
|
7
|
+
collections: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
|
|
8
|
+
}, import("zod/v4/core").$strict>;
|
|
9
|
+
/** `hubs/<id>/hub.yaml`: a hub's name, its defaults and the shared items it uses. */
|
|
10
|
+
export declare const Hub: import("zod").ZodObject<{
|
|
11
|
+
version: import("zod").ZodDefault<import("zod").ZodLiteral<1>>;
|
|
12
|
+
id: import("zod").ZodString;
|
|
13
|
+
name: import("zod").ZodString;
|
|
14
|
+
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
15
|
+
defaults: import("zod").ZodDefault<import("zod").ZodObject<{
|
|
16
|
+
runtime: import("zod").ZodOptional<import("zod").ZodString>;
|
|
17
|
+
model: import("zod").ZodOptional<import("zod").ZodString>;
|
|
18
|
+
}, import("zod/v4/core").$strict>>;
|
|
19
|
+
models: import("zod").ZodDefault<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodObject<{
|
|
20
|
+
provider: import("zod").ZodString;
|
|
21
|
+
model: import("zod").ZodString;
|
|
22
|
+
params: import("zod").ZodDefault<import("zod").ZodObject<{
|
|
23
|
+
temperature: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
24
|
+
topP: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
25
|
+
maxTokens: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
26
|
+
stop: import("zod").ZodOptional<import("zod").ZodArray<import("zod").ZodString>>;
|
|
27
|
+
reasoningEffort: import("zod").ZodOptional<import("zod").ZodEnum<{
|
|
28
|
+
high: "high";
|
|
29
|
+
low: "low";
|
|
30
|
+
medium: "medium";
|
|
31
|
+
}>>;
|
|
32
|
+
extra: import("zod").ZodOptional<import("zod").ZodRecord<import("zod").ZodString, import("zod").ZodUnknown>>;
|
|
33
|
+
}, import("zod/v4/core").$strict>>;
|
|
34
|
+
price: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
35
|
+
input: import("zod").ZodNumber;
|
|
36
|
+
output: import("zod").ZodNumber;
|
|
37
|
+
cacheRead: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
38
|
+
cacheWrite: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
39
|
+
cacheWrite1h: import("zod").ZodOptional<import("zod").ZodNumber>;
|
|
40
|
+
}, import("zod/v4/core").$strict>>;
|
|
41
|
+
description: import("zod").ZodOptional<import("zod").ZodString>;
|
|
42
|
+
fallback: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
|
|
43
|
+
}, import("zod/v4/core").$strict>>>;
|
|
44
|
+
uses: import("zod").ZodOptional<import("zod").ZodObject<{
|
|
45
|
+
connectors: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
|
|
46
|
+
skills: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
|
|
47
|
+
knowledge: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
|
|
48
|
+
collections: import("zod").ZodDefault<import("zod").ZodArray<import("zod").ZodString>>;
|
|
49
|
+
}, import("zod/v4/core").$strict>>;
|
|
50
|
+
}, import("zod/v4/core").$strict>;
|
|
51
|
+
/** A hub, with defaults filled in. */
|
|
52
|
+
export type Hub = Infer<typeof Hub>;
|
|
53
|
+
/** The shared items a hub lists in `uses`. */
|
|
54
|
+
export type HubUses = Infer<typeof HubUses>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { s } from "../../../../schema-kit/src/index.js";
|
|
2
|
+
import { collectionId, id, version } from "../../shared/fields.js";
|
|
3
|
+
import { ModelAlias } from "../models/schema.js";
|
|
4
|
+
/** The shared items a hub takes from its workspace, by kind. */
|
|
5
|
+
export const HubUses = s
|
|
6
|
+
.object({
|
|
7
|
+
connectors: s.array(id).default([]),
|
|
8
|
+
skills: s.array(id).default([]),
|
|
9
|
+
knowledge: s.array(id).default([]),
|
|
10
|
+
collections: s.array(collectionId).default([]),
|
|
11
|
+
})
|
|
12
|
+
.strict();
|
|
13
|
+
/** `hubs/<id>/hub.yaml`: a hub's name, its defaults and the shared items it uses. */
|
|
14
|
+
export const Hub = s
|
|
15
|
+
.object({
|
|
16
|
+
version,
|
|
17
|
+
id,
|
|
18
|
+
name: s.string().min(1),
|
|
19
|
+
description: s.string().optional(),
|
|
20
|
+
/** Overrides of the workspace defaults (runtime, model alias). */
|
|
21
|
+
defaults: s
|
|
22
|
+
.object({ runtime: s.string().optional(), model: s.string().optional() })
|
|
23
|
+
.strict()
|
|
24
|
+
.default({}),
|
|
25
|
+
/** Hub-level alias overrides, such as "smart" pointing at another model. */
|
|
26
|
+
models: s.record(s.string(), ModelAlias).default({}),
|
|
27
|
+
/**
|
|
28
|
+
* The shared items this hub may use. Without it every shared item is
|
|
29
|
+
* available; with it only the listed ones are, which keeps the hub
|
|
30
|
+
* self-contained.
|
|
31
|
+
*/
|
|
32
|
+
uses: HubUses.optional(),
|
|
33
|
+
})
|
|
34
|
+
.strict();
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { Path } from "../../../../schema-kit/src/index.js";
|
|
2
|
+
import { type Result } from "../../../../std/src/index.js";
|
|
3
|
+
import { type PolicyProblem } from "./policy.js";
|
|
4
|
+
import { type IntegrationSheet, type IntegrationSignIn } from "./schema.js";
|
|
5
|
+
/**
|
|
6
|
+
* A sign-in with every setting filled in, as the trust check shows it and as
|
|
7
|
+
* Halonic saves it with the grant. It has the shape of `ApprovedSignIn` in
|
|
8
|
+
* `core/oauth-sign-in`, which this package can't import; the host passes it
|
|
9
|
+
* on as it is. It holds no secret: `clientSecretName` is a name.
|
|
10
|
+
*/
|
|
11
|
+
export interface ResolvedSignIn {
|
|
12
|
+
readonly flow: "oauth-code";
|
|
13
|
+
readonly authorizeUrl: string;
|
|
14
|
+
readonly tokenUrl: string;
|
|
15
|
+
readonly revokeUrl?: string;
|
|
16
|
+
/** Only ever `true`: a sign-in that doesn't say so is left without the key. */
|
|
17
|
+
readonly revokeEndsClientGrants?: true;
|
|
18
|
+
readonly issuer?: string;
|
|
19
|
+
readonly clientId: string;
|
|
20
|
+
readonly clientAuth: "post" | "basic";
|
|
21
|
+
readonly clientSecretName?: string;
|
|
22
|
+
readonly scopes: readonly string[];
|
|
23
|
+
readonly accessHosts: readonly string[];
|
|
24
|
+
readonly as: "bearer" | "header";
|
|
25
|
+
readonly header?: string;
|
|
26
|
+
readonly prefix?: string;
|
|
27
|
+
}
|
|
28
|
+
/** Why a sign-in's client ID can't be resolved. */
|
|
29
|
+
export type ClientIdProblem = PolicyProblem & {
|
|
30
|
+
readonly code: "client-id-missing" | "client-id-invalid";
|
|
31
|
+
};
|
|
32
|
+
/** What {@link resolveSignIn} needs from its caller, who already checked the hosts. */
|
|
33
|
+
export interface SignInResolution {
|
|
34
|
+
readonly sheetId: string;
|
|
35
|
+
readonly settings: Readonly<Record<string, unknown>>;
|
|
36
|
+
/** The host a `{ fromSetting }` URL reads, `host[:port]`; undefined when the setting is a problem, which it reports. */
|
|
37
|
+
readonly hostOfSetting: (setting: string, path: Path) => string | undefined;
|
|
38
|
+
/** The hosts the access token may go to, already resolved. */
|
|
39
|
+
readonly accessHosts: readonly string[];
|
|
40
|
+
readonly path: Path;
|
|
41
|
+
readonly report: (problem: ClientIdProblem) => void;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Fills in one sign-in: its URLs (a `{ fromSetting, path }` URL becomes
|
|
45
|
+
* `https://host/path`), its client ID, and its scopes as plain words.
|
|
46
|
+
*
|
|
47
|
+
* @returns the resolved sign-in, or undefined when a setting it reads is
|
|
48
|
+
* missing or invalid; the reason is then passed to `report`
|
|
49
|
+
*
|
|
50
|
+
* @example
|
|
51
|
+
* resolveSignIn(signIn, resolution); // { tokenUrl: "https://git.example.com/oauth/token", … }
|
|
52
|
+
*/
|
|
53
|
+
export declare function resolveSignIn(signIn: IntegrationSignIn, resolution: SignInResolution): ResolvedSignIn | undefined;
|
|
54
|
+
/**
|
|
55
|
+
* Each sign-in of the sheet with its settings filled in, by name: what the
|
|
56
|
+
* user approves. Apart from `integrationPolicy`, which the kit can use
|
|
57
|
+
* before the client ID setting is set.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* approvedSignIns(sheet, { clientId: "abc123" }); // ok: { "example-account": { … } }
|
|
61
|
+
*/
|
|
62
|
+
export declare function approvedSignIns(sheet: IntegrationSheet, settings: Readonly<Record<string, unknown>>): Result<Record<string, ResolvedSignIn>, PolicyProblem[]>;
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { err, ok } from "../../../../std/src/index.js";
|
|
2
|
+
import { resolveHost, resolveSignIns, settingClasses } from "./policy.js";
|
|
3
|
+
import { CLIENT_ID_PATTERN, } from "./schema.js";
|
|
4
|
+
/**
|
|
5
|
+
* Fills in one sign-in: its URLs (a `{ fromSetting, path }` URL becomes
|
|
6
|
+
* `https://host/path`), its client ID, and its scopes as plain words.
|
|
7
|
+
*
|
|
8
|
+
* @returns the resolved sign-in, or undefined when a setting it reads is
|
|
9
|
+
* missing or invalid; the reason is then passed to `report`
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* resolveSignIn(signIn, resolution); // { tokenUrl: "https://git.example.com/oauth/token", … }
|
|
13
|
+
*/
|
|
14
|
+
export function resolveSignIn(signIn, resolution) {
|
|
15
|
+
const urlOf = (url, field) => {
|
|
16
|
+
if (typeof url === "string") {
|
|
17
|
+
return url;
|
|
18
|
+
}
|
|
19
|
+
const host = resolution.hostOfSetting(url.fromSetting, [...resolution.path, field]);
|
|
20
|
+
return host === undefined ? undefined : `https://${host}${url.path ?? ""}`;
|
|
21
|
+
};
|
|
22
|
+
const authorizeUrl = urlOf(signIn.authorizeUrl, "authorizeUrl");
|
|
23
|
+
const tokenUrl = urlOf(signIn.tokenUrl, "tokenUrl");
|
|
24
|
+
const revokeUrl = signIn.revokeUrl === undefined ? undefined : urlOf(signIn.revokeUrl, "revokeUrl");
|
|
25
|
+
const issuer = signIn.issuer === undefined ? undefined : urlOf(signIn.issuer, "issuer");
|
|
26
|
+
const clientId = clientIdOf(signIn, resolution);
|
|
27
|
+
const complete = authorizeUrl !== undefined &&
|
|
28
|
+
tokenUrl !== undefined &&
|
|
29
|
+
clientId !== undefined &&
|
|
30
|
+
(signIn.revokeUrl === undefined || revokeUrl !== undefined) &&
|
|
31
|
+
(signIn.issuer === undefined || issuer !== undefined);
|
|
32
|
+
if (!complete) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
return {
|
|
36
|
+
flow: signIn.flow,
|
|
37
|
+
authorizeUrl,
|
|
38
|
+
tokenUrl,
|
|
39
|
+
...(revokeUrl === undefined ? {} : { revokeUrl }),
|
|
40
|
+
...(signIn.revokeEndsClientGrants === true ? { revokeEndsClientGrants: true } : {}),
|
|
41
|
+
...(issuer === undefined ? {} : { issuer }),
|
|
42
|
+
clientId,
|
|
43
|
+
clientAuth: signIn.clientAuth,
|
|
44
|
+
...(signIn.clientSecret === undefined ? {} : { clientSecretName: signIn.clientSecret }),
|
|
45
|
+
scopes: signIn.scopes.map((entry) => entry.scope),
|
|
46
|
+
accessHosts: resolution.accessHosts,
|
|
47
|
+
as: signIn.access.as,
|
|
48
|
+
...(signIn.access.as === "header"
|
|
49
|
+
? {
|
|
50
|
+
header: signIn.access.header,
|
|
51
|
+
...(signIn.access.prefix === undefined ? {} : { prefix: signIn.access.prefix }),
|
|
52
|
+
}
|
|
53
|
+
: {}),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
function clientIdOf(signIn, resolution) {
|
|
57
|
+
if (typeof signIn.clientId === "string") {
|
|
58
|
+
return signIn.clientId;
|
|
59
|
+
}
|
|
60
|
+
const { fromSetting } = signIn.clientId;
|
|
61
|
+
const path = [...resolution.path, "clientId"];
|
|
62
|
+
const value = Object.hasOwn(resolution.settings, fromSetting)
|
|
63
|
+
? resolution.settings[fromSetting]
|
|
64
|
+
: undefined;
|
|
65
|
+
if (typeof value !== "string" || value === "") {
|
|
66
|
+
resolution.report({
|
|
67
|
+
code: "client-id-missing",
|
|
68
|
+
path,
|
|
69
|
+
message: `${resolution.sheetId}: the setting "${fromSetting}" must hold the sign-in's client ID`,
|
|
70
|
+
});
|
|
71
|
+
return undefined;
|
|
72
|
+
}
|
|
73
|
+
if (!CLIENT_ID_PATTERN.test(value)) {
|
|
74
|
+
resolution.report({
|
|
75
|
+
code: "client-id-invalid",
|
|
76
|
+
path,
|
|
77
|
+
message: `${resolution.sheetId}: the setting "${fromSetting}" must hold a client ID without spaces or line breaks`,
|
|
78
|
+
});
|
|
79
|
+
return undefined;
|
|
80
|
+
}
|
|
81
|
+
return value;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Fills in each sign-in of a sheet from the integration's settings.
|
|
85
|
+
*
|
|
86
|
+
* @param declared - what `integrationPolicy` resolved, for the access hosts
|
|
87
|
+
* @param report - called with each client ID problem
|
|
88
|
+
* @param hostOfSetting - the host a `{ fromSetting }` URL reads, or undefined
|
|
89
|
+
* when the setting is a problem, which it has already reported
|
|
90
|
+
*/
|
|
91
|
+
function approveEach(sheet, settings, declared, report, hostOfSetting) {
|
|
92
|
+
const approved = {};
|
|
93
|
+
for (const [name, signIn] of Object.entries(sheet.signIns)) {
|
|
94
|
+
const resolved = resolveSignIn(signIn, {
|
|
95
|
+
sheetId: sheet.id,
|
|
96
|
+
settings,
|
|
97
|
+
path: ["signIns", name],
|
|
98
|
+
accessHosts: declared[name]?.hosts ?? [],
|
|
99
|
+
hostOfSetting,
|
|
100
|
+
report,
|
|
101
|
+
});
|
|
102
|
+
if (resolved !== undefined) {
|
|
103
|
+
approved[name] = resolved;
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
return approved;
|
|
107
|
+
}
|
|
108
|
+
/**
|
|
109
|
+
* Each sign-in of the sheet with its settings filled in, by name: what the
|
|
110
|
+
* user approves. Apart from `integrationPolicy`, which the kit can use
|
|
111
|
+
* before the client ID setting is set.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* approvedSignIns(sheet, { clientId: "abc123" }); // ok: { "example-account": { … } }
|
|
115
|
+
*/
|
|
116
|
+
export function approvedSignIns(sheet, settings) {
|
|
117
|
+
const problems = [];
|
|
118
|
+
const classes = settingClasses(sheet);
|
|
119
|
+
const declared = resolveSignIns(sheet, classes, settings, problems);
|
|
120
|
+
const approved = approveEach(sheet, settings, declared, (problem) => problems.push(problem),
|
|
121
|
+
// The sheet's checks keep a sign-in's address setting in class `public`,
|
|
122
|
+
// and `resolveHost` refuses plain http there, so the host is always https.
|
|
123
|
+
(setting, path) => resolveHost(sheet, { fromSetting: setting }, classes, settings, path, problems)?.host);
|
|
124
|
+
return problems.length > 0 ? err(problems) : ok(approved);
|
|
125
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { IntegrationHost, IntegrationSecretHost } from "./schema.js";
|
|
2
|
+
/**
|
|
3
|
+
* A host as one text, to compare: `api.example.com`, or `fromSetting url`.
|
|
4
|
+
* A secret or a sign-in names a `{ fromSetting }` host by its setting alone,
|
|
5
|
+
* so the class isn't part of it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function hostKey(host: IntegrationHost | IntegrationSecretHost): string;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A host as one text, to compare: `api.example.com`, or `fromSetting url`.
|
|
3
|
+
* A secret or a sign-in names a `{ fromSetting }` host by its setting alone,
|
|
4
|
+
* so the class isn't part of it.
|
|
5
|
+
*/
|
|
6
|
+
export function hostKey(host) {
|
|
7
|
+
return typeof host === "string" ? host : `fromSetting ${host.fromSetting}`;
|
|
8
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { FileKind, KindCheckProblem } from "../../kind.js";
|
|
2
|
+
import { IntegrationSheet } from "./schema.js";
|
|
3
|
+
/**
|
|
4
|
+
* `integration.yaml`, next to an integration's code. It isn't a workspace
|
|
5
|
+
* file, so it has no place; the loader for integrations reads it.
|
|
6
|
+
*/
|
|
7
|
+
export declare const integrationKind: FileKind<IntegrationSheet>;
|
|
8
|
+
/**
|
|
9
|
+
* The rules over several fields: no list names a thing twice, a secret goes
|
|
10
|
+
* only to hosts the sheet declares, the sign-ins fit the sheet and its `kit`
|
|
11
|
+
* (`checkSignIns`), a send tool has a noun, a verb comes with a noun, a send
|
|
12
|
+
* tool never says "drafted", and
|
|
13
|
+
* the Google fields fit the sheet.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* checkIntegrationSheet(sheet); // [] for the weather example in the guide
|
|
17
|
+
*/
|
|
18
|
+
export declare function checkIntegrationSheet(sheet: IntegrationSheet): KindCheckProblem[];
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import { hostKey } from "./host-key.js";
|
|
2
|
+
import { GOOGLE_CHECK_URL_PATTERN, GOOGLE_SECRET, IntegrationSheet, isPlacedSecret, } from "./schema.js";
|
|
3
|
+
import { checkSignIns } from "./sign-in-checks.js";
|
|
4
|
+
/**
|
|
5
|
+
* `integration.yaml`, next to an integration's code. It isn't a workspace
|
|
6
|
+
* file, so it has no place; the loader for integrations reads it.
|
|
7
|
+
*/
|
|
8
|
+
export const integrationKind = {
|
|
9
|
+
name: "integration",
|
|
10
|
+
about: "An integration's permission sheet: its hosts, secrets, tools and limits.",
|
|
11
|
+
syntax: "yaml",
|
|
12
|
+
schema: IntegrationSheet,
|
|
13
|
+
places: [],
|
|
14
|
+
idFromPlace: "none",
|
|
15
|
+
check: checkIntegrationSheet,
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* The rules over several fields: no list names a thing twice, a secret goes
|
|
19
|
+
* only to hosts the sheet declares, the sign-ins fit the sheet and its `kit`
|
|
20
|
+
* (`checkSignIns`), a send tool has a noun, a verb comes with a noun, a send
|
|
21
|
+
* tool never says "drafted", and
|
|
22
|
+
* the Google fields fit the sheet.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* checkIntegrationSheet(sheet); // [] for the weather example in the guide
|
|
26
|
+
*/
|
|
27
|
+
export function checkIntegrationSheet(sheet) {
|
|
28
|
+
const problems = [];
|
|
29
|
+
const duplicates = (values, path, what) => {
|
|
30
|
+
const seen = new Set();
|
|
31
|
+
values.forEach((value, index) => {
|
|
32
|
+
if (seen.has(value)) {
|
|
33
|
+
problems.push({
|
|
34
|
+
severity: "error",
|
|
35
|
+
code: "duplicate",
|
|
36
|
+
path: [...path, index],
|
|
37
|
+
message: `Integration "${sheet.id}": ${what} ${value} is listed twice`,
|
|
38
|
+
});
|
|
39
|
+
}
|
|
40
|
+
seen.add(value);
|
|
41
|
+
});
|
|
42
|
+
};
|
|
43
|
+
duplicates(sheet.provides, ["provides"], "provides");
|
|
44
|
+
duplicates(sheet.hosts.map(hostKey), ["hosts"], "host");
|
|
45
|
+
duplicates(sheet.googleScopes?.map((entry) => entry.scope) ?? [], ["googleScopes"], "scope");
|
|
46
|
+
duplicates(sheet.googleApis?.map((entry) => entry.api) ?? [], ["googleApis"], "API");
|
|
47
|
+
duplicates(sheet.tokens.map((token) => token.name), ["tokens"], "token");
|
|
48
|
+
duplicates(sheet.tools.map((tool) => tool.name), ["tools"], "tool");
|
|
49
|
+
duplicates(sheet.needs, ["needs"], "need");
|
|
50
|
+
const recording = sheet.recording;
|
|
51
|
+
duplicates(recording?.userContent ?? [], ["recording", "userContent"], "path");
|
|
52
|
+
duplicates(recording?.secretFields ?? [], ["recording", "secretFields"], "field");
|
|
53
|
+
duplicates(recording?.allowContentTypes ?? [], ["recording", "allowContentTypes"], "type");
|
|
54
|
+
const declared = new Set(sheet.hosts.map(hostKey));
|
|
55
|
+
for (const [name, secret] of Object.entries(sheet.secrets)) {
|
|
56
|
+
if (!isPlacedSecret(secret)) {
|
|
57
|
+
continue; // a client secret has no hosts of its own; `checkSignIns` checks it
|
|
58
|
+
}
|
|
59
|
+
duplicates(secret.hosts.map(hostKey), ["secrets", name, "hosts"], "host");
|
|
60
|
+
secret.hosts.forEach((host, index) => {
|
|
61
|
+
if (!declared.has(hostKey(host))) {
|
|
62
|
+
problems.push({
|
|
63
|
+
severity: "error",
|
|
64
|
+
code: "secret-host-not-declared",
|
|
65
|
+
path: ["secrets", name, "hosts", index],
|
|
66
|
+
message: `Integration "${sheet.id}": secret "${name}" may only go to hosts in hosts, and ${hostKey(host)} isn't one`,
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
problems.push(...checkSignIns(sheet));
|
|
72
|
+
problems.push(...checkSendNouns(sheet));
|
|
73
|
+
problems.push(...checkToolVerbs(sheet));
|
|
74
|
+
problems.push(...checkDraftedVerbs(sheet));
|
|
75
|
+
problems.push(...checkGoogleFields(sheet));
|
|
76
|
+
return problems;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* A `send` tool says what it sends, so a run can say "Sent 1 email". A
|
|
80
|
+
* `read` or `write` tool may leave its noun out.
|
|
81
|
+
*/
|
|
82
|
+
function checkSendNouns(sheet) {
|
|
83
|
+
return sheet.tools.flatMap((tool, index) => tool.risk === "send" && tool.noun === undefined
|
|
84
|
+
? [
|
|
85
|
+
{
|
|
86
|
+
severity: "error",
|
|
87
|
+
code: "send-tool-without-noun",
|
|
88
|
+
path: ["tools", index],
|
|
89
|
+
message: `Integration "${sheet.id}": tool "${tool.name}" has risk send, so it needs a noun for what it sends, such as noun: { one: email, many: emails }, so a run can say "Sent 1 email"`,
|
|
90
|
+
},
|
|
91
|
+
]
|
|
92
|
+
: []);
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* A `verb` says what a call did to its noun ("Saved 1 Drive file"), so on its
|
|
96
|
+
* own it says nothing: a tool with a verb needs a noun too.
|
|
97
|
+
*/
|
|
98
|
+
function checkToolVerbs(sheet) {
|
|
99
|
+
return sheet.tools.flatMap((tool, index) => tool.verb !== undefined && tool.noun === undefined
|
|
100
|
+
? [
|
|
101
|
+
{
|
|
102
|
+
severity: "error",
|
|
103
|
+
code: "verb-without-noun",
|
|
104
|
+
path: ["tools", index, "verb"],
|
|
105
|
+
message: `Integration "${sheet.id}": tool "${tool.name}" has verb ${tool.verb} but no noun, so a run couldn't say what was ${tool.verb}; add one, such as noun: { one: file, many: files }`,
|
|
106
|
+
},
|
|
107
|
+
]
|
|
108
|
+
: []);
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* `drafted` says nothing was sent, so only a `write` tool may use it. The list
|
|
112
|
+
* is closed so a send can't be worded as something milder, and "drafted" is
|
|
113
|
+
* milder than "sent".
|
|
114
|
+
*/
|
|
115
|
+
function checkDraftedVerbs(sheet) {
|
|
116
|
+
return sheet.tools.flatMap((tool, index) => tool.verb === "drafted" && tool.risk !== "write"
|
|
117
|
+
? [
|
|
118
|
+
{
|
|
119
|
+
severity: "error",
|
|
120
|
+
code: "drafted-on-send-tool",
|
|
121
|
+
path: ["tools", index, "verb"],
|
|
122
|
+
message: `Integration "${sheet.id}": tool "${tool.name}" has risk ${tool.risk}, so it may not say drafted: only a write tool prepares something without sending it`,
|
|
123
|
+
},
|
|
124
|
+
]
|
|
125
|
+
: []);
|
|
126
|
+
}
|
|
127
|
+
/** The sheet fields that only an integration using the Google sign-in may have. */
|
|
128
|
+
const googleFields = ["googleScopes", "googleApis", "googleCheck"];
|
|
129
|
+
/**
|
|
130
|
+
* The Google fields belong to a sheet with the `google-account` secret. A
|
|
131
|
+
* sheet that asks for scopes names the APIs to switch on, and `googleCheck`
|
|
132
|
+
* carries the token, so it goes to a host of the sheet and of that secret.
|
|
133
|
+
* The same rules as the `google-sheet` check in halonic-com/integrations.
|
|
134
|
+
*/
|
|
135
|
+
function checkGoogleFields(sheet) {
|
|
136
|
+
const entry = Object.hasOwn(sheet.secrets, GOOGLE_SECRET)
|
|
137
|
+
? sheet.secrets[GOOGLE_SECRET]
|
|
138
|
+
: undefined;
|
|
139
|
+
// The Google secret is one the integration places; a client secret of that name has no token to send.
|
|
140
|
+
const secret = entry !== undefined && isPlacedSecret(entry) ? entry : undefined;
|
|
141
|
+
if (secret === undefined) {
|
|
142
|
+
return googleFields
|
|
143
|
+
.filter((field) => sheet[field] !== undefined)
|
|
144
|
+
.map((field) => ({
|
|
145
|
+
severity: "error",
|
|
146
|
+
code: "google-field-without-sign-in",
|
|
147
|
+
path: [field],
|
|
148
|
+
message: `Integration "${sheet.id}": ${field} is only for an integration with the ${GOOGLE_SECRET} secret. Remove it, or add the secret`,
|
|
149
|
+
}));
|
|
150
|
+
}
|
|
151
|
+
const problems = [];
|
|
152
|
+
if (sheet.googleScopes !== undefined && (sheet.googleApis ?? []).length === 0) {
|
|
153
|
+
problems.push({
|
|
154
|
+
severity: "error",
|
|
155
|
+
code: "google-apis-missing",
|
|
156
|
+
path: ["googleScopes"],
|
|
157
|
+
message: `Integration "${sheet.id}": a sheet with googleScopes also lists googleApis, { api, name } for each API the user switches on, such as { api: gmail.googleapis.com, name: Gmail API }`,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
const url = sheet.googleCheck?.url;
|
|
161
|
+
const host = url === undefined ? undefined : GOOGLE_CHECK_URL_PATTERN.exec(url)?.[1];
|
|
162
|
+
if (host !== undefined) {
|
|
163
|
+
const inSheet = sheet.hosts.some((declared) => declared === host);
|
|
164
|
+
const inSecret = secret.hosts.some((declared) => declared === host);
|
|
165
|
+
if (!inSheet || !inSecret) {
|
|
166
|
+
problems.push({
|
|
167
|
+
severity: "error",
|
|
168
|
+
code: "google-check-host-not-declared",
|
|
169
|
+
path: ["googleCheck", "url"],
|
|
170
|
+
message: `Integration "${sheet.id}": googleCheck carries the ${GOOGLE_SECRET} token, so ${host} must be in hosts and in that secret's hosts`,
|
|
171
|
+
});
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return problems;
|
|
175
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { type IssueCode, type Path } from "../../../../schema-kit/src/index.js";
|
|
2
|
+
import { type Result } from "../../../../std/src/index.js";
|
|
3
|
+
import { IntegrationSheet } from "./schema.js";
|
|
4
|
+
/** Why a sheet was refused: a schema issue code, or the code of one of the sheet's own checks. */
|
|
5
|
+
export interface SheetProblem {
|
|
6
|
+
readonly code: IssueCode | string;
|
|
7
|
+
readonly path: Path;
|
|
8
|
+
readonly message: string;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Checks a permission sheet that is already data, such as the JSON the build
|
|
12
|
+
* writes next to an integration, with the same schema and checks as
|
|
13
|
+
* `parseFile`. For a loader that must not read YAML.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* const sheet = parseIntegrationSheet(JSON.parse(text));
|
|
17
|
+
* if (!sheet.ok) refuse(sheet.error);
|
|
18
|
+
*/
|
|
19
|
+
export declare function parseIntegrationSheet(value: unknown): Result<IntegrationSheet, SheetProblem[]>;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { parse } from "../../../../schema-kit/src/index.js";
|
|
2
|
+
import { err, ok } from "../../../../std/src/index.js";
|
|
3
|
+
import { checkIntegrationSheet } from "./kind.js";
|
|
4
|
+
import { IntegrationSheet } from "./schema.js";
|
|
5
|
+
/**
|
|
6
|
+
* Checks a permission sheet that is already data, such as the JSON the build
|
|
7
|
+
* writes next to an integration, with the same schema and checks as
|
|
8
|
+
* `parseFile`. For a loader that must not read YAML.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const sheet = parseIntegrationSheet(JSON.parse(text));
|
|
12
|
+
* if (!sheet.ok) refuse(sheet.error);
|
|
13
|
+
*/
|
|
14
|
+
export function parseIntegrationSheet(value) {
|
|
15
|
+
const parsed = parse(IntegrationSheet, value);
|
|
16
|
+
if (!parsed.ok) {
|
|
17
|
+
return err(parsed.error.map(({ code, path, message }) => ({ code, path, message })));
|
|
18
|
+
}
|
|
19
|
+
const problems = checkIntegrationSheet(parsed.value).filter((problem) => problem.severity === "error");
|
|
20
|
+
if (problems.length > 0) {
|
|
21
|
+
return err(problems.map(({ code, path, message }) => ({ code, path, message })));
|
|
22
|
+
}
|
|
23
|
+
return ok(parsed.value);
|
|
24
|
+
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import type { Path } from "../../../../schema-kit/src/index.js";
|
|
2
|
+
import { type Result } from "../../../../std/src/index.js";
|
|
3
|
+
import { type AddressClass, type IntegrationHost, type IntegrationSecretHost, type IntegrationSheet } from "./schema.js";
|
|
4
|
+
/**
|
|
5
|
+
* What one integration may do, in the shape of the kit's `IntegrationPolicy`
|
|
6
|
+
* (`adapters/integration-kit`). The core can't import an adapter, so the
|
|
7
|
+
* shape is repeated here; the kit enforces it.
|
|
8
|
+
*/
|
|
9
|
+
export interface IntegrationPolicy {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
/** Hosts it may call over `https`: a host name, or `host:port` for a port other than 443. */
|
|
12
|
+
readonly hosts: readonly string[];
|
|
13
|
+
/** Hosts the user chose that it may call over plain `http`: on this machine or a private network. */
|
|
14
|
+
readonly localHosts?: readonly string[];
|
|
15
|
+
/** Each secret, the hosts it may go to, whether a request may go without it, and where it goes. */
|
|
16
|
+
readonly secrets: Readonly<Record<string, DeclaredSecret>>;
|
|
17
|
+
/** Each sign-in, and where its access token may go and how it is put in. */
|
|
18
|
+
readonly signIns: Readonly<Record<string, DeclaredSignIn>>;
|
|
19
|
+
readonly tokens: readonly string[];
|
|
20
|
+
}
|
|
21
|
+
/** One secret as the kit takes it. */
|
|
22
|
+
export interface DeclaredSecret {
|
|
23
|
+
readonly hosts: readonly string[];
|
|
24
|
+
readonly optional?: boolean;
|
|
25
|
+
/** Where the sheet puts it. The kit refuses any other placement. */
|
|
26
|
+
readonly placement: DeclaredPlacement;
|
|
27
|
+
}
|
|
28
|
+
/** Where the sheet puts a secret, as the kit's `DeclaredPlacement` says. */
|
|
29
|
+
export type DeclaredPlacement = {
|
|
30
|
+
readonly as: "bearer";
|
|
31
|
+
} | {
|
|
32
|
+
readonly as: "header";
|
|
33
|
+
readonly header: string;
|
|
34
|
+
readonly prefix?: string;
|
|
35
|
+
} | {
|
|
36
|
+
readonly as: "form";
|
|
37
|
+
readonly field: string;
|
|
38
|
+
};
|
|
39
|
+
/**
|
|
40
|
+
* One sign-in as the kit takes it: the hosts its access token may go to, and
|
|
41
|
+
* where the sheet puts it (`as`, and `header` and `prefix` for a header). The
|
|
42
|
+
* kit refuses any other placement.
|
|
43
|
+
*/
|
|
44
|
+
export type DeclaredSignIn = DeclaredSignInPlacement & {
|
|
45
|
+
readonly hosts: readonly string[];
|
|
46
|
+
/** The client secret, when the sign-in has one. Only Halonic's sign-in code uses it. */
|
|
47
|
+
readonly clientSecret?: DeclaredClientSecret;
|
|
48
|
+
};
|
|
49
|
+
/** Where the sheet puts a sign-in's access token. There is no `form`. */
|
|
50
|
+
export type DeclaredSignInPlacement = {
|
|
51
|
+
readonly as: "bearer";
|
|
52
|
+
} | {
|
|
53
|
+
readonly as: "header";
|
|
54
|
+
readonly header: string;
|
|
55
|
+
readonly prefix?: string;
|
|
56
|
+
};
|
|
57
|
+
/**
|
|
58
|
+
* A sign-in's client secret. Its hosts are the sign-in's token and revoke
|
|
59
|
+
* hosts and nothing else, and the integration can't place it.
|
|
60
|
+
*/
|
|
61
|
+
export interface DeclaredClientSecret {
|
|
62
|
+
readonly name: string;
|
|
63
|
+
readonly hosts: readonly string[];
|
|
64
|
+
}
|
|
65
|
+
/** The kit's request limits, as the sheet gives them. */
|
|
66
|
+
export type IntegrationLimits = NonNullable<IntegrationSheet["limits"]>;
|
|
67
|
+
/** What the kit needs to build an integration's host. */
|
|
68
|
+
export interface ResolvedIntegration {
|
|
69
|
+
readonly policy: IntegrationPolicy;
|
|
70
|
+
/** Left out when the sheet has none: the kit's defaults apply. */
|
|
71
|
+
readonly limits?: IntegrationLimits;
|
|
72
|
+
}
|
|
73
|
+
/** Why a `fromSetting` host can't be resolved. */
|
|
74
|
+
export interface PolicyProblem {
|
|
75
|
+
readonly code: "setting-missing" | "setting-not-a-url" | "setting-outside-class" | "plain-http-not-local" | "secret-over-plain-http" | "client-id-missing" | "client-id-invalid";
|
|
76
|
+
/** Where the host sits in the sheet. */
|
|
77
|
+
readonly path: Path;
|
|
78
|
+
readonly message: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Turns a parsed sheet and the integration's settings into the policy the
|
|
82
|
+
* kit enforces. A `{ fromSetting }` host becomes the host of the URL in that
|
|
83
|
+
* setting, which must be in the class the sheet declares for it: a value
|
|
84
|
+
* outside it is refused as `setting-outside-class`. This is the only place
|
|
85
|
+
* plain `http` is allowed: to a `loopback` or `private` host, and a secret
|
|
86
|
+
* only to a `loopback` one, even when it's optional: the kit checks where a
|
|
87
|
+
* secret may go before it looks the key up, so it would refuse every request
|
|
88
|
+
* that names the secret there, set up or not.
|
|
89
|
+
*
|
|
90
|
+
* @example
|
|
91
|
+
* // hosts: [{ fromSetting: url, class: loopback }]
|
|
92
|
+
* const resolved = integrationPolicy(sheet, { url: "http://localhost:8080/mcp" });
|
|
93
|
+
* if (resolved.ok) createIntegrationHost({ policy: resolved.value.policy, ...ports });
|
|
94
|
+
*/
|
|
95
|
+
export declare function integrationPolicy(sheet: IntegrationSheet, settings: Readonly<Record<string, unknown>>): Result<ResolvedIntegration, PolicyProblem[]>;
|
|
96
|
+
/**
|
|
97
|
+
* Each sign-in's access hosts and placement, and its client secret with the
|
|
98
|
+
* hosts of the sign-in's token and revoke URLs. The other sign-in URLs read
|
|
99
|
+
* settings that `hosts` already resolves, so they need no check here.
|
|
100
|
+
*/
|
|
101
|
+
export declare function resolveSignIns(sheet: IntegrationSheet, classes: ReadonlyMap<string, AddressClass>, settings: Readonly<Record<string, unknown>>, problems: PolicyProblem[]): Record<string, DeclaredSignIn>;
|
|
102
|
+
interface FoundHost {
|
|
103
|
+
/** As the kit matches it: `URL.host`, without the scheme's default port. */
|
|
104
|
+
readonly host: string;
|
|
105
|
+
readonly hostname: string;
|
|
106
|
+
/** Plain `http`, so only to a local address. */
|
|
107
|
+
readonly plain: boolean;
|
|
108
|
+
}
|
|
109
|
+
/** The class the sheet declares for each setting a `{ fromSetting }` host reads. */
|
|
110
|
+
export declare function settingClasses(sheet: IntegrationSheet): ReadonlyMap<string, AddressClass>;
|
|
111
|
+
export declare function resolveHost(sheet: IntegrationSheet, host: IntegrationHost | IntegrationSecretHost, classes: ReadonlyMap<string, AddressClass>, settings: Readonly<Record<string, unknown>>, path: Path, problems: PolicyProblem[]): FoundHost | undefined;
|
|
112
|
+
export {};
|