@aquaclawai/aquarium 1.0.0

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 (517) hide show
  1. package/dist/agent-types/claude-code/index.d.ts +2 -0
  2. package/dist/agent-types/claude-code/index.d.ts.map +1 -0
  3. package/dist/agent-types/claude-code/index.js +2 -0
  4. package/dist/agent-types/claude-code/index.js.map +1 -0
  5. package/dist/agent-types/claude-code/manifest.d.ts +3 -0
  6. package/dist/agent-types/claude-code/manifest.d.ts.map +1 -0
  7. package/dist/agent-types/claude-code/manifest.js +45 -0
  8. package/dist/agent-types/claude-code/manifest.js.map +1 -0
  9. package/dist/agent-types/openclaw/adapter.d.ts +3 -0
  10. package/dist/agent-types/openclaw/adapter.d.ts.map +1 -0
  11. package/dist/agent-types/openclaw/adapter.js +714 -0
  12. package/dist/agent-types/openclaw/adapter.js.map +1 -0
  13. package/dist/agent-types/openclaw/gateway-rpc.d.ts +21 -0
  14. package/dist/agent-types/openclaw/gateway-rpc.d.ts.map +1 -0
  15. package/dist/agent-types/openclaw/gateway-rpc.js +202 -0
  16. package/dist/agent-types/openclaw/gateway-rpc.js.map +1 -0
  17. package/dist/agent-types/openclaw/index.d.ts +3 -0
  18. package/dist/agent-types/openclaw/index.d.ts.map +1 -0
  19. package/dist/agent-types/openclaw/index.js +3 -0
  20. package/dist/agent-types/openclaw/index.js.map +1 -0
  21. package/dist/agent-types/openclaw/manifest.d.ts +137 -0
  22. package/dist/agent-types/openclaw/manifest.d.ts.map +1 -0
  23. package/dist/agent-types/openclaw/manifest.js +191 -0
  24. package/dist/agent-types/openclaw/manifest.js.map +1 -0
  25. package/dist/agent-types/openclaw/provider-registry.d.ts +46 -0
  26. package/dist/agent-types/openclaw/provider-registry.d.ts.map +1 -0
  27. package/dist/agent-types/openclaw/provider-registry.js +108 -0
  28. package/dist/agent-types/openclaw/provider-registry.js.map +1 -0
  29. package/dist/agent-types/openclaw/reverse-adapter.d.ts +7 -0
  30. package/dist/agent-types/openclaw/reverse-adapter.d.ts.map +1 -0
  31. package/dist/agent-types/openclaw/reverse-adapter.js +528 -0
  32. package/dist/agent-types/openclaw/reverse-adapter.js.map +1 -0
  33. package/dist/agent-types/openclaw/security-profiles.d.ts +21 -0
  34. package/dist/agent-types/openclaw/security-profiles.d.ts.map +1 -0
  35. package/dist/agent-types/openclaw/security-profiles.js +251 -0
  36. package/dist/agent-types/openclaw/security-profiles.js.map +1 -0
  37. package/dist/agent-types/openclaw/workspace-templates.d.ts +2 -0
  38. package/dist/agent-types/openclaw/workspace-templates.d.ts.map +1 -0
  39. package/dist/agent-types/openclaw/workspace-templates.js +363 -0
  40. package/dist/agent-types/openclaw/workspace-templates.js.map +1 -0
  41. package/dist/agent-types/opencode/index.d.ts +2 -0
  42. package/dist/agent-types/opencode/index.d.ts.map +1 -0
  43. package/dist/agent-types/opencode/index.js +2 -0
  44. package/dist/agent-types/opencode/index.js.map +1 -0
  45. package/dist/agent-types/opencode/manifest.d.ts +3 -0
  46. package/dist/agent-types/opencode/manifest.d.ts.map +1 -0
  47. package/dist/agent-types/opencode/manifest.js +63 -0
  48. package/dist/agent-types/opencode/manifest.js.map +1 -0
  49. package/dist/agent-types/registry.d.ts +4 -0
  50. package/dist/agent-types/registry.d.ts.map +1 -0
  51. package/dist/agent-types/registry.js +24 -0
  52. package/dist/agent-types/registry.js.map +1 -0
  53. package/dist/agent-types/types.d.ts +169 -0
  54. package/dist/agent-types/types.d.ts.map +1 -0
  55. package/dist/agent-types/types.js +2 -0
  56. package/dist/agent-types/types.js.map +1 -0
  57. package/dist/cli.d.ts +3 -0
  58. package/dist/cli.d.ts.map +1 -0
  59. package/dist/cli.js +72 -0
  60. package/dist/cli.js.map +1 -0
  61. package/dist/config.d.ts +68 -0
  62. package/dist/config.d.ts.map +1 -0
  63. package/dist/config.js +98 -0
  64. package/dist/config.js.map +1 -0
  65. package/dist/db/adapter.d.ts +21 -0
  66. package/dist/db/adapter.d.ts.map +1 -0
  67. package/dist/db/adapter.js +11 -0
  68. package/dist/db/adapter.js.map +1 -0
  69. package/dist/db/index.d.ts +4 -0
  70. package/dist/db/index.d.ts.map +1 -0
  71. package/dist/db/index.js +5 -0
  72. package/dist/db/index.js.map +1 -0
  73. package/dist/db/knexfile.d.ts +5 -0
  74. package/dist/db/knexfile.d.ts.map +1 -0
  75. package/dist/db/knexfile.js +34 -0
  76. package/dist/db/knexfile.js.map +1 -0
  77. package/dist/db/migration-helpers.d.ts +45 -0
  78. package/dist/db/migration-helpers.d.ts.map +1 -0
  79. package/dist/db/migration-helpers.js +90 -0
  80. package/dist/db/migration-helpers.js.map +1 -0
  81. package/dist/db/migrations/001_initial.d.ts +4 -0
  82. package/dist/db/migrations/001_initial.d.ts.map +1 -0
  83. package/dist/db/migrations/001_initial.js +56 -0
  84. package/dist/db/migrations/001_initial.js.map +1 -0
  85. package/dist/db/migrations/002_instance_config.d.ts +4 -0
  86. package/dist/db/migrations/002_instance_config.d.ts.map +1 -0
  87. package/dist/db/migrations/002_instance_config.js +12 -0
  88. package/dist/db/migrations/002_instance_config.js.map +1 -0
  89. package/dist/db/migrations/003_instance_status_message.d.ts +4 -0
  90. package/dist/db/migrations/003_instance_status_message.d.ts.map +1 -0
  91. package/dist/db/migrations/003_instance_status_message.js +11 -0
  92. package/dist/db/migrations/003_instance_status_message.js.map +1 -0
  93. package/dist/db/migrations/004_templates.d.ts +4 -0
  94. package/dist/db/migrations/004_templates.d.ts.map +1 -0
  95. package/dist/db/migrations/004_templates.js +95 -0
  96. package/dist/db/migrations/004_templates.js.map +1 -0
  97. package/dist/db/migrations/005_group_chats.d.ts +4 -0
  98. package/dist/db/migrations/005_group_chats.d.ts.map +1 -0
  99. package/dist/db/migrations/005_group_chats.js +66 -0
  100. package/dist/db/migrations/005_group_chats.js.map +1 -0
  101. package/dist/db/migrations/006_template_setup.d.ts +4 -0
  102. package/dist/db/migrations/006_template_setup.d.ts.map +1 -0
  103. package/dist/db/migrations/006_template_setup.js +14 -0
  104. package/dist/db/migrations/006_template_setup.js.map +1 -0
  105. package/dist/db/migrations/007_group_chat_v2.d.ts +4 -0
  106. package/dist/db/migrations/007_group_chat_v2.d.ts.map +1 -0
  107. package/dist/db/migrations/007_group_chat_v2.js +59 -0
  108. package/dist/db/migrations/007_group_chat_v2.js.map +1 -0
  109. package/dist/db/migrations/008_default_provider_openrouter.d.ts +4 -0
  110. package/dist/db/migrations/008_default_provider_openrouter.d.ts.map +1 -0
  111. package/dist/db/migrations/008_default_provider_openrouter.js +33 -0
  112. package/dist/db/migrations/008_default_provider_openrouter.js.map +1 -0
  113. package/dist/db/migrations/009_opencode_default_provider_openrouter.d.ts +4 -0
  114. package/dist/db/migrations/009_opencode_default_provider_openrouter.d.ts.map +1 -0
  115. package/dist/db/migrations/009_opencode_default_provider_openrouter.js +33 -0
  116. package/dist/db/migrations/009_opencode_default_provider_openrouter.js.map +1 -0
  117. package/dist/db/migrations/010_fix_null_default_provider.d.ts +4 -0
  118. package/dist/db/migrations/010_fix_null_default_provider.d.ts.map +1 -0
  119. package/dist/db/migrations/010_fix_null_default_provider.js +24 -0
  120. package/dist/db/migrations/010_fix_null_default_provider.js.map +1 -0
  121. package/dist/db/migrations/011_snapshots.d.ts +4 -0
  122. package/dist/db/migrations/011_snapshots.d.ts.map +1 -0
  123. package/dist/db/migrations/011_snapshots.js +27 -0
  124. package/dist/db/migrations/011_snapshots.js.map +1 -0
  125. package/dist/db/migrations/013_official_templates.d.ts +4 -0
  126. package/dist/db/migrations/013_official_templates.d.ts.map +1 -0
  127. package/dist/db/migrations/013_official_templates.js +173 -0
  128. package/dist/db/migrations/013_official_templates.js.map +1 -0
  129. package/dist/db/migrations/014_notifications.d.ts +4 -0
  130. package/dist/db/migrations/014_notifications.d.ts.map +1 -0
  131. package/dist/db/migrations/014_notifications.js +45 -0
  132. package/dist/db/migrations/014_notifications.js.map +1 -0
  133. package/dist/db/migrations/015_security_profile.d.ts +4 -0
  134. package/dist/db/migrations/015_security_profile.d.ts.map +1 -0
  135. package/dist/db/migrations/015_security_profile.js +14 -0
  136. package/dist/db/migrations/015_security_profile.js.map +1 -0
  137. package/dist/db/migrations/016_template_security.d.ts +4 -0
  138. package/dist/db/migrations/016_template_security.d.ts.map +1 -0
  139. package/dist/db/migrations/016_template_security.js +12 -0
  140. package/dist/db/migrations/016_template_security.js.map +1 -0
  141. package/dist/db/migrations/017_auth_events.d.ts +4 -0
  142. package/dist/db/migrations/017_auth_events.d.ts.map +1 -0
  143. package/dist/db/migrations/017_auth_events.js +19 -0
  144. package/dist/db/migrations/017_auth_events.js.map +1 -0
  145. package/dist/db/migrations/018_skill_market.d.ts +4 -0
  146. package/dist/db/migrations/018_skill_market.d.ts.map +1 -0
  147. package/dist/db/migrations/018_skill_market.js +21 -0
  148. package/dist/db/migrations/018_skill_market.js.map +1 -0
  149. package/dist/db/migrations/019_credential_audit_log.d.ts +4 -0
  150. package/dist/db/migrations/019_credential_audit_log.d.ts.map +1 -0
  151. package/dist/db/migrations/019_credential_audit_log.js +19 -0
  152. package/dist/db/migrations/019_credential_audit_log.js.map +1 -0
  153. package/dist/db/migrations/020_template_security_score.d.ts +4 -0
  154. package/dist/db/migrations/020_template_security_score.d.ts.map +1 -0
  155. package/dist/db/migrations/020_template_security_score.js +31 -0
  156. package/dist/db/migrations/020_template_security_score.js.map +1 -0
  157. package/dist/db/migrations/021_credential_enhancements.d.ts +4 -0
  158. package/dist/db/migrations/021_credential_enhancements.d.ts.map +1 -0
  159. package/dist/db/migrations/021_credential_enhancements.js +15 -0
  160. package/dist/db/migrations/021_credential_enhancements.js.map +1 -0
  161. package/dist/db/migrations/021_user_roles.d.ts +4 -0
  162. package/dist/db/migrations/021_user_roles.d.ts.map +1 -0
  163. package/dist/db/migrations/021_user_roles.js +11 -0
  164. package/dist/db/migrations/021_user_roles.js.map +1 -0
  165. package/dist/db/migrations/022_config_hash.d.ts +4 -0
  166. package/dist/db/migrations/022_config_hash.d.ts.map +1 -0
  167. package/dist/db/migrations/022_config_hash.js +11 -0
  168. package/dist/db/migrations/022_config_hash.js.map +1 -0
  169. package/dist/db/migrations/023_account_security.d.ts +4 -0
  170. package/dist/db/migrations/023_account_security.d.ts.map +1 -0
  171. package/dist/db/migrations/023_account_security.js +22 -0
  172. package/dist/db/migrations/023_account_security.js.map +1 -0
  173. package/dist/db/migrations/024_wizard_configs.d.ts +4 -0
  174. package/dist/db/migrations/024_wizard_configs.d.ts.map +1 -0
  175. package/dist/db/migrations/024_wizard_configs.js +165 -0
  176. package/dist/db/migrations/024_wizard_configs.js.map +1 -0
  177. package/dist/db/migrations/025_auth_dual_mode.d.ts +4 -0
  178. package/dist/db/migrations/025_auth_dual_mode.d.ts.map +1 -0
  179. package/dist/db/migrations/025_auth_dual_mode.js +19 -0
  180. package/dist/db/migrations/025_auth_dual_mode.js.map +1 -0
  181. package/dist/db/migrations/027_add_avatar_to_instances.d.ts +4 -0
  182. package/dist/db/migrations/027_add_avatar_to_instances.d.ts.map +1 -0
  183. package/dist/db/migrations/027_add_avatar_to_instances.js +11 -0
  184. package/dist/db/migrations/027_add_avatar_to_instances.js.map +1 -0
  185. package/dist/db/migrations/027_add_clerk_id.d.ts +4 -0
  186. package/dist/db/migrations/027_add_clerk_id.d.ts.map +1 -0
  187. package/dist/db/migrations/027_add_clerk_id.js +11 -0
  188. package/dist/db/migrations/027_add_clerk_id.js.map +1 -0
  189. package/dist/db/migrations/028_template_plugin_dependencies.d.ts +4 -0
  190. package/dist/db/migrations/028_template_plugin_dependencies.d.ts.map +1 -0
  191. package/dist/db/migrations/028_template_plugin_dependencies.js +18 -0
  192. package/dist/db/migrations/028_template_plugin_dependencies.js.map +1 -0
  193. package/dist/db/migrations/029_remap_orphan_config_keys.d.ts +21 -0
  194. package/dist/db/migrations/029_remap_orphan_config_keys.d.ts.map +1 -0
  195. package/dist/db/migrations/029_remap_orphan_config_keys.js +63 -0
  196. package/dist/db/migrations/029_remap_orphan_config_keys.js.map +1 -0
  197. package/dist/db/migrations/030_extend_notification_types.d.ts +4 -0
  198. package/dist/db/migrations/030_extend_notification_types.d.ts.map +1 -0
  199. package/dist/db/migrations/030_extend_notification_types.js +10 -0
  200. package/dist/db/migrations/030_extend_notification_types.js.map +1 -0
  201. package/dist/db/migrations/031_default_security_profile_developer.d.ts +9 -0
  202. package/dist/db/migrations/031_default_security_profile_developer.d.ts.map +1 -0
  203. package/dist/db/migrations/031_default_security_profile_developer.js +22 -0
  204. package/dist/db/migrations/031_default_security_profile_developer.js.map +1 -0
  205. package/dist/db/migrations/032_geo_template.d.ts +4 -0
  206. package/dist/db/migrations/032_geo_template.d.ts.map +1 -0
  207. package/dist/db/migrations/032_geo_template.js +133 -0
  208. package/dist/db/migrations/032_geo_template.js.map +1 -0
  209. package/dist/db/migrations/033_jinko_travel_template.d.ts +4 -0
  210. package/dist/db/migrations/033_jinko_travel_template.d.ts.map +1 -0
  211. package/dist/db/migrations/033_jinko_travel_template.js +126 -0
  212. package/dist/db/migrations/033_jinko_travel_template.js.map +1 -0
  213. package/dist/db/postgres-adapter.d.ts +13 -0
  214. package/dist/db/postgres-adapter.d.ts.map +1 -0
  215. package/dist/db/postgres-adapter.js +27 -0
  216. package/dist/db/postgres-adapter.js.map +1 -0
  217. package/dist/db/run-migrations.d.ts +2 -0
  218. package/dist/db/run-migrations.d.ts.map +1 -0
  219. package/dist/db/run-migrations.js +26 -0
  220. package/dist/db/run-migrations.js.map +1 -0
  221. package/dist/db/sqlite-adapter.d.ts +13 -0
  222. package/dist/db/sqlite-adapter.d.ts.map +1 -0
  223. package/dist/db/sqlite-adapter.js +29 -0
  224. package/dist/db/sqlite-adapter.js.map +1 -0
  225. package/dist/ee/litellm/litellm-key-manager.d.ts +16 -0
  226. package/dist/ee/litellm/litellm-key-manager.d.ts.map +1 -0
  227. package/dist/ee/litellm/litellm-key-manager.js +16 -0
  228. package/dist/ee/litellm/litellm-key-manager.js.map +1 -0
  229. package/dist/ee/litellm/litellm-model-seeder.d.ts +6 -0
  230. package/dist/ee/litellm/litellm-model-seeder.d.ts.map +1 -0
  231. package/dist/ee/litellm/litellm-model-seeder.js +6 -0
  232. package/dist/ee/litellm/litellm-model-seeder.js.map +1 -0
  233. package/dist/index.ce.d.ts +2 -0
  234. package/dist/index.ce.d.ts.map +1 -0
  235. package/dist/index.ce.js +12 -0
  236. package/dist/index.ce.js.map +1 -0
  237. package/dist/middleware/auth.d.ts +30 -0
  238. package/dist/middleware/auth.d.ts.map +1 -0
  239. package/dist/middleware/auth.js +86 -0
  240. package/dist/middleware/auth.js.map +1 -0
  241. package/dist/middleware/dynamic-middleware.d.ts +7 -0
  242. package/dist/middleware/dynamic-middleware.d.ts.map +1 -0
  243. package/dist/middleware/dynamic-middleware.js +46 -0
  244. package/dist/middleware/dynamic-middleware.js.map +1 -0
  245. package/dist/middleware/log-redaction.d.ts +2 -0
  246. package/dist/middleware/log-redaction.d.ts.map +1 -0
  247. package/dist/middleware/log-redaction.js +56 -0
  248. package/dist/middleware/log-redaction.js.map +1 -0
  249. package/dist/routes/admin.d.ts +3 -0
  250. package/dist/routes/admin.d.ts.map +1 -0
  251. package/dist/routes/admin.js +491 -0
  252. package/dist/routes/admin.js.map +1 -0
  253. package/dist/routes/agent-types.d.ts +3 -0
  254. package/dist/routes/agent-types.d.ts.map +1 -0
  255. package/dist/routes/agent-types.js +85 -0
  256. package/dist/routes/agent-types.js.map +1 -0
  257. package/dist/routes/auth.d.ts +3 -0
  258. package/dist/routes/auth.d.ts.map +1 -0
  259. package/dist/routes/auth.js +242 -0
  260. package/dist/routes/auth.js.map +1 -0
  261. package/dist/routes/channels.d.ts +3 -0
  262. package/dist/routes/channels.d.ts.map +1 -0
  263. package/dist/routes/channels.js +527 -0
  264. package/dist/routes/channels.js.map +1 -0
  265. package/dist/routes/credentials.d.ts +3 -0
  266. package/dist/routes/credentials.d.ts.map +1 -0
  267. package/dist/routes/credentials.js +81 -0
  268. package/dist/routes/credentials.js.map +1 -0
  269. package/dist/routes/dashboard.d.ts +3 -0
  270. package/dist/routes/dashboard.d.ts.map +1 -0
  271. package/dist/routes/dashboard.js +75 -0
  272. package/dist/routes/dashboard.js.map +1 -0
  273. package/dist/routes/exec-approval.d.ts +3 -0
  274. package/dist/routes/exec-approval.d.ts.map +1 -0
  275. package/dist/routes/exec-approval.js +60 -0
  276. package/dist/routes/exec-approval.js.map +1 -0
  277. package/dist/routes/group-chats.d.ts +3 -0
  278. package/dist/routes/group-chats.d.ts.map +1 -0
  279. package/dist/routes/group-chats.js +190 -0
  280. package/dist/routes/group-chats.js.map +1 -0
  281. package/dist/routes/instance-files.d.ts +3 -0
  282. package/dist/routes/instance-files.d.ts.map +1 -0
  283. package/dist/routes/instance-files.js +255 -0
  284. package/dist/routes/instance-files.js.map +1 -0
  285. package/dist/routes/instance-proxy.d.ts +40 -0
  286. package/dist/routes/instance-proxy.d.ts.map +1 -0
  287. package/dist/routes/instance-proxy.js +318 -0
  288. package/dist/routes/instance-proxy.js.map +1 -0
  289. package/dist/routes/instances.d.ts +3 -0
  290. package/dist/routes/instances.d.ts.map +1 -0
  291. package/dist/routes/instances.js +325 -0
  292. package/dist/routes/instances.js.map +1 -0
  293. package/dist/routes/metadata.d.ts +3 -0
  294. package/dist/routes/metadata.d.ts.map +1 -0
  295. package/dist/routes/metadata.js +13 -0
  296. package/dist/routes/metadata.js.map +1 -0
  297. package/dist/routes/notifications.d.ts +3 -0
  298. package/dist/routes/notifications.d.ts.map +1 -0
  299. package/dist/routes/notifications.js +104 -0
  300. package/dist/routes/notifications.js.map +1 -0
  301. package/dist/routes/oauth.d.ts +3 -0
  302. package/dist/routes/oauth.d.ts.map +1 -0
  303. package/dist/routes/oauth.js +516 -0
  304. package/dist/routes/oauth.js.map +1 -0
  305. package/dist/routes/rpc-proxy.d.ts +3 -0
  306. package/dist/routes/rpc-proxy.d.ts.map +1 -0
  307. package/dist/routes/rpc-proxy.js +116 -0
  308. package/dist/routes/rpc-proxy.js.map +1 -0
  309. package/dist/routes/security.d.ts +3 -0
  310. package/dist/routes/security.d.ts.map +1 -0
  311. package/dist/routes/security.js +43 -0
  312. package/dist/routes/security.js.map +1 -0
  313. package/dist/routes/skills.d.ts +3 -0
  314. package/dist/routes/skills.d.ts.map +1 -0
  315. package/dist/routes/skills.js +48 -0
  316. package/dist/routes/skills.js.map +1 -0
  317. package/dist/routes/snapshots.d.ts +3 -0
  318. package/dist/routes/snapshots.d.ts.map +1 -0
  319. package/dist/routes/snapshots.js +99 -0
  320. package/dist/routes/snapshots.js.map +1 -0
  321. package/dist/routes/system-config.d.ts +3 -0
  322. package/dist/routes/system-config.d.ts.map +1 -0
  323. package/dist/routes/system-config.js +75 -0
  324. package/dist/routes/system-config.js.map +1 -0
  325. package/dist/routes/templates.d.ts +3 -0
  326. package/dist/routes/templates.d.ts.map +1 -0
  327. package/dist/routes/templates.js +256 -0
  328. package/dist/routes/templates.js.map +1 -0
  329. package/dist/routes/ui-proxy.d.ts +3 -0
  330. package/dist/routes/ui-proxy.d.ts.map +1 -0
  331. package/dist/routes/ui-proxy.js +90 -0
  332. package/dist/routes/ui-proxy.js.map +1 -0
  333. package/dist/routes/user-credentials.d.ts +3 -0
  334. package/dist/routes/user-credentials.d.ts.map +1 -0
  335. package/dist/routes/user-credentials.js +85 -0
  336. package/dist/routes/user-credentials.js.map +1 -0
  337. package/dist/routes/users.d.ts +3 -0
  338. package/dist/routes/users.d.ts.map +1 -0
  339. package/dist/routes/users.js +30 -0
  340. package/dist/routes/users.js.map +1 -0
  341. package/dist/runtime/docker.d.ts +37 -0
  342. package/dist/runtime/docker.d.ts.map +1 -0
  343. package/dist/runtime/docker.js +612 -0
  344. package/dist/runtime/docker.js.map +1 -0
  345. package/dist/runtime/factory.d.ts +4 -0
  346. package/dist/runtime/factory.d.ts.map +1 -0
  347. package/dist/runtime/factory.js +21 -0
  348. package/dist/runtime/factory.js.map +1 -0
  349. package/dist/runtime/kubernetes.d.ts +34 -0
  350. package/dist/runtime/kubernetes.d.ts.map +1 -0
  351. package/dist/runtime/kubernetes.js +513 -0
  352. package/dist/runtime/kubernetes.js.map +1 -0
  353. package/dist/runtime/types.d.ts +81 -0
  354. package/dist/runtime/types.d.ts.map +1 -0
  355. package/dist/runtime/types.js +2 -0
  356. package/dist/runtime/types.js.map +1 -0
  357. package/dist/server-core.d.ts +26 -0
  358. package/dist/server-core.d.ts.map +1 -0
  359. package/dist/server-core.js +184 -0
  360. package/dist/server-core.js.map +1 -0
  361. package/dist/services/config-diff.d.ts +6 -0
  362. package/dist/services/config-diff.d.ts.map +1 -0
  363. package/dist/services/config-diff.js +85 -0
  364. package/dist/services/config-diff.js.map +1 -0
  365. package/dist/services/config-field-meta.d.ts +22 -0
  366. package/dist/services/config-field-meta.d.ts.map +1 -0
  367. package/dist/services/config-field-meta.js +177 -0
  368. package/dist/services/config-field-meta.js.map +1 -0
  369. package/dist/services/config-validator.d.ts +8 -0
  370. package/dist/services/config-validator.d.ts.map +1 -0
  371. package/dist/services/config-validator.js +59 -0
  372. package/dist/services/config-validator.js.map +1 -0
  373. package/dist/services/credential-audit.d.ts +13 -0
  374. package/dist/services/credential-audit.d.ts.map +1 -0
  375. package/dist/services/credential-audit.js +18 -0
  376. package/dist/services/credential-audit.js.map +1 -0
  377. package/dist/services/credential-store.d.ts +28 -0
  378. package/dist/services/credential-store.d.ts.map +1 -0
  379. package/dist/services/credential-store.js +99 -0
  380. package/dist/services/credential-store.js.map +1 -0
  381. package/dist/services/dlp-scanner.d.ts +9 -0
  382. package/dist/services/dlp-scanner.d.ts.map +1 -0
  383. package/dist/services/dlp-scanner.js +90 -0
  384. package/dist/services/dlp-scanner.js.map +1 -0
  385. package/dist/services/gateway-event-relay.d.ts +53 -0
  386. package/dist/services/gateway-event-relay.d.ts.map +1 -0
  387. package/dist/services/gateway-event-relay.js +519 -0
  388. package/dist/services/gateway-event-relay.js.map +1 -0
  389. package/dist/services/group-chat-manager.d.ts +17 -0
  390. package/dist/services/group-chat-manager.d.ts.map +1 -0
  391. package/dist/services/group-chat-manager.js +613 -0
  392. package/dist/services/group-chat-manager.js.map +1 -0
  393. package/dist/services/health-monitor.d.ts +3 -0
  394. package/dist/services/health-monitor.d.ts.map +1 -0
  395. package/dist/services/health-monitor.js +342 -0
  396. package/dist/services/health-monitor.js.map +1 -0
  397. package/dist/services/instance-manager.d.ts +20 -0
  398. package/dist/services/instance-manager.d.ts.map +1 -0
  399. package/dist/services/instance-manager.js +833 -0
  400. package/dist/services/instance-manager.js.map +1 -0
  401. package/dist/services/metadata-store.d.ts +3 -0
  402. package/dist/services/metadata-store.d.ts.map +1 -0
  403. package/dist/services/metadata-store.js +34 -0
  404. package/dist/services/metadata-store.js.map +1 -0
  405. package/dist/services/notification-store.d.ts +24 -0
  406. package/dist/services/notification-store.d.ts.map +1 -0
  407. package/dist/services/notification-store.js +216 -0
  408. package/dist/services/notification-store.js.map +1 -0
  409. package/dist/services/openrouter-models.d.ts +13 -0
  410. package/dist/services/openrouter-models.d.ts.map +1 -0
  411. package/dist/services/openrouter-models.js +46 -0
  412. package/dist/services/openrouter-models.js.map +1 -0
  413. package/dist/services/output-filter.d.ts +8 -0
  414. package/dist/services/output-filter.d.ts.map +1 -0
  415. package/dist/services/output-filter.js +230 -0
  416. package/dist/services/output-filter.js.map +1 -0
  417. package/dist/services/prompt-guard.d.ts +6 -0
  418. package/dist/services/prompt-guard.d.ts.map +1 -0
  419. package/dist/services/prompt-guard.js +165 -0
  420. package/dist/services/prompt-guard.js.map +1 -0
  421. package/dist/services/security-event-service.d.ts +11 -0
  422. package/dist/services/security-event-service.d.ts.map +1 -0
  423. package/dist/services/security-event-service.js +201 -0
  424. package/dist/services/security-event-service.js.map +1 -0
  425. package/dist/services/snapshot-store.d.ts +21 -0
  426. package/dist/services/snapshot-store.d.ts.map +1 -0
  427. package/dist/services/snapshot-store.js +330 -0
  428. package/dist/services/snapshot-store.js.map +1 -0
  429. package/dist/services/system-config.d.ts +15 -0
  430. package/dist/services/system-config.d.ts.map +1 -0
  431. package/dist/services/system-config.js +80 -0
  432. package/dist/services/system-config.js.map +1 -0
  433. package/dist/services/template-file-format.d.ts +32 -0
  434. package/dist/services/template-file-format.d.ts.map +1 -0
  435. package/dist/services/template-file-format.js +125 -0
  436. package/dist/services/template-file-format.js.map +1 -0
  437. package/dist/services/template-store.d.ts +21 -0
  438. package/dist/services/template-store.d.ts.map +1 -0
  439. package/dist/services/template-store.js +701 -0
  440. package/dist/services/template-store.js.map +1 -0
  441. package/dist/services/user-credential-store.d.ts +20 -0
  442. package/dist/services/user-credential-store.d.ts.map +1 -0
  443. package/dist/services/user-credential-store.js +243 -0
  444. package/dist/services/user-credential-store.js.map +1 -0
  445. package/dist/services/wizard-config-store.d.ts +38 -0
  446. package/dist/services/wizard-config-store.d.ts.map +1 -0
  447. package/dist/services/wizard-config-store.js +70 -0
  448. package/dist/services/wizard-config-store.js.map +1 -0
  449. package/dist/web-dist/assets/AdminPage-BrAU67Dg.js +1 -0
  450. package/dist/web-dist/assets/AgentAvatar-BKJckc1W.js +1 -0
  451. package/dist/web-dist/assets/AgentAvatar-Cq-M5jMd.css +1 -0
  452. package/dist/web-dist/assets/AppLayout-Bf0v_2wK.css +1 -0
  453. package/dist/web-dist/assets/AppLayout-DXgV0atq.js +1 -0
  454. package/dist/web-dist/assets/AssistantChatPage-uVLgKLay.js +6 -0
  455. package/dist/web-dist/assets/AssistantEditPage-Bab1X-DA.js +1 -0
  456. package/dist/web-dist/assets/AssistantVersionsPage-BQRw3BUF.js +1 -0
  457. package/dist/web-dist/assets/AvatarPicker-DmnkD8Rb.js +1 -0
  458. package/dist/web-dist/assets/AvatarPicker-LHUepNFa.css +1 -0
  459. package/dist/web-dist/assets/CeAuthProvider-38_x9VGA.js +1 -0
  460. package/dist/web-dist/assets/ChatHubPage-2l4cKq0x.css +1 -0
  461. package/dist/web-dist/assets/ChatHubPage-B2WduoUM.js +1 -0
  462. package/dist/web-dist/assets/ChatTab-CHpjEu8M.js +6 -0
  463. package/dist/web-dist/assets/CreateWizardPage-DFEQ3VX3.js +47 -0
  464. package/dist/web-dist/assets/CreateWizardPage-IqNXDOER.css +1 -0
  465. package/dist/web-dist/assets/CredentialsPage-CDeXpnLG.js +1 -0
  466. package/dist/web-dist/assets/CredentialsPage-aI4kLoJD.css +1 -0
  467. package/dist/web-dist/assets/DocsAboutPage-CMbxiw1u.js +26 -0
  468. package/dist/web-dist/assets/DocsChannelsPage-CtmKYKK_.js +1 -0
  469. package/dist/web-dist/assets/DocsGettingStartedPage-CpM7o8sw.js +1 -0
  470. package/dist/web-dist/assets/DocsGroupChatsPage-7w-RVSJR.js +1 -0
  471. package/dist/web-dist/assets/DocsHomePage-BGEU5xBg.js +1 -0
  472. package/dist/web-dist/assets/DocsInstancesPage-Sewnw_x7.js +1 -0
  473. package/dist/web-dist/assets/DocsLayout-S7-ONZwP.js +1 -0
  474. package/dist/web-dist/assets/DocsProvidersPage-MeWneL5K.js +1 -0
  475. package/dist/web-dist/assets/DocsSkillsPage-CzsHPXxE.js +1 -0
  476. package/dist/web-dist/assets/DocsTemplatesPage-BXASAEoO.js +1 -0
  477. package/dist/web-dist/assets/DocsWorkspacePage-qYNeK_YS.js +24 -0
  478. package/dist/web-dist/assets/ExportWizardPage-BhNvovbU.js +3 -0
  479. package/dist/web-dist/assets/ExportWizardPage-Cp-KSYUy.css +1 -0
  480. package/dist/web-dist/assets/GoogleOAuthCallback-CBvLawe2.js +1 -0
  481. package/dist/web-dist/assets/GroupChatPage-rMfhmtsX.js +1 -0
  482. package/dist/web-dist/assets/GroupChatsListPage-BOwxHFfA.js +1 -0
  483. package/dist/web-dist/assets/InstancePage-BBL68DKB.js +1 -0
  484. package/dist/web-dist/assets/InstancePage-CzysRY40.css +1 -0
  485. package/dist/web-dist/assets/MyAssistantsPage-B808ZfHg.css +1 -0
  486. package/dist/web-dist/assets/MyAssistantsPage-q3-hNMth.js +1 -0
  487. package/dist/web-dist/assets/ProfilePage-Dx8YdU59.js +1 -0
  488. package/dist/web-dist/assets/ProfilePage-JMOkUDx7.css +1 -0
  489. package/dist/web-dist/assets/SessionDrawer-Ba7pbZDJ.css +1 -0
  490. package/dist/web-dist/assets/SessionDrawer-CXzEQAfF.js +1 -0
  491. package/dist/web-dist/assets/SystemConfigPage-4dvxADwi.js +1 -0
  492. package/dist/web-dist/assets/SystemConfigPage-DRqVfLGt.css +1 -0
  493. package/dist/web-dist/assets/TemplatesPage-DqXuG-Gy.css +1 -0
  494. package/dist/web-dist/assets/TemplatesPage-HMS__ODO.js +1 -0
  495. package/dist/web-dist/assets/TestLoginPage-xVQL0lYP.js +1 -0
  496. package/dist/web-dist/assets/ThemeToggle-DymKEYXG.js +1 -0
  497. package/dist/web-dist/assets/WorkbenchPage-Bymo4SSt.css +1 -0
  498. package/dist/web-dist/assets/WorkbenchPage-ST3hVrbL.js +33 -0
  499. package/dist/web-dist/assets/api-B5psysvQ.js +1 -0
  500. package/dist/web-dist/assets/clock-dRyRszad.js +1 -0
  501. package/dist/web-dist/assets/createLucideIcon-DiGX-lN4.js +1 -0
  502. package/dist/web-dist/assets/group-chat-9BaA9G_8.css +1 -0
  503. package/dist/web-dist/assets/index-BqzqZJ96.js +26 -0
  504. package/dist/web-dist/assets/index-DyrDN1Of.css +1 -0
  505. package/dist/web-dist/assets/index-wWimwgy7.js +1 -0
  506. package/dist/web-dist/assets/provider-display-BgrE7u33.js +1 -0
  507. package/dist/web-dist/assets/types-1lNWpzYk.js +57 -0
  508. package/dist/web-dist/assets/types-B6ttO-6G.css +1 -0
  509. package/dist/web-dist/assets/useTranslation-B-8kenfJ.js +1 -0
  510. package/dist/web-dist/assets/zap-CVBnETFW.js +1 -0
  511. package/dist/web-dist/index.html +31 -0
  512. package/dist/web-dist/vite.svg +1 -0
  513. package/dist/ws/index.d.ts +7 -0
  514. package/dist/ws/index.d.ts.map +1 -0
  515. package/dist/ws/index.js +112 -0
  516. package/dist/ws/index.js.map +1 -0
  517. package/package.json +54 -0
@@ -0,0 +1,701 @@
1
+ import { db } from '../db/index.js';
2
+ import { createInstance } from './instance-manager.js';
3
+ import { addCredential } from './credential-store.js';
4
+ import { addUserCredential, resolveCredential } from './user-credential-store.js';
5
+ import { getRuntimeEngine } from '../runtime/factory.js';
6
+ import { reverseAdaptFromContainer } from '../agent-types/openclaw/reverse-adapter.js';
7
+ function parseJsonb(value, fallback) {
8
+ if (typeof value === 'string') {
9
+ try {
10
+ return JSON.parse(value);
11
+ }
12
+ catch {
13
+ return fallback;
14
+ }
15
+ }
16
+ return value ?? fallback;
17
+ }
18
+ /** Ensures a value is a JSON string for PostgreSQL JSONB insert. Knex returns JSONB columns as parsed objects. */
19
+ function stringifyJsonb(value) {
20
+ if (typeof value === 'string')
21
+ return value;
22
+ return JSON.stringify(value ?? null);
23
+ }
24
+ const SECURITY_PROFILE_SCORES = {
25
+ strict: 30,
26
+ standard: 20,
27
+ developer: 10,
28
+ unrestricted: 0,
29
+ };
30
+ function computeSecurityScore(security, mcpServers) {
31
+ if (!security)
32
+ return 0;
33
+ let score = 0;
34
+ const profileScore = SECURITY_PROFILE_SCORES[security.minSecurityProfile ?? ''];
35
+ score += profileScore ?? 0;
36
+ if (security.includeTrustLevels)
37
+ score += 15;
38
+ const neverDoCount = security.customNeverDoRules?.length ?? 0;
39
+ score += Math.min(neverDoCount * 5, 20);
40
+ const patternCount = security.customSuspiciousPatterns?.length ?? 0;
41
+ score += Math.min(patternCount * 5, 15);
42
+ const serverCount = Object.keys(mcpServers).length;
43
+ if (serverCount === 0) {
44
+ score += 20;
45
+ }
46
+ else if (serverCount <= 3) {
47
+ score += 10;
48
+ }
49
+ return Math.min(score, 100);
50
+ }
51
+ async function computeAndPersistScore(trx, templateId, contentSecurity, mcpServers) {
52
+ const score = computeSecurityScore(contentSecurity, mcpServers);
53
+ await trx('templates').where({ id: templateId }).update({ security_score: score });
54
+ return score;
55
+ }
56
+ function toManifest(row) {
57
+ return {
58
+ id: row.id,
59
+ slug: row.slug,
60
+ version: row.version,
61
+ isLatest: row.is_latest,
62
+ name: row.name,
63
+ description: row.description,
64
+ category: row.category,
65
+ tags: parseJsonb(row.tags, []),
66
+ locale: row.locale,
67
+ authorId: row.author_id,
68
+ authorName: row.author_name,
69
+ license: row.license,
70
+ trustLevel: row.trust_level,
71
+ minImageTag: row.min_image_tag,
72
+ agentType: row.agent_type,
73
+ billingMode: row.billing_mode ?? null,
74
+ requiredCredentials: parseJsonb(row.required_credentials, []),
75
+ mcpServers: parseJsonb(row.mcp_servers, {}),
76
+ skills: parseJsonb(row.skills, []),
77
+ pluginDependencies: parseJsonb(row.plugin_dependencies, []),
78
+ suggestedChannels: parseJsonb(row.suggested_channels, []),
79
+ forkedFrom: row.forked_from,
80
+ installCount: row.install_count,
81
+ forkCount: row.fork_count,
82
+ rating: Number(row.rating),
83
+ featured: row.featured,
84
+ usageCount: row.usage_count,
85
+ securityScore: row.security_score,
86
+ createdAt: String(row.created_at),
87
+ updatedAt: String(row.updated_at),
88
+ };
89
+ }
90
+ function toContent(row) {
91
+ const security = parseJsonb(row.security, null);
92
+ return {
93
+ id: row.id,
94
+ templateId: row.template_id,
95
+ workspaceFiles: parseJsonb(row.workspace_files, {}),
96
+ mcpServerConfigs: parseJsonb(row.mcp_server_configs, {}),
97
+ inlineSkills: parseJsonb(row.inline_skills, {}),
98
+ openclawConfig: parseJsonb(row.openclaw_config, {}),
99
+ pluginDependencies: parseJsonb(row.plugin_dependencies, []),
100
+ setupCommands: parseJsonb(row.setup_commands, []),
101
+ customImage: row.custom_image ?? null,
102
+ ...(security ? { security } : {}),
103
+ createdAt: String(row.created_at),
104
+ };
105
+ }
106
+ export async function listTemplates(filters) {
107
+ const page = filters.page ?? 1;
108
+ const limit = Math.min(filters.limit ?? 20, 100);
109
+ const offset = (page - 1) * limit;
110
+ let query = db('templates').where({ is_latest: true });
111
+ let countQuery = db('templates').where({ is_latest: true });
112
+ if (filters.category) {
113
+ query = query.where({ category: filters.category });
114
+ countQuery = countQuery.where({ category: filters.category });
115
+ }
116
+ if (filters.license) {
117
+ query = query.where({ license: filters.license });
118
+ countQuery = countQuery.where({ license: filters.license });
119
+ }
120
+ if (filters.trustLevel) {
121
+ query = query.where({ trust_level: filters.trustLevel });
122
+ countQuery = countQuery.where({ trust_level: filters.trustLevel });
123
+ }
124
+ if (filters.authorId) {
125
+ query = query.where({ author_id: filters.authorId });
126
+ countQuery = countQuery.where({ author_id: filters.authorId });
127
+ }
128
+ if (filters.search) {
129
+ const term = `%${filters.search}%`;
130
+ query = query.where(function () {
131
+ this.whereILike('name', term).orWhereILike('description', term);
132
+ });
133
+ countQuery = countQuery.where(function () {
134
+ this.whereILike('name', term).orWhereILike('description', term);
135
+ });
136
+ }
137
+ if (filters.tags && filters.tags.length > 0) {
138
+ query = query.whereRaw('tags \\?| ?', [filters.tags]);
139
+ countQuery = countQuery.whereRaw('tags \\?| ?', [filters.tags]);
140
+ }
141
+ if (filters.featured !== undefined) {
142
+ query = query.where({ featured: filters.featured });
143
+ countQuery = countQuery.where({ featured: filters.featured });
144
+ }
145
+ const [{ count: totalRaw }] = await countQuery.count('* as count');
146
+ const total = Number(totalRaw);
147
+ const rows = await query
148
+ .orderBy('featured', 'desc')
149
+ .orderBy('install_count', 'desc')
150
+ .offset(offset)
151
+ .limit(limit);
152
+ return {
153
+ items: rows.map(toManifest),
154
+ total,
155
+ page,
156
+ limit,
157
+ totalPages: Math.ceil(total / limit),
158
+ };
159
+ }
160
+ export async function getTemplate(idOrSlug) {
161
+ const isUuid = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(idOrSlug);
162
+ let row;
163
+ if (isUuid) {
164
+ row = await db('templates').where({ id: idOrSlug }).first();
165
+ }
166
+ else {
167
+ row = await db('templates').where({ slug: idOrSlug, is_latest: true }).first();
168
+ }
169
+ return row ? toManifest(row) : null;
170
+ }
171
+ export async function getTemplateContent(templateId) {
172
+ const row = await db('template_contents').where({ template_id: templateId }).first();
173
+ return row ? toContent(row) : null;
174
+ }
175
+ export async function createTemplate(userId, authorName, req) {
176
+ return db.transaction(async (trx) => {
177
+ const [templateRow] = await trx('templates')
178
+ .insert({
179
+ slug: req.slug,
180
+ name: req.name,
181
+ description: req.description ?? null,
182
+ category: req.category ?? 'custom',
183
+ tags: JSON.stringify(req.tags ?? []),
184
+ locale: req.locale ?? 'en-US',
185
+ author_id: userId,
186
+ author_name: authorName,
187
+ license: req.license ?? 'private',
188
+ min_image_tag: req.minImageTag ?? null,
189
+ agent_type: req.agentType ?? 'openclaw',
190
+ billing_mode: req.billingMode ?? null,
191
+ required_credentials: JSON.stringify(req.requiredCredentials ?? []),
192
+ mcp_servers: JSON.stringify(req.mcpServers ?? {}),
193
+ skills: JSON.stringify(req.skills ?? []),
194
+ plugin_dependencies: JSON.stringify(req.pluginDependencies ?? []),
195
+ suggested_channels: JSON.stringify(req.suggestedChannels ?? []),
196
+ })
197
+ .returning('*');
198
+ await trx('template_contents').insert({
199
+ template_id: templateRow.id,
200
+ workspace_files: JSON.stringify(req.content.workspaceFiles ?? {}),
201
+ mcp_server_configs: JSON.stringify(req.content.mcpServerConfigs ?? {}),
202
+ inline_skills: JSON.stringify(req.content.inlineSkills ?? {}),
203
+ openclaw_config: JSON.stringify(req.content.openclawConfig ?? {}),
204
+ setup_commands: JSON.stringify(req.content.setupCommands ?? []),
205
+ plugin_dependencies: JSON.stringify(req.content.pluginDependencies ?? []),
206
+ custom_image: req.content.customImage ?? null,
207
+ security: req.content.security ? JSON.stringify(req.content.security) : null,
208
+ });
209
+ const score = await computeAndPersistScore(trx, templateRow.id, req.content.security ?? null, req.mcpServers ?? {});
210
+ return toManifest({ ...templateRow, security_score: score });
211
+ });
212
+ }
213
+ export async function updateTemplate(templateId, userId, updates) {
214
+ const existing = await db('templates').where({ id: templateId }).first();
215
+ if (!existing)
216
+ throw new Error('Template not found');
217
+ if (existing.author_id !== userId)
218
+ throw new Error('Only the author can update this template');
219
+ return db.transaction(async (trx) => {
220
+ const latestRow = await trx('templates')
221
+ .where({ slug: existing.slug, is_latest: true })
222
+ .first();
223
+ const newVersion = bumpVersion((latestRow ?? existing).version);
224
+ await trx('templates').where({ slug: existing.slug, is_latest: true }).update({ is_latest: false });
225
+ const patch = {
226
+ slug: existing.slug,
227
+ version: newVersion,
228
+ is_latest: true,
229
+ author_id: existing.author_id,
230
+ author_name: existing.author_name,
231
+ agent_type: existing.agent_type,
232
+ forked_from: existing.forked_from,
233
+ install_count: existing.install_count,
234
+ fork_count: existing.fork_count,
235
+ rating: existing.rating,
236
+ };
237
+ if (updates.name !== undefined)
238
+ patch.name = updates.name;
239
+ else
240
+ patch.name = existing.name;
241
+ if (updates.description !== undefined)
242
+ patch.description = updates.description;
243
+ else
244
+ patch.description = existing.description;
245
+ if (updates.category !== undefined)
246
+ patch.category = updates.category;
247
+ else
248
+ patch.category = existing.category;
249
+ if (updates.tags !== undefined)
250
+ patch.tags = JSON.stringify(updates.tags);
251
+ else
252
+ patch.tags = stringifyJsonb(existing.tags);
253
+ if (updates.locale !== undefined)
254
+ patch.locale = updates.locale;
255
+ else
256
+ patch.locale = existing.locale;
257
+ if (updates.license !== undefined)
258
+ patch.license = updates.license;
259
+ else
260
+ patch.license = existing.license;
261
+ if (updates.minImageTag !== undefined)
262
+ patch.min_image_tag = updates.minImageTag;
263
+ else
264
+ patch.min_image_tag = existing.min_image_tag;
265
+ if (updates.requiredCredentials !== undefined)
266
+ patch.required_credentials = JSON.stringify(updates.requiredCredentials);
267
+ else
268
+ patch.required_credentials = stringifyJsonb(existing.required_credentials);
269
+ if (updates.mcpServers !== undefined)
270
+ patch.mcp_servers = JSON.stringify(updates.mcpServers);
271
+ else
272
+ patch.mcp_servers = stringifyJsonb(existing.mcp_servers);
273
+ if (updates.skills !== undefined)
274
+ patch.skills = JSON.stringify(updates.skills);
275
+ else
276
+ patch.skills = stringifyJsonb(existing.skills);
277
+ if (updates.pluginDependencies !== undefined)
278
+ patch.plugin_dependencies = JSON.stringify(updates.pluginDependencies);
279
+ else
280
+ patch.plugin_dependencies = stringifyJsonb(existing.plugin_dependencies);
281
+ if (updates.suggestedChannels !== undefined)
282
+ patch.suggested_channels = JSON.stringify(updates.suggestedChannels);
283
+ else
284
+ patch.suggested_channels = stringifyJsonb(existing.suggested_channels);
285
+ if (updates.billingMode !== undefined)
286
+ patch.billing_mode = updates.billingMode;
287
+ else
288
+ patch.billing_mode = existing.billing_mode;
289
+ const [newRow] = await trx('templates').insert(patch).returning('*');
290
+ const existingContent = await trx('template_contents').where({ template_id: templateId }).first();
291
+ const contentPatch = {
292
+ template_id: newRow.id,
293
+ workspace_files: JSON.stringify(updates.content?.workspaceFiles ?? parseJsonb(existingContent?.workspace_files, {})),
294
+ mcp_server_configs: JSON.stringify(updates.content?.mcpServerConfigs ?? parseJsonb(existingContent?.mcp_server_configs, {})),
295
+ inline_skills: JSON.stringify(updates.content?.inlineSkills ?? parseJsonb(existingContent?.inline_skills, {})),
296
+ openclaw_config: JSON.stringify(updates.content?.openclawConfig ?? parseJsonb(existingContent?.openclaw_config, {})),
297
+ setup_commands: JSON.stringify(updates.content?.setupCommands ?? parseJsonb(existingContent?.setup_commands, [])),
298
+ plugin_dependencies: JSON.stringify(updates.content?.pluginDependencies ?? parseJsonb(existingContent?.plugin_dependencies, [])),
299
+ custom_image: updates.content?.customImage ?? existingContent?.custom_image ?? null,
300
+ security: updates.content !== undefined
301
+ ? (updates.content.security ? JSON.stringify(updates.content.security) : null)
302
+ : existingContent?.security
303
+ ? stringifyJsonb(existingContent.security)
304
+ : null,
305
+ };
306
+ await trx('template_contents').insert(contentPatch);
307
+ const resolvedSecurity = updates.content?.security
308
+ ?? parseJsonb(existingContent?.security, null);
309
+ const resolvedMcpServers = updates.mcpServers
310
+ ?? parseJsonb(existing.mcp_servers, {});
311
+ const score = await computeAndPersistScore(trx, newRow.id, resolvedSecurity, resolvedMcpServers);
312
+ return toManifest({ ...newRow, security_score: score });
313
+ });
314
+ }
315
+ export async function deleteTemplate(templateId, userId, isAdmin = false) {
316
+ const existing = await db('templates').where({ id: templateId }).first();
317
+ if (!existing)
318
+ return false;
319
+ if (existing.author_id !== userId && !isAdmin)
320
+ throw new Error('Only the author or an admin can delete this template');
321
+ const count = await db('templates').where({ slug: existing.slug }).delete();
322
+ return count > 0;
323
+ }
324
+ export async function forkTemplate(templateId, userId, authorName) {
325
+ const original = await db('templates').where({ id: templateId }).first();
326
+ if (!original)
327
+ throw new Error('Template not found');
328
+ const content = await db('template_contents').where({ template_id: templateId }).first();
329
+ return db.transaction(async (trx) => {
330
+ const slug = `${original.slug}-fork-${Date.now().toString(36)}`;
331
+ const [forked] = await trx('templates')
332
+ .insert({
333
+ slug,
334
+ name: `${original.name} (Fork)`,
335
+ description: original.description,
336
+ category: original.category,
337
+ tags: stringifyJsonb(original.tags),
338
+ locale: original.locale,
339
+ author_id: userId,
340
+ author_name: authorName,
341
+ license: 'private',
342
+ min_image_tag: original.min_image_tag,
343
+ agent_type: original.agent_type,
344
+ billing_mode: original.billing_mode,
345
+ required_credentials: stringifyJsonb(original.required_credentials),
346
+ mcp_servers: stringifyJsonb(original.mcp_servers),
347
+ skills: stringifyJsonb(original.skills),
348
+ plugin_dependencies: stringifyJsonb(original.plugin_dependencies),
349
+ suggested_channels: stringifyJsonb(original.suggested_channels),
350
+ forked_from: templateId,
351
+ })
352
+ .returning('*');
353
+ if (content) {
354
+ await trx('template_contents').insert({
355
+ template_id: forked.id,
356
+ workspace_files: stringifyJsonb(content.workspace_files),
357
+ mcp_server_configs: stringifyJsonb(content.mcp_server_configs),
358
+ inline_skills: stringifyJsonb(content.inline_skills),
359
+ openclaw_config: stringifyJsonb(content.openclaw_config),
360
+ setup_commands: stringifyJsonb(content.setup_commands),
361
+ plugin_dependencies: stringifyJsonb(content.plugin_dependencies),
362
+ custom_image: content.custom_image ?? null,
363
+ security: content.security ? stringifyJsonb(content.security) : null,
364
+ });
365
+ }
366
+ await trx('templates').where({ id: templateId }).increment('fork_count', 1);
367
+ return toManifest(forked);
368
+ });
369
+ }
370
+ const SENSITIVE_PATTERNS = [
371
+ { re: /^sk-[a-zA-Z0-9]{20,}/, label: 'OpenAI API key' },
372
+ { re: /^hapi-[a-zA-Z0-9-]+/, label: 'HubSpot API key' },
373
+ { re: /^xoxb-[a-zA-Z0-9-]+/, label: 'Slack bot token' },
374
+ { re: /^ghp_[a-zA-Z0-9]+/, label: 'GitHub PAT' },
375
+ { re: /^gsk_[a-zA-Z0-9]+/, label: 'Groq API key' },
376
+ { re: /^AIza[a-zA-Z0-9_-]+/, label: 'Google API key' },
377
+ ];
378
+ function maskValue(value) {
379
+ if (value.length <= 8)
380
+ return '****';
381
+ return `${value.slice(0, 4)}****${value.slice(-4)}`;
382
+ }
383
+ export async function exportFromInstance(instanceId, userId) {
384
+ const instance = await db('instances').where({ id: instanceId, user_id: userId }).first();
385
+ if (!instance)
386
+ throw new Error('Instance not found');
387
+ // If instance is running, try reverse adapter for live extraction.
388
+ // runtime_id may be NULL (e.g. dev env reconciliation gap) — fall back to container name.
389
+ if (instance.status === 'running') {
390
+ try {
391
+ const deployTarget = instance.deployment_target || 'docker';
392
+ const engine = getRuntimeEngine(deployTarget);
393
+ if (engine.readFile) {
394
+ // Resolve runtimeId: use stored value, or construct container name from convention
395
+ const runtimeId = instance.runtime_id
396
+ || `${instance.agent_type || 'openclaw'}-${instanceId.slice(0, 8)}`;
397
+ const credentials = await db('instance_credentials')
398
+ .where({ instance_id: instanceId })
399
+ .select('provider', 'credential_type');
400
+ return await reverseAdaptFromContainer(engine, runtimeId, instance, credentials);
401
+ }
402
+ }
403
+ catch {
404
+ // Fall through to DB-only export
405
+ }
406
+ }
407
+ // DB-only fallback: parse config JSON (may be corrupt in dev environments)
408
+ let config;
409
+ try {
410
+ config = typeof instance.config === 'string' ? JSON.parse(instance.config) : (instance.config ?? {});
411
+ }
412
+ catch {
413
+ config = {};
414
+ }
415
+ const warnings = [];
416
+ const workspaceFiles = {};
417
+ const workspaceKeys = ['agentsmd', 'soulmd', 'identitymd', 'usermd', 'toolsmd', 'bootstrapmd', 'heartbeatmd', 'memorymd'];
418
+ for (const key of workspaceKeys) {
419
+ const displayKey = CONFIG_KEY_TO_DISPLAY[key] ?? key;
420
+ if (config[key]) {
421
+ workspaceFiles[displayKey] = config[key];
422
+ }
423
+ else if (config[displayKey]) {
424
+ workspaceFiles[displayKey] = config[displayKey];
425
+ }
426
+ }
427
+ const mcpServerConfigs = (config.mcpServers ?? {});
428
+ const sanitizedMcpConfigs = {};
429
+ for (const [name, serverConfig] of Object.entries(mcpServerConfigs)) {
430
+ if (!serverConfig || typeof serverConfig !== 'object') {
431
+ sanitizedMcpConfigs[name] = serverConfig;
432
+ continue;
433
+ }
434
+ const cfg = { ...serverConfig };
435
+ const env = cfg.env;
436
+ if (env && typeof env === 'object') {
437
+ const sanitizedEnv = {};
438
+ for (const [envKey, envValue] of Object.entries(env)) {
439
+ let isSensitive = false;
440
+ for (const { re } of SENSITIVE_PATTERNS) {
441
+ if (re.test(envValue)) {
442
+ isSensitive = true;
443
+ warnings.push({
444
+ type: 'possible_hardcoded_key',
445
+ location: `mcpServers.${name}.env.${envKey}`,
446
+ pattern: maskValue(envValue),
447
+ suggestion: `Replace with \${CREDENTIAL:${name}:api_key}`,
448
+ });
449
+ sanitizedEnv[envKey] = `\${CREDENTIAL:${name}:api_key}`;
450
+ break;
451
+ }
452
+ }
453
+ if (!isSensitive) {
454
+ sanitizedEnv[envKey] = envValue;
455
+ }
456
+ }
457
+ cfg.env = sanitizedEnv;
458
+ }
459
+ const headers = cfg.headers;
460
+ if (headers && typeof headers === 'object') {
461
+ const sanitizedHeaders = {};
462
+ for (const [headerKey, headerValue] of Object.entries(headers)) {
463
+ let isSensitive = false;
464
+ for (const { re } of SENSITIVE_PATTERNS) {
465
+ if (re.test(headerValue)) {
466
+ isSensitive = true;
467
+ warnings.push({
468
+ type: 'possible_hardcoded_key',
469
+ location: `mcpServers.${name}.headers.${headerKey}`,
470
+ pattern: maskValue(headerValue),
471
+ suggestion: `Replace with \${CREDENTIAL:${name}:api_key}`,
472
+ });
473
+ sanitizedHeaders[headerKey] = `\${CREDENTIAL:${name}:api_key}`;
474
+ break;
475
+ }
476
+ }
477
+ if (!isSensitive) {
478
+ sanitizedHeaders[headerKey] = headerValue;
479
+ }
480
+ }
481
+ cfg.headers = sanitizedHeaders;
482
+ }
483
+ sanitizedMcpConfigs[name] = cfg;
484
+ }
485
+ return {
486
+ draft: {
487
+ slug: slugify(instance.name),
488
+ name: instance.name,
489
+ description: `Exported from instance "${instance.name}"`,
490
+ category: 'custom',
491
+ tags: [],
492
+ agentType: instance.agent_type,
493
+ minImageTag: instance.image_tag,
494
+ billingMode: instance.billing_mode ?? undefined,
495
+ },
496
+ content: {
497
+ workspaceFiles,
498
+ mcpServerConfigs: sanitizedMcpConfigs,
499
+ inlineSkills: {},
500
+ openclawConfig: {},
501
+ setupCommands: [],
502
+ customImage: null,
503
+ },
504
+ securityWarnings: warnings,
505
+ };
506
+ }
507
+ function generateDependencySetupCommands(skills, pluginDeps, mcpServers) {
508
+ const commands = [];
509
+ const npmPackages = [];
510
+ for (const skill of skills) {
511
+ if (skill.source?.type === 'npm' && skill.source.spec) {
512
+ npmPackages.push(skill.source.spec);
513
+ }
514
+ else if (skill.source?.type === 'clawhub' && skill.source.slug) {
515
+ const spec = skill.source.version
516
+ ? `@openclaw/skill-${skill.source.slug}@${skill.source.version}`
517
+ : `@openclaw/skill-${skill.source.slug}`;
518
+ npmPackages.push(spec);
519
+ }
520
+ }
521
+ for (const plugin of pluginDeps) {
522
+ if (plugin.npmSpec) {
523
+ npmPackages.push(plugin.npmSpec);
524
+ }
525
+ }
526
+ if (npmPackages.length > 0) {
527
+ commands.push({
528
+ command: ['npm', 'install', '--save', ...npmPackages],
529
+ description: `Install ${npmPackages.length} package(s): ${npmPackages.join(', ')}`,
530
+ timeout: 120_000,
531
+ });
532
+ }
533
+ for (const [name, server] of Object.entries(mcpServers)) {
534
+ if (server.url)
535
+ continue;
536
+ if (server.installCommand && server.installCommand.length > 0) {
537
+ commands.push({
538
+ command: server.installCommand,
539
+ description: `Install MCP server: ${name}`,
540
+ timeout: 120_000,
541
+ });
542
+ }
543
+ else if (server.installSpec) {
544
+ const runtime = server.runtime ?? 'node';
545
+ if (runtime === 'node') {
546
+ commands.push({
547
+ command: ['npm', 'install', '--save', server.installSpec],
548
+ description: `Install MCP server: ${name} (${server.installSpec})`,
549
+ timeout: 120_000,
550
+ });
551
+ }
552
+ else if (runtime === 'python') {
553
+ commands.push({
554
+ command: ['pip', 'install', server.installSpec],
555
+ description: `Install MCP server: ${name} (${server.installSpec})`,
556
+ timeout: 120_000,
557
+ });
558
+ }
559
+ }
560
+ }
561
+ return commands;
562
+ }
563
+ export async function instantiateTemplate(templateId, userId, req) {
564
+ const template = await db('templates').where({ id: templateId }).first();
565
+ if (!template)
566
+ throw new Error('Template not found');
567
+ const content = await db('template_contents').where({ template_id: templateId }).first();
568
+ const credentialStatus = {};
569
+ const credentialsToStore = [];
570
+ const requiredCreds = parseJsonb(template.required_credentials, []);
571
+ for (const cred of requiredCreds) {
572
+ const key = `${cred.provider}:${cred.credentialType}`;
573
+ const providedValue = req.credentials?.[key];
574
+ if (providedValue) {
575
+ credentialStatus[key] = 'provided';
576
+ credentialsToStore.push({ provider: cred.provider, credentialType: cred.credentialType, value: providedValue });
577
+ if (req.saveToVault?.includes(key)) {
578
+ await addUserCredential(userId, cred.provider, cred.credentialType, providedValue);
579
+ }
580
+ }
581
+ else if (providedValue === null) {
582
+ try {
583
+ const vaultValue = await resolveCredential('', userId, cred.provider, cred.credentialType);
584
+ credentialStatus[key] = 'from_vault';
585
+ credentialsToStore.push({ provider: cred.provider, credentialType: cred.credentialType, value: vaultValue });
586
+ }
587
+ catch {
588
+ if (cred.required) {
589
+ credentialStatus[key] = 'missing';
590
+ }
591
+ }
592
+ }
593
+ else {
594
+ try {
595
+ const vaultValue = await resolveCredential('', userId, cred.provider, cred.credentialType);
596
+ credentialStatus[key] = 'from_vault';
597
+ credentialsToStore.push({ provider: cred.provider, credentialType: cred.credentialType, value: vaultValue });
598
+ }
599
+ catch {
600
+ if (cred.required) {
601
+ credentialStatus[key] = 'missing';
602
+ }
603
+ }
604
+ }
605
+ }
606
+ const missingRequired = Object.entries(credentialStatus)
607
+ .filter(([, status]) => status === 'missing')
608
+ .map(([key]) => key);
609
+ if (missingRequired.length > 0) {
610
+ throw new Error(`Missing required credentials: ${missingRequired.join(', ')}`);
611
+ }
612
+ const workspaceFiles = content ? parseJsonb(content.workspace_files, {}) : {};
613
+ const mcpServerConfigs = content ? parseJsonb(content.mcp_server_configs, {}) : {};
614
+ const openclawConfig = content ? parseJsonb(content.openclaw_config, {}) : {};
615
+ const explicitSetupCommands = content ? parseJsonb(content.setup_commands, []) : [];
616
+ const customImage = content ? (content.custom_image ?? null) : null;
617
+ const templateSecurity = content ? parseJsonb(content.security, null) : null;
618
+ const autoSetupCommands = generateDependencySetupCommands(parseJsonb(template.skills, []), parseJsonb(template.plugin_dependencies, []), parseJsonb(template.mcp_servers, {}));
619
+ const setupCommands = [...autoSetupCommands, ...explicitSetupCommands];
620
+ const resolvedSecurityProfile = req.securityProfile ?? 'standard';
621
+ if (templateSecurity?.minSecurityProfile) {
622
+ const profileOrder = ['strict', 'standard', 'developer', 'unrestricted'];
623
+ const templateLevel = profileOrder.indexOf(templateSecurity.minSecurityProfile);
624
+ const instanceLevel = profileOrder.indexOf(resolvedSecurityProfile);
625
+ if (instanceLevel > templateLevel) {
626
+ throw new Error(`Template requires ${templateSecurity.minSecurityProfile} security level, ` +
627
+ `but instance is ${resolvedSecurityProfile}`);
628
+ }
629
+ }
630
+ const instanceConfig = {};
631
+ for (const [key, value] of Object.entries(workspaceFiles)) {
632
+ const configKey = DISPLAY_TO_CONFIG_KEY[key] ?? key;
633
+ instanceConfig[configKey] = value;
634
+ }
635
+ if (Object.keys(mcpServerConfigs).length > 0) {
636
+ instanceConfig.mcpServers = mcpServerConfigs;
637
+ }
638
+ for (const [key, value] of Object.entries(openclawConfig)) {
639
+ instanceConfig[key] = value;
640
+ }
641
+ // Store setup commands so instance-manager can execute them post-start
642
+ if (setupCommands.length > 0) {
643
+ instanceConfig.__setupCommands = setupCommands;
644
+ }
645
+ // Store template security config so adapter can inject custom rules into SOUL.md
646
+ if (templateSecurity) {
647
+ instanceConfig.__templateSecurity = templateSecurity;
648
+ }
649
+ // Use custom image from template content, or fall back to manifest min_image_tag, then request imageTag
650
+ const resolvedImageTag = customImage ?? req.imageTag ?? template.min_image_tag ?? undefined;
651
+ // Resolve billing mode: request override → template default → 'byok' fallback
652
+ const resolvedBillingMode = req.billingMode ?? template.billing_mode ?? 'byok';
653
+ const instance = await createInstance(userId, {
654
+ name: req.instanceName,
655
+ agentType: template.agent_type,
656
+ imageTag: resolvedImageTag,
657
+ deploymentTarget: req.deploymentTarget,
658
+ billingMode: resolvedBillingMode,
659
+ securityProfile: resolvedSecurityProfile,
660
+ config: instanceConfig,
661
+ });
662
+ await db('instances').where({ id: instance.id }).update({
663
+ template_id: templateId,
664
+ template_version: template.version,
665
+ });
666
+ for (const cred of credentialsToStore) {
667
+ await addCredential(instance.id, cred.provider, cred.credentialType, cred.value);
668
+ }
669
+ await db('templates').where({ id: templateId }).increment('install_count', 1);
670
+ return {
671
+ instance: { ...instance, templateId, templateVersion: template.version },
672
+ credentialStatus,
673
+ };
674
+ }
675
+ function bumpVersion(current) {
676
+ const parts = current.split('.').map(Number);
677
+ if (parts.length === 3) {
678
+ parts[2] += 1;
679
+ return parts.join('.');
680
+ }
681
+ return `${current}.1`;
682
+ }
683
+ function slugify(text) {
684
+ return text
685
+ .toLowerCase()
686
+ .replace(/[^a-z0-9\u4e00-\u9fff]+/g, '-')
687
+ .replace(/^-+|-+$/g, '')
688
+ .slice(0, 128) || 'template';
689
+ }
690
+ const DISPLAY_TO_CONFIG_KEY = {
691
+ 'AGENTS.md': 'agentsmd',
692
+ 'SOUL.md': 'soulmd',
693
+ 'IDENTITY.md': 'identitymd',
694
+ 'USER.md': 'usermd',
695
+ 'TOOLS.md': 'toolsmd',
696
+ 'BOOTSTRAP.md': 'bootstrapmd',
697
+ 'HEARTBEAT.md': 'heartbeatmd',
698
+ 'MEMORY.md': 'memorymd',
699
+ };
700
+ const CONFIG_KEY_TO_DISPLAY = Object.fromEntries(Object.entries(DISPLAY_TO_CONFIG_KEY).map(([k, v]) => [v, k]));
701
+ //# sourceMappingURL=template-store.js.map