@try-works/dsh-model-as-tool 0.1.3 → 0.3.6

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 (257) hide show
  1. package/bin/dsh-tool-mode-credentials.mjs +20 -0
  2. package/bin/dsh-tool-mode.mjs +202 -0
  3. package/catalog/desert-ant-models.json +693 -693
  4. package/client/client.model-tools.js +592 -0
  5. package/client/index.js +1679 -0
  6. package/lib/adapters/index.d.ts.map +1 -1
  7. package/lib/adapters/index.js +4 -4
  8. package/lib/bindings.d.ts.map +1 -1
  9. package/lib/bindings.js +26 -25
  10. package/lib/capability.d.ts.map +1 -1
  11. package/lib/capability.js +17 -0
  12. package/lib/capture-path.d.ts +97 -0
  13. package/lib/capture-path.d.ts.map +1 -0
  14. package/lib/capture-path.js +152 -0
  15. package/lib/diagnostics.d.ts +166 -0
  16. package/lib/diagnostics.d.ts.map +1 -0
  17. package/lib/diagnostics.js +135 -0
  18. package/lib/extension-dependencies.d.ts +197 -0
  19. package/lib/extension-dependencies.d.ts.map +1 -0
  20. package/lib/extension-dependencies.js +369 -0
  21. package/lib/extension-dispatch.d.ts +117 -0
  22. package/lib/extension-dispatch.d.ts.map +1 -0
  23. package/lib/extension-dispatch.js +124 -0
  24. package/lib/extension-registrar.d.ts +100 -0
  25. package/lib/extension-registrar.d.ts.map +1 -0
  26. package/lib/extension-registrar.js +134 -0
  27. package/lib/extensions-api.d.ts +217 -0
  28. package/lib/extensions-api.d.ts.map +1 -0
  29. package/lib/extensions-api.js +17 -0
  30. package/lib/extensions-remote.d.ts +54 -0
  31. package/lib/extensions-remote.d.ts.map +1 -0
  32. package/lib/extensions-remote.js +66 -0
  33. package/lib/extensions-service.d.ts +334 -0
  34. package/lib/extensions-service.d.ts.map +1 -0
  35. package/lib/extensions-service.js +1351 -0
  36. package/lib/harness-llm.d.ts +138 -0
  37. package/lib/harness-llm.d.ts.map +1 -0
  38. package/lib/harness-llm.js +218 -0
  39. package/lib/harness-serving.d.ts +95 -0
  40. package/lib/harness-serving.d.ts.map +1 -0
  41. package/lib/harness-serving.js +157 -0
  42. package/lib/headless.d.ts +97 -0
  43. package/lib/headless.d.ts.map +1 -0
  44. package/lib/headless.js +349 -0
  45. package/lib/http-acquisition.d.ts +27 -0
  46. package/lib/http-acquisition.d.ts.map +1 -0
  47. package/lib/http-acquisition.js +136 -0
  48. package/lib/index.d.ts +250 -7
  49. package/lib/index.d.ts.map +1 -1
  50. package/lib/index.js +2625 -70
  51. package/lib/invocation-accounting.d.ts +169 -0
  52. package/lib/invocation-accounting.d.ts.map +1 -0
  53. package/lib/invocation-accounting.js +148 -0
  54. package/lib/legacy-migration.d.ts +95 -0
  55. package/lib/legacy-migration.d.ts.map +1 -0
  56. package/lib/legacy-migration.js +429 -0
  57. package/lib/managed-workers.d.ts +151 -0
  58. package/lib/managed-workers.d.ts.map +1 -0
  59. package/lib/managed-workers.js +249 -0
  60. package/lib/mcp/client-grant.d.ts +74 -0
  61. package/lib/mcp/client-grant.d.ts.map +1 -0
  62. package/lib/mcp/client-grant.js +60 -0
  63. package/lib/mcp/credential-cli.d.ts +38 -0
  64. package/lib/mcp/credential-cli.d.ts.map +1 -0
  65. package/lib/mcp/credential-cli.js +148 -0
  66. package/lib/mcp/credential-store.d.ts +143 -0
  67. package/lib/mcp/credential-store.d.ts.map +1 -0
  68. package/lib/mcp/credential-store.js +454 -0
  69. package/lib/mcp/host-binding.d.ts +25 -0
  70. package/lib/mcp/host-binding.d.ts.map +1 -1
  71. package/lib/mcp/host-binding.js +107 -14
  72. package/lib/mcp/http.d.ts +68 -18
  73. package/lib/mcp/http.d.ts.map +1 -1
  74. package/lib/mcp/http.js +390 -62
  75. package/lib/mcp/oauth.d.ts +149 -0
  76. package/lib/mcp/oauth.d.ts.map +1 -0
  77. package/lib/mcp/oauth.js +396 -0
  78. package/lib/mcp/protocol.d.ts +46 -7
  79. package/lib/mcp/protocol.d.ts.map +1 -1
  80. package/lib/mcp/protocol.js +63 -16
  81. package/lib/mcp/rate-limit.d.ts +68 -0
  82. package/lib/mcp/rate-limit.d.ts.map +1 -0
  83. package/lib/mcp/rate-limit.js +114 -0
  84. package/lib/mcp/sdk-v2.d.ts +17 -0
  85. package/lib/mcp/sdk-v2.d.ts.map +1 -0
  86. package/lib/mcp/sdk-v2.js +181 -0
  87. package/lib/mcp/server.d.ts +11 -1
  88. package/lib/mcp/server.d.ts.map +1 -1
  89. package/lib/mcp/server.js +80 -13
  90. package/lib/mcp/stdio.d.ts.map +1 -1
  91. package/lib/mcp/stdio.js +9 -1
  92. package/lib/mcp/subscriptions.d.ts +43 -1
  93. package/lib/mcp/subscriptions.d.ts.map +1 -1
  94. package/lib/mcp/subscriptions.js +90 -9
  95. package/lib/model-qualification.d.ts +192 -0
  96. package/lib/model-qualification.d.ts.map +1 -0
  97. package/lib/model-qualification.js +178 -0
  98. package/lib/planning.d.ts +246 -0
  99. package/lib/planning.d.ts.map +1 -0
  100. package/lib/planning.js +457 -0
  101. package/lib/prepared-assets.d.ts +178 -0
  102. package/lib/prepared-assets.d.ts.map +1 -0
  103. package/lib/prepared-assets.js +286 -0
  104. package/lib/provider-bridge.d.ts +37 -0
  105. package/lib/provider-bridge.d.ts.map +1 -1
  106. package/lib/provider-bridge.js +189 -12
  107. package/lib/ptc-authority.d.ts +140 -0
  108. package/lib/ptc-authority.d.ts.map +1 -0
  109. package/lib/ptc-authority.js +216 -0
  110. package/lib/ptc-runtime.d.ts +156 -0
  111. package/lib/ptc-runtime.d.ts.map +1 -0
  112. package/lib/ptc-runtime.js +191 -0
  113. package/lib/publication.d.ts +2 -1
  114. package/lib/publication.d.ts.map +1 -1
  115. package/lib/publication.js +13 -5
  116. package/lib/receipt.d.ts.map +1 -1
  117. package/lib/receipt.js +8 -0
  118. package/lib/title-proposal.d.ts +194 -0
  119. package/lib/title-proposal.d.ts.map +1 -0
  120. package/lib/title-proposal.js +244 -0
  121. package/lib/tool-mode-run.d.ts +235 -0
  122. package/lib/tool-mode-run.d.ts.map +1 -0
  123. package/lib/tool-mode-run.js +283 -0
  124. package/lib/types.d.ts +3 -1
  125. package/lib/types.d.ts.map +1 -1
  126. package/lib/update-surface.d.ts +79 -0
  127. package/lib/update-surface.d.ts.map +1 -0
  128. package/lib/update-surface.js +224 -0
  129. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/standard.d.ts +38 -0
  130. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/standard.d.ts.map +1 -0
  131. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/standard.js +445 -0
  132. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-embed.d.ts +14 -0
  133. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-embed.d.ts.map +1 -0
  134. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-embed.js +63 -0
  135. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-rerank.d.ts +14 -0
  136. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-rerank.d.ts.map +1 -0
  137. package/node_modules/@try-works/tool-mode-contracts/lib/contracts/text-rerank.js +76 -0
  138. package/node_modules/@try-works/tool-mode-contracts/lib/dsh.d.ts.map +1 -1
  139. package/node_modules/@try-works/tool-mode-contracts/lib/dsh.js +69 -55
  140. package/node_modules/@try-works/tool-mode-contracts/lib/index.d.ts +4 -1
  141. package/node_modules/@try-works/tool-mode-contracts/lib/index.d.ts.map +1 -1
  142. package/node_modules/@try-works/tool-mode-contracts/lib/index.js +26 -2
  143. package/node_modules/@try-works/tool-mode-contracts/lib/registry.d.ts +28 -2
  144. package/node_modules/@try-works/tool-mode-contracts/lib/registry.d.ts.map +1 -1
  145. package/node_modules/@try-works/tool-mode-contracts/lib/registry.js +93 -10
  146. package/node_modules/@try-works/tool-mode-contracts/package.json +0 -1
  147. package/node_modules/@try-works/tool-mode-extension-sdk/bin/dsh-tool-mode.mjs +20 -0
  148. package/node_modules/@try-works/tool-mode-extension-sdk/lib/cli.d.ts +80 -0
  149. package/node_modules/@try-works/tool-mode-extension-sdk/lib/cli.d.ts.map +1 -0
  150. package/node_modules/@try-works/tool-mode-extension-sdk/lib/cli.js +533 -0
  151. package/node_modules/@try-works/tool-mode-extension-sdk/lib/declarative-recipes.d.ts +83 -0
  152. package/node_modules/@try-works/tool-mode-extension-sdk/lib/declarative-recipes.d.ts.map +1 -0
  153. package/node_modules/@try-works/tool-mode-extension-sdk/lib/declarative-recipes.js +125 -0
  154. package/node_modules/@try-works/tool-mode-extension-sdk/lib/discovery.d.ts +70 -0
  155. package/node_modules/@try-works/tool-mode-extension-sdk/lib/discovery.d.ts.map +1 -0
  156. package/node_modules/@try-works/tool-mode-extension-sdk/lib/discovery.js +201 -0
  157. package/node_modules/@try-works/tool-mode-extension-sdk/lib/errors.d.ts +57 -0
  158. package/node_modules/@try-works/tool-mode-extension-sdk/lib/errors.d.ts.map +1 -0
  159. package/node_modules/@try-works/tool-mode-extension-sdk/lib/errors.js +83 -0
  160. package/node_modules/@try-works/tool-mode-extension-sdk/lib/index.d.ts +31 -0
  161. package/node_modules/@try-works/tool-mode-extension-sdk/lib/index.d.ts.map +1 -0
  162. package/node_modules/@try-works/tool-mode-extension-sdk/lib/index.js +31 -0
  163. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/archive.d.ts +86 -0
  164. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/archive.d.ts.map +1 -0
  165. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/archive.js +185 -0
  166. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/dependencies.d.ts +126 -0
  167. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/dependencies.d.ts.map +1 -0
  168. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/dependencies.js +297 -0
  169. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/lifecycle.d.ts +216 -0
  170. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/lifecycle.d.ts.map +1 -0
  171. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/lifecycle.js +800 -0
  172. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/migration.d.ts +210 -0
  173. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/migration.d.ts.map +1 -0
  174. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/migration.js +368 -0
  175. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/runtime-link.d.ts +63 -0
  176. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/runtime-link.d.ts.map +1 -0
  177. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/runtime-link.js +149 -0
  178. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/source-directory.d.ts +35 -0
  179. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/source-directory.d.ts.map +1 -0
  180. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/source-directory.js +179 -0
  181. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/staged.d.ts +179 -0
  182. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/staged.d.ts.map +1 -0
  183. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/staged.js +235 -0
  184. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/store.d.ts +367 -0
  185. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/store.d.ts.map +1 -0
  186. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/store.js +807 -0
  187. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.d.ts +185 -0
  188. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.d.ts.map +1 -0
  189. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.js +504 -0
  190. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.d.ts +17 -0
  191. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.d.ts.map +1 -0
  192. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.js +80 -0
  193. package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.d.ts +52 -0
  194. package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.d.ts.map +1 -0
  195. package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.js +102 -0
  196. package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.d.ts +171 -0
  197. package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.d.ts.map +1 -0
  198. package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.js +271 -0
  199. package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.d.ts +242 -0
  200. package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.d.ts.map +1 -0
  201. package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.js +58 -0
  202. package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.d.ts +118 -0
  203. package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.d.ts.map +1 -0
  204. package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.js +113 -0
  205. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.d.ts +2 -0
  206. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.d.ts.map +1 -0
  207. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.js +351 -0
  208. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.d.ts +150 -0
  209. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.d.ts.map +1 -0
  210. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.js +670 -0
  211. package/node_modules/@try-works/tool-mode-extension-sdk/package.json +53 -0
  212. package/node_modules/@try-works/tool-mode-extension-sdk/schema/extension-manifest-1.1.0.schema.json +253 -0
  213. package/node_modules/@try-works/tool-mode-recipes/bin/tool-mode-recipe.mjs +15 -0
  214. package/node_modules/@try-works/tool-mode-recipes/lib/broker.d.ts +427 -0
  215. package/node_modules/@try-works/tool-mode-recipes/lib/broker.d.ts.map +1 -0
  216. package/node_modules/@try-works/tool-mode-recipes/lib/broker.js +592 -0
  217. package/node_modules/@try-works/tool-mode-recipes/lib/cli.d.ts +60 -0
  218. package/node_modules/@try-works/tool-mode-recipes/lib/cli.d.ts.map +1 -0
  219. package/node_modules/@try-works/tool-mode-recipes/lib/cli.js +936 -0
  220. package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.d.ts +237 -0
  221. package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.d.ts.map +1 -0
  222. package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.js +200 -0
  223. package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.d.ts +85 -0
  224. package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.d.ts.map +1 -0
  225. package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.js +176 -0
  226. package/node_modules/@try-works/tool-mode-recipes/lib/images.d.ts +105 -0
  227. package/node_modules/@try-works/tool-mode-recipes/lib/images.d.ts.map +1 -0
  228. package/node_modules/@try-works/tool-mode-recipes/lib/images.js +129 -0
  229. package/node_modules/@try-works/tool-mode-recipes/lib/index.d.ts +25 -0
  230. package/node_modules/@try-works/tool-mode-recipes/lib/index.d.ts.map +1 -0
  231. package/node_modules/@try-works/tool-mode-recipes/lib/index.js +25 -0
  232. package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.d.ts +325 -0
  233. package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.d.ts.map +1 -0
  234. package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.js +1310 -0
  235. package/node_modules/@try-works/tool-mode-recipes/lib/templates.d.ts +51 -0
  236. package/node_modules/@try-works/tool-mode-recipes/lib/templates.d.ts.map +1 -0
  237. package/node_modules/@try-works/tool-mode-recipes/lib/templates.js +310 -0
  238. package/node_modules/@try-works/tool-mode-recipes/lib/titles.d.ts +227 -0
  239. package/node_modules/@try-works/tool-mode-recipes/lib/titles.d.ts.map +1 -0
  240. package/node_modules/@try-works/tool-mode-recipes/lib/titles.js +407 -0
  241. package/node_modules/@try-works/tool-mode-recipes/package.json +56 -0
  242. package/node_modules/@try-works/tool-mode-recipes/recipes/describe-image.json +38 -0
  243. package/node_modules/@try-works/tool-mode-recipes/recipes/text-title.json +45 -0
  244. package/node_modules/@try-works/tool-mode-recipes/schema/harness-model-recipe.schema.json +273 -0
  245. package/package.json +43 -15
  246. package/remote/spec.mjs +439 -0
  247. package/remote/typert.host.mjs +14 -0
  248. package/remote/typert.remote-client.mjs +16 -0
  249. package/lib/adapters/tongue.d.ts +0 -31
  250. package/lib/adapters/tongue.d.ts.map +0 -1
  251. package/lib/adapters/tongue.js +0 -93
  252. package/lib/adapters/voz.d.ts +0 -28
  253. package/lib/adapters/voz.d.ts.map +0 -1
  254. package/lib/adapters/voz.js +0 -102
  255. /package/{lib → node_modules/@try-works/tool-mode-extension-sdk/lib}/licensing.d.ts +0 -0
  256. /package/{lib → node_modules/@try-works/tool-mode-extension-sdk/lib}/licensing.d.ts.map +0 -0
  257. /package/{lib → node_modules/@try-works/tool-mode-extension-sdk/lib}/licensing.js +0 -0
@@ -0,0 +1,429 @@
1
+ /**
2
+ * The startup hook that migrates a legacy model-id era `state.json` into the
3
+ * versioned world (BASE-09, BASE-10), ONCE per profile — as a REAL
4
+ * transaction with crash recovery, not a read-then-overwrite.
5
+ *
6
+ * Before this module the migration table existed only as an SDK library with
7
+ * tests: nothing in the host's production startup ever ran it, so a real
8
+ * upgrade kept reading the old-world document forever. This module is the
9
+ * production caller. Its guarantees:
10
+ *
11
+ * - ONCE-ANCHOR + COMMIT: a non-secret sidecar marker
12
+ * (`<stateFile>.migrated.json`) is the commit record, written ATOMICALLY
13
+ * (temp + fsync + rename) as the LAST step of the transaction. The host's
14
+ * own state document keeps its exact shape — the store's writes are
15
+ * untouched and no parallel format is written. A marker is VALIDATED on
16
+ * every read (parse + exact version + list shape): a corrupt or
17
+ * foreign-version marker FAILS CLOSED instead of silently counting the
18
+ * profile as migrated;
19
+ * - IMMUTABLE JOURNAL: before ANY mutation, the original legacy document is
20
+ * journaled to `<stateFile>.legacy-backup.json` with EXCLUSIVE creation
21
+ * (`wx`). The journal is the legacy INPUT for every recovery. Its
22
+ * first-write-wins behavior is guaranteed BY THE TRANSACTION LOCK (the
23
+ * exists-check before the rename is advisory, not a lock);
24
+ * - RECOVERY: a crash between the host write and the marker leaves a journal
25
+ * WITHOUT a committed marker. The next boot detects that state and re-runs
26
+ * the transaction FROM THE VALIDATED JOURNAL — never from the already-
27
+ * rewritten state file, which has lost the staged enables, provider picks
28
+ * and prepared-asset facts. The host write MERGES with the current
29
+ * document (current enables are operator-era facts and are preserved;
30
+ * legacy disables are added), so an operator change after the crash is
31
+ * never discarded. A corrupt journal with no marker FAILS CLOSED;
32
+ * - TRANSACTION LOCK: the whole transaction runs under an exclusive lock
33
+ * file with an ownership token and pid. A stale lock is NEVER taken over
34
+ * automatically — the read-then-remove sequence is not atomic and two
35
+ * concurrent reapers could delete a successor's fresh lock — so a held lock
36
+ * FAILS CLOSED at the deadline and the operator removes it deliberately;
37
+ * release removes only a token-owned lock (the same discipline as the
38
+ * credential store);
39
+ * - the SDK profile half runs THROUGH the SDK's own
40
+ * `migrateLegacyProfileState` (its lock, idempotence, version gate) BEFORE
41
+ * the host document is written;
42
+ * - DISABLED legacy choices are preserved — ALL of them, mapped or not: an
43
+ * unmapped disabled id that vanished from the host state would let a later
44
+ * package restore silently enable what the operator turned off. Unresolved
45
+ * ids are REPORTED separately, never enabled;
46
+ * - legacy ENABLES are STAGED, never granted (BASE-10: a legacy enable is
47
+ * not consent to install, activate or prepare third-party code);
48
+ * - every persisted artifact (marker, journal, lock) is NON-SECRET by
49
+ * construction: model ids, provider identifiers and counts, never a secret.
50
+ *
51
+ * @module @try-works/dsh-model-as-tool/legacy-migration
52
+ */
53
+ import { closeSync, existsSync, fsyncSync, mkdirSync, openSync, readFileSync, renameSync, rmSync, writeFileSync, } from 'node:fs';
54
+ import { dirname } from 'node:path';
55
+ import { randomBytes } from 'node:crypto';
56
+ import { applyLegacyChoices, ExtensionStore, parseLegacyModelState, } from '@try-works/tool-mode-extension-sdk';
57
+ import { StateError } from "./state.js";
58
+ /** The marker version this host writes; equality, never a lower bound. */
59
+ export const MIGRATION_MARKER_VERSION = 1;
60
+ /** The marker path for one state file. */
61
+ export function migrationMarkerPath(stateFile) {
62
+ return `${stateFile}.migrated.json`;
63
+ }
64
+ /** The backup path for one state file. */
65
+ export function legacyBackupPath(stateFile) {
66
+ return `${stateFile}.legacy-backup.json`;
67
+ }
68
+ /** The transaction lock path for one state file. */
69
+ export function migrationLockPath(stateFile) {
70
+ return `${stateFile}.migration.lock`;
71
+ }
72
+ /** Unique ids in first-seen order. */
73
+ function unique(ids) {
74
+ return [...new Set(ids)];
75
+ }
76
+ /** A real blocking sleep, without burning the CPU. */
77
+ function sleep(ms) {
78
+ Atomics.wait(new Int32Array(new SharedArrayBuffer(4)), 0, 0, ms);
79
+ }
80
+ /**
81
+ * The transaction lock: exclusive creation, ownership token + pid, bounded
82
+ * retries, and release removes ONLY a token-owned lock. There is NO automatic
83
+ * stale takeover: two concurrent reapers could each read a stale record and
84
+ * remove a SUCCESSOR's fresh lock between its create and its next open — the
85
+ * read→rm sequence is not atomic. A lock whose holder cannot be proven live
86
+ * therefore FAILS CLOSED at the deadline and the operator removes the lock
87
+ * file deliberately.
88
+ */
89
+ function acquireMigrationLock(stateFile) {
90
+ const lockPath = migrationLockPath(stateFile);
91
+ const token = randomBytes(16).toString('hex');
92
+ const deadline = Date.now() + 10_000;
93
+ for (;;) {
94
+ try {
95
+ const fd = openSync(lockPath, 'wx');
96
+ try {
97
+ writeFileSync(fd, JSON.stringify({ token, pid: process.pid, at: Date.now() }), 'utf8');
98
+ fsyncSync(fd);
99
+ }
100
+ finally {
101
+ closeSync(fd);
102
+ }
103
+ return () => {
104
+ let held;
105
+ try {
106
+ held = JSON.parse(readFileSync(lockPath, 'utf8'));
107
+ }
108
+ catch {
109
+ return;
110
+ }
111
+ if (held === undefined || held.token !== token)
112
+ return;
113
+ try {
114
+ rmSync(lockPath, { force: true });
115
+ }
116
+ catch {
117
+ // Already gone.
118
+ }
119
+ };
120
+ }
121
+ catch (error) {
122
+ if (error.code !== 'EEXIST')
123
+ throw error;
124
+ if (Date.now() > deadline) {
125
+ throw new StateError('the legacy migration is locked by another writer; the transaction was not attempted '
126
+ + `(remove ${lockPath} only after confirming no writer holds it)`);
127
+ }
128
+ sleep(25);
129
+ }
130
+ }
131
+ }
132
+ /** Read and VALIDATE the marker; a corrupt or foreign marker fails closed. */
133
+ function readMarker(stateFile) {
134
+ let text;
135
+ try {
136
+ text = readFileSync(migrationMarkerPath(stateFile), 'utf8');
137
+ }
138
+ catch (error) {
139
+ if (error.code === 'ENOENT')
140
+ return undefined;
141
+ throw new StateError(`cannot read the migration marker ${migrationMarkerPath(stateFile)}: `
142
+ + `${error instanceof Error ? error.message : String(error)}`);
143
+ }
144
+ let parsed;
145
+ try {
146
+ parsed = JSON.parse(text);
147
+ }
148
+ catch (error) {
149
+ throw new StateError(`the migration marker ${migrationMarkerPath(stateFile)} is not valid JSON and will not be trusted: `
150
+ + `${error instanceof Error ? error.message : String(error)}`);
151
+ }
152
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
153
+ throw new StateError(`the migration marker ${migrationMarkerPath(stateFile)} is not a JSON object`);
154
+ }
155
+ const marker = parsed;
156
+ if (marker.hostStateVersion !== MIGRATION_MARKER_VERSION) {
157
+ throw new StateError(`the migration marker ${migrationMarkerPath(stateFile)} was written by a different era `
158
+ + `(hostStateVersion ${JSON.stringify(marker.hostStateVersion)}); this host writes ${MIGRATION_MARKER_VERSION}`);
159
+ }
160
+ // The FULL shape is validated: a marker that parses but does not say what a
161
+ // committed transaction says (legacy flag, timestamp, STRING id lists) is
162
+ // corrupt, and trusting it would silently count the profile as migrated.
163
+ if (typeof marker.legacy !== 'boolean' || typeof marker.migratedAt !== 'string') {
164
+ throw new StateError(`the migration marker ${migrationMarkerPath(stateFile)} does not carry a committed transaction record`);
165
+ }
166
+ if (!Array.isArray(marker.staged) || marker.staged.some(id => typeof id !== 'string')) {
167
+ throw new StateError(`the migration marker ${migrationMarkerPath(stateFile)} carries a malformed staged list`);
168
+ }
169
+ if (!Array.isArray(marker.unresolved) || marker.unresolved.some(id => typeof id !== 'string')) {
170
+ throw new StateError(`the migration marker ${migrationMarkerPath(stateFile)} carries a malformed unresolved list`);
171
+ }
172
+ return marker;
173
+ }
174
+ /** Write the marker ATOMICALLY: temp + fsync + rename, never a truncating write. */
175
+ function writeMarkerAtomic(stateFile, marker) {
176
+ mkdirSync(dirname(stateFile), { recursive: true });
177
+ const temporary = `${migrationMarkerPath(stateFile)}.tmp-${randomBytes(8).toString('hex')}`;
178
+ const fd = openSync(temporary, 'wx', 0o600);
179
+ try {
180
+ writeFileSync(fd, `${JSON.stringify(marker, null, 2)}\n`, 'utf8');
181
+ fsyncSync(fd);
182
+ }
183
+ finally {
184
+ closeSync(fd);
185
+ }
186
+ try {
187
+ renameSync(temporary, migrationMarkerPath(stateFile));
188
+ }
189
+ catch (error) {
190
+ rmSync(temporary, { force: true });
191
+ throw error;
192
+ }
193
+ }
194
+ /** Read and VALIDATE the journal; undefined only when it does not exist. */
195
+ function readBackup(stateFile) {
196
+ let text;
197
+ try {
198
+ text = readFileSync(legacyBackupPath(stateFile), 'utf8');
199
+ }
200
+ catch (error) {
201
+ if (error.code === 'ENOENT')
202
+ return undefined;
203
+ throw new StateError(`cannot read the migration journal ${legacyBackupPath(stateFile)}: `
204
+ + `${error instanceof Error ? error.message : String(error)}`);
205
+ }
206
+ let parsed;
207
+ try {
208
+ parsed = JSON.parse(text);
209
+ }
210
+ catch (error) {
211
+ throw new StateError(`the migration journal ${legacyBackupPath(stateFile)} is not valid JSON; `
212
+ + `an interrupted transaction cannot be recovered safely: ${error instanceof Error ? error.message : String(error)}`);
213
+ }
214
+ if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)
215
+ || !('legacyDocument' in parsed)) {
216
+ throw new StateError(`the migration journal ${legacyBackupPath(stateFile)} does not hold a legacyDocument`);
217
+ }
218
+ return parsed;
219
+ }
220
+ /** Journal the ORIGINAL document EXCLUSIVELY: `wx` create; the first-write-wins
221
+ * guarantee across retries comes from the TRANSACTION LOCK that serializes
222
+ * writers, with the exists-check as an advisory belt. */
223
+ function journalLegacyDocument(stateFile, legacyDocument) {
224
+ mkdirSync(dirname(stateFile), { recursive: true });
225
+ const temporary = `${legacyBackupPath(stateFile)}.tmp-${randomBytes(8).toString('hex')}`;
226
+ const backup = { migratedAt: new Date().toISOString(), legacyDocument };
227
+ const fd = openSync(temporary, 'wx', 0o600);
228
+ try {
229
+ writeFileSync(fd, `${JSON.stringify(backup, null, 2)}\n`, 'utf8');
230
+ fsyncSync(fd);
231
+ }
232
+ finally {
233
+ closeSync(fd);
234
+ }
235
+ try {
236
+ // link-or-rename is not available; the rename loses if a journal already
237
+ // exists (first-write-wins), which is exactly the retry discipline.
238
+ if (existsSync(legacyBackupPath(stateFile))) {
239
+ rmSync(temporary, { force: true });
240
+ return;
241
+ }
242
+ renameSync(temporary, legacyBackupPath(stateFile));
243
+ }
244
+ catch (error) {
245
+ rmSync(temporary, { force: true });
246
+ throw error;
247
+ }
248
+ }
249
+ /**
250
+ * Derive the migration facts from one legacy document (the SDK's table — no
251
+ * parallel format): staged enables, unresolved ids, the disabled ids and the
252
+ * enabled ids (the journal-enabled set the recovery merge stages by).
253
+ */
254
+ function deriveFacts(legacyDocument, source) {
255
+ const legacy = parseLegacyModelState(legacyDocument, source);
256
+ if (legacy.state === undefined) {
257
+ throw new StateError(legacy.diagnostic ?? `${source} is not a usable legacy state document`);
258
+ }
259
+ const applied = applyLegacyChoices(legacy.state);
260
+ const staged = [];
261
+ const unresolved = [];
262
+ for (const entry of applied.entries) {
263
+ switch (entry.kind) {
264
+ case 'enabled-choice':
265
+ if (entry.outcome === 'staged')
266
+ staged.push(entry.legacyModelId);
267
+ else if (entry.outcome === 'unresolved' || entry.outcome === 'conflicting')
268
+ unresolved.push(entry.legacyModelId);
269
+ break;
270
+ case 'disabled-choice':
271
+ case 'provider-selection':
272
+ case 'prepared-asset':
273
+ if (entry.outcome === 'unresolved')
274
+ unresolved.push(entry.legacyModelId);
275
+ break;
276
+ }
277
+ }
278
+ return {
279
+ staged,
280
+ unresolved,
281
+ legacyDisabled: [...legacy.state.disabled],
282
+ legacyEnabled: [...legacy.state.enabled],
283
+ legacyJson: JSON.stringify(legacyDocument),
284
+ };
285
+ }
286
+ /**
287
+ * Run the one-time legacy startup migration (with crash recovery).
288
+ *
289
+ * @param options.stateFile - the host's configured isolated state path.
290
+ * @param options.store - the host's state store over that path.
291
+ * @param options.extensionStoreDir - when the deployment mounts an extension
292
+ * store, the SDK profile migration runs there too.
293
+ * @param options.log - a non-secret log sink (the host's logger).
294
+ * @returns the outcome; the caller ALWAYS adopts `hostState` (the hook returns
295
+ * a fresh post-lock read on every path, so adopting it never re-applies a
296
+ * pre-hook snapshot).
297
+ */
298
+ export async function runLegacyStartupMigration(options) {
299
+ const { stateFile, store, extensionStoreDir, log } = options;
300
+ // The parent chain must exist BEFORE the lock file is created: a fresh
301
+ // profile's first boot has no directory yet.
302
+ mkdirSync(dirname(stateFile), { recursive: true });
303
+ const release = acquireMigrationLock(stateFile);
304
+ try {
305
+ return await transaction(stateFile, store, extensionStoreDir, log);
306
+ }
307
+ finally {
308
+ release();
309
+ }
310
+ }
311
+ async function transaction(stateFile, store, extensionStoreDir, log) {
312
+ // The once-anchor, VALIDATED: a marker is trusted only when it parses and
313
+ // carries exactly this host's version. A committed transaction is final.
314
+ const marker = readMarker(stateFile);
315
+ if (marker !== undefined) {
316
+ return {
317
+ ran: false,
318
+ hostState: store.read(),
319
+ staged: marker.staged,
320
+ unresolved: marker.unresolved,
321
+ logLine: undefined,
322
+ recovered: false,
323
+ };
324
+ }
325
+ // RECOVERY DECISION: a journal WITHOUT a committed marker is an interrupted
326
+ // transaction. The legacy INPUT is the VALIDATED journal — never the
327
+ // already-rewritten state file, which has lost the staged enables, provider
328
+ // picks and prepared-asset facts.
329
+ const backup = readBackup(stateFile);
330
+ const recovered = backup !== undefined;
331
+ let legacyDocument;
332
+ if (recovered) {
333
+ legacyDocument = backup.legacyDocument;
334
+ }
335
+ else {
336
+ let raw;
337
+ try {
338
+ raw = readFileSync(stateFile, 'utf8');
339
+ }
340
+ catch (error) {
341
+ if (error.code !== 'ENOENT') {
342
+ throw new StateError(`cannot read ${stateFile}: ${error instanceof Error ? error.message : String(error)}`);
343
+ }
344
+ }
345
+ if (raw === undefined) {
346
+ // A FRESH profile: nothing to migrate. The marker is written anyway so
347
+ // the profile's own later enable/disable writes can never be mis-read as
348
+ // a legacy era on a future boot.
349
+ writeMarkerAtomic(stateFile, {
350
+ hostStateVersion: MIGRATION_MARKER_VERSION,
351
+ migratedAt: new Date().toISOString(),
352
+ legacy: false,
353
+ staged: [],
354
+ unresolved: [],
355
+ });
356
+ return { ran: false, hostState: store.read(), staged: [], unresolved: [], logLine: undefined, recovered: false };
357
+ }
358
+ let parsed;
359
+ try {
360
+ parsed = JSON.parse(raw);
361
+ }
362
+ catch (error) {
363
+ throw new StateError(`${stateFile} is not valid JSON and will not be migrated or overwritten: `
364
+ + `${error instanceof Error ? error.message : String(error)}`);
365
+ }
366
+ // A document carrying a version key is not the legacy era. ANY version
367
+ // fails closed here (the SDK's equality gate, not a lower bound).
368
+ if (typeof parsed === 'object' && parsed !== null && !Array.isArray(parsed)) {
369
+ const version = parsed.stateVersion;
370
+ if (version !== undefined) {
371
+ throw new StateError(`${stateFile} carries a stateVersion (${JSON.stringify(version)}) this host does not write; `
372
+ + 'the migration refuses to re-interpret a versioned document');
373
+ }
374
+ }
375
+ legacyDocument = parsed;
376
+ }
377
+ const facts = deriveFacts(legacyDocument, recovered ? legacyBackupPath(stateFile) : stateFile);
378
+ // TRANSACTION ORDER — journal first (fresh runs only), SDK second, host
379
+ // write third, marker last. The journal exists BEFORE any mutation, so a
380
+ // crash at any later step leaves a recovery path from the original.
381
+ if (!recovered)
382
+ journalLegacyDocument(stateFile, legacyDocument);
383
+ let sdkEntries = [];
384
+ if (extensionStoreDir !== undefined && extensionStoreDir.length > 0) {
385
+ const extensionStore = new ExtensionStore(extensionStoreDir);
386
+ const report = await extensionStore.migrateLegacyProfileState('default', facts.legacyJson, legacyBackupPath(stateFile));
387
+ sdkEntries = report.entries;
388
+ }
389
+ // CONSERVATIVE MERGE, recovery only: the journal's ENABLED ids are legacy
390
+ // facts and are ALWAYS staged — even if the current document still carries
391
+ // them (a crash before the host write leaves the original legacy document
392
+ // in place, and trusting its enables would grant what BASE-10 stages).
393
+ // Current enables that are NOT journal-enabled ids are operator-era facts
394
+ // from after the crash and are kept. On a first run the current document IS
395
+ // the legacy document: nothing may be carried into `enabled` at all.
396
+ const current = store.read();
397
+ const journalEnabled = new Set(facts.legacyEnabled);
398
+ const hostState = recovered
399
+ ? {
400
+ enabled: unique(current.enabled.filter(id => !journalEnabled.has(id))).sort(),
401
+ disabled: unique([...current.disabled, ...facts.legacyDisabled]).sort(),
402
+ }
403
+ : {
404
+ enabled: [],
405
+ disabled: unique(facts.legacyDisabled).sort(),
406
+ };
407
+ store.write(hostState);
408
+ const stagedIds = unique(facts.staged);
409
+ const unresolvedIds = unique([...facts.unresolved, ...sdkEntries
410
+ .filter(entry => entry.outcome === 'unresolved')
411
+ .map(entry => entry.legacyModelId)]);
412
+ writeMarkerAtomic(stateFile, {
413
+ hostStateVersion: MIGRATION_MARKER_VERSION,
414
+ migratedAt: new Date().toISOString(),
415
+ legacy: true,
416
+ staged: stagedIds,
417
+ unresolved: unresolvedIds,
418
+ });
419
+ const logLine = `${recovered ? 'legacy migration RECOVERED from the journal' : 'legacy migration'}: `
420
+ + `${hostState.disabled.length} disabled choice(s) preserved, `
421
+ + `${stagedIds.length} enable(s) staged (not granted), `
422
+ + `${unresolvedIds.length} unresolved id(s) reported`
423
+ + (unresolvedIds.length > 0 ? `: ${unresolvedIds.join(', ')}` : '')
424
+ + (sdkEntries.length > 0 ? `; SDK profile entries: ${sdkEntries.length}` : '')
425
+ + `; original document journaled at ${legacyBackupPath(stateFile)}`;
426
+ log?.(logLine);
427
+ return { ran: true, hostState, staged: stagedIds, unresolved: unresolvedIds, logLine, recovered };
428
+ }
429
+ //# sourceMappingURL=legacy-migration.js.map
@@ -0,0 +1,151 @@
1
+ /**
2
+ * The host's managed-worker registry (EXT-20, the host half).
3
+ *
4
+ * The SDK ships the mechanism — {@link ManagedExtensionWorker}, a scrubbed-environment
5
+ * child process speaking the bounded invoke protocol — and this module is the host-side
6
+ * LIFETIME discipline: ONE worker process per extension per activation GENERATION,
7
+ * reused across invocations, disposed the moment the generation advances (a
8
+ * re-activation gets a fresh process, the old one never serves another call).
9
+ *
10
+ * What stays OUT of the worker, by construction:
11
+ *
12
+ * - the grant: the host authorizes the caller BEFORE dispatch ever builds a provider,
13
+ * so `providerFor` here runs only for calls that already passed authorization, and
14
+ * the worker receives exactly `{implementationId, input}` — no grant, no caller
15
+ * identity, no configuration secrets;
16
+ * - the schemas: input validation happened host-side before the call, and the returned
17
+ * value is validated against the declared output schema by the same path that
18
+ * validates the in-process result — the worker's payload is treated as untrusted
19
+ * data exactly like an in-process provider's;
20
+ * - receipts and accounting: untouched — they record the call in the same code path.
21
+ *
22
+ * IDENTITY: the worker is keyed by the extension's TRUE MANIFEST ID, never by a path
23
+ * or a package specifier (an install path must not leak into diagnostics or collide
24
+ * with a package name). The SDK child also derives its implementation->model mapping
25
+ * from the owning package.json + the manifest beside the entry, so this registry
26
+ * STAGES a host-owned worker directory — package.json + the manifest + a junction to
27
+ * the entry's directory — when the entry's own package root does not carry them
28
+ * (a staged store copy extracts no manifest). The entry's REAL bytes are the ones the
29
+ * worker executes: the junction resolves to the verified installed copy, never a host
30
+ * rewrite.
31
+ *
32
+ * Every worker failure surfaces as the SDK's ManagementError vocabulary
33
+ * (EXTENSION_FAULT), which the dispatch path converts into a tool error; the host
34
+ * process is never affected.
35
+ *
36
+ * @module @try-works/dsh-model-as-tool/managed-workers
37
+ */
38
+ import type { PreparedAssetMapV1, ProviderInspectionV1 } from '@try-works/tool-mode-extension-sdk';
39
+ /** What the host needs to route one extension's calls out of process. */
40
+ export interface ManagedWorkerBinding {
41
+ /**
42
+ * The extension's TRUE MANIFEST ID (the `id` field of the manifest), which keys
43
+ * the worker and is passed to the child as its identity. Never a path.
44
+ */
45
+ readonly extensionId: string;
46
+ /** Absolute path of the built `./tool-mode` entry (plain Node ESM). */
47
+ readonly entryPath: string;
48
+ /**
49
+ * Absolute path of the extension manifest, when the host can resolve one. Absent
50
+ * (a store copy with no extracted manifest), the worker cannot derive the model
51
+ * mapping and the call fails with the precise reason — until the SDK lands the
52
+ * host-supplied mapping API.
53
+ */
54
+ readonly manifestPath?: string;
55
+ /** The activation generation this binding serves (EXT-20 lifetime discipline). */
56
+ readonly generation: number;
57
+ /** Explicit environment names passed through to the scrubbed child env. */
58
+ readonly envPassthrough?: readonly string[];
59
+ }
60
+ /** The dispatch-provider shape the registry hands back. */
61
+ export interface ManagedWorkerProvider {
62
+ load(request: {
63
+ /** The manifest model id the assets prepare (worker.load keys by model id). */
64
+ readonly modelId: string;
65
+ readonly assets: Readonly<PreparedAssetMapV1>;
66
+ readonly signal: AbortSignal;
67
+ }): Promise<void>;
68
+ invoke(request: {
69
+ readonly implementationId: string;
70
+ readonly input: Readonly<Record<string, unknown>>;
71
+ readonly context: unknown;
72
+ }): Promise<Record<string, unknown>>;
73
+ }
74
+ /**
75
+ * The catalog-adapter surface a managed worker serves (EXT-20, host half).
76
+ *
77
+ * This is what the ProviderBridge uses in managed mode. The worker receives the
78
+ * narrow validated input plus a REQUEST-SCOPED path broker (the host's own
79
+ * authority, `resolvePath` — omitted means denial by the protocol), and answers
80
+ * with the payload; the host then applies the same reserved-meta assertion and
81
+ * contract translation as the in-process path. The worker never sees the grant,
82
+ * the caller identity or the host environment. Inspection and load/unload run
83
+ * ENTIRELY in the managed process through the SDK's inspect/load/unload APIs.
84
+ */
85
+ export interface ManagedWorkerAdapter {
86
+ /** Inspect one manifest model, entirely in the managed process (EXT-18). */
87
+ inspect(modelId: string, options?: {
88
+ readonly signal?: AbortSignal;
89
+ }): Promise<ProviderInspectionV1>;
90
+ /** Load the host-prepared assets for one model in the managed process. */
91
+ load(modelId: string, options: {
92
+ readonly assets: Readonly<PreparedAssetMapV1>;
93
+ readonly signal?: AbortSignal;
94
+ }): Promise<void>;
95
+ /** Release one model's loaded resources without disposing the worker. */
96
+ unload(modelId: string, options?: {
97
+ readonly signal?: AbortSignal;
98
+ }): Promise<void>;
99
+ /** Invoke one implementation through the managed process. */
100
+ invoke(request: {
101
+ readonly implementationId: string;
102
+ readonly input: Readonly<Record<string, unknown>>;
103
+ readonly signal?: AbortSignal;
104
+ /** The HOST's request-scoped canonical path broker; omitted means the child denies. */
105
+ readonly resolvePath?: (candidate: string) => string | Promise<string>;
106
+ }): Promise<Record<string, unknown>>;
107
+ /** Dispose the worker process and forget it (deactivation/teardown). */
108
+ dispose(): Promise<void>;
109
+ /** The child pid, when the process is alive. */
110
+ pid(): number | undefined;
111
+ }
112
+ /** Which provider lifecycle phases the CURRENT protocol serves in the child. */
113
+ export interface ManagedWorkerCapabilities {
114
+ /** TRUE: the SDK child serves the inspect message. */
115
+ readonly inspect: true;
116
+ /** TRUE: the SDK child serves the load/unload messages (host-prepared assets only). */
117
+ readonly load: true;
118
+ }
119
+ /** The registry of live extension workers. */
120
+ export interface ManagedWorkerRegistry {
121
+ /**
122
+ * The dispatch provider for one extension, creating or reusing the worker bound to
123
+ * the CURRENT generation. A generation change disposes the old process before the
124
+ * new one is created, so a stale worker can never serve a new activation's calls.
125
+ */
126
+ providerFor(binding: ManagedWorkerBinding): Promise<ManagedWorkerProvider>;
127
+ /**
128
+ * The catalog-adapter surface for one extension (the ProviderBridge's managed
129
+ * path): invoke over the wire, disposal, and the child pid. The same
130
+ * per-generation binding discipline as {@link providerFor}.
131
+ */
132
+ adapterFor(binding: ManagedWorkerBinding): Promise<ManagedWorkerAdapter>;
133
+ /** Dispose one extension's worker and forget it (the deactivation hook). */
134
+ dispose(extensionId: string): Promise<void>;
135
+ /** What the current SDK protocol serves, for the callers that refuse the rest. */
136
+ capabilities(): ManagedWorkerCapabilities;
137
+ /** The live bindings, for tests and diagnostics. */
138
+ bindings(): readonly {
139
+ readonly extensionId: string;
140
+ readonly generation: number;
141
+ readonly pid: number | undefined;
142
+ }[];
143
+ /** Dispose every worker (host teardown). */
144
+ disposeAll(): Promise<void>;
145
+ }
146
+ /**
147
+ * Create the host's managed-worker registry.
148
+ * @returns the registry.
149
+ */
150
+ export declare function createManagedWorkerRegistry(): ManagedWorkerRegistry;
151
+ //# sourceMappingURL=managed-workers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"managed-workers.d.ts","sourceRoot":"","sources":["../src/managed-workers.ts"],"names":[],"mappings":"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"}