jishushell 0.5.22 → 0.6.18

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 (3198) hide show
  1. package/apps/anythingllm-container.yaml +20 -177
  2. package/apps/browserless-chromium-container.yaml +17 -12
  3. package/apps/filebrowser-container.yaml +22 -9
  4. package/apps/hermes-container.yaml +23 -2
  5. package/apps/jishu-kb-container.yaml +152 -0
  6. package/apps/ollama-binary.yaml +32 -28
  7. package/apps/ollama-cpu-container.yaml +5 -0
  8. package/apps/ollama-with-hollama-binary.yaml +33 -28
  9. package/apps/openclaw-binary.yaml +34 -10
  10. package/apps/openclaw-container.yaml +33 -8
  11. package/apps/openclaw-with-ollama-container.yaml +8 -2
  12. package/apps/openclaw-with-searxng-container.yaml +18 -6
  13. package/apps/searxng-container.yaml +12 -7
  14. package/apps/weknora-container.yaml +29 -23
  15. package/dependencies/jishushell-panel-0.6.18.tgz +0 -0
  16. package/dist/cli/app.js +494 -192
  17. package/dist/cli/app.js.map +1 -1
  18. package/dist/cli/backup.js +112 -139
  19. package/dist/cli/backup.js.map +1 -1
  20. package/dist/cli/core.d.ts +30 -0
  21. package/dist/cli/core.js +1415 -0
  22. package/dist/cli/core.js.map +1 -0
  23. package/dist/cli/doctor.d.ts +1 -1
  24. package/dist/cli/doctor.js +50 -61
  25. package/dist/cli/doctor.js.map +1 -1
  26. package/dist/cli/job.js +62 -14
  27. package/dist/cli/job.js.map +1 -1
  28. package/dist/cli/llm.d.ts +1 -18
  29. package/dist/cli/llm.js +103 -83
  30. package/dist/cli/llm.js.map +1 -1
  31. package/dist/cli/managed-list.d.ts +1 -3
  32. package/dist/cli/managed-list.js +18 -16
  33. package/dist/cli/managed-list.js.map +1 -1
  34. package/dist/cli/migrate.d.ts +2 -0
  35. package/dist/cli/migrate.js +160 -0
  36. package/dist/cli/migrate.js.map +1 -0
  37. package/dist/cli.js +26 -2
  38. package/dist/cli.js.map +1 -1
  39. package/dist/config.d.ts +53 -44
  40. package/dist/config.js +216 -146
  41. package/dist/config.js.map +1 -1
  42. package/dist/constants.d.ts +0 -1
  43. package/dist/constants.js +0 -4
  44. package/dist/constants.js.map +1 -1
  45. package/dist/control.d.ts +7 -7
  46. package/dist/control.js +32 -24
  47. package/dist/control.js.map +1 -1
  48. package/dist/core.d.ts +5 -0
  49. package/dist/core.js +6 -0
  50. package/dist/core.js.map +1 -0
  51. package/dist/install.d.ts +3 -10
  52. package/dist/install.js +118 -43
  53. package/dist/install.js.map +1 -1
  54. package/dist/routes/apps.d.ts +1 -1
  55. package/dist/routes/apps.js +100 -234
  56. package/dist/routes/apps.js.map +1 -1
  57. package/dist/routes/auth.d.ts +1 -3
  58. package/dist/routes/auth.js +7 -14
  59. package/dist/routes/auth.js.map +1 -1
  60. package/dist/routes/backup.js +137 -334
  61. package/dist/routes/backup.js.map +1 -1
  62. package/dist/routes/external-mounts.d.ts +1 -1
  63. package/dist/routes/external-mounts.js +7 -7
  64. package/dist/routes/external-mounts.js.map +1 -1
  65. package/dist/routes/file-mounts.d.ts +4 -3
  66. package/dist/routes/file-mounts.js +51 -30
  67. package/dist/routes/file-mounts.js.map +1 -1
  68. package/dist/routes/files-organize.d.ts +2 -2
  69. package/dist/routes/files-organize.js +5 -5
  70. package/dist/routes/files-organize.js.map +1 -1
  71. package/dist/routes/files.d.ts +1 -1
  72. package/dist/routes/files.js +1 -1
  73. package/dist/routes/files.js.map +1 -1
  74. package/dist/routes/instances.d.ts +11 -4
  75. package/dist/routes/instances.js +482 -923
  76. package/dist/routes/instances.js.map +1 -1
  77. package/dist/routes/integration-apps.d.ts +14 -0
  78. package/dist/routes/integration-apps.js +81 -0
  79. package/dist/routes/integration-apps.js.map +1 -0
  80. package/dist/routes/integrations.d.ts +9 -0
  81. package/dist/routes/integrations.js +12 -0
  82. package/dist/routes/integrations.js.map +1 -0
  83. package/dist/routes/llm-proxy.d.ts +2 -0
  84. package/dist/routes/llm-proxy.js +294 -0
  85. package/dist/routes/llm-proxy.js.map +1 -0
  86. package/dist/routes/llm.d.ts +1 -1
  87. package/dist/routes/llm.js +25 -75
  88. package/dist/routes/llm.js.map +1 -1
  89. package/dist/routes/setup.js +93 -93
  90. package/dist/routes/setup.js.map +1 -1
  91. package/dist/routes/system.js +248 -54
  92. package/dist/routes/system.js.map +1 -1
  93. package/dist/routes/webdav.d.ts +1 -1
  94. package/dist/routes/webdav.js +2 -2
  95. package/dist/routes/webdav.js.map +1 -1
  96. package/dist/server.d.ts +2 -0
  97. package/dist/server.js +343 -312
  98. package/dist/server.js.map +1 -1
  99. package/dist/services/app-common/app-compiler.js +186 -0
  100. package/dist/services/app-common/app-compiler.js.map +1 -0
  101. package/dist/services/app-common/app-shared.d.ts +15 -0
  102. package/dist/services/app-common/app-shared.js +64 -0
  103. package/dist/services/app-common/app-shared.js.map +1 -0
  104. package/dist/services/app-common/capability-service.d.ts +45 -0
  105. package/dist/services/app-common/capability-service.js +331 -0
  106. package/dist/services/app-common/capability-service.js.map +1 -0
  107. package/dist/services/app-common/catalog-service.d.ts +59 -0
  108. package/dist/services/app-common/catalog-service.js +308 -0
  109. package/dist/services/app-common/catalog-service.js.map +1 -0
  110. package/dist/services/app-common/create-pipeline.d.ts +26 -0
  111. package/dist/services/app-common/create-pipeline.js +298 -0
  112. package/dist/services/app-common/create-pipeline.js.map +1 -0
  113. package/dist/services/app-common/delete-service.d.ts +5 -0
  114. package/dist/services/app-common/delete-service.js +104 -0
  115. package/dist/services/app-common/delete-service.js.map +1 -0
  116. package/dist/services/app-common/execution-owner.d.ts +23 -0
  117. package/dist/services/app-common/execution-owner.js +124 -0
  118. package/dist/services/app-common/execution-owner.js.map +1 -0
  119. package/dist/services/app-common/execution-service.d.ts +23 -0
  120. package/dist/services/app-common/execution-service.js +105 -0
  121. package/dist/services/app-common/execution-service.js.map +1 -0
  122. package/dist/services/app-common/id-normalizer.d.ts +31 -0
  123. package/dist/services/app-common/id-normalizer.js +83 -0
  124. package/dist/services/app-common/id-normalizer.js.map +1 -0
  125. package/dist/services/app-common/install-store.d.ts +34 -0
  126. package/dist/services/app-common/install-store.js +261 -0
  127. package/dist/services/app-common/install-store.js.map +1 -0
  128. package/dist/services/app-common/instance-store.d.ts +78 -0
  129. package/dist/services/app-common/instance-store.js +495 -0
  130. package/dist/services/app-common/instance-store.js.map +1 -0
  131. package/dist/services/app-common/integration-refs.d.ts +17 -0
  132. package/dist/services/app-common/integration-refs.js +47 -0
  133. package/dist/services/app-common/integration-refs.js.map +1 -0
  134. package/dist/services/app-common/lifecycle-pipeline.d.ts +62 -0
  135. package/dist/services/app-common/lifecycle-pipeline.js +317 -0
  136. package/dist/services/app-common/lifecycle-pipeline.js.map +1 -0
  137. package/dist/services/app-common/lifecycle-scripts.d.ts +38 -0
  138. package/dist/services/app-common/lifecycle-scripts.js +935 -0
  139. package/dist/services/app-common/lifecycle-scripts.js.map +1 -0
  140. package/dist/services/app-common/lifecycle-service.d.ts +68 -0
  141. package/dist/services/app-common/lifecycle-service.js +467 -0
  142. package/dist/services/app-common/lifecycle-service.js.map +1 -0
  143. package/dist/services/app-common/paths.d.ts +29 -0
  144. package/dist/services/app-common/paths.js +34 -0
  145. package/dist/services/app-common/paths.js.map +1 -0
  146. package/dist/services/app-common/platform-transform.d.ts +32 -0
  147. package/dist/services/app-common/platform-transform.js +65 -0
  148. package/dist/services/app-common/platform-transform.js.map +1 -0
  149. package/dist/services/app-common/provide-resolver.d.ts +29 -0
  150. package/dist/services/app-common/provide-resolver.js +129 -0
  151. package/dist/services/app-common/provide-resolver.js.map +1 -0
  152. package/dist/services/app-common/remote-spec.d.ts +14 -0
  153. package/dist/services/app-common/remote-spec.js +58 -0
  154. package/dist/services/app-common/remote-spec.js.map +1 -0
  155. package/dist/services/app-common/runtime-builder.d.ts +1 -0
  156. package/dist/services/app-common/runtime-builder.js +2 -0
  157. package/dist/services/app-common/runtime-builder.js.map +1 -0
  158. package/dist/services/app-common/runtime-facts.d.ts +19 -0
  159. package/dist/services/app-common/runtime-facts.js +126 -0
  160. package/dist/services/app-common/runtime-facts.js.map +1 -0
  161. package/dist/services/app-common/service.d.ts +9 -0
  162. package/dist/services/app-common/service.js +10 -0
  163. package/dist/services/app-common/service.js.map +1 -0
  164. package/dist/services/app-common/spec-materializer.d.ts +9 -0
  165. package/dist/services/app-common/spec-materializer.js +361 -0
  166. package/dist/services/app-common/spec-materializer.js.map +1 -0
  167. package/dist/services/app-common/status-refresh.d.ts +33 -0
  168. package/dist/services/app-common/status-refresh.js +759 -0
  169. package/dist/services/app-common/status-refresh.js.map +1 -0
  170. package/dist/services/app-common/task-service.d.ts +29 -0
  171. package/dist/services/app-common/task-service.js +93 -0
  172. package/dist/services/app-common/task-service.js.map +1 -0
  173. package/dist/services/app-common/terminal-session-manager.js +157 -0
  174. package/dist/services/app-common/terminal-session-manager.js.map +1 -0
  175. package/dist/services/app-modules/browserless/routes.d.ts +9 -0
  176. package/dist/services/app-modules/browserless/routes.js +517 -0
  177. package/dist/services/app-modules/browserless/routes.js.map +1 -0
  178. package/dist/services/app-modules/routes.d.ts +2 -0
  179. package/dist/services/app-modules/routes.js +5 -0
  180. package/dist/services/app-modules/routes.js.map +1 -0
  181. package/dist/services/backup/backup-admin.d.ts +95 -0
  182. package/dist/services/backup/backup-admin.js +246 -0
  183. package/dist/services/backup/backup-admin.js.map +1 -0
  184. package/dist/services/backup/backup-manager.d.ts +264 -0
  185. package/dist/services/backup/backup-manager.js +2318 -0
  186. package/dist/services/backup/backup-manager.js.map +1 -0
  187. package/dist/services/backup/backup-verify.js +240 -0
  188. package/dist/services/backup/backup-verify.js.map +1 -0
  189. package/dist/services/capabilities/browser-policy.d.ts +14 -0
  190. package/dist/services/capabilities/browser-policy.js +141 -0
  191. package/dist/services/capabilities/browser-policy.js.map +1 -0
  192. package/dist/services/capabilities/contract.d.ts +50 -0
  193. package/dist/services/capabilities/contract.js +129 -0
  194. package/dist/services/capabilities/contract.js.map +1 -0
  195. package/dist/services/capabilities/endpoint-validator.d.ts +42 -0
  196. package/dist/services/capabilities/endpoint-validator.js +114 -0
  197. package/dist/services/capabilities/endpoint-validator.js.map +1 -0
  198. package/dist/services/capabilities/health.d.ts +16 -0
  199. package/dist/services/capabilities/health.js +121 -0
  200. package/dist/services/capabilities/health.js.map +1 -0
  201. package/dist/services/capabilities/registry.d.ts +56 -0
  202. package/dist/services/capabilities/registry.js +222 -0
  203. package/dist/services/capabilities/registry.js.map +1 -0
  204. package/dist/services/capabilities/sync.d.ts +7 -0
  205. package/dist/services/capabilities/sync.js +223 -0
  206. package/dist/services/capabilities/sync.js.map +1 -0
  207. package/dist/services/capability-proxy/html-rewriters/browserless.d.ts +1 -0
  208. package/dist/services/capability-proxy/html-rewriters/browserless.js +83 -0
  209. package/dist/services/capability-proxy/html-rewriters/browserless.js.map +1 -0
  210. package/dist/services/capability-proxy/html-rewriters/index.d.ts +12 -0
  211. package/dist/services/capability-proxy/html-rewriters/index.js +25 -0
  212. package/dist/services/capability-proxy/html-rewriters/index.js.map +1 -0
  213. package/dist/services/capability-proxy/html-rewriters/jishukb.d.ts +1 -0
  214. package/dist/services/capability-proxy/html-rewriters/jishukb.js +161 -0
  215. package/dist/services/capability-proxy/html-rewriters/jishukb.js.map +1 -0
  216. package/dist/services/connections/admin.d.ts +80 -0
  217. package/dist/services/connections/admin.js +327 -0
  218. package/dist/services/connections/admin.js.map +1 -0
  219. package/dist/services/connections/apply.d.ts +110 -0
  220. package/dist/services/connections/apply.js +444 -0
  221. package/dist/services/connections/apply.js.map +1 -0
  222. package/dist/services/connections/resolver.d.ts +82 -0
  223. package/dist/services/connections/resolver.js +289 -0
  224. package/dist/services/connections/resolver.js.map +1 -0
  225. package/dist/services/connections/suggestions.d.ts +27 -0
  226. package/dist/services/connections/suggestions.js +124 -0
  227. package/dist/services/connections/suggestions.js.map +1 -0
  228. package/dist/services/connections/transactor.d.ts +39 -0
  229. package/dist/services/connections/transactor.js +307 -0
  230. package/dist/services/connections/transactor.js.map +1 -0
  231. package/dist/services/files/external-mounts.js +187 -0
  232. package/dist/services/files/external-mounts.js.map +1 -0
  233. package/dist/services/files/files-manager.d.ts +265 -0
  234. package/dist/services/files/files-manager.js +1189 -0
  235. package/dist/services/files/files-manager.js.map +1 -0
  236. package/dist/services/files/files-mounts.d.ts +42 -0
  237. package/dist/services/files/files-mounts.js +207 -0
  238. package/dist/services/files/files-mounts.js.map +1 -0
  239. package/dist/services/files/organize/applier.js +218 -0
  240. package/dist/services/files/organize/applier.js.map +1 -0
  241. package/dist/services/files/organize/rules.js +286 -0
  242. package/dist/services/files/organize/rules.js.map +1 -0
  243. package/dist/services/files/organize/scanner.js +366 -0
  244. package/dist/services/files/organize/scanner.js.map +1 -0
  245. package/dist/services/files/organize/store.js +82 -0
  246. package/dist/services/files/organize/store.js.map +1 -0
  247. package/dist/services/files/webdav/server.d.ts +47 -0
  248. package/dist/services/files/webdav/server.js +329 -0
  249. package/dist/services/files/webdav/server.js.map +1 -0
  250. package/dist/services/files/webdav/xml-builder.js.map +1 -0
  251. package/dist/services/instances/admin.d.ts +23 -0
  252. package/dist/services/instances/admin.js +218 -0
  253. package/dist/services/instances/admin.js.map +1 -0
  254. package/dist/services/instances/clone.d.ts +26 -0
  255. package/dist/services/instances/clone.js +78 -0
  256. package/dist/services/instances/clone.js.map +1 -0
  257. package/dist/services/instances/config-admin.d.ts +17 -0
  258. package/dist/services/instances/config-admin.js +181 -0
  259. package/dist/services/instances/config-admin.js.map +1 -0
  260. package/dist/services/instances/manager.d.ts +231 -0
  261. package/dist/services/instances/manager.js +1348 -0
  262. package/dist/services/instances/manager.js.map +1 -0
  263. package/dist/services/instances/passwords.js +173 -0
  264. package/dist/services/instances/passwords.js.map +1 -0
  265. package/dist/services/instances/types.d.ts +21 -0
  266. package/dist/services/instances/types.js +2 -0
  267. package/dist/services/instances/types.js.map +1 -0
  268. package/dist/services/integrations/anythingllm/integration.d.ts +25 -0
  269. package/dist/services/integrations/anythingllm/integration.js +251 -0
  270. package/dist/services/integrations/anythingllm/integration.js.map +1 -0
  271. package/dist/services/integrations/catalog.d.ts +3 -0
  272. package/dist/services/integrations/catalog.js +73 -0
  273. package/dist/services/integrations/catalog.js.map +1 -0
  274. package/dist/services/integrations/custom/integration.d.ts +28 -0
  275. package/dist/services/integrations/custom/integration.js +179 -0
  276. package/dist/services/integrations/custom/integration.js.map +1 -0
  277. package/dist/services/integrations/hermes/integration.d.ts +194 -0
  278. package/dist/services/integrations/hermes/integration.js +1669 -0
  279. package/dist/services/integrations/hermes/integration.js.map +1 -0
  280. package/dist/services/integrations/index.d.ts +40 -0
  281. package/dist/services/integrations/index.js +59 -0
  282. package/dist/services/integrations/index.js.map +1 -0
  283. package/dist/services/integrations/installable/catalog.d.ts +33 -0
  284. package/dist/services/integrations/installable/catalog.js +88 -0
  285. package/dist/services/integrations/installable/catalog.js.map +1 -0
  286. package/dist/services/integrations/installable/index.d.ts +35 -0
  287. package/dist/services/integrations/installable/index.js +170 -0
  288. package/dist/services/integrations/installable/index.js.map +1 -0
  289. package/dist/services/integrations/installable/installers/integration-probes.d.ts +50 -0
  290. package/dist/services/integrations/installable/installers/integration-probes.js +231 -0
  291. package/dist/services/integrations/installable/installers/integration-probes.js.map +1 -0
  292. package/dist/services/integrations/installable/installers/integration.d.ts +30 -0
  293. package/dist/services/integrations/installable/installers/integration.js +177 -0
  294. package/dist/services/integrations/installable/installers/integration.js.map +1 -0
  295. package/dist/services/integrations/installable/installers/registry-probe.js.map +1 -0
  296. package/dist/services/integrations/installable/installers/shell-script.d.ts +46 -0
  297. package/dist/services/integrations/installable/installers/shell-script.js +487 -0
  298. package/dist/services/integrations/installable/installers/shell-script.js.map +1 -0
  299. package/dist/services/integrations/installable/types.d.ts +130 -0
  300. package/dist/services/integrations/installable/types.js +19 -0
  301. package/dist/services/integrations/installable/types.js.map +1 -0
  302. package/dist/services/integrations/jishukb/integration.d.ts +22 -0
  303. package/dist/services/integrations/jishukb/integration.js +189 -0
  304. package/dist/services/integrations/jishukb/integration.js.map +1 -0
  305. package/dist/services/integrations/openclaw/anythingllm-shim.d.ts +46 -0
  306. package/dist/services/integrations/openclaw/anythingllm-shim.js +281 -0
  307. package/dist/services/integrations/openclaw/anythingllm-shim.js.map +1 -0
  308. package/dist/services/integrations/openclaw/drive-shim.d.ts +54 -0
  309. package/dist/services/integrations/openclaw/drive-shim.js +490 -0
  310. package/dist/services/integrations/openclaw/drive-shim.js.map +1 -0
  311. package/dist/services/integrations/openclaw/integration.d.ts +424 -0
  312. package/dist/services/integrations/openclaw/integration.js +4402 -0
  313. package/dist/services/integrations/openclaw/integration.js.map +1 -0
  314. package/dist/services/integrations/openclaw/jishukb-shim.d.ts +48 -0
  315. package/dist/services/integrations/openclaw/jishukb-shim.js +750 -0
  316. package/dist/services/integrations/openclaw/jishukb-shim.js.map +1 -0
  317. package/dist/services/integrations/openclaw/mcporter-lite.d.ts +24 -0
  318. package/dist/services/integrations/openclaw/mcporter-lite.js +276 -0
  319. package/dist/services/integrations/openclaw/mcporter-lite.js.map +1 -0
  320. package/dist/services/integrations/openclaw/mcporter.d.ts +46 -0
  321. package/dist/services/integrations/openclaw/mcporter.js +112 -0
  322. package/dist/services/integrations/openclaw/mcporter.js.map +1 -0
  323. package/dist/services/integrations/openclaw/routes.d.ts +21 -0
  324. package/dist/services/integrations/openclaw/routes.js +1191 -0
  325. package/dist/services/integrations/openclaw/routes.js.map +1 -0
  326. package/dist/services/integrations/registry.d.ts +17 -0
  327. package/dist/services/integrations/registry.js +36 -0
  328. package/dist/services/integrations/registry.js.map +1 -0
  329. package/dist/services/integrations/routes.d.ts +2 -0
  330. package/dist/services/integrations/routes.js +9 -0
  331. package/dist/services/integrations/routes.js.map +1 -0
  332. package/dist/services/integrations/types.d.ts +469 -0
  333. package/dist/services/integrations/types.js +2 -0
  334. package/dist/services/integrations/types.js.map +1 -0
  335. package/dist/services/legacy-migrator/classifier.d.ts +44 -0
  336. package/dist/services/legacy-migrator/classifier.js +309 -0
  337. package/dist/services/legacy-migrator/classifier.js.map +1 -0
  338. package/dist/services/legacy-migrator/executor.d.ts +42 -0
  339. package/dist/services/legacy-migrator/executor.js +637 -0
  340. package/dist/services/legacy-migrator/executor.js.map +1 -0
  341. package/dist/services/legacy-migrator/index.d.ts +31 -0
  342. package/dist/services/legacy-migrator/index.js +34 -0
  343. package/dist/services/legacy-migrator/index.js.map +1 -0
  344. package/dist/services/legacy-migrator/planner.d.ts +8 -0
  345. package/dist/services/legacy-migrator/planner.js +154 -0
  346. package/dist/services/legacy-migrator/planner.js.map +1 -0
  347. package/dist/services/legacy-migrator/provider-settings.d.ts +6 -0
  348. package/dist/services/legacy-migrator/provider-settings.js +72 -0
  349. package/dist/services/legacy-migrator/provider-settings.js.map +1 -0
  350. package/dist/services/legacy-migrator/report.d.ts +9 -0
  351. package/dist/services/legacy-migrator/report.js +99 -0
  352. package/dist/services/legacy-migrator/report.js.map +1 -0
  353. package/dist/services/legacy-migrator/scanner.d.ts +13 -0
  354. package/dist/services/legacy-migrator/scanner.js +157 -0
  355. package/dist/services/legacy-migrator/scanner.js.map +1 -0
  356. package/dist/services/legacy-migrator/types.d.ts +97 -0
  357. package/dist/services/legacy-migrator/types.js +23 -0
  358. package/dist/services/legacy-migrator/types.js.map +1 -0
  359. package/dist/services/llm-proxy/adapters.js +5 -4
  360. package/dist/services/llm-proxy/adapters.js.map +1 -1
  361. package/dist/services/llm-proxy/index.d.ts +8 -105
  362. package/dist/services/llm-proxy/index.js +12 -889
  363. package/dist/services/llm-proxy/index.js.map +1 -1
  364. package/dist/services/llm-proxy/instance-proxy.d.ts +61 -0
  365. package/dist/services/llm-proxy/instance-proxy.js +702 -0
  366. package/dist/services/llm-proxy/instance-proxy.js.map +1 -0
  367. package/dist/services/llm-proxy/probe.js +5 -14
  368. package/dist/services/llm-proxy/probe.js.map +1 -1
  369. package/dist/services/llm-proxy/providers.d.ts +21 -0
  370. package/dist/services/llm-proxy/providers.js +88 -0
  371. package/dist/services/llm-proxy/providers.js.map +1 -0
  372. package/dist/services/llm-proxy/proxy-runtime.d.ts +12 -0
  373. package/dist/services/llm-proxy/proxy-runtime.js +65 -0
  374. package/dist/services/llm-proxy/proxy-runtime.js.map +1 -0
  375. package/dist/services/llm-proxy/sse.d.ts +13 -3
  376. package/dist/services/llm-proxy/sse.js.map +1 -1
  377. package/dist/services/llm-proxy/ssrf.d.ts +11 -4
  378. package/dist/services/llm-proxy/ssrf.js +45 -7
  379. package/dist/services/llm-proxy/ssrf.js.map +1 -1
  380. package/dist/services/llm-proxy/validate-key.js +27 -51
  381. package/dist/services/llm-proxy/validate-key.js.map +1 -1
  382. package/dist/services/repair/runtime-repair.d.ts +22 -0
  383. package/dist/services/repair/runtime-repair.js +307 -0
  384. package/dist/services/repair/runtime-repair.js.map +1 -0
  385. package/dist/services/runtime/driver-registry.d.ts +21 -0
  386. package/dist/services/runtime/driver-registry.js +22 -0
  387. package/dist/services/runtime/driver-registry.js.map +1 -0
  388. package/dist/services/runtime/drivers/nomad.d.ts +260 -0
  389. package/dist/services/runtime/drivers/nomad.js +3092 -0
  390. package/dist/services/runtime/drivers/nomad.js.map +1 -0
  391. package/dist/services/runtime/errors.d.ts +3 -3
  392. package/dist/services/runtime/errors.js +3 -3
  393. package/dist/services/runtime/instance.d.ts +14 -16
  394. package/dist/services/runtime/instance.js +93 -110
  395. package/dist/services/runtime/instance.js.map +1 -1
  396. package/dist/services/runtime/job-id.d.ts +9 -0
  397. package/dist/services/runtime/job-id.js +15 -0
  398. package/dist/services/runtime/job-id.js.map +1 -0
  399. package/dist/services/runtime/mcp-shims/firewall.d.ts +2 -2
  400. package/dist/services/runtime/mcp-shims/firewall.js +2 -2
  401. package/dist/services/runtime/mcp-shims/searxng-shim.d.ts +3 -5
  402. package/dist/services/runtime/mcp-shims/searxng-shim.js +3 -5
  403. package/dist/services/runtime/mcp-shims/searxng-shim.js.map +1 -1
  404. package/dist/services/runtime/mcp-shims/write-mcp-entry.d.ts +20 -20
  405. package/dist/services/runtime/mcp-shims/write-mcp-entry.js +16 -16
  406. package/dist/services/runtime/mcp-shims/write-mcp-entry.js.map +1 -1
  407. package/dist/services/runtime/ownership-marker.d.ts +83 -0
  408. package/dist/services/runtime/ownership-marker.js +109 -0
  409. package/dist/services/runtime/ownership-marker.js.map +1 -0
  410. package/dist/services/runtime/types.d.ts +23 -511
  411. package/dist/services/runtime/types.js +0 -12
  412. package/dist/services/runtime/types.js.map +1 -1
  413. package/dist/services/runtime/workload-compiler.d.ts +17 -0
  414. package/dist/services/runtime/workload-compiler.js +525 -0
  415. package/dist/services/runtime/workload-compiler.js.map +1 -0
  416. package/dist/services/runtime/workload-types.d.ts +11 -0
  417. package/dist/services/runtime/workload-types.js +2 -0
  418. package/dist/services/runtime/workload-types.js.map +1 -0
  419. package/dist/services/setup/core-manager.d.ts +50 -0
  420. package/dist/services/setup/core-manager.js +456 -0
  421. package/dist/services/setup/core-manager.js.map +1 -0
  422. package/dist/services/setup/plugin-installer.js +136 -0
  423. package/dist/services/setup/plugin-installer.js.map +1 -0
  424. package/dist/services/setup/setup-manager.d.ts +158 -0
  425. package/dist/services/setup/setup-manager.js +2768 -0
  426. package/dist/services/setup/setup-manager.js.map +1 -0
  427. package/dist/services/system/cli-command.d.ts +5 -0
  428. package/dist/services/system/cli-command.js +18 -0
  429. package/dist/services/system/cli-command.js.map +1 -0
  430. package/dist/services/system/macos-launchd.d.ts +100 -0
  431. package/dist/services/system/macos-launchd.js +312 -0
  432. package/dist/services/system/macos-launchd.js.map +1 -0
  433. package/dist/services/system/repair-orchestrator.d.ts +71 -0
  434. package/dist/services/system/repair-orchestrator.js +412 -0
  435. package/dist/services/system/repair-orchestrator.js.map +1 -0
  436. package/dist/services/system/system-monitor.js +96 -0
  437. package/dist/services/system/system-monitor.js.map +1 -0
  438. package/dist/services/system/system-ollama-provider.d.ts +14 -0
  439. package/dist/services/system/system-ollama-provider.js +129 -0
  440. package/dist/services/system/system-ollama-provider.js.map +1 -0
  441. package/dist/services/system/system-reconciler.d.ts +59 -0
  442. package/dist/services/system/system-reconciler.js +710 -0
  443. package/dist/services/system/system-reconciler.js.map +1 -0
  444. package/dist/services/system/update-manager.d.ts +43 -0
  445. package/dist/services/system/update-manager.js +315 -0
  446. package/dist/services/system/update-manager.js.map +1 -0
  447. package/dist/services/system/upgrade-finalize.d.ts +80 -0
  448. package/dist/services/system/upgrade-finalize.js +507 -0
  449. package/dist/services/system/upgrade-finalize.js.map +1 -0
  450. package/dist/services/tasks/registry.d.ts +44 -0
  451. package/dist/services/tasks/registry.js +90 -0
  452. package/dist/services/tasks/registry.js.map +1 -0
  453. package/dist/services/telemetry/activation.d.ts +8 -4
  454. package/dist/services/telemetry/activation.js +12 -8
  455. package/dist/services/telemetry/activation.js.map +1 -1
  456. package/dist/services/telemetry/device-fingerprint.js +6 -1
  457. package/dist/services/telemetry/device-fingerprint.js.map +1 -1
  458. package/dist/services/telemetry/heartbeat.d.ts +8 -4
  459. package/dist/services/telemetry/heartbeat.js +12 -8
  460. package/dist/services/telemetry/heartbeat.js.map +1 -1
  461. package/dist/services/workspaces/builder.d.ts +29 -0
  462. package/dist/services/workspaces/builder.js +186 -0
  463. package/dist/services/workspaces/builder.js.map +1 -0
  464. package/dist/types.d.ts +361 -72
  465. package/dist/utils/docker-inspect.d.ts +19 -0
  466. package/dist/utils/docker-inspect.js +74 -0
  467. package/dist/utils/docker-inspect.js.map +1 -0
  468. package/dist/utils/instance-lock.d.ts +2 -2
  469. package/dist/utils/instance-lock.js +2 -2
  470. package/dist/utils/sudo-askpass.d.ts +23 -0
  471. package/dist/utils/sudo-askpass.js +83 -0
  472. package/dist/utils/sudo-askpass.js.map +1 -0
  473. package/install/jishu-install.sh +627 -109
  474. package/install/jishu-uninstall.sh +48 -12
  475. package/install/post-install.sh +316 -93
  476. package/install/post-uninstall.sh +99 -9
  477. package/node_modules/@fastify/accept-negotiator/LICENSE +22 -0
  478. package/node_modules/@fastify/accept-negotiator/README.md +52 -0
  479. package/node_modules/@fastify/accept-negotiator/index.js +170 -0
  480. package/node_modules/@fastify/accept-negotiator/package.json +77 -0
  481. package/node_modules/@fastify/accept-negotiator/types/index.d.ts +17 -0
  482. package/node_modules/@fastify/ajv-compiler/.gitattributes +2 -0
  483. package/node_modules/@fastify/ajv-compiler/.github/.stale.yml +21 -0
  484. package/node_modules/@fastify/ajv-compiler/.github/dependabot.yml +13 -0
  485. package/node_modules/@fastify/ajv-compiler/.github/tests_checker.yml +8 -0
  486. package/node_modules/@fastify/ajv-compiler/.github/workflows/ci.yml +33 -0
  487. package/node_modules/@fastify/ajv-compiler/LICENSE +23 -0
  488. package/node_modules/@fastify/ajv-compiler/README.md +237 -0
  489. package/node_modules/@fastify/ajv-compiler/benchmark/small-object.mjs +37 -0
  490. package/node_modules/@fastify/ajv-compiler/eslint.config.js +6 -0
  491. package/node_modules/@fastify/ajv-compiler/index.js +53 -0
  492. package/node_modules/@fastify/ajv-compiler/lib/default-ajv-options.js +14 -0
  493. package/node_modules/@fastify/ajv-compiler/lib/serializer-compiler.js +27 -0
  494. package/node_modules/@fastify/ajv-compiler/lib/validator-compiler.js +58 -0
  495. package/node_modules/@fastify/ajv-compiler/package.json +84 -0
  496. package/node_modules/@fastify/ajv-compiler/standalone.js +44 -0
  497. package/node_modules/@fastify/ajv-compiler/test/.gitkeep +0 -0
  498. package/node_modules/@fastify/ajv-compiler/test/duplicated-id-compile.test.js +55 -0
  499. package/node_modules/@fastify/ajv-compiler/test/index.test.js +307 -0
  500. package/node_modules/@fastify/ajv-compiler/test/plugins.test.js +246 -0
  501. package/node_modules/@fastify/ajv-compiler/test/serialization.test.js +279 -0
  502. package/node_modules/@fastify/ajv-compiler/test/standalone.test.js +203 -0
  503. package/node_modules/@fastify/ajv-compiler/types/index.d.ts +87 -0
  504. package/node_modules/@fastify/ajv-compiler/types/index.test-d.ts +302 -0
  505. package/node_modules/@fastify/error/.gitattributes +2 -0
  506. package/node_modules/@fastify/error/.github/dependabot.yml +13 -0
  507. package/node_modules/@fastify/error/.github/workflows/ci.yml +28 -0
  508. package/node_modules/@fastify/error/LICENSE +21 -0
  509. package/node_modules/@fastify/error/README.md +140 -0
  510. package/node_modules/@fastify/error/benchmarks/create.js +9 -0
  511. package/node_modules/@fastify/error/benchmarks/instantiate.js +18 -0
  512. package/node_modules/@fastify/error/benchmarks/no-stack.js +13 -0
  513. package/node_modules/@fastify/error/benchmarks/toString.js +11 -0
  514. package/node_modules/@fastify/error/eslint.config.js +6 -0
  515. package/node_modules/@fastify/error/index.js +100 -0
  516. package/node_modules/@fastify/error/package.json +75 -0
  517. package/node_modules/@fastify/error/test/index.test.js +232 -0
  518. package/node_modules/@fastify/error/test/instanceof.test.js +263 -0
  519. package/node_modules/@fastify/error/types/index.d.ts +49 -0
  520. package/node_modules/@fastify/error/types/index.test-d.ts +92 -0
  521. package/node_modules/@fastify/fast-json-stringify-compiler/.eslintrc +1 -0
  522. package/node_modules/@fastify/fast-json-stringify-compiler/.gitattributes +2 -0
  523. package/node_modules/@fastify/fast-json-stringify-compiler/.github/dependabot.yml +13 -0
  524. package/node_modules/@fastify/fast-json-stringify-compiler/.github/workflows/ci.yml +28 -0
  525. package/node_modules/@fastify/fast-json-stringify-compiler/LICENSE +21 -0
  526. package/node_modules/@fastify/fast-json-stringify-compiler/README.md +128 -0
  527. package/node_modules/@fastify/fast-json-stringify-compiler/eslint.config.js +6 -0
  528. package/node_modules/@fastify/fast-json-stringify-compiler/index.js +8 -0
  529. package/node_modules/@fastify/fast-json-stringify-compiler/package.json +71 -0
  530. package/node_modules/@fastify/fast-json-stringify-compiler/standalone.js +58 -0
  531. package/node_modules/@fastify/fast-json-stringify-compiler/test/duplicate-schema.test.js +26 -0
  532. package/node_modules/@fastify/fast-json-stringify-compiler/test/plugin.test.js +78 -0
  533. package/node_modules/@fastify/fast-json-stringify-compiler/test/standalone.test.js +230 -0
  534. package/node_modules/@fastify/fast-json-stringify-compiler/types/index.d.ts +41 -0
  535. package/node_modules/@fastify/fast-json-stringify-compiler/types/index.test-d.ts +142 -0
  536. package/node_modules/@fastify/forwarded/LICENSE +24 -0
  537. package/node_modules/@fastify/forwarded/README.md +43 -0
  538. package/node_modules/@fastify/forwarded/index.js +59 -0
  539. package/node_modules/@fastify/forwarded/package.json +74 -0
  540. package/node_modules/@fastify/forwarded/types/index.d.ts +14 -0
  541. package/node_modules/@fastify/merge-json-schemas/.gitattributes +2 -0
  542. package/node_modules/@fastify/merge-json-schemas/.github/dependabot.yml +13 -0
  543. package/node_modules/@fastify/merge-json-schemas/.github/workflows/ci.yml +23 -0
  544. package/node_modules/@fastify/merge-json-schemas/LICENSE +21 -0
  545. package/node_modules/@fastify/merge-json-schemas/README.md +119 -0
  546. package/node_modules/@fastify/merge-json-schemas/eslint.config.js +6 -0
  547. package/node_modules/@fastify/merge-json-schemas/index.js +357 -0
  548. package/node_modules/@fastify/merge-json-schemas/lib/errors.js +36 -0
  549. package/node_modules/@fastify/merge-json-schemas/lib/resolvers.js +127 -0
  550. package/node_modules/@fastify/merge-json-schemas/package.json +67 -0
  551. package/node_modules/@fastify/merge-json-schemas/test/additional-items.test.js +164 -0
  552. package/node_modules/@fastify/merge-json-schemas/test/additional-properties.test.js +129 -0
  553. package/node_modules/@fastify/merge-json-schemas/test/all-of.test.js +43 -0
  554. package/node_modules/@fastify/merge-json-schemas/test/any-of.test.js +81 -0
  555. package/node_modules/@fastify/merge-json-schemas/test/const.test.js +58 -0
  556. package/node_modules/@fastify/merge-json-schemas/test/contains.test.js +55 -0
  557. package/node_modules/@fastify/merge-json-schemas/test/custom-resolvers.test.js +50 -0
  558. package/node_modules/@fastify/merge-json-schemas/test/default-resolver.test.js +111 -0
  559. package/node_modules/@fastify/merge-json-schemas/test/default.test.js +50 -0
  560. package/node_modules/@fastify/merge-json-schemas/test/definitions.test.js +46 -0
  561. package/node_modules/@fastify/merge-json-schemas/test/defs.test.js +46 -0
  562. package/node_modules/@fastify/merge-json-schemas/test/dependencies.test.js +75 -0
  563. package/node_modules/@fastify/merge-json-schemas/test/dependent-required.test.js +75 -0
  564. package/node_modules/@fastify/merge-json-schemas/test/dependent-schemas.test.js +76 -0
  565. package/node_modules/@fastify/merge-json-schemas/test/enum.test.js +44 -0
  566. package/node_modules/@fastify/merge-json-schemas/test/exclusive-maximum.test.js +30 -0
  567. package/node_modules/@fastify/merge-json-schemas/test/exclusive-minimum.test.js +30 -0
  568. package/node_modules/@fastify/merge-json-schemas/test/format.test.js +36 -0
  569. package/node_modules/@fastify/merge-json-schemas/test/id.test.js +22 -0
  570. package/node_modules/@fastify/merge-json-schemas/test/if-then-else.test.js +550 -0
  571. package/node_modules/@fastify/merge-json-schemas/test/items.test.js +152 -0
  572. package/node_modules/@fastify/merge-json-schemas/test/max-items.test.js +30 -0
  573. package/node_modules/@fastify/merge-json-schemas/test/max-length.test.js +30 -0
  574. package/node_modules/@fastify/merge-json-schemas/test/max-properties.test.js +30 -0
  575. package/node_modules/@fastify/merge-json-schemas/test/maximum.test.js +30 -0
  576. package/node_modules/@fastify/merge-json-schemas/test/merge-schema.test.js +29 -0
  577. package/node_modules/@fastify/merge-json-schemas/test/min-items.test.js +30 -0
  578. package/node_modules/@fastify/merge-json-schemas/test/min-length.test.js +30 -0
  579. package/node_modules/@fastify/merge-json-schemas/test/min-properties.test.js +30 -0
  580. package/node_modules/@fastify/merge-json-schemas/test/minimum.test.js +30 -0
  581. package/node_modules/@fastify/merge-json-schemas/test/multiple-of.test.js +36 -0
  582. package/node_modules/@fastify/merge-json-schemas/test/not.test.js +29 -0
  583. package/node_modules/@fastify/merge-json-schemas/test/nullable.test.js +30 -0
  584. package/node_modules/@fastify/merge-json-schemas/test/one-of.test.js +144 -0
  585. package/node_modules/@fastify/merge-json-schemas/test/properties.test.js +312 -0
  586. package/node_modules/@fastify/merge-json-schemas/test/property-names.test.js +49 -0
  587. package/node_modules/@fastify/merge-json-schemas/test/required.test.js +30 -0
  588. package/node_modules/@fastify/merge-json-schemas/test/type.test.js +52 -0
  589. package/node_modules/@fastify/merge-json-schemas/test/unique-items.test.js +38 -0
  590. package/node_modules/@fastify/merge-json-schemas/test/utils.js +9 -0
  591. package/node_modules/@fastify/merge-json-schemas/types/index.d.ts +61 -0
  592. package/node_modules/@fastify/merge-json-schemas/types/index.test-d.ts +52 -0
  593. package/node_modules/@fastify/proxy-addr/.gitattributes +2 -0
  594. package/node_modules/@fastify/proxy-addr/.github/dependabot.yml +13 -0
  595. package/node_modules/@fastify/proxy-addr/.github/stale.yml +21 -0
  596. package/node_modules/@fastify/proxy-addr/.github/workflows/ci.yml +28 -0
  597. package/node_modules/@fastify/proxy-addr/LICENSE +24 -0
  598. package/node_modules/@fastify/proxy-addr/README.md +141 -0
  599. package/node_modules/@fastify/proxy-addr/benchmark/compiling.js +50 -0
  600. package/node_modules/@fastify/proxy-addr/benchmark/index.js +30 -0
  601. package/node_modules/@fastify/proxy-addr/benchmark/kind.js +57 -0
  602. package/node_modules/@fastify/proxy-addr/benchmark/matching.js +78 -0
  603. package/node_modules/@fastify/proxy-addr/eslint.config.js +6 -0
  604. package/node_modules/@fastify/proxy-addr/index.js +331 -0
  605. package/node_modules/@fastify/proxy-addr/package.json +73 -0
  606. package/node_modules/@fastify/proxy-addr/test/all.test.js +55 -0
  607. package/node_modules/@fastify/proxy-addr/test/base.test.js +365 -0
  608. package/node_modules/@fastify/proxy-addr/test/compile.test.js +58 -0
  609. package/node_modules/@fastify/proxy-addr/types/index.d.ts +18 -0
  610. package/node_modules/@fastify/proxy-addr/types/index.test-d.ts +27 -0
  611. package/node_modules/@fastify/send/.gitattributes +2 -0
  612. package/node_modules/@fastify/send/.github/dependabot.yml +13 -0
  613. package/node_modules/@fastify/send/.github/workflows/ci.yml +28 -0
  614. package/node_modules/@fastify/send/HISTORY.md +521 -0
  615. package/node_modules/@fastify/send/LICENSE +23 -0
  616. package/node_modules/@fastify/send/README.md +310 -0
  617. package/node_modules/@fastify/send/benchmarks/collapseLeadingSlashes.js +13 -0
  618. package/node_modules/@fastify/send/benchmarks/containsDotFile.js +15 -0
  619. package/node_modules/@fastify/send/benchmarks/isUtf8MimeType.js +23 -0
  620. package/node_modules/@fastify/send/benchmarks/normalizeList.js +14 -0
  621. package/node_modules/@fastify/send/benchmarks/parseBytesRange.js +15 -0
  622. package/node_modules/@fastify/send/eslint.config.js +6 -0
  623. package/node_modules/@fastify/send/examples/index.html +1 -0
  624. package/node_modules/@fastify/send/examples/simple.js +15 -0
  625. package/node_modules/@fastify/send/index.js +28 -0
  626. package/node_modules/@fastify/send/lib/collapseLeadingSlashes.js +25 -0
  627. package/node_modules/@fastify/send/lib/containsDotFile.js +23 -0
  628. package/node_modules/@fastify/send/lib/contentRange.js +18 -0
  629. package/node_modules/@fastify/send/lib/createHtmlDocument.js +29 -0
  630. package/node_modules/@fastify/send/lib/createHttpError.js +23 -0
  631. package/node_modules/@fastify/send/lib/isUtf8MimeType.js +12 -0
  632. package/node_modules/@fastify/send/lib/normalizeList.js +28 -0
  633. package/node_modules/@fastify/send/lib/parseBytesRange.js +133 -0
  634. package/node_modules/@fastify/send/lib/parseTokenList.js +46 -0
  635. package/node_modules/@fastify/send/lib/send.js +729 -0
  636. package/node_modules/@fastify/send/package.json +81 -0
  637. package/node_modules/@fastify/send/test/collapseLeadingSlashes.test.js +22 -0
  638. package/node_modules/@fastify/send/test/containsDotFile.test.js +18 -0
  639. package/node_modules/@fastify/send/test/fixtures/.hidden.txt +1 -0
  640. package/node_modules/@fastify/send/test/fixtures/.mine/.hidden.txt +1 -0
  641. package/node_modules/@fastify/send/test/fixtures/.mine/name.txt +1 -0
  642. package/node_modules/@fastify/send/test/fixtures/do..ts.txt +1 -0
  643. package/node_modules/@fastify/send/test/fixtures/empty.txt +0 -0
  644. package/node_modules/@fastify/send/test/fixtures/images/node-js.png +0 -0
  645. package/node_modules/@fastify/send/test/fixtures/name.d/name.txt +1 -0
  646. package/node_modules/@fastify/send/test/fixtures/name.dir/name.txt +1 -0
  647. package/node_modules/@fastify/send/test/fixtures/name.html +1 -0
  648. package/node_modules/@fastify/send/test/fixtures/name.txt +1 -0
  649. package/node_modules/@fastify/send/test/fixtures/no_ext +1 -0
  650. package/node_modules/@fastify/send/test/fixtures/nums.txt +1 -0
  651. package/node_modules/@fastify/send/test/fixtures/pets/.hidden.txt +1 -0
  652. package/node_modules/@fastify/send/test/fixtures/pets/index.html +3 -0
  653. package/node_modules/@fastify/send/test/fixtures/snow /342/230/203/index.html +0 -0
  654. package/node_modules/@fastify/send/test/fixtures/some thing.txt +1 -0
  655. package/node_modules/@fastify/send/test/fixtures/thing.html.html +1 -0
  656. package/node_modules/@fastify/send/test/fixtures/tobi.html +1 -0
  657. package/node_modules/@fastify/send/test/isUtf8MimeType.test.js +22 -0
  658. package/node_modules/@fastify/send/test/mime.test.js +56 -0
  659. package/node_modules/@fastify/send/test/normalizeList.test.js +28 -0
  660. package/node_modules/@fastify/send/test/parseBytesRange.test.js +103 -0
  661. package/node_modules/@fastify/send/test/send.1.test.js +646 -0
  662. package/node_modules/@fastify/send/test/send.2.test.js +977 -0
  663. package/node_modules/@fastify/send/test/send.3.test.js +133 -0
  664. package/node_modules/@fastify/send/test/utils.js +36 -0
  665. package/node_modules/@fastify/send/types/index.d.ts +167 -0
  666. package/node_modules/@fastify/send/types/index.test-d.ts +67 -0
  667. package/node_modules/@fastify/static/.gitattributes +5 -0
  668. package/node_modules/@fastify/static/.github/dependabot.yml +13 -0
  669. package/node_modules/@fastify/static/.github/workflows/ci.yml +33 -0
  670. package/node_modules/@fastify/static/.github/workflows/lock-threads.yml +19 -0
  671. package/node_modules/@fastify/static/LICENSE +21 -0
  672. package/node_modules/@fastify/static/README.md +538 -0
  673. package/node_modules/@fastify/static/eslint.config.js +7 -0
  674. package/node_modules/@fastify/static/example/public/.hidden/sample.json +1 -0
  675. package/node_modules/@fastify/static/example/public/images/sample.jpg +0 -0
  676. package/node_modules/@fastify/static/example/public/index.css +9 -0
  677. package/node_modules/@fastify/static/example/public/index.html +11 -0
  678. package/node_modules/@fastify/static/example/public/index.js +8 -0
  679. package/node_modules/@fastify/static/example/public2/test.css +4 -0
  680. package/node_modules/@fastify/static/example/public2/test.html +8 -0
  681. package/node_modules/@fastify/static/example/server-benchmark.js +39 -0
  682. package/node_modules/@fastify/static/example/server-compress.js +15 -0
  683. package/node_modules/@fastify/static/example/server-dir-list.js +38 -0
  684. package/node_modules/@fastify/static/example/server-hidden-file.js +15 -0
  685. package/node_modules/@fastify/static/example/server.js +13 -0
  686. package/node_modules/@fastify/static/index.js +726 -0
  687. package/node_modules/@fastify/static/lib/dirList.js +225 -0
  688. package/node_modules/@fastify/static/package.json +89 -0
  689. package/node_modules/@fastify/static/test/content-type/binary +0 -0
  690. package/node_modules/@fastify/static/test/content-type/binary.br +1 -0
  691. package/node_modules/@fastify/static/test/content-type/index.css +0 -0
  692. package/node_modules/@fastify/static/test/content-type/index.css.br +1 -0
  693. package/node_modules/@fastify/static/test/content-type/index.html +5 -0
  694. package/node_modules/@fastify/static/test/content-type/index.html.br +0 -0
  695. package/node_modules/@fastify/static/test/content-type/sample.jpg +0 -0
  696. package/node_modules/@fastify/static/test/content-type/test.txt +0 -0
  697. package/node_modules/@fastify/static/test/content-type/test.txt.br +1 -0
  698. package/node_modules/@fastify/static/test/content-type.test.js +144 -0
  699. package/node_modules/@fastify/static/test/dir-list.test.js +820 -0
  700. package/node_modules/@fastify/static/test/static/.example +1 -0
  701. package/node_modules/@fastify/static/test/static/100%.txt +1 -0
  702. package/node_modules/@fastify/static/test/static/a .md +1 -0
  703. package/node_modules/@fastify/static/test/static/deep/path/for/test/index.html +5 -0
  704. package/node_modules/@fastify/static/test/static/deep/path/for/test/purpose/foo.html +5 -0
  705. package/node_modules/@fastify/static/test/static/foo.html +3 -0
  706. package/node_modules/@fastify/static/test/static/foobar.html +3 -0
  707. package/node_modules/@fastify/static/test/static/index.css +0 -0
  708. package/node_modules/@fastify/static/test/static/index.html +5 -0
  709. package/node_modules/@fastify/static/test/static/shallow/sample.jpg +0 -0
  710. package/node_modules/@fastify/static/test/static-dotfiles/.aaa +0 -0
  711. package/node_modules/@fastify/static/test/static-dotfiles/dir/index.html +0 -0
  712. package/node_modules/@fastify/static/test/static-dotfiles/test.txt +0 -0
  713. package/node_modules/@fastify/static/test/static-encode/[...]/a .md +1 -0
  714. package/node_modules/@fastify/static/test/static-filtered/bar.private +1 -0
  715. package/node_modules/@fastify/static/test/static-filtered/deep/path/to/baz.html +3 -0
  716. package/node_modules/@fastify/static/test/static-filtered/deep/path/to/baz.private +1 -0
  717. package/node_modules/@fastify/static/test/static-filtered/index.html +3 -0
  718. package/node_modules/@fastify/static/test/static-hidden/.hidden/sample.json +1 -0
  719. package/node_modules/@fastify/static/test/static-pre-compressed/all-three.html +5 -0
  720. package/node_modules/@fastify/static/test/static-pre-compressed/all-three.html.br +0 -0
  721. package/node_modules/@fastify/static/test/static-pre-compressed/all-three.html.gz +0 -0
  722. package/node_modules/@fastify/static/test/static-pre-compressed/baz.json +3 -0
  723. package/node_modules/@fastify/static/test/static-pre-compressed/dir/index.html +5 -0
  724. package/node_modules/@fastify/static/test/static-pre-compressed/dir/index.html.br +0 -0
  725. package/node_modules/@fastify/static/test/static-pre-compressed/dir-gz/index.html +5 -0
  726. package/node_modules/@fastify/static/test/static-pre-compressed/dir-gz/index.html.gz +0 -0
  727. package/node_modules/@fastify/static/test/static-pre-compressed/empty/.gitkeep +0 -0
  728. package/node_modules/@fastify/static/test/static-pre-compressed/gzip-only.html +3 -0
  729. package/node_modules/@fastify/static/test/static-pre-compressed/gzip-only.html.gz +0 -0
  730. package/node_modules/@fastify/static/test/static-pre-compressed/index.html +5 -0
  731. package/node_modules/@fastify/static/test/static-pre-compressed/index.html.br +0 -0
  732. package/node_modules/@fastify/static/test/static-pre-compressed/sample.jpg +0 -0
  733. package/node_modules/@fastify/static/test/static-pre-compressed/sample.jpg.br +0 -0
  734. package/node_modules/@fastify/static/test/static-pre-compressed/uncompressed.html +3 -0
  735. package/node_modules/@fastify/static/test/static-symbolic-link/origin/subdir/subdir/index.html +3 -0
  736. package/node_modules/@fastify/static/test/static.test.js +4115 -0
  737. package/node_modules/@fastify/static/test/static2/bar.html +3 -0
  738. package/node_modules/@fastify/static/test/static2/index.html +3 -0
  739. package/node_modules/@fastify/static/types/index.d.ts +136 -0
  740. package/node_modules/@fastify/static/types/index.test-d.ts +240 -0
  741. package/node_modules/@lukeed/ms/dist/index.js +37 -0
  742. package/node_modules/@lukeed/ms/dist/index.min.js +1 -0
  743. package/node_modules/@lukeed/ms/dist/index.mjs +34 -0
  744. package/node_modules/@lukeed/ms/index.d.ts +2 -0
  745. package/node_modules/@lukeed/ms/license +9 -0
  746. package/node_modules/@lukeed/ms/package.json +48 -0
  747. package/node_modules/@lukeed/ms/readme.md +133 -0
  748. package/node_modules/@pinojs/redact/.github/dependabot.yml +13 -0
  749. package/node_modules/@pinojs/redact/.github/workflows/ci.yml +48 -0
  750. package/node_modules/@pinojs/redact/.github/workflows/publish-release.yml +43 -0
  751. package/node_modules/@pinojs/redact/LICENSE +21 -0
  752. package/node_modules/@pinojs/redact/README.md +350 -0
  753. package/node_modules/@pinojs/redact/benchmarks/basic.js +184 -0
  754. package/node_modules/@pinojs/redact/eslint.config.js +1 -0
  755. package/node_modules/@pinojs/redact/index.d.ts +52 -0
  756. package/node_modules/@pinojs/redact/index.js +529 -0
  757. package/node_modules/@pinojs/redact/index.test-d.ts +22 -0
  758. package/node_modules/@pinojs/redact/package.json +37 -0
  759. package/node_modules/@pinojs/redact/scripts/sync-version.mjs +20 -0
  760. package/node_modules/@pinojs/redact/test/actual-redact-comparison.test.js +211 -0
  761. package/node_modules/@pinojs/redact/test/index.test.js +824 -0
  762. package/node_modules/@pinojs/redact/test/integration.test.js +390 -0
  763. package/node_modules/@pinojs/redact/test/multiple-wildcards.test.js +227 -0
  764. package/node_modules/@pinojs/redact/test/prototype-pollution.test.js +223 -0
  765. package/node_modules/@pinojs/redact/test/selective-clone.test.js +115 -0
  766. package/node_modules/@pinojs/redact/tsconfig.json +19 -0
  767. package/node_modules/abstract-logging/Readme.md +47 -0
  768. package/node_modules/abstract-logging/index.js +18 -0
  769. package/node_modules/abstract-logging/package.json +25 -0
  770. package/node_modules/abstract-logging/test.js +17 -0
  771. package/node_modules/ajv/.runkit_example.js +23 -0
  772. package/node_modules/ajv/LICENSE +22 -0
  773. package/node_modules/ajv/README.md +207 -0
  774. package/node_modules/ajv/dist/2019.d.ts +19 -0
  775. package/node_modules/ajv/dist/2019.js +61 -0
  776. package/node_modules/ajv/dist/2019.js.map +1 -0
  777. package/node_modules/ajv/dist/2020.d.ts +19 -0
  778. package/node_modules/ajv/dist/2020.js +55 -0
  779. package/node_modules/ajv/dist/2020.js.map +1 -0
  780. package/node_modules/ajv/dist/ajv.d.ts +18 -0
  781. package/node_modules/ajv/dist/ajv.js +50 -0
  782. package/node_modules/ajv/dist/ajv.js.map +1 -0
  783. package/node_modules/ajv/dist/compile/codegen/code.d.ts +40 -0
  784. package/node_modules/ajv/dist/compile/codegen/code.js +156 -0
  785. package/node_modules/ajv/dist/compile/codegen/code.js.map +1 -0
  786. package/node_modules/ajv/dist/compile/codegen/index.d.ts +79 -0
  787. package/node_modules/ajv/dist/compile/codegen/index.js +697 -0
  788. package/node_modules/ajv/dist/compile/codegen/index.js.map +1 -0
  789. package/node_modules/ajv/dist/compile/codegen/scope.d.ts +79 -0
  790. package/node_modules/ajv/dist/compile/codegen/scope.js +143 -0
  791. package/node_modules/ajv/dist/compile/codegen/scope.js.map +1 -0
  792. package/node_modules/ajv/dist/compile/errors.d.ts +13 -0
  793. package/node_modules/ajv/dist/compile/errors.js +123 -0
  794. package/node_modules/ajv/dist/compile/errors.js.map +1 -0
  795. package/node_modules/ajv/dist/compile/index.d.ts +80 -0
  796. package/node_modules/ajv/dist/compile/index.js +242 -0
  797. package/node_modules/ajv/dist/compile/index.js.map +1 -0
  798. package/node_modules/ajv/dist/compile/jtd/parse.d.ts +4 -0
  799. package/node_modules/ajv/dist/compile/jtd/parse.js +350 -0
  800. package/node_modules/ajv/dist/compile/jtd/parse.js.map +1 -0
  801. package/node_modules/ajv/dist/compile/jtd/serialize.d.ts +4 -0
  802. package/node_modules/ajv/dist/compile/jtd/serialize.js +236 -0
  803. package/node_modules/ajv/dist/compile/jtd/serialize.js.map +1 -0
  804. package/node_modules/ajv/dist/compile/jtd/types.d.ts +6 -0
  805. package/node_modules/ajv/dist/compile/jtd/types.js +14 -0
  806. package/node_modules/ajv/dist/compile/jtd/types.js.map +1 -0
  807. package/node_modules/ajv/dist/compile/names.d.ts +20 -0
  808. package/node_modules/ajv/dist/compile/names.js +28 -0
  809. package/node_modules/ajv/dist/compile/names.js.map +1 -0
  810. package/node_modules/ajv/dist/compile/ref_error.d.ts +6 -0
  811. package/node_modules/ajv/dist/compile/ref_error.js +12 -0
  812. package/node_modules/ajv/dist/compile/ref_error.js.map +1 -0
  813. package/node_modules/ajv/dist/compile/resolve.d.ts +12 -0
  814. package/node_modules/ajv/dist/compile/resolve.js +155 -0
  815. package/node_modules/ajv/dist/compile/resolve.js.map +1 -0
  816. package/node_modules/ajv/dist/compile/rules.d.ts +28 -0
  817. package/node_modules/ajv/dist/compile/rules.js +26 -0
  818. package/node_modules/ajv/dist/compile/rules.js.map +1 -0
  819. package/node_modules/ajv/dist/compile/util.d.ts +40 -0
  820. package/node_modules/ajv/dist/compile/util.js +178 -0
  821. package/node_modules/ajv/dist/compile/util.js.map +1 -0
  822. package/node_modules/ajv/dist/compile/validate/applicability.d.ts +6 -0
  823. package/node_modules/ajv/dist/compile/validate/applicability.js +19 -0
  824. package/node_modules/ajv/dist/compile/validate/applicability.js.map +1 -0
  825. package/node_modules/ajv/dist/compile/validate/boolSchema.d.ts +4 -0
  826. package/node_modules/ajv/dist/compile/validate/boolSchema.js +50 -0
  827. package/node_modules/ajv/dist/compile/validate/boolSchema.js.map +1 -0
  828. package/node_modules/ajv/dist/compile/validate/dataType.d.ts +17 -0
  829. package/node_modules/ajv/dist/compile/validate/dataType.js +203 -0
  830. package/node_modules/ajv/dist/compile/validate/dataType.js.map +1 -0
  831. package/node_modules/ajv/dist/compile/validate/defaults.d.ts +2 -0
  832. package/node_modules/ajv/dist/compile/validate/defaults.js +35 -0
  833. package/node_modules/ajv/dist/compile/validate/defaults.js.map +1 -0
  834. package/node_modules/ajv/dist/compile/validate/index.d.ts +42 -0
  835. package/node_modules/ajv/dist/compile/validate/index.js +520 -0
  836. package/node_modules/ajv/dist/compile/validate/index.js.map +1 -0
  837. package/node_modules/ajv/dist/compile/validate/keyword.d.ts +8 -0
  838. package/node_modules/ajv/dist/compile/validate/keyword.js +124 -0
  839. package/node_modules/ajv/dist/compile/validate/keyword.js.map +1 -0
  840. package/node_modules/ajv/dist/compile/validate/subschema.d.ts +47 -0
  841. package/node_modules/ajv/dist/compile/validate/subschema.js +81 -0
  842. package/node_modules/ajv/dist/compile/validate/subschema.js.map +1 -0
  843. package/node_modules/ajv/dist/core.d.ts +174 -0
  844. package/node_modules/ajv/dist/core.js +618 -0
  845. package/node_modules/ajv/dist/core.js.map +1 -0
  846. package/node_modules/ajv/dist/jtd.d.ts +47 -0
  847. package/node_modules/ajv/dist/jtd.js +72 -0
  848. package/node_modules/ajv/dist/jtd.js.map +1 -0
  849. package/node_modules/ajv/dist/refs/data.json +13 -0
  850. package/node_modules/ajv/dist/refs/json-schema-2019-09/index.d.ts +2 -0
  851. package/node_modules/ajv/dist/refs/json-schema-2019-09/index.js +28 -0
  852. package/node_modules/ajv/dist/refs/json-schema-2019-09/index.js.map +1 -0
  853. package/node_modules/ajv/dist/refs/json-schema-2019-09/meta/applicator.json +53 -0
  854. package/node_modules/ajv/dist/refs/json-schema-2019-09/meta/content.json +17 -0
  855. package/node_modules/ajv/dist/refs/json-schema-2019-09/meta/core.json +57 -0
  856. package/node_modules/ajv/dist/refs/json-schema-2019-09/meta/format.json +14 -0
  857. package/node_modules/ajv/dist/refs/json-schema-2019-09/meta/meta-data.json +37 -0
  858. package/node_modules/ajv/dist/refs/json-schema-2019-09/meta/validation.json +90 -0
  859. package/node_modules/ajv/dist/refs/json-schema-2019-09/schema.json +39 -0
  860. package/node_modules/ajv/dist/refs/json-schema-2020-12/index.d.ts +2 -0
  861. package/node_modules/ajv/dist/refs/json-schema-2020-12/index.js +30 -0
  862. package/node_modules/ajv/dist/refs/json-schema-2020-12/index.js.map +1 -0
  863. package/node_modules/ajv/dist/refs/json-schema-2020-12/meta/applicator.json +48 -0
  864. package/node_modules/ajv/dist/refs/json-schema-2020-12/meta/content.json +17 -0
  865. package/node_modules/ajv/dist/refs/json-schema-2020-12/meta/core.json +51 -0
  866. package/node_modules/ajv/dist/refs/json-schema-2020-12/meta/format-annotation.json +14 -0
  867. package/node_modules/ajv/dist/refs/json-schema-2020-12/meta/meta-data.json +37 -0
  868. package/node_modules/ajv/dist/refs/json-schema-2020-12/meta/unevaluated.json +15 -0
  869. package/node_modules/ajv/dist/refs/json-schema-2020-12/meta/validation.json +90 -0
  870. package/node_modules/ajv/dist/refs/json-schema-2020-12/schema.json +55 -0
  871. package/node_modules/ajv/dist/refs/json-schema-draft-06.json +137 -0
  872. package/node_modules/ajv/dist/refs/json-schema-draft-07.json +151 -0
  873. package/node_modules/ajv/dist/refs/json-schema-secure.json +88 -0
  874. package/node_modules/ajv/dist/refs/jtd-schema.d.ts +3 -0
  875. package/node_modules/ajv/dist/refs/jtd-schema.js +118 -0
  876. package/node_modules/ajv/dist/refs/jtd-schema.js.map +1 -0
  877. package/node_modules/ajv/dist/runtime/equal.d.ts +6 -0
  878. package/node_modules/ajv/dist/runtime/equal.js +7 -0
  879. package/node_modules/ajv/dist/runtime/equal.js.map +1 -0
  880. package/node_modules/ajv/dist/runtime/parseJson.d.ts +18 -0
  881. package/node_modules/ajv/dist/runtime/parseJson.js +185 -0
  882. package/node_modules/ajv/dist/runtime/parseJson.js.map +1 -0
  883. package/node_modules/ajv/dist/runtime/quote.d.ts +5 -0
  884. package/node_modules/ajv/dist/runtime/quote.js +30 -0
  885. package/node_modules/ajv/dist/runtime/quote.js.map +1 -0
  886. package/node_modules/ajv/dist/runtime/re2.d.ts +6 -0
  887. package/node_modules/ajv/dist/runtime/re2.js +6 -0
  888. package/node_modules/ajv/dist/runtime/re2.js.map +1 -0
  889. package/node_modules/ajv/dist/runtime/timestamp.d.ts +5 -0
  890. package/node_modules/ajv/dist/runtime/timestamp.js +42 -0
  891. package/node_modules/ajv/dist/runtime/timestamp.js.map +1 -0
  892. package/node_modules/ajv/dist/runtime/ucs2length.d.ts +5 -0
  893. package/node_modules/ajv/dist/runtime/ucs2length.js +24 -0
  894. package/node_modules/ajv/dist/runtime/ucs2length.js.map +1 -0
  895. package/node_modules/ajv/dist/runtime/uri.d.ts +6 -0
  896. package/node_modules/ajv/dist/runtime/uri.js +6 -0
  897. package/node_modules/ajv/dist/runtime/uri.js.map +1 -0
  898. package/node_modules/ajv/dist/runtime/validation_error.d.ts +7 -0
  899. package/node_modules/ajv/dist/runtime/validation_error.js +11 -0
  900. package/node_modules/ajv/dist/runtime/validation_error.js.map +1 -0
  901. package/node_modules/ajv/dist/standalone/index.d.ts +6 -0
  902. package/node_modules/ajv/dist/standalone/index.js +90 -0
  903. package/node_modules/ajv/dist/standalone/index.js.map +1 -0
  904. package/node_modules/ajv/dist/standalone/instance.d.ts +12 -0
  905. package/node_modules/ajv/dist/standalone/instance.js +35 -0
  906. package/node_modules/ajv/dist/standalone/instance.js.map +1 -0
  907. package/node_modules/ajv/dist/types/index.d.ts +183 -0
  908. package/node_modules/ajv/dist/types/index.js +3 -0
  909. package/node_modules/ajv/dist/types/index.js.map +1 -0
  910. package/node_modules/ajv/dist/types/json-schema.d.ts +125 -0
  911. package/node_modules/ajv/dist/types/json-schema.js +3 -0
  912. package/node_modules/ajv/dist/types/json-schema.js.map +1 -0
  913. package/node_modules/ajv/dist/types/jtd-schema.d.ts +174 -0
  914. package/node_modules/ajv/dist/types/jtd-schema.js +3 -0
  915. package/node_modules/ajv/dist/types/jtd-schema.js.map +1 -0
  916. package/node_modules/ajv/dist/vocabularies/applicator/additionalItems.d.ts +8 -0
  917. package/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js +49 -0
  918. package/node_modules/ajv/dist/vocabularies/applicator/additionalItems.js.map +1 -0
  919. package/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.d.ts +6 -0
  920. package/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js +106 -0
  921. package/node_modules/ajv/dist/vocabularies/applicator/additionalProperties.js.map +1 -0
  922. package/node_modules/ajv/dist/vocabularies/applicator/allOf.d.ts +3 -0
  923. package/node_modules/ajv/dist/vocabularies/applicator/allOf.js +23 -0
  924. package/node_modules/ajv/dist/vocabularies/applicator/allOf.js.map +1 -0
  925. package/node_modules/ajv/dist/vocabularies/applicator/anyOf.d.ts +4 -0
  926. package/node_modules/ajv/dist/vocabularies/applicator/anyOf.js +12 -0
  927. package/node_modules/ajv/dist/vocabularies/applicator/anyOf.js.map +1 -0
  928. package/node_modules/ajv/dist/vocabularies/applicator/contains.d.ts +7 -0
  929. package/node_modules/ajv/dist/vocabularies/applicator/contains.js +95 -0
  930. package/node_modules/ajv/dist/vocabularies/applicator/contains.js.map +1 -0
  931. package/node_modules/ajv/dist/vocabularies/applicator/dependencies.d.ts +21 -0
  932. package/node_modules/ajv/dist/vocabularies/applicator/dependencies.js +85 -0
  933. package/node_modules/ajv/dist/vocabularies/applicator/dependencies.js.map +1 -0
  934. package/node_modules/ajv/dist/vocabularies/applicator/dependentSchemas.d.ts +3 -0
  935. package/node_modules/ajv/dist/vocabularies/applicator/dependentSchemas.js +11 -0
  936. package/node_modules/ajv/dist/vocabularies/applicator/dependentSchemas.js.map +1 -0
  937. package/node_modules/ajv/dist/vocabularies/applicator/if.d.ts +6 -0
  938. package/node_modules/ajv/dist/vocabularies/applicator/if.js +66 -0
  939. package/node_modules/ajv/dist/vocabularies/applicator/if.js.map +1 -0
  940. package/node_modules/ajv/dist/vocabularies/applicator/index.d.ts +13 -0
  941. package/node_modules/ajv/dist/vocabularies/applicator/index.js +44 -0
  942. package/node_modules/ajv/dist/vocabularies/applicator/index.js.map +1 -0
  943. package/node_modules/ajv/dist/vocabularies/applicator/items.d.ts +5 -0
  944. package/node_modules/ajv/dist/vocabularies/applicator/items.js +52 -0
  945. package/node_modules/ajv/dist/vocabularies/applicator/items.js.map +1 -0
  946. package/node_modules/ajv/dist/vocabularies/applicator/items2020.d.ts +6 -0
  947. package/node_modules/ajv/dist/vocabularies/applicator/items2020.js +30 -0
  948. package/node_modules/ajv/dist/vocabularies/applicator/items2020.js.map +1 -0
  949. package/node_modules/ajv/dist/vocabularies/applicator/not.d.ts +4 -0
  950. package/node_modules/ajv/dist/vocabularies/applicator/not.js +26 -0
  951. package/node_modules/ajv/dist/vocabularies/applicator/not.js.map +1 -0
  952. package/node_modules/ajv/dist/vocabularies/applicator/oneOf.d.ts +6 -0
  953. package/node_modules/ajv/dist/vocabularies/applicator/oneOf.js +60 -0
  954. package/node_modules/ajv/dist/vocabularies/applicator/oneOf.js.map +1 -0
  955. package/node_modules/ajv/dist/vocabularies/applicator/patternProperties.d.ts +3 -0
  956. package/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js +75 -0
  957. package/node_modules/ajv/dist/vocabularies/applicator/patternProperties.js.map +1 -0
  958. package/node_modules/ajv/dist/vocabularies/applicator/prefixItems.d.ts +3 -0
  959. package/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js +12 -0
  960. package/node_modules/ajv/dist/vocabularies/applicator/prefixItems.js.map +1 -0
  961. package/node_modules/ajv/dist/vocabularies/applicator/properties.d.ts +3 -0
  962. package/node_modules/ajv/dist/vocabularies/applicator/properties.js +54 -0
  963. package/node_modules/ajv/dist/vocabularies/applicator/properties.js.map +1 -0
  964. package/node_modules/ajv/dist/vocabularies/applicator/propertyNames.d.ts +6 -0
  965. package/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js +38 -0
  966. package/node_modules/ajv/dist/vocabularies/applicator/propertyNames.js.map +1 -0
  967. package/node_modules/ajv/dist/vocabularies/applicator/thenElse.d.ts +3 -0
  968. package/node_modules/ajv/dist/vocabularies/applicator/thenElse.js +13 -0
  969. package/node_modules/ajv/dist/vocabularies/applicator/thenElse.js.map +1 -0
  970. package/node_modules/ajv/dist/vocabularies/code.d.ts +17 -0
  971. package/node_modules/ajv/dist/vocabularies/code.js +131 -0
  972. package/node_modules/ajv/dist/vocabularies/code.js.map +1 -0
  973. package/node_modules/ajv/dist/vocabularies/core/id.d.ts +3 -0
  974. package/node_modules/ajv/dist/vocabularies/core/id.js +10 -0
  975. package/node_modules/ajv/dist/vocabularies/core/id.js.map +1 -0
  976. package/node_modules/ajv/dist/vocabularies/core/index.d.ts +3 -0
  977. package/node_modules/ajv/dist/vocabularies/core/index.js +16 -0
  978. package/node_modules/ajv/dist/vocabularies/core/index.js.map +1 -0
  979. package/node_modules/ajv/dist/vocabularies/core/ref.d.ts +8 -0
  980. package/node_modules/ajv/dist/vocabularies/core/ref.js +122 -0
  981. package/node_modules/ajv/dist/vocabularies/core/ref.js.map +1 -0
  982. package/node_modules/ajv/dist/vocabularies/discriminator/index.d.ts +5 -0
  983. package/node_modules/ajv/dist/vocabularies/discriminator/index.js +104 -0
  984. package/node_modules/ajv/dist/vocabularies/discriminator/index.js.map +1 -0
  985. package/node_modules/ajv/dist/vocabularies/discriminator/types.d.ts +10 -0
  986. package/node_modules/ajv/dist/vocabularies/discriminator/types.js +9 -0
  987. package/node_modules/ajv/dist/vocabularies/discriminator/types.js.map +1 -0
  988. package/node_modules/ajv/dist/vocabularies/draft2020.d.ts +3 -0
  989. package/node_modules/ajv/dist/vocabularies/draft2020.js +23 -0
  990. package/node_modules/ajv/dist/vocabularies/draft2020.js.map +1 -0
  991. package/node_modules/ajv/dist/vocabularies/draft7.d.ts +3 -0
  992. package/node_modules/ajv/dist/vocabularies/draft7.js +17 -0
  993. package/node_modules/ajv/dist/vocabularies/draft7.js.map +1 -0
  994. package/node_modules/ajv/dist/vocabularies/dynamic/dynamicAnchor.d.ts +5 -0
  995. package/node_modules/ajv/dist/vocabularies/dynamic/dynamicAnchor.js +30 -0
  996. package/node_modules/ajv/dist/vocabularies/dynamic/dynamicAnchor.js.map +1 -0
  997. package/node_modules/ajv/dist/vocabularies/dynamic/dynamicRef.d.ts +5 -0
  998. package/node_modules/ajv/dist/vocabularies/dynamic/dynamicRef.js +51 -0
  999. package/node_modules/ajv/dist/vocabularies/dynamic/dynamicRef.js.map +1 -0
  1000. package/node_modules/ajv/dist/vocabularies/dynamic/index.d.ts +3 -0
  1001. package/node_modules/ajv/dist/vocabularies/dynamic/index.js +9 -0
  1002. package/node_modules/ajv/dist/vocabularies/dynamic/index.js.map +1 -0
  1003. package/node_modules/ajv/dist/vocabularies/dynamic/recursiveAnchor.d.ts +3 -0
  1004. package/node_modules/ajv/dist/vocabularies/dynamic/recursiveAnchor.js +16 -0
  1005. package/node_modules/ajv/dist/vocabularies/dynamic/recursiveAnchor.js.map +1 -0
  1006. package/node_modules/ajv/dist/vocabularies/dynamic/recursiveRef.d.ts +3 -0
  1007. package/node_modules/ajv/dist/vocabularies/dynamic/recursiveRef.js +10 -0
  1008. package/node_modules/ajv/dist/vocabularies/dynamic/recursiveRef.js.map +1 -0
  1009. package/node_modules/ajv/dist/vocabularies/errors.d.ts +9 -0
  1010. package/node_modules/ajv/dist/vocabularies/errors.js +3 -0
  1011. package/node_modules/ajv/dist/vocabularies/errors.js.map +1 -0
  1012. package/node_modules/ajv/dist/vocabularies/format/format.d.ts +8 -0
  1013. package/node_modules/ajv/dist/vocabularies/format/format.js +92 -0
  1014. package/node_modules/ajv/dist/vocabularies/format/format.js.map +1 -0
  1015. package/node_modules/ajv/dist/vocabularies/format/index.d.ts +3 -0
  1016. package/node_modules/ajv/dist/vocabularies/format/index.js +6 -0
  1017. package/node_modules/ajv/dist/vocabularies/format/index.js.map +1 -0
  1018. package/node_modules/ajv/dist/vocabularies/jtd/discriminator.d.ts +6 -0
  1019. package/node_modules/ajv/dist/vocabularies/jtd/discriminator.js +71 -0
  1020. package/node_modules/ajv/dist/vocabularies/jtd/discriminator.js.map +1 -0
  1021. package/node_modules/ajv/dist/vocabularies/jtd/elements.d.ts +5 -0
  1022. package/node_modules/ajv/dist/vocabularies/jtd/elements.js +24 -0
  1023. package/node_modules/ajv/dist/vocabularies/jtd/elements.js.map +1 -0
  1024. package/node_modules/ajv/dist/vocabularies/jtd/enum.d.ts +6 -0
  1025. package/node_modules/ajv/dist/vocabularies/jtd/enum.js +43 -0
  1026. package/node_modules/ajv/dist/vocabularies/jtd/enum.js.map +1 -0
  1027. package/node_modules/ajv/dist/vocabularies/jtd/error.d.ts +9 -0
  1028. package/node_modules/ajv/dist/vocabularies/jtd/error.js +20 -0
  1029. package/node_modules/ajv/dist/vocabularies/jtd/error.js.map +1 -0
  1030. package/node_modules/ajv/dist/vocabularies/jtd/index.d.ts +10 -0
  1031. package/node_modules/ajv/dist/vocabularies/jtd/index.js +29 -0
  1032. package/node_modules/ajv/dist/vocabularies/jtd/index.js.map +1 -0
  1033. package/node_modules/ajv/dist/vocabularies/jtd/metadata.d.ts +5 -0
  1034. package/node_modules/ajv/dist/vocabularies/jtd/metadata.js +25 -0
  1035. package/node_modules/ajv/dist/vocabularies/jtd/metadata.js.map +1 -0
  1036. package/node_modules/ajv/dist/vocabularies/jtd/nullable.d.ts +4 -0
  1037. package/node_modules/ajv/dist/vocabularies/jtd/nullable.js +22 -0
  1038. package/node_modules/ajv/dist/vocabularies/jtd/nullable.js.map +1 -0
  1039. package/node_modules/ajv/dist/vocabularies/jtd/optionalProperties.d.ts +3 -0
  1040. package/node_modules/ajv/dist/vocabularies/jtd/optionalProperties.js +15 -0
  1041. package/node_modules/ajv/dist/vocabularies/jtd/optionalProperties.js.map +1 -0
  1042. package/node_modules/ajv/dist/vocabularies/jtd/properties.d.ts +22 -0
  1043. package/node_modules/ajv/dist/vocabularies/jtd/properties.js +149 -0
  1044. package/node_modules/ajv/dist/vocabularies/jtd/properties.js.map +1 -0
  1045. package/node_modules/ajv/dist/vocabularies/jtd/ref.d.ts +4 -0
  1046. package/node_modules/ajv/dist/vocabularies/jtd/ref.js +67 -0
  1047. package/node_modules/ajv/dist/vocabularies/jtd/ref.js.map +1 -0
  1048. package/node_modules/ajv/dist/vocabularies/jtd/type.d.ts +10 -0
  1049. package/node_modules/ajv/dist/vocabularies/jtd/type.js +69 -0
  1050. package/node_modules/ajv/dist/vocabularies/jtd/type.js.map +1 -0
  1051. package/node_modules/ajv/dist/vocabularies/jtd/union.d.ts +3 -0
  1052. package/node_modules/ajv/dist/vocabularies/jtd/union.js +12 -0
  1053. package/node_modules/ajv/dist/vocabularies/jtd/union.js.map +1 -0
  1054. package/node_modules/ajv/dist/vocabularies/jtd/values.d.ts +5 -0
  1055. package/node_modules/ajv/dist/vocabularies/jtd/values.js +51 -0
  1056. package/node_modules/ajv/dist/vocabularies/jtd/values.js.map +1 -0
  1057. package/node_modules/ajv/dist/vocabularies/metadata.d.ts +3 -0
  1058. package/node_modules/ajv/dist/vocabularies/metadata.js +18 -0
  1059. package/node_modules/ajv/dist/vocabularies/metadata.js.map +1 -0
  1060. package/node_modules/ajv/dist/vocabularies/next.d.ts +3 -0
  1061. package/node_modules/ajv/dist/vocabularies/next.js +8 -0
  1062. package/node_modules/ajv/dist/vocabularies/next.js.map +1 -0
  1063. package/node_modules/ajv/dist/vocabularies/unevaluated/index.d.ts +3 -0
  1064. package/node_modules/ajv/dist/vocabularies/unevaluated/index.js +7 -0
  1065. package/node_modules/ajv/dist/vocabularies/unevaluated/index.js.map +1 -0
  1066. package/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedItems.d.ts +6 -0
  1067. package/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedItems.js +40 -0
  1068. package/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedItems.js.map +1 -0
  1069. package/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.d.ts +6 -0
  1070. package/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js +65 -0
  1071. package/node_modules/ajv/dist/vocabularies/unevaluated/unevaluatedProperties.js.map +1 -0
  1072. package/node_modules/ajv/dist/vocabularies/validation/const.d.ts +6 -0
  1073. package/node_modules/ajv/dist/vocabularies/validation/const.js +25 -0
  1074. package/node_modules/ajv/dist/vocabularies/validation/const.js.map +1 -0
  1075. package/node_modules/ajv/dist/vocabularies/validation/dependentRequired.d.ts +5 -0
  1076. package/node_modules/ajv/dist/vocabularies/validation/dependentRequired.js +12 -0
  1077. package/node_modules/ajv/dist/vocabularies/validation/dependentRequired.js.map +1 -0
  1078. package/node_modules/ajv/dist/vocabularies/validation/enum.d.ts +8 -0
  1079. package/node_modules/ajv/dist/vocabularies/validation/enum.js +48 -0
  1080. package/node_modules/ajv/dist/vocabularies/validation/enum.js.map +1 -0
  1081. package/node_modules/ajv/dist/vocabularies/validation/index.d.ts +16 -0
  1082. package/node_modules/ajv/dist/vocabularies/validation/index.js +33 -0
  1083. package/node_modules/ajv/dist/vocabularies/validation/index.js.map +1 -0
  1084. package/node_modules/ajv/dist/vocabularies/validation/limitContains.d.ts +3 -0
  1085. package/node_modules/ajv/dist/vocabularies/validation/limitContains.js +15 -0
  1086. package/node_modules/ajv/dist/vocabularies/validation/limitContains.js.map +1 -0
  1087. package/node_modules/ajv/dist/vocabularies/validation/limitItems.d.ts +3 -0
  1088. package/node_modules/ajv/dist/vocabularies/validation/limitItems.js +24 -0
  1089. package/node_modules/ajv/dist/vocabularies/validation/limitItems.js.map +1 -0
  1090. package/node_modules/ajv/dist/vocabularies/validation/limitLength.d.ts +3 -0
  1091. package/node_modules/ajv/dist/vocabularies/validation/limitLength.js +27 -0
  1092. package/node_modules/ajv/dist/vocabularies/validation/limitLength.js.map +1 -0
  1093. package/node_modules/ajv/dist/vocabularies/validation/limitNumber.d.ts +11 -0
  1094. package/node_modules/ajv/dist/vocabularies/validation/limitNumber.js +27 -0
  1095. package/node_modules/ajv/dist/vocabularies/validation/limitNumber.js.map +1 -0
  1096. package/node_modules/ajv/dist/vocabularies/validation/limitProperties.d.ts +3 -0
  1097. package/node_modules/ajv/dist/vocabularies/validation/limitProperties.js +24 -0
  1098. package/node_modules/ajv/dist/vocabularies/validation/limitProperties.js.map +1 -0
  1099. package/node_modules/ajv/dist/vocabularies/validation/multipleOf.d.ts +8 -0
  1100. package/node_modules/ajv/dist/vocabularies/validation/multipleOf.js +26 -0
  1101. package/node_modules/ajv/dist/vocabularies/validation/multipleOf.js.map +1 -0
  1102. package/node_modules/ajv/dist/vocabularies/validation/pattern.d.ts +8 -0
  1103. package/node_modules/ajv/dist/vocabularies/validation/pattern.js +33 -0
  1104. package/node_modules/ajv/dist/vocabularies/validation/pattern.js.map +1 -0
  1105. package/node_modules/ajv/dist/vocabularies/validation/required.d.ts +8 -0
  1106. package/node_modules/ajv/dist/vocabularies/validation/required.js +79 -0
  1107. package/node_modules/ajv/dist/vocabularies/validation/required.js.map +1 -0
  1108. package/node_modules/ajv/dist/vocabularies/validation/uniqueItems.d.ts +9 -0
  1109. package/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js +64 -0
  1110. package/node_modules/ajv/dist/vocabularies/validation/uniqueItems.js.map +1 -0
  1111. package/node_modules/ajv/lib/2019.ts +81 -0
  1112. package/node_modules/ajv/lib/2020.ts +75 -0
  1113. package/node_modules/ajv/lib/ajv.ts +70 -0
  1114. package/node_modules/ajv/lib/compile/codegen/code.ts +169 -0
  1115. package/node_modules/ajv/lib/compile/codegen/index.ts +852 -0
  1116. package/node_modules/ajv/lib/compile/codegen/scope.ts +215 -0
  1117. package/node_modules/ajv/lib/compile/errors.ts +184 -0
  1118. package/node_modules/ajv/lib/compile/index.ts +324 -0
  1119. package/node_modules/ajv/lib/compile/jtd/parse.ts +411 -0
  1120. package/node_modules/ajv/lib/compile/jtd/serialize.ts +277 -0
  1121. package/node_modules/ajv/lib/compile/jtd/types.ts +16 -0
  1122. package/node_modules/ajv/lib/compile/names.ts +27 -0
  1123. package/node_modules/ajv/lib/compile/ref_error.ts +13 -0
  1124. package/node_modules/ajv/lib/compile/resolve.ts +149 -0
  1125. package/node_modules/ajv/lib/compile/rules.ts +50 -0
  1126. package/node_modules/ajv/lib/compile/util.ts +213 -0
  1127. package/node_modules/ajv/lib/compile/validate/applicability.ts +22 -0
  1128. package/node_modules/ajv/lib/compile/validate/boolSchema.ts +47 -0
  1129. package/node_modules/ajv/lib/compile/validate/dataType.ts +230 -0
  1130. package/node_modules/ajv/lib/compile/validate/defaults.ts +32 -0
  1131. package/node_modules/ajv/lib/compile/validate/index.ts +582 -0
  1132. package/node_modules/ajv/lib/compile/validate/keyword.ts +171 -0
  1133. package/node_modules/ajv/lib/compile/validate/subschema.ts +135 -0
  1134. package/node_modules/ajv/lib/core.ts +892 -0
  1135. package/node_modules/ajv/lib/jtd.ts +132 -0
  1136. package/node_modules/ajv/lib/refs/data.json +13 -0
  1137. package/node_modules/ajv/lib/refs/json-schema-2019-09/index.ts +28 -0
  1138. package/node_modules/ajv/lib/refs/json-schema-2019-09/meta/applicator.json +53 -0
  1139. package/node_modules/ajv/lib/refs/json-schema-2019-09/meta/content.json +17 -0
  1140. package/node_modules/ajv/lib/refs/json-schema-2019-09/meta/core.json +57 -0
  1141. package/node_modules/ajv/lib/refs/json-schema-2019-09/meta/format.json +14 -0
  1142. package/node_modules/ajv/lib/refs/json-schema-2019-09/meta/meta-data.json +37 -0
  1143. package/node_modules/ajv/lib/refs/json-schema-2019-09/meta/validation.json +90 -0
  1144. package/node_modules/ajv/lib/refs/json-schema-2019-09/schema.json +39 -0
  1145. package/node_modules/ajv/lib/refs/json-schema-2020-12/index.ts +30 -0
  1146. package/node_modules/ajv/lib/refs/json-schema-2020-12/meta/applicator.json +48 -0
  1147. package/node_modules/ajv/lib/refs/json-schema-2020-12/meta/content.json +17 -0
  1148. package/node_modules/ajv/lib/refs/json-schema-2020-12/meta/core.json +51 -0
  1149. package/node_modules/ajv/lib/refs/json-schema-2020-12/meta/format-annotation.json +14 -0
  1150. package/node_modules/ajv/lib/refs/json-schema-2020-12/meta/meta-data.json +37 -0
  1151. package/node_modules/ajv/lib/refs/json-schema-2020-12/meta/unevaluated.json +15 -0
  1152. package/node_modules/ajv/lib/refs/json-schema-2020-12/meta/validation.json +90 -0
  1153. package/node_modules/ajv/lib/refs/json-schema-2020-12/schema.json +55 -0
  1154. package/node_modules/ajv/lib/refs/json-schema-draft-06.json +137 -0
  1155. package/node_modules/ajv/lib/refs/json-schema-draft-07.json +151 -0
  1156. package/node_modules/ajv/lib/refs/json-schema-secure.json +88 -0
  1157. package/node_modules/ajv/lib/refs/jtd-schema.ts +130 -0
  1158. package/node_modules/ajv/lib/runtime/equal.ts +7 -0
  1159. package/node_modules/ajv/lib/runtime/parseJson.ts +177 -0
  1160. package/node_modules/ajv/lib/runtime/quote.ts +31 -0
  1161. package/node_modules/ajv/lib/runtime/re2.ts +6 -0
  1162. package/node_modules/ajv/lib/runtime/timestamp.ts +46 -0
  1163. package/node_modules/ajv/lib/runtime/ucs2length.ts +20 -0
  1164. package/node_modules/ajv/lib/runtime/uri.ts +6 -0
  1165. package/node_modules/ajv/lib/runtime/validation_error.ts +13 -0
  1166. package/node_modules/ajv/lib/standalone/index.ts +100 -0
  1167. package/node_modules/ajv/lib/standalone/instance.ts +36 -0
  1168. package/node_modules/ajv/lib/types/index.ts +244 -0
  1169. package/node_modules/ajv/lib/types/json-schema.ts +187 -0
  1170. package/node_modules/ajv/lib/types/jtd-schema.ts +273 -0
  1171. package/node_modules/ajv/lib/vocabularies/applicator/additionalItems.ts +56 -0
  1172. package/node_modules/ajv/lib/vocabularies/applicator/additionalProperties.ts +118 -0
  1173. package/node_modules/ajv/lib/vocabularies/applicator/allOf.ts +22 -0
  1174. package/node_modules/ajv/lib/vocabularies/applicator/anyOf.ts +14 -0
  1175. package/node_modules/ajv/lib/vocabularies/applicator/contains.ts +109 -0
  1176. package/node_modules/ajv/lib/vocabularies/applicator/dependencies.ts +112 -0
  1177. package/node_modules/ajv/lib/vocabularies/applicator/dependentSchemas.ts +11 -0
  1178. package/node_modules/ajv/lib/vocabularies/applicator/if.ts +80 -0
  1179. package/node_modules/ajv/lib/vocabularies/applicator/index.ts +53 -0
  1180. package/node_modules/ajv/lib/vocabularies/applicator/items.ts +59 -0
  1181. package/node_modules/ajv/lib/vocabularies/applicator/items2020.ts +36 -0
  1182. package/node_modules/ajv/lib/vocabularies/applicator/not.ts +38 -0
  1183. package/node_modules/ajv/lib/vocabularies/applicator/oneOf.ts +82 -0
  1184. package/node_modules/ajv/lib/vocabularies/applicator/patternProperties.ts +91 -0
  1185. package/node_modules/ajv/lib/vocabularies/applicator/prefixItems.ts +12 -0
  1186. package/node_modules/ajv/lib/vocabularies/applicator/properties.ts +57 -0
  1187. package/node_modules/ajv/lib/vocabularies/applicator/propertyNames.ts +50 -0
  1188. package/node_modules/ajv/lib/vocabularies/applicator/thenElse.ts +13 -0
  1189. package/node_modules/ajv/lib/vocabularies/code.ts +168 -0
  1190. package/node_modules/ajv/lib/vocabularies/core/id.ts +10 -0
  1191. package/node_modules/ajv/lib/vocabularies/core/index.ts +16 -0
  1192. package/node_modules/ajv/lib/vocabularies/core/ref.ts +129 -0
  1193. package/node_modules/ajv/lib/vocabularies/discriminator/index.ts +113 -0
  1194. package/node_modules/ajv/lib/vocabularies/discriminator/types.ts +12 -0
  1195. package/node_modules/ajv/lib/vocabularies/draft2020.ts +23 -0
  1196. package/node_modules/ajv/lib/vocabularies/draft7.ts +17 -0
  1197. package/node_modules/ajv/lib/vocabularies/dynamic/dynamicAnchor.ts +31 -0
  1198. package/node_modules/ajv/lib/vocabularies/dynamic/dynamicRef.ts +51 -0
  1199. package/node_modules/ajv/lib/vocabularies/dynamic/index.ts +9 -0
  1200. package/node_modules/ajv/lib/vocabularies/dynamic/recursiveAnchor.ts +14 -0
  1201. package/node_modules/ajv/lib/vocabularies/dynamic/recursiveRef.ts +10 -0
  1202. package/node_modules/ajv/lib/vocabularies/errors.ts +18 -0
  1203. package/node_modules/ajv/lib/vocabularies/format/format.ts +120 -0
  1204. package/node_modules/ajv/lib/vocabularies/format/index.ts +6 -0
  1205. package/node_modules/ajv/lib/vocabularies/jtd/discriminator.ts +89 -0
  1206. package/node_modules/ajv/lib/vocabularies/jtd/elements.ts +32 -0
  1207. package/node_modules/ajv/lib/vocabularies/jtd/enum.ts +45 -0
  1208. package/node_modules/ajv/lib/vocabularies/jtd/error.ts +23 -0
  1209. package/node_modules/ajv/lib/vocabularies/jtd/index.ts +37 -0
  1210. package/node_modules/ajv/lib/vocabularies/jtd/metadata.ts +24 -0
  1211. package/node_modules/ajv/lib/vocabularies/jtd/nullable.ts +21 -0
  1212. package/node_modules/ajv/lib/vocabularies/jtd/optionalProperties.ts +15 -0
  1213. package/node_modules/ajv/lib/vocabularies/jtd/properties.ts +184 -0
  1214. package/node_modules/ajv/lib/vocabularies/jtd/ref.ts +76 -0
  1215. package/node_modules/ajv/lib/vocabularies/jtd/type.ts +75 -0
  1216. package/node_modules/ajv/lib/vocabularies/jtd/union.ts +12 -0
  1217. package/node_modules/ajv/lib/vocabularies/jtd/values.ts +58 -0
  1218. package/node_modules/ajv/lib/vocabularies/metadata.ts +17 -0
  1219. package/node_modules/ajv/lib/vocabularies/next.ts +8 -0
  1220. package/node_modules/ajv/lib/vocabularies/unevaluated/index.ts +7 -0
  1221. package/node_modules/ajv/lib/vocabularies/unevaluated/unevaluatedItems.ts +47 -0
  1222. package/node_modules/ajv/lib/vocabularies/unevaluated/unevaluatedProperties.ts +85 -0
  1223. package/node_modules/ajv/lib/vocabularies/validation/const.ts +28 -0
  1224. package/node_modules/ajv/lib/vocabularies/validation/dependentRequired.ts +23 -0
  1225. package/node_modules/ajv/lib/vocabularies/validation/enum.ts +54 -0
  1226. package/node_modules/ajv/lib/vocabularies/validation/index.ts +49 -0
  1227. package/node_modules/ajv/lib/vocabularies/validation/limitContains.ts +16 -0
  1228. package/node_modules/ajv/lib/vocabularies/validation/limitItems.ts +26 -0
  1229. package/node_modules/ajv/lib/vocabularies/validation/limitLength.ts +30 -0
  1230. package/node_modules/ajv/lib/vocabularies/validation/limitNumber.ts +42 -0
  1231. package/node_modules/ajv/lib/vocabularies/validation/limitProperties.ts +26 -0
  1232. package/node_modules/ajv/lib/vocabularies/validation/multipleOf.ts +34 -0
  1233. package/node_modules/ajv/lib/vocabularies/validation/pattern.ts +39 -0
  1234. package/node_modules/ajv/lib/vocabularies/validation/required.ts +98 -0
  1235. package/node_modules/ajv/lib/vocabularies/validation/uniqueItems.ts +79 -0
  1236. package/node_modules/ajv/package.json +127 -0
  1237. package/node_modules/ajv-formats/LICENSE +21 -0
  1238. package/node_modules/ajv-formats/README.md +125 -0
  1239. package/node_modules/ajv-formats/dist/formats.d.ts +9 -0
  1240. package/node_modules/ajv-formats/dist/formats.js +208 -0
  1241. package/node_modules/ajv-formats/dist/formats.js.map +1 -0
  1242. package/node_modules/ajv-formats/dist/index.d.ts +15 -0
  1243. package/node_modules/ajv-formats/dist/index.js +37 -0
  1244. package/node_modules/ajv-formats/dist/index.js.map +1 -0
  1245. package/node_modules/ajv-formats/dist/limit.d.ts +10 -0
  1246. package/node_modules/ajv-formats/dist/limit.js +69 -0
  1247. package/node_modules/ajv-formats/dist/limit.js.map +1 -0
  1248. package/node_modules/ajv-formats/package.json +74 -0
  1249. package/node_modules/ajv-formats/src/formats.ts +269 -0
  1250. package/node_modules/ajv-formats/src/index.ts +62 -0
  1251. package/node_modules/ajv-formats/src/limit.ts +99 -0
  1252. package/node_modules/atomic-sleep/.travis.yml +11 -0
  1253. package/node_modules/atomic-sleep/LICENSE +22 -0
  1254. package/node_modules/atomic-sleep/index.js +38 -0
  1255. package/node_modules/atomic-sleep/package.json +37 -0
  1256. package/node_modules/atomic-sleep/readme.md +58 -0
  1257. package/node_modules/atomic-sleep/test.js +47 -0
  1258. package/node_modules/avvio/.borp.yaml +2 -0
  1259. package/node_modules/avvio/.gitattributes +2 -0
  1260. package/node_modules/avvio/.github/dependabot.yml +13 -0
  1261. package/node_modules/avvio/.github/release-drafter.yml +4 -0
  1262. package/node_modules/avvio/.github/workflows/ci.yml +33 -0
  1263. package/node_modules/avvio/LICENSE +24 -0
  1264. package/node_modules/avvio/README.md +700 -0
  1265. package/node_modules/avvio/boot.js +621 -0
  1266. package/node_modules/avvio/eslint.config.js +6 -0
  1267. package/node_modules/avvio/examples/example.js +72 -0
  1268. package/node_modules/avvio/index.d.ts +95 -0
  1269. package/node_modules/avvio/lib/create-promise.js +45 -0
  1270. package/node_modules/avvio/lib/debug.js +19 -0
  1271. package/node_modules/avvio/lib/errors.js +38 -0
  1272. package/node_modules/avvio/lib/execute-with-thenable.js +36 -0
  1273. package/node_modules/avvio/lib/get-plugin-name.js +34 -0
  1274. package/node_modules/avvio/lib/is-bundled-or-typescript-plugin.js +23 -0
  1275. package/node_modules/avvio/lib/is-promise-like.js +17 -0
  1276. package/node_modules/avvio/lib/plugin.js +279 -0
  1277. package/node_modules/avvio/lib/symbols.js +26 -0
  1278. package/node_modules/avvio/lib/thenify.js +60 -0
  1279. package/node_modules/avvio/lib/time-tree.js +200 -0
  1280. package/node_modules/avvio/lib/validate-plugin.js +26 -0
  1281. package/node_modules/avvio/package.json +74 -0
  1282. package/node_modules/avvio/test/after-and-ready.test.js +903 -0
  1283. package/node_modules/avvio/test/after-pass-through.test.js +33 -0
  1284. package/node_modules/avvio/test/after-self-promise.test.js +20 -0
  1285. package/node_modules/avvio/test/after-throw.test.js +26 -0
  1286. package/node_modules/avvio/test/after-use-after.test.js +87 -0
  1287. package/node_modules/avvio/test/async-await.test.js +323 -0
  1288. package/node_modules/avvio/test/await-after.test.js +448 -0
  1289. package/node_modules/avvio/test/await-self.test.js +31 -0
  1290. package/node_modules/avvio/test/await-use.test.js +295 -0
  1291. package/node_modules/avvio/test/basic.test.js +459 -0
  1292. package/node_modules/avvio/test/callbacks.test.js +116 -0
  1293. package/node_modules/avvio/test/catch-override-exception.test.js +27 -0
  1294. package/node_modules/avvio/test/chainable.test.js +70 -0
  1295. package/node_modules/avvio/test/close.test.js +562 -0
  1296. package/node_modules/avvio/test/errors.test.js +26 -0
  1297. package/node_modules/avvio/test/esm.mjs +12 -0
  1298. package/node_modules/avvio/test/esm.test.js +8 -0
  1299. package/node_modules/avvio/test/events-listeners.test.js +23 -0
  1300. package/node_modules/avvio/test/expose.test.js +76 -0
  1301. package/node_modules/avvio/test/fixtures/dummy.txt +1 -0
  1302. package/node_modules/avvio/test/fixtures/esm.mjs +3 -0
  1303. package/node_modules/avvio/test/fixtures/plugin-no-next.js +5 -0
  1304. package/node_modules/avvio/test/gh-issues/bug-205.test.js +17 -0
  1305. package/node_modules/avvio/test/lib/create-promise.test.js +56 -0
  1306. package/node_modules/avvio/test/lib/execute-with-thenable.test.js +86 -0
  1307. package/node_modules/avvio/test/lib/get-plugin-name.test.js +67 -0
  1308. package/node_modules/avvio/test/lib/is-bundled-or-typescript-plugin.test.js +20 -0
  1309. package/node_modules/avvio/test/lib/is-promise-like.test.js +20 -0
  1310. package/node_modules/avvio/test/lib/thenify.test.js +140 -0
  1311. package/node_modules/avvio/test/lib/time-tree.test.js +391 -0
  1312. package/node_modules/avvio/test/lib/validate-plugin.test.js +19 -0
  1313. package/node_modules/avvio/test/load-plugin.test.js +132 -0
  1314. package/node_modules/avvio/test/no-done.test.js +19 -0
  1315. package/node_modules/avvio/test/on-ready-timeout-await.test.js +33 -0
  1316. package/node_modules/avvio/test/override.test.js +385 -0
  1317. package/node_modules/avvio/test/plugin-loaded-so-far.test.js +81 -0
  1318. package/node_modules/avvio/test/plugin-name.test.js +58 -0
  1319. package/node_modules/avvio/test/plugin-timeout-await.test.js +33 -0
  1320. package/node_modules/avvio/test/plugin-timeout.test.js +227 -0
  1321. package/node_modules/avvio/test/pretty-print.test.js +76 -0
  1322. package/node_modules/avvio/test/reentrant.test.js +126 -0
  1323. package/node_modules/avvio/test/symbol-async-dispose.test.js +28 -0
  1324. package/node_modules/avvio/test/to-json.test.js +130 -0
  1325. package/node_modules/avvio/test/twice-done.test.js +23 -0
  1326. package/node_modules/avvio/test/types/index.ts +412 -0
  1327. package/node_modules/avvio/test/types/tsconfig.json +9 -0
  1328. package/node_modules/balanced-match/LICENSE.md +23 -0
  1329. package/node_modules/balanced-match/README.md +57 -0
  1330. package/node_modules/balanced-match/dist/commonjs/index.d.ts +9 -0
  1331. package/node_modules/balanced-match/dist/commonjs/index.d.ts.map +1 -0
  1332. package/node_modules/balanced-match/dist/commonjs/index.js +59 -0
  1333. package/node_modules/balanced-match/dist/commonjs/index.js.map +1 -0
  1334. package/node_modules/balanced-match/dist/commonjs/package.json +3 -0
  1335. package/node_modules/balanced-match/dist/esm/index.d.ts +9 -0
  1336. package/node_modules/balanced-match/dist/esm/index.d.ts.map +1 -0
  1337. package/node_modules/balanced-match/dist/esm/index.js +54 -0
  1338. package/node_modules/balanced-match/dist/esm/index.js.map +1 -0
  1339. package/node_modules/balanced-match/dist/esm/package.json +3 -0
  1340. package/node_modules/balanced-match/package.json +68 -0
  1341. package/node_modules/brace-expansion/LICENSE +23 -0
  1342. package/node_modules/brace-expansion/README.md +94 -0
  1343. package/node_modules/brace-expansion/dist/commonjs/index.d.ts +6 -0
  1344. package/node_modules/brace-expansion/dist/commonjs/index.d.ts.map +1 -0
  1345. package/node_modules/brace-expansion/dist/commonjs/index.js +201 -0
  1346. package/node_modules/brace-expansion/dist/commonjs/index.js.map +1 -0
  1347. package/node_modules/brace-expansion/dist/commonjs/package.json +3 -0
  1348. package/node_modules/brace-expansion/dist/esm/index.d.ts +6 -0
  1349. package/node_modules/brace-expansion/dist/esm/index.d.ts.map +1 -0
  1350. package/node_modules/brace-expansion/dist/esm/index.js +197 -0
  1351. package/node_modules/brace-expansion/dist/esm/index.js.map +1 -0
  1352. package/node_modules/brace-expansion/dist/esm/package.json +3 -0
  1353. package/node_modules/brace-expansion/package.json +64 -0
  1354. package/node_modules/content-disposition/LICENSE +22 -0
  1355. package/node_modules/content-disposition/README.md +141 -0
  1356. package/node_modules/content-disposition/index.js +536 -0
  1357. package/node_modules/content-disposition/package.json +40 -0
  1358. package/node_modules/cookie/LICENSE +24 -0
  1359. package/node_modules/cookie/README.md +295 -0
  1360. package/node_modules/cookie/dist/index.d.ts +148 -0
  1361. package/node_modules/cookie/dist/index.js +350 -0
  1362. package/node_modules/cookie/dist/index.js.map +1 -0
  1363. package/node_modules/cookie/package.json +47 -0
  1364. package/node_modules/depd/History.md +103 -0
  1365. package/node_modules/depd/LICENSE +22 -0
  1366. package/node_modules/depd/Readme.md +280 -0
  1367. package/node_modules/depd/index.js +538 -0
  1368. package/node_modules/depd/lib/browser/index.js +77 -0
  1369. package/node_modules/depd/package.json +45 -0
  1370. package/node_modules/dequal/dist/index.js +86 -0
  1371. package/node_modules/dequal/dist/index.min.js +1 -0
  1372. package/node_modules/dequal/dist/index.mjs +84 -0
  1373. package/node_modules/dequal/index.d.ts +1 -0
  1374. package/node_modules/dequal/license +21 -0
  1375. package/node_modules/dequal/lite/index.d.ts +1 -0
  1376. package/node_modules/dequal/lite/index.js +31 -0
  1377. package/node_modules/dequal/lite/index.min.js +1 -0
  1378. package/node_modules/dequal/lite/index.mjs +29 -0
  1379. package/node_modules/dequal/package.json +57 -0
  1380. package/node_modules/dequal/readme.md +112 -0
  1381. package/node_modules/escape-html/LICENSE +24 -0
  1382. package/node_modules/escape-html/Readme.md +43 -0
  1383. package/node_modules/escape-html/index.js +78 -0
  1384. package/node_modules/escape-html/package.json +24 -0
  1385. package/node_modules/fast-decode-uri-component/.travis.yml +12 -0
  1386. package/node_modules/fast-decode-uri-component/LICENSE +23 -0
  1387. package/node_modules/fast-decode-uri-component/README.md +43 -0
  1388. package/node_modules/fast-decode-uri-component/bench.js +35 -0
  1389. package/node_modules/fast-decode-uri-component/index.js +115 -0
  1390. package/node_modules/fast-decode-uri-component/package.json +33 -0
  1391. package/node_modules/fast-decode-uri-component/test.js +32 -0
  1392. package/node_modules/fast-deep-equal/LICENSE +21 -0
  1393. package/node_modules/fast-deep-equal/README.md +96 -0
  1394. package/node_modules/fast-deep-equal/es6/index.d.ts +2 -0
  1395. package/node_modules/fast-deep-equal/es6/index.js +72 -0
  1396. package/node_modules/fast-deep-equal/es6/react.d.ts +2 -0
  1397. package/node_modules/fast-deep-equal/es6/react.js +79 -0
  1398. package/node_modules/fast-deep-equal/index.d.ts +4 -0
  1399. package/node_modules/fast-deep-equal/index.js +46 -0
  1400. package/node_modules/fast-deep-equal/package.json +61 -0
  1401. package/node_modules/fast-deep-equal/react.d.ts +2 -0
  1402. package/node_modules/fast-deep-equal/react.js +53 -0
  1403. package/node_modules/fast-json-stringify/.gitattributes +2 -0
  1404. package/node_modules/fast-json-stringify/.github/dependabot.yml +13 -0
  1405. package/node_modules/fast-json-stringify/.github/workflows/ci.yml +33 -0
  1406. package/node_modules/fast-json-stringify/.github/workflows/lock-threads.yml +19 -0
  1407. package/node_modules/fast-json-stringify/LICENSE +22 -0
  1408. package/node_modules/fast-json-stringify/README.md +742 -0
  1409. package/node_modules/fast-json-stringify/benchmark/bench-cmp-branch.js +116 -0
  1410. package/node_modules/fast-json-stringify/benchmark/bench-cmp-lib.js +339 -0
  1411. package/node_modules/fast-json-stringify/benchmark/bench-thread.js +33 -0
  1412. package/node_modules/fast-json-stringify/benchmark/bench.js +391 -0
  1413. package/node_modules/fast-json-stringify/build/build-schema-validator.js +26 -0
  1414. package/node_modules/fast-json-stringify/eslint.config.js +9 -0
  1415. package/node_modules/fast-json-stringify/examples/example.js +81 -0
  1416. package/node_modules/fast-json-stringify/examples/server.js +42 -0
  1417. package/node_modules/fast-json-stringify/index.js +1312 -0
  1418. package/node_modules/fast-json-stringify/lib/location.js +24 -0
  1419. package/node_modules/fast-json-stringify/lib/merge-schemas.js +9 -0
  1420. package/node_modules/fast-json-stringify/lib/schema-validator.js +1134 -0
  1421. package/node_modules/fast-json-stringify/lib/serializer.js +141 -0
  1422. package/node_modules/fast-json-stringify/lib/standalone.js +34 -0
  1423. package/node_modules/fast-json-stringify/lib/validator.js +96 -0
  1424. package/node_modules/fast-json-stringify/package.json +89 -0
  1425. package/node_modules/fast-json-stringify/test/additionalProperties.test.js +332 -0
  1426. package/node_modules/fast-json-stringify/test/allof.test.js +751 -0
  1427. package/node_modules/fast-json-stringify/test/any.test.js +231 -0
  1428. package/node_modules/fast-json-stringify/test/anyof.test.js +812 -0
  1429. package/node_modules/fast-json-stringify/test/array.test.js +688 -0
  1430. package/node_modules/fast-json-stringify/test/asNumber.test.js +13 -0
  1431. package/node_modules/fast-json-stringify/test/basic.test.js +400 -0
  1432. package/node_modules/fast-json-stringify/test/bigint.test.js +76 -0
  1433. package/node_modules/fast-json-stringify/test/clean-cache.test.js +47 -0
  1434. package/node_modules/fast-json-stringify/test/const.test.js +314 -0
  1435. package/node_modules/fast-json-stringify/test/date.test.js +639 -0
  1436. package/node_modules/fast-json-stringify/test/debug-mode.test.js +142 -0
  1437. package/node_modules/fast-json-stringify/test/defaults.test.js +376 -0
  1438. package/node_modules/fast-json-stringify/test/enum.test.js +37 -0
  1439. package/node_modules/fast-json-stringify/test/fix-604.test.js +25 -0
  1440. package/node_modules/fast-json-stringify/test/fixtures/.keep +0 -0
  1441. package/node_modules/fast-json-stringify/test/if-then-else.test.js +540 -0
  1442. package/node_modules/fast-json-stringify/test/inferType.test.js +92 -0
  1443. package/node_modules/fast-json-stringify/test/infinity.test.js +55 -0
  1444. package/node_modules/fast-json-stringify/test/integer.test.js +194 -0
  1445. package/node_modules/fast-json-stringify/test/invalidSchema.test.js +38 -0
  1446. package/node_modules/fast-json-stringify/test/issue-479.test.js +57 -0
  1447. package/node_modules/fast-json-stringify/test/issue-793.test.js +107 -0
  1448. package/node_modules/fast-json-stringify/test/issue-794.test.js +177 -0
  1449. package/node_modules/fast-json-stringify/test/issue-836.test.js +183 -0
  1450. package/node_modules/fast-json-stringify/test/json-add-comma.test.js +57 -0
  1451. package/node_modules/fast-json-stringify/test/json-schema-test-suite/README.md +10 -0
  1452. package/node_modules/fast-json-stringify/test/json-schema-test-suite/draft4/required.json +54 -0
  1453. package/node_modules/fast-json-stringify/test/json-schema-test-suite/draft4.test.js +12 -0
  1454. package/node_modules/fast-json-stringify/test/json-schema-test-suite/draft6/required.json +70 -0
  1455. package/node_modules/fast-json-stringify/test/json-schema-test-suite/draft6.test.js +12 -0
  1456. package/node_modules/fast-json-stringify/test/json-schema-test-suite/draft7/required.json +70 -0
  1457. package/node_modules/fast-json-stringify/test/json-schema-test-suite/draft7.test.js +12 -0
  1458. package/node_modules/fast-json-stringify/test/json-schema-test-suite/util.js +31 -0
  1459. package/node_modules/fast-json-stringify/test/missing-values.test.js +88 -0
  1460. package/node_modules/fast-json-stringify/test/multi-type-serializer.test.js +19 -0
  1461. package/node_modules/fast-json-stringify/test/nestedObjects.test.js +63 -0
  1462. package/node_modules/fast-json-stringify/test/nullable.test.js +543 -0
  1463. package/node_modules/fast-json-stringify/test/oneof.test.js +510 -0
  1464. package/node_modules/fast-json-stringify/test/patternProperties.test.js +168 -0
  1465. package/node_modules/fast-json-stringify/test/recursion.test.js +245 -0
  1466. package/node_modules/fast-json-stringify/test/ref.json +12 -0
  1467. package/node_modules/fast-json-stringify/test/ref.test.js +2077 -0
  1468. package/node_modules/fast-json-stringify/test/regex.test.js +32 -0
  1469. package/node_modules/fast-json-stringify/test/required.test.js +204 -0
  1470. package/node_modules/fast-json-stringify/test/requiresAjv.test.js +50 -0
  1471. package/node_modules/fast-json-stringify/test/sanitize.test.js +141 -0
  1472. package/node_modules/fast-json-stringify/test/sanitize2.test.js +18 -0
  1473. package/node_modules/fast-json-stringify/test/sanitize3.test.js +17 -0
  1474. package/node_modules/fast-json-stringify/test/sanitize4.test.js +16 -0
  1475. package/node_modules/fast-json-stringify/test/sanitize5.test.js +16 -0
  1476. package/node_modules/fast-json-stringify/test/sanitize6.test.js +22 -0
  1477. package/node_modules/fast-json-stringify/test/sanitize7.test.js +68 -0
  1478. package/node_modules/fast-json-stringify/test/side-effect.test.js +196 -0
  1479. package/node_modules/fast-json-stringify/test/standalone-mode.test.js +219 -0
  1480. package/node_modules/fast-json-stringify/test/string.test.js +84 -0
  1481. package/node_modules/fast-json-stringify/test/surrogate.test.js +67 -0
  1482. package/node_modules/fast-json-stringify/test/toJSON.test.js +203 -0
  1483. package/node_modules/fast-json-stringify/test/typebox.test.js +36 -0
  1484. package/node_modules/fast-json-stringify/test/typesArray.test.js +550 -0
  1485. package/node_modules/fast-json-stringify/test/unknownFormats.test.js +27 -0
  1486. package/node_modules/fast-json-stringify/test/webpack.test.js +50 -0
  1487. package/node_modules/fast-json-stringify/types/index.d.ts +231 -0
  1488. package/node_modules/fast-json-stringify/types/index.tst.ts +259 -0
  1489. package/node_modules/fast-querystring/LICENSE +25 -0
  1490. package/node_modules/fast-querystring/README.md +114 -0
  1491. package/node_modules/fast-querystring/lib/index.d.ts +14 -0
  1492. package/node_modules/fast-querystring/lib/index.js +20 -0
  1493. package/node_modules/fast-querystring/lib/internals/querystring.js +96 -0
  1494. package/node_modules/fast-querystring/lib/parse.js +126 -0
  1495. package/node_modules/fast-querystring/lib/stringify.js +69 -0
  1496. package/node_modules/fast-querystring/package.json +56 -0
  1497. package/node_modules/fast-uri/.gitattributes +2 -0
  1498. package/node_modules/fast-uri/.github/dependabot.yml +13 -0
  1499. package/node_modules/fast-uri/.github/workflows/ci.yml +106 -0
  1500. package/node_modules/fast-uri/.github/workflows/lock-threads.yml +19 -0
  1501. package/node_modules/fast-uri/.github/workflows/package-manager-ci.yml +24 -0
  1502. package/node_modules/fast-uri/LICENSE +30 -0
  1503. package/node_modules/fast-uri/README.md +152 -0
  1504. package/node_modules/fast-uri/benchmark/benchmark.mjs +159 -0
  1505. package/node_modules/fast-uri/benchmark/equal.mjs +51 -0
  1506. package/node_modules/fast-uri/benchmark/non-simple-domain.mjs +22 -0
  1507. package/node_modules/fast-uri/benchmark/package.json +17 -0
  1508. package/node_modules/fast-uri/benchmark/string-array-to-hex-stripped.mjs +24 -0
  1509. package/node_modules/fast-uri/benchmark/ws-is-secure.mjs +65 -0
  1510. package/node_modules/fast-uri/eslint.config.js +6 -0
  1511. package/node_modules/fast-uri/index.js +406 -0
  1512. package/node_modules/fast-uri/lib/schemes.js +267 -0
  1513. package/node_modules/fast-uri/lib/utils.js +443 -0
  1514. package/node_modules/fast-uri/package.json +68 -0
  1515. package/node_modules/fast-uri/test/ajv.test.js +43 -0
  1516. package/node_modules/fast-uri/test/equal.test.js +117 -0
  1517. package/node_modules/fast-uri/test/fixtures/uri-js-parse.json +501 -0
  1518. package/node_modules/fast-uri/test/fixtures/uri-js-serialize.json +120 -0
  1519. package/node_modules/fast-uri/test/parse.test.js +323 -0
  1520. package/node_modules/fast-uri/test/resolve.test.js +87 -0
  1521. package/node_modules/fast-uri/test/rfc-3986.test.js +90 -0
  1522. package/node_modules/fast-uri/test/security-normalization.test.js +39 -0
  1523. package/node_modules/fast-uri/test/security.test.js +133 -0
  1524. package/node_modules/fast-uri/test/serialize.test.js +151 -0
  1525. package/node_modules/fast-uri/test/uri-js-compatibility.test.js +33 -0
  1526. package/node_modules/fast-uri/test/uri-js.test.js +912 -0
  1527. package/node_modules/fast-uri/test/util.test.js +38 -0
  1528. package/node_modules/fast-uri/tsconfig.json +9 -0
  1529. package/node_modules/fast-uri/types/index.d.ts +60 -0
  1530. package/node_modules/fast-uri/types/index.test-d.ts +17 -0
  1531. package/node_modules/fastify/.borp.yaml +3 -0
  1532. package/node_modules/fastify/.markdownlint-cli2.yaml +22 -0
  1533. package/node_modules/fastify/.prettierignore +1 -0
  1534. package/node_modules/fastify/GOVERNANCE.md +4 -0
  1535. package/node_modules/fastify/LICENSE +21 -0
  1536. package/node_modules/fastify/PROJECT_CHARTER.md +126 -0
  1537. package/node_modules/fastify/README.md +423 -0
  1538. package/node_modules/fastify/SECURITY.md +220 -0
  1539. package/node_modules/fastify/SPONSORS.md +24 -0
  1540. package/node_modules/fastify/build/build-error-serializer.js +35 -0
  1541. package/node_modules/fastify/build/build-validation.js +169 -0
  1542. package/node_modules/fastify/build/sync-version.js +11 -0
  1543. package/node_modules/fastify/docs/Guides/Benchmarking.md +60 -0
  1544. package/node_modules/fastify/docs/Guides/Database.md +321 -0
  1545. package/node_modules/fastify/docs/Guides/Delay-Accepting-Requests.md +608 -0
  1546. package/node_modules/fastify/docs/Guides/Detecting-When-Clients-Abort.md +172 -0
  1547. package/node_modules/fastify/docs/Guides/Ecosystem.md +730 -0
  1548. package/node_modules/fastify/docs/Guides/Fluent-Schema.md +127 -0
  1549. package/node_modules/fastify/docs/Guides/Getting-Started.md +620 -0
  1550. package/node_modules/fastify/docs/Guides/Index.md +43 -0
  1551. package/node_modules/fastify/docs/Guides/Migration-Guide-V3.md +287 -0
  1552. package/node_modules/fastify/docs/Guides/Migration-Guide-V4.md +267 -0
  1553. package/node_modules/fastify/docs/Guides/Migration-Guide-V5.md +727 -0
  1554. package/node_modules/fastify/docs/Guides/Plugins-Guide.md +520 -0
  1555. package/node_modules/fastify/docs/Guides/Prototype-Poisoning.md +383 -0
  1556. package/node_modules/fastify/docs/Guides/Recommendations.md +378 -0
  1557. package/node_modules/fastify/docs/Guides/Serverless.md +604 -0
  1558. package/node_modules/fastify/docs/Guides/Style-Guide.md +246 -0
  1559. package/node_modules/fastify/docs/Guides/Testing.md +481 -0
  1560. package/node_modules/fastify/docs/Guides/Write-Plugin.md +103 -0
  1561. package/node_modules/fastify/docs/Guides/Write-Type-Provider.md +34 -0
  1562. package/node_modules/fastify/docs/Reference/ContentTypeParser.md +271 -0
  1563. package/node_modules/fastify/docs/Reference/Decorators.md +436 -0
  1564. package/node_modules/fastify/docs/Reference/Encapsulation.md +194 -0
  1565. package/node_modules/fastify/docs/Reference/Errors.md +377 -0
  1566. package/node_modules/fastify/docs/Reference/HTTP2.md +94 -0
  1567. package/node_modules/fastify/docs/Reference/Hooks.md +958 -0
  1568. package/node_modules/fastify/docs/Reference/Index.md +73 -0
  1569. package/node_modules/fastify/docs/Reference/LTS.md +86 -0
  1570. package/node_modules/fastify/docs/Reference/Lifecycle.md +99 -0
  1571. package/node_modules/fastify/docs/Reference/Logging.md +268 -0
  1572. package/node_modules/fastify/docs/Reference/Middleware.md +79 -0
  1573. package/node_modules/fastify/docs/Reference/Plugins.md +245 -0
  1574. package/node_modules/fastify/docs/Reference/Principles.md +73 -0
  1575. package/node_modules/fastify/docs/Reference/Reply.md +1001 -0
  1576. package/node_modules/fastify/docs/Reference/Request.md +295 -0
  1577. package/node_modules/fastify/docs/Reference/Routes.md +802 -0
  1578. package/node_modules/fastify/docs/Reference/Server.md +2389 -0
  1579. package/node_modules/fastify/docs/Reference/Type-Providers.md +256 -0
  1580. package/node_modules/fastify/docs/Reference/TypeScript.md +1729 -0
  1581. package/node_modules/fastify/docs/Reference/Validation-and-Serialization.md +1130 -0
  1582. package/node_modules/fastify/docs/Reference/Warnings.md +58 -0
  1583. package/node_modules/fastify/docs/index.md +24 -0
  1584. package/node_modules/fastify/docs/resources/encapsulation_context.drawio +1 -0
  1585. package/node_modules/fastify/docs/resources/encapsulation_context.svg +3 -0
  1586. package/node_modules/fastify/eslint.config.js +35 -0
  1587. package/node_modules/fastify/examples/asyncawait.js +38 -0
  1588. package/node_modules/fastify/examples/benchmark/body.json +3 -0
  1589. package/node_modules/fastify/examples/benchmark/hooks-benchmark-async-await.js +44 -0
  1590. package/node_modules/fastify/examples/benchmark/hooks-benchmark.js +52 -0
  1591. package/node_modules/fastify/examples/benchmark/parser.js +47 -0
  1592. package/node_modules/fastify/examples/benchmark/simple.js +30 -0
  1593. package/node_modules/fastify/examples/benchmark/webstream.js +27 -0
  1594. package/node_modules/fastify/examples/hooks.js +91 -0
  1595. package/node_modules/fastify/examples/http2.js +39 -0
  1596. package/node_modules/fastify/examples/https.js +38 -0
  1597. package/node_modules/fastify/examples/parser.js +53 -0
  1598. package/node_modules/fastify/examples/plugin.js +12 -0
  1599. package/node_modules/fastify/examples/route-prefix.js +38 -0
  1600. package/node_modules/fastify/examples/shared-schema.js +38 -0
  1601. package/node_modules/fastify/examples/simple-stream.js +20 -0
  1602. package/node_modules/fastify/examples/simple.js +32 -0
  1603. package/node_modules/fastify/examples/simple.mjs +27 -0
  1604. package/node_modules/fastify/examples/typescript-server.ts +79 -0
  1605. package/node_modules/fastify/examples/use-plugin.js +29 -0
  1606. package/node_modules/fastify/fastify.d.ts +253 -0
  1607. package/node_modules/fastify/fastify.js +985 -0
  1608. package/node_modules/fastify/integration/server.js +29 -0
  1609. package/node_modules/fastify/integration/test.sh +23 -0
  1610. package/node_modules/fastify/lib/config-validator.js +1266 -0
  1611. package/node_modules/fastify/lib/content-type-parser.js +413 -0
  1612. package/node_modules/fastify/lib/content-type.js +160 -0
  1613. package/node_modules/fastify/lib/context.js +98 -0
  1614. package/node_modules/fastify/lib/decorate.js +152 -0
  1615. package/node_modules/fastify/lib/error-handler.js +173 -0
  1616. package/node_modules/fastify/lib/error-serializer.js +134 -0
  1617. package/node_modules/fastify/lib/error-status.js +14 -0
  1618. package/node_modules/fastify/lib/errors.js +516 -0
  1619. package/node_modules/fastify/lib/four-oh-four.js +190 -0
  1620. package/node_modules/fastify/lib/handle-request.js +195 -0
  1621. package/node_modules/fastify/lib/head-route.js +45 -0
  1622. package/node_modules/fastify/lib/hooks.js +429 -0
  1623. package/node_modules/fastify/lib/initial-config-validation.js +37 -0
  1624. package/node_modules/fastify/lib/logger-factory.js +136 -0
  1625. package/node_modules/fastify/lib/logger-pino.js +68 -0
  1626. package/node_modules/fastify/lib/noop-set.js +10 -0
  1627. package/node_modules/fastify/lib/plugin-override.js +90 -0
  1628. package/node_modules/fastify/lib/plugin-utils.js +169 -0
  1629. package/node_modules/fastify/lib/promise.js +23 -0
  1630. package/node_modules/fastify/lib/reply.js +1030 -0
  1631. package/node_modules/fastify/lib/req-id-gen-factory.js +52 -0
  1632. package/node_modules/fastify/lib/request.js +387 -0
  1633. package/node_modules/fastify/lib/route.js +686 -0
  1634. package/node_modules/fastify/lib/schema-controller.js +164 -0
  1635. package/node_modules/fastify/lib/schemas.js +207 -0
  1636. package/node_modules/fastify/lib/server.js +441 -0
  1637. package/node_modules/fastify/lib/symbols.js +71 -0
  1638. package/node_modules/fastify/lib/validation.js +280 -0
  1639. package/node_modules/fastify/lib/warnings.js +57 -0
  1640. package/node_modules/fastify/lib/wrap-thenable.js +84 -0
  1641. package/node_modules/fastify/package.json +225 -0
  1642. package/node_modules/fastify/scripts/validate-ecosystem-links.js +179 -0
  1643. package/node_modules/fastify/test/404s.test.js +2035 -0
  1644. package/node_modules/fastify/test/500s.test.js +422 -0
  1645. package/node_modules/fastify/test/allow-unsafe-regex.test.js +92 -0
  1646. package/node_modules/fastify/test/als.test.js +65 -0
  1647. package/node_modules/fastify/test/async-await.test.js +705 -0
  1648. package/node_modules/fastify/test/async-dispose.test.js +20 -0
  1649. package/node_modules/fastify/test/async_hooks.test.js +52 -0
  1650. package/node_modules/fastify/test/body-limit.test.js +224 -0
  1651. package/node_modules/fastify/test/buffer.test.js +74 -0
  1652. package/node_modules/fastify/test/build/error-serializer.test.js +36 -0
  1653. package/node_modules/fastify/test/build/version.test.js +14 -0
  1654. package/node_modules/fastify/test/build-certificate.js +109 -0
  1655. package/node_modules/fastify/test/bundler/README.md +29 -0
  1656. package/node_modules/fastify/test/bundler/esbuild/bundler-test.js +32 -0
  1657. package/node_modules/fastify/test/bundler/esbuild/package.json +10 -0
  1658. package/node_modules/fastify/test/bundler/esbuild/src/fail-plugin-version.js +14 -0
  1659. package/node_modules/fastify/test/bundler/esbuild/src/index.js +9 -0
  1660. package/node_modules/fastify/test/bundler/webpack/bundler-test.js +32 -0
  1661. package/node_modules/fastify/test/bundler/webpack/package.json +11 -0
  1662. package/node_modules/fastify/test/bundler/webpack/src/fail-plugin-version.js +14 -0
  1663. package/node_modules/fastify/test/bundler/webpack/src/index.js +9 -0
  1664. package/node_modules/fastify/test/bundler/webpack/webpack.config.js +15 -0
  1665. package/node_modules/fastify/test/case-insensitive.test.js +102 -0
  1666. package/node_modules/fastify/test/chainable.test.js +40 -0
  1667. package/node_modules/fastify/test/child-logger-factory.test.js +128 -0
  1668. package/node_modules/fastify/test/client-timeout.test.js +38 -0
  1669. package/node_modules/fastify/test/close-pipelining.test.js +78 -0
  1670. package/node_modules/fastify/test/close.test.js +706 -0
  1671. package/node_modules/fastify/test/conditional-pino.test.js +47 -0
  1672. package/node_modules/fastify/test/connection-timeout.test.js +42 -0
  1673. package/node_modules/fastify/test/constrained-routes.test.js +1138 -0
  1674. package/node_modules/fastify/test/content-length.test.js +174 -0
  1675. package/node_modules/fastify/test/content-parser.test.js +739 -0
  1676. package/node_modules/fastify/test/content-type.test.js +181 -0
  1677. package/node_modules/fastify/test/context-config.test.js +164 -0
  1678. package/node_modules/fastify/test/custom-http-server.test.js +118 -0
  1679. package/node_modules/fastify/test/custom-parser-async.test.js +59 -0
  1680. package/node_modules/fastify/test/custom-parser.0.test.js +701 -0
  1681. package/node_modules/fastify/test/custom-parser.1.test.js +266 -0
  1682. package/node_modules/fastify/test/custom-parser.2.test.js +91 -0
  1683. package/node_modules/fastify/test/custom-parser.3.test.js +208 -0
  1684. package/node_modules/fastify/test/custom-parser.4.test.js +218 -0
  1685. package/node_modules/fastify/test/custom-parser.5.test.js +130 -0
  1686. package/node_modules/fastify/test/custom-querystring-parser.test.js +129 -0
  1687. package/node_modules/fastify/test/decorator.test.js +1330 -0
  1688. package/node_modules/fastify/test/delete.test.js +344 -0
  1689. package/node_modules/fastify/test/diagnostics-channel/404.test.js +49 -0
  1690. package/node_modules/fastify/test/diagnostics-channel/async-delay-request.test.js +65 -0
  1691. package/node_modules/fastify/test/diagnostics-channel/async-request.test.js +64 -0
  1692. package/node_modules/fastify/test/diagnostics-channel/error-before-handler.test.js +35 -0
  1693. package/node_modules/fastify/test/diagnostics-channel/error-request.test.js +53 -0
  1694. package/node_modules/fastify/test/diagnostics-channel/error-status.test.js +123 -0
  1695. package/node_modules/fastify/test/diagnostics-channel/init.test.js +50 -0
  1696. package/node_modules/fastify/test/diagnostics-channel/sync-delay-request.test.js +49 -0
  1697. package/node_modules/fastify/test/diagnostics-channel/sync-request-reply.test.js +51 -0
  1698. package/node_modules/fastify/test/diagnostics-channel/sync-request.test.js +54 -0
  1699. package/node_modules/fastify/test/encapsulated-child-logger-factory.test.js +69 -0
  1700. package/node_modules/fastify/test/encapsulated-error-handler.test.js +237 -0
  1701. package/node_modules/fastify/test/esm/errorCodes.test.mjs +10 -0
  1702. package/node_modules/fastify/test/esm/esm.test.mjs +13 -0
  1703. package/node_modules/fastify/test/esm/index.test.js +8 -0
  1704. package/node_modules/fastify/test/esm/named-exports.mjs +14 -0
  1705. package/node_modules/fastify/test/esm/other.mjs +8 -0
  1706. package/node_modules/fastify/test/esm/plugin.mjs +8 -0
  1707. package/node_modules/fastify/test/fastify-instance.test.js +300 -0
  1708. package/node_modules/fastify/test/find-route.test.js +152 -0
  1709. package/node_modules/fastify/test/fluent-schema.test.js +209 -0
  1710. package/node_modules/fastify/test/genReqId.test.js +426 -0
  1711. package/node_modules/fastify/test/handler-context.test.js +45 -0
  1712. package/node_modules/fastify/test/handler-timeout.test.js +367 -0
  1713. package/node_modules/fastify/test/has-route.test.js +88 -0
  1714. package/node_modules/fastify/test/header-overflow.test.js +55 -0
  1715. package/node_modules/fastify/test/helper.js +496 -0
  1716. package/node_modules/fastify/test/hooks-async.test.js +1099 -0
  1717. package/node_modules/fastify/test/hooks.on-listen.test.js +1162 -0
  1718. package/node_modules/fastify/test/hooks.on-ready.test.js +421 -0
  1719. package/node_modules/fastify/test/hooks.test.js +3578 -0
  1720. package/node_modules/fastify/test/http-methods/copy.test.js +35 -0
  1721. package/node_modules/fastify/test/http-methods/custom-http-methods.test.js +114 -0
  1722. package/node_modules/fastify/test/http-methods/get.test.js +412 -0
  1723. package/node_modules/fastify/test/http-methods/head.test.js +263 -0
  1724. package/node_modules/fastify/test/http-methods/lock.test.js +108 -0
  1725. package/node_modules/fastify/test/http-methods/mkcalendar.test.js +143 -0
  1726. package/node_modules/fastify/test/http-methods/mkcol.test.js +35 -0
  1727. package/node_modules/fastify/test/http-methods/move.test.js +42 -0
  1728. package/node_modules/fastify/test/http-methods/propfind.test.js +136 -0
  1729. package/node_modules/fastify/test/http-methods/proppatch.test.js +105 -0
  1730. package/node_modules/fastify/test/http-methods/report.test.js +142 -0
  1731. package/node_modules/fastify/test/http-methods/search.test.js +233 -0
  1732. package/node_modules/fastify/test/http-methods/trace.test.js +21 -0
  1733. package/node_modules/fastify/test/http-methods/unlock.test.js +38 -0
  1734. package/node_modules/fastify/test/http2/closing.test.js +270 -0
  1735. package/node_modules/fastify/test/http2/constraint.test.js +109 -0
  1736. package/node_modules/fastify/test/http2/head.test.js +34 -0
  1737. package/node_modules/fastify/test/http2/plain.test.js +68 -0
  1738. package/node_modules/fastify/test/http2/secure-with-fallback.test.js +113 -0
  1739. package/node_modules/fastify/test/http2/secure.test.js +67 -0
  1740. package/node_modules/fastify/test/http2/unknown-http-method.test.js +34 -0
  1741. package/node_modules/fastify/test/https/custom-https-server.test.js +58 -0
  1742. package/node_modules/fastify/test/https/https.test.js +136 -0
  1743. package/node_modules/fastify/test/imports.test.js +17 -0
  1744. package/node_modules/fastify/test/inject.test.js +502 -0
  1745. package/node_modules/fastify/test/input-validation.js +335 -0
  1746. package/node_modules/fastify/test/internals/all.test.js +38 -0
  1747. package/node_modules/fastify/test/internals/content-type-parser.test.js +111 -0
  1748. package/node_modules/fastify/test/internals/context.test.js +31 -0
  1749. package/node_modules/fastify/test/internals/decorator.test.js +156 -0
  1750. package/node_modules/fastify/test/internals/errors.test.js +982 -0
  1751. package/node_modules/fastify/test/internals/handle-request.test.js +270 -0
  1752. package/node_modules/fastify/test/internals/hook-runner.test.js +449 -0
  1753. package/node_modules/fastify/test/internals/hooks.test.js +96 -0
  1754. package/node_modules/fastify/test/internals/initial-config.test.js +383 -0
  1755. package/node_modules/fastify/test/internals/logger.test.js +163 -0
  1756. package/node_modules/fastify/test/internals/plugin.test.js +170 -0
  1757. package/node_modules/fastify/test/internals/promise.test.js +63 -0
  1758. package/node_modules/fastify/test/internals/reply-serialize.test.js +714 -0
  1759. package/node_modules/fastify/test/internals/reply.test.js +1920 -0
  1760. package/node_modules/fastify/test/internals/req-id-gen-factory.test.js +133 -0
  1761. package/node_modules/fastify/test/internals/request-validate.test.js +1402 -0
  1762. package/node_modules/fastify/test/internals/request.test.js +506 -0
  1763. package/node_modules/fastify/test/internals/schema-controller-perf.test.js +40 -0
  1764. package/node_modules/fastify/test/internals/server.test.js +91 -0
  1765. package/node_modules/fastify/test/internals/validation.test.js +352 -0
  1766. package/node_modules/fastify/test/issue-4959.test.js +118 -0
  1767. package/node_modules/fastify/test/keep-alive-timeout.test.js +42 -0
  1768. package/node_modules/fastify/test/listen.1.test.js +154 -0
  1769. package/node_modules/fastify/test/listen.2.test.js +113 -0
  1770. package/node_modules/fastify/test/listen.3.test.js +83 -0
  1771. package/node_modules/fastify/test/listen.4.test.js +168 -0
  1772. package/node_modules/fastify/test/listen.5.test.js +122 -0
  1773. package/node_modules/fastify/test/logger/instantiation.test.js +341 -0
  1774. package/node_modules/fastify/test/logger/logger-test-utils.js +47 -0
  1775. package/node_modules/fastify/test/logger/logging.test.js +460 -0
  1776. package/node_modules/fastify/test/logger/options.test.js +579 -0
  1777. package/node_modules/fastify/test/logger/request.test.js +292 -0
  1778. package/node_modules/fastify/test/logger/response.test.js +183 -0
  1779. package/node_modules/fastify/test/logger/tap-parallel-not-ok +0 -0
  1780. package/node_modules/fastify/test/max-requests-per-socket.test.js +113 -0
  1781. package/node_modules/fastify/test/middleware.test.js +37 -0
  1782. package/node_modules/fastify/test/noop-set.test.js +19 -0
  1783. package/node_modules/fastify/test/nullable-validation.test.js +187 -0
  1784. package/node_modules/fastify/test/options.error-handler.test.js +5 -0
  1785. package/node_modules/fastify/test/options.test.js +5 -0
  1786. package/node_modules/fastify/test/output-validation.test.js +140 -0
  1787. package/node_modules/fastify/test/patch.error-handler.test.js +5 -0
  1788. package/node_modules/fastify/test/patch.test.js +5 -0
  1789. package/node_modules/fastify/test/plugin.1.test.js +230 -0
  1790. package/node_modules/fastify/test/plugin.2.test.js +314 -0
  1791. package/node_modules/fastify/test/plugin.3.test.js +287 -0
  1792. package/node_modules/fastify/test/plugin.4.test.js +504 -0
  1793. package/node_modules/fastify/test/plugin.helper.js +8 -0
  1794. package/node_modules/fastify/test/plugin.name.display.js +10 -0
  1795. package/node_modules/fastify/test/post-empty-body.test.js +38 -0
  1796. package/node_modules/fastify/test/pretty-print.test.js +366 -0
  1797. package/node_modules/fastify/test/promises.test.js +125 -0
  1798. package/node_modules/fastify/test/proto-poisoning.test.js +145 -0
  1799. package/node_modules/fastify/test/put.error-handler.test.js +5 -0
  1800. package/node_modules/fastify/test/put.test.js +5 -0
  1801. package/node_modules/fastify/test/register.test.js +184 -0
  1802. package/node_modules/fastify/test/reply-code.test.js +148 -0
  1803. package/node_modules/fastify/test/reply-early-hints.test.js +100 -0
  1804. package/node_modules/fastify/test/reply-error.test.js +815 -0
  1805. package/node_modules/fastify/test/reply-trailers.test.js +445 -0
  1806. package/node_modules/fastify/test/reply-web-stream-locked.test.js +37 -0
  1807. package/node_modules/fastify/test/request-error.test.js +624 -0
  1808. package/node_modules/fastify/test/request-header-host.test.js +339 -0
  1809. package/node_modules/fastify/test/request-id.test.js +118 -0
  1810. package/node_modules/fastify/test/request-port.test.js +72 -0
  1811. package/node_modules/fastify/test/request-timeout.test.js +53 -0
  1812. package/node_modules/fastify/test/route-hooks.test.js +635 -0
  1813. package/node_modules/fastify/test/route-prefix.test.js +904 -0
  1814. package/node_modules/fastify/test/route-shorthand.test.js +48 -0
  1815. package/node_modules/fastify/test/route.1.test.js +259 -0
  1816. package/node_modules/fastify/test/route.2.test.js +100 -0
  1817. package/node_modules/fastify/test/route.3.test.js +213 -0
  1818. package/node_modules/fastify/test/route.4.test.js +127 -0
  1819. package/node_modules/fastify/test/route.5.test.js +211 -0
  1820. package/node_modules/fastify/test/route.6.test.js +306 -0
  1821. package/node_modules/fastify/test/route.7.test.js +406 -0
  1822. package/node_modules/fastify/test/route.8.test.js +225 -0
  1823. package/node_modules/fastify/test/router-options.test.js +1108 -0
  1824. package/node_modules/fastify/test/same-shape.test.js +124 -0
  1825. package/node_modules/fastify/test/schema-examples.test.js +661 -0
  1826. package/node_modules/fastify/test/schema-feature.test.js +2198 -0
  1827. package/node_modules/fastify/test/schema-serialization.test.js +1171 -0
  1828. package/node_modules/fastify/test/schema-special-usage.test.js +1348 -0
  1829. package/node_modules/fastify/test/schema-validation.test.js +1593 -0
  1830. package/node_modules/fastify/test/scripts/validate-ecosystem-links.test.js +339 -0
  1831. package/node_modules/fastify/test/serialize-response.test.js +186 -0
  1832. package/node_modules/fastify/test/server.test.js +347 -0
  1833. package/node_modules/fastify/test/set-error-handler.test.js +69 -0
  1834. package/node_modules/fastify/test/skip-reply-send.test.js +317 -0
  1835. package/node_modules/fastify/test/stream-serializers.test.js +40 -0
  1836. package/node_modules/fastify/test/stream.1.test.js +94 -0
  1837. package/node_modules/fastify/test/stream.2.test.js +129 -0
  1838. package/node_modules/fastify/test/stream.3.test.js +198 -0
  1839. package/node_modules/fastify/test/stream.4.test.js +176 -0
  1840. package/node_modules/fastify/test/stream.5.test.js +188 -0
  1841. package/node_modules/fastify/test/sync-routes.test.js +32 -0
  1842. package/node_modules/fastify/test/throw.test.js +359 -0
  1843. package/node_modules/fastify/test/toolkit.js +63 -0
  1844. package/node_modules/fastify/test/trust-proxy.test.js +274 -0
  1845. package/node_modules/fastify/test/type-provider.test.js +22 -0
  1846. package/node_modules/fastify/test/types/content-type-parser.test-d.ts +72 -0
  1847. package/node_modules/fastify/test/types/decorate-request-reply.test-d.ts +18 -0
  1848. package/node_modules/fastify/test/types/dummy-plugin.ts +9 -0
  1849. package/node_modules/fastify/test/types/errors.test-d.ts +90 -0
  1850. package/node_modules/fastify/test/types/fastify.test-d.ts +352 -0
  1851. package/node_modules/fastify/test/types/hooks.test-d.ts +550 -0
  1852. package/node_modules/fastify/test/types/import.ts +2 -0
  1853. package/node_modules/fastify/test/types/instance.test-d.ts +588 -0
  1854. package/node_modules/fastify/test/types/logger.test-d.ts +277 -0
  1855. package/node_modules/fastify/test/types/plugin.test-d.ts +97 -0
  1856. package/node_modules/fastify/test/types/register.test-d.ts +237 -0
  1857. package/node_modules/fastify/test/types/reply.test-d.ts +254 -0
  1858. package/node_modules/fastify/test/types/request.test-d.ts +188 -0
  1859. package/node_modules/fastify/test/types/route.test-d.ts +553 -0
  1860. package/node_modules/fastify/test/types/schema.test-d.ts +135 -0
  1861. package/node_modules/fastify/test/types/serverFactory.test-d.ts +37 -0
  1862. package/node_modules/fastify/test/types/type-provider.test-d.ts +1213 -0
  1863. package/node_modules/fastify/test/types/using.test-d.ts +17 -0
  1864. package/node_modules/fastify/test/upgrade.test.js +52 -0
  1865. package/node_modules/fastify/test/url-rewriting.test.js +122 -0
  1866. package/node_modules/fastify/test/use-semicolon-delimiter.test.js +168 -0
  1867. package/node_modules/fastify/test/validation-error-handling.test.js +900 -0
  1868. package/node_modules/fastify/test/versioned-routes.test.js +603 -0
  1869. package/node_modules/fastify/test/web-api.test.js +616 -0
  1870. package/node_modules/fastify/test/wrap-thenable.test.js +30 -0
  1871. package/node_modules/fastify/types/content-type-parser.d.ts +75 -0
  1872. package/node_modules/fastify/types/context.d.ts +22 -0
  1873. package/node_modules/fastify/types/errors.d.ts +92 -0
  1874. package/node_modules/fastify/types/hooks.d.ts +875 -0
  1875. package/node_modules/fastify/types/instance.d.ts +609 -0
  1876. package/node_modules/fastify/types/logger.d.ts +107 -0
  1877. package/node_modules/fastify/types/plugin.d.ts +44 -0
  1878. package/node_modules/fastify/types/register.d.ts +42 -0
  1879. package/node_modules/fastify/types/reply.d.ts +81 -0
  1880. package/node_modules/fastify/types/request.d.ts +95 -0
  1881. package/node_modules/fastify/types/route.d.ts +199 -0
  1882. package/node_modules/fastify/types/schema.d.ts +61 -0
  1883. package/node_modules/fastify/types/server-factory.d.ts +19 -0
  1884. package/node_modules/fastify/types/type-provider.d.ts +130 -0
  1885. package/node_modules/fastify/types/utils.d.ts +98 -0
  1886. package/node_modules/fastify-plugin/.gitattributes +2 -0
  1887. package/node_modules/fastify-plugin/.github/dependabot.yml +13 -0
  1888. package/node_modules/fastify-plugin/.github/stale.yml +21 -0
  1889. package/node_modules/fastify-plugin/.github/workflows/ci.yml +28 -0
  1890. package/node_modules/fastify-plugin/LICENSE +23 -0
  1891. package/node_modules/fastify-plugin/README.md +188 -0
  1892. package/node_modules/fastify-plugin/eslint.config.js +6 -0
  1893. package/node_modules/fastify-plugin/lib/getPluginName.js +25 -0
  1894. package/node_modules/fastify-plugin/lib/toCamelCase.js +10 -0
  1895. package/node_modules/fastify-plugin/package.json +70 -0
  1896. package/node_modules/fastify-plugin/plugin.js +67 -0
  1897. package/node_modules/fastify-plugin/test/bundlers.test.js +110 -0
  1898. package/node_modules/fastify-plugin/test/checkVersion.test.js +67 -0
  1899. package/node_modules/fastify-plugin/test/composite.test.js +14 -0
  1900. package/node_modules/fastify-plugin/test/esm/esm.mjs +11 -0
  1901. package/node_modules/fastify-plugin/test/esm/index.test.js +11 -0
  1902. package/node_modules/fastify-plugin/test/extractPluginName.test.js +49 -0
  1903. package/node_modules/fastify-plugin/test/mu1tip1e.composite.test.js +15 -0
  1904. package/node_modules/fastify-plugin/test/test.js +396 -0
  1905. package/node_modules/fastify-plugin/test/toCamelCase.test.js +24 -0
  1906. package/node_modules/fastify-plugin/types/example-async.test-d.ts +19 -0
  1907. package/node_modules/fastify-plugin/types/example-callback.test-d.ts +19 -0
  1908. package/node_modules/fastify-plugin/types/plugin.d.ts +61 -0
  1909. package/node_modules/fastify-plugin/types/plugin.test-d.ts +166 -0
  1910. package/node_modules/fastq/LICENSE +13 -0
  1911. package/node_modules/fastq/README.md +310 -0
  1912. package/node_modules/fastq/SECURITY.md +15 -0
  1913. package/node_modules/fastq/bench.js +66 -0
  1914. package/node_modules/fastq/eslint.config.js +11 -0
  1915. package/node_modules/fastq/example.js +14 -0
  1916. package/node_modules/fastq/example.mjs +9 -0
  1917. package/node_modules/fastq/index.d.ts +59 -0
  1918. package/node_modules/fastq/package.json +49 -0
  1919. package/node_modules/fastq/queue.js +346 -0
  1920. package/node_modules/fastq/test/example.ts +83 -0
  1921. package/node_modules/fastq/test/promise.js +325 -0
  1922. package/node_modules/fastq/test/test.js +733 -0
  1923. package/node_modules/fastq/test/tsconfig.json +11 -0
  1924. package/node_modules/find-my-way/.github/dependabot.yml +34 -0
  1925. package/node_modules/find-my-way/.github/workflows/node.js.yml +68 -0
  1926. package/node_modules/find-my-way/LICENSE +21 -0
  1927. package/node_modules/find-my-way/README.md +885 -0
  1928. package/node_modules/find-my-way/benchmark/bench-thread.js +35 -0
  1929. package/node_modules/find-my-way/benchmark/bench.js +156 -0
  1930. package/node_modules/find-my-way/benchmark/compare-branches.js +113 -0
  1931. package/node_modules/find-my-way/benchmark/uri-decoding.js +55 -0
  1932. package/node_modules/find-my-way/example.js +29 -0
  1933. package/node_modules/find-my-way/index.d.ts +247 -0
  1934. package/node_modules/find-my-way/index.js +872 -0
  1935. package/node_modules/find-my-way/lib/constrainer.js +172 -0
  1936. package/node_modules/find-my-way/lib/handler-storage.js +175 -0
  1937. package/node_modules/find-my-way/lib/http-methods.js +13 -0
  1938. package/node_modules/find-my-way/lib/node.js +228 -0
  1939. package/node_modules/find-my-way/lib/null-object.js +8 -0
  1940. package/node_modules/find-my-way/lib/pretty-print.js +168 -0
  1941. package/node_modules/find-my-way/lib/strategies/accept-host.js +36 -0
  1942. package/node_modules/find-my-way/lib/strategies/accept-version.js +64 -0
  1943. package/node_modules/find-my-way/lib/strategies/http-method.js +15 -0
  1944. package/node_modules/find-my-way/lib/url-sanitizer.js +105 -0
  1945. package/node_modules/find-my-way/package.json +57 -0
  1946. package/node_modules/find-my-way/test/case-insensitive.test.js +230 -0
  1947. package/node_modules/find-my-way/test/constraint.custom-versioning.test.js +130 -0
  1948. package/node_modules/find-my-way/test/constraint.custom.async.test.js +111 -0
  1949. package/node_modules/find-my-way/test/constraint.custom.test.js +273 -0
  1950. package/node_modules/find-my-way/test/constraint.default-versioning.test.js +289 -0
  1951. package/node_modules/find-my-way/test/constraint.host.test.js +104 -0
  1952. package/node_modules/find-my-way/test/constraints.test.js +108 -0
  1953. package/node_modules/find-my-way/test/custom-querystring-parser.test.js +46 -0
  1954. package/node_modules/find-my-way/test/errors.test.js +484 -0
  1955. package/node_modules/find-my-way/test/fastify-issue-3129.test.js +34 -0
  1956. package/node_modules/find-my-way/test/fastify-issue-3957.test.js +23 -0
  1957. package/node_modules/find-my-way/test/find-route.test.js +275 -0
  1958. package/node_modules/find-my-way/test/find.test.js +16 -0
  1959. package/node_modules/find-my-way/test/for-in-loop.test.js +22 -0
  1960. package/node_modules/find-my-way/test/full-url.test.js +30 -0
  1961. package/node_modules/find-my-way/test/has-route.test.js +218 -0
  1962. package/node_modules/find-my-way/test/host-storage.test.js +27 -0
  1963. package/node_modules/find-my-way/test/http2/constraint.host.test.js +44 -0
  1964. package/node_modules/find-my-way/test/issue-101.test.js +31 -0
  1965. package/node_modules/find-my-way/test/issue-104.test.js +206 -0
  1966. package/node_modules/find-my-way/test/issue-110.test.js +31 -0
  1967. package/node_modules/find-my-way/test/issue-132.test.js +80 -0
  1968. package/node_modules/find-my-way/test/issue-145.test.js +24 -0
  1969. package/node_modules/find-my-way/test/issue-149.test.js +21 -0
  1970. package/node_modules/find-my-way/test/issue-151.test.js +54 -0
  1971. package/node_modules/find-my-way/test/issue-154.test.js +21 -0
  1972. package/node_modules/find-my-way/test/issue-161.test.js +88 -0
  1973. package/node_modules/find-my-way/test/issue-17.test.js +397 -0
  1974. package/node_modules/find-my-way/test/issue-175.test.js +80 -0
  1975. package/node_modules/find-my-way/test/issue-182.test.js +18 -0
  1976. package/node_modules/find-my-way/test/issue-190.test.js +44 -0
  1977. package/node_modules/find-my-way/test/issue-20.test.js +79 -0
  1978. package/node_modules/find-my-way/test/issue-206.test.js +121 -0
  1979. package/node_modules/find-my-way/test/issue-221.test.js +50 -0
  1980. package/node_modules/find-my-way/test/issue-234.test.js +94 -0
  1981. package/node_modules/find-my-way/test/issue-238.test.js +119 -0
  1982. package/node_modules/find-my-way/test/issue-240.test.js +30 -0
  1983. package/node_modules/find-my-way/test/issue-241.test.js +32 -0
  1984. package/node_modules/find-my-way/test/issue-247.test.js +51 -0
  1985. package/node_modules/find-my-way/test/issue-254.test.js +31 -0
  1986. package/node_modules/find-my-way/test/issue-28.test.js +618 -0
  1987. package/node_modules/find-my-way/test/issue-280.test.js +14 -0
  1988. package/node_modules/find-my-way/test/issue-285.test.js +37 -0
  1989. package/node_modules/find-my-way/test/issue-330.test.js +231 -0
  1990. package/node_modules/find-my-way/test/issue-44.test.js +149 -0
  1991. package/node_modules/find-my-way/test/issue-46.test.js +75 -0
  1992. package/node_modules/find-my-way/test/issue-49.test.js +108 -0
  1993. package/node_modules/find-my-way/test/issue-59.test.js +131 -0
  1994. package/node_modules/find-my-way/test/issue-62.test.js +28 -0
  1995. package/node_modules/find-my-way/test/issue-63.test.js +23 -0
  1996. package/node_modules/find-my-way/test/issue-67.test.js +50 -0
  1997. package/node_modules/find-my-way/test/issue-93.test.js +19 -0
  1998. package/node_modules/find-my-way/test/lookup-async.test.js +29 -0
  1999. package/node_modules/find-my-way/test/lookup.test.js +58 -0
  2000. package/node_modules/find-my-way/test/matching-order.test.js +17 -0
  2001. package/node_modules/find-my-way/test/max-param-length.test.js +44 -0
  2002. package/node_modules/find-my-way/test/methods.test.js +830 -0
  2003. package/node_modules/find-my-way/test/null-object.test.js +36 -0
  2004. package/node_modules/find-my-way/test/on-bad-url.test.js +72 -0
  2005. package/node_modules/find-my-way/test/optional-params.test.js +216 -0
  2006. package/node_modules/find-my-way/test/params-collisions.test.js +126 -0
  2007. package/node_modules/find-my-way/test/path-params-match.test.js +53 -0
  2008. package/node_modules/find-my-way/test/path-utils.test.js +68 -0
  2009. package/node_modules/find-my-way/test/pretty-print-tree.test.js +596 -0
  2010. package/node_modules/find-my-way/test/pretty-print.test.js +680 -0
  2011. package/node_modules/find-my-way/test/querystring.test.js +54 -0
  2012. package/node_modules/find-my-way/test/regex.test.js +269 -0
  2013. package/node_modules/find-my-way/test/repro-issue-414.test.js +57 -0
  2014. package/node_modules/find-my-way/test/routes-registered.test.js +45 -0
  2015. package/node_modules/find-my-way/test/server.test.js +368 -0
  2016. package/node_modules/find-my-way/test/shorthands.test.js +44 -0
  2017. package/node_modules/find-my-way/test/store.test.js +49 -0
  2018. package/node_modules/find-my-way/test/types/router.test-d.ts +188 -0
  2019. package/node_modules/find-my-way/test/url-sanitizer.test.js +43 -0
  2020. package/node_modules/glob/LICENSE.md +63 -0
  2021. package/node_modules/glob/README.md +1203 -0
  2022. package/node_modules/glob/dist/commonjs/glob.d.ts +396 -0
  2023. package/node_modules/glob/dist/commonjs/glob.d.ts.map +1 -0
  2024. package/node_modules/glob/dist/commonjs/glob.js +248 -0
  2025. package/node_modules/glob/dist/commonjs/glob.js.map +1 -0
  2026. package/node_modules/glob/dist/commonjs/has-magic.d.ts +14 -0
  2027. package/node_modules/glob/dist/commonjs/has-magic.d.ts.map +1 -0
  2028. package/node_modules/glob/dist/commonjs/has-magic.js +27 -0
  2029. package/node_modules/glob/dist/commonjs/has-magic.js.map +1 -0
  2030. package/node_modules/glob/dist/commonjs/ignore.d.ts +24 -0
  2031. package/node_modules/glob/dist/commonjs/ignore.d.ts.map +1 -0
  2032. package/node_modules/glob/dist/commonjs/ignore.js +119 -0
  2033. package/node_modules/glob/dist/commonjs/ignore.js.map +1 -0
  2034. package/node_modules/glob/dist/commonjs/index.d.ts +97 -0
  2035. package/node_modules/glob/dist/commonjs/index.d.ts.map +1 -0
  2036. package/node_modules/glob/dist/commonjs/index.js +68 -0
  2037. package/node_modules/glob/dist/commonjs/index.js.map +1 -0
  2038. package/node_modules/glob/dist/commonjs/index.min.js +4 -0
  2039. package/node_modules/glob/dist/commonjs/index.min.js.map +7 -0
  2040. package/node_modules/glob/dist/commonjs/package.json +3 -0
  2041. package/node_modules/glob/dist/commonjs/pattern.d.ts +79 -0
  2042. package/node_modules/glob/dist/commonjs/pattern.d.ts.map +1 -0
  2043. package/node_modules/glob/dist/commonjs/pattern.js +223 -0
  2044. package/node_modules/glob/dist/commonjs/pattern.js.map +1 -0
  2045. package/node_modules/glob/dist/commonjs/processor.d.ts +59 -0
  2046. package/node_modules/glob/dist/commonjs/processor.d.ts.map +1 -0
  2047. package/node_modules/glob/dist/commonjs/processor.js +301 -0
  2048. package/node_modules/glob/dist/commonjs/processor.js.map +1 -0
  2049. package/node_modules/glob/dist/commonjs/walker.d.ts +97 -0
  2050. package/node_modules/glob/dist/commonjs/walker.d.ts.map +1 -0
  2051. package/node_modules/glob/dist/commonjs/walker.js +387 -0
  2052. package/node_modules/glob/dist/commonjs/walker.js.map +1 -0
  2053. package/node_modules/glob/dist/esm/glob.d.ts +396 -0
  2054. package/node_modules/glob/dist/esm/glob.d.ts.map +1 -0
  2055. package/node_modules/glob/dist/esm/glob.js +244 -0
  2056. package/node_modules/glob/dist/esm/glob.js.map +1 -0
  2057. package/node_modules/glob/dist/esm/has-magic.d.ts +14 -0
  2058. package/node_modules/glob/dist/esm/has-magic.d.ts.map +1 -0
  2059. package/node_modules/glob/dist/esm/has-magic.js +23 -0
  2060. package/node_modules/glob/dist/esm/has-magic.js.map +1 -0
  2061. package/node_modules/glob/dist/esm/ignore.d.ts +24 -0
  2062. package/node_modules/glob/dist/esm/ignore.d.ts.map +1 -0
  2063. package/node_modules/glob/dist/esm/ignore.js +115 -0
  2064. package/node_modules/glob/dist/esm/ignore.js.map +1 -0
  2065. package/node_modules/glob/dist/esm/index.d.ts +97 -0
  2066. package/node_modules/glob/dist/esm/index.d.ts.map +1 -0
  2067. package/node_modules/glob/dist/esm/index.js +55 -0
  2068. package/node_modules/glob/dist/esm/index.js.map +1 -0
  2069. package/node_modules/glob/dist/esm/index.min.js +4 -0
  2070. package/node_modules/glob/dist/esm/index.min.js.map +7 -0
  2071. package/node_modules/glob/dist/esm/package.json +3 -0
  2072. package/node_modules/glob/dist/esm/pattern.d.ts +79 -0
  2073. package/node_modules/glob/dist/esm/pattern.d.ts.map +1 -0
  2074. package/node_modules/glob/dist/esm/pattern.js +219 -0
  2075. package/node_modules/glob/dist/esm/pattern.js.map +1 -0
  2076. package/node_modules/glob/dist/esm/processor.d.ts +59 -0
  2077. package/node_modules/glob/dist/esm/processor.d.ts.map +1 -0
  2078. package/node_modules/glob/dist/esm/processor.js +294 -0
  2079. package/node_modules/glob/dist/esm/processor.js.map +1 -0
  2080. package/node_modules/glob/dist/esm/walker.d.ts +97 -0
  2081. package/node_modules/glob/dist/esm/walker.d.ts.map +1 -0
  2082. package/node_modules/glob/dist/esm/walker.js +381 -0
  2083. package/node_modules/glob/dist/esm/walker.js.map +1 -0
  2084. package/node_modules/glob/package.json +98 -0
  2085. package/node_modules/http-errors/HISTORY.md +186 -0
  2086. package/node_modules/http-errors/LICENSE +23 -0
  2087. package/node_modules/http-errors/README.md +169 -0
  2088. package/node_modules/http-errors/index.js +290 -0
  2089. package/node_modules/http-errors/package.json +54 -0
  2090. package/node_modules/inherits/LICENSE +16 -0
  2091. package/node_modules/inherits/README.md +42 -0
  2092. package/node_modules/inherits/inherits.js +9 -0
  2093. package/node_modules/inherits/inherits_browser.js +27 -0
  2094. package/node_modules/inherits/package.json +29 -0
  2095. package/node_modules/ipaddr.js/LICENSE +19 -0
  2096. package/node_modules/ipaddr.js/README.md +229 -0
  2097. package/node_modules/ipaddr.js/ipaddr.min.js +1 -0
  2098. package/node_modules/ipaddr.js/lib/ipaddr.js +1082 -0
  2099. package/node_modules/ipaddr.js/lib/ipaddr.js.d.ts +72 -0
  2100. package/node_modules/ipaddr.js/package.json +36 -0
  2101. package/node_modules/jishushell-panel/LICENSE +6 -0
  2102. package/node_modules/jishushell-panel/README.md +47 -0
  2103. package/node_modules/jishushell-panel/output/dist/server.d.ts +13 -0
  2104. package/node_modules/jishushell-panel/output/dist/server.js +466 -0
  2105. package/node_modules/jishushell-panel/output/dist/server.js.map +1 -0
  2106. package/node_modules/jishushell-panel/output/public/assets/ApiKeyField-NKcbHjNz.js +1 -0
  2107. package/node_modules/jishushell-panel/output/public/assets/Dashboard-Da1fL38t.js +1 -0
  2108. package/node_modules/jishushell-panel/output/public/assets/HermesChatPanel-DZvmYsoh.js +1 -0
  2109. package/node_modules/jishushell-panel/output/public/assets/HermesConfigForm-BLUWlKwm.js +4 -0
  2110. package/node_modules/jishushell-panel/output/public/assets/InitPassword-BAKsshzk.js +1 -0
  2111. package/node_modules/jishushell-panel/output/public/assets/InstanceDetail-Dgyc_TX5.js +14 -0
  2112. package/node_modules/jishushell-panel/output/public/assets/Login-DHeOmwI8.js +1 -0
  2113. package/node_modules/jishushell-panel/output/public/assets/NewInstance-CIy0cYtp.js +1 -0
  2114. package/node_modules/jishushell-panel/output/public/assets/ProviderRecommendations-H0ByEYF0.js +1 -0
  2115. package/node_modules/jishushell-panel/output/public/assets/Settings-DAT-UMfP.js +1 -0
  2116. package/node_modules/jishushell-panel/output/public/assets/Setup-g3uckFYR.js +1 -0
  2117. package/node_modules/jishushell-panel/output/public/assets/WeixinLoginPanel-D-T6BxkQ.js +1 -0
  2118. package/node_modules/jishushell-panel/output/public/assets/api-C70Gt678.js +4 -0
  2119. package/node_modules/jishushell-panel/output/public/assets/index-DnnqTf7s.css +1 -0
  2120. package/node_modules/jishushell-panel/output/public/assets/index-ERt6_ngA.js +23 -0
  2121. package/node_modules/jishushell-panel/output/public/assets/registry-DF93EzIb.js +2 -0
  2122. package/node_modules/jishushell-panel/output/public/assets/rolldown-runtime-QTnfLwEv.js +1 -0
  2123. package/node_modules/jishushell-panel/output/public/assets/setup-task-q21GnI0E.js +1 -0
  2124. package/node_modules/jishushell-panel/output/public/assets/usePolling-DeoThIQn.js +1 -0
  2125. package/node_modules/jishushell-panel/output/public/assets/vendor-i18n-CS8DFbkQ.js +1 -0
  2126. package/node_modules/jishushell-panel/output/public/assets/vendor-react-Cc84NArf.js +8 -0
  2127. package/node_modules/jishushell-panel/output/public/index.html +22 -0
  2128. package/node_modules/jishushell-panel/package.json +33 -0
  2129. package/node_modules/json-schema-ref-resolver/.gitattributes +2 -0
  2130. package/node_modules/json-schema-ref-resolver/.github/dependabot.yml +13 -0
  2131. package/node_modules/json-schema-ref-resolver/.github/workflows/ci.yml +25 -0
  2132. package/node_modules/json-schema-ref-resolver/LICENSE +21 -0
  2133. package/node_modules/json-schema-ref-resolver/README.md +406 -0
  2134. package/node_modules/json-schema-ref-resolver/eslint.config.js +6 -0
  2135. package/node_modules/json-schema-ref-resolver/index.js +284 -0
  2136. package/node_modules/json-schema-ref-resolver/package.json +76 -0
  2137. package/node_modules/json-schema-ref-resolver/test/anchor.test.js +56 -0
  2138. package/node_modules/json-schema-ref-resolver/test/collisions.test.js +199 -0
  2139. package/node_modules/json-schema-ref-resolver/test/deref-schema.test.js +287 -0
  2140. package/node_modules/json-schema-ref-resolver/test/get-deref-schema.test.js +363 -0
  2141. package/node_modules/json-schema-ref-resolver/test/get-schema-dependencies.test.js +158 -0
  2142. package/node_modules/json-schema-ref-resolver/test/get-schema-refs.test.js +87 -0
  2143. package/node_modules/json-schema-ref-resolver/test/get-schema.test.js +222 -0
  2144. package/node_modules/json-schema-ref-resolver/test/has-schema.test.js +28 -0
  2145. package/node_modules/json-schema-ref-resolver/types/index.d.ts +67 -0
  2146. package/node_modules/json-schema-ref-resolver/types/index.test-d.ts +23 -0
  2147. package/node_modules/json-schema-traverse/.eslintrc.yml +27 -0
  2148. package/node_modules/json-schema-traverse/.github/FUNDING.yml +2 -0
  2149. package/node_modules/json-schema-traverse/.github/workflows/build.yml +28 -0
  2150. package/node_modules/json-schema-traverse/.github/workflows/publish.yml +27 -0
  2151. package/node_modules/json-schema-traverse/LICENSE +21 -0
  2152. package/node_modules/json-schema-traverse/README.md +95 -0
  2153. package/node_modules/json-schema-traverse/index.d.ts +40 -0
  2154. package/node_modules/json-schema-traverse/index.js +93 -0
  2155. package/node_modules/json-schema-traverse/package.json +43 -0
  2156. package/node_modules/json-schema-traverse/spec/.eslintrc.yml +6 -0
  2157. package/node_modules/json-schema-traverse/spec/fixtures/schema.js +125 -0
  2158. package/node_modules/json-schema-traverse/spec/index.spec.js +171 -0
  2159. package/node_modules/light-my-request/.gitattributes +2 -0
  2160. package/node_modules/light-my-request/.github/dependabot.yml +13 -0
  2161. package/node_modules/light-my-request/.github/stale.yml +21 -0
  2162. package/node_modules/light-my-request/.github/workflows/benchmark.yml +30 -0
  2163. package/node_modules/light-my-request/.github/workflows/ci.yml +23 -0
  2164. package/node_modules/light-my-request/LICENSE +32 -0
  2165. package/node_modules/light-my-request/README.md +261 -0
  2166. package/node_modules/light-my-request/benchmark/benchmark.js +164 -0
  2167. package/node_modules/light-my-request/build/build-validation.js +100 -0
  2168. package/node_modules/light-my-request/eslint.config.js +9 -0
  2169. package/node_modules/light-my-request/index.js +194 -0
  2170. package/node_modules/light-my-request/lib/config-validator.js +919 -0
  2171. package/node_modules/light-my-request/lib/form-data.js +79 -0
  2172. package/node_modules/light-my-request/lib/parse-url.js +47 -0
  2173. package/node_modules/light-my-request/lib/request.js +290 -0
  2174. package/node_modules/light-my-request/lib/response.js +240 -0
  2175. package/node_modules/light-my-request/node_modules/process-warning/.gitattributes +2 -0
  2176. package/node_modules/light-my-request/node_modules/process-warning/.github/dependabot.yml +13 -0
  2177. package/node_modules/light-my-request/node_modules/process-warning/.github/workflows/ci.yml +24 -0
  2178. package/node_modules/light-my-request/node_modules/process-warning/.taprc +2 -0
  2179. package/node_modules/light-my-request/node_modules/process-warning/LICENSE +21 -0
  2180. package/node_modules/light-my-request/node_modules/process-warning/README.md +118 -0
  2181. package/node_modules/light-my-request/node_modules/process-warning/benchmarks/warn.js +25 -0
  2182. package/node_modules/light-my-request/node_modules/process-warning/eslint.config.js +6 -0
  2183. package/node_modules/light-my-request/node_modules/process-warning/examples/example.js +11 -0
  2184. package/node_modules/light-my-request/node_modules/process-warning/index.js +124 -0
  2185. package/node_modules/light-my-request/node_modules/process-warning/package.json +73 -0
  2186. package/node_modules/light-my-request/node_modules/process-warning/test/emit-interpolated-string.test.js +29 -0
  2187. package/node_modules/light-my-request/node_modules/process-warning/test/emit-once-only.test.js +28 -0
  2188. package/node_modules/light-my-request/node_modules/process-warning/test/emit-reset.test.js +36 -0
  2189. package/node_modules/light-my-request/node_modules/process-warning/test/emit-set.test.js +30 -0
  2190. package/node_modules/light-my-request/node_modules/process-warning/test/emit-unlimited.test.js +37 -0
  2191. package/node_modules/light-my-request/node_modules/process-warning/test/index.test.js +99 -0
  2192. package/node_modules/light-my-request/node_modules/process-warning/test/issue-88.test.js +33 -0
  2193. package/node_modules/light-my-request/node_modules/process-warning/test/jest.test.js +22 -0
  2194. package/node_modules/light-my-request/node_modules/process-warning/test/no-warnings.test.js +80 -0
  2195. package/node_modules/light-my-request/node_modules/process-warning/types/index.d.ts +37 -0
  2196. package/node_modules/light-my-request/node_modules/process-warning/types/index.test-d.ts +36 -0
  2197. package/node_modules/light-my-request/package.json +85 -0
  2198. package/node_modules/light-my-request/test/async-await.test.js +55 -0
  2199. package/node_modules/light-my-request/test/index.test.js +2316 -0
  2200. package/node_modules/light-my-request/test/request.test.js +16 -0
  2201. package/node_modules/light-my-request/test/response.test.js +19 -0
  2202. package/node_modules/light-my-request/test/stream.test.js +359 -0
  2203. package/node_modules/light-my-request/types/index.d.ts +128 -0
  2204. package/node_modules/light-my-request/types/index.test-d.ts +149 -0
  2205. package/node_modules/mime/CHANGELOG.md +312 -0
  2206. package/node_modules/mime/LICENSE +21 -0
  2207. package/node_modules/mime/Mime.js +97 -0
  2208. package/node_modules/mime/README.md +178 -0
  2209. package/node_modules/mime/cli.js +46 -0
  2210. package/node_modules/mime/index.js +4 -0
  2211. package/node_modules/mime/lite.js +4 -0
  2212. package/node_modules/mime/package.json +52 -0
  2213. package/node_modules/mime/types/other.js +1 -0
  2214. package/node_modules/mime/types/standard.js +1 -0
  2215. package/node_modules/minimatch/LICENSE.md +55 -0
  2216. package/node_modules/minimatch/README.md +528 -0
  2217. package/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts +2 -0
  2218. package/node_modules/minimatch/dist/commonjs/assert-valid-pattern.d.ts.map +1 -0
  2219. package/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js +14 -0
  2220. package/node_modules/minimatch/dist/commonjs/assert-valid-pattern.js.map +1 -0
  2221. package/node_modules/minimatch/dist/commonjs/ast.d.ts +22 -0
  2222. package/node_modules/minimatch/dist/commonjs/ast.d.ts.map +1 -0
  2223. package/node_modules/minimatch/dist/commonjs/ast.js +845 -0
  2224. package/node_modules/minimatch/dist/commonjs/ast.js.map +1 -0
  2225. package/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts +8 -0
  2226. package/node_modules/minimatch/dist/commonjs/brace-expressions.d.ts.map +1 -0
  2227. package/node_modules/minimatch/dist/commonjs/brace-expressions.js +150 -0
  2228. package/node_modules/minimatch/dist/commonjs/brace-expressions.js.map +1 -0
  2229. package/node_modules/minimatch/dist/commonjs/escape.d.ts +15 -0
  2230. package/node_modules/minimatch/dist/commonjs/escape.d.ts.map +1 -0
  2231. package/node_modules/minimatch/dist/commonjs/escape.js +30 -0
  2232. package/node_modules/minimatch/dist/commonjs/escape.js.map +1 -0
  2233. package/node_modules/minimatch/dist/commonjs/index.d.ts +174 -0
  2234. package/node_modules/minimatch/dist/commonjs/index.d.ts.map +1 -0
  2235. package/node_modules/minimatch/dist/commonjs/index.js +1127 -0
  2236. package/node_modules/minimatch/dist/commonjs/index.js.map +1 -0
  2237. package/node_modules/minimatch/dist/commonjs/package.json +3 -0
  2238. package/node_modules/minimatch/dist/commonjs/unescape.d.ts +22 -0
  2239. package/node_modules/minimatch/dist/commonjs/unescape.d.ts.map +1 -0
  2240. package/node_modules/minimatch/dist/commonjs/unescape.js +38 -0
  2241. package/node_modules/minimatch/dist/commonjs/unescape.js.map +1 -0
  2242. package/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts +2 -0
  2243. package/node_modules/minimatch/dist/esm/assert-valid-pattern.d.ts.map +1 -0
  2244. package/node_modules/minimatch/dist/esm/assert-valid-pattern.js +10 -0
  2245. package/node_modules/minimatch/dist/esm/assert-valid-pattern.js.map +1 -0
  2246. package/node_modules/minimatch/dist/esm/ast.d.ts +22 -0
  2247. package/node_modules/minimatch/dist/esm/ast.d.ts.map +1 -0
  2248. package/node_modules/minimatch/dist/esm/ast.js +841 -0
  2249. package/node_modules/minimatch/dist/esm/ast.js.map +1 -0
  2250. package/node_modules/minimatch/dist/esm/brace-expressions.d.ts +8 -0
  2251. package/node_modules/minimatch/dist/esm/brace-expressions.d.ts.map +1 -0
  2252. package/node_modules/minimatch/dist/esm/brace-expressions.js +146 -0
  2253. package/node_modules/minimatch/dist/esm/brace-expressions.js.map +1 -0
  2254. package/node_modules/minimatch/dist/esm/escape.d.ts +15 -0
  2255. package/node_modules/minimatch/dist/esm/escape.d.ts.map +1 -0
  2256. package/node_modules/minimatch/dist/esm/escape.js +26 -0
  2257. package/node_modules/minimatch/dist/esm/escape.js.map +1 -0
  2258. package/node_modules/minimatch/dist/esm/index.d.ts +174 -0
  2259. package/node_modules/minimatch/dist/esm/index.d.ts.map +1 -0
  2260. package/node_modules/minimatch/dist/esm/index.js +1114 -0
  2261. package/node_modules/minimatch/dist/esm/index.js.map +1 -0
  2262. package/node_modules/minimatch/dist/esm/package.json +3 -0
  2263. package/node_modules/minimatch/dist/esm/unescape.d.ts +22 -0
  2264. package/node_modules/minimatch/dist/esm/unescape.d.ts.map +1 -0
  2265. package/node_modules/minimatch/dist/esm/unescape.js +34 -0
  2266. package/node_modules/minimatch/dist/esm/unescape.js.map +1 -0
  2267. package/node_modules/minimatch/package.json +73 -0
  2268. package/node_modules/minipass/LICENSE.md +55 -0
  2269. package/node_modules/minipass/README.md +825 -0
  2270. package/node_modules/minipass/dist/commonjs/index.d.ts +545 -0
  2271. package/node_modules/minipass/dist/commonjs/index.d.ts.map +1 -0
  2272. package/node_modules/minipass/dist/commonjs/index.js +1038 -0
  2273. package/node_modules/minipass/dist/commonjs/index.js.map +1 -0
  2274. package/node_modules/minipass/dist/commonjs/package.json +3 -0
  2275. package/node_modules/minipass/dist/esm/index.d.ts +545 -0
  2276. package/node_modules/minipass/dist/esm/index.d.ts.map +1 -0
  2277. package/node_modules/minipass/dist/esm/index.js +1020 -0
  2278. package/node_modules/minipass/dist/esm/index.js.map +1 -0
  2279. package/node_modules/minipass/dist/esm/package.json +3 -0
  2280. package/node_modules/minipass/package.json +77 -0
  2281. package/node_modules/on-exit-leak-free/.github/dependabot.yml +12 -0
  2282. package/node_modules/on-exit-leak-free/.github/workflows/ci.yml +46 -0
  2283. package/node_modules/on-exit-leak-free/LICENSE +21 -0
  2284. package/node_modules/on-exit-leak-free/README.md +54 -0
  2285. package/node_modules/on-exit-leak-free/index.js +108 -0
  2286. package/node_modules/on-exit-leak-free/package.json +37 -0
  2287. package/node_modules/on-exit-leak-free/test/base.test.js +30 -0
  2288. package/node_modules/on-exit-leak-free/test/event-emitter-leak.test.js +23 -0
  2289. package/node_modules/on-exit-leak-free/test/fixtures/beforeExit.js +33 -0
  2290. package/node_modules/on-exit-leak-free/test/fixtures/close.js +21 -0
  2291. package/node_modules/on-exit-leak-free/test/fixtures/gc-not-close.js +24 -0
  2292. package/node_modules/on-exit-leak-free/test/fixtures/unregister.js +24 -0
  2293. package/node_modules/path-scurry/LICENSE.md +55 -0
  2294. package/node_modules/path-scurry/README.md +636 -0
  2295. package/node_modules/path-scurry/dist/commonjs/index.d.ts +1115 -0
  2296. package/node_modules/path-scurry/dist/commonjs/index.d.ts.map +1 -0
  2297. package/node_modules/path-scurry/dist/commonjs/index.js +2018 -0
  2298. package/node_modules/path-scurry/dist/commonjs/index.js.map +1 -0
  2299. package/node_modules/path-scurry/dist/commonjs/package.json +3 -0
  2300. package/node_modules/path-scurry/dist/esm/index.d.ts +1115 -0
  2301. package/node_modules/path-scurry/dist/esm/index.d.ts.map +1 -0
  2302. package/node_modules/path-scurry/dist/esm/index.js +1983 -0
  2303. package/node_modules/path-scurry/dist/esm/index.js.map +1 -0
  2304. package/node_modules/path-scurry/dist/esm/package.json +3 -0
  2305. package/node_modules/path-scurry/node_modules/lru-cache/LICENSE.md +55 -0
  2306. package/node_modules/path-scurry/node_modules/lru-cache/README.md +469 -0
  2307. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel-browser.d.ts.map +1 -0
  2308. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel-browser.js.map +1 -0
  2309. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel.d.ts +5 -0
  2310. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/diagnostics-channel.js +7 -0
  2311. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/index.d.ts +1400 -0
  2312. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/index.d.ts.map +1 -0
  2313. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/index.js +1726 -0
  2314. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/index.js.map +1 -0
  2315. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/index.min.js +2 -0
  2316. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/index.min.js.map +7 -0
  2317. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/perf.d.ts +12 -0
  2318. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/perf.d.ts.map +1 -0
  2319. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/perf.js +10 -0
  2320. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/browser/perf.js.map +1 -0
  2321. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/diagnostics-channel-cjs.cjs.map +1 -0
  2322. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/diagnostics-channel-cjs.d.cts.map +1 -0
  2323. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/diagnostics-channel.d.ts +5 -0
  2324. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/diagnostics-channel.js +7 -0
  2325. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.d.ts +1400 -0
  2326. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.d.ts.map +1 -0
  2327. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.js +1726 -0
  2328. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.js.map +1 -0
  2329. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.min.js +2 -0
  2330. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/index.min.js.map +7 -0
  2331. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel-node.d.ts.map +1 -0
  2332. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel-node.js.map +1 -0
  2333. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel.d.ts +5 -0
  2334. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/diagnostics-channel.js +9 -0
  2335. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/index.d.ts +1400 -0
  2336. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/index.d.ts.map +1 -0
  2337. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/index.js +1726 -0
  2338. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/index.js.map +1 -0
  2339. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/index.min.js +2 -0
  2340. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/index.min.js.map +7 -0
  2341. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/perf.d.ts +12 -0
  2342. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/perf.d.ts.map +1 -0
  2343. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/perf.js +10 -0
  2344. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/node/perf.js.map +1 -0
  2345. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/package.json +3 -0
  2346. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/perf.d.ts +12 -0
  2347. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/perf.d.ts.map +1 -0
  2348. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/perf.js +10 -0
  2349. package/node_modules/path-scurry/node_modules/lru-cache/dist/commonjs/perf.js.map +1 -0
  2350. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/diagnostics-channel-browser.d.ts.map +1 -0
  2351. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/diagnostics-channel-browser.js.map +1 -0
  2352. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.d.ts +5 -0
  2353. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/diagnostics-channel.js +4 -0
  2354. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/index.d.ts +1400 -0
  2355. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/index.d.ts.map +1 -0
  2356. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/index.js +1722 -0
  2357. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/index.js.map +1 -0
  2358. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/index.min.js +2 -0
  2359. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/index.min.js.map +7 -0
  2360. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/perf.d.ts +12 -0
  2361. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/perf.d.ts.map +1 -0
  2362. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/perf.js +7 -0
  2363. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/browser/perf.js.map +1 -0
  2364. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/diagnostics-channel-esm.d.mts.map +1 -0
  2365. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/diagnostics-channel-esm.mjs.map +1 -0
  2366. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/diagnostics-channel.d.ts +5 -0
  2367. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/diagnostics-channel.js +19 -0
  2368. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.d.ts +1400 -0
  2369. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.d.ts.map +1 -0
  2370. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.js +1722 -0
  2371. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.js.map +1 -0
  2372. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.min.js +2 -0
  2373. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/index.min.js.map +7 -0
  2374. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/diagnostics-channel-node.d.ts.map +1 -0
  2375. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/diagnostics-channel-node.js.map +1 -0
  2376. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/diagnostics-channel.d.ts +5 -0
  2377. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/diagnostics-channel.js +6 -0
  2378. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/index.d.ts +1400 -0
  2379. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/index.d.ts.map +1 -0
  2380. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/index.js +1722 -0
  2381. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/index.js.map +1 -0
  2382. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/index.min.js +2 -0
  2383. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/index.min.js.map +7 -0
  2384. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/perf.d.ts +12 -0
  2385. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/perf.d.ts.map +1 -0
  2386. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/perf.js +7 -0
  2387. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/node/perf.js.map +1 -0
  2388. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/package.json +3 -0
  2389. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/perf.d.ts +12 -0
  2390. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/perf.d.ts.map +1 -0
  2391. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/perf.js +7 -0
  2392. package/node_modules/path-scurry/node_modules/lru-cache/dist/esm/perf.js.map +1 -0
  2393. package/node_modules/path-scurry/node_modules/lru-cache/package.json +154 -0
  2394. package/node_modules/path-scurry/package.json +72 -0
  2395. package/node_modules/pino/.nojekyll +0 -0
  2396. package/node_modules/pino/.prettierignore +1 -0
  2397. package/node_modules/pino/CNAME +1 -0
  2398. package/node_modules/pino/CONTRIBUTING.md +30 -0
  2399. package/node_modules/pino/LICENSE +21 -0
  2400. package/node_modules/pino/README.md +177 -0
  2401. package/node_modules/pino/SECURITY.md +87 -0
  2402. package/node_modules/pino/benchmarks/basic.bench.js +95 -0
  2403. package/node_modules/pino/benchmarks/child-child.bench.js +52 -0
  2404. package/node_modules/pino/benchmarks/child-creation.bench.js +73 -0
  2405. package/node_modules/pino/benchmarks/child.bench.js +62 -0
  2406. package/node_modules/pino/benchmarks/deep-object.bench.js +88 -0
  2407. package/node_modules/pino/benchmarks/formatters.bench.js +50 -0
  2408. package/node_modules/pino/benchmarks/internal/custom-levels.js +67 -0
  2409. package/node_modules/pino/benchmarks/internal/just-pino-heavy.bench.js +76 -0
  2410. package/node_modules/pino/benchmarks/internal/just-pino.bench.js +182 -0
  2411. package/node_modules/pino/benchmarks/internal/parent-vs-child.bench.js +75 -0
  2412. package/node_modules/pino/benchmarks/internal/redact.bench.js +86 -0
  2413. package/node_modules/pino/benchmarks/long-string.bench.js +81 -0
  2414. package/node_modules/pino/benchmarks/multi-arg.bench.js +193 -0
  2415. package/node_modules/pino/benchmarks/multistream.js +98 -0
  2416. package/node_modules/pino/benchmarks/object.bench.js +82 -0
  2417. package/node_modules/pino/benchmarks/utils/generate-benchmark-doc.js +36 -0
  2418. package/node_modules/pino/benchmarks/utils/runbench.js +138 -0
  2419. package/node_modules/pino/benchmarks/utils/wrap-log-level.js +55 -0
  2420. package/node_modules/pino/bin.js +6 -0
  2421. package/node_modules/pino/browser.js +547 -0
  2422. package/node_modules/pino/build/sync-version.js +25 -0
  2423. package/node_modules/pino/docs/api.md +1593 -0
  2424. package/node_modules/pino/docs/asynchronous.md +40 -0
  2425. package/node_modules/pino/docs/benchmarks.md +55 -0
  2426. package/node_modules/pino/docs/browser.md +278 -0
  2427. package/node_modules/pino/docs/bundling.md +40 -0
  2428. package/node_modules/pino/docs/child-loggers.md +95 -0
  2429. package/node_modules/pino/docs/diagnostics.md +16 -0
  2430. package/node_modules/pino/docs/ecosystem.md +86 -0
  2431. package/node_modules/pino/docs/help.md +345 -0
  2432. package/node_modules/pino/docs/lts.md +64 -0
  2433. package/node_modules/pino/docs/pretty.md +35 -0
  2434. package/node_modules/pino/docs/redaction.md +135 -0
  2435. package/node_modules/pino/docs/transports.md +1376 -0
  2436. package/node_modules/pino/docs/web.md +309 -0
  2437. package/node_modules/pino/eslint.config.js +28 -0
  2438. package/node_modules/pino/examples/basic.js +43 -0
  2439. package/node_modules/pino/examples/transport.js +68 -0
  2440. package/node_modules/pino/favicon.ico +0 -0
  2441. package/node_modules/pino/file.js +12 -0
  2442. package/node_modules/pino/inc-version.sh +42 -0
  2443. package/node_modules/pino/index.html +55 -0
  2444. package/node_modules/pino/lib/caller.js +30 -0
  2445. package/node_modules/pino/lib/constants.js +28 -0
  2446. package/node_modules/pino/lib/deprecations.js +8 -0
  2447. package/node_modules/pino/lib/levels.js +241 -0
  2448. package/node_modules/pino/lib/meta.js +3 -0
  2449. package/node_modules/pino/lib/multistream.js +203 -0
  2450. package/node_modules/pino/lib/proto.js +256 -0
  2451. package/node_modules/pino/lib/redaction.js +114 -0
  2452. package/node_modules/pino/lib/symbols.js +74 -0
  2453. package/node_modules/pino/lib/time.js +39 -0
  2454. package/node_modules/pino/lib/tools.js +427 -0
  2455. package/node_modules/pino/lib/transport-stream.js +56 -0
  2456. package/node_modules/pino/lib/transport.js +289 -0
  2457. package/node_modules/pino/lib/worker.js +194 -0
  2458. package/node_modules/pino/package.json +120 -0
  2459. package/node_modules/pino/pino.d.ts +908 -0
  2460. package/node_modules/pino/pino.js +234 -0
  2461. package/node_modules/pino/test/basic.test.js +886 -0
  2462. package/node_modules/pino/test/broken-pipe.test.js +59 -0
  2463. package/node_modules/pino/test/browser-child.test.js +132 -0
  2464. package/node_modules/pino/test/browser-disabled.test.js +87 -0
  2465. package/node_modules/pino/test/browser-early-console-freeze.test.js +12 -0
  2466. package/node_modules/pino/test/browser-is-level-enabled.test.js +101 -0
  2467. package/node_modules/pino/test/browser-levels.test.js +241 -0
  2468. package/node_modules/pino/test/browser-serializers.test.js +352 -0
  2469. package/node_modules/pino/test/browser-timestamp.test.js +88 -0
  2470. package/node_modules/pino/test/browser-transmit.test.js +417 -0
  2471. package/node_modules/pino/test/browser.test.js +698 -0
  2472. package/node_modules/pino/test/complex-objects.test.js +36 -0
  2473. package/node_modules/pino/test/crlf.test.js +34 -0
  2474. package/node_modules/pino/test/custom-levels.test.js +267 -0
  2475. package/node_modules/pino/test/diagnostics.test.js +107 -0
  2476. package/node_modules/pino/test/error-key.test.js +37 -0
  2477. package/node_modules/pino/test/error.test.js +403 -0
  2478. package/node_modules/pino/test/escaping.test.js +93 -0
  2479. package/node_modules/pino/test/esm/esm.mjs +14 -0
  2480. package/node_modules/pino/test/esm/index.test.js +21 -0
  2481. package/node_modules/pino/test/esm/named-exports.mjs +29 -0
  2482. package/node_modules/pino/test/exit.test.js +79 -0
  2483. package/node_modules/pino/test/fixtures/broken-pipe/basic.js +9 -0
  2484. package/node_modules/pino/test/fixtures/broken-pipe/destination.js +10 -0
  2485. package/node_modules/pino/test/fixtures/broken-pipe/syncfalse.js +12 -0
  2486. package/node_modules/pino/test/fixtures/console-transport.js +13 -0
  2487. package/node_modules/pino/test/fixtures/crashing-transport.js +13 -0
  2488. package/node_modules/pino/test/fixtures/default-exit.js +8 -0
  2489. package/node_modules/pino/test/fixtures/destination-exit.js +8 -0
  2490. package/node_modules/pino/test/fixtures/eval/index.js +13 -0
  2491. package/node_modules/pino/test/fixtures/eval/node_modules/14-files.js +3 -0
  2492. package/node_modules/pino/test/fixtures/eval/node_modules/2-files.js +3 -0
  2493. package/node_modules/pino/test/fixtures/eval/node_modules/file1.js +5 -0
  2494. package/node_modules/pino/test/fixtures/eval/node_modules/file10.js +5 -0
  2495. package/node_modules/pino/test/fixtures/eval/node_modules/file11.js +5 -0
  2496. package/node_modules/pino/test/fixtures/eval/node_modules/file12.js +5 -0
  2497. package/node_modules/pino/test/fixtures/eval/node_modules/file13.js +5 -0
  2498. package/node_modules/pino/test/fixtures/eval/node_modules/file14.js +11 -0
  2499. package/node_modules/pino/test/fixtures/eval/node_modules/file2.js +5 -0
  2500. package/node_modules/pino/test/fixtures/eval/node_modules/file3.js +5 -0
  2501. package/node_modules/pino/test/fixtures/eval/node_modules/file4.js +5 -0
  2502. package/node_modules/pino/test/fixtures/eval/node_modules/file5.js +5 -0
  2503. package/node_modules/pino/test/fixtures/eval/node_modules/file6.js +5 -0
  2504. package/node_modules/pino/test/fixtures/eval/node_modules/file7.js +5 -0
  2505. package/node_modules/pino/test/fixtures/eval/node_modules/file8.js +5 -0
  2506. package/node_modules/pino/test/fixtures/eval/node_modules/file9.js +5 -0
  2507. package/node_modules/pino/test/fixtures/noop-transport.js +10 -0
  2508. package/node_modules/pino/test/fixtures/pretty/null-prototype.js +8 -0
  2509. package/node_modules/pino/test/fixtures/stdout-hack-protection.js +11 -0
  2510. package/node_modules/pino/test/fixtures/syncfalse-child.js +6 -0
  2511. package/node_modules/pino/test/fixtures/syncfalse-exit.js +9 -0
  2512. package/node_modules/pino/test/fixtures/syncfalse-flush-exit.js +10 -0
  2513. package/node_modules/pino/test/fixtures/syncfalse.js +6 -0
  2514. package/node_modules/pino/test/fixtures/syntax-error-esm.mjs +2 -0
  2515. package/node_modules/pino/test/fixtures/to-file-transport-with-transform.js +20 -0
  2516. package/node_modules/pino/test/fixtures/to-file-transport.js +13 -0
  2517. package/node_modules/pino/test/fixtures/to-file-transport.mjs +8 -0
  2518. package/node_modules/pino/test/fixtures/transport/index.js +12 -0
  2519. package/node_modules/pino/test/fixtures/transport/package.json +5 -0
  2520. package/node_modules/pino/test/fixtures/transport-exit-immediately-with-async-dest.js +16 -0
  2521. package/node_modules/pino/test/fixtures/transport-exit-immediately.js +11 -0
  2522. package/node_modules/pino/test/fixtures/transport-exit-on-ready.js +12 -0
  2523. package/node_modules/pino/test/fixtures/transport-invalid-node-options.js +26 -0
  2524. package/node_modules/pino/test/fixtures/transport-main.js +9 -0
  2525. package/node_modules/pino/test/fixtures/transport-many-lines.js +29 -0
  2526. package/node_modules/pino/test/fixtures/transport-preload-main.mjs +13 -0
  2527. package/node_modules/pino/test/fixtures/transport-preload.mjs +13 -0
  2528. package/node_modules/pino/test/fixtures/transport-string-stdout.js +9 -0
  2529. package/node_modules/pino/test/fixtures/transport-transform.js +21 -0
  2530. package/node_modules/pino/test/fixtures/transport-uses-pino-config.js +33 -0
  2531. package/node_modules/pino/test/fixtures/transport-with-on-exit.js +12 -0
  2532. package/node_modules/pino/test/fixtures/transport-worker-data.js +19 -0
  2533. package/node_modules/pino/test/fixtures/transport-worker-name.js +24 -0
  2534. package/node_modules/pino/test/fixtures/transport-worker.js +15 -0
  2535. package/node_modules/pino/test/fixtures/transport-wrong-export-type.js +3 -0
  2536. package/node_modules/pino/test/fixtures/ts/to-file-transport-native.mts +15 -0
  2537. package/node_modules/pino/test/fixtures/ts/to-file-transport-with-transform.ts +18 -0
  2538. package/node_modules/pino/test/fixtures/ts/to-file-transport.ts +11 -0
  2539. package/node_modules/pino/test/fixtures/ts/transpile.cjs +36 -0
  2540. package/node_modules/pino/test/fixtures/ts/transport-exit-immediately-with-async-dest.ts +15 -0
  2541. package/node_modules/pino/test/fixtures/ts/transport-exit-immediately.ts +10 -0
  2542. package/node_modules/pino/test/fixtures/ts/transport-exit-on-ready.ts +11 -0
  2543. package/node_modules/pino/test/fixtures/ts/transport-main.ts +8 -0
  2544. package/node_modules/pino/test/fixtures/ts/transport-string-stdout.ts +8 -0
  2545. package/node_modules/pino/test/fixtures/ts/transport-worker.ts +14 -0
  2546. package/node_modules/pino/test/formatters.test.js +364 -0
  2547. package/node_modules/pino/test/helper.d.ts +4 -0
  2548. package/node_modules/pino/test/helper.js +155 -0
  2549. package/node_modules/pino/test/hooks.test.js +114 -0
  2550. package/node_modules/pino/test/http.test.js +214 -0
  2551. package/node_modules/pino/test/internals/version.test.js +17 -0
  2552. package/node_modules/pino/test/is-level-enabled.test.js +179 -0
  2553. package/node_modules/pino/test/jest/basic.spec.js +10 -0
  2554. package/node_modules/pino/test/levels.test.js +810 -0
  2555. package/node_modules/pino/test/metadata.test.js +120 -0
  2556. package/node_modules/pino/test/mixin-merge-strategy.test.js +57 -0
  2557. package/node_modules/pino/test/mixin.test.js +241 -0
  2558. package/node_modules/pino/test/multistream.test.js +729 -0
  2559. package/node_modules/pino/test/redact.test.js +893 -0
  2560. package/node_modules/pino/test/serializers.test.js +257 -0
  2561. package/node_modules/pino/test/stdout-protection.test.js +41 -0
  2562. package/node_modules/pino/test/syncfalse.test.js +186 -0
  2563. package/node_modules/pino/test/timestamp-nano.test.js +37 -0
  2564. package/node_modules/pino/test/timestamp.test.js +124 -0
  2565. package/node_modules/pino/test/transport/big.test.js +42 -0
  2566. package/node_modules/pino/test/transport/bundlers-support.test.js +99 -0
  2567. package/node_modules/pino/test/transport/caller.test.js +24 -0
  2568. package/node_modules/pino/test/transport/core.test.js +733 -0
  2569. package/node_modules/pino/test/transport/core.transpiled.test.ts +114 -0
  2570. package/node_modules/pino/test/transport/crash.test.js +36 -0
  2571. package/node_modules/pino/test/transport/module-link.test.js +241 -0
  2572. package/node_modules/pino/test/transport/native-type-stripping.test.mjs +151 -0
  2573. package/node_modules/pino/test/transport/node-options.test.js +116 -0
  2574. package/node_modules/pino/test/transport/pipeline.test.js +137 -0
  2575. package/node_modules/pino/test/transport/preload.test.js +54 -0
  2576. package/node_modules/pino/test/transport/repl.test.js +15 -0
  2577. package/node_modules/pino/test/transport/sync-false.test.js +67 -0
  2578. package/node_modules/pino/test/transport/sync-true.test.js +57 -0
  2579. package/node_modules/pino/test/transport/targets.test.js +48 -0
  2580. package/node_modules/pino/test/transport/uses-pino-config.test.js +166 -0
  2581. package/node_modules/pino/test/transport-stream.test.js +40 -0
  2582. package/node_modules/pino/test/types/pino-import.test-d.cts +30 -0
  2583. package/node_modules/pino/test/types/pino-multistream.test-d.ts +28 -0
  2584. package/node_modules/pino/test/types/pino-top-export.test-d.ts +34 -0
  2585. package/node_modules/pino/test/types/pino-transport.test-d.ts +156 -0
  2586. package/node_modules/pino/test/types/pino-type-only.test-d.ts +75 -0
  2587. package/node_modules/pino/test/types/pino.test-d.ts +683 -0
  2588. package/node_modules/pino/test/types/pino.ts +91 -0
  2589. package/node_modules/pino/tsconfig.json +14 -0
  2590. package/node_modules/pino-abstract-transport/.github/dependabot.yml +13 -0
  2591. package/node_modules/pino-abstract-transport/.github/workflows/ci.yml +80 -0
  2592. package/node_modules/pino-abstract-transport/.husky/pre-commit +4 -0
  2593. package/node_modules/pino-abstract-transport/LICENSE +21 -0
  2594. package/node_modules/pino-abstract-transport/README.md +171 -0
  2595. package/node_modules/pino-abstract-transport/index.d.ts +122 -0
  2596. package/node_modules/pino-abstract-transport/index.js +128 -0
  2597. package/node_modules/pino-abstract-transport/package.json +41 -0
  2598. package/node_modules/pino-abstract-transport/test/base.test.js +473 -0
  2599. package/node_modules/pino-abstract-transport/test/fixtures/transport-async-iteration.js +22 -0
  2600. package/node_modules/pino-abstract-transport/test/fixtures/transport-on-data.js +22 -0
  2601. package/node_modules/pino-abstract-transport/test/fixtures/transport-transform.js +24 -0
  2602. package/node_modules/pino-abstract-transport/test/fixtures/worker-pipeline.js +15 -0
  2603. package/node_modules/pino-abstract-transport/test/match.js +24 -0
  2604. package/node_modules/pino-abstract-transport/test/types/index.test-d.ts +31 -0
  2605. package/node_modules/pino-abstract-transport/test/worker.test.js +372 -0
  2606. package/node_modules/pino-std-serializers/.editorconfig +13 -0
  2607. package/node_modules/pino-std-serializers/.github/dependabot.yml +13 -0
  2608. package/node_modules/pino-std-serializers/.github/workflows/ci.yml +81 -0
  2609. package/node_modules/pino-std-serializers/LICENSE +7 -0
  2610. package/node_modules/pino-std-serializers/Readme.md +182 -0
  2611. package/node_modules/pino-std-serializers/eslint.config.js +7 -0
  2612. package/node_modules/pino-std-serializers/index.d.ts +145 -0
  2613. package/node_modules/pino-std-serializers/index.js +36 -0
  2614. package/node_modules/pino-std-serializers/lib/err-helpers.js +118 -0
  2615. package/node_modules/pino-std-serializers/lib/err-proto.js +48 -0
  2616. package/node_modules/pino-std-serializers/lib/err-with-cause.js +48 -0
  2617. package/node_modules/pino-std-serializers/lib/err.js +45 -0
  2618. package/node_modules/pino-std-serializers/lib/req.js +100 -0
  2619. package/node_modules/pino-std-serializers/lib/res.js +47 -0
  2620. package/node_modules/pino-std-serializers/package.json +42 -0
  2621. package/node_modules/pino-std-serializers/test/err-with-cause.test.js +187 -0
  2622. package/node_modules/pino-std-serializers/test/err.test.js +200 -0
  2623. package/node_modules/pino-std-serializers/test/req.test.js +477 -0
  2624. package/node_modules/pino-std-serializers/test/res.test.js +120 -0
  2625. package/node_modules/pino-std-serializers/test/types/index.test-d.ts +71 -0
  2626. package/node_modules/pino-std-serializers/tsconfig.json +13 -0
  2627. package/node_modules/process-warning/.gitattributes +2 -0
  2628. package/node_modules/process-warning/.github/dependabot.yml +13 -0
  2629. package/node_modules/process-warning/.github/workflows/ci.yml +22 -0
  2630. package/node_modules/process-warning/LICENSE +21 -0
  2631. package/node_modules/process-warning/README.md +118 -0
  2632. package/node_modules/process-warning/benchmarks/warn.js +25 -0
  2633. package/node_modules/process-warning/eslint.config.js +6 -0
  2634. package/node_modules/process-warning/examples/example.js +11 -0
  2635. package/node_modules/process-warning/index.js +124 -0
  2636. package/node_modules/process-warning/package.json +73 -0
  2637. package/node_modules/process-warning/test/emit-interpolated-string.test.js +34 -0
  2638. package/node_modules/process-warning/test/emit-once-only.test.js +33 -0
  2639. package/node_modules/process-warning/test/emit-reset.test.js +40 -0
  2640. package/node_modules/process-warning/test/emit-set.test.js +35 -0
  2641. package/node_modules/process-warning/test/emit-unlimited.test.js +42 -0
  2642. package/node_modules/process-warning/test/index.test.js +99 -0
  2643. package/node_modules/process-warning/test/issue-88.test.js +38 -0
  2644. package/node_modules/process-warning/test/jest.test.js +24 -0
  2645. package/node_modules/process-warning/test/no-warnings.test.js +80 -0
  2646. package/node_modules/process-warning/test/promise.js +10 -0
  2647. package/node_modules/process-warning/types/index.d.ts +37 -0
  2648. package/node_modules/process-warning/types/index.test-d.ts +36 -0
  2649. package/node_modules/quick-format-unescaped/.github/workflows/ci.yml +21 -0
  2650. package/node_modules/quick-format-unescaped/LICENSE +21 -0
  2651. package/node_modules/quick-format-unescaped/benchmark.js +24 -0
  2652. package/node_modules/quick-format-unescaped/index.js +109 -0
  2653. package/node_modules/quick-format-unescaped/package.json +29 -0
  2654. package/node_modules/quick-format-unescaped/readme.md +66 -0
  2655. package/node_modules/quick-format-unescaped/test/index.js +136 -0
  2656. package/node_modules/real-require/LICENSE.md +21 -0
  2657. package/node_modules/real-require/README.md +51 -0
  2658. package/node_modules/real-require/package.json +49 -0
  2659. package/node_modules/real-require/src/index.js +14 -0
  2660. package/node_modules/require-from-string/index.js +34 -0
  2661. package/node_modules/require-from-string/license +21 -0
  2662. package/node_modules/require-from-string/package.json +28 -0
  2663. package/node_modules/require-from-string/readme.md +56 -0
  2664. package/node_modules/ret/LICENSE +21 -0
  2665. package/node_modules/ret/README.md +539 -0
  2666. package/node_modules/ret/dist/index.d.ts +7 -0
  2667. package/node_modules/ret/dist/index.js +26 -0
  2668. package/node_modules/ret/dist/index.js.map +1 -0
  2669. package/node_modules/ret/dist/reconstruct.d.ts +2 -0
  2670. package/node_modules/ret/dist/reconstruct.js +77 -0
  2671. package/node_modules/ret/dist/reconstruct.js.map +1 -0
  2672. package/node_modules/ret/dist/sets-lookup.d.ts +5 -0
  2673. package/node_modules/ret/dist/sets-lookup.js +51 -0
  2674. package/node_modules/ret/dist/sets-lookup.js.map +1 -0
  2675. package/node_modules/ret/dist/sets.d.ts +9 -0
  2676. package/node_modules/ret/dist/sets.js +43 -0
  2677. package/node_modules/ret/dist/sets.js.map +1 -0
  2678. package/node_modules/ret/dist/tokenizer.d.ts +8 -0
  2679. package/node_modules/ret/dist/tokenizer.js +361 -0
  2680. package/node_modules/ret/dist/tokenizer.js.map +1 -0
  2681. package/node_modules/ret/dist/types/index.d.ts +3 -0
  2682. package/node_modules/ret/dist/types/index.js +16 -0
  2683. package/node_modules/ret/dist/types/index.js.map +1 -0
  2684. package/node_modules/ret/dist/types/set-lookup.d.ts +8 -0
  2685. package/node_modules/ret/dist/types/set-lookup.js +3 -0
  2686. package/node_modules/ret/dist/types/set-lookup.js.map +1 -0
  2687. package/node_modules/ret/dist/types/tokens.d.ts +41 -0
  2688. package/node_modules/ret/dist/types/tokens.js +3 -0
  2689. package/node_modules/ret/dist/types/tokens.js.map +1 -0
  2690. package/node_modules/ret/dist/types/types.d.ts +10 -0
  2691. package/node_modules/ret/dist/types/types.js +15 -0
  2692. package/node_modules/ret/dist/types/types.js.map +1 -0
  2693. package/node_modules/ret/dist/util.d.ts +18 -0
  2694. package/node_modules/ret/dist/util.js +82 -0
  2695. package/node_modules/ret/dist/util.js.map +1 -0
  2696. package/node_modules/ret/dist/write-set-tokens.d.ts +14 -0
  2697. package/node_modules/ret/dist/write-set-tokens.js +108 -0
  2698. package/node_modules/ret/dist/write-set-tokens.js.map +1 -0
  2699. package/node_modules/ret/package.json +42 -0
  2700. package/node_modules/reusify/.github/dependabot.yml +7 -0
  2701. package/node_modules/reusify/.github/workflows/ci.yml +96 -0
  2702. package/node_modules/reusify/LICENSE +22 -0
  2703. package/node_modules/reusify/README.md +139 -0
  2704. package/node_modules/reusify/SECURITY.md +15 -0
  2705. package/node_modules/reusify/benchmarks/createNoCodeFunction.js +30 -0
  2706. package/node_modules/reusify/benchmarks/fib.js +13 -0
  2707. package/node_modules/reusify/benchmarks/reuseNoCodeFunction.js +38 -0
  2708. package/node_modules/reusify/eslint.config.js +14 -0
  2709. package/node_modules/reusify/package.json +50 -0
  2710. package/node_modules/reusify/reusify.d.ts +14 -0
  2711. package/node_modules/reusify/reusify.js +33 -0
  2712. package/node_modules/reusify/test.js +66 -0
  2713. package/node_modules/reusify/tsconfig.json +11 -0
  2714. package/node_modules/rfdc/.github/workflows/ci.yml +21 -0
  2715. package/node_modules/rfdc/LICENSE +15 -0
  2716. package/node_modules/rfdc/default.js +3 -0
  2717. package/node_modules/rfdc/index.d.ts +13 -0
  2718. package/node_modules/rfdc/index.js +198 -0
  2719. package/node_modules/rfdc/index.test-d.ts +13 -0
  2720. package/node_modules/rfdc/package.json +73 -0
  2721. package/node_modules/rfdc/readme.md +181 -0
  2722. package/node_modules/rfdc/test/index.js +306 -0
  2723. package/node_modules/safe-regex2/.gitattributes +2 -0
  2724. package/node_modules/safe-regex2/.github/dependabot.yml +13 -0
  2725. package/node_modules/safe-regex2/.github/workflows/ci.yml +33 -0
  2726. package/node_modules/safe-regex2/.github/workflows/lock-threads.yml +19 -0
  2727. package/node_modules/safe-regex2/LICENSE +21 -0
  2728. package/node_modules/safe-regex2/README.md +68 -0
  2729. package/node_modules/safe-regex2/bin/safe-regex2.js +58 -0
  2730. package/node_modules/safe-regex2/eslint.config.js +6 -0
  2731. package/node_modules/safe-regex2/example/safe.js +5 -0
  2732. package/node_modules/safe-regex2/index.js +76 -0
  2733. package/node_modules/safe-regex2/package.json +78 -0
  2734. package/node_modules/safe-regex2/test/regex.test.js +58 -0
  2735. package/node_modules/safe-regex2/types/index.d.ts +9 -0
  2736. package/node_modules/safe-regex2/types/index.test-d.ts +12 -0
  2737. package/node_modules/safe-stable-stringify/LICENSE +21 -0
  2738. package/node_modules/safe-stable-stringify/esm/package.json +4 -0
  2739. package/node_modules/safe-stable-stringify/esm/wrapper.d.ts +4 -0
  2740. package/node_modules/safe-stable-stringify/esm/wrapper.js +6 -0
  2741. package/node_modules/safe-stable-stringify/index.d.ts +22 -0
  2742. package/node_modules/safe-stable-stringify/index.js +625 -0
  2743. package/node_modules/safe-stable-stringify/package.json +65 -0
  2744. package/node_modules/safe-stable-stringify/readme.md +179 -0
  2745. package/node_modules/secure-json-parse/.airtap.yml +7 -0
  2746. package/node_modules/secure-json-parse/.gitattributes +2 -0
  2747. package/node_modules/secure-json-parse/.github/dependabot.yml +13 -0
  2748. package/node_modules/secure-json-parse/.github/stale.yml +21 -0
  2749. package/node_modules/secure-json-parse/.github/workflows/ci.yml +149 -0
  2750. package/node_modules/secure-json-parse/LICENSE +19 -0
  2751. package/node_modules/secure-json-parse/README.md +132 -0
  2752. package/node_modules/secure-json-parse/benchmarks/ignore.js +35 -0
  2753. package/node_modules/secure-json-parse/benchmarks/no__proto__.js +40 -0
  2754. package/node_modules/secure-json-parse/benchmarks/package.json +15 -0
  2755. package/node_modules/secure-json-parse/benchmarks/remove.js +39 -0
  2756. package/node_modules/secure-json-parse/benchmarks/throw.js +49 -0
  2757. package/node_modules/secure-json-parse/benchmarks/valid.js +49 -0
  2758. package/node_modules/secure-json-parse/eslint.config.js +6 -0
  2759. package/node_modules/secure-json-parse/index.js +161 -0
  2760. package/node_modules/secure-json-parse/package.json +74 -0
  2761. package/node_modules/secure-json-parse/test/index.test.js +649 -0
  2762. package/node_modules/secure-json-parse/types/index.d.ts +60 -0
  2763. package/node_modules/secure-json-parse/types/index.test-d.ts +43 -0
  2764. package/node_modules/semver/LICENSE +15 -0
  2765. package/node_modules/semver/README.md +680 -0
  2766. package/node_modules/semver/bin/semver.js +195 -0
  2767. package/node_modules/semver/classes/comparator.js +143 -0
  2768. package/node_modules/semver/classes/index.js +7 -0
  2769. package/node_modules/semver/classes/range.js +573 -0
  2770. package/node_modules/semver/classes/semver.js +350 -0
  2771. package/node_modules/semver/functions/clean.js +8 -0
  2772. package/node_modules/semver/functions/cmp.js +54 -0
  2773. package/node_modules/semver/functions/coerce.js +62 -0
  2774. package/node_modules/semver/functions/compare-build.js +9 -0
  2775. package/node_modules/semver/functions/compare-loose.js +5 -0
  2776. package/node_modules/semver/functions/compare.js +7 -0
  2777. package/node_modules/semver/functions/diff.js +60 -0
  2778. package/node_modules/semver/functions/eq.js +5 -0
  2779. package/node_modules/semver/functions/gt.js +5 -0
  2780. package/node_modules/semver/functions/gte.js +5 -0
  2781. package/node_modules/semver/functions/inc.js +21 -0
  2782. package/node_modules/semver/functions/lt.js +5 -0
  2783. package/node_modules/semver/functions/lte.js +5 -0
  2784. package/node_modules/semver/functions/major.js +5 -0
  2785. package/node_modules/semver/functions/minor.js +5 -0
  2786. package/node_modules/semver/functions/neq.js +5 -0
  2787. package/node_modules/semver/functions/parse.js +18 -0
  2788. package/node_modules/semver/functions/patch.js +5 -0
  2789. package/node_modules/semver/functions/prerelease.js +8 -0
  2790. package/node_modules/semver/functions/rcompare.js +5 -0
  2791. package/node_modules/semver/functions/rsort.js +5 -0
  2792. package/node_modules/semver/functions/satisfies.js +12 -0
  2793. package/node_modules/semver/functions/sort.js +5 -0
  2794. package/node_modules/semver/functions/truncate.js +48 -0
  2795. package/node_modules/semver/functions/valid.js +8 -0
  2796. package/node_modules/semver/index.js +93 -0
  2797. package/node_modules/semver/internal/constants.js +37 -0
  2798. package/node_modules/semver/internal/debug.js +11 -0
  2799. package/node_modules/semver/internal/identifiers.js +29 -0
  2800. package/node_modules/semver/internal/lrucache.js +42 -0
  2801. package/node_modules/semver/internal/parse-options.js +17 -0
  2802. package/node_modules/semver/internal/re.js +223 -0
  2803. package/node_modules/semver/package.json +78 -0
  2804. package/node_modules/semver/preload.js +4 -0
  2805. package/node_modules/semver/range.bnf +17 -0
  2806. package/node_modules/semver/ranges/gtr.js +6 -0
  2807. package/node_modules/semver/ranges/intersects.js +9 -0
  2808. package/node_modules/semver/ranges/ltr.js +6 -0
  2809. package/node_modules/semver/ranges/max-satisfying.js +27 -0
  2810. package/node_modules/semver/ranges/min-satisfying.js +26 -0
  2811. package/node_modules/semver/ranges/min-version.js +63 -0
  2812. package/node_modules/semver/ranges/outside.js +82 -0
  2813. package/node_modules/semver/ranges/simplify.js +49 -0
  2814. package/node_modules/semver/ranges/subset.js +249 -0
  2815. package/node_modules/semver/ranges/to-comparators.js +10 -0
  2816. package/node_modules/semver/ranges/valid.js +13 -0
  2817. package/node_modules/set-cookie-parser/LICENSE +21 -0
  2818. package/node_modules/set-cookie-parser/README.md +202 -0
  2819. package/node_modules/set-cookie-parser/lib/set-cookie.js +242 -0
  2820. package/node_modules/set-cookie-parser/package.json +45 -0
  2821. package/node_modules/setprototypeof/LICENSE +13 -0
  2822. package/node_modules/setprototypeof/README.md +31 -0
  2823. package/node_modules/setprototypeof/index.d.ts +2 -0
  2824. package/node_modules/setprototypeof/index.js +17 -0
  2825. package/node_modules/setprototypeof/package.json +38 -0
  2826. package/node_modules/setprototypeof/test/index.js +24 -0
  2827. package/node_modules/sonic-boom/.eslintignore +2 -0
  2828. package/node_modules/sonic-boom/.taprc +3 -0
  2829. package/node_modules/sonic-boom/LICENSE +21 -0
  2830. package/node_modules/sonic-boom/README.md +153 -0
  2831. package/node_modules/sonic-boom/bench.js +98 -0
  2832. package/node_modules/sonic-boom/check.js +18 -0
  2833. package/node_modules/sonic-boom/example.js +8 -0
  2834. package/node_modules/sonic-boom/fixtures/firehose.js +22 -0
  2835. package/node_modules/sonic-boom/index.js +733 -0
  2836. package/node_modules/sonic-boom/package.json +52 -0
  2837. package/node_modules/sonic-boom/test/destroy.test.js +49 -0
  2838. package/node_modules/sonic-boom/test/end.test.js +98 -0
  2839. package/node_modules/sonic-boom/test/flush-sync.test.js +140 -0
  2840. package/node_modules/sonic-boom/test/flush.test.js +419 -0
  2841. package/node_modules/sonic-boom/test/fsync.test.js +63 -0
  2842. package/node_modules/sonic-boom/test/helper.js +42 -0
  2843. package/node_modules/sonic-boom/test/minlength.test.js +35 -0
  2844. package/node_modules/sonic-boom/test/mode.test.js +116 -0
  2845. package/node_modules/sonic-boom/test/periodicflush.test.js +61 -0
  2846. package/node_modules/sonic-boom/test/reopen.test.js +239 -0
  2847. package/node_modules/sonic-boom/test/retry.test.js +414 -0
  2848. package/node_modules/sonic-boom/test/sync.test.js +261 -0
  2849. package/node_modules/sonic-boom/test/write.test.js +515 -0
  2850. package/node_modules/sonic-boom/types/index.d.ts +63 -0
  2851. package/node_modules/sonic-boom/types/tests/test.ts +4 -0
  2852. package/node_modules/split2/LICENSE +13 -0
  2853. package/node_modules/split2/README.md +85 -0
  2854. package/node_modules/split2/bench.js +27 -0
  2855. package/node_modules/split2/index.js +141 -0
  2856. package/node_modules/split2/package.json +39 -0
  2857. package/node_modules/split2/test.js +409 -0
  2858. package/node_modules/statuses/HISTORY.md +87 -0
  2859. package/node_modules/statuses/LICENSE +23 -0
  2860. package/node_modules/statuses/README.md +139 -0
  2861. package/node_modules/statuses/codes.json +65 -0
  2862. package/node_modules/statuses/index.js +146 -0
  2863. package/node_modules/statuses/package.json +49 -0
  2864. package/node_modules/thread-stream/.claude/settings.local.json +15 -0
  2865. package/node_modules/thread-stream/.github/dependabot.yml +13 -0
  2866. package/node_modules/thread-stream/.github/workflows/ci.yml +74 -0
  2867. package/node_modules/thread-stream/LICENSE +21 -0
  2868. package/node_modules/thread-stream/README.md +138 -0
  2869. package/node_modules/thread-stream/bench.js +85 -0
  2870. package/node_modules/thread-stream/eslint.config.js +10 -0
  2871. package/node_modules/thread-stream/index.d.ts +99 -0
  2872. package/node_modules/thread-stream/index.js +645 -0
  2873. package/node_modules/thread-stream/lib/indexes.js +11 -0
  2874. package/node_modules/thread-stream/lib/wait.js +77 -0
  2875. package/node_modules/thread-stream/lib/worker.js +298 -0
  2876. package/node_modules/thread-stream/node_modules/real-require/LICENSE.md +21 -0
  2877. package/node_modules/thread-stream/node_modules/real-require/README.md +51 -0
  2878. package/node_modules/thread-stream/node_modules/real-require/package.json +38 -0
  2879. package/node_modules/thread-stream/node_modules/real-require/src/index.js +14 -0
  2880. package/node_modules/thread-stream/package.json +50 -0
  2881. package/node_modules/thread-stream/test/base.test.js +259 -0
  2882. package/node_modules/thread-stream/test/bench.test.js +38 -0
  2883. package/node_modules/thread-stream/test/bundlers.test.js +59 -0
  2884. package/node_modules/thread-stream/test/close-on-gc.js +37 -0
  2885. package/node_modules/thread-stream/test/commonjs-fallback.test.js +75 -0
  2886. package/node_modules/thread-stream/test/context.test.js +21 -0
  2887. package/node_modules/thread-stream/test/create-and-exit.js +16 -0
  2888. package/node_modules/thread-stream/test/custom-worker.js +9 -0
  2889. package/node_modules/thread-stream/test/dir with spaces/test-package.zip +0 -0
  2890. package/node_modules/thread-stream/test/emit-event.js +22 -0
  2891. package/node_modules/thread-stream/test/end.test.js +56 -0
  2892. package/node_modules/thread-stream/test/error.js +14 -0
  2893. package/node_modules/thread-stream/test/esm.test.mjs +46 -0
  2894. package/node_modules/thread-stream/test/event.test.js +24 -0
  2895. package/node_modules/thread-stream/test/exit.js +14 -0
  2896. package/node_modules/thread-stream/test/flush-worker.js +68 -0
  2897. package/node_modules/thread-stream/test/flush.test.js +112 -0
  2898. package/node_modules/thread-stream/test/get-context.js +22 -0
  2899. package/node_modules/thread-stream/test/helper.d.ts +1 -0
  2900. package/node_modules/thread-stream/test/helper.js +26 -0
  2901. package/node_modules/thread-stream/test/indexes.test.js +11 -0
  2902. package/node_modules/thread-stream/test/message-without-code.js +19 -0
  2903. package/node_modules/thread-stream/test/multibyte-chars.test.mjs +75 -0
  2904. package/node_modules/thread-stream/test/multibyte-overrun.test.mjs +33 -0
  2905. package/node_modules/thread-stream/test/on-message.js +18 -0
  2906. package/node_modules/thread-stream/test/pkg/index.js +37 -0
  2907. package/node_modules/thread-stream/test/pkg/pkg.config.json +14 -0
  2908. package/node_modules/thread-stream/test/pkg/pkg.test.js +45 -0
  2909. package/node_modules/thread-stream/test/port.js +16 -0
  2910. package/node_modules/thread-stream/test/post-message.test.js +23 -0
  2911. package/node_modules/thread-stream/test/report-thread-name.js +16 -0
  2912. package/node_modules/thread-stream/test/string-limit-2.test.js +35 -0
  2913. package/node_modules/thread-stream/test/string-limit.test.js +37 -0
  2914. package/node_modules/thread-stream/test/syntax-error.mjs +2 -0
  2915. package/node_modules/thread-stream/test/thread-management.test.js +150 -0
  2916. package/node_modules/thread-stream/test/to-file-on-destroy.js +23 -0
  2917. package/node_modules/thread-stream/test/to-file-on-final.js +24 -0
  2918. package/node_modules/thread-stream/test/to-file.js +12 -0
  2919. package/node_modules/thread-stream/test/to-file.mjs +8 -0
  2920. package/node_modules/thread-stream/test/to-next.js +9 -0
  2921. package/node_modules/thread-stream/test/transpiled.test.js +29 -0
  2922. package/node_modules/thread-stream/test/ts/to-file.ts +10 -0
  2923. package/node_modules/thread-stream/test/ts/transpile.sh +19 -0
  2924. package/node_modules/thread-stream/test/ts-commonjs-default-export.zip +0 -0
  2925. package/node_modules/thread-stream/test/ts-native.test.mjs +35 -0
  2926. package/node_modules/thread-stream/test/ts-node-fallback.test.js +35 -0
  2927. package/node_modules/thread-stream/test/uncaughtException.js +21 -0
  2928. package/node_modules/thread-stream/test/unhandledRejection.js +21 -0
  2929. package/node_modules/thread-stream/test/watch-mode.test.js +30 -0
  2930. package/node_modules/thread-stream/test/worker-name.test.js +43 -0
  2931. package/node_modules/thread-stream/test/yarnrc.yml +7 -0
  2932. package/node_modules/thread-stream/tsconfig.json +8 -0
  2933. package/node_modules/toad-cache/LICENSE +21 -0
  2934. package/node_modules/toad-cache/README.md +265 -0
  2935. package/node_modules/toad-cache/dist/toad-cache.cjs +878 -0
  2936. package/node_modules/toad-cache/dist/toad-cache.mjs +852 -0
  2937. package/node_modules/toad-cache/package.json +84 -0
  2938. package/node_modules/toad-cache/toad-cache.d.cts +138 -0
  2939. package/node_modules/toad-cache/toad-cache.d.ts +128 -0
  2940. package/node_modules/toidentifier/HISTORY.md +9 -0
  2941. package/node_modules/toidentifier/LICENSE +21 -0
  2942. package/node_modules/toidentifier/README.md +61 -0
  2943. package/node_modules/toidentifier/index.js +32 -0
  2944. package/node_modules/toidentifier/package.json +38 -0
  2945. package/package.json +43 -20
  2946. package/scripts/build-local.sh +10 -11
  2947. package/scripts/check-app-path-boundaries.mjs +121 -0
  2948. package/scripts/check-app-spec.mjs +127 -25
  2949. package/scripts/check-colima-launchd.mjs +26 -22
  2950. package/scripts/check-integration-isolation.ts +541 -0
  2951. package/scripts/check-new-file-tests.mjs +16 -47
  2952. package/scripts/check-open-core-boundaries.mjs +334 -0
  2953. package/scripts/check-test-layering.sh +86 -0
  2954. package/scripts/fixtures/instances/hermes-sample/instance.json +3 -2
  2955. package/scripts/fixtures/instances/legacy-openclaw-sample/instance.json +1 -1
  2956. package/scripts/local-web-upgrade-test.README +147 -0
  2957. package/scripts/local-web-upgrade-test.example.env +54 -0
  2958. package/scripts/local-web-upgrade-test.sh +894 -0
  2959. package/scripts/pack-gui-and-send-pi.sh +41 -0
  2960. package/scripts/pack-with-gui.mjs +391 -0
  2961. package/scripts/perf/instances.js +1 -1
  2962. package/scripts/prune-open-core-dist.mjs +91 -0
  2963. package/scripts/run.sh +24 -25
  2964. package/scripts/setup-pi.sh +2 -2
  2965. package/scripts/smoke/hermes-bootstrap.sh +7 -7
  2966. package/scripts/smoke-backend.mjs +33 -1
  2967. package/templates/hermes-entrypoint.sh +19 -29
  2968. package/apps/openwebui-container.yaml +0 -97
  2969. package/apps/playwright-container.yaml +0 -126
  2970. package/dist/cli/panel.d.ts +0 -27
  2971. package/dist/cli/panel.js +0 -805
  2972. package/dist/cli/panel.js.map +0 -1
  2973. package/dist/crypto-shim.d.ts +0 -1
  2974. package/dist/crypto-shim.js +0 -2
  2975. package/dist/crypto-shim.js.map +0 -1
  2976. package/dist/routes/agent-apps.d.ts +0 -15
  2977. package/dist/routes/agent-apps.js +0 -78
  2978. package/dist/routes/agent-apps.js.map +0 -1
  2979. package/dist/routes/internal.d.ts +0 -2
  2980. package/dist/routes/internal.js +0 -59
  2981. package/dist/routes/internal.js.map +0 -1
  2982. package/dist/routes/runtime.d.ts +0 -15
  2983. package/dist/routes/runtime.js +0 -69
  2984. package/dist/routes/runtime.js.map +0 -1
  2985. package/dist/services/agent-apps/catalog.d.ts +0 -33
  2986. package/dist/services/agent-apps/catalog.js +0 -88
  2987. package/dist/services/agent-apps/catalog.js.map +0 -1
  2988. package/dist/services/agent-apps/index.d.ts +0 -36
  2989. package/dist/services/agent-apps/index.js +0 -171
  2990. package/dist/services/agent-apps/index.js.map +0 -1
  2991. package/dist/services/agent-apps/installers/adapter-probes.d.ts +0 -49
  2992. package/dist/services/agent-apps/installers/adapter-probes.js +0 -223
  2993. package/dist/services/agent-apps/installers/adapter-probes.js.map +0 -1
  2994. package/dist/services/agent-apps/installers/adapter.d.ts +0 -30
  2995. package/dist/services/agent-apps/installers/adapter.js +0 -171
  2996. package/dist/services/agent-apps/installers/adapter.js.map +0 -1
  2997. package/dist/services/agent-apps/installers/registry-probe.js.map +0 -1
  2998. package/dist/services/agent-apps/installers/shell-script.d.ts +0 -47
  2999. package/dist/services/agent-apps/installers/shell-script.js +0 -488
  3000. package/dist/services/agent-apps/installers/shell-script.js.map +0 -1
  3001. package/dist/services/agent-apps/types.d.ts +0 -128
  3002. package/dist/services/agent-apps/types.js +0 -17
  3003. package/dist/services/agent-apps/types.js.map +0 -1
  3004. package/dist/services/app/app-compiler.js +0 -172
  3005. package/dist/services/app/app-compiler.js.map +0 -1
  3006. package/dist/services/app/app-manager.d.ts +0 -174
  3007. package/dist/services/app/app-manager.js +0 -2741
  3008. package/dist/services/app/app-manager.js.map +0 -1
  3009. package/dist/services/app/custom-manager.d.ts +0 -27
  3010. package/dist/services/app/custom-manager.js +0 -285
  3011. package/dist/services/app/custom-manager.js.map +0 -1
  3012. package/dist/services/app/hermes-agent-manager.d.ts +0 -20
  3013. package/dist/services/app/hermes-agent-manager.js +0 -292
  3014. package/dist/services/app/hermes-agent-manager.js.map +0 -1
  3015. package/dist/services/app/id-normalizer.d.ts +0 -27
  3016. package/dist/services/app/id-normalizer.js +0 -77
  3017. package/dist/services/app/id-normalizer.js.map +0 -1
  3018. package/dist/services/app/ollama-manager.d.ts +0 -18
  3019. package/dist/services/app/ollama-manager.js +0 -207
  3020. package/dist/services/app/ollama-manager.js.map +0 -1
  3021. package/dist/services/app/openclaw-manager.d.ts +0 -63
  3022. package/dist/services/app/openclaw-manager.js +0 -1210
  3023. package/dist/services/app/openclaw-manager.js.map +0 -1
  3024. package/dist/services/app/paths.d.ts +0 -47
  3025. package/dist/services/app/paths.js +0 -68
  3026. package/dist/services/app/paths.js.map +0 -1
  3027. package/dist/services/app/platform-transform.d.ts +0 -32
  3028. package/dist/services/app/platform-transform.js +0 -65
  3029. package/dist/services/app/platform-transform.js.map +0 -1
  3030. package/dist/services/app/provide-resolver.d.ts +0 -29
  3031. package/dist/services/app/provide-resolver.js +0 -112
  3032. package/dist/services/app/provide-resolver.js.map +0 -1
  3033. package/dist/services/app/registry.d.ts +0 -17
  3034. package/dist/services/app/registry.js +0 -31
  3035. package/dist/services/app/registry.js.map +0 -1
  3036. package/dist/services/app/remote-spec.d.ts +0 -14
  3037. package/dist/services/app/remote-spec.js +0 -58
  3038. package/dist/services/app/remote-spec.js.map +0 -1
  3039. package/dist/services/app/terminal-session-manager.js +0 -157
  3040. package/dist/services/app/terminal-session-manager.js.map +0 -1
  3041. package/dist/services/app/types.d.ts +0 -72
  3042. package/dist/services/app/types.js +0 -16
  3043. package/dist/services/app/types.js.map +0 -1
  3044. package/dist/services/app-passwords.js +0 -173
  3045. package/dist/services/app-passwords.js.map +0 -1
  3046. package/dist/services/backup-manager.d.ts +0 -264
  3047. package/dist/services/backup-manager.js +0 -2264
  3048. package/dist/services/backup-manager.js.map +0 -1
  3049. package/dist/services/backup-verify.js +0 -240
  3050. package/dist/services/backup-verify.js.map +0 -1
  3051. package/dist/services/capability-endpoint-validator.d.ts +0 -41
  3052. package/dist/services/capability-endpoint-validator.js +0 -123
  3053. package/dist/services/capability-endpoint-validator.js.map +0 -1
  3054. package/dist/services/capability-health.d.ts +0 -16
  3055. package/dist/services/capability-health.js +0 -121
  3056. package/dist/services/capability-health.js.map +0 -1
  3057. package/dist/services/capability-registry.d.ts +0 -106
  3058. package/dist/services/capability-registry.js +0 -313
  3059. package/dist/services/capability-registry.js.map +0 -1
  3060. package/dist/services/connection-apply.d.ts +0 -91
  3061. package/dist/services/connection-apply.js +0 -475
  3062. package/dist/services/connection-apply.js.map +0 -1
  3063. package/dist/services/connection-resolver.d.ts +0 -65
  3064. package/dist/services/connection-resolver.js +0 -281
  3065. package/dist/services/connection-resolver.js.map +0 -1
  3066. package/dist/services/connection-transactor.d.ts +0 -39
  3067. package/dist/services/connection-transactor.js +0 -351
  3068. package/dist/services/connection-transactor.js.map +0 -1
  3069. package/dist/services/external-mounts.js +0 -187
  3070. package/dist/services/external-mounts.js.map +0 -1
  3071. package/dist/services/files-manager.d.ts +0 -252
  3072. package/dist/services/files-manager.js +0 -1075
  3073. package/dist/services/files-manager.js.map +0 -1
  3074. package/dist/services/files-mounts.d.ts +0 -42
  3075. package/dist/services/files-mounts.js +0 -207
  3076. package/dist/services/files-mounts.js.map +0 -1
  3077. package/dist/services/instance-manager.d.ts +0 -191
  3078. package/dist/services/instance-manager.js +0 -1296
  3079. package/dist/services/instance-manager.js.map +0 -1
  3080. package/dist/services/macos-launchd.d.ts +0 -89
  3081. package/dist/services/macos-launchd.js +0 -273
  3082. package/dist/services/macos-launchd.js.map +0 -1
  3083. package/dist/services/nomad-manager.d.ts +0 -290
  3084. package/dist/services/nomad-manager.js +0 -3953
  3085. package/dist/services/nomad-manager.js.map +0 -1
  3086. package/dist/services/organize/applier.js +0 -218
  3087. package/dist/services/organize/applier.js.map +0 -1
  3088. package/dist/services/organize/rules.js +0 -286
  3089. package/dist/services/organize/rules.js.map +0 -1
  3090. package/dist/services/organize/scanner.js +0 -366
  3091. package/dist/services/organize/scanner.js.map +0 -1
  3092. package/dist/services/organize/store.js +0 -82
  3093. package/dist/services/organize/store.js.map +0 -1
  3094. package/dist/services/panel-manager.d.ts +0 -50
  3095. package/dist/services/panel-manager.js +0 -472
  3096. package/dist/services/panel-manager.js.map +0 -1
  3097. package/dist/services/plugin-installer.js +0 -128
  3098. package/dist/services/plugin-installer.js.map +0 -1
  3099. package/dist/services/process-manager.d.ts +0 -25
  3100. package/dist/services/process-manager.js +0 -568
  3101. package/dist/services/process-manager.js.map +0 -1
  3102. package/dist/services/runtime/adapters/custom.d.ts +0 -20
  3103. package/dist/services/runtime/adapters/custom.js +0 -146
  3104. package/dist/services/runtime/adapters/custom.js.map +0 -1
  3105. package/dist/services/runtime/adapters/hermes.d.ts +0 -204
  3106. package/dist/services/runtime/adapters/hermes.js +0 -1631
  3107. package/dist/services/runtime/adapters/hermes.js.map +0 -1
  3108. package/dist/services/runtime/adapters/openclaw-mcporter.d.ts +0 -45
  3109. package/dist/services/runtime/adapters/openclaw-mcporter.js +0 -108
  3110. package/dist/services/runtime/adapters/openclaw-mcporter.js.map +0 -1
  3111. package/dist/services/runtime/adapters/openclaw-routes.d.ts +0 -23
  3112. package/dist/services/runtime/adapters/openclaw-routes.js +0 -1014
  3113. package/dist/services/runtime/adapters/openclaw-routes.js.map +0 -1
  3114. package/dist/services/runtime/adapters/openclaw.d.ts +0 -393
  3115. package/dist/services/runtime/adapters/openclaw.js +0 -3853
  3116. package/dist/services/runtime/adapters/openclaw.js.map +0 -1
  3117. package/dist/services/runtime/index.d.ts +0 -34
  3118. package/dist/services/runtime/index.js +0 -51
  3119. package/dist/services/runtime/index.js.map +0 -1
  3120. package/dist/services/runtime/mcp-shims/anythingllm-shim.d.ts +0 -46
  3121. package/dist/services/runtime/mcp-shims/anythingllm-shim.js +0 -281
  3122. package/dist/services/runtime/mcp-shims/anythingllm-shim.js.map +0 -1
  3123. package/dist/services/runtime/mcp-shims/drive-shim.d.ts +0 -54
  3124. package/dist/services/runtime/mcp-shims/drive-shim.js +0 -489
  3125. package/dist/services/runtime/mcp-shims/drive-shim.js.map +0 -1
  3126. package/dist/services/runtime/migrations.d.ts +0 -23
  3127. package/dist/services/runtime/migrations.js +0 -125
  3128. package/dist/services/runtime/migrations.js.map +0 -1
  3129. package/dist/services/runtime/registry.d.ts +0 -13
  3130. package/dist/services/runtime/registry.js +0 -32
  3131. package/dist/services/runtime/registry.js.map +0 -1
  3132. package/dist/services/setup-manager.d.ts +0 -136
  3133. package/dist/services/setup-manager.js +0 -2149
  3134. package/dist/services/setup-manager.js.map +0 -1
  3135. package/dist/services/suggestions.d.ts +0 -27
  3136. package/dist/services/suggestions.js +0 -133
  3137. package/dist/services/suggestions.js.map +0 -1
  3138. package/dist/services/system-monitor.js +0 -79
  3139. package/dist/services/system-monitor.js.map +0 -1
  3140. package/dist/services/task-registry.d.ts +0 -44
  3141. package/dist/services/task-registry.js +0 -76
  3142. package/dist/services/task-registry.js.map +0 -1
  3143. package/dist/services/types-shim.d.ts +0 -16
  3144. package/dist/services/types-shim.js +0 -2
  3145. package/dist/services/types-shim.js.map +0 -1
  3146. package/dist/services/update-manager.d.ts +0 -47
  3147. package/dist/services/update-manager.js +0 -323
  3148. package/dist/services/update-manager.js.map +0 -1
  3149. package/dist/services/webdav/server.d.ts +0 -24
  3150. package/dist/services/webdav/server.js +0 -420
  3151. package/dist/services/webdav/server.js.map +0 -1
  3152. package/dist/services/webdav/xml-builder.js.map +0 -1
  3153. package/dist/services/workspace-builder.d.ts +0 -29
  3154. package/dist/services/workspace-builder.js +0 -188
  3155. package/dist/services/workspace-builder.js.map +0 -1
  3156. package/public/assets/ApiKeyField-CvyAOcJS.js +0 -1
  3157. package/public/assets/Dashboard-AuJESBlJ.js +0 -1
  3158. package/public/assets/HermesChatPanel-CByPREwb.js +0 -1
  3159. package/public/assets/HermesConfigForm-DRda8FKX.js +0 -4
  3160. package/public/assets/InitPassword-ka4wNpM5.js +0 -1
  3161. package/public/assets/InstanceDetail-Cg1nS8HX.js +0 -92
  3162. package/public/assets/Login-aPajuQzf.js +0 -1
  3163. package/public/assets/NewInstance-Dd1ebNIx.js +0 -1
  3164. package/public/assets/ProviderRecommendations-DFmADQ7V.js +0 -1
  3165. package/public/assets/Settings-BYQnbLYL.js +0 -1
  3166. package/public/assets/Setup-D05lwDOV.js +0 -1
  3167. package/public/assets/WeixinLoginPanel-D89kdhP4.js +0 -9
  3168. package/public/assets/index-HSXCsceK.css +0 -1
  3169. package/public/assets/index-bnBu0nlQ.js +0 -19
  3170. package/public/assets/registry-C_qeFTkZ.js +0 -2
  3171. package/public/assets/usePolling-Bn93fe7M.js +0 -1
  3172. package/public/assets/vendor-i18n-flxcMVeP.js +0 -9
  3173. package/public/assets/vendor-react-ZC5T_huj.js +0 -59
  3174. package/public/index.html +0 -20
  3175. package/scripts/build-image.sh +0 -55
  3176. package/scripts/check-adapter-isolation.ts +0 -293
  3177. package/scripts/check-i18n.mjs +0 -154
  3178. /package/dist/services/{app → app-common}/app-compiler.d.ts +0 -0
  3179. /package/dist/services/{app → app-common}/terminal-session-manager.d.ts +0 -0
  3180. /package/dist/services/{backup-verify.d.ts → backup/backup-verify.d.ts} +0 -0
  3181. /package/dist/services/{external-mounts.d.ts → files/external-mounts.d.ts} +0 -0
  3182. /package/dist/services/{organize → files/organize}/applier.d.ts +0 -0
  3183. /package/dist/services/{organize → files/organize}/rules.d.ts +0 -0
  3184. /package/dist/services/{organize → files/organize}/scanner.d.ts +0 -0
  3185. /package/dist/services/{organize → files/organize}/store.d.ts +0 -0
  3186. /package/dist/services/{webdav → files/webdav}/xml-builder.d.ts +0 -0
  3187. /package/dist/services/{webdav → files/webdav}/xml-builder.js +0 -0
  3188. /package/dist/services/{app-passwords.d.ts → instances/passwords.d.ts} +0 -0
  3189. /package/dist/services/{agent-apps → integrations/installable}/installers/registry-probe.d.ts +0 -0
  3190. /package/dist/services/{agent-apps → integrations/installable}/installers/registry-probe.js +0 -0
  3191. /package/dist/services/{plugin-installer.d.ts → setup/plugin-installer.d.ts} +0 -0
  3192. /package/dist/services/{system-monitor.d.ts → system/system-monitor.d.ts} +0 -0
  3193. /package/{public → node_modules/jishushell-panel/output/public}/assets/logo-black-theme-DywLAtFy.png +0 -0
  3194. /package/{public → node_modules/jishushell-panel/output/public}/assets/logo-white-theme-DXffFAWw.png +0 -0
  3195. /package/{public → node_modules/jishushell-panel/output/public}/favicon.png +0 -0
  3196. /package/{public → node_modules/jishushell-panel/output/public}/logos/hermes.png +0 -0
  3197. /package/{public → node_modules/jishushell-panel/output/public}/logos/ollama.png +0 -0
  3198. /package/{public → node_modules/jishushell-panel/output/public}/logos/openclaw.svg +0 -0
@@ -0,0 +1,4402 @@
1
+ /**
2
+ * OpenClawIntegration — the framework face of OpenClaw business logic.
3
+ *
4
+ * Legacy AppIntegration implementation retained during migration toward the
5
+ * model described in docs/core-app-architecture.md. The
6
+ * short-term goal remains: OpenClaw-specific knowledge should leave generic
7
+ * framework code and live behind this integration boundary.
8
+ *
9
+ * Why not a huge rewrite in a single pass?
10
+ * A full physical migration of ~6500 lines of OpenClaw code out of
11
+ * `instance-manager.ts` / the Nomad driver / `setup-manager.ts` is a
12
+ * multi-PR undertaking. This file lands the **structural** decoupling
13
+ * (contract + dispatch) today, so:
14
+ *
15
+ * 1. Every framework call site now goes through `getIntegration(integrationKind).X()`
16
+ * with zero string-literal branching on "openclaw" / "hermes".
17
+ * 2. OpenClaw-specific imperative logic that was already contained (Nomad
18
+ * task build, on-disk patches, npm update seed, pairing CLI mapping)
19
+ * is physically moved into this file.
20
+ * 3. Larger pieces that are still entangled inside instance-manager.ts
21
+ * (`saveConfig` with channel-plugin auto-install, `createInstance`
22
+ * with `openclaw.json` seeding) are exposed through integration hooks
23
+ * that framework code calls, and the physical code move from
24
+ * instance-manager.ts into a sibling `openclaw-*.ts` file is a
25
+ * straightforward follow-up PR — the `check-integration-isolation.ts`
26
+ * script blocks new integration-specific code from sneaking back into the
27
+ * framework layer.
28
+ *
29
+ * This is legacy AppIntegration compatibility. New app lifecycle work should
30
+ * follow docs/core-app-architecture.md instead of extending this as the
31
+ * primary app model:
32
+ *
33
+ * 1. Create `src/services/integrations/foo/integration.ts` mirroring this file.
34
+ * 2. Add a side-effect registration import to `src/services/integrations/index.ts`.
35
+ * 3. Add one line to `frontend/src/runtimes/registry.ts`.
36
+ * 4. Done. No `instance-manager.ts` / runtime driver / routes edits.
37
+ */
38
+ import { execFile, execFileSync } from "child_process";
39
+ import { accessSync, chmodSync, chownSync, copyFileSync, cpSync, constants, existsSync, lstatSync, mkdirSync, readdirSync, readFileSync, realpathSync, renameSync, rmSync, statSync, symlinkSync, unlinkSync, writeFileSync, } from "fs";
40
+ import { createHash, randomBytes } from "crypto";
41
+ import { homedir, userInfo } from "os";
42
+ import { delimiter, dirname, join, resolve as pathResolve } from "path";
43
+ import { getNomadDriver, getOpenclawDockerImage, JISHUSHELL_HOME, getCoreLanHost, getCorePort, } from "../../../config.js";
44
+ import { ensureDirContainer, ensureDirHost, writeConfigFile } from "../../../utils/fs.js";
45
+ import { safeWriteJson } from "../../../utils/safe-json.js";
46
+ import { chownToServiceUser, getInstance, getRuntimeEnvFiles, listInstances, normalizePath, notifyConfigChange, resolveServiceUser, updateInstanceMeta, updateEnvFile, } from "../../instances/manager.js";
47
+ import { applyTemporaryBrowserAllowlistToConfigObject, browserlessEndpointAllowedHostname, DEFAULT_BROWSER_ALLOWED_HOSTNAMES, mergeBrowserAllowedHostnames, readTemporaryBrowserAllowedHostnames, stripTemporaryBrowserAllowlistFromConfigObject, } from "../../capabilities/browser-policy.js";
48
+ import { getInstanceDir as framework_instanceDir, instanceMetaPath } from "../../../config.js";
49
+ import { createTask, emitTask, spawnWithTask, getDirSizeMB, npmProgressParser, dockerBuildProgressParser, resolveDockerInvocation, } from "../../setup/setup-manager.js";
50
+ import { DEFAULT_OPENCLAW_DOCKER_IMAGE, setOpenclawDockerImage, OPENCLAW_MODULES, OPENCLAW_PKG_DIR, } from "../../../config.js";
51
+ import { fileURLToPath } from "node:url";
52
+ import { inspectDockerImage, toDockerInspectUserError } from "../../../utils/docker-inspect.js";
53
+ import { getDefaultLlmProvider, normalizeProviderApi } from "../../llm-proxy/providers.js";
54
+ import { bootstrapInstanceProxy, getInstanceConfig as getProxyInstanceConfig, } from "../../llm-proxy/instance-proxy.js";
55
+ import { renderStandaloneMcporterSource } from "./mcporter-lite.js";
56
+ import { resolveNomadJobId } from "../../runtime/job-id.js";
57
+ import { DEFINITION_FILENAME, MANIFEST_FILENAME, RESOLVED_SPEC_FILENAME, } from "../../app-common/paths.js";
58
+ import { registerIntegration } from "../registry.js";
59
+ import { isOwnedByInstance, writeOwnershipMarker } from "../../runtime/ownership-marker.js";
60
+ import { mcporterPath, mergeMcporterServers, removeMcporterServers } from "./mcporter.js";
61
+ // ── Constants physically migrated from the Nomad driver ───────────────
62
+ //
63
+ // These used to live as module-scope constants in the Nomad driver and were
64
+ // read by `buildTaskDocker` / `buildRuntime` helpers. They describe how
65
+ // OpenClaw expects to be launched — container image paths, default command,
66
+ // memory ceilings — and therefore belong to the OpenClaw integration, not the
67
+ // Nomad scheduler.
68
+ const DEFAULT_COMMAND = "/usr/bin/openclaw";
69
+ // Default invocation for a fresh OpenClaw container. `--port 18789` is the
70
+ // process's container-internal listener (= `containerPort`), NOT a host port.
71
+ // Host-side publishing is decided by Core's allocator and persisted into
72
+ // `runtime.ports[].hostPort`; the OpenClaw binary itself always speaks on
73
+ // 18789 inside the container regardless of how Core maps it on the outside.
74
+ const DEFAULT_ARGS = ["gateway", "run", "--port", "18789", "--allow-unconfigured"];
75
+ const DEFAULT_USER = userInfo().username;
76
+ const DEFAULT_CWD = homedir();
77
+ const DEFAULT_ENV = {
78
+ HOME: homedir(),
79
+ TMPDIR: "/tmp",
80
+ PATH: `${homedir()}/.local/bin:${homedir()}/.npm-global/bin:${homedir()}/bin:${homedir()}/.volta/bin:` +
81
+ `${homedir()}/.asdf/shims:${homedir()}/.bun/bin:${homedir()}/.nvm/current/bin:${homedir()}/.fnm/current/bin:` +
82
+ `${homedir()}/.local/share/pnpm:/usr/local/bin:/usr/bin:/bin`,
83
+ };
84
+ const DEFAULT_RESOURCES = { CPU: 500, MemoryMB: 512 };
85
+ // Path inside the openclaw-runtime Docker image where the baked-in openclaw
86
+ // npm package lives. Referenced by the entrypoint shim as the fallback and
87
+ // used by the control-UI "Update now" path through a pre-seeded symlink in
88
+ // $HOME/.npm-global (see ensureOpenclawUpdateSeed below).
89
+ const CONTAINER_IMAGE_PKG_ROOT = "/app/node_modules/openclaw";
90
+ const VALID_USER_RE = /^[a-z0-9._-]{1,32}$/;
91
+ const DOCKER_IMAGE_RE = /^[a-zA-Z0-9][a-zA-Z0-9\-_.:/@]*$/;
92
+ const MAX_DOCKER_IMAGE_NAME_LEN = 256;
93
+ export const OPENCLAW_DEFAULT_CONTAINER_PORT = 18789;
94
+ export const OPENCLAW_PREFERRED_HOST_PORT = OPENCLAW_DEFAULT_CONTAINER_PORT;
95
+ /**
96
+ * Resolve the container-internal listening port the OpenClaw process binds.
97
+ *
98
+ * Belongs to the runtime hot path (called from `OpenClawIntegration.buildRuntime`)
99
+ * and must therefore obey the canonical port model: the only allowed sources
100
+ * are `runtime.ports[].containerPort` (Core's persisted desired runtime) or
101
+ * the OpenClaw binary's documented default.
102
+ */
103
+ function resolveOpenclawContainerPort(rawRuntime) {
104
+ const ports = Array.isArray(rawRuntime?.ports) ? rawRuntime.ports : [];
105
+ for (const port of ports) {
106
+ if (port?.name === "gateway" && Number.isInteger(port?.containerPort) && port.containerPort > 0) {
107
+ return port.containerPort;
108
+ }
109
+ }
110
+ for (const port of ports) {
111
+ if (Number.isInteger(port?.containerPort) && port.containerPort > 0) {
112
+ return port.containerPort;
113
+ }
114
+ }
115
+ return OPENCLAW_DEFAULT_CONTAINER_PORT;
116
+ }
117
+ // ── Capability profile (moved from runtime/instance.ts) ──────────────
118
+ //
119
+ // Describes what the framework should expose for OpenClaw instances. The
120
+ // frontend uses this to decide which tabs render and how the Chat tab looks.
121
+ const DEFAULT_CAPABILITIES = {
122
+ ui: {
123
+ http: true,
124
+ websocket: true,
125
+ chatPanel: "iframe",
126
+ },
127
+ pairing: {
128
+ list: true,
129
+ approve: true,
130
+ revoke: false,
131
+ clearPending: false,
132
+ },
133
+ configEditor: "json",
134
+ configSchema: false,
135
+ customProvider: true,
136
+ pluginInstall: true,
137
+ skills: true,
138
+ mcp: true,
139
+ memory: true,
140
+ backupRestore: true,
141
+ usageStats: true,
142
+ restartlessReload: false,
143
+ messagingPlatforms: ["feishu", "openclaw-weixin"],
144
+ };
145
+ export const OPENCLAW_CONTROL_UI_PROXY_RE = /^\/api\/integrations\/openclaw\/instances\/([a-z0-9][a-z0-9-]{0,62})\/control-ui(?:\/(.*))?$/;
146
+ const OPENCLAW_CONTROL_UI_PUBLIC_PROXY = {
147
+ basePathPattern: OPENCLAW_CONTROL_UI_PROXY_RE,
148
+ authBypass: true,
149
+ websocket: true,
150
+ buildHeaders: ({ match }) => {
151
+ try {
152
+ const cfg = loadEffectiveConfig(match.instanceId);
153
+ const token = cfg?.gateway?.auth?.token;
154
+ if (typeof token === "string" && token.trim()) {
155
+ return { authorization: `Bearer ${token.trim()}` };
156
+ }
157
+ }
158
+ catch {
159
+ // Best effort: if config is unavailable, OpenClaw returns its normal auth error.
160
+ }
161
+ return {};
162
+ },
163
+ resolveTarget: async ({ match, query }) => {
164
+ const im = await lazyIm();
165
+ const port = im.getPrimaryHostPort(match.instanceId);
166
+ const host = await im.getPrimaryHostForInstance(match.instanceId);
167
+ const suffix = match.suffix.replace(/^\/+/, "");
168
+ return {
169
+ protocol: "http",
170
+ host,
171
+ port,
172
+ path: `/${suffix}${query}`,
173
+ };
174
+ },
175
+ };
176
+ export async function ensureOpenclawControlUiAllowedOrigin(instanceId, origin) {
177
+ const normalizedOrigin = origin.trim();
178
+ if (!normalizedOrigin)
179
+ return false;
180
+ const im = await lazyIm();
181
+ const config = im.getStoredConfig(instanceId);
182
+ if (!config)
183
+ return false;
184
+ const gateway = config.gateway ??= {};
185
+ const controlUi = gateway.controlUi ??= {};
186
+ const existing = Array.isArray(controlUi.allowedOrigins)
187
+ ? controlUi.allowedOrigins.map((value) => String(value))
188
+ : [];
189
+ const normalized = new Set(existing.map((value) => value.trim().toLowerCase()).filter(Boolean));
190
+ if (normalized.has("*") || normalized.has(normalizedOrigin.toLowerCase()))
191
+ return false;
192
+ controlUi.allowedOrigins = [...existing.filter((value) => value.trim()), normalizedOrigin];
193
+ await im.saveConfig(instanceId, config);
194
+ return true;
195
+ }
196
+ import { FILES_ROOT } from "../../../config.js";
197
+ function readFileMounts(runtime) {
198
+ const raw = runtime.fileMounts;
199
+ return Array.isArray(raw) ? raw : [];
200
+ }
201
+ /**
202
+ * Build the volume list for the docker driver:
203
+ * 1. The existing openclaw-home self-mount (HOME == container HOME)
204
+ * 2. The root FILES_ROOT bind when any mount has empty path
205
+ * ({"path":"","alias":"","mode":"rw"} — the default for new
206
+ * instances). Without this, in-container plugins (Feishu / WeChat
207
+ * send_file) try `fs.open("/home/.../files/...")` and hit ENOENT
208
+ * because the host path isn't bind-mounted. Verified on pi2
209
+ * 2026-05-11: claw1's drive_resolve_local_path returned a valid
210
+ * abs_path; feishu_im_user_message then ENOENT'd on it.
211
+ * 3. One additional bind per non-root FileMount, host==container so
212
+ * the workspace/{alias} symlink (placed by rebuildWorkspace)
213
+ * resolves identically inside the container.
214
+ *
215
+ * Mode "ro" is enforced by the docker bind option; raw_exec / process
216
+ * modes don't go through this path (the agent runs natively on the host
217
+ * and reads files directly).
218
+ */
219
+ function buildVolumes(openclawHome, runtime) {
220
+ const list = [`${openclawHome}:${openclawHome}:rw`];
221
+ for (const abs of listMountedHostPaths(runtime)) {
222
+ const mode = readFileMounts(runtime).find((m) => !m.path || join(FILES_ROOT, m.path) === abs)?.mode === "ro" ? "ro" : "rw";
223
+ list.push(`${abs}:${abs}:${mode}`);
224
+ }
225
+ return list;
226
+ }
227
+ function listMountedHostPaths(runtime) {
228
+ let rootBound = false;
229
+ const list = [];
230
+ for (const m of readFileMounts(runtime)) {
231
+ if (!m)
232
+ continue;
233
+ if (!m.path) {
234
+ if (rootBound)
235
+ continue;
236
+ list.push(FILES_ROOT);
237
+ rootBound = true;
238
+ continue;
239
+ }
240
+ if (rootBound)
241
+ continue; // root already covers every subtree
242
+ list.push(join(FILES_ROOT, m.path));
243
+ }
244
+ return list;
245
+ }
246
+ function listJishukbUploadRoots(runtime, openclawHome) {
247
+ return Array.from(new Set([
248
+ ...listMountedHostPaths(runtime),
249
+ join(openclawHome, ".openclaw", "media", "inbound"),
250
+ ]));
251
+ }
252
+ // ── Path helpers (physically migrated from instance-manager.ts) ───────
253
+ const INSTANCE_OPENCLAW_HOME_DIRNAME = "openclaw-home";
254
+ const INSTANCE_MODEL_ENV_FILENAME = "model.env";
255
+ const OPENCLAW_STATE_DIRNAME = ".openclaw";
256
+ const OPENCLAW_CONFIG_FILENAME = "openclaw.json";
257
+ function defaultOpenclawHome(instanceId) {
258
+ return join(framework_instanceDir(instanceId), INSTANCE_OPENCLAW_HOME_DIRNAME);
259
+ }
260
+ function openclawHomeFromMetadata(meta, instanceId) {
261
+ const integrationHome = meta?.paths?.integrationHome;
262
+ return typeof integrationHome === "string" && integrationHome.trim()
263
+ ? integrationHome
264
+ : defaultOpenclawHome(instanceId);
265
+ }
266
+ function defaultOpenclawModelEnvFile(instanceId) {
267
+ return join(framework_instanceDir(instanceId), INSTANCE_MODEL_ENV_FILENAME);
268
+ }
269
+ function isPrecreatedManagedAppDir(dir) {
270
+ return existsSync(join(dir, DEFINITION_FILENAME))
271
+ && existsSync(join(dir, RESOLVED_SPEC_FILENAME))
272
+ && existsSync(join(dir, MANIFEST_FILENAME));
273
+ }
274
+ function openclawConfigPath(instanceId, home) {
275
+ const h = home ?? defaultOpenclawHome(instanceId);
276
+ return join(h, OPENCLAW_STATE_DIRNAME, OPENCLAW_CONFIG_FILENAME);
277
+ }
278
+ function legacyOpenclawConfigPath(instanceId, home) {
279
+ const h = home ?? defaultOpenclawHome(instanceId);
280
+ return join(h, OPENCLAW_CONFIG_FILENAME);
281
+ }
282
+ /**
283
+ * Resolve the most relevant openclaw.json path for a SOURCE instance used
284
+ * by the clone_from branch. Prefers the .openclaw/ state dir, falls back
285
+ * to the legacy flat path only as a clone/import boundary reader so clones of
286
+ * old instances still work. Normal runtime config reads call
287
+ * `migrateLegacyOuterConfigOnce()` instead of treating this legacy path as a
288
+ * second source of truth.
289
+ */
290
+ function resolveExistingConfigPath(instanceId) {
291
+ const runtimePath = openclawConfigPath(instanceId);
292
+ if (existsSync(runtimePath))
293
+ return runtimePath;
294
+ const legacy = legacyOpenclawConfigPath(instanceId);
295
+ if (existsSync(legacy))
296
+ return legacy;
297
+ return runtimePath;
298
+ }
299
+ function migrateLegacyOuterConfigOnce(instanceId) {
300
+ const runtimePath = openclawConfigPath(instanceId);
301
+ const legacyPath = legacyOpenclawConfigPath(instanceId);
302
+ if (!existsSync(legacyPath))
303
+ return;
304
+ // Step 6 one-shot fallback reader: historical OpenClaw installs stored
305
+ // config at `$OPENCLAW_HOME/openclaw.json`. Normal runtime must now read and
306
+ // write only `$OPENCLAW_HOME/.openclaw/openclaw.json`; this boundary converts
307
+ // old disk state into the canonical path and removes the old mirror so it
308
+ // cannot resurrect fields on a later save.
309
+ if (!existsSync(runtimePath)) {
310
+ ensureDirContainer(dirname(runtimePath));
311
+ copyFileSync(legacyPath, runtimePath);
312
+ chownToServiceUser(runtimePath);
313
+ }
314
+ rmSync(legacyPath, { force: true });
315
+ }
316
+ const OPENCLAW_BROWSER_SESSION_INDEX_RELATIVE_PATH = [
317
+ OPENCLAW_STATE_DIRNAME,
318
+ "agents",
319
+ "main",
320
+ "sessions",
321
+ "sessions.json",
322
+ ];
323
+ const OPENCLAW_BROWSER_SESSION_SUMMARY_MAX_FILE_SIZE = 10 * 1024 * 1024;
324
+ function isBrowserSummaryRecord(value) {
325
+ return !!value && typeof value === "object" && !Array.isArray(value);
326
+ }
327
+ function normalizeBrowserSummaryText(value) {
328
+ return typeof value === "string" && value.trim() ? value.trim() : null;
329
+ }
330
+ function normalizeBrowserSummaryTimestamp(value) {
331
+ const text = normalizeBrowserSummaryText(value);
332
+ if (!text)
333
+ return null;
334
+ const parsed = new Date(text);
335
+ return Number.isNaN(parsed.getTime()) ? null : parsed.toISOString();
336
+ }
337
+ function unavailableBrowserConsumerActivitySummary() {
338
+ return {
339
+ recentSession: {
340
+ state: "unavailable",
341
+ sessionKey: null,
342
+ lastMessageAt: null,
343
+ origin: null,
344
+ channel: null,
345
+ },
346
+ lastBrowserAttempt: {
347
+ state: "unavailable",
348
+ action: null,
349
+ profile: null,
350
+ url: null,
351
+ error: null,
352
+ timestamp: null,
353
+ },
354
+ };
355
+ }
356
+ function noSessionsBrowserConsumerActivitySummary() {
357
+ return {
358
+ recentSession: {
359
+ state: "no_sessions",
360
+ sessionKey: null,
361
+ lastMessageAt: null,
362
+ origin: null,
363
+ channel: null,
364
+ },
365
+ lastBrowserAttempt: {
366
+ state: "none",
367
+ action: null,
368
+ profile: null,
369
+ url: null,
370
+ error: null,
371
+ timestamp: null,
372
+ },
373
+ };
374
+ }
375
+ function isInsideResolvedHome(resolvedHome, resolvedPath) {
376
+ return resolvedPath === resolvedHome || resolvedPath.startsWith(`${resolvedHome}/`);
377
+ }
378
+ function resolveSafeOpenclawBrowserSummaryFile(resolvedHome, candidatePath) {
379
+ if (!candidatePath || !existsSync(candidatePath))
380
+ return null;
381
+ try {
382
+ const resolvedPath = realpathSync(candidatePath);
383
+ if (!isInsideResolvedHome(resolvedHome, resolvedPath))
384
+ return null;
385
+ const stats = statSync(resolvedPath);
386
+ if (!stats.isFile() || stats.size > OPENCLAW_BROWSER_SESSION_SUMMARY_MAX_FILE_SIZE)
387
+ return null;
388
+ return resolvedPath;
389
+ }
390
+ catch {
391
+ return null;
392
+ }
393
+ }
394
+ function readOpenclawBrowserSessionIndex(openclawHome) {
395
+ let resolvedHome;
396
+ try {
397
+ resolvedHome = realpathSync(openclawHome);
398
+ }
399
+ catch {
400
+ return "unavailable";
401
+ }
402
+ const sessionsIndex = join(openclawHome, ...OPENCLAW_BROWSER_SESSION_INDEX_RELATIVE_PATH);
403
+ if (!existsSync(sessionsIndex))
404
+ return "no_sessions";
405
+ const resolvedIndex = resolveSafeOpenclawBrowserSummaryFile(resolvedHome, sessionsIndex);
406
+ if (!resolvedIndex)
407
+ return "unavailable";
408
+ let raw;
409
+ try {
410
+ raw = JSON.parse(readFileSync(resolvedIndex, "utf-8"));
411
+ }
412
+ catch {
413
+ return "unavailable";
414
+ }
415
+ if (!isBrowserSummaryRecord(raw))
416
+ return "unavailable";
417
+ return {
418
+ resolvedHome,
419
+ sessions: Object.entries(raw).map(([sessionKey, sessionMeta]) => ({
420
+ sessionKey,
421
+ sessionFile: normalizeBrowserSummaryText(sessionMeta?.sessionFile),
422
+ origin: normalizeBrowserSummaryText(sessionMeta?.origin?.label),
423
+ channel: normalizeBrowserSummaryText(sessionMeta?.origin?.provider),
424
+ })),
425
+ };
426
+ }
427
+ function browserAttemptIsNewer(candidate, current) {
428
+ const candidateTs = candidate.timestamp ? Date.parse(candidate.timestamp) : Number.NaN;
429
+ const currentTs = current.timestamp ? Date.parse(current.timestamp) : Number.NaN;
430
+ const safeCandidateTs = Number.isFinite(candidateTs) ? candidateTs : Number.NEGATIVE_INFINITY;
431
+ const safeCurrentTs = Number.isFinite(currentTs) ? currentTs : Number.NEGATIVE_INFINITY;
432
+ if (safeCandidateTs !== safeCurrentTs)
433
+ return safeCandidateTs > safeCurrentTs;
434
+ if (current.state === "none" && candidate.state !== "none")
435
+ return true;
436
+ return false;
437
+ }
438
+ function summarizeOpenclawBrowserAttemptFromContent(content) {
439
+ const toolCalls = new Map();
440
+ let lastStatusProfile = null;
441
+ let lastAttempt = {
442
+ state: "none",
443
+ action: null,
444
+ profile: null,
445
+ url: null,
446
+ error: null,
447
+ timestamp: null,
448
+ };
449
+ for (const line of content.split("\n")) {
450
+ if (!line.trim())
451
+ continue;
452
+ let entry;
453
+ try {
454
+ entry = JSON.parse(line);
455
+ }
456
+ catch {
457
+ continue;
458
+ }
459
+ if (!isBrowserSummaryRecord(entry) || entry.type !== "message")
460
+ continue;
461
+ const message = isBrowserSummaryRecord(entry.message) ? entry.message : {};
462
+ const timestamp = normalizeBrowserSummaryTimestamp(entry.timestamp);
463
+ const contentBlocks = Array.isArray(message.content) ? message.content : [];
464
+ for (const block of contentBlocks) {
465
+ if (!isBrowserSummaryRecord(block) || block.type !== "toolCall" || block.name !== "browser")
466
+ continue;
467
+ const args = isBrowserSummaryRecord(block.arguments) ? block.arguments : {};
468
+ toolCalls.set(String(block.id ?? ""), {
469
+ action: normalizeBrowserSummaryText(args.action),
470
+ profile: normalizeBrowserSummaryText(args.profile),
471
+ url: normalizeBrowserSummaryText(args.url),
472
+ timestamp,
473
+ });
474
+ }
475
+ if (message.role !== "toolResult" || message.toolName !== "browser")
476
+ continue;
477
+ const call = toolCalls.get(String(message.toolCallId ?? "")) ?? {
478
+ action: null,
479
+ profile: null,
480
+ url: null,
481
+ timestamp,
482
+ };
483
+ const details = isBrowserSummaryRecord(message.details) ? message.details : {};
484
+ const statusProfile = normalizeBrowserSummaryText(details.profile);
485
+ if (call.action === "status" && statusProfile) {
486
+ lastStatusProfile = statusProfile;
487
+ lastAttempt = {
488
+ state: "status_only",
489
+ action: call.action,
490
+ profile: statusProfile,
491
+ url: call.url,
492
+ error: null,
493
+ timestamp: timestamp ?? call.timestamp,
494
+ };
495
+ continue;
496
+ }
497
+ if (call.action !== "open" && call.action !== "navigate")
498
+ continue;
499
+ const error = normalizeBrowserSummaryText(details.error);
500
+ const profile = call.profile ?? statusProfile;
501
+ const ok = typeof details.ok === "boolean" ? details.ok : !error;
502
+ const state = error
503
+ ? (profile === "openclaw"
504
+ && lastStatusProfile === "browserless"
505
+ && error.includes("No supported browser found")
506
+ ? "wrong_profile_selected"
507
+ : "browser_failed_before_session")
508
+ : (ok ? "browser_open_succeeded" : "browser_failed_before_session");
509
+ lastAttempt = {
510
+ state,
511
+ action: call.action,
512
+ profile,
513
+ url: call.url ?? normalizeBrowserSummaryText(details.url),
514
+ error,
515
+ timestamp: timestamp ?? call.timestamp,
516
+ };
517
+ }
518
+ return lastAttempt;
519
+ }
520
+ export function summarizeRecentOpenclawBrowserSession(instanceId) {
521
+ const openclawHome = openclawHomeFromMetadata(getInstance(instanceId), instanceId);
522
+ if (!openclawHome)
523
+ return unavailableBrowserConsumerActivitySummary();
524
+ const index = readOpenclawBrowserSessionIndex(openclawHome);
525
+ if (index === "unavailable")
526
+ return unavailableBrowserConsumerActivitySummary();
527
+ if (index === "no_sessions")
528
+ return noSessionsBrowserConsumerActivitySummary();
529
+ const summary = noSessionsBrowserConsumerActivitySummary();
530
+ for (const session of index.sessions) {
531
+ const resolvedSessionFile = resolveSafeOpenclawBrowserSummaryFile(index.resolvedHome, session.sessionFile);
532
+ if (!resolvedSessionFile)
533
+ continue;
534
+ let content;
535
+ try {
536
+ content = readFileSync(resolvedSessionFile, "utf-8");
537
+ }
538
+ catch {
539
+ continue;
540
+ }
541
+ let lastMessageAt = null;
542
+ for (const line of content.split("\n")) {
543
+ if (!line.trim())
544
+ continue;
545
+ let entry;
546
+ try {
547
+ entry = JSON.parse(line);
548
+ }
549
+ catch {
550
+ continue;
551
+ }
552
+ if (!isBrowserSummaryRecord(entry) || entry.type !== "message")
553
+ continue;
554
+ const timestamp = normalizeBrowserSummaryTimestamp(entry.timestamp);
555
+ if (timestamp)
556
+ lastMessageAt = timestamp;
557
+ }
558
+ if (lastMessageAt && (summary.recentSession.state !== "available"
559
+ || !summary.recentSession.lastMessageAt
560
+ || summary.recentSession.lastMessageAt < lastMessageAt)) {
561
+ summary.recentSession = {
562
+ state: "available",
563
+ sessionKey: session.sessionKey,
564
+ lastMessageAt,
565
+ origin: session.origin,
566
+ channel: session.channel,
567
+ };
568
+ }
569
+ const attempt = summarizeOpenclawBrowserAttemptFromContent(content);
570
+ if (browserAttemptIsNewer(attempt, summary.lastBrowserAttempt)) {
571
+ summary.lastBrowserAttempt = attempt;
572
+ }
573
+ }
574
+ return summary;
575
+ }
576
+ // ── Runtime + config defaults (physically migrated) ───────────────────
577
+ function resolveOpenclawBin() {
578
+ const candidates = [
579
+ join(JISHUSHELL_HOME, "packages", "openclaw", "bin", "openclaw"),
580
+ "/usr/local/bin/openclaw",
581
+ "/usr/bin/openclaw",
582
+ ];
583
+ for (const p of candidates) {
584
+ if (existsSync(p)) {
585
+ try {
586
+ chmodSync(p, 0o755);
587
+ }
588
+ catch {
589
+ /* best effort — may be a symlink */
590
+ }
591
+ try {
592
+ const real = realpathSync(p);
593
+ if (real !== p)
594
+ chmodSync(real, 0o755);
595
+ }
596
+ catch {
597
+ /* best effort */
598
+ }
599
+ return p;
600
+ }
601
+ }
602
+ // Fallback: scan $PATH for user-installed openclaw (nvm, homebrew, etc.)
603
+ // Uses in-process lookup instead of spawning `which` for security and performance.
604
+ const fromPath = findExecutableOnPath("openclaw");
605
+ if (fromPath)
606
+ return fromPath;
607
+ return candidates[0]; // will fail with clear error at spawn
608
+ }
609
+ /**
610
+ * Search $PATH for an executable by name. Returns the first match or null.
611
+ * Does not chmod the result — PATH-discovered binaries are not managed by JishuShell.
612
+ */
613
+ function findExecutableOnPath(name) {
614
+ const pathEnv = process.env.PATH || "";
615
+ for (const dir of pathEnv.split(delimiter)) {
616
+ if (!dir)
617
+ continue;
618
+ const candidate = join(dir, name);
619
+ try {
620
+ accessSync(candidate, constants.X_OK);
621
+ return candidate;
622
+ }
623
+ catch {
624
+ /* not found or not executable in this dir */
625
+ }
626
+ }
627
+ return null;
628
+ }
629
+ function starterConfig() {
630
+ const dp = getDefaultLlmProvider();
631
+ let providerName = "minimax";
632
+ let providerConfig = {
633
+ baseUrl: "https://api.minimaxi.com/v1",
634
+ api: "openai-completions",
635
+ models: [{ id: "MiniMax-M2.7", name: "MiniMax M2.7", contextWindow: 204800 }],
636
+ };
637
+ let defaultModel = "minimax/MiniMax-M2.7";
638
+ if (dp?.id) {
639
+ providerName = dp.id;
640
+ providerConfig = {
641
+ baseUrl: dp.baseUrl,
642
+ api: normalizeProviderApi(dp.api),
643
+ ...(dp.authHeader ? { authHeader: true } : {}),
644
+ models: dp.models || [],
645
+ };
646
+ const modelId = dp.selectedModelId || dp.models?.[0]?.id || "";
647
+ defaultModel = `${providerName}/${modelId}`;
648
+ }
649
+ const config = {
650
+ models: { providers: { [providerName]: providerConfig } },
651
+ agents: { defaults: { model: defaultModel, models: { [defaultModel]: {} } } },
652
+ channels: {},
653
+ gateway: {
654
+ mode: "local",
655
+ auth: { mode: "token", token: randomBytes(24).toString("hex") },
656
+ controlUi: { dangerouslyDisableDeviceAuth: true },
657
+ },
658
+ plugins: { entries: { feishu: { enabled: false } } },
659
+ };
660
+ if (dp?.id) {
661
+ config["x-jishushell"] = {
662
+ proxy: {
663
+ upstream: {
664
+ providerId: dp.id,
665
+ baseUrl: dp.baseUrl,
666
+ api: normalizeProviderApi(dp.api),
667
+ authHeader: dp.authHeader === true || typeof dp.authHeader === "string",
668
+ models: dp.models || [],
669
+ selectedModelId: dp.selectedModelId || dp.models?.[0]?.id || "",
670
+ hasApiKey: !!dp.apiKey,
671
+ },
672
+ },
673
+ };
674
+ }
675
+ return config;
676
+ }
677
+ async function finalizeOpenclawCreatedInstance(instanceId, createArgs) {
678
+ const appSpec = createArgs?.appSpec;
679
+ const cloneFrom = createArgs?.cloneFrom;
680
+ const cloneOptions = createArgs?.cloneOptions;
681
+ const d = framework_instanceDir(instanceId);
682
+ const im = await lazyIm();
683
+ const home = openclawHomeFromMetadata(getInstance(instanceId), instanceId);
684
+ const envFiles = getRuntimeEnvFiles(instanceId);
685
+ const runtime = im.getInstanceRuntime(instanceId);
686
+ const configPath = openclawConfigPath(instanceId, home);
687
+ for (const ef of envFiles) {
688
+ if (!existsSync(ef))
689
+ writeConfigFile(ef, "");
690
+ }
691
+ try {
692
+ const runtimeUser = runtime?.user;
693
+ if (runtimeUser && runtimeUser !== userInfo().username) {
694
+ for (const ef of envFiles) {
695
+ execFileSync("chown", [runtimeUser, ef], { timeout: 5000 });
696
+ }
697
+ }
698
+ }
699
+ catch {
700
+ /* ignore - same user or no permission to chown */
701
+ }
702
+ ensureDirContainer(dirname(configPath));
703
+ if (cloneFrom && !existsSync(configPath)) {
704
+ const srcConfig = resolveExistingConfigPath(cloneFrom);
705
+ if (existsSync(srcConfig)) {
706
+ try {
707
+ const cloned = JSON.parse(readFileSync(srcConfig, "utf-8"));
708
+ const providers = cloned?.models?.providers;
709
+ if (providers) {
710
+ for (const [pid, prov] of Object.entries(providers)) {
711
+ if (typeof prov?.baseUrl === "string" &&
712
+ prov.baseUrl.includes("/proxy/")) {
713
+ delete providers[pid];
714
+ continue;
715
+ }
716
+ if (typeof prov === "object" && prov !== null) {
717
+ delete prov.apiKey;
718
+ }
719
+ }
720
+ }
721
+ const defaultModel = cloned?.agents?.defaults?.model;
722
+ if (typeof defaultModel === "string" &&
723
+ (defaultModel.startsWith("jsproxy/") || defaultModel.startsWith("js-"))) {
724
+ delete cloned.agents.defaults.model;
725
+ }
726
+ stripImBindings(cloned);
727
+ if (!cloned.gateway)
728
+ cloned.gateway = {};
729
+ if (!cloned.gateway.auth)
730
+ cloned.gateway.auth = { mode: "token" };
731
+ cloned.gateway.auth.token = randomBytes(24).toString("hex");
732
+ const subdirs = ["extensions", "workspace"];
733
+ if (cloneOptions?.include_memory !== false) {
734
+ const memDir = join(dirname(srcConfig), "memory");
735
+ if (existsSync(memDir))
736
+ subdirs.push("memory");
737
+ }
738
+ if (cloneOptions?.include_sessions) {
739
+ const sessDir = join(dirname(srcConfig), "agents");
740
+ if (existsSync(sessDir))
741
+ subdirs.push("agents");
742
+ }
743
+ for (const subdir of subdirs) {
744
+ const srcDir = join(dirname(srcConfig), subdir);
745
+ const dstDir = join(dirname(configPath), subdir);
746
+ if (existsSync(srcDir) && !existsSync(dstDir)) {
747
+ try {
748
+ cpSync(srcDir, dstDir, { recursive: true });
749
+ }
750
+ catch {
751
+ /* best effort */
752
+ }
753
+ }
754
+ }
755
+ writeConfigFile(configPath, JSON.stringify(cloned, null, 2));
756
+ const srcMeta = getInstance(cloneFrom);
757
+ const srcXj = srcMeta?.["x-jishushell"];
758
+ if (srcXj?.proxy?.upstream) {
759
+ const dstXj = structuredClone({ proxy: { upstream: srcXj.proxy.upstream } });
760
+ delete dstXj.proxy.upstream.apiKey;
761
+ updateInstanceMeta(instanceId, { "x-jishushell": dstXj });
762
+ }
763
+ }
764
+ catch (error) {
765
+ throw new Error(`Cannot clone OpenClaw config from ${cloneFrom}: ${error?.message ?? error}`);
766
+ }
767
+ }
768
+ }
769
+ if (!existsSync(configPath)) {
770
+ writeConfigFile(configPath, JSON.stringify(starterConfig(), null, 2));
771
+ const dp = getDefaultLlmProvider();
772
+ if (dp?.apiKey && dp?.id && envFiles.length) {
773
+ const providerEnv = join(dirname(envFiles[0]), "provider.env");
774
+ updateEnvFile(providerEnv, { UPSTREAM_API_KEY: dp.apiKey });
775
+ }
776
+ }
777
+ const runtimeOverlay = appSpec?.runtime;
778
+ const overlayDefaults = runtimeOverlay?.defaults
779
+ ?? runtimeOverlay?.config_defaults;
780
+ if (overlayDefaults && existsSync(configPath)) {
781
+ try {
782
+ const existing = JSON.parse(readFileSync(configPath, "utf-8"));
783
+ const defaults = overlayDefaults;
784
+ for (const [key, value] of Object.entries(defaults)) {
785
+ if (typeof value === "object" &&
786
+ value !== null &&
787
+ !Array.isArray(value) &&
788
+ typeof existing[key] === "object" &&
789
+ existing[key] !== null) {
790
+ existing[key] = { ...existing[key], ...value };
791
+ }
792
+ else {
793
+ existing[key] = value;
794
+ }
795
+ }
796
+ writeConfigFile(configPath, JSON.stringify(existing, null, 2));
797
+ }
798
+ catch {
799
+ /* ignore merge errors */
800
+ }
801
+ }
802
+ const overlaySkills = Array.isArray(runtimeOverlay?.skills)
803
+ ? runtimeOverlay.skills
804
+ : null;
805
+ if (overlaySkills) {
806
+ try {
807
+ const skillsDir = join(dirname(configPath), "skills");
808
+ ensureDirContainer(skillsDir);
809
+ const skillMeta = join(skillsDir, ".app-skills.json");
810
+ safeWriteJson(skillMeta, {
811
+ instanceId,
812
+ definitionId: appSpec?.id ?? instanceId,
813
+ skills: overlaySkills,
814
+ });
815
+ }
816
+ catch {
817
+ /* ignore */
818
+ }
819
+ }
820
+ // Clones intentionally inherit the source instance's Core-managed upstream
821
+ // credential. provider.env contains only the AES-encrypted upstream key and
822
+ // is never exposed to the OpenClaw process; the clone still gets its own
823
+ // JSPROXY_API_KEY in model.env below.
824
+ if (cloneFrom && envFiles.length) {
825
+ const srcEnvFiles = getRuntimeEnvFiles(cloneFrom);
826
+ const srcEnvFile = srcEnvFiles[0];
827
+ const dstEnvFile = envFiles[0];
828
+ if (srcEnvFile) {
829
+ const srcProvider = join(dirname(srcEnvFile), "provider.env");
830
+ const dstProvider = join(dirname(dstEnvFile), "provider.env");
831
+ if (existsSync(srcProvider) && !existsSync(dstProvider)) {
832
+ copyFileSync(srcProvider, dstProvider);
833
+ }
834
+ }
835
+ }
836
+ try {
837
+ await bootstrapInstanceProxy(instanceId);
838
+ }
839
+ catch (e) {
840
+ console.warn(`[openclaw] Proxy bootstrap for ${instanceId} deferred: ${e.message}`);
841
+ }
842
+ const svcUser = resolveServiceUser();
843
+ if (svcUser) {
844
+ try {
845
+ execFileSync("chown", ["-R", `${svcUser.uid}:${svcUser.gid}`, d], {
846
+ timeout: 10_000,
847
+ });
848
+ if (!home.startsWith(d + "/") && existsSync(home)) {
849
+ execFileSync("chown", ["-R", `${svcUser.uid}:${svcUser.gid}`, home], {
850
+ timeout: 10_000,
851
+ });
852
+ }
853
+ }
854
+ catch (e) {
855
+ console.warn(`[openclaw] chown for ${instanceId} failed:`, e.message);
856
+ }
857
+ }
858
+ }
859
+ // ── Nomad-patching helpers (migrated from the runtime driver) ──────────
860
+ /**
861
+ * In docker bridge mode, 127.0.0.1 inside the container resolves to the
862
+ * container's own loopback, not the host. Rewrite the jsproxy provider
863
+ * baseUrl in openclaw.json to use host.docker.internal instead.
864
+ */
865
+ function patchJsproxyBaseUrl(configPath) {
866
+ try {
867
+ const raw = readFileSync(configPath, "utf-8");
868
+ const patched = raw.replace(/http:\/\/127\.0\.0\.1:(\d+)\/proxy/g, `http://host.docker.internal:$1/proxy`);
869
+ if (patched !== raw) {
870
+ writeConfigFile(configPath, patched);
871
+ console.log(`[openclaw] Patched jsproxy baseUrl in ${configPath} (127.0.0.1 → host.docker.internal)`);
872
+ }
873
+ }
874
+ catch (e) {
875
+ console.warn(`[openclaw] Failed to patch jsproxy baseUrl in ${configPath}: ${e.message}`);
876
+ }
877
+ }
878
+ /** Known private/internal hostnames used by JishuShell's local proxy. */
879
+ const PRIVATE_NETWORK_HOSTS = ["host.docker.internal", "127.0.0.1", "localhost", "0.0.0.0"];
880
+ export function isPrivateNetworkBaseUrl(baseUrl) {
881
+ try {
882
+ const url = new URL(baseUrl);
883
+ if (PRIVATE_NETWORK_HOSTS.includes(url.hostname))
884
+ return true;
885
+ if (url.hostname.startsWith("10."))
886
+ return true;
887
+ if (url.hostname.startsWith("192.168."))
888
+ return true;
889
+ // RFC 1918: 172.16.0.0/12 → 172.16.x.x through 172.31.x.x
890
+ const m = url.hostname.match(/^172\.(\d+)\./);
891
+ if (m) {
892
+ const second = parseInt(m[1], 10);
893
+ if (second >= 16 && second <= 31)
894
+ return true;
895
+ }
896
+ return false;
897
+ }
898
+ catch {
899
+ return false;
900
+ }
901
+ }
902
+ /**
903
+ * Ensure `request.allowPrivateNetwork: true` is set on providers whose baseUrl
904
+ * targets a private/internal host (e.g. host.docker.internal). Without this,
905
+ * OpenClaw's SSRF guard blocks requests to the JishuShell local proxy.
906
+ */
907
+ export function patchPrivateNetworkAllowFlag(configPath) {
908
+ try {
909
+ const raw = readFileSync(configPath, "utf-8");
910
+ const config = JSON.parse(raw);
911
+ const providers = config?.models?.providers;
912
+ if (!providers || typeof providers !== "object")
913
+ return;
914
+ let changed = false;
915
+ for (const [, provider] of Object.entries(providers)) {
916
+ if (typeof provider !== "object" || provider === null)
917
+ continue;
918
+ const p = provider;
919
+ if (typeof p.baseUrl !== "string")
920
+ continue;
921
+ if (!isPrivateNetworkBaseUrl(p.baseUrl))
922
+ continue;
923
+ if (p.request?.allowPrivateNetwork === true)
924
+ continue;
925
+ p.request = { ...(p.request || {}), allowPrivateNetwork: true };
926
+ changed = true;
927
+ }
928
+ if (changed) {
929
+ writeConfigFile(configPath, JSON.stringify(config, null, 2));
930
+ console.log(`[openclaw] Patched request.allowPrivateNetwork in ${configPath} for private-network providers`);
931
+ }
932
+ }
933
+ catch (e) {
934
+ console.warn(`[openclaw] Failed to patch allowPrivateNetwork in ${configPath}: ${e.message}`);
935
+ }
936
+ }
937
+ /**
938
+ * Docker bridge port publishing cannot reach a process that only binds the
939
+ * container loopback. Normalize default/loopback gateway binds to `lan` so
940
+ * Nomad's published host port can reach the gateway.
941
+ */
942
+ function patchDockerBridgeGatewayBind(configPath) {
943
+ try {
944
+ const raw = readFileSync(configPath, "utf-8");
945
+ const parsed = JSON.parse(raw);
946
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
947
+ return;
948
+ const gatewayRaw = parsed.gateway;
949
+ const gateway = gatewayRaw && typeof gatewayRaw === "object" && !Array.isArray(gatewayRaw)
950
+ ? gatewayRaw
951
+ : (parsed.gateway = {});
952
+ const bind = typeof gateway.bind === "string" ? gateway.bind.trim() : "";
953
+ if (bind && bind !== "loopback")
954
+ return;
955
+ gateway.bind = "lan";
956
+ const next = JSON.stringify(parsed, null, 2);
957
+ const output = raw.endsWith("\n") ? `${next}\n` : next;
958
+ if (output === raw)
959
+ return;
960
+ writeConfigFile(configPath, output);
961
+ console.log(`[openclaw] Normalized gateway.bind to "lan" in ${configPath} for Docker bridge networking`);
962
+ }
963
+ catch (e) {
964
+ console.warn(`[openclaw] Failed to patch gateway.bind in ${configPath}: ${e.message}`);
965
+ }
966
+ }
967
+ /**
968
+ * Ensure the `llm-agent` capability advertised by openclaw-*.yaml works for
969
+ * every instance, including ones created before this code shipped: enable
970
+ * OpenClaw's OpenAI-compatible endpoints in `openclaw.json` on every start.
971
+ *
972
+ * Runs idempotently next to `patchDockerBridgeGatewayBind`. The OpenAI
973
+ * routes (`/v1/chat/completions`, `/v1/responses`, `/v1/models`,
974
+ * `/v1/embeddings`) live in openclaw's bundled server.impl and are gated
975
+ * behind `gateway.http.endpoints.{chatCompletions,responses}.enabled` —
976
+ * default false, so a fresh OpenClaw install would 404 those paths even
977
+ * though OpenWebUI binds it through the connections page.
978
+ */
979
+ export function patchOpenAIEndpointsEnabled(configPath) {
980
+ try {
981
+ const raw = readFileSync(configPath, "utf-8");
982
+ const parsed = JSON.parse(raw);
983
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed))
984
+ return;
985
+ const root = parsed;
986
+ const gateway = root.gateway && typeof root.gateway === "object" && !Array.isArray(root.gateway)
987
+ ? root.gateway
988
+ : (root.gateway = {});
989
+ const http = gateway.http && typeof gateway.http === "object" && !Array.isArray(gateway.http)
990
+ ? gateway.http
991
+ : (gateway.http = {});
992
+ const endpoints = http.endpoints && typeof http.endpoints === "object" && !Array.isArray(http.endpoints)
993
+ ? http.endpoints
994
+ : (http.endpoints = {});
995
+ let changed = false;
996
+ for (const key of ["chatCompletions", "responses"]) {
997
+ const ep = endpoints[key] && typeof endpoints[key] === "object" && !Array.isArray(endpoints[key])
998
+ ? endpoints[key]
999
+ : (endpoints[key] = {});
1000
+ if (ep.enabled !== true) {
1001
+ ep.enabled = true;
1002
+ changed = true;
1003
+ }
1004
+ }
1005
+ if (!changed)
1006
+ return;
1007
+ const next = JSON.stringify(parsed, null, 2);
1008
+ const output = raw.endsWith("\n") ? `${next}\n` : next;
1009
+ writeConfigFile(configPath, output);
1010
+ console.log(`[openclaw] Enabled gateway.http.endpoints.{chatCompletions,responses} in ${configPath} for llm-agent capability`);
1011
+ }
1012
+ catch (e) {
1013
+ console.warn(`[openclaw] Failed to patch OpenAI endpoints in ${configPath}: ${e.message}`);
1014
+ }
1015
+ }
1016
+ /**
1017
+ * Deep-merge a SearXNG connection into an OpenClaw config file at `configPath`.
1018
+ *
1019
+ * Writes both halves of the wiring required for the `web_search` tool to use
1020
+ * the registry-resolved SearXNG instance:
1021
+ *
1022
+ * plugins.entries.searxng.enabled = true
1023
+ * plugins.entries.searxng.config.webSearch.baseUrl = baseUrl
1024
+ * tools.web.search.provider = "searxng"
1025
+ *
1026
+ * The provider selector is required because OpenClaw's built-in default is
1027
+ * `"brave"`; without it the tool fails with `missing_brave_api_key` even when
1028
+ * the searxng plugin is otherwise correctly configured (verified on Pi
1029
+ * 2026-04-29: claw11 had the plugin block right but the selector unset).
1030
+ *
1031
+ * Why a partial deep-merge instead of `saveNativeConfig`: the latter is
1032
+ * destructive — it replaces top-level keys wholesale and only preserves a
1033
+ * hardcoded subset (`plugins.installs`, `plugins.entries` per-key, partial
1034
+ * `channels` merge). A partial patch through it would wipe `models.providers`
1035
+ * / `agents.defaults` / etc., bricking the instance with `No API key found
1036
+ * for provider "openai"` on the next chat. So we read, merge, write back.
1037
+ *
1038
+ * No-op when the config file is absent (instance not yet started).
1039
+ */
1040
+ export function applySearxngConnectionToConfig(configPath, baseUrl) {
1041
+ if (!existsSync(configPath))
1042
+ return;
1043
+ const existing = JSON.parse(readFileSync(configPath, "utf-8"));
1044
+ existing.plugins = existing.plugins ?? {};
1045
+ existing.plugins.entries = existing.plugins.entries ?? {};
1046
+ const prior = existing.plugins.entries.searxng ?? {};
1047
+ existing.plugins.entries.searxng = {
1048
+ ...prior,
1049
+ enabled: true,
1050
+ config: {
1051
+ ...(prior.config ?? {}),
1052
+ webSearch: {
1053
+ ...((prior.config ?? {}).webSearch ?? {}),
1054
+ baseUrl,
1055
+ },
1056
+ },
1057
+ };
1058
+ existing.tools = existing.tools ?? {};
1059
+ existing.tools.web = existing.tools.web ?? {};
1060
+ existing.tools.web.search = existing.tools.web.search ?? {};
1061
+ existing.tools.web.search.provider = "searxng";
1062
+ safeWriteJson(configPath, existing);
1063
+ }
1064
+ /**
1065
+ * Counterpart to `applySearxngConnectionToConfig` — invoked when the user
1066
+ * unbinds the SEARCH slot in the Connections tab. Without this, unbinding
1067
+ * left the plugin entry enabled with a baseUrl pointing at the now-gone
1068
+ * searxng provider, and `tools.web.search.provider="searxng"` kept routing
1069
+ * the agent's `web_search` tool through that dead URL on every chat.
1070
+ *
1071
+ * Conservative cleanup so a future re-bind (or user-customized plugin
1072
+ * settings) survives:
1073
+ * - flip the searxng plugin to enabled:false (don't delete the entry —
1074
+ * user may have hand-tuned it and we want re-bind to re-enable cheaply)
1075
+ * - drop the stale `webSearch.baseUrl` so nothing reads it as still-live
1076
+ * - clear `tools.web.search.provider` so the runtime falls back to its
1077
+ * built-in default (which today errors out with `missing_brave_api_key`
1078
+ * — the right outcome: search was unbound, web_search shouldn't work)
1079
+ *
1080
+ * No-op when the config file is absent.
1081
+ */
1082
+ export function clearSearxngConnectionFromConfig(configPath) {
1083
+ if (!existsSync(configPath))
1084
+ return;
1085
+ const existing = JSON.parse(readFileSync(configPath, "utf-8"));
1086
+ const sx = existing?.plugins?.entries?.searxng;
1087
+ if (sx && typeof sx === "object") {
1088
+ sx.enabled = false;
1089
+ if (sx.config?.webSearch && typeof sx.config.webSearch === "object") {
1090
+ delete sx.config.webSearch.baseUrl;
1091
+ }
1092
+ }
1093
+ if (existing?.tools?.web?.search && typeof existing.tools.web.search === "object") {
1094
+ delete existing.tools.web.search.provider;
1095
+ }
1096
+ safeWriteJson(configPath, existing);
1097
+ }
1098
+ /** Profile name used in `browser.profiles` for jishushell-managed Browserless bindings. */
1099
+ const BROWSERLESS_PROFILE = "browserless";
1100
+ /**
1101
+ * Default `color` for the jishushell-managed browserless profile. OpenClaw's
1102
+ * profile schema treats `color` as required (the field shows up as the
1103
+ * profile chip tint in the UI); omitting it triggers
1104
+ * "browser.profiles.browserless.color: Invalid input: expected string,
1105
+ * received undefined"
1106
+ * on every config reload, which crashloops the gateway. Verified against
1107
+ * the runtime image `ghcr.io/x-aijishu/openclaw-runtime:2026.4.15` on Pi 2
1108
+ * (2026-05-07). The tone is Browserless brand green; users can override it
1109
+ * once and we preserve their override on re-bind via the `prior` spread.
1110
+ */
1111
+ const BROWSERLESS_DEFAULT_COLOR = "#00AA66";
1112
+ /**
1113
+ * Deep-merge a Browserless CDP connection into an OpenClaw config file at
1114
+ * `configPath`. Mirrors `applySearxngConnectionToConfig` for the browser slot.
1115
+ *
1116
+ * Writes:
1117
+ * browser.profiles.browserless.cdpUrl = cdpUrl // ws:// or wss://
1118
+ * browser.profiles.browserless.attachOnly = true // since v2026.3.2
1119
+ * browser.profiles.browserless.color = "#00AA66" // required by schema
1120
+ * browser.defaultProfile = "browserless" // only if unset
1121
+ * browser.enabled = true // only if unset
1122
+ * gateway.nodes.browser.mode = "off" // only if unset
1123
+ *
1124
+ * Why per-profile `attachOnly` and not global `browser.attachOnly`: global
1125
+ * attachOnly forces every profile to skip launch — that breaks the user's
1126
+ * other manually-configured profiles. Per-profile attachOnly was added in
1127
+ * OpenClaw v2026.3.2; older versions silently ignore the extra field and
1128
+ * fall back to attach-via-cdpUrl semantics (which `cdpUrl` triggers on its
1129
+ * own from v2.0.0-beta5), so the schema is forward-compatible all the way
1130
+ * back to the first remote-CDP release.
1131
+ *
1132
+ * Why `gateway.nodes.browser.mode = "off"`: in OpenClaw 2026.5.6 the
1133
+ * gateway only registers the `browser.request` WS method when this config
1134
+ * block exists. Without it, `openclaw browser …` CLI and the gateway
1135
+ * canvas tool both fail with `unknown method: browser.request` or
1136
+ * `node required`. Setting `mode: "off"` forces gateway-local CDP
1137
+ * dispatch (use `cdpUrl` directly, never look for paired nodes), which
1138
+ * matches jishushell's intent: Browserless is a service-style provider,
1139
+ * not a node-style provider. Verified end-to-end on Pi 2 (2026-05-07):
1140
+ * Browserless `/sessions` shows `numbConnected: 1` and `openclaw browser
1141
+ * navigate <allowed-host>` succeeds + screenshots render correctly.
1142
+ *
1143
+ * `defaultProfile`, `enabled`, and `gateway.nodes.browser.mode` are all
1144
+ * set only when absent so user-customized values survive a re-bind. The
1145
+ * `enabled` flag is never flipped off — Browserless binding shouldn't
1146
+ * override a user who explicitly disabled the browser tool tree.
1147
+ *
1148
+ * SSRF policy: on every Browserless bind, the bound CDP endpoint hostname is
1149
+ * merged into `allowedHostnames` so OpenClaw can connect to the trusted
1150
+ * Browserless service even when it is advertised on a private LAN address.
1151
+ * On first bind (when the `allowedHostnames` list is empty or absent), a
1152
+ * small set of common public-internet hosts is also pre-populated so users
1153
+ * don't have to whitelist every popular site one by one. The public defaults
1154
+ * are a one-time bootstrap — once the user has any entries, further binds
1155
+ * leave those entries untouched except for refreshing the active endpoint.
1156
+ *
1157
+ * No-op when the config file is absent (instance not yet started).
1158
+ */
1159
+ export function applyBrowserlessConnectionToConfig(configPath, cdpUrl) {
1160
+ if (!existsSync(configPath))
1161
+ return;
1162
+ const existing = JSON.parse(readFileSync(configPath, "utf-8"));
1163
+ const browser = (existing.browser ??= {});
1164
+ if (browser.enabled === undefined)
1165
+ browser.enabled = true;
1166
+ if (!browser.defaultProfile)
1167
+ browser.defaultProfile = BROWSERLESS_PROFILE;
1168
+ const profiles = (browser.profiles ??= {});
1169
+ const prior = profiles[BROWSERLESS_PROFILE] ?? {};
1170
+ profiles[BROWSERLESS_PROFILE] = {
1171
+ ...prior,
1172
+ cdpUrl,
1173
+ attachOnly: true,
1174
+ color: typeof prior.color === "string" && prior.color ? prior.color : BROWSERLESS_DEFAULT_COLOR,
1175
+ };
1176
+ if (existing.meta?._js_allowAll) {
1177
+ delete browser.ssrfPolicy;
1178
+ }
1179
+ else {
1180
+ const ssrfPolicy = (browser.ssrfPolicy ??= {});
1181
+ const existingAllowedHostnames = Array.isArray(ssrfPolicy.allowedHostnames)
1182
+ ? ssrfPolicy.allowedHostnames.map((entry) => String(entry))
1183
+ : [];
1184
+ const bootstrapHostnames = existingAllowedHostnames.length === 0
1185
+ ? DEFAULT_BROWSER_ALLOWED_HOSTNAMES
1186
+ : existingAllowedHostnames;
1187
+ ssrfPolicy.allowedHostnames = mergeBrowserAllowedHostnames(bootstrapHostnames, browserlessEndpointAllowedHostname(cdpUrl));
1188
+ }
1189
+ const gateway = (existing.gateway ??= {});
1190
+ const nodes = (gateway.nodes ??= {});
1191
+ const browserPolicy = (nodes.browser ??= {});
1192
+ if (browserPolicy.mode === undefined)
1193
+ browserPolicy.mode = "off";
1194
+ safeWriteJson(configPath, existing);
1195
+ }
1196
+ /**
1197
+ * Counterpart to `applyBrowserlessConnectionToConfig` — invoked when the user
1198
+ * unbinds the BROWSER slot in the Connections tab. Removes the
1199
+ * jishushell-managed `browserless` profile and clears `defaultProfile` only
1200
+ * if it still points at that profile (so user-set defaults pointing at their
1201
+ * own profiles survive). Other profiles and `browser.enabled` are left alone.
1202
+ *
1203
+ * No-op when the config file is absent.
1204
+ */
1205
+ export function clearBrowserlessConnectionFromConfig(configPath) {
1206
+ if (!existsSync(configPath))
1207
+ return;
1208
+ const existing = JSON.parse(readFileSync(configPath, "utf-8"));
1209
+ const browser = existing?.browser;
1210
+ if (!browser || typeof browser !== "object")
1211
+ return;
1212
+ if (browser.profiles && typeof browser.profiles === "object") {
1213
+ delete browser.profiles[BROWSERLESS_PROFILE];
1214
+ }
1215
+ if (browser.defaultProfile === BROWSERLESS_PROFILE) {
1216
+ delete browser.defaultProfile;
1217
+ }
1218
+ safeWriteJson(configPath, existing);
1219
+ }
1220
+ /**
1221
+ * Bump when a panel-side change invalidates the agent's prior reasoning
1222
+ * within an existing chat session — e.g., a mount fix that turns prior
1223
+ * "I can't read this file" tool failures into stale conclusions. The
1224
+ * first onBeforeStart after the bump rotates the instance's session
1225
+ * jsonl files (`<file>.jsonl` → `<file>.jsonl.reset.<ts>`), so the next
1226
+ * user message lands on a clean context window. Old transcripts are
1227
+ * preserved as .reset.* siblings — never deleted, just archived.
1228
+ *
1229
+ * Concrete history:
1230
+ * 2026.5.11.1 — buildVolumes root-mount fix: empty-path FileMount
1231
+ * finally binds FILES_ROOT into docker containers. Prior
1232
+ * sessions had agent conclude "drive only has metadata,
1233
+ * no file content" after ENOENT — that reasoning is
1234
+ * poisoned post-fix.
1235
+ * 2026.5.11.2 — WeChat target-format rule in TOOLS.md: agent was
1236
+ * extrapolating Feishu's `user:` prefix onto WeChat
1237
+ * chat_ids that don't carry it, causing WeChat's
1238
+ * getuploadurl to return ret:-1. Prior sessions need
1239
+ * rotation so the agent re-reads the corrected target
1240
+ * rule and stops adding the prefix.
1241
+ * 2026.6.4.2 — jishu-kb citations response + mcporter fallback shebang:
1242
+ * agent was concluding KB was empty because the shim only
1243
+ * recognized `chunks/results/hits`, while current jishu-kb
1244
+ * returns `citations`. The fallback wrapper also baked a
1245
+ * host-specific node shebang that some OpenClaw runtimes
1246
+ * could not execute directly. Prior sessions need rotation
1247
+ * so the agent retries with the fixed tool behavior.
1248
+ * 2026.6.4.3 — jishu-kb multi-tool surface: KB management/upload/delete
1249
+ * tools and handbook/config reads are now available.
1250
+ * Prior sessions need rotation so the model re-reads the
1251
+ * expanded tool instructions instead of the old search-only
1252
+ * guidance.
1253
+ * 2026.6.10.1 — Browserless profile rule in TOOLS.md: Browserless-bound
1254
+ * instances now spell out that `browser.open` should not
1255
+ * default to `profile: "openclaw"` after status/doctor
1256
+ * already report `browserless via cdp`.
1257
+ * 2026.6.11.1 — Browserless shared-browser handoff rule: Browserless is
1258
+ * now described as a user-takeover-capable shared browser
1259
+ * surface.
1260
+ * 2026.6.12.1 — Browserless site-side anti-bot classification rule:
1261
+ * site WAF/captcha blocks are not Browser Allowlist misses.
1262
+ *
1263
+ * Format: YYYY.M.D.N (date + same-day bump counter). Compare as strings;
1264
+ * any difference means rotate. Stored per-instance at
1265
+ * `<instanceDir>/runtime-contract.txt`
1266
+ */
1267
+ const RUNTIME_CONTRACT_VERSION = "2026.6.12.1";
1268
+ const JISHUSHELL_DRIVE_HINT_BEGIN = "<!-- jishushell-drive: BEGIN auto-generated -->";
1269
+ const JISHUSHELL_DRIVE_HINT_END = "<!-- jishushell-drive: END -->";
1270
+ const JISHUSHELL_KB_HINT_BEGIN = "<!-- jishushell-kb: BEGIN auto-generated -->";
1271
+ const JISHUSHELL_KB_HINT_END = "<!-- jishushell-kb: END -->";
1272
+ const JISHUSHELL_BROWSERLESS_HINT_BEGIN = "<!-- jishushell-browserless: BEGIN auto-generated -->";
1273
+ const JISHUSHELL_BROWSERLESS_HINT_END = "<!-- jishushell-browserless: END -->";
1274
+ /**
1275
+ * Rotate session jsonl files when the runtime contract version has bumped
1276
+ * since this instance last started. Matches OpenClaw's own .reset.<ts>
1277
+ * naming convention so its existing UI/cleanup paths still apply.
1278
+ *
1279
+ * Why this exists: when a panel upgrade fixes a runtime bug (e.g. the
1280
+ * 2026-05-11 mount-bind fix), the agent's prior turn-by-turn reasoning
1281
+ * inside an existing session is anchored to the broken behaviour. Even
1282
+ * after the fix is deployed and the alloc restarted, the LLM keeps
1283
+ * citing past tool failures and refusing to retry. Rotating the session
1284
+ * jsonl(s) gives the next user message a clean context where the agent
1285
+ * sees fresh TOOLS.md + fresh tool outputs.
1286
+ *
1287
+ * Side effect: the user loses chat scrollback in IM/web. Acceptable
1288
+ * because (a) the rotated file is preserved on disk, (b) panel upgrades
1289
+ * are infrequent, (c) the alternative — agent stuck in old reasoning —
1290
+ * is worse UX.
1291
+ */
1292
+ function rotateSessionsIfContractChanged(instanceId, openclawHome) {
1293
+ try {
1294
+ const markerPath = join(framework_instanceDir(instanceId), "runtime-contract.txt");
1295
+ let previous = "";
1296
+ try {
1297
+ previous = readFileSync(markerPath, "utf-8").trim();
1298
+ }
1299
+ catch (e) {
1300
+ if (e?.code !== "ENOENT")
1301
+ throw e;
1302
+ }
1303
+ if (previous === RUNTIME_CONTRACT_VERSION)
1304
+ return;
1305
+ const sessionsDir = join(openclawHome, ".openclaw", "agents", "main", "sessions");
1306
+ if (existsSync(sessionsDir)) {
1307
+ const ts = new Date()
1308
+ .toISOString()
1309
+ .replace(/:/g, "-")
1310
+ .replace(/\.\d+Z$/, ".000Z");
1311
+ const entries = readdirSync(sessionsDir);
1312
+ let rotated = 0;
1313
+ let rotateFailed = false;
1314
+ for (const name of entries) {
1315
+ if (!name.endsWith(".jsonl"))
1316
+ continue; // skip already-rotated
1317
+ const from = join(sessionsDir, name);
1318
+ const to = `${from}.reset.${ts}`;
1319
+ try {
1320
+ renameSync(from, to);
1321
+ rotated++;
1322
+ }
1323
+ catch (e) {
1324
+ rotateFailed = true;
1325
+ console.warn(`[openclaw] session rotate failed for ${from}: ${e?.message ?? e}`);
1326
+ }
1327
+ }
1328
+ if (rotated > 0) {
1329
+ console.log(`[openclaw] runtime contract ${previous || "(none)"} → ${RUNTIME_CONTRACT_VERSION}: rotated ${rotated} session(s) under ${sessionsDir}`);
1330
+ }
1331
+ if (rotateFailed)
1332
+ return;
1333
+ }
1334
+ writeConfigFile(markerPath, RUNTIME_CONTRACT_VERSION + "\n");
1335
+ }
1336
+ catch (e) {
1337
+ console.warn(`[openclaw] rotateSessionsIfContractChanged failed: ${e?.message ?? e}`);
1338
+ }
1339
+ }
1340
+ /**
1341
+ * Inject a guarded section into the agent's TOOLS.md telling the LLM that
1342
+ * user files live on the local filesystem (host==container bind mount),
1343
+ * not on some remote "drive server", and showing the concrete
1344
+ * resolve-then-send chain for IM channels (Feishu / WeChat).
1345
+ *
1346
+ * Why this exists: the LLM defaults to interpreting `drive` as a remote
1347
+ * service, then refuses to send NAS files via IM with "I can't access the
1348
+ * cloud drive" — even when `drive_list` literally just enumerated them.
1349
+ * Verified on pi2 2026-05-11: claw1 saw `文档/宇树G1-D...xlsx` via
1350
+ * drive_list, then told the user to "open Feishu cloud space and forward
1351
+ * it back" because nothing in TOOLS.md tied drive paths to filesystem
1352
+ * paths. This patcher closes that gap by spelling it out.
1353
+ *
1354
+ * Idempotent: section is bracketed by HTML markers; content between them
1355
+ * is rewritten on every call. User edits OUTSIDE the markers are kept.
1356
+ *
1357
+ * filesRoot is baked in so the example abs path matches the actual install
1358
+ * — third-party users on `/home/alice/.jishushell/files/` see their own
1359
+ * root, not pi's.
1360
+ */
1361
+ export function patchToolsMdDriveHint(workspaceDir, filesRoot, mcporterCommand = "mcporter", instanceId) {
1362
+ try {
1363
+ const toolsPath = join(workspaceDir, "TOOLS.md");
1364
+ let original = "";
1365
+ try {
1366
+ original = readFileSync(toolsPath, "utf-8");
1367
+ }
1368
+ catch (e) {
1369
+ if (e?.code !== "ENOENT")
1370
+ throw e;
1371
+ }
1372
+ const cli = mcporterCommand === "mcporter" ? "mcporter" : JSON.stringify(mcporterCommand);
1373
+ const generatedOutboxPath = instanceId
1374
+ ? `agent-data/${instanceId}/outbox/x.pdf`
1375
+ : "agent-data/<instance>/outbox/x.pdf";
1376
+ const section = [
1377
+ JISHUSHELL_DRIVE_HINT_BEGIN,
1378
+ "",
1379
+ "### 📁 用户的 NAS / 文件库",
1380
+ "",
1381
+ "⚠️ **用户文件操作硬路由 — 必读**",
1382
+ "",
1383
+ "**单一规则(语言无关)**:用户用任何语言(中文 / English / 日本語 / ...)说「**我的 / 我的 / my / mine / our / the user's / 私の**」+ 任何文件/目录/资料/笔记/文档/代码/data/notes/docs/files → **CRUD 全部走 `drive.*` 工具,禁止用 shell 在 cwd 上操作**。判定按**语义**不按**字面**,本表只是举例。",
1384
+ "",
1385
+ "动作 ↔ 工具映射表(用户文件场景,中英混排示例):",
1386
+ "",
1387
+ "| 用户意图(多语言示例) | ✅ 必须用 | ❌ 禁止 |",
1388
+ "|---|---|---|",
1389
+ "| list / show / 「列一下 / 我有什么 / 看看我的 / what files do I have / show me my docs / list my files」 | `drive_list` | `ls`, `find`, `pwd` |",
1390
+ "| read / open / 「打开 / 看看 / 念一下 / 内容是啥 / open my X / read the content of / what's in」 | `drive_read_preview` / `drive_read_full` | `cat`, `head`, `tail` |",
1391
+ "| search / find / 「搜 / 找一下 / 哪里提到 / search my docs for / find X in my files / where did I write about」 | `drive_search` | `grep`, `rg` |",
1392
+ "| write / save / create / 「写 / 存 / 记一下 / 新建 / save this as / write a note / create a file」 | `drive_write_text` / `drive_write_binary` | `echo >`, `cat <<EOF`, `tee` |",
1393
+ "| delete / remove / 「删 / 扔掉 / delete X / remove the file」 | `drive_delete` | `rm` |",
1394
+ "| rename / move / 「改名 / 挪到 / 移到 / rename X to Y / move X to」 | `drive_move` | `mv` |",
1395
+ "| mkdir / 「建文件夹 / create a folder / make a directory」 | `drive_mkdir` | `mkdir` |",
1396
+ "| quota / space / 「配额 / 空间 / how much space / quota / disk usage」 | `drive_quota` | `df`, `du` |",
1397
+ "| send / share / 「发给我 / 把 X 发出去 / send me X / share the file with me」 | `drive_resolve_local_path` → IM `send_file` | (拒绝 / refuse) |",
1398
+ "",
1399
+ "**触发词不完全列表(再次强调:语义优先)**:",
1400
+ "- 中文:我的、我那份、我之前的、我刚刚的、用户的、咱们的、文件、文档、资料、笔记、报告、合同、PDF、Excel、附件",
1401
+ "- English: my, mine, our, the user's, files, file, doc(s), document(s), note(s), paper(s), report(s), spreadsheet(s), pdf(s), attachment(s)",
1402
+ "- 其它语言:私の (ja) / mes (fr) / mein (de) / 我的 (variants) — 含义相同时同等处理",
1403
+ "",
1404
+ "**为什么硬规定**:cwd 是你自己的运行骨架(`AGENTS.md`、`TOOLS.md`、`memory/`、`state/`、`config/`),跟用户**毫无关系**。",
1405
+ "- 用户问「我有什么文件 / what files do I have」你 `ls` cwd → 列出 `AGENTS.md`、`memory/` → 用户懵 + 觉得 jishushell 装错了",
1406
+ "- 用户说「帮我写笔记 notes.md / save a note for me」你 `echo > notes.md` 落 cwd → 文件落到 agent 工作目录,用户在 filebrowser 看不到 → 数据等于丢了",
1407
+ "- 用户说「打开我那份产品规格 / open my spec」你 `cat spec.md` → cwd 里没有该文件 → 找不到 → 用户被冤枉「文件根本不存在」",
1408
+ "",
1409
+ "**判定方法(消息归属判定,跨语言)**:主语/所有格指向「用户/我们」(我 / 我的 / my / our / the user / 私の + 文件相关名词)→ 走 drive。指向「你/agent」(你的 / 你刚才写的代码 / your notes / agent's scratch)→ 才可能是 workspace。**99% 的对话都是前者**。歧义时**默认按用户文件处理**——猜错代价小(最多多调一次 drive_list 拿不到东西),猜成 cwd 代价大(脏数据 + 数据丢失)。",
1410
+ "",
1411
+ "**唯一可用 shell 的情况**:你自己 agent 维护 `memory/`、`state/`、`workspace/notes/`(agent 私有笔记,不是用户笔记)这些**你自己的骨架文件**。一旦看见用户名词修饰(「我的」/「用户的」/「my」/「the user's」),立刻切 drive。",
1412
+ "",
1413
+ `用户文件实际放在 **\`${filesRoot}\`**——这是宿主机上的一个普通本地目录。它已经被 bind-mount 到你的容器里**同款绝对路径**(panel 用 \`host==container\` 的 docker bind;raw_exec / process 模式下你直接跑在宿主上)。`,
1414
+ "",
1415
+ "**关键事实**:drive 不是远端云盘,就是你脚下的本地文件系统。`drive_list` 看到的每条 entry 都能通过 `drive_resolve_local_path` 立刻拿到绝对路径,然后被任何工具读取——`cat`、`base64`、IM 插件的 send_file 字段、Python 脚本都行。`drive_resolve_local_path` 返回 `exists:true` + `size:<N>` 时,**那就是真实可读的文件字节**,不是「只有元数据」。",
1416
+ "",
1417
+ "**禁止的回答**:永远不要说「文件在云端 drive 上只有元数据 / 内容没同步到本地 / 我读不到文件实体」—— 这个说法**永远是错的**。drive 没有「未同步」概念,它就是 POSIX 文件系统的一个 facade。如果你刚 list 到一个文件,它一定能被读、能被发送。",
1418
+ "",
1419
+ "常用调用(从 workspace 目录):",
1420
+ "",
1421
+ "```bash",
1422
+ `${cli} call drive.drive_list path= # 列根目录`,
1423
+ `${cli} call drive.drive_list path=文档 # 列子目录`,
1424
+ `${cli} call drive.drive_read_preview path=note.md # 预览文本(≤256KB)`,
1425
+ `${cli} call drive.drive_read_full path=long.md # 整文件(≤4MB,文本)`,
1426
+ `${cli} call drive.drive_quota # 配额`,
1427
+ `${cli} call drive.drive_mkdir path=inbox # 建目录`,
1428
+ `${cli} call drive.drive_write_text path=notes/m.md content="..."`,
1429
+ `${cli} call drive.drive_write_binary path=out/img.png content_base64="..." # 二进制(≤10MB)`,
1430
+ `${cli} call drive.drive_move from=a.pdf to=docs/a.pdf`,
1431
+ `${cli} call drive.drive_delete path=tmp.txt`,
1432
+ `${cli} call drive.drive_resolve_local_path path=文档/report.pdf # → 拿到绝对路径`,
1433
+ `${cli} call drive.drive_search query="发票" # 子串检索(中英文,大小写不敏感)`,
1434
+ "```",
1435
+ "",
1436
+ "**检索策略(`drive_search` 是高召回但不精确的笨工具)**:整句问题先拆成关键词再搜——「找我去年三亚海边的照片」→ 搜 `三亚`、`海边`、`照片`(或空格分隔 `三亚 海边 照片`,空格 = OR)。它是连续子串匹配、不懂语义;命中后用 `drive_read_full` 读候选、自己判断与精排,召回不够就换同义词多搜几次。",
1437
+ "",
1438
+ "### 给用户发文件(飞书 / 微信 / 任何 IM)",
1439
+ "",
1440
+ "**用户问 \"把 X 文件发我\" 时不要拒绝、不要让用户去飞书云空间下载**——99% 的情况文件已经在你的文件系统里了。标准流程:",
1441
+ "",
1442
+ "1. `drive_list` 或 `drive_search` 先确认文件在 NAS 里(你刚 list 过的也算)。",
1443
+ "2. `drive_resolve_local_path path=文档/x.xlsx` 拿到 `abs_path`,确认 `exists:true`。",
1444
+ "3. 把 `abs_path` 传给**当前会话所在 IM 通道**的发送工具。**`target` 字段一律原样照搬当前消息 `Conversation info` 里的 `chat_id`——一个字符都不要加、不要改、不要补前缀**。各通道 chat_id 形态本来就不一样,照搬就对。",
1445
+ " - **飞书 DM**:metadata 给 `\"chat_id\":\"user:ou_xxx\"`(自带 `user:` 前缀,**这是飞书的格式不是通用约定**)→ `target=\"user:ou_xxx\"`。工具用 `message` (channel=feishu, msg_type=file, path=<abs_path>) 或 `openclaw-lark` 的 `feishu_im_user_message`。",
1446
+ " - **微信 DM**:metadata 给 `\"chat_id\":\"o9cq...@im.wechat\"`(**裸 ID,没有 `user:` 前缀**)→ `target=\"o9cq...@im.wechat\"`。工具用 `message` (channel=openclaw-weixin, msg_type=file, path=<abs_path>)。**千万别照搬飞书的 `user:` 加上去**——会让微信服务端的 `getuploadurl` 返 `ret:-1`,文件传不出去。",
1447
+ " - 通用规则:当前 inbound 消息的 `from` 就是回复 target。打开你刚收到的那条 user message 里 `Conversation info` 的 JSON,把 `chat_id` 整段复制就行。",
1448
+ "4. 失败先查 `exists` 字段、文件大小、IM 通道大小上限(飞书典型 30MB、微信 20MB),再决定降级方案。",
1449
+ "",
1450
+ "**ENOENT / \"no such file or directory\" 处理**:IM 插件返回 ENOENT 但 `drive_resolve_local_path` 刚刚 `exists:true`,**99% 是 panel 刚升级 / mount 刚刷新,但你这个 alloc 用的是旧 spec**。无脑重试一次。还是 ENOENT 才提示用户去 panel 重启实例(stop+start,不是 restart)——但**永远不要**回答 \"文件只是元数据所以读不到\",那是错的。",
1451
+ "",
1452
+ `要发**新生成**的文件(PDF、图片、报表):先 \`drive_write_binary path=${generatedOutboxPath} content_base64=...\` 落盘,再 resolve → 发送。`,
1453
+ "",
1454
+ "### 用户给你发文件",
1455
+ "",
1456
+ "目前飞书/微信通道不会自动把附件落盘到 NAS。当用户说\"文件给你了\"但你 `drive_list inbox` 看不到:",
1457
+ "- 优先让用户走 panel 的 Filebrowser(`/apps/filebrowser/`)或 WebDAV 把文件上传到 `inbox/`,再告诉你路径。",
1458
+ "- 飞书附件流:如果飞书 app 已配 `im:resource` 权限,可以用 `feishu_im_user_fetch_resource` 取 file_key、落到 `inbox/feishu/<date>/`。",
1459
+ "",
1460
+ "权限:在 panel \"关联 agent\" UI 里给实例授 ro/rw。403 时让用户去 panel 加。",
1461
+ "",
1462
+ JISHUSHELL_DRIVE_HINT_END,
1463
+ "",
1464
+ ].join("\n");
1465
+ let next;
1466
+ const beginIdx = original.indexOf(JISHUSHELL_DRIVE_HINT_BEGIN);
1467
+ const endIdx = original.indexOf(JISHUSHELL_DRIVE_HINT_END);
1468
+ if (beginIdx >= 0 && endIdx > beginIdx) {
1469
+ const tail = endIdx + JISHUSHELL_DRIVE_HINT_END.length;
1470
+ const after = original
1471
+ .slice(tail)
1472
+ .replace(/^\n+/, "\n");
1473
+ next = original.slice(0, beginIdx) + section + after;
1474
+ }
1475
+ else {
1476
+ const sep = original && !original.endsWith("\n") ? "\n\n" : "\n";
1477
+ next = (original ? original + sep : "") + section;
1478
+ }
1479
+ if (next === original)
1480
+ return;
1481
+ writeConfigFile(toolsPath, next);
1482
+ console.log(`[openclaw] Patched drive hint into ${toolsPath}`);
1483
+ }
1484
+ catch (e) {
1485
+ console.warn(`[openclaw] Failed to patch TOOLS.md drive hint: ${e.message}`);
1486
+ }
1487
+ }
1488
+ export function patchToolsMdBrowserlessHint(workspaceDir, mode) {
1489
+ try {
1490
+ const toolsPath = join(workspaceDir, "TOOLS.md");
1491
+ let original = "";
1492
+ try {
1493
+ original = readFileSync(toolsPath, "utf-8");
1494
+ }
1495
+ catch (e) {
1496
+ if (e?.code !== "ENOENT")
1497
+ throw e;
1498
+ if (mode === "remove")
1499
+ return;
1500
+ }
1501
+ const stripRe = /\n*<!-- jishushell-browserless: BEGIN[^>]*-->[\s\S]*?<!-- jishushell-browserless: END[^>]*-->\n*/g;
1502
+ const stripped = original.replace(stripRe, "\n");
1503
+ let next;
1504
+ if (mode === "remove") {
1505
+ if (stripped === original)
1506
+ return;
1507
+ next = stripped;
1508
+ }
1509
+ else {
1510
+ const section = [
1511
+ JISHUSHELL_BROWSERLESS_HINT_BEGIN,
1512
+ "",
1513
+ "### Browserless shared-browser rule",
1514
+ "",
1515
+ "In JishuShell, Browserless is a shared interactive browser surface:",
1516
+ "- the agent opens and drives pages with the `browser` tool;",
1517
+ "- the user can take over the same Browserless session from the JishuShell panel's Browserless debugger;",
1518
+ "- login forms, captchas, permission prompts, cookie banners, MFA, and similar blockers are handoff points, not terminal failures.",
1519
+ "",
1520
+ "Follow these rules whenever you use the `browser` tool:",
1521
+ "",
1522
+ "1. If `browser status` or `browser doctor` reports `profile = \"browserless\"` / `browserless via cdp`, keep subsequent page-opening actions on Browserless.",
1523
+ "2. For ordinary website opening, prefer omitting `profile` entirely so the configured default can apply.",
1524
+ "3. If you must set a profile explicitly, use `profile: \"browserless\"` unless the user explicitly asked for a different named profile.",
1525
+ "4. Do not switch to `profile: \"openclaw\"` just because the target site may need login. Browserless is the login-capable path in this setup.",
1526
+ "5. If the user explicitly asks to open a browser, says \"I will log in\", \"let me handle it\", or wants to clear a captcha / permission prompt themselves, do not stop at `browser.status`. After the health check, call `browser.open` on the requested site, or `about:blank` if no site was given, so a live Browserless session exists for takeover.",
1527
+ "6. After opening the page, explicitly tell the user to continue in the Browserless debugger / panel and wait for them. The expected workflow is open -> handoff -> user acts -> agent resumes.",
1528
+ "7. Do not claim that `attachOnly`, `headless`, or the lack of a local OS window means the user cannot interact. In this setup the visual surface is the Browserless debugger in JishuShell.",
1529
+ "8. If login, captcha, cookie consent, permissions, MFA, or payment confirmation appears, keep the Browserless session alive and hand control to the user instead of abandoning the task.",
1530
+ "9. If Browserless status is healthy but a later `browser.open` with `profile: \"openclaw\"` would search for a local browser executable, that is the wrong choice for this instance.",
1531
+ "10. If `browser.open` fails with `browser endpoint blocked by policy`, immediately tell the user the blocked hostname, that the block happened before Browserless, where to unblock it in Panel -> this instance -> Browser Allowlist, and ask the user to tell you after whitelisting so you can retry. Do not silently fall back to web_fetch / web_search before delivering that notice.",
1532
+ "11. If `browser.open` succeeds but the page/status/body shows a target-site anti-bot / WAF / verification block, for example `whaleguard block`, `HTTP 432`, `403`, `captcha`, `verify`, or a blank page saying it was blocked, do not tell the user to add the host to the Browser Allowlist. The site was reached and then rejected the browser/session.",
1533
+ "12. For Ctrip / WhaleGuard specifically, do not keep retrying the blocked deep link such as `flights.ctrip.com/online/list/...`. Open `https://www.ctrip.com/` first, keep the Browserless session alive, ask the user to take over in the Browserless debugger to log in / pass verification / perform the search manually, and wait.",
1534
+ "13. Do not claim that a live page/session is ready for takeover unless `browser.open` actually succeeded. A healthy Browserless status alone is not proof that the user already has a visible page to interact with.",
1535
+ "",
1536
+ JISHUSHELL_BROWSERLESS_HINT_END,
1537
+ "",
1538
+ ].join("\n");
1539
+ const sep = stripped && !stripped.endsWith("\n") ? "\n\n" : "\n";
1540
+ next = (stripped ? stripped + sep : "") + section;
1541
+ }
1542
+ if (next === original)
1543
+ return;
1544
+ writeConfigFile(toolsPath, next);
1545
+ console.log(`[openclaw] ${mode === "remove" ? "Removed" : "Patched"} browserless hint in ${toolsPath}`);
1546
+ }
1547
+ catch (e) {
1548
+ console.warn(`[openclaw] Failed to ${mode} TOOLS.md browserless hint: ${e.message}`);
1549
+ }
1550
+ }
1551
+ export function resolveKbProvider(kbBinding) {
1552
+ const LEGACY_PROVIDER_ANYLLM = "anythingllm-container";
1553
+ const LEGACY_PROVIDER_JISHUKB = "jishu-kb-container";
1554
+ const capabilityToTag = (capability) => {
1555
+ if (capability === "knowledge-jishukb")
1556
+ return "jishukb";
1557
+ if (capability === "knowledge-anythingllm")
1558
+ return "anythingllm";
1559
+ return null;
1560
+ };
1561
+ const legacyProviderIdToTag = (providerId) => {
1562
+ if (providerId === LEGACY_PROVIDER_JISHUKB)
1563
+ return "jishukb";
1564
+ if (providerId === LEGACY_PROVIDER_ANYLLM)
1565
+ return "anythingllm";
1566
+ return null;
1567
+ };
1568
+ const entryToTag = (entry) => {
1569
+ if (!entry || typeof entry !== "object")
1570
+ return null;
1571
+ // Canonical connection bindings store the provider instance id in
1572
+ // providerId and the concrete provider kind in capability. The provider
1573
+ // instance id is user-controlled (`jishu-kb`, `my-kb`, ...), so runtime
1574
+ // wiring must key off capability, not template/provider-id strings.
1575
+ return capabilityToTag(entry.capability) ?? legacyProviderIdToTag(entry.providerId);
1576
+ };
1577
+ if (kbBinding === null)
1578
+ return null;
1579
+ if (kbBinding && typeof kbBinding === "object") {
1580
+ const b = kbBinding;
1581
+ if (b.kind === "single") {
1582
+ return entryToTag(b);
1583
+ }
1584
+ if (b.kind === "many") {
1585
+ // User selected the "many" mode but the providers array is malformed
1586
+ // or empty → treat as "no known provider bound", same as a list of
1587
+ // only-unknown providers. Avoids the surprise where a malformed
1588
+ // array silently falls back to legacy auto-anythingllm.
1589
+ if (!Array.isArray(b.providers))
1590
+ return null;
1591
+ // First known match in the user's order wins — the UI lets users
1592
+ // drag to reorder; we honor that order rather than imposing our own.
1593
+ for (const p of b.providers) {
1594
+ const tag = entryToTag(p);
1595
+ if (tag !== null)
1596
+ return tag;
1597
+ }
1598
+ return null;
1599
+ }
1600
+ return null;
1601
+ }
1602
+ return null;
1603
+ }
1604
+ function providerCredentialsPath(providerId) {
1605
+ return join(JISHUSHELL_HOME, "provider-credentials", providerId, "credentials.json");
1606
+ }
1607
+ function legacyProviderCredentialsPath(providerId) {
1608
+ return join(JISHUSHELL_HOME, "apps", providerId, "credentials.json");
1609
+ }
1610
+ function cleanupEmptyLegacyProviderDir(providerId) {
1611
+ const dir = join(JISHUSHELL_HOME, "apps", providerId);
1612
+ try {
1613
+ if (existsSync(dir) && readdirSync(dir).length === 0) {
1614
+ rmSync(dir, { recursive: false, force: true });
1615
+ }
1616
+ }
1617
+ catch {
1618
+ /* best effort */
1619
+ }
1620
+ }
1621
+ function resolveProviderCredentialsPath(providerId) {
1622
+ const nextPath = providerCredentialsPath(providerId);
1623
+ if (existsSync(nextPath))
1624
+ return nextPath;
1625
+ const legacyPath = legacyProviderCredentialsPath(providerId);
1626
+ if (!existsSync(legacyPath))
1627
+ return nextPath;
1628
+ try {
1629
+ ensureDirHost(dirname(nextPath));
1630
+ renameSync(legacyPath, nextPath);
1631
+ cleanupEmptyLegacyProviderDir(providerId);
1632
+ console.log(`[openclaw] migrated ${providerId} credentials to ${nextPath}`);
1633
+ return nextPath;
1634
+ }
1635
+ catch (error) {
1636
+ console.warn(`[openclaw] failed to migrate ${providerId} credentials from legacy apps/ path:`, error?.message ?? error);
1637
+ return legacyPath;
1638
+ }
1639
+ }
1640
+ export async function resolveJishukbDefaultKbIdForOpenClaw(baseUrl, configuredKbId) {
1641
+ const kbId = typeof configuredKbId === "string" ? configuredKbId.trim() : "";
1642
+ if (kbId && kbId !== "default")
1643
+ return kbId;
1644
+ try {
1645
+ const { ensureDefaultKb } = await import("../jishukb/integration.js");
1646
+ await ensureDefaultKb(baseUrl);
1647
+ return "default";
1648
+ }
1649
+ catch (error) {
1650
+ console.warn(`[openclaw] kb: jishu-kb default KB is not usable; wiring without a default kbId: ` +
1651
+ `${error?.message ?? error}`);
1652
+ return "";
1653
+ }
1654
+ }
1655
+ /**
1656
+ * Per-provider kb-shim residue cleanup. Wipes the shim source (replacing
1657
+ * the bytes with a removal marker rather than `unlink`-ing — the latter
1658
+ * would race with a concurrent `node <shim>` that already opened it) and
1659
+ * `unlink`s the sibling `secret.json` if any. Idempotent and safe to call
1660
+ * even if no shim was ever installed.
1661
+ *
1662
+ * Called by EVERY branch of the kb auto-wire block so a rebind from
1663
+ * anythingllm ↔ jishukb (or → null) never leaves stale shim files or
1664
+ * 0o600 secrets on disk. The "wipe by overwrite" pattern matches what
1665
+ * the old anythingllm-only branch did before the dispatch refactor.
1666
+ *
1667
+ * integrationHome is the OpenClaw container's `$HOME` (the value returned by
1668
+ * `openclawIntegration.resolveAgentHome(instanceId)`). `which` selects the
1669
+ * provider: each gets its own `__mcp_shims__/<which>/` subtree.
1670
+ *
1671
+ * Exported so the security-critical secret-deletion behavior can be
1672
+ * covered by a focused unit test without standing up the full start hook.
1673
+ */
1674
+ export function wipeKbShimDir(integrationHome, which) {
1675
+ const dir = join(integrationHome, "__mcp_shims__", which);
1676
+ const shimPath = join(dir, `${which}-shim.js`);
1677
+ const removalMarker = which === "anythingllm"
1678
+ ? "// removed: AnythingLLM not bound as knowledge provider\n"
1679
+ : "// removed: jishu-kb not bound as knowledge provider\n";
1680
+ try {
1681
+ if (existsSync(shimPath)) {
1682
+ writeFileSync(shimPath, removalMarker, { mode: 0o644 });
1683
+ }
1684
+ }
1685
+ catch { /* best effort */ }
1686
+ // AnythingLLM's shim has a sibling 0o600 secret.json (API key). v1
1687
+ // jishu-kb ships without auth so no secret to wipe — when jishu-kb
1688
+ // adds JISHU_KB_AUTH_TOKEN_FILE we'll start writing a secret.json
1689
+ // here too and the unlink must be added below.
1690
+ if (which === "anythingllm") {
1691
+ const secretPath = join(dir, "secret.json");
1692
+ try {
1693
+ if (existsSync(secretPath))
1694
+ unlinkSync(secretPath);
1695
+ }
1696
+ catch { /* best effort */ }
1697
+ }
1698
+ }
1699
+ export function patchToolsMdKbHint(workspaceDir, mode, provider, mcporterCommand = "mcporter", instanceId, mediaInboundRoot) {
1700
+ try {
1701
+ const toolsPath = join(workspaceDir, "TOOLS.md");
1702
+ let original = "";
1703
+ try {
1704
+ original = readFileSync(toolsPath, "utf-8");
1705
+ }
1706
+ catch (e) {
1707
+ if (e?.code !== "ENOENT")
1708
+ throw e;
1709
+ if (mode === "remove")
1710
+ return; // nothing to strip
1711
+ }
1712
+ // Strip every existing kb section first — tolerant of legacy variants
1713
+ // (e.g. early manual injections that used "END auto-generated -->"
1714
+ // instead of the current "END -->" marker). Without this, repeated
1715
+ // re-patches would accumulate sections in TOOLS.md.
1716
+ const STRIP_RE = /\n*<!-- jishushell-kb: BEGIN[^>]*-->[\s\S]*?<!-- jishushell-kb: END[^>]*-->\n*/g;
1717
+ const stripped = original.replace(STRIP_RE, "\n");
1718
+ let next;
1719
+ if (mode === "remove") {
1720
+ if (stripped === original)
1721
+ return;
1722
+ next = stripped;
1723
+ }
1724
+ else {
1725
+ if (!provider) {
1726
+ throw new Error("provider is required when installing KB hint");
1727
+ }
1728
+ const cli = mcporterCommand === "mcporter" ? "mcporter" : JSON.stringify(mcporterCommand);
1729
+ const generatedOutboxPath = instanceId
1730
+ ? `agent-data/${instanceId}/outbox/report.md`
1731
+ : "agent-data/<instance>/outbox/report.md";
1732
+ const attachmentInboxPath = mediaInboundRoot || "<openclawHome>/.openclaw/media/inbound";
1733
+ const section = provider === "jishukb"
1734
+ ? [
1735
+ JISHUSHELL_KB_HINT_BEGIN,
1736
+ "",
1737
+ "### 📚 知识库(JishuShell-KB)",
1738
+ "",
1739
+ "用户长期投递并已经导入到 **JishuShell-KB** 的文档(手册、PDF、内部笔记、会议纪要等)可以检索;你也可以列知识库、创建知识库、把 drive 文件上传入库、查看已索引文档、查看 handbook、读取**脱敏后的**当前配置,以及在用户明确确认时删除文档/知识库。",
1740
+ "",
1741
+ "**当前 provider 暴露的工具**:",
1742
+ "",
1743
+ `- \`${cli} call kb.kb_list\` — 列出所有知识库(拿 id / name / chunks 数)`,
1744
+ `- \`${cli} call kb.kb_create name="产品文档" description="可选"\` — 新建知识库`,
1745
+ `- \`${cli} call kb.kb_search query="<用户原话>" kbId=<可选> topK=<可选>\` — 检索指定或默认知识库`,
1746
+ `- \`${cli} call kb.kb_upload path="<drive_resolve_local_path 返回的绝对路径>" kbId="<目标知识库 id>"\` — 上传并索引文件到指定知识库`,
1747
+ `- \`${cli} call kb.kb_list_documents kbId=<可选>\` — 列出指定或默认知识库里的已索引文档`,
1748
+ `- \`${cli} call kb.kb_read_handbook section="设置 → 知识库"\` — 读取 handbook 全文或指定章节`,
1749
+ `- \`${cli} call kb.kb_get_config\` — 读取当前**脱敏后的**知识库配置摘要`,
1750
+ `- \`${cli} call kb.kb_delete_document kbId="<知识库 id>" documentId="<文档 id>" confirmDocumentId="<同一个文档 id>"\` — 删除文档(危险操作,必须显式确认)`,
1751
+ `- \`${cli} call kb.kb_delete_kb kbId="<知识库 id>" confirmKbId="<同一个知识库 id>"\` — 删除知识库(危险操作,必须显式确认)`,
1752
+ "",
1753
+ "**推荐调用顺序**:",
1754
+ "1. 用户提到“某个指定知识库 / 某个库里”但你不知道 id → 先 `kb_list`。",
1755
+ "2. 用户要把 drive 里的文件加入知识库 → 先 `drive_resolve_local_path`,再 `kb_upload path=<abs_path> kbId=<显式 id>`。",
1756
+ `3. 用户当前消息已经附了文件,而且消息里给了宿主机绝对路径(通常在 \`${attachmentInboxPath}/...\`)→ 直接把这个绝对路径传给 \`kb_upload\`;不要先把内容重写到 \`files/\` 根目录,也不要自己猜 \`agent-data/agent1/...\` 这种路径。`,
1757
+ `4. 用户要上传你**新生成**的文件 → 先 \`drive_write_text\` / \`drive_write_binary\` 到 \`${generatedOutboxPath}\`,再 \`drive_resolve_local_path\` → \`kb_upload\`。`,
1758
+ "5. 用户要新建库并马上上传 → `kb_create` → 记住返回的 id → `kb_upload`。",
1759
+ "6. 用户要解释某个设置项怎么用 → 先 `kb_read_handbook`,必要时再 `kb_get_config` 看当前值。",
1760
+ "",
1761
+ `**安全规则**:写操作和删除操作不要猜目标知识库;拿不准就先 \`kb_list\`。删除必须是用户明确要求,且把 confirm 字段原样填成同一个 id。 \`kb_get_config\` 只返回脱敏摘要,不会给你密钥。 \`kb_upload\` 只接受来自当前实例已挂载文件目录,或当前实例附件 inbox(\`${attachmentInboxPath}/...\`)的绝对路径。**`,
1762
+ "",
1763
+ "**与 drive 的分工**:",
1764
+ "- `drive.*` = 文件系统 facade(列目录、读字节、拿绝对路径)—— 要的是**文件本体**用 drive",
1765
+ "- `kb.*` = 知识库检索/管理/上传 —— 要的是**知识库里的内容和状态**用 kb",
1766
+ "",
1767
+ "两者数据不共享:drive 里有文件 ≠ 某个知识库已经索引了它。",
1768
+ "",
1769
+ "**搜不到时的标准回复**:如果 `kb_search` 没结果,就直接说「我在当前知识库里没找到相关内容」。如果用户问的是 drive 里已有文件,可进一步建议「要我把它上传到某个知识库吗?」—— 但上传前先确认目标 kbId,不要自己猜默认库。",
1770
+ "",
1771
+ JISHUSHELL_KB_HINT_END,
1772
+ "",
1773
+ ].join("\n")
1774
+ : [
1775
+ JISHUSHELL_KB_HINT_BEGIN,
1776
+ "",
1777
+ "### 📚 知识库(AnythingLLM)",
1778
+ "",
1779
+ "用户长期投递的文档(手册、PDF、内部笔记、过往会议纪要等)由 **AnythingLLM** 维护索引(本地 LanceDB 向量库 + 内置 Xenova ONNX embedder),通过 `kb.kb_search` 一次调用拿「答案 + 引用来源」。",
1780
+ "",
1781
+ "**两个工具**:",
1782
+ "",
1783
+ `- \`${cli} call kb.kb_search query="<用户原话>"\` — 在已索引文档里检索,返回答案 + 最多 5 条引用源`,
1784
+ `- \`${cli} call kb.kb_ingest path="<绝对路径>"\` — 把 drive 里的文件加入知识库并 embed(用户说「加进知识库 / index this / 学习这份」时调)`,
1785
+ "",
1786
+ "**ingest 标准链**(drive 里的文件 → 知识库):",
1787
+ `1. \`${cli} call drive.drive_resolve_local_path path=inbox/contract.pdf\` → 拿 \`abs_path\``,
1788
+ `2. \`${cli} call kb.kb_ingest path=<abs_path>\` → AnythingLLM 自动 embed`,
1789
+ "3. 几秒后用户问相关问题,`kb_search` 命中",
1790
+ "",
1791
+ "**search 什么时候调**:用户问的东西像在已上传文档里能找到——「那个 X 的手册里怎么说」、「我们之前关于 Y 的讨论」、「产品规格」、「合同条款」、「what does the doc say about X」等。",
1792
+ "",
1793
+ "**什么时候不要调**:寒暄、纯代码生成、数学计算、实时信息(天气/股票/新闻)、**操作 NAS 文件**(那是 `drive.*`,不是 kb)、纯创作类。",
1794
+ "",
1795
+ "**与 drive 的分工**:",
1796
+ "- `drive.*` = 文件系统 facade(列目录、读字节、发文件)—— 要的是**文件本体**用 drive",
1797
+ "- `kb.kb_search` / `kb.kb_ingest` = 语义检索 + RAG 入库 —— 要的是**答案/知识**用 kb",
1798
+ "",
1799
+ "两者数据**不共享**:drive 看到 `manual.pdf` ≠ kb 一定能搜到它。要让 kb 能搜到 → 先 `kb_ingest`。",
1800
+ "",
1801
+ "**搜不到时的标准回复**:`kb_search` 回答里说「无相关文档」或 sources 为空 → 先确认 drive 里有没有相关文件,如果有,主动建议「要我把它加入知识库吗」(用户同意就 `drive_resolve_local_path` + `kb_ingest`);drive 也没有,告诉用户「我在你的知识库里没找到相关内容」,然后**不要继续幻想答案**。",
1802
+ "",
1803
+ JISHUSHELL_KB_HINT_END,
1804
+ "",
1805
+ ].join("\n");
1806
+ const sep = stripped && !stripped.endsWith("\n") ? "\n\n" : "\n";
1807
+ next = (stripped ? stripped + sep : "") + section;
1808
+ }
1809
+ if (next === original)
1810
+ return;
1811
+ writeConfigFile(toolsPath, next);
1812
+ console.log(`[openclaw] ${mode === "remove" ? "Removed" : "Patched"} kb hint in ${toolsPath}`);
1813
+ }
1814
+ catch (e) {
1815
+ console.warn(`[openclaw] Failed to ${mode} TOOLS.md kb hint: ${e.message}`);
1816
+ }
1817
+ }
1818
+ /**
1819
+ * Pre-seed the per-instance npm global prefix with a symlink to the image's
1820
+ * baked openclaw package so OpenClaw's in-gateway "Update now" handler can
1821
+ * detect the install as an npm global install. Idempotent; docker driver only.
1822
+ */
1823
+ function ensureOpenclawUpdateSeed(openclawHome, instanceId) {
1824
+ if (getNomadDriver() !== "docker")
1825
+ return;
1826
+ if (!openclawHome)
1827
+ return;
1828
+ const linkDir = join(openclawHome, ".npm-global", "lib", "node_modules");
1829
+ const linkPath = join(linkDir, "openclaw");
1830
+ try {
1831
+ lstatSync(linkPath);
1832
+ return;
1833
+ }
1834
+ catch (err) {
1835
+ if (err?.code !== "ENOENT") {
1836
+ console.warn(`[openclaw] update-seed: lstat failed for ${linkPath}: ${err?.message ?? err}`);
1837
+ return;
1838
+ }
1839
+ }
1840
+ try {
1841
+ mkdirSync(linkDir, { recursive: true });
1842
+ symlinkSync(CONTAINER_IMAGE_PKG_ROOT, linkPath);
1843
+ console.log(`[openclaw] update-seed ${instanceId}: seeded ${linkPath} -> ${CONTAINER_IMAGE_PKG_ROOT}`);
1844
+ }
1845
+ catch (err) {
1846
+ console.warn(`[openclaw] update-seed ${instanceId}: failed to create seed: ${err?.message ?? err}`);
1847
+ }
1848
+ }
1849
+ // ── Session fence patch (OpenClaw >= 5.19 regression) ─────────────────
1850
+ /**
1851
+ * The minimum OpenClaw version where the session fence bug exists.
1852
+ * The bug was introduced in v2026.5.19 — `eventMayReachTranscriptWriters()`
1853
+ * doesn't recognize `"message"` / `"custom_message"` event types, causing
1854
+ * session writes to bypass `withSessionWriteLock`, which in turn leaves
1855
+ * the file fingerprint stale and triggers `EmbeddedAttemptSessionTakeoverError`
1856
+ * on the next prompt.
1857
+ *
1858
+ * Additionally, on virtiofs mounts (macOS → Colima VM → Docker), file
1859
+ * metadata (mtime/ctime) can drift between `releaseForPrompt()` and
1860
+ * `assertSessionFileFence()` even without actual writes, due to the
1861
+ * multi-layer filesystem stack timing. Patching `assertSessionFileFence`
1862
+ * to a no-op fully disables the flawed fence check.
1863
+ */
1864
+ const SESSION_FENCE_BUG_MIN_VERSION = [2026, 5, 19];
1865
+ /**
1866
+ * Maximum version (exclusive) to apply the patch. Once OpenClaw ships a fix
1867
+ * upstream, set a concrete version here to stop patching newer releases.
1868
+ * For now, no upper bound — patch all versions >= MIN.
1869
+ */
1870
+ /**
1871
+ * Safety limit: if the extracted function body exceeds this many characters,
1872
+ * skip the patch to avoid corrupting the bundle (e.g. brace-depth counter
1873
+ * fooled by string literals containing braces in a future refactored version).
1874
+ */
1875
+ const MAX_PATCH_TARGET_BODY_LENGTH = 5000;
1876
+ /**
1877
+ * Patch targets: each entry defines a function to replace.
1878
+ * - `eventMayReachTranscriptWriters`: broad return prevents events from
1879
+ * bypassing the write lock (necessary but not sufficient on virtiofs).
1880
+ * - `assertSessionFileFence`: no-op disables the fingerprint comparison
1881
+ * that false-triggers due to virtiofs stat drift.
1882
+ */
1883
+ const SESSION_FENCE_PATCH_TARGETS = [
1884
+ {
1885
+ fnName: "function assertSessionFileFence()",
1886
+ litNeedle: "sameSessionFileFingerprint",
1887
+ replacement: "function assertSessionFileFence() { return; }",
1888
+ },
1889
+ {
1890
+ fnName: "function eventMayReachTranscriptWriters",
1891
+ litNeedle: '"message_update"',
1892
+ replacement: 'function eventMayReachTranscriptWriters(session, event) { return typeof event?.type === "string"; }',
1893
+ },
1894
+ ];
1895
+ /**
1896
+ * Patch the session fence bug in OpenClaw >= 5.19 by replacing the
1897
+ * `eventMayReachTranscriptWriters` function in the minified bundle.
1898
+ *
1899
+ * Idempotent: uses a marker file containing the SHA-256 of the patched
1900
+ * file. Skips if already patched or if the pattern is not found (future
1901
+ * fixed version or different bundle layout).
1902
+ *
1903
+ * Docker-only: the bug manifests through the virtiofs mount timing
1904
+ * discrepancy between container and host — raw_exec/process modes are
1905
+ * unaffected in practice.
1906
+ */
1907
+ export function patchSessionFenceBug(openclawHome, instanceId) {
1908
+ if (getNomadDriver() !== "docker")
1909
+ return;
1910
+ // 1. Read installed version from npm-global package.json
1911
+ const pkgPath = join(openclawHome, ".npm-global", "lib", "node_modules", "openclaw", "package.json");
1912
+ let versionStr;
1913
+ try {
1914
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
1915
+ versionStr = pkg.version || "";
1916
+ }
1917
+ catch {
1918
+ return; // no npm-global install or unreadable — skip
1919
+ }
1920
+ // 2. Parse version and check minimum threshold
1921
+ const parts = versionStr.split(".").map(Number);
1922
+ if (parts.length < 3 || parts.some(Number.isNaN))
1923
+ return;
1924
+ const [major, minor, patch] = parts;
1925
+ const [minMajor, minMinor, minPatch] = SESSION_FENCE_BUG_MIN_VERSION;
1926
+ if (major < minMajor ||
1927
+ (major === minMajor && minor < minMinor) ||
1928
+ (major === minMajor && minor === minMinor && patch < minPatch)) {
1929
+ return; // version predates the bug
1930
+ }
1931
+ // 3. Find the selection-*.js bundle that contains the target function.
1932
+ // There may be multiple selection-*.js files in dist/; only one holds
1933
+ // the session management code.
1934
+ const distDir = join(openclawHome, ".npm-global", "lib", "node_modules", "openclaw", "dist");
1935
+ let bundleFiles;
1936
+ try {
1937
+ const entries = readdirSync(distDir);
1938
+ bundleFiles = entries.filter((f) => f.startsWith("selection-") && f.endsWith(".js"));
1939
+ }
1940
+ catch {
1941
+ return; // dist dir missing or unreadable
1942
+ }
1943
+ if (bundleFiles.length === 0)
1944
+ return;
1945
+ // Scan each candidate for any of the patch target signatures
1946
+ let bundlePath;
1947
+ let bundleContent;
1948
+ for (const file of bundleFiles) {
1949
+ const candidatePath = join(distDir, file);
1950
+ let content;
1951
+ try {
1952
+ content = readFileSync(candidatePath, "utf-8");
1953
+ }
1954
+ catch {
1955
+ continue;
1956
+ }
1957
+ // Match if any target's fnName or litNeedle is present
1958
+ const hasTarget = SESSION_FENCE_PATCH_TARGETS.some((t) => content.includes(t.fnName) || content.includes(t.litNeedle));
1959
+ if (hasTarget) {
1960
+ bundlePath = candidatePath;
1961
+ bundleContent = content;
1962
+ break;
1963
+ }
1964
+ }
1965
+ if (!bundlePath || !bundleContent)
1966
+ return;
1967
+ // 4. Check marker file for idempotency
1968
+ const markerPath = join(distDir, `.session-fence-patched`);
1969
+ const currentHash = createHash("sha256").update(bundleContent).digest("hex");
1970
+ try {
1971
+ const marker = readFileSync(markerPath, "utf-8").trim();
1972
+ if (marker === currentHash)
1973
+ return; // already patched, hash matches
1974
+ }
1975
+ catch {
1976
+ // marker missing — proceed
1977
+ }
1978
+ // 5. Apply each patch target using brace-depth counting to extract and
1979
+ // replace function bodies. Process targets in order; earlier patches
1980
+ // shift offsets so we re-search after each replacement.
1981
+ let patched = bundleContent;
1982
+ let patchCount = 0;
1983
+ for (const target of SESSION_FENCE_PATCH_TARGETS) {
1984
+ let fnStart = patched.indexOf(target.fnName);
1985
+ // Fallback for eventMayReachTranscriptWriters: locate by unique literal
1986
+ // combination ("message_update" near "message_end" and "agent_end")
1987
+ if (fnStart === -1 && target.litNeedle === '"message_update"') {
1988
+ let scanPos = 0;
1989
+ while (scanPos < patched.length) {
1990
+ const litIdx = patched.indexOf(target.litNeedle, scanPos);
1991
+ if (litIdx === -1)
1992
+ break;
1993
+ const window = patched.slice(litIdx, litIdx + 200);
1994
+ if (window.includes('"message_end"') && window.includes('"agent_end"')) {
1995
+ const searchStart = Math.max(0, litIdx - 300);
1996
+ const prefix = patched.slice(searchStart, litIdx);
1997
+ const fnKeywordIdx = prefix.lastIndexOf("function ");
1998
+ if (fnKeywordIdx !== -1) {
1999
+ fnStart = searchStart + fnKeywordIdx;
2000
+ break;
2001
+ }
2002
+ }
2003
+ scanPos = litIdx + 1;
2004
+ }
2005
+ }
2006
+ if (fnStart === -1)
2007
+ continue; // target not found (already patched or fixed version)
2008
+ // Check if already patched (replacement is short and contains `return;`)
2009
+ const peekEnd = Math.min(fnStart + target.replacement.length + 10, patched.length);
2010
+ const peek = patched.slice(fnStart, peekEnd);
2011
+ if (peek.startsWith(target.replacement))
2012
+ continue;
2013
+ // Extract function body with brace-depth counting
2014
+ const braceStart = patched.indexOf("{", fnStart);
2015
+ if (braceStart === -1)
2016
+ continue;
2017
+ let depth = 0;
2018
+ let fnEnd = -1;
2019
+ for (let i = braceStart; i < patched.length; i++) {
2020
+ if (patched[i] === "{")
2021
+ depth++;
2022
+ else if (patched[i] === "}") {
2023
+ depth--;
2024
+ if (depth === 0) {
2025
+ fnEnd = i + 1;
2026
+ break;
2027
+ }
2028
+ }
2029
+ }
2030
+ if (fnEnd === -1)
2031
+ continue;
2032
+ // Safety: if extracted body is suspiciously large, skip to avoid corrupting
2033
+ // the bundle (brace counter may have been fooled by string contents).
2034
+ if (fnEnd - fnStart > MAX_PATCH_TARGET_BODY_LENGTH) {
2035
+ console.warn(`[openclaw] session-fence-patch ${instanceId}: skipping ${target.fnName} — body too large (${fnEnd - fnStart} chars)`);
2036
+ continue;
2037
+ }
2038
+ patched = patched.slice(0, fnStart) + target.replacement + patched.slice(fnEnd);
2039
+ patchCount++;
2040
+ }
2041
+ if (patchCount === 0) {
2042
+ // No targets needed patching — write marker for current state
2043
+ try {
2044
+ writeFileSync(markerPath, currentHash + "\n", "utf-8");
2045
+ }
2046
+ catch {
2047
+ /* best effort */
2048
+ }
2049
+ return;
2050
+ }
2051
+ // 7. Atomic write: temp file → rename
2052
+ const tmpPath = bundlePath + `.tmp.${randomBytes(4).toString("hex")}`;
2053
+ try {
2054
+ writeFileSync(tmpPath, patched, "utf-8");
2055
+ renameSync(tmpPath, bundlePath);
2056
+ }
2057
+ catch (err) {
2058
+ // Clean up temp file on failure
2059
+ try {
2060
+ unlinkSync(tmpPath);
2061
+ }
2062
+ catch {
2063
+ /* ignore */
2064
+ }
2065
+ console.warn(`[openclaw] session-fence-patch ${instanceId}: atomic write failed: ${err?.message ?? err}`);
2066
+ return;
2067
+ }
2068
+ // 8. Write marker with hash of the PATCHED file
2069
+ const patchedHash = createHash("sha256").update(patched).digest("hex");
2070
+ try {
2071
+ writeFileSync(markerPath, patchedHash + "\n", "utf-8");
2072
+ }
2073
+ catch {
2074
+ // Non-fatal — patch was applied, marker just helps idempotency
2075
+ }
2076
+ console.log(`[openclaw] session-fence-patch ${instanceId}: patched ${bundlePath.split("/").pop()} (v${versionStr})`);
2077
+ }
2078
+ // ── Container-side patch script ───────────────────────────────────────────
2079
+ /**
2080
+ * Self-contained Node.js script that patches the session fence bug from
2081
+ * INSIDE the container. Written to `$OPENCLAW_HOME/.jishushell/session-fence-patch.mjs`
2082
+ * by onBeforeStart and executed by the inline Docker entrypoint before the
2083
+ * OpenClaw gateway starts.
2084
+ *
2085
+ * This covers the case where an in-container `npm install openclaw@latest`
2086
+ * upgrades to a buggy version (>= 5.19) after the container was created
2087
+ * with a clean image (5.7). The host-side `patchSessionFenceBug` cannot
2088
+ * patch at onBeforeStart time because the npm-global directory may not yet
2089
+ * contain the upgraded bundle (it's a dangling symlink to a container-only path).
2090
+ */
2091
+ const CONTAINER_PATCH_SCRIPT = `#!/usr/bin/env node
2092
+ // Session fence patch — auto-generated by JishuShell.
2093
+ // Patches assertSessionFileFence + eventMayReachTranscriptWriters
2094
+ // in OpenClaw >= 2026.5.19 to work around virtiofs stat drift.
2095
+ import { readFileSync, writeFileSync, readdirSync, renameSync, existsSync } from "fs";
2096
+ import { join } from "path";
2097
+ import { createHash } from "crypto";
2098
+
2099
+ const home = process.env.HOME || process.env.OPENCLAW_HOME || "/home/openclaw";
2100
+ const distDir = join(home, ".npm-global", "lib", "node_modules", "openclaw", "dist");
2101
+ const pkgPath = join(home, ".npm-global", "lib", "node_modules", "openclaw", "package.json");
2102
+
2103
+ try {
2104
+ const pkg = JSON.parse(readFileSync(pkgPath, "utf-8"));
2105
+ const parts = (pkg.version || "").split(".").map(Number);
2106
+ if (parts.length < 3 || parts[0] < 2026 || (parts[0] === 2026 && parts[1] < 5) ||
2107
+ (parts[0] === 2026 && parts[1] === 5 && parts[2] < 19)) process.exit(0);
2108
+ // No upper version cap for now — patch all versions >= 5.19
2109
+ } catch { process.exit(0); }
2110
+
2111
+ const markerPath = join(distDir, ".session-fence-patched");
2112
+ let files;
2113
+ try { files = readdirSync(distDir).filter(f => f.startsWith("selection-") && f.endsWith(".js")); }
2114
+ catch { process.exit(0); }
2115
+
2116
+ const targets = [
2117
+ { fn: "function assertSessionFileFence()", repl: "function assertSessionFileFence() { return; }" },
2118
+ { fn: "function eventMayReachTranscriptWriters", repl: 'function eventMayReachTranscriptWriters(session, event) { return typeof event?.type === "string"; }' },
2119
+ ];
2120
+
2121
+ for (const file of files) {
2122
+ const p = join(distDir, file);
2123
+ let src;
2124
+ try { src = readFileSync(p, "utf-8"); } catch { continue; }
2125
+ if (!targets.some(t => src.includes(t.fn) || src.includes("sameSessionFileFingerprint"))) continue;
2126
+
2127
+ const hash = createHash("sha256").update(src).digest("hex");
2128
+ try { if (readFileSync(markerPath, "utf-8").trim() === hash) process.exit(0); } catch {}
2129
+
2130
+ let modified = src;
2131
+ let count = 0;
2132
+ for (const t of targets) {
2133
+ const idx = modified.indexOf(t.fn);
2134
+ if (idx === -1) continue;
2135
+ if (modified.slice(idx, idx + t.repl.length + 5).startsWith(t.repl)) continue;
2136
+ const braceStart = modified.indexOf("{", idx);
2137
+ if (braceStart === -1) continue;
2138
+ let d = 0, end = -1;
2139
+ for (let i = braceStart; i < modified.length; i++) {
2140
+ if (modified[i] === "{") d++;
2141
+ else if (modified[i] === "}") { d--; if (d === 0) { end = i + 1; break; } }
2142
+ }
2143
+ if (end === -1) continue;
2144
+ if (end - idx > 5000) continue; // safety: skip if body suspiciously large
2145
+ modified = modified.slice(0, idx) + t.repl + modified.slice(end);
2146
+ count++;
2147
+ }
2148
+ if (count === 0) {
2149
+ try { writeFileSync(markerPath, hash + "\\n"); } catch {}
2150
+ process.exit(0);
2151
+ }
2152
+ const tmp = p + ".tmp." + Math.random().toString(36).slice(2, 8);
2153
+ writeFileSync(tmp, modified);
2154
+ renameSync(tmp, p);
2155
+ const newHash = createHash("sha256").update(modified).digest("hex");
2156
+ try { writeFileSync(markerPath, newHash + "\\n"); } catch {}
2157
+ console.log("[session-fence-patch] patched " + file);
2158
+ break;
2159
+ }
2160
+ `;
2161
+ const CONTAINER_PATCH_ENTRYPOINT_COMMAND = 'node "$HOME/.jishushell/session-fence-patch.mjs" 2>/dev/null || true; exec /usr/local/bin/openclaw-entry.sh "$@"';
2162
+ /**
2163
+ * Write the container-side patch script to the openclaw-home directory so it
2164
+ * is available inside the container via the bind mount.
2165
+ *
2166
+ * Called from onBeforeStart. Idempotent — only rewrites if content changed.
2167
+ */
2168
+ export function writeContainerPatchScript(openclawHome) {
2169
+ const scriptDir = join(openclawHome, ".jishushell");
2170
+ try {
2171
+ ensureDirContainer(scriptDir);
2172
+ }
2173
+ catch (err) {
2174
+ console.warn(`[openclaw] Failed to prepare container patch directory ${scriptDir}: ${err?.message ?? err}`);
2175
+ return;
2176
+ }
2177
+ const scriptPath = join(scriptDir, "session-fence-patch.mjs");
2178
+ ensureReadableContent(scriptPath, CONTAINER_PATCH_SCRIPT);
2179
+ }
2180
+ function ensureReadableContent(path, content) {
2181
+ try {
2182
+ if (existsSync(path) && readFileSync(path, "utf-8") === content) {
2183
+ chmodSync(path, 0o644);
2184
+ return;
2185
+ }
2186
+ writeConfigFile(path, content);
2187
+ }
2188
+ catch (err) {
2189
+ console.warn(`[openclaw] Failed to write patch script ${path}: ${err?.message ?? err}`);
2190
+ }
2191
+ }
2192
+ function resolveUidGid(username) {
2193
+ try {
2194
+ if (!VALID_USER_RE.test(username)) {
2195
+ console.warn(`[openclaw] Invalid username for UID lookup: ${username}`);
2196
+ return `${process.getuid()}:${process.getgid()}`;
2197
+ }
2198
+ const passwd = readFileSync("/etc/passwd", "utf-8");
2199
+ const line = passwd.split("\n").find((l) => l.startsWith(username + ":"));
2200
+ if (line) {
2201
+ const parts = line.split(":");
2202
+ const uid = parseInt(parts[2], 10);
2203
+ const gid = parseInt(parts[3], 10);
2204
+ if (!isNaN(uid) && !isNaN(gid))
2205
+ return `${uid}:${gid}`;
2206
+ }
2207
+ }
2208
+ catch {
2209
+ /* ignore */
2210
+ }
2211
+ return `${process.getuid()}:${process.getgid()}`;
2212
+ }
2213
+ // Host peripheral device nodes worth passing into a privileged OpenClaw
2214
+ // container so the agent reaches cameras / GPU / audio like a native install.
2215
+ // Directory roots are fully expanded; the prefixes match numbered top-level
2216
+ // nodes (e.g. /dev/video0, /dev/media1, /dev/mali0).
2217
+ const PERIPHERAL_DEV_ROOTS = ["/dev/dri", "/dev/snd"];
2218
+ const PERIPHERAL_DEV_PREFIXES = ["/dev/video", "/dev/media", "/dev/v4l-subdev", "/dev/mali", "/dev/dma_heap"];
2219
+ // Raw-disk / kernel-memory / device-mapper nodes that must NEVER be passed
2220
+ // into a container, even if a hand-edited `runtime.devices` entry — or a
2221
+ // symlink sitting under a peripheral prefix (e.g. /dev/videoX -> /dev/sda) —
2222
+ // resolves to one. Peripheral passthrough must not silently become raw host
2223
+ // disk or physical-memory access. Prefix match (anchored at /dev/) so
2224
+ // partitions like /dev/sda1 and /dev/nvme0n1p2 are covered too.
2225
+ const FORBIDDEN_DEVICE_RE = /^\/dev\/(mem|kmem|kmsg|port|sd[a-z]|hd[a-z]|vd[a-z]|nvme\d|mmcblk\d|sr\d|md\d|loop\d|dm-\d|mapper\/|disk\/|block\/)/;
2226
+ /**
2227
+ * Enumerate the host's media/accelerator device nodes (plus any explicit
2228
+ * extras from `runtime.devices`) so a privileged container can open them.
2229
+ * Returns docker `devices` entries (real, symlink-resolved paths, deduped)
2230
+ * and the set of owning group gids — the (non-root) container user is added
2231
+ * to those gids via `group_add` so the 0660 root:video / root:render /
2232
+ * root:audio nodes are actually accessible inside the container. Missing
2233
+ * nodes are skipped, so this is a no-op on hosts without such hardware.
2234
+ */
2235
+ function collectPrivilegedDevices(extraPaths = []) {
2236
+ const candidates = new Set(extraPaths);
2237
+ for (const root of PERIPHERAL_DEV_ROOTS) {
2238
+ try {
2239
+ for (const name of readdirSync(root))
2240
+ candidates.add(`${root}/${name}`);
2241
+ }
2242
+ catch { /* root absent on this host */ }
2243
+ }
2244
+ try {
2245
+ for (const name of readdirSync("/dev")) {
2246
+ const full = `/dev/${name}`;
2247
+ if (PERIPHERAL_DEV_PREFIXES.some((p) => full.startsWith(p)))
2248
+ candidates.add(full);
2249
+ }
2250
+ }
2251
+ catch { /* /dev unreadable (non-Linux) */ }
2252
+ const devices = [];
2253
+ const gids = new Set();
2254
+ const seen = new Set();
2255
+ for (const path of candidates) {
2256
+ let real;
2257
+ try {
2258
+ real = realpathSync(path);
2259
+ }
2260
+ catch {
2261
+ continue;
2262
+ }
2263
+ if (seen.has(real))
2264
+ continue;
2265
+ seen.add(real);
2266
+ // Defense-in-depth: only ever expose real /dev nodes, and never raw
2267
+ // disk / memory / device-mapper targets — applies to auto-discovered
2268
+ // nodes (catches a malicious symlink under a peripheral prefix) and to
2269
+ // explicit runtime.devices entries alike.
2270
+ if (!real.startsWith("/dev/") || FORBIDDEN_DEVICE_RE.test(real)) {
2271
+ console.warn(`[openclaw] refusing device passthrough "${path}" -> "${real}" (outside /dev or on denylist)`);
2272
+ continue;
2273
+ }
2274
+ let st;
2275
+ try {
2276
+ st = statSync(real);
2277
+ }
2278
+ catch {
2279
+ continue;
2280
+ }
2281
+ if (!st.isCharacterDevice() && !st.isBlockDevice())
2282
+ continue;
2283
+ devices.push({ host_path: real, container_path: real, cgroup_permissions: "rw" });
2284
+ if (typeof st.gid === "number" && st.gid > 0)
2285
+ gids.add(st.gid);
2286
+ }
2287
+ return { devices, groupAdd: [...gids].map(String) };
2288
+ }
2289
+ // ── Nomad template safety (migrated from the runtime driver) ──────────
2290
+ const NOMAD_TEMPLATE_UNSAFE_RE = /[{}"\\]/;
2291
+ function assertSafeTemplateId(id) {
2292
+ if (NOMAD_TEMPLATE_UNSAFE_RE.test(id)) {
2293
+ throw new Error(`Job ID "${id}" contains characters unsafe for Nomad Template interpolation`);
2294
+ }
2295
+ }
2296
+ // ── Lazy-imported framework helpers (avoid circular deps) ─────────────
2297
+ //
2298
+ // The integration reaches back into instance-manager.ts for helpers that still
2299
+ // live there. Using lazy `await import()` keeps the static import graph
2300
+ // acyclic, so integrations/index.ts -> integrations/openclaw/integration.ts loads cleanly before
2301
+ // instance-manager.ts needs it.
2302
+ async function lazyIm() {
2303
+ return await import("../../instances/manager.js");
2304
+ }
2305
+ // ── Docker image build helpers (physically migrated from setup-manager) ─
2306
+ //
2307
+ // All OpenClaw-specific docker image build knowledge lives here. setup-manager
2308
+ // only retains a thin dispatch wrapper so the public
2309
+ // `buildSlimOpenclawImage()` / `startBuildSlimOpenclawImage()` API remains
2310
+ // back-compatible for routes/setup.ts and the CLI installer.
2311
+ /** Matches a semver-ish tag suffix, e.g. "...:2026.4.9" or "...:v1.2.3-beta". */
2312
+ const PINNED_IMAGE_TAG_RE = /:[0-9]+\.[0-9]+\.[0-9]+(-[A-Za-z0-9.-]+)?$/;
2313
+ /**
2314
+ * Query the npm registry for the current OpenClaw version. Used to bust the
2315
+ * Docker layer cache for `RUN npm install openclaw@${ver}` during local build.
2316
+ */
2317
+ function resolveOpenclawNpmVersion() {
2318
+ try {
2319
+ const out = execFileSync("npm", ["view", "openclaw", "version"], {
2320
+ timeout: 15000,
2321
+ encoding: "utf-8",
2322
+ stdio: ["ignore", "pipe", "ignore"],
2323
+ }).trim();
2324
+ if (/^\d+\.\d+\.\d+/.test(out))
2325
+ return out;
2326
+ }
2327
+ catch {
2328
+ /* npm not reachable */
2329
+ }
2330
+ return "latest";
2331
+ }
2332
+ /**
2333
+ * Read the OpenClaw version bundled at /app/ inside a Docker image.
2334
+ */
2335
+ function readBundledOpenclawVersion(invocation, image) {
2336
+ try {
2337
+ const out = execFileSync(invocation.cmd, [
2338
+ ...invocation.argsPrefix,
2339
+ "run",
2340
+ "--rm",
2341
+ "--entrypoint",
2342
+ "node",
2343
+ image,
2344
+ "-p",
2345
+ "require('/app/node_modules/openclaw/package.json').version",
2346
+ ], { timeout: 20000, encoding: "utf-8", stdio: ["ignore", "pipe", "ignore"] }).trim();
2347
+ if (/^\d+\.\d+\.\d+/.test(out))
2348
+ return out;
2349
+ }
2350
+ catch {
2351
+ /* docker unavailable, image missing, or path not present */
2352
+ }
2353
+ return "";
2354
+ }
2355
+ /**
2356
+ * Add a pinned version alias for an image, then drop the mutable :latest /
2357
+ * :slim tag. See original setup-manager commentary for details.
2358
+ */
2359
+ function capturePinnedImageTag(invocation, targetTag, explicitVersion) {
2360
+ if (PINNED_IMAGE_TAG_RE.test(targetTag))
2361
+ return targetTag;
2362
+ let version = explicitVersion && /^\d+\.\d+\.\d+/.test(explicitVersion) ? explicitVersion : "";
2363
+ if (!version) {
2364
+ version = readBundledOpenclawVersion(invocation, targetTag);
2365
+ }
2366
+ if (!version || !/^\d+\.\d+\.\d+/.test(version))
2367
+ return targetTag;
2368
+ const colonIdx = targetTag.lastIndexOf(":");
2369
+ const slashIdx = targetTag.lastIndexOf("/");
2370
+ const hasTag = colonIdx > slashIdx;
2371
+ const repo = hasTag ? targetTag.slice(0, colonIdx) : targetTag;
2372
+ const pinnedTag = `${repo}:${version}`;
2373
+ if (pinnedTag === targetTag)
2374
+ return targetTag;
2375
+ try {
2376
+ execFileSync(invocation.cmd, [...invocation.argsPrefix, "tag", targetTag, pinnedTag], { timeout: 10000, stdio: "ignore" });
2377
+ }
2378
+ catch {
2379
+ return targetTag;
2380
+ }
2381
+ if (/:(latest|slim)$/.test(targetTag)) {
2382
+ try {
2383
+ execFileSync(invocation.cmd, [...invocation.argsPrefix, "rmi", targetTag], { timeout: 10000, stdio: "ignore" });
2384
+ }
2385
+ catch {
2386
+ /* best-effort cleanup */
2387
+ }
2388
+ }
2389
+ return pinnedTag;
2390
+ }
2391
+ /**
2392
+ * Try docker pull, fall back to local `Dockerfile.openclaw-slim` build. This
2393
+ * is the primary image-prep path used by every setup flow. Called from the
2394
+ * integration's `buildRuntimeImage()` method.
2395
+ */
2396
+ async function pullOrBuildOpenclawImageWithTask(task, tag) {
2397
+ const targetTag = tag || DEFAULT_OPENCLAW_DOCKER_IMAGE;
2398
+ try {
2399
+ const invocation = resolveDockerInvocation();
2400
+ // Always attempt pull — when the image is already local and in sync
2401
+ // with upstream, docker returns within seconds after a digest check.
2402
+ // The "skip if image present" early exit was making "reinstall" feel
2403
+ // like a no-op; explicit re-pull matches user intent better. On pull
2404
+ // failure we still fall back to local build below.
2405
+ emitTask(task, { type: "progress", message: `正在拉取镜像: ${targetTag} ...`, progress: 10 });
2406
+ const pullResult = await spawnWithTask(task, invocation.cmd, [...invocation.argsPrefix, "pull", targetTag], { timeout: 600000 });
2407
+ if (pullResult.ok) {
2408
+ const pinned = capturePinnedImageTag(invocation, targetTag);
2409
+ setOpenclawDockerImage(pinned);
2410
+ emitTask(task, { type: "done", message: `镜像拉取成功: ${pinned}`, progress: 100 });
2411
+ task.status = "done";
2412
+ return { ok: true, message: `Docker image ${pinned} pulled`, taskId: task.id };
2413
+ }
2414
+ console.log(`[openclaw] docker pull failed for ${targetTag}, falling back to local build...`);
2415
+ emitTask(task, {
2416
+ type: "progress",
2417
+ message: `拉取失败,正在本地构建镜像: ${targetTag} ...`,
2418
+ progress: 20,
2419
+ });
2420
+ const projectRoot = join(dirname(fileURLToPath(import.meta.url)), "../../../..");
2421
+ const dockerfilePath = join(projectRoot, "Dockerfile.openclaw-slim");
2422
+ if (!existsSync(dockerfilePath)) {
2423
+ emitTask(task, {
2424
+ type: "error",
2425
+ message: "Dockerfile.openclaw-slim not found, cannot fallback to local build",
2426
+ });
2427
+ task.status = "error";
2428
+ return {
2429
+ ok: false,
2430
+ message: "Docker pull failed and Dockerfile.openclaw-slim not found",
2431
+ taskId: task.id,
2432
+ };
2433
+ }
2434
+ const openclawVersion = resolveOpenclawNpmVersion();
2435
+ console.log(`[openclaw] building image with OPENCLAW_VERSION=${openclawVersion}`);
2436
+ const buildResult = await spawnWithTask(task, invocation.cmd, [
2437
+ ...invocation.argsPrefix,
2438
+ "build",
2439
+ "--network=host",
2440
+ "--build-arg",
2441
+ `OPENCLAW_VERSION=${openclawVersion}`,
2442
+ "-f",
2443
+ dockerfilePath,
2444
+ "-t",
2445
+ targetTag,
2446
+ projectRoot,
2447
+ ], { timeout: 1800000, progressParser: dockerBuildProgressParser });
2448
+ if (!buildResult.ok) {
2449
+ try {
2450
+ execFileSync(invocation.cmd, [...invocation.argsPrefix, "image", "prune", "-f"], { timeout: 15000, stdio: "ignore" });
2451
+ }
2452
+ catch {
2453
+ /* best-effort */
2454
+ }
2455
+ emitTask(task, { type: "error", message: "Docker 镜像构建失败" });
2456
+ task.status = "error";
2457
+ return {
2458
+ ok: false,
2459
+ message: "Docker image build failed",
2460
+ error: buildResult.output,
2461
+ taskId: task.id,
2462
+ };
2463
+ }
2464
+ const pinned = capturePinnedImageTag(invocation, targetTag, openclawVersion);
2465
+ setOpenclawDockerImage(pinned);
2466
+ emitTask(task, {
2467
+ type: "done",
2468
+ message: `OpenClaw 镜像就绪 (本地构建): ${pinned}`,
2469
+ progress: 100,
2470
+ });
2471
+ task.status = "done";
2472
+ return { ok: true, message: `Docker image ${pinned} built locally`, taskId: task.id };
2473
+ }
2474
+ catch (e) {
2475
+ emitTask(task, { type: "error", message: `镜像获取失败: ${e.message}` });
2476
+ task.status = "error";
2477
+ return {
2478
+ ok: false,
2479
+ message: "Docker image pull/build failed",
2480
+ error: e.message,
2481
+ taskId: task.id,
2482
+ };
2483
+ }
2484
+ }
2485
+ function sanitizeConnectionMcpName(name) {
2486
+ return name.replace(/[^a-zA-Z0-9_-]/g, "-").slice(0, 64);
2487
+ }
2488
+ function connectionMcpTransport(protocol) {
2489
+ switch ((protocol || "").toLowerCase()) {
2490
+ case "http":
2491
+ case "https":
2492
+ return "http";
2493
+ case "sse":
2494
+ case "ws":
2495
+ case "wss":
2496
+ return "sse";
2497
+ default:
2498
+ return undefined;
2499
+ }
2500
+ }
2501
+ function isIPv6Host(host) {
2502
+ return /:.*:/.test(host) && !host.startsWith("[");
2503
+ }
2504
+ function bracketIPv6Host(host) {
2505
+ return isIPv6Host(host) ? `[${host}]` : host;
2506
+ }
2507
+ function buildConnectionHttpBaseUrl(entry) {
2508
+ const protocol = entry.protocol === "https" ? "https" : "http";
2509
+ const url = new URL(`${protocol}://${bracketIPv6Host(entry.host)}:${entry.hostPort}`);
2510
+ if (entry.path && entry.path !== "/")
2511
+ url.pathname = entry.path;
2512
+ return url.toString().replace(/\/$/, "");
2513
+ }
2514
+ function applyOpenClawMcpBinding(args) {
2515
+ const { instanceId, binding } = args;
2516
+ if (binding.category !== "mcp" || binding.entries.length === 0)
2517
+ return;
2518
+ const source = {
2519
+ kind: "connection",
2520
+ slot: binding.slot,
2521
+ consumerInstanceId: instanceId,
2522
+ };
2523
+ // Replace-style: drop prior connection-managed entries for this
2524
+ // (slot, consumer) pair, then merge the currently resolved providers.
2525
+ removeMcporterServers(instanceId, { source });
2526
+ const servers = {};
2527
+ for (const entry of binding.entries) {
2528
+ const name = sanitizeConnectionMcpName(`${entry.capability}-${entry.instanceId}`);
2529
+ const transport = connectionMcpTransport(entry.protocol);
2530
+ const url = transport === "stdio" ? undefined : buildConnectionHttpBaseUrl(entry);
2531
+ servers[name] = {
2532
+ ...(transport ? { transport } : {}),
2533
+ ...(url ? { url } : {}),
2534
+ __source: source,
2535
+ };
2536
+ }
2537
+ mergeMcporterServers(instanceId, servers);
2538
+ }
2539
+ function unapplyOpenClawMcpBinding(args) {
2540
+ if (args.category !== "mcp")
2541
+ return;
2542
+ removeMcporterServers(args.instanceId, {
2543
+ source: {
2544
+ kind: "connection",
2545
+ slot: args.slot,
2546
+ consumerInstanceId: args.instanceId,
2547
+ },
2548
+ });
2549
+ }
2550
+ // ── OpenClawIntegration class ─────────────────────────────────────────────
2551
+ class OpenClawIntegration {
2552
+ kind = "openclaw";
2553
+ displayName = "OpenClaw";
2554
+ defaultCapabilities = DEFAULT_CAPABILITIES;
2555
+ publicProxy = OPENCLAW_CONTROL_UI_PUBLIC_PROXY;
2556
+ preferredHostPort = OPENCLAW_PREFERRED_HOST_PORT;
2557
+ manifest = {
2558
+ kind: "openclaw",
2559
+ displayName: "OpenClaw",
2560
+ description: "默认 runtime,支持克隆、飞书 / 企业微信插件",
2561
+ defaultCapabilities: DEFAULT_CAPABILITIES,
2562
+ requiresNomadDocker: false,
2563
+ diskSpaceMB: 2048,
2564
+ catalogGroup: "agents",
2565
+ catalogIcon: "openclaw",
2566
+ defaultTab: "chat",
2567
+ supportsClone: true,
2568
+ connectionRole: "agent",
2569
+ defaultConnectionApplyMode: "proxy-upstream",
2570
+ requiredForSetupReady: true,
2571
+ defaultCreateAppSpecId: "openclaw-container",
2572
+ createAppSpecAliases: ["openclaw", "openclaw-container.yaml"],
2573
+ autoStartRequiresDefaultLlmProvider: true,
2574
+ embeddedUiSurface: "integration-control-ui",
2575
+ };
2576
+ async registerRoutes(app) {
2577
+ const { registerOpenclawRoutes } = await import("./routes.js");
2578
+ registerOpenclawRoutes(app);
2579
+ }
2580
+ hooks = {
2581
+ onCreatePrepare: async (ctx) => this.prepareInitialLayout(ctx),
2582
+ onPrepareControlUiOrigin: async ({ instanceId, origin, action }) => {
2583
+ const added = await ensureOpenclawControlUiAllowedOrigin(instanceId, origin);
2584
+ if (added) {
2585
+ console.log(`[openclaw-control-ui] prepared allowed origin for ${instanceId} action=${action} origin=${origin}`);
2586
+ }
2587
+ return added;
2588
+ },
2589
+ /**
2590
+ * Full OpenClaw pre-start prelude — used to live inline in
2591
+ * the Nomad driver's start path as an `if (!hermes) { ... }` branch
2592
+ * (~80 lines). Framework code now calls this hook uniformly for every
2593
+ * kind; Hermes provides a no-op and OpenClaw owns the full sequence:
2594
+ *
2595
+ * 1. Ensure `openclaw.json` exists + fix state-dir permissions
2596
+ * 2. Docker-bridge: patch gateway.bind + jsproxy baseUrl
2597
+ * 3. Seed `$HOME/.npm-global` for in-gateway "Update now"
2598
+ * 4. Validate + image-inspect the Docker image; background-pull on miss
2599
+ * 5. Write JSPROXY_API_KEY into Nomad Variables
2600
+ *
2601
+ * Throws on fatal errors. Framework catches and returns the structured
2602
+ * result; a `taskId` property on the thrown error signals an async
2603
+ * image pull in progress.
2604
+ *
2605
+ * Step 13 (2026-06-09): the historical "stop legacy host-mode
2606
+ * subprocess" step has been removed. Host-mode / process-manager
2607
+ * driven instances are no longer supported on the runtime path;
2608
+ * `jishushell migrate legacy` must convert them to canonical
2609
+ * `apps/<id>` layout before they can be started under Nomad.
2610
+ */
2611
+ onBeforeStart: async ({ instanceId }) => {
2612
+ // 1. Config path existence check + permissions — use local resolvers
2613
+ // instead of lazy importing back into instance-manager.
2614
+ let configPath;
2615
+ try {
2616
+ configPath = openclawIntegration.resolveConfigPath(instanceId);
2617
+ }
2618
+ catch {
2619
+ return; // bail gracefully for non-OpenClaw instances
2620
+ }
2621
+ if (!existsSync(configPath)) {
2622
+ throw new Error("Config file not found");
2623
+ }
2624
+ if (getNomadDriver() === "docker") {
2625
+ const stateDir = dirname(configPath);
2626
+ ensureDirContainer(stateDir);
2627
+ try {
2628
+ for (const entry of readdirSync(stateDir, { withFileTypes: true })) {
2629
+ if (entry.isDirectory()) {
2630
+ const sub = join(stateDir, entry.name);
2631
+ ensureDirContainer(sub);
2632
+ try {
2633
+ for (const child of readdirSync(sub, { withFileTypes: true })) {
2634
+ if (child.isDirectory())
2635
+ ensureDirContainer(join(sub, child.name));
2636
+ }
2637
+ }
2638
+ catch {
2639
+ /* ignore */
2640
+ }
2641
+ }
2642
+ }
2643
+ }
2644
+ catch {
2645
+ /* ignore */
2646
+ }
2647
+ if (existsSync(configPath))
2648
+ chmodSync(configPath, 0o644);
2649
+ // 3. Docker bridge patches
2650
+ patchDockerBridgeGatewayBind(configPath);
2651
+ patchJsproxyBaseUrl(configPath);
2652
+ patchPrivateNetworkAllowFlag(configPath);
2653
+ }
2654
+ // Driver-agnostic: enable the OpenAI-compatible endpoints on every
2655
+ // start so the `llm-agent` capability advertised by openclaw-*.yaml
2656
+ // works for both fresh installs and instances created before this
2657
+ // patcher shipped. Idempotent — bails out fast if already enabled.
2658
+ patchOpenAIEndpointsEnabled(configPath);
2659
+ // 4. npm update-seed — use local resolver
2660
+ try {
2661
+ const home = openclawIntegration.resolveAgentHome(instanceId);
2662
+ if (home)
2663
+ ensureOpenclawUpdateSeed(home, instanceId);
2664
+ }
2665
+ catch {
2666
+ /* best effort */
2667
+ }
2668
+ // 4a. Patch session fence bug in OpenClaw >= 5.19
2669
+ try {
2670
+ const home = openclawIntegration.resolveAgentHome(instanceId);
2671
+ if (home) {
2672
+ patchSessionFenceBug(home, instanceId);
2673
+ // Also write the container-side patch script so that even if
2674
+ // the host-side patch couldn't apply (e.g. symlink to container
2675
+ // path), the container will self-patch on startup.
2676
+ if (getNomadDriver() === "docker") {
2677
+ writeContainerPatchScript(home);
2678
+ }
2679
+ }
2680
+ }
2681
+ catch {
2682
+ /* best effort — patch failure must not prevent start */
2683
+ }
2684
+ // 4b. Build the workspace symlink layout from this instance's
2685
+ // fileMounts (M1 W2). For docker mode, the corresponding
2686
+ // volume bindings are added in buildNomadTask below; for
2687
+ // raw_exec / process modes, the symlinks are sufficient
2688
+ // (no container layer between agent and host fs).
2689
+ try {
2690
+ const home = openclawIntegration.resolveAgentHome(instanceId);
2691
+ const im = await lazyIm();
2692
+ const runtime = im.getInstanceRuntime(instanceId);
2693
+ const mounts = readFileMounts(runtime);
2694
+ if (home) {
2695
+ const { rebuildWorkspace } = await import("../../workspaces/builder.js");
2696
+ rebuildWorkspace({
2697
+ integrationHome: home,
2698
+ filesRoot: FILES_ROOT,
2699
+ mounts,
2700
+ instanceId,
2701
+ });
2702
+ }
2703
+ }
2704
+ catch (e) {
2705
+ // Surface migration-required clearly; otherwise fall back to a
2706
+ // warning so a misconfigured mount cannot prevent instance start.
2707
+ if (e?.reason === "needs-migration") {
2708
+ throw new Error(`instance ${instanceId} workspace contains pre-W2 user data; run legacy migration first (${e.message})`);
2709
+ }
2710
+ console.warn(`[openclaw] workspace rebuild skipped: ${e?.message ?? e}`);
2711
+ }
2712
+ // 4b-bis. Patch TOOLS.md with the drive-shim hint so the agent
2713
+ // understands user files are local (host==container bind) and
2714
+ // knows the resolve→send chain for IM channels. Without this,
2715
+ // the LLM defaults to "drive = remote cloud service" and
2716
+ // refuses to send NAS files via Feishu/WeChat. Runs after the
2717
+ // workspace rebuild because that step creates the workspace
2718
+ // tree if missing.
2719
+ try {
2720
+ const home = openclawIntegration.resolveAgentHome(instanceId);
2721
+ if (home) {
2722
+ patchToolsMdDriveHint(join(home, ".openclaw", "workspace"), FILES_ROOT, join(home, ".npm-global", "bin", "jishushell-mcporter"), instanceId);
2723
+ }
2724
+ }
2725
+ catch (e) {
2726
+ console.warn(`[openclaw] TOOLS.md drive hint skipped: ${e?.message ?? e}`);
2727
+ }
2728
+ try {
2729
+ const home = openclawIntegration.resolveAgentHome(instanceId);
2730
+ if (home) {
2731
+ const configPath = openclawConfigPath(instanceId, home);
2732
+ const runtimeConfig = existsSync(configPath)
2733
+ ? JSON.parse(readFileSync(configPath, "utf-8"))
2734
+ : {};
2735
+ const shouldInstallBrowserlessHint = runtimeConfig?.browser?.defaultProfile === BROWSERLESS_PROFILE;
2736
+ patchToolsMdBrowserlessHint(join(home, ".openclaw", "workspace"), shouldInstallBrowserlessHint ? "install" : "remove");
2737
+ }
2738
+ }
2739
+ catch (e) {
2740
+ console.warn(`[openclaw] TOOLS.md browserless hint skipped: ${e?.message ?? e}`);
2741
+ }
2742
+ // 4b-ter. Rotate stale session jsonl(s) when the runtime contract
2743
+ // bumps. This is the auto-recovery path for panel upgrades
2744
+ // that fix runtime bugs the agent has already "concluded
2745
+ // around" inside an existing session — without rotation the
2746
+ // LLM keeps citing past failures and refusing to retry even
2747
+ // after the underlying bug is fixed. Idempotent: after the
2748
+ // first onBeforeStart post-upgrade writes the new marker,
2749
+ // subsequent starts are no-ops.
2750
+ try {
2751
+ const home = openclawIntegration.resolveAgentHome(instanceId);
2752
+ if (home)
2753
+ rotateSessionsIfContractChanged(instanceId, home);
2754
+ }
2755
+ catch (e) {
2756
+ console.warn(`[openclaw] session rotation skipped: ${e?.message ?? e}`);
2757
+ }
2758
+ // 4c. Install the drive MCP shim so the agent can call panel
2759
+ // file/organize APIs from chat (M1 W1.6). Idempotent — we
2760
+ // overwrite the shim file every start to pick up fixes, and
2761
+ // mergeMcporterServers marks the entry with __source so user-
2762
+ // managed mcporter entries are preserved untouched.
2763
+ try {
2764
+ const home = openclawIntegration.resolveAgentHome(instanceId);
2765
+ if (home) {
2766
+ const { substituteDriveShimPlaceholders } = await import("./drive-shim.js");
2767
+ const { mergeMcporterServers } = await import("./mcporter.js");
2768
+ const { getInternalMcpToken } = await import("../../../config.js");
2769
+ // Pick the core URL based on how THIS instance will actually run.
2770
+ // For a containerized instance (raw_exec/docker via Nomad with a
2771
+ // docker image), `host.docker.internal:<corePort>` resolves through
2772
+ // the bridge gateway. For a host-process / binary spec under Nomad
2773
+ // raw_exec, the task gets its own network namespace where
2774
+ // 127.0.0.1 only reaches the task itself — must use the host's
2775
+ // LAN IPv4 so the shim's fetch crosses back into the host netns.
2776
+ // Detected via the instance's resolved runtime: container tasks
2777
+ // carry `runtime.image`, binary tasks carry only `runtime.command`.
2778
+ const corePort = getCorePort();
2779
+ let driveCoreHost = "host.docker.internal";
2780
+ try {
2781
+ const im2 = await lazyIm();
2782
+ const rt = im2.getInstanceRuntime(instanceId);
2783
+ if (!rt?.image) {
2784
+ driveCoreHost = getCoreLanHost();
2785
+ }
2786
+ }
2787
+ catch (e) {
2788
+ console.warn(`[openclaw] drive shim runtime detection failed for ${instanceId}; using container-reachable core host:`, e);
2789
+ }
2790
+ const driveCoreUrl = `http://${driveCoreHost}:${corePort}`;
2791
+ const shimDir = join(home, "__mcp_shims__", "drive");
2792
+ ensureDirContainer(shimDir);
2793
+ const shimPath = join(shimDir, "drive-shim.mjs");
2794
+ // Bake coreUrl/token/instanceId into the shim source so it works
2795
+ // even when OpenClaw scrubs env on MCP subprocess spawn (verified
2796
+ // 2026-05-11 on pi2: env scrub made the shim default to the
2797
+ // unreachable host.docker.internal and surface as "fetch failed").
2798
+ const internalToken = getInternalMcpToken();
2799
+ const shimSource = substituteDriveShimPlaceholders({
2800
+ coreUrl: driveCoreUrl,
2801
+ token: internalToken,
2802
+ instanceId,
2803
+ });
2804
+ writeFileSync(shimPath, shimSource, { mode: 0o755 });
2805
+ mergeMcporterServers(instanceId, {
2806
+ drive: {
2807
+ command: "node",
2808
+ args: [shimPath],
2809
+ env: {
2810
+ // Env still set as a belt-and-suspenders. With baked-in
2811
+ // values in the shim source itself, these become a fallback
2812
+ // for dev/manual testing — production never depends on them.
2813
+ JISHUSHELL_INTERNAL_TOKEN: internalToken,
2814
+ JISHUSHELL_INSTANCE_ID: instanceId,
2815
+ JISHUSHELL_CORE_URL: driveCoreUrl,
2816
+ JISHUSHELL_CORE_PORT: String(corePort),
2817
+ },
2818
+ __source: {
2819
+ kind: "connection",
2820
+ slot: "drive",
2821
+ consumerInstanceId: instanceId,
2822
+ },
2823
+ },
2824
+ });
2825
+ }
2826
+ }
2827
+ catch (e) {
2828
+ console.warn(`[openclaw] drive shim install skipped: ${e?.message ?? e}`);
2829
+ }
2830
+ // 4c-quater. Auto-wire knowledge MCP shim. The Connections-tab
2831
+ // knowledge slot (declared as `requires: knowledge` on the
2832
+ // OpenClaw spec, persisted under `instance.connections.KNOWLEDGE_BASE_URL`)
2833
+ // is honored here, so unbinding in the UI actually takes effect.
2834
+ // Provider resolution (matching connection-resolver.ts):
2835
+ //
2836
+ // - `null` → user explicitly disconnected →
2837
+ // DO NOT inject (and strip any prior shim).
2838
+ // - kind=single + providerId → use that provider's shim.
2839
+ // - kind=many → first known match in user order wins.
2840
+ // - undefined/unknown → no provider; migration/repair may
2841
+ // materialize old defaults into an
2842
+ // explicit binding, but runtime never
2843
+ // guesses from credentials.json.
2844
+ //
2845
+ // Mutual cleanup: rebinding from anythingllm → jishukb (or
2846
+ // vice versa, or → null) wipes the OTHER provider's shim dir
2847
+ // in EVERY branch. Leaving a 0o600 secret.json + bearer-
2848
+ // prefilled shim source on disk after unbind would be a
2849
+ // lingering security smell.
2850
+ //
2851
+ // Secrets handling (defense-in-depth, anythingllm only):
2852
+ // - shim source (mode 0o644) carries baseUrl + workspace only;
2853
+ // the API key lives in a sibling `secret.json` (0o600).
2854
+ // - mcporter.json (0o644) env carries only non-secret hints
2855
+ // for hand-running. Production shim reads the secret file.
2856
+ // jishu-kb v1 ships without auth, so no secret.json.
2857
+ try {
2858
+ const home = openclawIntegration.resolveAgentHome(instanceId);
2859
+ if (home) {
2860
+ const instMeta = getInstance(instanceId);
2861
+ const provider = resolveKbProvider(instMeta?.connections?.KNOWLEDGE_BASE_URL);
2862
+ const mcporterCommand = join(home, ".npm-global", "bin", "jishushell-mcporter");
2863
+ const wsDir = join(home, ".openclaw", "workspace");
2864
+ const anyllmShimDir = join(home, "__mcp_shims__", "anythingllm");
2865
+ const anyllmShimPath = join(anyllmShimDir, "anythingllm-shim.js");
2866
+ const anyllmSecretPath = join(anyllmShimDir, "secret.json");
2867
+ const jishukbShimDir = join(home, "__mcp_shims__", "jishukb");
2868
+ const jishukbShimPath = join(jishukbShimDir, "jishukb-shim.js");
2869
+ const { mergeMcporterServers, removeMcporterServers } = await import("./mcporter.js");
2870
+ if (provider === "jishukb") {
2871
+ // Wipe the OTHER provider's residue first (including its
2872
+ // 0o600 secret.json). Security smell to leave it on disk.
2873
+ wipeKbShimDir(home, "anythingllm");
2874
+ const credPath = resolveProviderCredentialsPath("jishu-kb-container");
2875
+ let creds = null;
2876
+ if (existsSync(credPath)) {
2877
+ try {
2878
+ creds = JSON.parse(readFileSync(credPath, "utf-8"));
2879
+ }
2880
+ catch (e) {
2881
+ console.warn(`[openclaw] kb: invalid jishu-kb credentials.json: ${e?.message ?? e}`);
2882
+ }
2883
+ }
2884
+ if (creds?.baseUrl) {
2885
+ const kbId = await resolveJishukbDefaultKbIdForOpenClaw(creds.baseUrl, creds.kbId);
2886
+ const { substituteJishukbShimPlaceholders } = await import("./jishukb-shim.js");
2887
+ ensureDirContainer(jishukbShimDir);
2888
+ const shimSource = substituteJishukbShimPlaceholders({
2889
+ baseUrl: creds.baseUrl,
2890
+ kbId,
2891
+ allowedUploadRoots: listJishukbUploadRoots(instMeta?.runtime ?? {}, home),
2892
+ });
2893
+ writeFileSync(jishukbShimPath, shimSource, { mode: 0o644 });
2894
+ mergeMcporterServers(instanceId, {
2895
+ kb: {
2896
+ command: "node",
2897
+ args: [jishukbShimPath],
2898
+ env: {
2899
+ // Belt-and-suspenders fallback for hand-running.
2900
+ // Baked values in the shim source are the production
2901
+ // source of truth. No secret in v1.
2902
+ JISHUKB_BASE_URL: creds.baseUrl,
2903
+ JISHUKB_KB_ID: kbId,
2904
+ },
2905
+ __source: {
2906
+ kind: "connection",
2907
+ slot: "knowledge",
2908
+ consumerInstanceId: instanceId,
2909
+ },
2910
+ },
2911
+ });
2912
+ patchToolsMdKbHint(wsDir, "install", "jishukb", mcporterCommand, instanceId, join(home, ".openclaw", "media", "inbound"));
2913
+ }
2914
+ else {
2915
+ // jishu-kb bound but baseUrl not yet ready / credentials missing.
2916
+ // Remove any prior kb registration so the agent doesn't
2917
+ // call a stale shim, and wipe our own shim dir for hygiene.
2918
+ console.warn(`[openclaw] kb: jishu-kb bound but baseUrl missing at ${credPath} — skipping shim install`);
2919
+ removeMcporterServers(instanceId, {
2920
+ source: { kind: "connection", slot: "knowledge", consumerInstanceId: instanceId },
2921
+ });
2922
+ patchToolsMdKbHint(wsDir, "remove");
2923
+ wipeKbShimDir(home, "jishukb");
2924
+ }
2925
+ }
2926
+ else if (provider === "anythingllm") {
2927
+ // Wipe the OTHER provider's residue first.
2928
+ wipeKbShimDir(home, "jishukb");
2929
+ const credPath = resolveProviderCredentialsPath("anythingllm-container");
2930
+ let kbCreds = null;
2931
+ if (existsSync(credPath)) {
2932
+ try {
2933
+ kbCreds = JSON.parse(readFileSync(credPath, "utf-8"));
2934
+ }
2935
+ catch (e) {
2936
+ console.warn(`[openclaw] kb: invalid credentials.json: ${e?.message ?? e}`);
2937
+ }
2938
+ }
2939
+ if (kbCreds?.apiKey && kbCreds?.baseUrl) {
2940
+ const { substituteAnythingllmShimPlaceholders } = await import("./anythingllm-shim.js");
2941
+ ensureDirContainer(anyllmShimDir);
2942
+ const shimSource = substituteAnythingllmShimPlaceholders({
2943
+ baseUrl: kbCreds.baseUrl,
2944
+ workspace: kbCreds.workspace || "default",
2945
+ });
2946
+ writeFileSync(anyllmShimPath, shimSource, { mode: 0o644 });
2947
+ // chmod after write to dodge umask; secret.json must be 0o600.
2948
+ writeFileSync(anyllmSecretPath, JSON.stringify({ apiKey: kbCreds.apiKey }), { mode: 0o600 });
2949
+ try {
2950
+ chmodSync(anyllmSecretPath, 0o600);
2951
+ }
2952
+ catch { /* best effort */ }
2953
+ mergeMcporterServers(instanceId, {
2954
+ kb: {
2955
+ command: "node",
2956
+ args: [anyllmShimPath],
2957
+ env: {
2958
+ // Belt-and-suspenders fallback for hand-running. Baked
2959
+ // values in the shim source are the production source
2960
+ // of truth for baseUrl + workspace; the API key is
2961
+ // intentionally NOT placed here — it lives in
2962
+ // `secret.json` (0o600) next to the shim so this 0o644
2963
+ // file stays free of secrets.
2964
+ ANYTHINGLLM_BASE_URL: kbCreds.baseUrl,
2965
+ ANYTHINGLLM_WORKSPACE: kbCreds.workspace || "default",
2966
+ },
2967
+ __source: {
2968
+ kind: "connection",
2969
+ slot: "knowledge",
2970
+ consumerInstanceId: instanceId,
2971
+ },
2972
+ },
2973
+ });
2974
+ patchToolsMdKbHint(wsDir, "install", "anythingllm", mcporterCommand);
2975
+ }
2976
+ else {
2977
+ // AnythingLLM bound but creds missing → strip and clean.
2978
+ removeMcporterServers(instanceId, {
2979
+ source: { kind: "connection", slot: "knowledge", consumerInstanceId: instanceId },
2980
+ });
2981
+ patchToolsMdKbHint(wsDir, "remove");
2982
+ wipeKbShimDir(home, "anythingllm");
2983
+ }
2984
+ }
2985
+ else {
2986
+ // provider === null → user explicitly unbound, or bound to
2987
+ // an unknown/unsupported provider. Strip kb server and wipe
2988
+ // both shim dirs.
2989
+ removeMcporterServers(instanceId, {
2990
+ source: { kind: "connection", slot: "knowledge", consumerInstanceId: instanceId },
2991
+ });
2992
+ patchToolsMdKbHint(wsDir, "remove");
2993
+ wipeKbShimDir(home, "anythingllm");
2994
+ wipeKbShimDir(home, "jishukb");
2995
+ }
2996
+ }
2997
+ }
2998
+ catch (e) {
2999
+ console.warn(`[openclaw] kb shim wiring skipped: ${e?.message ?? e}`);
3000
+ }
3001
+ // 4c-bis. Self-heal MCPORTER_CONFIG env on existing instances. Without
3002
+ // this, mcporter can't find its config when invoked from the
3003
+ // gateway's CWD (openclaw-home/) or from the workspace symlink
3004
+ // (which points at user files, also no config/), so every drive
3005
+ // tool call fails with "Unknown MCP server 'drive'" and the agent
3006
+ // degrades into reporting a generic "network error". New instances
3007
+ // get this env via the binary/container runtime template; this
3008
+ // block back-fills it for instances created before that template
3009
+ // update so users don't have to recreate them.
3010
+ try {
3011
+ const im2 = await lazyIm();
3012
+ const rt = im2.getInstanceRuntime(instanceId);
3013
+ const home = openclawIntegration.resolveAgentHome(instanceId);
3014
+ if (home && rt && (!rt.env || !rt.env.MCPORTER_CONFIG)) {
3015
+ const desired = `${home}/.openclaw/workspace/config/mcporter.json`;
3016
+ const nextEnv = { ...(rt.env || {}), MCPORTER_CONFIG: desired };
3017
+ im2.updateInstanceMeta(instanceId, { runtime: { ...rt, env: nextEnv } });
3018
+ console.log(`[openclaw] self-healed MCPORTER_CONFIG env for ${instanceId}`);
3019
+ }
3020
+ }
3021
+ catch (e) {
3022
+ console.warn(`[openclaw] MCPORTER_CONFIG self-heal failed: ${e?.message ?? e}`);
3023
+ }
3024
+ // 4d. Install a standalone mcporter-compatible FALLBACK wrapper at
3025
+ // `$OPENCLAW_HOME/.npm-global/bin/jishushell-mcporter`. Fresh
3026
+ // instances often do not carry an actual mcporter npm install, yet
3027
+ // TOOLS.md asks the model to shell out for drive/kb access. Keep
3028
+ // the fallback on a distinct path so we do NOT clobber a real
3029
+ // mcporter install that may support transports/features beyond this
3030
+ // wrapper's narrow built-in scope.
3031
+ try {
3032
+ const home = openclawIntegration.resolveAgentHome(instanceId);
3033
+ if (home) {
3034
+ const mcporterBin = join(home, ".npm-global", "bin", "jishushell-mcporter");
3035
+ ensureDirContainer(join(home, ".npm-global", "bin"));
3036
+ writeFileSync(mcporterBin, renderStandaloneMcporterSource(), { mode: 0o755 });
3037
+ try {
3038
+ chmodSync(mcporterBin, 0o755);
3039
+ }
3040
+ catch { /* best effort */ }
3041
+ console.log(`[openclaw] installed standalone mcporter fallback at ${mcporterBin}`);
3042
+ }
3043
+ }
3044
+ catch (e) {
3045
+ console.warn(`[openclaw] mcporter self-heal failed: ${e?.message ?? e}`);
3046
+ }
3047
+ // 5. Docker image validation + background pull fallback
3048
+ if (getNomadDriver() === "docker") {
3049
+ const image = getOpenclawDockerImage();
3050
+ if (!DOCKER_IMAGE_RE.test(image) || image.length > MAX_DOCKER_IMAGE_NAME_LEN) {
3051
+ throw new Error(`Invalid Docker image name: "${image}"`);
3052
+ }
3053
+ const imageCheck = inspectDockerImage(image, { timeout: 10000 });
3054
+ if (!imageCheck.ok) {
3055
+ const inspectError = toDockerInspectUserError(image, imageCheck);
3056
+ if (imageCheck.reason !== "not_found") {
3057
+ const err = new Error(inspectError.message);
3058
+ err.code = inspectError.code;
3059
+ err.statusCode = inspectError.statusCode;
3060
+ throw err;
3061
+ }
3062
+ console.log(`[openclaw] Docker image ${image} not found, starting background pull`);
3063
+ try {
3064
+ const result = openclawIntegration.startBuildRuntimeImage({ tag: image });
3065
+ const err = new Error(`${inspectError.message} Pull started in background.`);
3066
+ err.building = true;
3067
+ err.taskId = result.taskId;
3068
+ err.code = inspectError.code;
3069
+ err.statusCode = 202;
3070
+ throw err;
3071
+ }
3072
+ catch (e) {
3073
+ if (e?.building)
3074
+ throw e;
3075
+ throw new Error(`Docker image ${image} not available: ${e?.message ?? e}`);
3076
+ }
3077
+ }
3078
+ }
3079
+ // 6. Write instance secrets to Nomad Variables
3080
+ try {
3081
+ const nomad = await import("../../runtime/drivers/nomad.js");
3082
+ if (typeof nomad.writeInstanceVariables === "function") {
3083
+ await nomad.writeInstanceVariables(instanceId);
3084
+ }
3085
+ }
3086
+ catch (e) {
3087
+ throw new Error(`Failed to store instance secrets in Nomad Variables: ${e?.message ?? e}`);
3088
+ }
3089
+ },
3090
+ /**
3091
+ * OpenClaw auto-installs IM channel plugins (feishu, weixin, etc.) when
3092
+ * they're enabled in `openclaw.json`. That logic currently lives in
3093
+ * `instance-manager.saveConfig()`; wiring it through this hook is a
3094
+ * no-op during MVP because saveConfig still runs inline. The hook
3095
+ * exists so the physical-migration follow-up PR can move the code into
3096
+ * this file without touching framework code.
3097
+ */
3098
+ onConfigSaved: async (_args) => {
3099
+ /* reserved — channel plugin install hook, filled by follow-up PR */
3100
+ },
3101
+ onCreate: async ({ instanceId, createArgs }) => {
3102
+ await finalizeOpenclawCreatedInstance(instanceId, createArgs);
3103
+ },
3104
+ /**
3105
+ * Surface an orphan-directory warning when the canonical integration home
3106
+ * points outside the instance dir. The framework's deleteInstance
3107
+ * only rm's the instance dir itself, so custom-home layouts leave a
3108
+ * tree that the operator must clean up manually — UNLESS the Step 5
3109
+ * ownership marker proves Core created the tree as part of THIS
3110
+ * instance, in which case it is safe to remove.
3111
+ */
3112
+ onDelete: async ({ instanceId, meta }) => {
3113
+ const home = openclawHomeFromMetadata(meta, instanceId);
3114
+ const instDir = framework_instanceDir(instanceId);
3115
+ if (home.startsWith(instDir))
3116
+ return; // inside the instance dir — rm already caught it
3117
+ if (!existsSync(home))
3118
+ return;
3119
+ // Step 5: marker match is the canonical proof of Core ownership.
3120
+ // Without it we MUST NOT delete — the directory might be user data
3121
+ // (e.g. a hand-curated `~/.openclaw-data`) that happened to be
3122
+ // selected as the integration home for read-only reuse.
3123
+ if (isOwnedByInstance(home, instanceId)) {
3124
+ try {
3125
+ rmSync(home, { recursive: true, force: true });
3126
+ return;
3127
+ }
3128
+ catch (e) {
3129
+ return {
3130
+ warnings: [
3131
+ `Failed to remove Core-owned OpenClaw integration home '${home}': ${e?.message ?? e}. Delete manually.`,
3132
+ ],
3133
+ };
3134
+ }
3135
+ }
3136
+ return {
3137
+ warnings: [
3138
+ `Custom OpenClaw integration home '${home}' was preserved (no Core ownership marker found). Delete manually if no longer needed.`,
3139
+ ],
3140
+ };
3141
+ },
3142
+ /**
3143
+ * Rewrite `openclaw.json` x-jishushell.proxy.upstream when the panel
3144
+ * default provider changes. Delegates to instance-manager's existing
3145
+ * helper so the transition stays stepwise.
3146
+ */
3147
+ onUpstreamProviderChange: async ({ instanceId, upstream }) => {
3148
+ try {
3149
+ const im = await lazyIm();
3150
+ if (typeof im.pushUpstreamToInstance === "function") {
3151
+ await im.pushUpstreamToInstance(instanceId, upstream);
3152
+ }
3153
+ }
3154
+ catch (e) {
3155
+ console.warn(`[openclaw] onUpstreamProviderChange failed for ${instanceId}: ${e.message}`);
3156
+ }
3157
+ },
3158
+ };
3159
+ async prepareInitialLayout(ctx) {
3160
+ const instDir = framework_instanceDir(ctx.instanceId);
3161
+ const metaPath = instanceMetaPath(ctx.instanceId);
3162
+ if (existsSync(metaPath))
3163
+ throw new Error(`Instance '${ctx.instanceId}' already exists`);
3164
+ if (existsSync(instDir) && !isPrecreatedManagedAppDir(instDir)) {
3165
+ throw new Error(`Instance '${ctx.instanceId}' already exists`);
3166
+ }
3167
+ const integrationHome = ctx.integrationHome
3168
+ ? normalizePath(ctx.integrationHome)
3169
+ : defaultOpenclawHome(ctx.instanceId);
3170
+ if (ctx.integrationHome) {
3171
+ const resolved = pathResolve(integrationHome);
3172
+ if (!resolved.startsWith(JISHUSHELL_HOME) && !resolved.startsWith("/home/")) {
3173
+ throw new Error(`OpenClaw integration home must be under ${JISHUSHELL_HOME} or /home/`);
3174
+ }
3175
+ const parentDir = dirname(resolved);
3176
+ if (existsSync(parentDir)) {
3177
+ const realParent = realpathSync(parentDir);
3178
+ if (!realParent.startsWith(JISHUSHELL_HOME) && !realParent.startsWith("/home/")) {
3179
+ throw new Error(`OpenClaw integration home parent resolves outside allowed paths (symlink detected)`);
3180
+ }
3181
+ }
3182
+ const shared = listInstances().filter((inst) => normalizePath(openclawHomeFromMetadata(inst, inst.id)) ===
3183
+ normalizePath(integrationHome));
3184
+ if (shared.length) {
3185
+ throw new Error(`OpenClaw home '${integrationHome}' is already used by instance(s): ${shared
3186
+ .map((i) => i.id)
3187
+ .join(", ")}`);
3188
+ }
3189
+ }
3190
+ if (existsSync(integrationHome)) {
3191
+ try {
3192
+ const entries = readdirSync(integrationHome);
3193
+ if (entries.length > 0) {
3194
+ // Step 5 (bootstrap ownership marker): non-empty directories are
3195
+ // disambiguated via the ownership marker rather than treated as
3196
+ // "already installed".
3197
+ // - Marker present AND `instanceId` matches → this is debris
3198
+ // from a previous failed install of THE SAME instance id.
3199
+ // Safe to wipe the contents and retry from scratch (preserve
3200
+ // the directory itself so chown/permissions stay stable).
3201
+ // - Marker present but a different `instanceId` → another
3202
+ // instance owns this tree (catches the case where the path
3203
+ // conflict check above missed because the other instance
3204
+ // was already deleted but the home was left behind).
3205
+ // - Marker absent → user data (e.g. a hand-curated
3206
+ // `~/.openclaw-data` populated before installing JishuShell).
3207
+ // Refuse to touch it.
3208
+ if (isOwnedByInstance(integrationHome, ctx.instanceId)) {
3209
+ for (const entry of entries) {
3210
+ rmSync(join(integrationHome, entry), { recursive: true, force: true });
3211
+ }
3212
+ }
3213
+ else {
3214
+ throw new Error(`OpenClaw home directory '${integrationHome}' already exists and is not empty. ` +
3215
+ `Remove it manually or choose a different path.`);
3216
+ }
3217
+ }
3218
+ }
3219
+ catch (e) {
3220
+ if (e.message.includes("not empty"))
3221
+ throw e;
3222
+ }
3223
+ }
3224
+ ensureDirContainer(instDir);
3225
+ try {
3226
+ const parentGid = statSync(dirname(instDir)).gid;
3227
+ chownSync(instDir, -1, parentGid);
3228
+ }
3229
+ catch {
3230
+ /* non-root without CAP_CHOWN */
3231
+ }
3232
+ ensureDirContainer(integrationHome);
3233
+ // Step 5: write the ownership marker as soon as the home directory
3234
+ // exists. Doing this BEFORE any other subdir creation makes the
3235
+ // marker the earliest persisted signal of Core ownership — if any
3236
+ // subsequent setup step throws, the next install retry's pre-check
3237
+ // will see the matching marker and proceed via the "wipe and retry"
3238
+ // branch above. The marker is consulted only by install pre-check,
3239
+ // install rollback, and uninstall — never by start/status/proxy
3240
+ // paths (presence MUST NOT be interpreted as "instance running").
3241
+ writeOwnershipMarker(integrationHome, {
3242
+ instanceId: ctx.instanceId,
3243
+ integrationKind: "openclaw",
3244
+ });
3245
+ ensureDirContainer(join(integrationHome, OPENCLAW_STATE_DIRNAME));
3246
+ return {
3247
+ instanceDir: instDir,
3248
+ integrationHome,
3249
+ primaryConfig: join(integrationHome, OPENCLAW_STATE_DIRNAME, OPENCLAW_CONFIG_FILENAME),
3250
+ secretEnv: defaultOpenclawModelEnvFile(ctx.instanceId),
3251
+ };
3252
+ }
3253
+ async buildRuntime(instanceId) {
3254
+ // OpenClaw persists its runtime in legacy snake_case shape
3255
+ // ({env_files, resources, ...}). Translate at read time into the
3256
+ // engine-neutral RuntimeSpec contract.
3257
+ const im = await lazyIm();
3258
+ const raw = im.getInstanceRuntime(instanceId);
3259
+ const home = openclawHomeFromMetadata(getInstance(instanceId), instanceId);
3260
+ const env = { ...DEFAULT_ENV, ...(raw?.env || {}) };
3261
+ if (home && !env.MCPORTER_CONFIG) {
3262
+ env.MCPORTER_CONFIG = `${home}/.openclaw/workspace/config/mcporter.json`;
3263
+ }
3264
+ return {
3265
+ image: raw?.image ?? getOpenclawDockerImage(),
3266
+ command: String(raw?.command || DEFAULT_COMMAND),
3267
+ args: Array.isArray(raw?.args) ? raw.args.map(String) : [...DEFAULT_ARGS],
3268
+ cwd: String(raw?.cwd || home || DEFAULT_CWD),
3269
+ user: String(raw?.user || DEFAULT_USER),
3270
+ env,
3271
+ envFiles: Array.isArray(raw?.env_files)
3272
+ ? raw.env_files
3273
+ : Array.isArray(raw?.envFiles)
3274
+ ? raw.envFiles
3275
+ : [],
3276
+ resources: {
3277
+ CPU: Number(raw?.resources?.CPU ?? DEFAULT_RESOURCES.CPU),
3278
+ MemoryMB: Number(raw?.resources?.MemoryMB ?? DEFAULT_RESOURCES.MemoryMB),
3279
+ MemoryMaxMB: raw?.resources?.MemoryMaxMB != null ? Number(raw.resources.MemoryMaxMB) : undefined,
3280
+ },
3281
+ ports: [
3282
+ {
3283
+ name: "gateway",
3284
+ containerPort: resolveOpenclawContainerPort(raw),
3285
+ hostPort: im.getPrimaryHostPort(instanceId),
3286
+ visibility: "external",
3287
+ },
3288
+ ],
3289
+ volumes: [{ hostPath: home, containerPath: home, mode: "rw" }],
3290
+ health: null,
3291
+ };
3292
+ }
3293
+ async getPersistedRuntimeSpec(instanceId) {
3294
+ const im = await lazyIm();
3295
+ const rawRuntime = im.getInstanceRuntime(instanceId);
3296
+ const openclawHome = openclawHomeFromMetadata(getInstance(instanceId), instanceId);
3297
+ const runtime = await this.buildRuntime(instanceId);
3298
+ const env = { ...(runtime.env ?? {}) };
3299
+ injectProviderHostEnv(env, instanceId);
3300
+ delete env.JSPROXY_API_KEY;
3301
+ return {
3302
+ ...runtime,
3303
+ // WorkloadCompiler contributes the compatibility entrypoint, so keep the
3304
+ // persisted command empty here to avoid emitting both `command` and
3305
+ // `entrypoint` in the docker config.
3306
+ command: "",
3307
+ user: resolveUidGid(String(rawRuntime.user || DEFAULT_USER)),
3308
+ env,
3309
+ volumes: buildVolumes(openclawHome, rawRuntime).map((entry) => {
3310
+ const [hostPath, containerPath, mode = "rw"] = entry.split(":");
3311
+ return {
3312
+ hostPath,
3313
+ containerPath,
3314
+ mode: mode === "ro" ? "ro" : "rw",
3315
+ };
3316
+ }),
3317
+ };
3318
+ }
3319
+ async buildRuntimeContribution(instanceId) {
3320
+ const im = await lazyIm();
3321
+ const openclawHome = openclawHomeFromMetadata(getInstance(instanceId), instanceId);
3322
+ const safeJobId = resolveNomadJobId(instanceId, this.nomadJobPrefix);
3323
+ assertSafeTemplateId(safeJobId);
3324
+ // Opt-in privilege relaxation (per-instance runtime.privileged). Default
3325
+ // keeps the hardened container (read-only rootfs + the base cap_drop=ALL /
3326
+ // no-new-privileges applied by the workload compiler). When enabled, the
3327
+ // driverConfig deep-merges over that base to relax it to native-install-
3328
+ // like permissions — writable rootfs, docker default caps (cap_drop=[]),
3329
+ // no-new-privileges off — and passes through host peripheral devices +
3330
+ // group_add of their owning gids. Toggle via `jishushell job privileged`.
3331
+ const rawRuntime = im.getInstanceRuntime(instanceId);
3332
+ const privileged = rawRuntime.privileged === true;
3333
+ const peripherals = privileged
3334
+ ? collectPrivilegedDevices(Array.isArray(rawRuntime.devices) ? rawRuntime.devices.map(String) : [])
3335
+ : { devices: [], groupAdd: [] };
3336
+ if (privileged) {
3337
+ console.warn(`[openclaw] instance ${instanceId} running with privileged=true — hardening relaxed (writable rootfs, default caps, no-new-privileges off); ${peripherals.devices.length} host device(s) passed through, group_add=[${peripherals.groupAdd.join(",")}]`);
3338
+ }
3339
+ const driverConfig = {
3340
+ entrypoint: ["/bin/sh", "-c", CONTAINER_PATCH_ENTRYPOINT_COMMAND, "--"],
3341
+ readonly_rootfs: !privileged,
3342
+ mounts: [
3343
+ { type: "tmpfs", target: "/tmp", tmpfs_options: { size: 536870912 } },
3344
+ { type: "tmpfs", target: "/var/tmp", tmpfs_options: { size: 67108864 } },
3345
+ { type: "tmpfs", target: "/run", tmpfs_options: { size: 52428800 } },
3346
+ ],
3347
+ ...(privileged
3348
+ ? {
3349
+ cap_drop: [],
3350
+ security_opt: [],
3351
+ ...(peripherals.devices.length > 0 ? { devices: peripherals.devices } : {}),
3352
+ ...(peripherals.groupAdd.length > 0 ? { group_add: peripherals.groupAdd } : {}),
3353
+ }
3354
+ : {}),
3355
+ };
3356
+ return {
3357
+ tasks: {
3358
+ gateway: {
3359
+ env: {
3360
+ HOME: openclawHome,
3361
+ OPENCLAW_HOME: openclawHome,
3362
+ OPENCLAW_INSTANCE_ID: instanceId,
3363
+ OPENCLAW_STATE_DIR: `${openclawHome}/.openclaw`,
3364
+ OPENCLAW_SYSTEMD_UNIT: `nomad-${safeJobId}.service`,
3365
+ npm_config_prefix: `${openclawHome}/.npm-global`,
3366
+ PIP_USER: "1",
3367
+ PYTHONUSERBASE: `${openclawHome}/.local`,
3368
+ NODE_ENV: "production",
3369
+ NODE_PATH: [
3370
+ `${openclawHome}/.npm-global/lib/node_modules`,
3371
+ "/app/node_modules",
3372
+ ].join(":"),
3373
+ PATH: [
3374
+ `${openclawHome}/.npm-global/bin`,
3375
+ `${openclawHome}/.local/bin`,
3376
+ `${openclawHome}/go/bin`,
3377
+ `${openclawHome}/.cargo/bin`,
3378
+ "/usr/local/sbin",
3379
+ "/usr/local/bin",
3380
+ "/usr/sbin",
3381
+ "/usr/bin",
3382
+ "/sbin",
3383
+ "/bin",
3384
+ ].join(":"),
3385
+ },
3386
+ driverConfig,
3387
+ templates: [
3388
+ {
3389
+ DestPath: "secrets/instance.env",
3390
+ Envvars: true,
3391
+ EmbeddedTmpl: [
3392
+ `{{ if nomadVarExists "nomad/jobs/${safeJobId}/openclaw/gateway" }}`,
3393
+ `JSPROXY_API_KEY={{ with nomadVar "nomad/jobs/${safeJobId}/openclaw/gateway" }}{{ .JSPROXY_API_KEY }}{{ end }}`,
3394
+ `{{ end }}`,
3395
+ ].join("\n"),
3396
+ ChangeMode: "restart",
3397
+ },
3398
+ ],
3399
+ },
3400
+ },
3401
+ };
3402
+ }
3403
+ async getRuntimeVersion(_instanceId) {
3404
+ // Parse the image reference (digest > tag) for the baseline image.
3405
+ const image = getOpenclawDockerImage() || "";
3406
+ let ref;
3407
+ let digest;
3408
+ if (image) {
3409
+ if (image.includes("@")) {
3410
+ digest = image.split("@", 2)[1];
3411
+ }
3412
+ else {
3413
+ const lastColon = image.lastIndexOf(":");
3414
+ const lastSlash = image.lastIndexOf("/");
3415
+ if (lastColon > lastSlash)
3416
+ ref = image.slice(lastColon + 1);
3417
+ }
3418
+ }
3419
+ return { integrationKind: "openclaw", ref, digest, mode: "baseline" };
3420
+ }
3421
+ async getConfigMeta(instanceId) {
3422
+ return {
3423
+ integrationKind: "openclaw",
3424
+ format: "json",
3425
+ schemaId: "openclaw/v1",
3426
+ capabilities: DEFAULT_CAPABILITIES,
3427
+ secretFields: ["content.x-jishushell.proxy.upstream.apiKey"],
3428
+ runtimeVersion: await this.getRuntimeVersion(instanceId),
3429
+ };
3430
+ }
3431
+ async readConfig(instanceId) {
3432
+ const im = await lazyIm();
3433
+ const content = im.getStoredConfig
3434
+ ? im.getStoredConfig(instanceId)
3435
+ : null;
3436
+ return {
3437
+ format: "json",
3438
+ content: (content && typeof content === "object") ? content : {},
3439
+ };
3440
+ }
3441
+ async writeConfig(instanceId, doc) {
3442
+ if (doc.format !== "json") {
3443
+ throw new Error(`OpenClaw config requires format="json", got "${doc.format}"`);
3444
+ }
3445
+ // Route through llmProxy.saveInstanceConfig so x-jishushell.proxy
3446
+ // metadata is stripped, the upstream apiKey is AES-encrypted to
3447
+ // provider.env, and models.providers is rewritten to the local
3448
+ // proxy — same contract HermesIntegration.writeConfig uses. That
3449
+ // function internally calls instanceManager.saveConfig, which
3450
+ // dispatches back to this integration's saveNativeConfig() for the
3451
+ // raw disk write (distinct method, no recursion).
3452
+ const { saveInstanceConfig } = await import("../../llm-proxy/instance-proxy.js");
3453
+ await saveInstanceConfig(instanceId, doc.content);
3454
+ return this.readConfig(instanceId);
3455
+ }
3456
+ async buildPairingListCommand(_instanceId) {
3457
+ return ["openclaw", "pairing", "list"];
3458
+ }
3459
+ async buildPairingApproveCommand(_instanceId, input) {
3460
+ return ["openclaw", "pairing", "approve", input.channel, input.code];
3461
+ }
3462
+ // ── Native config I/O (physically migrated from instance-manager) ───
3463
+ channelPluginMap = CHANNEL_PLUGIN_MAP;
3464
+ /**
3465
+ * Get the stored raw OpenClaw config (from `.openclaw/openclaw.json`
3466
+ * or the legacy `openclaw.json`), merged with the x-jishushell
3467
+ * metadata pulled from `instance.json`. Returns null when the instance
3468
+ * has no persisted config yet.
3469
+ */
3470
+ getNativeConfig(instanceId) {
3471
+ const config = loadEffectiveConfig(instanceId);
3472
+ if (!config)
3473
+ return null;
3474
+ const tempHosts = readTemporaryBrowserAllowedHostnames(instanceId);
3475
+ const stripped = stripTemporaryBrowserAllowlistFromConfigObject(config, tempHosts);
3476
+ // Always merge the latest upstream proxy config from instance.json
3477
+ const meta = getInstance(instanceId);
3478
+ if (meta?.["x-jishushell"]) {
3479
+ stripped["x-jishushell"] = meta["x-jishushell"];
3480
+ }
3481
+ return stripped;
3482
+ }
3483
+ /**
3484
+ * Get the stored raw config WITHOUT provider key injection. Used by
3485
+ * callers that round-trip the config back to disk (e.g. credential
3486
+ * writers) — injecting the provider key would re-persist it to the
3487
+ * config file, which is exactly what `saveConfig` takes pains to avoid.
3488
+ */
3489
+ getStoredNativeConfig(instanceId) {
3490
+ const config = loadEffectiveConfig(instanceId);
3491
+ if (!config)
3492
+ return null;
3493
+ const tempHosts = readTemporaryBrowserAllowedHostnames(instanceId);
3494
+ const stripped = stripTemporaryBrowserAllowlistFromConfigObject(config, tempHosts);
3495
+ const meta = getInstance(instanceId);
3496
+ if (meta?.["x-jishushell"]) {
3497
+ stripped["x-jishushell"] = meta["x-jishushell"];
3498
+ }
3499
+ return stripped;
3500
+ }
3501
+ isChannelPluginInstalled(instanceId, channelId) {
3502
+ return isChannelPluginInstalled(instanceId, channelId);
3503
+ }
3504
+ async installChannelPlugin(instanceId, channelId) {
3505
+ return installChannelPlugin(instanceId, channelId);
3506
+ }
3507
+ saveNativeConfig(instanceId, config) {
3508
+ return saveNativeConfigImpl(instanceId, config);
3509
+ }
3510
+ /**
3511
+ * Connection-apply hook: translate resolved `inject_as` env vars into
3512
+ * OpenClaw-native plugin config and
3513
+ * persist them into `openclaw.json`. Without this, the runtime env
3514
+ * injected by the Nomad driver's connection env phase sits
3515
+ * in the container unused — the OpenClaw agent reads tool config from
3516
+ * `openclaw.json`, not from environment variables.
3517
+ *
3518
+ * Currently wired:
3519
+ * SEARCH_API_BASE_URL → plugins.entries.searxng.config.webSearch.baseUrl
3520
+ * SEARCH_API_BASE_URL → tools.web.search.provider = "searxng"
3521
+ *
3522
+ * The provider selector at `tools.web.search.provider` is required: without
3523
+ * it the `web_search` tool defaults to Brave and fails with
3524
+ * `missing_brave_api_key` even when the searxng plugin is fully configured.
3525
+ *
3526
+ * Browser / LLM / MCP wiring lands in PR 9b — they need their own
3527
+ * config-shape mapping (browser → tools.browser, llm → models.providers,
3528
+ * mcp already wired via the OpenClaw mcporter helper).
3529
+ *
3530
+ * The write goes through `saveNativeConfig` which preserves relevant fields
3531
+ * from the existing canonical on-disk config, so user-managed plugin entries (e.g.
3532
+ * openclaw-lark) are preserved. Plugin auto-enable then promotes the
3533
+ * searxng entry into `plugins.allow` automatically on next start
3534
+ * because we set `enabled:true` and provide config (the openclaw
3535
+ * runtime treats the presence of `config.webSearch.baseUrl` as a
3536
+ * "configured" signal — see `plugin-auto-enable` in the openclaw
3537
+ * dist bundle).
3538
+ */
3539
+ async applyConnectionEnv(instanceId, env) {
3540
+ const configPath = openclawConfigPath(instanceId);
3541
+ const searchUrl = env.SEARCH_API_BASE_URL;
3542
+ if (typeof searchUrl === "string") {
3543
+ if (searchUrl === "") {
3544
+ // Empty value — connection-transactor's UNPERSIST_HOOKS uses this as
3545
+ // the "unbind" signal. Clear the searxng plugin config so the next
3546
+ // start doesn't keep routing web_search through a now-disconnected
3547
+ // provider.
3548
+ try {
3549
+ clearSearxngConnectionFromConfig(configPath);
3550
+ }
3551
+ catch (e) {
3552
+ console.warn(`[openclaw] applyConnectionEnv search unbind failed for ${instanceId}: ${e.message}`);
3553
+ }
3554
+ }
3555
+ else {
3556
+ // SEARCH_API_BASE_URL points at "<base>/search" (the SearXNG search
3557
+ // endpoint). The plugin's webSearch.baseUrl wants the bare origin —
3558
+ // strip the trailing "/search" path segment if present.
3559
+ // baseUrl stays at the registry-resolved host:port snapshot from
3560
+ // when the user PUT /connections; the framework re-runs this hook
3561
+ // on every instance start (lifecycle connection refresh), so host
3562
+ // IP changes propagate automatically on next agent restart.
3563
+ let baseUrl = searchUrl;
3564
+ try {
3565
+ const u = new URL(searchUrl);
3566
+ if (u.pathname === "/search" || u.pathname === "/search/") {
3567
+ u.pathname = "";
3568
+ baseUrl = u.toString().replace(/\/$/, "");
3569
+ }
3570
+ try {
3571
+ applySearxngConnectionToConfig(configPath, baseUrl);
3572
+ }
3573
+ catch (e) {
3574
+ console.warn(`[openclaw] applyConnectionEnv search merge failed for ${instanceId}: ${e.message}`);
3575
+ }
3576
+ }
3577
+ catch {
3578
+ // not a URL — skip silently; the openclaw plugin would break
3579
+ // with a non-URL baseUrl, and start should still proceed.
3580
+ }
3581
+ }
3582
+ }
3583
+ const cdpUrl = env.BROWSER_CDP_URL;
3584
+ if (typeof cdpUrl === "string") {
3585
+ if (cdpUrl === "") {
3586
+ try {
3587
+ clearBrowserlessConnectionFromConfig(configPath);
3588
+ }
3589
+ catch (e) {
3590
+ console.warn(`[openclaw] applyConnectionEnv browser unbind failed for ${instanceId}: ${e.message}`);
3591
+ }
3592
+ }
3593
+ else if (/^wss?:\/\//.test(cdpUrl)) {
3594
+ try {
3595
+ applyBrowserlessConnectionToConfig(configPath, cdpUrl);
3596
+ }
3597
+ catch (e) {
3598
+ console.warn(`[openclaw] applyConnectionEnv browser merge failed for ${instanceId}: ${e.message}`);
3599
+ }
3600
+ }
3601
+ // Non-ws scheme: skip silently. The connection-apply browser hook
3602
+ // already builds ws:// from the capability protocol; an http:// here
3603
+ // would mean a misconfigured provider — better to no-op than to
3604
+ // write a URL OpenClaw can't dial.
3605
+ }
3606
+ }
3607
+ async applyConnectionBinding(args) {
3608
+ applyOpenClawMcpBinding(args);
3609
+ }
3610
+ async unapplyConnectionBinding(args) {
3611
+ unapplyOpenClawMcpBinding(args);
3612
+ }
3613
+ listConnectionSideEffectFiles(args) {
3614
+ const home = openclawHomeFromMetadata(getInstance(args.instanceId), args.instanceId);
3615
+ const envFile = getRuntimeEnvFiles(args.instanceId)[0] ?? defaultOpenclawModelEnvFile(args.instanceId);
3616
+ return [
3617
+ join(dirname(envFile), "provider.env"),
3618
+ openclawConfigPath(args.instanceId, home),
3619
+ mcporterPath(args.instanceId),
3620
+ ];
3621
+ }
3622
+ // ── Path resolvers (physically migrated) ───────────────────────────
3623
+ resolveBin() {
3624
+ return resolveOpenclawBin();
3625
+ }
3626
+ getSystemVersion() {
3627
+ try {
3628
+ return execFileSync(resolveOpenclawBin(), ["--version"], { encoding: "utf-8", timeout: 5_000 }).trim() || "unknown";
3629
+ }
3630
+ catch {
3631
+ return "unknown";
3632
+ }
3633
+ }
3634
+ resolveAgentHome(instanceId) {
3635
+ const meta = getInstance(instanceId);
3636
+ return openclawHomeFromMetadata(meta, instanceId);
3637
+ }
3638
+ summarizeRecentBrowserSession(instanceId) {
3639
+ return summarizeRecentOpenclawBrowserSession(instanceId);
3640
+ }
3641
+ /** Env vars OpenClaw's CLI needs when backup-manager runs it as a subprocess. */
3642
+ buildCliEnv(instanceId) {
3643
+ return { OPENCLAW_HOME: this.resolveAgentHome(instanceId) };
3644
+ }
3645
+ /**
3646
+ * Rewrite only the host-side published gateway port (canonical Step 2
3647
+ * integration contract).
3648
+ *
3649
+ * Domain semantics:
3650
+ * - `hostPort` is Core-allocated and may be rewritten freely.
3651
+ * - `containerPort` is the in-container OpenClaw listener and MUST stay
3652
+ * stable across host-port reallocations.
3653
+ *
3654
+ * Missing canonical `runtime.ports[]` is a migration error for ordinary
3655
+ * lifecycle paths; this method must not synthesize runtime facts.
3656
+ */
3657
+ reallocateRuntimePort(runtime, newPort) {
3658
+ if (Array.isArray(runtime.ports) && runtime.ports.length > 0) {
3659
+ runtime.ports = runtime.ports.map((port, index) => {
3660
+ const isGateway = port?.name === "gateway" || index === 0;
3661
+ return isGateway
3662
+ ? { ...port, hostPort: newPort }
3663
+ : port;
3664
+ });
3665
+ return;
3666
+ }
3667
+ throw new Error("[openclaw-integration] reallocateRuntimePort: instance is missing canonical "
3668
+ + "runtime.ports[]; run migration or repair before reallocating.");
3669
+ }
3670
+ nomadJobPrefix = "openclaw-";
3671
+ // Must match the path referenced by this integration's buildNomadTask Templates
3672
+ // (see `nomadVar "nomad/jobs/<jid>/openclaw/gateway"` in the template body).
3673
+ nomadVariablePath = "openclaw/gateway";
3674
+ resolveConfigPath(instanceId) {
3675
+ return openclawConfigPath(instanceId, this.resolveAgentHome(instanceId));
3676
+ }
3677
+ resolveLegacyConfigPath(instanceId) {
3678
+ return legacyOpenclawConfigPath(instanceId, this.resolveAgentHome(instanceId));
3679
+ }
3680
+ /**
3681
+ * Return other OpenClaw instance IDs that share this one's
3682
+ * canonical integration-home path. Used by the start-time conflict check.
3683
+ */
3684
+ findInstancesSharingHome(instanceId) {
3685
+ const target = normalizePath(this.resolveAgentHome(instanceId));
3686
+ return listInstances()
3687
+ .filter((inst) => inst.id !== instanceId)
3688
+ .filter((inst) => {
3689
+ const meta = inst;
3690
+ const otherHome = openclawHomeFromMetadata(meta, inst.id);
3691
+ return normalizePath(otherHome) === target;
3692
+ })
3693
+ .map((inst) => inst.id);
3694
+ }
3695
+ // ── Feishu / WeChat credential writers (physically migrated) ───────
3696
+ saveFeishuCredentials(instanceId, creds) {
3697
+ if (!FEISHU_APP_ID_RE.test(creds.appId)) {
3698
+ throw new Error(`Invalid Feishu appId format: expected cli_<alnum> (got "${creds.appId}")`);
3699
+ }
3700
+ if (!creds.appSecret || typeof creds.appSecret !== "string" || creds.appSecret.length < 4) {
3701
+ throw new Error("Invalid Feishu appSecret: must be a non-empty string");
3702
+ }
3703
+ const configPath = this.resolveConfigPath(instanceId);
3704
+ let config = {};
3705
+ try {
3706
+ if (existsSync(configPath)) {
3707
+ config = JSON.parse(readFileSync(configPath, "utf-8"));
3708
+ }
3709
+ }
3710
+ catch {
3711
+ /* best effort */
3712
+ }
3713
+ config.plugins ??= {};
3714
+ config.plugins.entries ??= {};
3715
+ config.plugins.entries.feishu = { enabled: false };
3716
+ config.plugins.entries["openclaw-lark"] = { enabled: true };
3717
+ config.channels ??= {};
3718
+ config.channels.feishu = {
3719
+ ...config.channels.feishu,
3720
+ enabled: true,
3721
+ appId: creds.appId,
3722
+ appSecret: creds.appSecret,
3723
+ domain: creds.domain,
3724
+ dmPolicy: "open",
3725
+ allowFrom: ["*"],
3726
+ };
3727
+ safeWriteJson(configPath, config);
3728
+ chownToServiceUser(configPath);
3729
+ console.log(`[openclaw] Feishu credentials saved for ${instanceId}, domain=${creds.domain}`);
3730
+ }
3731
+ saveWeixinCredentials(instanceId, creds) {
3732
+ if (!creds.accountId || !SAFE_ACCOUNT_ID_RE.test(creds.accountId) || creds.accountId.includes("..")) {
3733
+ throw new Error(`Invalid accountId: must be 1-128 chars of [a-zA-Z0-9@._-] without '..'`);
3734
+ }
3735
+ const home = this.resolveAgentHome(instanceId);
3736
+ const stateDir = join(home, OPENCLAW_STATE_DIRNAME, "openclaw-weixin");
3737
+ const accountsDir = join(stateDir, "accounts");
3738
+ ensureDirContainer(accountsDir);
3739
+ const credObj = {
3740
+ token: creds.token,
3741
+ baseUrl: creds.baseUrl,
3742
+ userId: creds.userId,
3743
+ savedAt: new Date().toISOString(),
3744
+ };
3745
+ safeWriteJson(join(accountsDir, `${creds.accountId}.json`), credObj);
3746
+ safeWriteJson(join(accountsDir, "default.json"), credObj);
3747
+ chownToServiceUser(join(accountsDir, `${creds.accountId}.json`), join(accountsDir, "default.json"));
3748
+ // Update accounts.json index
3749
+ const indexPath = join(stateDir, "accounts.json");
3750
+ let index = [];
3751
+ try {
3752
+ const raw = readFileSync(indexPath, "utf-8");
3753
+ index = JSON.parse(raw);
3754
+ }
3755
+ catch {
3756
+ /* start fresh */
3757
+ }
3758
+ if (!Array.isArray(index))
3759
+ index = [];
3760
+ if (!index.includes(creds.accountId))
3761
+ index.push(creds.accountId);
3762
+ safeWriteJson(indexPath, index);
3763
+ const configPath = this.resolveConfigPath(instanceId);
3764
+ let config = {};
3765
+ try {
3766
+ if (existsSync(configPath))
3767
+ config = JSON.parse(readFileSync(configPath, "utf-8"));
3768
+ }
3769
+ catch {
3770
+ /* best effort */
3771
+ }
3772
+ config.plugins ??= {};
3773
+ config.plugins.entries ??= {};
3774
+ config.plugins.entries["openclaw-weixin"] ??= {};
3775
+ config.plugins.entries["openclaw-weixin"].enabled = true;
3776
+ config.channels ??= {};
3777
+ config.channels["openclaw-weixin"] ??= {};
3778
+ config.channels["openclaw-weixin"].enabled = true;
3779
+ const normalizedId = creds.accountId.replace(/[@.]/g, "-");
3780
+ const accounts = config.channels["openclaw-weixin"].accounts ??= {};
3781
+ accounts[creds.accountId] = { enabled: true };
3782
+ if (normalizedId !== creds.accountId)
3783
+ accounts[normalizedId] = { enabled: true };
3784
+ accounts["default"] = { enabled: true };
3785
+ if (!config.channels["openclaw-weixin"].defaultAccount) {
3786
+ config.channels["openclaw-weixin"].defaultAccount = "default";
3787
+ }
3788
+ safeWriteJson(configPath, config);
3789
+ chownToServiceUser(configPath);
3790
+ console.log(`[openclaw] WeChat credentials saved for ${instanceId}, account=${creds.accountId}`);
3791
+ }
3792
+ getWeixinAccounts(instanceId) {
3793
+ const home = this.resolveAgentHome(instanceId);
3794
+ const stateDir = join(home, OPENCLAW_STATE_DIRNAME, "openclaw-weixin");
3795
+ const accountsDir = join(stateDir, "accounts");
3796
+ if (!existsSync(accountsDir))
3797
+ return [];
3798
+ let indexedIds = [];
3799
+ try {
3800
+ indexedIds = JSON.parse(readFileSync(join(stateDir, "accounts.json"), "utf-8"));
3801
+ }
3802
+ catch {
3803
+ /* fallback to scanning */
3804
+ }
3805
+ const results = [];
3806
+ for (const f of readdirSync(accountsDir)) {
3807
+ if (!f.endsWith(".json"))
3808
+ continue;
3809
+ const id = f.replace(/\.json$/, "");
3810
+ if (indexedIds.length > 0 && !indexedIds.includes(id))
3811
+ continue;
3812
+ if (id === "default")
3813
+ continue;
3814
+ try {
3815
+ const data = JSON.parse(readFileSync(join(accountsDir, f), "utf-8"));
3816
+ results.push({
3817
+ accountId: id,
3818
+ userId: data.userId,
3819
+ savedAt: data.savedAt,
3820
+ });
3821
+ }
3822
+ catch {
3823
+ /* skip */
3824
+ }
3825
+ }
3826
+ return results;
3827
+ }
3828
+ // ── Legacy runtime install ────────────────────────────────────────────
3829
+ //
3830
+ // Installs the OpenClaw npm package via `npm install -g --prefix` so that
3831
+ // postinstall scripts run naturally. Emits SSE progress through the task
3832
+ // machinery exported by setup-manager.
3833
+ async installRuntime(opts) {
3834
+ const version = opts?.version ?? "latest";
3835
+ try {
3836
+ const openclawPkgDir = join(OPENCLAW_MODULES, "openclaw");
3837
+ if (existsSync(openclawPkgDir)) {
3838
+ const ver = readInstalledOpenclawVersion() || "unknown";
3839
+ return { ok: true, message: `OpenClaw already installed: ${ver}` };
3840
+ }
3841
+ const task = createTask("openclaw");
3842
+ ensureDirHost(OPENCLAW_PKG_DIR);
3843
+ emitTask(task, { type: "progress", message: "开始安装 OpenClaw...", progress: 0 });
3844
+ const sizeTracker = setInterval(() => {
3845
+ const sizeMB = getDirSizeMB(OPENCLAW_PKG_DIR);
3846
+ const pct = Math.min(95, Math.round((sizeMB / OPENCLAW_EXPECTED_SIZE_MB) * 95));
3847
+ if (pct > 0) {
3848
+ emitTask(task, {
3849
+ type: "progress",
3850
+ message: `下载安装中... ${sizeMB}MB / ~${OPENCLAW_EXPECTED_SIZE_MB}MB`,
3851
+ progress: pct,
3852
+ });
3853
+ }
3854
+ }, 3000);
3855
+ const result = await spawnWithTask(task, "npm", ["install", "-g", "--prefix", OPENCLAW_PKG_DIR, `openclaw@${version}`], { timeout: 600000, progressParser: npmProgressParser });
3856
+ clearInterval(sizeTracker);
3857
+ if (!result.ok) {
3858
+ emitTask(task, { type: "error", message: "OpenClaw 安装失败" });
3859
+ task.status = "error";
3860
+ return {
3861
+ ok: false,
3862
+ message: "OpenClaw installation failed",
3863
+ error: result.output,
3864
+ taskId: task.id,
3865
+ };
3866
+ }
3867
+ const ver = readInstalledOpenclawVersion() || "installed";
3868
+ emitTask(task, { type: "done", message: `OpenClaw 安装完成: ${ver}`, progress: 100 });
3869
+ task.status = "done";
3870
+ return { ok: true, message: `OpenClaw installed: ${ver}`, taskId: task.id };
3871
+ }
3872
+ catch (e) {
3873
+ return { ok: false, message: "OpenClaw installation failed", error: e.message };
3874
+ }
3875
+ }
3876
+ /**
3877
+ * Build / pull the OpenClaw Docker image. Blocking — useful for CLI
3878
+ * installer and `runFullSetup()`. Non-blocking variant below is used by
3879
+ * the REST API and the integration's own `onBeforeStart` self-heal path.
3880
+ */
3881
+ async buildRuntimeImage(opts) {
3882
+ const task = createTask("openclaw-docker-pull");
3883
+ return pullOrBuildOpenclawImageWithTask(task, opts?.tag);
3884
+ }
3885
+ /**
3886
+ * Non-blocking variant of `buildRuntimeImage` — returns a task id
3887
+ * immediately so the caller can poll SSE progress.
3888
+ */
3889
+ startBuildRuntimeImage(opts) {
3890
+ const task = createTask("openclaw-docker-pull");
3891
+ void pullOrBuildOpenclawImageWithTask(task, opts?.tag).catch((err) => {
3892
+ emitTask(task, {
3893
+ type: "error",
3894
+ message: `镜像获取失败: ${err?.message || err}`,
3895
+ });
3896
+ task.status = "error";
3897
+ });
3898
+ return { ok: true, message: "Docker image pull started", taskId: task.id };
3899
+ }
3900
+ /**
3901
+ * Return OpenClaw's readiness for spawning instances. Docker image
3902
+ * presence is the gating factor in the default docker-mode deployment;
3903
+ * the legacy `npm install` path is still reported as `installed` but is
3904
+ * not required for the docker-driver stack.
3905
+ */
3906
+ getInstallStatus() {
3907
+ // OPENCLAW_MODULES may be undefined when config is partially mocked in tests.
3908
+ const pkgInstalled = OPENCLAW_MODULES ? existsSync(join(OPENCLAW_MODULES, "openclaw")) : false;
3909
+ const version = pkgInstalled ? readInstalledOpenclawVersion() : undefined;
3910
+ const imageTag = getOpenclawDockerImage?.() ?? "";
3911
+ let imageReady = false;
3912
+ try {
3913
+ const invocation = resolveDockerInvocation();
3914
+ if (invocation?.cmd) {
3915
+ execFileSync(invocation.cmd, [...invocation.argsPrefix, "image", "inspect", imageTag], {
3916
+ timeout: 5000,
3917
+ stdio: "ignore",
3918
+ });
3919
+ imageReady = true;
3920
+ }
3921
+ }
3922
+ catch { /* image absent */ }
3923
+ return {
3924
+ installed: imageReady || pkgInstalled,
3925
+ imageReady,
3926
+ version: version || undefined,
3927
+ };
3928
+ }
3929
+ }
3930
+ // ── Install-time helpers (used by installRuntime) ─────────────────────
3931
+ const OPENCLAW_EXPECTED_SIZE_MB = 700;
3932
+ function readInstalledOpenclawVersion() {
3933
+ try {
3934
+ const pkg = join(OPENCLAW_MODULES, "openclaw", "package.json");
3935
+ if (existsSync(pkg))
3936
+ return JSON.parse(readFileSync(pkg, "utf-8")).version || "";
3937
+ }
3938
+ catch {
3939
+ /* best effort */
3940
+ }
3941
+ return "";
3942
+ }
3943
+ // Feishu app IDs issued by the open platform follow `cli_<hex/alnum>`.
3944
+ const FEISHU_APP_ID_RE = /^cli_[a-zA-Z0-9]{8,64}$/;
3945
+ const SAFE_ACCOUNT_ID_RE = /^[a-zA-Z0-9@._-]{1,128}$/;
3946
+ // ── Channel plugin constants (physically migrated) ───────────────────
3947
+ const CHANNEL_EXT_DIR_ALIAS = {
3948
+ feishu: "openclaw-lark",
3949
+ lark: "openclaw-lark",
3950
+ };
3951
+ const CHANNEL_PLUGIN_MAP = {
3952
+ feishu: "@larksuite/openclaw-lark",
3953
+ lark: "@larksuite/openclaw-lark",
3954
+ telegram: "@openclaw/telegram",
3955
+ discord: "@openclaw/discord",
3956
+ slack: "@openclaw/slack",
3957
+ whatsapp: "@openclaw/whatsapp",
3958
+ signal: "@openclaw/signal",
3959
+ line: "@openclaw/line",
3960
+ msteams: "@openclaw/msteams",
3961
+ "openclaw-weixin": "@tencent-weixin/openclaw-weixin",
3962
+ };
3963
+ const IM_PLUGIN_ENTRY_IDS = new Set([
3964
+ ...Object.keys(CHANNEL_PLUGIN_MAP),
3965
+ ...Object.values(CHANNEL_EXT_DIR_ALIAS),
3966
+ ]);
3967
+ // ── Config I/O helpers (physically migrated) ─────────────────────────
3968
+ function hasConfiguredValue(value) {
3969
+ if (typeof value !== "string")
3970
+ return !!value;
3971
+ return value.trim().length > 0;
3972
+ }
3973
+ function loadJsonSafe(path) {
3974
+ try {
3975
+ return JSON.parse(readFileSync(path, "utf-8"));
3976
+ }
3977
+ catch (e) {
3978
+ console.warn(`[openclaw] Failed to parse ${path}: ${e.message}`);
3979
+ return null;
3980
+ }
3981
+ }
3982
+ function loadEffectiveConfig(instanceId) {
3983
+ migrateLegacyOuterConfigOnce(instanceId);
3984
+ const runtimePath = openclawConfigPath(instanceId);
3985
+ if (existsSync(runtimePath))
3986
+ return loadJsonSafe(runtimePath);
3987
+ return null;
3988
+ }
3989
+ function applyFeishuDebugAccessDefaults(channel) {
3990
+ if (channel.enabled === false)
3991
+ return;
3992
+ if (!hasConfiguredValue(channel.appId))
3993
+ return;
3994
+ if (!hasConfiguredValue(channel.appSecret))
3995
+ return;
3996
+ let dmPolicy = channel.dmPolicy;
3997
+ if (typeof dmPolicy !== "string" || !dmPolicy.trim()) {
3998
+ channel.dmPolicy = "open";
3999
+ dmPolicy = "open";
4000
+ }
4001
+ if (dmPolicy !== "open")
4002
+ return;
4003
+ if (!("resolveSenderNames" in channel))
4004
+ channel.resolveSenderNames = false;
4005
+ let accounts = channel.accounts;
4006
+ if (typeof accounts !== "object" || accounts === null) {
4007
+ accounts = {};
4008
+ channel.accounts = accounts;
4009
+ }
4010
+ let defaultAccount = accounts.default;
4011
+ if (typeof defaultAccount !== "object" || defaultAccount === null) {
4012
+ defaultAccount = {};
4013
+ accounts.default = defaultAccount;
4014
+ }
4015
+ if (!("resolveSenderNames" in defaultAccount))
4016
+ defaultAccount.resolveSenderNames = false;
4017
+ const allowFrom = channel.allowFrom;
4018
+ if (Array.isArray(allowFrom)) {
4019
+ const normalized = allowFrom.map((e) => String(e).trim()).filter(Boolean);
4020
+ if (!normalized.includes("*"))
4021
+ normalized.push("*");
4022
+ channel.allowFrom = normalized;
4023
+ return;
4024
+ }
4025
+ channel.allowFrom = ["*"];
4026
+ }
4027
+ function prepareConfigForSave(config) {
4028
+ const configToWrite = structuredClone(config);
4029
+ delete configToWrite["x-jishushell"];
4030
+ const providers = configToWrite.models?.providers || {};
4031
+ const channels = configToWrite.channels || {};
4032
+ const plugins = configToWrite.plugins ??= {};
4033
+ const pluginEntries = plugins.entries ??= {};
4034
+ for (const [providerId, provider] of Object.entries(providers)) {
4035
+ if (typeof provider !== "object" || provider === null)
4036
+ continue;
4037
+ const p = provider;
4038
+ p.api = normalizeProviderApi(typeof p.api === "string" ? p.api : undefined);
4039
+ // Ensure allowPrivateNetwork for providers targeting the local proxy
4040
+ if (typeof p.baseUrl === "string" && isPrivateNetworkBaseUrl(p.baseUrl)) {
4041
+ p.request = { ...(p.request || {}), allowPrivateNetwork: true };
4042
+ }
4043
+ if (!("apiKey" in p))
4044
+ continue;
4045
+ if (typeof p.baseUrl === "string" && p.baseUrl.includes("/proxy/"))
4046
+ continue;
4047
+ // Step 7: normal OpenClaw config saves must not write legacy
4048
+ // provider-specific *_API_KEY env variables. API keys for the active
4049
+ // upstream are persisted by llm-proxy.saveInstanceConfig() into
4050
+ // provider.env; if a raw provider apiKey leaks into this lower-level save
4051
+ // path, strip it from openclaw.json rather than creating a second secret
4052
+ // source.
4053
+ delete p.apiKey;
4054
+ }
4055
+ for (const [channelId, channel] of Object.entries(channels)) {
4056
+ if (typeof channel !== "object" || channel === null)
4057
+ continue;
4058
+ const ch = channel;
4059
+ if (channelId === "feishu" || channelId === "lark")
4060
+ applyFeishuDebugAccessDefaults(ch);
4061
+ let pluginEntry = pluginEntries[channelId];
4062
+ if (pluginEntry == null) {
4063
+ pluginEntry = {};
4064
+ pluginEntries[channelId] = pluginEntry;
4065
+ }
4066
+ if (typeof pluginEntry === "object") {
4067
+ pluginEntry.enabled = ch.enabled !== false;
4068
+ }
4069
+ }
4070
+ return configToWrite;
4071
+ }
4072
+ /**
4073
+ * Auto-injects provider-specific host env vars that OpenClaw tools need
4074
+ * at runtime, if the user hasn't already set them explicitly.
4075
+ *
4076
+ * Currently handles:
4077
+ * - MINIMAX_API_HOST: Derived from MINIMAX_BASE_URL or upstream proxy config
4078
+ * to ensure the VLM tool calls the correct MiniMax API domain.
4079
+ *
4080
+ * Note: Only MiniMax needs this because its VLM tool reads MINIMAX_API_HOST
4081
+ * to determine the endpoint. DeepSeek does not have a dedicated VLM tool
4082
+ * in OpenClaw that requires a similar host env var.
4083
+ */
4084
+ function injectProviderHostEnv(env, instanceId) {
4085
+ // MINIMAX_API_HOST — needed by OpenClaw's VLM tool to call the correct domain
4086
+ if (!env.MINIMAX_API_HOST) {
4087
+ const baseUrl = env.MINIMAX_BASE_URL || "";
4088
+ if (baseUrl) {
4089
+ try {
4090
+ const parsed = new URL(baseUrl);
4091
+ env.MINIMAX_API_HOST = `${parsed.protocol}//${parsed.host}`;
4092
+ }
4093
+ catch { /* invalid URL, skip */ }
4094
+ }
4095
+ else {
4096
+ // Infer from upstream proxy config if available
4097
+ const config = getProxyInstanceConfig(instanceId);
4098
+ const upstream = config?.["x-jishushell"]?.proxy?.upstream;
4099
+ if (upstream?.providerId === "minimax" && upstream.baseUrl) {
4100
+ try {
4101
+ const parsed = new URL(upstream.baseUrl);
4102
+ env.MINIMAX_API_HOST = `${parsed.protocol}//${parsed.host}`;
4103
+ }
4104
+ catch { /* invalid URL, skip */ }
4105
+ }
4106
+ }
4107
+ }
4108
+ }
4109
+ /**
4110
+ * Dissociate a cloned/imported config from its source instance's IM bindings.
4111
+ * Physically migrated from `instance-manager.stripImBindings` so framework
4112
+ * code no longer references OpenClaw channel concepts.
4113
+ *
4114
+ * Exported so `OpenClawIntegration.createInstance`'s clone path + `backup-manager`
4115
+ * import paths can use it without depending on instance-manager.
4116
+ */
4117
+ export function stripImBindings(config) {
4118
+ if (config?.channels)
4119
+ delete config.channels;
4120
+ const entries = config?.plugins?.entries;
4121
+ if (entries && typeof entries === "object") {
4122
+ for (const key of Object.keys(entries)) {
4123
+ if (IM_PLUGIN_ENTRY_IDS.has(key))
4124
+ delete entries[key];
4125
+ }
4126
+ }
4127
+ }
4128
+ function getChannelExtensionsDir(instanceId) {
4129
+ const home = openclawHomeFromMetadata(getInstance(instanceId), instanceId);
4130
+ return join(home, OPENCLAW_STATE_DIRNAME, "extensions");
4131
+ }
4132
+ function getStockExtensionsDir() {
4133
+ return join(JISHUSHELL_HOME, "packages", "openclaw", "lib", "node_modules", "openclaw", "extensions");
4134
+ }
4135
+ function isChannelPluginInstalled(instanceId, channelId) {
4136
+ const extDirName = CHANNEL_EXT_DIR_ALIAS[channelId] || channelId;
4137
+ const stockExtDir = getStockExtensionsDir();
4138
+ if (existsSync(join(getChannelExtensionsDir(instanceId), extDirName)))
4139
+ return true;
4140
+ if (existsSync(join(stockExtDir, extDirName)))
4141
+ return true;
4142
+ if (extDirName !== channelId && existsSync(join(stockExtDir, channelId)))
4143
+ return true;
4144
+ // OpenClaw's npm-backed plugin store lives at
4145
+ // `<home>/.openclaw/npm/node_modules/<pkg>`. The CLI refuses to reinstall
4146
+ // when that path is present ("plugin already exists ... delete it first"),
4147
+ // even if the per-instance extensions/<name> dir is missing (e.g. the
4148
+ // first install was interrupted, or the dir was manually cleaned). Treat
4149
+ // the npm path as authoritative so re-saves stay idempotent.
4150
+ const pkg = CHANNEL_PLUGIN_MAP[channelId];
4151
+ if (pkg) {
4152
+ const home = openclawHomeFromMetadata(getInstance(instanceId), instanceId);
4153
+ const npmPath = join(home, OPENCLAW_STATE_DIRNAME, "npm", "node_modules", ...pkg.split("/"));
4154
+ if (existsSync(npmPath))
4155
+ return true;
4156
+ }
4157
+ return false;
4158
+ }
4159
+ /**
4160
+ * Install a single channel plugin. Docker mode → `docker exec` inside the
4161
+ * running container. Host mode → spawn the host openclaw binary directly.
4162
+ * Physically migrated from `instance-manager.installChannelPlugin`.
4163
+ */
4164
+ async function installChannelPlugin(instanceId, channelId) {
4165
+ const pkg = CHANNEL_PLUGIN_MAP[channelId];
4166
+ if (!pkg)
4167
+ throw new Error(`Unknown channel: ${channelId}`);
4168
+ if (isChannelPluginInstalled(instanceId, channelId))
4169
+ return;
4170
+ const home = openclawHomeFromMetadata(getInstance(instanceId), instanceId);
4171
+ const extensionsDir = getChannelExtensionsDir(instanceId);
4172
+ if (getNomadDriver() === "docker") {
4173
+ await installChannelPluginViaDocker(instanceId, channelId, pkg, extensionsDir);
4174
+ return;
4175
+ }
4176
+ const openclawBin = resolveOpenclawBin();
4177
+ const nodeBinDir = dirname(process.execPath);
4178
+ const childPath = [nodeBinDir, process.env.PATH].filter(Boolean).join(":");
4179
+ const proxyEnvKeys = [
4180
+ "http_proxy", "HTTP_PROXY", "https_proxy", "HTTPS_PROXY",
4181
+ "no_proxy", "NO_PROXY", "NODE_EXTRA_CA_CERTS", "NODE_TLS_REJECT_UNAUTHORIZED",
4182
+ ];
4183
+ const proxyEnv = {};
4184
+ for (const key of proxyEnvKeys) {
4185
+ if (process.env[key])
4186
+ proxyEnv[key] = process.env[key];
4187
+ }
4188
+ const childEnv = {
4189
+ PATH: childPath,
4190
+ HOME: process.env.HOME,
4191
+ LANG: process.env.LANG,
4192
+ OPENCLAW_HOME: home,
4193
+ ...proxyEnv,
4194
+ };
4195
+ const MAX_ATTEMPTS = 3;
4196
+ const RETRY_DELAY_MS = 5_000;
4197
+ const attemptInstall = () => new Promise((resolve, reject) => {
4198
+ execFile(openclawBin, ["plugins", "install", pkg], { cwd: home, env: childEnv, timeout: 300_000 }, (err, stdout, stderr) => {
4199
+ if (err && !isChannelPluginInstalled(instanceId, channelId)) {
4200
+ const msg = [stderr?.trim(), stdout?.trim(), err.message].filter(Boolean).join(" | ");
4201
+ console.error(`[plugins] ${pkg} exit code ${err.code ?? "?"}, stderr: ${stderr?.trim() || "(empty)"}, stdout: ${stdout?.trim() || "(empty)"}`);
4202
+ try {
4203
+ if (existsSync(extensionsDir)) {
4204
+ for (const entry of readdirSync(extensionsDir)) {
4205
+ if (entry.startsWith(".openclaw-install-stage-")) {
4206
+ rmSync(join(extensionsDir, entry), { recursive: true, force: true });
4207
+ console.log(`[plugins] Cleaned up stage dir: ${entry}`);
4208
+ }
4209
+ }
4210
+ }
4211
+ }
4212
+ catch {
4213
+ /* ignore */
4214
+ }
4215
+ reject(new Error(msg));
4216
+ }
4217
+ else {
4218
+ if (err)
4219
+ console.log(`[plugins] ${pkg} installed (ignored non-zero exit)`);
4220
+ else
4221
+ console.log(`[plugins] ${pkg} installed`);
4222
+ resolve();
4223
+ }
4224
+ });
4225
+ });
4226
+ console.log(`[plugins] Installing ${pkg} for ${channelId} (host)...`);
4227
+ let lastErr;
4228
+ for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
4229
+ try {
4230
+ await attemptInstall();
4231
+ const extDirName = CHANNEL_EXT_DIR_ALIAS[channelId] || channelId;
4232
+ const installedExtDir = join(extensionsDir, extDirName);
4233
+ if (existsSync(installedExtDir)) {
4234
+ ensureDirContainer(installedExtDir);
4235
+ try {
4236
+ for (const entry of readdirSync(installedExtDir, { withFileTypes: true })) {
4237
+ if (entry.isDirectory()) {
4238
+ ensureDirContainer(join(installedExtDir, entry.name));
4239
+ }
4240
+ }
4241
+ }
4242
+ catch {
4243
+ /* best effort */
4244
+ }
4245
+ }
4246
+ ensureDirContainer(extensionsDir);
4247
+ return;
4248
+ }
4249
+ catch (err) {
4250
+ lastErr = err;
4251
+ const isFetchError = /fetch failed/i.test(err.message ?? "");
4252
+ if (isFetchError && attempt < MAX_ATTEMPTS) {
4253
+ console.warn(`[plugins] ${pkg} install attempt ${attempt}/${MAX_ATTEMPTS} failed, retrying in ${RETRY_DELAY_MS / 1000}s...`);
4254
+ await new Promise((r) => setTimeout(r, RETRY_DELAY_MS));
4255
+ continue;
4256
+ }
4257
+ console.error(`[plugins] Failed to install ${pkg}:`, err.message);
4258
+ break;
4259
+ }
4260
+ }
4261
+ throw lastErr;
4262
+ }
4263
+ async function installChannelPluginViaDocker(instanceId, channelId, pkg, extensionsDir) {
4264
+ const { exec } = await import("../../runtime/drivers/nomad.js");
4265
+ const MAX_ATTEMPTS = 3;
4266
+ const RETRY_DELAY_MS = 5_000;
4267
+ console.log(`[plugins] Installing ${pkg} for ${channelId} via docker exec (instance: ${instanceId})...`);
4268
+ let lastErr;
4269
+ for (let attempt = 1; attempt <= MAX_ATTEMPTS; attempt++) {
4270
+ try {
4271
+ const result = await exec(instanceId, ["openclaw", "plugins", "install", pkg], 300_000);
4272
+ if (result.exitCode !== 0 && !isChannelPluginInstalled(instanceId, channelId)) {
4273
+ const msg = [result.stderr?.trim(), result.stdout?.trim()].filter(Boolean).join(" | ");
4274
+ console.error(`[plugins] ${pkg} docker exec exit code ${result.exitCode}, output: ${msg}`);
4275
+ throw new Error(msg || `openclaw plugins install exited with code ${result.exitCode}`);
4276
+ }
4277
+ if (result.exitCode !== 0) {
4278
+ console.log(`[plugins] ${pkg} installed via docker (ignored non-zero exit)`);
4279
+ }
4280
+ else {
4281
+ console.log(`[plugins] ${pkg} installed via docker`);
4282
+ }
4283
+ const extDirName = CHANNEL_EXT_DIR_ALIAS[channelId] || channelId;
4284
+ const installedExtDir = join(extensionsDir, extDirName);
4285
+ if (existsSync(installedExtDir)) {
4286
+ ensureDirContainer(installedExtDir);
4287
+ try {
4288
+ for (const entry of readdirSync(installedExtDir, { withFileTypes: true })) {
4289
+ if (entry.isDirectory()) {
4290
+ ensureDirContainer(join(installedExtDir, entry.name));
4291
+ }
4292
+ }
4293
+ }
4294
+ catch {
4295
+ /* best effort */
4296
+ }
4297
+ }
4298
+ ensureDirContainer(extensionsDir);
4299
+ return;
4300
+ }
4301
+ catch (err) {
4302
+ lastErr = err;
4303
+ if (/not running/i.test(err.message ?? "")) {
4304
+ throw new Error("请先启动实例后再安装插件(Docker 模式下插件需在容器内安装)");
4305
+ }
4306
+ const isTransient = /fetch failed|ECONNREFUSED/i.test(err.message ?? "");
4307
+ if (isTransient && attempt < MAX_ATTEMPTS) {
4308
+ console.warn(`[plugins] ${pkg} docker install attempt ${attempt}/${MAX_ATTEMPTS} failed, retrying...`);
4309
+ await new Promise((r) => setTimeout(r, RETRY_DELAY_MS));
4310
+ continue;
4311
+ }
4312
+ console.error(`[plugins] Failed to install ${pkg} via docker:`, err.message);
4313
+ break;
4314
+ }
4315
+ }
4316
+ throw lastErr;
4317
+ }
4318
+ /**
4319
+ * Full saveConfig implementation. Writes `.openclaw/openclaw.json`, updates
4320
+ * env files with provider API keys, preserves backend-managed fields, and
4321
+ * fires config-change listeners.
4322
+ *
4323
+ * Step 6 boundary: normal saves must not mirror into the legacy outer
4324
+ * `$OPENCLAW_HOME/openclaw.json`. Any old outer config is migrated once before
4325
+ * writing canonical state, then removed.
4326
+ *
4327
+ * Physically migrated from `instance-manager.saveConfig`.
4328
+ */
4329
+ function saveNativeConfigImpl(instanceId, config) {
4330
+ const configPath = openclawConfigPath(instanceId);
4331
+ if (!existsSync(framework_instanceDir(instanceId)))
4332
+ return false;
4333
+ migrateLegacyOuterConfigOnce(instanceId);
4334
+ // Save x-jishushell metadata to instance.json (not openclaw.json)
4335
+ if (config["x-jishushell"]) {
4336
+ updateInstanceMeta(instanceId, { "x-jishushell": config["x-jishushell"] });
4337
+ }
4338
+ const configToWrite = prepareConfigForSave(config);
4339
+ const temporaryHosts = readTemporaryBrowserAllowedHostnames(instanceId);
4340
+ const configWithTemporaryHosts = applyTemporaryBrowserAllowlistToConfigObject(configToWrite, temporaryHosts);
4341
+ // If openclaw-lark is enabled, resolve which feishu plugin to use
4342
+ if (configWithTemporaryHosts.plugins?.entries?.["openclaw-lark"]?.enabled) {
4343
+ const stockExtDir = getStockExtensionsDir();
4344
+ const stockFeishu = join(stockExtDir, "feishu");
4345
+ const stockOcl = join(stockExtDir, "openclaw-lark");
4346
+ const instanceOcl = join(getChannelExtensionsDir(instanceId), "openclaw-lark");
4347
+ if (existsSync(stockFeishu) && !existsSync(stockOcl) && !existsSync(instanceOcl)) {
4348
+ configWithTemporaryHosts.plugins.entries.feishu = { enabled: true };
4349
+ delete configWithTemporaryHosts.plugins.entries["openclaw-lark"];
4350
+ }
4351
+ else if (existsSync(stockFeishu)) {
4352
+ configWithTemporaryHosts.plugins ??= {};
4353
+ configWithTemporaryHosts.plugins.entries ??= {};
4354
+ configWithTemporaryHosts.plugins.entries.feishu = { enabled: false };
4355
+ }
4356
+ }
4357
+ // Preserve backend-managed fields
4358
+ if (existsSync(configPath)) {
4359
+ try {
4360
+ const existing = JSON.parse(readFileSync(configPath, "utf-8"));
4361
+ if (existing.plugins?.installs) {
4362
+ configWithTemporaryHosts.plugins ??= {};
4363
+ configWithTemporaryHosts.plugins.installs = { ...existing.plugins.installs, ...configWithTemporaryHosts.plugins?.installs };
4364
+ }
4365
+ if (existing.plugins?.entries && configWithTemporaryHosts.plugins?.entries) {
4366
+ for (const [key, val] of Object.entries(configWithTemporaryHosts.plugins.entries)) {
4367
+ const old = existing.plugins.entries[key];
4368
+ if (val && typeof val === "object" && !Array.isArray(val) && old && typeof old === "object") {
4369
+ configWithTemporaryHosts.plugins.entries[key] = { ...old, ...val };
4370
+ }
4371
+ }
4372
+ }
4373
+ if (existing.channels && configWithTemporaryHosts.channels) {
4374
+ for (const [key, val] of Object.entries(configWithTemporaryHosts.channels)) {
4375
+ const old = existing.channels[key];
4376
+ if (val && typeof val === "object" && !Array.isArray(val) && old && typeof old === "object") {
4377
+ configWithTemporaryHosts.channels[key] = { ...old, ...val };
4378
+ }
4379
+ }
4380
+ }
4381
+ }
4382
+ catch {
4383
+ /* best effort */
4384
+ }
4385
+ }
4386
+ // Backup + atomic write
4387
+ if (existsSync(configPath)) {
4388
+ copyFileSync(configPath, configPath + ".bak");
4389
+ }
4390
+ const configJson = JSON.stringify(configWithTemporaryHosts, null, 2);
4391
+ ensureDirContainer(dirname(configPath));
4392
+ writeConfigFile(configPath + ".tmp", configJson);
4393
+ JSON.parse(readFileSync(configPath + ".tmp", "utf-8"));
4394
+ renameSync(configPath + ".tmp", configPath);
4395
+ chownToServiceUser(configPath);
4396
+ // Notify listeners (LLM proxy cache invalidation etc.)
4397
+ notifyConfigChange(instanceId);
4398
+ return true;
4399
+ }
4400
+ export const openclawIntegration = new OpenClawIntegration();
4401
+ registerIntegration(openclawIntegration);
4402
+ //# sourceMappingURL=integration.js.map