@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,186 @@
|
|
|
1
|
+
import type { ChatRequest, ChatResponse, ChatStreamEvent } from "./chat.js";
|
|
2
|
+
import type { HttpClient } from "./http-client.js";
|
|
3
|
+
import type { Secrets } from "./secrets.js";
|
|
4
|
+
/** Version of the {@link LlmProvider} and {@link LlmProviderFactory} ports. A breaking change bumps it and comes with an ADR. */
|
|
5
|
+
export declare const llmProviderVersion = 1;
|
|
6
|
+
/** What a provider's models can do. */
|
|
7
|
+
export interface LlmCapabilities {
|
|
8
|
+
/** Whether its models can call tools. */
|
|
9
|
+
tools: boolean;
|
|
10
|
+
/** Whether it can be asked for a JSON answer. */
|
|
11
|
+
jsonOutput: boolean;
|
|
12
|
+
/** Whether its models accept images. */
|
|
13
|
+
vision: boolean;
|
|
14
|
+
/** Whether it can stream an answer as it is written. */
|
|
15
|
+
streaming: boolean;
|
|
16
|
+
}
|
|
17
|
+
/** A model provider (OpenAI, Gemini, Ollama, the scripted test model …) as one workspace configures it. */
|
|
18
|
+
export interface LlmProvider {
|
|
19
|
+
/** The provider's id in the workspace's providers. */
|
|
20
|
+
readonly id: string;
|
|
21
|
+
/** The adapter type, such as "openai". */
|
|
22
|
+
readonly type: string;
|
|
23
|
+
/** What its models can do. */
|
|
24
|
+
readonly capabilities: LlmCapabilities;
|
|
25
|
+
/**
|
|
26
|
+
* Makes one model call.
|
|
27
|
+
*
|
|
28
|
+
* @throws {ModelCallError} when the call fails, with the reason why: no
|
|
29
|
+
* key, offline, the model is missing, it can't call tools, it ran out of
|
|
30
|
+
* memory, the key wasn't accepted, the account is out of credit, the
|
|
31
|
+
* provider is busy, or the provider refused. Callers treat any other error as `refused`, except the abort
|
|
32
|
+
* error when `request.signal` aborts the call.
|
|
33
|
+
*/
|
|
34
|
+
chat(request: ChatRequest): Promise<ChatResponse>;
|
|
35
|
+
/**
|
|
36
|
+
* Makes one model call and yields the answer as it is written, ending
|
|
37
|
+
* with a `done` event that holds the full {@link ChatResponse}. Present
|
|
38
|
+
* only when `capabilities.streaming` is true; callers check both and
|
|
39
|
+
* fall back to `chat()`. Aborting `request.signal` ends the stream with
|
|
40
|
+
* an error.
|
|
41
|
+
*
|
|
42
|
+
* @throws {ModelCallError} when the call fails, before the first event or
|
|
43
|
+
* during the stream, with the same reason `chat()` would give for the same
|
|
44
|
+
* failure.
|
|
45
|
+
*/
|
|
46
|
+
stream?(request: ChatRequest): AsyncIterable<ChatStreamEvent>;
|
|
47
|
+
}
|
|
48
|
+
/** Every reason a model call can fail with, in {@link ModelCallErrorReason} order. */
|
|
49
|
+
export declare const modelCallErrorReasons: readonly ["no-key", "offline", "model-missing", "model-no-tools", "out-of-memory", "key-refused", "out-of-credit", "provider-busy", "refused", "local-only"];
|
|
50
|
+
/**
|
|
51
|
+
* Why a model call failed:
|
|
52
|
+
* - `no-key`: the provider needs a key and its secret isn't set. A provider
|
|
53
|
+
* that has a key and is turned away says `key-refused`.
|
|
54
|
+
* - `offline`: the provider couldn't be reached, such as no network, a DNS
|
|
55
|
+
* failure, a refused connection or a timeout. The error names the `host`
|
|
56
|
+
* when the provider knows it.
|
|
57
|
+
* - `model-missing`: the provider doesn't have the model asked for.
|
|
58
|
+
* - `model-no-tools`: the model can't call tools and the request offered some.
|
|
59
|
+
* - `out-of-memory`: the model doesn't fit in the memory of the machine that
|
|
60
|
+
* runs it. Providers find it with {@link isModelOutOfMemory}.
|
|
61
|
+
* - `key-refused`: the provider didn't accept the key (HTTP 401 or 403).
|
|
62
|
+
* - `out-of-credit`: the account at the provider has no credit left or
|
|
63
|
+
* reached its spending limit, such as HTTP 402 or OpenAI's 429 with
|
|
64
|
+
* `insufficient_quota`. This is never Halonic's own budget.
|
|
65
|
+
* - `provider-busy`: the provider is overloaded or asked the caller to slow
|
|
66
|
+
* down, such as any other HTTP 429, a 5xx or Anthropic's 529.
|
|
67
|
+
* - `refused`: anything else the provider turned down or failed on.
|
|
68
|
+
* - `local-only`: the workspace is local only (`privacy.localOnly: true`)
|
|
69
|
+
* and the model's provider isn't local, so the engine never called it.
|
|
70
|
+
*/
|
|
71
|
+
export type ModelCallErrorReason = (typeof modelCallErrorReasons)[number];
|
|
72
|
+
/**
|
|
73
|
+
* The error an {@link LlmProvider} throws when a model call fails, so the
|
|
74
|
+
* engine can tell why and decide whether to try the next model. Its message
|
|
75
|
+
* is plain text for the run log; it never holds a key or any part of one.
|
|
76
|
+
*
|
|
77
|
+
* Check for it with {@link isModelCallError}, not `instanceof`: an adapter
|
|
78
|
+
* may be built against its own copy of this package.
|
|
79
|
+
*
|
|
80
|
+
* @example
|
|
81
|
+
* throw new ModelCallError("model-missing", `openai has no model "gpt-9"`);
|
|
82
|
+
* throw new ModelCallError("offline", "Ollama didn't answer.", { host: "localhost:11434", cause });
|
|
83
|
+
*/
|
|
84
|
+
export declare class ModelCallError extends Error {
|
|
85
|
+
readonly name = "ModelCallError";
|
|
86
|
+
readonly reason: ModelCallErrorReason;
|
|
87
|
+
/**
|
|
88
|
+
* With `offline` only: the host that didn't answer, as its name and port,
|
|
89
|
+
* such as `localhost:11434`. Never a URL with a path, a query or a key.
|
|
90
|
+
*/
|
|
91
|
+
readonly host: string | undefined;
|
|
92
|
+
/**
|
|
93
|
+
* @param reason - why the call failed
|
|
94
|
+
* @param message - plain text for the run log, never a key
|
|
95
|
+
* @param options - `cause` keeps the error this one wraps; `host` names the
|
|
96
|
+
* host that didn't answer, and is kept only with `offline`
|
|
97
|
+
*/
|
|
98
|
+
constructor(reason: ModelCallErrorReason, message: string, options?: {
|
|
99
|
+
cause?: unknown;
|
|
100
|
+
host?: string;
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Whether `value` is a {@link ModelCallError}: an `Error` named
|
|
105
|
+
* "ModelCallError" with one of the known reasons. It works across copies of
|
|
106
|
+
* this package, where `instanceof` doesn't.
|
|
107
|
+
*
|
|
108
|
+
* @example
|
|
109
|
+
* const reason = isModelCallError(error) ? error.reason : "refused";
|
|
110
|
+
*/
|
|
111
|
+
export declare function isModelCallError(value: unknown): value is ModelCallError;
|
|
112
|
+
/**
|
|
113
|
+
* The provider's own error text, as the `cause` of a {@link ModelCallError}
|
|
114
|
+
* for an error reply (requirement `ports.vendor-error-text`). It stays
|
|
115
|
+
* out of the message, which Studio and the command line show: microcopy 1.4
|
|
116
|
+
* allows no quoted outside text there. The engine keeps it in the run log
|
|
117
|
+
* for `--debug` and Copy details.
|
|
118
|
+
*
|
|
119
|
+
* The provider shortens the text and checks it for keys before it builds
|
|
120
|
+
* one: whatever is in it may end up in the run log.
|
|
121
|
+
*
|
|
122
|
+
* Check for it with {@link isVendorErrorText}, not `instanceof`: an adapter
|
|
123
|
+
* may be built against its own copy of this package.
|
|
124
|
+
*
|
|
125
|
+
* @example
|
|
126
|
+
* const cause = new VendorErrorText(400, "max_tokens: 200000 > 64000");
|
|
127
|
+
* throw new ModelCallError("refused", `anthropic refused the call (HTTP 400)`, { cause });
|
|
128
|
+
*/
|
|
129
|
+
export declare class VendorErrorText extends Error {
|
|
130
|
+
readonly name = "VendorErrorText";
|
|
131
|
+
/**
|
|
132
|
+
* The HTTP status the text came with, or for an error in a stream the
|
|
133
|
+
* status its error type stands for; undefined when there is none.
|
|
134
|
+
*/
|
|
135
|
+
readonly status: number | undefined;
|
|
136
|
+
/**
|
|
137
|
+
* @param status - the HTTP status the text came with, or undefined when there is none
|
|
138
|
+
* @param text - the provider's text, already shortened and checked for keys
|
|
139
|
+
*/
|
|
140
|
+
constructor(status: number | undefined, text: string);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Whether `value` is a {@link VendorErrorText}: an `Error` named
|
|
144
|
+
* "VendorErrorText" with a `status` that is a whole number or set to
|
|
145
|
+
* undefined. It works across copies of this package, where `instanceof`
|
|
146
|
+
* doesn't.
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* const text = isVendorErrorText(error.cause) ? error.cause.message : undefined;
|
|
150
|
+
*/
|
|
151
|
+
export declare function isVendorErrorText(value: unknown): value is VendorErrorText;
|
|
152
|
+
/**
|
|
153
|
+
* True when a model server's error text says the model ran out of memory.
|
|
154
|
+
* A provider calls it on an error body, then throws a {@link ModelCallError}
|
|
155
|
+
* with `out-of-memory` (requirement `ports.model-out-of-memory-text`).
|
|
156
|
+
*
|
|
157
|
+
* @example
|
|
158
|
+
* isModelOutOfMemory("model requires more system memory (12.0 GiB) than is available (7.6 GiB)"); // true
|
|
159
|
+
*/
|
|
160
|
+
export declare function isModelOutOfMemory(text: string): boolean;
|
|
161
|
+
/** A provider as the workspace's YAML configures it. */
|
|
162
|
+
export interface ProviderConfig {
|
|
163
|
+
/** The provider's id in the workspace. */
|
|
164
|
+
id: string;
|
|
165
|
+
/** The adapter type, such as "openai"; picks the factory. */
|
|
166
|
+
type: string;
|
|
167
|
+
/** The provider's address, when it isn't the adapter's default. */
|
|
168
|
+
baseUrl?: string;
|
|
169
|
+
/** The **name** of the secret that holds the API key, never the key itself. */
|
|
170
|
+
secret?: string;
|
|
171
|
+
/** Whether the models run on this machine (such as Ollama), so they have no price. */
|
|
172
|
+
local: boolean;
|
|
173
|
+
/** Settings only this adapter type understands. */
|
|
174
|
+
options: Record<string, unknown>;
|
|
175
|
+
}
|
|
176
|
+
/** What a factory may use to build a provider. */
|
|
177
|
+
export interface ProviderFactoryContext {
|
|
178
|
+
secrets: Secrets;
|
|
179
|
+
http: HttpClient;
|
|
180
|
+
}
|
|
181
|
+
/** Creates a provider from its YAML config. One factory per adapter type. */
|
|
182
|
+
export interface LlmProviderFactory {
|
|
183
|
+
/** The `type` this factory handles. */
|
|
184
|
+
readonly type: string;
|
|
185
|
+
create(config: ProviderConfig, context: ProviderFactoryContext): LlmProvider;
|
|
186
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
/** Version of the {@link LlmProvider} and {@link LlmProviderFactory} ports. A breaking change bumps it and comes with an ADR. */
|
|
2
|
+
export const llmProviderVersion = 1;
|
|
3
|
+
/** Every reason a model call can fail with, in {@link ModelCallErrorReason} order. */
|
|
4
|
+
export const modelCallErrorReasons = [
|
|
5
|
+
"no-key",
|
|
6
|
+
"offline",
|
|
7
|
+
"model-missing",
|
|
8
|
+
"model-no-tools",
|
|
9
|
+
"out-of-memory",
|
|
10
|
+
"key-refused",
|
|
11
|
+
"out-of-credit",
|
|
12
|
+
"provider-busy",
|
|
13
|
+
"refused",
|
|
14
|
+
"local-only",
|
|
15
|
+
];
|
|
16
|
+
/**
|
|
17
|
+
* The error an {@link LlmProvider} throws when a model call fails, so the
|
|
18
|
+
* engine can tell why and decide whether to try the next model. Its message
|
|
19
|
+
* is plain text for the run log; it never holds a key or any part of one.
|
|
20
|
+
*
|
|
21
|
+
* Check for it with {@link isModelCallError}, not `instanceof`: an adapter
|
|
22
|
+
* may be built against its own copy of this package.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* throw new ModelCallError("model-missing", `openai has no model "gpt-9"`);
|
|
26
|
+
* throw new ModelCallError("offline", "Ollama didn't answer.", { host: "localhost:11434", cause });
|
|
27
|
+
*/
|
|
28
|
+
export class ModelCallError extends Error {
|
|
29
|
+
name = "ModelCallError";
|
|
30
|
+
reason;
|
|
31
|
+
/**
|
|
32
|
+
* With `offline` only: the host that didn't answer, as its name and port,
|
|
33
|
+
* such as `localhost:11434`. Never a URL with a path, a query or a key.
|
|
34
|
+
*/
|
|
35
|
+
host;
|
|
36
|
+
/**
|
|
37
|
+
* @param reason - why the call failed
|
|
38
|
+
* @param message - plain text for the run log, never a key
|
|
39
|
+
* @param options - `cause` keeps the error this one wraps; `host` names the
|
|
40
|
+
* host that didn't answer, and is kept only with `offline`
|
|
41
|
+
*/
|
|
42
|
+
constructor(reason, message, options) {
|
|
43
|
+
super(message, options);
|
|
44
|
+
this.reason = reason;
|
|
45
|
+
this.host = reason === "offline" ? options?.host : undefined;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Whether `value` is a {@link ModelCallError}: an `Error` named
|
|
50
|
+
* "ModelCallError" with one of the known reasons. It works across copies of
|
|
51
|
+
* this package, where `instanceof` doesn't.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* const reason = isModelCallError(error) ? error.reason : "refused";
|
|
55
|
+
*/
|
|
56
|
+
export function isModelCallError(value) {
|
|
57
|
+
if (!(value instanceof Error) || value.name !== "ModelCallError")
|
|
58
|
+
return false;
|
|
59
|
+
const { reason, host } = value;
|
|
60
|
+
const knownReason = modelCallErrorReasons.some((known) => known === reason);
|
|
61
|
+
return knownReason && (host === undefined || typeof host === "string");
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* The provider's own error text, as the `cause` of a {@link ModelCallError}
|
|
65
|
+
* for an error reply (requirement `ports.vendor-error-text`). It stays
|
|
66
|
+
* out of the message, which Studio and the command line show: microcopy 1.4
|
|
67
|
+
* allows no quoted outside text there. The engine keeps it in the run log
|
|
68
|
+
* for `--debug` and Copy details.
|
|
69
|
+
*
|
|
70
|
+
* The provider shortens the text and checks it for keys before it builds
|
|
71
|
+
* one: whatever is in it may end up in the run log.
|
|
72
|
+
*
|
|
73
|
+
* Check for it with {@link isVendorErrorText}, not `instanceof`: an adapter
|
|
74
|
+
* may be built against its own copy of this package.
|
|
75
|
+
*
|
|
76
|
+
* @example
|
|
77
|
+
* const cause = new VendorErrorText(400, "max_tokens: 200000 > 64000");
|
|
78
|
+
* throw new ModelCallError("refused", `anthropic refused the call (HTTP 400)`, { cause });
|
|
79
|
+
*/
|
|
80
|
+
export class VendorErrorText extends Error {
|
|
81
|
+
name = "VendorErrorText";
|
|
82
|
+
/**
|
|
83
|
+
* The HTTP status the text came with, or for an error in a stream the
|
|
84
|
+
* status its error type stands for; undefined when there is none.
|
|
85
|
+
*/
|
|
86
|
+
status;
|
|
87
|
+
/**
|
|
88
|
+
* @param status - the HTTP status the text came with, or undefined when there is none
|
|
89
|
+
* @param text - the provider's text, already shortened and checked for keys
|
|
90
|
+
*/
|
|
91
|
+
constructor(status, text) {
|
|
92
|
+
super(text);
|
|
93
|
+
this.status = status;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Whether `value` is a {@link VendorErrorText}: an `Error` named
|
|
98
|
+
* "VendorErrorText" with a `status` that is a whole number or set to
|
|
99
|
+
* undefined. It works across copies of this package, where `instanceof`
|
|
100
|
+
* doesn't.
|
|
101
|
+
*
|
|
102
|
+
* @example
|
|
103
|
+
* const text = isVendorErrorText(error.cause) ? error.cause.message : undefined;
|
|
104
|
+
*/
|
|
105
|
+
export function isVendorErrorText(value) {
|
|
106
|
+
if (!(value instanceof Error) || value.name !== "VendorErrorText")
|
|
107
|
+
return false;
|
|
108
|
+
if (!Object.hasOwn(value, "status"))
|
|
109
|
+
return false;
|
|
110
|
+
const { status } = value;
|
|
111
|
+
return status === undefined || Number.isInteger(status);
|
|
112
|
+
}
|
|
113
|
+
// What model servers say when the model doesn't fit in memory: Ollama's own
|
|
114
|
+
// check, llama.cpp's allocation failures, and the CUDA, ROCm and Metal
|
|
115
|
+
// messages they pass on. Lower case, matched anywhere in the text.
|
|
116
|
+
const outOfMemoryPhrases = [
|
|
117
|
+
"out of memory",
|
|
118
|
+
// Ollama's llama-server loader: "llama-server reported out-of-memory during startup: …".
|
|
119
|
+
"out-of-memory",
|
|
120
|
+
"requires more system memory",
|
|
121
|
+
"insufficient memory",
|
|
122
|
+
"not enough memory",
|
|
123
|
+
"failed to allocate",
|
|
124
|
+
"unable to allocate",
|
|
125
|
+
"cudamalloc failed",
|
|
126
|
+
"hipmalloc failed",
|
|
127
|
+
];
|
|
128
|
+
/**
|
|
129
|
+
* True when a model server's error text says the model ran out of memory.
|
|
130
|
+
* A provider calls it on an error body, then throws a {@link ModelCallError}
|
|
131
|
+
* with `out-of-memory` (requirement `ports.model-out-of-memory-text`).
|
|
132
|
+
*
|
|
133
|
+
* @example
|
|
134
|
+
* isModelOutOfMemory("model requires more system memory (12.0 GiB) than is available (7.6 GiB)"); // true
|
|
135
|
+
*/
|
|
136
|
+
export function isModelOutOfMemory(text) {
|
|
137
|
+
const lowered = text.toLowerCase();
|
|
138
|
+
return outOfMemoryPhrases.some((phrase) => lowered.includes(phrase));
|
|
139
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Usage } from "../../events/src/index.js";
|
|
2
|
+
/** A model's price per million tokens, in the workspace's budget currency, as `models.yaml` gives it. */
|
|
3
|
+
export interface ModelPrice {
|
|
4
|
+
readonly input: number;
|
|
5
|
+
readonly output: number;
|
|
6
|
+
/**
|
|
7
|
+
* Input tokens read from the prompt cache. Absent: they cost `input`, so a
|
|
8
|
+
* call is never left unpriced because its model has no cache price.
|
|
9
|
+
*/
|
|
10
|
+
readonly cacheRead?: number;
|
|
11
|
+
/**
|
|
12
|
+
* Input tokens written to the prompt cache for its short lifetime
|
|
13
|
+
* (Anthropic: 5 minutes). Absent: they cost `input`.
|
|
14
|
+
*/
|
|
15
|
+
readonly cacheWrite?: number;
|
|
16
|
+
/**
|
|
17
|
+
* Input tokens written to the prompt cache for 1 hour. Absent: they cost
|
|
18
|
+
* `cacheWrite`, or `input` when that is absent too. Both are cheaper than
|
|
19
|
+
* a 1-hour write, so a model with 1-hour writes should give this price.
|
|
20
|
+
*/
|
|
21
|
+
readonly cacheWrite1h?: number;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* What a call with `usage` costs at `price`, in the workspace's budget
|
|
25
|
+
* currency and not rounded: each kind of token times its own price, divided
|
|
26
|
+
* by a million once (requirement `ports.model-price`). Cache tokens cost the
|
|
27
|
+
* input price when the model has no cache price; 1-hour cache writes cost the
|
|
28
|
+
* short write price first.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* priceOf({ input: 3, output: 15 }, { inputTokens: 1000, outputTokens: 200 }); // 0.006
|
|
32
|
+
* priceOf({ input: 3, output: 15, cacheRead: 0.3 }, { inputTokens: 0, outputTokens: 0, cacheReadTokens: 10_000 }); // 0.003
|
|
33
|
+
*/
|
|
34
|
+
export declare function priceOf(price: ModelPrice, usage: Usage): number;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// A model's price and what a call costs at it. The engine and the bridge
|
|
2
|
+
// both price calls with `priceOf`, so a call costs the same on either path.
|
|
3
|
+
/**
|
|
4
|
+
* What a call with `usage` costs at `price`, in the workspace's budget
|
|
5
|
+
* currency and not rounded: each kind of token times its own price, divided
|
|
6
|
+
* by a million once (requirement `ports.model-price`). Cache tokens cost the
|
|
7
|
+
* input price when the model has no cache price; 1-hour cache writes cost the
|
|
8
|
+
* short write price first.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* priceOf({ input: 3, output: 15 }, { inputTokens: 1000, outputTokens: 200 }); // 0.006
|
|
12
|
+
* priceOf({ input: 3, output: 15, cacheRead: 0.3 }, { inputTokens: 0, outputTokens: 0, cacheReadTokens: 10_000 }); // 0.003
|
|
13
|
+
*/
|
|
14
|
+
export function priceOf(price, usage) {
|
|
15
|
+
const tokensPerPrice = 1_000_000;
|
|
16
|
+
const cacheReadPrice = price.cacheRead ?? price.input;
|
|
17
|
+
const cacheWritePrice = price.cacheWrite ?? price.input;
|
|
18
|
+
const cacheWrite1hPrice = price.cacheWrite1h ?? cacheWritePrice;
|
|
19
|
+
const total = usage.inputTokens * price.input +
|
|
20
|
+
usage.outputTokens * price.output +
|
|
21
|
+
(usage.cacheReadTokens ?? 0) * cacheReadPrice +
|
|
22
|
+
(usage.cacheWriteTokens ?? 0) * cacheWritePrice +
|
|
23
|
+
(usage.cacheWrite1hTokens ?? 0) * cacheWrite1hPrice;
|
|
24
|
+
return total / tokensPerPrice;
|
|
25
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** Version of the {@link PasswordHasher} port. A breaking change bumps it and comes with an ADR. */
|
|
2
|
+
export declare const passwordHasherVersion = 1;
|
|
3
|
+
/**
|
|
4
|
+
* Hashes and checks the sign-in password.
|
|
5
|
+
*
|
|
6
|
+
* **Two formats.** Each adapter makes exactly one format, and the target
|
|
7
|
+
* decides which: a hash verifies on any adapter of the same format. The
|
|
8
|
+
* hash is self-describing text, and each format has its own requirement with
|
|
9
|
+
* known-answer vectors:
|
|
10
|
+
*
|
|
11
|
+
* ```text
|
|
12
|
+
* $scrypt$ln=<log2 N>,r=<r>,p=<p>$<salt>$<key> serve
|
|
13
|
+
* $pbkdf2-sha256-chain$i=<rounds>,n=<runs>$<salt>$<hash> cloud targets
|
|
14
|
+
* ```
|
|
15
|
+
*
|
|
16
|
+
* Cloud targets can't use scrypt: WebCrypto has no memory-hard hash, and a
|
|
17
|
+
* Worker has too little memory for scrypt at safe settings. So they chain
|
|
18
|
+
* PBKDF2-SHA256, each run's output being the next run's input, which costs
|
|
19
|
+
* an attacker the same per guess as one run of `i × n` rounds (HAL-136).
|
|
20
|
+
* The hash for a cloud target is made on your machine at deploy time, with
|
|
21
|
+
* the same adapter the Worker checks it with.
|
|
22
|
+
*
|
|
23
|
+
* **What both formats share:**
|
|
24
|
+
* - The salt is exactly 16 random bytes from `crypto.getRandomValues`, and the
|
|
25
|
+
* key or hash exactly 32 bytes. Both are standard base64 without `=`
|
|
26
|
+
* padding; any other length, or padding, makes the hash malformed.
|
|
27
|
+
* - The password is normalised to Unicode NFC and then encoded as UTF-8, so
|
|
28
|
+
* "é" typed as one character or as "e" plus an accent gives the same hash.
|
|
29
|
+
*
|
|
30
|
+
* **scrypt** (requirement `ports.password-hash-format`): new hashes use
|
|
31
|
+
* ln=14, r=8, p=5. `verify` accepts only ln 14 to 15, r exactly 8 and p 5 to
|
|
32
|
+
* 16. The upper bounds keep a configured hash within a Worker's memory
|
|
33
|
+
* (ln=15 needs 32 MiB; ln=20 would need 1 GiB).
|
|
34
|
+
*
|
|
35
|
+
* **Chained PBKDF2** (requirement `ports.password-hash-format-pbkdf2-chain`):
|
|
36
|
+
* new hashes use i=100000, n=6. `verify` accepts only i exactly 100000 (the
|
|
37
|
+
* most a Worker allows per run) and n 6 to 20.
|
|
38
|
+
*/
|
|
39
|
+
export interface PasswordHasher {
|
|
40
|
+
/** A new hash with its own salt and the current settings, safe to store. */
|
|
41
|
+
hash(password: string): Promise<string>;
|
|
42
|
+
/**
|
|
43
|
+
* Whether the password matches the hash. Takes the same time whether it
|
|
44
|
+
* does or not.
|
|
45
|
+
*
|
|
46
|
+
* @throws RangeError when the hash is malformed, in another format (the
|
|
47
|
+
* other format above included), or uses settings outside the allowed
|
|
48
|
+
* range. A broken hash is a configuration error, and returning `false`
|
|
49
|
+
* would hide it behind "wrong password".
|
|
50
|
+
*/
|
|
51
|
+
verify(password: string, hash: string): Promise<boolean>;
|
|
52
|
+
/**
|
|
53
|
+
* Whether the hash uses other settings than new hashes do (for scrypt
|
|
54
|
+
* anything but ln=14, r=8, p=5; for chained PBKDF2 any n but 6). The
|
|
55
|
+
* sign-in password hash is a configured, read-only secret, so nothing
|
|
56
|
+
* replaces it automatically: the host reports it, and the hash is replaced
|
|
57
|
+
* by setting the password again (CLI, or `halonic deploy` for a cloud
|
|
58
|
+
* target).
|
|
59
|
+
*
|
|
60
|
+
* @throws RangeError as {@link PasswordHasher.verify} does
|
|
61
|
+
*/
|
|
62
|
+
needsRehash(hash: string): boolean;
|
|
63
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
/** Version of the {@link PluginFolderWriter} port. A breaking change bumps it and comes with an ADR. */
|
|
2
|
+
export declare const pluginFolderWriterVersion = 1;
|
|
3
|
+
/**
|
|
4
|
+
* Refuses an id that isn't one folder name every system opens the same way,
|
|
5
|
+
* the only kind of id a {@link PluginFolderWriter} method takes: empty, `.`,
|
|
6
|
+
* `..`, or one with a `/` or `\` could reach a folder inside a plugin or
|
|
7
|
+
* outside the plugins folder, and one Windows or macOS opens as another
|
|
8
|
+
* entry (see the port) could get round the `taken` check. Upper case is
|
|
9
|
+
* fine.
|
|
10
|
+
*
|
|
11
|
+
* @throws RangeError naming the id
|
|
12
|
+
*/
|
|
13
|
+
export declare function checkPluginId(id: string): void;
|
|
14
|
+
/**
|
|
15
|
+
* Refuses what {@link PluginFolderWriter.place} must never write: an unsafe
|
|
16
|
+
* id; a file path that `checkWorkspacePath` refuses or with a segment the
|
|
17
|
+
* id rule refuses; two paths that are the same file on a disk that ignores
|
|
18
|
+
* case; or a path that is a file and also a folder above another file, in
|
|
19
|
+
* any case. Paths are compared segment by segment with `segmentAsOpened`,
|
|
20
|
+
* so what lands on any disk is exactly the set of files given. Adapters
|
|
21
|
+
* call it before they touch storage.
|
|
22
|
+
*
|
|
23
|
+
* @throws RangeError naming the id or the path
|
|
24
|
+
*/
|
|
25
|
+
export declare function checkPluginFiles(id: string, files: ReadonlyMap<string, Uint8Array>): void;
|
|
26
|
+
/** Options for {@link PluginFolderWriter.place}. */
|
|
27
|
+
export interface PlacePluginOptions {
|
|
28
|
+
/**
|
|
29
|
+
* Put the new plugin folder in place of the one already there, for a new
|
|
30
|
+
* commit of the same plugin. Only a real folder with exactly this id is
|
|
31
|
+
* replaced: one whose name differs only in case, or a link, stays and
|
|
32
|
+
* gives `"taken"`.
|
|
33
|
+
*/
|
|
34
|
+
readonly replace: boolean;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* What {@link PluginFolderWriter.place} did: `placed` the folder, or found
|
|
38
|
+
* the id `taken` and wrote nothing into the plugins folder.
|
|
39
|
+
*/
|
|
40
|
+
export type PluginPlacement = "placed" | "taken";
|
|
41
|
+
/**
|
|
42
|
+
* Write access to the profile's plugins folder, which holds one folder per
|
|
43
|
+
* plugin, named by its id (requirement `ports.plugin-folder-writer`).
|
|
44
|
+
* Installing a plugin places it here and removing it takes it away; a
|
|
45
|
+
* `FolderReader` over the same folder reads it.
|
|
46
|
+
*
|
|
47
|
+
* **The plugins folder lives in the person's profile, never in a
|
|
48
|
+
* workspace**, so a workspace can't install a plugin.
|
|
49
|
+
*
|
|
50
|
+
* **Whole or not at all.** `place` writes the files into a new folder
|
|
51
|
+
* beside the plugins folder, never inside it, and then moves that folder
|
|
52
|
+
* into place, so a reader never lists a plugin that is half written. When
|
|
53
|
+
* it fails, nothing new is left in the plugins folder.
|
|
54
|
+
*
|
|
55
|
+
* **Every method refuses an unsafe id or path** with a `RangeError` before
|
|
56
|
+
* it touches storage. An id is one folder name: not empty, `.` or `..`, and
|
|
57
|
+
* with no `/` or `\`. Neither an id nor a segment of a file's path may be a
|
|
58
|
+
* name Windows or macOS opens as another entry or can't name: no `:`, no
|
|
59
|
+
* trailing dot or space, no `~` followed by a digit, no device name such
|
|
60
|
+
* as `con`, and no control character. A file's path is relative and "/"
|
|
61
|
+
* separated, by the rule of `checkWorkspacePath`; no two paths may be the
|
|
62
|
+
* same file on a disk that ignores case, and no file's path may also be a
|
|
63
|
+
* folder above another file.
|
|
64
|
+
*
|
|
65
|
+
* **The same name in any case** means the same after `segmentAsOpened`,
|
|
66
|
+
* in every adapter, whatever the disk under it does.
|
|
67
|
+
*
|
|
68
|
+
* `place` writes whatever files it is given, even none: refusing a plugin
|
|
69
|
+
* without a `plugin.yaml` is the plugin service's job.
|
|
70
|
+
*
|
|
71
|
+
* Nothing is ever written or deleted through a link: `place` never
|
|
72
|
+
* replaces one, and `remove` takes away the link itself, never what it
|
|
73
|
+
* points to.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* const files = new Map([["plugin.yaml", manifestBytes], ["backend/index.js", codeBytes]]);
|
|
77
|
+
* if ((await writer.place("weather", files, { replace: false })) === "taken") {
|
|
78
|
+
* showAlreadyAdded("weather");
|
|
79
|
+
* }
|
|
80
|
+
*/
|
|
81
|
+
export interface PluginFolderWriter {
|
|
82
|
+
/** Human-readable location of the plugins folder, such as "~/.halonic/plugins" or "memory:plugins". */
|
|
83
|
+
readonly location: string;
|
|
84
|
+
/**
|
|
85
|
+
* Writes `files` as the plugin folder `id`, whole or not at all. Without
|
|
86
|
+
* `replace`, gives `"taken"` and writes nothing when any entry at the top
|
|
87
|
+
* of the plugins folder already has this name, in any case, so two
|
|
88
|
+
* plugins never differ only in case.
|
|
89
|
+
*
|
|
90
|
+
* @param id - the plugin's id, which names its folder
|
|
91
|
+
* @param files - every file's bytes, by path from the plugin folder
|
|
92
|
+
* @throws a `RangeError` for an unsafe id or path, before anything is written
|
|
93
|
+
*/
|
|
94
|
+
place(id: string, files: ReadonlyMap<string, Uint8Array>, options: PlacePluginOptions): Promise<PluginPlacement>;
|
|
95
|
+
/**
|
|
96
|
+
* Removes the entry named exactly `id` at the top of the plugins folder:
|
|
97
|
+
* a folder with everything in it, or a link itself and never what it
|
|
98
|
+
* points to. Nothing happens when there is none, even when an entry has
|
|
99
|
+
* the id in another case: `remove("weather")` leaves `Weather`.
|
|
100
|
+
*
|
|
101
|
+
* @throws a `RangeError` for an unsafe id, before anything is removed
|
|
102
|
+
*/
|
|
103
|
+
remove(id: string): Promise<void>;
|
|
104
|
+
}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { checkWorkspacePath, segmentAsOpened } from "./definition-store.js";
|
|
2
|
+
/** Version of the {@link PluginFolderWriter} port. A breaking change bumps it and comes with an ADR. */
|
|
3
|
+
export const pluginFolderWriterVersion = 1;
|
|
4
|
+
/** Windows device names, which open the device whatever the extension: `con`, `nul.txt`, `com1`. */
|
|
5
|
+
const windowsDevice = /^(con|prn|aux|nul|conin\$|conout\$|com[0-9¹²³]|lpt[0-9¹²³])$/u;
|
|
6
|
+
/**
|
|
7
|
+
* Why Windows or macOS would open `name` as another entry, or can't name it,
|
|
8
|
+
* if so: a `:` (an NTFS stream), a trailing dot or space (dropped), a `~`
|
|
9
|
+
* followed by a digit (an 8.3 short name), a device name, a control
|
|
10
|
+
* character, or a character Windows doesn't allow in a name. The `:` and
|
|
11
|
+
* `~digit` rule is the one private workspace paths use.
|
|
12
|
+
*/
|
|
13
|
+
function whyNotPortable(name) {
|
|
14
|
+
if (name.includes(":"))
|
|
15
|
+
return "no `:`, which Windows opens as a stream";
|
|
16
|
+
if (/[. ]$/u.test(name))
|
|
17
|
+
return "no trailing dot or space, which Windows drops";
|
|
18
|
+
if (/~\d/u.test(name))
|
|
19
|
+
return "no `~` followed by a digit, which Windows opens as a short name";
|
|
20
|
+
if ([...name].some(isControlCharacter))
|
|
21
|
+
return "no control character";
|
|
22
|
+
if (/[<>"|?*]/u.test(name))
|
|
23
|
+
return 'no `<`, `>`, `"`, `|`, `?` or `*`, which Windows refuses';
|
|
24
|
+
const base = segmentAsOpened(name).split(".")[0]?.trimEnd() ?? "";
|
|
25
|
+
if (windowsDevice.test(base))
|
|
26
|
+
return "not a Windows device name such as `con` or `nul`";
|
|
27
|
+
return undefined;
|
|
28
|
+
}
|
|
29
|
+
/** NUL to U+001F and DEL. */
|
|
30
|
+
function isControlCharacter(character) {
|
|
31
|
+
const code = character.codePointAt(0) ?? 0;
|
|
32
|
+
return code < 0x20 || code === 0x7f;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Refuses an id that isn't one folder name every system opens the same way,
|
|
36
|
+
* the only kind of id a {@link PluginFolderWriter} method takes: empty, `.`,
|
|
37
|
+
* `..`, or one with a `/` or `\` could reach a folder inside a plugin or
|
|
38
|
+
* outside the plugins folder, and one Windows or macOS opens as another
|
|
39
|
+
* entry (see the port) could get round the `taken` check. Upper case is
|
|
40
|
+
* fine.
|
|
41
|
+
*
|
|
42
|
+
* @throws RangeError naming the id
|
|
43
|
+
*/
|
|
44
|
+
export function checkPluginId(id) {
|
|
45
|
+
if (id === "" || id === "." || id === ".." || /[/\\]/u.test(id)) {
|
|
46
|
+
throw new RangeError(`${JSON.stringify(id)} isn't a plugin id: give one folder name.`);
|
|
47
|
+
}
|
|
48
|
+
const why = whyNotPortable(id);
|
|
49
|
+
if (why !== undefined) {
|
|
50
|
+
throw new RangeError(`${JSON.stringify(id)} isn't a plugin id: ${why}.`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Refuses what {@link PluginFolderWriter.place} must never write: an unsafe
|
|
55
|
+
* id; a file path that `checkWorkspacePath` refuses or with a segment the
|
|
56
|
+
* id rule refuses; two paths that are the same file on a disk that ignores
|
|
57
|
+
* case; or a path that is a file and also a folder above another file, in
|
|
58
|
+
* any case. Paths are compared segment by segment with `segmentAsOpened`,
|
|
59
|
+
* so what lands on any disk is exactly the set of files given. Adapters
|
|
60
|
+
* call it before they touch storage.
|
|
61
|
+
*
|
|
62
|
+
* @throws RangeError naming the id or the path
|
|
63
|
+
*/
|
|
64
|
+
export function checkPluginFiles(id, files) {
|
|
65
|
+
checkPluginId(id);
|
|
66
|
+
/** Each file's path as a disk that ignores case opens it, to the path given. */
|
|
67
|
+
const opened = new Map();
|
|
68
|
+
for (const path of files.keys()) {
|
|
69
|
+
checkWorkspacePath(path);
|
|
70
|
+
for (const segment of path.split("/")) {
|
|
71
|
+
const why = whyNotPortable(segment);
|
|
72
|
+
if (why !== undefined) {
|
|
73
|
+
throw new RangeError(`Unsafe plugin file path ${JSON.stringify(path)}: ${why}.`);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const key = pathAsOpened(path);
|
|
77
|
+
const same = opened.get(key);
|
|
78
|
+
if (same !== undefined) {
|
|
79
|
+
throw new RangeError(`${JSON.stringify(same)} and ${JSON.stringify(path)} are the same file on a disk that ignores case.`);
|
|
80
|
+
}
|
|
81
|
+
opened.set(key, path);
|
|
82
|
+
}
|
|
83
|
+
for (const path of files.keys()) {
|
|
84
|
+
const segments = path.split("/");
|
|
85
|
+
for (let depth = 1; depth < segments.length; depth++) {
|
|
86
|
+
const file = opened.get(pathAsOpened(segments.slice(0, depth).join("/")));
|
|
87
|
+
if (file !== undefined) {
|
|
88
|
+
throw new RangeError(`${JSON.stringify(file)} is a file and also a folder above ${JSON.stringify(path)}.`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
function pathAsOpened(path) {
|
|
94
|
+
return path.split("/").map(segmentAsOpened).join("/");
|
|
95
|
+
}
|