@halonicjs/testing 0.1.0 → 0.1.2

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.
Files changed (228) hide show
  1. package/NOTICE +4 -0
  2. package/README.md +1 -1
  3. package/dist/adapters/http-kit/src/address-checking.d.ts +19 -0
  4. package/dist/adapters/http-kit/src/address-checking.js +1 -0
  5. package/dist/adapters/http-kit/src/connector-host-class.d.ts +14 -0
  6. package/dist/adapters/http-kit/src/connector-host-class.js +34 -0
  7. package/dist/adapters/http-kit/src/index.d.ts +3 -0
  8. package/dist/adapters/http-kit/src/index.js +2 -0
  9. package/dist/adapters/http-kit/src/ollama-tags.d.ts +20 -0
  10. package/dist/adapters/http-kit/src/ollama-tags.js +38 -0
  11. package/dist/adapters/integration-kit/src/auth-placement.d.ts +40 -0
  12. package/dist/adapters/integration-kit/src/auth-placement.js +102 -0
  13. package/dist/adapters/integration-kit/src/current-secret-forms.d.ts +28 -0
  14. package/dist/adapters/integration-kit/src/current-secret-forms.js +60 -0
  15. package/dist/adapters/integration-kit/src/declaration.d.ts +2 -1
  16. package/dist/adapters/integration-kit/src/declaration.js +4 -3
  17. package/dist/adapters/integration-kit/src/host.d.ts +7 -1
  18. package/dist/adapters/integration-kit/src/host.js +1 -0
  19. package/dist/adapters/integration-kit/src/index.d.ts +5 -2
  20. package/dist/adapters/integration-kit/src/index.js +2 -0
  21. package/dist/adapters/integration-kit/src/leak-attempt.d.ts +4 -2
  22. package/dist/adapters/integration-kit/src/leak-attempt.js +5 -2
  23. package/dist/adapters/integration-kit/src/limited-http.d.ts +7 -1
  24. package/dist/adapters/integration-kit/src/limited-http.js +53 -10
  25. package/dist/adapters/integration-kit/src/loader.d.ts +28 -11
  26. package/dist/adapters/integration-kit/src/loader.js +36 -21
  27. package/dist/adapters/integration-kit/src/own-request.d.ts +2 -2
  28. package/dist/adapters/integration-kit/src/own-request.js +1 -1
  29. package/dist/adapters/integration-kit/src/plugin-load.d.ts +3 -3
  30. package/dist/adapters/integration-kit/src/plugin-load.js +5 -5
  31. package/dist/adapters/integration-kit/src/policy.d.ts +28 -0
  32. package/dist/adapters/integration-kit/src/response-body.d.ts +6 -2
  33. package/dist/adapters/integration-kit/src/secret-filter.d.ts +3 -3
  34. package/dist/adapters/integration-kit/src/secret-filter.js +19 -4
  35. package/dist/adapters/integration-kit/src/secret-in-request.d.ts +3 -0
  36. package/dist/adapters/integration-kit/src/secret-in-request.js +8 -2
  37. package/dist/adapters/integration-kit/src/secret-placement.d.ts +35 -25
  38. package/dist/adapters/integration-kit/src/secret-placement.js +65 -95
  39. package/dist/adapters/integration-kit/src/sign-in-placement.d.ts +29 -0
  40. package/dist/adapters/integration-kit/src/sign-in-placement.js +92 -0
  41. package/dist/adapters/integration-kit/src/workspace-choices.d.ts +37 -0
  42. package/dist/adapters/integration-kit/src/workspace-choices.js +37 -0
  43. package/dist/core/events/src/blocked-sites.d.ts +57 -0
  44. package/dist/core/events/src/blocked-sites.js +89 -0
  45. package/dist/core/events/src/connector-listing-failed.d.ts +18 -0
  46. package/dist/core/events/src/connector-listing-failed.js +1 -0
  47. package/dist/core/events/src/home-path.d.ts +4 -1
  48. package/dist/core/events/src/home-path.js +14 -3
  49. package/dist/core/events/src/index.d.ts +8 -2
  50. package/dist/core/events/src/index.js +5 -0
  51. package/dist/core/events/src/provider-notes.d.ts +16 -0
  52. package/dist/core/events/src/provider-notes.js +24 -0
  53. package/dist/core/events/src/run-basics.d.ts +131 -10
  54. package/dist/core/events/src/run-event.d.ts +120 -11
  55. package/dist/core/events/src/run-reads.d.ts +25 -0
  56. package/dist/core/events/src/run-reads.js +44 -0
  57. package/dist/core/events/src/run-sends.d.ts +47 -0
  58. package/dist/core/events/src/run-sends.js +68 -0
  59. package/dist/core/events/src/run-summary.d.ts +11 -1
  60. package/dist/core/events/src/sandbox-opened-read.d.ts +2 -1
  61. package/dist/core/events/src/sandbox-opened-read.js +27 -2
  62. package/dist/core/events/src/sandbox-opened.d.ts +37 -4
  63. package/dist/core/events/src/sandbox-opened.js +13 -3
  64. package/dist/core/events/src/summarize.js +8 -1
  65. package/dist/core/events/src/timeline-entry.js +1 -0
  66. package/dist/core/events/src/tool-failure-cause.d.ts +25 -0
  67. package/dist/core/events/src/tool-failure-cause.js +66 -0
  68. package/dist/core/format/src/index.d.ts +9 -6
  69. package/dist/core/format/src/index.js +7 -3
  70. package/dist/core/format/src/integration/index.d.ts +3 -2
  71. package/dist/core/format/src/integration/index.js +2 -1
  72. package/dist/core/format/src/kinds/agent/harness-limits.d.ts +14 -0
  73. package/dist/core/format/src/kinds/agent/harness-limits.js +27 -0
  74. package/dist/core/format/src/kinds/agent/sandbox-fields.d.ts +15 -5
  75. package/dist/core/format/src/kinds/agent/sandbox-fields.js +29 -10
  76. package/dist/core/format/src/kinds/agent/schema.d.ts +5 -0
  77. package/dist/core/format/src/kinds/agent/schema.js +5 -2
  78. package/dist/core/format/src/kinds/connector/is-local.js +1 -1
  79. package/dist/core/format/src/kinds/connector/kind.js +122 -2
  80. package/dist/core/format/src/kinds/connector/schema.d.ts +38 -0
  81. package/dist/core/format/src/kinds/connector/schema.js +71 -2
  82. package/dist/core/format/src/kinds/deployments/kind.js +25 -1
  83. package/dist/core/format/src/kinds/deployments/schema.d.ts +40 -0
  84. package/dist/core/format/src/kinds/deployments/schema.js +52 -0
  85. package/dist/core/format/src/kinds/integration/approved-sign-ins.d.ts +62 -0
  86. package/dist/core/format/src/kinds/integration/approved-sign-ins.js +125 -0
  87. package/dist/core/format/src/kinds/integration/host-key.d.ts +7 -0
  88. package/dist/core/format/src/kinds/integration/host-key.js +8 -0
  89. package/dist/core/format/src/kinds/integration/kind.d.ts +4 -2
  90. package/dist/core/format/src/kinds/integration/kind.js +49 -12
  91. package/dist/core/format/src/kinds/integration/policy.d.ts +47 -2
  92. package/dist/core/format/src/kinds/integration/policy.js +61 -2
  93. package/dist/core/format/src/kinds/integration/schema.d.ts +180 -3
  94. package/dist/core/format/src/kinds/integration/schema.js +133 -7
  95. package/dist/core/format/src/kinds/integration/sign-in-checks.d.ts +14 -0
  96. package/dist/core/format/src/kinds/integration/sign-in-checks.js +150 -0
  97. package/dist/core/format/src/kinds/integration/sign-in-urls.d.ts +19 -0
  98. package/dist/core/format/src/kinds/integration/sign-in-urls.js +47 -0
  99. package/dist/core/format/src/kinds/plugin/checks.d.ts +3 -2
  100. package/dist/core/format/src/kinds/plugin/checks.js +24 -6
  101. package/dist/core/format/src/kinds/plugin/schema.d.ts +130 -0
  102. package/dist/core/format/src/kinds/plugin/schema.js +26 -6
  103. package/dist/core/format/src/kinds/plugin/ui-checks.d.ts +1 -1
  104. package/dist/core/format/src/kinds/plugin/ui-checks.js +1 -10
  105. package/dist/core/format/src/kinds/provider/kind.js +40 -1
  106. package/dist/core/format/src/kinds/provider/types.d.ts +19 -0
  107. package/dist/core/format/src/kinds/provider/types.js +22 -0
  108. package/dist/core/format/src/kinds/routine/kind.js +38 -1
  109. package/dist/core/format/src/kinds/routine/schema.d.ts +20 -5
  110. package/dist/core/format/src/kinds/routine/schema.js +42 -14
  111. package/dist/core/format/src/kinds/routine/webhook-headers.d.ts +9 -0
  112. package/dist/core/format/src/kinds/routine/webhook-headers.js +26 -0
  113. package/dist/core/format/src/kinds/workflow/schema.js +1 -1
  114. package/dist/core/format/src/kinds/workspace/kind.js +1 -1
  115. package/dist/core/format/src/kinds/workspace/schema.d.ts +2 -2
  116. package/dist/core/format/src/kinds/workspace/schema.js +6 -5
  117. package/dist/core/format/src/parse-file.js +3 -1
  118. package/dist/core/format/src/shared/fields.d.ts +12 -8
  119. package/dist/core/format/src/shared/fields.js +48 -19
  120. package/dist/core/format/src/shared/guard.d.ts +8 -0
  121. package/dist/core/format/src/shared/guard.js +50 -1
  122. package/dist/core/format/src/shared/missing-keys.d.ts +17 -0
  123. package/dist/core/format/src/shared/missing-keys.js +110 -0
  124. package/dist/core/ports/src/agent-runs-not-available.d.ts +21 -0
  125. package/dist/core/ports/src/agent-runs-not-available.js +25 -0
  126. package/dist/core/ports/src/blob-store.d.ts +12 -0
  127. package/dist/core/ports/src/blob-store.js +22 -0
  128. package/dist/core/ports/src/chat.d.ts +8 -0
  129. package/dist/core/ports/src/connector-client.d.ts +48 -4
  130. package/dist/core/ports/src/connector-client.js +17 -0
  131. package/dist/core/ports/src/connector-start-failure.d.ts +31 -0
  132. package/dist/core/ports/src/connector-start-failure.js +32 -0
  133. package/dist/core/ports/src/connector-tool-error.d.ts +33 -0
  134. package/dist/core/ports/src/connector-tool-error.js +40 -0
  135. package/dist/core/ports/src/definition-store-left-out.d.ts +46 -0
  136. package/dist/core/ports/src/definition-store-left-out.js +47 -0
  137. package/dist/core/ports/src/definition-store.d.ts +36 -5
  138. package/dist/core/ports/src/definition-store.js +1 -1
  139. package/dist/core/ports/src/deploy-target.d.ts +358 -0
  140. package/dist/core/ports/src/deploy-target.js +2 -0
  141. package/dist/core/ports/src/harness-bridge-server.d.ts +67 -7
  142. package/dist/core/ports/src/harness-sign-in-command.d.ts +27 -0
  143. package/dist/core/ports/src/harness-sign-in-command.js +31 -0
  144. package/dist/core/ports/src/harness.d.ts +79 -15
  145. package/dist/core/ports/src/harness.js +1 -1
  146. package/dist/core/ports/src/host-settings-store.d.ts +116 -0
  147. package/dist/core/ports/src/host-settings-store.js +106 -0
  148. package/dist/core/ports/src/host-too-old.d.ts +23 -0
  149. package/dist/core/ports/src/host-too-old.js +27 -0
  150. package/dist/core/ports/src/index.d.ts +32 -13
  151. package/dist/core/ports/src/index.js +28 -8
  152. package/dist/core/ports/src/instruction-trust-store.d.ts +81 -0
  153. package/dist/core/ports/src/instruction-trust-store.js +43 -0
  154. package/dist/core/ports/src/integration.d.ts +71 -7
  155. package/dist/core/ports/src/integration.js +22 -4
  156. package/dist/core/ports/src/llm-provider.d.ts +39 -6
  157. package/dist/core/ports/src/llm-provider.js +46 -3
  158. package/dist/core/ports/src/pairing-codes.d.ts +111 -0
  159. package/dist/core/ports/src/pairing-codes.js +336 -0
  160. package/dist/core/ports/src/pairing-qr-bytes.d.ts +32 -0
  161. package/dist/core/ports/src/pairing-qr-bytes.js +116 -0
  162. package/dist/core/ports/src/password-hasher.d.ts +36 -20
  163. package/dist/core/ports/src/port-versions.d.ts +13 -6
  164. package/dist/core/ports/src/port-versions.js +14 -0
  165. package/dist/core/ports/src/program-probe.d.ts +25 -2
  166. package/dist/core/ports/src/program-probe.js +1 -1
  167. package/dist/core/ports/src/provider-default-base-url.d.ts +10 -0
  168. package/dist/core/ports/src/provider-default-base-url.js +18 -0
  169. package/dist/core/ports/src/record-store.d.ts +17 -0
  170. package/dist/core/ports/src/record-store.js +70 -0
  171. package/dist/core/ports/src/remote-control.d.ts +159 -0
  172. package/dist/core/ports/src/remote-control.js +26 -0
  173. package/dist/core/ports/src/remote-gateway-protocol.d.ts +220 -0
  174. package/dist/core/ports/src/remote-gateway-protocol.js +62 -0
  175. package/dist/core/ports/src/remote-gateway-session.d.ts +194 -0
  176. package/dist/core/ports/src/remote-gateway-session.js +241 -0
  177. package/dist/core/ports/src/run-executor.d.ts +44 -7
  178. package/dist/core/ports/src/run-executor.js +1 -1
  179. package/dist/core/ports/src/run-target-not-found.d.ts +34 -0
  180. package/dist/core/ports/src/run-target-not-found.js +41 -0
  181. package/dist/core/ports/src/sandbox-setting-store.d.ts +68 -0
  182. package/dist/core/ports/src/sandbox-setting-store.js +33 -0
  183. package/dist/core/ports/src/sandbox.d.ts +149 -13
  184. package/dist/core/ports/src/sandbox.js +52 -2
  185. package/dist/core/ports/src/secrets.d.ts +105 -1
  186. package/dist/core/ports/src/secrets.js +75 -2
  187. package/dist/core/ports/src/tool-approval-store.d.ts +50 -8
  188. package/dist/core/ports/src/tool-approval-store.js +59 -0
  189. package/dist/core/ports/src/tunnel-provider.d.ts +117 -0
  190. package/dist/core/ports/src/tunnel-provider.js +65 -0
  191. package/dist/core/ports/src/tunnel-resolver.d.ts +83 -0
  192. package/dist/core/ports/src/tunnel-resolver.js +36 -0
  193. package/dist/core/ports/src/vcs-status.d.ts +8 -0
  194. package/dist/core/ports/src/vcs-status.js +90 -0
  195. package/dist/core/ports/src/vcs.d.ts +30 -0
  196. package/dist/core/schema-kit/src/builders.d.ts +5 -0
  197. package/dist/core/schema-kit/src/builders.js +5 -0
  198. package/dist/core/std/src/amount.d.ts +13 -0
  199. package/dist/core/std/src/amount.js +22 -0
  200. package/dist/core/std/src/hidden-characters.d.ts +28 -0
  201. package/dist/core/std/src/hidden-characters.js +72 -0
  202. package/dist/core/std/src/index.d.ts +7 -0
  203. package/dist/core/std/src/index.js +7 -0
  204. package/dist/core/std/src/path-overlap.d.ts +22 -0
  205. package/dist/core/std/src/path-overlap.js +57 -0
  206. package/dist/core/std/src/public-suffixes.generated.d.ts +9 -0
  207. package/dist/core/std/src/public-suffixes.generated.js +10428 -0
  208. package/dist/core/std/src/registrable-domain.d.ts +10 -0
  209. package/dist/core/std/src/registrable-domain.js +62 -0
  210. package/dist/core/std/src/secret-variable-name.d.ts +12 -0
  211. package/dist/core/std/src/secret-variable-name.js +34 -0
  212. package/dist/core/std/src/site-name.d.ts +35 -0
  213. package/dist/core/std/src/site-name.js +111 -0
  214. package/dist/core/std/src/url-host.d.ts +35 -0
  215. package/dist/core/std/src/url-host.js +170 -0
  216. package/dist/core/std/src/word-diff.d.ts +28 -0
  217. package/dist/core/std/src/word-diff.js +77 -0
  218. package/dist/core/yaml/src/edit-data.d.ts +7 -0
  219. package/dist/core/yaml/src/edit-data.js +62 -3
  220. package/dist/core/yaml/src/edit.d.ts +7 -0
  221. package/dist/core/yaml/src/edit.js +34 -3
  222. package/dist/core/yaml/src/splice-node.d.ts +6 -0
  223. package/dist/core/yaml/src/splice-node.js +10 -0
  224. package/dist/core/yaml/src/splice.js +20 -10
  225. package/dist/testing/integration/src/checks.d.ts +5 -3
  226. package/dist/testing/integration/src/checks.js +31 -3
  227. package/dist/testing/integration/src/load.js +3 -1
  228. package/package.json +9 -2
package/NOTICE CHANGED
@@ -1 +1,5 @@
1
1
  Halonic, Copyright 2026 The Halonic Authors
2
+
3
+ This product includes a copy of the Public Suffix List
4
+ (https://publicsuffix.org/), in packages/core/std/src/public-suffixes.generated.ts,
5
+ under the Mozilla Public License 2.0 (https://mozilla.org/MPL/2.0/).
package/README.md CHANGED
@@ -11,7 +11,7 @@ one:
11
11
  npm install --save-dev --save-exact @halonicjs/testing @halonicjs/adapters vitest
12
12
  ```
13
13
 
14
- ## `@halonicjs/testing/integration`
14
+ ## The conformance suite
15
15
 
16
16
  The suite loads the integration from its permission sheet through the kit's
17
17
  real loader, as Halonic does. It runs it with fake secret values, a replay
@@ -0,0 +1,19 @@
1
+ import type { HttpClient } from "../../../core/ports/src/index.js";
2
+ declare const addressChecking: unique symbol;
3
+ /**
4
+ * An `HttpClient` that checks addresses itself: on every request and every
5
+ * redirect hop it resolves the name, checks each address against the host's
6
+ * class, and connects only to an address it checked (I5 design, HAL-958
7
+ * section 3.8). A permission sheet names hosts only, so whatever sends an
8
+ * integration's requests must be one of these, or a public name that
9
+ * resolves to this computer would get through.
10
+ *
11
+ * The mark is a type, not a value: a plain `fetch` wrapper doesn't fit where
12
+ * this is asked for. Only an address-checking transport, such as the Node
13
+ * one, says it is one. A test that answers without a network asserts it with
14
+ * `as`, and says why.
15
+ */
16
+ export interface AddressCheckingHttpClient extends HttpClient {
17
+ readonly [addressChecking]: true;
18
+ }
19
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,14 @@
1
+ import { type HostClass } from "./address-class.js";
2
+ /**
3
+ * Where an `http` connector's or an integration's address may lead: an
4
+ * address written as numbers to its own class, `localhost` to this computer,
5
+ * and any other name to the internet only. The address as written is what the
6
+ * person saw when they trusted the workspace; a name that resolves to a
7
+ * home-network address is refused, so a DNS answer can't move a request onto
8
+ * the person's own network.
9
+ *
10
+ * @example
11
+ * connectorHostClass(new URL("http://localhost:8080/mcp")); // "loopback"
12
+ * connectorHostClass(new URL("https://notes.acme.test/mcp")); // "public"
13
+ */
14
+ export declare function connectorHostClass(url: URL): HostClass | undefined;
@@ -0,0 +1,34 @@
1
+ import { classifyAddress } from "./address-class.js";
2
+ /**
3
+ * Where an `http` connector's or an integration's address may lead: an
4
+ * address written as numbers to its own class, `localhost` to this computer,
5
+ * and any other name to the internet only. The address as written is what the
6
+ * person saw when they trusted the workspace; a name that resolves to a
7
+ * home-network address is refused, so a DNS answer can't move a request onto
8
+ * the person's own network.
9
+ *
10
+ * @example
11
+ * connectorHostClass(new URL("http://localhost:8080/mcp")); // "loopback"
12
+ * connectorHostClass(new URL("https://notes.acme.test/mcp")); // "public"
13
+ */
14
+ export function connectorHostClass(url) {
15
+ const host = url.hostname.replace(/^\[|\]$/g, "").toLowerCase();
16
+ if (host === "localhost")
17
+ return "loopback";
18
+ const written = addressClassOf(host);
19
+ if (written === undefined)
20
+ return "public";
21
+ return written === "public" || written === "private" || written === "loopback"
22
+ ? written
23
+ : undefined;
24
+ }
25
+ /** The class of `host` when it is an IP address, or `undefined` for a name. */
26
+ function addressClassOf(host) {
27
+ try {
28
+ return classifyAddress(host);
29
+ }
30
+ catch {
31
+ // Not an address but a name: the caller decides.
32
+ return undefined;
33
+ }
34
+ }
@@ -1,2 +1,5 @@
1
+ export type { AddressCheckingHttpClient } from "./address-checking.js";
1
2
  export { type AddressClass, addressAllowedFor, classifyAddress, type HostClass, } from "./address-class.js";
3
+ export { connectorHostClass } from "./connector-host-class.js";
2
4
  export { type IpAddress, parseIpAddress } from "./ip-address.js";
5
+ export { ollamaAnswerTimeoutMs, ollamaTagsUrl, readOllamaTags } from "./ollama-tags.js";
@@ -1,2 +1,4 @@
1
1
  export { addressAllowedFor, classifyAddress, } from "./address-class.js";
2
+ export { connectorHostClass } from "./connector-host-class.js";
2
3
  export { parseIpAddress } from "./ip-address.js";
4
+ export { ollamaAnswerTimeoutMs, ollamaTagsUrl, readOllamaTags } from "./ollama-tags.js";
@@ -0,0 +1,20 @@
1
+ import type { HttpClient } from "../../../core/ports/src/index.js";
2
+ /** Where Ollama lists its downloaded models: its own list, with the names `ollama pull` takes. */
3
+ export declare const ollamaTagsUrl = "http://localhost:11434/api/tags";
4
+ /**
5
+ * How long Ollama may take to send its whole answer. The model screen waits
6
+ * for it, so it is also the longest an Ollama that hangs keeps it waiting.
7
+ */
8
+ export declare const ollamaAnswerTimeoutMs = 3000;
9
+ /**
10
+ * Asks `GET http://localhost:11434/api/tags` and gives Ollama's answer as
11
+ * parsed JSON. It sends no key, refuses redirects, and gives up when the
12
+ * whole answer, body included, hasn't come within {@link ollamaAnswerTimeoutMs}.
13
+ *
14
+ * @throws when Ollama doesn't answer in time, answers with an error status,
15
+ * or sends what isn't JSON
16
+ *
17
+ * @example
18
+ * await detectLocalModels(ollamaDownloadedModelSource(() => readOllamaTags({ fetch })));
19
+ */
20
+ export declare function readOllamaTags(http: HttpClient): Promise<unknown>;
@@ -0,0 +1,38 @@
1
+ // Asks Ollama on this computer which models it has downloaded, for the model
2
+ // detection in `@halonicjs/app`. Here, so the CLI and Studio's services send
3
+ // the same request. Only Ollama, only this computer, at its usual address:
4
+ // v0.1 has no way to name another one.
5
+ //
6
+ // It gives the answer unread: `@halonicjs/app` reads the list. Importing
7
+ // `@halonicjs/app` here would put it in the fenced integration runner's file,
8
+ // which bundles this package and may import nothing but Node's own modules.
9
+ /** Where Ollama lists its downloaded models: its own list, with the names `ollama pull` takes. */
10
+ export const ollamaTagsUrl = "http://localhost:11434/api/tags";
11
+ /**
12
+ * How long Ollama may take to send its whole answer. The model screen waits
13
+ * for it, so it is also the longest an Ollama that hangs keeps it waiting.
14
+ */
15
+ export const ollamaAnswerTimeoutMs = 3_000;
16
+ /**
17
+ * Asks `GET http://localhost:11434/api/tags` and gives Ollama's answer as
18
+ * parsed JSON. It sends no key, refuses redirects, and gives up when the
19
+ * whole answer, body included, hasn't come within {@link ollamaAnswerTimeoutMs}.
20
+ *
21
+ * @throws when Ollama doesn't answer in time, answers with an error status,
22
+ * or sends what isn't JSON
23
+ *
24
+ * @example
25
+ * await detectLocalModels(ollamaDownloadedModelSource(() => readOllamaTags({ fetch })));
26
+ */
27
+ export async function readOllamaTags(http) {
28
+ // One signal for the request and the body, so a body that never ends times out too.
29
+ const response = await http.fetch(ollamaTagsUrl, {
30
+ redirect: "error",
31
+ signal: AbortSignal.timeout(ollamaAnswerTimeoutMs),
32
+ });
33
+ if (!response.ok) {
34
+ await response.body?.cancel();
35
+ throw new Error(`Ollama answered /api/tags with HTTP ${response.status}.`);
36
+ }
37
+ return response.json();
38
+ }
@@ -0,0 +1,40 @@
1
+ import type { AuthPlacement, SecretPlacement, SignInPlacement } from "../../../core/ports/src/index.js";
2
+ import type { IntegrationPolicy } from "./policy.js";
3
+ /** The placement puts a secret, not a sign-in's token. */
4
+ export declare function isSecretPlacement(placement: AuthPlacement): placement is SecretPlacement;
5
+ /** The placement puts a sign-in's access token, not a secret. */
6
+ export declare function isSignInPlacement(placement: AuthPlacement): placement is SignInPlacement;
7
+ /**
8
+ * Copies the placements the integration's code gave into frozen objects of
9
+ * text fields, reading each field once. The kit checks and places only
10
+ * these copies: the code keeps its own objects and could change them, or
11
+ * give a getter, after the check and before the secret is placed. A field
12
+ * that isn't text is refused here, because an object could turn into other
13
+ * text each time it is read.
14
+ */
15
+ export declare function copyPlacements(policy: IntegrationPolicy, placements: readonly unknown[]): readonly AuthPlacement[];
16
+ /**
17
+ * Checks every placement against the sheet before a secret value or a token
18
+ * is read. Give it the copies from {@link copyPlacements}, never the code's
19
+ * own objects. Where a secret or token may go is for
20
+ * {@link checkPlacementHosts}.
21
+ */
22
+ export declare function checkPlacements(policy: IntegrationPolicy, placements: readonly AuthPlacement[]): void;
23
+ /**
24
+ * Checks that every placed secret or token may go to the request's first
25
+ * host, once the URL is parsed. {@link checkPlacements} has already run, so
26
+ * every secret and sign-in is declared.
27
+ */
28
+ export declare function checkPlacementHosts(policy: IntegrationPolicy, placements: readonly AuthPlacement[], url: URL): void;
29
+ /**
30
+ * Puts the secrets and tokens allowed for this hop's host into the headers
31
+ * and the form body. A placement whose secret or token may not go to this
32
+ * hop is left out, which happens after a redirect to another declared host.
33
+ *
34
+ * @param tokens the access tokens read for this hop, by sign-in
35
+ * @returns the form body to send, when a placement wrote into it
36
+ */
37
+ export declare function place(policy: IntegrationPolicy, placements: readonly AuthPlacement[], values: {
38
+ readonly secrets: ReadonlyMap<string, string>;
39
+ readonly tokens: ReadonlyMap<string, string>;
40
+ }, url: URL, headers: Headers, form: URLSearchParams | undefined): URLSearchParams | undefined;
@@ -0,0 +1,102 @@
1
+ import { IntegrationRefusedError } from "@halonicjs/adapters/integration-kit";
2
+ import { checkSecretHost, checkSecretPlacement, placeSecret, quoted } from "./secret-placement.js";
3
+ import { checkSignInPlacement, checkSignInPlacementHost, placeToken } from "./sign-in-placement.js";
4
+ /** The placement puts a secret, not a sign-in's token. */
5
+ export function isSecretPlacement(placement) {
6
+ return "secret" in placement;
7
+ }
8
+ /** The placement puts a sign-in's access token, not a secret. */
9
+ export function isSignInPlacement(placement) {
10
+ return "signIn" in placement;
11
+ }
12
+ /**
13
+ * Copies the placements the integration's code gave into frozen objects of
14
+ * text fields, reading each field once. The kit checks and places only
15
+ * these copies: the code keeps its own objects and could change them, or
16
+ * give a getter, after the check and before the secret is placed. A field
17
+ * that isn't text is refused here, because an object could turn into other
18
+ * text each time it is read.
19
+ */
20
+ export function copyPlacements(policy, placements) {
21
+ return Object.freeze(placements.map((placement) => copyPlacement(policy, placement)));
22
+ }
23
+ function copyPlacement(policy, placement) {
24
+ if (typeof placement !== "object" || placement === null) {
25
+ throw new IntegrationRefusedError("placement-not-in-sheet", `${policy.name}: a placement is not an object with text fields`);
26
+ }
27
+ const given = placement;
28
+ // The types say `secret` and `signIn` never appear together. If both do, nothing is placed, so a `signIn` key can't carry a secret past the secret check.
29
+ if ("secret" in given && "signIn" in given) {
30
+ throw new IntegrationRefusedError("placement-not-in-sheet", `${policy.name}: a placement names both a secret and a sign-in; it must name one`);
31
+ }
32
+ const kind = "signIn" in given ? "signIn" : "secret";
33
+ const owner = kind === "signIn" ? "sign-in" : "secret";
34
+ const name = given[kind];
35
+ const as = given.as;
36
+ if (typeof name !== "string")
37
+ throw notText(policy, `the ${owner}'s name`, owner);
38
+ if (typeof as !== "string")
39
+ throw notText(policy, `the "as" of the ${owner} ${quoted(name)}`, owner);
40
+ const copy = { [kind]: name, as };
41
+ for (const key of ["header", "prefix", "field"]) {
42
+ const value = given[key];
43
+ if (value === undefined)
44
+ continue;
45
+ if (typeof value !== "string")
46
+ throw notText(policy, `the "${key}" of the ${owner} ${quoted(name)}`, owner);
47
+ copy[key] = value;
48
+ }
49
+ // Whether the fields fit together is for `checkPlacements` to say.
50
+ return Object.freeze(copy);
51
+ }
52
+ /** A part of a placement that isn't text, named with the kind of placement it is in. */
53
+ function notText(policy, what, kind) {
54
+ return new IntegrationRefusedError("placement-not-in-sheet", `${policy.name}: ${what} in a ${kind} placement is not text`);
55
+ }
56
+ /**
57
+ * Checks every placement against the sheet before a secret value or a token
58
+ * is read. Give it the copies from {@link copyPlacements}, never the code's
59
+ * own objects. Where a secret or token may go is for
60
+ * {@link checkPlacementHosts}.
61
+ */
62
+ export function checkPlacements(policy, placements) {
63
+ for (const placement of placements) {
64
+ if (isSecretPlacement(placement))
65
+ checkSecretPlacement(policy, placement);
66
+ else
67
+ checkSignInPlacement(policy, placement);
68
+ }
69
+ }
70
+ /**
71
+ * Checks that every placed secret or token may go to the request's first
72
+ * host, once the URL is parsed. {@link checkPlacements} has already run, so
73
+ * every secret and sign-in is declared.
74
+ */
75
+ export function checkPlacementHosts(policy, placements, url) {
76
+ for (const placement of placements) {
77
+ if (isSecretPlacement(placement))
78
+ checkSecretHost(policy, placement, url);
79
+ else
80
+ checkSignInPlacementHost(policy, placement, url);
81
+ }
82
+ }
83
+ /**
84
+ * Puts the secrets and tokens allowed for this hop's host into the headers
85
+ * and the form body. A placement whose secret or token may not go to this
86
+ * hop is left out, which happens after a redirect to another declared host.
87
+ *
88
+ * @param tokens the access tokens read for this hop, by sign-in
89
+ * @returns the form body to send, when a placement wrote into it
90
+ */
91
+ export function place(policy, placements, values, url, headers, form) {
92
+ let body = form;
93
+ for (const placement of placements) {
94
+ if (isSecretPlacement(placement)) {
95
+ body = placeSecret(policy, placement, values.secrets.get(placement.secret), url, headers, body);
96
+ }
97
+ else {
98
+ placeToken(placement, values.tokens.get(placement.signIn), headers);
99
+ }
100
+ }
101
+ return body;
102
+ }
@@ -0,0 +1,28 @@
1
+ import type { SignInTokens } from "../../../core/ports/src/index.js";
2
+ import { type SecretForms, type SecretOnWire } from "./secret-filter.js";
3
+ /**
4
+ * The forms the filter looks for now. Sign-in tokens change while an
5
+ * integration runs, so a filter outside the kit, such as the runner bridge's,
6
+ * asks for them each time it filters instead of keeping the forms it built
7
+ * at the start. The same `SecretForms` object comes back until a value changes.
8
+ */
9
+ export type CurrentSecretForms = () => SecretForms;
10
+ /**
11
+ * The forms of `secrets` and of every value the sign-ins' `filterValues`
12
+ * lists now: the access tokens not yet expired, the refresh token and the
13
+ * client secret. A sign-in value is matched in every form a secret is.
14
+ *
15
+ * @example
16
+ * const current = currentSecretForms([{ value: key }], signIns.tokens);
17
+ * removeSecrets(text, current());
18
+ */
19
+ export declare function currentSecretForms(secrets: readonly SecretOnWire[], signIns?: Pick<SignInTokens, "filterValues">): CurrentSecretForms;
20
+ /**
21
+ * A stream step that removes the current secrets, for the bridge's stderr.
22
+ * When the forms change, a value that began in the bytes held back and ends in
23
+ * the next piece is still found: the held bytes go through the new forms again.
24
+ *
25
+ * @example
26
+ * runner.stderr.pipeThrough(removeCurrentSecretsStream(current))
27
+ */
28
+ export declare function removeCurrentSecretsStream(current: CurrentSecretForms): TransformStream<Uint8Array, Uint8Array>;
@@ -0,0 +1,60 @@
1
+ import { SecretRemover, secretForms, } from "./secret-filter.js";
2
+ /**
3
+ * The forms of `secrets` and of every value the sign-ins' `filterValues`
4
+ * lists now: the access tokens not yet expired, the refresh token and the
5
+ * client secret. A sign-in value is matched in every form a secret is.
6
+ *
7
+ * @example
8
+ * const current = currentSecretForms([{ value: key }], signIns.tokens);
9
+ * removeSecrets(text, current());
10
+ */
11
+ export function currentSecretForms(secrets, signIns) {
12
+ const fixed = secretForms(secrets);
13
+ if (signIns === undefined) {
14
+ return () => fixed;
15
+ }
16
+ let listed = [];
17
+ let forms = fixed;
18
+ return () => {
19
+ const values = signIns.filterValues();
20
+ if (!sameValues(values, listed)) {
21
+ listed = [...values];
22
+ forms = secretForms([...secrets, ...values.map((value) => ({ value }))]);
23
+ }
24
+ return forms;
25
+ };
26
+ }
27
+ function sameValues(a, b) {
28
+ return a.length === b.length && a.every((value, index) => value === b[index]);
29
+ }
30
+ /**
31
+ * A stream step that removes the current secrets, for the bridge's stderr.
32
+ * When the forms change, a value that began in the bytes held back and ends in
33
+ * the next piece is still found: the held bytes go through the new forms again.
34
+ *
35
+ * @example
36
+ * runner.stderr.pipeThrough(removeCurrentSecretsStream(current))
37
+ */
38
+ export function removeCurrentSecretsStream(current) {
39
+ let forms = current();
40
+ let remover = new SecretRemover(forms);
41
+ return new TransformStream({
42
+ transform(piece, controller) {
43
+ const now = current();
44
+ if (now !== forms) {
45
+ const held = remover.flush();
46
+ forms = now;
47
+ remover = new SecretRemover(now);
48
+ enqueueIfAny(controller, remover.push(held));
49
+ }
50
+ enqueueIfAny(controller, remover.push(piece));
51
+ },
52
+ flush(controller) {
53
+ enqueueIfAny(controller, remover.flush());
54
+ },
55
+ });
56
+ }
57
+ function enqueueIfAny(controller, bytes) {
58
+ if (bytes.length > 0)
59
+ controller.enqueue(bytes);
60
+ }
@@ -2,7 +2,8 @@ import type { IntegrationSheet } from "../../../core/format/src/integration/inde
2
2
  import { type Integration } from "../../../core/ports/src/index.js";
3
3
  import type { LoadProblem } from "./load-problem.js";
4
4
  /**
5
- * Where the integration's code differs from its permission sheet: the kit
5
+ * Where the integration's code differs from its permission sheet, or the sheet
6
+ * needs a newer kit than this Halonic offers: the kit
6
7
  * version, the name, the version, and each tool's text, `risk` and
7
8
  * `untrusted`. The user approves the sheet, so the code must be exactly what
8
9
  * it says. Empty when they match. Only what the code declares is read, so a
@@ -1,6 +1,7 @@
1
1
  import { integrationVersion } from "../../../core/ports/src/index.js";
2
2
  /**
3
- * Where the integration's code differs from its permission sheet: the kit
3
+ * Where the integration's code differs from its permission sheet, or the sheet
4
+ * needs a newer kit than this Halonic offers: the kit
4
5
  * version, the name, the version, and each tool's text, `risk` and
5
6
  * `untrusted`. The user approves the sheet, so the code must be exactly what
6
7
  * it says. Empty when they match. Only what the code declares is read, so a
@@ -12,8 +13,8 @@ import { integrationVersion } from "../../../core/ports/src/index.js";
12
13
  export function declarationProblems(sheet, integration) {
13
14
  const problems = [];
14
15
  const add = (code, path, message) => problems.push({ code, path, message: `${sheet.id}: ${message}` });
15
- if (sheet.kit !== integrationVersion) {
16
- add("kit-version", ["kit"], `built against kit ${sheet.kit}, but this Halonic offers kit ${integrationVersion}`);
16
+ if (sheet.kit > integrationVersion) {
17
+ add("kit-version", ["kit"], `this integration needs a newer version of Halonic (it is built against kit ${sheet.kit}, and this Halonic offers kit ${integrationVersion})`);
17
18
  }
18
19
  if (integration.name !== sheet.id) {
19
20
  add("name-differs", ["id"], `the code is named "${integration.name}"`);
@@ -1,4 +1,4 @@
1
- import type { HttpClient, IntegrationHost, Secrets, TokenStore } from "../../../core/ports/src/index.js";
1
+ import type { HttpClient, IntegrationHost, Secrets, SignInTokens, TokenStore } from "../../../core/ports/src/index.js";
2
2
  import { type RequestLimits } from "./limited-http.js";
3
3
  import type { IntegrationPolicy } from "./policy.js";
4
4
  import { RequestLog } from "./request-log.js";
@@ -8,6 +8,12 @@ export interface IntegrationHostOptions {
8
8
  readonly transport: HttpClient;
9
9
  readonly secrets: Secrets;
10
10
  readonly tokens: TokenStore;
11
+ /**
12
+ * Where the kit gets the access tokens of the sheet's sign-ins, and tells
13
+ * about a 401. Without it, a request that places a token is refused as
14
+ * `sign-in-needed`.
15
+ */
16
+ readonly signInTokens?: SignInTokens;
11
17
  readonly settings?: Readonly<Record<string, unknown>>;
12
18
  readonly limits?: RequestLimits;
13
19
  readonly now?: () => number;
@@ -17,6 +17,7 @@ export function createIntegrationHost(options) {
17
17
  transport: options.transport,
18
18
  secrets: options.secrets,
19
19
  log,
20
+ ...(options.signInTokens ? { signInTokens: options.signInTokens } : {}),
20
21
  ...(options.limits ? { limits: options.limits } : {}),
21
22
  ...(options.now ? { now: options.now } : {}),
22
23
  });
@@ -1,14 +1,17 @@
1
+ export type { AddressCheckingHttpClient } from "../../http-kit/src/index.js";
2
+ export { type CurrentSecretForms, currentSecretForms, removeCurrentSecretsStream, } from "./current-secret-forms.js";
1
3
  export { declarationProblems } from "./declaration.js";
2
4
  export { type CreatedIntegrationHost, createIntegrationHost, type IntegrationHostOptions, } from "./host.js";
3
5
  export { IntegrationRefusedError, IntegrationTimeoutError, type RefusalCode, } from "@halonicjs/adapters/integration-kit";
4
6
  export { leakAttemptCodes } from "./leak-attempt.js";
5
7
  export { createLimitedHttpClient, type LimitedHttpOptions, type RequestLimits, } from "./limited-http.js";
6
8
  export type { LoadProblem } from "./load-problem.js";
7
- export { type IntegrationSource, type LoadedIntegration, type LoadIntegrationOptions, loadIntegration, type PreparedIntegration, type PrepareIntegrationOptions, prepareIntegration, providerChoices, type WorkspaceChoices, } from "./loader.js";
9
+ export { type IntegrationSource, type LoadedIntegration, type LoadIntegrationOptions, loadIntegration, type PreparedIntegration, type PrepareIntegrationOptions, prepareIntegration, providerChoices, } from "./loader.js";
8
10
  export { pluginLoadProblems } from "./plugin-load.js";
9
- export { allowedUrl, type DeclaredPlacement, type DeclaredSecret, type IntegrationPolicy, namePattern, } from "./policy.js";
11
+ export { allowedUrl, type DeclaredPlacement, type DeclaredSecret, type DeclaredSignIn, type DeclaredSignInPlacement, type IntegrationPolicy, namePattern, } from "./policy.js";
10
12
  export { maxRequestBodyBytes } from "./request-body.js";
11
13
  export { RequestLog, type RequestLogEntry } from "./request-log.js";
12
14
  export { scopedTokens, storedTokenName } from "./scoped-tokens.js";
13
15
  export { removeSecrets, removeSecretsFromHeaders, removeSecretsStream, type SecretForms, type SecretOnWire, SecretRemover, secretForms, secretRemoved, } from "./secret-filter.js";
14
16
  export { clampWaitMs, integrationWait } from "./wait.js";
17
+ export { choiceSettings, chosenSecrets, type WorkspaceChoices } from "./workspace-choices.js";
@@ -6,6 +6,7 @@
6
6
  // outside the conformance suite's bundle and points it at the published kit;
7
7
  // it fails when host code imports a file inside the entry's folder instead
8
8
  // of the entry itself. Internal code imports by relative path.
9
+ export { currentSecretForms, removeCurrentSecretsStream, } from "./current-secret-forms.js";
9
10
  export { declarationProblems } from "./declaration.js";
10
11
  export { createIntegrationHost, } from "./host.js";
11
12
  export { IntegrationRefusedError, IntegrationTimeoutError, } from "@halonicjs/adapters/integration-kit";
@@ -19,3 +20,4 @@ export { RequestLog } from "./request-log.js";
19
20
  export { scopedTokens, storedTokenName } from "./scoped-tokens.js";
20
21
  export { removeSecrets, removeSecretsFromHeaders, removeSecretsStream, SecretRemover, secretForms, secretRemoved, } from "./secret-filter.js";
21
22
  export { clampWaitMs, integrationWait } from "./wait.js";
23
+ export { choiceSettings, chosenSecrets } from "./workspace-choices.js";
@@ -1,8 +1,10 @@
1
1
  import type { RefusalCode } from "@halonicjs/adapters/integration-kit";
2
2
  /**
3
3
  * The refusal codes that mean the integration tried to get a secret out:
4
- * it carried a secret value in its own request, or it asked the kit to
5
- * place a secret somewhere its permission sheet doesn't say. A connector
4
+ * it carried a secret value in its own request, it asked the kit to
5
+ * place a secret or a sign-in's token somewhere its permission sheet doesn't
6
+ * say, or it asked for a client secret, which only Halonic's sign-in code
7
+ * may send. A connector
6
8
  * that gets one of these should be paused, not just shown the error. Every
7
9
  * other code is an ordinary mistake, such as a host the sheet doesn't list
8
10
  * or a body that is too large, or comes from the server, such as
@@ -1,7 +1,9 @@
1
1
  /**
2
2
  * The refusal codes that mean the integration tried to get a secret out:
3
- * it carried a secret value in its own request, or it asked the kit to
4
- * place a secret somewhere its permission sheet doesn't say. A connector
3
+ * it carried a secret value in its own request, it asked the kit to
4
+ * place a secret or a sign-in's token somewhere its permission sheet doesn't
5
+ * say, or it asked for a client secret, which only Halonic's sign-in code
6
+ * may send. A connector
5
7
  * that gets one of these should be paused, not just shown the error. Every
6
8
  * other code is an ordinary mistake, such as a host the sheet doesn't list
7
9
  * or a body that is too large, or comes from the server, such as
@@ -13,4 +15,5 @@
13
15
  export const leakAttemptCodes = Object.freeze([
14
16
  "secret-in-request",
15
17
  "placement-not-in-sheet",
18
+ "secret-sign-in-only",
16
19
  ]);
@@ -1,4 +1,4 @@
1
- import type { HttpClient, IntegrationHttpClient, Secrets } from "../../../core/ports/src/index.js";
1
+ import type { HttpClient, IntegrationHttpClient, Secrets, SignInTokens } from "../../../core/ports/src/index.js";
2
2
  import { type IntegrationPolicy } from "./policy.js";
3
3
  import type { RequestLog } from "./request-log.js";
4
4
  /**
@@ -31,6 +31,12 @@ export interface LimitedHttpOptions {
31
31
  readonly transport: HttpClient;
32
32
  /** Where the kit reads the values of the secrets it places. */
33
33
  readonly secrets: Secrets;
34
+ /**
35
+ * Where the kit gets the access token of a sign-in it places, and what it
36
+ * tells when a server answers 401. Without it, a request that places a
37
+ * token is refused as `sign-in-needed`.
38
+ */
39
+ readonly signInTokens?: SignInTokens;
34
40
  readonly log: RequestLog;
35
41
  readonly limits?: RequestLimits;
36
42
  /** Milliseconds for the request log's timings. Default `Date.now`. */