aws-runtime-bridge 1.9.134 → 1.9.137

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 (820) hide show
  1. package/dist/adapter/AcodeSdkAdapter.d.ts +8 -0
  2. package/dist/adapter/AcodeSdkAdapter.js +5 -5
  3. package/dist/config.d.ts +4 -0
  4. package/dist/config.js +2 -2
  5. package/dist/index.js +1 -1
  6. package/dist/routes/ai-sources.js +1 -1
  7. package/dist/routes/capabilities.d.ts +2 -0
  8. package/dist/routes/capabilities.js +2 -0
  9. package/dist/routes/instance.d.ts +0 -1
  10. package/dist/routes/instance.js +1 -1
  11. package/dist/routes/mcp-extra.d.ts +2 -0
  12. package/dist/routes/mcp-extra.js +3 -0
  13. package/dist/routes/mcp.d.ts +1 -0
  14. package/dist/routes/mcp.js +1 -1
  15. package/dist/routes/plugins.d.ts +2 -0
  16. package/dist/routes/plugins.js +2 -0
  17. package/dist/routes/skills.d.ts +1 -0
  18. package/dist/routes/skills.js +1 -1
  19. package/dist/routes/terminal.js +25 -25
  20. package/dist/services/agent-capability-sync.d.ts +7 -0
  21. package/dist/services/agent-capability-sync.js +2 -0
  22. package/{package/cc-switch-sdk/dist → dist}/services/ai-config-service.d.ts +3 -0
  23. package/dist/services/ai-config-service.js +4 -0
  24. package/dist/services/ai-source-apply.d.ts +1 -1
  25. package/dist/services/ai-source-apply.js +1 -1
  26. package/dist/services/capability-config.d.ts +21 -0
  27. package/dist/services/capability-config.js +3 -0
  28. package/dist/services/instance-ai-config-service.d.ts +1 -0
  29. package/dist/services/instance-ai-config-service.js +1 -1
  30. package/dist/services/instance-features.d.ts +21 -0
  31. package/dist/services/instance-features.js +1 -1
  32. package/dist/services/instance-init-service.d.ts +7 -4
  33. package/dist/services/instance-init-service.js +1 -1
  34. package/dist/services/instance-state.js +1 -1
  35. package/dist/services/legacy-path-migration.d.ts +2 -0
  36. package/dist/services/legacy-path-migration.js +1 -1
  37. package/dist/services/mcp-deploy.d.ts +49 -0
  38. package/dist/services/mcp-deploy.js +4 -0
  39. package/dist/services/plugin-event-buffer.d.ts +49 -0
  40. package/dist/services/plugin-event-buffer.js +2 -0
  41. package/dist/services/plugin-manager.d.ts +240 -0
  42. package/dist/services/plugin-manager.js +10 -0
  43. package/dist/services/plugin-package.d.ts +8 -0
  44. package/dist/services/plugin-package.js +2 -0
  45. package/dist/services/skill-manager.d.ts +41 -0
  46. package/dist/services/skill-manager.js +3 -0
  47. package/dist/types.d.ts +11 -61
  48. package/dist/utils/file-utils.d.ts +9 -6
  49. package/dist/utils/file-utils.js +2 -2
  50. package/dist/utils/mcp-utils.d.ts +1 -37
  51. package/dist/utils/mcp-utils.js +1 -1
  52. package/package/acode/dist/built-in-file-tools.js +2 -2
  53. package/package/acode/dist/commands/commandRegistry.d.ts +2 -0
  54. package/package/acode/dist/commands/commandRegistry.js +1 -1
  55. package/package/acode/dist/index.d.ts +2 -0
  56. package/package/acode/dist/index.js +1 -1
  57. package/package/acode/dist/plugin-tools.d.ts +14 -0
  58. package/package/acode/dist/plugin-tools.js +14 -0
  59. package/package/acode/dist/plugin-types.d.ts +109 -0
  60. package/package/acode/dist/runtime.d.ts +2 -0
  61. package/package/acode/dist/runtime.js +14 -14
  62. package/package/acode/dist/sub-agent-manager.js +1 -1
  63. package/package/acode/dist/types.d.ts +3 -0
  64. package/package/aws-client-agent-mcp/dist/agent-client.d.ts +9 -1
  65. package/package/aws-client-agent-mcp/dist/agent-client.js +1 -1
  66. package/package/aws-client-agent-mcp/dist/mcp-server.d.ts +11 -0
  67. package/package/aws-client-agent-mcp/dist/mcp-server.js +21 -21
  68. package/package/aws-client-agent-mcp/dist/mcp-tools.js +2 -4
  69. package/package/aws-client-agent-mcp/dist/memory-tools.js +8 -10
  70. package/package/aws-client-agent-mcp/dist/types.d.ts +21 -0
  71. package/package.json +4 -10
  72. package/dist/adapters/cc-switch/common.d.ts +0 -41
  73. package/dist/adapters/cc-switch/common.js +0 -2
  74. package/dist/adapters/cc-switch/index.d.ts +0 -19
  75. package/dist/adapters/cc-switch/index.js +0 -2
  76. package/dist/adapters/cc-switch/mcp-acode.d.ts +0 -10
  77. package/dist/adapters/cc-switch/mcp-acode.js +0 -2
  78. package/dist/adapters/cc-switch/mcp-claude.d.ts +0 -10
  79. package/dist/adapters/cc-switch/mcp-claude.js +0 -2
  80. package/dist/adapters/cc-switch/mcp-claudecode.d.ts +0 -10
  81. package/dist/adapters/cc-switch/mcp-claudecode.js +0 -2
  82. package/dist/adapters/cc-switch/mcp-codex.d.ts +0 -10
  83. package/dist/adapters/cc-switch/mcp-codex.js +0 -11
  84. package/dist/adapters/cc-switch/mcp-opencode.d.ts +0 -14
  85. package/dist/adapters/cc-switch/mcp-opencode.js +0 -2
  86. package/dist/adapters/cc-switch/mcp-placeholder.d.ts +0 -9
  87. package/dist/adapters/cc-switch/mcp-placeholder.js +0 -2
  88. package/dist/adapters/cc-switch/skill-acode.d.ts +0 -5
  89. package/dist/adapters/cc-switch/skill-acode.js +0 -2
  90. package/dist/adapters/cc-switch/skill-claude.d.ts +0 -5
  91. package/dist/adapters/cc-switch/skill-claude.js +0 -2
  92. package/dist/adapters/cc-switch/skill-claudecode.d.ts +0 -5
  93. package/dist/adapters/cc-switch/skill-claudecode.js +0 -2
  94. package/dist/adapters/cc-switch/skill-codex.d.ts +0 -4
  95. package/dist/adapters/cc-switch/skill-codex.js +0 -2
  96. package/dist/adapters/cc-switch/skill-directory.d.ts +0 -9
  97. package/dist/adapters/cc-switch/skill-directory.js +0 -3
  98. package/dist/adapters/cc-switch/skill-opencode.d.ts +0 -5
  99. package/dist/adapters/cc-switch/skill-opencode.js +0 -2
  100. package/dist/adapters/cc-switch/skill-placeholder.d.ts +0 -9
  101. package/dist/adapters/cc-switch/skill-placeholder.js +0 -2
  102. package/dist/services/cc-switch-sdk.d.ts +0 -17
  103. package/dist/services/cc-switch-sdk.js +0 -2
  104. package/dist/services/instance-service.d.ts +0 -78
  105. package/dist/services/instance-service.js +0 -2
  106. package/node_modules/@cc-switch/sdk/README.md +0 -541
  107. package/node_modules/@cc-switch/sdk/dist/constants.d.ts +0 -8
  108. package/node_modules/@cc-switch/sdk/dist/constants.js +0 -2
  109. package/node_modules/@cc-switch/sdk/dist/errors.d.ts +0 -5
  110. package/node_modules/@cc-switch/sdk/dist/errors.js +0 -2
  111. package/node_modules/@cc-switch/sdk/dist/index.d.ts +0 -5
  112. package/node_modules/@cc-switch/sdk/dist/index.js +0 -2
  113. package/node_modules/@cc-switch/sdk/dist/schemas.d.ts +0 -7
  114. package/node_modules/@cc-switch/sdk/dist/schemas.js +0 -2
  115. package/node_modules/@cc-switch/sdk/dist/sdk.d.ts +0 -59
  116. package/node_modules/@cc-switch/sdk/dist/sdk.js +0 -2
  117. package/node_modules/@cc-switch/sdk/dist/services/ai-config-service.d.ts +0 -81
  118. package/node_modules/@cc-switch/sdk/dist/services/ai-config-service.js +0 -4
  119. package/node_modules/@cc-switch/sdk/dist/services/mcp-model.d.ts +0 -16
  120. package/node_modules/@cc-switch/sdk/dist/services/mcp-model.js +0 -2
  121. package/node_modules/@cc-switch/sdk/dist/services/mcp-service.d.ts +0 -17
  122. package/node_modules/@cc-switch/sdk/dist/services/mcp-service.js +0 -2
  123. package/node_modules/@cc-switch/sdk/dist/services/skill-model.d.ts +0 -16
  124. package/node_modules/@cc-switch/sdk/dist/services/skill-model.js +0 -2
  125. package/node_modules/@cc-switch/sdk/dist/services/skill-service.d.ts +0 -16
  126. package/node_modules/@cc-switch/sdk/dist/services/skill-service.js +0 -2
  127. package/node_modules/@cc-switch/sdk/dist/state.d.ts +0 -3
  128. package/node_modules/@cc-switch/sdk/dist/state.js +0 -2
  129. package/node_modules/@cc-switch/sdk/dist/types.d.ts +0 -78
  130. package/node_modules/@cc-switch/sdk/dist/utils/fs.d.ts +0 -10
  131. package/node_modules/@cc-switch/sdk/dist/utils/fs.js +0 -3
  132. package/node_modules/@cc-switch/sdk/dist/utils/id.d.ts +0 -3
  133. package/node_modules/@cc-switch/sdk/dist/utils/id.js +0 -2
  134. package/node_modules/@cc-switch/sdk/package.json +0 -31
  135. package/node_modules/zod/LICENSE +0 -21
  136. package/node_modules/zod/README.md +0 -208
  137. package/node_modules/zod/index.cjs +0 -33
  138. package/node_modules/zod/index.d.cts +0 -4
  139. package/node_modules/zod/index.d.ts +0 -4
  140. package/node_modules/zod/index.js +0 -4
  141. package/node_modules/zod/locales/index.cjs +0 -17
  142. package/node_modules/zod/locales/index.d.cts +0 -1
  143. package/node_modules/zod/locales/index.d.ts +0 -1
  144. package/node_modules/zod/locales/index.js +0 -1
  145. package/node_modules/zod/locales/package.json +0 -6
  146. package/node_modules/zod/mini/index.cjs +0 -17
  147. package/node_modules/zod/mini/index.d.cts +0 -1
  148. package/node_modules/zod/mini/index.d.ts +0 -1
  149. package/node_modules/zod/mini/index.js +0 -1
  150. package/node_modules/zod/mini/package.json +0 -6
  151. package/node_modules/zod/package.json +0 -135
  152. package/node_modules/zod/src/index.ts +0 -4
  153. package/node_modules/zod/src/locales/index.ts +0 -1
  154. package/node_modules/zod/src/mini/index.ts +0 -1
  155. package/node_modules/zod/src/v3/ZodError.ts +0 -330
  156. package/node_modules/zod/src/v3/benchmarks/datetime.ts +0 -58
  157. package/node_modules/zod/src/v3/benchmarks/discriminatedUnion.ts +0 -80
  158. package/node_modules/zod/src/v3/benchmarks/index.ts +0 -59
  159. package/node_modules/zod/src/v3/benchmarks/ipv4.ts +0 -57
  160. package/node_modules/zod/src/v3/benchmarks/object.ts +0 -69
  161. package/node_modules/zod/src/v3/benchmarks/primitives.ts +0 -162
  162. package/node_modules/zod/src/v3/benchmarks/realworld.ts +0 -63
  163. package/node_modules/zod/src/v3/benchmarks/string.ts +0 -55
  164. package/node_modules/zod/src/v3/benchmarks/union.ts +0 -80
  165. package/node_modules/zod/src/v3/errors.ts +0 -13
  166. package/node_modules/zod/src/v3/external.ts +0 -6
  167. package/node_modules/zod/src/v3/helpers/enumUtil.ts +0 -17
  168. package/node_modules/zod/src/v3/helpers/errorUtil.ts +0 -8
  169. package/node_modules/zod/src/v3/helpers/parseUtil.ts +0 -176
  170. package/node_modules/zod/src/v3/helpers/partialUtil.ts +0 -34
  171. package/node_modules/zod/src/v3/helpers/typeAliases.ts +0 -2
  172. package/node_modules/zod/src/v3/helpers/util.ts +0 -224
  173. package/node_modules/zod/src/v3/index.ts +0 -4
  174. package/node_modules/zod/src/v3/locales/en.ts +0 -124
  175. package/node_modules/zod/src/v3/standard-schema.ts +0 -113
  176. package/node_modules/zod/src/v3/tests/Mocker.ts +0 -54
  177. package/node_modules/zod/src/v3/tests/all-errors.test.ts +0 -157
  178. package/node_modules/zod/src/v3/tests/anyunknown.test.ts +0 -28
  179. package/node_modules/zod/src/v3/tests/array.test.ts +0 -71
  180. package/node_modules/zod/src/v3/tests/async-parsing.test.ts +0 -388
  181. package/node_modules/zod/src/v3/tests/async-refinements.test.ts +0 -46
  182. package/node_modules/zod/src/v3/tests/base.test.ts +0 -29
  183. package/node_modules/zod/src/v3/tests/bigint.test.ts +0 -55
  184. package/node_modules/zod/src/v3/tests/branded.test.ts +0 -53
  185. package/node_modules/zod/src/v3/tests/catch.test.ts +0 -220
  186. package/node_modules/zod/src/v3/tests/coerce.test.ts +0 -133
  187. package/node_modules/zod/src/v3/tests/complex.test.ts +0 -56
  188. package/node_modules/zod/src/v3/tests/custom.test.ts +0 -31
  189. package/node_modules/zod/src/v3/tests/date.test.ts +0 -32
  190. package/node_modules/zod/src/v3/tests/deepmasking.test.ts +0 -186
  191. package/node_modules/zod/src/v3/tests/default.test.ts +0 -112
  192. package/node_modules/zod/src/v3/tests/description.test.ts +0 -33
  193. package/node_modules/zod/src/v3/tests/discriminated-unions.test.ts +0 -315
  194. package/node_modules/zod/src/v3/tests/enum.test.ts +0 -80
  195. package/node_modules/zod/src/v3/tests/error.test.ts +0 -551
  196. package/node_modules/zod/src/v3/tests/firstparty.test.ts +0 -87
  197. package/node_modules/zod/src/v3/tests/firstpartyschematypes.test.ts +0 -21
  198. package/node_modules/zod/src/v3/tests/function.test.ts +0 -257
  199. package/node_modules/zod/src/v3/tests/generics.test.ts +0 -48
  200. package/node_modules/zod/src/v3/tests/instanceof.test.ts +0 -37
  201. package/node_modules/zod/src/v3/tests/intersection.test.ts +0 -110
  202. package/node_modules/zod/src/v3/tests/language-server.source.ts +0 -76
  203. package/node_modules/zod/src/v3/tests/language-server.test.ts +0 -207
  204. package/node_modules/zod/src/v3/tests/literal.test.ts +0 -36
  205. package/node_modules/zod/src/v3/tests/map.test.ts +0 -110
  206. package/node_modules/zod/src/v3/tests/masking.test.ts +0 -4
  207. package/node_modules/zod/src/v3/tests/mocker.test.ts +0 -19
  208. package/node_modules/zod/src/v3/tests/nan.test.ts +0 -21
  209. package/node_modules/zod/src/v3/tests/nativeEnum.test.ts +0 -87
  210. package/node_modules/zod/src/v3/tests/nullable.test.ts +0 -42
  211. package/node_modules/zod/src/v3/tests/number.test.ts +0 -176
  212. package/node_modules/zod/src/v3/tests/object-augmentation.test.ts +0 -29
  213. package/node_modules/zod/src/v3/tests/object-in-es5-env.test.ts +0 -29
  214. package/node_modules/zod/src/v3/tests/object.test.ts +0 -434
  215. package/node_modules/zod/src/v3/tests/optional.test.ts +0 -42
  216. package/node_modules/zod/src/v3/tests/parseUtil.test.ts +0 -23
  217. package/node_modules/zod/src/v3/tests/parser.test.ts +0 -41
  218. package/node_modules/zod/src/v3/tests/partials.test.ts +0 -243
  219. package/node_modules/zod/src/v3/tests/pickomit.test.ts +0 -111
  220. package/node_modules/zod/src/v3/tests/pipeline.test.ts +0 -29
  221. package/node_modules/zod/src/v3/tests/preprocess.test.ts +0 -186
  222. package/node_modules/zod/src/v3/tests/primitive.test.ts +0 -440
  223. package/node_modules/zod/src/v3/tests/promise.test.ts +0 -90
  224. package/node_modules/zod/src/v3/tests/readonly.test.ts +0 -194
  225. package/node_modules/zod/src/v3/tests/record.test.ts +0 -171
  226. package/node_modules/zod/src/v3/tests/recursive.test.ts +0 -197
  227. package/node_modules/zod/src/v3/tests/refine.test.ts +0 -313
  228. package/node_modules/zod/src/v3/tests/safeparse.test.ts +0 -27
  229. package/node_modules/zod/src/v3/tests/set.test.ts +0 -142
  230. package/node_modules/zod/src/v3/tests/standard-schema.test.ts +0 -83
  231. package/node_modules/zod/src/v3/tests/string.test.ts +0 -916
  232. package/node_modules/zod/src/v3/tests/transformer.test.ts +0 -233
  233. package/node_modules/zod/src/v3/tests/tuple.test.ts +0 -90
  234. package/node_modules/zod/src/v3/tests/unions.test.ts +0 -57
  235. package/node_modules/zod/src/v3/tests/validations.test.ts +0 -133
  236. package/node_modules/zod/src/v3/tests/void.test.ts +0 -15
  237. package/node_modules/zod/src/v3/types.ts +0 -5138
  238. package/node_modules/zod/src/v4/classic/checks.ts +0 -31
  239. package/node_modules/zod/src/v4/classic/coerce.ts +0 -27
  240. package/node_modules/zod/src/v4/classic/compat.ts +0 -70
  241. package/node_modules/zod/src/v4/classic/errors.ts +0 -82
  242. package/node_modules/zod/src/v4/classic/external.ts +0 -50
  243. package/node_modules/zod/src/v4/classic/index.ts +0 -5
  244. package/node_modules/zod/src/v4/classic/iso.ts +0 -90
  245. package/node_modules/zod/src/v4/classic/parse.ts +0 -82
  246. package/node_modules/zod/src/v4/classic/schemas.ts +0 -2197
  247. package/node_modules/zod/src/v4/classic/tests/anyunknown.test.ts +0 -26
  248. package/node_modules/zod/src/v4/classic/tests/array.test.ts +0 -264
  249. package/node_modules/zod/src/v4/classic/tests/assignability.test.ts +0 -210
  250. package/node_modules/zod/src/v4/classic/tests/async-parsing.test.ts +0 -381
  251. package/node_modules/zod/src/v4/classic/tests/async-refinements.test.ts +0 -68
  252. package/node_modules/zod/src/v4/classic/tests/base.test.ts +0 -7
  253. package/node_modules/zod/src/v4/classic/tests/bigint.test.ts +0 -54
  254. package/node_modules/zod/src/v4/classic/tests/brand.test.ts +0 -63
  255. package/node_modules/zod/src/v4/classic/tests/catch.test.ts +0 -276
  256. package/node_modules/zod/src/v4/classic/tests/coalesce.test.ts +0 -20
  257. package/node_modules/zod/src/v4/classic/tests/codec-examples.test.ts +0 -573
  258. package/node_modules/zod/src/v4/classic/tests/codec.test.ts +0 -562
  259. package/node_modules/zod/src/v4/classic/tests/coerce.test.ts +0 -160
  260. package/node_modules/zod/src/v4/classic/tests/continuability.test.ts +0 -352
  261. package/node_modules/zod/src/v4/classic/tests/custom.test.ts +0 -40
  262. package/node_modules/zod/src/v4/classic/tests/date.test.ts +0 -31
  263. package/node_modules/zod/src/v4/classic/tests/datetime.test.ts +0 -302
  264. package/node_modules/zod/src/v4/classic/tests/default.test.ts +0 -365
  265. package/node_modules/zod/src/v4/classic/tests/description.test.ts +0 -32
  266. package/node_modules/zod/src/v4/classic/tests/discriminated-unions.test.ts +0 -661
  267. package/node_modules/zod/src/v4/classic/tests/enum.test.ts +0 -285
  268. package/node_modules/zod/src/v4/classic/tests/error-utils.test.ts +0 -595
  269. package/node_modules/zod/src/v4/classic/tests/error.test.ts +0 -711
  270. package/node_modules/zod/src/v4/classic/tests/file.test.ts +0 -96
  271. package/node_modules/zod/src/v4/classic/tests/firstparty.test.ts +0 -179
  272. package/node_modules/zod/src/v4/classic/tests/function.test.ts +0 -308
  273. package/node_modules/zod/src/v4/classic/tests/generics.test.ts +0 -72
  274. package/node_modules/zod/src/v4/classic/tests/hash.test.ts +0 -68
  275. package/node_modules/zod/src/v4/classic/tests/index.test.ts +0 -844
  276. package/node_modules/zod/src/v4/classic/tests/instanceof.test.ts +0 -34
  277. package/node_modules/zod/src/v4/classic/tests/intersection.test.ts +0 -171
  278. package/node_modules/zod/src/v4/classic/tests/json.test.ts +0 -108
  279. package/node_modules/zod/src/v4/classic/tests/lazy.test.ts +0 -227
  280. package/node_modules/zod/src/v4/classic/tests/literal.test.ts +0 -117
  281. package/node_modules/zod/src/v4/classic/tests/map.test.ts +0 -196
  282. package/node_modules/zod/src/v4/classic/tests/nan.test.ts +0 -21
  283. package/node_modules/zod/src/v4/classic/tests/nested-refine.test.ts +0 -168
  284. package/node_modules/zod/src/v4/classic/tests/nonoptional.test.ts +0 -101
  285. package/node_modules/zod/src/v4/classic/tests/nullable.test.ts +0 -22
  286. package/node_modules/zod/src/v4/classic/tests/number.test.ts +0 -270
  287. package/node_modules/zod/src/v4/classic/tests/object.test.ts +0 -609
  288. package/node_modules/zod/src/v4/classic/tests/optional.test.ts +0 -136
  289. package/node_modules/zod/src/v4/classic/tests/partial.test.ts +0 -340
  290. package/node_modules/zod/src/v4/classic/tests/pickomit.test.ts +0 -127
  291. package/node_modules/zod/src/v4/classic/tests/pipe.test.ts +0 -101
  292. package/node_modules/zod/src/v4/classic/tests/prefault.test.ts +0 -74
  293. package/node_modules/zod/src/v4/classic/tests/preprocess.test.ts +0 -282
  294. package/node_modules/zod/src/v4/classic/tests/primitive.test.ts +0 -175
  295. package/node_modules/zod/src/v4/classic/tests/promise.test.ts +0 -81
  296. package/node_modules/zod/src/v4/classic/tests/prototypes.test.ts +0 -23
  297. package/node_modules/zod/src/v4/classic/tests/readonly.test.ts +0 -252
  298. package/node_modules/zod/src/v4/classic/tests/record.test.ts +0 -356
  299. package/node_modules/zod/src/v4/classic/tests/recursive-types.test.ts +0 -582
  300. package/node_modules/zod/src/v4/classic/tests/refine.test.ts +0 -605
  301. package/node_modules/zod/src/v4/classic/tests/registries.test.ts +0 -204
  302. package/node_modules/zod/src/v4/classic/tests/set.test.ts +0 -181
  303. package/node_modules/zod/src/v4/classic/tests/standard-schema.test.ts +0 -57
  304. package/node_modules/zod/src/v4/classic/tests/string-formats.test.ts +0 -125
  305. package/node_modules/zod/src/v4/classic/tests/string.test.ts +0 -1080
  306. package/node_modules/zod/src/v4/classic/tests/stringbool.test.ts +0 -106
  307. package/node_modules/zod/src/v4/classic/tests/template-literal.test.ts +0 -763
  308. package/node_modules/zod/src/v4/classic/tests/to-json-schema.test.ts +0 -2622
  309. package/node_modules/zod/src/v4/classic/tests/transform.test.ts +0 -361
  310. package/node_modules/zod/src/v4/classic/tests/tuple.test.ts +0 -163
  311. package/node_modules/zod/src/v4/classic/tests/union.test.ts +0 -181
  312. package/node_modules/zod/src/v4/classic/tests/validations.test.ts +0 -283
  313. package/node_modules/zod/src/v4/classic/tests/void.test.ts +0 -12
  314. package/node_modules/zod/src/v4/core/api.ts +0 -1621
  315. package/node_modules/zod/src/v4/core/checks.ts +0 -1287
  316. package/node_modules/zod/src/v4/core/config.ts +0 -15
  317. package/node_modules/zod/src/v4/core/core.ts +0 -115
  318. package/node_modules/zod/src/v4/core/doc.ts +0 -44
  319. package/node_modules/zod/src/v4/core/errors.ts +0 -413
  320. package/node_modules/zod/src/v4/core/index.ts +0 -14
  321. package/node_modules/zod/src/v4/core/json-schema.ts +0 -147
  322. package/node_modules/zod/src/v4/core/parse.ts +0 -195
  323. package/node_modules/zod/src/v4/core/regexes.ts +0 -177
  324. package/node_modules/zod/src/v4/core/registries.ts +0 -97
  325. package/node_modules/zod/src/v4/core/schemas.ts +0 -4317
  326. package/node_modules/zod/src/v4/core/standard-schema.ts +0 -64
  327. package/node_modules/zod/src/v4/core/tests/extend.test.ts +0 -18
  328. package/node_modules/zod/src/v4/core/tests/index.test.ts +0 -46
  329. package/node_modules/zod/src/v4/core/tests/locales/be.test.ts +0 -124
  330. package/node_modules/zod/src/v4/core/tests/locales/en.test.ts +0 -22
  331. package/node_modules/zod/src/v4/core/tests/locales/es.test.ts +0 -181
  332. package/node_modules/zod/src/v4/core/tests/locales/ru.test.ts +0 -128
  333. package/node_modules/zod/src/v4/core/tests/locales/tr.test.ts +0 -69
  334. package/node_modules/zod/src/v4/core/to-json-schema.ts +0 -1044
  335. package/node_modules/zod/src/v4/core/util.ts +0 -910
  336. package/node_modules/zod/src/v4/core/versions.ts +0 -5
  337. package/node_modules/zod/src/v4/core/zsf.ts +0 -323
  338. package/node_modules/zod/src/v4/index.ts +0 -4
  339. package/node_modules/zod/src/v4/locales/ar.ts +0 -125
  340. package/node_modules/zod/src/v4/locales/az.ts +0 -121
  341. package/node_modules/zod/src/v4/locales/be.ts +0 -184
  342. package/node_modules/zod/src/v4/locales/bg.ts +0 -136
  343. package/node_modules/zod/src/v4/locales/ca.ts +0 -127
  344. package/node_modules/zod/src/v4/locales/cs.ts +0 -142
  345. package/node_modules/zod/src/v4/locales/da.ts +0 -141
  346. package/node_modules/zod/src/v4/locales/de.ts +0 -124
  347. package/node_modules/zod/src/v4/locales/en.ts +0 -127
  348. package/node_modules/zod/src/v4/locales/eo.ts +0 -125
  349. package/node_modules/zod/src/v4/locales/es.ts +0 -159
  350. package/node_modules/zod/src/v4/locales/fa.ts +0 -134
  351. package/node_modules/zod/src/v4/locales/fi.ts +0 -131
  352. package/node_modules/zod/src/v4/locales/fr-CA.ts +0 -126
  353. package/node_modules/zod/src/v4/locales/fr.ts +0 -124
  354. package/node_modules/zod/src/v4/locales/he.ts +0 -125
  355. package/node_modules/zod/src/v4/locales/hu.ts +0 -126
  356. package/node_modules/zod/src/v4/locales/id.ts +0 -125
  357. package/node_modules/zod/src/v4/locales/index.ts +0 -47
  358. package/node_modules/zod/src/v4/locales/is.ts +0 -127
  359. package/node_modules/zod/src/v4/locales/it.ts +0 -125
  360. package/node_modules/zod/src/v4/locales/ja.ts +0 -122
  361. package/node_modules/zod/src/v4/locales/ka.ts +0 -138
  362. package/node_modules/zod/src/v4/locales/kh.ts +0 -7
  363. package/node_modules/zod/src/v4/locales/km.ts +0 -126
  364. package/node_modules/zod/src/v4/locales/ko.ts +0 -131
  365. package/node_modules/zod/src/v4/locales/lt.ts +0 -265
  366. package/node_modules/zod/src/v4/locales/mk.ts +0 -127
  367. package/node_modules/zod/src/v4/locales/ms.ts +0 -124
  368. package/node_modules/zod/src/v4/locales/nl.ts +0 -126
  369. package/node_modules/zod/src/v4/locales/no.ts +0 -124
  370. package/node_modules/zod/src/v4/locales/ota.ts +0 -125
  371. package/node_modules/zod/src/v4/locales/pl.ts +0 -126
  372. package/node_modules/zod/src/v4/locales/ps.ts +0 -133
  373. package/node_modules/zod/src/v4/locales/pt.ts +0 -123
  374. package/node_modules/zod/src/v4/locales/ru.ts +0 -184
  375. package/node_modules/zod/src/v4/locales/sl.ts +0 -126
  376. package/node_modules/zod/src/v4/locales/sv.ts +0 -127
  377. package/node_modules/zod/src/v4/locales/ta.ts +0 -125
  378. package/node_modules/zod/src/v4/locales/th.ts +0 -126
  379. package/node_modules/zod/src/v4/locales/tr.ts +0 -121
  380. package/node_modules/zod/src/v4/locales/ua.ts +0 -7
  381. package/node_modules/zod/src/v4/locales/uk.ts +0 -126
  382. package/node_modules/zod/src/v4/locales/ur.ts +0 -126
  383. package/node_modules/zod/src/v4/locales/vi.ts +0 -125
  384. package/node_modules/zod/src/v4/locales/yo.ts +0 -131
  385. package/node_modules/zod/src/v4/locales/zh-CN.ts +0 -123
  386. package/node_modules/zod/src/v4/locales/zh-TW.ts +0 -125
  387. package/node_modules/zod/src/v4/mini/checks.ts +0 -32
  388. package/node_modules/zod/src/v4/mini/coerce.ts +0 -22
  389. package/node_modules/zod/src/v4/mini/external.ts +0 -40
  390. package/node_modules/zod/src/v4/mini/index.ts +0 -3
  391. package/node_modules/zod/src/v4/mini/iso.ts +0 -62
  392. package/node_modules/zod/src/v4/mini/parse.ts +0 -14
  393. package/node_modules/zod/src/v4/mini/schemas.ts +0 -1725
  394. package/node_modules/zod/src/v4/mini/tests/assignability.test.ts +0 -129
  395. package/node_modules/zod/src/v4/mini/tests/brand.test.ts +0 -51
  396. package/node_modules/zod/src/v4/mini/tests/checks.test.ts +0 -144
  397. package/node_modules/zod/src/v4/mini/tests/codec.test.ts +0 -529
  398. package/node_modules/zod/src/v4/mini/tests/computed.test.ts +0 -36
  399. package/node_modules/zod/src/v4/mini/tests/error.test.ts +0 -22
  400. package/node_modules/zod/src/v4/mini/tests/functions.test.ts +0 -43
  401. package/node_modules/zod/src/v4/mini/tests/index.test.ts +0 -899
  402. package/node_modules/zod/src/v4/mini/tests/number.test.ts +0 -95
  403. package/node_modules/zod/src/v4/mini/tests/object.test.ts +0 -200
  404. package/node_modules/zod/src/v4/mini/tests/prototypes.test.ts +0 -43
  405. package/node_modules/zod/src/v4/mini/tests/recursive-types.test.ts +0 -275
  406. package/node_modules/zod/src/v4/mini/tests/string.test.ts +0 -315
  407. package/node_modules/zod/src/v4-mini/index.ts +0 -1
  408. package/node_modules/zod/v3/ZodError.cjs +0 -138
  409. package/node_modules/zod/v3/ZodError.d.cts +0 -164
  410. package/node_modules/zod/v3/ZodError.d.ts +0 -164
  411. package/node_modules/zod/v3/ZodError.js +0 -133
  412. package/node_modules/zod/v3/errors.cjs +0 -17
  413. package/node_modules/zod/v3/errors.d.cts +0 -5
  414. package/node_modules/zod/v3/errors.d.ts +0 -5
  415. package/node_modules/zod/v3/errors.js +0 -9
  416. package/node_modules/zod/v3/external.cjs +0 -22
  417. package/node_modules/zod/v3/external.d.cts +0 -6
  418. package/node_modules/zod/v3/external.d.ts +0 -6
  419. package/node_modules/zod/v3/external.js +0 -6
  420. package/node_modules/zod/v3/helpers/enumUtil.cjs +0 -2
  421. package/node_modules/zod/v3/helpers/enumUtil.d.cts +0 -8
  422. package/node_modules/zod/v3/helpers/enumUtil.d.ts +0 -8
  423. package/node_modules/zod/v3/helpers/enumUtil.js +0 -1
  424. package/node_modules/zod/v3/helpers/errorUtil.cjs +0 -9
  425. package/node_modules/zod/v3/helpers/errorUtil.d.cts +0 -9
  426. package/node_modules/zod/v3/helpers/errorUtil.d.ts +0 -9
  427. package/node_modules/zod/v3/helpers/errorUtil.js +0 -6
  428. package/node_modules/zod/v3/helpers/parseUtil.cjs +0 -124
  429. package/node_modules/zod/v3/helpers/parseUtil.d.cts +0 -78
  430. package/node_modules/zod/v3/helpers/parseUtil.d.ts +0 -78
  431. package/node_modules/zod/v3/helpers/parseUtil.js +0 -109
  432. package/node_modules/zod/v3/helpers/partialUtil.cjs +0 -2
  433. package/node_modules/zod/v3/helpers/partialUtil.d.cts +0 -8
  434. package/node_modules/zod/v3/helpers/partialUtil.d.ts +0 -8
  435. package/node_modules/zod/v3/helpers/partialUtil.js +0 -1
  436. package/node_modules/zod/v3/helpers/typeAliases.cjs +0 -2
  437. package/node_modules/zod/v3/helpers/typeAliases.d.cts +0 -2
  438. package/node_modules/zod/v3/helpers/typeAliases.d.ts +0 -2
  439. package/node_modules/zod/v3/helpers/typeAliases.js +0 -1
  440. package/node_modules/zod/v3/helpers/util.cjs +0 -137
  441. package/node_modules/zod/v3/helpers/util.d.cts +0 -85
  442. package/node_modules/zod/v3/helpers/util.d.ts +0 -85
  443. package/node_modules/zod/v3/helpers/util.js +0 -133
  444. package/node_modules/zod/v3/index.cjs +0 -33
  445. package/node_modules/zod/v3/index.d.cts +0 -4
  446. package/node_modules/zod/v3/index.d.ts +0 -4
  447. package/node_modules/zod/v3/index.js +0 -4
  448. package/node_modules/zod/v3/locales/en.cjs +0 -112
  449. package/node_modules/zod/v3/locales/en.d.cts +0 -3
  450. package/node_modules/zod/v3/locales/en.d.ts +0 -3
  451. package/node_modules/zod/v3/locales/en.js +0 -109
  452. package/node_modules/zod/v3/package.json +0 -6
  453. package/node_modules/zod/v3/standard-schema.cjs +0 -2
  454. package/node_modules/zod/v3/standard-schema.d.cts +0 -102
  455. package/node_modules/zod/v3/standard-schema.d.ts +0 -102
  456. package/node_modules/zod/v3/standard-schema.js +0 -1
  457. package/node_modules/zod/v3/types.cjs +0 -3777
  458. package/node_modules/zod/v3/types.d.cts +0 -1034
  459. package/node_modules/zod/v3/types.d.ts +0 -1034
  460. package/node_modules/zod/v3/types.js +0 -3695
  461. package/node_modules/zod/v4/classic/checks.cjs +0 -32
  462. package/node_modules/zod/v4/classic/checks.d.cts +0 -1
  463. package/node_modules/zod/v4/classic/checks.d.ts +0 -1
  464. package/node_modules/zod/v4/classic/checks.js +0 -1
  465. package/node_modules/zod/v4/classic/coerce.cjs +0 -47
  466. package/node_modules/zod/v4/classic/coerce.d.cts +0 -17
  467. package/node_modules/zod/v4/classic/coerce.d.ts +0 -17
  468. package/node_modules/zod/v4/classic/coerce.js +0 -17
  469. package/node_modules/zod/v4/classic/compat.cjs +0 -61
  470. package/node_modules/zod/v4/classic/compat.d.cts +0 -50
  471. package/node_modules/zod/v4/classic/compat.d.ts +0 -50
  472. package/node_modules/zod/v4/classic/compat.js +0 -31
  473. package/node_modules/zod/v4/classic/errors.cjs +0 -74
  474. package/node_modules/zod/v4/classic/errors.d.cts +0 -30
  475. package/node_modules/zod/v4/classic/errors.d.ts +0 -30
  476. package/node_modules/zod/v4/classic/errors.js +0 -48
  477. package/node_modules/zod/v4/classic/external.cjs +0 -70
  478. package/node_modules/zod/v4/classic/external.d.cts +0 -13
  479. package/node_modules/zod/v4/classic/external.d.ts +0 -13
  480. package/node_modules/zod/v4/classic/external.js +0 -18
  481. package/node_modules/zod/v4/classic/index.cjs +0 -33
  482. package/node_modules/zod/v4/classic/index.d.cts +0 -4
  483. package/node_modules/zod/v4/classic/index.d.ts +0 -4
  484. package/node_modules/zod/v4/classic/index.js +0 -4
  485. package/node_modules/zod/v4/classic/iso.cjs +0 -60
  486. package/node_modules/zod/v4/classic/iso.d.cts +0 -22
  487. package/node_modules/zod/v4/classic/iso.d.ts +0 -22
  488. package/node_modules/zod/v4/classic/iso.js +0 -30
  489. package/node_modules/zod/v4/classic/package.json +0 -6
  490. package/node_modules/zod/v4/classic/parse.cjs +0 -41
  491. package/node_modules/zod/v4/classic/parse.d.cts +0 -31
  492. package/node_modules/zod/v4/classic/parse.d.ts +0 -31
  493. package/node_modules/zod/v4/classic/parse.js +0 -15
  494. package/node_modules/zod/v4/classic/schemas.cjs +0 -1151
  495. package/node_modules/zod/v4/classic/schemas.d.cts +0 -673
  496. package/node_modules/zod/v4/classic/schemas.d.ts +0 -673
  497. package/node_modules/zod/v4/classic/schemas.js +0 -1040
  498. package/node_modules/zod/v4/core/api.cjs +0 -1060
  499. package/node_modules/zod/v4/core/api.d.cts +0 -295
  500. package/node_modules/zod/v4/core/api.d.ts +0 -295
  501. package/node_modules/zod/v4/core/api.js +0 -925
  502. package/node_modules/zod/v4/core/checks.cjs +0 -595
  503. package/node_modules/zod/v4/core/checks.d.cts +0 -278
  504. package/node_modules/zod/v4/core/checks.d.ts +0 -278
  505. package/node_modules/zod/v4/core/checks.js +0 -569
  506. package/node_modules/zod/v4/core/core.cjs +0 -74
  507. package/node_modules/zod/v4/core/core.d.cts +0 -52
  508. package/node_modules/zod/v4/core/core.d.ts +0 -52
  509. package/node_modules/zod/v4/core/core.js +0 -67
  510. package/node_modules/zod/v4/core/doc.cjs +0 -39
  511. package/node_modules/zod/v4/core/doc.d.cts +0 -14
  512. package/node_modules/zod/v4/core/doc.d.ts +0 -14
  513. package/node_modules/zod/v4/core/doc.js +0 -35
  514. package/node_modules/zod/v4/core/errors.cjs +0 -213
  515. package/node_modules/zod/v4/core/errors.d.cts +0 -210
  516. package/node_modules/zod/v4/core/errors.d.ts +0 -210
  517. package/node_modules/zod/v4/core/errors.js +0 -182
  518. package/node_modules/zod/v4/core/index.cjs +0 -43
  519. package/node_modules/zod/v4/core/index.d.cts +0 -14
  520. package/node_modules/zod/v4/core/index.d.ts +0 -14
  521. package/node_modules/zod/v4/core/index.js +0 -14
  522. package/node_modules/zod/v4/core/json-schema.cjs +0 -2
  523. package/node_modules/zod/v4/core/json-schema.d.cts +0 -88
  524. package/node_modules/zod/v4/core/json-schema.d.ts +0 -88
  525. package/node_modules/zod/v4/core/json-schema.js +0 -1
  526. package/node_modules/zod/v4/core/package.json +0 -6
  527. package/node_modules/zod/v4/core/parse.cjs +0 -131
  528. package/node_modules/zod/v4/core/parse.d.cts +0 -49
  529. package/node_modules/zod/v4/core/parse.d.ts +0 -49
  530. package/node_modules/zod/v4/core/parse.js +0 -93
  531. package/node_modules/zod/v4/core/regexes.cjs +0 -136
  532. package/node_modules/zod/v4/core/regexes.d.cts +0 -78
  533. package/node_modules/zod/v4/core/regexes.d.ts +0 -78
  534. package/node_modules/zod/v4/core/regexes.js +0 -127
  535. package/node_modules/zod/v4/core/registries.cjs +0 -57
  536. package/node_modules/zod/v4/core/registries.d.cts +0 -35
  537. package/node_modules/zod/v4/core/registries.d.ts +0 -35
  538. package/node_modules/zod/v4/core/registries.js +0 -52
  539. package/node_modules/zod/v4/core/schemas.cjs +0 -1986
  540. package/node_modules/zod/v4/core/schemas.d.cts +0 -1113
  541. package/node_modules/zod/v4/core/schemas.d.ts +0 -1113
  542. package/node_modules/zod/v4/core/schemas.js +0 -1955
  543. package/node_modules/zod/v4/core/standard-schema.cjs +0 -2
  544. package/node_modules/zod/v4/core/standard-schema.d.cts +0 -55
  545. package/node_modules/zod/v4/core/standard-schema.d.ts +0 -55
  546. package/node_modules/zod/v4/core/standard-schema.js +0 -1
  547. package/node_modules/zod/v4/core/to-json-schema.cjs +0 -920
  548. package/node_modules/zod/v4/core/to-json-schema.d.cts +0 -90
  549. package/node_modules/zod/v4/core/to-json-schema.d.ts +0 -90
  550. package/node_modules/zod/v4/core/to-json-schema.js +0 -915
  551. package/node_modules/zod/v4/core/util.cjs +0 -658
  552. package/node_modules/zod/v4/core/util.d.cts +0 -197
  553. package/node_modules/zod/v4/core/util.d.ts +0 -197
  554. package/node_modules/zod/v4/core/util.js +0 -601
  555. package/node_modules/zod/v4/core/versions.cjs +0 -8
  556. package/node_modules/zod/v4/core/versions.d.cts +0 -5
  557. package/node_modules/zod/v4/core/versions.d.ts +0 -5
  558. package/node_modules/zod/v4/core/versions.js +0 -5
  559. package/node_modules/zod/v4/index.cjs +0 -22
  560. package/node_modules/zod/v4/index.d.cts +0 -3
  561. package/node_modules/zod/v4/index.d.ts +0 -3
  562. package/node_modules/zod/v4/index.js +0 -3
  563. package/node_modules/zod/v4/locales/ar.cjs +0 -143
  564. package/node_modules/zod/v4/locales/ar.d.cts +0 -5
  565. package/node_modules/zod/v4/locales/ar.d.ts +0 -4
  566. package/node_modules/zod/v4/locales/ar.js +0 -116
  567. package/node_modules/zod/v4/locales/az.cjs +0 -142
  568. package/node_modules/zod/v4/locales/az.d.cts +0 -5
  569. package/node_modules/zod/v4/locales/az.d.ts +0 -4
  570. package/node_modules/zod/v4/locales/az.js +0 -115
  571. package/node_modules/zod/v4/locales/be.cjs +0 -191
  572. package/node_modules/zod/v4/locales/be.d.cts +0 -5
  573. package/node_modules/zod/v4/locales/be.d.ts +0 -4
  574. package/node_modules/zod/v4/locales/be.js +0 -164
  575. package/node_modules/zod/v4/locales/bg.cjs +0 -156
  576. package/node_modules/zod/v4/locales/bg.d.cts +0 -5
  577. package/node_modules/zod/v4/locales/bg.d.ts +0 -5
  578. package/node_modules/zod/v4/locales/bg.js +0 -128
  579. package/node_modules/zod/v4/locales/ca.cjs +0 -145
  580. package/node_modules/zod/v4/locales/ca.d.cts +0 -5
  581. package/node_modules/zod/v4/locales/ca.d.ts +0 -4
  582. package/node_modules/zod/v4/locales/ca.js +0 -118
  583. package/node_modules/zod/v4/locales/cs.cjs +0 -162
  584. package/node_modules/zod/v4/locales/cs.d.cts +0 -5
  585. package/node_modules/zod/v4/locales/cs.d.ts +0 -4
  586. package/node_modules/zod/v4/locales/cs.js +0 -135
  587. package/node_modules/zod/v4/locales/da.cjs +0 -158
  588. package/node_modules/zod/v4/locales/da.d.cts +0 -5
  589. package/node_modules/zod/v4/locales/da.d.ts +0 -4
  590. package/node_modules/zod/v4/locales/da.js +0 -131
  591. package/node_modules/zod/v4/locales/de.cjs +0 -143
  592. package/node_modules/zod/v4/locales/de.d.cts +0 -5
  593. package/node_modules/zod/v4/locales/de.d.ts +0 -4
  594. package/node_modules/zod/v4/locales/de.js +0 -116
  595. package/node_modules/zod/v4/locales/en.cjs +0 -145
  596. package/node_modules/zod/v4/locales/en.d.cts +0 -5
  597. package/node_modules/zod/v4/locales/en.d.ts +0 -5
  598. package/node_modules/zod/v4/locales/en.js +0 -117
  599. package/node_modules/zod/v4/locales/eo.cjs +0 -144
  600. package/node_modules/zod/v4/locales/eo.d.cts +0 -5
  601. package/node_modules/zod/v4/locales/eo.d.ts +0 -5
  602. package/node_modules/zod/v4/locales/eo.js +0 -116
  603. package/node_modules/zod/v4/locales/es.cjs +0 -176
  604. package/node_modules/zod/v4/locales/es.d.cts +0 -5
  605. package/node_modules/zod/v4/locales/es.d.ts +0 -4
  606. package/node_modules/zod/v4/locales/es.js +0 -149
  607. package/node_modules/zod/v4/locales/fa.cjs +0 -149
  608. package/node_modules/zod/v4/locales/fa.d.cts +0 -5
  609. package/node_modules/zod/v4/locales/fa.d.ts +0 -4
  610. package/node_modules/zod/v4/locales/fa.js +0 -122
  611. package/node_modules/zod/v4/locales/fi.cjs +0 -149
  612. package/node_modules/zod/v4/locales/fi.d.cts +0 -5
  613. package/node_modules/zod/v4/locales/fi.d.ts +0 -4
  614. package/node_modules/zod/v4/locales/fi.js +0 -122
  615. package/node_modules/zod/v4/locales/fr-CA.cjs +0 -144
  616. package/node_modules/zod/v4/locales/fr-CA.d.cts +0 -5
  617. package/node_modules/zod/v4/locales/fr-CA.d.ts +0 -4
  618. package/node_modules/zod/v4/locales/fr-CA.js +0 -117
  619. package/node_modules/zod/v4/locales/fr.cjs +0 -143
  620. package/node_modules/zod/v4/locales/fr.d.cts +0 -5
  621. package/node_modules/zod/v4/locales/fr.d.ts +0 -4
  622. package/node_modules/zod/v4/locales/fr.js +0 -116
  623. package/node_modules/zod/v4/locales/he.cjs +0 -144
  624. package/node_modules/zod/v4/locales/he.d.cts +0 -5
  625. package/node_modules/zod/v4/locales/he.d.ts +0 -4
  626. package/node_modules/zod/v4/locales/he.js +0 -117
  627. package/node_modules/zod/v4/locales/hu.cjs +0 -144
  628. package/node_modules/zod/v4/locales/hu.d.cts +0 -5
  629. package/node_modules/zod/v4/locales/hu.d.ts +0 -4
  630. package/node_modules/zod/v4/locales/hu.js +0 -117
  631. package/node_modules/zod/v4/locales/id.cjs +0 -143
  632. package/node_modules/zod/v4/locales/id.d.cts +0 -5
  633. package/node_modules/zod/v4/locales/id.d.ts +0 -4
  634. package/node_modules/zod/v4/locales/id.js +0 -116
  635. package/node_modules/zod/v4/locales/index.cjs +0 -100
  636. package/node_modules/zod/v4/locales/index.d.cts +0 -47
  637. package/node_modules/zod/v4/locales/index.d.ts +0 -47
  638. package/node_modules/zod/v4/locales/index.js +0 -47
  639. package/node_modules/zod/v4/locales/is.cjs +0 -145
  640. package/node_modules/zod/v4/locales/is.d.cts +0 -5
  641. package/node_modules/zod/v4/locales/is.d.ts +0 -5
  642. package/node_modules/zod/v4/locales/is.js +0 -117
  643. package/node_modules/zod/v4/locales/it.cjs +0 -144
  644. package/node_modules/zod/v4/locales/it.d.cts +0 -5
  645. package/node_modules/zod/v4/locales/it.d.ts +0 -4
  646. package/node_modules/zod/v4/locales/it.js +0 -117
  647. package/node_modules/zod/v4/locales/ja.cjs +0 -142
  648. package/node_modules/zod/v4/locales/ja.d.cts +0 -5
  649. package/node_modules/zod/v4/locales/ja.d.ts +0 -4
  650. package/node_modules/zod/v4/locales/ja.js +0 -115
  651. package/node_modules/zod/v4/locales/ka.cjs +0 -153
  652. package/node_modules/zod/v4/locales/ka.d.cts +0 -5
  653. package/node_modules/zod/v4/locales/ka.d.ts +0 -5
  654. package/node_modules/zod/v4/locales/ka.js +0 -125
  655. package/node_modules/zod/v4/locales/kh.cjs +0 -12
  656. package/node_modules/zod/v4/locales/kh.d.cts +0 -5
  657. package/node_modules/zod/v4/locales/kh.d.ts +0 -5
  658. package/node_modules/zod/v4/locales/kh.js +0 -5
  659. package/node_modules/zod/v4/locales/km.cjs +0 -144
  660. package/node_modules/zod/v4/locales/km.d.cts +0 -5
  661. package/node_modules/zod/v4/locales/km.d.ts +0 -4
  662. package/node_modules/zod/v4/locales/km.js +0 -117
  663. package/node_modules/zod/v4/locales/ko.cjs +0 -148
  664. package/node_modules/zod/v4/locales/ko.d.cts +0 -5
  665. package/node_modules/zod/v4/locales/ko.d.ts +0 -4
  666. package/node_modules/zod/v4/locales/ko.js +0 -121
  667. package/node_modules/zod/v4/locales/lt.cjs +0 -258
  668. package/node_modules/zod/v4/locales/lt.d.cts +0 -5
  669. package/node_modules/zod/v4/locales/lt.d.ts +0 -5
  670. package/node_modules/zod/v4/locales/lt.js +0 -230
  671. package/node_modules/zod/v4/locales/mk.cjs +0 -145
  672. package/node_modules/zod/v4/locales/mk.d.cts +0 -5
  673. package/node_modules/zod/v4/locales/mk.d.ts +0 -4
  674. package/node_modules/zod/v4/locales/mk.js +0 -118
  675. package/node_modules/zod/v4/locales/ms.cjs +0 -143
  676. package/node_modules/zod/v4/locales/ms.d.cts +0 -5
  677. package/node_modules/zod/v4/locales/ms.d.ts +0 -4
  678. package/node_modules/zod/v4/locales/ms.js +0 -116
  679. package/node_modules/zod/v4/locales/nl.cjs +0 -144
  680. package/node_modules/zod/v4/locales/nl.d.cts +0 -5
  681. package/node_modules/zod/v4/locales/nl.d.ts +0 -4
  682. package/node_modules/zod/v4/locales/nl.js +0 -117
  683. package/node_modules/zod/v4/locales/no.cjs +0 -143
  684. package/node_modules/zod/v4/locales/no.d.cts +0 -5
  685. package/node_modules/zod/v4/locales/no.d.ts +0 -4
  686. package/node_modules/zod/v4/locales/no.js +0 -116
  687. package/node_modules/zod/v4/locales/ota.cjs +0 -144
  688. package/node_modules/zod/v4/locales/ota.d.cts +0 -5
  689. package/node_modules/zod/v4/locales/ota.d.ts +0 -4
  690. package/node_modules/zod/v4/locales/ota.js +0 -117
  691. package/node_modules/zod/v4/locales/package.json +0 -6
  692. package/node_modules/zod/v4/locales/pl.cjs +0 -144
  693. package/node_modules/zod/v4/locales/pl.d.cts +0 -5
  694. package/node_modules/zod/v4/locales/pl.d.ts +0 -4
  695. package/node_modules/zod/v4/locales/pl.js +0 -117
  696. package/node_modules/zod/v4/locales/ps.cjs +0 -149
  697. package/node_modules/zod/v4/locales/ps.d.cts +0 -5
  698. package/node_modules/zod/v4/locales/ps.d.ts +0 -4
  699. package/node_modules/zod/v4/locales/ps.js +0 -122
  700. package/node_modules/zod/v4/locales/pt.cjs +0 -143
  701. package/node_modules/zod/v4/locales/pt.d.cts +0 -5
  702. package/node_modules/zod/v4/locales/pt.d.ts +0 -4
  703. package/node_modules/zod/v4/locales/pt.js +0 -116
  704. package/node_modules/zod/v4/locales/ru.cjs +0 -191
  705. package/node_modules/zod/v4/locales/ru.d.cts +0 -5
  706. package/node_modules/zod/v4/locales/ru.d.ts +0 -4
  707. package/node_modules/zod/v4/locales/ru.js +0 -164
  708. package/node_modules/zod/v4/locales/sl.cjs +0 -144
  709. package/node_modules/zod/v4/locales/sl.d.cts +0 -5
  710. package/node_modules/zod/v4/locales/sl.d.ts +0 -4
  711. package/node_modules/zod/v4/locales/sl.js +0 -117
  712. package/node_modules/zod/v4/locales/sv.cjs +0 -145
  713. package/node_modules/zod/v4/locales/sv.d.cts +0 -5
  714. package/node_modules/zod/v4/locales/sv.d.ts +0 -4
  715. package/node_modules/zod/v4/locales/sv.js +0 -118
  716. package/node_modules/zod/v4/locales/ta.cjs +0 -144
  717. package/node_modules/zod/v4/locales/ta.d.cts +0 -5
  718. package/node_modules/zod/v4/locales/ta.d.ts +0 -4
  719. package/node_modules/zod/v4/locales/ta.js +0 -117
  720. package/node_modules/zod/v4/locales/th.cjs +0 -144
  721. package/node_modules/zod/v4/locales/th.d.cts +0 -5
  722. package/node_modules/zod/v4/locales/th.d.ts +0 -4
  723. package/node_modules/zod/v4/locales/th.js +0 -117
  724. package/node_modules/zod/v4/locales/tr.cjs +0 -143
  725. package/node_modules/zod/v4/locales/tr.d.cts +0 -5
  726. package/node_modules/zod/v4/locales/tr.d.ts +0 -5
  727. package/node_modules/zod/v4/locales/tr.js +0 -115
  728. package/node_modules/zod/v4/locales/ua.cjs +0 -12
  729. package/node_modules/zod/v4/locales/ua.d.cts +0 -5
  730. package/node_modules/zod/v4/locales/ua.d.ts +0 -5
  731. package/node_modules/zod/v4/locales/ua.js +0 -5
  732. package/node_modules/zod/v4/locales/uk.cjs +0 -144
  733. package/node_modules/zod/v4/locales/uk.d.cts +0 -5
  734. package/node_modules/zod/v4/locales/uk.d.ts +0 -4
  735. package/node_modules/zod/v4/locales/uk.js +0 -117
  736. package/node_modules/zod/v4/locales/ur.cjs +0 -144
  737. package/node_modules/zod/v4/locales/ur.d.cts +0 -5
  738. package/node_modules/zod/v4/locales/ur.d.ts +0 -4
  739. package/node_modules/zod/v4/locales/ur.js +0 -117
  740. package/node_modules/zod/v4/locales/vi.cjs +0 -143
  741. package/node_modules/zod/v4/locales/vi.d.cts +0 -5
  742. package/node_modules/zod/v4/locales/vi.d.ts +0 -4
  743. package/node_modules/zod/v4/locales/vi.js +0 -116
  744. package/node_modules/zod/v4/locales/yo.cjs +0 -142
  745. package/node_modules/zod/v4/locales/yo.d.cts +0 -5
  746. package/node_modules/zod/v4/locales/yo.d.ts +0 -4
  747. package/node_modules/zod/v4/locales/yo.js +0 -115
  748. package/node_modules/zod/v4/locales/zh-CN.cjs +0 -143
  749. package/node_modules/zod/v4/locales/zh-CN.d.cts +0 -5
  750. package/node_modules/zod/v4/locales/zh-CN.d.ts +0 -4
  751. package/node_modules/zod/v4/locales/zh-CN.js +0 -116
  752. package/node_modules/zod/v4/locales/zh-TW.cjs +0 -144
  753. package/node_modules/zod/v4/locales/zh-TW.d.cts +0 -5
  754. package/node_modules/zod/v4/locales/zh-TW.d.ts +0 -4
  755. package/node_modules/zod/v4/locales/zh-TW.js +0 -117
  756. package/node_modules/zod/v4/mini/checks.cjs +0 -34
  757. package/node_modules/zod/v4/mini/checks.d.cts +0 -1
  758. package/node_modules/zod/v4/mini/checks.d.ts +0 -1
  759. package/node_modules/zod/v4/mini/checks.js +0 -1
  760. package/node_modules/zod/v4/mini/coerce.cjs +0 -47
  761. package/node_modules/zod/v4/mini/coerce.d.cts +0 -7
  762. package/node_modules/zod/v4/mini/coerce.d.ts +0 -7
  763. package/node_modules/zod/v4/mini/coerce.js +0 -17
  764. package/node_modules/zod/v4/mini/external.cjs +0 -62
  765. package/node_modules/zod/v4/mini/external.d.cts +0 -11
  766. package/node_modules/zod/v4/mini/external.d.ts +0 -11
  767. package/node_modules/zod/v4/mini/external.js +0 -13
  768. package/node_modules/zod/v4/mini/index.cjs +0 -32
  769. package/node_modules/zod/v4/mini/index.d.cts +0 -3
  770. package/node_modules/zod/v4/mini/index.d.ts +0 -3
  771. package/node_modules/zod/v4/mini/index.js +0 -3
  772. package/node_modules/zod/v4/mini/iso.cjs +0 -60
  773. package/node_modules/zod/v4/mini/iso.d.cts +0 -22
  774. package/node_modules/zod/v4/mini/iso.d.ts +0 -22
  775. package/node_modules/zod/v4/mini/iso.js +0 -30
  776. package/node_modules/zod/v4/mini/package.json +0 -6
  777. package/node_modules/zod/v4/mini/parse.cjs +0 -16
  778. package/node_modules/zod/v4/mini/parse.d.cts +0 -1
  779. package/node_modules/zod/v4/mini/parse.d.ts +0 -1
  780. package/node_modules/zod/v4/mini/parse.js +0 -1
  781. package/node_modules/zod/v4/mini/schemas.cjs +0 -892
  782. package/node_modules/zod/v4/mini/schemas.d.cts +0 -407
  783. package/node_modules/zod/v4/mini/schemas.d.ts +0 -407
  784. package/node_modules/zod/v4/mini/schemas.js +0 -775
  785. package/node_modules/zod/v4/package.json +0 -6
  786. package/node_modules/zod/v4-mini/index.cjs +0 -17
  787. package/node_modules/zod/v4-mini/index.d.cts +0 -1
  788. package/node_modules/zod/v4-mini/index.d.ts +0 -1
  789. package/node_modules/zod/v4-mini/index.js +0 -1
  790. package/node_modules/zod/v4-mini/package.json +0 -6
  791. package/package/cc-switch-sdk/README.md +0 -541
  792. package/package/cc-switch-sdk/dist/constants.d.ts +0 -8
  793. package/package/cc-switch-sdk/dist/constants.js +0 -2
  794. package/package/cc-switch-sdk/dist/errors.d.ts +0 -5
  795. package/package/cc-switch-sdk/dist/errors.js +0 -2
  796. package/package/cc-switch-sdk/dist/index.d.ts +0 -5
  797. package/package/cc-switch-sdk/dist/index.js +0 -2
  798. package/package/cc-switch-sdk/dist/schemas.d.ts +0 -7
  799. package/package/cc-switch-sdk/dist/schemas.js +0 -2
  800. package/package/cc-switch-sdk/dist/sdk.d.ts +0 -59
  801. package/package/cc-switch-sdk/dist/sdk.js +0 -2
  802. package/package/cc-switch-sdk/dist/services/ai-config-service.js +0 -4
  803. package/package/cc-switch-sdk/dist/services/mcp-model.d.ts +0 -16
  804. package/package/cc-switch-sdk/dist/services/mcp-model.js +0 -2
  805. package/package/cc-switch-sdk/dist/services/mcp-service.d.ts +0 -17
  806. package/package/cc-switch-sdk/dist/services/mcp-service.js +0 -2
  807. package/package/cc-switch-sdk/dist/services/skill-model.d.ts +0 -16
  808. package/package/cc-switch-sdk/dist/services/skill-model.js +0 -2
  809. package/package/cc-switch-sdk/dist/services/skill-service.d.ts +0 -16
  810. package/package/cc-switch-sdk/dist/services/skill-service.js +0 -2
  811. package/package/cc-switch-sdk/dist/state.d.ts +0 -3
  812. package/package/cc-switch-sdk/dist/state.js +0 -2
  813. package/package/cc-switch-sdk/dist/types.d.ts +0 -78
  814. package/package/cc-switch-sdk/dist/types.js +0 -1
  815. package/package/cc-switch-sdk/dist/utils/fs.d.ts +0 -10
  816. package/package/cc-switch-sdk/dist/utils/fs.js +0 -3
  817. package/package/cc-switch-sdk/dist/utils/id.d.ts +0 -3
  818. package/package/cc-switch-sdk/dist/utils/id.js +0 -2
  819. package/package/cc-switch-sdk/package.json +0 -31
  820. /package/{node_modules/@cc-switch/sdk/dist/types.js → package/acode/dist/plugin-types.js} +0 -0
@@ -0,0 +1,10 @@
1
+ import{spawn as C}from"node:child_process";import{cpSync as F,existsSync as S,lstatSync as X,mkdirSync as L,readFileSync as E,readdirSync as H,renameSync as V,rmSync as v,symlinkSync as Q,writeFileSync as B}from"node:fs";import{dirname as Z,join as g,resolve as R,sep as ee}from"node:path";import{pathToFileURL as te}from"node:url";import{parseAcodeCommandMarkdown as ne}from"@agentswork/acode";import{getAcodePluginDataHome as K}from"../config.js";import{createLogger as re}from"../utils/logger.js";import{sanitizeAgentId as M,withFileLock as W}from"../utils/file-utils.js";import{isCapabilityEnabled as se,getAgentPluginSources as ie}from"./instance-features.js";import{setDeployedDefaultsProvider as oe,reconcileDefaultsFromDeployed as ae}from"./capability-config.js";import{downloadPluginZip as le,sanitizeArchiveFileName as ue}from"../utils/file-utils.js";import{PluginEventBuffer as ce}from"./plugin-event-buffer.js";import{extractPluginZip as j}from"./plugin-package.js";const d=re("plugin-manager"),de=200,_=256*1024,fe=4*1024,ge=6e4,J=6e4,pe=/^[a-zA-Z0-9_][a-zA-Z0-9_-]*$/,I=/^[a-z0-9][a-z0-9-]*$/,he=["system.","aws-","acode-"],me=new Set(["NODE_OPTIONS","NODE_PATH","NODE_EXTRA_CA_CERTS","NODE_REPL_HISTORY","LD_PRELOAD","LD_LIBRARY_PATH","LD_AUDIT","DYLD_INSERT_LIBRARIES","DYLD_LIBRARY_PATH","DYLD_FRAMEWORK_PATH","PYTHONPATH","PYTHONSTARTUP","PYTHONHOME","PERL5LIB","PERL5OPT","RUBYOPT","RUBYLIB","BASH_ENV","ENV","SHELLOPTS","BASHOPTS","IFS","PS1","PS4","GIT_SSH","GIT_SSH_COMMAND","GIT_CONFIG","GIT_CONFIG_GLOBAL","PATH","HOME","USERPROFILE","SYSTEMROOT","COMSPEC","TEMP","TMP","LANG","TZ"]),ye=/^[A-Za-z_][A-Za-z0-9_]*$/,Se=process.platform==="win32"?"junction":"dir",we=/[^\x20-\x7E]/,$e=6e4,x=20,Pe=80;function P(l){return typeof l=="object"&&l!==null&&!Array.isArray(l)}function O(l,e){let t=l;for(const n of e.split(".")){if(!P(t))return;t=t[n]}return t}function A(l,e){return l.length<=e?l:`${l.slice(0,e)}\u2026(\u622A\u65AD,\u5171 ${l.length} \u5B57\u7B26)`}async function b(l,e=8,t=200){for(let n=0;;n++)try{v(l,{recursive:!0,force:!0});return}catch(r){if(n>=e-1)throw r;await new Promise(s=>setTimeout(s,t))}}function k(l,e){l.logs.push(`${new Date().toISOString()} ${e}`),l.logs.length>de&&l.logs.shift()}function q(l,e,t="params"){if(!P(l))return[];const n=[],r=l.type;if(typeof r=="string"&&!ve(r,e))return[`${t}: \u671F\u671B ${r}\uFF0C\u5B9E\u9645 ${De(e)}`];if(Array.isArray(l.enum)&&l.enum.length>0&&(l.enum.some(o=>JSON.stringify(o)===JSON.stringify(e))||n.push(`${t}: \u503C ${JSON.stringify(e)} \u4E0D\u5728\u679A\u4E3E ${JSON.stringify(l.enum)} \u5185`)),r==="object"&&P(e)){const s=P(l.properties)?l.properties:{},o=Array.isArray(l.required)?l.required:[];for(const i of o)(!(i in e)||e[i]===void 0)&&n.push(`${t}.${i}: \u5FC5\u586B\u53C2\u6570\u7F3A\u5931`);for(const[i,a]of Object.entries(s))i in e&&e[i]!==void 0&&n.push(...q(a,e[i],`${t}.${i}`));if(l.additionalProperties===!1)for(const i of Object.keys(e))i in s||n.push(`${t}.${i}: \u4E0D\u5141\u8BB8\u7684\u672A\u77E5\u53C2\u6570\uFF08schema additionalProperties=false\uFF09`)}return r==="array"&&Array.isArray(e)&&P(l.items)&&e.forEach((s,o)=>{n.push(...q(l.items,s,`${t}[${o}]`))}),n}function ve(l,e){switch(l){case"string":return typeof e=="string";case"number":return typeof e=="number"&&Number.isFinite(e);case"boolean":return typeof e=="boolean";case"object":return P(e);case"array":return Array.isArray(e);case"null":return e===null;default:return!0}}function De(l){return l===null?"null":Array.isArray(l)?"array":typeof l}class Ee{constructor(e={}){this.agents=new Map,this.templatePullInFlight=new Set,this.backgroundTemplatePulls=new Set,this.rootDir=e.rootDir??g(K(),"plugins"),this.runtimeRootDir=e.runtimeRootDir??g(K(),"plugins-runtime")}forAgent(e){return{listPlugins:()=>this.list(e),getCatalog:()=>this.getCatalog(e),getToolSchema:t=>this.getToolSchema(e,t),invokeTool:(t,n,r,s)=>this.invokeTool(e,t,n,r,s),manage:t=>this.manage(e,t),getCommandDirs:()=>this.getCommandDirs(e)}}setOnPluginsChanged(e){this.onPluginsChanged=e}notifyPluginsChanged(e){try{this.onPluginsChanged?.(e)}catch(t){d.warn("[agent:%s] onPluginsChanged \u56DE\u8C03\u5931\u8D25: %s",e,t instanceof Error?t.message:String(t))}}async getCommandDirs(e){return[...(await this.hydrate(e)).plugins.values()].filter(n=>n.enabled&&n.commandDir).map(n=>n.commandDir)}async getPluginCommands(e){const t=await this.hydrate(e),n=[];for(const r of t.plugins.values())!r.enabled||!r.commandDir||n.push(...this.parsePluginCommandDir(r));return n}parsePluginCommandDir(e){const t=[];try{for(const n of H(e.commandDir)){if(!n.endsWith(".md"))continue;const r=g(e.commandDir,n);try{t.push(ne(r,E(r,"utf8")))}catch(s){d.warn("[plugin:%s] \u547D\u4EE4\u89E3\u6790\u5931\u8D25 %s: %s",e.name,n,s instanceof Error?s.message:String(s))}}}catch{}return t}async list(e){const t=await this.hydrate(e),n=new Map;for(const r of t.plugins.values()){const s=this.toSummary(r);n.set(s.name,s)}for(const r of this.readSharedManifest()){const s=r.pluginName;if(!this.deployedPluginHealthy(s))continue;const i=n.get(s);if(i){String(i.source||"").startsWith("shared:")&&(i.enabled=this.effectiveSharedEnabled(e,r));continue}n.set(s,{name:s,version:this.deployedPluginVersion(s),status:"enabled",enabled:this.effectiveSharedEnabled(e,r),source:`shared:${r.fileName??`${s}.zip`}`,installedAt:new Date().toISOString(),toolCount:0,listeners:[]})}return[...n.values()].sort((r,s)=>r.name.localeCompare(s.name))}deployedPluginVersion(e){try{const t=JSON.parse(E(g(this.deployedPluginDir(e),"plugin.json"),"utf8"));return typeof t.version=="string"?t.version:void 0}catch{return}}async getCatalog(e){const t=await this.hydrate(e),n=[];for(const r of t.plugins.values()){if(!r.enabled||r.status==="error")continue;const s=r.tools.slice(0,x).map(o=>({name:o.name,description:A(o.title||o.description,Pe),requiredParams:this.requiredParamsOf(o)}));r.tools.length>x&&s.push({name:`(\u53E6\u6709 ${r.tools.length-x} \u4E2A\u5DE5\u5177\u672A\u5217\u51FA)`,description:'\u7528 function_call {action:"catalog"} \u67E5\u770B\u5168\u91CF',requiredParams:void 0}),n.push({plugin:r.name,version:r.version,description:r.description,status:r.status,tools:s})}return{revision:t.buffer.currentRevision,plugins:n}}async getToolSchema(e,t){const n=ke(t);if(!n)return null;const s=(await this.hydrate(e)).plugins.get(n.plugin);if(!s||!s.enabled)return null;const o=s.tools.find(i=>i.name===n.tool);return o?{plugin:s.name,name:o.name,title:o.title,description:o.description,inputSchema:o.inputSchema??{type:"object",properties:{}}}:null}async invokeTool(e,t,n,r,s){const o=await this.hydrate(e),i=o.plugins.get(t);if(!i)return{ok:!1,error:`\u63D2\u4EF6 ${t} \u672A\u5B89\u88C5\uFF08\u53EF\u7528\u63D2\u4EF6: ${[...o.plugins.keys()].join(", ")||"\u65E0"}\uFF09`};if(!i.enabled)return{ok:!1,error:`\u63D2\u4EF6 ${t} \u5DF2\u505C\u7528\uFF0C\u53EF\u8BA9\u7528\u6237\u5728\u9762\u677F\u6216\u7528 plugin_manage enable \u542F\u7528`};const a=i.tools.find(u=>u.name===n);if(!a)return{ok:!1,error:`\u63D2\u4EF6 ${t} \u65E0\u5DE5\u5177 ${n}\uFF08\u53EF\u7528: ${i.tools.map(u=>u.name).join(", ")||"\u65E0"}\uFF09`};if(a.inputSchema){const u=q(a.inputSchema,r);if(u.length>0)return{ok:!1,error:`\u53C2\u6570\u6821\u9A8C\u5931\u8D25: ${u.join("; ")}`,inputSchema:a.inputSchema}}return this.executeHandler(e,i,a,r,s)}async executeHandler(e,t,n,r,s){const o=Date.now(),i=n.handler??{type:"process"};try{return i.type==="mcp"?{ok:!1,error:"handler.type=mcp \u5C06\u5728\u540E\u7EED\u7248\u672C\u652F\u6301\uFF0C\u8BF7\u6539\u7528 process/module handler"}:i.type==="module"?{ok:!0,result:await this.invokeModuleHandler(t,i,r,e,s),durationMs:Date.now()-o}:!i.command||!i.command.trim()?{ok:!1,error:`\u5DE5\u5177 ${n.name} \u7684 process handler \u7F3A\u5C11 command`}:{ok:!0,result:await this.invokeProcessHandler(t,i,r,e,s),durationMs:Date.now()-o}}catch(a){return{ok:!1,error:a instanceof Error?a.message:String(a),durationMs:Date.now()-o}}}async invokeProcessHandler(e,t,n,r,s){const o=U(t.command??"",{params:n});if(o.length===0)throw new Error("process handler command \u4E3A\u7A7A");const i=typeof t.timeoutMs=="number"&&t.timeoutMs>0?t.timeoutMs:ge,a=new AbortController,u=()=>a.abort();s?.signal?.addEventListener("abort",u,{once:!0});const c=setTimeout(()=>a.abort(),i);try{return await new Promise((f,y)=>{d.info("[plugin:%s] spawn: %s",e.name,o.join(" "));const m=C(o[0],o.slice(1),{cwd:e.dir,env:this.buildPluginEnv(e,r),shell:t.shell===!0,windowsHide:!0,signal:a.signal});let p="",w="";m.stdin?.on("error",()=>{}),m.stdout?.on("data",$=>{p.length<_&&(p+=$.toString("utf8"))}),m.stderr?.on("data",$=>{w.length<_&&(w+=$.toString("utf8"))}),m.on("error",$=>{y(new Error(`\u63D2\u4EF6\u8FDB\u7A0B\u542F\u52A8\u5931\u8D25: ${$.message}`))}),m.on("close",$=>{const D=p.trim();if($!==0){const N=A(w.trim()||D||"(\u65E0\u8F93\u51FA)",600);y(new Error(a.signal.aborted?`\u63D2\u4EF6\u8FDB\u7A0B\u8D85\u65F6(${i}ms)\u6216\u88AB\u4E2D\u6B62`:`\u63D2\u4EF6\u8FDB\u7A0B\u9000\u51FA\u7801 ${$}: ${N}`));return}if(!D){f({ok:!0});return}try{f(JSON.parse(D))}catch{f(D)}});try{t.stdin==="params"?m.stdin?.end(`${JSON.stringify(n)}
2
+ `):m.stdin?.end()}catch{}})}finally{clearTimeout(c),s?.signal?.removeEventListener("abort",u)}}async invokeModuleHandler(e,t,n,r,s){if(!t.module)throw new Error("module handler \u7F3A\u5C11 module \u8DEF\u5F84");const o=g(e.dir,t.module);let i=e.moduleCache.get(o);i||(i=await import(te(o).href),e.moduleCache.set(o,i));const a=t.export||"default",c=i[a];if(typeof c!="function")throw new Error(`\u6A21\u5757 ${t.module} \u672A\u5BFC\u51FA\u51FD\u6570 ${a}`);return await c(n,{agentId:r,signal:s?.signal,pluginRoot:e.dir})}buildPluginEnv(e,t){const n={};for(const s of["PATH","HOME","USERPROFILE","SystemRoot","COMSPEC","TEMP","TMP","LANG","TZ"]){const o=process.env[s];o!==void 0&&(n[s]=o)}n.ACODE_PLUGIN_ROOT=e.dir,n.ACODE_AGENT_ID=t,n.ACODE_PLUGIN_NAME=e.name;const r=new Set((e.userConfig??[]).map(s=>s.key));for(const[s,o]of Object.entries(e.configValues))r.has(s)&&(!ye.test(s)||me.has(s.toUpperCase())||(n[s]=o));return n}async manage(e,t){const n=this.agentState(e),r=n.queue.then(async()=>{const s=await this.hydrate(e);return this.doManage(s,t)});return n.queue=r.catch(()=>{}),r}async doManage(e,t){switch(t.action){case"list":return{ok:!0,plugins:[...e.plugins.values()].map(n=>this.toSummary(n))};case"install":return this.installPlugin(e,t);case"uninstall":return this.uninstallPlugin(e,t);case"reload":return this.reloadPlugin(e,t);case"enable":case"disable":return this.setEnabled(e,t,t.action==="enable");default:return{ok:!1,error:`\u672A\u77E5 action: ${String(t.action)}`}}}async installPlugin(e,t){const n=(t.source??"").trim();if(!n)return{ok:!1,error:"install \u9700\u8981 source\uFF08\u5F53\u524D\u652F\u6301 local:<\u63D2\u4EF6\u76EE\u5F55\u7EDD\u5BF9\u8DEF\u5F84>\uFF09"};const r=n.split(":",1)[0];if(r!=="local")return{ok:!1,error:`\u6682\u4E0D\u652F\u6301\u63D2\u4EF6\u6765\u6E90 "${r}:"\uFF08npm:/git: \u5728\u8DEF\u7EBF\u56FE\u4E2D\uFF1Bzip \u5305\u8BF7\u7528\u9762\u677F\u5BFC\u5165\u6216 POST /runtime/plugins/:agentId/upload\uFF09`};const s=n.slice(6).trim();if(!s||!S(g(s,"plugin.json")))return{ok:!1,error:`\u63D2\u4EF6\u76EE\u5F55\u4E0D\u5B58\u5728\u6216\u7F3A\u5C11 plugin.json: ${s}`};const o=R(this.rootDir),i=R(s);return i!==o&&!i.startsWith(o+ee)?{ok:!1,error:`local \u6765\u6E90\u5FC5\u987B\u5728\u63D2\u4EF6\u76EE\u5F55\uFF08${this.rootDir}\uFF09\u5185\u52A0\u8F7D\uFF0C\u4E0D\u5141\u8BB8\u4EFB\u610F\u8DEF\u5F84: ${s}`}:this.installFromDirectory(e,s,n,t.config)}async installFromZip(e,t,n,r){if(!t||t.length===0)return{ok:!1,error:"zip \u5305\u5185\u5BB9\u4E3A\u7A7A"};const s=await this.hydrate(e),o=s.queue.then(async()=>{const i=g(this.rootDir,"tmp",`upload-${Date.now()}-${Math.random().toString(36).slice(2,8)}`);try{const a=await j(t,i);return S(g(a.pluginDir,"plugin.json"))?(d.info("[agent:%s] zip \u5BFC\u5165: %s\uFF08%d \u4E2A\u6587\u4EF6\uFF09",e,n,a.fileCount),await this.installFromDirectory(s,a.pluginDir,`upload:${n}`,r)):{ok:!1,error:"zip \u5185\u672A\u627E\u5230 plugin.json\uFF08\u8BF7\u6253\u5305\u63D2\u4EF6\u76EE\u5F55\uFF0C\u4E14 zip \u5185\u8DEF\u5F84\u4F7F\u7528\u82F1\u6587\uFF09"}}catch(a){const u=a instanceof Error?a.message:String(a);return d.warn("[agent:%s] zip \u5BFC\u5165\u5931\u8D25: %s",e,u),{ok:!1,error:`zip \u5BFC\u5165\u5931\u8D25: ${u}`}}finally{await b(i,3,100).catch(()=>{})}});return s.queue=o.catch(()=>{}),o}async installFromDirectory(e,t,n,r){const s=this.loadManifestOnly(t);if(!s.ok)return s;const o=s.manifest.name,i=g(this.rootDir,"cache",M(e.agentId),o),a=e.plugins.get(o);a&&this.stopAllListeners(a);try{await b(i),L(Z(i),{recursive:!0}),F(t,i,{recursive:!0,filter:f=>!/[\\/]\.git([\\/]|$)/.test(f)&&!/[\\/]node_modules([\\/]|$)/.test(f)})}catch(f){const y=f instanceof Error?f.message:String(f);return d.warn("[agent:%s] \u63D2\u4EF6\u7269\u5316\u5931\u8D25\uFF08%s\uFF09: %s",e.agentId,n,y),a&&this.startAllListeners(e,a),{ok:!1,error:`\u63D2\u4EF6\u7269\u5316\u5931\u8D25: ${y}`}}const u=this.loadPluginFromDir(e,i,n,new Date().toISOString(),r??{});if(!u.ok)return d.warn("[agent:%s] \u63D2\u4EF6\u88C5\u8F7D\u5931\u8D25\uFF08%s\uFF09: %s",e.agentId,n,u.error),await b(i),u;const c=u.plugin;return e.plugins.set(c.name,c),this.persistInstalled(e),this.startAllListeners(e,c),d.info("[agent:%s] \u63D2\u4EF6\u5DF2\u5B89\u88C5: %s@%s",e.agentId,c.name,c.version??"?"),this.notifyPluginsChanged(e.agentId),{ok:!0,summary:this.toSummary(c)}}async uninstallPlugin(e,t){const n=(t.name??"").trim(),r=e.plugins.get(n);return r?(this.stopAllListeners(r),e.plugins.delete(n),this.readSharedManifest().some(o=>o.pluginName===n)&&this.removeRuntimeLink(e.agentId,n),this.persistInstalled(e),await b(r.dir),d.info("[agent:%s] \u63D2\u4EF6\u5DF2\u5378\u8F7D: %s",e.agentId,n),this.notifyPluginsChanged(e.agentId),{ok:!0}):{ok:!1,error:`\u63D2\u4EF6 ${n} \u672A\u5B89\u88C5`}}async reloadPlugin(e,t){const n=(t.name??"").trim(),r=e.plugins.get(n);if(!r)return{ok:!1,error:`\u63D2\u4EF6 ${n} \u672A\u5B89\u88C5`};const s=this.loadPluginFromDir(e,r.dir,r.source,r.installedAt,r.configValues);if(!s.ok)return{ok:!1,error:`\u91CD\u8F7D\u5931\u8D25\uFF08\u4FDD\u7559\u65E7\u7248\u672C\u8FD0\u884C\uFF09: ${s.error}`};const o=s.plugin;return this.stopAllListeners(r),e.plugins.set(n,o),this.persistInstalled(e),this.startAllListeners(e,o),d.info("[agent:%s] \u63D2\u4EF6\u5DF2\u91CD\u8F7D: %s",e.agentId,n),this.notifyPluginsChanged(e.agentId),{ok:!0,summary:this.toSummary(o)}}async setEnabled(e,t,n){const r=(t.name??"").trim(),s=e.plugins.get(r);return s?(s.enabled=n,n?this.startAllListeners(e,s):this.stopAllListeners(s),this.persistInstalled(e),this.notifyPluginsChanged(e.agentId),{ok:!0,summary:this.toSummary(s)}):{ok:!1,error:`\u63D2\u4EF6 ${r} \u672A\u5B89\u88C5`}}deployedDir(){return g(this.rootDir,"deployed")}deployedManifestFile(){return g(this.deployedDir(),"manifest.json")}deployedPluginDir(e){if(!z(e))throw new Error(`\u975E\u6CD5\u63D2\u4EF6\u540D\uFF08\u4EC5\u5141\u8BB8 ${I}\uFF09: ${JSON.stringify(e)}`);const t=g(this.deployedDir(),e),n=R(this.deployedDir());if(R(t)!==g(n,e))throw new Error(`\u63D2\u4EF6\u76EE\u5F55\u8D8A\u51FA\u90E8\u7F72\u533A: ${e}`);return t}legacySharedDir(){return g(this.rootDir,"shared")}readSharedManifest(){try{const e=JSON.parse(E(this.deployedManifestFile(),"utf8"));return Array.isArray(e.plugins)?e.plugins.filter(t=>t&&z(t.pluginName)):[]}catch{return[]}}writeSharedManifest(e){L(this.deployedDir(),{recursive:!0}),B(this.deployedManifestFile(),`${JSON.stringify({version:2,plugins:e},null,2)}
3
+ `,"utf8")}async migrateLegacySharedIfNeeded(){try{if(S(this.deployedManifestFile()))return;const e=g(this.legacySharedDir(),"manifest.json");if(!S(e))return;const t=JSON.parse(E(e,"utf8")),n=Array.isArray(t.plugins)?t.plugins:[];if(n.length===0)return;const r=[];for(const s of n){const o=g(this.legacySharedDir(),s.zipFile);if(!(!s.pluginName||!S(o)))try{const i=await this.deployPluginZipToPersistentDir(E(o),s.pluginName);if(!i)continue;r.push(i),d.info("[shared] \u65E7\u5171\u4EAB\u63D2\u4EF6\u8FC1\u79FB\u5230\u90E8\u7F72\u533A: %s",s.pluginName)}catch(i){d.warn("[shared] \u65E7\u5171\u4EAB\u63D2\u4EF6 %s \u8FC1\u79FB\u5931\u8D25: %s",s.pluginName,i instanceof Error?i.message:String(i))}}r.length>0&&this.writeSharedManifest(r),v(this.legacySharedDir(),{recursive:!0,force:!0})}catch(e){d.warn("[shared] \u65E7\u5171\u4EAB\u63D2\u4EF6\u8FC1\u79FB\u672A\u6267\u884C\uFF08\u4E0B\u6B21\u91CD\u8BD5\uFF09: %s",e instanceof Error?e.message:String(e))}}deployedPluginHealthy(e){return S(g(this.deployedPluginDir(e),"plugin.json"))}runtimeDirFor(e){return g(this.runtimeRootDir,M(e))}runtimeLinkPath(e,t){return g(this.runtimeDirFor(e),t)}ensureRuntimeLink(e,t){const n=this.runtimeLinkPath(e,t),r=this.deployedPluginDir(t);if(!S(g(r,"plugin.json")))return!1;L(this.runtimeDirFor(e),{recursive:!0});try{if(S(n)){let s=!1;try{s=X(n).isSymbolicLink()}catch{s=!1}if(s)try{return H(n),!0}catch{}v(n,{recursive:!0,force:!0})}return Q(r,n,Se),d.info("[agent:%s] \u63D2\u4EF6\u8FD0\u884C\u65F6\u94FE\u63A5\u5DF2\u5EFA\u7ACB: %s \u2192 %s",e,n,r),!0}catch(s){return d.warn("[agent:%s] \u63D2\u4EF6\u8FD0\u884C\u65F6\u94FE\u63A5\u5931\u8D25\uFF08%s \u2192 %s\uFF09: %s",e,t,r,s instanceof Error?s.message:String(s)),!1}}removeRuntimeLink(e,t){const n=this.runtimeLinkPath(e,t);try{S(n)&&(v(n,{recursive:!0,force:!0}),d.info("[agent:%s] \u63D2\u4EF6\u8FD0\u884C\u65F6\u94FE\u63A5\u5DF2\u79FB\u9664: %s",e,t))}catch(r){d.warn("[agent:%s] \u63D2\u4EF6\u8FD0\u884C\u65F6\u94FE\u63A5\u79FB\u9664\u5931\u8D25\uFF08%s\uFF09: %s",e,t,r instanceof Error?r.message:String(r))}}async saveSharedPlugin(e,t,n=!0,r){if(!e||e.length===0)return{ok:!1,error:"zip \u5305\u5185\u5BB9\u4E3A\u7A7A"};await this.migrateLegacySharedIfNeeded();const s=g(this.rootDir,"tmp",`deploy-${Date.now()}-${Math.random().toString(36).slice(2,8)}`);try{const o=await j(e,s),i=this.loadManifestOnly(o.pluginDir);if(!i.ok)return i;const a=i.manifest.name,u=this.readSharedManifest().find(p=>p.pluginName===a);if(u&&u.sha256===r&&this.deployedPluginHealthy(a))return{ok:!0,pluginName:a};await this.suspendDeployedPluginAcrossAgents(a),L(this.deployedDir(),{recursive:!0});const c=this.deployedPluginDir(a),f=g(this.deployedDir(),`.old-${a}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`);if(S(c))try{V(c,f)}catch{v(c,{recursive:!0,force:!0})}try{F(o.pluginDir,c,{recursive:!0,filter:p=>!/[\\/]\.git([\\/]|$)/.test(p)&&!/[\\/]node_modules([\\/]|$)/.test(p)})}catch(p){throw S(f)&&(v(c,{recursive:!0,force:!0}),V(f,c)),p}S(f)&&v(f,{recursive:!0,force:!0}),await W(this.deployedManifestFile(),async()=>{const p=this.readSharedManifest().filter(w=>w.pluginName!==a);p.push({pluginName:a,zipFile:u?.zipFile??`${a}.zip`,fileName:t,defaultEnabled:n,sha256:r}),this.writeSharedManifest(p)}),d.info("[shared] \u63D2\u4EF6\u5DF2\u90E8\u7F72\u5230 bridge: %s\uFF08\u6765\u6E90 %s%s\uFF09",a,t,r?`, sha256=${r.slice(0,12)}\u2026`:"");const m=(await this.applySharedToKnownAgents()).find(p=>p.installed.includes(a));return m&&d.info("[shared] \u5DF2\u540C\u6B65\u5230\u8FD0\u884C\u4E2D agent: %s",m.agentId),{ok:!0,pluginName:a}}catch(o){const i=o instanceof Error?o.message:String(o);return d.warn("[shared] \u63D2\u4EF6\u90E8\u7F72\u5931\u8D25\uFF08%s\uFF09: %s",t,i),{ok:!1,error:`\u63D2\u4EF6\u90E8\u7F72\u5931\u8D25: ${i}`}}finally{await b(s,3,100).catch(()=>{})}}async deployPluginZipToPersistentDir(e,t){if(!e||e.length===0)return null;const n=g(this.rootDir,"tmp",`migrate-${Date.now()}-${Math.random().toString(36).slice(2,8)}`);try{const r=await j(e,n),s=this.loadManifestOnly(r.pluginDir);if(!s.ok)return null;const o=s.manifest.name;if(t&&o!==t)return null;L(this.deployedDir(),{recursive:!0});const i=this.deployedPluginDir(o);return S(i)&&v(i,{recursive:!0,force:!0}),F(r.pluginDir,i,{recursive:!0,filter:a=>!/[\\/]\.git([\\/]|$)/.test(a)&&!/[\\/]node_modules([\\/]|$)/.test(a)}),{pluginName:o,zipFile:`${o}.zip`,fileName:`${o}.zip`,defaultEnabled:!0}}finally{v(n,{recursive:!0,force:!0})}}async suspendDeployedPluginAcrossAgents(e){for(const t of[...this.agents.values()]){if(!t.hydrated)continue;const n=t.queue.then(async()=>{const r=t.plugins.get(e);r&&(this.stopAllListeners(r),t.plugins.delete(e),d.info("[agent:%s] \u5DF2\u6458\u9664\u63D2\u4EF6\u7B49\u5F85\u90E8\u7F72\u533A\u66F4\u65B0: %s",t.agentId,e))});t.queue=n.catch(()=>{}),await n}}async applySharedToKnownAgents(){const e=[];for(const t of this.agents.values()){if(!t.hydrated)continue;const n=await this.syncSharedIntoStateQueued(t);n.length>0&&e.push({agentId:t.agentId,installed:n})}return e}async syncSharedIntoStateQueued(e){const t=e.queue.then(()=>this.syncSharedIntoState(e));return e.queue=t.catch(()=>[]),t}effectiveSharedEnabled(e,t){return se(e,"plugins",t.pluginName)&&(t.defaultEnabled??!0)}async pullTemplatePluginsFromCapabilities(e){const t=ie(e.agentId);if(!t)return;const n=this.readSharedManifest();for(const[r,s]of Object.entries(t)){if(!s.url)continue;const o=n.find(a=>a.pluginName===r);if(!o||!o.sha256||o.sha256===s.sha256&&this.deployedPluginHealthy(r)||this.templatePullInFlight.has(r))continue;this.templatePullInFlight.add(r);const i=g(this.rootDir,"tmp",`pull-${M(e.agentId)}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`);try{L(i,{recursive:!0});let a=`${r}.zip`;try{const y=decodeURIComponent(s.url.split("/").pop()||"");y.toLowerCase().endsWith(".zip")&&(a=ue(y,`${r}.zip`))}catch{}const u=await le({downloadUrl:s.url,fileName:a,sha256:s.sha256},i);if(!u)continue;const c=E(u.outputPath),f=await this.saveSharedPlugin(c,u.fileName,o.defaultEnabled??!0,s.sha256);f.ok?d.info("[agent:%s] \u5DF2\u90E8\u7F72\u63D2\u4EF6\u81EA\u52A8\u5BF9\u8D26\u66F4\u65B0\u6210\u529F: %s",e.agentId,f.pluginName??r):d.warn("[agent:%s] \u5DF2\u90E8\u7F72\u63D2\u4EF6\u66F4\u65B0\u5931\u8D25: %s: %s",e.agentId,r,f.error)}catch(a){d.warn("[agent:%s] \u5DF2\u90E8\u7F72\u63D2\u4EF6 %s \u66F4\u65B0\u5931\u8D25: %s",e.agentId,r,a instanceof Error?a.message:String(a))}finally{this.templatePullInFlight.delete(r),await b(i,3,100).catch(()=>{})}}}queueTemplatePull(e){this.backgroundTemplatePulls.has(e.agentId)||(this.backgroundTemplatePulls.add(e.agentId),this.pullTemplatePluginsFromCapabilities(e).catch(t=>{d.warn("[agent:%s] \u540E\u53F0\u63D2\u4EF6\u5BF9\u8D26\u66F4\u65B0\u5931\u8D25: %s",e.agentId,t instanceof Error?t.message:String(t))}).finally(()=>{this.backgroundTemplatePulls.delete(e.agentId)}))}async syncSharedIntoState(e){this.queueTemplatePull(e);const t=this.readSharedManifest(),n=new Set,r=[];for(const s of t)if(n.add(s.pluginName),this.effectiveSharedEnabled(e.agentId,s)){const i=e.plugins.get(s.pluginName);if(!this.ensureRuntimeLink(e.agentId,s.pluginName))continue;const a=this.runtimeLinkPath(e.agentId,s.pluginName);if(!i){const u=this.loadPluginFromDir(e,a,`shared:${s.fileName}`,new Date().toISOString(),{});u.ok?(e.plugins.set(u.plugin.name,u.plugin),r.push(u.plugin.name),d.info("[agent:%s] \u5DF2\u90E8\u7F72\u63D2\u4EF6\u5DF2\u6309\u5F00\u542F\u6001\u52A0\u8F7D: %s",e.agentId,s.pluginName)):d.warn("[agent:%s] \u5DF2\u90E8\u7F72\u63D2\u4EF6\u52A0\u8F7D\u5931\u8D25: %s: %s",e.agentId,s.pluginName,u.error)}}else{const i=e.plugins.get(s.pluginName);i&&(this.stopAllListeners(i),e.plugins.delete(s.pluginName)),this.removeRuntimeLink(e.agentId,s.pluginName)}return this.cleanupRuntimeDir(e,n),this.persistInstalled(e),r}cleanupRuntimeDir(e,t){const n=this.runtimeDirFor(e.agentId);try{if(!S(n))return;const r=new Set(t);for(const s of H(n))!r.has(s)&&!e.plugins.has(s)&&this.removeRuntimeLink(e.agentId,s)}catch{}}async applyCapabilities(e){const t=await this.hydrate(e);await this.pullTemplatePluginsFromCapabilities(t),await this.syncSharedIntoState(t)}async drainEvents(e,t={}){const n=await this.hydrate(e);this.ensureListenersRunning(n);const r=n.buffer.drain(t),s=await this.getCatalog(e);return{revision:r.revision,events:r.events,catalog:s,compactionSeq:n.compactionSeq}}markAgentCompacted(e){const t=this.agentState(e);t.compactionSeq++,d.debug("[agent:%s] \u4E0A\u4E0B\u6587\u538B\u7F29\u6807\u8BB0: compactionSeq=%d",e,t.compactionSeq)}async enqueueExternalEvent(e,t,n){const r=await this.hydrate(e),s=r.plugins.get(t);if(!s||!s.enabled)return{ok:!1,error:`\u63D2\u4EF6 ${t} \u672A\u5B89\u88C5\u6216\u5DF2\u505C\u7528`};const o=typeof n.event=="string"?n.event:"",i=s.listeners.find(a=>a.transport.type==="http-callback"&&(!o||a.event===o));return i?(this.enqueueEvent(r,s,i,n),{ok:!0}):{ok:!1,error:`\u63D2\u4EF6 ${t} \u65E0\u5339\u914D\u7684 http-callback \u76D1\u542C\u5668\uFF08event=${o||"(\u7A7A)"}\uFF09`}}agentState(e){let t=this.agents.get(e);return t||(t={agentId:e,plugins:new Map,buffer:new ce(e),hydrated:!1,queue:Promise.resolve(),eventSeq:0,compactionSeq:0},this.agents.set(e,t)),t}async hydrate(e){await this.migrateLegacySharedIfNeeded();const t=this.agentState(e);if(t.hydrated)return t;t.hydrated=!0;const n=this.installedFile(e);if(!S(n))return await this.syncSharedIntoState(t).catch(()=>{}),t;try{const r=JSON.parse(E(n,"utf8"));for(const s of r.plugins??[]){if(String(s.source||"").startsWith("shared:"))continue;const i=g(this.rootDir,"cache",M(e),s.name);if(!S(g(i,"plugin.json"))){d.warn("[agent:%s] \u5DF2\u5B89\u88C5\u63D2\u4EF6\u76EE\u5F55\u7F3A\u5931\uFF0C\u8DF3\u8FC7: %s",e,s.name);continue}const a=this.loadPluginFromDir(t,i,s.source,s.installedAt,s.config??{});if(a.ok){const u=a.plugin;u.enabled=s.enabled,t.plugins.set(u.name,u)}else d.warn("[agent:%s] \u63D2\u4EF6\u88C5\u8F7D\u5931\u8D25: %s: %s",e,s.name,a.error)}}catch(r){const s=r instanceof Error?r.message:String(r);d.error("[agent:%s] installed.json \u89E3\u6790\u5931\u8D25: %s",e,s)}return await this.syncSharedIntoState(t).catch(r=>{d.warn("[agent:%s] \u5171\u4EAB\u63D2\u4EF6\u540C\u6B65\u5931\u8D25: %s",e,r instanceof Error?r.message:String(r))}),t}installedFile(e){return g(this.rootDir,"agents",M(e),"installed.json")}persistInstalled(e){const t=this.installedFile(e.agentId);L(Z(t),{recursive:!0});const n=[...e.plugins.values()].map(r=>({name:r.name,source:r.source,installedAt:r.installedAt,enabled:r.enabled,config:r.configValues}));B(t,`${JSON.stringify({version:1,plugins:n},null,2)}
4
+ `,"utf8")}readJsonFile(e){if(!S(e))return{ok:!0,data:{}};try{const t=JSON.parse(E(e,"utf8"));return P(t)?{ok:!0,data:t}:{ok:!1,error:`${e}: \u6839\u8282\u70B9\u987B\u4E3A\u5BF9\u8C61`}}catch(t){const n=t instanceof Error?t.message:String(t);return{ok:!1,error:`${e}: JSON \u89E3\u6790\u5931\u8D25: ${n}`}}}loadManifestOnly(e){const t=this.readJsonFile(g(e,"plugin.json"));if(!t.ok)return t;const n=t.data,r=Ae(n);return r?{ok:!1,error:r}:{ok:!0,manifest:n}}loadPluginFromDir(e,t,n,r,s){const o=this.loadManifestOnly(t);if(!o.ok)return o;const i=o.manifest,a=g(t,i.tools??"tools/tools.json"),u=this.readJsonFile(a);if(!u.ok)return u;const c=[],f=Array.isArray(u.data.tools)?u.data.tools:[];for(const h of f){const T=Le(h);if(T)return{ok:!1,error:`${i.tools??"tools/tools.json"}: ${T}`};c.push(h)}const y=g(t,i.listeners??"listeners/listeners.json"),m=this.readJsonFile(y);if(!m.ok)return m;const p=[],w=Array.isArray(m.data.listeners)?m.data.listeners:[];for(const h of w){const T=Te(h);if(T)return{ok:!1,error:`${i.listeners??"listeners/listeners.json"}: ${T}`};p.push(h)}const $=Array.isArray(i.userConfig)?i.userConfig:[],D={...s};for(const h of $){if(!h||typeof h.key!="string"||!/^[A-Za-z_][A-Za-z0-9_]*$/.test(h.key))return{ok:!1,error:"plugin.json: userConfig.key \u975E\u6CD5\uFF08\u987B\u4E3A\u73AF\u5883\u53D8\u91CF\u540D\uFF09"};if(!(typeof D[h.key]=="string"&&D[h.key].length>0)&&h.required){const G=h.default!==void 0&&typeof h.default=="string"?h.default:"";if(G)D[h.key]=G;else return{ok:!1,error:`\u7F3A\u5C11\u5FC5\u9700\u914D\u7F6E ${h.key}${h.description?`\uFF08${h.description}\uFF09`:""}\uFF0C\u5B89\u88C5\u65F6\u8BF7\u5728 config \u4E2D\u63D0\u4F9B`}}}const N=i.commands;let Y;if(typeof N=="string"&&N.trim()){const h=g(t,N.trim());S(h)&&(Y=h)}return{ok:!0,plugin:{name:i.name,version:typeof i.version=="string"?i.version:void 0,description:typeof i.description=="string"?i.description:void 0,source:n,installedAt:r,dir:t,enabled:!0,tools:c,listeners:p,commandDir:Y,userConfig:$,configValues:D,status:"enabled",runtimes:p.map(h=>({def:h,stopping:!1,restarts:0,logs:[]})),moduleCache:new Map}}}ensureListenersRunning(e){for(const t of e.plugins.values())if(t.enabled)for(const n of t.runtimes)!n.child&&!n.timer&&!n.backoffTimer&&!n.stopping&&this.startListener(e,t,n)}startAllListeners(e,t){for(const n of t.runtimes)this.stopListener(n),t.enabled&&this.startListener(e,t,n)}stopAllListeners(e){for(const t of e.runtimes)this.stopListener(t)}startListener(e,t,n){const r=n.def.transport??{type:"command-stream"};if(r.type==="http-callback"){n.stopping=!1;return}if(r.type==="poll-command"){const s=Math.max(5e3,r.intervalMs??3e4);n.stopping=!1,n.timer=setInterval(()=>{this.pollListenerOnce(e,t,n)},s),this.pollListenerOnce(e,t,n);return}if(!r.command){n.lastError="command-stream \u7F3A\u5C11 command",k(n,`ERROR ${n.lastError}`);return}n.stopping=!1,this.spawnListenerChild(e,t,n)}spawnListenerChild(e,t,n){const s=n.def.transport?.command??"",o=U(s,{});try{k(n,`spawn: ${o.join(" ")}`);const i=C(o[0],o.slice(1),{cwd:t.dir,env:this.buildPluginEnv(t,e.agentId),shell:!1,windowsHide:!0,stdio:["ignore","pipe","pipe"]});n.child=i,n.lastError=void 0;let a="";i.stdout?.on("data",u=>{a+=u.toString("utf8");let c=a.indexOf(`
5
+ `);for(;c>=0;){const f=a.slice(0,c).trim();a=a.slice(c+1),f&&this.handleListenerLine(e,t,n,f),c=a.indexOf(`
6
+ `)}a.length>1024*1024&&(a=a.slice(-4096))}),i.stderr?.on("data",u=>{k(n,`stderr: ${A(u.toString("utf8").trimEnd(),400)}`)}),i.on("error",u=>{n.lastError=`\u8FDB\u7A0B\u542F\u52A8\u5931\u8D25: ${u.message}`,k(n,`ERROR ${n.lastError}`)}),i.on("close",u=>{n.child=void 0,!n.stopping&&(n.lastError=`\u76D1\u542C\u8FDB\u7A0B\u9000\u51FA\uFF08code=${u??"signal"}\uFF09`,k(n,`exit code=${u??"signal"}\uFF0C\u51C6\u5907\u91CD\u542F`),this.scheduleListenerRestart(e,t,n))})}catch(i){const a=i instanceof Error?i.message:String(i);n.lastError=a,k(n,`ERROR spawn: ${a}`),this.scheduleListenerRestart(e,t,n)}}scheduleListenerRestart(e,t,n){if(n.stopping)return;const r=Math.max(500,n.def.transport?.restartBackoffMs??2e3),s=Math.min($e,r*2**Math.min(n.restarts,6));n.restarts++,k(n,`restart #${n.restarts} in ${s}ms`),n.backoffTimer=setTimeout(()=>{n.backoffTimer=void 0,n.stopping||this.spawnListenerChild(e,t,n)},s)}async pollListenerOnce(e,t,n){if(n.polling)return;const r=n.def.transport?.command??"",s=U(r,{});if(s.length===0)return;n.polling=!0;const o=new AbortController,i=setTimeout(()=>o.abort(),J);try{const a=await new Promise((u,c)=>{const f=C(s[0],s.slice(1),{cwd:t.dir,env:this.buildPluginEnv(t,e.agentId),shell:!1,windowsHide:!0,stdio:["ignore","pipe","pipe"],signal:o.signal});let y="",m="";f.stdout?.on("data",w=>{y.length<_&&(y+=w.toString("utf8"))}),f.stderr?.on("data",w=>{m.length<_&&(m+=w.toString("utf8"))});const p=()=>o.signal.aborted;f.on("error",w=>{c(p()?new Error(`poll \u8D85\u65F6(${J}ms)`):w)}),f.on("close",w=>{p()?c(new Error(`poll \u8D85\u65F6(${J}ms)`)):w===0?u(y):c(new Error(`exit ${w}: ${A(m||y,300)}`))})});n.lastError=void 0;for(const u of a.split(`
7
+ `)){const c=u.trim();c&&this.handleListenerLine(e,t,n,c)}}catch(a){const u=a instanceof Error?a.message:String(a);n.lastError=u,k(n,`poll \u5931\u8D25: ${u}`)}finally{clearTimeout(i),n.polling=!1}}stopListener(e){if(e.stopping=!0,e.restarts=0,e.child){try{e.child.kill()}catch{}e.child=void 0}e.timer&&(clearInterval(e.timer),e.timer=void 0),e.backoffTimer&&(clearTimeout(e.backoffTimer),e.backoffTimer=void 0)}handleListenerLine(e,t,n,r){k(n,`event: ${A(r,300)}`);let s;try{s=JSON.parse(r)}catch{n.lastError="\u4E8B\u4EF6\u884C\u4E0D\u662F\u5408\u6CD5 JSON\uFF08\u8981\u6C42 JSONL\uFF09";return}if(!P(s))return;const o=typeof s.event=="string"?s.event:n.def.event,i=o===n.def.event?n.def:t.listeners.find(a=>a.event===o);i&&(i.delivery&&i.delivery!=="poll"&&d.debug("[plugin:%s] delivery=%s \u6682\u6309 poll \u4EA4\u4ED8",t.name,i.delivery),this.enqueueEvent(e,t,i,s))}enqueueEvent(e,t,n,r){for(const[y,m]of Object.entries(n.matcher??{})){const p=O(r,y);if(!(Array.isArray(m)?m:[m]).some($=>JSON.stringify($)===JSON.stringify(p)))return}let s;if(n.dedupKey){const y=O(r,n.dedupKey);y!=null&&(s=A(String(y),256))}e.eventSeq++;const o=A(be(r.data??r),fe),i=n.promptTemplate?Oe(n.promptTemplate,r):`\u3010\u63D2\u4EF6\u4E8B\u4EF6\u3011${t.name} \xB7 ${n.event}${n.description?`
8
+ ${n.description}`:""}`,a=(n.toolHints??[]).join(","),u=`${i}
9
+ [plugin-event] plugin=${t.name} event=${n.event}`+(a?` toolHints=${a}`:"")+` payload=${o}`,c={msgId:A(s?`plugin-event-${t.name}-${s}`:`plugin-event-${t.name}-${n.event}-${e.eventSeq}`,512),channel:"plugin-event",senderId:`plugin:${t.name}`,senderName:`\u63D2\u4EF6[${t.name}]`,receiverId:e.agentId||void 0,content:u,requireReply:!1,role:"system",timestamp:new Date().toISOString()},f=n.priority??"normal";e.buffer.push({plugin:t.name,event:n.event,priority:f,dedupKey:s,receivedAt:Date.now(),message:c})}requiredParamsOf(e){const t=e.inputSchema;if(!(!t||!Array.isArray(t.required)))return t.required.filter(n=>typeof n=="string")}toSummary(e){return{name:e.name,version:e.version,description:e.description,status:e.status,enabled:e.enabled,source:e.source,installedAt:e.installedAt,toolCount:e.tools.length,listeners:e.runtimes.map(t=>({event:t.def.event,delivery:t.def.delivery??"poll",running:!!(t.child||t.timer)||t.def.transport?.type==="http-callback",error:t.lastError})),error:e.error}}async getLogs(e,t){const r=(await this.hydrate(e)).plugins.get(t);if(!r)return{ok:!1,error:`\u63D2\u4EF6 ${t} \u672A\u5B89\u88C5`,logs:[]};const s=[];for(const o of r.runtimes)s.push(`\u2500\u2500 listener ${o.def.event} (${o.def.transport?.type}) ${o.lastError?`[error: ${o.lastError}]`:""}`),s.push(...o.logs);return{ok:!0,logs:s}}async stopAgent(e){const t=this.agents.get(e);if(t){for(const n of t.plugins.values())this.stopAllListeners(n);this.agents.delete(e)}}async stopAll(){for(const e of[...this.agents.keys()])await this.stopAgent(e)}async listDeployed(){await this.migrateLegacySharedIfNeeded();const e=this.readSharedManifest(),t=[];for(const n of e){const r=this.deployedPluginDir(n.pluginName),s=this.deployedPluginHealthy(n.pluginName);let o;if(s)try{const i=JSON.parse(E(g(r,"plugin.json"),"utf8"));typeof i.version=="string"&&(o=i.version)}catch{}t.push({pluginName:n.pluginName,version:o,fileName:n.fileName??`${n.pluginName}.zip`,defaultEnabled:n.defaultEnabled!==!1,sha256:n.sha256,deployed:s})}return t}deployedDefaultEnabled(){const e=this.readSharedManifest(),t={};for(const n of e)t[n.pluginName]=n.defaultEnabled!==!1;return t}async removeDeployedPlugin(e){if(!z(e))return{ok:!1,error:"pluginName \u975E\u6CD5\uFF08\u987B\u4E3A kebab-case\uFF0C1~64 \u5B57\u7B26\uFF09"};await this.migrateLegacySharedIfNeeded();for(const t of[...this.agents.values()]){if(!t.hydrated)continue;const n=t.queue.then(async()=>{const r=t.plugins.get(e);r&&(this.stopAllListeners(r),t.plugins.delete(e)),this.removeRuntimeLink(t.agentId,e),this.persistInstalled(t)});t.queue=n.catch(()=>{}),await n}await W(this.deployedManifestFile(),async()=>{const t=this.readSharedManifest().filter(n=>n.pluginName!==e);this.writeSharedManifest(t)});try{v(this.deployedPluginDir(e),{recursive:!0,force:!0})}catch(t){return{ok:!1,error:`\u90E8\u7F72\u76EE\u5F55\u6E05\u7406\u5931\u8D25: ${t instanceof Error?t.message:String(t)}`}}return d.info("[shared] \u63D2\u4EF6\u5DF2\u4ECE bridge \u79FB\u9664\u90E8\u7F72: %s",e),{ok:!0}}}function ke(l){const e=l.indexOf(".");if(e<=0||e>=l.length-1)return null;const t=l.slice(0,e),n=l.slice(e+1);return!I.test(t)||!n.trim()?null:{plugin:t,tool:n.trim()}}function z(l){return typeof l=="string"&&l.length>0&&l.length<=64&&I.test(l)}function Ae(l){const e=l.name;if(typeof e!="string"||!I.test(e))return`plugin.json: name \u975E\u6CD5\uFF08\u987B\u4E3A kebab-case\uFF09: ${String(e)}`;if(e.length>64)return"plugin.json: name \u8FC7\u957F\uFF08\u226464\uFF09";for(const t of he)if(e===t.replace(/\.$/,"")||e.startsWith(t))return`plugin.json: name \u4F7F\u7528\u4E86\u4FDD\u7559\u524D\u7F00 ${t}`;return we.test(e)?"plugin.json: name \u542B\u975E ASCII \u5B57\u7B26\uFF08\u540C\u5F62\u5B57\u9632\u62A4\uFF09":l.version!==void 0&&typeof l.version!="string"?"plugin.json: version \u987B\u4E3A\u5B57\u7B26\u4E32":l.userConfig!==void 0&&!Array.isArray(l.userConfig)?"plugin.json: userConfig \u987B\u4E3A\u6570\u7EC4":null}function Le(l){if(!P(l))return"\u5DE5\u5177\u6761\u76EE\u987B\u4E3A\u5BF9\u8C61";const e=l.name;if(typeof e!="string"||!pe.test(e))return`\u5DE5\u5177 name \u975E\u6CD5: ${String(e)}`;if(typeof l.description!="string"||!l.description.trim())return`\u5DE5\u5177 ${e} \u7F3A\u5C11 description`;const t=l.handler;if(!P(t))return`\u5DE5\u5177 ${e} \u7F3A\u5C11 handler`;const n=t.type;return n!=="process"&&n!=="module"&&n!=="mcp"?`\u5DE5\u5177 ${e} handler.type \u975E\u6CD5: ${String(n)}`:n==="process"&&typeof t.command!="string"?`\u5DE5\u5177 ${e} \u7684 process handler \u7F3A\u5C11 command`:n==="module"&&typeof t.module!="string"?`\u5DE5\u5177 ${e} \u7684 module handler \u7F3A\u5C11 module`:l.inputSchema!==void 0&&!P(l.inputSchema)?`\u5DE5\u5177 ${e} inputSchema \u987B\u4E3A\u5BF9\u8C61`:null}function Te(l){if(!P(l))return"\u76D1\u542C\u5668\u6761\u76EE\u987B\u4E3A\u5BF9\u8C61";if(typeof l.event!="string"||!l.event.trim())return"\u76D1\u542C\u5668\u7F3A\u5C11 event";const e=l.transport;if(!P(e))return`\u76D1\u542C\u5668 ${String(l.event)} \u7F3A\u5C11 transport`;const t=e.type;if(t!=="command-stream"&&t!=="poll-command"&&t!=="http-callback")return`\u76D1\u542C\u5668 ${String(l.event)} transport.type \u975E\u6CD5: ${String(t)}`;if((t==="command-stream"||t==="poll-command")&&typeof e.command!="string")return`\u76D1\u542C\u5668 ${String(l.event)} \u7684 ${t} transport \u7F3A\u5C11 command`;const n=l.delivery;return n!==void 0&&n!=="poll"&&n!=="force"&&n!=="wake"?`\u76D1\u542C\u5668 ${String(l.event)} delivery \u975E\u6CD5: ${String(n)}`:null}function U(l,e){return l.trim().split(/\s+/).map(t=>{const n=/^\{\{(.+)\}\}$/.exec(t);if(n){const r=O(e,n[1].trim());return r==null?"":typeof r=="string"?r:JSON.stringify(r)}return t.replace(/\{\{(.+?)\}\}/g,(r,s)=>{const o=O(e,s.trim());return o==null?"":typeof o=="string"?o:JSON.stringify(o)})}).filter(t=>t!=="")}function Oe(l,e){return l.replace(/\{\{(.+?)\}\}/g,(t,n)=>{let r=O(e,n.trim());return r===void 0&&!n.trim().startsWith("params.")&&(r=O(e,`data.${n.trim()}`)),r==null?"":typeof r=="string"?r:JSON.stringify(r)})}function be(l){try{return JSON.stringify(l)??"null"}catch{return"(\u4E0D\u53EF\u5E8F\u5217\u5316\u7684\u4E8B\u4EF6\u8D1F\u8F7D)"}}const Ne=new Ee;oe("plugins",()=>Ne.deployedDefaultEnabled());const Ge=()=>ae("plugins");export{Ee as PluginManager,z as isValidPluginName,Ne as pluginManager,Ge as reconcilePluginsDefaultsFromDeployed,U as renderCommandArgv,ke as splitQualifiedName,q as validateAgainstSchema,Ae as validateManifest};
10
+
@@ -0,0 +1,8 @@
1
+
2
+ export interface PluginZipExtractResult {
3
+
4
+ pluginDir: string;
5
+ fileCount: number;
6
+ }
7
+
8
+ export declare function extractPluginZip(zipBuffer: Buffer, stagingRoot: string): Promise<PluginZipExtractResult>;
@@ -0,0 +1,2 @@
1
+ import{createWriteStream as w}from"node:fs";import{mkdir as m,readdir as h,rm as p}from"node:fs/promises";import u from"node:path";import{Readable as d,Transform as f}from"node:stream";import{pipeline as y}from"node:stream/promises";import x from"unzipper";const s={maxEntries:2e3,maxFileBytes:100*1024*1024,maxTotalBytes:200*1024*1024,maxPathLength:400,maxPathDepth:24};function z(t,e){let r=0;return new f({transform(i,o,a){if(r+=i.length,r>t){a(new Error(`${e} \u8D85\u51FA\u4E0A\u9650\uFF08${t} \u5B57\u8282\uFF09`));return}a(null,i)}})}function E(t,e){let r=0;return{transform(){return new f({transform(i,o,a){if(r+=i.length,r>t){a(new Error(`${e} \u8D85\u51FA\u603B\u91CF\u4E0A\u9650\uFF08${t} \u5B57\u8282\uFF09`));return}a(null,i)}})}}}function $(t,e){const r=String(e||"").replace(/\\/g,"/");if(!r||r.startsWith("/")||/^[A-Za-z]:/.test(r)||r.split("/").includes(".."))throw new Error(`zip \u6761\u76EE\u8DEF\u5F84\u975E\u6CD5: ${e}`);if(r.length>s.maxPathLength)throw new Error(`zip \u6761\u76EE\u8DEF\u5F84\u8FC7\u957F: ${e}`);if(r.split("/").filter(Boolean).length>s.maxPathDepth)throw new Error(`zip \u6761\u76EE\u8DEF\u5F84\u8FC7\u6DF1: ${e}`);const i=u.resolve(t,r),o=u.resolve(t)+u.sep;if(i!==u.resolve(t)&&!i.startsWith(o))throw new Error(`zip \u6761\u76EE\u8D8A\u754C\uFF08zip-slip\uFF09: ${e}`);return i}async function F(t,e){await p(e,{recursive:!0,force:!0}),await m(e,{recursive:!0});const r=d.from([t]),i=r.pipe(x.Parse({forceStream:!0}));let o=0,a=0;const c=E(s.maxTotalBytes,"zip \u89E3\u538B\u603B\u91CF");try{for await(const n of i){const l=$(e,n.path);if(n.type==="Directory"){await m(l,{recursive:!0}),n.autodrain?.();continue}if(n.type!=="File"){n.autodrain?.();continue}if(o++,o>s.maxEntries)throw new Error(`zip \u6761\u76EE\u6570\u8D85\u51FA\u4E0A\u9650\uFF08${s.maxEntries}\uFF09`);if(a+=Number(n.size??0),a>s.maxTotalBytes)throw new Error(`zip \u603B\u91CF\u8D85\u51FA\u4E0A\u9650\uFF08${s.maxTotalBytes} \u5B57\u8282\uFF09`);await m(u.dirname(l),{recursive:!0}),await y(n,z(s.maxFileBytes,`zip \u6761\u76EE ${n.path}`),c.transform(),w(l))}}catch(n){throw await p(e,{recursive:!0,force:!0}).catch(()=>{}),n}finally{r.destroy(),i.destroy?.()}if(o===0)throw new Error("zip \u5185\u6CA1\u6709\u6587\u4EF6\uFF08\u9700\u8981\u5305\u542B plugin.json\uFF09");return{pluginDir:await v(e),fileCount:o}}async function v(t){const r=(await h(t,{withFileTypes:!0})).filter(i=>!i.name.startsWith("."));return r.length===1&&r[0].isDirectory()?u.join(t,r[0].name):t}export{F as extractPluginZip};
2
+
@@ -0,0 +1,41 @@
1
+
2
+ export interface DeployedSkillEntry {
3
+ skillName: string;
4
+ zipFile: string;
5
+ fileName: string;
6
+ defaultEnabled: boolean;
7
+ sha256?: string;
8
+ }
9
+ export interface DeployedSkillResult {
10
+ ok: boolean;
11
+ error?: string;
12
+ skillName?: string;
13
+ }
14
+
15
+ export declare function isValidSkillName(name: unknown): name is string;
16
+ export declare class SkillManager {
17
+ private readonly rootDir;
18
+ private static _instance;
19
+ static getInstance(): SkillManager;
20
+ private constructor();
21
+ private manifestFile;
22
+ private skillDir;
23
+ private isHealthy;
24
+ private readManifest;
25
+ private writeManifest;
26
+
27
+ saveSharedSkill(zipBuffer: Buffer, originalName: string, defaultEnabled?: boolean, sha256?: string, requestedSkillName?: string): Promise<DeployedSkillResult>;
28
+
29
+ removeDeployedSkill(skillName: string): Promise<{
30
+ ok: boolean;
31
+ error?: string;
32
+ }>;
33
+
34
+ listDeployed(): DeployedSkillEntry[];
35
+
36
+ deployedDefaultEnabled(): Record<string, boolean>;
37
+
38
+ private applyToKnownAgents;
39
+ }
40
+ export declare const skillManager: SkillManager;
41
+ export declare const reconcileSkillsDefaultsFromDeployed: () => number;
@@ -0,0 +1,3 @@
1
+ import{promises as g}from"node:fs";import{cpSync as S,existsSync as c,mkdirSync as $,readFileSync as j,readdirSync as A,rmSync as d,writeFileSync as E}from"node:fs";import i from"node:path";import{getAcodeSkillDataHome as I}from"../config.js";import{createLogger as b}from"../utils/logger.js";import{extractSkillZip as x,resolveSkillSourceDirFromExtractRoot as L}from"../utils/file-utils.js";import{getSkillFarmRoot as N,syncAgentSkillFarm as _}from"./agent-capability-sync.js";import{getAgentInitRoot as D}from"./instance-state.js";import{setDeployedDefaultsProvider as K,reconcileDefaultsFromDeployed as z}from"./capability-config.js";const h=b("skill-manager");function F(n){return typeof n=="string"&&n.length>0&&n.length<=128&&/^[a-zA-Z0-9_.-]+$/.test(n)}const O=1;class p{static getInstance(){return this._instance||(this._instance=new p(i.join(I(),"skills","deployed"))),this._instance}constructor(r){this.rootDir=r}manifestFile(){return i.join(this.rootDir,"manifest.json")}skillDir(r){const t=i.join(this.rootDir,r),e=i.resolve(this.rootDir);if(i.resolve(t)!==i.join(e,r))throw new Error(`\u6280\u80FD\u76EE\u5F55\u8D8A\u51FA\u90E8\u7F72\u533A: ${r}`);return t}isHealthy(r){return c(i.join(this.skillDir(r),"SKILL.md"))}readManifest(){try{const r=JSON.parse(j(this.manifestFile(),"utf8"));return Array.isArray(r.skills)?r.skills.filter(t=>t&&t.skillName):[]}catch{return[]}}writeManifest(r){$(this.rootDir,{recursive:!0}),E(this.manifestFile(),`${JSON.stringify({version:O,skills:r},null,2)}
2
+ `,"utf8")}async saveSharedSkill(r,t,e=!0,m,w){if(!r||r.length===0)return{ok:!1,error:"zip \u5305\u5185\u5BB9\u4E3A\u7A7A"};const y=i.join(D("_tmp"),`skill-deploy-${Date.now()}-${Math.random().toString(36).slice(2,8)}`);try{await R(r,y);const o=await L(y),l=i.basename(i.resolve(o)),M=String(t||"").replace(/\.zip$/i,"").trim(),s=w&&w.trim()||(l&&!l.startsWith("skill-deploy-")?l:"")||M;if(!F(s))return{ok:!1,error:`\u6280\u80FD\u540D\u975E\u6CD5: ${JSON.stringify(s)}`};if(!c(i.join(o,"SKILL.md")))return{ok:!1,error:`\u6280\u80FD\u5305\u7F3A\u5C11 SKILL.md: ${t}`};const k=this.readManifest().find(u=>u.skillName===s);if(k&&k.sha256===m&&this.isHealthy(s))return{ok:!0,skillName:s};$(this.rootDir,{recursive:!0});const a=this.skillDir(s),f=i.join(this.rootDir,`.old-${s}-${Date.now()}-${Math.random().toString(36).slice(2,8)}`);if(c(a))try{S(a,f,{recursive:!0})}catch{d(a,{recursive:!0,force:!0})}try{S(o,a,{recursive:!0})}catch(u){throw c(f)&&(d(a,{recursive:!0,force:!0}),S(f,a,{recursive:!0})),u}c(f)&&d(f,{recursive:!0,force:!0});const v=this.readManifest().filter(u=>u.skillName!==s);return v.push({skillName:s,zipFile:k?.zipFile??`${s}.zip`,fileName:t,defaultEnabled:e,sha256:m}),this.writeManifest(v),h.info("[shared] \u6280\u80FD\u5DF2\u90E8\u7F72\u5230 bridge: %s\uFF08\u6765\u6E90 %s%s\uFF09",s,t,m?`, sha256=${m.slice(0,12)}\u2026`:""),this.applyToKnownAgents(),{ok:!0,skillName:s}}catch(o){const l=o instanceof Error?o.message:String(o);return h.warn("[shared] \u6280\u80FD\u90E8\u7F72\u5931\u8D25\uFF08%s\uFF09: %s",t,l),{ok:!1,error:`\u6280\u80FD\u90E8\u7F72\u5931\u8D25: ${l}`}}finally{try{d(y,{recursive:!0,force:!0})}catch{}}}async removeDeployedSkill(r){if(!F(r))return{ok:!1,error:"skillName \u975E\u6CD5"};const t=this.readManifest().filter(e=>e.skillName!==r);this.writeManifest(t);try{d(this.skillDir(r),{recursive:!0,force:!0})}catch(e){return{ok:!1,error:`\u90E8\u7F72\u76EE\u5F55\u6E05\u7406\u5931\u8D25: ${e instanceof Error?e.message:String(e)}`}}return this.applyToKnownAgents(),h.info("[shared] \u6280\u80FD\u5DF2\u4ECE bridge \u79FB\u9664\u90E8\u7F72: %s",r),{ok:!0}}listDeployed(){return this.readManifest().filter(r=>!/^skill-deploy-/.test(r.skillName)).map(r=>({...r,deployed:this.isHealthy(r.skillName)}))}deployedDefaultEnabled(){const r={};for(const t of this.readManifest())/^skill-deploy-/.test(t.skillName)||(r[t.skillName]=t.defaultEnabled);return r}applyToKnownAgents(){const r=new Set;for(const t of[N(),i.dirname(i.resolve(D("_")))])try{if(c(t))for(const e of A(t))e.startsWith(".")||r.add(e)}catch{}for(const t of r)try{_(t)}catch(e){h.warn("[shared] \u540C\u6B65\u6280\u80FD\u519C\u573A\u5931\u8D25 agent=%s: %s",t,e instanceof Error?e.message:String(e))}}}p._instance=null;async function R(n,r){const t=i.join(D("_tmp"),`skill-${Date.now()}-${Math.random().toString(36).slice(2,8)}.zip`);await g.mkdir(i.dirname(t),{recursive:!0}),await g.writeFile(t,n);try{await x(t,r)}finally{await g.rm(t,{force:!0}).catch(()=>{})}}const H=p.getInstance();K("skills",()=>H.deployedDefaultEnabled());const U=()=>z("skills");export{p as SkillManager,F as isValidSkillName,U as reconcileSkillsDefaultsFromDeployed,H as skillManager};
3
+
package/dist/types.d.ts CHANGED
@@ -1,19 +1,17 @@
1
- import type { AppFlags } from '@cc-switch/sdk';
2
1
  import type { Request, Response, NextFunction } from 'express';
3
- export type { McpServerSpec, AppFlags } from '@cc-switch/sdk';
4
2
 
5
3
  export interface CreateMcpServerInput {
6
4
  name: string;
7
- server: import('@cc-switch/sdk').McpServerSpec;
5
+ server: McpServerConfig;
8
6
  description?: string;
9
- apps?: Partial<AppFlags>;
7
+ apps?: Partial<SdkApps>;
10
8
  }
11
9
 
12
10
  export interface UpdateMcpServerInput {
13
11
  name?: string;
14
- server?: import('@cc-switch/sdk').McpServerSpec;
12
+ server?: McpServerConfig;
15
13
  description?: string;
16
- apps?: Partial<AppFlags>;
14
+ apps?: Partial<SdkApps>;
17
15
  }
18
16
  export interface Session {
19
17
  agentId: string;
@@ -29,6 +27,13 @@ export interface SkillPackage {
29
27
  sha256?: string;
30
28
  skillName?: string;
31
29
  }
30
+
31
+ export interface PluginPackage {
32
+ downloadUrl?: string;
33
+ fileName?: string;
34
+ sha256?: string;
35
+ pluginName?: string;
36
+ }
32
37
  export interface McpPayload {
33
38
  id?: string;
34
39
  name: string;
@@ -157,18 +162,6 @@ export interface AiSourceApplyPayload {
157
162
  codex?: Record<string, unknown> | null;
158
163
  opencode?: Record<string, unknown> | null;
159
164
  }
160
- export interface CcSwitchAppPaths {
161
- runtimeHome: string;
162
- acodeConfigFile: string;
163
- acodeSkillsDir: string;
164
- claudeConfigFile: string;
165
- claudeMcpConfigFile: string;
166
- claudeSkillsDir: string;
167
- codexConfigFile: string;
168
- codexSkillsDir: string;
169
- opencodeConfigFile: string;
170
- opencodeSkillsDir: string;
171
- }
172
165
  export interface DownloadResult {
173
166
  fileName: string;
174
167
  outputPath: string;
@@ -179,49 +172,6 @@ export interface CallbackResponse {
179
172
  ok: boolean;
180
173
  [key: string]: unknown;
181
174
  }
182
- export interface InitResult {
183
- ok: boolean;
184
- agentId: string;
185
- workspacePath: string;
186
- initRoot: string;
187
- enabledTools: string[];
188
- toolStatus?: Record<string, ToolInstallStatus>;
189
- logs?: InitLogEntry[];
190
- skill: {
191
- enabled: boolean;
192
- packagePresent: boolean;
193
- installedCount?: number;
194
- installed?: LegacySkillStateItem[];
195
- };
196
- mcp: {
197
- enabled: boolean;
198
- configPath: string | null;
199
- installedCount?: number;
200
- };
201
- adapterResult?: unknown;
202
- installed?: {
203
- skills: LegacySkillStateItem[];
204
- mcpServers: LegacyMcpStateItem[];
205
- };
206
- }
207
- export interface SyncStateResult {
208
- state: InstanceState;
209
- configPath: string;
210
- skills: LegacySkillStateItem[];
211
- mcpServers: LegacyMcpStateItem[];
212
- }
213
- export interface AdapterResult {
214
- ok: boolean;
215
- adapter: string;
216
- action: string;
217
- agentId: string;
218
- payload: unknown;
219
- paths: CcSwitchAppPaths;
220
- snapshot: {
221
- skills: number;
222
- mcpServers: number;
223
- };
224
- }
225
175
  export interface PersistedSession {
226
176
  sessionId: string;
227
177
  agentId: string;
@@ -1,16 +1,19 @@
1
- import type { AppFlags, InstalledSkill, CcSwitchSdk } from '@cc-switch/sdk';
2
- import type { SkillPackage, DownloadResult, Skill } from '../types.js';
1
+ import type { SkillPackage, PluginPackage, DownloadResult } from '../types.js';
3
2
  export declare function ensureDir(targetDir: string): Promise<string>;
4
3
  export declare function withFileLock<T>(targetPath: string, operation: () => Promise<T>): Promise<T>;
5
4
  export declare function stringifyStableJson(value: unknown): string;
5
+
6
+ export declare function sanitizeAgentId(agentId: string): string;
7
+
8
+ export declare function sanitizeArchiveFileName(fileName: string, fallback: string): string;
6
9
  export declare function atomicWriteFile(targetPath: string, content: string): Promise<void>;
10
+
11
+ export declare function atomicWriteFileSync(targetPath: string, content: string): void;
7
12
  export declare function atomicWriteJsonFile(targetPath: string, value: unknown): Promise<void>;
8
13
  export declare function downloadSkillZip(skillPackage: SkillPackage, targetDir: string): Promise<DownloadResult | null>;
9
14
  export declare function runCommand(command: string, args: string[]): Promise<void>;
10
15
  export declare function escapePowerShellLiteral(text: string): string;
16
+
11
17
  export declare function extractSkillZip(zipFilePath: string, extractRootDir: string): Promise<void>;
12
18
  export declare function resolveSkillSourceDirFromExtractRoot(extractRootDir: string): Promise<string>;
13
- export declare function toSdkAppsFromEnabledTools(enabledTools: string[]): AppFlags;
14
- export declare function resolveSkillSourceDir(skill: Skill): string;
15
- export declare function ensureDirectoryExists(directoryPath: string): Promise<void>;
16
- export declare function installSkillPackageToSdk(sdk: CcSwitchSdk, skillPackage: SkillPackage, skillDir: string, sdkApps: AppFlags): Promise<InstalledSkill | null>;
19
+ export declare function downloadPluginZip(pluginPackage: PluginPackage, targetDir: string): Promise<DownloadResult | null>;
@@ -1,3 +1,3 @@
1
- import{spawn as g}from"node:child_process";import{createHash as x,randomUUID as $}from"node:crypto";import{promises as c}from"node:fs";import a from"node:path";import b from"axios";import{schedulerBaseUrl as d}from"../config.js";import{getRuntimeAccessToken as w}from"../services/runtime-binding.js";const p=new Map;async function N(e){return await c.mkdir(e,{recursive:!0}),e}async function W(e,t){const r=a.resolve(e),i=p.get(r)??Promise.resolve();let n;const s=new Promise(l=>{n=l}),o=i.then(()=>s);p.set(r,o),await i;try{return await t()}finally{n(),p.get(r)===o&&p.delete(r)}}function E(e){if(!e||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function f(e){return Array.isArray(e)?e.map(t=>f(t)):E(e)?Object.keys(e).sort().reduce((t,r)=>(t[r]=f(e[r]),t),{}):e}function j(e){return`${JSON.stringify(f(e),null,2)}
2
- `}async function k(e,t){await N(a.dirname(e));const r=a.dirname(e),i=a.basename(e),n=a.join(r,`.${i}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`);try{await c.writeFile(n,t,"utf-8"),await c.rename(n,e)}catch(s){throw await c.rm(n,{force:!0}).catch(()=>{}),s}}async function z(e,t){await k(e,j(t))}async function A(e,t){if(!e||!e.downloadUrl)return null;const r=String(e.downloadUrl).trim();if(!r)return null;let i=r;i.startsWith("/")&&(i=`${d}${i}`);const n=e.fileName&&String(e.fileName).trim()?String(e.fileName).trim():"skill-package.zip",s=a.join(t,n),o=w(d)||w();if(!o)throw new Error("runtime access token is required to download skill package");const l=await b.get(i,{responseType:"arraybuffer",headers:{"X-Runtime-Token":o}}),u=Buffer.from(l.data);if(await c.writeFile(s,u),e.sha256&&x("sha256").update(u).digest("hex")!==String(e.sha256).trim().toLowerCase())throw new Error("skill zip checksum mismatch");return{fileName:n,outputPath:s,bytes:u.length}}async function h(e,t){await new Promise((r,i)=>{const n=g(e,t,{stdio:["ignore","pipe","pipe"]});let s="";n.stderr?.on("data",o=>{s+=String(o||"")}),n.on("error",o=>{i(o)}),n.on("close",o=>{if(o!==0){i(new Error(s||`${e} exited with code ${o}`));return}r()})})}function y(e){return String(e||"").replace(/'/g,"''")}async function D(e,t){if(await c.rm(t,{recursive:!0,force:!0}),await c.mkdir(t,{recursive:!0}),process.platform==="win32"){const r=y(e),i=y(t);await h("powershell.exe",["-NoLogo","-NoProfile","-Command",`Expand-Archive -LiteralPath '${r}' -DestinationPath '${i}' -Force`]);return}await h("unzip",["-o",e,"-d",t])}async function F(e){const r=(await c.readdir(e,{withFileTypes:!0})).filter(i=>!i.name.startsWith("."));return r.length===1&&r[0].isDirectory()?a.join(e,r[0].name):e}function B(e){const t=Array.isArray(e)?e:[],r=i=>t.includes(i);return{acode:r("acode"),claude:r("claude"),claudecode:r("claudecode"),codex:r("codex"),gemini:r("gemini"),opencode:r("opencode"),openclaw:r("openclaw")}}function q(e){const t=String(e?.sourceDir||e?.directory||e?.filePath||"").trim();if(!t)throw new Error("skill.sourceDir is required");return a.resolve(t)}async function M(e){if(!(await c.stat(e)).isDirectory())throw new Error(`not a directory: ${e}`)}async function Z(e,t,r,i){const n=await A(t,r);if(!n)return null;const s=a.join(r,`${a.parse(n.fileName).name}-${$()}`);await D(n.outputPath,s);const o=await F(s),l=String(t?.skillName||n.fileName||"").trim()||n.fileName,m=e.getAllSkills().find(S=>String(S?.name||"").trim()===l);return m?e.updateSkill(m.id,{name:l,apps:i}):e.installSkill({sourceDir:o,name:l,apps:i})}export{k as atomicWriteFile,z as atomicWriteJsonFile,A as downloadSkillZip,N as ensureDir,M as ensureDirectoryExists,y as escapePowerShellLiteral,D as extractSkillZip,Z as installSkillPackageToSdk,q as resolveSkillSourceDir,F as resolveSkillSourceDirFromExtractRoot,h as runCommand,j as stringifyStableJson,B as toSdkAppsFromEnabledTools,W as withFileLock};
1
+ import{spawn as E}from"node:child_process";import{createHash as h}from"node:crypto";import{createWriteStream as B,mkdirSync as b,renameSync as z,rmSync as U,writeFileSync as k}from"node:fs";import{promises as c}from"node:fs";import a from"node:path";import{Readable as T,Transform as y}from"node:stream";import{pipeline as v}from"node:stream/promises";import F from"unzipper";import S from"axios";import{DEFAULT_SCHEDULER_BASE_URL as L,schedulerBaseUrl as _}from"../config.js";import{getRuntimeAccessToken as p,loadRuntimeBinding as A}from"../services/runtime-binding.js";const d=new Map;function g(){const e=String(process.env.AWS_RUNTIME_SCHEDULER_BASE_URL||"").trim();if(e)return e;const t=A(),r=String(t.schedulerBaseUrl||"").trim();return t.status==="paired"&&r?r:_||L}async function W(e){return await c.mkdir(e,{recursive:!0}),e}async function Y(e,t){const r=a.resolve(e),n=d.get(r)??Promise.resolve();let i;const o=new Promise(m=>{i=m}),s=n.then(()=>o);d.set(r,s),await n;try{return await t()}finally{i(),d.get(r)===s&&d.delete(r)}}function j(e){if(!e||typeof e!="object")return!1;const t=Object.getPrototypeOf(e);return t===Object.prototype||t===null}function w(e){return Array.isArray(e)?e.map(t=>w(t)):j(e)?Object.keys(e).sort().reduce((t,r)=>(t[r]=w(e[r]),t),{}):e}function N(e){return`${JSON.stringify(w(e),null,2)}
2
+ `}function P(e){return String(e??"").replace(/[^a-zA-Z0-9_.-]/g,"_").replace(/^\.+/g,"").slice(0,128)}function x(e,t){const r=String(e??"").trim();if(!r||/[\\/]/.test(r))return t;const n=a.basename(r);return!n||n==="."||n===".."?t:n}async function C(e,t){await W(a.dirname(e));const r=a.dirname(e),n=a.basename(e),i=a.join(r,`.${n}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`);try{await c.writeFile(i,t,"utf-8"),await c.rename(i,e)}catch(o){throw await c.rm(i,{force:!0}).catch(()=>{}),o}}function ee(e,t){b(a.dirname(e),{recursive:!0});const r=a.dirname(e),n=a.basename(e),i=a.join(r,`.${n}.tmp-${process.pid}-${Date.now()}-${Math.random().toString(16).slice(2)}`);try{k(i,t,"utf-8"),z(i,e)}catch(o){try{U(i,{force:!0})}catch{}throw o}}async function re(e,t){await C(e,N(t))}async function te(e,t){if(!e||!e.downloadUrl)return null;const r=String(e.downloadUrl).trim();if(!r)return null;const n=g();let i=r;i.startsWith("/")&&(i=`${n}${i}`);const o=x(e.fileName,"skill-package.zip"),s=a.join(t,o),m=p(n)||p();if(!m)throw new Error("runtime access token is required to download skill package");const l=await S.get(i,{responseType:"arraybuffer",timeout:3e4,headers:{"X-Runtime-Token":m}}),u=Buffer.from(l.data);if(await c.writeFile(s,u),e.sha256&&h("sha256").update(u).digest("hex")!==String(e.sha256).trim().toLowerCase())throw new Error("skill zip checksum mismatch");return{fileName:o,outputPath:s,bytes:u.length}}async function ne(e,t){await new Promise((r,n)=>{const i=E(e,t,{stdio:["ignore","pipe","pipe"]});let o="";i.stderr?.on("data",s=>{o+=String(s||"")}),i.on("error",s=>{n(s)}),i.on("close",s=>{if(s!==0){n(new Error(o||`${e} exited with code ${s}`));return}r()})})}function ie(e){return String(e||"").replace(/'/g,"''")}const f={maxEntries:2e3,maxFileBytes:100*1024*1024,maxTotalBytes:200*1024*1024,maxPathLength:400,maxPathDepth:24};function D(e,t){const r=String(t||"").replace(/\\/g,"/");if(!r||r.startsWith("/")||/^[A-Za-z]:/.test(r)||r.split("/").includes(".."))throw new Error(`skill zip \u6761\u76EE\u8DEF\u5F84\u975E\u6CD5: ${t}`);if(r.length>f.maxPathLength)throw new Error(`skill zip \u6761\u76EE\u8DEF\u5F84\u8FC7\u957F: ${t}`);if(r.split("/").filter(Boolean).length>f.maxPathDepth)throw new Error(`skill zip \u6761\u76EE\u8DEF\u5F84\u8FC7\u6DF1: ${t}`);const n=a.resolve(e,r),i=a.resolve(e)+a.sep;if(n!==a.resolve(e)&&!n.startsWith(i))throw new Error(`skill zip \u6761\u76EE\u8D8A\u754C\uFF08zip-slip\uFF09: ${t}`);return n}function I(e,t){let r=0;return new y({transform(n,i,o){if(r+=n.length,r>e){o(new Error(`${t} \u8D85\u51FA\u4E0A\u9650\uFF08${e} \u5B57\u8282\uFF09`));return}o(null,n)}})}function O(e,t){let r=0;return{transform(){return new y({transform(n,i,o){if(r+=n.length,r>e){o(new Error(`${t} \u8D85\u51FA\u603B\u91CF\u4E0A\u9650\uFF08${e} \u5B57\u8282\uFF09`));return}o(null,n)}})}}}async function oe(e,t){await c.rm(t,{recursive:!0,force:!0}),await c.mkdir(t,{recursive:!0});const r=await c.readFile(e),n=T.from([r]),i=n.pipe(F.Parse({forceStream:!0}));let o=0,s=0;const m=O(f.maxTotalBytes,"skill zip \u89E3\u538B\u603B\u91CF");try{for await(const l of i){const u=D(t,l.path);if(l.type==="Directory"){await c.mkdir(u,{recursive:!0}),l.autodrain?.();continue}if(l.type!=="File"){l.autodrain?.();continue}if(o++,o>f.maxEntries)throw new Error(`skill zip \u6761\u76EE\u6570\u8D85\u51FA\u4E0A\u9650\uFF08${f.maxEntries}\uFF09`);if(s+=Number(l.size??0),s>f.maxTotalBytes)throw new Error(`skill zip \u603B\u91CF\u8D85\u51FA\u4E0A\u9650\uFF08${f.maxTotalBytes} \u5B57\u8282\uFF09`);await c.mkdir(a.dirname(u),{recursive:!0}),await v(l,I(f.maxFileBytes,`skill zip \u6761\u76EE ${l.path}`),m.transform(),B(u))}}catch(l){throw await c.rm(t,{recursive:!0,force:!0}).catch(()=>{}),l}finally{n.destroy(),i.destroy?.()}}async function se(e){const r=(await c.readdir(e,{withFileTypes:!0})).filter(n=>!n.name.startsWith("."));return r.length===1&&r[0].isDirectory()?a.join(e,r[0].name):e}async function ae(e,t){if(!e||!e.downloadUrl)return null;const r=String(e.downloadUrl).trim();if(!r)return null;const n=g();let i=r;i.startsWith("/")&&(i=`${n}${i}`);const o=x(e.fileName,"plugin-package.zip"),s=a.join(t,o),m=p(n)||p();if(!m)throw new Error("runtime access token is required to download plugin package");const l=await S.get(i,{responseType:"arraybuffer",timeout:3e4,headers:{"X-Runtime-Token":m}}),u=Buffer.from(l.data);if(await c.writeFile(s,u),e.sha256&&h("sha256").update(u).digest("hex")!==String(e.sha256).trim().toLowerCase())throw new Error(`plugin package sha256 mismatch: ${o}`);return{fileName:o,outputPath:s,bytes:u.length}}export{C as atomicWriteFile,ee as atomicWriteFileSync,re as atomicWriteJsonFile,ae as downloadPluginZip,te as downloadSkillZip,W as ensureDir,ie as escapePowerShellLiteral,oe as extractSkillZip,se as resolveSkillSourceDirFromExtractRoot,ne as runCommand,P as sanitizeAgentId,x as sanitizeArchiveFileName,N as stringifyStableJson,Y as withFileLock};
3
3
 
@@ -1,38 +1,2 @@
1
-
2
- import type { LegacyMcpStateItem, McpPayload, McpServerConfig, SdkApps } from '../types.js';
3
- import type { McpServerSpec } from '@cc-switch/sdk';
4
-
5
- export declare function buildMcpConfigContent(mcpServers: LegacyMcpStateItem[]): string;
6
-
1
+ import type { McpPayload } from "../types.js";
7
2
  export declare function normalizeMcpPayload(payload: unknown): McpPayload | null;
8
-
9
- export declare function normalizeSdkAppFlags(rawApps: unknown): SdkApps | undefined;
10
-
11
- export declare function normalizeSdkMcpServerSpec(rawMcp: unknown): McpServerSpec;
12
-
13
- export interface McpServerFromSdk {
14
- id?: string;
15
- name?: string;
16
- server?: McpServerConfig;
17
- apps?: SdkApps;
18
- }
19
-
20
- export declare function toLegacyMcpStateItem(mcpServer: McpServerFromSdk): LegacyMcpStateItem;
21
-
22
- export declare function toLegacySkillStateItem(skill: {
23
- id?: string;
24
- name?: string;
25
- directory?: string;
26
- sourceDir?: string;
27
- filePath?: string;
28
- apps?: SdkApps;
29
- installedAt?: string | number;
30
- }): {
31
- id: string;
32
- name: string;
33
- fileName: string;
34
- filePath: string;
35
- bytes: number;
36
- apps?: SdkApps;
37
- installedAt: string;
38
- };
@@ -1,2 +1,2 @@
1
- import s from"node:path";import{randomUUID as c}from"node:crypto";import{parseBoolean as a}from"./validation.js";function u(n){const e=Array.isArray(n)?n:[],o={};for(const t of e){if(!t||!a(t.enabled,!0))continue;const r=String(t.name||"").trim();if(!r)continue;const i={transport:String(t.transport||"stdio").trim().toLowerCase()};t.command!=null&&String(t.command).trim()&&(i.command=String(t.command).trim()),t.url!=null&&String(t.url).trim()&&(i.url=String(t.url).trim()),t.args!=null&&(i.args=Array.isArray(t.args)?t.args:[]),t.env!=null&&typeof t.env=="object"&&(i.env=t.env),o[r]=i}return JSON.stringify({mcpServers:o},null,2)}function g(n){if(!n||typeof n!="object")return null;const e=n,o=String(e.name||"").trim();return o?{id:String(e.id||c()),name:o,transport:String(e.transport||"stdio").trim().toLowerCase(),command:e.command==null?"":String(e.command),url:e.url==null?"":String(e.url),args:Array.isArray(e.args)?e.args.map(t=>String(t)):[],env:e.env&&typeof e.env=="object"?e.env:{},enabled:a(e.enabled,!0),installedAt:e.installedAt||new Date().toISOString()}:null}function f(n){if(!n||typeof n!="object")return;const e=n,o=a(e.claudecode,!1)||a(e.claude,!1);return{acode:a(e.acode,!1),claude:!1,claudecode:o,codex:a(e.codex,!1),gemini:a(e.gemini,!1),opencode:a(e.opencode,!1),openclaw:a(e.openclaw,!1)}}function S(n){const e=n&&typeof n=="object"?n:{},o=e.server&&typeof e.server=="object"?e.server:{},t=String(o.type||e.transport||"stdio").trim().toLowerCase(),r={...o,type:t};return e.command!=null&&String(e.command).trim()&&(r.command=String(e.command).trim()),e.url!=null&&String(e.url).trim()&&(r.url=String(e.url).trim()),e.args!=null&&(r.args=Array.isArray(e.args)?e.args.map(l=>String(l)):[]),e.env!=null&&typeof e.env=="object"&&(r.env=e.env),e.headers!=null&&typeof e.headers=="object"&&(r.headers=e.headers),r}function y(n){const e=n?.server&&typeof n.server=="object"?n.server:{},o=n?.apps&&typeof n.apps=="object"?n.apps:{};return{id:String(n?.id||c()),name:String(n?.name||"").trim(),transport:String(e.type||"stdio").trim().toLowerCase(),command:e.command==null?"":String(e.command),url:e.url==null?"":String(e.url),args:Array.isArray(e.args)?e.args.map(t=>String(t)):[],env:e.env&&typeof e.env=="object"?e.env:{},enabled:!!(o.acode||o.claudecode||o.codex||o.gemini||o.opencode||o.openclaw),apps:{acode:!!o.acode,claude:!1,claudecode:!!o.claudecode,codex:!!o.codex,gemini:!!o.gemini,opencode:!!o.opencode,openclaw:!!o.openclaw},installedAt:new Date().toISOString()}}function v(n){const e=String(n?.directory||n?.sourceDir||n?.filePath||"").trim(),o=n?.apps&&typeof n.apps=="object"?n.apps:{};return{id:String(n?.id||c()),name:String(n?.name||s.basename(e||"skill")).trim(),fileName:e?s.basename(e):"",filePath:e,bytes:0,apps:{acode:!!o.acode,claude:!1,claudecode:!!o.claudecode,codex:!!o.codex,gemini:!!o.gemini,opencode:!!o.opencode,openclaw:!!o.openclaw},installedAt:n?.installedAt?new Date(n.installedAt).toISOString():new Date().toISOString()}}export{u as buildMcpConfigContent,g as normalizeMcpPayload,f as normalizeSdkAppFlags,S as normalizeSdkMcpServerSpec,y as toLegacyMcpStateItem,v as toLegacySkillStateItem};
1
+ import{randomUUID as o}from"node:crypto";import{parseBoolean as a}from"./validation.js";function m(n){if(!n||typeof n!="object")return null;const r=n,t=String(r.name||"").trim();return t?{id:String(r.id||o()),name:t,transport:String(r.transport||"stdio").trim().toLowerCase(),command:r.command==null?"":String(r.command),url:r.url==null?"":String(r.url),args:Array.isArray(r.args)?r.args.map(e=>String(e)):[],env:r.env&&typeof r.env=="object"?r.env:{},enabled:a(r.enabled,!0),installedAt:r.installedAt||new Date().toISOString()}:null}export{m as normalizeMcpPayload};
2
2
 
@@ -1,4 +1,4 @@
1
- import{randomUUID as nt}from"node:crypto";import{promises as m,createReadStream as G}from"node:fs";import it from"node:os";import d from"node:path";import X from"node:readline";import{runShellCommand as at}from"./builtins/shellCommandRunner.js";import{createOutputEventCollector as rt}from"./builtins/commandOutputEvents.js";import{symbolsTool as st}from"./built-in-symbols-tool.js";import{createListBackgroundCommandsTool as ct,createKillBackgroundCommandTool as lt,createReadBackgroundOutputTool as ut}from"./background-command-tools.js";import{detectImageFormatFromBuffer as dt,formatBytes as T,imageMediaType as Y,readImageDimensions as pt,tryResizeWithSharp as ht}from"./image-utils.js";const ft=2e3,O=2e3,mt=50*1024,H=4096,wt=.3,gt=new Set([".png",".jpg",".jpeg",".gif",".bmp",".ico",".webp",".tiff",".tif",".zip",".gz",".tar",".rar",".7z",".bz2",".xz",".lz",".exe",".dll",".so",".dylib",".bin",".o",".a",".pdf",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".mp3",".mp4",".avi",".mov",".wav",".flv",".mkv",".ogg",".woff",".woff2",".ttf",".otf",".eot",".class",".jar",".war",".ear",".pyc",".pyo",".node",".sqlite",".db",".mdb",".wasm"]),_t=new Set(["png","jpg","jpeg","gif","webp"]),K=20*1024*1024,L=10*1024*1024,U=Math.floor(3.75*1024*1024),C=2e3,yt=15e3,bt=1e3,kt=1024*1024,Pt=256*1024,Et=1e3,vt=new Set([".git","node_modules","dist","build",".next",".nuxt",".cache",".turbo",".output","coverage",".nyc_output"]),te={fileReadOutside:"allow",commandExecution:"allow",fileModification:"allow"};async function F(n,o,e){if(!n)return;const t=n.getLevel(o);if(t==="deny")throw new Error(`Operation blocked by tool permission policy (${o} = deny). Explain this restriction to the user if needed.`);if(t==="ask"&&!await n.requestPermission(o,e))throw new Error(`Operation denied by the user (${o}). Do not retry the same operation without asking the user.`)}function v(n){return n.replace(/\\/g,"/")}async function V(n){try{return await m.access(n),!0}catch{return!1}}function xt(n,o){if(!o)return 0;let e=0,t=n.indexOf(o);for(;t>=0;)e+=1,t=n.indexOf(o,t+o.length);return e}function $(n,o,e){for(const t of o){const i=n[t];if(typeof i=="string")return i}throw new Error(`${e} is required`)}function I(n,o){for(const e of o){const t=n[e];if(typeof t=="string"&&t.trim())return t}}function B(n,o,e){for(const t of o){const i=n[t],s=typeof i=="number"?i:typeof i=="string"?Number(i):NaN;if(Number.isFinite(s)&&s>0)return Math.floor(s)}return e}async function Z(n){const o=d.extname(n).toLowerCase();if(gt.has(o))return!0;const e=await m.open(n,"r");try{const t=Buffer.alloc(H),{bytesRead:i}=await e.read(t,0,H,0);if(i===0)return!1;const s=t.subarray(0,i);if(s.includes(0))return!0;let r=0;for(let a=0;a<i;a++){const c=s[a];(c<9||c>13&&c<32)&&r++}return r/i>wt}finally{await e.close()}}function M(n,o){const e=d.resolve(o),t=d.relative(n,e);if(t.startsWith("..")||d.isAbsolute(t))throw new Error(`Target path is outside workspace: ${e}`);return e}function D(n){return n==="~"||n.startsWith("~/")?d.join(it.homedir(),n.slice(1)):n}async function Tt(n,o){const e=d.resolve(String(n||"").trim()),t=await m.realpath(e);if(!(await m.stat(t)).isDirectory())throw new Error(`Workspace path is not a directory: ${e}`);if(!o?.trim())return{workspaceRoot:t,cwd:t};const s=D(o.trim()),r=d.isAbsolute(s)?d.resolve(s):d.resolve(e,s),a=d.relative(e,r);if(a.startsWith("..")||d.isAbsolute(a))throw new Error(`Command cwd is outside workspace: ${r}`);const c=M(t,await m.realpath(r));if(!(await m.stat(c)).isDirectory())throw new Error(`Command cwd is not a directory: ${c}`);return{workspaceRoot:t,cwd:c}}async function Rt(n,o){const e=await m.realpath(d.dirname(o));M(n,e);try{if((await m.lstat(o)).isSymbolicLink())throw new Error(`Refusing to write through symbolic link: ${o}`)}catch(t){if((typeof t=="object"&&t!==null?Reflect.get(t,"code"):void 0)!=="ENOENT")throw t}}async function A(n,o){const e=d.resolve(String(n||"").trim()),t=await m.realpath(e);if(!(await m.stat(t)).isDirectory())throw new Error(`Workspace path is not a directory: ${e}`);const s=D(o.trim());if(!s)throw new Error("file_path is required");const r=d.isAbsolute(s)?d.resolve(s):d.resolve(e,s),a=d.relative(e,r);if(a.startsWith("..")||d.isAbsolute(a))throw new Error(`Target path is outside workspace: ${r}`);return{workspaceRoot:t,requestedPath:r,targetPath:M(t,d.join(t,a))}}async function J(n,o,e){const t=d.resolve(String(n||"").trim()),i=await m.realpath(t);if(!(await m.stat(i)).isDirectory())throw new Error(`Workspace path is not a directory: ${t}`);const r=D(o.trim());if(!r)throw new Error("file_path is required");const a=d.isAbsolute(r)?d.resolve(r):d.resolve(t,r),c=d.relative(t,a),u=await m.realpath(a).catch(()=>a),l=d.relative(i,u);if(c.startsWith("..")||d.isAbsolute(c)||l.startsWith("..")||d.isAbsolute(l)){if(!e)throw new Error(`Target path is outside workspace: ${a}`);return await F(e,"fileReadOutside",{path:a}),{workspaceRoot:i,requestedPath:a,targetPath:u}}return{workspaceRoot:i,requestedPath:a,targetPath:M(i,u)}}async function Q(n,o,e){const t=await A(n,o),i=d.dirname(t.targetPath),s=!await V(i);await m.mkdir(i,{recursive:!0}),await Rt(t.workspaceRoot,t.targetPath);const r=d.join(i,`.${d.basename(t.targetPath)}.${process.pid}.${nt()}.tmp`);try{await m.writeFile(r,e,"utf-8"),await m.rename(r,t.targetPath)}catch(a){throw await m.rm(r,{force:!0}),a}return{workspaceRoot:t.workspaceRoot,targetPath:t.targetPath,bytes:Buffer.byteLength(e,"utf-8"),createdParentDirectory:s}}async function $t(n,o){const e=await A(n,o),t=M(e.workspaceRoot,await m.realpath(e.targetPath));if(!(await m.stat(t)).isFile())throw new Error(`Path is not a file: ${t}`);return{workspaceRoot:e.workspaceRoot,targetPath:t,content:await m.readFile(t,"utf-8")}}async function St(n,o,e,t,i){const s=await J(n,o,i),r=s.targetPath;if(!(await m.stat(r)).isFile())throw new Error(`Path is not a file: ${r}`);if(await Z(r))return{workspaceRoot:s.workspaceRoot,targetPath:r,content:"[Binary file, content skipped]",isBinary:!0,truncated:!1,totalLines:0,shownFromLine:0,shownToLine:0};const c=G(r,{encoding:"utf-8"}),u=X.createInterface({input:c,crlfDelay:1/0});try{const l=[];let w=0,h=0,g=0,p=!1,P=!1;const f=e-1;for await(const _ of u){if(h++,w<f){w++;continue}if(l.length>=t){p=!0,w++;continue}let R=_;R.length>O&&(R=R.slice(0,O)+`... (line truncated to ${O} chars)`);const S=`${w+1}: ${R}`,x=Buffer.byteLength(S,"utf-8")+1;if(g+x>mt){P=!0;break}l.push(S),g+=x,w++}if(h>0&&l.length===0&&!p&&!P&&f>=h)throw new Error(`offset ${e} exceeds total line count ${h} in file: ${r}`);const y=l.length>0?e:0,E=l.length>0?e+l.length-1:0;let b;P?b=`Output capped at 50 KB. Showing lines ${y}-${E}. Use offset=${E+1} to continue.`:p?b=`Showing lines ${y}-${E} of ${h}. Use offset=${E+1} to continue.`:b=`End of file - total ${h} lines`;const k=l.length>0?l.join(`
1
+ import{randomUUID as nt}from"node:crypto";import{promises as m,createReadStream as G}from"node:fs";import it from"node:os";import d from"node:path";import X from"node:readline";import{runShellCommand as at}from"./builtins/shellCommandRunner.js";import{createOutputEventCollector as rt}from"./builtins/commandOutputEvents.js";import{symbolsTool as st}from"./built-in-symbols-tool.js";import{createListBackgroundCommandsTool as ct,createKillBackgroundCommandTool as lt,createReadBackgroundOutputTool as ut}from"./background-command-tools.js";import{detectImageFormatFromBuffer as dt,formatBytes as x,imageMediaType as Y,readImageDimensions as ht,tryResizeWithSharp as pt}from"./image-utils.js";const ft=2e3,O=2e3,mt=50*1024,H=4096,wt=.3,gt=new Set([".png",".jpg",".jpeg",".gif",".bmp",".ico",".webp",".tiff",".tif",".zip",".gz",".tar",".rar",".7z",".bz2",".xz",".lz",".exe",".dll",".so",".dylib",".bin",".o",".a",".pdf",".doc",".docx",".xls",".xlsx",".ppt",".pptx",".mp3",".mp4",".avi",".mov",".wav",".flv",".mkv",".ogg",".woff",".woff2",".ttf",".otf",".eot",".class",".jar",".war",".ear",".pyc",".pyo",".node",".sqlite",".db",".mdb",".wasm"]),_t=new Set(["png","jpg","jpeg","gif","webp"]),K=20*1024*1024,L=10*1024*1024,U=Math.floor(3.75*1024*1024),C=2e3,yt=15e3,bt=1e3,kt=1024*1024,Et=256*1024,Pt=1e3,vt=new Set([".git","node_modules","dist","build",".next",".nuxt",".cache",".turbo",".output","coverage",".nyc_output"]),te={fileReadOutside:"allow",commandExecution:"allow",fileModification:"allow"};async function F(n,o,e){if(!n)return;const t=n.getLevel(o);if(t==="deny")throw new Error(`Operation blocked by tool permission policy (${o} = deny). Explain this restriction to the user if needed.`);if(t==="ask"&&!await n.requestPermission(o,e))throw new Error(`Operation denied by the user (${o}). Do not retry the same operation without asking the user.`)}function $(n){return n.replace(/\\/g,"/")}async function V(n){try{return await m.access(n),!0}catch{return!1}}function xt(n,o){if(!o)return 0;let e=0,t=n.indexOf(o);for(;t>=0;)e+=1,t=n.indexOf(o,t+o.length);return e}function R(n,o,e){for(const t of o){const i=n[t];if(typeof i=="string")return i}throw new Error(`${e} is required`)}function I(n,o){for(const e of o){const t=n[e];if(typeof t=="string"&&t.trim())return t}}function B(n,o,e){for(const t of o){const i=n[t],s=typeof i=="number"?i:typeof i=="string"?Number(i):NaN;if(Number.isFinite(s)&&s>0)return Math.floor(s)}return e}async function Z(n){const o=d.extname(n).toLowerCase();if(gt.has(o))return!0;const e=await m.open(n,"r");try{const t=Buffer.alloc(H),{bytesRead:i}=await e.read(t,0,H,0);if(i===0)return!1;const s=t.subarray(0,i);if(s.includes(0))return!0;let a=0;for(let r=0;r<i;r++){const c=s[r];(c<9||c>13&&c<32)&&a++}return a/i>wt}finally{await e.close()}}function M(n,o){const e=d.resolve(o),t=d.relative(n,e);if(t.startsWith("..")||d.isAbsolute(t))throw new Error(`Target path is outside workspace: ${e}`);return e}function D(n){return n==="~"||n.startsWith("~/")?d.join(it.homedir(),n.slice(1)):n}async function Tt(n,o){const e=d.resolve(String(n||"").trim()),t=await m.realpath(e);if(!(await m.stat(t)).isDirectory())throw new Error(`Workspace path is not a directory: ${e}`);if(!o?.trim())return{workspaceRoot:t,cwd:t};const s=D(o.trim()),a=d.isAbsolute(s)?d.resolve(s):d.resolve(e,s),r=d.relative(e,a);if(r.startsWith("..")||d.isAbsolute(r))throw new Error(`Command cwd is outside workspace: ${a}`);const c=M(t,await m.realpath(a));if(!(await m.stat(c)).isDirectory())throw new Error(`Command cwd is not a directory: ${c}`);return{workspaceRoot:t,cwd:c}}async function $t(n,o){const e=await m.realpath(d.dirname(o));M(n,e);try{if((await m.lstat(o)).isSymbolicLink())throw new Error(`Refusing to write through symbolic link: ${o}`)}catch(t){if((typeof t=="object"&&t!==null?Reflect.get(t,"code"):void 0)!=="ENOENT")throw t}}async function A(n,o){const e=d.resolve(String(n||"").trim()),t=await m.realpath(e);if(!(await m.stat(t)).isDirectory())throw new Error(`Workspace path is not a directory: ${e}`);const s=D(o.trim());if(!s)throw new Error("file_path is required");const a=d.isAbsolute(s)?d.resolve(s):d.resolve(e,s),r=d.relative(e,a);if(r.startsWith("..")||d.isAbsolute(r))throw new Error(`Target path is outside workspace: ${a}`);return{workspaceRoot:t,requestedPath:a,targetPath:M(t,d.join(t,r))}}async function J(n,o,e){const t=d.resolve(String(n||"").trim()),i=await m.realpath(t);if(!(await m.stat(i)).isDirectory())throw new Error(`Workspace path is not a directory: ${t}`);const a=D(o.trim());if(!a)throw new Error("file_path is required");const r=d.isAbsolute(a)?d.resolve(a):d.resolve(t,a),c=d.relative(t,r),u=await m.realpath(r).catch(()=>r),l=d.relative(i,u);if(c.startsWith("..")||d.isAbsolute(c)||l.startsWith("..")||d.isAbsolute(l)){if(!e)throw new Error(`Target path is outside workspace: ${r}`);return await F(e,"fileReadOutside",{path:r}),{workspaceRoot:i,requestedPath:r,targetPath:u}}return{workspaceRoot:i,requestedPath:r,targetPath:M(i,u)}}async function Q(n,o,e){const t=await A(n,o),i=d.dirname(t.targetPath),s=!await V(i);await m.mkdir(i,{recursive:!0}),await $t(t.workspaceRoot,t.targetPath);const a=d.join(i,`.${d.basename(t.targetPath)}.${process.pid}.${nt()}.tmp`);try{await m.writeFile(a,e,"utf-8"),await m.rename(a,t.targetPath)}catch(r){throw await m.rm(a,{force:!0}),r}return{workspaceRoot:t.workspaceRoot,targetPath:t.targetPath,bytes:Buffer.byteLength(e,"utf-8"),createdParentDirectory:s}}async function Rt(n,o){const e=await A(n,o),t=M(e.workspaceRoot,await m.realpath(e.targetPath));if(!(await m.stat(t)).isFile())throw new Error(`Path is not a file: ${t}`);return{workspaceRoot:e.workspaceRoot,targetPath:t,content:await m.readFile(t,"utf-8")}}async function St(n,o,e,t,i){const s=await J(n,o,i),a=s.targetPath;if(!(await m.stat(a)).isFile())throw new Error(`Path is not a file: ${a}`);if(await Z(a))return{workspaceRoot:s.workspaceRoot,targetPath:a,content:"[Binary file, content skipped]",isBinary:!0,truncated:!1,totalLines:0,shownFromLine:0,shownToLine:0};const c=G(a,{encoding:"utf-8"}),u=X.createInterface({input:c,crlfDelay:1/0});try{const l=[];let w=0,p=0,_=0,h=!1,k=!1;const f=e-1;for await(const g of u){if(p++,w<f){w++;continue}if(l.length>=t){h=!0,w++;continue}let T=g;T.length>O&&(T=T.slice(0,O)+`... (line truncated to ${O} chars)`);const S=`${w+1}: ${T}`,v=Buffer.byteLength(S,"utf-8")+1;if(_+v>mt){k=!0;break}l.push(S),_+=v,w++}if(p>0&&l.length===0&&!h&&!k&&f>=p)throw new Error(`offset ${e} exceeds total line count ${p} in file: ${a}`);const y=l.length>0?e:0,b=l.length>0?e+l.length-1:0;let E;k?E=`Output capped at 50 KB. Showing lines ${y}-${b}. Use offset=${b+1} to continue.`:h?E=`Showing lines ${y}-${b} of ${p}. Use offset=${b+1} to continue.`:E=`End of file - total ${p} lines`;const P=l.length>0?l.join(`
2
2
  `)+`
3
- `+b:b;return{workspaceRoot:s.workspaceRoot,targetPath:r,content:k,isBinary:!1,truncated:p||P,totalLines:P?-1:h,shownFromLine:y,shownToLine:E}}finally{u.close(),c.destroy()}}function W(n){return/^https?:\/\//i.test(n)}async function It(n){let o;try{o=new URL(n)}catch{throw new Error(`Invalid image URL: ${n}`)}if(o.protocol!=="http:"&&o.protocol!=="https:")throw new Error(`Unsupported image URL protocol: ${o.protocol} (only http/https)`);let e;try{e=await fetch(n,{signal:AbortSignal.timeout(yt)})}catch(u){const l=u instanceof Error?u.message:String(u);throw new Error(`Image URL fetch failed: ${n} (${l})`)}if(!e.ok)throw new Error(`Image URL fetch failed: ${n} (HTTP ${e.status})`);const t=(e.headers.get("content-type")||"").split(";")[0]?.trim().toLowerCase()||"";if(t&&!t.startsWith("image/"))throw new Error(`URL did not return an image (content-type: ${t}): ${n}`);const i=Number(e.headers.get("content-length")||"");if(Number.isFinite(i)&&i>L)throw new Error(`Image too large to fetch: ${n} (${T(i)} > ${T(L)})`);const s=e.body;if(!s){const u=await e.arrayBuffer();if(u.byteLength>L)throw new Error(`Image too large to fetch: ${n} (${T(u.byteLength)} > ${T(L)})`);return Buffer.from(u)}const r=s.getReader(),a=[];let c=0;for(;;){const{done:u,value:l}=await r.read();if(u)break;if(l){if(c+=l.byteLength,c>L)throw r.cancel().catch(()=>{}),new Error(`Image too large to fetch: ${n} (${T(c)} > ${T(L)})`);a.push(Buffer.from(l))}}return Buffer.concat(a,c)}async function Mt(n,o,e){let t,i,s;if(W(o))t=await It(o),i=o;else{const E=await J(n,o,e),b=E.targetPath,k=await m.stat(b);if(!k.isFile())throw new Error(`Path is not a file: ${b}`);if(k.size>K)throw new Error(`Image file too large to read: ${v(b)} (${T(k.size)} > ${T(K)}). Downscale it first.`);t=await m.readFile(b),i=v(b),s=v(E.workspaceRoot)}if(t.length===0)throw new Error(`Image file is empty: ${i}`);const r=dt(t);if(!r)throw new Error(`Unsupported or corrupt image (unrecognized format): ${i}`);const a=pt(t);let c=r,u=t,l=a?.width,w=a?.height,h=!1;const g=await ht(t,r,{maxWidth:C,maxHeight:C,maxBytes:U});if(g)u=g.buffer,c=g.mediaType,l=g.width,w=g.height,h=g.changed;else if(t.length>U)throw new Error(`Image too large to inline: ${i} (${T(t.length)} > ${T(U)}). Downscale it first, e.g. via Bash: magick "${o}" -resize ${C}x${C} "${o}". Installing sharp enables automatic downscaling.`);const p=l&&w?`${l}x${w}`:"unknown dimensions",P=h&&a&&a.width!==l?` (resized from ${a.width}x${a.height})`:h?" (resized)":"",f=`[Image: ${i}, ${p}${P}, ${T(u.length)}]`,y=W(o)?d.basename(new URL(o).pathname)||"image":d.basename(i);return{ok:!0,tool:"read_file",...s!==void 0?{workspacePath:s}:{},filePath:i,content:f,isBinary:!1,image:{mediaType:Y(c),width:l??null,height:w??null,originalWidth:a?.width??null,originalHeight:a?.height??null,resized:h,size:u.length},attachments:[{type:"image",name:y,mediaType:Y(c),base64Data:u.toString("base64")}]}}function tt(n){let o="",e=0;for(;e<n.length;){const t=n[e];if(t==="*")o+="[^/]*";else if(t==="?")o+="[^/]";else if(t==="{"){const i=n.indexOf("}",e);if(i>=0){const s=n.slice(e+1,i);o+=`(${s.split(",").join("|")})`,e=i}else o+="\\{"}else if(t==="["){const i=n.indexOf("]",e);i>=0?(o+=n.slice(e,i+1),e=i):o+="\\["}else"+^$.()|\\".includes(t)?o+="\\"+t:o+=t;e++}return new RegExp(`^${o}$`)}async function Ot(n,o,e,t){const i=[];async function s(r){if(i.length>=t)return;const a=await m.readdir(r,{withFileTypes:!0});for(const c of a){if(i.length>=t)return;if(c.name.startsWith(".")&&c.isDirectory())continue;const u=d.join(r,c.name);if(c.isDirectory()){if(vt.has(c.name))continue;await s(u)}else if(c.isFile()){if(o&&!o.test(c.name)||e&&e.test(c.name))continue;i.push(u)}}}return await s(n),i}async function Lt(n,o,e){if((await m.stat(n)).size>kt)return{matches:[],count:0};if(await Z(n))return{matches:[],count:0};const i=d.relative(o,n).replace(/\\/g,"/"),s=[];let r=0;const a=G(n,{encoding:"utf-8"}),c=X.createInterface({input:a,crlfDelay:1/0});try{let u=0;for await(const l of c)if(u++,e.regex.test(l)){if(r++,e.collectContent){let w=l;if(w.length>O&&(w=w.slice(0,O)+`... (line truncated to ${O} chars)`),s.push({file:i,line:u,content:w}),s.length>=e.maxResults)break}if(e.stopOnFirstMatch)break}}finally{c.close(),a.destroy()}return{matches:s,count:r}}const et=10*6e4,At=et,Ft=6e4,Bt=10*6e4;function Nt(n,o,e){return{kind:"builtin",toolName:"write_file",exposedName:"write_file",description:"Create or overwrite a UTF-8 text file inside the current workspace. Parent directories are created automatically.",inputSchema:{type:"object",properties:{file_path:{type:"string",description:"Workspace-relative file path to write."},content:{type:"string",description:"Complete UTF-8 file content."},reason:{type:"string",description:"Optional reason for this change, e.g. what bug is being fixed. Helps humans understand the change later."}},required:["file_path","content"],additionalProperties:!1},async execute(t){const i=$(t,["file_path","filePath"],"file_path"),s=$(t,["content"],"content"),r=I(t,["reason"]),a=await A(n,i);await F(e,"fileModification",{operation:"write",path:a.targetPath});const c=await V(a.targetPath),u=c?await m.readFile(a.targetPath,"utf-8").catch(()=>null):null,l=await Q(n,i,s);if(o){const w=d.relative(l.workspaceRoot,l.targetPath).replace(/\\/g,"/");await o({filePath:w,operation:c?"UPDATE":"CREATE",beforeContent:u,afterContent:s,reason:r})}return{ok:!0,tool:"write_file",workspacePath:v(l.workspaceRoot),filePath:v(l.targetPath),bytes:l.bytes,createdParentDirectory:l.createdParentDirectory}}}}function Ct(n,o,e){return{kind:"builtin",toolName:"edit_file",exposedName:"edit_file",description:"Replace exactly one occurrence of old_string with new_string in a UTF-8 workspace text file.",inputSchema:{type:"object",properties:{file_path:{type:"string",description:"Workspace-relative file path to edit."},old_string:{type:"string",description:"Existing text to replace. Must occur exactly once."},new_string:{type:"string",description:"Replacement text."},reason:{type:"string",description:"Optional reason for this change, e.g. what bug is being fixed. Helps humans understand the change later."}},required:["file_path","old_string","new_string"],additionalProperties:!1},async execute(t){const i=$(t,["file_path","filePath"],"file_path"),s=$(t,["old_string","oldString"],"old_string"),r=$(t,["new_string","newString"],"new_string"),a=I(t,["reason"]);if(!s)throw new Error("old_string must not be empty");const c=await A(n,i);await F(e,"fileModification",{operation:"edit",path:c.targetPath});const u=await $t(n,i),l=xt(u.content,s);if(l===0)throw new Error("old_string was not found in file");if(l>1)throw new Error(`old_string occurs ${l} times; provide a unique match`);const w=u.content.replace(s,r),h=await Q(n,i,w);if(o){const g=d.relative(h.workspaceRoot,h.targetPath).replace(/\\/g,"/");await o({filePath:g,operation:"UPDATE",beforeContent:u.content,afterContent:w,reason:a})}return{ok:!0,tool:"edit_file",workspacePath:v(h.workspaceRoot),filePath:v(h.targetPath),replacements:1,bytes:h.bytes}}}}function Ut(n,o,e){return{kind:"builtin",toolName:"delete_file",exposedName:"delete_file",description:"Delete a file inside the current workspace. Returns an error if the file does not exist.",inputSchema:{type:"object",properties:{file_path:{type:"string",description:"Workspace-relative file path to delete."},reason:{type:"string",description:"Optional reason for this change, e.g. what bug is being fixed. Helps humans understand the change later."}},required:["file_path"],additionalProperties:!1},async execute(t){const i=$(t,["file_path","filePath"],"file_path"),s=I(t,["reason"]),r=await A(n,i);await F(e,"fileModification",{operation:"delete",path:r.targetPath});const a=M(r.workspaceRoot,await m.realpath(r.targetPath).catch(()=>r.targetPath)),c=await m.stat(a).catch(()=>null);if(!c)throw new Error(`File does not exist: ${a}`);if(!c.isFile())throw new Error(`Path is not a file: ${a}`);const u=await m.readFile(a,"utf-8").catch(()=>null);if(await m.rm(a,{force:!0}),o){const l=d.relative(r.workspaceRoot,a).replace(/\\/g,"/");await o({filePath:l,operation:"DELETE",beforeContent:u,afterContent:null,reason:s})}return{ok:!0,tool:"delete_file",workspacePath:v(r.workspaceRoot),filePath:v(a),deleted:!0}}}}function Dt(n,o){return{kind:"builtin",toolName:"read_file",exposedName:"read_file",description:"Read a UTF-8 text file inside the current workspace. Returns content with line numbers in the format '<line>: <content>'. Supports offset (1-indexed line number to start from) and limit (max lines to return, default 2000). Output is capped at 2000 lines or 50 KB, whichever is reached first. Individual lines longer than 2000 characters are truncated. Avoid tiny repeated slices (e.g. 30-line chunks); read a larger window if more context is needed. Images (.png/.jpg/.jpeg/.gif/.webp) and http(s) image URLs are also supported: the image is inlined into the conversation so you can see it (requires a model with image input). offset/limit are ignored for images; oversized images are automatically downscaled when sharp is available.",inputSchema:{type:"object",properties:{file_path:{type:"string",description:"Workspace-relative file path to read. Also accepts an http(s) URL pointing to an image."},offset:{type:"number",description:"Line number to start reading from (1-indexed). Defaults to 1."},limit:{type:"number",description:"Maximum number of lines to return. Defaults to 2000."}},required:["file_path"],additionalProperties:!1},async execute(e){const t=$(e,["file_path","filePath"],"file_path"),i=d.extname(t).toLowerCase().slice(1);if(W(t)||_t.has(i))return await Mt(n,t,o);const s=B(e,["offset"],1),r=B(e,["limit"],ft),a=await St(n,t,s,r,o);return{ok:!0,tool:"read_file",workspacePath:v(a.workspaceRoot),filePath:v(a.targetPath),content:a.content,isBinary:a.isBinary,truncated:a.truncated,totalLines:a.totalLines,shownFromLine:a.shownFromLine,shownToLine:a.shownToLine}}}}function Wt(n,o,e,t){return{kind:"builtin",toolName:"Bash",exposedName:"Bash",description:"Execute a shell command in the current workspace. Use for local diagnostics, builds, tests, and OS commands. The command runs with a bounded timeout and returns stdout, stderr, exit code, and (if interrupted) partial output. By default (wait_seconds omitted or -1) the command runs in the FOREGROUND and streams output in real time; if the 5-minute adapter watchdog fires while it is still running, the command is interrupted and the partial output produced so far is returned (large output is spilled to a file via outputFilePath to avoid context overflow), with watchdogInterrupted=true. For long-running commands use wait_seconds=0 or n>0 to run in the BACKGROUND, then manage them via list_background_commands / read_background_output / kill_background_command / await_complete.",inputSchema:{type:"object",properties:{command:{type:"string",description:"Shell command to execute."},cwd:{type:"string",description:"Optional workspace-relative working directory. Defaults to the workspace root."},timeout_ms:{type:"number",description:"Optional timeout in milliseconds. Defaults to 600000 and is capped at 600000."},inactivity_timeout_ms:{type:"number",description:"Optional no-output timeout in milliseconds. Defaults to 60000 and is capped at 600000."},wait_seconds:{type:"number",description:"How to wait for the command to finish. Omitted values (or -1, the default): run in the FOREGROUND until completion; if the 5-minute adapter watchdog fires first, the command is interrupted and only the partial output already produced is returned (watchdogInterrupted=true; large output spills to outputFilePath). 0: spawn and immediately execute in the background, return task_id. n>0: wait up to n seconds; if still running, move to the background and return task_id. Background commands remain subject to timeout_ms (total upper bound); inactivity_timeout_ms is ignored once backgrounded.",minimum:-1},description:{type:"string",description:"Optional short reason for running the command."}},required:["command"],additionalProperties:!1},async execute(i,s){const r=$(i,["command"],"command").trim();if(!r)throw new Error("command must not be empty");const a=B(i,["timeout_ms","timeoutMs"],At),c=Math.min(a,et),u=B(i,["inactivity_timeout_ms","inactivityTimeoutMs"],Ft),l=Math.min(u,Bt),w=I(i,["cwd"]),h=await Tt(n,w);await F(t,"commandExecution",{command:r,cwd:v(h.cwd)});const g=i.wait_seconds,P=typeof g=="number"&&Number.isFinite(g)?g:-1;if(P!==-1&&e)return await qt({deps:e,command:r,agentId:o,workspaceRoot:h.workspaceRoot,cwd:h.cwd,timeoutMs:c,inactivityTimeoutMs:l,waitSeconds:P,onOutput:s?.onOutput,settleSignal:s?.settleSignal});const f=await at({commandText:r,agentId:o,workspaceRoot:h.workspaceRoot,cwd:h.cwd,timeoutMs:c,inactivityTimeoutMs:l,onOutput:s?.onOutput,watchdogSignal:s?.settleSignal}),y={ok:f.exitCode===0&&!f.timedOut,tool:"Bash",command:r,cwd:v(h.cwd),exitCode:f.exitCode,signal:f.signal,timedOut:f.timedOut,inactivityTimedOut:f.inactivityTimedOut,watchdogInterrupted:f.watchdogInterrupted,timeoutMs:c,inactivityTimeoutMs:l,durationMs:f.durationMs,outputSpilled:f.outputSpilled,outputFilePath:f.outputFilePath,outputLineCount:f.outputLineCount,commandFilePath:f.commandFilePath,commandLineCount:f.commandLineCount,stdout:f.stdout,stderr:f.stderr};return f.watchdogInterrupted?{...y,message:"Command was interrupted by the adapter watchdog after ~5 minutes of synchronous (foreground) execution. Only the partial output produced so far is returned above"+(f.outputFilePath?` (full output spilled to "${f.outputFilePath}"; read it if you need more)`:"")+". For long-running commands, re-run with wait_seconds=0 (or n>0) to execute in the background, then manage via await_complete / list_background_commands / read_background_output / kill_background_command."}:y}}}async function qt(n){const{deps:o,command:e,agentId:t,workspaceRoot:i,cwd:s,timeoutMs:r,inactivityTimeoutMs:a,waitSeconds:c,onOutput:u,settleSignal:l}=n,w=u?rt({cwd:s,commandLineCount:0,onOutput:u}):void 0;let h=!!w;const g=()=>{h&&(h=!1,w?.close())};try{const{taskId:p,completion:P}=o.manager.startCommand({commandText:e,agentId:t,workspaceRoot:i,cwd:s,timeoutMs:r,inactivityTimeoutMs:a,onOutput:h?k=>{h&&w?.push(k.stream,k.text)}:void 0,onCompleted:o.emitCompleted});if(c===0)return o.manager.disableInactivityTimeout(t,p),g(),{ok:!0,tool:"Bash",command:e,backgrounded:!0,taskId:p,status:"backgrounded",reason:"immediate",message:`Command moved to background. Use await_complete(bg_cmd_ids=["${p}"]) to block until it finishes, read_background_output(task_id="${p}", mode="tail") to read output, list_background_commands to view all, or kill_background_command(task_id="${p}") to stop.`};const f=c===-1?0:Math.max(0,Math.floor(c*1e3));let y,E;c===-1?E=Promise.resolve("__never__"):E=new Promise(k=>{y=setTimeout(()=>k("__timeout__"),f),y.unref?.()});const b=l?l.then(()=>"__settle__"):Promise.resolve("__never__");try{const k=await Promise.race([P,E,b]);if(k==="__settle__")return o.manager.disableInactivityTimeout(t,p),{ok:!0,tool:"Bash",command:e,backgrounded:!0,taskId:p,status:"backgrounded",reason:"watchdog_timeout",waitedMs:f,message:`Command still running after watchdog timeout; moved to background. Use await_complete(bg_cmd_ids=["${p}"]) to block until it finishes, read_background_output(task_id="${p}", mode="tail") to read output, or kill_background_command(task_id="${p}") to stop.`};if(k==="__timeout__")return o.manager.disableInactivityTimeout(t,p),{ok:!0,tool:"Bash",command:e,backgrounded:!0,taskId:p,status:"backgrounded",reason:"timeout",waitedMs:f,message:`Command still running after ${c}s; moved to background. Use await_complete(bg_cmd_ids=["${p}"]) to block until it finishes, or read_background_output(task_id="${p}", mode="tail") / kill_background_command(task_id="${p}") to inspect.`};const _=k;return{ok:_.exitCode===0&&!_.timedOut,tool:"Bash",command:e,backgrounded:!1,taskId:p,exitCode:_.exitCode,signal:_.signal,timedOut:_.timedOut,inactivityTimedOut:_.inactivityTimedOut,timeoutMs:_.timeoutMs,inactivityTimeoutMs:_.inactivityTimeoutMs,durationMs:_.durationMs,outputSpilled:_.outputSpilled,outputFilePath:_.outputFilePath,outputLineCount:_.outputLineCount,commandFilePath:_.commandFilePath,commandLineCount:_.commandLineCount,stdout:_.stdout,stderr:_.stderr}}finally{y&&clearTimeout(y),g()}}catch(p){if(p?.code==="too_many_tasks"||p?.code==="global_limit_reached")return{ok:!1,tool:"Bash",command:e,backgrounded:!1,status:"not_executed",error:p.code,message:`Command was NOT executed: ${p.message}. Wait for some background tasks to finish/cleanup (per-agent limit 16, global 256), or reduce concurrent background commands, then retry.`};throw p}}function jt(n){return{kind:"builtin",toolName:"grep",exposedName:"grep",description:"Search file contents using regular expressions within the workspace. Returns matched lines with file paths and line numbers. Supports include/exclude glob patterns, case-insensitive matching, and three output modes (content, files_with_matches, count). Searches recursively through directories, skipping binary files, hidden directories, and common build/dependency directories (node_modules, .git, dist, etc.).",inputSchema:{type:"object",properties:{pattern:{type:"string",description:"Regular expression pattern to search for in file contents."},path:{type:"string",description:"Workspace-relative file or directory path to search in. Defaults to the workspace root."},include:{type:"string",description:"Glob pattern to filter files by name (e.g. '*.ts', '*.{js,ts}'). Only matching files are searched."},exclude:{type:"string",description:"Glob pattern to exclude files by name (e.g. '*.test.ts'). Matching files are skipped."},case_insensitive:{type:"boolean",description:"Case-insensitive matching. Default false."},output_mode:{type:"string",enum:["content","files_with_matches","count"],description:"Output format: 'content' returns matched lines with line numbers (default), 'files_with_matches' returns only file paths with matches, 'count' returns match counts per file."},max_results:{type:"number",description:"Maximum number of matched lines to return (content mode). Default 1000."}},required:["pattern"],additionalProperties:!1},async execute(o){const e=$(o,["pattern"],"pattern"),t=I(o,["path"])||".",i=I(o,["include"]),s=I(o,["exclude"]),r=o.case_insensitive===!0,a=(()=>{const x=o.output_mode;return x==="files_with_matches"||x==="count"?x:"content"})(),c=B(o,["max_results"],Et),u=r?"i":"";let l;try{l=new RegExp(e,u)}catch(x){throw new Error(`Invalid regex pattern: ${x instanceof Error?x.message:String(x)}`)}const w=i?tt(i):null,h=s?tt(s):null,g=await A(n,t),p=M(g.workspaceRoot,await m.realpath(g.targetPath)),P=await m.stat(p);let f;if(P.isFile())f=[p];else if(P.isDirectory())f=await Ot(p,w,h,bt);else throw new Error(`Path is neither a file nor a directory: ${p}`);const y=[],E=[],b=[];let k=0,_=0,R=!1;for(const x of f){if(a==="content"&&y.length>=c){R=!0;break}const ot={regex:l,maxResults:a==="content"?c-y.length:Number.MAX_SAFE_INTEGER,collectContent:a==="content",stopOnFirstMatch:a==="files_with_matches"},N=await Lt(x,g.workspaceRoot,ot);if(N.count>0){const q=d.relative(g.workspaceRoot,x).replace(/\\/g,"/");if(b.push(q),k+=N.count,a==="content"){for(const j of N.matches){const z=Buffer.byteLength(j.content,"utf-8")+64;if(_+z>Pt){R=!0;break}_+=z,y.push(j)}if(R)break;if(y.length>=c){R=!0;break}}else a==="count"&&E.push({file:q,count:N.count})}}const S={ok:!0,tool:"grep",pattern:e,searchPath:v(g.targetPath),outputMode:a,filesSearched:f.length,filesMatched:b.length,totalMatches:k,truncated:R};return a==="content"?S.matches=y:a==="files_with_matches"?S.matches=b:S.matches=E,S}}}function ee(n,o,e,t,i){const s=o||"unknown",r=[Dt(n,i),Nt(n,e,i),Ct(n,e,i),Ut(n,e,i),jt(n),Wt(n,s,t,i),st(n)];return t&&r.push(ct(s,t),lt(s,t),ut(s,t)),r}export{te as DEFAULT_TOOL_PERMISSION_POLICY,ee as createBuiltInFileTools,M as ensureInsideWorkspace,A as resolveWorkspaceTarget};
3
+ `+E:E;return{workspaceRoot:s.workspaceRoot,targetPath:a,content:P,isBinary:!1,truncated:h||k,totalLines:k?-1:p,shownFromLine:y,shownToLine:b}}finally{u.close(),c.destroy()}}function W(n){return/^https?:\/\//i.test(n)}async function It(n){let o;try{o=new URL(n)}catch{throw new Error(`Invalid image URL: ${n}`)}if(o.protocol!=="http:"&&o.protocol!=="https:")throw new Error(`Unsupported image URL protocol: ${o.protocol} (only http/https)`);let e;try{e=await fetch(n,{signal:AbortSignal.timeout(yt)})}catch(u){const l=u instanceof Error?u.message:String(u);throw new Error(`Image URL fetch failed: ${n} (${l})`)}if(!e.ok)throw new Error(`Image URL fetch failed: ${n} (HTTP ${e.status})`);const t=(e.headers.get("content-type")||"").split(";")[0]?.trim().toLowerCase()||"";if(t&&!t.startsWith("image/"))throw new Error(`URL did not return an image (content-type: ${t}): ${n}`);const i=Number(e.headers.get("content-length")||"");if(Number.isFinite(i)&&i>L)throw new Error(`Image too large to fetch: ${n} (${x(i)} > ${x(L)})`);const s=e.body;if(!s){const u=await e.arrayBuffer();if(u.byteLength>L)throw new Error(`Image too large to fetch: ${n} (${x(u.byteLength)} > ${x(L)})`);return Buffer.from(u)}const a=s.getReader(),r=[];let c=0;for(;;){const{done:u,value:l}=await a.read();if(u)break;if(l){if(c+=l.byteLength,c>L)throw a.cancel().catch(()=>{}),new Error(`Image too large to fetch: ${n} (${x(c)} > ${x(L)})`);r.push(Buffer.from(l))}}return Buffer.concat(r,c)}async function Mt(n,o,e){let t,i;if(W(o))t=await It(o),i=o;else{const b=(await J(n,o,e)).targetPath,E=await m.stat(b);if(!E.isFile())throw new Error(`Path is not a file: ${b}`);if(E.size>K)throw new Error(`Image file too large to read: ${$(b)} (${x(E.size)} > ${x(K)}). Downscale it first.`);t=await m.readFile(b),i=$(b)}if(t.length===0)throw new Error(`Image file is empty: ${i}`);const s=dt(t);if(!s)throw new Error(`Unsupported or corrupt image (unrecognized format): ${i}`);const a=ht(t);let r=s,c=t,u=a?.width,l=a?.height,w=!1;const p=await pt(t,s,{maxWidth:C,maxHeight:C,maxBytes:U});if(p)c=p.buffer,r=p.mediaType,u=p.width,l=p.height,w=p.changed;else if(t.length>U)throw new Error(`Image too large to inline: ${i} (${x(t.length)} > ${x(U)}). Downscale it first, e.g. via Bash: magick "${o}" -resize ${C}x${C} "${o}". Installing sharp enables automatic downscaling.`);const _=u&&l?`${u}x${l}`:"unknown dimensions",h=w&&a&&a.width!==u?` (resized from ${a.width}x${a.height})`:w?" (resized)":"",k=`[Image: ${i}, ${_}${h}, ${x(c.length)}]`,f=W(o)?d.basename(new URL(o).pathname)||"image":d.basename(i);return{ok:!0,filePath:i,content:k,isBinary:!1,image:{mediaType:Y(r),width:u??null,height:l??null,originalWidth:a?.width??null,originalHeight:a?.height??null,resized:w,size:c.length},attachments:[{type:"image",name:f,mediaType:Y(r),base64Data:c.toString("base64")}]}}function tt(n){let o="",e=0;for(;e<n.length;){const t=n[e];if(t==="*")o+="[^/]*";else if(t==="?")o+="[^/]";else if(t==="{"){const i=n.indexOf("}",e);if(i>=0){const s=n.slice(e+1,i);o+=`(${s.split(",").join("|")})`,e=i}else o+="\\{"}else if(t==="["){const i=n.indexOf("]",e);i>=0?(o+=n.slice(e,i+1),e=i):o+="\\["}else"+^$.()|\\".includes(t)?o+="\\"+t:o+=t;e++}return new RegExp(`^${o}$`)}async function Ot(n,o,e,t){const i=[];async function s(a){if(i.length>=t)return;const r=await m.readdir(a,{withFileTypes:!0});for(const c of r){if(i.length>=t)return;if(c.name.startsWith(".")&&c.isDirectory())continue;const u=d.join(a,c.name);if(c.isDirectory()){if(vt.has(c.name))continue;await s(u)}else if(c.isFile()){if(o&&!o.test(c.name)||e&&e.test(c.name))continue;i.push(u)}}}return await s(n),i}async function Lt(n,o,e){if((await m.stat(n)).size>kt)return{matches:[],count:0};if(await Z(n))return{matches:[],count:0};const i=d.relative(o,n).replace(/\\/g,"/"),s=[];let a=0;const r=G(n,{encoding:"utf-8"}),c=X.createInterface({input:r,crlfDelay:1/0});try{let u=0;for await(const l of c)if(u++,e.regex.test(l)){if(a++,e.collectContent){let w=l;if(w.length>O&&(w=w.slice(0,O)+`... (line truncated to ${O} chars)`),s.push({file:i,line:u,content:w}),s.length>=e.maxResults)break}if(e.stopOnFirstMatch)break}}finally{c.close(),r.destroy()}return{matches:s,count:a}}const et=10*6e4,At=et,Ft=6e4,Bt=10*6e4;function Nt(n,o,e){return{kind:"builtin",toolName:"write_file",exposedName:"write_file",description:"Create or overwrite a UTF-8 text file inside the current workspace. Parent directories are created automatically.",inputSchema:{type:"object",properties:{file_path:{type:"string",description:"Workspace-relative file path to write."},content:{type:"string",description:"Complete UTF-8 file content."},reason:{type:"string",description:"Optional reason for this change, e.g. what bug is being fixed. Helps humans understand the change later."}},required:["file_path","content"],additionalProperties:!1},async execute(t){const i=R(t,["file_path","filePath"],"file_path"),s=R(t,["content"],"content"),a=I(t,["reason"]),r=await A(n,i);await F(e,"fileModification",{operation:"write",path:r.targetPath});const c=await V(r.targetPath),u=c?await m.readFile(r.targetPath,"utf-8").catch(()=>null):null,l=await Q(n,i,s);if(o){const w=d.relative(l.workspaceRoot,l.targetPath).replace(/\\/g,"/");await o({filePath:w,operation:c?"UPDATE":"CREATE",beforeContent:u,afterContent:s,reason:a})}return{ok:!0,filePath:$(l.targetPath),bytes:l.bytes,createdParentDirectory:l.createdParentDirectory}}}}function Ct(n,o,e){return{kind:"builtin",toolName:"edit_file",exposedName:"edit_file",description:"Replace exactly one occurrence of old_string with new_string in a UTF-8 workspace text file.",inputSchema:{type:"object",properties:{file_path:{type:"string",description:"Workspace-relative file path to edit."},old_string:{type:"string",description:"Existing text to replace. Must occur exactly once."},new_string:{type:"string",description:"Replacement text."},reason:{type:"string",description:"Optional reason for this change, e.g. what bug is being fixed. Helps humans understand the change later."}},required:["file_path","old_string","new_string"],additionalProperties:!1},async execute(t){const i=R(t,["file_path","filePath"],"file_path"),s=R(t,["old_string","oldString"],"old_string"),a=R(t,["new_string","newString"],"new_string"),r=I(t,["reason"]);if(!s)throw new Error("old_string must not be empty");const c=await A(n,i);await F(e,"fileModification",{operation:"edit",path:c.targetPath});const u=await Rt(n,i),l=xt(u.content,s);if(l===0)throw new Error("old_string was not found in file");if(l>1)throw new Error(`old_string occurs ${l} times; provide a unique match`);const w=u.content.replace(s,a),p=await Q(n,i,w);if(o){const _=d.relative(p.workspaceRoot,p.targetPath).replace(/\\/g,"/");await o({filePath:_,operation:"UPDATE",beforeContent:u.content,afterContent:w,reason:r})}return{ok:!0,filePath:$(p.targetPath),bytes:p.bytes}}}}function Ut(n,o,e){return{kind:"builtin",toolName:"delete_file",exposedName:"delete_file",description:"Delete a file inside the current workspace. Returns an error if the file does not exist.",inputSchema:{type:"object",properties:{file_path:{type:"string",description:"Workspace-relative file path to delete."},reason:{type:"string",description:"Optional reason for this change, e.g. what bug is being fixed. Helps humans understand the change later."}},required:["file_path"],additionalProperties:!1},async execute(t){const i=R(t,["file_path","filePath"],"file_path"),s=I(t,["reason"]),a=await A(n,i);await F(e,"fileModification",{operation:"delete",path:a.targetPath});const r=M(a.workspaceRoot,await m.realpath(a.targetPath).catch(()=>a.targetPath)),c=await m.stat(r).catch(()=>null);if(!c)throw new Error(`File does not exist: ${r}`);if(!c.isFile())throw new Error(`Path is not a file: ${r}`);const u=await m.readFile(r,"utf-8").catch(()=>null);if(await m.rm(r,{force:!0}),o){const l=d.relative(a.workspaceRoot,r).replace(/\\/g,"/");await o({filePath:l,operation:"DELETE",beforeContent:u,afterContent:null,reason:s})}return{ok:!0,filePath:$(r),deleted:!0}}}}function Dt(n,o){return{kind:"builtin",toolName:"read_file",exposedName:"read_file",description:"Read a UTF-8 text file inside the current workspace. Returns content with line numbers in the format '<line>: <content>'. Supports offset (1-indexed line number to start from) and limit (max lines to return, default 2000). Output is capped at 2000 lines or 50 KB, whichever is reached first. Individual lines longer than 2000 characters are truncated. Avoid tiny repeated slices (e.g. 30-line chunks); read a larger window if more context is needed. Images (.png/.jpg/.jpeg/.gif/.webp) and http(s) image URLs are also supported: the image is inlined into the conversation so you can see it (requires a model with image input). offset/limit are ignored for images; oversized images are automatically downscaled when sharp is available.",inputSchema:{type:"object",properties:{file_path:{type:"string",description:"Workspace-relative file path to read. Also accepts an http(s) URL pointing to an image."},offset:{type:"number",description:"Line number to start reading from (1-indexed). Defaults to 1."},limit:{type:"number",description:"Maximum number of lines to return. Defaults to 2000."}},required:["file_path"],additionalProperties:!1},async execute(e){const t=R(e,["file_path","filePath"],"file_path"),i=d.extname(t).toLowerCase().slice(1);if(W(t)||_t.has(i))return await Mt(n,t,o);const s=B(e,["offset"],1),a=B(e,["limit"],ft),r=await St(n,t,s,a,o);return{ok:!0,filePath:$(r.targetPath),content:r.content,isBinary:r.isBinary,truncated:r.truncated,totalLines:r.totalLines,shownFromLine:r.shownFromLine,shownToLine:r.shownToLine}}}}function Wt(n,o,e,t){return{kind:"builtin",toolName:"Bash",exposedName:"Bash",description:"Execute a shell command in the current workspace. Use for local diagnostics, builds, tests, and OS commands. The command runs with a bounded timeout and returns stdout, stderr, exit code, and (if interrupted) partial output. By default (wait_seconds omitted or -1) the command runs in the FOREGROUND and streams output in real time; if the 5-minute adapter watchdog fires while it is still running, the command is interrupted and the partial output produced so far is returned (large output is spilled to a file via outputFilePath to avoid context overflow), with watchdogInterrupted=true. For long-running commands use wait_seconds=0 or n>0 to run in the BACKGROUND, then manage them via list_background_commands / read_background_output / kill_background_command / await_complete.",inputSchema:{type:"object",properties:{command:{type:"string",description:"Shell command to execute."},cwd:{type:"string",description:"Optional workspace-relative working directory. Defaults to the workspace root."},timeout_ms:{type:"number",description:"Optional timeout in milliseconds. Defaults to 600000 and is capped at 600000."},inactivity_timeout_ms:{type:"number",description:"Optional no-output timeout in milliseconds. Defaults to 60000 and is capped at 600000."},wait_seconds:{type:"number",description:"How to wait for the command to finish. Omitted values (or -1, the default): run in the FOREGROUND until completion; if the 5-minute adapter watchdog fires first, the command is interrupted and only the partial output already produced is returned (watchdogInterrupted=true; large output spills to outputFilePath). 0: spawn and immediately execute in the background, return task_id. n>0: wait up to n seconds; if still running, move to the background and return task_id. Background commands remain subject to timeout_ms (total upper bound); inactivity_timeout_ms is ignored once backgrounded.",minimum:-1},description:{type:"string",description:"Optional short reason for running the command."}},required:["command"],additionalProperties:!1},async execute(i,s){const a=R(i,["command"],"command").trim();if(!a)throw new Error("command must not be empty");const r=B(i,["timeout_ms","timeoutMs"],At),c=Math.min(r,et),u=B(i,["inactivity_timeout_ms","inactivityTimeoutMs"],Ft),l=Math.min(u,Bt),w=I(i,["cwd"]),p=await Tt(n,w);await F(t,"commandExecution",{command:a,cwd:$(p.cwd)});const _=i.wait_seconds,k=typeof _=="number"&&Number.isFinite(_)?_:-1;if(k!==-1&&e)return await qt({deps:e,command:a,agentId:o,workspaceRoot:p.workspaceRoot,cwd:p.cwd,timeoutMs:c,inactivityTimeoutMs:l,waitSeconds:k,onOutput:s?.onOutput,settleSignal:s?.settleSignal});const f=await at({commandText:a,agentId:o,workspaceRoot:p.workspaceRoot,cwd:p.cwd,timeoutMs:c,inactivityTimeoutMs:l,onOutput:s?.onOutput,watchdogSignal:s?.settleSignal}),y={ok:f.exitCode===0&&!f.timedOut,tool:"Bash",command:a,cwd:$(p.cwd),exitCode:f.exitCode,signal:f.signal,timedOut:f.timedOut,inactivityTimedOut:f.inactivityTimedOut,watchdogInterrupted:f.watchdogInterrupted,timeoutMs:c,inactivityTimeoutMs:l,durationMs:f.durationMs,outputSpilled:f.outputSpilled,outputFilePath:f.outputFilePath,outputLineCount:f.outputLineCount,commandFilePath:f.commandFilePath,commandLineCount:f.commandLineCount,stdout:f.stdout,stderr:f.stderr};return f.watchdogInterrupted?{...y,message:"Command was interrupted by the adapter watchdog after ~5 minutes of synchronous (foreground) execution. Only the partial output produced so far is returned above"+(f.outputFilePath?` (full output spilled to "${f.outputFilePath}"; read it if you need more)`:"")+". For long-running commands, re-run with wait_seconds=0 (or n>0) to execute in the background, then manage via await_complete / list_background_commands / read_background_output / kill_background_command."}:y}}}async function qt(n){const{deps:o,command:e,agentId:t,workspaceRoot:i,cwd:s,timeoutMs:a,inactivityTimeoutMs:r,waitSeconds:c,onOutput:u,settleSignal:l}=n,w=u?rt({cwd:s,commandLineCount:0,onOutput:u}):void 0;let p=!!w;const _=()=>{p&&(p=!1,w?.close())};try{const{taskId:h,completion:k}=o.manager.startCommand({commandText:e,agentId:t,workspaceRoot:i,cwd:s,timeoutMs:a,inactivityTimeoutMs:r,onOutput:p?P=>{p&&w?.push(P.stream,P.text)}:void 0,onCompleted:o.emitCompleted});if(c===0)return o.manager.disableInactivityTimeout(t,h),_(),{ok:!0,tool:"Bash",command:e,backgrounded:!0,taskId:h,status:"backgrounded",reason:"immediate",message:`Command moved to background. Use await_complete(bg_cmd_ids=["${h}"]) to block until it finishes, read_background_output(task_id="${h}", mode="tail") to read output, list_background_commands to view all, or kill_background_command(task_id="${h}") to stop.`};const f=c===-1?0:Math.max(0,Math.floor(c*1e3));let y,b;c===-1?b=Promise.resolve("__never__"):b=new Promise(P=>{y=setTimeout(()=>P("__timeout__"),f),y.unref?.()});const E=l?l.then(()=>"__settle__"):Promise.resolve("__never__");try{const P=await Promise.race([k,b,E]);if(P==="__settle__")return o.manager.disableInactivityTimeout(t,h),{ok:!0,tool:"Bash",command:e,backgrounded:!0,taskId:h,status:"backgrounded",reason:"watchdog_timeout",waitedMs:f,message:`Command still running after watchdog timeout; moved to background. Use await_complete(bg_cmd_ids=["${h}"]) to block until it finishes, read_background_output(task_id="${h}", mode="tail") to read output, or kill_background_command(task_id="${h}") to stop.`};if(P==="__timeout__")return o.manager.disableInactivityTimeout(t,h),{ok:!0,tool:"Bash",command:e,backgrounded:!0,taskId:h,status:"backgrounded",reason:"timeout",waitedMs:f,message:`Command still running after ${c}s; moved to background. Use await_complete(bg_cmd_ids=["${h}"]) to block until it finishes, or read_background_output(task_id="${h}", mode="tail") / kill_background_command(task_id="${h}") to inspect.`};const g=P;return{ok:g.exitCode===0&&!g.timedOut,tool:"Bash",command:e,backgrounded:!1,taskId:h,exitCode:g.exitCode,signal:g.signal,timedOut:g.timedOut,inactivityTimedOut:g.inactivityTimedOut,timeoutMs:g.timeoutMs,inactivityTimeoutMs:g.inactivityTimeoutMs,durationMs:g.durationMs,outputSpilled:g.outputSpilled,outputFilePath:g.outputFilePath,outputLineCount:g.outputLineCount,commandFilePath:g.commandFilePath,commandLineCount:g.commandLineCount,stdout:g.stdout,stderr:g.stderr}}finally{y&&clearTimeout(y),_()}}catch(h){if(h?.code==="too_many_tasks"||h?.code==="global_limit_reached")return{ok:!1,tool:"Bash",command:e,backgrounded:!1,status:"not_executed",error:h.code,message:`Command was NOT executed: ${h.message}. Wait for some background tasks to finish/cleanup (per-agent limit 16, global 256), or reduce concurrent background commands, then retry.`};throw h}}function jt(n){return{kind:"builtin",toolName:"grep",exposedName:"grep",description:"Search file contents using regular expressions within the workspace. Returns matched lines with file paths and line numbers. Supports include/exclude glob patterns, case-insensitive matching, and three output modes (content, files_with_matches, count). Searches recursively through directories, skipping binary files, hidden directories, and common build/dependency directories (node_modules, .git, dist, etc.).",inputSchema:{type:"object",properties:{pattern:{type:"string",description:"Regular expression pattern to search for in file contents."},path:{type:"string",description:"Workspace-relative file or directory path to search in. Defaults to the workspace root."},include:{type:"string",description:"Glob pattern to filter files by name (e.g. '*.ts', '*.{js,ts}'). Only matching files are searched."},exclude:{type:"string",description:"Glob pattern to exclude files by name (e.g. '*.test.ts'). Matching files are skipped."},case_insensitive:{type:"boolean",description:"Case-insensitive matching. Default false."},output_mode:{type:"string",enum:["content","files_with_matches","count"],description:"Output format: 'content' returns matched lines with line numbers (default), 'files_with_matches' returns only file paths with matches, 'count' returns match counts per file."},max_results:{type:"number",description:"Maximum number of matched lines to return (content mode). Default 1000."}},required:["pattern"],additionalProperties:!1},async execute(o){const e=R(o,["pattern"],"pattern"),t=I(o,["path"])||".",i=I(o,["include"]),s=I(o,["exclude"]),a=o.case_insensitive===!0,r=(()=>{const v=o.output_mode;return v==="files_with_matches"||v==="count"?v:"content"})(),c=B(o,["max_results"],Pt),u=a?"i":"";let l;try{l=new RegExp(e,u)}catch(v){throw new Error(`Invalid regex pattern: ${v instanceof Error?v.message:String(v)}`)}const w=i?tt(i):null,p=s?tt(s):null,_=await A(n,t),h=M(_.workspaceRoot,await m.realpath(_.targetPath)),k=await m.stat(h);let f;if(k.isFile())f=[h];else if(k.isDirectory())f=await Ot(h,w,p,bt);else throw new Error(`Path is neither a file nor a directory: ${h}`);const y=[],b=[],E=[];let P=0,g=0,T=!1;for(const v of f){if(r==="content"&&y.length>=c){T=!0;break}const ot={regex:l,maxResults:r==="content"?c-y.length:Number.MAX_SAFE_INTEGER,collectContent:r==="content",stopOnFirstMatch:r==="files_with_matches"},N=await Lt(v,_.workspaceRoot,ot);if(N.count>0){const q=d.relative(_.workspaceRoot,v).replace(/\\/g,"/");if(E.push(q),P+=N.count,r==="content"){for(const j of N.matches){const z=Buffer.byteLength(j.content,"utf-8")+64;if(g+z>Et){T=!0;break}g+=z,y.push(j)}if(T)break;if(y.length>=c){T=!0;break}}else r==="count"&&b.push({file:q,count:N.count})}}const S={ok:!0,tool:"grep",pattern:e,searchPath:$(_.targetPath),outputMode:r,filesSearched:f.length,filesMatched:E.length,totalMatches:P,truncated:T};return r==="content"?S.matches=y:r==="files_with_matches"?S.matches=E:S.matches=b,S}}}function ee(n,o,e,t,i){const s=o||"unknown",a=[Dt(n,i),Nt(n,e,i),Ct(n,e,i),Ut(n,e,i),jt(n),Wt(n,s,t,i),st(n)];return t&&a.push(ct(s,t),lt(s,t),ut(s,t)),a}export{te as DEFAULT_TOOL_PERMISSION_POLICY,ee as createBuiltInFileTools,M as ensureInsideWorkspace,A as resolveWorkspaceTarget};
4
4
 
@@ -8,5 +8,7 @@ export declare class ACodeCommandRegistry {
8
8
  private readonly commands;
9
9
  constructor(commands: readonly ACodeCommandSpec[]);
10
10
  list(): ACodeCommandSpec[];
11
+
12
+ addCommands(commands: readonly ACodeCommandSpec[]): void;
11
13
  expand(input: string): ExpandedAcodeCommand | null;
12
14
  }
@@ -1,2 +1,2 @@
1
- function r(e){return e.replace(/^\/+/,"").trim().toLowerCase()}class s{constructor(n){this.commands=new Map;for(const t of n)this.commands.set(r(t.name),t)}list(){return[...this.commands.values()]}expand(n){const t=n.trim().match(/^\/([^\s]+)(?:\s+(.*))?$/s);if(!t)return null;const m=this.commands.get(r(t[1]??""));if(!m)return null;const o=(t[2]??"").trim();return{command:m,argumentsText:o,prompt:m.body.replace(/\$ARGUMENTS/g,o)}}}export{s as ACodeCommandRegistry};
1
+ function o(s){return s.replace(/^\/+/,"").trim().toLowerCase()}class e{constructor(t){this.commands=new Map;for(const m of t)this.commands.set(o(m.name),m)}list(){return[...this.commands.values()]}addCommands(t){for(const m of t)this.commands.set(o(m.name),m)}expand(t){const m=t.trim().match(/^\/([^\s]+)(?:\s+(.*))?$/s);if(!m)return null;const n=this.commands.get(o(m[1]??""));if(!n)return null;const a=(m[2]??"").trim();return{command:n,argumentsText:a,prompt:n.body.replace(/\$ARGUMENTS/g,a)}}}export{e as ACodeCommandRegistry};
2
2
 
@@ -11,6 +11,8 @@ export * from './sub-agent-manager.js';
11
11
  export * from './sub-agent-tools.js';
12
12
  export * from './built-in-file-tools.js';
13
13
  export * from './terminal-types.js';
14
+ export * from './plugin-types.js';
15
+ export * from './plugin-tools.js';
14
16
  export * from './parsers/types.js';
15
17
  export * from './parsers/tree-sitter-loader.js';
16
18
  export * from './parsers/ast-cache.js';
@@ -1,2 +1,2 @@
1
- export*from"./commands/commandRegistry.js";export*from"./commands/commandLoader.js";export*from"./commands/commandParser.js";export*from"./config.js";export*from"./hooks/hookBus.js";export*from"./runtime.js";export*from"./types.js";export*from"./sub-agent-types.js";export*from"./sub-agent-store.js";export*from"./sub-agent-manager.js";export*from"./sub-agent-tools.js";export*from"./built-in-file-tools.js";export*from"./terminal-types.js";export*from"./parsers/types.js";export*from"./parsers/tree-sitter-loader.js";export*from"./parsers/ast-cache.js";export*from"./parsers/language-detector.js";export*from"./parsers/language-queries.js";export*from"./parsers/symbol-extractor.js";export*from"./built-in-symbols-tool.js";
1
+ export*from"./commands/commandRegistry.js";export*from"./commands/commandLoader.js";export*from"./commands/commandParser.js";export*from"./config.js";export*from"./hooks/hookBus.js";export*from"./runtime.js";export*from"./types.js";export*from"./sub-agent-types.js";export*from"./sub-agent-store.js";export*from"./sub-agent-manager.js";export*from"./sub-agent-tools.js";export*from"./built-in-file-tools.js";export*from"./terminal-types.js";export*from"./plugin-types.js";export*from"./plugin-tools.js";export*from"./parsers/types.js";export*from"./parsers/tree-sitter-loader.js";export*from"./parsers/ast-cache.js";export*from"./parsers/language-detector.js";export*from"./parsers/language-queries.js";export*from"./parsers/symbol-extractor.js";export*from"./built-in-symbols-tool.js";
2
2
 
@@ -0,0 +1,14 @@
1
+
2
+ import type { ACodeBuiltInTool } from "./built-in-file-tools.js";
3
+ import type { ACodePluginBridge } from "./plugin-types.js";
4
+ export interface PluginToolsDeps {
5
+ pluginBridge?: ACodePluginBridge;
6
+ }
7
+
8
+ export declare function splitQualifiedToolName(qualifiedName: string): {
9
+ plugin: string;
10
+ tool: string;
11
+ } | null;
12
+ export declare function createPluginTools(deps: PluginToolsDeps): ACodeBuiltInTool[];
13
+
14
+ export declare function buildPluginPrompt(): string;