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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (260) 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 +614 -0
  5. package/client/index.js +1717 -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 +325 -0
  19. package/lib/extension-dependencies.d.ts.map +1 -0
  20. package/lib/extension-dependencies.js +858 -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 +221 -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 +367 -0
  34. package/lib/extensions-service.d.ts.map +1 -0
  35. package/lib/extensions-service.js +1527 -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 +271 -7
  49. package/lib/index.d.ts.map +1 -1
  50. package/lib/index.js +2644 -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 +32 -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 +32 -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 +191 -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/tar-gzip-source.d.ts +44 -0
  188. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/tar-gzip-source.d.ts.map +1 -0
  189. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/tar-gzip-source.js +243 -0
  190. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.d.ts +185 -0
  191. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.d.ts.map +1 -0
  192. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/update-flow.js +504 -0
  193. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.d.ts +17 -0
  194. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.d.ts.map +1 -0
  195. package/node_modules/@try-works/tool-mode-extension-sdk/lib/install/zip-source.js +80 -0
  196. package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.d.ts +52 -0
  197. package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.d.ts.map +1 -0
  198. package/node_modules/@try-works/tool-mode-extension-sdk/lib/load.js +102 -0
  199. package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.d.ts +171 -0
  200. package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.d.ts.map +1 -0
  201. package/node_modules/@try-works/tool-mode-extension-sdk/lib/manifest.js +271 -0
  202. package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.d.ts +242 -0
  203. package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.d.ts.map +1 -0
  204. package/node_modules/@try-works/tool-mode-extension-sdk/lib/runtime.js +58 -0
  205. package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.d.ts +118 -0
  206. package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.d.ts.map +1 -0
  207. package/node_modules/@try-works/tool-mode-extension-sdk/lib/state.js +113 -0
  208. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.d.ts +2 -0
  209. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.d.ts.map +1 -0
  210. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker/worker-child.js +351 -0
  211. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.d.ts +150 -0
  212. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.d.ts.map +1 -0
  213. package/node_modules/@try-works/tool-mode-extension-sdk/lib/worker.js +670 -0
  214. package/node_modules/@try-works/tool-mode-extension-sdk/package.json +53 -0
  215. package/node_modules/@try-works/tool-mode-extension-sdk/schema/extension-manifest-1.1.0.schema.json +253 -0
  216. package/node_modules/@try-works/tool-mode-recipes/bin/tool-mode-recipe.mjs +15 -0
  217. package/node_modules/@try-works/tool-mode-recipes/lib/broker.d.ts +427 -0
  218. package/node_modules/@try-works/tool-mode-recipes/lib/broker.d.ts.map +1 -0
  219. package/node_modules/@try-works/tool-mode-recipes/lib/broker.js +592 -0
  220. package/node_modules/@try-works/tool-mode-recipes/lib/cli.d.ts +60 -0
  221. package/node_modules/@try-works/tool-mode-recipes/lib/cli.d.ts.map +1 -0
  222. package/node_modules/@try-works/tool-mode-recipes/lib/cli.js +936 -0
  223. package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.d.ts +237 -0
  224. package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.d.ts.map +1 -0
  225. package/node_modules/@try-works/tool-mode-recipes/lib/dsh-adapter.js +200 -0
  226. package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.d.ts +85 -0
  227. package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.d.ts.map +1 -0
  228. package/node_modules/@try-works/tool-mode-recipes/lib/fixture-provider.js +176 -0
  229. package/node_modules/@try-works/tool-mode-recipes/lib/images.d.ts +105 -0
  230. package/node_modules/@try-works/tool-mode-recipes/lib/images.d.ts.map +1 -0
  231. package/node_modules/@try-works/tool-mode-recipes/lib/images.js +129 -0
  232. package/node_modules/@try-works/tool-mode-recipes/lib/index.d.ts +25 -0
  233. package/node_modules/@try-works/tool-mode-recipes/lib/index.d.ts.map +1 -0
  234. package/node_modules/@try-works/tool-mode-recipes/lib/index.js +25 -0
  235. package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.d.ts +325 -0
  236. package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.d.ts.map +1 -0
  237. package/node_modules/@try-works/tool-mode-recipes/lib/recipe-format.js +1310 -0
  238. package/node_modules/@try-works/tool-mode-recipes/lib/templates.d.ts +51 -0
  239. package/node_modules/@try-works/tool-mode-recipes/lib/templates.d.ts.map +1 -0
  240. package/node_modules/@try-works/tool-mode-recipes/lib/templates.js +310 -0
  241. package/node_modules/@try-works/tool-mode-recipes/lib/titles.d.ts +227 -0
  242. package/node_modules/@try-works/tool-mode-recipes/lib/titles.d.ts.map +1 -0
  243. package/node_modules/@try-works/tool-mode-recipes/lib/titles.js +407 -0
  244. package/node_modules/@try-works/tool-mode-recipes/package.json +56 -0
  245. package/node_modules/@try-works/tool-mode-recipes/recipes/describe-image.json +38 -0
  246. package/node_modules/@try-works/tool-mode-recipes/recipes/text-title.json +45 -0
  247. package/node_modules/@try-works/tool-mode-recipes/schema/harness-model-recipe.schema.json +273 -0
  248. package/package.json +43 -15
  249. package/remote/spec.mjs +462 -0
  250. package/remote/typert.host.mjs +14 -0
  251. package/remote/typert.remote-client.mjs +16 -0
  252. package/lib/adapters/tongue.d.ts +0 -31
  253. package/lib/adapters/tongue.d.ts.map +0 -1
  254. package/lib/adapters/tongue.js +0 -93
  255. package/lib/adapters/voz.d.ts +0 -28
  256. package/lib/adapters/voz.d.ts.map +0 -1
  257. package/lib/adapters/voz.js +0 -102
  258. /package/{lib → node_modules/@try-works/tool-mode-extension-sdk/lib}/licensing.d.ts +0 -0
  259. /package/{lib → node_modules/@try-works/tool-mode-extension-sdk/lib}/licensing.d.ts.map +0 -0
  260. /package/{lib → node_modules/@try-works/tool-mode-extension-sdk/lib}/licensing.js +0 -0
@@ -0,0 +1,178 @@
1
+ /**
2
+ * Model qualification and capability resolution (MODEL-01, MODEL-04, MODEL-05, MODEL-06).
3
+ *
4
+ * Four rules, each guarding a way of claiming more than is known:
5
+ *
6
+ * - **A platform table is not proof of correct inference** (MODEL-05). A record is
7
+ * qualified only when the exact revision, artifact hash, tokenizer, processor, engine
8
+ * version, ABI and execution provider are all recorded. A missing field is a GAP, and
9
+ * a gap is not a qualification.
10
+ * - **A model's modality list is not an adapter's** (MODEL-05). A model can support
11
+ * video while the selected adapter does not, so what is ADVERTISED is the INTERSECTION
12
+ * of the two, described as such.
13
+ * - **A model name is not a capability test** (MODEL-06). Capability comes from the
14
+ * resolved model, never from recognising a brand.
15
+ * - **Unknown is not unsupported** (MODEL-06). The requirement says to record them
16
+ * separately, because collapsing them lets an unevaluated capability be reported as a
17
+ * known absence — or, worse, the reverse.
18
+ *
19
+ * @module @try-works/dsh-model-as-tool/model-qualification
20
+ */
21
+ /** The fields a qualification record must carry. */
22
+ export const QUALIFICATION_FIELDS = [
23
+ 'modelRevision', 'artifactSha', 'tokenizer', 'processor',
24
+ 'engineVersion', 'nodeAbi', 'architecture', 'executionProvider',
25
+ ];
26
+ /**
27
+ * Report which qualification fields are missing (MODEL-05).
28
+ *
29
+ * A platform table, a successful package import or a runnable base model is not proof of
30
+ * correct inference, so a record with gaps is not a qualification however well it runs.
31
+ * @param record - the partial record.
32
+ * @returns the missing fields.
33
+ */
34
+ export function qualificationGaps(record) {
35
+ return QUALIFICATION_FIELDS.filter(field => {
36
+ const value = record[field];
37
+ return typeof value !== 'string' || value.length === 0;
38
+ });
39
+ }
40
+ /**
41
+ * Whether a record qualifies a path (MODEL-05).
42
+ * @param record - the partial record.
43
+ * @returns whether every required field is present.
44
+ */
45
+ export function isQualified(record) {
46
+ return qualificationGaps(record).length === 0;
47
+ }
48
+ /**
49
+ * The capabilities that may be ADVERTISED (MODEL-05).
50
+ *
51
+ * The intersection, because a model can support a modality while the selected adapter
52
+ * does not. Advertising the model's list would promise something the adapter cannot do.
53
+ * @param claim - what each side supports.
54
+ * @returns the advertisable modalities.
55
+ */
56
+ export function advertisableModalities(claim) {
57
+ const adapter = new Set(claim.adapterSupports);
58
+ return claim.modelSupports.filter(modality => adapter.has(modality));
59
+ }
60
+ /**
61
+ * Describe a model's capability as the INTERSECTION (MODEL-05).
62
+ *
63
+ * The description names what is not advertisable and why, so a reader is not left to
64
+ * infer that the model lacks the modality when in fact the adapter does.
65
+ * @param claim - what each side supports.
66
+ * @returns a description that is true of the pairing.
67
+ */
68
+ export function describeCapability(claim) {
69
+ const advertisable = advertisableModalities(claim);
70
+ const adapter = new Set(claim.adapterSupports);
71
+ // Named rather than omitted: the model supports these, this adapter does not.
72
+ const modelOnly = claim.modelSupports.filter(modality => !adapter.has(modality));
73
+ const base = advertisable.length === 0
74
+ ? 'no modality is advertisable through this adapter'
75
+ : `advertisable: ${advertisable.join(', ')}`;
76
+ return modelOnly.length === 0
77
+ ? base
78
+ : `${base} (the model also supports ${modelOnly.join(', ')}, which this adapter does not)`;
79
+ }
80
+ /**
81
+ * Resolve one capability (MODEL-06).
82
+ *
83
+ * A capability is resolved from what was EVALUATED. A model name is never consulted,
84
+ * because a brand is not a capability test, and an unevaluated capability returns
85
+ * `unknown` rather than being inferred from a sibling.
86
+ * @param evidence - the observed result, or undefined when not evaluated.
87
+ * @returns the state.
88
+ */
89
+ export function resolveCapability(evidence) {
90
+ if (evidence === undefined)
91
+ return 'unknown';
92
+ return evidence ? 'supported' : 'unsupported';
93
+ }
94
+ /**
95
+ * Whether a model name may be used to infer a capability (MODEL-06).
96
+ *
97
+ * It may not. Returns false so the prohibition is asserted rather than merely intended:
98
+ * a rule that lives only in a comment is one a future branch will not read.
99
+ * @returns always false.
100
+ */
101
+ export function modelNameImpliesCapability() {
102
+ return false;
103
+ }
104
+ /**
105
+ * Whether an execution mode is acceptable for the end user (MODEL-04).
106
+ *
107
+ * Python, WSL, Docker, a GPU and a consumer compile step are all refused: maintainers may
108
+ * use Python to export artifacts, but it MUST NOT be required on an end user's Windows
109
+ * machine. A browser-only API does not establish Node support.
110
+ * @param mode - the mode.
111
+ * @returns the verdict, with a reason when refused.
112
+ */
113
+ export function executionModeVerdict(mode) {
114
+ switch (mode) {
115
+ case 'js-wasm-node':
116
+ case 'onnxruntime-node':
117
+ case 'managed-native-windows':
118
+ return { acceptable: true };
119
+ case 'python-required':
120
+ return {
121
+ acceptable: false,
122
+ reason: 'Python may be used by maintainers to export and verify artifacts, but must not be required on an end user machine',
123
+ };
124
+ case 'wsl-required':
125
+ return { acceptable: false, reason: 'WSL must not be required on an end user machine' };
126
+ case 'docker-required':
127
+ return { acceptable: false, reason: 'Docker must not be required on an end user machine' };
128
+ case 'gpu-required':
129
+ return { acceptable: false, reason: 'no GPU requirement is permitted' };
130
+ case 'browser-only':
131
+ return { acceptable: false, reason: 'browser-only APIs do not establish Node support' };
132
+ case 'consumer-compile':
133
+ return { acceptable: false, reason: 'no consumer-side compile is permitted' };
134
+ }
135
+ }
136
+ /**
137
+ * Whether one embedding space may silently stand in for another (BASE-12).
138
+ *
139
+ * Only when the dimensions MATCH. EmbeddingGemma 2 is 768-dimensional and MiniLM is
140
+ * 384-dimensional, so substituting one for the other silently would compare vectors of
141
+ * different widths and produce meaningless similarity.
142
+ * @param from - the space in use.
143
+ * @param to - the proposed replacement.
144
+ * @returns whether the substitution is safe without an explicit migration.
145
+ */
146
+ export function maySubstituteSilently(from, to) {
147
+ return from.dimensions === to.dimensions;
148
+ }
149
+ /**
150
+ * Describe an embedding substitution (BASE-12).
151
+ * @param from - the space in use.
152
+ * @param to - the proposed replacement.
153
+ * @returns a description naming the incompatibility when there is one.
154
+ */
155
+ export function describeSubstitution(from, to) {
156
+ if (maySubstituteSilently(from, to)) {
157
+ return `${to.modelId} produces ${to.dimensions}-dimensional vectors, matching ${from.modelId}`;
158
+ }
159
+ return `${to.modelId} produces ${to.dimensions}-dimensional vectors and ${from.modelId} produces `
160
+ + `${from.dimensions}; existing vectors are not comparable and require an explicit re-index`;
161
+ }
162
+ /**
163
+ * The reduced dimensionalities EmbeddingGemma 2 supports (MODEL-01).
164
+ *
165
+ * The model card describes 768 reducible to 512, 256 and 128. Recorded rather than
166
+ * assumed, because a reduction that is not applied consistently produces vectors that
167
+ * cannot be compared with each other.
168
+ */
169
+ export const EMBEDDINGGEMMA2_DIMENSIONS = [768, 512, 256, 128];
170
+ /**
171
+ * Whether a stated dimensionality is one EmbeddingGemma 2 can produce (MODEL-01).
172
+ * @param dimensions - the stated width.
173
+ * @returns whether it is a documented width.
174
+ */
175
+ export function isEmbeddingGemma2Width(dimensions) {
176
+ return EMBEDDINGGEMMA2_DIMENSIONS.includes(dimensions);
177
+ }
178
+ //# sourceMappingURL=model-qualification.js.map
@@ -0,0 +1,246 @@
1
+ /**
2
+ * The host-side `tools_plan` discipline (NDL-02, NDL-03).
3
+ *
4
+ * The Needle extension implements the ENGINE half of the planning contract: one-shot
5
+ * proposals over a caller-supplied tool list, with the list validated by the extension
6
+ * itself. What NDL-02 forbids is the HOST trusting that caller-supplied list. The list is
7
+ * the authorization surface: whatever schemas the planner receives, it may propose calls
8
+ * against, and a caller who could hand over the whole registry — or a list of its own
9
+ * invention — would be using `tools_plan` as a permission oracle. So the host owns four
10
+ * things the extension never sees:
11
+ *
12
+ * 1. **The frozen snapshot.** At first use, the host captures the currently registered
13
+ * tool schemas (name, description, parameters — nothing executable) into a snapshot
14
+ * that is deep-copied and deep-frozen. Later registry changes cannot leak into it, and
15
+ * a holder of the snapshot cannot mutate it. The planner receives ONLY entries from
16
+ * this snapshot; it never receives the caller's declared tool list, an unfiltered
17
+ * registry, or anything callable (NDL-02's "narrow public broker").
18
+ *
19
+ * 2. **The requested-name gate.** The caller asks for names; the host intersects them
20
+ * with the LIVE registry. Unknown names (never registered, or withdrawn), excluded
21
+ * names (management and composition), duplicates, and live-but-unsnapshotted names are
22
+ * all REJECTED — the whole call fails with every rejection named, never a silently
23
+ * smaller offer set (the CODE-03 "reject rather than omit" discipline).
24
+ *
25
+ * 3. **Host-side re-validation.** When the provider returns proposals, the host
26
+ * re-validates every proposal against the SNAPSHOT schema, not the provider's own
27
+ * verdict. A proposal the engine fabricated outside the offered set, or arguments that
28
+ * violate the frozen schema, are moved to `rejected` with the violations named.
29
+ *
30
+ * 4. **Fresh policy checks.** A proposal is DATA; executing it goes through the registry's
31
+ * own admission later (NDL-03). The host still refuses to return a proposal whose tool
32
+ * is no longer registered — deactivated or withdrawn after the snapshot was captured —
33
+ * so a caller never receives a proposal for a tool that is not currently callable.
34
+ *
35
+ * Everything here is a pure function over plain data: the DSH context, the store and the
36
+ * lifecycle stay in the host wiring, so the discipline is testable without mounting a
37
+ * plugin and without the pinned engine artifacts.
38
+ *
39
+ * @module @try-works/dsh-model-as-tool/planning
40
+ */
41
+ /** The caller-facing name of the planning contract (NDL-02). */
42
+ export declare const PLANNING_TOOL_NAME = "tools_plan";
43
+ /**
44
+ * Tool names the planning surface must never offer or propose (NDL-02 + CODE-07).
45
+ *
46
+ * The program-binding exclusions are reused rather than restated: a proposal targeting
47
+ * `tool_mode_run` (the recursive composition door) or the management surface would hand a
48
+ * caller the same proxy grant CODE-07 withholds from programs. `tools_plan` itself is
49
+ * added so a plan can never propose planning — recursive planning is noise, and the
50
+ * planning tool is not a leaf inference tool.
51
+ *
52
+ * SEALED like {@link EXCLUDED_BINDINGS} — a frozen ARRAY, because freezing a `Set` does
53
+ * not stop `add`/`delete` — so the planning surface and the program-binding surface
54
+ * cannot desynchronize through a runtime mutation.
55
+ */
56
+ export declare const PLANNING_EXCLUDED_TOOLS: readonly string[];
57
+ /** The registry view a tool schema is captured from (the DSH `ToolSchema` projection). */
58
+ export interface RegistryToolSchema {
59
+ readonly name: string;
60
+ readonly description: string;
61
+ /** The model-facing JSON Schema of the arguments. */
62
+ readonly parameters: Readonly<Record<string, unknown>>;
63
+ }
64
+ /** One frozen entry in the snapshot. */
65
+ export interface SnapshotTool {
66
+ readonly name: string;
67
+ readonly description: string;
68
+ /** Deep-frozen: the snapshot is data nobody can edit after capture. */
69
+ readonly parameters: Readonly<Record<string, unknown>>;
70
+ }
71
+ /** The frozen host-approved schema snapshot (NDL-02). */
72
+ export interface ToolSchemaSnapshot {
73
+ /** The catalog generation at capture, so a snapshot is attributable. */
74
+ readonly generation: number;
75
+ /** Frozen entries, keyed by name. */
76
+ readonly tools: ReadonlyMap<string, SnapshotTool>;
77
+ }
78
+ /**
79
+ * Capture the frozen host-approved tool schema snapshot (NDL-02).
80
+ *
81
+ * The capture is a DEEP COPY: mutating the registry afterwards — registering a tool,
82
+ * withdrawing one, changing a description — cannot change the snapshot, and mutating the
83
+ * snapshot is refused by the runtime because every node is frozen. Excluded names are
84
+ * skipped rather than captured-then-filtered, so a management tool's schema never enters
85
+ * the snapshot at all.
86
+ *
87
+ * An empty description is replaced with a stated placeholder rather than captured empty:
88
+ * the planner-side input contract requires a non-empty description, and a capture that
89
+ * guaranteed a later refusal would freeze a call failure into the snapshot.
90
+ * @param schemas - the registry view at capture time.
91
+ * @param options - the generation, and optionally the excluded names (defaults to
92
+ * {@link PLANNING_EXCLUDED_TOOLS}).
93
+ * @returns the frozen snapshot.
94
+ */
95
+ export declare function captureToolSchemaSnapshot(schemas: readonly RegistryToolSchema[], options: {
96
+ readonly generation: number;
97
+ readonly excluded?: readonly string[];
98
+ }): ToolSchemaSnapshot;
99
+ /** Why one requested name was refused. */
100
+ export interface PlanningRejection {
101
+ readonly name: string;
102
+ readonly reason: 'duplicate' | 'excluded' | 'unknown' | 'not-in-snapshot';
103
+ /** What the caller can do about it. */
104
+ readonly remedy: string;
105
+ }
106
+ /** The outcome of the requested-name gate. */
107
+ export type PlanningDecision = {
108
+ readonly ok: true;
109
+ readonly offered: readonly SnapshotTool[];
110
+ } | {
111
+ readonly ok: false;
112
+ readonly rejections: readonly PlanningRejection[];
113
+ };
114
+ /**
115
+ * Intersect the requested names with the live registry and the frozen snapshot (NDL-02).
116
+ *
117
+ * All-or-nothing, mirroring the CODE-03 bindings gate: if ANY requested name is
118
+ * unattainable the whole call is refused with every rejection named, because handing the
119
+ * caller a smaller offer set than it asked for would produce a plan for a different
120
+ * request than the one it stated.
121
+ * @param snapshot - the frozen snapshot, the ONLY source of schemas.
122
+ * @param requested - the names the caller asked to plan over.
123
+ * @param liveLeaf - the leaf tool names currently registered, exclusions already applied.
124
+ * @param excluded - the names refused by policy regardless of registration. Defaults to
125
+ * {@link PLANNING_EXCLUDED_TOOLS}.
126
+ * @returns the offered entries, or every rejection.
127
+ */
128
+ export declare function offerToolsFromSnapshot(snapshot: ToolSchemaSnapshot, requested: readonly string[], liveLeaf: ReadonlySet<string>, excluded?: readonly string[]): PlanningDecision;
129
+ /**
130
+ * Describe a refused request for a caller (NDL-02).
131
+ * @param rejections - the refusals.
132
+ * @returns a readable summary naming every rejection and why.
133
+ */
134
+ export declare function describePlanningRejections(rejections: readonly PlanningRejection[]): string;
135
+ /** One proposal record, normalized from the provider's payload. */
136
+ export interface ProposalEntry {
137
+ readonly name: string;
138
+ readonly arguments: Record<string, unknown>;
139
+ readonly offered: boolean;
140
+ readonly valid: boolean;
141
+ readonly issues: readonly string[];
142
+ }
143
+ /** What a re-check pass produced. */
144
+ export interface RecheckOutcome {
145
+ /** The payload with proposals that failed any re-check moved to `rejected`. */
146
+ readonly payload: Record<string, unknown>;
147
+ /** Non-fatal notes naming what was moved; free of caller content. */
148
+ readonly warnings: readonly string[];
149
+ }
150
+ /**
151
+ * Raised when a provider returns a proposal record that is not proposal-shaped.
152
+ *
153
+ * The provider's declared output contract types every field and closes the record, so a
154
+ * malformed entry is a PROVIDER DEFECT — and it is surfaced as one rather than silently
155
+ * coerced. Coercing a non-object `arguments` into `{}` would present a record the
156
+ * provider never produced as if the host had validated it, and dropping undeclared
157
+ * fields would hide a contract violation the output validator should refuse.
158
+ */
159
+ export declare class ProviderDefectError extends Error {
160
+ readonly name = "ProviderDefectError";
161
+ }
162
+ /**
163
+ * Re-check the provider's proposals against the frozen snapshot, the per-call offered set
164
+ * AND the live authorization state (NDL-02, NDL-03).
165
+ *
166
+ * The provider's own validation is not trusted here: it validated against the list the
167
+ * HOST built, but the host still re-checks every proposal before it reaches a caller,
168
+ * because a proposal is the one thing a caller will treat as authorized. Four checks:
169
+ *
170
+ * - the name must be IN the frozen snapshot (the engine cannot invent a plannable tool);
171
+ * - the arguments must satisfy the SNAPSHOT's schema, compiled fresh per snapshot entry;
172
+ * - the name must be in the OFFERED set for THIS call — a provider proposing a tool the
173
+ * caller never requested must not pass it through as valid, even when it is
174
+ * snapshotted, schema-valid and still registered;
175
+ * - the tool must STILL BE AUTHORIZED right now (NDL-03): a tool deactivated, withdrawn
176
+ * or quarantined after capture fails the fresh policy check, and the proposal is
177
+ * refused rather than returned as if it were executable.
178
+ *
179
+ * A proposal failing any check is MOVED to `rejected` with the issues appended, and one
180
+ * bounded warning per moved proposal is returned for the receipt and the meta envelope.
181
+ * A proposal record that is not proposal-shaped throws {@link ProviderDefectError}: the
182
+ * defect belongs to the provider, and silently repairing it would hide the violation.
183
+ * @param snapshot - the frozen snapshot.
184
+ * @param payload - the provider's result.
185
+ * @param offeredNames - the names the HOST offered for this call.
186
+ * @param isCurrentlyAuthorized - the live authorization predicate, read at re-check time;
187
+ * `true` admits, a string is the refusal reason.
188
+ * @returns the amended payload and the warnings.
189
+ */
190
+ export declare function recheckProposals(snapshot: ToolSchemaSnapshot, payload: Record<string, unknown>, offeredNames: ReadonlySet<string>, isCurrentlyAuthorized: (name: string) => true | string): RecheckOutcome;
191
+ /**
192
+ * The input the HOST advertises and validates for `tools_plan` (NDL-02).
193
+ *
194
+ * The caller names tools as STRINGS — a requested eligible subset, never a grant and
195
+ * never full declarations. The extension's own shipped input schema (full tool objects)
196
+ * remains its provider contract; the host is the broker that turns requested names into
197
+ * snapshot entries, so a caller never supplies the schemas the planner reasons over.
198
+ * Bounds mirror the shipped extension input, so the advertised surface and the transport
199
+ * surface cannot admit different requests.
200
+ */
201
+ export declare const PLANNING_TOOL_INPUT_SCHEMA: {
202
+ readonly type: "object";
203
+ readonly additionalProperties: false;
204
+ readonly required: readonly ["request", "tools"];
205
+ readonly properties: {
206
+ readonly request: {
207
+ readonly type: "string";
208
+ readonly minLength: 1;
209
+ readonly maxLength: 32768;
210
+ readonly description: "The user request the plan is derived from, verbatim.";
211
+ };
212
+ readonly tools: {
213
+ readonly type: "array";
214
+ readonly minItems: 1;
215
+ readonly maxItems: 64;
216
+ readonly description: "The tool names to plan over. A requested eligible subset, never a grant; unknown or excluded names refuse the call.";
217
+ readonly items: {
218
+ readonly type: "string";
219
+ readonly minLength: 1;
220
+ };
221
+ };
222
+ readonly system: {
223
+ readonly type: "string";
224
+ readonly maxLength: 4096;
225
+ readonly description: "Session facts the model should assume: the date, the locale, the device.";
226
+ };
227
+ readonly max_new_tokens: {
228
+ readonly type: "integer";
229
+ readonly minimum: 16;
230
+ readonly maximum: 4096;
231
+ readonly description: "Response-token budget for the planner.";
232
+ };
233
+ };
234
+ };
235
+ /**
236
+ * Whether a declared input schema has the planning shape (a `tools` array property).
237
+ *
238
+ * The NAME alone is not enough to treat a contribution as the planning contract: a
239
+ * package that named a tool `tools_plan` without the planning input would otherwise be
240
+ * served through the planning pipeline and fail in ways nobody could see. The name plus
241
+ * the shape is the contract; the host refuses the name without the shape.
242
+ * @param schema - the declared input schema.
243
+ * @returns whether the schema declares an array-valued `tools` property.
244
+ */
245
+ export declare function hasPlanningInputShape(schema: Readonly<Record<string, unknown>> | undefined): boolean;
246
+ //# sourceMappingURL=planning.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"planning.d.ts","sourceRoot":"","sources":["../src/planning.ts"],"names":[],"mappings":"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"}