@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,592 @@
1
+ // Generated by scripts/gen-remote-artifacts.mjs from remote/spec.mjs — do not edit.
2
+ //
3
+ // The package-local chunk the browser half loads with
4
+ // require.async('./client.model-tools.js'). It carries the same strict descriptors as
5
+ // the ESM ./remote artifact; see remote/spec.mjs for the wire contract.
6
+ window.__ModuleLoader__.load({
7
+ id: "@try-works/dsh-model-as-tool",
8
+ chunk: "client.model-tools.js",
9
+ factory(require) {
10
+ var module = { exports: {} }
11
+ var exports = module.exports
12
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' })
13
+
14
+ const PACKAGE = "@try-works/dsh-model-as-tool"
15
+ const SERVICE = "modelTools"
16
+ const NAMESPACE = "modelTools"
17
+ const INSTALL_WIRE_METHOD = "installExtension"
18
+
19
+ function parseModelToolsValue(schema, value) {
20
+ switch (schema.kind) {
21
+ case 'string':
22
+ if (typeof value !== 'string') throw new TypeError('expected a string')
23
+ return value
24
+ case 'boolean':
25
+ if (typeof value !== 'boolean') throw new TypeError('expected a boolean')
26
+ return value
27
+ case 'number':
28
+ if (typeof value !== 'number' || !Number.isFinite(value)) throw new TypeError('expected a finite number')
29
+ return value
30
+ case 'null':
31
+ if (value !== null) throw new TypeError('expected null')
32
+ return null
33
+ case 'literal':
34
+ if (value !== schema.value) throw new TypeError('expected ' + JSON.stringify(schema.value))
35
+ return value
36
+ case 'optional':
37
+ return value === undefined ? undefined : parseModelToolsValue(schema.of, value)
38
+ case 'nullable':
39
+ return value === null ? null : parseModelToolsValue(schema.of, value)
40
+ case 'array':
41
+ if (!Array.isArray(value)) throw new TypeError('expected an array')
42
+ return value.map((item) => parseModelToolsValue(schema.of, item))
43
+ case 'record': {
44
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
45
+ throw new TypeError('expected a string-keyed record')
46
+ }
47
+ const parsed = {}
48
+ for (const [key, item] of Object.entries(value)) parsed[key] = parseModelToolsValue(schema.of, item)
49
+ return parsed
50
+ }
51
+ case 'object': {
52
+ if (typeof value !== 'object' || value === null || Array.isArray(value)) {
53
+ throw new TypeError('expected an object')
54
+ }
55
+ const parsed = {}
56
+ for (const [key, field] of Object.entries(schema.fields)) {
57
+ const raw = value[key]
58
+ if (field.kind === 'optional') {
59
+ const item = parseModelToolsValue(field, raw)
60
+ if (item !== undefined) parsed[key] = item
61
+ continue
62
+ }
63
+ if (raw === undefined) throw new TypeError('missing field ' + JSON.stringify(key))
64
+ parsed[key] = parseModelToolsValue(field, raw)
65
+ }
66
+ return parsed
67
+ }
68
+ case 'union': {
69
+ let last
70
+ for (const variant of schema.of) {
71
+ try {
72
+ return parseModelToolsValue(variant, value)
73
+ } catch (error) {
74
+ last = error
75
+ }
76
+ }
77
+ throw new TypeError('value matched no union variant: ' + last.message)
78
+ }
79
+ default:
80
+ throw new TypeError('unknown schema kind ' + JSON.stringify(schema.kind))
81
+ }
82
+ }
83
+
84
+ function codecForModelToolsValue(typeSymbol, schema) {
85
+ let parser
86
+ return {
87
+ mode: 'strict',
88
+ typeSymbol,
89
+ create: () => (parser ??= { parse: (value) => parseModelToolsValue(schema, value) }),
90
+ }
91
+ }
92
+
93
+ function descriptorsFromModelToolsSpecs(packageName, serviceKey, namespace, specs) {
94
+ return specs.map((spec) => {
95
+ const descriptor = {
96
+ id: packageName + '#' + namespace + '/' + spec.method,
97
+ service: serviceKey,
98
+ namespace,
99
+ method: spec.method,
100
+ description: spec.description,
101
+ invocation: { kind: 'direct' },
102
+ parameters: spec.parameters.map((parameter) => {
103
+ const entry = {
104
+ name: parameter.name,
105
+ wire: parameter.wire,
106
+ source: 'json',
107
+ codec: codecForModelToolsValue(parameter.typeSymbol, parameter.schema),
108
+ strictCodec: codecForModelToolsValue(parameter.strictTypeSymbol, parameter.schema),
109
+ }
110
+ if (parameter.description !== undefined) entry.description = parameter.description
111
+ if (parameter.acceptsUndefined === true) entry.acceptsUndefined = true
112
+ return entry
113
+ }),
114
+ cancellation: { parameter: 'signal' },
115
+ result: {
116
+ mode: 'strict',
117
+ typeSymbol: spec.result.typeSymbol,
118
+ create: codecForModelToolsValue(spec.result.typeSymbol, spec.result.schema).create,
119
+ description: spec.result.description,
120
+ },
121
+ }
122
+ if (spec.implementation !== undefined) descriptor.implementation = spec.implementation
123
+ return descriptor
124
+ })
125
+ }
126
+
127
+ const METHOD_SPECS = [
128
+ {
129
+ "method": "describe",
130
+ "description": "Read the current extension state; the page calls it on mount and after each action.",
131
+ "parameters": [],
132
+ "result": {
133
+ "typeSymbol": "@try-works/dsh-model-as-tool#modelTools/describe:result",
134
+ "description": "the extension surface as the host currently sees it.",
135
+ "schema": {
136
+ "kind": "object",
137
+ "fields": {
138
+ "store": {
139
+ "kind": "nullable",
140
+ "of": {
141
+ "kind": "string"
142
+ }
143
+ },
144
+ "writable": {
145
+ "kind": "boolean"
146
+ },
147
+ "sourceDir": {
148
+ "kind": "nullable",
149
+ "of": {
150
+ "kind": "string"
151
+ }
152
+ },
153
+ "extensions": {
154
+ "kind": "array",
155
+ "of": {
156
+ "kind": "object",
157
+ "fields": {
158
+ "id": {
159
+ "kind": "string"
160
+ },
161
+ "package": {
162
+ "kind": "nullable",
163
+ "of": {
164
+ "kind": "string"
165
+ }
166
+ },
167
+ "version": {
168
+ "kind": "nullable",
169
+ "of": {
170
+ "kind": "string"
171
+ }
172
+ },
173
+ "installed": {
174
+ "kind": "boolean"
175
+ },
176
+ "active": {
177
+ "kind": "boolean"
178
+ },
179
+ "disabled": {
180
+ "kind": "boolean"
181
+ },
182
+ "integrity": {
183
+ "kind": "union",
184
+ "of": [
185
+ {
186
+ "kind": "literal",
187
+ "value": "unchanged"
188
+ },
189
+ {
190
+ "kind": "literal",
191
+ "value": "changed"
192
+ },
193
+ {
194
+ "kind": "literal",
195
+ "value": "unknown"
196
+ }
197
+ ]
198
+ },
199
+ "tools": {
200
+ "kind": "array",
201
+ "of": {
202
+ "kind": "string"
203
+ }
204
+ },
205
+ "reason": {
206
+ "kind": "nullable",
207
+ "of": {
208
+ "kind": "string"
209
+ }
210
+ },
211
+ "requirements": {
212
+ "kind": "optional",
213
+ "of": {
214
+ "kind": "array",
215
+ "of": {
216
+ "kind": "object",
217
+ "fields": {
218
+ "kind": {
219
+ "kind": "union",
220
+ "of": [
221
+ {
222
+ "kind": "literal",
223
+ "value": "store"
224
+ },
225
+ {
226
+ "kind": "literal",
227
+ "value": "source"
228
+ },
229
+ {
230
+ "kind": "literal",
231
+ "value": "dependencies"
232
+ },
233
+ {
234
+ "kind": "literal",
235
+ "value": "assets"
236
+ },
237
+ {
238
+ "kind": "literal",
239
+ "value": "executable"
240
+ },
241
+ {
242
+ "kind": "literal",
243
+ "value": "harness-model"
244
+ },
245
+ {
246
+ "kind": "literal",
247
+ "value": "platform"
248
+ },
249
+ {
250
+ "kind": "literal",
251
+ "value": "integrity"
252
+ },
253
+ {
254
+ "kind": "literal",
255
+ "value": "activation"
256
+ }
257
+ ]
258
+ },
259
+ "satisfied": {
260
+ "kind": "boolean"
261
+ },
262
+ "reason": {
263
+ "kind": "string"
264
+ },
265
+ "action": {
266
+ "kind": "union",
267
+ "of": [
268
+ {
269
+ "kind": "literal",
270
+ "value": "install"
271
+ },
272
+ {
273
+ "kind": "literal",
274
+ "value": "prepare"
275
+ },
276
+ {
277
+ "kind": "literal",
278
+ "value": "enable"
279
+ },
280
+ {
281
+ "kind": "literal",
282
+ "value": "config"
283
+ },
284
+ {
285
+ "kind": "literal",
286
+ "value": "none"
287
+ }
288
+ ]
289
+ }
290
+ }
291
+ }
292
+ }
293
+ },
294
+ "blocked": {
295
+ "kind": "optional",
296
+ "of": {
297
+ "kind": "boolean"
298
+ }
299
+ }
300
+ }
301
+ }
302
+ }
303
+ }
304
+ }
305
+ }
306
+ },
307
+ {
308
+ "method": "installExtension",
309
+ "implementation": "install",
310
+ "description": "Install one extension from `source`, or the configured first-party source.",
311
+ "parameters": [
312
+ {
313
+ "name": "id",
314
+ "wire": "id",
315
+ "description": "the extension id, for example `@try-works/extension-laya`.",
316
+ "acceptsUndefined": false,
317
+ "typeSymbol": "@try-works/dsh-model-as-tool#modelTools/install:id",
318
+ "strictTypeSymbol": "@try-works/dsh-model-as-tool#modelTools/install:id",
319
+ "schema": {
320
+ "kind": "string"
321
+ }
322
+ },
323
+ {
324
+ "name": "source",
325
+ "wire": "source",
326
+ "description": "an explicit install directory; absent means the configured first-party source.",
327
+ "acceptsUndefined": true,
328
+ "typeSymbol": "@try-works/dsh-model-as-tool#modelTools/install:source",
329
+ "strictTypeSymbol": "@try-works/dsh-model-as-tool#modelTools/install:source",
330
+ "schema": {
331
+ "kind": "optional",
332
+ "of": {
333
+ "kind": "string"
334
+ }
335
+ }
336
+ }
337
+ ],
338
+ "result": {
339
+ "typeSymbol": "@try-works/dsh-model-as-tool#modelTools/install:result",
340
+ "description": "the installed extension; installation is not activation.",
341
+ "schema": {
342
+ "kind": "object",
343
+ "fields": {
344
+ "id": {
345
+ "kind": "string"
346
+ },
347
+ "version": {
348
+ "kind": "string"
349
+ },
350
+ "active": {
351
+ "kind": "boolean"
352
+ }
353
+ }
354
+ }
355
+ }
356
+ },
357
+ {
358
+ "method": "enable",
359
+ "description": "Activate an installed extension (removes it from `disabledExtensions`).",
360
+ "parameters": [
361
+ {
362
+ "name": "id",
363
+ "wire": "id",
364
+ "description": "the extension id to activate.",
365
+ "acceptsUndefined": false,
366
+ "typeSymbol": "@try-works/dsh-model-as-tool#modelTools/enable:id",
367
+ "strictTypeSymbol": "@try-works/dsh-model-as-tool#modelTools/enable:id",
368
+ "schema": {
369
+ "kind": "string"
370
+ }
371
+ }
372
+ ],
373
+ "result": {
374
+ "typeSymbol": "@try-works/dsh-model-as-tool#modelTools/enable:result",
375
+ "description": "the extension state after activation.",
376
+ "schema": {
377
+ "kind": "object",
378
+ "fields": {
379
+ "id": {
380
+ "kind": "string"
381
+ },
382
+ "active": {
383
+ "kind": "boolean"
384
+ },
385
+ "disabled": {
386
+ "kind": "boolean"
387
+ }
388
+ }
389
+ }
390
+ }
391
+ },
392
+ {
393
+ "method": "disable",
394
+ "description": "Deactivate an extension (adds it to `disabledExtensions`).",
395
+ "parameters": [
396
+ {
397
+ "name": "id",
398
+ "wire": "id",
399
+ "description": "the extension id to deactivate.",
400
+ "acceptsUndefined": false,
401
+ "typeSymbol": "@try-works/dsh-model-as-tool#modelTools/disable:id",
402
+ "strictTypeSymbol": "@try-works/dsh-model-as-tool#modelTools/disable:id",
403
+ "schema": {
404
+ "kind": "string"
405
+ }
406
+ }
407
+ ],
408
+ "result": {
409
+ "typeSymbol": "@try-works/dsh-model-as-tool#modelTools/disable:result",
410
+ "description": "the extension state after deactivation.",
411
+ "schema": {
412
+ "kind": "object",
413
+ "fields": {
414
+ "id": {
415
+ "kind": "string"
416
+ },
417
+ "active": {
418
+ "kind": "boolean"
419
+ },
420
+ "disabled": {
421
+ "kind": "boolean"
422
+ }
423
+ }
424
+ }
425
+ }
426
+ },
427
+ {
428
+ "method": "prepare",
429
+ "description": "Acquire and verify the installed extension's model assets, then record the readiness a following enable needs.",
430
+ "parameters": [
431
+ {
432
+ "name": "id",
433
+ "wire": "id",
434
+ "description": "the installed extension id to prepare.",
435
+ "acceptsUndefined": false,
436
+ "typeSymbol": "@try-works/dsh-model-as-tool#modelTools/prepare:id",
437
+ "strictTypeSymbol": "@try-works/dsh-model-as-tool#modelTools/prepare:id",
438
+ "schema": {
439
+ "kind": "string"
440
+ }
441
+ }
442
+ ],
443
+ "result": {
444
+ "typeSymbol": "@try-works/dsh-model-as-tool#modelTools/prepare:result",
445
+ "description": "the preparation outcome, its RES-02 disclosure, and the readiness recorded for each declared model.",
446
+ "schema": {
447
+ "kind": "object",
448
+ "fields": {
449
+ "id": {
450
+ "kind": "string"
451
+ },
452
+ "prepared": {
453
+ "kind": "boolean"
454
+ },
455
+ "reason": {
456
+ "kind": "nullable",
457
+ "of": {
458
+ "kind": "string"
459
+ }
460
+ },
461
+ "plan": {
462
+ "kind": "nullable",
463
+ "of": {
464
+ "kind": "object",
465
+ "fields": {
466
+ "modelId": {
467
+ "kind": "string"
468
+ },
469
+ "modelRevision": {
470
+ "kind": "string"
471
+ },
472
+ "assets": {
473
+ "kind": "array",
474
+ "of": {
475
+ "kind": "object",
476
+ "fields": {
477
+ "assetId": {
478
+ "kind": "string"
479
+ },
480
+ "bytes": {
481
+ "kind": "number"
482
+ },
483
+ "source": {
484
+ "kind": "string"
485
+ },
486
+ "executable": {
487
+ "kind": "boolean"
488
+ }
489
+ }
490
+ }
491
+ },
492
+ "totalBytes": {
493
+ "kind": "number"
494
+ },
495
+ "storageBytes": {
496
+ "kind": "number"
497
+ },
498
+ "requiresExecutableApproval": {
499
+ "kind": "boolean"
500
+ },
501
+ "license": {
502
+ "kind": "object",
503
+ "fields": {
504
+ "name": {
505
+ "kind": "string"
506
+ },
507
+ "url": {
508
+ "kind": "string"
509
+ }
510
+ }
511
+ }
512
+ }
513
+ }
514
+ },
515
+ "readiness": {
516
+ "kind": "record",
517
+ "of": {
518
+ "kind": "union",
519
+ "of": [
520
+ {
521
+ "kind": "literal",
522
+ "value": "unavailable"
523
+ },
524
+ {
525
+ "kind": "literal",
526
+ "value": "needs-preparation"
527
+ },
528
+ {
529
+ "kind": "literal",
530
+ "value": "preparing"
531
+ },
532
+ {
533
+ "kind": "literal",
534
+ "value": "prepared-cold"
535
+ },
536
+ {
537
+ "kind": "literal",
538
+ "value": "loading"
539
+ },
540
+ {
541
+ "kind": "literal",
542
+ "value": "ready"
543
+ },
544
+ {
545
+ "kind": "literal",
546
+ "value": "busy"
547
+ },
548
+ {
549
+ "kind": "literal",
550
+ "value": "failed"
551
+ }
552
+ ]
553
+ }
554
+ },
555
+ "groups": {
556
+ "kind": "array",
557
+ "of": {
558
+ "kind": "string"
559
+ }
560
+ },
561
+ "activationReady": {
562
+ "kind": "boolean"
563
+ }
564
+ }
565
+ }
566
+ }
567
+ }
568
+ ]
569
+
570
+ const contribution = {
571
+ package: PACKAGE,
572
+ descriptors: descriptorsFromModelToolsSpecs(PACKAGE, SERVICE, NAMESPACE, METHOD_SPECS),
573
+ }
574
+
575
+ /**
576
+ * Mount the contribution in the calling client plugin's fiber.
577
+ * @param ctx - the client Cordis context whose Remote service is available.
578
+ * @returns null when this Host/assembly has no Client Remote service, else
579
+ * the Remote service and the namespace disposer.
580
+ */
581
+ async function mount(ctx) {
582
+ const remote = typeof ctx?.get === 'function' ? ctx.get('remote') : undefined
583
+ if (remote === undefined || remote === null || typeof remote.$mount !== 'function') return null
584
+ const dispose = await remote.$mount(contribution)
585
+ return { remote, dispose }
586
+ }
587
+
588
+ exports.contribution = contribution
589
+ exports.mount = mount
590
+ return module.exports
591
+ },
592
+ })