@capyclaw/ppt-suite 2.4.10 → 2.5.68

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 (651) hide show
  1. package/README.md +45 -42
  2. package/composition.lock.json +46 -70
  3. package/contract/ppt-contract.json +310 -11
  4. package/cordis.patch.yml +5 -25
  5. package/dsh-suite.json +108 -194
  6. package/lib/index.mjs +1 -1
  7. package/node_modules/@capyclaw/asset-service/README.md +48 -0
  8. package/node_modules/@capyclaw/asset-service/cordis.patch.yml +4 -0
  9. package/node_modules/@capyclaw/asset-service/dsh-suite.json +29 -0
  10. package/node_modules/@capyclaw/asset-service/lib/host.mjs +14 -0
  11. package/node_modules/@capyclaw/asset-service/package.json +59 -0
  12. package/node_modules/@capyclaw/asset-service/src/index.mjs +304 -0
  13. package/node_modules/@capyclaw/document-workbench/README.md +125 -0
  14. package/node_modules/@capyclaw/document-workbench/package.json +44 -0
  15. package/node_modules/@capyclaw/document-workbench/src/bridge/index.mjs +321 -0
  16. package/node_modules/@capyclaw/document-workbench/src/client/index.mjs +625 -0
  17. package/node_modules/@capyclaw/document-workbench/src/client/screenshot.mjs +98 -0
  18. package/node_modules/@capyclaw/document-workbench/src/index.mjs +9 -0
  19. package/node_modules/@capyclaw/document-workbench/src/model/audit.mjs +101 -0
  20. package/node_modules/@capyclaw/document-workbench/src/model/conformance.mjs +92 -0
  21. package/node_modules/@capyclaw/document-workbench/src/model/ids.mjs +56 -0
  22. package/node_modules/@capyclaw/document-workbench/src/model/index.mjs +18 -0
  23. package/node_modules/@capyclaw/document-workbench/src/model/locate.mjs +118 -0
  24. package/node_modules/@capyclaw/document-workbench/src/model/manifest.mjs +148 -0
  25. package/node_modules/@capyclaw/document-workbench/src/model/ops.mjs +160 -0
  26. package/node_modules/@capyclaw/document-workbench/src/model/validate.mjs +72 -0
  27. package/node_modules/@capyclaw/document-workbench/src/ops/index.mjs +93 -0
  28. package/node_modules/@capyclaw/document-workbench/src/session/context.mjs +103 -0
  29. package/node_modules/@capyclaw/document-workbench/src/session/index.mjs +394 -0
  30. package/node_modules/@capyclaw/document-workbench/src/session/lease.mjs +105 -0
  31. package/node_modules/@capyclaw/document-workbench/src/session/mode.mjs +80 -0
  32. package/node_modules/@capyclaw/document-workbench/src/session/sanitize.mjs +107 -0
  33. package/node_modules/@capyclaw/document-workbench/src/session/state.mjs +159 -0
  34. package/node_modules/@capyclaw/document-workbench/src/session/watch.mjs +63 -0
  35. package/node_modules/@capyclaw/document-workbench/src/store/file-backend.mjs +158 -0
  36. package/node_modules/@capyclaw/document-workbench/src/testing/index.mjs +75 -0
  37. package/node_modules/@capyclaw/editor-host/README.md +37 -0
  38. package/node_modules/@capyclaw/editor-host/cordis.patch.yml +4 -0
  39. package/node_modules/@capyclaw/editor-host/dsh-suite.json +29 -0
  40. package/node_modules/@capyclaw/editor-host/lib/host.mjs +14 -0
  41. package/node_modules/@capyclaw/editor-host/package.json +59 -0
  42. package/node_modules/@capyclaw/editor-host/src/index.mjs +164 -0
  43. package/node_modules/@capyclaw/foundation/README.md +51 -0
  44. package/node_modules/@capyclaw/foundation/abi/bridge.mjs +86 -0
  45. package/node_modules/@capyclaw/foundation/abi/errors.mjs +63 -0
  46. package/node_modules/@capyclaw/foundation/abi/index.mjs +35 -0
  47. package/node_modules/@capyclaw/foundation/abi/kinds.mjs +271 -0
  48. package/node_modules/@capyclaw/foundation/abi/loader.mjs +345 -0
  49. package/node_modules/@capyclaw/foundation/abi/schema.mjs +98 -0
  50. package/node_modules/@capyclaw/foundation/abi/spec.mjs +255 -0
  51. package/node_modules/@capyclaw/foundation/abi/validate.mjs +24 -0
  52. package/node_modules/@capyclaw/foundation/abi/version.mjs +82 -0
  53. package/node_modules/@capyclaw/foundation/cordis.patch.yml +5 -0
  54. package/node_modules/@capyclaw/foundation/kit/index.mjs +6 -0
  55. package/node_modules/@capyclaw/foundation/lib/adapters/client-panel.mjs +98 -0
  56. package/node_modules/@capyclaw/foundation/lib/adapters/host-event.mjs +35 -0
  57. package/node_modules/@capyclaw/foundation/lib/adapters/http-router.mjs +69 -0
  58. package/node_modules/@capyclaw/foundation/lib/adapters/lifecycle-hook.mjs +55 -0
  59. package/node_modules/@capyclaw/foundation/lib/adapters/own-server.mjs +113 -0
  60. package/node_modules/@capyclaw/foundation/lib/adapters/raw.mjs +69 -0
  61. package/node_modules/@capyclaw/foundation/lib/adapters/runtime-driver.mjs +120 -0
  62. package/node_modules/@capyclaw/foundation/lib/adapters/service-provider.mjs +77 -0
  63. package/node_modules/@capyclaw/foundation/lib/adapters/skill-provider.mjs +56 -0
  64. package/node_modules/@capyclaw/foundation/lib/adapters/tool-provider.mjs +50 -0
  65. package/node_modules/@capyclaw/foundation/lib/adapters/ui-panel.mjs +64 -0
  66. package/node_modules/@capyclaw/foundation/lib/ctx-service.mjs +42 -0
  67. package/node_modules/@capyclaw/foundation/lib/host/caps.mjs +34 -0
  68. package/node_modules/@capyclaw/foundation/lib/host/contract.mjs +85 -0
  69. package/node_modules/@capyclaw/foundation/lib/host/dsh.mjs +50 -0
  70. package/node_modules/@capyclaw/foundation/lib/host/memory.mjs +160 -0
  71. package/node_modules/@capyclaw/foundation/lib/host.mjs +23 -0
  72. package/node_modules/@capyclaw/foundation/lib/kernel.mjs +185 -0
  73. package/node_modules/@capyclaw/foundation/lib/skill/scan.mjs +115 -0
  74. package/node_modules/@capyclaw/foundation/lib/subsystems/events.mjs +60 -0
  75. package/node_modules/@capyclaw/foundation/lib/subsystems/log.mjs +51 -0
  76. package/node_modules/@capyclaw/foundation/lib/subsystems/net.mjs +188 -0
  77. package/node_modules/@capyclaw/foundation/package.json +53 -0
  78. package/node_modules/@capyclaw/foundation/runtime/index.mjs +20 -0
  79. package/node_modules/@capyclaw/plugin-kit/INTEGRATION.md +100 -0
  80. package/node_modules/@capyclaw/plugin-kit/README.md +70 -0
  81. package/node_modules/@capyclaw/plugin-kit/bin/sync.mjs +103 -0
  82. package/node_modules/@capyclaw/plugin-kit/package.json +69 -0
  83. package/node_modules/@capyclaw/plugin-kit/src/cli.mjs +56 -0
  84. package/node_modules/@capyclaw/plugin-kit/src/config.mjs +142 -0
  85. package/node_modules/@capyclaw/plugin-kit/src/editor/heartbeat-worker.js +129 -0
  86. package/node_modules/@capyclaw/plugin-kit/src/editor/lease.mjs +58 -0
  87. package/node_modules/@capyclaw/plugin-kit/src/editor/shadow.mjs +219 -0
  88. package/node_modules/@capyclaw/plugin-kit/src/editor/transport.js +13 -0
  89. package/node_modules/@capyclaw/plugin-kit/src/index.mjs +13 -0
  90. package/node_modules/@capyclaw/plugin-kit/src/pack.mjs +230 -0
  91. package/node_modules/@capyclaw/plugin-kit/src/runtime/context.mjs +128 -0
  92. package/node_modules/@capyclaw/plugin-kit/src/self-contained.mjs +307 -0
  93. package/node_modules/@capyclaw/plugin-kit/src/service/api.mjs +45 -0
  94. package/node_modules/@capyclaw/plugin-kit/src/service/http.mjs +113 -0
  95. package/node_modules/@capyclaw/plugin-kit/src/service/mcp-http.mjs +150 -0
  96. package/node_modules/@capyclaw/plugin-kit/src/service/server.mjs +131 -0
  97. package/node_modules/@capyclaw/plugin-kit/src/skills/provider.mjs +82 -0
  98. package/node_modules/@capyclaw/plugin-kit/src/store/blob-store.mjs +109 -0
  99. package/node_modules/@capyclaw/plugin-kit/src/store/content-store.mjs +17 -0
  100. package/node_modules/@capyclaw/plugin-kit/src/store/journal-store.mjs +89 -0
  101. package/node_modules/@capyclaw/plugin-kit/src/tools/result.mjs +57 -0
  102. package/node_modules/@capyclaw/plugin-kit/src/tools/validate.mjs +150 -0
  103. package/node_modules/@capyclaw/plugin-kit/src/tuning.mjs +82 -0
  104. package/node_modules/@capyclaw/plugin-kit/src/util/fs-lock.mjs +132 -0
  105. package/node_modules/@capyclaw/plugin-kit/src/util/http.mjs +130 -0
  106. package/node_modules/@capyclaw/plugin-kit/src/workspace/manager.mjs +656 -0
  107. package/node_modules/@capyclaw/plugin-kit/src/zip.mjs +181 -0
  108. package/node_modules/@capyclaw/portal/README.md +70 -0
  109. package/node_modules/@capyclaw/portal/lib/index.mjs +387 -0
  110. package/node_modules/@capyclaw/portal/lib/ledger.mjs +194 -0
  111. package/node_modules/@capyclaw/portal/lib/portal-agent.ps1 +811 -0
  112. package/node_modules/@capyclaw/portal/lib/portal-darwin.mjs +183 -0
  113. package/node_modules/@capyclaw/portal/package.json +40 -0
  114. package/node_modules/@capyclaw/ppt-editor/LICENSE +661 -0
  115. package/node_modules/@capyclaw/ppt-editor/README.md +86 -0
  116. package/node_modules/@capyclaw/ppt-editor/THIRD_PARTY_NOTICES.md +21 -0
  117. package/node_modules/@capyclaw/ppt-editor/app.js +6298 -0
  118. package/node_modules/@capyclaw/ppt-editor/contract/ppt-contract.json +1828 -0
  119. package/node_modules/@capyclaw/ppt-editor/heartbeat-worker.js +129 -0
  120. package/node_modules/@capyclaw/ppt-editor/index.html +176 -0
  121. package/node_modules/@capyclaw/ppt-editor/lib/index.mjs +8 -0
  122. package/node_modules/@capyclaw/ppt-editor/package.json +57 -0
  123. package/node_modules/@capyclaw/ppt-editor/ppt-full-app.js +381 -0
  124. package/node_modules/@capyclaw/ppt-skill-api/README.md +3 -0
  125. package/node_modules/@capyclaw/ppt-skill-api/contract/ppt-contract.json +1828 -0
  126. package/node_modules/@capyclaw/ppt-skill-api/cordis.patch.yml +4 -0
  127. package/node_modules/@capyclaw/ppt-skill-api/package.json +49 -0
  128. package/node_modules/@capyclaw/ppt-skill-api/plugin.mjs +15 -0
  129. package/node_modules/@capyclaw/ppt-skill-api/skills/pptist-api/SKILL.md +137 -0
  130. package/node_modules/@capyclaw/ppt-skill-api/skills/pptist-api/references/tool-contract.md +1646 -0
  131. package/node_modules/@capyclaw/ppt-skill-api/skills/pptist-api/references/visual-qa.md +28 -0
  132. package/node_modules/@capyclaw/ppt-skill-proposal/README.md +3 -0
  133. package/node_modules/@capyclaw/ppt-skill-proposal/contract/ppt-contract.json +1828 -0
  134. package/node_modules/@capyclaw/ppt-skill-proposal/cordis.patch.yml +4 -0
  135. package/node_modules/@capyclaw/ppt-skill-proposal/package.json +49 -0
  136. package/node_modules/@capyclaw/ppt-skill-proposal/plugin.mjs +15 -0
  137. package/node_modules/@capyclaw/ppt-skill-proposal/skills/pptmaster-proposal/SKILL.md +83 -0
  138. package/node_modules/@capyclaw/ppt-skill-proposal/skills/pptmaster-proposal/references/anti-ai-slop.md +18 -0
  139. package/node_modules/@capyclaw/ppt-skill-proposal/skills/pptmaster-proposal/references/deck-structure.md +42 -0
  140. package/node_modules/@capyclaw/ppt-skill-proposal/skills/pptmaster-proposal/references/design-tokens.md +36 -0
  141. package/node_modules/@capyclaw/ppt-skill-proposal/skills/pptmaster-proposal/references/layout-system.md +30 -0
  142. package/node_modules/@capyclaw/ppt-skill-proposal/skills/pptmaster-proposal/references/page-craft.md +31 -0
  143. package/node_modules/@capyclaw/ppt-skill-proposal/skills/pptmaster-proposal/references/scqa-pyramid.md +26 -0
  144. package/node_modules/@capyclaw/ppt-workbench/LICENSE +661 -0
  145. package/node_modules/@capyclaw/ppt-workbench/README.md +173 -0
  146. package/node_modules/@capyclaw/ppt-workbench/THIRD_PARTY_NOTICES.md +21 -0
  147. package/node_modules/@capyclaw/ppt-workbench/contract/ppt-contract.json +1828 -0
  148. package/node_modules/@capyclaw/ppt-workbench/core/audit.js +507 -0
  149. package/node_modules/@capyclaw/ppt-workbench/core/chart.js +199 -0
  150. package/node_modules/@capyclaw/ppt-workbench/core/color.js +170 -0
  151. package/node_modules/@capyclaw/ppt-workbench/core/deck-layout.js +375 -0
  152. package/node_modules/@capyclaw/ppt-workbench/core/formula.js +80 -0
  153. package/node_modules/@capyclaw/ppt-workbench/core/hfmath/hershey.js +1763 -0
  154. package/node_modules/@capyclaw/ppt-workbench/core/hfmath/index.js +1176 -0
  155. package/node_modules/@capyclaw/ppt-workbench/core/hfmath/stretch.js +41 -0
  156. package/node_modules/@capyclaw/ppt-workbench/core/hfmath/symbols.js +408 -0
  157. package/node_modules/@capyclaw/ppt-workbench/core/inspect.js +366 -0
  158. package/node_modules/@capyclaw/ppt-workbench/core/manuscript/compare.mjs +103 -0
  159. package/node_modules/@capyclaw/ppt-workbench/core/manuscript/compile.mjs +322 -0
  160. package/node_modules/@capyclaw/ppt-workbench/core/manuscript/edit.mjs +239 -0
  161. package/node_modules/@capyclaw/ppt-workbench/core/manuscript/parse.mjs +346 -0
  162. package/node_modules/@capyclaw/ppt-workbench/core/manuscript/render-html.mjs +84 -0
  163. package/node_modules/@capyclaw/ppt-workbench/core/manuscript/sync.mjs +101 -0
  164. package/node_modules/@capyclaw/ppt-workbench/core/measure.js +104 -0
  165. package/node_modules/@capyclaw/ppt-workbench/core/ops/browser.js +28 -0
  166. package/node_modules/@capyclaw/ppt-workbench/core/ops/chart.js +64 -0
  167. package/node_modules/@capyclaw/ppt-workbench/core/ops/deck.js +21 -0
  168. package/node_modules/@capyclaw/ppt-workbench/core/ops/element.js +55 -0
  169. package/node_modules/@capyclaw/ppt-workbench/core/ops/history.js +11 -0
  170. package/node_modules/@capyclaw/ppt-workbench/core/ops/import.js +95 -0
  171. package/node_modules/@capyclaw/ppt-workbench/core/ops/index.js +39 -0
  172. package/node_modules/@capyclaw/ppt-workbench/core/ops/playback.js +9 -0
  173. package/node_modules/@capyclaw/ppt-workbench/core/ops/recolor.js +87 -0
  174. package/node_modules/@capyclaw/ppt-workbench/core/ops/slide.js +66 -0
  175. package/node_modules/@capyclaw/ppt-workbench/core/ops/table.js +85 -0
  176. package/node_modules/@capyclaw/ppt-workbench/core/ops/text.js +35 -0
  177. package/node_modules/@capyclaw/ppt-workbench/core/ops/view.js +13 -0
  178. package/node_modules/@capyclaw/ppt-workbench/core/ops.js +12 -0
  179. package/node_modules/@capyclaw/ppt-workbench/core/quick.js +52 -0
  180. package/node_modules/@capyclaw/ppt-workbench/core/shape-library.js +122 -0
  181. package/node_modules/@capyclaw/ppt-workbench/core/table.js +178 -0
  182. package/node_modules/@capyclaw/ppt-workbench/core/text.js +200 -0
  183. package/node_modules/@capyclaw/ppt-workbench/lib/host.mjs +1 -0
  184. package/node_modules/@capyclaw/ppt-workbench/package.json +73 -0
  185. package/node_modules/@capyclaw/ppt-workbench/plugin.mjs +1 -0
  186. package/node_modules/@capyclaw/ppt-workbench/server/audit.mjs +2 -0
  187. package/node_modules/@capyclaw/ppt-workbench/server/bridge-client.mjs +308 -0
  188. package/node_modules/@capyclaw/ppt-workbench/server/constants.mjs +21 -0
  189. package/node_modules/@capyclaw/ppt-workbench/server/contract-snapshots.mjs +89 -0
  190. package/node_modules/@capyclaw/ppt-workbench/server/contract.mjs +24 -0
  191. package/node_modules/@capyclaw/ppt-workbench/server/deck-layout.mjs +2 -0
  192. package/node_modules/@capyclaw/ppt-workbench/server/editor-assets.mjs +132 -0
  193. package/node_modules/@capyclaw/ppt-workbench/server/embedded-host.mjs +252 -0
  194. package/node_modules/@capyclaw/ppt-workbench/server/http-utils.mjs +2 -0
  195. package/node_modules/@capyclaw/ppt-workbench/server/infra/http.mjs +2 -0
  196. package/node_modules/@capyclaw/ppt-workbench/server/infra/runtime/context.mjs +2 -0
  197. package/node_modules/@capyclaw/ppt-workbench/server/infra/store/blob-store.mjs +2 -0
  198. package/node_modules/@capyclaw/ppt-workbench/server/infra/tuning.mjs +2 -0
  199. package/node_modules/@capyclaw/ppt-workbench/server/infra/util/fs-lock.mjs +2 -0
  200. package/node_modules/@capyclaw/ppt-workbench/server/infra/workspace/manager.mjs +2 -0
  201. package/node_modules/@capyclaw/ppt-workbench/server/mcp/dispatch.mjs +2 -0
  202. package/node_modules/@capyclaw/ppt-workbench/server/mcp/handler.mjs +2 -0
  203. package/node_modules/@capyclaw/ppt-workbench/server/mcp/instructions.mjs +66 -0
  204. package/node_modules/@capyclaw/ppt-workbench/server/ppt-shim.mjs +168 -0
  205. package/node_modules/@capyclaw/ppt-workbench/server/relay.mjs +282 -0
  206. package/node_modules/@capyclaw/ppt-workbench/server/routes/assets.mjs +2 -0
  207. package/node_modules/@capyclaw/ppt-workbench/server/routes/bridge.mjs +74 -0
  208. package/node_modules/@capyclaw/ppt-workbench/server/routes/editor.mjs +9 -0
  209. package/node_modules/@capyclaw/ppt-workbench/server/routes/import.mjs +260 -0
  210. package/node_modules/@capyclaw/ppt-workbench/server/routes/manuscript.mjs +414 -0
  211. package/node_modules/@capyclaw/ppt-workbench/server/routes/mcp.mjs +17 -0
  212. package/node_modules/@capyclaw/ppt-workbench/server/routes/session.mjs +36 -0
  213. package/node_modules/@capyclaw/ppt-workbench/server/runtime/recovery.mjs +9 -0
  214. package/node_modules/@capyclaw/ppt-workbench/server/runtime/watch.mjs +17 -0
  215. package/node_modules/@capyclaw/ppt-workbench/server/session-context.mjs +5 -0
  216. package/node_modules/@capyclaw/ppt-workbench/server/shared/SHARED_MANIFEST.json +70 -0
  217. package/node_modules/@capyclaw/ppt-workbench/server/shared/asset-service.mjs +2 -0
  218. package/node_modules/@capyclaw/ppt-workbench/server/shared/editor-host.mjs +2 -0
  219. package/node_modules/@capyclaw/ppt-workbench/server/shared/kit/editor/lease.mjs +2 -0
  220. package/node_modules/@capyclaw/ppt-workbench/server/shared/kit/service/api.mjs +2 -0
  221. package/node_modules/@capyclaw/ppt-workbench/server/shared/kit/service/http.mjs +2 -0
  222. package/node_modules/@capyclaw/ppt-workbench/server/shared/kit/service/mcp-http.mjs +2 -0
  223. package/node_modules/@capyclaw/ppt-workbench/server/shared/kit/tools/validate.mjs +2 -0
  224. package/node_modules/@capyclaw/ppt-workbench/server/shared/kit/tuning.mjs +2 -0
  225. package/node_modules/@capyclaw/ppt-workbench/server/shared/kit/util/fs-lock.mjs +2 -0
  226. package/node_modules/@capyclaw/ppt-workbench/server/shared/service-host.mjs +2 -0
  227. package/node_modules/@capyclaw/ppt-workbench/server/shared/tool-host.mjs +2 -0
  228. package/node_modules/@capyclaw/ppt-workbench/server/shared/tuning.mjs +2 -0
  229. package/node_modules/@capyclaw/ppt-workbench/server/store/backends/file-backend.mjs +13 -0
  230. package/node_modules/@capyclaw/ppt-workbench/server/store/checkpoints.mjs +28 -0
  231. package/node_modules/@capyclaw/ppt-workbench/server/store/deck-sanitize.mjs +68 -0
  232. package/node_modules/@capyclaw/ppt-workbench/server/store/doc.mjs +56 -0
  233. package/node_modules/@capyclaw/ppt-workbench/server/store/index.mjs +34 -0
  234. package/node_modules/@capyclaw/ppt-workbench/server/store/journal.mjs +9 -0
  235. package/node_modules/@capyclaw/ppt-workbench/server/store/lease.mjs +2 -0
  236. package/node_modules/@capyclaw/ppt-workbench/server/store/sanitize.mjs +33 -0
  237. package/node_modules/@capyclaw/ppt-workbench/server/store/sessions.mjs +314 -0
  238. package/node_modules/@capyclaw/ppt-workbench/server/store.mjs +2 -0
  239. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/apply.mjs +33 -0
  240. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/audit.mjs +28 -0
  241. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/chart.mjs +83 -0
  242. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/compose.mjs +97 -0
  243. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/contract.mjs +38 -0
  244. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/deck.mjs +27 -0
  245. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/element.mjs +67 -0
  246. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/export.mjs +99 -0
  247. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/formula.mjs +72 -0
  248. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/history.mjs +29 -0
  249. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/image.mjs +174 -0
  250. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/imagesearch.mjs +203 -0
  251. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/import.mjs +180 -0
  252. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/index.mjs +64 -0
  253. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/inspect.mjs +46 -0
  254. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/line.mjs +58 -0
  255. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/manuscript.mjs +208 -0
  256. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/notes.mjs +33 -0
  257. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/present.mjs +34 -0
  258. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/recolor.mjs +62 -0
  259. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/screenshot.mjs +191 -0
  260. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/shape.mjs +64 -0
  261. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/slide.mjs +81 -0
  262. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/style.mjs +48 -0
  263. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/table.mjs +127 -0
  264. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/task.mjs +52 -0
  265. package/node_modules/@capyclaw/ppt-workbench/server/tools/capabilities/text.mjs +82 -0
  266. package/node_modules/@capyclaw/ppt-workbench/server/tools/domains/color.mjs +4 -0
  267. package/node_modules/@capyclaw/ppt-workbench/server/tools/domains/image.mjs +78 -0
  268. package/node_modules/@capyclaw/ppt-workbench/server/tools/domains/index.mjs +7 -0
  269. package/node_modules/@capyclaw/ppt-workbench/server/tools/domains/manuscript-media.mjs +159 -0
  270. package/node_modules/@capyclaw/ppt-workbench/server/tools/domains/offline-render.mjs +256 -0
  271. package/node_modules/@capyclaw/ppt-workbench/server/tools/domains/pptx-export.mjs +577 -0
  272. package/node_modules/@capyclaw/ppt-workbench/server/tools/domains/recolor.mjs +25 -0
  273. package/node_modules/@capyclaw/ppt-workbench/server/tools/domains/remote-image.mjs +443 -0
  274. package/node_modules/@capyclaw/ppt-workbench/server/tools/domains/slide.mjs +21 -0
  275. package/node_modules/@capyclaw/ppt-workbench/server/tools/domains/text-style.mjs +11 -0
  276. package/node_modules/@capyclaw/ppt-workbench/server/tools/domains/tooling.mjs +13 -0
  277. package/node_modules/@capyclaw/ppt-workbench/server/tools/index.mjs +14 -0
  278. package/node_modules/@capyclaw/ppt-workbench/server/tools/kernel/define.mjs +5 -0
  279. package/node_modules/@capyclaw/ppt-workbench/server/tools/kernel/ports.mjs +52 -0
  280. package/node_modules/@capyclaw/ppt-workbench/server/tools/kernel/registry.mjs +17 -0
  281. package/node_modules/@capyclaw/ppt-workbench/server/tools/model/deck-schema.mjs +105 -0
  282. package/node_modules/@capyclaw/ppt-workbench/server/tools.mjs +18 -0
  283. package/node_modules/@capyclaw/ppt-workbench/server/tuning.mjs +93 -0
  284. package/node_modules/@capyclaw/ppt-workbench/server/validate.mjs +2 -0
  285. package/node_modules/@capyclaw/ppt-workbench/server/workbench-framework.mjs +305 -0
  286. package/node_modules/@capyclaw/service-broker/README.md +104 -0
  287. package/node_modules/@capyclaw/service-broker/cordis.patch.yml +8 -0
  288. package/node_modules/@capyclaw/service-broker/dsh-suite.json +21 -0
  289. package/node_modules/@capyclaw/service-broker/lib/control.mjs +193 -0
  290. package/node_modules/@capyclaw/service-broker/lib/discovery.mjs +109 -0
  291. package/node_modules/@capyclaw/service-broker/lib/engine.mjs +1236 -0
  292. package/node_modules/@capyclaw/service-broker/lib/host.mjs +182 -0
  293. package/node_modules/@capyclaw/service-broker/lib/manifest.mjs +249 -0
  294. package/node_modules/@capyclaw/service-broker/lib/recovery.mjs +275 -0
  295. package/node_modules/@capyclaw/service-broker/lib/skills-client.mjs +28 -0
  296. package/node_modules/@capyclaw/service-broker/lib/spec.mjs +78 -0
  297. package/node_modules/@capyclaw/service-broker/package.json +65 -0
  298. package/node_modules/@capyclaw/service-broker/server.mjs +81 -0
  299. package/node_modules/@capyclaw/service-broker/service.schema.json +62 -0
  300. package/node_modules/@capyclaw/service-broker/services.json +3 -0
  301. package/node_modules/@capyclaw/service-host/README.md +86 -0
  302. package/node_modules/@capyclaw/service-host/cordis.patch.yml +4 -0
  303. package/node_modules/@capyclaw/service-host/dsh-suite.json +29 -0
  304. package/node_modules/@capyclaw/service-host/lib/host.mjs +22 -0
  305. package/node_modules/@capyclaw/service-host/package.json +60 -0
  306. package/node_modules/@capyclaw/service-host/src/index.mjs +571 -0
  307. package/node_modules/@capyclaw/service-host/src/tuning.mjs +63 -0
  308. package/node_modules/@capyclaw/skills-service/README.md +31 -0
  309. package/node_modules/@capyclaw/skills-service/package.json +30 -0
  310. package/node_modules/@capyclaw/skills-service/server.mjs +237 -0
  311. package/node_modules/@capyclaw/tool-host/README.md +56 -0
  312. package/node_modules/@capyclaw/tool-host/cordis.patch.yml +4 -0
  313. package/node_modules/@capyclaw/tool-host/dsh-suite.json +30 -0
  314. package/node_modules/@capyclaw/tool-host/lib/host.mjs +16 -0
  315. package/node_modules/@capyclaw/tool-host/package.json +59 -0
  316. package/node_modules/@capyclaw/tool-host/src/descriptors.mjs +166 -0
  317. package/node_modules/@capyclaw/tool-host/src/index.mjs +416 -0
  318. package/node_modules/@types/node/LICENSE +21 -0
  319. package/node_modules/@types/node/README.md +15 -0
  320. package/node_modules/@types/node/assert/strict.d.ts +8 -0
  321. package/node_modules/@types/node/assert.d.ts +1005 -0
  322. package/node_modules/@types/node/async_hooks.d.ts +586 -0
  323. package/node_modules/@types/node/buffer.buffer.d.ts +457 -0
  324. package/node_modules/@types/node/buffer.d.ts +1901 -0
  325. package/node_modules/@types/node/child_process.d.ts +1453 -0
  326. package/node_modules/@types/node/cluster.d.ts +578 -0
  327. package/node_modules/@types/node/compatibility/disposable.d.ts +14 -0
  328. package/node_modules/@types/node/compatibility/index.d.ts +9 -0
  329. package/node_modules/@types/node/compatibility/indexable.d.ts +20 -0
  330. package/node_modules/@types/node/compatibility/iterators.d.ts +20 -0
  331. package/node_modules/@types/node/console.d.ts +452 -0
  332. package/node_modules/@types/node/constants.d.ts +21 -0
  333. package/node_modules/@types/node/crypto.d.ts +4504 -0
  334. package/node_modules/@types/node/dgram.d.ts +596 -0
  335. package/node_modules/@types/node/diagnostics_channel.d.ts +551 -0
  336. package/node_modules/@types/node/dns/promises.d.ts +477 -0
  337. package/node_modules/@types/node/dns.d.ts +860 -0
  338. package/node_modules/@types/node/domain.d.ts +170 -0
  339. package/node_modules/@types/node/events.d.ts +863 -0
  340. package/node_modules/@types/node/fs/promises.d.ts +1208 -0
  341. package/node_modules/@types/node/fs.d.ts +4332 -0
  342. package/node_modules/@types/node/globals.d.ts +170 -0
  343. package/node_modules/@types/node/globals.typedarray.d.ts +21 -0
  344. package/node_modules/@types/node/http.d.ts +1919 -0
  345. package/node_modules/@types/node/http2.d.ts +2580 -0
  346. package/node_modules/@types/node/https.d.ts +549 -0
  347. package/node_modules/@types/node/index.d.ts +92 -0
  348. package/node_modules/@types/node/inspector.generated.d.ts +2775 -0
  349. package/node_modules/@types/node/module.d.ts +503 -0
  350. package/node_modules/@types/node/net.d.ts +924 -0
  351. package/node_modules/@types/node/os.d.ts +480 -0
  352. package/node_modules/@types/node/package.json +145 -0
  353. package/node_modules/@types/node/path.d.ts +191 -0
  354. package/node_modules/@types/node/perf_hooks.d.ts +860 -0
  355. package/node_modules/@types/node/process.d.ts +1632 -0
  356. package/node_modules/@types/node/punycode.d.ts +117 -0
  357. package/node_modules/@types/node/querystring.d.ts +140 -0
  358. package/node_modules/@types/node/readline/promises.d.ts +154 -0
  359. package/node_modules/@types/node/readline.d.ts +715 -0
  360. package/node_modules/@types/node/repl.d.ts +430 -0
  361. package/node_modules/@types/node/stream/consumers.d.ts +38 -0
  362. package/node_modules/@types/node/stream/promises.d.ts +90 -0
  363. package/node_modules/@types/node/stream/web.d.ts +527 -0
  364. package/node_modules/@types/node/stream.d.ts +1680 -0
  365. package/node_modules/@types/node/string_decoder.d.ts +67 -0
  366. package/node_modules/@types/node/test.d.ts +1208 -0
  367. package/node_modules/@types/node/timers/promises.d.ts +108 -0
  368. package/node_modules/@types/node/timers.d.ts +286 -0
  369. package/node_modules/@types/node/tls.d.ts +1204 -0
  370. package/node_modules/@types/node/trace_events.d.ts +171 -0
  371. package/node_modules/@types/node/ts5.6/buffer.buffer.d.ts +455 -0
  372. package/node_modules/@types/node/ts5.6/globals.typedarray.d.ts +19 -0
  373. package/node_modules/@types/node/ts5.6/index.d.ts +92 -0
  374. package/node_modules/@types/node/tty.d.ts +206 -0
  375. package/node_modules/@types/node/url.d.ts +957 -0
  376. package/node_modules/@types/node/util.d.ts +2083 -0
  377. package/node_modules/@types/node/v8.d.ts +753 -0
  378. package/node_modules/@types/node/vm.d.ts +704 -0
  379. package/node_modules/@types/node/wasi.d.ts +160 -0
  380. package/node_modules/@types/node/web-globals/abortcontroller.d.ts +34 -0
  381. package/node_modules/@types/node/web-globals/domexception.d.ts +68 -0
  382. package/node_modules/@types/node/web-globals/events.d.ts +81 -0
  383. package/node_modules/@types/node/web-globals/fetch.d.ts +38 -0
  384. package/node_modules/@types/node/worker_threads.d.ts +698 -0
  385. package/node_modules/@types/node/zlib.d.ts +517 -0
  386. package/node_modules/core-util-is/LICENSE +19 -0
  387. package/node_modules/core-util-is/README.md +3 -0
  388. package/node_modules/core-util-is/lib/util.js +107 -0
  389. package/node_modules/core-util-is/package.json +38 -0
  390. package/node_modules/https/package.json +15 -0
  391. package/node_modules/image-size/LICENSE +9 -0
  392. package/node_modules/image-size/Readme.md +184 -0
  393. package/node_modules/image-size/bin/image-size.js +53 -0
  394. package/node_modules/image-size/dist/detector.d.ts +2 -0
  395. package/node_modules/image-size/dist/detector.js +30 -0
  396. package/node_modules/image-size/dist/index.d.ts +10 -0
  397. package/node_modules/image-size/dist/index.js +129 -0
  398. package/node_modules/image-size/dist/types/bmp.d.ts +2 -0
  399. package/node_modules/image-size/dist/types/bmp.js +11 -0
  400. package/node_modules/image-size/dist/types/cur.d.ts +2 -0
  401. package/node_modules/image-size/dist/types/cur.js +17 -0
  402. package/node_modules/image-size/dist/types/dds.d.ts +2 -0
  403. package/node_modules/image-size/dist/types/dds.js +11 -0
  404. package/node_modules/image-size/dist/types/gif.d.ts +2 -0
  405. package/node_modules/image-size/dist/types/gif.js +12 -0
  406. package/node_modules/image-size/dist/types/heif.d.ts +2 -0
  407. package/node_modules/image-size/dist/types/heif.js +40 -0
  408. package/node_modules/image-size/dist/types/icns.d.ts +2 -0
  409. package/node_modules/image-size/dist/types/icns.js +101 -0
  410. package/node_modules/image-size/dist/types/ico.d.ts +2 -0
  411. package/node_modules/image-size/dist/types/ico.js +68 -0
  412. package/node_modules/image-size/dist/types/index.d.ts +23 -0
  413. package/node_modules/image-size/dist/types/index.js +46 -0
  414. package/node_modules/image-size/dist/types/interface.d.ts +13 -0
  415. package/node_modules/image-size/dist/types/interface.js +2 -0
  416. package/node_modules/image-size/dist/types/j2c.d.ts +2 -0
  417. package/node_modules/image-size/dist/types/j2c.js +12 -0
  418. package/node_modules/image-size/dist/types/jp2.d.ts +2 -0
  419. package/node_modules/image-size/dist/types/jp2.js +27 -0
  420. package/node_modules/image-size/dist/types/jpg.d.ts +2 -0
  421. package/node_modules/image-size/dist/types/jpg.js +123 -0
  422. package/node_modules/image-size/dist/types/jxl-stream.d.ts +2 -0
  423. package/node_modules/image-size/dist/types/jxl-stream.js +45 -0
  424. package/node_modules/image-size/dist/types/jxl.d.ts +2 -0
  425. package/node_modules/image-size/dist/types/jxl.js +59 -0
  426. package/node_modules/image-size/dist/types/ktx.d.ts +2 -0
  427. package/node_modules/image-size/dist/types/ktx.js +19 -0
  428. package/node_modules/image-size/dist/types/png.d.ts +2 -0
  429. package/node_modules/image-size/dist/types/png.js +35 -0
  430. package/node_modules/image-size/dist/types/pnm.d.ts +2 -0
  431. package/node_modules/image-size/dist/types/pnm.js +72 -0
  432. package/node_modules/image-size/dist/types/psd.d.ts +2 -0
  433. package/node_modules/image-size/dist/types/psd.js +11 -0
  434. package/node_modules/image-size/dist/types/svg.d.ts +2 -0
  435. package/node_modules/image-size/dist/types/svg.js +90 -0
  436. package/node_modules/image-size/dist/types/tga.d.ts +2 -0
  437. package/node_modules/image-size/dist/types/tga.js +15 -0
  438. package/node_modules/image-size/dist/types/tiff.d.ts +2 -0
  439. package/node_modules/image-size/dist/types/tiff.js +95 -0
  440. package/node_modules/image-size/dist/types/utils.d.ts +15 -0
  441. package/node_modules/image-size/dist/types/utils.js +75 -0
  442. package/node_modules/image-size/dist/types/webp.d.ts +2 -0
  443. package/node_modules/image-size/dist/types/webp.js +60 -0
  444. package/node_modules/image-size/dist/utils/bit-reader.d.ts +10 -0
  445. package/node_modules/image-size/dist/utils/bit-reader.js +44 -0
  446. package/node_modules/image-size/package.json +81 -0
  447. package/node_modules/immediate/LICENSE.txt +20 -0
  448. package/node_modules/immediate/README.md +93 -0
  449. package/node_modules/immediate/dist/immediate.js +75 -0
  450. package/node_modules/immediate/dist/immediate.min.js +1 -0
  451. package/node_modules/immediate/lib/browser.js +69 -0
  452. package/node_modules/immediate/lib/index.js +73 -0
  453. package/node_modules/immediate/package.json +42 -0
  454. package/node_modules/inherits/LICENSE +16 -0
  455. package/node_modules/inherits/README.md +42 -0
  456. package/node_modules/inherits/inherits.js +9 -0
  457. package/node_modules/inherits/inherits_browser.js +27 -0
  458. package/node_modules/inherits/package.json +29 -0
  459. package/node_modules/isarray/.npmignore +1 -0
  460. package/node_modules/isarray/.travis.yml +4 -0
  461. package/node_modules/isarray/Makefile +6 -0
  462. package/node_modules/isarray/README.md +60 -0
  463. package/node_modules/isarray/component.json +19 -0
  464. package/node_modules/isarray/index.js +5 -0
  465. package/node_modules/isarray/package.json +45 -0
  466. package/node_modules/isarray/test.js +20 -0
  467. package/node_modules/jszip/.codeclimate.yml +16 -0
  468. package/node_modules/jszip/.editorconfig +8 -0
  469. package/node_modules/jszip/.eslintrc.js +43 -0
  470. package/node_modules/jszip/CHANGES.md +210 -0
  471. package/node_modules/jszip/LICENSE.markdown +651 -0
  472. package/node_modules/jszip/README.markdown +33 -0
  473. package/node_modules/jszip/dist/jszip.js +11586 -0
  474. package/node_modules/jszip/dist/jszip.min.js +13 -0
  475. package/node_modules/jszip/index.d.ts +344 -0
  476. package/node_modules/jszip/lib/base64.js +106 -0
  477. package/node_modules/jszip/lib/compressedObject.js +74 -0
  478. package/node_modules/jszip/lib/compressions.js +14 -0
  479. package/node_modules/jszip/lib/crc32.js +77 -0
  480. package/node_modules/jszip/lib/defaults.js +11 -0
  481. package/node_modules/jszip/lib/external.js +18 -0
  482. package/node_modules/jszip/lib/flate.js +85 -0
  483. package/node_modules/jszip/lib/generate/ZipFileWorker.js +539 -0
  484. package/node_modules/jszip/lib/generate/index.js +57 -0
  485. package/node_modules/jszip/lib/index.js +55 -0
  486. package/node_modules/jszip/lib/license_header.js +11 -0
  487. package/node_modules/jszip/lib/load.js +88 -0
  488. package/node_modules/jszip/lib/nodejs/NodejsStreamInputAdapter.js +74 -0
  489. package/node_modules/jszip/lib/nodejs/NodejsStreamOutputAdapter.js +42 -0
  490. package/node_modules/jszip/lib/nodejsUtils.js +57 -0
  491. package/node_modules/jszip/lib/object.js +384 -0
  492. package/node_modules/jszip/lib/readable-stream-browser.js +10 -0
  493. package/node_modules/jszip/lib/reader/ArrayReader.js +57 -0
  494. package/node_modules/jszip/lib/reader/DataReader.js +116 -0
  495. package/node_modules/jszip/lib/reader/NodeBufferReader.js +19 -0
  496. package/node_modules/jszip/lib/reader/StringReader.js +38 -0
  497. package/node_modules/jszip/lib/reader/Uint8ArrayReader.js +22 -0
  498. package/node_modules/jszip/lib/reader/readerFor.js +28 -0
  499. package/node_modules/jszip/lib/signature.js +7 -0
  500. package/node_modules/jszip/lib/stream/ConvertWorker.js +26 -0
  501. package/node_modules/jszip/lib/stream/Crc32Probe.js +24 -0
  502. package/node_modules/jszip/lib/stream/DataLengthProbe.js +29 -0
  503. package/node_modules/jszip/lib/stream/DataWorker.js +116 -0
  504. package/node_modules/jszip/lib/stream/GenericWorker.js +263 -0
  505. package/node_modules/jszip/lib/stream/StreamHelper.js +214 -0
  506. package/node_modules/jszip/lib/support.js +38 -0
  507. package/node_modules/jszip/lib/utf8.js +275 -0
  508. package/node_modules/jszip/lib/utils.js +510 -0
  509. package/node_modules/jszip/lib/zipEntries.js +261 -0
  510. package/node_modules/jszip/lib/zipEntry.js +293 -0
  511. package/node_modules/jszip/lib/zipObject.js +133 -0
  512. package/node_modules/jszip/package.json +67 -0
  513. package/node_modules/jszip/sponsors.md +21 -0
  514. package/node_modules/jszip/tsconfig.json +101 -0
  515. package/node_modules/jszip/vendor/FileSaver.js +247 -0
  516. package/node_modules/lie/README.md +62 -0
  517. package/node_modules/lie/dist/lie.js +350 -0
  518. package/node_modules/lie/dist/lie.min.js +1 -0
  519. package/node_modules/lie/dist/lie.polyfill.js +358 -0
  520. package/node_modules/lie/dist/lie.polyfill.min.js +1 -0
  521. package/node_modules/lie/lib/browser.js +273 -0
  522. package/node_modules/lie/lib/index.js +298 -0
  523. package/node_modules/lie/license.md +7 -0
  524. package/node_modules/lie/lie.d.ts +244 -0
  525. package/node_modules/lie/package.json +69 -0
  526. package/node_modules/lie/polyfill.js +4 -0
  527. package/node_modules/pako/LICENSE +21 -0
  528. package/node_modules/pako/README.md +191 -0
  529. package/node_modules/pako/dist/pako.js +6818 -0
  530. package/node_modules/pako/dist/pako.min.js +1 -0
  531. package/node_modules/pako/dist/pako_deflate.js +3997 -0
  532. package/node_modules/pako/dist/pako_deflate.min.js +1 -0
  533. package/node_modules/pako/dist/pako_inflate.js +3300 -0
  534. package/node_modules/pako/dist/pako_inflate.min.js +1 -0
  535. package/node_modules/pako/index.js +14 -0
  536. package/node_modules/pako/lib/deflate.js +400 -0
  537. package/node_modules/pako/lib/inflate.js +423 -0
  538. package/node_modules/pako/lib/utils/common.js +105 -0
  539. package/node_modules/pako/lib/utils/strings.js +187 -0
  540. package/node_modules/pako/lib/zlib/README +59 -0
  541. package/node_modules/pako/lib/zlib/adler32.js +51 -0
  542. package/node_modules/pako/lib/zlib/constants.js +68 -0
  543. package/node_modules/pako/lib/zlib/crc32.js +59 -0
  544. package/node_modules/pako/lib/zlib/deflate.js +1874 -0
  545. package/node_modules/pako/lib/zlib/gzheader.js +58 -0
  546. package/node_modules/pako/lib/zlib/inffast.js +345 -0
  547. package/node_modules/pako/lib/zlib/inflate.js +1556 -0
  548. package/node_modules/pako/lib/zlib/inftrees.js +343 -0
  549. package/node_modules/pako/lib/zlib/messages.js +32 -0
  550. package/node_modules/pako/lib/zlib/trees.js +1222 -0
  551. package/node_modules/pako/lib/zlib/zstream.js +47 -0
  552. package/node_modules/pako/package.json +44 -0
  553. package/node_modules/pptxgenjs/LICENSE +21 -0
  554. package/node_modules/pptxgenjs/README.md +284 -0
  555. package/node_modules/pptxgenjs/dist/pptxgen.bundle.js +3 -0
  556. package/node_modules/pptxgenjs/dist/pptxgen.bundle.js.map +1 -0
  557. package/node_modules/pptxgenjs/dist/pptxgen.cjs.js +7445 -0
  558. package/node_modules/pptxgenjs/dist/pptxgen.es.js +7439 -0
  559. package/node_modules/pptxgenjs/dist/pptxgen.min.js +3 -0
  560. package/node_modules/pptxgenjs/dist/pptxgen.min.js.map +1 -0
  561. package/node_modules/pptxgenjs/package.json +89 -0
  562. package/node_modules/pptxgenjs/types/index.d.ts +2670 -0
  563. package/node_modules/process-nextick-args/index.js +45 -0
  564. package/node_modules/process-nextick-args/license.md +19 -0
  565. package/node_modules/process-nextick-args/package.json +25 -0
  566. package/node_modules/process-nextick-args/readme.md +18 -0
  567. package/node_modules/queue/LICENSE +8 -0
  568. package/node_modules/queue/index.d.ts +173 -0
  569. package/node_modules/queue/index.js +195 -0
  570. package/node_modules/queue/package.json +43 -0
  571. package/node_modules/queue/readme.md +221 -0
  572. package/node_modules/readable-stream/.travis.yml +34 -0
  573. package/node_modules/readable-stream/CONTRIBUTING.md +38 -0
  574. package/node_modules/readable-stream/GOVERNANCE.md +136 -0
  575. package/node_modules/readable-stream/LICENSE +47 -0
  576. package/node_modules/readable-stream/README.md +58 -0
  577. package/node_modules/readable-stream/doc/wg-meetings/2015-01-30.md +60 -0
  578. package/node_modules/readable-stream/duplex-browser.js +1 -0
  579. package/node_modules/readable-stream/duplex.js +1 -0
  580. package/node_modules/readable-stream/lib/_stream_duplex.js +131 -0
  581. package/node_modules/readable-stream/lib/_stream_passthrough.js +47 -0
  582. package/node_modules/readable-stream/lib/_stream_readable.js +1019 -0
  583. package/node_modules/readable-stream/lib/_stream_transform.js +214 -0
  584. package/node_modules/readable-stream/lib/_stream_writable.js +685 -0
  585. package/node_modules/readable-stream/lib/internal/streams/BufferList.js +78 -0
  586. package/node_modules/readable-stream/lib/internal/streams/destroy.js +84 -0
  587. package/node_modules/readable-stream/lib/internal/streams/stream-browser.js +1 -0
  588. package/node_modules/readable-stream/lib/internal/streams/stream.js +1 -0
  589. package/node_modules/readable-stream/package.json +52 -0
  590. package/node_modules/readable-stream/passthrough.js +1 -0
  591. package/node_modules/readable-stream/readable-browser.js +7 -0
  592. package/node_modules/readable-stream/readable.js +19 -0
  593. package/node_modules/readable-stream/transform.js +1 -0
  594. package/node_modules/readable-stream/writable-browser.js +1 -0
  595. package/node_modules/readable-stream/writable.js +8 -0
  596. package/node_modules/safe-buffer/LICENSE +21 -0
  597. package/node_modules/safe-buffer/README.md +584 -0
  598. package/node_modules/safe-buffer/index.d.ts +187 -0
  599. package/node_modules/safe-buffer/index.js +62 -0
  600. package/node_modules/safe-buffer/package.json +37 -0
  601. package/node_modules/setimmediate/LICENSE.txt +20 -0
  602. package/node_modules/setimmediate/package.json +30 -0
  603. package/node_modules/setimmediate/setImmediate.js +186 -0
  604. package/node_modules/string_decoder/.travis.yml +50 -0
  605. package/node_modules/string_decoder/LICENSE +48 -0
  606. package/node_modules/string_decoder/README.md +47 -0
  607. package/node_modules/string_decoder/lib/string_decoder.js +296 -0
  608. package/node_modules/string_decoder/package.json +31 -0
  609. package/node_modules/undici-types/README.md +6 -0
  610. package/node_modules/undici-types/agent.d.ts +31 -0
  611. package/node_modules/undici-types/api.d.ts +43 -0
  612. package/node_modules/undici-types/balanced-pool.d.ts +18 -0
  613. package/node_modules/undici-types/cache.d.ts +36 -0
  614. package/node_modules/undici-types/client.d.ts +97 -0
  615. package/node_modules/undici-types/connector.d.ts +34 -0
  616. package/node_modules/undici-types/content-type.d.ts +21 -0
  617. package/node_modules/undici-types/cookies.d.ts +28 -0
  618. package/node_modules/undici-types/diagnostics-channel.d.ts +67 -0
  619. package/node_modules/undici-types/dispatcher.d.ts +241 -0
  620. package/node_modules/undici-types/errors.d.ts +128 -0
  621. package/node_modules/undici-types/fetch.d.ts +209 -0
  622. package/node_modules/undici-types/file.d.ts +39 -0
  623. package/node_modules/undici-types/filereader.d.ts +54 -0
  624. package/node_modules/undici-types/formdata.d.ts +108 -0
  625. package/node_modules/undici-types/global-dispatcher.d.ts +9 -0
  626. package/node_modules/undici-types/global-origin.d.ts +7 -0
  627. package/node_modules/undici-types/handlers.d.ts +9 -0
  628. package/node_modules/undici-types/header.d.ts +4 -0
  629. package/node_modules/undici-types/index.d.ts +63 -0
  630. package/node_modules/undici-types/interceptors.d.ts +5 -0
  631. package/node_modules/undici-types/mock-agent.d.ts +50 -0
  632. package/node_modules/undici-types/mock-client.d.ts +25 -0
  633. package/node_modules/undici-types/mock-errors.d.ts +12 -0
  634. package/node_modules/undici-types/mock-interceptor.d.ts +93 -0
  635. package/node_modules/undici-types/mock-pool.d.ts +25 -0
  636. package/node_modules/undici-types/package.json +55 -0
  637. package/node_modules/undici-types/patch.d.ts +71 -0
  638. package/node_modules/undici-types/pool-stats.d.ts +19 -0
  639. package/node_modules/undici-types/pool.d.ts +28 -0
  640. package/node_modules/undici-types/proxy-agent.d.ts +30 -0
  641. package/node_modules/undici-types/readable.d.ts +61 -0
  642. package/node_modules/undici-types/webidl.d.ts +220 -0
  643. package/node_modules/undici-types/websocket.d.ts +131 -0
  644. package/node_modules/util-deprecate/History.md +16 -0
  645. package/node_modules/util-deprecate/LICENSE +24 -0
  646. package/node_modules/util-deprecate/README.md +53 -0
  647. package/node_modules/util-deprecate/browser.js +67 -0
  648. package/node_modules/util-deprecate/node.js +6 -0
  649. package/node_modules/util-deprecate/package.json +27 -0
  650. package/package.json +54 -21
  651. package/services.json +1 -20
@@ -0,0 +1,571 @@
1
+ /**
2
+ * @capyclaw/service-host —— 通用服务宿主。
3
+ *
4
+ * 功能插件只声明“我有哪些路由、健康字段、指标”,不再自己写:
5
+ * - http server / listen / 端口扫描 / strictPort
6
+ * - 单实例锁 / 复用探测 / discovery 文件
7
+ * - /healthz /metrics 标准骨架
8
+ * - 静态资源、路径穿越防护、优雅关闭
9
+ *
10
+ * 两种模式:
11
+ * standalone(默认):自建 loopback server,行为与旧 relay 一致;
12
+ * embedded:传入 DSH 的 ctx.webServer,把同一套路由挂到 `<basePath>` 前缀。
13
+ */
14
+ import http from 'node:http'
15
+ import fs from 'node:fs'
16
+ import os from 'node:os'
17
+ import path from 'node:path'
18
+ import crypto from 'node:crypto'
19
+ import { listen, send, sendText, readBody } from '@capyclaw/plugin-kit/service/http'
20
+ import { createServiceApi } from '@capyclaw/plugin-kit/service/api'
21
+ import { isLoopbackOrigin as sharedIsLoopbackOrigin, mimeFor } from '@capyclaw/plugin-kit/util/http'
22
+ import { tuning } from './tuning.mjs'
23
+
24
+ function slugOf(id) {
25
+ return String(id || 'service').toLowerCase().replace(/[^a-z0-9]+/g, '_').replace(/^_+|_+$/g, '') || 'service'
26
+ }
27
+
28
+ function pidAlive(pid) {
29
+ if (!pid) return false
30
+ try { process.kill(pid, 0); return true } catch (error) { return error.code === 'EPERM' }
31
+ }
32
+
33
+ /** 浏览器跨源写请求防护:只允许本机 loopback 页面 POST(空 Origin 视为同源导航,放行)。 */
34
+ const isLoopbackOrigin = sharedIsLoopbackOrigin
35
+
36
+ /**
37
+ * 挂载前缀之后的可选会话段:`<prefix>/s/<会话id>/…`。
38
+ *
39
+ * 「每个会话一个地址」不该由每个插件各自拼 query,而是基建默认行为:工作台挂到
40
+ * `/capyclaw/ppt/` 之后,`/capyclaw/ppt/s/<sid>/` 自动可用,页面用自己的
41
+ * pathname 就知道该在哪个会话里呈现。形状与网关 `/s/<会话id>/` 一致,sid 也只
42
+ * 放行安全字符(与 gateway 的 SID_RE 同形),不引入路径分隔歧义。
43
+ */
44
+ const SESSION_PATH = /^\/s\/([A-Za-z0-9][A-Za-z0-9._~-]{0,127})(?=\/|$)/
45
+
46
+ /**
47
+ * 抢占实例锁。
48
+ *
49
+ * 判定「有没有别的实例在跑」不能只看 pid:Windows 会复用 pid,relay 崩溃后那个
50
+ * 号码很容易落到无关进程(本机就撞上过 BaiduNetdiskUnite),于是锁永远抢不到、
51
+ * workbench 再也起不来。所以 pid 存活只是必要条件,最终以「锁里记的端口是否还在
52
+ * 应答本服务的健康端点」为准。
53
+ */
54
+ async function acquireLock(lockFile, { healthPath, id } = {}) {
55
+ fs.mkdirSync(path.dirname(lockFile), { recursive: true })
56
+ const token = crypto.randomBytes(12).toString('hex')
57
+ const { lockFreshGraceMs } = tuning()
58
+ /** 刚拿到锁、还没 listen 成功的实例允许占位多久(秒级即可,超时视为卡死)。 */
59
+ const startingGraceMs = Math.max(lockFreshGraceMs, 15000)
60
+ for (let attempt = 0; attempt < 2; attempt++) {
61
+ try {
62
+ /* 原子创建:两个进程同时启动时只有一个能拿到 'wx'。 */
63
+ const fd = fs.openSync(lockFile, 'wx')
64
+ try {
65
+ fs.writeFileSync(fd, JSON.stringify({ pid: process.pid, token, port: 0, timestamp: Date.now() }))
66
+ try { fs.fsyncSync(fd) } catch { /* 部分文件系统不支持 */ }
67
+ } finally {
68
+ fs.closeSync(fd)
69
+ }
70
+ return { file: lockFile, token }
71
+ } catch (error) {
72
+ if (error.code !== 'EEXIST') throw error
73
+ let info = null
74
+ try { info = JSON.parse(fs.readFileSync(lockFile, 'utf8')) } catch { /* 可能正在写入 */ }
75
+ let age = 0
76
+ try { age = Date.now() - fs.statSync(lockFile).mtimeMs } catch { /* 已被移除 */ }
77
+ if (info && info.pid) {
78
+ const alive = pidAlive(info.pid)
79
+ if (alive) {
80
+ if (Number(info.port) > 0 && healthPath) {
81
+ const probe = await probeExisting(`http://127.0.0.1:${Number(info.port)}`, healthPath, id)
82
+ if (probe.verdict === 'found') return null
83
+ /* 探针不可结论(超时等)≠ 端口没人:保守拒绝抢锁,宁可本次不起,
84
+ * 也不把可能活着的实例顶成双开(split-brain)。 */
85
+ if (probe.verdict === 'inconclusive') return null
86
+ /* pid 活着但锁里的端口明确拒绝连接 ⇒ pid 是被复用的号码,锁是残留。 */
87
+ } else if (age < startingGraceMs) {
88
+ return null
89
+ }
90
+ }
91
+ } else if (age < lockFreshGraceMs) {
92
+ return null
93
+ }
94
+ try { fs.rmSync(lockFile, { force: true }) } catch { /* 忽略 */ }
95
+ }
96
+ }
97
+ return null
98
+ }
99
+
100
+ function writeLock(lock, port) {
101
+ let current = null
102
+ try { current = JSON.parse(fs.readFileSync(lock.file, 'utf8')) } catch { /* 忽略 */ }
103
+ if (!current || current.token !== lock.token) {
104
+ throw new Error(`锁已被其它实例接管: ${lock.file}`)
105
+ }
106
+ fs.writeFileSync(lock.file, JSON.stringify({
107
+ pid: process.pid, token: lock.token, port, timestamp: Date.now(),
108
+ }))
109
+ }
110
+
111
+ function releaseLock(lock) {
112
+ if (!lock) return
113
+ try {
114
+ const data = JSON.parse(fs.readFileSync(lock.file, 'utf8'))
115
+ if (data.token === lock.token) fs.rmSync(lock.file, { force: true })
116
+ } catch { /* 不是自己的锁或已被删除 */ }
117
+ }
118
+
119
+ async function probeExisting(origin, healthPath, id) {
120
+ try {
121
+ const res = await fetch(`${origin}${healthPath}`, { signal: AbortSignal.timeout(tuning().reuseProbeTimeoutMs) })
122
+ if (!res.ok) return { verdict: 'absent' }
123
+ const info = await res.json()
124
+ if (info?.service === id || info?.name === id || info?.bridge === id) return { verdict: 'found', info }
125
+ return { verdict: 'absent' }
126
+ } catch (error) {
127
+ /* 只有「连接被拒绝」能证明端口上没有服务;超时/连接重置等是「不可结论」——
128
+ * 锁持有者可能只是应答慢。把不可结论当成「没人」会回收活锁,让两个实例同时
129
+ * 跑起来(split-brain)。调用方对 inconclusive 必须保守拒绝,而不是抢锁。 */
130
+ const code = error?.cause?.code || error?.code
131
+ if (code === 'ECONNREFUSED') return { verdict: 'absent' }
132
+ return { verdict: 'inconclusive' }
133
+ }
134
+ }
135
+
136
+ function safeJoin(root, rel) {
137
+ const target = path.resolve(root, `.${path.sep}${rel}`)
138
+ const base = path.resolve(root)
139
+ return target === base || target.startsWith(base + path.sep) ? target : null
140
+ }
141
+
142
+ /**
143
+ * @param {{
144
+ * id: string,
145
+ * title?: string,
146
+ * version?: string,
147
+ * contractVersion?: string,
148
+ * publicBasePath?: string,
149
+ * health?: (() => object)|object,
150
+ * metrics?: (() => Array<[string, number]>|string)|Array<[string, number]>|string,
151
+ * }} options
152
+ */
153
+ export function createServiceApp(options = {}) {
154
+ if (!options.id) throw new Error('createServiceApp: id 必填')
155
+ const id = String(options.id)
156
+ const title = options.title || id
157
+ const version = options.version || '0.0.0'
158
+ const contractVersion = options.contractVersion || '1.0.0'
159
+ const slug = slugOf(options.slug || id)
160
+ const startedAt = Date.now()
161
+ const routes = []
162
+ let healthExtra = options.health || null
163
+ let metricsExtra = options.metrics || null
164
+ let server = null
165
+ let embeddedDispose = null
166
+ let basePath = options.publicBasePath || ''
167
+ let listeningPort = 0
168
+ let url = ''
169
+ let closed = false
170
+ let workdir = ''
171
+
172
+ const app = {
173
+ id,
174
+ title,
175
+ version,
176
+ contractVersion,
177
+ slug,
178
+ get port() { return listeningPort },
179
+ get url() { return url },
180
+ get running() { return !!server || !!embeddedDispose },
181
+
182
+ /** 注册一个中间件式路由:返回 true 表示已处理。 */
183
+ use(handler) {
184
+ if (typeof handler !== 'function') throw new Error('service-host: route handler 必须是函数')
185
+ routes.push(handler)
186
+ return () => {
187
+ const index = routes.indexOf(handler)
188
+ if (index >= 0) routes.splice(index, 1)
189
+ }
190
+ },
191
+
192
+ get(pathname, handler) {
193
+ return app.use((req, res, u) => {
194
+ if (req.method !== 'GET' && req.method !== 'HEAD') return false
195
+ if (u.pathname !== pathname) return false
196
+ return Promise.resolve(handler(req, res, u)).then(() => true)
197
+ })
198
+ },
199
+
200
+ post(pathname, handler) {
201
+ return app.use((req, res, u) => {
202
+ if (req.method !== 'POST' || u.pathname !== pathname) return false
203
+ return Promise.resolve(handler(req, res, u)).then(() => true)
204
+ })
205
+ },
206
+
207
+ /** 静态目录挂载。files 可给显式映射:{ '/': ['index.html','text/html'] }。 */
208
+ static(prefix, dir, { files = null, index = 'index.html' } = {}) {
209
+ const cleanPrefix = prefix === '/' ? '' : prefix.replace(/\/+$/, '')
210
+ return app.use((req, res, u) => {
211
+ if (req.method !== 'GET' && req.method !== 'HEAD') return false
212
+ if (cleanPrefix && u.pathname !== cleanPrefix && !u.pathname.startsWith(cleanPrefix + '/')) return false
213
+ const relRaw = cleanPrefix ? u.pathname.slice(cleanPrefix.length) : u.pathname
214
+ const rel = relRaw === '' || relRaw === '/' ? index : decodeURIComponent(relRaw.replace(/^\/+/, ''))
215
+ let file = null
216
+ let type = mimeFor(rel)
217
+ if (files) {
218
+ const hit = files[relRaw === '' ? '/' : relRaw] || files[relRaw]
219
+ if (!hit) return false
220
+ const [name, explicitType] = Array.isArray(hit) ? hit : [hit]
221
+ file = safeJoin(dir, name)
222
+ type = explicitType || type
223
+ } else {
224
+ file = safeJoin(dir, rel)
225
+ }
226
+ if (!file) return false
227
+ try {
228
+ const data = fs.readFileSync(file)
229
+ res.writeHead(200, {
230
+ 'content-type': type,
231
+ 'content-length': data.length,
232
+ 'x-content-type-options': 'nosniff',
233
+ 'referrer-policy': 'no-referrer',
234
+ 'cache-control': 'no-cache',
235
+ })
236
+ res.end(req.method === 'HEAD' ? undefined : data)
237
+ return true
238
+ } catch {
239
+ return false
240
+ }
241
+ })
242
+ },
243
+
244
+ setHealth(fn) { healthExtra = fn; return app },
245
+ setMetrics(fn) { metricsExtra = fn; return app },
246
+
247
+ async health() {
248
+ const extra = typeof healthExtra === 'function' ? await healthExtra() : (healthExtra || {})
249
+ return {
250
+ ...extra,
251
+ ok: true,
252
+ service: id,
253
+ name: id,
254
+ title,
255
+ version,
256
+ contractVersion,
257
+ pid: process.pid,
258
+ port: listeningPort,
259
+ ...(workdir ? { workdir } : {}),
260
+ uptimeSec: Math.max(0, Math.round((Date.now() - startedAt) / 1000)),
261
+ }
262
+ },
263
+
264
+ async metricsText() {
265
+ const uptime = Math.max(0, Math.round((Date.now() - startedAt) / 1000))
266
+ const lines = [
267
+ `# HELP ${slug}_up 服务是否在线`,
268
+ `# TYPE ${slug}_up gauge`,
269
+ `${slug}_up 1`,
270
+ `# HELP ${slug}_uptime_seconds 服务运行秒数`,
271
+ `# TYPE ${slug}_uptime_seconds gauge`,
272
+ `${slug}_uptime_seconds ${uptime}`,
273
+ `# HELP ${slug}_port 实际监听端口`,
274
+ `# TYPE ${slug}_port gauge`,
275
+ `${slug}_port ${listeningPort}`,
276
+ ]
277
+ const extra = typeof metricsExtra === 'function' ? await metricsExtra() : metricsExtra
278
+ if (typeof extra === 'string' && extra) lines.push(extra.replace(/\s+$/, ''))
279
+ else if (Array.isArray(extra)) {
280
+ for (const row of extra) {
281
+ if (!Array.isArray(row)) continue
282
+ const [name, value] = row
283
+ if (name) lines.push(`${name} ${Number(value) || 0}`)
284
+ }
285
+ }
286
+ return lines.join('\n') + '\n'
287
+ },
288
+
289
+ async dispatch(req, res, stripPrefix = '') {
290
+ try {
291
+ /* 畸形请求行(如 absolute-form URL)不能让整个宿主进程崩溃。 */
292
+ const u = new URL(req.url || '/', 'http://127.0.0.1')
293
+ if (req.method !== 'GET' && req.method !== 'HEAD' && !isLoopbackOrigin(req.headers.origin)) {
294
+ return send(req, res, 403, { ok: false, error: 'cross-origin write blocked' })
295
+ }
296
+ if (stripPrefix && (u.pathname === stripPrefix || u.pathname.startsWith(stripPrefix + '/'))) {
297
+ u.pathname = u.pathname.slice(stripPrefix.length) || '/'
298
+ }
299
+ /* 挂载前缀之后再允许一层会话段:`<prefix>/s/<会话id>/…`。
300
+ * 剥掉它再交给工作台自己的路由,相对资源和相对 API 因此一行都不用改;
301
+ * 会话 id 同时挂在 `u.sessionId` / `req.sessionId` 上,需要区分的路由直接读。 */
302
+ const session = SESSION_PATH.exec(u.pathname)
303
+ if (session) {
304
+ const sid = session[1]
305
+ const rest = u.pathname.slice(session[0].length)
306
+ if (!rest) {
307
+ /* `<prefix>/s/<sid>` 少了尾斜杠:相对地址会被解析成 `<prefix>/s/<文件>`,
308
+ * 页面里的 ./app.js 直接 404。和静态宿主一样 301 补齐。 */
309
+ const location = `${stripPrefix || ''}${u.pathname}/${u.search || ''}`
310
+ try {
311
+ res.writeHead(301, { location, 'cache-control': 'no-store' })
312
+ res.end()
313
+ } catch { res.destroy() }
314
+ return
315
+ }
316
+ u.sessionId = sid
317
+ req.sessionId = sid
318
+ u.pathname = rest
319
+ }
320
+ if (u.pathname === '/healthz') {
321
+ return send(req, res, 200, await app.health())
322
+ }
323
+ if (u.pathname === '/metrics') {
324
+ return sendText(req, res, 200, await app.metricsText(), 'text/plain; version=0.0.4; charset=utf-8')
325
+ }
326
+ for (const handler of routes) {
327
+ if (await handler(req, res, u)) return
328
+ }
329
+ return send(req, res, 404, { ok: false, error: 'not found', path: u.pathname })
330
+ } catch (error) {
331
+ const status = error?.code === 'BODY_TOO_LARGE'
332
+ ? 413
333
+ : error?.code === 'BAD_JSON' || error?.code === 'ERR_INVALID_URL'
334
+ ? 400
335
+ : 500
336
+ if (!res.headersSent) send(req, res, status, { ok: false, error: String((error && error.message) || error) })
337
+ else res.destroy()
338
+ }
339
+ },
340
+
341
+ /**
342
+ * @param {{
343
+ * port?: number, host?: string, strictPort?: boolean, allowReuse?: boolean,
344
+ * scanLimit?: number, lockFile?: string, hostDir?: string,
345
+ * discoveryFile?: string, discovery?: object, publicBasePath?: string,
346
+ * webServer?: object, basePath?: string,
347
+ * }} listenOptions
348
+ */
349
+ async listen(listenOptions = {}) {
350
+ if (app.running) throw new Error(`service-host ${id}: 已经在运行`)
351
+ /* close 之后允许再次 listen:复位 closed,否则第二次 close 变空操作,
352
+ * 注册/锁/discovery 全部泄漏(历史故障形态)。 */
353
+ closed = false
354
+ const host = listenOptions.host || '127.0.0.1'
355
+ const port = Number(listenOptions.port ?? 0)
356
+ const strictPort = !!listenOptions.strictPort
357
+ const allowReuse = listenOptions.allowReuse !== false
358
+ const scanLimit = Number(listenOptions.scanLimit ?? tuning().portScanLimit)
359
+ basePath = listenOptions.publicBasePath ?? listenOptions.basePath ?? basePath ?? ''
360
+ if (basePath === '/') basePath = ''
361
+
362
+ const webServer = listenOptions.webServer
363
+ if (webServer && typeof webServer.register === 'function') {
364
+ const prefix = basePath || `/plugins/${id}`
365
+ embeddedDispose = webServer.register({
366
+ kind: 'prefix',
367
+ path: prefix,
368
+ handler: (req, res) => app.dispatch(req, res, prefix),
369
+ })
370
+ listeningPort = Number(webServer.port) || 0
371
+ url = `http://127.0.0.1:${listeningPort}${prefix}`
372
+ return { url, port: listeningPort, reused: false, mode: 'embedded', stop: app.close }
373
+ }
374
+
375
+ const hostDir = listenOptions.hostDir || path.join(os.tmpdir(), `dsh-${id}`)
376
+ workdir = path.resolve(hostDir)
377
+ const lockFile = listenOptions.lockFile || path.join(hostDir, 'service.lock')
378
+ const publicBasePath = basePath
379
+ const healthPath = `${publicBasePath}/healthz` || '/healthz'
380
+
381
+ if (allowReuse && port > 0) {
382
+ const probe = await probeExisting(`http://127.0.0.1:${port}`, healthPath, id)
383
+ const existing = probe.verdict === 'found' ? probe.info : null
384
+ /* 复用必须“同身份”:契约版本相同只说明协议兼容,不代表跑的是当前代码。
385
+ * 历史故障:套件升级到 0.2.1 后,9 小时前的 0.2.0 进程因 contractVersion
386
+ * 同为 1.0.0 被复用,新代码根本没跑起来。身份 = 包版本 + 契约版本 + 数据目录。
387
+ * workdir 不同 = 同版本但指向另一份数据,静默复用会把请求打进错实例。 */
388
+ const sameContract = !!existing?.contractVersion && existing.contractVersion === contractVersion
389
+ const sameVersion = !existing?.version || existing.version === version
390
+ const sameWorkdir = !existing?.workdir || path.resolve(existing.workdir) === workdir
391
+ if (existing && sameContract && sameVersion && sameWorkdir) {
392
+ listeningPort = port
393
+ url = `http://127.0.0.1:${port}${publicBasePath}`
394
+ return { url, port, reused: true, mode: 'standalone', stop: async () => {} }
395
+ }
396
+ if (existing && !(sameContract && sameVersion && sameWorkdir)) {
397
+ const old = `pid ${existing.pid || '?'},version ${existing.version || '?'},contract ${existing.contractVersion || '?'},workdir ${existing.workdir || '?'}`
398
+ throw new Error(
399
+ `${id} 端口 ${port} 被不同身份的实例占用(${old};当前 ${version} / ${contractVersion} / ${workdir})。` +
400
+ `为避免“新套件 + 旧进程”或“同版本 + 错数据目录”的假启动,已拒绝复用:请结束 ${existing.pid || '该'} 进程或重启 DSH 后再启动。`,
401
+ )
402
+ }
403
+ }
404
+
405
+ const lock = await acquireLock(lockFile, { healthPath, id })
406
+ if (!lock) {
407
+ throw new Error(`${id} 已有另一个实例在运行;如确认没有,请删除锁文件: ${lockFile}`)
408
+ }
409
+
410
+ let actualPort = port
411
+ let lastError = null
412
+ const requestTimeoutMs = Number(listenOptions.requestTimeoutMs) || 30000
413
+ const headersTimeoutMs = Number(listenOptions.headersTimeoutMs) || 10000
414
+ const keepAliveTimeoutMs = Number(listenOptions.keepAliveTimeoutMs) || 5000
415
+ for (let attempt = 0; attempt <= (strictPort ? 0 : scanLimit); attempt++) {
416
+ const tryPort = port === 0 ? 0 : port + attempt
417
+ try {
418
+ server = await listen(tryPort, { host, requestTimeoutMs, headersTimeoutMs, keepAliveTimeoutMs })
419
+ actualPort = server.address().port
420
+ break
421
+ } catch (error) {
422
+ lastError = error
423
+ if (port === 0 || strictPort || attempt === scanLimit) {
424
+ releaseLock(lock)
425
+ throw new Error(`端口 ${tryPort} 不可用${strictPort ? '(strictPort)' : ''}: ${(error && error.message) || error}`)
426
+ }
427
+ }
428
+ }
429
+ if (!server) {
430
+ releaseLock(lock)
431
+ throw lastError || new Error('无法监听端口')
432
+ }
433
+
434
+ try {
435
+ writeLock(lock, actualPort)
436
+ } catch (error) {
437
+ try { server.close() } catch { /* 忽略 */ }
438
+ server = null
439
+ releaseLock(lock)
440
+ throw error
441
+ }
442
+ listeningPort = actualPort
443
+ url = `http://127.0.0.1:${actualPort}${publicBasePath}`
444
+
445
+ server.on('request', (req, res) => {
446
+ Promise.resolve(app.dispatch(req, res, publicBasePath)).catch((error) => {
447
+ try {
448
+ if (!res.headersSent) send(req, res, 500, { ok: false, error: String((error && error.message) || error) })
449
+ else res.destroy()
450
+ } catch { /* 连接已断开 */ }
451
+ })
452
+ })
453
+ const discoveryFile = listenOptions.discoveryFile
454
+ || (listenOptions.hostDir ? path.join(hostDir, 'discovery.json') : '')
455
+ if (discoveryFile) {
456
+ try {
457
+ fs.mkdirSync(path.dirname(discoveryFile), { recursive: true })
458
+ fs.writeFileSync(discoveryFile, JSON.stringify({
459
+ service: id,
460
+ ...(listenOptions.discovery || {}),
461
+ url, port: actualPort, pid: process.pid, updated: new Date().toISOString(),
462
+ }, null, 2))
463
+ } catch { /* discovery 写失败不影响服务 */ }
464
+ }
465
+
466
+ app._lock = lock
467
+ app._discoveryFile = discoveryFile
468
+ return { url, port: actualPort, reused: false, mode: 'standalone', stop: app.close }
469
+ },
470
+
471
+ async close() {
472
+ if (closed) return
473
+ closed = true
474
+ if (embeddedDispose) {
475
+ try { embeddedDispose() } catch { /* 忽略 */ }
476
+ embeddedDispose = null
477
+ return
478
+ }
479
+ if (!server) return
480
+ const srv = server
481
+ server = null
482
+ await new Promise((resolve) => {
483
+ const { closeGraceMs, closeForceMs } = tuning()
484
+ let done = false
485
+ const finish = () => { if (done) return; done = true; resolve() }
486
+ srv.close(finish)
487
+ setTimeout(() => srv.closeAllConnections?.(), closeGraceMs).unref?.()
488
+ setTimeout(finish, closeForceMs).unref?.()
489
+ })
490
+ if (app._discoveryFile) {
491
+ try {
492
+ const data = JSON.parse(fs.readFileSync(app._discoveryFile, 'utf8'))
493
+ if (data.pid === process.pid) fs.rmSync(app._discoveryFile, { force: true })
494
+ } catch { /* 忽略 */ }
495
+ }
496
+ if (app._lock) releaseLock(app._lock)
497
+ },
498
+ }
499
+
500
+ return app
501
+ }
502
+
503
+ export function createServiceHost(config = {}) {
504
+ return {
505
+ api: createServiceApi('serviceHost', '1.0.0', ['http', 'static', 'health', 'metrics', 'lock', 'reuse', 'discovery', 'shared-host']),
506
+ version: '0.1.0',
507
+ createApp(options = {}) {
508
+ return createServiceApp({ ...config, ...options })
509
+ },
510
+ createSharedHost(options = {}) {
511
+ return createSharedHost({ ...config, ...options })
512
+ },
513
+ readBody,
514
+ }
515
+ }
516
+
517
+ /**
518
+ * 共享宿主:多个功能插件挂到同一个 HTTP server / 同一个端口。
519
+ *
520
+ * const host = ctx.serviceHost.createSharedHost({ id: 'dsh-app' })
521
+ * host.mount('/plugins/ppt', pptApp)
522
+ * host.mount('/plugins/canvas', canvasApp)
523
+ * await host.listen({ port: 3080 })
524
+ *
525
+ * 每个子 app 仍由 createServiceApp 创建;共享宿主只负责前缀分发和统一生命周期。
526
+ * @param {{ id?: string, title?: string, version?: string, contractVersion?: string, health?: Function|object }} options
527
+ */
528
+ export function createSharedHost(options = {}) {
529
+ const mounts = new Map()
530
+ const id = options.id || 'dsh-shared-host'
531
+ const app = createServiceApp({
532
+ ...options,
533
+ id,
534
+ title: options.title || 'DSH Shared Host',
535
+ version: options.version || '0.1.0',
536
+ contractVersion: options.contractVersion || '1.0.0',
537
+ health: options.health || (() => ({ children: [...mounts.keys()] })),
538
+ })
539
+
540
+ const mount = (prefix, child) => {
541
+ const clean = String(prefix || '').replace(/\/+$/, '') || '/'
542
+ if (clean === '/') throw new Error('shared-host: 子插件必须使用非根前缀')
543
+ if (mounts.has(clean)) throw new Error(`shared-host: 前缀已挂载: ${clean}`)
544
+ if (!child || typeof child.dispatch !== 'function') throw new Error(`shared-host: ${clean} 的子 app 必须提供 dispatch()`)
545
+ const dispose = app.use((req, res, u) => {
546
+ if (u.pathname !== clean && !u.pathname.startsWith(clean + '/')) return false
547
+ return child.dispatch(req, res, clean).then(() => true)
548
+ })
549
+ mounts.set(clean, { child, dispose })
550
+ return () => {
551
+ dispose()
552
+ mounts.delete(clean)
553
+ }
554
+ }
555
+
556
+ return {
557
+ id,
558
+ app,
559
+ api: createServiceApi('serviceHost', '1.0.0', ['shared-host']),
560
+ mount,
561
+ children() { return [...mounts.keys()] },
562
+ listen(listenOptions = {}) {
563
+ return app.listen(listenOptions)
564
+ },
565
+ close() {
566
+ return app.close()
567
+ },
568
+ }
569
+ }
570
+
571
+ export { send, sendText, readBody }
@@ -0,0 +1,63 @@
1
+ /**
2
+ * @capyclaw/service-host 运行时调优层。
3
+ *
4
+ * 默认值与进化搜索(evolution/ NSGA-II)的 founder 基线保持一致;
5
+ * 生产环境可用 DSH_TUNING_JSON 覆盖(按包名分组),测试/评估用 setTuning 注入。
6
+ */
7
+
8
+ const DEFAULTS = {
9
+ /* 端口被占时向后顺延扫描的次数上限(非 strictPort) */
10
+ portScanLimit: 50,
11
+ /* 复用既有实例的 /healthz 探测超时
12
+ * 200ms 由进化搜索固化(evolution/,2026-11-01):黑洞端口启动阻塞 425→227ms;
13
+ * 健康实例 RTT 1-3ms,仍有 60 倍以上余量。 */
14
+ reuseProbeTimeoutMs: 200,
15
+ /* 单实例锁:空/坏锁视为残留前的宽限 */
16
+ lockFreshGraceMs: 2000,
17
+ /* 优雅关闭:先等 N ms 再断开全部连接 */
18
+ closeGraceMs: 50,
19
+ /* 优雅关闭:强制完成的兜底时限 */
20
+ closeForceMs: 1000,
21
+ }
22
+
23
+ let overrides = {}
24
+ let envLoaded = false
25
+
26
+ function loadEnv() {
27
+ if (envLoaded) return
28
+ envLoaded = true
29
+ try {
30
+ const raw = process.env.DSH_TUNING_JSON
31
+ if (!raw) return
32
+ const parsed = JSON.parse(raw)
33
+ if (!parsed || typeof parsed !== 'object') return
34
+ const own = parsed['dsh-service-host'] && typeof parsed['dsh-service-host'] === 'object'
35
+ ? parsed['dsh-service-host']
36
+ : parsed
37
+ for (const key of Object.keys(DEFAULTS)) {
38
+ if (own[key] !== undefined) overrides[key] = own[key]
39
+ }
40
+ } catch { /* 非法 JSON 静默忽略:调优失败不能阻塞启动 */ }
41
+ }
42
+
43
+ /** 当前生效参数(默认值 + env + setTuning 覆盖)。 */
44
+ export function tuning() {
45
+ loadEnv()
46
+ return { ...DEFAULTS, ...overrides }
47
+ }
48
+
49
+ /** 测试/评估注入。只接受已知键,避免拼写错误静默生效。 */
50
+ export function setTuning(patch = {}) {
51
+ loadEnv()
52
+ for (const [key, value] of Object.entries(patch)) {
53
+ if (key in DEFAULTS) overrides[key] = value
54
+ }
55
+ }
56
+
57
+ /** 恢复到默认值 + env 覆盖。 */
58
+ export function resetTuning() {
59
+ overrides = {}
60
+ envLoaded = false
61
+ }
62
+
63
+ export const TUNING_DEFAULTS = { ...DEFAULTS }
@@ -0,0 +1,31 @@
1
+ # capyclaw-skills-service
2
+
3
+ DSH 独立技能服务(服务解耦标准形态)。把原「`ctx.skills` 进程内注册表」的
4
+ 技能内容(SKILL.md)搬出 dsh 进程,作为独立端口服务:
5
+
6
+ ```
7
+ GET /healthz { ok, service:"dsh-skills", pid, port, providers, skills }
8
+ GET /skills 全量技能清单(聚合各 provider)
9
+ GET /skills/:name 单技能正文(原 provider.get 形状)
10
+ ```
11
+
12
+ ## 技能数据源
13
+
14
+ 自动扫描两类布局(都找 `capyclaw-ppt-skill-*` 目录里的 `lib/index.mjs`):
15
+
16
+ - dev 树:`../plugin/capyclaw-ppt-skill-*`
17
+ - 套件安装态:本目录同级(`node_modules/capyclaw-ppt-skill-*`)
18
+
19
+ 可用 `--providers <dir>[[;|,]dir…]` 显式指定。
20
+
21
+ ## 由谁拉起
22
+
23
+ `@capyclaw/service-broker` 按清单以独立进程拉起(套件捆绑布局的清单见
24
+ @capyclaw/ppt-suite 包根 `services.json`,端口 `"auto"` 由 broker 现分配)。dsh 侧经 broker 的
25
+ skills 瘦客户端(`ctx.skills` 兼容形状)访问本服务。
26
+
27
+ ## 独立运行
28
+
29
+ ```bash
30
+ node server.mjs [--port 0] [--providers dir1,dir2] # 0 = OS 随机分配
31
+ ```