dsh-agent-plugins-market 0.9.0 → 0.9.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (358) hide show
  1. package/README.md +64 -154
  2. package/README.zh.md +74 -164
  3. package/assets/dsh-agent-plugins.png +0 -0
  4. package/client/client.js +5371 -1085
  5. package/client/client.js.map +1 -1
  6. package/lib/index.js +2 -257
  7. package/lib/{application → packages/market-bundle/src/application}/catalog.js +207 -41
  8. package/lib/{application → packages/market-bundle/src/application}/details.js +73 -29
  9. package/lib/packages/market-bundle/src/application/extension-inventory.js +408 -0
  10. package/lib/packages/market-bundle/src/application/extension-project.js +64 -0
  11. package/lib/packages/market-bundle/src/application/resource-inventory.js +96 -0
  12. package/lib/packages/market-bundle/src/application/server-config.js +9 -0
  13. package/lib/packages/market-bundle/src/application/suite-queries.js +86 -0
  14. package/lib/packages/market-bundle/src/index.js +372 -0
  15. package/lib/{runtime/host → packages/market-bundle/src/platform}/feedback-tool.js +2 -2
  16. package/lib/{runtime/host → packages/market-bundle/src/platform}/settings-namespace.js +55 -7
  17. package/lib/packages/market-bundle/src/platform/settings-schema.js +25 -0
  18. package/lib/packages/market-bundle/src/routes-extension-presets.js +161 -0
  19. package/lib/packages/market-bundle/src/routes-resources.js +127 -0
  20. package/lib/{routes.js → packages/market-bundle/src/routes.js} +225 -21
  21. package/lib/packages/market-bundle/src/runtime-adapters.js +57 -0
  22. package/lib/packages/market-bundle/src/session-extension.js +337 -0
  23. package/lib/{application → packages/market-catalog/src/application}/catalog-context.js +7 -4
  24. package/lib/{application → packages/market-catalog/src/application}/install-store.js +3 -3
  25. package/lib/{application → packages/market-catalog/src/application}/snapshot-cache.js +100 -11
  26. package/lib/{application → packages/market-catalog/src/application}/source-store.js +24 -11
  27. package/lib/{application → packages/market-catalog/src/application}/state/state-store.js +1 -1
  28. package/lib/{application → packages/market-catalog/src/application}/state/storage-migration.js +1 -1
  29. package/lib/packages/market-catalog/src/index.js +19 -0
  30. package/lib/{catalog → packages/market-catalog/src/scanning}/archive.js +1 -1
  31. package/lib/{catalog → packages/market-catalog/src/scanning}/codex-mcp.js +1 -1
  32. package/lib/{catalog → packages/market-catalog/src/scanning}/component-files.js +2 -2
  33. package/lib/{catalog → packages/market-catalog/src/scanning}/manifests.js +2 -2
  34. package/lib/{catalog → packages/market-catalog/src/scanning}/native-project.js +1 -1
  35. package/lib/{catalog → packages/market-catalog/src/scanning}/paths.js +1 -1
  36. package/lib/{catalog → packages/market-catalog/src/scanning}/plugin-variables.js +21 -1
  37. package/lib/{catalog → packages/market-catalog/src/scanning}/scan-resolvers.js +35 -2
  38. package/lib/{catalog → packages/market-catalog/src/scanning}/skills-parse.js +40 -10
  39. package/lib/{catalog → packages/market-catalog/src/scanning}/validate.js +15 -2
  40. package/lib/packages/market-contracts/src/contracts/extension-presets.js +125 -0
  41. package/lib/{contracts → packages/market-contracts/src/contracts}/market.js +33 -5
  42. package/lib/packages/market-contracts/src/contracts/mcp-overrides.js +2 -0
  43. package/lib/packages/market-contracts/src/contracts/resource-window.js +29 -0
  44. package/lib/packages/market-contracts/src/contracts/settings.js +130 -0
  45. package/lib/packages/market-contracts/src/contracts/surface-toggles.js +29 -0
  46. package/lib/packages/market-contracts/src/contracts/translation.js +28 -0
  47. package/lib/packages/market-contracts/src/index.js +4 -0
  48. package/lib/{model → packages/market-contracts/src/model}/layouts.js +11 -0
  49. package/lib/{application → packages/market-contracts/src/ports}/ports.js +3 -0
  50. package/lib/{application/mcp/mcp-redaction.js → packages/market-contracts/src/redaction.js} +17 -1
  51. package/lib/{application → packages/market-lsp/src/application}/lsp/lsp-direct-config.js +2 -2
  52. package/lib/{application → packages/market-lsp/src/application}/lsp/lsp-server-state.js +1 -1
  53. package/lib/{application → packages/market-lsp/src/application}/lsp/lsp-status.js +20 -3
  54. package/lib/{application → packages/market-lsp/src/application}/lsp/profile-seam.js +1 -1
  55. package/lib/packages/market-lsp/src/application/lsp/validation.js +46 -0
  56. package/lib/{application → packages/market-lsp/src/application}/lsp-service.js +61 -3
  57. package/lib/packages/market-lsp/src/index.js +8 -0
  58. package/lib/{runtime → packages/market-lsp/src/runtime}/lsp/lsp-mounts.js +79 -40
  59. package/lib/{application → packages/market-mcp/src/application}/mcp/mcp-backend.js +0 -16
  60. package/lib/{application → packages/market-mcp/src/application}/mcp/mcp-config.js +104 -21
  61. package/lib/{application → packages/market-mcp/src/application}/mcp/mcp-direct-config.js +12 -4
  62. package/lib/{application → packages/market-mcp/src/application}/mcp/mcp-overrides.js +4 -4
  63. package/lib/{application → packages/market-mcp/src/application}/mcp/mcp-status.js +49 -10
  64. package/lib/packages/market-mcp/src/application/mcp/validation.js +63 -0
  65. package/lib/{application → packages/market-mcp/src/application}/mcp-service.js +111 -91
  66. package/lib/packages/market-mcp/src/index.js +10 -0
  67. package/lib/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/bridge.js +12 -9
  68. package/lib/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/connection.js +1 -1
  69. package/lib/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/oauth.js +1 -1
  70. package/lib/packages/market-mcp/src/runtime/mcp/bridge/tool-ownership.js +26 -0
  71. package/lib/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/tools.js +1 -1
  72. package/lib/{runtime → packages/market-mcp/src/runtime}/mcp/mcp-auth-record.js +35 -4
  73. package/lib/{runtime → packages/market-mcp/src/runtime}/mcp/mcp-mounts.js +35 -4
  74. package/lib/packages/market-runtime/src/adapter-contracts.js +1 -0
  75. package/lib/packages/market-runtime/src/application/command-resources.js +74 -0
  76. package/lib/packages/market-runtime/src/application/extension-authorization.js +27 -0
  77. package/lib/packages/market-runtime/src/application/extension-hook-selection.js +56 -0
  78. package/lib/packages/market-runtime/src/application/extension-suite-declarations.js +57 -0
  79. package/lib/packages/market-runtime/src/application/extension-suite-selection.js +84 -0
  80. package/lib/packages/market-runtime/src/application/fs-probe.js +43 -0
  81. package/lib/packages/market-runtime/src/application/panel-resources.js +370 -0
  82. package/lib/{application → packages/market-runtime/src/application}/panels/user-hooks.js +2 -2
  83. package/lib/{application → packages/market-runtime/src/application}/panels/user-store.js +53 -13
  84. package/lib/{application → packages/market-runtime/src/application}/project-agent-roles.js +20 -11
  85. package/lib/packages/market-runtime/src/application/state/extension-presets.js +144 -0
  86. package/lib/packages/market-runtime/src/application/state/resource-favorites.js +90 -0
  87. package/lib/packages/market-runtime/src/application/state/resource-filters.js +2 -0
  88. package/lib/packages/market-runtime/src/application/state/surface-toggles.js +10 -0
  89. package/lib/packages/market-runtime/src/application/state/workspace-policy.js +56 -0
  90. package/lib/packages/market-runtime/src/catalog-port.js +1 -0
  91. package/lib/packages/market-runtime/src/extension-service.js +1 -0
  92. package/lib/packages/market-runtime/src/index.js +31 -0
  93. package/lib/{runtime → packages/market-runtime/src/runtime}/agents/agent-role-router.js +74 -79
  94. package/lib/packages/market-runtime/src/runtime/agents/agent-teams-seat.js +58 -0
  95. package/lib/{runtime → packages/market-runtime/src/runtime}/agents/subagent-catalog.js +89 -21
  96. package/lib/packages/market-runtime/src/runtime/agents/team-coordination.js +51 -0
  97. package/lib/packages/market-runtime/src/runtime/agents/teammate-role-runtime.js +241 -0
  98. package/lib/packages/market-runtime/src/runtime/agents/teammate-role-tool.js +130 -0
  99. package/lib/{runtime → packages/market-runtime/src/runtime}/core/reconcile-scheduler.js +2 -2
  100. package/lib/packages/market-runtime/src/runtime/core/reconciler.js +457 -0
  101. package/lib/packages/market-runtime/src/runtime/host/command-name-allocator.js +168 -0
  102. package/lib/packages/market-runtime/src/runtime/host/extension-progress.js +120 -0
  103. package/lib/packages/market-runtime/src/runtime/host/extension-runtime.js +405 -0
  104. package/lib/packages/market-runtime/src/runtime/host/extension-session-state.js +839 -0
  105. package/lib/packages/market-runtime/src/runtime/host/extension-tool-gates.js +96 -0
  106. package/lib/{runtime → packages/market-runtime/src/runtime}/host/failure-detail.js +1 -1
  107. package/lib/{runtime → packages/market-runtime/src/runtime}/host/host-locale.js +2 -0
  108. package/lib/packages/market-runtime/src/runtime/host/menu-row-identities.js +38 -0
  109. package/lib/packages/market-runtime/src/runtime/host/resource-filter-service.js +81 -0
  110. package/lib/packages/market-runtime/src/runtime/host/scoped-contributors.js +304 -0
  111. package/lib/packages/market-runtime/src/runtime/host/surface-toggle-service.js +15 -0
  112. package/lib/packages/market-runtime/src/runtime/panels/user-commands.js +211 -0
  113. package/lib/{runtime → packages/market-runtime/src/runtime}/panels/user-panels.js +34 -14
  114. package/lib/packages/market-runtime/src/runtime/surfaces/commands-mounts.js +256 -0
  115. package/lib/packages/market-runtime/src/runtime/surfaces/extension-hooks.js +294 -0
  116. package/lib/packages/market-runtime/src/runtime/surfaces/hook-dry-run.js +122 -0
  117. package/lib/{runtime → packages/market-runtime/src/runtime}/surfaces/hooks-mounts.js +1 -1
  118. package/lib/{runtime → packages/market-runtime/src/runtime}/surfaces/project-runtime.js +23 -13
  119. package/lib/packages/market-runtime/src/runtime/surfaces/skills-provider.js +241 -0
  120. package/lib/packages/market-translation/src/application/state/translation-cache.js +122 -0
  121. package/lib/packages/market-translation/src/application/translation/chain.js +99 -0
  122. package/lib/packages/market-translation/src/application/translation/document.js +384 -0
  123. package/lib/packages/market-translation/src/application/translation/localizer.js +642 -0
  124. package/lib/packages/market-translation/src/application/translation/service.js +113 -0
  125. package/lib/packages/market-translation/src/application/translation/unit.js +19 -0
  126. package/lib/packages/market-translation/src/index.js +4 -0
  127. package/lib/packages/market-translation/src/runtime/host/llm-translator.js +278 -0
  128. package/lib/packages/market-translation/src/runtime/host/machine-translator.js +152 -0
  129. package/lib/packages/market-translation/src/runtime/host/text-masking.js +96 -0
  130. package/lib/packages/market-translation/src/runtime/host/translation-providers.js +116 -0
  131. package/lib/types/index.d.ts +2 -130
  132. package/lib/types/{application → packages/market-bundle/src/application}/catalog.d.ts +117 -22
  133. package/lib/types/packages/market-bundle/src/application/details.d.ts +24 -0
  134. package/lib/types/packages/market-bundle/src/application/extension-inventory.d.ts +45 -0
  135. package/lib/types/packages/market-bundle/src/application/extension-project.d.ts +26 -0
  136. package/lib/types/packages/market-bundle/src/application/resource-inventory.d.ts +42 -0
  137. package/lib/types/packages/market-bundle/src/application/server-config.d.ts +9 -0
  138. package/lib/types/packages/market-bundle/src/application/suite-queries.d.ts +84 -0
  139. package/lib/types/packages/market-bundle/src/index.d.ts +125 -0
  140. package/lib/types/{runtime/host → packages/market-bundle/src/platform}/settings-namespace.d.ts +44 -9
  141. package/lib/types/{application/mcp/mcp-backend.d.ts → packages/market-bundle/src/platform/settings-schema.d.ts} +13 -28
  142. package/lib/types/packages/market-bundle/src/routes-extension-presets.d.ts +15 -0
  143. package/lib/types/packages/market-bundle/src/routes-resources.d.ts +17 -0
  144. package/lib/types/packages/market-bundle/src/routes.d.ts +32 -0
  145. package/lib/types/packages/market-bundle/src/runtime-adapters.d.ts +42 -0
  146. package/lib/types/packages/market-bundle/src/session-extension.d.ts +62 -0
  147. package/lib/types/{application → packages/market-catalog/src/application}/catalog-context.d.ts +11 -3
  148. package/lib/types/{application → packages/market-catalog/src/application}/install-store.d.ts +1 -1
  149. package/lib/types/{application → packages/market-catalog/src/application}/regions.d.ts +1 -1
  150. package/lib/types/{application → packages/market-catalog/src/application}/snapshot-cache.d.ts +44 -2
  151. package/lib/types/{application → packages/market-catalog/src/application}/source-store.d.ts +12 -3
  152. package/lib/types/{application → packages/market-catalog/src/application}/state/state-store.d.ts +1 -1
  153. package/lib/types/packages/market-catalog/src/index.d.ts +22 -0
  154. package/lib/types/{catalog → packages/market-catalog/src/scanning}/archive.d.ts +1 -1
  155. package/lib/types/{catalog → packages/market-catalog/src/scanning}/codex-mcp.d.ts +1 -1
  156. package/lib/types/{catalog → packages/market-catalog/src/scanning}/component-files.d.ts +1 -1
  157. package/lib/types/{catalog → packages/market-catalog/src/scanning}/lsp-spec.d.ts +1 -1
  158. package/lib/types/{catalog → packages/market-catalog/src/scanning}/manifests.d.ts +3 -3
  159. package/lib/types/{catalog → packages/market-catalog/src/scanning}/native-project.d.ts +2 -2
  160. package/lib/types/{catalog → packages/market-catalog/src/scanning}/plugin-variables.d.ts +12 -1
  161. package/lib/types/{catalog → packages/market-catalog/src/scanning}/project-config.d.ts +2 -2
  162. package/lib/types/{catalog → packages/market-catalog/src/scanning}/project-hooks.d.ts +2 -2
  163. package/lib/types/{catalog → packages/market-catalog/src/scanning}/scan-pipeline.d.ts +1 -1
  164. package/lib/types/{catalog → packages/market-catalog/src/scanning}/scan-resolvers.d.ts +3 -3
  165. package/lib/types/{catalog → packages/market-catalog/src/scanning}/source-catalog.d.ts +1 -1
  166. package/lib/types/{catalog → packages/market-catalog/src/scanning}/suite-components.d.ts +1 -1
  167. package/lib/types/{catalog → packages/market-catalog/src/scanning}/suite-scanner.d.ts +1 -1
  168. package/lib/types/{catalog → packages/market-catalog/src/scanning}/surfaces.d.ts +1 -1
  169. package/lib/types/{catalog → packages/market-catalog/src/scanning}/validate.d.ts +1 -1
  170. package/lib/types/packages/market-contracts/src/contracts/extension-presets.d.ts +237 -0
  171. package/lib/types/{contracts → packages/market-contracts/src/contracts}/market.d.ts +87 -16
  172. package/lib/types/packages/market-contracts/src/contracts/mcp-overrides.d.ts +39 -0
  173. package/lib/types/{contracts → packages/market-contracts/src/contracts}/mcp-status.d.ts +9 -0
  174. package/lib/types/packages/market-contracts/src/contracts/resource-window.d.ts +70 -0
  175. package/lib/types/packages/market-contracts/src/contracts/settings.d.ts +121 -0
  176. package/lib/types/packages/market-contracts/src/contracts/surface-toggles.d.ts +28 -0
  177. package/lib/types/packages/market-contracts/src/contracts/translation.d.ts +81 -0
  178. package/lib/types/{runtime → packages/market-contracts/src}/host/plugin-message-source.d.ts +1 -1
  179. package/lib/types/packages/market-contracts/src/index.d.ts +5 -0
  180. package/lib/types/{model → packages/market-contracts/src/model}/layouts.d.ts +7 -0
  181. package/lib/types/{model → packages/market-contracts/src/model}/types.d.ts +2 -2
  182. package/lib/types/packages/market-contracts/src/ports/ports.d.ts +183 -0
  183. package/lib/types/{application → packages/market-contracts/src/ports}/queries.d.ts +27 -6
  184. package/lib/types/{application/mcp/mcp-redaction.d.ts → packages/market-contracts/src/redaction.d.ts} +2 -0
  185. package/lib/types/{application → packages/market-lsp/src/application}/lsp/lsp-direct-config.d.ts +1 -1
  186. package/lib/types/{application → packages/market-lsp/src/application}/lsp/lsp-status.d.ts +21 -5
  187. package/lib/types/packages/market-lsp/src/application/lsp/validation.d.ts +8 -0
  188. package/lib/types/{application → packages/market-lsp/src/application}/lsp-service.d.ts +19 -6
  189. package/lib/types/packages/market-lsp/src/index.d.ts +8 -0
  190. package/lib/types/{runtime → packages/market-lsp/src/runtime}/lsp/lsp-mounts.d.ts +26 -6
  191. package/lib/types/packages/market-mcp/src/application/mcp/mcp-backend.d.ts +28 -0
  192. package/lib/types/{application → packages/market-mcp/src/application}/mcp/mcp-bridge-config.d.ts +1 -1
  193. package/lib/types/{application → packages/market-mcp/src/application}/mcp/mcp-config.d.ts +2 -2
  194. package/lib/types/{application → packages/market-mcp/src/application}/mcp/mcp-direct-config.d.ts +6 -1
  195. package/lib/types/{application → packages/market-mcp/src/application}/mcp/mcp-overrides.d.ts +4 -38
  196. package/lib/types/packages/market-mcp/src/application/mcp/mcp-status.d.ts +40 -0
  197. package/lib/types/{application/server-config.d.ts → packages/market-mcp/src/application/mcp/validation.d.ts} +2 -10
  198. package/lib/types/{application → packages/market-mcp/src/application}/mcp-service.d.ts +22 -16
  199. package/lib/types/packages/market-mcp/src/index.d.ts +12 -0
  200. package/lib/types/packages/market-mcp/src/runtime/mcp/bridge/tool-ownership.d.ts +14 -0
  201. package/lib/types/{runtime → packages/market-mcp/src/runtime}/mcp/mcp-auth-record.d.ts +4 -0
  202. package/lib/types/{runtime → packages/market-mcp/src/runtime}/mcp/mcp-mounts.d.ts +19 -3
  203. package/lib/types/packages/market-runtime/src/adapter-contracts.d.ts +89 -0
  204. package/lib/types/{application → packages/market-runtime/src/application}/agent-roles.d.ts +2 -0
  205. package/lib/types/packages/market-runtime/src/application/command-resources.d.ts +26 -0
  206. package/lib/types/packages/market-runtime/src/application/extension-authorization.d.ts +12 -0
  207. package/lib/types/packages/market-runtime/src/application/extension-hook-selection.d.ts +23 -0
  208. package/lib/types/packages/market-runtime/src/application/extension-suite-declarations.d.ts +10 -0
  209. package/lib/types/packages/market-runtime/src/application/extension-suite-selection.d.ts +30 -0
  210. package/lib/types/packages/market-runtime/src/application/fs-probe.d.ts +12 -0
  211. package/lib/types/packages/market-runtime/src/application/panel-resources.d.ts +100 -0
  212. package/lib/types/{application → packages/market-runtime/src/application}/panels/user-hooks.d.ts +1 -1
  213. package/lib/types/packages/market-runtime/src/application/project-agent-roles.d.ts +10 -0
  214. package/lib/types/packages/market-runtime/src/application/state/extension-presets.d.ts +24 -0
  215. package/lib/types/packages/market-runtime/src/application/state/resource-favorites.d.ts +9 -0
  216. package/lib/types/packages/market-runtime/src/application/state/resource-filters.d.ts +2 -0
  217. package/lib/types/packages/market-runtime/src/application/state/surface-toggles.d.ts +6 -0
  218. package/lib/types/packages/market-runtime/src/application/state/workspace-policy.d.ts +19 -0
  219. package/lib/types/packages/market-runtime/src/catalog-port.d.ts +30 -0
  220. package/lib/types/packages/market-runtime/src/extension-service.d.ts +14 -0
  221. package/lib/types/packages/market-runtime/src/index.d.ts +41 -0
  222. package/lib/types/{runtime → packages/market-runtime/src/runtime}/agents/agent-role-router.d.ts +66 -31
  223. package/lib/types/packages/market-runtime/src/runtime/agents/agent-teams-seat.d.ts +41 -0
  224. package/lib/types/{runtime → packages/market-runtime/src/runtime}/agents/subagent-catalog.d.ts +34 -2
  225. package/lib/types/packages/market-runtime/src/runtime/agents/team-coordination.d.ts +8 -0
  226. package/lib/types/packages/market-runtime/src/runtime/agents/teammate-role-runtime.d.ts +74 -0
  227. package/lib/types/packages/market-runtime/src/runtime/agents/teammate-role-tool.d.ts +6 -0
  228. package/lib/types/{runtime → packages/market-runtime/src/runtime}/core/reconcile-scheduler.d.ts +5 -2
  229. package/lib/types/packages/market-runtime/src/runtime/core/reconciler.d.ts +141 -0
  230. package/lib/types/packages/market-runtime/src/runtime/host/command-name-allocator.d.ts +132 -0
  231. package/lib/types/packages/market-runtime/src/runtime/host/extension-progress.d.ts +91 -0
  232. package/lib/types/packages/market-runtime/src/runtime/host/extension-runtime.d.ts +77 -0
  233. package/lib/types/packages/market-runtime/src/runtime/host/extension-session-state.d.ts +242 -0
  234. package/lib/types/packages/market-runtime/src/runtime/host/extension-tool-gates.d.ts +38 -0
  235. package/lib/types/{runtime → packages/market-runtime/src/runtime}/host/host-locale.d.ts +1 -1
  236. package/lib/types/packages/market-runtime/src/runtime/host/menu-row-identities.d.ts +50 -0
  237. package/lib/types/{runtime → packages/market-runtime/src/runtime}/host/model-catalog.d.ts +1 -1
  238. package/lib/types/packages/market-runtime/src/runtime/host/resource-filter-service.d.ts +34 -0
  239. package/lib/types/packages/market-runtime/src/runtime/host/scoped-contributors.d.ts +58 -0
  240. package/lib/types/packages/market-runtime/src/runtime/host/surface-toggle-service.d.ts +10 -0
  241. package/lib/types/packages/market-runtime/src/runtime/panels/user-commands.d.ts +74 -0
  242. package/lib/types/{runtime → packages/market-runtime/src/runtime}/panels/user-panels.d.ts +7 -1
  243. package/lib/types/packages/market-runtime/src/runtime/surfaces/commands-mounts.d.ts +81 -0
  244. package/lib/types/packages/market-runtime/src/runtime/surfaces/extension-hooks.d.ts +59 -0
  245. package/lib/types/packages/market-runtime/src/runtime/surfaces/hook-dry-run.d.ts +91 -0
  246. package/lib/types/{runtime → packages/market-runtime/src/runtime}/surfaces/hooks-mounts.d.ts +1 -1
  247. package/lib/types/{runtime → packages/market-runtime/src/runtime}/surfaces/project-runtime.d.ts +8 -5
  248. package/lib/types/packages/market-runtime/src/runtime/surfaces/skills-provider.d.ts +71 -0
  249. package/lib/types/packages/market-translation/src/application/state/translation-cache.d.ts +56 -0
  250. package/lib/types/packages/market-translation/src/application/translation/chain.d.ts +47 -0
  251. package/lib/types/packages/market-translation/src/application/translation/document.d.ts +54 -0
  252. package/lib/types/packages/market-translation/src/application/translation/localizer.d.ts +325 -0
  253. package/lib/types/packages/market-translation/src/application/translation/service.d.ts +89 -0
  254. package/lib/types/packages/market-translation/src/application/translation/unit.d.ts +35 -0
  255. package/lib/types/packages/market-translation/src/index.d.ts +4 -0
  256. package/lib/types/packages/market-translation/src/runtime/host/llm-translator.d.ts +30 -0
  257. package/lib/types/packages/market-translation/src/runtime/host/machine-translator.d.ts +52 -0
  258. package/lib/types/packages/market-translation/src/runtime/host/text-masking.d.ts +42 -0
  259. package/lib/types/packages/market-translation/src/runtime/host/translation-providers.d.ts +42 -0
  260. package/locale/en.json +6 -0
  261. package/locale/zh.json +6 -0
  262. package/package.json +47 -10
  263. package/schemas/README.md +4 -4
  264. package/schemas/agent-plugins/spec.md +2 -2
  265. package/schemas/com.deepseek.harness/spec.md +1 -1
  266. package/schemas/skill-collection/spec.md +10 -2
  267. package/lib/application/panel-resources.js +0 -161
  268. package/lib/application/server-config.js +0 -109
  269. package/lib/contracts/settings.js +0 -63
  270. package/lib/runtime/core/reconciler.js +0 -100
  271. package/lib/runtime/panels/user-commands.js +0 -105
  272. package/lib/runtime/surfaces/commands-mounts.js +0 -186
  273. package/lib/runtime/surfaces/skills-provider.js +0 -160
  274. package/lib/types/application/details.d.ts +0 -7
  275. package/lib/types/application/mcp/mcp-status.d.ts +0 -24
  276. package/lib/types/application/panel-resources.d.ts +0 -28
  277. package/lib/types/application/ports.d.ts +0 -86
  278. package/lib/types/application/project-agent-roles.d.ts +0 -3
  279. package/lib/types/contracts/settings.d.ts +0 -59
  280. package/lib/types/routes.d.ts +0 -16
  281. package/lib/types/runtime/core/reconciler.d.ts +0 -58
  282. package/lib/types/runtime/panels/user-commands.d.ts +0 -27
  283. package/lib/types/runtime/surfaces/commands-mounts.d.ts +0 -48
  284. package/lib/types/runtime/surfaces/skills-provider.d.ts +0 -23
  285. /package/lib/{application → packages/market-catalog/src/application}/deadline.js +0 -0
  286. /package/lib/{application → packages/market-catalog/src/application}/json-file.js +0 -0
  287. /package/lib/{application → packages/market-catalog/src/application}/regions.js +0 -0
  288. /package/lib/{catalog → packages/market-catalog/src/scanning}/fs-probes.js +0 -0
  289. /package/lib/{catalog → packages/market-catalog/src/scanning}/git.js +0 -0
  290. /package/lib/{catalog → packages/market-catalog/src/scanning}/lsp-spec.js +0 -0
  291. /package/lib/{catalog → packages/market-catalog/src/scanning}/project-config.js +0 -0
  292. /package/lib/{catalog → packages/market-catalog/src/scanning}/project-hooks.js +0 -0
  293. /package/lib/{catalog → packages/market-catalog/src/scanning}/scan-pipeline.js +0 -0
  294. /package/lib/{catalog → packages/market-catalog/src/scanning}/source-catalog.js +0 -0
  295. /package/lib/{catalog → packages/market-catalog/src/scanning}/suite-components.js +0 -0
  296. /package/lib/{catalog → packages/market-catalog/src/scanning}/suite-scanner.js +0 -0
  297. /package/lib/{catalog → packages/market-catalog/src/scanning}/surfaces.js +0 -0
  298. /package/lib/{contracts → packages/market-contracts/src/contracts}/lsp-status.js +0 -0
  299. /package/lib/{contracts → packages/market-contracts/src/contracts}/lsp.js +0 -0
  300. /package/lib/{contracts → packages/market-contracts/src/contracts}/mcp-status.js +0 -0
  301. /package/lib/{contracts → packages/market-contracts/src/contracts}/mcp.js +0 -0
  302. /package/lib/{runtime → packages/market-contracts/src}/host/plugin-message-source.js +0 -0
  303. /package/lib/{model → packages/market-contracts/src/model}/command-names.js +0 -0
  304. /package/lib/{model → packages/market-contracts/src/model}/preset-source.js +0 -0
  305. /package/lib/{model → packages/market-contracts/src/model}/types.js +0 -0
  306. /package/lib/{application → packages/market-contracts/src/ports}/queries.js +0 -0
  307. /package/lib/{application → packages/market-mcp/src/application}/mcp/mcp-bridge-config.js +0 -0
  308. /package/lib/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/host-contract.js +0 -0
  309. /package/lib/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/host-seams.js +0 -0
  310. /package/lib/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/plugin-identity.js +0 -0
  311. /package/lib/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/projection.js +0 -0
  312. /package/lib/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/transport.js +0 -0
  313. /package/lib/{runtime → packages/market-mcp/src/runtime}/mcp/mcp-credentials.js +0 -0
  314. /package/lib/{application → packages/market-runtime/src/application}/agent-roles.js +0 -0
  315. /package/lib/{runtime → packages/market-runtime/src/runtime}/agents/agent-role-names.js +0 -0
  316. /package/lib/{runtime → packages/market-runtime/src/runtime}/core/context.js +0 -0
  317. /package/lib/{runtime → packages/market-runtime/src/runtime}/core/mount-lifecycle.js +0 -0
  318. /package/lib/{runtime → packages/market-runtime/src/runtime}/core/source-auto-update.js +0 -0
  319. /package/lib/{runtime → packages/market-runtime/src/runtime}/core/timer-seat.js +0 -0
  320. /package/lib/{runtime → packages/market-runtime/src/runtime}/host/model-catalog.js +0 -0
  321. /package/lib/{runtime → packages/market-runtime/src/runtime}/host/shell-path.js +0 -0
  322. /package/lib/{runtime → packages/market-runtime/src/runtime}/host/tool-registry-observer.js +0 -0
  323. /package/lib/{runtime → packages/market-runtime/src/runtime}/surfaces/dynamic-context.js +0 -0
  324. /package/lib/types/{runtime/host → packages/market-bundle/src/platform}/feedback-tool.d.ts +0 -0
  325. /package/lib/types/{application → packages/market-catalog/src/application}/deadline.d.ts +0 -0
  326. /package/lib/types/{application → packages/market-catalog/src/application}/json-file.d.ts +0 -0
  327. /package/lib/types/{application → packages/market-catalog/src/application}/state/storage-migration.d.ts +0 -0
  328. /package/lib/types/{catalog → packages/market-catalog/src/scanning}/fs-probes.d.ts +0 -0
  329. /package/lib/types/{catalog → packages/market-catalog/src/scanning}/git.d.ts +0 -0
  330. /package/lib/types/{catalog → packages/market-catalog/src/scanning}/paths.d.ts +0 -0
  331. /package/lib/types/{catalog → packages/market-catalog/src/scanning}/skills-parse.d.ts +0 -0
  332. /package/lib/types/{contracts → packages/market-contracts/src/contracts}/lsp-status.d.ts +0 -0
  333. /package/lib/types/{contracts → packages/market-contracts/src/contracts}/lsp.d.ts +0 -0
  334. /package/lib/types/{contracts → packages/market-contracts/src/contracts}/mcp.d.ts +0 -0
  335. /package/lib/types/{model → packages/market-contracts/src/model}/command-names.d.ts +0 -0
  336. /package/lib/types/{model → packages/market-contracts/src/model}/preset-source.d.ts +0 -0
  337. /package/lib/types/{application → packages/market-lsp/src/application}/lsp/lsp-server-state.d.ts +0 -0
  338. /package/lib/types/{application → packages/market-lsp/src/application}/lsp/profile-seam.d.ts +0 -0
  339. /package/lib/types/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/bridge.d.ts +0 -0
  340. /package/lib/types/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/connection.d.ts +0 -0
  341. /package/lib/types/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/host-contract.d.ts +0 -0
  342. /package/lib/types/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/host-seams.d.ts +0 -0
  343. /package/lib/types/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/oauth.d.ts +0 -0
  344. /package/lib/types/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/plugin-identity.d.ts +0 -0
  345. /package/lib/types/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/projection.d.ts +0 -0
  346. /package/lib/types/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/tools.d.ts +0 -0
  347. /package/lib/types/{runtime → packages/market-mcp/src/runtime}/mcp/bridge/transport.d.ts +0 -0
  348. /package/lib/types/{runtime → packages/market-mcp/src/runtime}/mcp/mcp-credentials.d.ts +0 -0
  349. /package/lib/types/{application → packages/market-runtime/src/application}/panels/user-store.d.ts +0 -0
  350. /package/lib/types/{runtime → packages/market-runtime/src/runtime}/agents/agent-role-names.d.ts +0 -0
  351. /package/lib/types/{runtime → packages/market-runtime/src/runtime}/core/context.d.ts +0 -0
  352. /package/lib/types/{runtime → packages/market-runtime/src/runtime}/core/mount-lifecycle.d.ts +0 -0
  353. /package/lib/types/{runtime → packages/market-runtime/src/runtime}/core/source-auto-update.d.ts +0 -0
  354. /package/lib/types/{runtime → packages/market-runtime/src/runtime}/core/timer-seat.d.ts +0 -0
  355. /package/lib/types/{runtime → packages/market-runtime/src/runtime}/host/failure-detail.d.ts +0 -0
  356. /package/lib/types/{runtime → packages/market-runtime/src/runtime}/host/shell-path.d.ts +0 -0
  357. /package/lib/types/{runtime → packages/market-runtime/src/runtime}/host/tool-registry-observer.d.ts +0 -0
  358. /package/lib/types/{runtime → packages/market-runtime/src/runtime}/surfaces/dynamic-context.d.ts +0 -0
@@ -0,0 +1,54 @@
1
+ import type { DocumentTranslation } from '../../../../market-contracts/src/contracts/translation.js';
2
+ /** Legacy description chunk bound. Document paragraphs use a separate sentence budget. */
3
+ export declare const MAX_DOCUMENT_CHUNK_CHARS = 800;
4
+ /** Conservative document payload bound, below the smallest target batch allowance. */
5
+ export declare const MAX_PARAGRAPH_REQUEST_CHARS = 1600;
6
+ /** No character fallback: a sentence that exceeds the bound keeps its paragraph authored. */
7
+ export declare function paragraphParts(text: string): string[] | undefined;
8
+ /**
9
+ * Transform prose in a single GFM/math tree. All non-text inline nodes and block
10
+ * structures stay local; providers see paragraph text with ordered boundaries.
11
+ * A malformed boundary sequence leaves that paragraph authored, never rewrites
12
+ * link destinations, code, or the surrounding list/reference structure.
13
+ */
14
+ export declare function translateMarkdownDocument(source: string, localize: (text: string, parts: readonly string[] | undefined) => {
15
+ text: string;
16
+ pending: boolean;
17
+ failed?: boolean;
18
+ }): DocumentTranslation;
19
+ /** One piece of a document: the text to send, and whether it is worth sending at all. */
20
+ export interface DocumentChunk {
21
+ /** The slice exactly as authored, so a body nothing was translated for reassembles unchanged. */
22
+ text: string;
23
+ /** False for verbatim regions — fenced code — which no provider should ever see. */
24
+ translatable: boolean;
25
+ /**
26
+ * The authored text between this chunk and the next, byte for byte: the line
27
+ * ending that closed it, the blank lines that followed, and — on the last
28
+ * chunk — whatever trails the body.
29
+ *
30
+ * It is never sent to a provider, which is what keeps a model from eating the
31
+ * blank line between two blocks. Reassembly is
32
+ * `chunks.map(chunk => chunk.text + chunk.separator).join('')`.
33
+ */
34
+ separator: string;
35
+ }
36
+ /**
37
+ * Split a document body into translation units, in document order.
38
+ *
39
+ * The returned chunks partition the body: each chunk's text followed by its own
40
+ * {@link DocumentChunk.separator}, concatenated in order, is the input byte for
41
+ * byte. Every prose chunk fits {@link MAX_DOCUMENT_CHUNK_CHARS}; code chunks are
42
+ * as long as the fence they hold, however long that is, because they are never
43
+ * sent anywhere.
44
+ *
45
+ * The fence rule reads a fence indented up to three spaces as a fence, which is
46
+ * exactly a fence inside a list item, and passes it through verbatim like any
47
+ * other. A four-space indented code block is read as prose — the Markdown rule
48
+ * for it is contextual, and the indentation it shares with a list item's
49
+ * continuation text made every non-contextual test for it wrong on real
50
+ * documents — so its text does reach a provider.
51
+ * @param text - the document body, frontmatter already removed by the caller.
52
+ * @returns the chunks, in document order; none for a body with no text at all.
53
+ */
54
+ export declare function chunkDocument(text: string): DocumentChunk[];
@@ -0,0 +1,325 @@
1
+ /**
2
+ * Localize translatable fields without ever blocking the read path.
3
+ *
4
+ * The market reads an upstream catalog whose prose is English. A zh deployment
5
+ * wants Chinese, so every unit with no cached translation is queued for the
6
+ * provider chain and the caller keeps rendering the original until the
7
+ * translation lands.
8
+ *
9
+ * Three properties matter more than throughput:
10
+ *
11
+ * - **The read never waits.** {@link TranslationLocalizer.localize} is
12
+ * synchronous and answers from the in-memory cache. A miss returns the
13
+ * original text plus a pending flag; the work happens off the read path.
14
+ * - **A failure is invisible.** An unavailable, throttled, or broken provider
15
+ * degrades to the original text. Nothing here throws into the caller.
16
+ * - **Each text is paid for once.** The cache survives restarts, and the queue
17
+ * is indexed by the source text: the cache key names the entity, but two
18
+ * entities carrying one text share one provider call and each keeps its own
19
+ * entry. A text that keeps failing backs off instead of retrying in a loop.
20
+ * @module application/translation/localizer
21
+ */
22
+ import type { TranslationUnit } from './unit.js';
23
+ import { type TranslationProvider } from './chain.js';
24
+ /** The localization answer for one field. */
25
+ export interface LocalizedText {
26
+ /** The text to render now: the translation when cached, else the original. */
27
+ text: string;
28
+ /** True when a translation is queued or in flight and the text may improve. */
29
+ pending: boolean;
30
+ }
31
+ export interface LocalizerOptions {
32
+ /** The plugin's own storage root; the cache file lives directly inside it. */
33
+ dataRoot: string;
34
+ /** The ordered provider chain; empty means translation is a no-op. */
35
+ providers: readonly TranslationProvider[];
36
+ /**
37
+ * Stable identity of the current chain, folded into every cache key.
38
+ *
39
+ * Read per call, never cached: a deployment that switches providers must
40
+ * miss the cache it filled under the old one rather than serve the old
41
+ * engine's output as if it were the new engine's.
42
+ */
43
+ providerIdentity: () => string;
44
+ /**
45
+ * Whether translation is switched on, read per call rather than captured.
46
+ *
47
+ * The settings switch can flip long after construction, so a chain built once
48
+ * must still stop and start with it. Absent means always on, which keeps the
49
+ * localizer usable on its own in a test.
50
+ */
51
+ enabled?: (() => boolean) | undefined;
52
+ /** Clock seam; tests drive backoff and TTL through it. */
53
+ now?: (() => number) | undefined;
54
+ }
55
+ /** Texts per provider call. Bounds both payload size and the blast radius of one failure. */
56
+ export declare const MAX_BATCH_SIZE = 20;
57
+ /**
58
+ * Source characters per provider call.
59
+ *
60
+ * The model hop sizes one call's output from the source that call carries (see
61
+ * `runtime/host/llm-translator.ts`), so this is the input half of the same
62
+ * number: 6,400 source characters is what one call's response is sized for, and
63
+ * {@link MAX_DOCUMENT_CHUNK_CHARS} bounds each text inside it first. A
64
+ * count-only cap let a batch of document chunks ask for several times the output
65
+ * the call is allowed to produce, and a generation cut off at that ceiling fails
66
+ * the whole batch *and* retires the model hop for the rest of the session
67
+ * (`chain.ts` trips a provider on any failure).
68
+ *
69
+ * The expansion this covers is measured over this repository's own bilingual
70
+ * documents — 0.461 of the English character count at the median, 0.617 at the
71
+ * worst, over 90 pairs. What that costs in *tokens* is an estimate rather than a
72
+ * measurement, because nothing in this tree tokenizes; the arithmetic lives with
73
+ * the translator's own constant.
74
+ *
75
+ * The binding constraint is the model hop's own output budget, not a vendor
76
+ * request limit. The two public endpoints this chain calls are the consumer
77
+ * endpoints the vendors' own translation widgets call, not the Cloud APIs whose
78
+ * documented per-request limits are quoted for these products, so no
79
+ * request-size number is claimed here. Moving a hop onto an officially
80
+ * documented API would have to re-derive this constant against that API's own
81
+ * limit.
82
+ *
83
+ * Description traffic reaches this budget only for a long field: a description
84
+ * longer than one chunk travels in chunks like a document body, and everything
85
+ * shorter batches by count.
86
+ */
87
+ export declare const MAX_BATCH_CHARS = 6400;
88
+ /**
89
+ * English output can expand Chinese source; reserve a smaller raw-source batch
90
+ * for the model adapter's estimated 1.5 tokens per source character. Separators
91
+ * and masking can expand the payload further, so this is not a truncation guarantee.
92
+ */
93
+ export declare const MAX_EN_BATCH_CHARS = 2400;
94
+ /**
95
+ * How long an enqueue waits for company before its batch starts.
96
+ *
97
+ * Callers enqueue as they discover text: the panel learns one description per
98
+ * file it reads, so a synchronous pump sent one text per provider call. A
99
+ * short deferral lets a burst land in one batch, and a lone unit waits at most
100
+ * this long — invisible beside a provider round trip. A batch that is already
101
+ * full never waits: {@link TranslationLocalizer.schedulePump} cancels the
102
+ * window and starts it immediately, so a burst's throughput is unchanged and
103
+ * only its grouping is.
104
+ */
105
+ export declare const BATCH_COALESCE_MS = 25;
106
+ /**
107
+ * Whether prose contains text to translate into the resolved interface language.
108
+ * Chinese targets retain the Latin-versus-Han heuristic; English targets accept
109
+ * any Han text, including Chinese embedded in predominantly English prose.
110
+ * @param text - upstream prose; blank and absent values never queue work.
111
+ * @param target - resolved target language, defaulting to Chinese for existing callers.
112
+ */
113
+ export declare function needsTranslation(text: string | undefined, target?: string): text is string;
114
+ /**
115
+ * Owns the translation cache, the text-indexed queue, and the retry policy.
116
+ *
117
+ * One instance per plugin activation; {@link load} must run before the first
118
+ * {@link localize} so cached translations are available synchronously.
119
+ */
120
+ export declare class TranslationLocalizer {
121
+ private readonly dataRoot;
122
+ private readonly providers;
123
+ private readonly providerIdentity;
124
+ private readonly now;
125
+ private entries;
126
+ /**
127
+ * Translations indexed by source text rather than by entity.
128
+ *
129
+ * The cache key names the entity, which is what makes the file the record of
130
+ * what was translated for whom — and it is also what made one text two
131
+ * provider calls when two entities carried it. This index is the other half:
132
+ * a text already answered for one entity answers for every other, and the
133
+ * answer is written under the second entity's own key so its durable record
134
+ * is complete as well.
135
+ *
136
+ * Derived state, never loaded from disk: entries are keyed by entity and
137
+ * carry no text, so the index warms as reads hit those entries and as batches
138
+ * land. Every entity read in one session is therefore served from the first
139
+ * read of its text, and the next session serves each entity from its own
140
+ * entry.
141
+ */
142
+ private readonly byText;
143
+ private readonly documentRetries;
144
+ /** The text each queued or running job owns, so a second entity carrying it waits for that answer. */
145
+ private readonly owners;
146
+ private readonly pending;
147
+ /** Keys already running, so a second request for one key does not queue twice. */
148
+ private readonly inflight;
149
+ /**
150
+ * Per-text attempt count and the earliest retry time.
151
+ *
152
+ * Keyed by text rather than by entity key: a text the provider cannot answer
153
+ * fails the same way wherever it is rendered, so one attempt budget belongs
154
+ * to it. Keyed per entity, a broken chain would burn that budget once per
155
+ * field — the spend this index exists to bound.
156
+ */
157
+ private readonly retry;
158
+ private active;
159
+ /** Invalidated work cannot mutate a later queue or cache. */
160
+ private generation;
161
+ private readonly controllers;
162
+ private lastEnabled;
163
+ /** Serializes cache writes and deletion, including a write already in flight. */
164
+ private persistence;
165
+ /** The armed coalescing window, or undefined when no pump is scheduled. */
166
+ private pumpTimer;
167
+ private dirty;
168
+ private flushTimer;
169
+ private disposed;
170
+ /** Consulted per call: the settings switch may flip long after construction. */
171
+ private readonly enabled;
172
+ constructor(options: LocalizerOptions);
173
+ /**
174
+ * Read the persisted cache once. A missing or unreadable file is not an
175
+ * error: the market simply starts with nothing translated.
176
+ */
177
+ load(): Promise<void>;
178
+ /**
179
+ * Drop every cached translation, in memory and on disk.
180
+ *
181
+ * The caller re-reads afterwards: the panel translates lazily, so the next
182
+ * read is what repopulates the cache.
183
+ *
184
+ * A provider the chain retired after an earlier failure goes with it. Clearing
185
+ * is an explicit "translate this again", and without this half a single
186
+ * cut-off generation — or one endpoint that was down for a minute — leaves
187
+ * the model hop out of the chain for the rest of the process: every later
188
+ * batch skips it, every read reports nothing pending, and no control on screen
189
+ * can bring it back. The cost bound the chain exists for is one attempt per
190
+ * user request, not one for the process's lifetime.
191
+ * Invalidates queued and running work. Calls made after the reset starts may
192
+ * enqueue new work; their writes follow the deletion.
193
+ * @returns fulfillment after prior cache writes and the deletion finish.
194
+ */
195
+ clear(): Promise<void>;
196
+ /**
197
+ * Forget why translation failed, keeping every translation already made.
198
+ *
199
+ * This is the settings switch's own "try again", and it is not the same as
200
+ * {@link clear}: clearing re-pays for the whole cache, while switching back on
201
+ * only asks for the failures to be forgotten. Both halves of a failure record
202
+ * go together — the per-text attempt budget, or a text that spent its four
203
+ * attempts never queues again, and the chain's process-wide breaker, or a
204
+ * retired provider is skipped for the rest of the process. Resetting one
205
+ * without the other is why switching off and on used to recover nothing that
206
+ * clearing the cache did not.
207
+ */
208
+ resetFailures(): void;
209
+ /**
210
+ * Apply a live settings change. Off cancels unfinished work without deleting
211
+ * cached answers; on resets failures and waits for the next read to enqueue.
212
+ * Call from the settings subscription so cancellation needs no panel read.
213
+ */
214
+ onEnabledChanged(): void;
215
+ private syncEnabled;
216
+ private cancelWork;
217
+ /** Number of texts waiting for a provider call; drives the client's re-read. */
218
+ get pendingCount(): number;
219
+ /**
220
+ * Resolve one field for the active locale.
221
+ *
222
+ * Never awaits and never throws. A cached translation wins; otherwise the
223
+ * original text is returned and the unit is queued when the chain has an
224
+ * available provider and the text actually needs translating.
225
+ *
226
+ * The preference is resolved to the language the interface actually renders
227
+ * before anything else reads it, and that target — not the preference tag —
228
+ * is what the cache key and the provider call carry. So `ja` and `zh-Hant`
229
+ * read the Chinese dictionary and are served the Chinese entry a `zh` reader
230
+ * already paid for, and an English interface answers the same way here as it
231
+ * does at every surface's own gate.
232
+ * @param unit - the surface, entity id, role, and upstream text.
233
+ * @param locale - the host interface preference the panel renders under.
234
+ * @returns the text to render now and whether it may still improve.
235
+ */
236
+ localize(unit: TranslationUnit, locale: string): LocalizedText;
237
+ /**
238
+ * Identity of one source text under a target and a provider chain.
239
+ *
240
+ * The target and the chain are part of it for the reason the cache key
241
+ * carries them: a Chinese answer must never serve an English request, and one
242
+ * engine's output must never be handed over as another's. The role is absent
243
+ * on purpose — a description and a document chunk with the same text are one
244
+ * text to translate, and the translation of a string does not depend on which
245
+ * field it fills.
246
+ * @param target - the resolved target language tag.
247
+ * @param identity - the provider chain's identity for this call.
248
+ * @param text - the source text exactly as authored.
249
+ * @returns the index key shared by every entity carrying this text.
250
+ */
251
+ private textIdentity;
252
+ private identityFor;
253
+ /** Retry this document's failed texts without discarding completed translations. */
254
+ retryDocument(surface: TranslationUnit['surface'], id: string): void;
255
+ /** Publish and persist a paragraph only after every bounded part has an answer. */
256
+ localizeParagraph(unit: TranslationUnit, parts: readonly string[] | undefined, locale: string): LocalizedText & {
257
+ failed?: boolean;
258
+ };
259
+ /** Write one shared answer under one entity's key and mark the cache for a flush. */
260
+ private record;
261
+ /**
262
+ * Queue one job unless its text is already queued, running, or backing off.
263
+ *
264
+ * The return value is what the caller reports as pending, so a text that is
265
+ * waiting out a backoff — or that has exhausted its attempts — answers
266
+ * "nothing more is coming" and the panel stops re-reading. Reporting pending
267
+ * for work that will never start would poll the overview forever. An entity
268
+ * whose text is in flight for another entity reports pending without queueing
269
+ * a call of its own: one call answers both, and the alias is served the
270
+ * moment it lands.
271
+ * @param job - the unit to translate and the key it will be cached under.
272
+ * @returns whether this text now has work queued or running.
273
+ */
274
+ private enqueue;
275
+ /**
276
+ * Arrange the next pump: now for a full batch, else after the coalescing
277
+ * window so the units a burst is still adding ride the same provider call.
278
+ */
279
+ private schedulePump;
280
+ /** Only work with the same target can fill a provider batch. */
281
+ private hasFullBatch;
282
+ /** Start as many queued batches as the concurrency cap allows. */
283
+ private pump;
284
+ /**
285
+ * Run one batch. A batch-level failure backs off every member; a single empty
286
+ * result backs off only that text, so one bad text cannot stall nineteen good
287
+ * ones. Every failure path is silent for the caller: the panel keeps the
288
+ * original text either way.
289
+ */
290
+ private run;
291
+ /** Record one failed attempt and push the text's next try further out. */
292
+ private fail;
293
+ /**
294
+ * Batch successful translations into one write instead of one per text.
295
+ *
296
+ * A translation that lands after {@link dispose} has no timer to ride and no
297
+ * later read to pick it up, so it is written immediately: otherwise the call
298
+ * is paid for and the result is dropped on unload.
299
+ */
300
+ private scheduleFlush;
301
+ /** Persist the cache when it changed. A failed write keeps the in-memory copy. */
302
+ flush(): Promise<void>;
303
+ /**
304
+ * Wait until the queue drains or the deadline passes.
305
+ *
306
+ * Warm-up uses this so a scan can hand off and a test can assert the result
307
+ * without polling; production never blocks a request on it.
308
+ * @param deadlineMs - maximum wait; omitted waits for the queue alone.
309
+ * @returns whether the queue drained before the deadline.
310
+ */
311
+ settle(deadlineMs?: number): Promise<boolean>;
312
+ /**
313
+ * Cancel timers and drop queued work; in-flight calls finish and are
314
+ * persisted by {@link flush}.
315
+ *
316
+ * A disposed instance cannot deliver its queue — {@link enqueue} refuses new
317
+ * work and the pump refuses to start — so leaving it populated would strand
318
+ * its units behind a {@link pendingCount} that never falls, and a
319
+ * {@link settle} waiting on them would run out its deadline instead of
320
+ * returning. Dropping them costs nothing durable: translation is lazy, the
321
+ * cache is the only state that has to survive, and the next activation's
322
+ * first read queues whatever is still missing.
323
+ */
324
+ dispose(): void;
325
+ }
@@ -0,0 +1,89 @@
1
+ /**
2
+ * The market's translation service: the reads a catalog surface asks for, over
3
+ * one localizer this service owns.
4
+ *
5
+ * The three reads are the whole translation vocabulary a surface needs — one
6
+ * entity's fields, one authored text, one Markdown document — and every one of
7
+ * them resolves through the same localizer, so the cache, the queue and the
8
+ * provider chain stay a single instance per activation. The localizer's own
9
+ * lifecycle (load, dispose, clear, enabled edge, settle) is forwarded rather
10
+ * than re-exposed, so a caller cannot reach past it.
11
+ * @module application/translation/service
12
+ */
13
+ import type { DocumentTranslation, TranslationFields, TranslationSurfaceKind } from '../../../../market-contracts/src/contracts/translation.js';
14
+ import { type LocalizerOptions } from './localizer.js';
15
+ /** Composition options of the service; the localizer's own options, unchanged. */
16
+ export type TranslationServiceOptions = LocalizerOptions;
17
+ export declare class TranslationService {
18
+ private readonly localizer;
19
+ constructor(options: LocalizerOptions);
20
+ /** Read the persisted cache once, before the first {@link translateFields} read. */
21
+ load(): Promise<void>;
22
+ /** Cancel timers and drop queued work; in-flight calls finish and are persisted. */
23
+ dispose(): void;
24
+ /** Drop every cached translation, in memory and on disk. */
25
+ clear(): Promise<void>;
26
+ /** Apply a live display-preference change: off cancels unfinished work, on forgets failures. */
27
+ onEnabledChanged(): void;
28
+ /** Wait until the queue drains or the deadline passes. */
29
+ settle(deadlineMs?: number): Promise<boolean>;
30
+ /**
31
+ * Translate one entity's description for a surface.
32
+ *
33
+ * Only the description is a translatable field: a name is an identity the user
34
+ * types, greps, and matches against upstream documentation, so the collector
35
+ * hands back no unit for one. Nothing here waits on a provider: an uncached
36
+ * field answers with the upstream text and reports itself pending.
37
+ *
38
+ * A description longer than one chunk travels in chunks, exactly as a
39
+ * document body does ({@link localizeText}), so the size of an upstream field
40
+ * is never a reason for a provider call to be cut off.
41
+ *
42
+ * Exposed for the panel and status surfaces that build their own rows; it is
43
+ * not part of the HTTP route surface.
44
+ * @param surface - the surface the entity belongs to.
45
+ * @param id - the entity's stable identity inside that surface.
46
+ * @param fields - the entity's upstream name and description.
47
+ * @param locale - the host locale this read resolved once; there is no
48
+ * default, because a default would re-read the host preference per entity and
49
+ * make a read's cost scale with its row count.
50
+ * @returns the translated fields and how many of them are still pending.
51
+ */
52
+ translateFields(surface: TranslationSurfaceKind, id: string, fields: {
53
+ name?: string | undefined;
54
+ description?: string | undefined;
55
+ }, locale: string): {
56
+ fields: TranslationFields;
57
+ pending: number;
58
+ };
59
+ /**
60
+ * Translate one authored text, chunk by chunk, and reassemble it exactly.
61
+ *
62
+ * Every text the layer sends travels the way a document does: split on blank
63
+ * lines into chunks one request may carry, fenced code passed through
64
+ * verbatim, and the authored text between chunks re-emitted rather than
65
+ * synthesized — so a text nothing was translated for comes back byte for
66
+ * byte, and a translated one keeps the author's own blank lines. A
67
+ * description is chunked for the same reason a document is: the model hop
68
+ * sizes one call's output from the source it carries, and a text that exceeds
69
+ * that budget is cut off mid-generation, which fails the batch and retires the
70
+ * provider for the rest of the session.
71
+ * @param surface - the surface the entity belongs to.
72
+ * @param id - the entity's stable identity inside that surface.
73
+ * @param role - which text of the entity this is; the cache key's role slot.
74
+ * @param text - the authored text.
75
+ * @param locale - the interface language this read resolved once.
76
+ * @returns the reassembled text and how many of its chunks are still in flight.
77
+ */
78
+ private localizeText;
79
+ /**
80
+ * Translate paragraphs in one complete Markdown tree. The provider receives
81
+ * prose only. Links, code, math, references and nested containers remain local.
82
+ * The result includes a translated document and paragraph-paired Markdown.
83
+ * Unchanged output preserves the source bytes. Changed output preserves the
84
+ * parsed structure and uses canonical Markdown formatting. Pending paragraphs
85
+ * remain authored until complete. The retry flag resets only this document
86
+ * failure budgets and the provider breaker, without clearing cached successes.
87
+ */
88
+ translateDocument(surface: TranslationSurfaceKind, id: string, text: string, locale: string, retry?: boolean): DocumentTranslation;
89
+ }
@@ -0,0 +1,35 @@
1
+ import type { TranslationRole, TranslationSurfaceKind } from '../../../../market-contracts/src/contracts/translation.js';
2
+ /** One translatable field: the entity it belongs to and the source text. */
3
+ export interface TranslationUnit {
4
+ surface: TranslationSurfaceKind;
5
+ /** Stable identity of the entity inside its surface (e.g. "sourceId/suiteId"). */
6
+ id: string;
7
+ /** The upstream text, exactly as authored. */
8
+ text: string;
9
+ /**
10
+ * Which text of the entity this is; the cache key's role slot.
11
+ *
12
+ * Absent means {@link TranslationRole}'s description — the only role the
13
+ * layer had before document bodies joined it — so every entry already on disk
14
+ * keeps the key it was written under.
15
+ */
16
+ role?: TranslationRole | undefined;
17
+ /** Optional cache namespace for document algorithms; legacy fields omit it. */
18
+ strategy?: string | undefined;
19
+ }
20
+ /**
21
+ * Collect units for one entity, skipping empty or undefined text.
22
+ *
23
+ * Descriptions only: a name is an identifier the user types and matches against
24
+ * upstream documentation, and translating one made it harder to recognize than
25
+ * the original. The text is carried verbatim — the emptiness check trims, but
26
+ * the unit does not, so the cache key stays tied to what upstream authored.
27
+ * @param surface - the surface the entity belongs to.
28
+ * @param id - the entity's stable identity inside that surface.
29
+ * @param fields - the entity's upstream name and description.
30
+ * @returns the units to translate.
31
+ */
32
+ export declare function collectUnits(surface: TranslationSurfaceKind, id: string, fields: {
33
+ name?: string | undefined;
34
+ description?: string | undefined;
35
+ }): TranslationUnit[];
@@ -0,0 +1,4 @@
1
+ /** Explicit cross-domain entry surface. Internal modules are not import targets for siblings. */
2
+ export { TranslationService } from './application/translation/service.js';
3
+ export { createLlmTranslator } from './runtime/host/llm-translator.js';
4
+ export { createTranslationProviders } from './runtime/host/translation-providers.js';
@@ -0,0 +1,30 @@
1
+ import type { TranslationProvider } from '../../application/translation/chain.js';
2
+ /** The host seams this translator reads; every one is optional at composition. */
3
+ export interface TranslatorHost {
4
+ get?(name: string): unknown;
5
+ }
6
+ /** Ceiling for one call, so a large one cannot ask for an unbounded generation. */
7
+ export declare const MAX_OUTPUT_TOKENS_CAP = 4096;
8
+ /**
9
+ * The output budget for one call carrying this much source text.
10
+ *
11
+ * Sized from the source rather than from the text count: what a call has to
12
+ * answer is the expansion of the text it was handed, so a batch of one long
13
+ * text and a batch of twenty short ones are budgeted by the same rule.
14
+ * @param sourceChars - characters in the user turn this call will send.
15
+ * @param locale - target language; English uses the larger expansion allowance.
16
+ * @returns the output token ceiling to ask the route for.
17
+ */
18
+ export declare function outputTokenBudget(sourceChars: number, locale?: string): number;
19
+ /**
20
+ * Build the model-backed provider over one plugin context.
21
+ *
22
+ * Every read is deferred to the call, because the LLM and default-model
23
+ * services provision after apply() returns; a value captured here would stay
24
+ * undefined for the life of the process. available() therefore re-resolves the
25
+ * route on each question, and a deployment with no model configured never
26
+ * queues work nothing can complete.
27
+ * @param host - the plugin context, read structurally so tests can pass a stub.
28
+ * @returns a provider bound to this context.
29
+ */
30
+ export declare function createLlmTranslator(host: TranslatorHost): TranslationProvider;
@@ -0,0 +1,52 @@
1
+ /**
2
+ * The two keyless public machine-translation endpoints, as batch adapters.
3
+ *
4
+ * Both are called by the chain in `application/translation/chain.ts`; the
5
+ * network effect lives here so the chain stays pure orchestration. Each
6
+ * endpoint takes one array and answers with one array in the same order, which
7
+ * is what lets a batch of twenty units travel as a single request.
8
+ *
9
+ * Neither requires registration, a token or a proxy, and that is the whole
10
+ * point of the pair: the market ships translation on by default, with nothing
11
+ * for the operator to configure.
12
+ * @module runtime/host/machine-translator
13
+ */
14
+ import type { TranslationProviderId } from '../../../../market-contracts/src/contracts/translation.js';
15
+ /** One batch translation over a keyless public endpoint. */
16
+ export interface MachineTranslationRequest {
17
+ /** The texts to translate, in the order the answers must come back in. */
18
+ texts: readonly string[];
19
+ /** Target locale id, as the host names it (for example `zh`). */
20
+ locale: string;
21
+ /** Caller cancellation, merged by the chain with this provider's deadline. */
22
+ signal: AbortSignal;
23
+ }
24
+ /** One batch translation result, tagged with the endpoint that produced it. */
25
+ export interface MachineTranslationResult {
26
+ /** The translations, positionally aligned with the request. */
27
+ texts: string[];
28
+ /** The endpoint that answered. */
29
+ provider: TranslationProviderId;
30
+ }
31
+ /**
32
+ * Translate one batch through Google's public endpoint.
33
+ *
34
+ * The body is the endpoint's own protobuf-JSON envelope: a single triple of
35
+ * texts, source language and target language, tagged `wt_lib` so the answer
36
+ * comes back as a plain array rather than as the widget's HTML payload.
37
+ * @param request - the batch, its target locale and cancellation.
38
+ * @returns the translations and the provider id.
39
+ * @throws when the request fails, the endpoint refuses it, or the answer does not line up.
40
+ */
41
+ export declare function googleTranslate(request: MachineTranslationRequest): Promise<MachineTranslationResult>;
42
+ /**
43
+ * Translate one batch through Microsoft's public endpoint.
44
+ *
45
+ * The body is the bare string array, and the languages ride the query string.
46
+ * `isEnterpriseClient=false` selects the consumer backend, which is the one
47
+ * that answers without authentication.
48
+ * @param request - the batch, its target locale and cancellation.
49
+ * @returns the translations and the provider id.
50
+ * @throws when the request fails, the endpoint refuses it, or the answer does not line up.
51
+ */
52
+ export declare function microsoftTranslate(request: MachineTranslationRequest): Promise<MachineTranslationResult>;
@@ -0,0 +1,42 @@
1
+ /**
2
+ * Mask the spans a machine engine corrupts, then restore them from its answer.
3
+ *
4
+ * Neither keyless endpoint leaves technical text alone: Google's HTML aligner
5
+ * escapes a bare `<`, and Microsoft folds angle brackets into pseudo-tags. The
6
+ * spans those engines damage — inline code, URLs, tag fragments and `${VAR}`
7
+ * paths — are exactly what a catalog description is made of, and the fixed terms
8
+ * are the ones an engine likes to paraphrase. Sending a bracketed token instead
9
+ * keeps the payload plain, and the restore table puts the original text back.
10
+ *
11
+ * The same table is the integrity check. An answer is accepted only when every
12
+ * placeholder it recorded comes back exactly once and nothing placeholder-shaped
13
+ * was invented, so a truncated or rewritten answer is discarded rather than
14
+ * rendered with a stray `⟦C1⟧` in it.
15
+ * @module runtime/host/text-masking
16
+ */
17
+ /** One masked payload: the text to send, and the restore table. */
18
+ export interface MaskedText {
19
+ /** The text to hand to a translation engine. */
20
+ text: string;
21
+ /** Placeholder to original span, for {@link unmaskText}. */
22
+ placeholders: ReadonlyMap<string, string>;
23
+ }
24
+ /**
25
+ * Replace every span the engines damage with a numbered placeholder.
26
+ * @param input - the upstream text, exactly as authored.
27
+ * @returns the text to send, and the table that restores it.
28
+ */
29
+ export declare function maskText(input: string): MaskedText;
30
+ /**
31
+ * Put every masked span back, or reject the answer.
32
+ *
33
+ * An answer is rejected — `undefined`, so the caller discards the item instead
34
+ * of caching it — when a placeholder is missing, arrives twice, or when the
35
+ * engine invented one of its own. A short answer that dropped a placeholder
36
+ * would otherwise restore a sentence with a hole in it, and an invented one
37
+ * would render as literal brackets.
38
+ * @param masked - the text the engine returned.
39
+ * @param placeholders - the table {@link maskText} produced for that text.
40
+ * @returns the restored text, or `undefined` when the answer cannot be trusted.
41
+ */
42
+ export declare function unmaskText(masked: string, placeholders: ReadonlyMap<string, string>): string | undefined;