@synap-core/cli 1.10.0 → 1.12.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (461) hide show
  1. package/README.md +23 -198
  2. package/dist/build-info.json +6 -0
  3. package/dist/commands/agent-run.js +3 -2
  4. package/dist/commands/agent-run.js.map +1 -1
  5. package/dist/commands/agents.d.ts +33 -17
  6. package/dist/commands/agents.js +203 -237
  7. package/dist/commands/agents.js.map +1 -1
  8. package/dist/commands/app.d.ts +143 -0
  9. package/dist/commands/app.js +523 -0
  10. package/dist/commands/app.js.map +1 -0
  11. package/dist/commands/automate.d.ts +21 -0
  12. package/dist/commands/automate.js +42 -0
  13. package/dist/commands/automate.js.map +1 -0
  14. package/dist/commands/automation-schema.test.d.ts +16 -0
  15. package/dist/commands/automation-schema.test.js +77 -0
  16. package/dist/commands/automation-schema.test.js.map +1 -0
  17. package/dist/commands/automation.d.ts +12 -0
  18. package/dist/commands/automation.js +80 -35
  19. package/dist/commands/automation.js.map +1 -1
  20. package/dist/commands/bridge-setup.d.ts +14 -1
  21. package/dist/commands/bridge-setup.js +392 -128
  22. package/dist/commands/bridge-setup.js.map +1 -1
  23. package/dist/commands/cap-connections.d.ts +4 -4
  24. package/dist/commands/cap-connections.js +14 -14
  25. package/dist/commands/cap-connections.js.map +1 -1
  26. package/dist/commands/capability.d.ts +2 -0
  27. package/dist/commands/capability.js +297 -176
  28. package/dist/commands/capability.js.map +1 -1
  29. package/dist/commands/catalog.d.ts +275 -0
  30. package/dist/commands/catalog.js +481 -0
  31. package/dist/commands/catalog.js.map +1 -0
  32. package/dist/commands/cell.d.ts +155 -8
  33. package/dist/commands/cell.js +416 -40
  34. package/dist/commands/cell.js.map +1 -1
  35. package/dist/commands/centrality.js +3 -14
  36. package/dist/commands/centrality.js.map +1 -1
  37. package/dist/commands/connect.d.ts +38 -13
  38. package/dist/commands/connect.js +68 -167
  39. package/dist/commands/connect.js.map +1 -1
  40. package/dist/commands/connections.d.ts +3 -2
  41. package/dist/commands/connections.js +95 -25
  42. package/dist/commands/connections.js.map +1 -1
  43. package/dist/commands/context.js +9 -2
  44. package/dist/commands/context.js.map +1 -1
  45. package/dist/commands/data-extra.d.ts +34 -0
  46. package/dist/commands/data-extra.js +198 -25
  47. package/dist/commands/data-extra.js.map +1 -1
  48. package/dist/commands/data.d.ts +120 -2
  49. package/dist/commands/data.js +307 -24
  50. package/dist/commands/data.js.map +1 -1
  51. package/dist/commands/diagnose.d.ts +66 -4
  52. package/dist/commands/diagnose.js +329 -29
  53. package/dist/commands/diagnose.js.map +1 -1
  54. package/dist/commands/digest.js +2 -1
  55. package/dist/commands/digest.js.map +1 -1
  56. package/dist/commands/doc.d.ts +25 -4
  57. package/dist/commands/doc.js +100 -18
  58. package/dist/commands/doc.js.map +1 -1
  59. package/dist/commands/doctor.d.ts +130 -0
  60. package/dist/commands/doctor.js +814 -0
  61. package/dist/commands/doctor.js.map +1 -0
  62. package/dist/commands/events.js +3 -1
  63. package/dist/commands/events.js.map +1 -1
  64. package/dist/commands/explain.js +5 -5
  65. package/dist/commands/explain.js.map +1 -1
  66. package/dist/commands/graph.js +5 -3
  67. package/dist/commands/graph.js.map +1 -1
  68. package/dist/commands/import.d.ts +368 -13
  69. package/dist/commands/import.js +1096 -55
  70. package/dist/commands/import.js.map +1 -1
  71. package/dist/commands/init.d.ts +20 -9
  72. package/dist/commands/init.js +433 -973
  73. package/dist/commands/init.js.map +1 -1
  74. package/dist/commands/keys.d.ts +1 -0
  75. package/dist/commands/keys.js +15 -2
  76. package/dist/commands/keys.js.map +1 -1
  77. package/dist/commands/knowledge.d.ts +28 -6
  78. package/dist/commands/knowledge.js +358 -73
  79. package/dist/commands/knowledge.js.map +1 -1
  80. package/dist/commands/launch.js +2 -2
  81. package/dist/commands/launch.js.map +1 -1
  82. package/dist/commands/lens.d.ts +37 -1
  83. package/dist/commands/lens.js +193 -72
  84. package/dist/commands/lens.js.map +1 -1
  85. package/dist/commands/market-authoring.d.ts +72 -0
  86. package/dist/commands/market-authoring.js +566 -0
  87. package/dist/commands/market-authoring.js.map +1 -0
  88. package/dist/commands/market-official.d.ts +58 -0
  89. package/dist/commands/market-official.js +84 -0
  90. package/dist/commands/market-official.js.map +1 -0
  91. package/dist/commands/market.d.ts +419 -20
  92. package/dist/commands/market.js +2124 -193
  93. package/dist/commands/market.js.map +1 -1
  94. package/dist/commands/mcp.d.ts +70 -13
  95. package/dist/commands/mcp.js +308 -40
  96. package/dist/commands/mcp.js.map +1 -1
  97. package/dist/commands/open.d.ts +39 -9
  98. package/dist/commands/open.js +80 -25
  99. package/dist/commands/open.js.map +1 -1
  100. package/dist/commands/playbook.d.ts +42 -0
  101. package/dist/commands/playbook.js +162 -0
  102. package/dist/commands/playbook.js.map +1 -0
  103. package/dist/commands/pod.js +1 -1
  104. package/dist/commands/pod.js.map +1 -1
  105. package/dist/commands/pods.d.ts +19 -0
  106. package/dist/commands/pods.js +220 -85
  107. package/dist/commands/pods.js.map +1 -1
  108. package/dist/commands/proposals-actions.d.ts +62 -0
  109. package/dist/commands/proposals-actions.js +146 -8
  110. package/dist/commands/proposals-actions.js.map +1 -1
  111. package/dist/commands/proposals-await.d.ts +68 -0
  112. package/dist/commands/proposals-await.js +248 -0
  113. package/dist/commands/proposals-await.js.map +1 -0
  114. package/dist/commands/proton-setup.d.ts +73 -0
  115. package/dist/commands/proton-setup.js +577 -0
  116. package/dist/commands/proton-setup.js.map +1 -0
  117. package/dist/commands/providers.d.ts +23 -0
  118. package/dist/commands/providers.js +126 -1
  119. package/dist/commands/providers.js.map +1 -1
  120. package/dist/commands/raycast.js +6 -2
  121. package/dist/commands/raycast.js.map +1 -1
  122. package/dist/commands/rule.d.ts +150 -0
  123. package/dist/commands/rule.js +447 -0
  124. package/dist/commands/rule.js.map +1 -0
  125. package/dist/commands/session-wait.d.ts +111 -0
  126. package/dist/commands/session-wait.js +209 -0
  127. package/dist/commands/session-wait.js.map +1 -0
  128. package/dist/commands/sessions.d.ts +52 -0
  129. package/dist/commands/sessions.js +479 -58
  130. package/dist/commands/sessions.js.map +1 -1
  131. package/dist/commands/skill-manage.d.ts +21 -0
  132. package/dist/commands/skill-manage.js +136 -19
  133. package/dist/commands/skill-manage.js.map +1 -1
  134. package/dist/commands/skills.js +19 -1
  135. package/dist/commands/skills.js.map +1 -1
  136. package/dist/commands/status.d.ts +1 -4
  137. package/dist/commands/status.js +5 -34
  138. package/dist/commands/status.js.map +1 -1
  139. package/dist/commands/statusline.backoff.test.d.ts +13 -0
  140. package/dist/commands/statusline.backoff.test.js +100 -0
  141. package/dist/commands/statusline.backoff.test.js.map +1 -0
  142. package/dist/commands/statusline.js +16 -9
  143. package/dist/commands/statusline.js.map +1 -1
  144. package/dist/commands/sync-status.d.ts +12 -0
  145. package/dist/commands/sync-status.js +125 -0
  146. package/dist/commands/sync-status.js.map +1 -0
  147. package/dist/commands/templates-retire.d.ts +34 -0
  148. package/dist/commands/templates-retire.js +192 -0
  149. package/dist/commands/templates-retire.js.map +1 -0
  150. package/dist/commands/tools.js +6 -21
  151. package/dist/commands/tools.js.map +1 -1
  152. package/dist/commands/tracks.d.ts +51 -0
  153. package/dist/commands/tracks.js +291 -0
  154. package/dist/commands/tracks.js.map +1 -0
  155. package/dist/commands/update.d.ts +3 -11
  156. package/dist/commands/update.js +5 -134
  157. package/dist/commands/update.js.map +1 -1
  158. package/dist/commands/upload.d.ts +68 -0
  159. package/dist/commands/upload.js +257 -0
  160. package/dist/commands/upload.js.map +1 -0
  161. package/dist/commands/vendor.d.ts +28 -0
  162. package/dist/commands/vendor.js +110 -0
  163. package/dist/commands/vendor.js.map +1 -0
  164. package/dist/commands/versions.js +6 -0
  165. package/dist/commands/versions.js.map +1 -1
  166. package/dist/commands/view.js +10 -5
  167. package/dist/commands/view.js.map +1 -1
  168. package/dist/commands/whoami.d.ts +23 -3
  169. package/dist/commands/whoami.js +169 -23
  170. package/dist/commands/whoami.js.map +1 -1
  171. package/dist/commands/worker.d.ts +122 -0
  172. package/dist/commands/worker.js +435 -0
  173. package/dist/commands/worker.js.map +1 -0
  174. package/dist/commands/worker.test.d.ts +1 -0
  175. package/dist/commands/worker.test.js +116 -0
  176. package/dist/commands/worker.test.js.map +1 -0
  177. package/dist/commands/workspace-ops.d.ts +35 -0
  178. package/dist/commands/workspace-ops.js +153 -0
  179. package/dist/commands/workspace-ops.js.map +1 -0
  180. package/dist/index.d.ts +6 -6
  181. package/dist/index.js +1009 -171
  182. package/dist/index.js.map +1 -1
  183. package/dist/lib/agent-connections.d.ts +31 -0
  184. package/dist/lib/agent-connections.js +33 -0
  185. package/dist/lib/agent-connections.js.map +1 -0
  186. package/dist/lib/agent-detect.d.ts +27 -0
  187. package/dist/lib/agent-detect.js +71 -0
  188. package/dist/lib/agent-detect.js.map +1 -0
  189. package/dist/lib/agent-door.d.ts +138 -0
  190. package/dist/lib/agent-door.js +426 -0
  191. package/dist/lib/agent-door.js.map +1 -0
  192. package/dist/lib/agents-config.d.ts +2 -0
  193. package/dist/lib/agents-config.js +4 -9
  194. package/dist/lib/agents-config.js.map +1 -1
  195. package/dist/lib/approval-poll.d.ts +31 -2
  196. package/dist/lib/approval-poll.js +20 -7
  197. package/dist/lib/approval-poll.js.map +1 -1
  198. package/dist/lib/atomic-file.d.ts +48 -0
  199. package/dist/lib/atomic-file.js +129 -0
  200. package/dist/lib/atomic-file.js.map +1 -0
  201. package/dist/lib/auth.d.ts +14 -9
  202. package/dist/lib/auth.js +44 -61
  203. package/dist/lib/auth.js.map +1 -1
  204. package/dist/lib/batch-approval.d.ts +85 -0
  205. package/dist/lib/batch-approval.js +170 -0
  206. package/dist/lib/batch-approval.js.map +1 -0
  207. package/dist/lib/capture-lane.d.ts +6 -5
  208. package/dist/lib/capture-lane.js +11 -8
  209. package/dist/lib/capture-lane.js.map +1 -1
  210. package/dist/lib/capture-structure.d.ts +342 -0
  211. package/dist/lib/capture-structure.js +295 -0
  212. package/dist/lib/capture-structure.js.map +1 -0
  213. package/dist/lib/catalog-templates.d.ts +59 -0
  214. package/dist/lib/catalog-templates.js +126 -0
  215. package/dist/lib/catalog-templates.js.map +1 -0
  216. package/dist/lib/cli-build.d.ts +19 -0
  217. package/dist/lib/cli-build.js +37 -0
  218. package/dist/lib/cli-build.js.map +1 -0
  219. package/dist/lib/conversation-headers.d.ts +18 -0
  220. package/dist/lib/conversation-headers.js +32 -0
  221. package/dist/lib/conversation-headers.js.map +1 -0
  222. package/dist/lib/cp-packages.d.ts +216 -4
  223. package/dist/lib/cp-packages.js +414 -11
  224. package/dist/lib/cp-packages.js.map +1 -1
  225. package/dist/lib/credential-class.d.ts +117 -0
  226. package/dist/lib/credential-class.js +116 -0
  227. package/dist/lib/credential-class.js.map +1 -0
  228. package/dist/lib/describe-lens.d.ts +35 -0
  229. package/dist/lib/describe-lens.js +40 -0
  230. package/dist/lib/describe-lens.js.map +1 -1
  231. package/dist/lib/device-connect.d.ts +125 -0
  232. package/dist/lib/device-connect.js +256 -0
  233. package/dist/lib/device-connect.js.map +1 -0
  234. package/dist/lib/directory-lens.d.ts +99 -0
  235. package/dist/lib/directory-lens.js +187 -0
  236. package/dist/lib/directory-lens.js.map +1 -0
  237. package/dist/lib/exporter-coverage.d.ts +71 -0
  238. package/dist/lib/exporter-coverage.js +97 -0
  239. package/dist/lib/exporter-coverage.js.map +1 -0
  240. package/dist/lib/hub-client.d.ts +43 -9
  241. package/dist/lib/hub-client.js +429 -65
  242. package/dist/lib/hub-client.js.map +1 -1
  243. package/dist/lib/id.d.ts +23 -0
  244. package/dist/lib/id.js +35 -0
  245. package/dist/lib/id.js.map +1 -0
  246. package/dist/lib/init-connect.d.ts +41 -0
  247. package/dist/lib/init-connect.js +75 -0
  248. package/dist/lib/init-connect.js.map +1 -0
  249. package/dist/lib/init-exit.d.ts +24 -0
  250. package/dist/lib/init-exit.js +41 -0
  251. package/dist/lib/init-exit.js.map +1 -0
  252. package/dist/lib/init-flow.d.ts +25 -0
  253. package/dist/lib/init-flow.js +40 -0
  254. package/dist/lib/init-flow.js.map +1 -0
  255. package/dist/lib/init-handoff.d.ts +16 -0
  256. package/dist/lib/init-handoff.js +19 -0
  257. package/dist/lib/init-handoff.js.map +1 -0
  258. package/dist/lib/init-output.d.ts +18 -0
  259. package/dist/lib/init-output.js +43 -0
  260. package/dist/lib/init-output.js.map +1 -0
  261. package/dist/lib/init-pod.d.ts +45 -0
  262. package/dist/lib/init-pod.js +36 -0
  263. package/dist/lib/init-pod.js.map +1 -0
  264. package/dist/lib/installed.d.ts +210 -11
  265. package/dist/lib/installed.js +234 -36
  266. package/dist/lib/installed.js.map +1 -1
  267. package/dist/lib/key-approval.d.ts +57 -0
  268. package/dist/lib/key-approval.js +117 -0
  269. package/dist/lib/key-approval.js.map +1 -0
  270. package/dist/lib/key-diagnosis.d.ts +56 -0
  271. package/dist/lib/key-diagnosis.js +227 -0
  272. package/dist/lib/key-diagnosis.js.map +1 -0
  273. package/dist/lib/key-doctor.d.ts +136 -0
  274. package/dist/lib/key-doctor.js +286 -0
  275. package/dist/lib/key-doctor.js.map +1 -0
  276. package/dist/lib/key-locations.d.ts +120 -0
  277. package/dist/lib/key-locations.js +326 -0
  278. package/dist/lib/key-locations.js.map +1 -0
  279. package/dist/lib/key-source.d.ts +66 -0
  280. package/dist/lib/key-source.js +106 -0
  281. package/dist/lib/key-source.js.map +1 -0
  282. package/dist/lib/key-state.d.ts +70 -0
  283. package/dist/lib/key-state.js +115 -0
  284. package/dist/lib/key-state.js.map +1 -0
  285. package/dist/lib/kind-package.d.ts +181 -0
  286. package/dist/lib/kind-package.js +679 -0
  287. package/dist/lib/kind-package.js.map +1 -0
  288. package/dist/lib/knowledge-title.d.ts +24 -0
  289. package/dist/lib/knowledge-title.js +46 -0
  290. package/dist/lib/knowledge-title.js.map +1 -0
  291. package/dist/lib/knowledge-title.test.d.ts +1 -0
  292. package/dist/lib/knowledge-title.test.js +34 -0
  293. package/dist/lib/knowledge-title.test.js.map +1 -0
  294. package/dist/lib/machine-instance.d.ts +64 -0
  295. package/dist/lib/machine-instance.js +142 -0
  296. package/dist/lib/machine-instance.js.map +1 -0
  297. package/dist/lib/mcp-bridge.d.ts +42 -0
  298. package/dist/lib/mcp-bridge.js +147 -0
  299. package/dist/lib/mcp-bridge.js.map +1 -0
  300. package/dist/lib/mcp-bridge.test.d.ts +1 -0
  301. package/dist/lib/mcp-bridge.test.js +90 -0
  302. package/dist/lib/mcp-bridge.test.js.map +1 -0
  303. package/dist/lib/mcp-call.d.ts +30 -0
  304. package/dist/lib/mcp-call.js +107 -0
  305. package/dist/lib/mcp-call.js.map +1 -0
  306. package/dist/lib/mcp-snippets.d.ts +53 -0
  307. package/dist/lib/mcp-snippets.js +82 -0
  308. package/dist/lib/mcp-snippets.js.map +1 -0
  309. package/dist/lib/next-steps.d.ts +8 -0
  310. package/dist/lib/next-steps.js +31 -1
  311. package/dist/lib/next-steps.js.map +1 -1
  312. package/dist/lib/package-wire.d.ts +179 -0
  313. package/dist/lib/package-wire.js +68 -0
  314. package/dist/lib/package-wire.js.map +1 -0
  315. package/dist/lib/pair-link.d.ts +38 -0
  316. package/dist/lib/pair-link.js +68 -0
  317. package/dist/lib/pair-link.js.map +1 -0
  318. package/dist/lib/pod-wide.d.ts +40 -0
  319. package/dist/lib/pod-wide.js +46 -0
  320. package/dist/lib/pod-wide.js.map +1 -0
  321. package/dist/lib/pod.d.ts +119 -115
  322. package/dist/lib/pod.js +206 -412
  323. package/dist/lib/pod.js.map +1 -1
  324. package/dist/lib/project-ref.d.ts +9 -3
  325. package/dist/lib/project-ref.js +10 -4
  326. package/dist/lib/project-ref.js.map +1 -1
  327. package/dist/lib/review-credential.d.ts +119 -0
  328. package/dist/lib/review-credential.js +147 -0
  329. package/dist/lib/review-credential.js.map +1 -0
  330. package/dist/lib/safe-open.d.ts +49 -0
  331. package/dist/lib/safe-open.js +119 -0
  332. package/dist/lib/safe-open.js.map +1 -0
  333. package/dist/lib/session-lens.d.ts +40 -1
  334. package/dist/lib/session-lens.js +54 -4
  335. package/dist/lib/session-lens.js.map +1 -1
  336. package/dist/lib/superwhisper-import.d.ts +8 -0
  337. package/dist/lib/superwhisper-import.js +14 -7
  338. package/dist/lib/superwhisper-import.js.map +1 -1
  339. package/dist/lib/superwhisper-title.test.d.ts +1 -0
  340. package/dist/lib/superwhisper-title.test.js +18 -0
  341. package/dist/lib/superwhisper-title.test.js.map +1 -0
  342. package/dist/lib/targets.d.ts +134 -10
  343. package/dist/lib/targets.js +962 -258
  344. package/dist/lib/targets.js.map +1 -1
  345. package/dist/lib/template-file.d.ts +78 -0
  346. package/dist/lib/template-file.js +140 -0
  347. package/dist/lib/template-file.js.map +1 -0
  348. package/dist/lib/template-lifecycle.d.ts +217 -0
  349. package/dist/lib/template-lifecycle.js +433 -0
  350. package/dist/lib/template-lifecycle.js.map +1 -0
  351. package/dist/lib/template-steps.d.ts +88 -0
  352. package/dist/lib/template-steps.js +118 -0
  353. package/dist/lib/template-steps.js.map +1 -0
  354. package/dist/lib/time-ago.d.ts +2 -0
  355. package/dist/lib/time-ago.js +15 -0
  356. package/dist/lib/time-ago.js.map +1 -0
  357. package/dist/utils/logger.js +5 -2
  358. package/dist/utils/logger.js.map +1 -1
  359. package/package.json +25 -18
  360. package/skills/README.md +12 -10
  361. package/skills/agent-os/SKILL.md +220 -99
  362. package/skills/manifest.json +2 -2
  363. package/skills/onboard/SKILL.md +61 -25
  364. package/skills/synap/README.md +5 -8
  365. package/skills/synap/SKILL.md +1185 -301
  366. package/skills/synap/_order.txt +7 -0
  367. package/skills/synap/_skill.yaml +1 -1
  368. package/skills/synap/automations.md +15 -0
  369. package/skills/synap/capture.md +54 -151
  370. package/skills/synap/cli-operations.md +24 -18
  371. package/skills/synap/common-mistakes.md +1 -0
  372. package/skills/synap/concepts.md +28 -0
  373. package/skills/synap/content-os.md +92 -0
  374. package/skills/synap/creative-loop.md +15 -10
  375. package/skills/synap/crm.md +21 -52
  376. package/skills/synap/digesting-a-channel.md +25 -0
  377. package/skills/synap/document-embeds.md +141 -47
  378. package/skills/synap/escalation-ladder.md +20 -10
  379. package/skills/synap/focus-sessions.md +47 -21
  380. package/skills/synap/from-intent.md +142 -0
  381. package/skills/synap/governance-rules.md +4 -4
  382. package/skills/synap/governance.md +10 -7
  383. package/skills/synap/hand-off.md +33 -0
  384. package/skills/synap/inline-patterns.md +15 -7
  385. package/skills/synap/lenses.md +33 -15
  386. package/skills/synap/linking.md +41 -40
  387. package/skills/synap/mcp-remote-servers.md +64 -0
  388. package/skills/synap/mental-model.md +24 -22
  389. package/skills/synap/multi-entity-capture.md +6 -4
  390. package/skills/synap/operating-mode-rules.md +1 -1
  391. package/skills/synap/processes.md +118 -0
  392. package/skills/synap/quick-reference.md +5 -1
  393. package/skills/synap/reading.md +3 -1
  394. package/skills/synap/reflexes.md +12 -42
  395. package/skills/synap/viewframe-cells.md +38 -5
  396. package/skills/synap/work-flow.md +1 -1
  397. package/skills/synap/work-model.md +96 -0
  398. package/skills/synap/worked-examples.md +21 -1
  399. package/skills/synap/workspace-design.md +14 -10
  400. package/skills/synap/writes.md +165 -35
  401. package/skills/synap/writing-titles.md +63 -0
  402. package/skills/synap-app/SKILL.md +319 -0
  403. package/skills/synap-app/_order.txt +5 -0
  404. package/skills/synap-app/_skill.yaml +20 -0
  405. package/skills/synap-app/creating-the-base-app.md +64 -0
  406. package/skills/synap-app/governance.md +42 -0
  407. package/skills/synap-app/install-commands.md +55 -0
  408. package/skills/synap-app/overview.md +50 -0
  409. package/skills/synap-app/using-the-sdk.md +73 -0
  410. package/skills/synap-design/SKILL.md +474 -0
  411. package/skills/synap-design/_order.txt +4 -0
  412. package/skills/synap-design/_skill.yaml +21 -0
  413. package/skills/synap-design/loop.md +134 -0
  414. package/skills/synap-design/overview.md +44 -0
  415. package/skills/synap-design/principles.md +130 -0
  416. package/skills/synap-design/system.md +133 -0
  417. package/skills/synap-market/SKILL.md +625 -0
  418. package/skills/synap-market/_order.txt +5 -0
  419. package/skills/synap-market/_skill.yaml +24 -0
  420. package/skills/synap-market/author-and-publish.md +212 -0
  421. package/skills/synap-market/discover-and-fetch.md +59 -0
  422. package/skills/synap-market/governance-and-catalog.md +63 -0
  423. package/skills/synap-market/install.md +133 -0
  424. package/skills/synap-market/overview.md +119 -0
  425. package/skills/synap-schema/SKILL.md +172 -10
  426. package/skills/synap-schema/_order.txt +2 -0
  427. package/skills/synap-schema/_skill.yaml +4 -2
  428. package/skills/synap-schema/common-mistakes.md +4 -2
  429. package/skills/synap-schema/discover-profiles.md +1 -1
  430. package/skills/synap-schema/entity-scope.md +15 -3
  431. package/skills/synap-schema/extend-first.md +29 -0
  432. package/skills/synap-schema/extend-vs-create.md +1 -1
  433. package/skills/synap-schema/intent-vocabulary-ssot.md +111 -0
  434. package/skills/synap-schema/property-types.md +1 -1
  435. package/skills/synap-schema/relations.md +1 -1
  436. package/skills/synap-ui/SKILL.md +19 -12
  437. package/skills/synap-ui/_skill.yaml +1 -1
  438. package/skills/synap-ui/ai-companion.md +1 -1
  439. package/skills/synap-ui/arranging-bento.md +2 -0
  440. package/skills/synap-ui/bento-layouts.md +10 -10
  441. package/skills/synap-ui/bento-recipes.md +313 -543
  442. package/skills/synap-ui/four-builds.md +5 -0
  443. package/skills/synap-ui/view-types.md +2 -2
  444. package/skills/synap-ui/widget-catalog.md +22 -278
  445. package/templates/automations/bookmark-enrichment.automation.json +290 -13
  446. package/templates/automations/url-bookmark-capture.automation.json +73 -11
  447. package/templates/skills/authoring-playbooks/SKILL.md +6 -3
  448. package/templates/skills/authoring-playbooks/reference/stages-contract.md +15 -0
  449. package/templates/skills/authoring-playbooks/reference/worked-example.md +3 -0
  450. package/dist/commands/infra.d.ts +0 -21
  451. package/dist/commands/infra.js +0 -262
  452. package/dist/commands/infra.js.map +0 -1
  453. package/dist/lib/browser-auth.d.ts +0 -35
  454. package/dist/lib/browser-auth.js +0 -170
  455. package/dist/lib/browser-auth.js.map +0 -1
  456. package/dist/lib/openclaw.d.ts +0 -32
  457. package/dist/lib/openclaw.js +0 -164
  458. package/dist/lib/openclaw.js.map +0 -1
  459. package/dist/lib/seed.d.ts +0 -13
  460. package/dist/lib/seed.js +0 -135
  461. package/dist/lib/seed.js.map +0 -1
package/dist/lib/pod.js CHANGED
@@ -1,11 +1,11 @@
1
1
  /**
2
2
  * Synap pod connection and management utilities.
3
3
  */
4
+ import { readJsonStrict, writeFileAtomic, ensureSecretDir } from "./atomic-file.js";
4
5
  import { execSync } from "child_process";
5
6
  import fs from "node:fs";
6
7
  import path from "node:path";
7
8
  import os from "node:os";
8
- const CP_URL = process.env.SYNAP_CP_URL ?? "https://api.synap.live";
9
9
  // ─── Local CLI config (persists pod connections) ──────────────────────────────
10
10
  const CONFIG_DIR = path.join(os.homedir(), ".synap");
11
11
  const CONFIG_FILE = path.join(CONFIG_DIR, "config.json");
@@ -18,45 +18,49 @@ export const SURFACE_NAMES = [
18
18
  "claude-desktop",
19
19
  "cursor",
20
20
  "codex",
21
+ "chatgpt",
22
+ "chatgpt-oauth",
21
23
  "opencode",
22
24
  "aider",
23
25
  "windsurf",
24
26
  "goose",
25
27
  "zed",
26
28
  "vscode",
29
+ "grok",
27
30
  "discord",
31
+ "proton",
32
+ "generic",
28
33
  ];
29
34
  /**
30
- * agentTypes already owned by OTHER doors — `POST /setup/agent` treats agentType
31
- * as a POD-WIDE SINGLETON, so `agents create` deriving a slug that collides with
32
- * one of these would silently hijack that door's agent + key. Superset of the
33
- * surfaces above plus the non-surface provisioning types (generic/openwebui MCP
34
- * mappings; openclaw/cli/memory). Single source of truth for the collision guard.
35
+ * agentTypes already owned by OTHER doors — provisioning is singleton per
36
+ * (createdByUserId, agentType), so `agents create` deriving a slug that collides
37
+ * with one of these would reuse that surface's agent for this user. Superset of
38
+ * the surfaces above plus the non-surface provisioning types (generic/openwebui
39
+ * MCP mappings; cli/memory, and the retired "openclaw", which pods may still
40
+ * hold an agent of). Single source of truth for the collision guard.
35
41
  */
36
42
  export const RESERVED_AGENT_TYPES = new Set([
37
43
  ...SURFACE_NAMES,
38
- "generic",
39
44
  "openwebui",
40
45
  "openclaw",
41
46
  "cli",
42
47
  "memory",
43
48
  ]);
44
49
  function ensureConfigDir() {
45
- if (!fs.existsSync(CONFIG_DIR)) {
46
- fs.mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
47
- }
50
+ ensureSecretDir(CONFIG_DIR);
48
51
  }
49
52
  function readMultiConfig() {
50
- // Read new format
51
- try {
52
- if (fs.existsSync(CONFIG_FILE)) {
53
- const parsed = JSON.parse(fs.readFileSync(CONFIG_FILE, "utf-8"));
53
+ // Read new format. A file that exists but does not parse THROWS
54
+ // (`ConfigUnreadableError`): read as "no pods", the next write would have
55
+ // persisted that and wiped every profile.
56
+ {
57
+ const parsed = readJsonStrict(CONFIG_FILE);
58
+ if (parsed) {
54
59
  if (parsed.pods)
55
- return { activePod: parsed.activePod ?? "", pods: parsed.pods, activeWorkspaceId: parsed.activeWorkspaceId, activeProjectId: parsed.activeProjectId, activeProject: parsed.activeProject, surfaces: parsed.surfaces, agentKeys: parsed.agentKeys, agentWorkspaceRouting: parsed.agentWorkspaceRouting };
60
+ return { activePod: parsed.activePod ?? "", pods: parsed.pods, activeWorkspaceId: parsed.activeWorkspaceId, activeWorkspace: parsed.activeWorkspace, activeProjectId: parsed.activeProjectId, activeProject: parsed.activeProject, surfaces: parsed.surfaces, agentKeys: parsed.agentKeys, agentKeysByPod: parsed.agentKeysByPod, pendingAgentKeys: parsed.pendingAgentKeys, agentWorkspaceRouting: parsed.agentWorkspaceRouting };
56
61
  // File exists but has old/unrecognized shape — fall through to migration
57
62
  }
58
63
  }
59
- catch { /* fall through */ }
60
64
  // Migrate from legacy flat format
61
65
  try {
62
66
  if (fs.existsSync(LEGACY_CONFIG_FILE)) {
@@ -75,14 +79,10 @@ function writeMultiConfig(config) {
75
79
  ensureConfigDir();
76
80
  // Merge with existing file so fields managed by other modules (e.g. `agents`)
77
81
  // are preserved when pod.ts only updates its own subset.
78
- let existing = {};
79
- try {
80
- if (fs.existsSync(CONFIG_FILE)) {
81
- existing = JSON.parse(fs.readFileSync(CONFIG_FILE, "utf-8"));
82
- }
83
- }
84
- catch { /* start fresh */ }
85
- fs.writeFileSync(CONFIG_FILE, JSON.stringify({ ...existing, ...config }, null, 2), { mode: 0o600 });
82
+ // An unreadable file throws here — never "start fresh" over someone's profiles.
83
+ const existing = readJsonStrict(CONFIG_FILE) ?? {};
84
+ // temp + fsync + rename: a crash mid-write never leaves a truncated config.
85
+ writeFileAtomic(CONFIG_FILE, JSON.stringify({ ...existing, ...config }, null, 2), { mode: 0o600 });
86
86
  }
87
87
  // ─── Public API ───────────────────────────────────────────────────────────────
88
88
  /**
@@ -162,12 +162,17 @@ export function setPodOverrideByName(name) {
162
162
  return pod;
163
163
  }
164
164
  /** Top-level commands that declare their OWN `--pod <name>` — their native handling must win. */
165
- const NATIVE_POD_FLAG_COMMANDS = new Set(["agents", "bridge-setup"]);
165
+ // bridge-setup owns a command-local --pod with custom prompt UX — leave it alone.
166
+ // agents used to be here too, but commander root also registers --pod and the
167
+ // flag never reached `agents create` (opts.pod stayed undefined), so create
168
+ // fell through to env agent keys → SURFACE_AGENT_TYPE_REQUIRED. Agents now
169
+ // rely on this bootstrap override like every other command.
170
+ const NATIVE_POD_FLAG_COMMANDS = new Set(["bridge-setup"]);
166
171
  /**
167
172
  * Consume a position-independent `--pod <name>` (or `--pod=<name>`) from argv and
168
173
  * register it as the per-invocation override. Mutates `argv` in place so commander
169
174
  * never sees the flag (it isn't registered per-command). No-op when the argv
170
- * targets a command that owns `--pod` itself (agents, bridge-setup). Throws with a
175
+ * targets a command that owns `--pod` itself (bridge-setup). Throws with a
171
176
  * helpful message when the named profile is unknown.
172
177
  */
173
178
  export function bootstrapPodOverride(argv) {
@@ -210,18 +215,111 @@ export function setActivePod(name) {
210
215
  writeMultiConfig(config);
211
216
  return config.pods[name];
212
217
  }
213
- /** Get the active workspace ID: explicit override first, then the pod default. */
214
- export function getActiveWorkspaceId() {
218
+ /** The active pod's profile NAME (not its config), or undefined if none is set. */
219
+ export function getActivePodName() {
220
+ const config = readMultiConfig();
221
+ return config.activePod && config.pods[config.activePod] ? config.activePod : undefined;
222
+ }
223
+ /** Find a saved pod profile NAME by its URL (trailing slashes ignored). */
224
+ export function findPodNameByUrl(url) {
225
+ if (!url)
226
+ return undefined;
227
+ const norm = (u) => u.replace(/\/+$/, "");
228
+ const target = norm(url);
229
+ const config = readMultiConfig();
230
+ for (const [name, p] of Object.entries(config.pods)) {
231
+ if (norm(p.podUrl) === target)
232
+ return name;
233
+ }
234
+ return undefined;
235
+ }
236
+ /**
237
+ * Resolve the workspace to use for a specific pod — PURE (no disk, no network),
238
+ * so the cross-pod rule is unit-testable.
239
+ *
240
+ * A workspace lives on exactly one pod, but `activeWorkspaceId` is a single
241
+ * pod-agnostic global. Sending it to the wrong pod is the "Access denied to
242
+ * workspace" 403. The rule: only honor the global override for the pod it
243
+ * actually belongs to; otherwise fall back to THAT pod's own default workspace.
244
+ *
245
+ * 1. No override set → the target pod's own default.
246
+ * 2. Override has a pod binding → honor it only for its bound pod; for any
247
+ * other pod, use that pod's default.
248
+ * 3. Legacy override (no binding) that equals ANOTHER saved pod's default →
249
+ * it clearly belongs to that pod → use the target's default.
250
+ * 4. Otherwise no evidence it's foreign → assume it's the target pod's (the
251
+ * legacy `synap use <custom-ws-on-this-pod>` case) → honor it.
252
+ */
253
+ export function resolveWorkspaceForPod(config, podName) {
254
+ const targetPod = podName ? config.pods[podName] : undefined;
255
+ const override = config.activeWorkspaceId;
256
+ const binding = config.activeWorkspace;
257
+ // Prefer a binding that matches the target pod even when activeWorkspaceId
258
+ // drifted to a foreign UUID (common after dual-pod work).
259
+ if (binding && binding.podName === podName) {
260
+ return binding.workspaceId;
261
+ }
262
+ if (binding && binding.podName !== podName) {
263
+ // Binding is for another pod — never use its workspace; only the target
264
+ // profile default if it doesn't look stolen from another profile.
265
+ return safePodDefaultWorkspace(config, podName, targetPod?.workspaceId);
266
+ }
267
+ if (!override) {
268
+ return safePodDefaultWorkspace(config, podName, targetPod?.workspaceId);
269
+ }
270
+ const belongsToAnotherPod = Object.entries(config.pods).some(([name, p]) => name !== podName && p.workspaceId === override);
271
+ if (belongsToAnotherPod) {
272
+ return safePodDefaultWorkspace(config, podName, targetPod?.workspaceId);
273
+ }
274
+ return override;
275
+ }
276
+ /**
277
+ * Profile `workspaceId` can drift to a UUID that belongs on another pod
278
+ * (dual-pod dogfood). Never return a default that is another profile's
279
+ * configured workspaceId. If the default is still suspect and differs from
280
+ * every other profile default, we cannot prove it's foreign without the
281
+ * server — return it only when unique among profile defaults.
282
+ */
283
+ function safePodDefaultWorkspace(config, podName, defaultWs) {
284
+ if (!defaultWs || !podName)
285
+ return defaultWs || undefined;
286
+ const stolenAsOtherDefault = Object.entries(config.pods).some(([name, p]) => name !== podName && p.workspaceId === defaultWs);
287
+ if (stolenAsOtherDefault)
288
+ return undefined;
289
+ return defaultWs;
290
+ }
291
+ /**
292
+ * Get the active workspace ID for a pod (by profile NAME). Applies the cross-pod
293
+ * rule in {@link resolveWorkspaceForPod}. Omit `podName` for the active pod.
294
+ */
295
+ export function getActiveWorkspaceIdForPod(podName) {
215
296
  const config = readMultiConfig();
216
- if (config.activeWorkspaceId)
217
- return config.activeWorkspaceId;
218
- const pod = config.activePod ? config.pods[config.activePod] : undefined;
219
- return pod?.workspaceId || undefined;
297
+ return resolveWorkspaceForPod(config, podName ?? (config.activePod || undefined));
220
298
  }
221
- /** Persist a workspace as the active context for all subsequent commands. */
222
- export function setActiveWorkspaceId(workspaceId) {
299
+ /**
300
+ * Get the active workspace ID for the ACTIVE pod: explicit override first (only
301
+ * if it belongs to this pod), then the pod default. Cross-pod-safe: a global
302
+ * override left over from another pod is ignored rather than sent (avoids the
303
+ * "Access denied to workspace" 403).
304
+ */
305
+ export function getActiveWorkspaceId() {
306
+ return getActiveWorkspaceIdForPod();
307
+ }
308
+ /**
309
+ * Persist a workspace as the active context for all subsequent commands.
310
+ * Records the pod the workspace belongs to (defaults to the active pod) so
311
+ * later cross-pod resolution can tell whether the override applies.
312
+ */
313
+ export function setActiveWorkspaceId(workspaceId, podName) {
223
314
  const config = readMultiConfig();
224
315
  config.activeWorkspaceId = workspaceId;
316
+ const boundPod = podName ?? config.activePod;
317
+ if (boundPod && config.pods[boundPod]) {
318
+ config.activeWorkspace = { workspaceId, podName: boundPod };
319
+ }
320
+ else {
321
+ delete config.activeWorkspace;
322
+ }
225
323
  writeMultiConfig(config);
226
324
  }
227
325
  /** Get the active project ID: durable override set by `synap project use`. */
@@ -229,10 +327,22 @@ export function getActiveProjectId() {
229
327
  const config = readMultiConfig();
230
328
  return config.activeProjectId || undefined;
231
329
  }
232
- /** Persist a project as the active context for all subsequent commands. */
233
- export function setActiveProjectId(projectId) {
330
+ /**
331
+ * Persist a project as the active context for all subsequent commands.
332
+ * Records the pod it was set against (defaults to the active pod) so
333
+ * {@link resolveHubConfig} can refuse to send it to a foreign pod.
334
+ * Peer of {@link setActiveWorkspaceId}.
335
+ */
336
+ export function setActiveProjectId(projectId, podName) {
234
337
  const config = readMultiConfig();
235
338
  config.activeProjectId = projectId;
339
+ const boundPod = podName ?? config.activePod;
340
+ if (boundPod && config.pods[boundPod]) {
341
+ config.activeProject = { projectId, podName: boundPod };
342
+ }
343
+ else {
344
+ delete config.activeProject;
345
+ }
236
346
  writeMultiConfig(config);
237
347
  }
238
348
  /**
@@ -254,20 +364,74 @@ export function getActiveProjectBinding() {
254
364
  export function clearActiveProjectId() {
255
365
  const config = readMultiConfig();
256
366
  delete config.activeProjectId;
367
+ delete config.activeProject;
257
368
  writeMultiConfig(config);
258
369
  }
259
370
  // ─── Surface agent keys ───────────────────────────────────────────────────────
260
- /** Store a dedicated agent key for a specific surface (e.g. "raycast", "claude-code"). */
371
+ /** Normalize a pod URL for map keys (strip trailing slashes). */
372
+ function normalizePodUrl(url) {
373
+ return url.replace(/\/+$/, "");
374
+ }
375
+ /**
376
+ * Store a dedicated agent key for a specific surface (e.g. "raycast", "claude-code").
377
+ * Always writes `agentKeys[surface]` (last-write, backward compat). When `key.podUrl`
378
+ * is set, also stores under `agentKeysByPod[surface][normalizedPodUrl]` so multi-pod
379
+ * surfaces can look up the key for the pod they are actually talking to.
380
+ */
261
381
  export function setSurfaceAgentKey(surface, key) {
262
382
  const config = readMultiConfig();
263
383
  config.agentKeys = config.agentKeys ?? {};
264
- config.agentKeys[surface] = key;
384
+ config.agentKeys[surface] = key; // last write for backward compat
385
+ if (key.podUrl) {
386
+ config.agentKeysByPod = config.agentKeysByPod ?? {};
387
+ const bySurface = config.agentKeysByPod[surface] ?? {};
388
+ bySurface[normalizePodUrl(key.podUrl)] = key;
389
+ config.agentKeysByPod[surface] = bySurface;
390
+ }
265
391
  writeMultiConfig(config);
266
392
  }
267
- /** Read back the stored agent key for a surface. Returns null if not provisioned. */
268
- export function getSurfaceAgentKey(surface) {
393
+ /**
394
+ * Read back the stored agent key for a surface.
395
+ * When `podUrl` is provided, prefer `agentKeysByPod` for that pod; if only a legacy
396
+ * `agentKeys[surface]` entry exists, return it only when its podUrl matches (or is
397
+ * unset). Never return a key known to belong to a different pod.
398
+ */
399
+ export function getSurfaceAgentKey(surface, podUrl) {
269
400
  const config = readMultiConfig();
270
- return config.agentKeys?.[surface] ?? null;
401
+ if (podUrl && config.agentKeysByPod?.[surface]) {
402
+ const hit = config.agentKeysByPod[surface][normalizePodUrl(podUrl)];
403
+ if (hit)
404
+ return hit;
405
+ }
406
+ const legacy = config.agentKeys?.[surface] ?? null;
407
+ if (podUrl && legacy?.podUrl && normalizePodUrl(legacy.podUrl) !== normalizePodUrl(podUrl)) {
408
+ return null; // do not return wrong-pod key
409
+ }
410
+ return legacy;
411
+ }
412
+ export function getPendingAgentKey(surface, podUrl) {
413
+ return readMultiConfig().pendingAgentKeys?.[surface]?.[normalizePodUrl(podUrl)] ?? null;
414
+ }
415
+ export function setPendingAgentKey(surface, key) {
416
+ const config = readMultiConfig();
417
+ config.pendingAgentKeys = config.pendingAgentKeys ?? {};
418
+ const bySurface = config.pendingAgentKeys[surface] ?? {};
419
+ bySurface[normalizePodUrl(key.podUrl)] = key;
420
+ config.pendingAgentKeys[surface] = bySurface;
421
+ writeMultiConfig(config);
422
+ }
423
+ export function clearPendingAgentKey(surface, podUrl) {
424
+ const config = readMultiConfig();
425
+ const bySurface = config.pendingAgentKeys?.[surface];
426
+ if (!bySurface || !(normalizePodUrl(podUrl) in bySurface))
427
+ return;
428
+ delete bySurface[normalizePodUrl(podUrl)];
429
+ if (Object.keys(bySurface).length === 0)
430
+ delete config.pendingAgentKeys[surface];
431
+ // writeMultiConfig MERGES over the file, so an emptied map must be written
432
+ // as an empty object, never dropped (a dropped key would keep the old value).
433
+ config.pendingAgentKeys = config.pendingAgentKeys ?? {};
434
+ writeMultiConfig(config);
271
435
  }
272
436
  export function setAgentWorkspaceRouting(routing) {
273
437
  const config = readMultiConfig();
@@ -281,6 +445,7 @@ export function getAgentWorkspaceRouting() {
281
445
  export function clearActiveWorkspaceId() {
282
446
  const config = readMultiConfig();
283
447
  delete config.activeWorkspaceId;
448
+ delete config.activeWorkspace;
284
449
  writeMultiConfig(config);
285
450
  }
286
451
  export function removePodProfile(name) {
@@ -294,15 +459,6 @@ export function removePodProfile(name) {
294
459
  }
295
460
  writeMultiConfig(config);
296
461
  }
297
- /** @deprecated Use addPodProfile("default", config) */
298
- export function saveLocalPodConfig(podConfig) {
299
- const config = readMultiConfig();
300
- const name = config.activePod || "default";
301
- config.pods[name] = podConfig;
302
- if (!config.activePod)
303
- config.activePod = name;
304
- writeMultiConfig(config);
305
- }
306
462
  /**
307
463
  * Check if a Synap pod is healthy.
308
464
  */
@@ -329,366 +485,4 @@ export async function checkPodHealth(podUrl) {
329
485
  export function startSelfHostedPod() {
330
486
  execSync('curl -fsSL https://raw.githubusercontent.com/Synap-core/backend/main/install.sh | bash', { stdio: "inherit" });
331
487
  }
332
- /**
333
- * Install the synap skill into OpenClaw.
334
- */
335
- /**
336
- * Open a Pod session for the CP-authenticated user.
337
- * Calls the issuer for a short-lived generic assertion, then exchanges that
338
- * assertion directly with the Pod. The issuer never receives a Pod session.
339
- *
340
- * Returns the Kratos session token the Pod mints after its own membership check.
341
- * That token authenticates subsequent pod tRPC calls (e.g.
342
- * `apiKeys.connectIntegration`) as the pod user, via the X-Session-Token header.
343
- * `sessionToken` is null only if the pod handshake returned no token (e.g. 409).
344
- */
345
- export async function provisionUserOnPod(podUrl, cpToken) {
346
- // Step 1: get an issuer assertion for this Pod.
347
- const assertionRes = await fetch(`${CP_URL}/pods/federation/assertion`, {
348
- method: "POST",
349
- headers: {
350
- "Content-Type": "application/json",
351
- Authorization: `Bearer ${cpToken}`,
352
- },
353
- body: JSON.stringify({ podUrl }),
354
- signal: AbortSignal.timeout(10000),
355
- });
356
- if (!assertionRes.ok) {
357
- const body = await assertionRes.text().catch(() => "");
358
- throw new Error(`Could not get Pod issuer assertion (HTTP ${assertionRes.status}): ${body.slice(0, 200)}`);
359
- }
360
- const { assertion } = (await assertionRes.json());
361
- if (!assertion) {
362
- throw new Error("Control Plane did not return a Pod issuer assertion");
363
- }
364
- // Step 2: exchange only with the Pod. It derives the issuer from `iss` and
365
- // verifies its own trusted-issuer registry and local membership.
366
- const exchangeRes = await fetch(`${podUrl}/api/federation/exchange`, {
367
- method: "POST",
368
- headers: { "Content-Type": "application/json" },
369
- body: JSON.stringify({ assertion }),
370
- signal: AbortSignal.timeout(15000),
371
- });
372
- if (!exchangeRes.ok) {
373
- const body = await exchangeRes.text().catch(() => "");
374
- throw new Error(`Pod issuer assertion exchange failed (HTTP ${exchangeRes.status}): ${body.slice(0, 200)}`);
375
- }
376
- // The pod returns the Kratos session token in the handshake body (the same
377
- // value the browser receives as the ory_kratos_session cookie).
378
- let sessionToken = null;
379
- try {
380
- const data = (await exchangeRes.json());
381
- sessionToken = data.session_token ?? null;
382
- }
383
- catch {
384
- // 409 or an empty body — no token to capture.
385
- }
386
- return { sessionToken };
387
- }
388
- /**
389
- * Issue a scoped Hub Protocol API key on the pod for an authenticated user.
390
- *
391
- * Canonical path: the pod's `apiKeys.connectIntegration` tRPC procedure — the
392
- * same one the pod-admin `/connect` page and the browser's LocalCliRow use.
393
- * Auth is the Kratos session token minted by {@link provisionUserOnPod},
394
- * forwarded as the `X-Session-Token` header. (Replaces the removed CP relay
395
- * `POST /pods/setup-agent`, which now returns 410.)
396
- *
397
- * Backend tRPC uses the superjson transformer, so the input rides in a
398
- * `{ json: ... }` envelope and the output is unwrapped from `result.data.json`.
399
- */
400
- export async function setupAgentViaPod(podUrl, sessionToken, integration = "openclaw") {
401
- const res = await fetch(`${podUrl}/trpc/apiKeys.connectIntegration`, {
402
- method: "POST",
403
- headers: {
404
- "Content-Type": "application/json",
405
- "X-Session-Token": sessionToken,
406
- },
407
- // strategy: "replace_existing" makes re-running `synap init` idempotent —
408
- // it revokes any prior key for this integration and mints a fresh one.
409
- body: JSON.stringify({
410
- json: { integration, strategy: "replace_existing" },
411
- }),
412
- signal: AbortSignal.timeout(15000),
413
- });
414
- const body = (await res.json().catch(() => null));
415
- if (!res.ok || !body || body.error) {
416
- const msg = body?.error?.message ?? `HTTP ${res.status}`;
417
- throw new Error(`Pod key issuance failed: ${msg}`);
418
- }
419
- const data = body.result?.data?.json;
420
- if (!data?.apiKey) {
421
- throw new Error("Pod returned no API key from connectIntegration");
422
- }
423
- return {
424
- hubApiKey: data.apiKey,
425
- // The connectIntegration key is owned by the human pod user directly — there
426
- // is no separate agent user in this model (same as the browser flow). Left
427
- // empty; the hub client resolves the acting user via /users/me at runtime.
428
- agentUserId: "",
429
- workspaceId: data.workspaceId ?? "",
430
- };
431
- }
432
- /**
433
- * Enable OpenClaw as a free addon on a SELF-HOSTED pod.
434
- * Uses the PROVISIONING_TOKEN directly against the pod.
435
- *
436
- * Routes through the shared `provisionAgentKey()` wrapper (dynamic import to
437
- * avoid a circular pod.ts <-> targets.ts static import). `workspaceId` is no
438
- * longer part of the response — agents are pod-wide singletons now; scope is
439
- * granted separately via `enrollAgentIfNeeded()`, not returned from setup.
440
- */
441
- export async function enableOpenClawAddon(podUrl, provisioningToken) {
442
- const { provisionAgentKey } = await import("./targets.js");
443
- const { hubApiKey, agentUserId } = await provisionAgentKey(podUrl, provisioningToken, "openclaw");
444
- return { hubApiKey, agentUserId, workspaceId: "" };
445
- }
446
- /**
447
- * Enable OpenClaw as an addon on a MANAGED pod via the Control Plane.
448
- * Calls POST /openclaw/provision on the CP (requires CP session token).
449
- * Returns the podId so the caller can poll status if needed.
450
- */
451
- export async function enableOpenClawAddonManaged(cpToken, podUrl) {
452
- // Find the pod ID from the CP
453
- const podsRes = await fetch(`${CP_URL}/pods`, {
454
- headers: { Authorization: `Bearer ${cpToken}` },
455
- signal: AbortSignal.timeout(10000),
456
- });
457
- if (!podsRes.ok)
458
- throw new Error(`Could not fetch pods (HTTP ${podsRes.status})`);
459
- const { pods } = (await podsRes.json());
460
- const appDomain = "synap.live";
461
- const pod = pods.find((p) => {
462
- const url = p.customDomain ? `https://${p.customDomain}` : `https://${p.subdomain}.${appDomain}`;
463
- return url === podUrl || podUrl.includes(p.subdomain);
464
- });
465
- // Not a local profile miss — this is a lookup against the pods the Control
466
- // Plane says you own, so podNotFoundError's "synap pods add" is the wrong fix.
467
- if (!pod) {
468
- const owned = pods.map((p) => p.customDomain ?? `${p.subdomain}.${appDomain}`).join(", ") || "(none)";
469
- throw new Error(`No pod matching ${podUrl} on your account. Pods on this account: ${owned}.`);
470
- }
471
- const provRes = await fetch(`${CP_URL}/openclaw/provision`, {
472
- method: "POST",
473
- headers: {
474
- "Content-Type": "application/json",
475
- Authorization: `Bearer ${cpToken}`,
476
- },
477
- body: JSON.stringify({ podId: pod.id }),
478
- signal: AbortSignal.timeout(15000),
479
- });
480
- if (!provRes.ok) {
481
- const body = await provRes.text().catch(() => "");
482
- throw new Error(`OpenClaw provision failed (HTTP ${provRes.status}): ${body.slice(0, 200)}`);
483
- }
484
- return { podId: pod.id };
485
- }
486
- /**
487
- * Check server resources (RAM, disk).
488
- */
489
- export function checkServerResources() {
490
- let ramTotal = 0;
491
- let ramFree = 0;
492
- let diskFree = "unknown";
493
- try {
494
- const mem = execSync("free -m 2>/dev/null || sysctl -n hw.memsize 2>/dev/null", {
495
- encoding: "utf-8",
496
- timeout: 3000,
497
- });
498
- const lines = mem.trim().split("\n");
499
- if (lines.length > 1) {
500
- const parts = lines[1].split(/\s+/);
501
- ramTotal = parseInt(parts[1], 10) || 0;
502
- ramFree = parseInt(parts[6] || parts[3], 10) || 0;
503
- }
504
- else {
505
- const bytes = parseInt(lines[0], 10);
506
- if (bytes > 0) {
507
- ramTotal = Math.round(bytes / 1024 / 1024);
508
- ramFree = Math.round(ramTotal * 0.5);
509
- }
510
- }
511
- }
512
- catch { /* can't detect */ }
513
- try {
514
- const df = execSync("df -h / 2>/dev/null | tail -1", {
515
- encoding: "utf-8",
516
- timeout: 3000,
517
- });
518
- diskFree = df.trim().split(/\s+/)[3] || "unknown";
519
- }
520
- catch { /* can't detect */ }
521
- return { ramTotal, ramFree, diskFree };
522
- }
523
- /**
524
- * Start OpenClaw as a Docker addon on the local server.
525
- * Writes env vars to the pod's .env file and runs docker compose --profile openclaw.
526
- * Only works when the CLI is running ON the pod server.
527
- */
528
- /**
529
- * Find the Synap deploy directory — where the .env and docker-compose files live.
530
- *
531
- * Strategy (most reliable first):
532
- * 1. Docker label — inspect any running synap container for
533
- * com.docker.compose.project.working_dir (always accurate, zero guessing)
534
- * 2. Walk up from cwd — works when running from inside the repo
535
- * 3. Common install paths as a last resort
536
- */
537
- export function findSynapDeployDir() {
538
- // ── 1. Ask Docker itself ───────────────────────────────────────────────
539
- try {
540
- // Find any container that belongs to a synap compose project
541
- const psOut = execSync("docker ps --format '{{.Names}}' 2>/dev/null", { encoding: "utf-8", timeout: 4000 });
542
- const synapContainer = psOut
543
- .split("\n")
544
- .map((l) => l.trim())
545
- .find((n) => /synap|openclaw/i.test(n));
546
- if (synapContainer) {
547
- const workDir = execSync(`docker inspect --format '{{index .Config.Labels "com.docker.compose.project.working_dir"}}' ${synapContainer} 2>/dev/null`, { encoding: "utf-8", timeout: 4000 }).trim();
548
- if (workDir && workDir !== "<no value>" && fs.existsSync(workDir)) {
549
- // compose project.working_dir is the folder containing docker-compose.yml
550
- // but the .env may be in a "deploy" subdirectory
551
- if (hasSynapCompose(workDir))
552
- return workDir;
553
- const deploySub = path.join(workDir, "deploy");
554
- if (hasSynapCompose(deploySub))
555
- return deploySub;
556
- return workDir; // trust Docker even if compose check fails
557
- }
558
- }
559
- }
560
- catch {
561
- // Docker not available or no containers — fall through
562
- }
563
- // ── 2. Walk up from cwd ────────────────────────────────────────────────
564
- let dir = process.cwd();
565
- for (let i = 0; i < 6; i++) {
566
- if (hasSynapCompose(dir))
567
- return dir;
568
- const parent = path.dirname(dir);
569
- if (parent === dir)
570
- break;
571
- dir = parent;
572
- }
573
- // ── 3. Common install paths ────────────────────────────────────────────
574
- const home = os.homedir();
575
- const fallbacks = [
576
- "/srv/synap",
577
- "/opt/synap",
578
- path.join(home, "synap-backend", "deploy"),
579
- path.join(home, "synap-backend"),
580
- path.join(home, "synap"),
581
- ];
582
- for (const d of fallbacks) {
583
- if (hasSynapCompose(d))
584
- return d;
585
- }
586
- return null;
587
- }
588
- function hasSynapCompose(dir) {
589
- try {
590
- for (const name of ["docker-compose.standalone.yml", "docker-compose.yml"]) {
591
- const f = path.join(dir, name);
592
- if (fs.existsSync(f)) {
593
- const content = fs.readFileSync(f, "utf-8");
594
- if (/ghcr\.io\/synap-core\/backend|synap-backend/i.test(content))
595
- return true;
596
- }
597
- }
598
- }
599
- catch {
600
- // unreadable
601
- }
602
- return false;
603
- }
604
- /**
605
- * Write OpenClaw env vars into the deploy dir .env and start the container.
606
- * Does NOT wait for health — OpenClaw can take several minutes to initialize
607
- * (first run pulls ~1GB image + runs setup). Caller should tell user to run
608
- * `synap finish` once it's up.
609
- *
610
- * Returns the deploy dir used.
611
- */
612
- export function startOpenClawOnServer(hubApiKey, agentUserId, workspaceId, podUrl, projectId) {
613
- const deployDir = findSynapDeployDir();
614
- if (!deployDir) {
615
- throw new Error("Could not find your Synap deploy directory.\n" +
616
- "Run from inside the synap-backend folder, or set SYNAP_DEPLOY_DIR env var.");
617
- }
618
- // ── Write env vars ───────────────────────────────────────────────────────
619
- const envFile = path.join(deployDir, ".env");
620
- const envVars = {
621
- OPENCLAW_HUB_API_KEY: hubApiKey,
622
- SYNAP_AGENT_USER_ID: agentUserId,
623
- SYNAP_WORKSPACE_ID: workspaceId,
624
- SYNAP_POD_URL: podUrl,
625
- };
626
- // Project is a peer lens to workspace — only injected when one is resolved.
627
- if (projectId)
628
- envVars.SYNAP_PROJECT_ID = projectId;
629
- let envContent = "";
630
- try {
631
- envContent = fs.existsSync(envFile) ? fs.readFileSync(envFile, "utf-8") : "";
632
- }
633
- catch { /* start fresh */ }
634
- for (const [key, value] of Object.entries(envVars)) {
635
- const regex = new RegExp(`^${key}=.*`, "m");
636
- const line = `${key}=${value}`;
637
- envContent = regex.test(envContent)
638
- ? envContent.replace(regex, line)
639
- : (envContent.endsWith("\n") || envContent === ""
640
- ? envContent + line + "\n"
641
- : envContent + "\n" + line + "\n");
642
- }
643
- fs.writeFileSync(envFile, envContent, { mode: 0o600 });
644
- // ── Start container ──────────────────────────────────────────────────────
645
- const composeFile = fs.existsSync(path.join(deployDir, "docker-compose.standalone.yml"))
646
- ? "docker-compose.standalone.yml"
647
- : "docker-compose.yml";
648
- // pipe stderr to /dev/null to suppress WARN lines about unset env vars
649
- // (those warnings are cosmetic — other services' vars not needed by openclaw)
650
- execSync(`docker compose -f ${composeFile} --profile openclaw up -d openclaw 2>/dev/null`, { stdio: ["ignore", "inherit", "ignore"], cwd: deployDir, timeout: 300_000 });
651
- return deployDir;
652
- }
653
- /**
654
- * Install the synap skill into OpenClaw.
655
- */
656
- const SKILL_SLUG = "synap";
657
- /**
658
- * Install the synap skill into OpenClaw.
659
- * Automatically chooses the right execution path:
660
- * - Local install: runs `openclaw skills install synap` directly
661
- * - Docker container: runs `docker exec <container> openclaw skills install synap`
662
- */
663
- export function installSynapSkill(containerName) {
664
- const cmd = containerName
665
- ? `docker exec ${containerName} openclaw skills install ${SKILL_SLUG}`
666
- : `openclaw skills install ${SKILL_SLUG}`;
667
- try {
668
- execSync(cmd, { stdio: "inherit", timeout: 60000 });
669
- }
670
- catch {
671
- if (containerName) {
672
- throw new Error(`Could not install skill via docker exec.\n` +
673
- `Run manually: docker exec ${containerName} openclaw skills install ${SKILL_SLUG}`);
674
- }
675
- else {
676
- throw new Error(`openclaw not found in PATH.\n` +
677
- `Run manually: openclaw skills install ${SKILL_SLUG}\n` +
678
- `Or if OpenClaw is in Docker: docker exec openclaw openclaw skills install ${SKILL_SLUG}`);
679
- }
680
- }
681
- }
682
- /**
683
- * Check whether the synap skill is installed inside a Docker container.
684
- */
685
- export function isSynapSkillInstalledInDocker(containerName) {
686
- try {
687
- const out = execSync(`docker exec ${containerName} openclaw skills list 2>/dev/null`, { encoding: "utf-8", timeout: 10000 });
688
- return /synap/i.test(out);
689
- }
690
- catch {
691
- return false;
692
- }
693
- }
694
488
  //# sourceMappingURL=pod.js.map