@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,37 @@
|
|
|
1
|
+
import { priceOf } from "./model-price.js";
|
|
2
|
+
/** Version of the {@link HarnessBridgeServer} port. A breaking change bumps it and comes with an ADR. */
|
|
3
|
+
export const harnessBridgeServerVersion = 1;
|
|
4
|
+
/**
|
|
5
|
+
* The `cost` the bridge records on a model call's `llm.response`, in the
|
|
6
|
+
* workspace's budget currency (requirement `ports.harness-bridge-server`).
|
|
7
|
+
* A sign-in call costs 0, because the person's subscription pays. A keyed call
|
|
8
|
+
* costs its tokens at the model's price ({@link priceOf}), or is `undefined` (unpriced) when the
|
|
9
|
+
* model has no price.
|
|
10
|
+
*
|
|
11
|
+
* @deprecated Use {@link bridgeCallCharge}, which also marks a sign-in call
|
|
12
|
+
* `paidBy: "subscription"`. Recording this cost alone writes a sign-in call
|
|
13
|
+
* as a free call, so the run never counts it in `subscriptionCalls`.
|
|
14
|
+
*/
|
|
15
|
+
export function bridgeCallCost(access, price, usage) {
|
|
16
|
+
if (access.kind === "sign-in")
|
|
17
|
+
return 0;
|
|
18
|
+
if (price === null)
|
|
19
|
+
return undefined;
|
|
20
|
+
return priceOf(price, usage);
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* The `cost` and `paidBy` the bridge records on a model call's
|
|
24
|
+
* `llm.response` (requirement `ports.harness-bridge-server`). A sign-in call
|
|
25
|
+
* gets `cost: 0` and `paidBy: "subscription"`, so the run counts it in
|
|
26
|
+
* `subscriptionCalls`. A keyed call gets the cost from {@link bridgeCallCost},
|
|
27
|
+
* or nothing when its model has no price.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* recorder.record({ type: "llm.response", ...call, ...bridgeCallCharge(access, price, usage) });
|
|
31
|
+
*/
|
|
32
|
+
export function bridgeCallCharge(access, price, usage) {
|
|
33
|
+
if (access.kind === "sign-in")
|
|
34
|
+
return { cost: 0, paidBy: "subscription" };
|
|
35
|
+
const cost = bridgeCallCost(access, price, usage);
|
|
36
|
+
return cost === undefined ? {} : { cost };
|
|
37
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { HarnessSignIn } from "./harness.js";
|
|
2
|
+
/**
|
|
3
|
+
* The terminal a person types a sign-in into: PowerShell, the default
|
|
4
|
+
* terminal on Windows, or `sh` and the shells that read it like `sh` elsewhere.
|
|
5
|
+
*/
|
|
6
|
+
export type SignInShell = "powershell" | "sh";
|
|
7
|
+
/**
|
|
8
|
+
* A harness's sign-in for one agent, as a person types it into their own
|
|
9
|
+
* terminal (requirement `ports.harness-sign-in-command`). Studio shows it
|
|
10
|
+
* when it can't open a window, and `halonic doctor` shows it for each
|
|
11
|
+
* agent that isn't signed in, so both print the same command.
|
|
12
|
+
*
|
|
13
|
+
* It names the program as the person's `PATH` finds it and sets the
|
|
14
|
+
* agent's folder for this command only. The folder is single-quoted, so the
|
|
15
|
+
* shell takes it as it is: no variable, `~` or wildcard in it is expanded.
|
|
16
|
+
*
|
|
17
|
+
* @param signIn - the harness's own sign-in
|
|
18
|
+
* @param settingsFolder - the agent's settings folder, absolute
|
|
19
|
+
* @param shell - the terminal it is typed into
|
|
20
|
+
*
|
|
21
|
+
* @example
|
|
22
|
+
* signInCommandText(claudeCodeSignIn, "/data/agents/writer", "sh");
|
|
23
|
+
* // CLAUDE_CONFIG_DIR='/data/agents/writer' claude auth login
|
|
24
|
+
* signInCommandText(claudeCodeSignIn, agentFolder, "powershell");
|
|
25
|
+
* // $env:CLAUDE_CONFIG_DIR = '<agentFolder>'; claude auth login
|
|
26
|
+
*/
|
|
27
|
+
export declare function signInCommandText(signIn: HarnessSignIn, settingsFolder: string, shell: SignInShell): string;
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A harness's sign-in for one agent, as a person types it into their own
|
|
3
|
+
* terminal (requirement `ports.harness-sign-in-command`). Studio shows it
|
|
4
|
+
* when it can't open a window, and `halonic doctor` shows it for each
|
|
5
|
+
* agent that isn't signed in, so both print the same command.
|
|
6
|
+
*
|
|
7
|
+
* It names the program as the person's `PATH` finds it and sets the
|
|
8
|
+
* agent's folder for this command only. The folder is single-quoted, so the
|
|
9
|
+
* shell takes it as it is: no variable, `~` or wildcard in it is expanded.
|
|
10
|
+
*
|
|
11
|
+
* @param signIn - the harness's own sign-in
|
|
12
|
+
* @param settingsFolder - the agent's settings folder, absolute
|
|
13
|
+
* @param shell - the terminal it is typed into
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* signInCommandText(claudeCodeSignIn, "/data/agents/writer", "sh");
|
|
17
|
+
* // CLAUDE_CONFIG_DIR='/data/agents/writer' claude auth login
|
|
18
|
+
* signInCommandText(claudeCodeSignIn, agentFolder, "powershell");
|
|
19
|
+
* // $env:CLAUDE_CONFIG_DIR = '<agentFolder>'; claude auth login
|
|
20
|
+
*/
|
|
21
|
+
export function signInCommandText(signIn, settingsFolder, shell) {
|
|
22
|
+
const words = [signIn.program, ...signIn.args].join(" ");
|
|
23
|
+
if (shell === "powershell") {
|
|
24
|
+
// PowerShell keeps a single-quoted string as it is, apart from `''` for one `'`.
|
|
25
|
+
const folder = `'${settingsFolder.replaceAll("'", "''")}'`;
|
|
26
|
+
return `$env:${signIn.folderVariable} = ${folder}; ${words}`;
|
|
27
|
+
}
|
|
28
|
+
// `sh` keeps a single-quoted string as it is; a `'` closes it, so it is written `'\''`.
|
|
29
|
+
const folder = `'${settingsFolder.replaceAll("'", "'\\''")}'`;
|
|
30
|
+
return `${signIn.folderVariable}=${folder} ${words}`;
|
|
31
|
+
}
|
|
@@ -0,0 +1,283 @@
|
|
|
1
|
+
import type { AgentResume, RunEventBody, RunEventType } from "../../events/src/index.js";
|
|
2
|
+
import type { SandboxProfile, SandboxSession } from "./sandbox.js";
|
|
3
|
+
/** Version of the {@link Harness} port. A breaking change bumps it and comes with an ADR. */
|
|
4
|
+
export declare const harnessVersion = 3;
|
|
5
|
+
/**
|
|
6
|
+
* Whether a harness can run on this machine, as `detect()` finds it. Studio
|
|
7
|
+
* turns it into the sentence next to the harness choice, so each case
|
|
8
|
+
* carries what that sentence needs.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const found = await codex.detect();
|
|
12
|
+
* if (found.status === "missing") show(`${codex.name} isn't installed`);
|
|
13
|
+
* if (found.status === "unsupported") {
|
|
14
|
+
* const oldest = found.supported.replace(/^>=/, "");
|
|
15
|
+
* show(`${codex.name} ${found.version} isn't supported. Halonic needs ${oldest} or newer.`);
|
|
16
|
+
* }
|
|
17
|
+
* if (found.status === "signed-out") show(`Found ${codex.name} ${found.version} · not signed in`);
|
|
18
|
+
*/
|
|
19
|
+
export type HarnessDetection =
|
|
20
|
+
/**
|
|
21
|
+
* Installed in a version Halonic supports, and signed in, or its sign-in
|
|
22
|
+
* can't be checked. Asked about an agent's settings folder, "signed in"
|
|
23
|
+
* means that agent is; otherwise it means the person is, in their own
|
|
24
|
+
* settings, which a run never uses.
|
|
25
|
+
*/
|
|
26
|
+
{
|
|
27
|
+
status: "ready";
|
|
28
|
+
version: string;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Installed in a version Halonic supports, but the program says no one is
|
|
32
|
+
* signed in: for the agent whose settings folder `detect()` was given, or
|
|
33
|
+
* else on this computer. It can still run when Halonic holds a key
|
|
34
|
+
* for the agent's model provider, so this isn't an error on its own.
|
|
35
|
+
*/
|
|
36
|
+
| {
|
|
37
|
+
status: "signed-out";
|
|
38
|
+
version: string;
|
|
39
|
+
}
|
|
40
|
+
/** The program isn't installed, or isn't where Halonic looks for it. */
|
|
41
|
+
| {
|
|
42
|
+
status: "missing";
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Installed, but in a version Halonic doesn't support. `supported` names the
|
|
46
|
+
* oldest version it does, always written as ">=X.Y.Z" (such as ">=1.0.0"),
|
|
47
|
+
* so screens can drop the ">=" and say "needs 1.0.0 or newer".
|
|
48
|
+
*/
|
|
49
|
+
| {
|
|
50
|
+
status: "unsupported";
|
|
51
|
+
version: string;
|
|
52
|
+
supported: string;
|
|
53
|
+
}
|
|
54
|
+
/** Found, but asking it for its version failed; `error` says how, in words a person can act on. */
|
|
55
|
+
| {
|
|
56
|
+
status: "failed";
|
|
57
|
+
error: string;
|
|
58
|
+
};
|
|
59
|
+
/** What `detect()` may be asked about. */
|
|
60
|
+
export interface HarnessDetectOptions {
|
|
61
|
+
/**
|
|
62
|
+
* The agent's own settings folder, the one its runs get as
|
|
63
|
+
* `settingsFolder`. With it, the sign-in answer is about that agent, which
|
|
64
|
+
* is what a run needs. Without it, `detect()` checks the program and the
|
|
65
|
+
* person's own sign-in, as `halonic doctor` does outside an agent.
|
|
66
|
+
*/
|
|
67
|
+
settingsFolder?: string;
|
|
68
|
+
}
|
|
69
|
+
/** What a harness run is asked to do: one agent of one run, with the agent's own settings. */
|
|
70
|
+
export interface HarnessTask {
|
|
71
|
+
/** The run this agent belongs to. Every event the harness reports is written to its log. */
|
|
72
|
+
runId: string;
|
|
73
|
+
hubId: string;
|
|
74
|
+
/** The agent's id; the harness sets it as `agent` on the events it reports for this agent. */
|
|
75
|
+
agentId: string;
|
|
76
|
+
/** The agent's instructions from its file; empty when it has none. */
|
|
77
|
+
instructions: string;
|
|
78
|
+
/** What the agent is asked to do in this run: the task step's prompt, or the chat message. */
|
|
79
|
+
prompt: string;
|
|
80
|
+
/** The model the agent's file names; the harness's own default when absent. */
|
|
81
|
+
model?: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* The request header that carries the run's bridge token. The token has a
|
|
85
|
+
* header of its own because `Authorization` isn't free: with a subscription,
|
|
86
|
+
* it carries the person's own sign-in, which the bridge passes on unread.
|
|
87
|
+
* Never put the token in the URL, because paths end up in logs.
|
|
88
|
+
*/
|
|
89
|
+
export declare const harnessBridgeTokenHeader = "x-halonic-run-token";
|
|
90
|
+
/**
|
|
91
|
+
* The Halonic bridge of one run: an address in Halonic that serves the model
|
|
92
|
+
* gateway and Halonic's tools over MCP. The harness points its program at
|
|
93
|
+
* `url` and has it send `token` in the {@link harnessBridgeTokenHeader}
|
|
94
|
+
* header on every request.
|
|
95
|
+
*
|
|
96
|
+
* The token is a credential for this run only. A harness never writes it into
|
|
97
|
+
* an event, a log line or an error message.
|
|
98
|
+
*/
|
|
99
|
+
export interface HarnessBridge {
|
|
100
|
+
/**
|
|
101
|
+
* The address the program calls: on loopback, such as
|
|
102
|
+
* "http://127.0.0.1:41817", or, when the bridge serves a Unix socket, the
|
|
103
|
+
* name the sandbox's proxy sends to it, such as
|
|
104
|
+
* "http://bridge.halonic.invalid".
|
|
105
|
+
*/
|
|
106
|
+
url: string;
|
|
107
|
+
/** The run's random token. */
|
|
108
|
+
token: string;
|
|
109
|
+
/**
|
|
110
|
+
* The absolute path of the Unix socket the bridge serves, when it serves
|
|
111
|
+
* one instead of a loopback port. Absent for a loopback bridge.
|
|
112
|
+
*/
|
|
113
|
+
socketPath?: string;
|
|
114
|
+
}
|
|
115
|
+
/** The body of the run log event with this `type`. */
|
|
116
|
+
type RunEventOf<Type extends RunEventType> = Extract<RunEventBody, {
|
|
117
|
+
type: Type;
|
|
118
|
+
}>;
|
|
119
|
+
/**
|
|
120
|
+
* What a harness reports, as run log events without the fields the engine
|
|
121
|
+
* adds. A harness run is still a Halonic run: Runs, the receipt, budgets and
|
|
122
|
+
* the inbox read these events as they read the built-in agent loop's, so a
|
|
123
|
+
* harness has no event types of its own.
|
|
124
|
+
*
|
|
125
|
+
* The engine adds the run fields (`runId`, `seq`, `at`) and the workflow
|
|
126
|
+
* `state` the agent runs in, then writes the event to the run's log.
|
|
127
|
+
*
|
|
128
|
+
* - `agent.started` and `agent.finished` with a `parent` report a subagent.
|
|
129
|
+
* The engine writes the task's own `agent.started` before it calls
|
|
130
|
+
* `start`; the stream ends with the task's own `agent.finished`, without a
|
|
131
|
+
* `parent`, whose `output` is the agent's result.
|
|
132
|
+
* - `llm.request`, `llm.response` and `llm.fallback` report model calls, with
|
|
133
|
+
* their token use and cost.
|
|
134
|
+
* - `knowledge.searched`, `tool.called` and `tool.result` report tool use.
|
|
135
|
+
* - `approval.requested` asks a person for an OK; the harness waits until
|
|
136
|
+
* `send` brings the answer. The built-in loop sets `resume`, so the run can
|
|
137
|
+
* continue after a restart; a program can't be resumed, so a program
|
|
138
|
+
* harness leaves it out.
|
|
139
|
+
*
|
|
140
|
+
* `approval.resolved` isn't here: the engine writes it when a person answers,
|
|
141
|
+
* and passes the answer on with `send`.
|
|
142
|
+
*
|
|
143
|
+
* Each model call and tool call is recorded once. A call that goes through
|
|
144
|
+
* the Halonic bridge is recorded by the bridge, so a harness reports only the
|
|
145
|
+
* calls its program makes elsewhere. The built-in loop calls the model port
|
|
146
|
+
* and Halonic's tools directly, so it reports all of its own.
|
|
147
|
+
*/
|
|
148
|
+
export type HarnessEvent = Omit<RunEventOf<"agent.started">, "state"> | RunEventOf<"llm.request"> | RunEventOf<"llm.response"> | RunEventOf<"llm.fallback"> | RunEventOf<"knowledge.searched"> | RunEventOf<"tool.called"> | RunEventOf<"tool.result"> | (Omit<RunEventOf<"approval.requested">, "state" | "resume"> & {
|
|
149
|
+
resume?: AgentResume;
|
|
150
|
+
}) | Omit<RunEventOf<"agent.finished">, "state">;
|
|
151
|
+
/** What `send` passes to a running harness. */
|
|
152
|
+
export type HarnessInput =
|
|
153
|
+
/** A person's answer to a question the agent asked, or the next message of a chat. */
|
|
154
|
+
{
|
|
155
|
+
type: "answer";
|
|
156
|
+
text: string;
|
|
157
|
+
}
|
|
158
|
+
/** A person's decision on the `approval.requested` event with this `callId`. */
|
|
159
|
+
| {
|
|
160
|
+
type: "approval";
|
|
161
|
+
callId: string;
|
|
162
|
+
approved: boolean;
|
|
163
|
+
comment?: string;
|
|
164
|
+
};
|
|
165
|
+
/**
|
|
166
|
+
* One harness run: its events, read with `for await`, and the way to answer
|
|
167
|
+
* it or stop it.
|
|
168
|
+
*
|
|
169
|
+
* The stream ends with the task agent's `agent.finished` and yields nothing
|
|
170
|
+
* after it. A run that fails or is cancelled ends the stream with an error
|
|
171
|
+
* instead. An error never contains the bridge token.
|
|
172
|
+
*/
|
|
173
|
+
export interface HarnessRun extends AsyncIterable<HarnessEvent> {
|
|
174
|
+
/**
|
|
175
|
+
* Passes a person's answer or approval decision to the run.
|
|
176
|
+
*
|
|
177
|
+
* @throws when the run has ended, or no `approval.requested` with that `callId` is waiting
|
|
178
|
+
*/
|
|
179
|
+
send(input: HarnessInput): Promise<void>;
|
|
180
|
+
/**
|
|
181
|
+
* Stops the run. Resolves once every program it started has stopped; does nothing on a run that has ended.
|
|
182
|
+
*
|
|
183
|
+
* @throws when a program it started can't be stopped, so it may still be running; the error never contains the bridge token
|
|
184
|
+
*/
|
|
185
|
+
cancel(): Promise<void>;
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* What drives an agent: Halonic's own agent loop, Claude Code or Codex. An
|
|
189
|
+
* agent's file picks one by `id`.
|
|
190
|
+
*
|
|
191
|
+
* Every harness runs behind Halonic's `Sandbox` port and reaches Halonic
|
|
192
|
+
* only through the bridge, so integrations, secrets and approvals stay in
|
|
193
|
+
* Halonic. The built-in loop starts no program for the agent: it calls the
|
|
194
|
+
* model port and Halonic's tools directly, ignores `bridge`, and uses
|
|
195
|
+
* `session` only to start the stdio connectors a workspace names. On a
|
|
196
|
+
* target that can't start programs, such as a cloud worker, the session's
|
|
197
|
+
* `start` throws, so the same loop runs there without stdio connectors.
|
|
198
|
+
*
|
|
199
|
+
* @example
|
|
200
|
+
* const found = await harness.detect({ settingsFolder: agentSettingsFolder });
|
|
201
|
+
* if (found.status !== "ready") return;
|
|
202
|
+
* const extra = harness.environment?.(bridge, profile) ?? {};
|
|
203
|
+
* const session = await sandbox.open({ ...profile, env: addHarnessEnvironment(profile.env, extra) });
|
|
204
|
+
* const run = harness.start(task, session, bridge);
|
|
205
|
+
* for await (const event of run) {
|
|
206
|
+
* if (event.type === "approval.requested") await run.send(await askPerson(event));
|
|
207
|
+
* else record(event);
|
|
208
|
+
* }
|
|
209
|
+
*/
|
|
210
|
+
export interface Harness {
|
|
211
|
+
/** The value of `harness` in an agent's file, such as "claude-code". */
|
|
212
|
+
readonly id: string;
|
|
213
|
+
/** The name a person reads, such as "Claude Code". */
|
|
214
|
+
readonly name: string;
|
|
215
|
+
/**
|
|
216
|
+
* Finds the harness's program on this machine, checks its version and,
|
|
217
|
+
* where the program can tell, whether someone is signed in to it. Given
|
|
218
|
+
* an agent's settings folder, it asks the program about that folder's
|
|
219
|
+
* sign-in (requirement `ports.harness-detect-folder`). Never throws: a
|
|
220
|
+
* problem is a {@link HarnessDetection}.
|
|
221
|
+
*/
|
|
222
|
+
detect(options?: HarnessDetectOptions): Promise<HarnessDetection>;
|
|
223
|
+
/**
|
|
224
|
+
* The environment variables the harness's program needs, such as the
|
|
225
|
+
* bridge's address, the token header and the program's own settings and
|
|
226
|
+
* temp folders (requirement `ports.harness-environment`). The engine calls
|
|
227
|
+
* it before it opens the sandbox and adds the result to the profile's `env`
|
|
228
|
+
* with {@link addHarnessEnvironment}, so `session.profile` stays exactly
|
|
229
|
+
* what the program gets.
|
|
230
|
+
*
|
|
231
|
+
* Optional: the built-in loop starts no program, so it has none.
|
|
232
|
+
*/
|
|
233
|
+
environment?(bridge: HarnessBridge, folders: Pick<SandboxProfile, "workingFolder" | "tempFolder" | "settingsFolder">): Record<string, string>;
|
|
234
|
+
/**
|
|
235
|
+
* Starts the agent on `task` inside the sandbox `session`, pointed at the
|
|
236
|
+
* run's `bridge`. Returns at once; a program that can't start ends the
|
|
237
|
+
* stream with an error.
|
|
238
|
+
*/
|
|
239
|
+
start(task: HarnessTask, session: SandboxSession, bridge: HarnessBridge): HarnessRun;
|
|
240
|
+
/**
|
|
241
|
+
* How a person signs in to the harness's program for one agent, with the
|
|
242
|
+
* program's own sign-in (requirement `ports.harness-sign-in`). Studio runs
|
|
243
|
+
* it in a terminal the person can see, and `halonic doctor` shows it.
|
|
244
|
+
*
|
|
245
|
+
* Optional: the built-in loop has no sign-in of its own.
|
|
246
|
+
*/
|
|
247
|
+
readonly signIn?: HarnessSignIn;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* The program's own sign-in, pointed at one agent's settings folder. Each
|
|
251
|
+
* agent signs in on its own, so a run reaches only its own sign-in; the
|
|
252
|
+
* person's own is never copied there.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* // Claude Code: CLAUDE_CONFIG_DIR=<agent's folder> claude auth login
|
|
256
|
+
* const { program, args, folderVariable } = harness.signIn;
|
|
257
|
+
* start(program, args, { [folderVariable]: profile.settingsFolder });
|
|
258
|
+
*/
|
|
259
|
+
export interface HarnessSignIn {
|
|
260
|
+
/** The program, by the name Halonic finds it under, such as "claude". */
|
|
261
|
+
readonly program: string;
|
|
262
|
+
/** What it is asked to sign in, such as `["auth", "login"]`. */
|
|
263
|
+
readonly args: readonly string[];
|
|
264
|
+
/**
|
|
265
|
+
* The environment variable that points the program at the agent's
|
|
266
|
+
* settings folder, such as "CLAUDE_CONFIG_DIR": the same one
|
|
267
|
+
* `environment()` sets for a run.
|
|
268
|
+
*/
|
|
269
|
+
readonly folderVariable: string;
|
|
270
|
+
}
|
|
271
|
+
/**
|
|
272
|
+
* The profile's environment with a harness's variables added (requirement
|
|
273
|
+
* `ports.harness-environment`). A harness may only add: a name the engine
|
|
274
|
+
* already set is an error, so a harness can't quietly replace `PATH` or
|
|
275
|
+
* `HOME`. Names are compared without regard to case, because Windows treats
|
|
276
|
+
* `Path` and `PATH` as one variable. For the same reason a harness may not set
|
|
277
|
+
* two names that differ only in case: which one wins would depend on the
|
|
278
|
+
* platform.
|
|
279
|
+
*
|
|
280
|
+
* @throws Error naming the variables in question, never their values, which may hold the run token
|
|
281
|
+
*/
|
|
282
|
+
export declare function addHarnessEnvironment(engine: Readonly<Record<string, string>>, harness: Readonly<Record<string, string>>): Record<string, string>;
|
|
283
|
+
export {};
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/** Version of the {@link Harness} port. A breaking change bumps it and comes with an ADR. */
|
|
2
|
+
export const harnessVersion = 3;
|
|
3
|
+
/**
|
|
4
|
+
* The request header that carries the run's bridge token. The token has a
|
|
5
|
+
* header of its own because `Authorization` isn't free: with a subscription,
|
|
6
|
+
* it carries the person's own sign-in, which the bridge passes on unread.
|
|
7
|
+
* Never put the token in the URL, because paths end up in logs.
|
|
8
|
+
*/
|
|
9
|
+
export const harnessBridgeTokenHeader = "x-halonic-run-token";
|
|
10
|
+
/**
|
|
11
|
+
* The profile's environment with a harness's variables added (requirement
|
|
12
|
+
* `ports.harness-environment`). A harness may only add: a name the engine
|
|
13
|
+
* already set is an error, so a harness can't quietly replace `PATH` or
|
|
14
|
+
* `HOME`. Names are compared without regard to case, because Windows treats
|
|
15
|
+
* `Path` and `PATH` as one variable. For the same reason a harness may not set
|
|
16
|
+
* two names that differ only in case: which one wins would depend on the
|
|
17
|
+
* platform.
|
|
18
|
+
*
|
|
19
|
+
* @throws Error naming the variables in question, never their values, which may hold the run token
|
|
20
|
+
*/
|
|
21
|
+
export function addHarnessEnvironment(engine, harness) {
|
|
22
|
+
const twice = namesSetTwice(Object.keys(harness));
|
|
23
|
+
if (twice.length > 0) {
|
|
24
|
+
throw new Error(`The harness sets environment variables that differ only in case: ${twice.join(", ")}`);
|
|
25
|
+
}
|
|
26
|
+
const engineNames = new Set(Object.keys(engine).map((name) => name.toUpperCase()));
|
|
27
|
+
const clashes = Object.keys(harness).filter((name) => engineNames.has(name.toUpperCase()));
|
|
28
|
+
if (clashes.length > 0) {
|
|
29
|
+
throw new Error(`The harness sets environment variables Halonic already sets: ${clashes.join(", ")}`);
|
|
30
|
+
}
|
|
31
|
+
return { ...engine, ...harness };
|
|
32
|
+
}
|
|
33
|
+
/** The names that share their spelling, apart from case, with an earlier name. */
|
|
34
|
+
function namesSetTwice(names) {
|
|
35
|
+
const seen = new Set();
|
|
36
|
+
const twice = [];
|
|
37
|
+
for (const name of names) {
|
|
38
|
+
const key = name.toUpperCase();
|
|
39
|
+
if (seen.has(key))
|
|
40
|
+
twice.push(name);
|
|
41
|
+
else
|
|
42
|
+
seen.add(key);
|
|
43
|
+
}
|
|
44
|
+
return twice;
|
|
45
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/** Version of the {@link HostSettingsStore} port. A breaking change bumps it and comes with an ADR. */
|
|
2
|
+
export declare const hostSettingsStoreVersion = 1;
|
|
3
|
+
/** A saved setting's value: anything `JSON.parse` can give back. */
|
|
4
|
+
export type HostSettingValue = null | boolean | number | string | readonly HostSettingValue[] | {
|
|
5
|
+
readonly [name: string]: HostSettingValue;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Every saved setting, by key.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* const values: HostSettingValues = { "assistant.turn-limit": 16, "assistant.connector-tools": true };
|
|
12
|
+
*/
|
|
13
|
+
export type HostSettingValues = Readonly<Record<string, HostSettingValue>>;
|
|
14
|
+
/**
|
|
15
|
+
* The most bytes every saved value may take together, as compact JSON of
|
|
16
|
+
* the values by key (`JSON.stringify(values)` in UTF-8), so long
|
|
17
|
+
* instructions fit and a runaway value doesn't.
|
|
18
|
+
*/
|
|
19
|
+
export declare const hostSettingsMaxBytes: number;
|
|
20
|
+
/**
|
|
21
|
+
* Whether `key` can name a host setting: at most 64 characters, the section
|
|
22
|
+
* first, such as `assistant.turn-limit` or `sandbox.new-agents`. Adapters
|
|
23
|
+
* refuse any other key, so no key can be `__proto__` or hold a path.
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* isHostSettingKey("assistant.turn-limit"); // true
|
|
27
|
+
* isHostSettingKey("turn-limit"); // false: no section
|
|
28
|
+
*/
|
|
29
|
+
export declare function isHostSettingKey(key: string): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* The settings kept where Halonic runs, for every workspace on that
|
|
32
|
+
* computer: the assistant and the sandbox default (`host`-scoped settings
|
|
33
|
+
* in Studio). They live in the user's profile, `settings/host.json` for the
|
|
34
|
+
* CLI, `serve` and the desktop app, memory for tests and the browser demo,
|
|
35
|
+
* and **never in a workspace file**. A provider key is never one of them,
|
|
36
|
+
* only its secret name.
|
|
37
|
+
*
|
|
38
|
+
* The port only stores JSON values by key. `HostSettings` in `core/app`
|
|
39
|
+
* gives each setting its schema and default, so a value that doesn't fit
|
|
40
|
+
* reads as the default. The saved settings are `{ "version": 1, "values":
|
|
41
|
+
* {…} }`; the contract suite's golden cases
|
|
42
|
+
* (`packages/testing/contracts/src/golden/host-settings-limits.json`) list
|
|
43
|
+
* the keys, sizes and saved shapes every adapter, the desktop shell's Rust
|
|
44
|
+
* side too, agrees on.
|
|
45
|
+
*
|
|
46
|
+
* - Saved settings that can't be parsed read as none saved, so every
|
|
47
|
+
* setting starts from its default. The first save over them keeps them
|
|
48
|
+
* first as a broken copy (`host.json.broken`, replacing an older one),
|
|
49
|
+
* so they can still be recovered.
|
|
50
|
+
* - A save keeps everything it doesn't change exactly as it is: other
|
|
51
|
+
* keys, keys `read` leaves out, and the fields and `version` of settings
|
|
52
|
+
* saved by a newer Halonic.
|
|
53
|
+
* - Saves through one store run one at a time, so two saves of different
|
|
54
|
+
* keys keep both, and so do two windows of the desktop app, which save
|
|
55
|
+
* through one process. Between processes (the CLI and the desktop app
|
|
56
|
+
* saving at the same moment) the last save wins.
|
|
57
|
+
* - Settings that can't be read at all (no permission, a link) make `read`
|
|
58
|
+
* throw, so Studio can say it couldn't load them.
|
|
59
|
+
*/
|
|
60
|
+
export interface HostSettingsStore {
|
|
61
|
+
/** Every saved value by key; an empty object when none is saved or they can't be parsed. */
|
|
62
|
+
read(): Promise<HostSettingValues>;
|
|
63
|
+
/**
|
|
64
|
+
* Saves one key's value and leaves every other key as it is. A reader
|
|
65
|
+
* sees the settings from before the save or after it, never half of them.
|
|
66
|
+
*
|
|
67
|
+
* @throws RangeError when the key isn't one {@link isHostSettingKey} allows, a
|
|
68
|
+
* number isn't finite, or the settings would be over {@link hostSettingsMaxBytes};
|
|
69
|
+
* nothing is saved then
|
|
70
|
+
*/
|
|
71
|
+
set(key: string, value: HostSettingValue): Promise<void>;
|
|
72
|
+
/**
|
|
73
|
+
* Removes one key and leaves every other key as it is. Removing a key
|
|
74
|
+
* that isn't saved is not an error, and a removal is never refused for
|
|
75
|
+
* size, even when the saved settings are already over
|
|
76
|
+
* {@link hostSettingsMaxBytes}.
|
|
77
|
+
*
|
|
78
|
+
* @throws RangeError when the key isn't one {@link isHostSettingKey} allows; nothing is saved then
|
|
79
|
+
*/
|
|
80
|
+
remove(key: string): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Calls `listener` after the saved settings may have changed, by this
|
|
83
|
+
* store or by anything else (another window, the CLI). It may call more
|
|
84
|
+
* than once for one change, and once for several, so the caller reads
|
|
85
|
+
* again and compares. It never calls after the returned stop function.
|
|
86
|
+
*/
|
|
87
|
+
watch(listener: () => void): () => void;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The values in saved settings' text, leaving out any key
|
|
91
|
+
* {@link isHostSettingKey} refuses; `undefined` when the text can't be
|
|
92
|
+
* parsed as `{ "values": {…} }`. For adapters, which only read and write.
|
|
93
|
+
*
|
|
94
|
+
* @example
|
|
95
|
+
* readSavedHostSettings('{"version":1,"values":{"assistant.turn-limit":20}}'); // { "assistant.turn-limit": 20 }
|
|
96
|
+
* readSavedHostSettings('{"version":1,"values":{'); // undefined
|
|
97
|
+
*/
|
|
98
|
+
export declare function readSavedHostSettings(text: string): HostSettingValues | undefined;
|
|
99
|
+
/** What an adapter writes for one save, from {@link changeSavedHostSettings}. */
|
|
100
|
+
export interface SavedHostSettingsChange {
|
|
101
|
+
/** The settings' new text. */
|
|
102
|
+
readonly text: string;
|
|
103
|
+
/** Whether the old text couldn't be parsed, so the adapter keeps it as a broken copy first. */
|
|
104
|
+
readonly broken: boolean;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* The saved settings' text with one key saved, or removed when `value` is
|
|
108
|
+
* `undefined`, and everything else kept as it is. For adapters, which only
|
|
109
|
+
* read and write.
|
|
110
|
+
*
|
|
111
|
+
* @param text - the saved settings' text, `undefined` when none is saved
|
|
112
|
+
* @throws RangeError when the key isn't one {@link isHostSettingKey} allows, a
|
|
113
|
+
* number isn't finite, or a saved value would bring the values over
|
|
114
|
+
* {@link hostSettingsMaxBytes}; a removal is never refused for size
|
|
115
|
+
*/
|
|
116
|
+
export declare function changeSavedHostSettings(text: string | undefined, key: string, value: HostSettingValue | undefined): SavedHostSettingsChange;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/** Version of the {@link HostSettingsStore} port. A breaking change bumps it and comes with an ADR. */
|
|
2
|
+
export const hostSettingsStoreVersion = 1;
|
|
3
|
+
/**
|
|
4
|
+
* The most bytes every saved value may take together, as compact JSON of
|
|
5
|
+
* the values by key (`JSON.stringify(values)` in UTF-8), so long
|
|
6
|
+
* instructions fit and a runaway value doesn't.
|
|
7
|
+
*/
|
|
8
|
+
export const hostSettingsMaxBytes = 256 * 1024;
|
|
9
|
+
/** A key is two or more lowercase words joined by dots, each word letters and digits with single `-`. */
|
|
10
|
+
const keyPattern = /^[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?:\.[a-z][a-z0-9]*(?:-[a-z0-9]+)*)+$/;
|
|
11
|
+
/**
|
|
12
|
+
* Whether `key` can name a host setting: at most 64 characters, the section
|
|
13
|
+
* first, such as `assistant.turn-limit` or `sandbox.new-agents`. Adapters
|
|
14
|
+
* refuse any other key, so no key can be `__proto__` or hold a path.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* isHostSettingKey("assistant.turn-limit"); // true
|
|
18
|
+
* isHostSettingKey("turn-limit"); // false: no section
|
|
19
|
+
*/
|
|
20
|
+
export function isHostSettingKey(key) {
|
|
21
|
+
return key.length <= 64 && keyPattern.test(key);
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* The values in saved settings' text, leaving out any key
|
|
25
|
+
* {@link isHostSettingKey} refuses; `undefined` when the text can't be
|
|
26
|
+
* parsed as `{ "values": {…} }`. For adapters, which only read and write.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* readSavedHostSettings('{"version":1,"values":{"assistant.turn-limit":20}}'); // { "assistant.turn-limit": 20 }
|
|
30
|
+
* readSavedHostSettings('{"version":1,"values":{'); // undefined
|
|
31
|
+
*/
|
|
32
|
+
export function readSavedHostSettings(text) {
|
|
33
|
+
const saved = parseSaved(text);
|
|
34
|
+
if (saved === undefined)
|
|
35
|
+
return undefined;
|
|
36
|
+
return Object.fromEntries(Object.entries(saved.values).filter(([key]) => isHostSettingKey(key)));
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* The saved settings' text with one key saved, or removed when `value` is
|
|
40
|
+
* `undefined`, and everything else kept as it is. For adapters, which only
|
|
41
|
+
* read and write.
|
|
42
|
+
*
|
|
43
|
+
* @param text - the saved settings' text, `undefined` when none is saved
|
|
44
|
+
* @throws RangeError when the key isn't one {@link isHostSettingKey} allows, a
|
|
45
|
+
* number isn't finite, or a saved value would bring the values over
|
|
46
|
+
* {@link hostSettingsMaxBytes}; a removal is never refused for size
|
|
47
|
+
*/
|
|
48
|
+
export function changeSavedHostSettings(text, key, value) {
|
|
49
|
+
if (!isHostSettingKey(key)) {
|
|
50
|
+
throw new RangeError(`${JSON.stringify(key)} can't name a setting.`);
|
|
51
|
+
}
|
|
52
|
+
if (value !== undefined && !holdsOnlyFiniteNumbers(value)) {
|
|
53
|
+
throw new RangeError(`The value for ${key} has a number that isn't finite.`);
|
|
54
|
+
}
|
|
55
|
+
const saved = text === undefined ? undefined : parseSaved(text);
|
|
56
|
+
const values = { ...saved?.values };
|
|
57
|
+
if (value === undefined)
|
|
58
|
+
delete values[key];
|
|
59
|
+
else
|
|
60
|
+
values[key] = value;
|
|
61
|
+
// A removal is never refused for size, so settings already over it (saved
|
|
62
|
+
// by a newer Halonic, or edited by hand) can still be brought back under it.
|
|
63
|
+
if (value !== undefined && utf8Length(JSON.stringify(values)) > hostSettingsMaxBytes) {
|
|
64
|
+
throw new RangeError(`The settings would be over ${hostSettingsMaxBytes} bytes with ${key}.`);
|
|
65
|
+
}
|
|
66
|
+
return {
|
|
67
|
+
text: `${JSON.stringify({ version: 1, ...saved, values }, null, 2)}\n`,
|
|
68
|
+
broken: text !== undefined && saved === undefined,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function parseSaved(text) {
|
|
72
|
+
let parsed;
|
|
73
|
+
try {
|
|
74
|
+
parsed = JSON.parse(text);
|
|
75
|
+
}
|
|
76
|
+
catch {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
return isObject(parsed) && isObject(parsed["values"]) ? parsed : undefined;
|
|
80
|
+
}
|
|
81
|
+
function isObject(value) {
|
|
82
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
83
|
+
}
|
|
84
|
+
/** `text`'s length in UTF-8 bytes. The core has no `TextEncoder`; JSON text has no lone surrogates. */
|
|
85
|
+
function utf8Length(text) {
|
|
86
|
+
let bytes = 0;
|
|
87
|
+
for (const character of text) {
|
|
88
|
+
const code = character.codePointAt(0) ?? 0;
|
|
89
|
+
if (code < 0x80)
|
|
90
|
+
bytes += 1;
|
|
91
|
+
else if (code < 0x800)
|
|
92
|
+
bytes += 2;
|
|
93
|
+
else if (code < 0x10000)
|
|
94
|
+
bytes += 3;
|
|
95
|
+
else
|
|
96
|
+
bytes += 4;
|
|
97
|
+
}
|
|
98
|
+
return bytes;
|
|
99
|
+
}
|
|
100
|
+
function holdsOnlyFiniteNumbers(value) {
|
|
101
|
+
if (typeof value === "number")
|
|
102
|
+
return Number.isFinite(value);
|
|
103
|
+
if (typeof value !== "object" || value === null)
|
|
104
|
+
return true;
|
|
105
|
+
return Object.values(value).every(holdsOnlyFiniteNumbers);
|
|
106
|
+
}
|