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,96 @@
1
+ import { finalExtension } from '@deepseek-ai/dsh-lsp';
2
+ import { scopeChainOf } from '@deepseek-ai/dsh-scope';
3
+ /** Keep error-code and identity prefixes stable; suffixes explain recovery without granting permission. */
4
+ const DISABLED_SUFFIX = ' — unavailable in this session. Do not retry unchanged; if required, ask the user to check session readiness and enable this resource.';
5
+ const INVALID_FILE_PATH_SUFFIX = ' — pass the file_path string of the target file, for example "src/index.ts".';
6
+ const NO_PROVIDER_SUFFIX = ' — no mounted LSP provider serves this extension. If required, ask the user to configure one.';
7
+ const AMBIGUOUS_PROVIDER_SUFFIX = ' — more than one mounted LSP provider serves this extension. Ask the user to resolve the configuration to exactly one mounted provider before retrying.';
8
+ /**
9
+ * Filter inherited extension tools and guard Native/PTC execution using the public rc.2 runtime.
10
+ * Policy errors and unready sessions deny owned capabilities. Project MCP mounts in the agent's
11
+ * own scope must also filter their wanted rows: host restrictions do not hide own-scope tools.
12
+ */
13
+ export function attachExtensionToolGates(agent, ownership, policy) {
14
+ const tools = agent.ctx.tools;
15
+ let disposed = false;
16
+ let refreshing = false;
17
+ let deniedNames = '';
18
+ let releaseRestriction;
19
+ const allows = (resource) => {
20
+ try {
21
+ return policy.ready(agent) && policy.allows(agent, resource.resourceId, resource.suiteId);
22
+ }
23
+ catch {
24
+ return false;
25
+ }
26
+ };
27
+ const lspAllowed = () => ownership.lspProviders().some(allows);
28
+ const refresh = () => {
29
+ if (disposed || refreshing)
30
+ return;
31
+ refreshing = true;
32
+ try {
33
+ const ancestors = scopeChainOf(agent).slice(1);
34
+ const deny = new Set(ownership
35
+ .mcpTools()
36
+ .filter(entry => (entry.scope === undefined || ancestors.includes(entry.scope)) && tools.get(entry.name, ancestors[0]) === entry.definition && !allows(entry))
37
+ .map(entry => entry.name));
38
+ if (ownership.ownsLspTool() && tools.get('lsp') !== undefined && !lspAllowed())
39
+ deny.add('lsp');
40
+ const names = [...deny].sort();
41
+ const signature = JSON.stringify(names);
42
+ if (signature === deniedNames)
43
+ return;
44
+ // Publish the signature before restrict/dispose emit unfiltered tools/change notifications.
45
+ deniedNames = signature;
46
+ const previous = releaseRestriction;
47
+ releaseRestriction = names.length === 0 ? undefined : tools.restrict({ deny: names });
48
+ previous?.();
49
+ }
50
+ finally {
51
+ refreshing = false;
52
+ }
53
+ };
54
+ const releaseGuard = tools.guard(exec => {
55
+ if (exec.agent !== agent)
56
+ return undefined;
57
+ const definition = tools.get(exec.name, agent);
58
+ const owned = ownership.mcpTools().find(entry => entry.definition === definition);
59
+ if (owned !== undefined && !allows(owned))
60
+ return 'extension-resource-disabled: ' + owned.resourceId + DISABLED_SUFFIX;
61
+ if (exec.name !== 'lsp' || !ownership.ownsLspTool() || definition !== tools.get('lsp'))
62
+ return undefined;
63
+ const args = exec.arguments;
64
+ if (typeof args !== 'object' || args === null || !('file_path' in args) || typeof args.file_path !== 'string')
65
+ return 'extension-lsp-route-unavailable: invalid file_path' + INVALID_FILE_PATH_SUFFIX;
66
+ const extension = finalExtension(args.file_path);
67
+ const providers = ownership.lspProviders().filter(provider => provider.extensions.includes(extension));
68
+ if (providers.length === 0)
69
+ return 'extension-lsp-route-unavailable: ' + extension + NO_PROVIDER_SUFFIX;
70
+ if (providers.length > 1)
71
+ return 'extension-lsp-route-unavailable: ' + extension + AMBIGUOUS_PROVIDER_SUFFIX;
72
+ const provider = providers[0];
73
+ return allows(provider) ? undefined : 'extension-resource-disabled: ' + provider.resourceId + DISABLED_SUFFIX;
74
+ });
75
+ const releaseListener = agent.ctx.on('tools/change', refresh);
76
+ try {
77
+ refresh();
78
+ }
79
+ catch (error) {
80
+ releaseListener();
81
+ releaseGuard();
82
+ releaseRestriction?.();
83
+ throw error;
84
+ }
85
+ return {
86
+ refresh,
87
+ dispose() {
88
+ if (disposed)
89
+ return;
90
+ disposed = true;
91
+ releaseListener();
92
+ releaseGuard();
93
+ releaseRestriction?.();
94
+ }
95
+ };
96
+ }
@@ -9,7 +9,7 @@
9
9
  *
10
10
  * @module runtime/failure-detail
11
11
  */
12
- import { redactErrorMessage } from '../../application/mcp/mcp-redaction.js';
12
+ import { redactErrorMessage } from '../../../../market-contracts/src/redaction.js';
13
13
  /** How many cause messages one failure keeps; a mount failure's chain is short. */
14
14
  const MAX_CAUSES = 4;
15
15
  /** The message text of an error, a thrown string, or an object carrying one. */
@@ -14,11 +14,13 @@
14
14
  */
15
15
  const zh = {
16
16
  commandAcknowledged: '/{command} 已转交模型执行',
17
+ commandNotSelected: '/{command} 未在当前会话启用',
17
18
  userCommandSourceLabel: '用户命令',
18
19
  feedbackToolCardTitle: '提交市场体验反馈'
19
20
  };
20
21
  const en = {
21
22
  commandAcknowledged: '/{command} forwarded to the model for execution',
23
+ commandNotSelected: '/{command} is not enabled in this session',
22
24
  userCommandSourceLabel: 'user command',
23
25
  feedbackToolCardTitle: 'File market feedback'
24
26
  };
@@ -0,0 +1,38 @@
1
+ /**
2
+ * Pair the installed and user-authored entries this plugin owns with the menu
3
+ * rows they appear as.
4
+ *
5
+ * A command whose registration has no panel entry is skipped rather than
6
+ * guessed at: without the panel's own text there is no id to share and no
7
+ * translation to show. A skill the panel lists contributes whatever translation
8
+ * the panel already resolved for it.
9
+ * @param source - the panels to read and the live command registrations to match.
10
+ * @returns one identity per owned menu row.
11
+ */
12
+ export async function collectMenuRowIdentities(source) {
13
+ const [skills, commands] = await Promise.all([source.panels.skills.list(), source.panels.commands.list()]);
14
+ const commandsByPanelId = new Map(commands.map(entry => [entry.id ?? entry.name, entry]));
15
+ const identities = [];
16
+ for (const registration of source.commands) {
17
+ const entry = commandsByPanelId.get(registration.id);
18
+ if (entry === undefined)
19
+ continue;
20
+ identities.push({
21
+ source: 'commands',
22
+ name: registration.name,
23
+ id: registration.id,
24
+ authoredName: entry.name,
25
+ ...(entry.description === '' ? {} : { authoredDescription: entry.description })
26
+ });
27
+ }
28
+ for (const entry of skills) {
29
+ identities.push({
30
+ source: 'skills',
31
+ name: entry.name,
32
+ id: entry.id ?? entry.name,
33
+ authoredName: entry.name,
34
+ ...(entry.description === '' ? {} : { authoredDescription: entry.description })
35
+ });
36
+ }
37
+ return identities;
38
+ }
@@ -0,0 +1,81 @@
1
+ import { SURFACE_TOGGLE_KEYS } from '../../../../market-contracts/src/contracts/surface-toggles.js';
2
+ import { allFiltersOn, loadResourceFilters, mutateResourceFilters } from '../../application/state/workspace-policy.js';
3
+ import { deleteResourceFavorite, loadResourceFavorites, saveResourceFavorite } from '../../application/state/resource-favorites.js';
4
+ export class ResourceFilterService {
5
+ dataRoot;
6
+ hooks;
7
+ filters = allFiltersOn();
8
+ workspace;
9
+ tail = Promise.resolve();
10
+ constructor(dataRoot, workspace, hooks) {
11
+ this.dataRoot = dataRoot;
12
+ this.hooks = hooks;
13
+ this.workspace = workspace ?? '';
14
+ }
15
+ enqueue(work) {
16
+ const running = this.tail.then(work);
17
+ this.tail = running.then(() => { }, () => { });
18
+ return running;
19
+ }
20
+ /** Reload shares mutation ordering; an earlier read cannot overwrite a later write. */
21
+ async reload() {
22
+ await this.enqueue(async () => {
23
+ if (this.workspace !== '')
24
+ this.filters = await loadResourceFilters(this.dataRoot, this.workspace);
25
+ });
26
+ }
27
+ /** Callers receive detached data, never the owner's mutable snapshot. */
28
+ currentFilters() {
29
+ return structuredClone(this.filters);
30
+ }
31
+ currentToggles() {
32
+ return { ...this.filters.toggles };
33
+ }
34
+ allowsSurface(key) {
35
+ return this.filters.toggles[key];
36
+ }
37
+ allowsEntry(face, entryId) {
38
+ return !(this.filters.offEntries[face]?.includes(entryId) ?? false);
39
+ }
40
+ allows(face, entryId) {
41
+ return this.allowsEntry(face, entryId);
42
+ }
43
+ offEntriesOf(face) {
44
+ return [...(this.filters.offEntries[face] ?? [])];
45
+ }
46
+ mutate(change) {
47
+ return this.enqueue(async () => {
48
+ const next = this.workspace === '' ? change(structuredClone(this.filters)) : await mutateResourceFilters(this.dataRoot, this.workspace, change);
49
+ this.filters = next;
50
+ await this.hooks.onFiltersChanged();
51
+ return this.currentFilters();
52
+ });
53
+ }
54
+ async setSurface(key, enabled) {
55
+ if (!SURFACE_TOGGLE_KEYS.includes(key))
56
+ return this.currentToggles();
57
+ return (await this.mutate(current => ({ ...current, toggles: { ...current.toggles, [key]: enabled } }))).toggles;
58
+ }
59
+ async setEntry(face, entryId, enabled) {
60
+ return this.mutate(current => {
61
+ const entries = current.offEntries[face] ?? [];
62
+ const next = enabled ? entries.filter(id => id !== entryId) : entries.includes(entryId) ? entries : [...entries, entryId];
63
+ const offEntries = next.length === 0 ? Object.fromEntries(Object.entries(current.offEntries).filter(([key]) => key !== face)) : { ...current.offEntries, [face]: next };
64
+ return { ...current, offEntries };
65
+ });
66
+ }
67
+ /** One complete commit and one refresh. Failed refresh does not roll back persisted state. */
68
+ async applyFilters(toggles, offEntries) {
69
+ const captured = structuredClone({ toggles, offEntries });
70
+ return this.mutate(() => captured);
71
+ }
72
+ async favorites() {
73
+ return loadResourceFavorites(this.dataRoot);
74
+ }
75
+ async saveFavorite(input) {
76
+ return saveResourceFavorite(this.dataRoot, input);
77
+ }
78
+ async deleteFavorite(id) {
79
+ await deleteResourceFavorite(this.dataRoot, id);
80
+ }
81
+ }
@@ -0,0 +1,304 @@
1
+ import { pluginResourceId } from '../../application/panel-resources.js';
2
+ import { hookResourceId } from '../../../../market-contracts/src/contracts/extension-presets.js';
3
+ import { exposesIndividualHooks } from '../../application/extension-hook-selection.js';
4
+ import { SuiteSkillProvider } from '../surfaces/skills-provider.js';
5
+ import { CommandMountRegistry } from '../surfaces/commands-mounts.js';
6
+ import { UserCommandMountRegistry } from '../panels/user-commands.js';
7
+ import { UserPanelSkillProvider } from '../panels/user-panels.js';
8
+ import { ExtensionHooks } from '../surfaces/extension-hooks.js';
9
+ import { suiteInstructions } from '../surfaces/project-runtime.js';
10
+ import { bindHostLocale } from './host-locale.js';
11
+ import { inspectToolRegistry } from './tool-registry-observer.js';
12
+ const suiteId = (suite) => 'market:' + suite.sourceId + '/' + suite.id;
13
+ const entryId = (suite, kind, name) => kind + ':' + pluginResourceId(suite.sourceId, suite.id, kind, name);
14
+ export class ScopedExtensionContributors {
15
+ ports;
16
+ mounted = new Map();
17
+ hostMcp = new Map();
18
+ hostQueues = new Map();
19
+ constructor(ports) {
20
+ this.ports = ports;
21
+ }
22
+ registrationAllows(agent, id) {
23
+ return (this.ports.registrationAllows ?? this.ports.allows)(agent, id);
24
+ }
25
+ registerSkills(agent, scope, mount) {
26
+ mount.releaseSkills.push(scope.skills.registerProvider(control => {
27
+ mount.controls.push(control);
28
+ return new SuiteSkillProvider(this.ports.catalog, {
29
+ dataRoot: this.ports.dataRoot,
30
+ shell: this.ports.shell,
31
+ ...(this.ports.suites === undefined
32
+ ? {}
33
+ : {
34
+ suites: () => this.ports.suites(agent),
35
+ overrideDisabled: (suite, skill) => mount.active && this.ports.allows(agent, entryId(suite, 'skills', skill.name))
36
+ }),
37
+ suiteAllowed: suite => mount.active && this.ports.allows(agent, suiteId(suite)),
38
+ entryAllowed: (suite, skill) => mount.active && this.ports.allows(agent, entryId(suite, 'skills', skill.name))
39
+ });
40
+ }));
41
+ const skills = this.ports.panels?.skills;
42
+ if (skills) {
43
+ mount.releaseSkills.push(scope.skills.registerProvider(control => {
44
+ mount.controls.push(control);
45
+ return new UserPanelSkillProvider(skills, {
46
+ enabled: entry => mount.active && this.ports.allows(agent, 'skills:' + entry.name)
47
+ });
48
+ }));
49
+ }
50
+ }
51
+ async attach(agent) {
52
+ const current = this.mounted.get(agent);
53
+ if (current)
54
+ return current;
55
+ const mount = { controls: [], releaseSkills: [], instructions: [], active: true };
56
+ this.mounted.set(agent, mount);
57
+ if (!this.ports.panels) {
58
+ const fiber = agent.ctx.inject(['skills'], scope => this.registerSkills(agent, scope, mount));
59
+ mount.fiber = fiber;
60
+ await fiber;
61
+ return mount;
62
+ }
63
+ const fiber = agent.ctx.inject(['skills', 'commands', 'tools', 'systemPrompt'], scope => {
64
+ this.registerSkills(agent, scope, mount);
65
+ const t = this.ports.t ?? bindHostLocale(undefined);
66
+ mount.commands = new CommandMountRegistry(scope, t, this.ports.dataRoot);
67
+ mount.users = new UserCommandMountRegistry(scope, this.ports.panels.commands, t);
68
+ mount.commands.setSelectionPolicy((suite, name) => mount.active && this.ports.allows(agent, entryId(suite, 'commands', name)), (suite, name) => mount.active && this.registrationAllows(agent, entryId(suite, 'commands', name)), { allowDisabled: this.ports.suites !== undefined });
69
+ mount.users.setSelectionPolicy(name => mount.active && this.ports.allows(agent, 'commands:' + name), name => mount.active && this.registrationAllows(agent, 'commands:' + name), { allowDisabled: this.ports.suites !== undefined });
70
+ mount.hookFiber = scope.inject(['shell', 'sessionProjections'], hookScope => {
71
+ // The suite grant covers every hook of a suite that publishes no individual
72
+ // row; a suite that does publish them is decided hook by hook, on the exact
73
+ // identity the inventory exposed.
74
+ mount.hooks = new ExtensionHooks(hookScope, agent, suite => mount.active && this.ports.allows(agent, suiteId(suite)), (suite, event, index) => !exposesIndividualHooks(suite) || (mount.active && this.ports.allows(agent, hookResourceId(suite.sourceId, suite.id, event, index))), this.ports.dataRoot);
75
+ hookScope.effect(() => () => mount.hooks.dispose(), 'dsh-agent-plugins-market: scoped hooks');
76
+ });
77
+ mount.mcp = this.ports.mcpMounts(scope, this.ports.dataRoot);
78
+ mount.mcp.setBackendProvider(() => this.ports.catalog.mcpBackend());
79
+ mount.mcp.setOverridesProvider(async () => {
80
+ const suites = this.ports.suites === undefined
81
+ ? (await this.ports.catalog.readProjectCatalog(agent.session.header.cwd)).enabledSuites
82
+ : (await this.ports.suites(agent)).filter(suite => suite.dimension === 'project');
83
+ const overrides = await this.ports.catalog.allMcpOverrides(suites);
84
+ if (this.ports.suites === undefined)
85
+ return overrides;
86
+ const projected = new Map(overrides);
87
+ for (const suite of suites) {
88
+ const owner = suite.sourceId + '/' + suite.id;
89
+ const rows = { ...overrides.get(owner) };
90
+ for (const key of Object.keys(suite.mcp?.servers ?? {})) {
91
+ if (this.registrationAllows(agent, 'mcp:plugin:' + owner + '/' + key))
92
+ rows[key] = { ...rows[key], enabled: true };
93
+ }
94
+ projected.set(owner, rows);
95
+ }
96
+ return projected;
97
+ });
98
+ scope.systemPrompt.section({
99
+ name: 'agent-plugins:instructions',
100
+ order: 500,
101
+ text: () => mount.active
102
+ ? mount.instructions
103
+ .filter(row => this.ports.allows(agent, row.parent) && this.ports.allows(agent, row.id))
104
+ .map(row => row.text)
105
+ .join('\n\n')
106
+ : ''
107
+ });
108
+ scope.effect(() => async () => {
109
+ mount.active = false;
110
+ mount.instructions = [];
111
+ await mount.hooks?.dispose();
112
+ mount.commands?.disposeAll();
113
+ mount.users?.disposeAll();
114
+ await mount.mcp?.disposeAll();
115
+ }, 'dsh-agent-plugins-market: scoped contributors');
116
+ });
117
+ mount.fiber = fiber;
118
+ try {
119
+ await fiber;
120
+ if (!mount.commands || !mount.mcp)
121
+ throw new Error('extension-contributors-not-ready');
122
+ return mount;
123
+ }
124
+ catch (error) {
125
+ await this.dispose(agent);
126
+ throw error;
127
+ }
128
+ }
129
+ /** Called inside the session maintenance transaction, before its committed record. */
130
+ async reconcile(agent, selection) {
131
+ if (!this.ports.panels && !selection.enabledIds.some(id => id.startsWith('market:'))) {
132
+ await this.dispose(agent);
133
+ return;
134
+ }
135
+ const mount = await this.attach(agent);
136
+ for (const control of mount.controls)
137
+ control.invalidate();
138
+ if (!this.ports.panels)
139
+ return;
140
+ const [suites, backend] = await Promise.all([
141
+ this.ports.suites?.(agent) ??
142
+ Promise.all([this.ports.catalog.enabledUserSuites(), this.ports.catalog.readProjectCatalog(agent.session.header.cwd)]).then(([user, project]) => [
143
+ ...user,
144
+ ...project.enabledSuites
145
+ ]),
146
+ this.ports.catalog.mcpBackend()
147
+ ]);
148
+ const selected = suites.filter(suite => this.registrationAllows(agent, suiteId(suite)));
149
+ if (selected.some(suite => suite.activeSurfaces.hooks && suite.surfaces.hooks > 0) && !mount.hooks)
150
+ throw new Error('extension-hooks-require-shell-and-session-projections');
151
+ const diagnostics = await Promise.all([mount.commands.reconcile(selected), mount.users.reconcile(), mount.hooks?.reconcile(selected) ?? []]);
152
+ for (const group of diagnostics)
153
+ for (const diagnostic of group)
154
+ agent.ctx.logger.warn('[dsh-agent-plugins-market] ' + (typeof diagnostic === 'string' ? diagnostic : diagnostic.reason));
155
+ const instructions = [];
156
+ for (const suite of selected) {
157
+ const parent = suiteId(suite);
158
+ const { startupSkill, ...manifest } = suite.manifest;
159
+ const paths = { dataRoot: this.ports.dataRoot, projectDir: agent.session.header.cwd };
160
+ const system = await suiteInstructions([{ ...suite, manifest }], paths);
161
+ if (system.text)
162
+ instructions.push({ id: parent, parent, text: system.text });
163
+ if (startupSkill && this.registrationAllows(agent, entryId(suite, 'skills', startupSkill))) {
164
+ const withoutSystem = { ...suite };
165
+ delete withoutSystem.systemPrompt;
166
+ const startup = await suiteInstructions([withoutSystem], paths);
167
+ if (startup.text)
168
+ instructions.push({ id: entryId(suite, 'skills', startupSkill), parent, text: startup.text });
169
+ }
170
+ }
171
+ mount.instructions = instructions;
172
+ if (backend === 'host') {
173
+ await mount.mcp.reconcile([]);
174
+ // Host compatibility remains global-managed, independent of session projection.
175
+ await this.reconcileHostMcp(agent, mount, (await this.ports.catalog.readProjectCatalog(agent.session.header.cwd)).enabledSuites);
176
+ }
177
+ else {
178
+ await this.releaseHostMcp(agent, mount);
179
+ const projectMcp = selected
180
+ .filter(suite => suite.dimension === 'project')
181
+ .map(suite => suite.mcp === undefined
182
+ ? suite
183
+ : {
184
+ ...suite,
185
+ mcp: {
186
+ ...suite.mcp,
187
+ servers: Object.fromEntries(Object.entries(suite.mcp.servers).filter(([key]) => this.registrationAllows(agent, 'mcp:plugin:' + suite.sourceId + '/' + suite.id + '/' + key)))
188
+ }
189
+ });
190
+ for (const diagnostic of await mount.mcp.reconcile(projectMcp))
191
+ agent.ctx.logger.warn('[dsh-agent-plugins-market] project MCP: ' + diagnostic.reason);
192
+ }
193
+ }
194
+ async hostOperation(cwd, work) {
195
+ const pending = (this.hostQueues.get(cwd) ?? Promise.resolve()).catch(() => { }).then(work);
196
+ this.hostQueues.set(cwd, pending);
197
+ try {
198
+ await pending;
199
+ }
200
+ finally {
201
+ if (this.hostQueues.get(cwd) === pending)
202
+ this.hostQueues.delete(cwd);
203
+ }
204
+ }
205
+ async reconcileHostMcp(agent, mount, suites) {
206
+ const cwd = agent.session.header.cwd;
207
+ await this.hostOperation(cwd, async () => {
208
+ let shared = this.hostMcp.get(cwd);
209
+ if (!shared) {
210
+ const host = this.ports.hostContext;
211
+ if (!host)
212
+ throw new Error('extension-host-mcp-owner-unavailable');
213
+ let registry;
214
+ const fiber = host.inject(['tools'], scope => {
215
+ registry = this.ports.mcpMounts(scope, this.ports.dataRoot);
216
+ registry.setBackendProvider(async () => 'host');
217
+ registry.setToolNamesProvider(() => inspectToolRegistry(scope.tools).map(tool => tool.name));
218
+ registry.setOverridesProvider(async () => this.ports.catalog.allMcpOverrides((await this.ports.catalog.readProjectCatalog(cwd)).enabledSuites));
219
+ scope.effect(() => () => registry.disposeAll(), 'dsh-agent-plugins-market: shared project MCP');
220
+ });
221
+ try {
222
+ await fiber;
223
+ }
224
+ catch (error) {
225
+ await fiber.dispose();
226
+ throw error;
227
+ }
228
+ if (!registry) {
229
+ await fiber.dispose();
230
+ throw new Error('extension-host-mcp-owner-unavailable');
231
+ }
232
+ shared = { fiber, registry, agents: new Set() };
233
+ this.hostMcp.set(cwd, shared);
234
+ }
235
+ shared.agents.add(agent);
236
+ mount.hostMcpWorkspace = cwd;
237
+ for (const diagnostic of await shared.registry.reconcile(suites))
238
+ agent.ctx.logger.warn('[dsh-agent-plugins-market] project MCP: ' + diagnostic.reason);
239
+ });
240
+ }
241
+ async releaseHostMcp(agent, mount) {
242
+ const cwd = mount.hostMcpWorkspace;
243
+ if (cwd === undefined)
244
+ return;
245
+ delete mount.hostMcpWorkspace;
246
+ await this.hostOperation(cwd, async () => {
247
+ const shared = this.hostMcp.get(cwd);
248
+ if (!shared)
249
+ return;
250
+ shared.agents.delete(agent);
251
+ if (shared.agents.size > 0)
252
+ return;
253
+ try {
254
+ await shared.fiber.dispose();
255
+ }
256
+ finally {
257
+ this.hostMcp.delete(cwd);
258
+ }
259
+ });
260
+ }
261
+ committed(agent) {
262
+ for (const control of this.mounted.get(agent)?.controls ?? [])
263
+ control.invalidate();
264
+ }
265
+ /** Invalidate cached summaries and run startup hooks only after the session is durably ready. */
266
+ async ready(agent, source) {
267
+ const mount = this.mounted.get(agent);
268
+ for (const control of mount?.controls ?? [])
269
+ control.invalidate();
270
+ if (source === 'clear' || source === 'compact' || source === undefined)
271
+ return;
272
+ try {
273
+ await mount?.hooks?.start(source === 'resume' || source === 'legacy' ? 'resume' : 'startup');
274
+ }
275
+ catch (error) {
276
+ agent.ctx.logger.warn('[dsh-agent-plugins-market] SessionStart hook failed: ' + String(error));
277
+ }
278
+ }
279
+ invalidateAll() {
280
+ for (const mount of this.mounted.values())
281
+ for (const control of mount.controls)
282
+ control.invalidate();
283
+ }
284
+ toolOwnership(agent) {
285
+ return this.mounted.get(agent)?.mcp?.toolOwnership() ?? [];
286
+ }
287
+ registrations() {
288
+ return [...this.mounted.values()].flatMap(mount => [...(mount.commands?.registrations() ?? []), ...(mount.users?.registrations() ?? [])]);
289
+ }
290
+ async dispose(agent) {
291
+ const mount = this.mounted.get(agent);
292
+ if (!mount)
293
+ return;
294
+ this.mounted.delete(agent);
295
+ mount.active = false;
296
+ for (const release of mount.releaseSkills.splice(0))
297
+ release();
298
+ await mount.fiber?.dispose();
299
+ await this.releaseHostMcp(agent, mount);
300
+ }
301
+ async disposeAll() {
302
+ await Promise.all([...this.mounted.keys()].map(agent => this.dispose(agent)));
303
+ }
304
+ }
@@ -0,0 +1,15 @@
1
+ export class SurfaceToggleService {
2
+ owner;
3
+ constructor(owner) {
4
+ this.owner = owner;
5
+ }
6
+ async reload() {
7
+ await this.owner.reload();
8
+ }
9
+ currentToggles() {
10
+ return this.owner.currentToggles();
11
+ }
12
+ async set(key, enabled) {
13
+ return this.owner.setSurface(key, enabled);
14
+ }
15
+ }