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,294 @@
1
+ /** Session-owned command hooks; execution, decoding, merging, and durable records use the host protocol. */
2
+ import { readFile } from 'node:fs/promises';
3
+ import { createUserMessage } from '@deepseek-ai/dsh-llm';
4
+ import { carrierKeyOf } from '@deepseek-ai/dsh-scope';
5
+ import { DEFAULT_HOOK_TIMEOUT_MS, DEFAULT_STDERR_SUMMARY_MAX_CHARS, appendHookInvoked, appendHookResult, createDetachedRuns, matchesMatcher, mergeHookOutputs, runHook } from '@deepseek-ai/dsh-hook-protocol';
6
+ import { qualifiedSuiteId } from '../../../../market-catalog/src/index.js';
7
+ import { expandPluginPaths, pluginPathEnvironment, pluginRootOf, suiteDataDir } from '../../../../market-catalog/src/index.js';
8
+ import { normalizeHookDocuments, standaloneHookDocument } from '../../../../market-catalog/src/index.js';
9
+ import { hookConfigPath } from './hooks-mounts.js';
10
+ const CONTEXT_SOURCE = { kind: 'hooks-claude-code' };
11
+ /**
12
+ * Own one live Agent's hooks. Supply a live context injected with shell and
13
+ * sessionProjections, plus a synchronous live authorization check. Reconcile before
14
+ * awaiting start; agent/created is deliberately not observed. Dispose before the
15
+ * Agent or its context tears down. Each command rechecks authorization.
16
+ * Subagent events use the exact parent carrier, but identify the child on stdin.
17
+ * Like the host bridge, input rewrites, systemMessage and run-level halt are not
18
+ * applied; SubagentStop is observation-only. Unknown remote child cwd is empty.
19
+ * Every command receives its suite's path variables in the process environment,
20
+ * the same values its command string expands to.
21
+ */
22
+ export class ExtensionHooks {
23
+ ctx;
24
+ agent;
25
+ isSuiteAllowed;
26
+ isHookAllowed;
27
+ dataRoot;
28
+ selected = new Map();
29
+ pending = Promise.resolve();
30
+ runs = createDetachedRuns();
31
+ listeners = [];
32
+ children = new Map();
33
+ startup;
34
+ closing;
35
+ disposed = false;
36
+ revision = 0;
37
+ handler = 0;
38
+ constructor(ctx, agent, isSuiteAllowed,
39
+ /**
40
+ * Live check for one hook's own identity: the event and its declaration index,
41
+ * the same position the session inventory published a row for. Absent keeps the
42
+ * parent-suite contract, which is what a suite with no individual row requires.
43
+ */
44
+ isHookAllowed,
45
+ /** Plugin storage root; supplies the suite's data directory to hook processes. */
46
+ dataRoot) {
47
+ this.ctx = ctx;
48
+ this.agent = agent;
49
+ this.isSuiteAllowed = isSuiteAllowed;
50
+ this.isHookAllowed = isHookAllowed;
51
+ this.dataRoot = dataRoot;
52
+ this.listeners.push(ctx.on('agent/pre-step', (event, next) => {
53
+ // A submitted prompt is authored input. A claimed batch can also carry this
54
+ // plugin's own metadata, which is neither a prompt nor prompt content.
55
+ const authored = event.messages.filter(message => message.source.kind === 'user');
56
+ if (event.agent !== agent || this.disposed || authored.length === 0)
57
+ return next();
58
+ return this.track(async () => {
59
+ const merged = await this.runPoint('UserPromptSubmit', '', { ...base(agent, 'UserPromptSubmit'), prompt: text(authored.flatMap(message => message.content)) }, agent, event.turn, event.signal);
60
+ if (this.disposed)
61
+ return next();
62
+ if (merged.decision === 'deny')
63
+ return { kind: 'reject' };
64
+ const downstream = await next();
65
+ const context = contextFrom(merged);
66
+ return !this.disposed && context && downstream.kind === 'enter' ? { ...downstream, messages: [...downstream.messages, context] } : downstream;
67
+ });
68
+ }));
69
+ this.listeners.push(ctx.on('tools/pre-execute', (exec, next) => {
70
+ if (exec.agent !== agent || this.disposed)
71
+ return next();
72
+ return this.track(async () => {
73
+ const merged = await this.runPoint('PreToolUse', exec.name, { ...base(agent, 'PreToolUse'), tool_name: exec.name, tool_input: exec.arguments, tool_use_id: exec.callId }, agent, this.lastTurn(), exec.signal);
74
+ if (this.disposed)
75
+ return next();
76
+ if (merged.decision === 'deny')
77
+ return { kind: 'deny', reason: merged.reason ?? 'blocked by PreToolUse hook' };
78
+ if (merged.decision === 'ask')
79
+ return { kind: 'ask', ...(merged.reason === undefined ? {} : { reason: merged.reason }) };
80
+ return next();
81
+ });
82
+ }));
83
+ this.listeners.push(ctx.on('tools/post-execute', (exec, result, next) => {
84
+ if (exec.agent !== agent || this.disposed)
85
+ return next();
86
+ return this.track(async () => {
87
+ const merged = await this.runPoint('PostToolUse', exec.name, { ...base(agent, 'PostToolUse'), tool_name: exec.name, tool_input: exec.arguments, tool_use_id: exec.callId, tool_response: text(result.content) }, agent, this.lastTurn(), exec.signal);
88
+ if (this.disposed)
89
+ return next();
90
+ const context = contextFrom(merged);
91
+ if (merged.decision === 'deny')
92
+ return {
93
+ kind: 'block',
94
+ feedback: [{ type: 'text', text: merged.reason ?? 'blocked by PostToolUse hook' }],
95
+ ...(context ? { additionalContexts: [context] } : {})
96
+ };
97
+ const downstream = await next();
98
+ return !this.disposed && context ? { ...downstream, additionalContexts: [context, ...(downstream.additionalContexts ?? [])] } : downstream;
99
+ });
100
+ }));
101
+ this.listeners.push(ctx.on('agent/turn-stopping', event => {
102
+ if (event.agent !== agent || this.disposed)
103
+ return;
104
+ return this.track(async () => {
105
+ const merged = await this.runPoint('Stop', '', { ...base(agent, 'Stop'), stop_hook_active: false }, agent, event.turn, event.signal);
106
+ if (!this.disposed && merged.decision === 'deny')
107
+ agent.steer(createUserMessage({ content: [{ type: 'text', text: merged.reason ?? 'continue: blocked by Stop hook' }], source: CONTEXT_SOURCE }));
108
+ });
109
+ }));
110
+ const observeSubagent = this.observeSubagent.bind(this);
111
+ // Subagent lifecycle payloads omit the parent; Cordis binds this to its routing carrier.
112
+ this.listeners.push(ctx.on('subagent/start', function (info) {
113
+ if (carrierKeyOf(this) === agent)
114
+ observeSubagent('SubagentStart', info);
115
+ }));
116
+ this.listeners.push(ctx.on('subagent/end', function (info) {
117
+ if (carrierKeyOf(this) === agent)
118
+ observeSubagent('SubagentStop', info);
119
+ }));
120
+ }
121
+ /** Replace selection; malformed suites are dropped with diagnostics. Does not replay startup. */
122
+ reconcile(suites) {
123
+ if (this.disposed)
124
+ return Promise.resolve([]);
125
+ const revision = ++this.revision;
126
+ this.selected.clear();
127
+ const run = this.pending.then(async () => {
128
+ const selected = new Map();
129
+ const diagnostics = [];
130
+ for (const suite of suites) {
131
+ if (!suite.enabled || !suite.activeSurfaces.hooks || this.disposed || revision !== this.revision)
132
+ continue;
133
+ const suiteId = qualifiedSuiteId(suite.sourceId, suite.id);
134
+ try {
135
+ let raw = suite.hooks === undefined ? undefined : { hooks: suite.hooks.events };
136
+ let file = suite.manifest.path;
137
+ if (raw === undefined && suite.resources === undefined) {
138
+ const path = await hookConfigPath(suite.root);
139
+ if (path !== undefined) {
140
+ file = path;
141
+ raw = JSON.parse(await readFile(path, 'utf8'));
142
+ }
143
+ }
144
+ if (raw === undefined)
145
+ continue;
146
+ if (typeof raw !== 'object' || raw === null || Array.isArray(raw))
147
+ throw new Error('hooks must be an event table');
148
+ const errors = [];
149
+ const hooks = normalizeHookDocuments(suite.hooks?.projectRoot, [{ file, settings: standaloneHookDocument(raw) }], errors);
150
+ diagnostics.push(...errors.map(reason => ({ suiteId, reason })));
151
+ if (hooks)
152
+ selected.set(suiteId, { suite, hooks });
153
+ }
154
+ catch (error) {
155
+ diagnostics.push({ suiteId, reason: String(error) });
156
+ }
157
+ }
158
+ if (!this.disposed && revision === this.revision)
159
+ this.selected = selected;
160
+ return diagnostics;
161
+ });
162
+ this.pending = run.then(() => undefined);
163
+ return run;
164
+ }
165
+ /** Run SessionStart once, after already-submitted reconciliation, and await its context injection. */
166
+ start(source, signal) {
167
+ if (this.startup)
168
+ return this.startup;
169
+ if (this.disposed)
170
+ return Promise.resolve();
171
+ this.startup = this.track(async () => {
172
+ await this.pending;
173
+ const merged = await this.runPoint('SessionStart', source, { ...base(this.agent, 'SessionStart'), source }, this.agent, undefined, signal);
174
+ const context = contextFrom(merged);
175
+ if (!this.disposed && !signal?.aborted && context)
176
+ this.agent.inject(context);
177
+ });
178
+ return this.startup;
179
+ }
180
+ /** Stop admission, unregister listeners, abort and await owned runs. Repeated calls share completion. */
181
+ dispose() {
182
+ if (this.closing)
183
+ return this.closing;
184
+ this.disposed = true;
185
+ this.selected.clear();
186
+ this.children.clear();
187
+ for (const unregister of this.listeners.splice(0))
188
+ unregister();
189
+ this.closing = Promise.all([this.runs.drain(), this.pending]).then(() => undefined);
190
+ return this.closing;
191
+ }
192
+ observeSubagent(point, info) {
193
+ if (this.disposed)
194
+ return;
195
+ const child = this.children.get(info.runId) ?? (info.local ? this.ctx.get('agents')?.get(info.id) : undefined);
196
+ if (point === 'SubagentStart' && child)
197
+ this.children.set(info.runId, child);
198
+ if (point === 'SubagentStop')
199
+ this.children.delete(info.runId);
200
+ void this.track(async () => {
201
+ const merged = await this.runPoint(point, 'general-purpose', {
202
+ ...base(child, point, info.id),
203
+ agent_id: info.id,
204
+ agent_type: 'general-purpose',
205
+ ...(point === 'SubagentStop' ? { stop_hook_active: false } : {})
206
+ }, child);
207
+ const context = contextFrom(merged);
208
+ if (!this.disposed && point === 'SubagentStart' && context && child && this.children.get(info.runId) === child)
209
+ child.inject(context);
210
+ }).catch(error => {
211
+ this.ctx.logger.warn('extension-hooks: ' + point + ' hook failed: ' + String(error));
212
+ });
213
+ }
214
+ track(work) {
215
+ const run = work();
216
+ this.runs.track(run);
217
+ return run;
218
+ }
219
+ lastTurn() {
220
+ const boundary = this.ctx.sessionProjections.stateOf(this.agent.session, 'turnBoundary');
221
+ return boundary?.openTurnStartSeq == null ? undefined : boundary.lastTurn;
222
+ }
223
+ async runPoint(point, query, payload, subject, turn, signal) {
224
+ const outputs = [];
225
+ const ownerSignal = signal ? AbortSignal.any([signal, this.runs.signal]) : this.runs.signal;
226
+ for (const [key, selection] of this.selected) {
227
+ const { suite, hooks } = selection;
228
+ const cwd = subject?.session.header.cwd;
229
+ const projectDir = hooks.projectRoot ?? cwd;
230
+ // One context drives both the inline substitution and the process
231
+ // environment, so a command and its own process.env reads agree.
232
+ const root = pluginRootOf(suite);
233
+ const data = root === undefined || this.dataRoot === undefined ? undefined : suiteDataDir(this.dataRoot, suite.sourceId, suite.id);
234
+ const pathContext = { ...(root === undefined ? {} : { root }), ...(data === undefined ? {} : { data }), ...(projectDir === undefined ? {} : { projectDir }) };
235
+ const env = pluginPathEnvironment(pathContext);
236
+ // The declaration index counts every command hook of this event in declaration
237
+ // order and across matcher groups, exactly as the session inventory numbered
238
+ // its rows: a hook whose matcher does not apply still advances the position.
239
+ let index = 0;
240
+ for (const group of hooks.events[point] ?? []) {
241
+ const matched = matchesMatcher(group.matcher, query, 'claude-code');
242
+ for (const hook of group.hooks) {
243
+ const position = index++;
244
+ if (!matched)
245
+ continue;
246
+ if (this.disposed || ownerSignal.aborted || this.selected.get(key) !== selection)
247
+ break;
248
+ let allowed = false;
249
+ try {
250
+ allowed = this.isSuiteAllowed(suite) === true && this.isHookAllowed?.(suite, point, position) !== false;
251
+ }
252
+ catch (error) {
253
+ this.ctx.logger.warn('extension-hooks: authorization failed for ' + key + ': ' + String(error));
254
+ }
255
+ if (!allowed)
256
+ continue;
257
+ const handlerId = 'extension-hooks:' + this.agent.id + ':' + key + ':' + point + ':' + ++this.handler;
258
+ if (subject && turn !== undefined)
259
+ appendHookInvoked(subject.session, { turn, point, dialect: 'claude-code', handlerId, ...(group.matcher === undefined ? {} : { matcher: group.matcher }) });
260
+ const { output, durationMs } = await runHook(this.ctx.shell, { command: expandPluginPaths(hook.command, pathContext), ...(hook.timeout === undefined ? {} : { timeoutSec: hook.timeout }) }, {
261
+ payload,
262
+ defaultTimeoutMs: DEFAULT_HOOK_TIMEOUT_MS,
263
+ signal: ownerSignal,
264
+ trailingNewline: true,
265
+ expectedEventName: point,
266
+ ...(cwd === undefined ? {} : { cwd }),
267
+ ...(Object.keys(env).length === 0 ? {} : { env })
268
+ }, () => performance.now());
269
+ if (subject && turn !== undefined)
270
+ appendHookResult(subject.session, { turn, point, handlerId, output, durationMs, stderrSummaryMaxChars: DEFAULT_STDERR_SUMMARY_MAX_CHARS });
271
+ if (output.updatedInput !== undefined || output.systemMessage !== undefined || output.continue === false)
272
+ this.ctx.logger.warn('extension-hooks: ' + key + ' ' + point + ': updatedInput, systemMessage, and run-level halt are not supported by the host bridge');
273
+ if (!this.disposed && !ownerSignal.aborted)
274
+ outputs.push(output);
275
+ }
276
+ }
277
+ }
278
+ return mergeHookOutputs(outputs);
279
+ }
280
+ }
281
+ function base(agent, point, id = '') {
282
+ return { session_id: agent?.session.header.id ?? id, transcript_path: '', cwd: agent?.session.header.cwd ?? '', hook_event_name: point };
283
+ }
284
+ function text(content) {
285
+ return content
286
+ .filter(block => block.type === 'text')
287
+ .map(block => block.text)
288
+ .join('');
289
+ }
290
+ function contextFrom(merged) {
291
+ return merged.additionalContext.length === 0
292
+ ? undefined
293
+ : createUserMessage({ content: merged.additionalContext.map(text => ({ type: 'text', text })), source: CONTEXT_SOURCE });
294
+ }
@@ -0,0 +1,122 @@
1
+ /**
2
+ * One declared command hook's bounded dry run.
3
+ *
4
+ * The declaration is resolved by the caller from the scanned catalog; this
5
+ * module only runs an already-resolved command. A client never supplies the
6
+ * command text, and the run directory is always the user's home directory, so a
7
+ * dry run cannot be steered at an arbitrary path or an arbitrary program.
8
+ *
9
+ * The host shell is reached as the executor seam (resolve plus execute),
10
+ * without injecting shell, because this read may run outside any session
11
+ * fiber. A profile that provides no shell answers a result-level error instead
12
+ * of throwing.
13
+ */
14
+ import { homedir } from 'node:os';
15
+ /** Per-stream cap, in characters, on the output one result carries. */
16
+ export const HOOK_RUN_MAX_OUTPUT_CHARS = 32_768;
17
+ /** Timeout applied when the declaration carries none. */
18
+ export const HOOK_RUN_DEFAULT_TIMEOUT_SEC = 30;
19
+ /** Hard ceiling on any dry run, whatever the declaration asks for. */
20
+ export const HOOK_RUN_MAX_TIMEOUT_MS = 60_000;
21
+ /** A resolved declaration that named no runnable hook. */
22
+ export const HOOK_RUN_UNKNOWN_DECLARATION = 'hook-run-unknown-declaration';
23
+ /** A matched declaration that carries no command (a rejected declaration exists only as a diagnostic). */
24
+ export const HOOK_RUN_NO_COMMAND = 'hook-run-no-command';
25
+ /** No shell executor is mounted in this profile. */
26
+ export const HOOK_RUN_SHELL_UNAVAILABLE = 'hook-run-shell-unavailable';
27
+ /** The executor rejected the run before it produced an outcome. */
28
+ export const HOOK_RUN_FAILED = 'hook-run-failed';
29
+ /**
30
+ * Narrow a resolved shell seam to the executor surface, or answer undefined.
31
+ *
32
+ * The seam is read without injecting shell, so its value is untyped at the
33
+ * boundary. A service that only exposes the legacy run shape is not an
34
+ * executor and is reported as unavailable rather than run against.
35
+ * @param value - the service resolved from the context, if any.
36
+ * @returns the executor surface, or undefined when no executor is mounted.
37
+ */
38
+ export function hookRunShellOf(value) {
39
+ if (typeof value !== 'object' || value === null)
40
+ return undefined;
41
+ const shell = value;
42
+ return typeof shell.resolve === 'function' && typeof shell.execute === 'function' ? shell : undefined;
43
+ }
44
+ /**
45
+ * The synthetic stdin payload one dry run writes.
46
+ *
47
+ * It carries the same event name the declaration fired under and the directory
48
+ * the command runs in, so a script that reads stdin sees a coherent event,
49
+ * plus dry_run: true so it can refuse to act for real.
50
+ * @param event - the declared event the hook belongs to.
51
+ * @param cwd - the directory the command runs in.
52
+ * @returns the JSON payload, newline terminated.
53
+ */
54
+ export function hookRunStdin(event, cwd) {
55
+ return (JSON.stringify({
56
+ hook_event_name: event,
57
+ session_id: 'dry-run',
58
+ transcript_path: '',
59
+ cwd,
60
+ permission_mode: 'default',
61
+ dry_run: true
62
+ }) + '\n');
63
+ }
64
+ /** One bounded stream: the text a result carries and whether it was cut. */
65
+ function bounded(text, truncated) {
66
+ return text.length <= HOOK_RUN_MAX_OUTPUT_CHARS ? { text, truncated } : { text: text.slice(0, HOOK_RUN_MAX_OUTPUT_CHARS), truncated: true };
67
+ }
68
+ /** One result that reports a failure without running anything. */
69
+ export function hookRunFailure(code) {
70
+ return { cwd: homedir(), stdout: '', stderr: '', durationMs: 0, timedOut: false, truncated: false, error: code };
71
+ }
72
+ /**
73
+ * Run one resolved command in the home directory under a bounded timeout.
74
+ *
75
+ * The timeout is the declaration's own, defaulted to HOOK_RUN_DEFAULT_TIMEOUT_SEC
76
+ * and capped at HOOK_RUN_MAX_TIMEOUT_MS; the command's cwd is the home
77
+ * directory whatever the caller passes elsewhere. Both streams are capped
78
+ * independently, and an executor rejection becomes a result, so the request
79
+ * never fails with a thrown error.
80
+ * @param shell - the resolved host shell executor.
81
+ * @param command - the declaration's own command text.
82
+ * @param options - the event, declared timeout, and suite environment.
83
+ * @returns the bounded result of the run.
84
+ */
85
+ export async function runHookDryRun(shell, command, options) {
86
+ const cwd = homedir();
87
+ const timeoutMs = Math.min((options.timeoutSec ?? HOOK_RUN_DEFAULT_TIMEOUT_SEC) * 1000, HOOK_RUN_MAX_TIMEOUT_MS);
88
+ const started = performance.now();
89
+ try {
90
+ const spec = shell.resolve({
91
+ command,
92
+ workdir: cwd,
93
+ timeoutMs,
94
+ stdin: hookRunStdin(options.event, cwd),
95
+ stdoutMaxBytes: HOOK_RUN_MAX_OUTPUT_CHARS,
96
+ ...(options.env === undefined ? {} : { env: options.env })
97
+ });
98
+ const result = await (await shell.execute(spec)).result();
99
+ const stdout = bounded(result.stdout.text, result.stdout.truncated);
100
+ const stderr = bounded(result.stderr.text, result.stderr.truncated);
101
+ return {
102
+ cwd,
103
+ ...(result.exitCode === null ? {} : { exitCode: result.exitCode }),
104
+ stdout: stdout.text,
105
+ stderr: stderr.text,
106
+ durationMs: performance.now() - started,
107
+ timedOut: result.timedOut,
108
+ truncated: stdout.truncated || stderr.truncated
109
+ };
110
+ }
111
+ catch (error) {
112
+ return {
113
+ cwd,
114
+ stdout: '',
115
+ stderr: '',
116
+ durationMs: performance.now() - started,
117
+ timedOut: false,
118
+ truncated: false,
119
+ error: error instanceof Error ? error.message : String(error)
120
+ };
121
+ }
122
+ }
@@ -19,7 +19,7 @@ import { tmpdir } from 'node:os';
19
19
  import { createHash } from 'node:crypto';
20
20
  import { join } from 'node:path';
21
21
  import { SerialPassQueue } from '../core/mount-lifecycle.js';
22
- import { qualifiedSuiteId } from '../../catalog/paths.js';
22
+ import { qualifiedSuiteId } from '../../../../market-catalog/src/index.js';
23
23
  export class HooksMountRegistry {
24
24
  ctx;
25
25
  live = new Map();
@@ -1,29 +1,30 @@
1
1
  import { CommandMountRegistry } from './commands-mounts.js';
2
- import { expandPluginPaths, pluginRootOf } from '../../catalog/plugin-variables.js';
3
- import { suiteDataDir } from '../../catalog/paths.js';
4
- import { McpMountRegistry } from '../mcp/mcp-mounts.js';
2
+ import { expandPluginPaths, pluginRootOf } from '../../../../market-catalog/src/index.js';
3
+ import { suiteDataDir } from '../../../../market-catalog/src/index.js';
5
4
  import { HooksMountRegistry } from './hooks-mounts.js';
6
5
  import { readFile } from 'node:fs/promises';
7
- import { stripFrontmatter } from '../../catalog/skills-parse.js';
6
+ import { stripFrontmatter } from '../../../../market-catalog/src/index.js';
8
7
  import { parseFrontmatterRecord } from '../../application/panels/user-store.js';
9
8
  /** Mount under existing and newly created agents; the caller owns refresh and teardown. */
10
- export function mountProjectCommands(ctx, catalog, t, dataRoot) {
11
- return mountProjectSurface(ctx, catalog, 'commands', scope => new CommandMountRegistry(scope, t, dataRoot));
9
+ export function mountProjectCommands(ctx, catalog, t, dataRoot, allows) {
10
+ return mountProjectSurface(ctx, catalog, 'commands', scope => new CommandMountRegistry(scope, t, dataRoot), false, allows);
12
11
  }
13
12
  /** MCP uses a separate injected child so network startup cannot delay local commands. */
14
- export function mountProjectMcp(ctx, catalog, dataRoot) {
13
+ export function mountProjectMcp(ctx, catalog, dataRoot, mcpMounts, allows) {
15
14
  return mountProjectSurface(ctx, catalog, 'tools', scope => {
16
- const registry = new McpMountRegistry(scope, dataRoot);
15
+ const registry = mcpMounts(scope, dataRoot);
17
16
  registry.setBackendProvider(() => catalog.mcpBackend());
18
17
  return registry;
19
- });
18
+ }, false, allows);
20
19
  }
21
20
  /** Wait for both bridge dependencies before attempting a scoped hook mount. */
22
21
  export function mountProjectHooks(ctx, catalog) {
23
22
  return mountProjectSurface(ctx, catalog, ['shell', 'sessionProjections'], scope => new HooksMountRegistry(scope));
24
23
  }
25
24
  /** Kimi's startup skill and system-prompt declarations use the existing scoped prompt service. */
26
- export function mountSuiteInstructions(ctx, catalog, dataRoot) {
25
+ export function mountSuiteInstructions(ctx, catalog, dataRoot,
26
+ /** Whether one user-dimension suite may contribute instructions; absent allows all. */
27
+ suiteAllowed) {
27
28
  return mountProjectSurface(ctx, catalog, 'systemPrompt', (scope, agent) => {
28
29
  let text = '';
29
30
  const host = scope;
@@ -31,7 +32,8 @@ export function mountSuiteInstructions(ctx, catalog, dataRoot) {
31
32
  return {
32
33
  async reconcile(projectSuites) {
33
34
  const projectDir = agent.session.header.cwd;
34
- const result = await suiteInstructions([...(await catalog.enabledUserSuites()), ...projectSuites], {
35
+ const userSuites = (await catalog.enabledUserSuites()).filter(suite => suiteAllowed?.(suite) !== false);
36
+ const result = await suiteInstructions([...userSuites, ...projectSuites], {
35
37
  ...(dataRoot === undefined ? {} : { dataRoot }),
36
38
  ...(projectDir === undefined ? {} : { projectDir })
37
39
  });
@@ -82,7 +84,14 @@ export async function suiteInstructions(suites, paths = {}) {
82
84
  }
83
85
  return { text: chunks.join('\n\n'), errors };
84
86
  }
85
- function mountProjectSurface(ctx, catalog, service, create, withoutProject = false) {
87
+ function mountProjectSurface(ctx, catalog, service, create, withoutProject = false,
88
+ /**
89
+ * The workspace switch this surface answers, read on every refresh. A
90
+ * switched-off surface reconciles to an empty snapshot, which is the same
91
+ * "nothing wanted" pass a project with no such files already produces: the
92
+ * agent-scoped seat stays attached and only the data it serves collapses.
93
+ */
94
+ allows) {
86
95
  const host = ctx;
87
96
  const mounts = new Map();
88
97
  const serviceLabel = typeof service === 'string' ? service : service.join(',');
@@ -101,7 +110,8 @@ function mountProjectSurface(ctx, catalog, service, create, withoutProject = fal
101
110
  queue = queue.catch(warn).then(async () => {
102
111
  if (!active)
103
112
  return;
104
- const snapshot = cwd === undefined ? { enabledSuites: [] } : await catalog.readProjectCatalog(cwd);
113
+ const off = allows?.() === false;
114
+ const snapshot = cwd === undefined || off ? { enabledSuites: [] } : await catalog.readProjectCatalog(cwd);
105
115
  if (!active)
106
116
  return;
107
117
  const diagnostics = await registry.reconcile([...snapshot.enabledSuites]);