@halonicjs/testing 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +202 -0
- package/NOTICE +1 -0
- package/README.md +41 -1
- package/dist/adapters/http-kit/src/address-class.d.ts +34 -0
- package/dist/adapters/http-kit/src/address-class.js +109 -0
- package/dist/adapters/http-kit/src/index.d.ts +2 -0
- package/dist/adapters/http-kit/src/index.js +2 -0
- package/dist/adapters/http-kit/src/ip-address.d.ts +23 -0
- package/dist/adapters/http-kit/src/ip-address.js +89 -0
- package/dist/adapters/integration-kit/src/declaration.d.ts +14 -0
- package/dist/adapters/integration-kit/src/declaration.js +77 -0
- package/dist/adapters/integration-kit/src/host.d.ts +28 -0
- package/dist/adapters/integration-kit/src/host.js +30 -0
- package/dist/adapters/integration-kit/src/index.d.ts +14 -0
- package/dist/adapters/integration-kit/src/index.js +21 -0
- package/dist/adapters/integration-kit/src/leak-attempt.d.ts +14 -0
- package/dist/adapters/integration-kit/src/leak-attempt.js +16 -0
- package/dist/adapters/integration-kit/src/limited-http.d.ts +49 -0
- package/dist/adapters/integration-kit/src/limited-http.js +182 -0
- package/dist/adapters/integration-kit/src/load-problem.d.ts +20 -0
- package/dist/adapters/integration-kit/src/load-problem.js +1 -0
- package/dist/adapters/integration-kit/src/loader.d.ts +104 -0
- package/dist/adapters/integration-kit/src/loader.js +219 -0
- package/dist/adapters/integration-kit/src/local-address.d.ts +15 -0
- package/dist/adapters/integration-kit/src/local-address.js +25 -0
- package/dist/adapters/integration-kit/src/own-request.d.ts +33 -0
- package/dist/adapters/integration-kit/src/own-request.js +36 -0
- package/dist/adapters/integration-kit/src/plugin-load.d.ts +14 -0
- package/dist/adapters/integration-kit/src/plugin-load.js +58 -0
- package/dist/adapters/integration-kit/src/policy.d.ts +55 -0
- package/dist/adapters/integration-kit/src/policy.js +37 -0
- package/dist/adapters/integration-kit/src/request-body.d.ts +38 -0
- package/dist/adapters/integration-kit/src/request-body.js +68 -0
- package/dist/adapters/integration-kit/src/request-log.d.ts +25 -0
- package/dist/adapters/integration-kit/src/request-log.js +17 -0
- package/dist/adapters/integration-kit/src/response-body.d.ts +23 -0
- package/dist/adapters/integration-kit/src/response-body.js +117 -0
- package/dist/adapters/integration-kit/src/scoped-tokens.d.ts +14 -0
- package/dist/adapters/integration-kit/src/scoped-tokens.js +27 -0
- package/dist/adapters/integration-kit/src/secret-filter.d.ts +84 -0
- package/dist/adapters/integration-kit/src/secret-filter.js +205 -0
- package/dist/adapters/integration-kit/src/secret-in-request.d.ts +59 -0
- package/dist/adapters/integration-kit/src/secret-in-request.js +133 -0
- package/dist/adapters/integration-kit/src/secret-placement.d.ts +36 -0
- package/dist/adapters/integration-kit/src/secret-placement.js +190 -0
- package/dist/adapters/integration-kit/src/wait.d.ts +16 -0
- package/dist/adapters/integration-kit/src/wait.js +35 -0
- package/dist/core/events/src/add-usage.d.ts +10 -0
- package/dist/core/events/src/add-usage.js +27 -0
- package/dist/core/events/src/agent-resume.d.ts +24 -0
- package/dist/core/events/src/agent-resume.js +1 -0
- package/dist/core/events/src/home-path.d.ts +13 -0
- package/dist/core/events/src/home-path.js +26 -0
- package/dist/core/events/src/index.d.ts +13 -0
- package/dist/core/events/src/index.js +7 -0
- package/dist/core/events/src/run-basics.d.ts +205 -0
- package/dist/core/events/src/run-basics.js +1 -0
- package/dist/core/events/src/run-event.d.ts +434 -0
- package/dist/core/events/src/run-event.js +1 -0
- package/dist/core/events/src/run-summary.d.ts +108 -0
- package/dist/core/events/src/run-summary.js +1 -0
- package/dist/core/events/src/sandbox-blocked.d.ts +42 -0
- package/dist/core/events/src/sandbox-blocked.js +26 -0
- package/dist/core/events/src/sandbox-opened-read.d.ts +17 -0
- package/dist/core/events/src/sandbox-opened-read.js +63 -0
- package/dist/core/events/src/sandbox-opened.d.ts +94 -0
- package/dist/core/events/src/sandbox-opened.js +52 -0
- package/dist/core/events/src/summarize.d.ts +14 -0
- package/dist/core/events/src/summarize.js +188 -0
- package/dist/core/events/src/timeline-entry.d.ts +21 -0
- package/dist/core/events/src/timeline-entry.js +105 -0
- package/dist/core/events/src/upgrade.d.ts +23 -0
- package/dist/core/events/src/upgrade.js +49 -0
- package/dist/core/format/src/compact.d.ts +30 -0
- package/dist/core/format/src/compact.js +72 -0
- package/dist/core/format/src/index.d.ts +37 -0
- package/dist/core/format/src/index.js +23 -0
- package/dist/core/format/src/integration/index.d.ts +6 -0
- package/dist/core/format/src/integration/index.js +9 -0
- package/dist/core/format/src/json-schema.d.ts +26 -0
- package/dist/core/format/src/json-schema.js +48 -0
- package/dist/core/format/src/kind.d.ts +65 -0
- package/dist/core/format/src/kind.js +1 -0
- package/dist/core/format/src/kinds/agent/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/agent/kind.js +10 -0
- package/dist/core/format/src/kinds/agent/sandbox-fields.d.ts +89 -0
- package/dist/core/format/src/kinds/agent/sandbox-fields.js +197 -0
- package/dist/core/format/src/kinds/agent/schema.d.ts +147 -0
- package/dist/core/format/src/kinds/agent/schema.js +107 -0
- package/dist/core/format/src/kinds/agent/working-folder-start.d.ts +74 -0
- package/dist/core/format/src/kinds/agent/working-folder-start.js +312 -0
- package/dist/core/format/src/kinds/collection/kind.d.ts +8 -0
- package/dist/core/format/src/kinds/collection/kind.js +14 -0
- package/dist/core/format/src/kinds/collection/schema.d.ts +89 -0
- package/dist/core/format/src/kinds/collection/schema.js +90 -0
- package/dist/core/format/src/kinds/connector/is-local.d.ts +10 -0
- package/dist/core/format/src/kinds/connector/is-local.js +43 -0
- package/dist/core/format/src/kinds/connector/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/connector/kind.js +119 -0
- package/dist/core/format/src/kinds/connector/schema.d.ts +50 -0
- package/dist/core/format/src/kinds/connector/schema.js +92 -0
- package/dist/core/format/src/kinds/deployments/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/deployments/kind.js +25 -0
- package/dist/core/format/src/kinds/deployments/schema.d.ts +37 -0
- package/dist/core/format/src/kinds/deployments/schema.js +42 -0
- package/dist/core/format/src/kinds/hub/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/hub/kind.js +10 -0
- package/dist/core/format/src/kinds/hub/schema.d.ts +54 -0
- package/dist/core/format/src/kinds/hub/schema.js +34 -0
- package/dist/core/format/src/kinds/integration/kind.d.ts +16 -0
- package/dist/core/format/src/kinds/integration/kind.js +138 -0
- package/dist/core/format/src/kinds/integration/parse-sheet.d.ts +19 -0
- package/dist/core/format/src/kinds/integration/parse-sheet.js +24 -0
- package/dist/core/format/src/kinds/integration/policy.d.ts +67 -0
- package/dist/core/format/src/kinds/integration/policy.js +268 -0
- package/dist/core/format/src/kinds/integration/schema.d.ts +233 -0
- package/dist/core/format/src/kinds/integration/schema.js +233 -0
- package/dist/core/format/src/kinds/knowledge/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/knowledge/kind.js +13 -0
- package/dist/core/format/src/kinds/knowledge/schema.d.ts +18 -0
- package/dist/core/format/src/kinds/knowledge/schema.js +25 -0
- package/dist/core/format/src/kinds/models/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/models/kind.js +10 -0
- package/dist/core/format/src/kinds/models/schema.d.ts +92 -0
- package/dist/core/format/src/kinds/models/schema.js +38 -0
- package/dist/core/format/src/kinds/plugin/backend.d.ts +22 -0
- package/dist/core/format/src/kinds/plugin/backend.js +31 -0
- package/dist/core/format/src/kinds/plugin/checks.d.ts +13 -0
- package/dist/core/format/src/kinds/plugin/checks.js +131 -0
- package/dist/core/format/src/kinds/plugin/kind.d.ts +8 -0
- package/dist/core/format/src/kinds/plugin/kind.js +16 -0
- package/dist/core/format/src/kinds/plugin/problems.d.ts +24 -0
- package/dist/core/format/src/kinds/plugin/problems.js +65 -0
- package/dist/core/format/src/kinds/plugin/schema.d.ts +542 -0
- package/dist/core/format/src/kinds/plugin/schema.js +261 -0
- package/dist/core/format/src/kinds/plugin/setting-values.d.ts +17 -0
- package/dist/core/format/src/kinds/plugin/setting-values.js +38 -0
- package/dist/core/format/src/kinds/plugin/ui-checks.d.ts +8 -0
- package/dist/core/format/src/kinds/plugin/ui-checks.js +94 -0
- package/dist/core/format/src/kinds/provider/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/provider/kind.js +24 -0
- package/dist/core/format/src/kinds/provider/schema.d.ts +17 -0
- package/dist/core/format/src/kinds/provider/schema.js +22 -0
- package/dist/core/format/src/kinds/routine/kind.d.ts +8 -0
- package/dist/core/format/src/kinds/routine/kind.js +25 -0
- package/dist/core/format/src/kinds/routine/schema.d.ts +84 -0
- package/dist/core/format/src/kinds/routine/schema.js +93 -0
- package/dist/core/format/src/kinds/runtime/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/runtime/kind.js +13 -0
- package/dist/core/format/src/kinds/runtime/schema.d.ts +10 -0
- package/dist/core/format/src/kinds/runtime/schema.js +12 -0
- package/dist/core/format/src/kinds/skill/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/skill/kind.js +10 -0
- package/dist/core/format/src/kinds/skill/schema.d.ts +17 -0
- package/dist/core/format/src/kinds/skill/schema.js +17 -0
- package/dist/core/format/src/kinds/skill/scripts-folder.d.ts +27 -0
- package/dist/core/format/src/kinds/skill/scripts-folder.js +37 -0
- package/dist/core/format/src/kinds/workflow/kind.d.ts +8 -0
- package/dist/core/format/src/kinds/workflow/kind.js +14 -0
- package/dist/core/format/src/kinds/workflow/schema.d.ts +162 -0
- package/dist/core/format/src/kinds/workflow/schema.js +106 -0
- package/dist/core/format/src/kinds/workflow-test/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/workflow-test/kind.js +14 -0
- package/dist/core/format/src/kinds/workflow-test/schema.d.ts +67 -0
- package/dist/core/format/src/kinds/workflow-test/schema.js +59 -0
- package/dist/core/format/src/kinds/workspace/kind.d.ts +4 -0
- package/dist/core/format/src/kinds/workspace/kind.js +10 -0
- package/dist/core/format/src/kinds/workspace/schema.d.ts +72 -0
- package/dist/core/format/src/kinds/workspace/schema.js +66 -0
- package/dist/core/format/src/parse-file.d.ts +69 -0
- package/dist/core/format/src/parse-file.js +105 -0
- package/dist/core/format/src/recording/format.d.ts +81 -0
- package/dist/core/format/src/recording/format.js +102 -0
- package/dist/core/format/src/recording/index.d.ts +1 -0
- package/dist/core/format/src/recording/index.js +3 -0
- package/dist/core/format/src/registry.d.ts +64 -0
- package/dist/core/format/src/registry.js +61 -0
- package/dist/core/format/src/reserved.d.ts +20 -0
- package/dist/core/format/src/reserved.js +30 -0
- package/dist/core/format/src/shared/fields.d.ts +37 -0
- package/dist/core/format/src/shared/fields.js +54 -0
- package/dist/core/format/src/shared/guard.d.ts +32 -0
- package/dist/core/format/src/shared/guard.js +16 -0
- package/dist/core/format/src/shared/key-in-value.d.ts +28 -0
- package/dist/core/format/src/shared/key-in-value.js +82 -0
- package/dist/core/format/src/shared/legacy-keys.d.ts +8 -0
- package/dist/core/format/src/shared/legacy-keys.js +17 -0
- package/dist/core/format/src/shared/program-start.d.ts +60 -0
- package/dist/core/format/src/shared/program-start.js +99 -0
- package/dist/core/format/src/shared/relative-path.d.ts +29 -0
- package/dist/core/format/src/shared/relative-path.js +50 -0
- package/dist/core/format/src/shared/secret-name.d.ts +24 -0
- package/dist/core/format/src/shared/secret-name.js +107 -0
- package/dist/core/format/src/source.d.ts +16 -0
- package/dist/core/format/src/source.js +73 -0
- package/dist/core/ports/src/agent-placement-store.d.ts +74 -0
- package/dist/core/ports/src/agent-placement-store.js +27 -0
- package/dist/core/ports/src/blob-store.d.ts +33 -0
- package/dist/core/ports/src/blob-store.js +2 -0
- package/dist/core/ports/src/cant-try-error.d.ts +35 -0
- package/dist/core/ports/src/cant-try-error.js +44 -0
- package/dist/core/ports/src/chat.d.ts +127 -0
- package/dist/core/ports/src/chat.js +1 -0
- package/dist/core/ports/src/clock.d.ts +7 -0
- package/dist/core/ports/src/clock.js +2 -0
- package/dist/core/ports/src/connection-settings-store.d.ts +57 -0
- package/dist/core/ports/src/connection-settings-store.js +2 -0
- package/dist/core/ports/src/connector-client.d.ts +259 -0
- package/dist/core/ports/src/connector-client.js +2 -0
- package/dist/core/ports/src/coordination.d.ts +84 -0
- package/dist/core/ports/src/coordination.js +2 -0
- package/dist/core/ports/src/definition-store.d.ts +208 -0
- package/dist/core/ports/src/definition-store.js +122 -0
- package/dist/core/ports/src/digest.d.ts +14 -0
- package/dist/core/ports/src/digest.js +2 -0
- package/dist/core/ports/src/folder-reader.d.ts +89 -0
- package/dist/core/ports/src/folder-reader.js +2 -0
- package/dist/core/ports/src/harness-bridge-server.d.ts +189 -0
- package/dist/core/ports/src/harness-bridge-server.js +37 -0
- package/dist/core/ports/src/harness.d.ts +250 -0
- package/dist/core/ports/src/harness.js +45 -0
- package/dist/core/ports/src/http-client.d.ts +27 -0
- package/dist/core/ports/src/http-client.js +2 -0
- package/dist/core/ports/src/id-generator.d.ts +14 -0
- package/dist/core/ports/src/id-generator.js +2 -0
- package/dist/core/ports/src/index.d.ts +37 -0
- package/dist/core/ports/src/index.js +36 -0
- package/dist/core/ports/src/integration.d.ts +178 -0
- package/dist/core/ports/src/integration.js +13 -0
- package/dist/core/ports/src/knowledge-provider.d.ts +65 -0
- package/dist/core/ports/src/knowledge-provider.js +2 -0
- package/dist/core/ports/src/llm-cache.d.ts +13 -0
- package/dist/core/ports/src/llm-cache.js +2 -0
- package/dist/core/ports/src/llm-provider.d.ts +184 -0
- package/dist/core/ports/src/llm-provider.js +136 -0
- package/dist/core/ports/src/model-price.d.ts +34 -0
- package/dist/core/ports/src/model-price.js +25 -0
- package/dist/core/ports/src/password-hasher.d.ts +47 -0
- package/dist/core/ports/src/password-hasher.js +2 -0
- package/dist/core/ports/src/plugin-folder-writer.d.ts +104 -0
- package/dist/core/ports/src/plugin-folder-writer.js +95 -0
- package/dist/core/ports/src/port-versions.d.ts +44 -0
- package/dist/core/ports/src/port-versions.js +74 -0
- package/dist/core/ports/src/program-probe.d.ts +46 -0
- package/dist/core/ports/src/program-probe.js +2 -0
- package/dist/core/ports/src/record-store.d.ts +62 -0
- package/dist/core/ports/src/record-store.js +38 -0
- package/dist/core/ports/src/resource-probe.d.ts +59 -0
- package/dist/core/ports/src/resource-probe.js +2 -0
- package/dist/core/ports/src/run-executor.d.ts +302 -0
- package/dist/core/ports/src/run-executor.js +2 -0
- package/dist/core/ports/src/run-failure-error.d.ts +49 -0
- package/dist/core/ports/src/run-failure-error.js +47 -0
- package/dist/core/ports/src/run-store.d.ts +194 -0
- package/dist/core/ports/src/run-store.js +131 -0
- package/dist/core/ports/src/sandbox.d.ts +247 -0
- package/dist/core/ports/src/sandbox.js +34 -0
- package/dist/core/ports/src/scheduler.d.ts +85 -0
- package/dist/core/ports/src/scheduler.js +2 -0
- package/dist/core/ports/src/secrets.d.ts +128 -0
- package/dist/core/ports/src/secrets.js +144 -0
- package/dist/core/ports/src/token-store.d.ts +19 -0
- package/dist/core/ports/src/token-store.js +2 -0
- package/dist/core/ports/src/tool-approval-store.d.ts +211 -0
- package/dist/core/ports/src/tool-approval-store.js +57 -0
- package/dist/core/ports/src/trust-store.d.ts +72 -0
- package/dist/core/ports/src/trust-store.js +2 -0
- package/dist/core/ports/src/unfenced-run-consent-store.d.ts +43 -0
- package/dist/core/ports/src/unfenced-run-consent-store.js +2 -0
- package/dist/core/ports/src/vcs.d.ts +394 -0
- package/dist/core/ports/src/vcs.js +48 -0
- package/dist/core/schema-kit/src/builders.d.ts +50 -0
- package/dist/core/schema-kit/src/builders.js +72 -0
- package/dist/core/schema-kit/src/depth.d.ts +15 -0
- package/dist/core/schema-kit/src/depth.js +37 -0
- package/dist/core/schema-kit/src/index.d.ts +6 -0
- package/dist/core/schema-kit/src/index.js +6 -0
- package/dist/core/schema-kit/src/issue.d.ts +22 -0
- package/dist/core/schema-kit/src/issue.js +23 -0
- package/dist/core/schema-kit/src/json-schema.d.ts +23 -0
- package/dist/core/schema-kit/src/json-schema.js +22 -0
- package/dist/core/schema-kit/src/parse.d.ts +17 -0
- package/dist/core/schema-kit/src/parse.js +25 -0
- package/dist/core/schema-kit/src/schema.d.ts +12 -0
- package/dist/core/schema-kit/src/schema.js +1 -0
- package/dist/core/std/src/ascii-host.d.ts +18 -0
- package/dist/core/std/src/ascii-host.js +110 -0
- package/dist/core/std/src/assert.d.ts +39 -0
- package/dist/core/std/src/assert.js +59 -0
- package/dist/core/std/src/base64url.d.ts +23 -0
- package/dist/core/std/src/base64url.js +65 -0
- package/dist/core/std/src/canonical-json.d.ts +18 -0
- package/dist/core/std/src/canonical-json.js +56 -0
- package/dist/core/std/src/clock.d.ts +27 -0
- package/dist/core/std/src/clock.js +33 -0
- package/dist/core/std/src/constant-time.d.ts +16 -0
- package/dist/core/std/src/constant-time.js +26 -0
- package/dist/core/std/src/content-digest.d.ts +24 -0
- package/dist/core/std/src/content-digest.js +28 -0
- package/dist/core/std/src/deep-clone.d.ts +15 -0
- package/dist/core/std/src/deep-clone.js +59 -0
- package/dist/core/std/src/deep-equal.d.ts +23 -0
- package/dist/core/std/src/deep-equal.js +64 -0
- package/dist/core/std/src/emitter.d.ts +42 -0
- package/dist/core/std/src/emitter.js +74 -0
- package/dist/core/std/src/error-kind.d.ts +88 -0
- package/dist/core/std/src/error-kind.js +98 -0
- package/dist/core/std/src/hex.d.ts +10 -0
- package/dist/core/std/src/hex.js +16 -0
- package/dist/core/std/src/ids.d.ts +45 -0
- package/dist/core/std/src/ids.js +49 -0
- package/dist/core/std/src/index.d.ts +25 -0
- package/dist/core/std/src/index.js +26 -0
- package/dist/core/std/src/keyed-queue.d.ts +18 -0
- package/dist/core/std/src/keyed-queue.js +32 -0
- package/dist/core/std/src/line-diff.d.ts +83 -0
- package/dist/core/std/src/line-diff.js +179 -0
- package/dist/core/std/src/line-merge.d.ts +63 -0
- package/dist/core/std/src/line-merge.js +138 -0
- package/dist/core/std/src/plain-data.d.ts +32 -0
- package/dist/core/std/src/plain-data.js +57 -0
- package/dist/core/std/src/posix-path.d.ts +61 -0
- package/dist/core/std/src/posix-path.js +121 -0
- package/dist/core/std/src/result.d.ts +55 -0
- package/dist/core/std/src/result.js +52 -0
- package/dist/core/std/src/secret-scrubber.d.ts +54 -0
- package/dist/core/std/src/secret-scrubber.js +124 -0
- package/dist/core/std/src/secret-shape.d.ts +20 -0
- package/dist/core/std/src/secret-shape.js +53 -0
- package/dist/core/std/src/stop-signal.d.ts +44 -0
- package/dist/core/std/src/stop-signal.js +77 -0
- package/dist/core/std/src/text.d.ts +28 -0
- package/dist/core/std/src/text.js +54 -0
- package/dist/core/std/src/utf8.d.ts +23 -0
- package/dist/core/std/src/utf8.js +110 -0
- package/dist/core/std/src/version.d.ts +48 -0
- package/dist/core/std/src/version.js +103 -0
- package/dist/core/yaml/src/depth.d.ts +14 -0
- package/dist/core/yaml/src/depth.js +140 -0
- package/dist/core/yaml/src/edit-data.d.ts +47 -0
- package/dist/core/yaml/src/edit-data.js +286 -0
- package/dist/core/yaml/src/edit-text.d.ts +92 -0
- package/dist/core/yaml/src/edit-text.js +267 -0
- package/dist/core/yaml/src/edit.d.ts +47 -0
- package/dist/core/yaml/src/edit.js +198 -0
- package/dist/core/yaml/src/index.d.ts +5 -0
- package/dist/core/yaml/src/index.js +4 -0
- package/dist/core/yaml/src/problem.d.ts +20 -0
- package/dist/core/yaml/src/problem.js +1 -0
- package/dist/core/yaml/src/read.d.ts +47 -0
- package/dist/core/yaml/src/read.js +130 -0
- package/dist/core/yaml/src/splice-node.d.ts +47 -0
- package/dist/core/yaml/src/splice-node.js +333 -0
- package/dist/core/yaml/src/splice.d.ts +13 -0
- package/dist/core/yaml/src/splice.js +174 -0
- package/dist/core/yaml/src/unsupported.d.ts +26 -0
- package/dist/core/yaml/src/unsupported.js +70 -0
- package/dist/core/yaml/src/write.d.ts +35 -0
- package/dist/core/yaml/src/write.js +44 -0
- package/dist/testing/integration/src/canaries.d.ts +14 -0
- package/dist/testing/integration/src/canaries.js +17 -0
- package/dist/testing/integration/src/checks.d.ts +37 -0
- package/dist/testing/integration/src/checks.js +195 -0
- package/dist/testing/integration/src/describe.d.ts +35 -0
- package/dist/testing/integration/src/describe.js +74 -0
- package/dist/testing/integration/src/failure.d.ts +6 -0
- package/dist/testing/integration/src/failure.js +8 -0
- package/dist/testing/integration/src/fake-wait.d.ts +18 -0
- package/dist/testing/integration/src/fake-wait.js +21 -0
- package/dist/testing/integration/src/index.d.ts +10 -0
- package/dist/testing/integration/src/index.js +11 -0
- package/dist/testing/integration/src/load.d.ts +14 -0
- package/dist/testing/integration/src/load.js +45 -0
- package/dist/testing/integration/src/plugin-folder.d.ts +23 -0
- package/dist/testing/integration/src/plugin-folder.js +59 -0
- package/dist/testing/integration/src/plugin.d.ts +32 -0
- package/dist/testing/integration/src/plugin.js +57 -0
- package/dist/testing/integration/src/recording.d.ts +84 -0
- package/dist/testing/integration/src/recording.js +164 -0
- package/dist/testing/integration/src/run.d.ts +60 -0
- package/dist/testing/integration/src/run.js +81 -0
- package/dist/testing/integration/src/source-scan.d.ts +16 -0
- package/dist/testing/integration/src/source-scan.js +40 -0
- package/package.json +34 -3
|
@@ -0,0 +1,136 @@
|
|
|
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
|
+
];
|
|
15
|
+
/**
|
|
16
|
+
* The error an {@link LlmProvider} throws when a model call fails, so the
|
|
17
|
+
* engine can tell why and decide whether to try the next model. Its message
|
|
18
|
+
* is plain text for the run log; it never holds a key or any part of one.
|
|
19
|
+
*
|
|
20
|
+
* Check for it with {@link isModelCallError}, not `instanceof`: an adapter
|
|
21
|
+
* may be built against its own copy of this package.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* throw new ModelCallError("model-missing", `openai has no model "gpt-9"`);
|
|
25
|
+
* throw new ModelCallError("offline", "Ollama didn't answer.", { host: "localhost:11434", cause });
|
|
26
|
+
*/
|
|
27
|
+
export class ModelCallError extends Error {
|
|
28
|
+
name = "ModelCallError";
|
|
29
|
+
reason;
|
|
30
|
+
/**
|
|
31
|
+
* With `offline` only: the host that didn't answer, as its name and port,
|
|
32
|
+
* such as `localhost:11434`. Never a URL with a path, a query or a key.
|
|
33
|
+
*/
|
|
34
|
+
host;
|
|
35
|
+
/**
|
|
36
|
+
* @param reason - why the call failed
|
|
37
|
+
* @param message - plain text for the run log, never a key
|
|
38
|
+
* @param options - `cause` keeps the error this one wraps; `host` names the
|
|
39
|
+
* host that didn't answer, and is kept only with `offline`
|
|
40
|
+
*/
|
|
41
|
+
constructor(reason, message, options) {
|
|
42
|
+
super(message, options);
|
|
43
|
+
this.reason = reason;
|
|
44
|
+
this.host = reason === "offline" ? options?.host : undefined;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Whether `value` is a {@link ModelCallError}: an `Error` named
|
|
49
|
+
* "ModelCallError" with one of the known reasons. It works across copies of
|
|
50
|
+
* this package, where `instanceof` doesn't.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* const reason = isModelCallError(error) ? error.reason : "refused";
|
|
54
|
+
*/
|
|
55
|
+
export function isModelCallError(value) {
|
|
56
|
+
if (!(value instanceof Error) || value.name !== "ModelCallError")
|
|
57
|
+
return false;
|
|
58
|
+
const { reason, host } = value;
|
|
59
|
+
const knownReason = modelCallErrorReasons.some((known) => known === reason);
|
|
60
|
+
return knownReason && (host === undefined || typeof host === "string");
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The provider's own error text, as the `cause` of a {@link ModelCallError}
|
|
64
|
+
* for an error reply (requirement `ports.vendor-error-text`). It stays
|
|
65
|
+
* out of the message, which Studio and the command line show: microcopy 1.4
|
|
66
|
+
* allows no quoted outside text there. The engine keeps it in the run log
|
|
67
|
+
* for `--debug` and Copy details.
|
|
68
|
+
*
|
|
69
|
+
* The provider shortens the text and checks it for keys before it builds
|
|
70
|
+
* one: whatever is in it may end up in the run log.
|
|
71
|
+
*
|
|
72
|
+
* Check for it with {@link isVendorErrorText}, not `instanceof`: an adapter
|
|
73
|
+
* may be built against its own copy of this package.
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* const cause = new VendorErrorText(400, "max_tokens: 200000 > 64000");
|
|
77
|
+
* throw new ModelCallError("refused", `anthropic refused the call (HTTP 400)`, { cause });
|
|
78
|
+
*/
|
|
79
|
+
export class VendorErrorText extends Error {
|
|
80
|
+
name = "VendorErrorText";
|
|
81
|
+
/**
|
|
82
|
+
* The HTTP status the text came with, or for an error in a stream the
|
|
83
|
+
* status its error type stands for; undefined when there is none.
|
|
84
|
+
*/
|
|
85
|
+
status;
|
|
86
|
+
/**
|
|
87
|
+
* @param status - the HTTP status the text came with, or undefined when there is none
|
|
88
|
+
* @param text - the provider's text, already shortened and checked for keys
|
|
89
|
+
*/
|
|
90
|
+
constructor(status, text) {
|
|
91
|
+
super(text);
|
|
92
|
+
this.status = status;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Whether `value` is a {@link VendorErrorText}: an `Error` named
|
|
97
|
+
* "VendorErrorText" with a `status` that is a whole number or set to
|
|
98
|
+
* undefined. It works across copies of this package, where `instanceof`
|
|
99
|
+
* doesn't.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* const text = isVendorErrorText(error.cause) ? error.cause.message : undefined;
|
|
103
|
+
*/
|
|
104
|
+
export function isVendorErrorText(value) {
|
|
105
|
+
if (!(value instanceof Error) || value.name !== "VendorErrorText")
|
|
106
|
+
return false;
|
|
107
|
+
if (!Object.hasOwn(value, "status"))
|
|
108
|
+
return false;
|
|
109
|
+
const { status } = value;
|
|
110
|
+
return status === undefined || Number.isInteger(status);
|
|
111
|
+
}
|
|
112
|
+
// What model servers say when the model doesn't fit in memory: Ollama's own
|
|
113
|
+
// check, llama.cpp's allocation failures, and the CUDA, ROCm and Metal
|
|
114
|
+
// messages they pass on. Lower case, matched anywhere in the text.
|
|
115
|
+
const outOfMemoryPhrases = [
|
|
116
|
+
"out of memory",
|
|
117
|
+
"requires more system memory",
|
|
118
|
+
"insufficient memory",
|
|
119
|
+
"not enough memory",
|
|
120
|
+
"failed to allocate",
|
|
121
|
+
"unable to allocate",
|
|
122
|
+
"cudamalloc failed",
|
|
123
|
+
"hipmalloc failed",
|
|
124
|
+
];
|
|
125
|
+
/**
|
|
126
|
+
* True when a model server's error text says the model ran out of memory.
|
|
127
|
+
* A provider calls it on an error body, then throws a {@link ModelCallError}
|
|
128
|
+
* with `out-of-memory` (requirement `ports.model-out-of-memory-text`).
|
|
129
|
+
*
|
|
130
|
+
* @example
|
|
131
|
+
* isModelOutOfMemory("model requires more system memory (12.0 GiB) than is available (7.6 GiB)"); // true
|
|
132
|
+
*/
|
|
133
|
+
export function isModelOutOfMemory(text) {
|
|
134
|
+
const lowered = text.toLowerCase();
|
|
135
|
+
return outOfMemoryPhrases.some((phrase) => lowered.includes(phrase));
|
|
136
|
+
}
|
|
@@ -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,47 @@
|
|
|
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. Every runtime uses scrypt from
|
|
5
|
+
* `core/std`, so a hash made on your machine for a cloud
|
|
6
|
+
* deployment verifies there.
|
|
7
|
+
*
|
|
8
|
+
* **The hash format** is self-describing text, the same on every adapter
|
|
9
|
+
* (requirement `ports.password-hash-format` has a known-answer vector):
|
|
10
|
+
*
|
|
11
|
+
* ```text
|
|
12
|
+
* $scrypt$ln=<log2 N>,r=<r>,p=<p>$<salt>$<key>
|
|
13
|
+
* ```
|
|
14
|
+
*
|
|
15
|
+
* - The salt is exactly 16 random bytes from `crypto.getRandomValues`, and the
|
|
16
|
+
* key exactly 32 bytes. Both are standard base64 without `=` padding; any
|
|
17
|
+
* other length, or padding, makes the hash malformed.
|
|
18
|
+
* - New hashes use ln=14, r=8, p=5. `verify`
|
|
19
|
+
* accepts only ln 14 to 15, r exactly 8 and p 5 to 16. The upper bounds
|
|
20
|
+
* keep a configured hash within a Worker's memory (ln=15 needs 32 MiB;
|
|
21
|
+
* ln=20 would need 1 GiB).
|
|
22
|
+
* - The password is normalised to Unicode NFC and then encoded as UTF-8, so
|
|
23
|
+
* "é" typed as one character or as "e" plus an accent gives the same hash.
|
|
24
|
+
*/
|
|
25
|
+
export interface PasswordHasher {
|
|
26
|
+
/** A new hash with its own salt and the current settings, safe to store. */
|
|
27
|
+
hash(password: string): Promise<string>;
|
|
28
|
+
/**
|
|
29
|
+
* Whether the password matches the hash. Takes the same time whether it
|
|
30
|
+
* does or not.
|
|
31
|
+
*
|
|
32
|
+
* @throws RangeError when the hash is malformed, in another format, or uses
|
|
33
|
+
* settings outside the allowed range. A broken hash is a configuration
|
|
34
|
+
* error, and returning `false` would hide it behind "wrong password".
|
|
35
|
+
*/
|
|
36
|
+
verify(password: string, hash: string): Promise<boolean>;
|
|
37
|
+
/**
|
|
38
|
+
* Whether the hash uses other settings than new hashes do (anything but
|
|
39
|
+
* ln=14, r=8, p=5, above or below). The sign-in password hash is a
|
|
40
|
+
* configured, read-only secret, so nothing replaces it automatically: the
|
|
41
|
+
* host reports it, and the hash is replaced by setting the password again
|
|
42
|
+
* (CLI).
|
|
43
|
+
*
|
|
44
|
+
* @throws RangeError as {@link PasswordHasher.verify} does
|
|
45
|
+
*/
|
|
46
|
+
needsRehash(hash: string): boolean;
|
|
47
|
+
}
|
|
@@ -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
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Every port and its current version, by port name. Adapters and contract
|
|
3
|
+
* suites can record which version they were written against; the README
|
|
4
|
+
* table is checked against this list.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* if (portVersions.RunStore !== 1) throw new Error("this adapter implements RunStore 1");
|
|
8
|
+
*/
|
|
9
|
+
export declare const portVersions: {
|
|
10
|
+
readonly AgentPlacementStore: 1;
|
|
11
|
+
readonly BlobStore: 1;
|
|
12
|
+
readonly Clock: 1;
|
|
13
|
+
readonly ConnectionSettingsStore: 1;
|
|
14
|
+
readonly ConnectorClient: 1;
|
|
15
|
+
readonly Coordination: 1;
|
|
16
|
+
readonly DefinitionStore: 2;
|
|
17
|
+
readonly Digest: 1;
|
|
18
|
+
readonly FolderReader: 1;
|
|
19
|
+
readonly Harness: 2;
|
|
20
|
+
readonly HarnessBridgeServer: 1;
|
|
21
|
+
readonly HttpClient: 1;
|
|
22
|
+
readonly IdGenerator: 1;
|
|
23
|
+
readonly Integration: 1;
|
|
24
|
+
readonly KnowledgeProvider: 1;
|
|
25
|
+
readonly LlmCache: 1;
|
|
26
|
+
readonly LlmProvider: 1;
|
|
27
|
+
readonly PasswordHasher: 1;
|
|
28
|
+
readonly PluginFolderWriter: 1;
|
|
29
|
+
readonly ProgramProbe: 1;
|
|
30
|
+
readonly RecordStore: 2;
|
|
31
|
+
readonly ResourceProbe: 1;
|
|
32
|
+
readonly RunExecutor: 1;
|
|
33
|
+
readonly RunStore: 1;
|
|
34
|
+
readonly Sandbox: 5;
|
|
35
|
+
readonly Scheduler: 1;
|
|
36
|
+
readonly Secrets: 1;
|
|
37
|
+
readonly TokenStore: 1;
|
|
38
|
+
readonly ToolApprovalStore: 1;
|
|
39
|
+
readonly TrustStore: 1;
|
|
40
|
+
readonly UnfencedRunConsentStore: 1;
|
|
41
|
+
readonly Vcs: 2;
|
|
42
|
+
};
|
|
43
|
+
/** The name of a port, such as "RunStore". */
|
|
44
|
+
export type PortName = keyof typeof portVersions;
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
import { agentPlacementStoreVersion } from "./agent-placement-store.js";
|
|
2
|
+
import { blobStoreVersion } from "./blob-store.js";
|
|
3
|
+
import { clockVersion } from "./clock.js";
|
|
4
|
+
import { connectionSettingsStoreVersion } from "./connection-settings-store.js";
|
|
5
|
+
import { connectorClientVersion } from "./connector-client.js";
|
|
6
|
+
import { coordinationVersion } from "./coordination.js";
|
|
7
|
+
import { definitionStoreVersion } from "./definition-store.js";
|
|
8
|
+
import { digestVersion } from "./digest.js";
|
|
9
|
+
import { folderReaderVersion } from "./folder-reader.js";
|
|
10
|
+
import { harnessVersion } from "./harness.js";
|
|
11
|
+
import { harnessBridgeServerVersion } from "./harness-bridge-server.js";
|
|
12
|
+
import { httpClientVersion } from "./http-client.js";
|
|
13
|
+
import { idGeneratorVersion } from "./id-generator.js";
|
|
14
|
+
import { integrationVersion } from "./integration.js";
|
|
15
|
+
import { knowledgeProviderVersion } from "./knowledge-provider.js";
|
|
16
|
+
import { llmCacheVersion } from "./llm-cache.js";
|
|
17
|
+
import { llmProviderVersion } from "./llm-provider.js";
|
|
18
|
+
import { passwordHasherVersion } from "./password-hasher.js";
|
|
19
|
+
import { pluginFolderWriterVersion } from "./plugin-folder-writer.js";
|
|
20
|
+
import { programProbeVersion } from "./program-probe.js";
|
|
21
|
+
import { recordStoreVersion } from "./record-store.js";
|
|
22
|
+
import { resourceProbeVersion } from "./resource-probe.js";
|
|
23
|
+
import { runExecutorVersion } from "./run-executor.js";
|
|
24
|
+
import { runStoreVersion } from "./run-store.js";
|
|
25
|
+
import { sandboxVersion } from "./sandbox.js";
|
|
26
|
+
import { schedulerVersion } from "./scheduler.js";
|
|
27
|
+
import { secretsVersion } from "./secrets.js";
|
|
28
|
+
import { tokenStoreVersion } from "./token-store.js";
|
|
29
|
+
import { toolApprovalStoreVersion } from "./tool-approval-store.js";
|
|
30
|
+
import { trustStoreVersion } from "./trust-store.js";
|
|
31
|
+
import { unfencedRunConsentStoreVersion } from "./unfenced-run-consent-store.js";
|
|
32
|
+
import { vcsVersion } from "./vcs.js";
|
|
33
|
+
/**
|
|
34
|
+
* Every port and its current version, by port name. Adapters and contract
|
|
35
|
+
* suites can record which version they were written against; the README
|
|
36
|
+
* table is checked against this list.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* if (portVersions.RunStore !== 1) throw new Error("this adapter implements RunStore 1");
|
|
40
|
+
*/
|
|
41
|
+
export const portVersions = {
|
|
42
|
+
AgentPlacementStore: agentPlacementStoreVersion,
|
|
43
|
+
BlobStore: blobStoreVersion,
|
|
44
|
+
Clock: clockVersion,
|
|
45
|
+
ConnectionSettingsStore: connectionSettingsStoreVersion,
|
|
46
|
+
ConnectorClient: connectorClientVersion,
|
|
47
|
+
Coordination: coordinationVersion,
|
|
48
|
+
DefinitionStore: definitionStoreVersion,
|
|
49
|
+
Digest: digestVersion,
|
|
50
|
+
FolderReader: folderReaderVersion,
|
|
51
|
+
Harness: harnessVersion,
|
|
52
|
+
HarnessBridgeServer: harnessBridgeServerVersion,
|
|
53
|
+
HttpClient: httpClientVersion,
|
|
54
|
+
IdGenerator: idGeneratorVersion,
|
|
55
|
+
Integration: integrationVersion,
|
|
56
|
+
KnowledgeProvider: knowledgeProviderVersion,
|
|
57
|
+
LlmCache: llmCacheVersion,
|
|
58
|
+
LlmProvider: llmProviderVersion,
|
|
59
|
+
PasswordHasher: passwordHasherVersion,
|
|
60
|
+
PluginFolderWriter: pluginFolderWriterVersion,
|
|
61
|
+
ProgramProbe: programProbeVersion,
|
|
62
|
+
RecordStore: recordStoreVersion,
|
|
63
|
+
ResourceProbe: resourceProbeVersion,
|
|
64
|
+
RunExecutor: runExecutorVersion,
|
|
65
|
+
RunStore: runStoreVersion,
|
|
66
|
+
Sandbox: sandboxVersion,
|
|
67
|
+
Scheduler: schedulerVersion,
|
|
68
|
+
Secrets: secretsVersion,
|
|
69
|
+
TokenStore: tokenStoreVersion,
|
|
70
|
+
ToolApprovalStore: toolApprovalStoreVersion,
|
|
71
|
+
TrustStore: trustStoreVersion,
|
|
72
|
+
UnfencedRunConsentStore: unfencedRunConsentStoreVersion,
|
|
73
|
+
Vcs: vcsVersion,
|
|
74
|
+
};
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
/** Version of the {@link ProgramProbe} port. A breaking change bumps it and comes with an ADR. */
|
|
2
|
+
export declare const programProbeVersion = 1;
|
|
3
|
+
/**
|
|
4
|
+
* What asking a program something answered. `missing`: no program of that
|
|
5
|
+
* name is where Halonic looks for it. `ran`: it ran and ended, with what it
|
|
6
|
+
* wrote; `code` is `null` when a signal ended it. `failed`: it was found but
|
|
7
|
+
* couldn't be run, or didn't end in time; `error` says which, in one plain
|
|
8
|
+
* sentence.
|
|
9
|
+
*/
|
|
10
|
+
export type ProgramProbeResult = {
|
|
11
|
+
status: "missing";
|
|
12
|
+
} | {
|
|
13
|
+
status: "ran";
|
|
14
|
+
path: string;
|
|
15
|
+
code: number | null;
|
|
16
|
+
stdout: string;
|
|
17
|
+
stderr: string;
|
|
18
|
+
} | {
|
|
19
|
+
status: "failed";
|
|
20
|
+
path: string;
|
|
21
|
+
error: string;
|
|
22
|
+
};
|
|
23
|
+
/**
|
|
24
|
+
* Finds a program on this machine and asks it something short, such as
|
|
25
|
+
* `claude --version`, the way a harness's `detect()` needs (requirement
|
|
26
|
+
* `ports.program-probe`). The launcher (`sandbox-host`) provides it, so a
|
|
27
|
+
* harness finds its program where the sandbox will start it from.
|
|
28
|
+
*
|
|
29
|
+
* The program is found by name the same way the launcher starts it: as an
|
|
30
|
+
* absolute path, never through a shell. It gets no secrets in its
|
|
31
|
+
* environment, a short time limit chosen by the adapter, and its output is
|
|
32
|
+
* cut to a few kilobytes.
|
|
33
|
+
*
|
|
34
|
+
* @example
|
|
35
|
+
* const answer = await probe.ask("codex", ["--version"]);
|
|
36
|
+
* if (answer.status === "missing") return { status: "missing" };
|
|
37
|
+
*/
|
|
38
|
+
export interface ProgramProbe {
|
|
39
|
+
/**
|
|
40
|
+
* Runs `program` with `args` and reports how it went. Never throws: a
|
|
41
|
+
* problem is a {@link ProgramProbeResult}.
|
|
42
|
+
*
|
|
43
|
+
* @param program a bare name, such as "claude". A name with a path separator is `missing`.
|
|
44
|
+
*/
|
|
45
|
+
ask(program: string, args: readonly string[]): Promise<ProgramProbeResult>;
|
|
46
|
+
}
|