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,120 @@
1
+ /**
2
+ * Session progress for the extension window: whether a session carries work the
3
+ * user authored.
4
+ *
5
+ * The host folds this answer once per session through its projection registry and
6
+ * then advances it per committed event, so a window read no longer scans the whole
7
+ * event log. The wire meaning is unchanged: a started turn, or a user/inbox
8
+ * message this plugin did not author. A host that publishes no projection registry
9
+ * falls back to the historical log scan instead of answering a constant.
10
+ *
11
+ * @module runtime/host/extension-progress
12
+ */
13
+ import { z } from 'zod';
14
+ import { EXTENSION_SESSION_SOURCE } from './extension-session-state.js';
15
+ /** The projection key this plugin owns; host-only, so it never reaches a client view. */
16
+ export const EXTENSION_PROGRESS_KEY = 'marketExtensionProgress';
17
+ const STARTED = { started: true };
18
+ const BLANK = { started: false };
19
+ /**
20
+ * Whether one committed event is authored progress.
21
+ *
22
+ * This is the definition the wire field has always carried: a started turn, or a
23
+ * user/inbox message whose source is not this plugin's own and carries no form.
24
+ * @param event - one committed session event.
25
+ * @returns true when the event proves the user started work.
26
+ */
27
+ export function eventCarriesProgress(event) {
28
+ if (event.type === 'turn/start')
29
+ return true;
30
+ const messages = event.type === 'user/message' ? [event.data] : event.type === 'agent/inbox/spliced' ? event.data.inserted : [];
31
+ return messages.some(message => message.source.kind !== EXTENSION_SESSION_SOURCE && !('form' in message.source));
32
+ }
33
+ /** The host fold this plugin registers: monotonic, because progress never un-happens. */
34
+ export const extensionProgressProjection = {
35
+ key: EXTENSION_PROGRESS_KEY,
36
+ stateVersion: 1,
37
+ stateSchema: z.object({ started: z.boolean() }),
38
+ init: () => BLANK,
39
+ apply: (state, event) => (state.started || !eventCarriesProgress(event) ? state : STARTED)
40
+ };
41
+ /**
42
+ * Read progress from the log itself.
43
+ *
44
+ * The compatibility fallback for a host without the projection registry. The
45
+ * synchronous full-log reader is deprecated host-side; this call carries the
46
+ * deferred-migration waiver the deprecation decision allows, and disappears when
47
+ * every supported host publishes the registry.
48
+ * @param session - session whose log is scanned.
49
+ * @returns true when the log carries authored progress.
50
+ */
51
+ export function scanExtensionProgress(session) {
52
+ return session.snapshotEvents().some(eventCarriesProgress);
53
+ }
54
+ /**
55
+ * Owns this plugin's projection registration and answers one session's progress.
56
+ *
57
+ * The injected callback re-runs whenever a required service changes, so the
58
+ * reader guards it with its own disposal flag and owns the injected fiber: a
59
+ * disposed reader never registers again, and an older effect cleanup never
60
+ * clears a newer registration pointer.
61
+ */
62
+ export class ExtensionProgressReader {
63
+ ctx;
64
+ unregister;
65
+ injection;
66
+ disposed = false;
67
+ /** Settles once the current registration attempt has run; production reads do not await it. */
68
+ ready;
69
+ /**
70
+ * Register the projection for the lifetime of the calling context.
71
+ * @param ctx - context whose fiber owns the registration.
72
+ */
73
+ constructor(ctx) {
74
+ this.ctx = ctx;
75
+ this.injection = this.ctx.inject(['sessionProjections'], scoped => {
76
+ if (this.disposed)
77
+ return;
78
+ scoped.effect(() => {
79
+ if (this.disposed)
80
+ return () => { };
81
+ const dispose = scoped.sessionProjections.register(extensionProgressProjection);
82
+ this.unregister = dispose;
83
+ return () => {
84
+ // Identity guard: a cleanup for an older registration must not clear a newer one.
85
+ if (this.unregister === dispose)
86
+ this.unregister = undefined;
87
+ dispose();
88
+ };
89
+ }, 'dsh-agent-plugins-market: extension progress projection');
90
+ });
91
+ this.ready = Promise.resolve(this.injection);
92
+ }
93
+ /** True while this plugin's projection is registered in the live registry. */
94
+ get registered() {
95
+ return this.unregister !== undefined;
96
+ }
97
+ /**
98
+ * Whether one session carries authored progress.
99
+ * @param session - session to answer for.
100
+ * @returns the folded answer, or the log scan when no registry is published.
101
+ */
102
+ read(session) {
103
+ const state = this.ctx.get('sessionProjections')?.stateOf(session, EXTENSION_PROGRESS_KEY);
104
+ return state === undefined ? scanExtensionProgress(session) : state.started;
105
+ }
106
+ /**
107
+ * Unregister the projection and release the injected fiber, so a registry that
108
+ * arrives or cycles later cannot register this reader again.
109
+ * @returns after the injected fiber has unloaded.
110
+ */
111
+ async dispose() {
112
+ this.disposed = true;
113
+ const dispose = this.unregister;
114
+ this.unregister = undefined;
115
+ dispose?.();
116
+ const injection = this.injection;
117
+ this.injection = undefined;
118
+ await injection?.dispose();
119
+ }
120
+ }
@@ -0,0 +1,405 @@
1
+ /** Session-addressed preset operations; only acknowledged session changes replace live contributions. */
2
+ import { isAbsolute } from 'node:path';
3
+ import { SessionId } from '@deepseek-ai/dsh-session';
4
+ import { ExtensionPresetStore, ExtensionPresetError } from '../../application/state/extension-presets.js';
5
+ import { loadResourceFilters } from '../../application/state/resource-filters.js';
6
+ import { extensionResourceEnabled } from '../../application/extension-authorization.js';
7
+ import { CONFIGURATION_PARENT_IDS, captureExtensionSelection } from '../../../../market-contracts/src/contracts/extension-presets.js';
8
+ import { ExtensionSessionState } from './extension-session-state.js';
9
+ import { ExtensionProgressReader } from './extension-progress.js';
10
+ function failure(code) {
11
+ return Object.assign(new Error(code), { code });
12
+ }
13
+ export function extensionWorkspace(agent) {
14
+ const cwd = agent.session.header.cwd;
15
+ if (typeof cwd !== 'string' || !isAbsolute(cwd))
16
+ throw failure('extension-workspace-unavailable');
17
+ return cwd;
18
+ }
19
+ export class ExtensionRuntime {
20
+ ctx;
21
+ ports;
22
+ state;
23
+ store;
24
+ /** Folded session progress; the log scan is only the no-registry fallback. */
25
+ progress;
26
+ resources = new Map();
27
+ /** Agents whose cached inventory predates the current catalog; authorization fails closed until re-read. */
28
+ stale = new Set();
29
+ /** Bumped on every catalog change: a read that began earlier may not publish its answer. */
30
+ epoch = 0;
31
+ dirty = new Set();
32
+ /** Eligible inventory at the last successful rebuild; selection and current availability still gate every call. */
33
+ registeredIds = new Map();
34
+ appliedEpochs = new Map();
35
+ refreshing = new Map();
36
+ lifetime = new AbortController();
37
+ disposed = false;
38
+ /** Per-agent read sequence: a slow earlier response must not overwrite a newer inventory. */
39
+ reads = new Map();
40
+ targets = new Map();
41
+ off = [];
42
+ constructor(ctx, ports) {
43
+ this.ctx = ctx;
44
+ this.ports = ports;
45
+ this.store = new ExtensionPresetStore(ports.dataRoot);
46
+ this.progress = new ExtensionProgressReader(ctx);
47
+ this.state = new ExtensionSessionState(ctx, {
48
+ ...(ports.eligible === undefined ? {} : { eligible: (agent) => ports.eligible?.(agent) === true }),
49
+ initialSelection: (agent, source) => this.initialSelection(agent, source),
50
+ committed: agent => {
51
+ if (this.appliedEpochs.get(agent) === this.epoch)
52
+ this.dirty.delete(agent);
53
+ try {
54
+ ports.committed?.(agent);
55
+ }
56
+ catch (error) {
57
+ this.dirty.add(agent);
58
+ throw error;
59
+ }
60
+ },
61
+ applySelection: async (agent, selection) => {
62
+ const epoch = this.epoch;
63
+ await this.refreshInventory(agent);
64
+ this.targets.set(agent, selection);
65
+ try {
66
+ const receipt = await ports.applySelection(agent, selection);
67
+ if (!this.stale.has(agent) && epoch === this.epoch) {
68
+ this.appliedEpochs.set(agent, epoch);
69
+ this.registeredIds.set(agent, this.availableIds(agent));
70
+ }
71
+ return receipt;
72
+ }
73
+ finally {
74
+ this.targets.delete(agent);
75
+ }
76
+ }
77
+ });
78
+ this.off.push(ctx.on('agent/created', async ({ agent, source }) => {
79
+ await ports.ready?.(agent, source);
80
+ }));
81
+ this.off.push(ctx.on('agent/disposed', ({ agent }) => {
82
+ this.resources.delete(agent);
83
+ this.targets.delete(agent);
84
+ this.dirty.delete(agent);
85
+ this.stale.delete(agent);
86
+ this.reads.delete(agent);
87
+ this.registeredIds.delete(agent);
88
+ this.appliedEpochs.delete(agent);
89
+ }));
90
+ }
91
+ async start() {
92
+ await this.state.start();
93
+ for (const agent of this.ctx.agents.list())
94
+ await this.ports.ready?.(agent, 'legacy');
95
+ }
96
+ ready(agent) {
97
+ try {
98
+ return this.state.read(agent) !== undefined;
99
+ }
100
+ catch {
101
+ return false;
102
+ }
103
+ }
104
+ allows(agent, resourceId, suiteId) {
105
+ if (this.stale.has(agent))
106
+ return false;
107
+ if (this.dirty.has(agent) && !this.registeredIds.get(agent)?.has(resourceId))
108
+ return false;
109
+ try {
110
+ const snapshot = this.state.read(agent);
111
+ return snapshot !== undefined && this.selected(agent, snapshot.selection, resourceId, suiteId);
112
+ }
113
+ catch {
114
+ return false;
115
+ }
116
+ }
117
+ availableIds(agent) {
118
+ return new Set((this.resources.get(agent) ?? []).filter(row => row.available && row.control !== 'global-only').map(row => row.id));
119
+ }
120
+ /** Registration alone may inspect a pending target; execution must call allows. */
121
+ registrationAllows(agent, resourceId, suiteId) {
122
+ if (this.stale.has(agent))
123
+ return false;
124
+ const target = this.targets.get(agent);
125
+ return target === undefined ? this.allows(agent, resourceId, suiteId) : this.selected(agent, target, resourceId, suiteId);
126
+ }
127
+ selected(agent, selection, resourceId, suiteId) {
128
+ const resources = this.resources.get(agent) ?? [];
129
+ const row = resources.find(resource => resource.id === resourceId);
130
+ // A configuration parent publishes no row anywhere: the hooks bridge and the
131
+ // mount filter still address it by its suite id, so the grant is derived from
132
+ // the children it owns, exactly as extensionResourceEnabled derives it for a
133
+ // parent row that does exist.
134
+ if (row === undefined) {
135
+ if (!CONFIGURATION_PARENT_IDS.has(resourceId))
136
+ return false;
137
+ return resources.some(child => child.suiteResourceId === resourceId && extensionResourceEnabled(child, selection, resources));
138
+ }
139
+ // The caller names the suite with a bare 'source/suite' while the selection
140
+ // holds 'market:source/suite' resource ids, and extensionResourceEnabled
141
+ // already requires the authoritative parent (suiteResourceId) to be selected
142
+ // and available. Comparing the caller's suiteId here could only ever deny a
143
+ // granted call, so the argument is deliberately not consulted.
144
+ void suiteId;
145
+ return extensionResourceEnabled(row, selection, resources);
146
+ }
147
+ /**
148
+ * A catalog change can revoke a global resource at any moment, so every live
149
+ * agent's cached inventory is dropped and authorization denies until the
150
+ * inventory has been re-read from the new catalog. Callers never wait for a
151
+ * panel poll to observe a disable or uninstall.
152
+ */
153
+ invalidate() {
154
+ this.epoch += 1;
155
+ for (const agent of this.ctx.agents.list()) {
156
+ if (this.ports.eligible?.(agent) === false)
157
+ continue;
158
+ this.stale.add(agent);
159
+ this.dirty.add(agent);
160
+ }
161
+ }
162
+ /** Re-read every live agent's inventory; an agent whose read fails stays denied. */
163
+ async refreshAll() {
164
+ await Promise.all(this.ctx.agents
165
+ .list()
166
+ .filter(agent => this.ports.eligible?.(agent) !== false)
167
+ .map(agent => this.refreshAgent(agent)));
168
+ }
169
+ async refreshAgent(agent) {
170
+ if (this.disposed || !this.dirty.has(agent) || this.refreshing.has(agent))
171
+ return;
172
+ const work = async () => {
173
+ const epoch = this.epoch;
174
+ await agent.runMaintenance(async (signal) => {
175
+ const snapshot = this.state.status(agent);
176
+ if (!snapshot.ready || !snapshot.selection)
177
+ return;
178
+ await this.refreshInventory(agent);
179
+ signal.throwIfAborted();
180
+ if (this.stale.has(agent))
181
+ return;
182
+ this.targets.set(agent, snapshot.selection);
183
+ let receipt = undefined;
184
+ try {
185
+ receipt = await this.ports.applySelection(agent, snapshot.selection);
186
+ signal.throwIfAborted();
187
+ if (epoch !== this.epoch) {
188
+ const staleReceipt = receipt;
189
+ receipt = undefined;
190
+ await staleReceipt?.rollback();
191
+ return;
192
+ }
193
+ receipt?.commit();
194
+ }
195
+ catch (error) {
196
+ try {
197
+ await receipt?.rollback();
198
+ }
199
+ catch (cleanupError) {
200
+ this.ctx.logger.warn(String(cleanupError));
201
+ }
202
+ throw error;
203
+ }
204
+ finally {
205
+ this.targets.delete(agent);
206
+ }
207
+ this.registeredIds.set(agent, this.availableIds(agent));
208
+ this.dirty.delete(agent);
209
+ try {
210
+ this.ports.committed?.(agent);
211
+ }
212
+ catch (error) {
213
+ this.dirty.add(agent);
214
+ throw error;
215
+ }
216
+ });
217
+ };
218
+ if (agent.status !== 'idle') {
219
+ // Availability can revoke a capability during a turn without taking over the host's input queue.
220
+ try {
221
+ await this.refreshInventory(agent);
222
+ }
223
+ catch (error) {
224
+ this.ctx.logger.warn('extension inventory refresh: ' + String(error));
225
+ }
226
+ let removeAbort = () => { };
227
+ const aborted = new Promise(resolve => {
228
+ const stop = () => resolve();
229
+ this.lifetime.signal.addEventListener('abort', stop, { once: true });
230
+ removeAbort = () => this.lifetime.signal.removeEventListener('abort', stop);
231
+ });
232
+ const deferred = Promise.race([agent.whenIdle(), aborted]).then(async () => {
233
+ removeAbort();
234
+ this.refreshing.delete(agent);
235
+ if (!this.disposed && this.ctx.agents.get(agent.id) === agent)
236
+ await this.refreshAgent(agent);
237
+ });
238
+ this.refreshing.set(agent, deferred);
239
+ void deferred.catch(error => this.ctx.logger.warn('extension refresh: ' + String(error)));
240
+ return;
241
+ }
242
+ const startedEpoch = this.epoch;
243
+ const pending = work().catch(error => {
244
+ this.ctx.logger.warn('extension refresh: ' + String(error));
245
+ });
246
+ this.refreshing.set(agent, pending);
247
+ await pending;
248
+ this.refreshing.delete(agent);
249
+ if (!this.disposed && this.dirty.has(agent) && startedEpoch !== this.epoch)
250
+ await this.refreshAgent(agent);
251
+ }
252
+ async refreshInventory(agent) {
253
+ const epoch = this.epoch;
254
+ const sequence = (this.reads.get(agent) ?? 0) + 1;
255
+ this.reads.set(agent, sequence);
256
+ const resources = await this.ports.inventory(agent);
257
+ // Publish only when this is still the newest read and the catalog has not
258
+ // changed since it started: a read that predates a revoke must never clear
259
+ // the stale mark, and a slow answer must never overwrite a newer inventory.
260
+ if (this.reads.get(agent) === sequence && epoch === this.epoch) {
261
+ this.resources.set(agent, resources);
262
+ this.stale.delete(agent);
263
+ if (this.dirty.has(agent))
264
+ this.ports.committed?.(agent);
265
+ }
266
+ return resources;
267
+ }
268
+ /** The settings Hooks tab: sessionless by design, so no agent is resolved and no session state is consulted. */
269
+ async hooksOverview() {
270
+ if (this.ports.hooksOverview === undefined)
271
+ throw failure('extension-hooks-unavailable');
272
+ return this.ports.hooksOverview();
273
+ }
274
+ /** One declared hook's dry run: the composition resolves the command, this service only gates availability and forwards. */
275
+ async hookRun(input) {
276
+ if (this.ports.hookRun === undefined)
277
+ throw failure('extension-hook-run-unavailable');
278
+ return this.ports.hookRun(input);
279
+ }
280
+ agent(sessionId) {
281
+ const agent = this.ctx.agents.get(SessionId(sessionId));
282
+ if (!agent)
283
+ throw failure('extension-session-not-found');
284
+ extensionWorkspace(agent);
285
+ return agent;
286
+ }
287
+ async initialSelection(agent, source) {
288
+ const workspace = extensionWorkspace(agent);
289
+ const resources = await this.refreshInventory(agent);
290
+ const library = await this.store.read(workspace);
291
+ const preset = source === 'legacy' ? undefined : library.presets.find(row => row.id === library.defaultPresetId);
292
+ if (preset)
293
+ return captureExtensionSelection(preset, []);
294
+ const legacy = source === 'legacy' ? await loadResourceFilters(this.ports.dataRoot, workspace) : undefined;
295
+ const available = resources.filter(row => row.control !== 'global-only' &&
296
+ row.available &&
297
+ row.globalEnabled !== false &&
298
+ // The legacy resource filter predates the hooks face, so it carries no
299
+ // evidence for it; those rows select like any other when no filter ran.
300
+ (legacy === undefined || row.face === 'hooks' || (legacy.toggles[row.face] && !legacy.offEntries[row.face]?.includes(row.id))));
301
+ // The guard set keeps every available id, the configuration parents
302
+ // included: the child-keeps-parent check below must still see them. Only
303
+ // the published selection drops a configuration parent, whose grant is
304
+ // derived from the selected children at read time.
305
+ const ids = new Set(available.map(row => row.id));
306
+ return captureExtensionSelection(null, available.filter(row => row.suiteResourceId === undefined || ids.has(row.suiteResourceId)).map(row => row.id));
307
+ }
308
+ async window(sessionId) {
309
+ const agent = this.agent(sessionId);
310
+ const [library, resources] = await Promise.all([this.store.read(extensionWorkspace(agent)), this.refreshInventory(agent)]);
311
+ await this.state.whenSelectionSettled(agent);
312
+ const status = this.state.status(agent);
313
+ // Not ready is a reportable state, not a failed read: the payload carries
314
+ // the diagnostics plus a display-only snapshot that authorizes nothing.
315
+ const state = status.ready ? this.state.read(agent) : undefined;
316
+ const started = this.progress.read(agent.session);
317
+ const intent = this.state.intended(agent);
318
+ return {
319
+ sessionId,
320
+ workspace: extensionWorkspace(agent),
321
+ started,
322
+ busy: agent.status !== 'idle',
323
+ library,
324
+ state: state ?? { revision: status.revision, selection: status.selection ?? captureExtensionSelection(null, []) },
325
+ // The pending request rides the payload so the manager shows what is coming
326
+ // without a banner and cannot snap back to the superseded selection.
327
+ ...(intent === undefined ? {} : { intendedSelection: intent.selection, intendedRevision: intent.revision }),
328
+ // The last accepted selection revision, effective or pending: the CAS base a
329
+ // client keeps across a promotion, which never moves backwards.
330
+ selectionRevision: this.state.selectionRevision(agent),
331
+ resources,
332
+ status
333
+ };
334
+ }
335
+ /** Recovery is an explicit, revision-checked act; it never invents a selection. */
336
+ async recover(sessionId, revision) {
337
+ const agent = this.agent(sessionId);
338
+ if (this.dirty.has(agent) && this.state.status(agent).ready) {
339
+ if (this.state.read(agent)?.revision !== revision)
340
+ throw failure('extension-session-conflict');
341
+ await this.refreshAgent(agent);
342
+ if (this.dirty.has(agent))
343
+ throw failure('extension-refresh-pending');
344
+ }
345
+ else
346
+ await this.state.recover(agent, revision);
347
+ await this.ports.ready?.(agent);
348
+ }
349
+ async create(sessionId, revision, input) {
350
+ await this.store.create(extensionWorkspace(this.agent(sessionId)), revision, input);
351
+ }
352
+ async update(sessionId, revision, id, input) {
353
+ const agent = this.agent(sessionId);
354
+ const workspace = extensionWorkspace(agent);
355
+ await this.store.update(workspace, revision, id, input);
356
+ // An edit to the preset this session is running, or has already asked for, is a
357
+ // request for this session alone: every other session keeps its own snapshot.
358
+ const library = await this.store.read(workspace);
359
+ const revised = library.presets.find(row => row.id === id);
360
+ // A pending request is the newer intent, so it decides both whether this edit
361
+ // concerns this session and which revision the new request compares against.
362
+ const intended = this.state.intended(agent);
363
+ const effective = this.state.status(agent).ready ? this.state.read(agent) : undefined;
364
+ const selection = intended?.selection ?? effective?.selection;
365
+ if (revised === undefined || selection?.presetId !== id)
366
+ return;
367
+ const resources = await this.refreshInventory(agent);
368
+ await this.state.requestSelection(agent, this.state.selectionRevision(agent), captureExtensionSelection(revised, resources.filter(row => row.control !== 'global-only' && row.available && row.globalEnabled !== false).map(row => row.id)));
369
+ }
370
+ async delete(sessionId, revision, id) {
371
+ await this.store.delete(extensionWorkspace(this.agent(sessionId)), revision, id);
372
+ }
373
+ async setDefault(sessionId, revision, id) {
374
+ await this.store.setDefault(extensionWorkspace(this.agent(sessionId)), revision, id);
375
+ }
376
+ async select(sessionId, revision, id) {
377
+ const agent = this.agent(sessionId);
378
+ const library = await this.store.read(extensionWorkspace(agent));
379
+ const preset = library.presets.find(row => row.id === id);
380
+ if (id !== null && !preset)
381
+ throw new ExtensionPresetError('preset-not-found', 'extension preset no longer exists');
382
+ const resources = await this.refreshInventory(agent);
383
+ // A request made while a turn owns the session is durable intent, not an
384
+ // application: the committed selection keeps authorizing until the boundary.
385
+ const outcome = await this.state.requestSelection(agent, revision, captureExtensionSelection(preset ?? null, resources.filter(row => row.control !== 'global-only' && row.available && row.globalEnabled !== false).map(row => row.id)));
386
+ if (outcome.applied)
387
+ await this.ports.ready?.(agent);
388
+ }
389
+ async dispose() {
390
+ this.disposed = true;
391
+ this.lifetime.abort();
392
+ await Promise.allSettled([...this.refreshing.values()]);
393
+ for (const off of this.off.splice(0))
394
+ off();
395
+ await this.progress.dispose();
396
+ await this.state.dispose();
397
+ this.resources.clear();
398
+ this.targets.clear();
399
+ this.stale.clear();
400
+ this.reads.clear();
401
+ this.registeredIds.clear();
402
+ this.appliedEpochs.clear();
403
+ this.dirty.clear();
404
+ }
405
+ }