@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,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compares two byte arrays in time that depends only on their length, never
|
|
3
|
+
* on where they first differ. Use it to check password hashes and tokens, so
|
|
4
|
+
* an attacker can't learn a secret from how long a comparison takes.
|
|
5
|
+
*
|
|
6
|
+
* Arrays of different lengths are unequal at once: lengths aren't secret
|
|
7
|
+
* here, because hashes and tokens have a fixed length.
|
|
8
|
+
*
|
|
9
|
+
* @param first - the first bytes
|
|
10
|
+
* @param second - the second bytes
|
|
11
|
+
* @returns true when both hold the same bytes
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* constantTimeEqual(storedHash, await hasher.hash(password, salt)); // true or false
|
|
15
|
+
*/
|
|
16
|
+
export function constantTimeEqual(first, second) {
|
|
17
|
+
if (first.length !== second.length) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
let difference = 0;
|
|
21
|
+
for (let index = 0; index < first.length; index++) {
|
|
22
|
+
// No early exit: every byte is compared, and differences pile up in one number.
|
|
23
|
+
difference |= (first[index] ?? 0) ^ (second[index] ?? 0);
|
|
24
|
+
}
|
|
25
|
+
return difference === 0;
|
|
26
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Anything that hashes bytes with SHA-256, such as the `Digest` port. The
|
|
3
|
+
* core has no hash code of its own, so the caller passes one in.
|
|
4
|
+
*/
|
|
5
|
+
export interface Sha256 {
|
|
6
|
+
/** The 32-byte SHA-256 of the bytes. */
|
|
7
|
+
sha256(data: Uint8Array): Promise<Uint8Array>;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The digest of a workspace file's text, as `DefinitionStore.write` expects
|
|
11
|
+
* it: `sha256:` and the 64 lowercase hex characters of the SHA-256 of the
|
|
12
|
+
* text's UTF-8 bytes.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* await contentDigest("hello", digest);
|
|
16
|
+
* // "sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
|
|
17
|
+
*/
|
|
18
|
+
export declare function contentDigest(content: string, digest: Sha256): Promise<`sha256:${string}`>;
|
|
19
|
+
/**
|
|
20
|
+
* Whether a file's text, or `null` when there is no file, is what a caller
|
|
21
|
+
* expects: the {@link contentDigest} of the text it last read, or `"absent"`
|
|
22
|
+
* for no file. Every store calls this before a write with `expected`.
|
|
23
|
+
*/
|
|
24
|
+
export declare function matchesExpected(current: string | null, expected: string, digest: Sha256): Promise<boolean>;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
// The digest the `DefinitionStore` port's write-if-unchanged check compares.
|
|
2
|
+
// It lives here, not in `@halonicjs/ports`, because the ports package uses no
|
|
3
|
+
// other package and the core has no `TextEncoder`.
|
|
4
|
+
import { bytesToHex } from "./hex.js";
|
|
5
|
+
import { encodeUtf8 } from "./utf8.js";
|
|
6
|
+
/**
|
|
7
|
+
* The digest of a workspace file's text, as `DefinitionStore.write` expects
|
|
8
|
+
* it: `sha256:` and the 64 lowercase hex characters of the SHA-256 of the
|
|
9
|
+
* text's UTF-8 bytes.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* await contentDigest("hello", digest);
|
|
13
|
+
* // "sha256:2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824"
|
|
14
|
+
*/
|
|
15
|
+
export async function contentDigest(content, digest) {
|
|
16
|
+
return `sha256:${bytesToHex(await digest.sha256(encodeUtf8(content)))}`;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Whether a file's text, or `null` when there is no file, is what a caller
|
|
20
|
+
* expects: the {@link contentDigest} of the text it last read, or `"absent"`
|
|
21
|
+
* for no file. Every store calls this before a write with `expected`.
|
|
22
|
+
*/
|
|
23
|
+
export async function matchesExpected(current, expected, digest) {
|
|
24
|
+
if (expected === "absent" || current === null) {
|
|
25
|
+
return expected === "absent" && current === null;
|
|
26
|
+
}
|
|
27
|
+
return (await contentDigest(current, digest)) === expected;
|
|
28
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copies plain data all the way down: arrays, plain objects, dates and
|
|
3
|
+
* primitives. A value that appears twice, or contains itself, is copied once
|
|
4
|
+
* and shared the same way in the copy, as `structuredClone` does. The core
|
|
5
|
+
* has no `structuredClone`, so this replaces it for run events, records and
|
|
6
|
+
* workflow context.
|
|
7
|
+
*
|
|
8
|
+
* @param value - the data to copy
|
|
9
|
+
* @returns a copy that shares no objects with `value`
|
|
10
|
+
* @throws TypeError for anything that isn't plain data, such as a function, a `Map` or a class instance
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const copy = deepClone({ steps: [{ id: "a" }] });
|
|
14
|
+
*/
|
|
15
|
+
export declare function deepClone<T>(value: T): T;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { describeObject, isPlainObject, keyPath } from "./plain-data.js";
|
|
2
|
+
/**
|
|
3
|
+
* Copies plain data all the way down: arrays, plain objects, dates and
|
|
4
|
+
* primitives. A value that appears twice, or contains itself, is copied once
|
|
5
|
+
* and shared the same way in the copy, as `structuredClone` does. The core
|
|
6
|
+
* has no `structuredClone`, so this replaces it for run events, records and
|
|
7
|
+
* workflow context.
|
|
8
|
+
*
|
|
9
|
+
* @param value - the data to copy
|
|
10
|
+
* @returns a copy that shares no objects with `value`
|
|
11
|
+
* @throws TypeError for anything that isn't plain data, such as a function, a `Map` or a class instance
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const copy = deepClone({ steps: [{ id: "a" }] });
|
|
15
|
+
*/
|
|
16
|
+
export function deepClone(value) {
|
|
17
|
+
return cloneValue(value, new Map(), "value");
|
|
18
|
+
}
|
|
19
|
+
function cloneValue(value, copies, path) {
|
|
20
|
+
if (typeof value === "function" || typeof value === "symbol") {
|
|
21
|
+
throw new TypeError(`deepClone can't copy the ${typeof value} at ${path}.`);
|
|
22
|
+
}
|
|
23
|
+
if (typeof value !== "object" || value === null) {
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
const existing = copies.get(value);
|
|
27
|
+
if (existing !== undefined) {
|
|
28
|
+
return existing;
|
|
29
|
+
}
|
|
30
|
+
if (value instanceof Date) {
|
|
31
|
+
const copy = new Date(value.getTime());
|
|
32
|
+
copies.set(value, copy);
|
|
33
|
+
return copy;
|
|
34
|
+
}
|
|
35
|
+
if (Array.isArray(value)) {
|
|
36
|
+
const copy = [];
|
|
37
|
+
copies.set(value, copy);
|
|
38
|
+
for (let index = 0; index < value.length; index++) {
|
|
39
|
+
copy.push(cloneValue(value[index], copies, `${path}[${index}]`));
|
|
40
|
+
}
|
|
41
|
+
return copy;
|
|
42
|
+
}
|
|
43
|
+
if (isPlainObject(value)) {
|
|
44
|
+
const copy = Object.getPrototypeOf(value) === null ? Object.create(null) : {};
|
|
45
|
+
copies.set(value, copy);
|
|
46
|
+
for (const key of Object.keys(value)) {
|
|
47
|
+
// defineProperty, not assignment: a "__proto__" key from JSON.parse
|
|
48
|
+
// stays a plain key instead of changing the copy's prototype.
|
|
49
|
+
Object.defineProperty(copy, key, {
|
|
50
|
+
value: cloneValue(value[key], copies, keyPath(path, key)),
|
|
51
|
+
enumerable: true,
|
|
52
|
+
writable: true,
|
|
53
|
+
configurable: true,
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
return copy;
|
|
57
|
+
}
|
|
58
|
+
throw new TypeError(`deepClone copies plain data only, but ${path} is ${describeObject(value)}.`);
|
|
59
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compares two values by content: arrays item by item, plain objects key by
|
|
3
|
+
* key in any order, and dates by time. Numbers compare with `===`, except
|
|
4
|
+
* that `NaN` equals `NaN`. Any other object (a `Map`, a class instance)
|
|
5
|
+
* equals only itself.
|
|
6
|
+
*
|
|
7
|
+
* Unlike comparing `JSON.stringify` output, key order doesn't matter, and a
|
|
8
|
+
* key whose value is `undefined` is still a key: `{ a: undefined }` doesn't
|
|
9
|
+
* equal `{}`.
|
|
10
|
+
*
|
|
11
|
+
* Cyclic data isn't supported: comparing it throws a `RangeError`. JSON can't
|
|
12
|
+
* express cycles, and `@halonicjs/yaml` rejects aliases that refer to
|
|
13
|
+
* themselves. `deepClone` keeps cycles because it mirrors `structuredClone`,
|
|
14
|
+
* while comparing a cycle would need extra bookkeeping on every call.
|
|
15
|
+
*
|
|
16
|
+
* @param first - the first value
|
|
17
|
+
* @param second - the second value
|
|
18
|
+
* @returns true when both have the same content
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* deepEqual({ a: [1, 2], b: "x" }, { b: "x", a: [1, 2] }); // true
|
|
22
|
+
*/
|
|
23
|
+
export declare function deepEqual(first: unknown, second: unknown): boolean;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { isPlainObject } from "./plain-data.js";
|
|
2
|
+
/**
|
|
3
|
+
* Compares two values by content: arrays item by item, plain objects key by
|
|
4
|
+
* key in any order, and dates by time. Numbers compare with `===`, except
|
|
5
|
+
* that `NaN` equals `NaN`. Any other object (a `Map`, a class instance)
|
|
6
|
+
* equals only itself.
|
|
7
|
+
*
|
|
8
|
+
* Unlike comparing `JSON.stringify` output, key order doesn't matter, and a
|
|
9
|
+
* key whose value is `undefined` is still a key: `{ a: undefined }` doesn't
|
|
10
|
+
* equal `{}`.
|
|
11
|
+
*
|
|
12
|
+
* Cyclic data isn't supported: comparing it throws a `RangeError`. JSON can't
|
|
13
|
+
* express cycles, and `@halonicjs/yaml` rejects aliases that refer to
|
|
14
|
+
* themselves. `deepClone` keeps cycles because it mirrors `structuredClone`,
|
|
15
|
+
* while comparing a cycle would need extra bookkeeping on every call.
|
|
16
|
+
*
|
|
17
|
+
* @param first - the first value
|
|
18
|
+
* @param second - the second value
|
|
19
|
+
* @returns true when both have the same content
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* deepEqual({ a: [1, 2], b: "x" }, { b: "x", a: [1, 2] }); // true
|
|
23
|
+
*/
|
|
24
|
+
export function deepEqual(first, second) {
|
|
25
|
+
if (first === second) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
if (typeof first === "number" && typeof second === "number") {
|
|
29
|
+
return Number.isNaN(first) && Number.isNaN(second);
|
|
30
|
+
}
|
|
31
|
+
if (Array.isArray(first) && Array.isArray(second)) {
|
|
32
|
+
return arraysEqual(first, second);
|
|
33
|
+
}
|
|
34
|
+
if (first instanceof Date && second instanceof Date) {
|
|
35
|
+
return Object.is(first.getTime(), second.getTime());
|
|
36
|
+
}
|
|
37
|
+
if (isPlainObject(first) && isPlainObject(second)) {
|
|
38
|
+
return objectsEqual(first, second);
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}
|
|
42
|
+
function arraysEqual(first, second) {
|
|
43
|
+
if (first.length !== second.length) {
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
for (let index = 0; index < first.length; index++) {
|
|
47
|
+
if (!deepEqual(first[index], second[index])) {
|
|
48
|
+
return false;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
function objectsEqual(first, second) {
|
|
54
|
+
const firstKeys = Object.keys(first);
|
|
55
|
+
if (firstKeys.length !== Object.keys(second).length) {
|
|
56
|
+
return false;
|
|
57
|
+
}
|
|
58
|
+
for (const key of firstKeys) {
|
|
59
|
+
if (!Object.hasOwn(second, key) || !deepEqual(first[key], second[key])) {
|
|
60
|
+
return false;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
return true;
|
|
64
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/** A function that receives one kind of event. */
|
|
2
|
+
export type Listener<Payload> = (payload: Payload) => void;
|
|
3
|
+
/**
|
|
4
|
+
* A small typed event emitter. `Events` maps each event name to the type of
|
|
5
|
+
* its payload, so `emit` and `on` check both.
|
|
6
|
+
*
|
|
7
|
+
* Listeners run in the order they were added. A listener added or removed
|
|
8
|
+
* while an event is being sent takes effect from the next event. If a
|
|
9
|
+
* listener throws, the others still run, and `emit` then throws the error
|
|
10
|
+
* (or an `AggregateError` with all of them).
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* const changes = new Emitter<{ saved: { path: string }; closed: undefined }>();
|
|
14
|
+
* const stop = changes.on("saved", ({ path }) => console.log(path));
|
|
15
|
+
* changes.emit("saved", { path: "hubs/support/hub.yaml" });
|
|
16
|
+
* stop();
|
|
17
|
+
*/
|
|
18
|
+
export declare class Emitter<Events extends Record<string, unknown>> {
|
|
19
|
+
private readonly listeners;
|
|
20
|
+
/**
|
|
21
|
+
* Adds a listener for one event.
|
|
22
|
+
*
|
|
23
|
+
* @param name - the event to listen to
|
|
24
|
+
* @param listener - called with each payload
|
|
25
|
+
* @returns a function that removes the listener again; calling it twice is harmless
|
|
26
|
+
*/
|
|
27
|
+
on<Name extends keyof Events>(name: Name, listener: Listener<Events[Name]>): () => void;
|
|
28
|
+
/**
|
|
29
|
+
* Sends an event to every listener for it.
|
|
30
|
+
*
|
|
31
|
+
* @param name - the event
|
|
32
|
+
* @param payload - what the listeners receive
|
|
33
|
+
* @throws the error of the one listener that threw, or an `AggregateError` when several did
|
|
34
|
+
*/
|
|
35
|
+
emit<Name extends keyof Events>(name: Name, payload: Events[Name]): void;
|
|
36
|
+
/**
|
|
37
|
+
* How many listeners an event has.
|
|
38
|
+
*
|
|
39
|
+
* @param name - the event
|
|
40
|
+
*/
|
|
41
|
+
listenerCount(name: keyof Events): number;
|
|
42
|
+
}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A small typed event emitter. `Events` maps each event name to the type of
|
|
3
|
+
* its payload, so `emit` and `on` check both.
|
|
4
|
+
*
|
|
5
|
+
* Listeners run in the order they were added. A listener added or removed
|
|
6
|
+
* while an event is being sent takes effect from the next event. If a
|
|
7
|
+
* listener throws, the others still run, and `emit` then throws the error
|
|
8
|
+
* (or an `AggregateError` with all of them).
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const changes = new Emitter<{ saved: { path: string }; closed: undefined }>();
|
|
12
|
+
* const stop = changes.on("saved", ({ path }) => console.log(path));
|
|
13
|
+
* changes.emit("saved", { path: "hubs/support/hub.yaml" });
|
|
14
|
+
* stop();
|
|
15
|
+
*/
|
|
16
|
+
export class Emitter {
|
|
17
|
+
listeners = new Map();
|
|
18
|
+
/**
|
|
19
|
+
* Adds a listener for one event.
|
|
20
|
+
*
|
|
21
|
+
* @param name - the event to listen to
|
|
22
|
+
* @param listener - called with each payload
|
|
23
|
+
* @returns a function that removes the listener again; calling it twice is harmless
|
|
24
|
+
*/
|
|
25
|
+
on(name, listener) {
|
|
26
|
+
let forName = this.listeners.get(name);
|
|
27
|
+
if (forName === undefined) {
|
|
28
|
+
forName = new Set();
|
|
29
|
+
this.listeners.set(name, forName);
|
|
30
|
+
}
|
|
31
|
+
// Wrapped, so adding the same function twice gives two independent listeners.
|
|
32
|
+
const entry = (payload) => listener(payload);
|
|
33
|
+
forName.add(entry);
|
|
34
|
+
return () => {
|
|
35
|
+
forName.delete(entry);
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Sends an event to every listener for it.
|
|
40
|
+
*
|
|
41
|
+
* @param name - the event
|
|
42
|
+
* @param payload - what the listeners receive
|
|
43
|
+
* @throws the error of the one listener that threw, or an `AggregateError` when several did
|
|
44
|
+
*/
|
|
45
|
+
emit(name, payload) {
|
|
46
|
+
const forName = this.listeners.get(name);
|
|
47
|
+
if (forName === undefined) {
|
|
48
|
+
return;
|
|
49
|
+
}
|
|
50
|
+
const errors = [];
|
|
51
|
+
for (const listener of [...forName]) {
|
|
52
|
+
try {
|
|
53
|
+
listener(payload);
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
errors.push(error);
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (errors.length === 1) {
|
|
60
|
+
throw errors[0];
|
|
61
|
+
}
|
|
62
|
+
if (errors.length > 1) {
|
|
63
|
+
throw new AggregateError(errors, `${errors.length} listeners for "${String(name)}" failed.`);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* How many listeners an event has.
|
|
68
|
+
*
|
|
69
|
+
* @param name - the event
|
|
70
|
+
*/
|
|
71
|
+
listenerCount(name) {
|
|
72
|
+
return this.listeners.get(name)?.size ?? 0;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every kind of error a surface (HTTP, CLI, Studio, MCP) can respond to, in a
|
|
3
|
+
* fixed order for exhaustive tests and docs. Each surface turns a kind into
|
|
4
|
+
* its response in one `switch` that ends in
|
|
5
|
+
* `assertNever(kind, "error kind")`, so a new kind fails the typecheck until
|
|
6
|
+
* every surface handles it.
|
|
7
|
+
*
|
|
8
|
+
* - `invalid_input`: the request or file is wrong; the caller fixes the input.
|
|
9
|
+
* - `not_found`: the thing asked for doesn't exist.
|
|
10
|
+
* - `conflict`: it exists, but its state doesn't allow this now: it already
|
|
11
|
+
* exists, someone else changed it first, or another step must come first.
|
|
12
|
+
* - `unauthenticated`: we don't know who is asking, or their sign-in expired.
|
|
13
|
+
* - `denied`: we know who is asking, but a rule says no.
|
|
14
|
+
* - `limit_reached`: a rate limit, quota or spend budget is used up.
|
|
15
|
+
* - `unavailable`: something we depend on is down or timed out; a retry may work.
|
|
16
|
+
* - `internal`: a bug on our side. Anything without a kind is `internal`.
|
|
17
|
+
*/
|
|
18
|
+
export declare const errorKinds: readonly ["invalid_input", "not_found", "conflict", "unauthenticated", "denied", "limit_reached", "unavailable", "internal"];
|
|
19
|
+
/** One of {@link errorKinds}. */
|
|
20
|
+
export type ErrorKind = (typeof errorKinds)[number];
|
|
21
|
+
/**
|
|
22
|
+
* True when `value` is one of the error kinds. Use it to decode a kind that
|
|
23
|
+
* came over the wire, such as the `kind` in an HTTP error body.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* isErrorKind("not_found"); // true
|
|
27
|
+
* isErrorKind("not-found"); // false
|
|
28
|
+
*/
|
|
29
|
+
export declare function isErrorKind(value: unknown): value is ErrorKind;
|
|
30
|
+
/** What a {@link KindedError} can carry besides its kind and message. */
|
|
31
|
+
export type KindedErrorOptions = {
|
|
32
|
+
/**
|
|
33
|
+
* The one next step that fixes it, as a sentence on its own line, such as
|
|
34
|
+
* "Start Ollama, then run again." Leave it out when there is no step to
|
|
35
|
+
* suggest: surfaces then show no fix and never make one up.
|
|
36
|
+
*/
|
|
37
|
+
readonly fix?: string;
|
|
38
|
+
/** The error this one wraps, for the log. */
|
|
39
|
+
readonly cause?: unknown;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* An error with a kind, for code that fails in a way a person should hear
|
|
43
|
+
* about. Errors that already have their own class don't have to extend this
|
|
44
|
+
* one: a `kind` property is enough for {@link errorKindOf}.
|
|
45
|
+
*
|
|
46
|
+
* The message must be safe to show and to log: no secrets, tokens, internal
|
|
47
|
+
* paths or internal codes. Surfaces show a generic message for `internal`
|
|
48
|
+
* instead of this one, so don't rely on the text of an `internal` error
|
|
49
|
+
* reaching the user; put what helps there in the log. The same rule holds
|
|
50
|
+
* for the optional `fix`, which is kept apart from the message so a surface
|
|
51
|
+
* can show it on its own line or in its own JSON field.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* throw new KindedError("not_found", `There is no routine named "${name}".`);
|
|
55
|
+
* throw new KindedError("unavailable", "Halonic couldn't reach Ollama.", {
|
|
56
|
+
* fix: "Start Ollama, then run again.",
|
|
57
|
+
* });
|
|
58
|
+
*/
|
|
59
|
+
export declare class KindedError extends Error {
|
|
60
|
+
readonly name = "KindedError";
|
|
61
|
+
readonly kind: ErrorKind;
|
|
62
|
+
/** The one next step that fixes it; `undefined` when there is none to suggest. */
|
|
63
|
+
readonly fix: string | undefined;
|
|
64
|
+
/**
|
|
65
|
+
* @param kind - how a surface should respond
|
|
66
|
+
* @param message - safe to show and to log
|
|
67
|
+
* @param options - `fix` is the next step, safe to show and to log; `cause`
|
|
68
|
+
* keeps the error this one wraps, for the log
|
|
69
|
+
*/
|
|
70
|
+
constructor(kind: ErrorKind, message: string, options?: KindedErrorOptions);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* The kind of any thrown value, for the one function per surface that turns
|
|
74
|
+
* errors into responses. A value has a kind when it is an object with a
|
|
75
|
+
* valid `kind` string and a `message` string: a `KindedError`, an error class
|
|
76
|
+
* with a `kind` property, or the `{ kind, message }` shape an error takes over
|
|
77
|
+
* HTTP or IPC. Anything else is `internal`, including objects that only have
|
|
78
|
+
* a `kind`, such as events.
|
|
79
|
+
*
|
|
80
|
+
* It reads only the value itself, never its `cause`: code that wraps an error
|
|
81
|
+
* chooses the kind of the wrapper on purpose.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* errorKindOf(new KindedError("conflict", "The run changed.")); // "conflict"
|
|
85
|
+
* errorKindOf({ kind: "not_found", message: "No such hub." }); // "not_found"
|
|
86
|
+
* errorKindOf(new TypeError("x is undefined")); // "internal"
|
|
87
|
+
*/
|
|
88
|
+
export declare function errorKindOf(error: unknown): ErrorKind;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every kind of error a surface (HTTP, CLI, Studio, MCP) can respond to, in a
|
|
3
|
+
* fixed order for exhaustive tests and docs. Each surface turns a kind into
|
|
4
|
+
* its response in one `switch` that ends in
|
|
5
|
+
* `assertNever(kind, "error kind")`, so a new kind fails the typecheck until
|
|
6
|
+
* every surface handles it.
|
|
7
|
+
*
|
|
8
|
+
* - `invalid_input`: the request or file is wrong; the caller fixes the input.
|
|
9
|
+
* - `not_found`: the thing asked for doesn't exist.
|
|
10
|
+
* - `conflict`: it exists, but its state doesn't allow this now: it already
|
|
11
|
+
* exists, someone else changed it first, or another step must come first.
|
|
12
|
+
* - `unauthenticated`: we don't know who is asking, or their sign-in expired.
|
|
13
|
+
* - `denied`: we know who is asking, but a rule says no.
|
|
14
|
+
* - `limit_reached`: a rate limit, quota or spend budget is used up.
|
|
15
|
+
* - `unavailable`: something we depend on is down or timed out; a retry may work.
|
|
16
|
+
* - `internal`: a bug on our side. Anything without a kind is `internal`.
|
|
17
|
+
*/
|
|
18
|
+
export const errorKinds = [
|
|
19
|
+
"invalid_input",
|
|
20
|
+
"not_found",
|
|
21
|
+
"conflict",
|
|
22
|
+
"unauthenticated",
|
|
23
|
+
"denied",
|
|
24
|
+
"limit_reached",
|
|
25
|
+
"unavailable",
|
|
26
|
+
"internal",
|
|
27
|
+
];
|
|
28
|
+
/**
|
|
29
|
+
* True when `value` is one of the error kinds. Use it to decode a kind that
|
|
30
|
+
* came over the wire, such as the `kind` in an HTTP error body.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* isErrorKind("not_found"); // true
|
|
34
|
+
* isErrorKind("not-found"); // false
|
|
35
|
+
*/
|
|
36
|
+
export function isErrorKind(value) {
|
|
37
|
+
return errorKinds.some((kind) => kind === value);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* An error with a kind, for code that fails in a way a person should hear
|
|
41
|
+
* about. Errors that already have their own class don't have to extend this
|
|
42
|
+
* one: a `kind` property is enough for {@link errorKindOf}.
|
|
43
|
+
*
|
|
44
|
+
* The message must be safe to show and to log: no secrets, tokens, internal
|
|
45
|
+
* paths or internal codes. Surfaces show a generic message for `internal`
|
|
46
|
+
* instead of this one, so don't rely on the text of an `internal` error
|
|
47
|
+
* reaching the user; put what helps there in the log. The same rule holds
|
|
48
|
+
* for the optional `fix`, which is kept apart from the message so a surface
|
|
49
|
+
* can show it on its own line or in its own JSON field.
|
|
50
|
+
*
|
|
51
|
+
* @example
|
|
52
|
+
* throw new KindedError("not_found", `There is no routine named "${name}".`);
|
|
53
|
+
* throw new KindedError("unavailable", "Halonic couldn't reach Ollama.", {
|
|
54
|
+
* fix: "Start Ollama, then run again.",
|
|
55
|
+
* });
|
|
56
|
+
*/
|
|
57
|
+
export class KindedError extends Error {
|
|
58
|
+
name = "KindedError";
|
|
59
|
+
kind;
|
|
60
|
+
/** The one next step that fixes it; `undefined` when there is none to suggest. */
|
|
61
|
+
fix;
|
|
62
|
+
/**
|
|
63
|
+
* @param kind - how a surface should respond
|
|
64
|
+
* @param message - safe to show and to log
|
|
65
|
+
* @param options - `fix` is the next step, safe to show and to log; `cause`
|
|
66
|
+
* keeps the error this one wraps, for the log
|
|
67
|
+
*/
|
|
68
|
+
constructor(kind, message, options = {}) {
|
|
69
|
+
super(message, "cause" in options ? { cause: options.cause } : undefined);
|
|
70
|
+
this.kind = kind;
|
|
71
|
+
this.fix = options.fix;
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* The kind of any thrown value, for the one function per surface that turns
|
|
76
|
+
* errors into responses. A value has a kind when it is an object with a
|
|
77
|
+
* valid `kind` string and a `message` string: a `KindedError`, an error class
|
|
78
|
+
* with a `kind` property, or the `{ kind, message }` shape an error takes over
|
|
79
|
+
* HTTP or IPC. Anything else is `internal`, including objects that only have
|
|
80
|
+
* a `kind`, such as events.
|
|
81
|
+
*
|
|
82
|
+
* It reads only the value itself, never its `cause`: code that wraps an error
|
|
83
|
+
* chooses the kind of the wrapper on purpose.
|
|
84
|
+
*
|
|
85
|
+
* @example
|
|
86
|
+
* errorKindOf(new KindedError("conflict", "The run changed.")); // "conflict"
|
|
87
|
+
* errorKindOf({ kind: "not_found", message: "No such hub." }); // "not_found"
|
|
88
|
+
* errorKindOf(new TypeError("x is undefined")); // "internal"
|
|
89
|
+
*/
|
|
90
|
+
export function errorKindOf(error) {
|
|
91
|
+
if (typeof error !== "object" || error === null || !("kind" in error) || !("message" in error)) {
|
|
92
|
+
return "internal";
|
|
93
|
+
}
|
|
94
|
+
if (isErrorKind(error.kind) && typeof error.message === "string") {
|
|
95
|
+
return error.kind;
|
|
96
|
+
}
|
|
97
|
+
return "internal";
|
|
98
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writes bytes as lowercase hexadecimal text, two characters per byte.
|
|
3
|
+
*
|
|
4
|
+
* @param bytes - the bytes to write
|
|
5
|
+
* @returns the hex text, empty for no bytes
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* bytesToHex(new Uint8Array([0, 171, 255])); // "00abff"
|
|
9
|
+
*/
|
|
10
|
+
export declare function bytesToHex(bytes: Uint8Array): string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Writes bytes as lowercase hexadecimal text, two characters per byte.
|
|
3
|
+
*
|
|
4
|
+
* @param bytes - the bytes to write
|
|
5
|
+
* @returns the hex text, empty for no bytes
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* bytesToHex(new Uint8Array([0, 171, 255])); // "00abff"
|
|
9
|
+
*/
|
|
10
|
+
export function bytesToHex(bytes) {
|
|
11
|
+
let text = "";
|
|
12
|
+
for (const byte of bytes) {
|
|
13
|
+
text += byte.toString(16).padStart(2, "0");
|
|
14
|
+
}
|
|
15
|
+
return text;
|
|
16
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Whether a code point is one nobody sees on screen but that can still change
|
|
3
|
+
* the text around it, such as a right-to-left override.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* isHiddenCharacter(0x202e); // true
|
|
7
|
+
* isHiddenCharacter("a".codePointAt(0) ?? 0); // false
|
|
8
|
+
*/
|
|
9
|
+
export declare function isHiddenCharacter(codePoint: number): boolean;
|
|
10
|
+
/**
|
|
11
|
+
* JSON text with every hidden character written as a `\uXXXX` escape, so the
|
|
12
|
+
* raw JSON shows it too and stays the same JSON. A character above U+FFFF,
|
|
13
|
+
* such as a tag character, becomes its two UTF-16 escapes. Hidden characters
|
|
14
|
+
* can only stand inside JSON strings, where an escape means the same.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* escapeHidden(JSON.stringify(`Refund${String.fromCodePoint(0x202e)}for Sam`)); // '"Refund\\u202efor Sam"'
|
|
18
|
+
*/
|
|
19
|
+
export declare function escapeHidden(json: string): string;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The code point ranges a text can carry without anyone seeing them: control
|
|
3
|
+
* characters other than tab (U+0009) and newline (U+000A), the soft hyphen,
|
|
4
|
+
* zero-width characters, direction marks, overrides and isolates, the word
|
|
5
|
+
* joiner and invisible operators, the byte order mark and Unicode tag
|
|
6
|
+
* characters. Written as numbers, so the source holds no invisible character
|
|
7
|
+
* itself.
|
|
8
|
+
*/
|
|
9
|
+
const hiddenRanges = [
|
|
10
|
+
[0x0000, 0x0008],
|
|
11
|
+
[0x000b, 0x001f],
|
|
12
|
+
[0x007f, 0x009f],
|
|
13
|
+
[0x00ad, 0x00ad],
|
|
14
|
+
[0x061c, 0x061c],
|
|
15
|
+
[0x200b, 0x200f],
|
|
16
|
+
[0x202a, 0x202e],
|
|
17
|
+
[0x2060, 0x2064],
|
|
18
|
+
[0x2066, 0x2069],
|
|
19
|
+
[0xfeff, 0xfeff],
|
|
20
|
+
[0xe0000, 0xe007f],
|
|
21
|
+
];
|
|
22
|
+
/**
|
|
23
|
+
* Whether a code point is one nobody sees on screen but that can still change
|
|
24
|
+
* the text around it, such as a right-to-left override.
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* isHiddenCharacter(0x202e); // true
|
|
28
|
+
* isHiddenCharacter("a".codePointAt(0) ?? 0); // false
|
|
29
|
+
*/
|
|
30
|
+
export function isHiddenCharacter(codePoint) {
|
|
31
|
+
return hiddenRanges.some(([first, last]) => codePoint >= first && codePoint <= last);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* JSON text with every hidden character written as a `\uXXXX` escape, so the
|
|
35
|
+
* raw JSON shows it too and stays the same JSON. A character above U+FFFF,
|
|
36
|
+
* such as a tag character, becomes its two UTF-16 escapes. Hidden characters
|
|
37
|
+
* can only stand inside JSON strings, where an escape means the same.
|
|
38
|
+
*
|
|
39
|
+
* @example
|
|
40
|
+
* escapeHidden(JSON.stringify(`Refund${String.fromCodePoint(0x202e)}for Sam`)); // '"Refund\\u202efor Sam"'
|
|
41
|
+
*/
|
|
42
|
+
export function escapeHidden(json) {
|
|
43
|
+
let escaped = "";
|
|
44
|
+
for (const character of json) {
|
|
45
|
+
if (!isHiddenCharacter(character.codePointAt(0) ?? 0)) {
|
|
46
|
+
escaped += character;
|
|
47
|
+
continue;
|
|
48
|
+
}
|
|
49
|
+
for (let index = 0; index < character.length; index++) {
|
|
50
|
+
escaped += `\\u${character.charCodeAt(index).toString(16).padStart(4, "0")}`;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return escaped;
|
|
54
|
+
}
|