@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,47 @@
|
|
|
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: 3;
|
|
20
|
+
readonly HarnessBridgeServer: 1;
|
|
21
|
+
readonly HostSettingsStore: 1;
|
|
22
|
+
readonly HttpClient: 1;
|
|
23
|
+
readonly IdGenerator: 1;
|
|
24
|
+
readonly InstructionTrustStore: 1;
|
|
25
|
+
readonly Integration: 2;
|
|
26
|
+
readonly KnowledgeProvider: 1;
|
|
27
|
+
readonly LlmCache: 1;
|
|
28
|
+
readonly LlmProvider: 1;
|
|
29
|
+
readonly PasswordHasher: 1;
|
|
30
|
+
readonly PluginFolderWriter: 1;
|
|
31
|
+
readonly ProgramProbe: 2;
|
|
32
|
+
readonly RecordStore: 2;
|
|
33
|
+
readonly ResourceProbe: 1;
|
|
34
|
+
readonly RunExecutor: 1;
|
|
35
|
+
readonly RunStore: 1;
|
|
36
|
+
readonly Sandbox: 7;
|
|
37
|
+
readonly SandboxSettingStore: 1;
|
|
38
|
+
readonly Scheduler: 1;
|
|
39
|
+
readonly Secrets: 1;
|
|
40
|
+
readonly TokenStore: 1;
|
|
41
|
+
readonly ToolApprovalStore: 1;
|
|
42
|
+
readonly TrustStore: 1;
|
|
43
|
+
readonly UnfencedRunConsentStore: 1;
|
|
44
|
+
readonly Vcs: 2;
|
|
45
|
+
};
|
|
46
|
+
/** The name of a port, such as "RunStore". */
|
|
47
|
+
export type PortName = keyof typeof portVersions;
|
|
@@ -0,0 +1,80 @@
|
|
|
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 { hostSettingsStoreVersion } from "./host-settings-store.js";
|
|
13
|
+
import { httpClientVersion } from "./http-client.js";
|
|
14
|
+
import { idGeneratorVersion } from "./id-generator.js";
|
|
15
|
+
import { instructionTrustStoreVersion } from "./instruction-trust-store.js";
|
|
16
|
+
import { integrationVersion } from "./integration.js";
|
|
17
|
+
import { knowledgeProviderVersion } from "./knowledge-provider.js";
|
|
18
|
+
import { llmCacheVersion } from "./llm-cache.js";
|
|
19
|
+
import { llmProviderVersion } from "./llm-provider.js";
|
|
20
|
+
import { passwordHasherVersion } from "./password-hasher.js";
|
|
21
|
+
import { pluginFolderWriterVersion } from "./plugin-folder-writer.js";
|
|
22
|
+
import { programProbeVersion } from "./program-probe.js";
|
|
23
|
+
import { recordStoreVersion } from "./record-store.js";
|
|
24
|
+
import { resourceProbeVersion } from "./resource-probe.js";
|
|
25
|
+
import { runExecutorVersion } from "./run-executor.js";
|
|
26
|
+
import { runStoreVersion } from "./run-store.js";
|
|
27
|
+
import { sandboxVersion } from "./sandbox.js";
|
|
28
|
+
import { sandboxSettingStoreVersion } from "./sandbox-setting-store.js";
|
|
29
|
+
import { schedulerVersion } from "./scheduler.js";
|
|
30
|
+
import { secretsVersion } from "./secrets.js";
|
|
31
|
+
import { tokenStoreVersion } from "./token-store.js";
|
|
32
|
+
import { toolApprovalStoreVersion } from "./tool-approval-store.js";
|
|
33
|
+
import { trustStoreVersion } from "./trust-store.js";
|
|
34
|
+
import { unfencedRunConsentStoreVersion } from "./unfenced-run-consent-store.js";
|
|
35
|
+
import { vcsVersion } from "./vcs.js";
|
|
36
|
+
/**
|
|
37
|
+
* Every port and its current version, by port name. Adapters and contract
|
|
38
|
+
* suites can record which version they were written against; the README
|
|
39
|
+
* table is checked against this list.
|
|
40
|
+
*
|
|
41
|
+
* @example
|
|
42
|
+
* if (portVersions.RunStore !== 1) throw new Error("this adapter implements RunStore 1");
|
|
43
|
+
*/
|
|
44
|
+
export const portVersions = {
|
|
45
|
+
AgentPlacementStore: agentPlacementStoreVersion,
|
|
46
|
+
BlobStore: blobStoreVersion,
|
|
47
|
+
Clock: clockVersion,
|
|
48
|
+
ConnectionSettingsStore: connectionSettingsStoreVersion,
|
|
49
|
+
ConnectorClient: connectorClientVersion,
|
|
50
|
+
Coordination: coordinationVersion,
|
|
51
|
+
DefinitionStore: definitionStoreVersion,
|
|
52
|
+
Digest: digestVersion,
|
|
53
|
+
FolderReader: folderReaderVersion,
|
|
54
|
+
Harness: harnessVersion,
|
|
55
|
+
HarnessBridgeServer: harnessBridgeServerVersion,
|
|
56
|
+
HostSettingsStore: hostSettingsStoreVersion,
|
|
57
|
+
HttpClient: httpClientVersion,
|
|
58
|
+
IdGenerator: idGeneratorVersion,
|
|
59
|
+
InstructionTrustStore: instructionTrustStoreVersion,
|
|
60
|
+
Integration: integrationVersion,
|
|
61
|
+
KnowledgeProvider: knowledgeProviderVersion,
|
|
62
|
+
LlmCache: llmCacheVersion,
|
|
63
|
+
LlmProvider: llmProviderVersion,
|
|
64
|
+
PasswordHasher: passwordHasherVersion,
|
|
65
|
+
PluginFolderWriter: pluginFolderWriterVersion,
|
|
66
|
+
ProgramProbe: programProbeVersion,
|
|
67
|
+
RecordStore: recordStoreVersion,
|
|
68
|
+
ResourceProbe: resourceProbeVersion,
|
|
69
|
+
RunExecutor: runExecutorVersion,
|
|
70
|
+
RunStore: runStoreVersion,
|
|
71
|
+
Sandbox: sandboxVersion,
|
|
72
|
+
SandboxSettingStore: sandboxSettingStoreVersion,
|
|
73
|
+
Scheduler: schedulerVersion,
|
|
74
|
+
Secrets: secretsVersion,
|
|
75
|
+
TokenStore: tokenStoreVersion,
|
|
76
|
+
ToolApprovalStore: toolApprovalStoreVersion,
|
|
77
|
+
TrustStore: trustStoreVersion,
|
|
78
|
+
UnfencedRunConsentStore: unfencedRunConsentStoreVersion,
|
|
79
|
+
Vcs: vcsVersion,
|
|
80
|
+
};
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/** Version of the {@link ProgramProbe} port. A breaking change bumps it and comes with an ADR. */
|
|
2
|
+
export declare const programProbeVersion = 2;
|
|
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
|
+
* The program's own settings folder, for a question about one agent's
|
|
25
|
+
* settings, such as whether that agent is signed in. `variable` is the
|
|
26
|
+
* environment variable that points the program at the folder, such as
|
|
27
|
+
* "CLAUDE_CONFIG_DIR"; `path` is the folder, an absolute path.
|
|
28
|
+
*/
|
|
29
|
+
export interface ProgramSettingsFolder {
|
|
30
|
+
readonly variable: string;
|
|
31
|
+
readonly path: string;
|
|
32
|
+
}
|
|
33
|
+
/** What else a question to a program may say. */
|
|
34
|
+
export interface ProgramQuestion {
|
|
35
|
+
/**
|
|
36
|
+
* Asks the program about this settings folder instead of the person's
|
|
37
|
+
* own. A probe sets only this variable on top of what it always passes,
|
|
38
|
+
* and refuses a variable it doesn't know as `failed`, so this can't pass
|
|
39
|
+
* anything else to the program.
|
|
40
|
+
*/
|
|
41
|
+
readonly settingsFolder?: ProgramSettingsFolder;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Finds a program on this machine and asks it something short, such as
|
|
45
|
+
* `claude --version`, the way a harness's `detect()` needs (requirement
|
|
46
|
+
* `ports.program-probe`). The launcher (`sandbox-host`) provides it, so a
|
|
47
|
+
* harness finds its program where the sandbox will start it from.
|
|
48
|
+
*
|
|
49
|
+
* The program is found by name the same way the launcher starts it: as an
|
|
50
|
+
* absolute path, never through a shell. It gets no secrets in its
|
|
51
|
+
* environment, a short time limit chosen by the adapter, and its output is
|
|
52
|
+
* cut to a few kilobytes.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* const answer = await probe.ask("codex", ["--version"]);
|
|
56
|
+
* if (answer.status === "missing") return { status: "missing" };
|
|
57
|
+
* const signIn = await probe.ask("codex", ["login", "status"], {
|
|
58
|
+
* settingsFolder: { variable: "CODEX_HOME", path: agentFolder },
|
|
59
|
+
* });
|
|
60
|
+
*/
|
|
61
|
+
export interface ProgramProbe {
|
|
62
|
+
/**
|
|
63
|
+
* Runs `program` with `args` and reports how it went. Never throws: a
|
|
64
|
+
* problem is a {@link ProgramProbeResult}.
|
|
65
|
+
*
|
|
66
|
+
* @param program a bare name, such as "claude". A name with a path separator is `missing`.
|
|
67
|
+
*/
|
|
68
|
+
ask(program: string, args: readonly string[], question?: ProgramQuestion): Promise<ProgramProbeResult>;
|
|
69
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The address a provider of this type calls when it sets no `baseUrl`, or
|
|
3
|
+
* undefined when the type has no usual address. The adapters' presets and
|
|
4
|
+
* the cost rules both read this one table, so they can't drift apart.
|
|
5
|
+
*
|
|
6
|
+
* @example
|
|
7
|
+
* defaultBaseUrl("ollama"); // "http://localhost:11434/v1"
|
|
8
|
+
* defaultBaseUrl("openai-compatible"); // undefined
|
|
9
|
+
*/
|
|
10
|
+
export declare function defaultBaseUrl(type: string): string | undefined;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** The address a provider type calls when its YAML has no `baseUrl`, for the types that have a usual one. */
|
|
2
|
+
const defaultBaseUrls = {
|
|
3
|
+
openai: "https://api.openai.com/v1",
|
|
4
|
+
ollama: "http://localhost:11434/v1",
|
|
5
|
+
lmstudio: "http://localhost:1234/v1",
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* The address a provider of this type calls when it sets no `baseUrl`, or
|
|
9
|
+
* undefined when the type has no usual address. The adapters' presets and
|
|
10
|
+
* the cost rules both read this one table, so they can't drift apart.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* defaultBaseUrl("ollama"); // "http://localhost:11434/v1"
|
|
14
|
+
* defaultBaseUrl("openai-compatible"); // undefined
|
|
15
|
+
*/
|
|
16
|
+
export function defaultBaseUrl(type) {
|
|
17
|
+
return Object.hasOwn(defaultBaseUrls, type) ? defaultBaseUrls[type] : undefined;
|
|
18
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/** Version of the {@link RecordStore} port. A breaking change bumps it and comes with an ADR. */
|
|
2
|
+
export declare const recordStoreVersion = 2;
|
|
3
|
+
/** One change to a record in a collection. The current records are the log folded up. */
|
|
4
|
+
export interface RecordChange {
|
|
5
|
+
at: string;
|
|
6
|
+
collection: string;
|
|
7
|
+
id: string;
|
|
8
|
+
op: "add" | "update" | "remove" | "seed";
|
|
9
|
+
/** add, seed: all values; update: only the changed ones; remove: null. */
|
|
10
|
+
values: Record<string, unknown> | null;
|
|
11
|
+
/** The run (and agent) or person that made the change. */
|
|
12
|
+
by?: {
|
|
13
|
+
runId?: string;
|
|
14
|
+
agent?: string;
|
|
15
|
+
person?: string;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* The data in collections, kept as a log of changes per collection and never
|
|
20
|
+
* in git. Collection names are values, never table or file names chosen by
|
|
21
|
+
* the caller.
|
|
22
|
+
*/
|
|
23
|
+
export interface RecordStore {
|
|
24
|
+
/** Appends changes, in order. Changes to several collections may come in one call. */
|
|
25
|
+
append(changes: readonly RecordChange[]): Promise<void>;
|
|
26
|
+
/** Every change to a collection, oldest first. Empty for an unknown collection. */
|
|
27
|
+
changes(collection: string): Promise<RecordChange[]>;
|
|
28
|
+
/**
|
|
29
|
+
* Replaces a collection's log with its current records, so overwritten and
|
|
30
|
+
* removed values leave the storage. Afterwards {@link changes} gives one
|
|
31
|
+
* `seed` per current record, with the values {@link foldRecords} gives, the
|
|
32
|
+
* `at` of the record's last change and no `by`. Other collections stay as
|
|
33
|
+
* they are; an unknown or empty collection stays empty.
|
|
34
|
+
*
|
|
35
|
+
* A change appended while a compact runs is either folded into the seeds
|
|
36
|
+
* or kept after them, never lost; for example, read, fold and replace in
|
|
37
|
+
* one transaction or under the store's write lock.
|
|
38
|
+
*/
|
|
39
|
+
compact(collection: string): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
/** A record as its changes leave it: its current values and the time of its last change. */
|
|
42
|
+
export interface CurrentRecord {
|
|
43
|
+
values: Record<string, unknown>;
|
|
44
|
+
at: string;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* Folds changes, oldest first, into the current records by id. `add` and
|
|
48
|
+
* `seed` set all values, `update` merges its values into the record's, and
|
|
49
|
+
* `remove` drops the record. Every reader of a {@link RecordStore} and every
|
|
50
|
+
* {@link RecordStore.compact} folds this way.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* const leads = foldRecords(await records.changes("leads"));
|
|
54
|
+
* leads.get("1")?.values; // { name: "Ada L." }
|
|
55
|
+
*/
|
|
56
|
+
export declare function foldRecords(changes: readonly RecordChange[]): Map<string, CurrentRecord>;
|
|
57
|
+
/**
|
|
58
|
+
* What a collection's changes become when it is compacted: one `seed` per
|
|
59
|
+
* current record, with its folded values, the `at` of its last change and
|
|
60
|
+
* no `by`. Adapters write this in place of the collection's log.
|
|
61
|
+
*/
|
|
62
|
+
export declare function compactedChanges(collection: string, changes: readonly RecordChange[]): RecordChange[];
|
|
63
|
+
/** Writes changes as record log lines: one JSON change per line, each ending in a line break. */
|
|
64
|
+
export declare function formatRecordLines(changes: readonly RecordChange[]): string;
|
|
65
|
+
/**
|
|
66
|
+
* Reads a collection log's whole lines back into changes. Every line must
|
|
67
|
+
* hold a change to this collection: one for another collection means the
|
|
68
|
+
* file was copied or renamed by hand. Pass only whole lines, each ending in
|
|
69
|
+
* a line break: a torn last line, from a crash or an append still being
|
|
70
|
+
* written, is the adapter's to leave out first.
|
|
71
|
+
*
|
|
72
|
+
* @param lines - the log's whole lines, or `""` for an empty log
|
|
73
|
+
* @param collection - the collection the log belongs to
|
|
74
|
+
* @param file - the log's name or path, for the error message
|
|
75
|
+
* @returns the changes, oldest first
|
|
76
|
+
* @throws RangeError when the text doesn't end in a line break
|
|
77
|
+
* @throws Error naming the file and line when a line is broken
|
|
78
|
+
*/
|
|
79
|
+
export declare function parseRecordLines(lines: string, collection: string, file: string): RecordChange[];
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
/** Version of the {@link RecordStore} port. A breaking change bumps it and comes with an ADR. */
|
|
2
|
+
export const recordStoreVersion = 2;
|
|
3
|
+
/**
|
|
4
|
+
* Folds changes, oldest first, into the current records by id. `add` and
|
|
5
|
+
* `seed` set all values, `update` merges its values into the record's, and
|
|
6
|
+
* `remove` drops the record. Every reader of a {@link RecordStore} and every
|
|
7
|
+
* {@link RecordStore.compact} folds this way.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* const leads = foldRecords(await records.changes("leads"));
|
|
11
|
+
* leads.get("1")?.values; // { name: "Ada L." }
|
|
12
|
+
*/
|
|
13
|
+
export function foldRecords(changes) {
|
|
14
|
+
const records = new Map();
|
|
15
|
+
for (const change of changes) {
|
|
16
|
+
if (change.op === "remove") {
|
|
17
|
+
records.delete(change.id);
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
const earlier = change.op === "update" ? records.get(change.id)?.values : undefined;
|
|
21
|
+
records.set(change.id, { values: { ...earlier, ...change.values }, at: change.at });
|
|
22
|
+
}
|
|
23
|
+
return records;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* What a collection's changes become when it is compacted: one `seed` per
|
|
27
|
+
* current record, with its folded values, the `at` of its last change and
|
|
28
|
+
* no `by`. Adapters write this in place of the collection's log.
|
|
29
|
+
*/
|
|
30
|
+
export function compactedChanges(collection, changes) {
|
|
31
|
+
return [...foldRecords(changes)].map(([id, record]) => ({
|
|
32
|
+
at: record.at,
|
|
33
|
+
collection,
|
|
34
|
+
id,
|
|
35
|
+
op: "seed",
|
|
36
|
+
values: record.values,
|
|
37
|
+
}));
|
|
38
|
+
}
|
|
39
|
+
// A collection's log file rules, which every adapter that keeps records as
|
|
40
|
+
// files applies: the CLI's `FileRecordStore` in `fs-node` and the desktop
|
|
41
|
+
// app's store in `fs-tauri`, whose shell writes the same files. Bytes stay
|
|
42
|
+
// with the adapters: each finds the log's whole lines and decodes them its
|
|
43
|
+
// own way, then reads them here.
|
|
44
|
+
const recordOps = new Set(["add", "update", "remove", "seed"]);
|
|
45
|
+
/** Writes changes as record log lines: one JSON change per line, each ending in a line break. */
|
|
46
|
+
export function formatRecordLines(changes) {
|
|
47
|
+
return changes.map((change) => `${JSON.stringify(change)}\n`).join("");
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Reads a collection log's whole lines back into changes. Every line must
|
|
51
|
+
* hold a change to this collection: one for another collection means the
|
|
52
|
+
* file was copied or renamed by hand. Pass only whole lines, each ending in
|
|
53
|
+
* a line break: a torn last line, from a crash or an append still being
|
|
54
|
+
* written, is the adapter's to leave out first.
|
|
55
|
+
*
|
|
56
|
+
* @param lines - the log's whole lines, or `""` for an empty log
|
|
57
|
+
* @param collection - the collection the log belongs to
|
|
58
|
+
* @param file - the log's name or path, for the error message
|
|
59
|
+
* @returns the changes, oldest first
|
|
60
|
+
* @throws RangeError when the text doesn't end in a line break
|
|
61
|
+
* @throws Error naming the file and line when a line is broken
|
|
62
|
+
*/
|
|
63
|
+
export function parseRecordLines(lines, collection, file) {
|
|
64
|
+
if (lines === "") {
|
|
65
|
+
return [];
|
|
66
|
+
}
|
|
67
|
+
if (!lines.endsWith("\n")) {
|
|
68
|
+
throw new RangeError(`Only whole lines of record log ${JSON.stringify(file)} can be read.`);
|
|
69
|
+
}
|
|
70
|
+
return lines
|
|
71
|
+
.slice(0, -1)
|
|
72
|
+
.split("\n")
|
|
73
|
+
.map((line, index) => parseRecordLine(line, index + 1, collection, file));
|
|
74
|
+
}
|
|
75
|
+
function parseRecordLine(line, number, collection, file) {
|
|
76
|
+
const broken = (why) => new Error(`Broken record log ${JSON.stringify(file)}, line ${number}: ${why}`);
|
|
77
|
+
let parsed;
|
|
78
|
+
try {
|
|
79
|
+
parsed = JSON.parse(line);
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
throw broken("it is not JSON.");
|
|
83
|
+
}
|
|
84
|
+
if (!isRecordChange(parsed)) {
|
|
85
|
+
throw broken("it is not a record change.");
|
|
86
|
+
}
|
|
87
|
+
if (parsed.collection !== collection) {
|
|
88
|
+
throw broken(`it holds a change to another collection, ${JSON.stringify(parsed.collection)}.`);
|
|
89
|
+
}
|
|
90
|
+
return parsed;
|
|
91
|
+
}
|
|
92
|
+
/** Whether a parsed line has the fields of a {@link RecordChange}, with the types the port gives them. */
|
|
93
|
+
function isRecordChange(value) {
|
|
94
|
+
if (!isPlainObject(value)) {
|
|
95
|
+
return false;
|
|
96
|
+
}
|
|
97
|
+
const { at, collection, id, op, values, by } = value;
|
|
98
|
+
return (typeof at === "string" &&
|
|
99
|
+
typeof collection === "string" &&
|
|
100
|
+
typeof id === "string" &&
|
|
101
|
+
typeof op === "string" &&
|
|
102
|
+
recordOps.has(op) &&
|
|
103
|
+
(values === null || isPlainObject(values)) &&
|
|
104
|
+
(by === undefined || isPlainObject(by)));
|
|
105
|
+
}
|
|
106
|
+
function isPlainObject(value) {
|
|
107
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
108
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/** Version of the {@link ResourceProbe} port. A breaking change bumps it and comes with an ADR. */
|
|
2
|
+
export declare const resourceProbeVersion = 1;
|
|
3
|
+
/** One process the engine started, such as a harness, a sandbox or an MCP server. */
|
|
4
|
+
export interface ProcessUsage {
|
|
5
|
+
/** The operating system's process id. */
|
|
6
|
+
readonly pid: number;
|
|
7
|
+
/** The program's name, such as "claude", without its folder. */
|
|
8
|
+
readonly name: string;
|
|
9
|
+
/** The memory the process holds now (its resident set), in bytes. */
|
|
10
|
+
readonly memoryBytes: number;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* How much disk space a folder's files take. `complete` is `false` when the
|
|
14
|
+
* adapter stopped counting at its limit, so `bytes` is a lower bound.
|
|
15
|
+
*/
|
|
16
|
+
export interface FolderSize {
|
|
17
|
+
readonly bytes: number;
|
|
18
|
+
readonly complete: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Reads what the engine uses on this machine: memory, the processes it
|
|
22
|
+
* started and disk space (failure-path guide, rule 3; requirement
|
|
23
|
+
* `ports.resource-probe`). `ResourceReport` in `core/app` puts the numbers
|
|
24
|
+
* together for `halonic doctor` and the Studio.
|
|
25
|
+
*
|
|
26
|
+
* Every method reads the machine once, when it's called; nothing here polls
|
|
27
|
+
* or keeps a timer. All numbers are whole, non-negative bytes.
|
|
28
|
+
*
|
|
29
|
+
* @example
|
|
30
|
+
* const free = await probe.freeDisk(dataFolder);
|
|
31
|
+
* if (free < 1024 ** 3) warnings.push("low-disk");
|
|
32
|
+
*/
|
|
33
|
+
export interface ResourceProbe {
|
|
34
|
+
/** The engine process's own memory (its resident set), in bytes. */
|
|
35
|
+
engineMemory(): Promise<number>;
|
|
36
|
+
/**
|
|
37
|
+
* Every process below the engine's own process, children and their
|
|
38
|
+
* children, in ascending `pid` order. Processes that end while they're
|
|
39
|
+
* being read are left out.
|
|
40
|
+
*/
|
|
41
|
+
childProcesses(): Promise<readonly ProcessUsage[]>;
|
|
42
|
+
/**
|
|
43
|
+
* The sizes of the files in the folder at `path` and in the folders below
|
|
44
|
+
* it: the bytes they hold, not the blocks the drive sets aside. Symbolic
|
|
45
|
+
* links aren't followed, so a link out of the folder adds nothing. A path
|
|
46
|
+
* where nothing is gives 0 bytes, complete.
|
|
47
|
+
*
|
|
48
|
+
* @param path - an absolute path
|
|
49
|
+
*/
|
|
50
|
+
folderSize(path: string): Promise<FolderSize>;
|
|
51
|
+
/**
|
|
52
|
+
* The free space a program without special rights can use on the drive
|
|
53
|
+
* that holds `path`, in bytes. When nothing is at `path` yet, the drive of
|
|
54
|
+
* its nearest existing parent folder.
|
|
55
|
+
*
|
|
56
|
+
* @param path - an absolute path
|
|
57
|
+
*/
|
|
58
|
+
freeDisk(path: string): Promise<number>;
|
|
59
|
+
}
|