@lobu/runtime-server 22.0.0 → 23.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 (218) hide show
  1. package/dist/catalogs/connectors.json +1353 -181
  2. package/dist/catalogs/skills.json +1 -1
  3. package/dist/component.json +1 -1
  4. package/dist/connectors/README.md +14 -1
  5. package/dist/connectors/google_gmail.ts +1 -0
  6. package/dist/connectors/jira-helpers.ts +313 -0
  7. package/dist/connectors/jira.ts +29 -221
  8. package/dist/connectors/linkedin-browser-script.ts +13 -0
  9. package/dist/connectors/linkedin-draft-page.js +104 -0
  10. package/dist/connectors/linkedin-drafts.ts +73 -0
  11. package/dist/connectors/linkedin-identity.ts +32 -0
  12. package/dist/connectors/linkedin-inbox-adapter.js +1185 -0
  13. package/dist/connectors/linkedin-inbox.ts +156 -0
  14. package/dist/connectors/linkedin-like.ts +114 -0
  15. package/dist/connectors/linkedin-takeout.ts +577 -0
  16. package/dist/connectors/linkedin.ts +3998 -0
  17. package/dist/connectors/takeout-utils.ts +240 -0
  18. package/dist/connectors/tiktok-inbox-page.js +9 -9
  19. package/dist/connectors/tiktok-web-page.js +21 -15
  20. package/dist/connectors/tiktok_web.ts +63 -30
  21. package/dist/connectors/whatsapp-web-adapter.js +64 -564
  22. package/dist/connectors/whatsapp-web-helpers.ts +30 -444
  23. package/dist/connectors/whatsapp-web-identity.ts +20 -6
  24. package/dist/connectors/whatsapp_web.ts +45 -645
  25. package/dist/connectors/x-dm-adapter.js +556 -0
  26. package/dist/connectors/x-identity.ts +31 -2
  27. package/dist/connectors/x.ts +266 -120
  28. package/dist/db/migrations/20261017120000_drop_feeds_kind_virtual.sql +26 -0
  29. package/dist/db/migrations/20261017130000_drop_retired_dead_code_columns.sql +46 -0
  30. package/dist/dependencies.bun.lock +41 -41
  31. package/dist/guest.bundle.js +288 -148
  32. package/dist/owletto/dist/assets/_-3J-IrxWk.js +2 -0
  33. package/dist/owletto/dist/assets/{_-CEPl6gU4.js → _-DYUE3ix4.js} +3 -3
  34. package/dist/owletto/dist/assets/_agentId-Bn2IAjIy.js +2 -0
  35. package/dist/owletto/dist/assets/{_agentId-CBC_SadO.js → _agentId-Cam7Z0N7.js} +2 -2
  36. package/dist/owletto/dist/assets/{_automationId-YTTNksw6.js → _automationId-CXEiKVZJ.js} +2 -2
  37. package/dist/owletto/dist/assets/{_connectorKey._connectionId-fK0h7RAp.js → _connectorKey._connectionId-CS85l61t.js} +2 -2
  38. package/dist/owletto/dist/assets/{_connectorKey.index-C7TPS598.js → _connectorKey.index-clVDIyW0.js} +2 -2
  39. package/dist/owletto/dist/assets/{_conversationId-CEhxlTIo.js → _conversationId-Ci2k-BuN.js} +2 -2
  40. package/dist/owletto/dist/assets/{_deploymentId-BQfYN1U2.js → _deploymentId-BuUzGtVL.js} +2 -2
  41. package/dist/owletto/dist/assets/{_eventId-Cl8GSdjg.js → _eventId-B0662F8h.js} +2 -2
  42. package/dist/owletto/dist/assets/_name-CwWePlOl.js +2 -0
  43. package/dist/owletto/dist/assets/{_owner-cUtGHqSw.js → _owner-dTWkrKsK.js} +3 -3
  44. package/dist/owletto/dist/assets/_shape-BtS3y4M9.js +2 -0
  45. package/dist/owletto/dist/assets/_skillKey-Dc9m-nlR.js +2 -0
  46. package/dist/owletto/dist/assets/{_slug-CU1PuHB9.js → _slug-DQHutM41.js} +2 -2
  47. package/dist/owletto/dist/assets/_viewKey-B30ik8ma.js +2 -0
  48. package/dist/owletto/dist/assets/_viewKey-CUHypQnF.js +2 -0
  49. package/dist/owletto/dist/assets/{accept-invitation-D3OgJG4i.js → accept-invitation-w17IFTtf.js} +2 -2
  50. package/dist/owletto/dist/assets/{activity-route-view-DQglkhXU.js → activity-route-view-CMqYiiKM.js} +2 -2
  51. package/dist/owletto/dist/assets/{agent-card-controls-DzRs4Ix9.js → agent-card-controls-mnTN2AZt.js} +2 -2
  52. package/dist/owletto/dist/assets/{agent-client-setup-list-B2SvH7xD.js → agent-client-setup-list-Bg3hBfUV.js} +2 -2
  53. package/dist/owletto/dist/assets/{agent-connect-pages-B6uKvT_X.js → agent-connect-pages-B_vrqLVc.js} +2 -2
  54. package/dist/owletto/dist/assets/{agent-editor-form-oUnIYHd7.js → agent-editor-form-hTs7eO_U.js} +2 -2
  55. package/dist/owletto/dist/assets/{agent-guardrails-route-BaV1VpDh.js → agent-guardrails-route-BOrCXcAl.js} +2 -2
  56. package/dist/owletto/dist/assets/{agent-loading-shells-CtZJM2Gc.js → agent-loading-shells-Dqcvky-k.js} +2 -2
  57. package/dist/owletto/dist/assets/{agent-permissions-matrix-Ds48KFK9.js → agent-permissions-matrix-BOo_4r_4.js} +2 -2
  58. package/dist/owletto/dist/assets/{agent-skill-context-DPk5r08w.js → agent-skill-context-CCdvtlmH.js} +2 -2
  59. package/dist/owletto/dist/assets/{agent-skills-route-DYpB5H1J.js → agent-skills-route-BUxIswuq.js} +2 -2
  60. package/dist/owletto/dist/assets/{agent-subpage-shell-B3K_jPYR.js → agent-subpage-shell-D92imvSt.js} +2 -2
  61. package/dist/owletto/dist/assets/agent-thread-BJOijbT0.js +6 -0
  62. package/dist/owletto/dist/assets/agents-9XjpDj_S.js +2 -0
  63. package/dist/owletto/dist/assets/{agents-workbench-CMyk4PI7.js → agents-workbench-Bt5QCYQ7.js} +2 -2
  64. package/dist/owletto/dist/assets/{app._appId-DH1Qutz6.js → app._appId-CKv7_squ.js} +2 -2
  65. package/dist/owletto/dist/assets/{automation-detail-content-CEDNboId.js → automation-detail-content-vUwVumXf.js} +2 -2
  66. package/dist/owletto/dist/assets/automations-9XjpDj_S.js +2 -0
  67. package/dist/owletto/dist/assets/{callback-CU-hb8JB.js → callback-BRgcL8gz.js} +2 -2
  68. package/dist/owletto/dist/assets/{card-DIF8SF9b.js → card-Djgp00r_.js} +2 -2
  69. package/dist/owletto/dist/assets/{claim-DELEa-gH.js → claim-BYUZnyMp.js} +2 -2
  70. package/dist/owletto/dist/assets/{clients-CpG676mg.js → clients-D3Zbjxin.js} +2 -2
  71. package/dist/owletto/dist/assets/{code-editor-V27Z4o3P.js → code-editor-DHeyRGZI.js} +2 -2
  72. package/dist/owletto/dist/assets/connect-CfsFsy9P.js +2 -0
  73. package/dist/owletto/dist/assets/connect._clientId-DkiC8xos.js +2 -0
  74. package/dist/owletto/dist/assets/connected._clientId-CIXrGOsT.js +2 -0
  75. package/dist/owletto/dist/assets/{connected._clientId.activity-DQWcUqKM.js → connected._clientId.activity-Ckdz6I0y.js} +2 -2
  76. package/dist/owletto/dist/assets/{connected._clientId.index-BC3R303A.js → connected._clientId.index-CNxafNeo.js} +2 -2
  77. package/dist/owletto/dist/assets/{connection-DySpRE9x.js → connection-C3XXFEqh.js} +2 -2
  78. package/dist/owletto/dist/assets/{connection-feed-detail-C_D68j6d.js → connection-feed-detail-CIJJLDP8.js} +2 -2
  79. package/dist/owletto/dist/assets/{connections-browser-Cnv2iBbZ.js → connections-browser-CKZjzRz6.js} +2 -2
  80. package/dist/owletto/dist/assets/{connector-provenance-CNXtzYg5.js → connector-provenance-8-d8hl10.js} +2 -2
  81. package/dist/owletto/dist/assets/{connector-scope-lists-BKDetNDc.js → connector-scope-lists-CadPVsI3.js} +2 -2
  82. package/dist/owletto/dist/assets/{connectors-BJnk1z_2.js → connectors-lvLJ30lo.js} +2 -2
  83. package/dist/owletto/dist/assets/{consent-BVzxrAO9.js → consent-CdSvVCgx.js} +2 -2
  84. package/dist/owletto/dist/assets/{conversations-table-DfZGICl7.js → conversations-table-BdXoZAfc.js} +2 -2
  85. package/dist/owletto/dist/assets/{core.esm-DiTpULFl.js → core.esm-CYvgWCuv.js} +2 -2
  86. package/dist/owletto/dist/assets/create-0xW9eXxG.js +2 -0
  87. package/dist/owletto/dist/assets/{create-JRFM8mMf.js → create-B0qhrrX4.js} +2 -2
  88. package/dist/owletto/dist/assets/create-CAfF-yI1.js +2 -0
  89. package/dist/owletto/dist/assets/create-automation-form-CtSSeYj3.js +3 -0
  90. package/dist/owletto/dist/assets/create._connectorKey-i6xxkWKV.js +2 -0
  91. package/dist/owletto/dist/assets/{cronstrue-DPXl0qA2.js → cronstrue-n4qGUraE.js} +2 -2
  92. package/dist/owletto/dist/assets/deployments-4Itm35Xc.js +2 -0
  93. package/dist/owletto/dist/assets/{deployments-DCQdFdwG.js → deployments-RvUdVkj3.js} +2 -2
  94. package/dist/owletto/dist/assets/{deployments-body-D6TAWs_6.js → deployments-body-BMp7UsMo.js} +2 -2
  95. package/dist/owletto/dist/assets/{device-CntqYW65.js → device-CPU6CjkJ.js} +2 -2
  96. package/dist/owletto/dist/assets/{device-pin-tombstone-Bz4JHHMK.js → device-pin-tombstone-CrjG7gPo.js} +2 -2
  97. package/dist/owletto/dist/assets/{device._deviceId-D4plO3GM.js → device._deviceId-Cs3ZmXWo.js} +2 -2
  98. package/dist/owletto/dist/assets/{entity-options-UJs64GdQ.js → entity-options-uXjgT7y9.js} +2 -2
  99. package/dist/owletto/dist/assets/{entity-page-Djz6T50J.js → entity-page-Dc0LGr5U.js} +2 -2
  100. package/dist/owletto/dist/assets/{entity-type-page-OznRag6A.js → entity-type-page-CwZxa0BR.js} +2 -2
  101. package/dist/owletto/dist/assets/{event-detail-04qOUGIP.js → event-detail-ve2d6Gbb.js} +2 -2
  102. package/dist/owletto/dist/assets/{events-feed-fucGZSJR.js → events-feed-BtvhZF1f.js} +2 -2
  103. package/dist/owletto/dist/assets/{filter-editors-DCQgGLyR.js → filter-editors-Cj-v6NtH.js} +2 -2
  104. package/dist/owletto/dist/assets/{full-page-spinner-KpV2FS2u.js → full-page-spinner-DqpH99np.js} +2 -2
  105. package/dist/owletto/dist/assets/guardrails-HFo2Ut8B.js +2 -0
  106. package/dist/owletto/dist/assets/identity-BigVSBCl.js +2 -0
  107. package/dist/owletto/dist/assets/{index-BEvyBdOU.js → index-B9uPN6FC.js} +2 -2
  108. package/dist/owletto/dist/assets/{index-BNh2cidi.js → index-BQVliQW1.js} +2 -2
  109. package/dist/owletto/dist/assets/index-BfedB4Rc.js +2 -0
  110. package/dist/owletto/dist/assets/index-CUw3aKBI.js +2 -0
  111. package/dist/owletto/dist/assets/index-CXhxUkv3.js +2 -0
  112. package/dist/owletto/dist/assets/{index-_oPeVpL_.js → index-Cr5hwh-C.js} +66 -66
  113. package/dist/owletto/dist/assets/index-CzkTV4ZQ.js +2 -0
  114. package/dist/owletto/dist/assets/index-DKSx8JN_.js +2 -0
  115. package/dist/owletto/dist/assets/{index-D3s8rhG9.js → index-DVk7Ug0d.js} +2 -2
  116. package/dist/owletto/dist/assets/index-DmZuKGf8.js +2 -0
  117. package/dist/owletto/dist/assets/{index-DCdkwg9H.js → index-Hio-HRfo.js} +2 -2
  118. package/dist/owletto/dist/assets/{index-BJXkc60S.js → index-ICgKp3YK.js} +2 -2
  119. package/dist/owletto/dist/assets/index-cPcroOH0.js +2 -0
  120. package/dist/owletto/dist/assets/{index-BOzuAbvi.js → index-n7sTbNv4.js} +2 -2
  121. package/dist/owletto/dist/assets/index-xiFpcWKv.js +2 -0
  122. package/dist/owletto/dist/assets/{json-diff-D_Ym3Uku.js → json-diff-DBoag_OS.js} +2 -2
  123. package/dist/owletto/dist/assets/{list-skeleton-Bl0OS39L.js → list-skeleton-C_GuoxAH.js} +2 -2
  124. package/dist/owletto/dist/assets/{login-QHdxqX-4.js → login-Ci6ixHuL.js} +2 -2
  125. package/dist/owletto/dist/assets/{logout-DUccApuZ.js → logout-CLGgeZB7.js} +2 -2
  126. package/dist/owletto/dist/assets/{member-scope-gate-CFbrq1by.js → member-scope-gate-B44INDPY.js} +2 -2
  127. package/dist/owletto/dist/assets/{memory-browse-page-IrIXuZTF.js → memory-browse-page-DyQiRvzl.js} +2 -2
  128. package/dist/owletto/dist/assets/{model-selector-CB1BDvlW.js → model-selector-dAbDgJvx.js} +2 -2
  129. package/dist/owletto/dist/assets/models-DpVP7ZwX.js +2 -0
  130. package/dist/owletto/dist/assets/{new-BWo8_Pms.js → new-BUb7AnEW.js} +2 -2
  131. package/dist/owletto/dist/assets/{new-B5UsLiy6.js → new-BkdULx2r.js} +2 -2
  132. package/dist/owletto/dist/assets/{new-DpmDXmFI.js → new-CHOr-EcI.js} +2 -2
  133. package/dist/owletto/dist/assets/{oauth-workspace-access-PGyTnW2K.js → oauth-workspace-access-BxsjwgdH.js} +2 -2
  134. package/dist/owletto/dist/assets/{organization-BH8PYlVu.js → organization-gxGeDjIV.js} +2 -2
  135. package/dist/owletto/dist/assets/{peek-pane-content-B2AFNTzP.js → peek-pane-content-CHoQHe2H.js} +2 -2
  136. package/dist/owletto/dist/assets/{permissions-CwN_YP3u.js → permissions-aPHaKLec.js} +2 -2
  137. package/dist/owletto/dist/assets/{proposal-review-shell-DKKGu4Ww.js → proposal-review-shell-UcZr87_Q.js} +2 -2
  138. package/dist/owletto/dist/assets/public-shell-ready-DcnlADmj.js +2 -0
  139. package/dist/owletto/dist/assets/{recent-DqdZE_TI.js → recent-D-65Pgu-.js} +2 -2
  140. package/dist/owletto/dist/assets/{record-activity-CvgZyCmw.js → record-activity-CBXH6v1d.js} +2 -2
  141. package/dist/owletto/dist/assets/{renderer-BL6VcwQH.js → renderer-mEDnVW0O.js} +2 -2
  142. package/dist/owletto/dist/assets/{reset-password-DAvBYkiI.js → reset-password-uX_V6bip.js} +2 -2
  143. package/dist/owletto/dist/assets/{runs-BWtc5rmc.js → runs-C0rCgGwX.js} +2 -2
  144. package/dist/owletto/dist/assets/runs-panel-Du1JMjg5.js +2 -0
  145. package/dist/owletto/dist/assets/{runs-table-DxIiqrSk.js → runs-table-syPJ6r6T.js} +2 -2
  146. package/dist/owletto/dist/assets/{settings-Crxlwps-.js → settings-9NkNA1G1.js} +2 -2
  147. package/dist/owletto/dist/assets/settings-E-10sLQX.js +2 -0
  148. package/dist/owletto/dist/assets/skills-D2Ri9b4f.js +2 -0
  149. package/dist/owletto/dist/assets/{source-record-panels-CRIPMWfN.js → source-record-panels-CPyzlfD1.js} +2 -2
  150. package/dist/owletto/dist/assets/{status-dot-C5KDvvm9.js → status-dot-B-EWMgq6.js} +2 -2
  151. package/dist/owletto/dist/assets/{tabs-B4Er9hJj.js → tabs-DqIIkCX-.js} +2 -2
  152. package/dist/owletto/dist/assets/{use-mention-search-DqEykWl_.js → use-mention-search-By8RZyKW.js} +2 -2
  153. package/dist/owletto/dist/assets/{view-param-filters-Cylutoy1.js → view-param-filters-CqLZQrnO.js} +2 -2
  154. package/dist/owletto/dist/index.html +1 -1
  155. package/dist/server-main.bundle.mjs +11447 -10762
  156. package/npm-shrinkwrap.json +160 -160
  157. package/package.json +1 -1
  158. package/vendor/connector-sdk/dist/browser-handoff-banner.d.ts +39 -0
  159. package/vendor/connector-sdk/dist/browser-handoff-banner.js +175 -0
  160. package/vendor/connector-sdk/dist/browser-source-read.d.ts +52 -0
  161. package/vendor/connector-sdk/dist/browser-source-read.js +107 -0
  162. package/vendor/connector-sdk/dist/connector-types.d.ts +10 -0
  163. package/vendor/connector-sdk/dist/index.d.ts +3 -0
  164. package/vendor/connector-sdk/dist/index.js +2 -0
  165. package/vendor/connector-sdk/package.json +9 -1
  166. package/vendor/core/dist/capabilities.d.ts +1 -1
  167. package/vendor/core/dist/capabilities.js +0 -1
  168. package/vendor/core/dist/connector-query-errors.d.ts +32 -0
  169. package/vendor/core/dist/connector-query-errors.js +41 -1
  170. package/vendor/core/dist/contracts/tools/manage-conversations.js +2 -2
  171. package/vendor/core/dist/contracts/tools/manage-feeds.d.ts +14 -0
  172. package/vendor/core/dist/contracts/tools/manage-feeds.js +17 -0
  173. package/vendor/core/dist/contracts/worker/protocol.d.ts +8 -131
  174. package/vendor/core/dist/contracts/worker/protocol.js +9 -61
  175. package/vendor/core/dist/device-pin-tombstones.d.ts +44 -0
  176. package/vendor/core/dist/device-pin-tombstones.js +57 -0
  177. package/vendor/core/dist/index.d.ts +2 -1
  178. package/vendor/core/dist/index.js +1 -0
  179. package/vendor/core/dist/logger.js +10 -25
  180. package/vendor/core/dist/utils/diagnostic-scrubber.js +258 -21
  181. package/vendor/core/dist/worker/wire.d.ts +0 -10
  182. package/vendor/core/package.json +6 -6
  183. package/vendor/views/package.json +1 -1
  184. package/dist/owletto/dist/assets/_-C_zNZben.js +0 -2
  185. package/dist/owletto/dist/assets/_agentId-QQW91cHX.js +0 -2
  186. package/dist/owletto/dist/assets/_name-t3oBJ6Zf.js +0 -2
  187. package/dist/owletto/dist/assets/_shape-bo2lMVCu.js +0 -2
  188. package/dist/owletto/dist/assets/_skillKey-Dwm4Q4wI.js +0 -2
  189. package/dist/owletto/dist/assets/_viewKey-Bh6E_NxA.js +0 -2
  190. package/dist/owletto/dist/assets/_viewKey-D4jKl-Zf.js +0 -2
  191. package/dist/owletto/dist/assets/agent-thread-C8UaUTWc.js +0 -6
  192. package/dist/owletto/dist/assets/agents-F4mGI2oF.js +0 -2
  193. package/dist/owletto/dist/assets/automations-F4mGI2oF.js +0 -2
  194. package/dist/owletto/dist/assets/connect-B2YL6qIK.js +0 -2
  195. package/dist/owletto/dist/assets/connect._clientId-B6LDmDRV.js +0 -2
  196. package/dist/owletto/dist/assets/connected._clientId-D_HaKoI1.js +0 -2
  197. package/dist/owletto/dist/assets/create-CUqO6Kfk.js +0 -2
  198. package/dist/owletto/dist/assets/create-automation-form-_4vUkrls.js +0 -3
  199. package/dist/owletto/dist/assets/create-iHcxV0xd.js +0 -2
  200. package/dist/owletto/dist/assets/create._connectorKey-CCYLEicg.js +0 -2
  201. package/dist/owletto/dist/assets/deployments-ihkhK1zV.js +0 -2
  202. package/dist/owletto/dist/assets/guardrails-molekzAF.js +0 -2
  203. package/dist/owletto/dist/assets/identity-BJcaG66g.js +0 -2
  204. package/dist/owletto/dist/assets/index-B04ON9Jv.js +0 -2
  205. package/dist/owletto/dist/assets/index-BOsK-K-2.js +0 -2
  206. package/dist/owletto/dist/assets/index-Bk1x7A67.js +0 -2
  207. package/dist/owletto/dist/assets/index-CFnx5huL.js +0 -2
  208. package/dist/owletto/dist/assets/index-Dbd1jusf.js +0 -2
  209. package/dist/owletto/dist/assets/index-DqZuqC08.js +0 -2
  210. package/dist/owletto/dist/assets/index-Dr-Xg_xO.js +0 -2
  211. package/dist/owletto/dist/assets/index-KPOvMVa-.js +0 -2
  212. package/dist/owletto/dist/assets/models-DnMb3n-Z.js +0 -2
  213. package/dist/owletto/dist/assets/public-shell-ready-7KYnww6e.js +0 -2
  214. package/dist/owletto/dist/assets/runs-panel-BO3h5RkS.js +0 -2
  215. package/dist/owletto/dist/assets/settings-4Ev-0iNL.js +0 -2
  216. package/dist/owletto/dist/assets/skills-D0X430X8.js +0 -2
  217. package/vendor/core/dist/contracts/worker/device-chat.d.ts +0 -4
  218. package/vendor/core/dist/contracts/worker/device-chat.js +0 -26
@@ -8,7 +8,7 @@
8
8
  "version": "1.0.0",
9
9
  "description": "Set up new Lobu agents end to end and operate existing Lobu projects and memory: interview, scaffold, validate, authenticate, connect feeds, execute operations, and test Automations.",
10
10
  "detail": {
11
- "instructions": "# Lobu\n\nUse this skill when setting up a brand-new Lobu agent from scratch (follow \"Onboarding a New Project\" below) or when running, validating, evaluating, or connecting an existing Lobu project, or operating Lobu memory from a coding agent.\n\nThe `AGENTS.md` generated into a new project is the source of truth for the config API (the `define*` helpers, connectors, auth, Automations, memory) — this skill does not duplicate it. For an existing project, jump to \"Core Model\" + the relevant reference section below.\n\n## Onboarding a New Project\n\nUse this playbook when a new user asks you to build them a Lobu agent from scratch. Set it up end to end: ground yourself in what the user already has, interview, discover, scaffold, prove the complete local path, then offer the deployment choice. Do not call the setup complete until every path the user selected has actually passed end to end. If an external provider, authorization, deployment, or rate limit blocks the proof, name the exact blocker and leave the setup as blocked rather than claiming success.\n\n### 1. Ground yourself in what the user already has\n\nBefore interviewing, look at what already exists so your questions and suggestions are personal rather than a blank slate. This is discovery, not a design decision — do not let it skip the interview.\n\n- Local: run `lobu context list` to see existing contexts; check the current directory and home for existing Lobu projects (`lobu.config.ts`), configured MCP servers, and CLI auth state. Note what the user already set up.\n- Cloud: if the user has an active session (do not create one just to look), call `client.organizations.list()`, `client.agents.list()` for each org, `client.catalog.listInstalled({ kinds: [\"connectors\"] })`, and `search_memory` for prior knowledge. This reveals existing agents, connectors, and memory you can build on.\n- Tell the user what you are looking at so they can correct you, and let what you find shape the options you offer. Never treat this discovery as an identity signal: orgs, emails, or domains never prove a company or product, and never mention a competitor or third party unless it actually appears in what you found.\n\nDo NOT ask for a login email during the interview. Email is only needed when a managed connector actually requires a session (step 3) or when the user chooses cloud deployment (step 6); ask for it at that point. Treat identity only as identity; never infer a company from an email address or domain.\n\n### 2. Interview with concrete, personalized options\n\nInterview the user one question at a time; wait for each answer, do not guess, and do not batch the questions. Anchor each question in what you found in step 1. Instead of asking \"what agent do you want?\" as a blank slate, summarize what you see and offer two or three concrete alternatives to choose from:\n\n- \"You already have org X with connectors A and B installed and N existing agents. Do you want to (a) add a new agent on top of those, (b) extend one of the existing agents, or (c) start something standalone?\"\n- \"For what it should do, the common shapes are (a) a triage agent that reads incoming chat and files a ticket, (b) a scheduled report that summarizes new activity each morning, (c) a research agent that answers questions from your connected tools. Which fits, or what would you change?\"\n\nOffer a default so the user can answer \"the first one\" — decisive users and undecided users both move faster with a concrete menu.\n\n- What company or product is this for?\n- What does it do, and who does it serve?\n- What is its public domain? (optional for a personal project)\n- Do I have permission to research the public website and other public sources?\n- What is the agent for?\n- What should we call it?\n- Who uses it: just me, my team, or each of my customers?\n- How should it behave, and what may it do unattended versus only with approval?\n- What should it remember? Model this as one to three entity types.\n- Where does its data come from? Pick one connector or custom source to start.\n- Where should people talk to it? Offer Web UI, API or SDK, MCP, Slack, Teams, WhatsApp, Discord, Google Chat, and Telegram without forcing a chat platform. If Slack is chosen, ask whether to join Lobu's hosted workspace for a quick start, install Lobu into an existing workspace, or use a custom Slack app; then ask whether to test the DM with Lobu, a named channel, or both, and whether people knowledge means conversation participants, bound-channel members, or the full workspace directory.\n- Should anything run on a schedule?\n- Which supported LLM provider credential does the user have?\n\nIf the user gave permission to research and has a public domain, research the company before proposing the design. Summarize its product, customers, workflows, and useful signals, and cite the public sources you used. Then propose one to three entity types, their relationships, the first data source, one or two useful Automations, and suitable interaction channels. Play back a short numbered plan and wait for confirmation before scaffolding anything.\n\n### 3. Discover the surface before choosing how to scaffold\n\nCheck Node is 22-24 or 26+ (only Node 25 is unsupported), then run `lobu context list` and identify the named Lobu Cloud context; do not assume the active context still points to cloud after a local run. If a managed or cloud connector was chosen and there is no session, ask for the login email at that point, explain that Lobu will email an approval link, and run `lobu login --email <confirmed-address> --context <cloud-name>`. The person approving must sign in with that same email; knowing an address never grants access. After a successful login, an empty organization membership list is a tenancy/discovery result, not an authentication failure: call `client.organizations.list()` and explain the result. Never revoke or repeat login with `--force` unless the user separately approves that re-authentication.\n\nUse ClientSDK through Lobu MCP or `lobu memory exec` with the explicit cloud context. Call `client.organizations.list()` to find public organizations offering managed connections. Call `client.catalog.listInstalled({ kinds: [\"connectors\"] })`; if the connector is not installed, call `client.catalog.listCatalog({ kinds: [\"connectors\"] })`. Inspect the selected entry's `detail.auth_schema`, `detail.options_schema`, `detail.feeds_schema`, and `detail.automation_events` instead of guessing field names. On account-scoped `/mcp`, select an authorized home workspace first with `const home = await client.org(homeSlug)` and call `home.connections.connectManaged`; put the public provider org in `managed_by_org`, rather than selecting that provider org with `client.org`. This call runs against cloud, not the embedded runtime. If a matching live managed offer exists, explain it and call `client.connections.connectManaged` only after consent. Complete the returned user authorization, then run `lobu context use <cloud-name>` immediately before executing its `local_bootstrap_command` from the parent directory where the new project should be created; use `--here` only after entering an empty directory, and do not create a blank Lobu scaffold first. Ask for bring-your-own OAuth credentials only if no managed offer exists or the user prefers their own app.\n\n**If no connector in the catalog matches the data source, do not report \"no integration exists\"** — author a custom connector: write `connectors/<name>.connector.ts` in the project, register it with `connectorFromFile(\"./connectors/<name>.connector.ts\")`, and model it on the [npm downloads example](https://github.com/lobu-ai/lobu/blob/main/examples/lobu-crm/npm-downloads.connector.ts). See [Connector authoring](https://github.com/lobu-ai/lobu/blob/main/docs/connector-authoring.md) for the full contract; the end-to-end entity/event/Automation model is in [Lobu concepts](https://github.com/lobu-ai/lobu/blob/main/docs/CONCEPTS.md).\n\n### 4. Scaffold and build from the confirmed plan\n\nIf managed auth supplied a `local_bootstrap_command`, use the project it generated. Otherwise run `npx @lobu/cli@latest init` with the confirmed name and provider. Postgres is built in, so `lobu run` starts an embedded database; ask for `DATABASE_URL` only if the user chooses external Postgres. Read the generated `AGENTS.md` completely before editing `lobu.config.ts`. Use the canonical reference at `https://github.com/lobu-ai/lobu/blob/main/examples/lobu-crm/lobu.config.ts` when needed; do not assume that example exists in the new project's filesystem. Briefly explain how the chosen feed may use checkpoints to collect incrementally, emits events, builds shared entity memory, and gives both chat and Automations the same governed context.\n\n`feeds_schema.<feed>.eventKinds` are the default Automation trigger catalog for feed connectors: every declared kind is a subscribable event type (`event_type` = the kind slug) for any feed that emits the kind. A feed's first successful non-dry sync establishes its baseline without activation; later inserts of a matching kind activate subscribers. Feed-scoped filtering is not yet available (events dedupe by connection + origin id, so a `feed_key` match would miss origins first seen by another feed). `automation_events` (now derived from eventKinds when a connector declares none) is the trigger picker's list. If no declared kind matches the use case, use a scheduled Automation with a bounded named SQL source and read event text from `payload_text`. Validate the query against the running local schema before relying on it. If `feeds_schema` is empty, do not invent or trigger a feed; chat integrations such as Slack can deliver incoming messages directly. For Slack or Telegram, prefer `defineConnection` with `credentialMode: \"hosted\"` so no bot token is required; `lobu run` prints the exact hosted-workspace join URL, own-workspace install URL when available, and short-lived link command. This hosted chat path requires a cloud session and the agent applied to that cloud workspace; the link targets the cloud agent. It does not create a local Slack data connection or prove local Slack search. Use those returned values instead of constructing URLs. A printed `/lobu link <code>` is one-time: redeem it in the first selected DM or channel. In an installed workspace whose installer is linked to Lobu, bind each additional surface with `/lobu link <agent-id>`; otherwise generate a fresh code for that surface. Mention Lobu in a channel test and verify the App Home separately. Lobu email login and Slack installation are separate: the email link authorizes Lobu CLI access, while an existing-workspace install requires the user or workspace admin to approve Slack's OAuth screen. Never describe Slack consent as an email approval. Use `credentialMode: \"byo\"` only if the user chooses their own app. Tell the user once which remaining secrets are required and add only `secret(\"ENV_NAME\")` placeholders to config. Never open or request permission to read `.env`; inspect `.env.example` when present and declared secret placeholder names only. Never read, print, invent, or paste a real secret into source or chat.\n\nIf the user wants the agent to know people in Slack, ask whether that means conversation participants, members of bound channels, or the full workspace directory. Installing the app proves none of those by itself. Verify the selected scope by inspecting the people or member entities Lobu actually materialized and by asking the agent a roster question. If human-readable names or non-participants are unavailable, identify that exact product gap; never claim the complete workspace directory was synced.\n\n### 5. Prove the complete local path\n\nChange into the generated project directory and verify `pwd` contains the intended `lobu.config.ts`; never run project commands from its parent. Run `npx @lobu/cli@latest validate`, boot with `npx @lobu/cli@latest run`, and verify health and the local Web UI. With the embedded database default, `lobu run` creates and selects the local context and auto-applies the project; with an external `DATABASE_URL`, it does neither, so authenticate and apply to that runtime explicitly. Send a harmless direct chat message without tools.\n\nBefore consent to access provider data, inspect only catalog, connection, auth-profile, and feed metadata. For browser access, inspect the paired device and connection metadata without invoking browser actions. Durable managed OAuth and env-profile credentials stay at the gateway. Do not run a feed or connector dry-run before consent, because a dry-run may still read provider data. Ask explicitly before accessing real provider data. Only after approval, dry-run the connector or feed server-side and trigger the selected feed manually if that connector actually declares one. A feed dry-run records its run but persists no collected events, entities, attachments, checkpoint changes, or feed sync state. Run each Automation once, poll `client.operations.getRun` with its returned `run_id`, and show each completed run plus any declared result event or entity. For a run-result-only or reaction-only Automation, use the completed run and the Automation `view_url` returned by Lobu. For Slack, treat DM, channel mention, App Home, and requested member discovery as four separate checks. Keep actions in approval mode unless the user explicitly approves execution. If any step fails, fix it and rerun that step; do not silently substitute a different path.\n\n### 6. Offer the deployment choice\n\nAfter the local proof, ask the user whether to keep running locally or deploy to Lobu Cloud. Explain that the embedded local runtime and Lobu Cloud are separate targets, and that keeping it local needs no further setup. Only if the user chooses cloud deployment, ask for the login email to identify the deployer, explain that Lobu will email an approval link, and run `lobu login --email <confirmed-address> --context <cloud-name>`; the person approving must sign in with that same email. Because `lobu apply` has no context flag, use `lobu context list` and then `lobu context use <cloud-name>` to select an explicit cloud context before deployment. Run `lobu apply --dry-run` first, show the target organization and exact plan, and wait for confirmation before applying. After apply, use only authoritative `view_url` values and link commands returned by Lobu; never construct URLs. Present the working access choices: Web UI, direct agent chat, API or SDK, MCP, and any channels the user selected.\n\n## Core Model\n\n- **Lobu** is the agent framework, runtime, deployment layer, and memory surface.\n- Keep framework configuration in `lobu.config.ts` (TypeScript, `defineConfig` from `@lobu/cli/config`).\n- Keep agent identity and instructions in `IDENTITY.md`, `SOUL.md`, and `USER.md`.\n- Keep reusable capability bundles in `skills/<name>/SKILL.md` or `agents/<agent>/skills/<name>/SKILL.md`.\n- Use `lobu login` for CLI authentication. Do not use a separate memory login command.\n- Use `lobu connect` for MCP client and skill setup.\n- Use `lobu memory ...` for memory operations, seeding, and direct tool calls.\n\nReference the canonical docs before guessing how a feature works:\n[Lobu concepts](https://github.com/lobu-ai/lobu/blob/main/docs/CONCEPTS.md)\n(entities vs events, identity, end-to-end lifecycle),\n[Automations](https://github.com/lobu-ai/lobu/blob/main/docs/AUTOMATIONS.md)\n(trigger/source/output contract), and\n[Connector authoring](https://github.com/lobu-ai/lobu/blob/main/docs/connector-authoring.md)\n(custom connectors).\n\n## Project Checklist\n\n1. Read `lobu.config.ts` first.\n2. Read the active agent files under `agents/<id>/`.\n3. Check local skills under `skills/` and `agents/<id>/skills/`.\n4. Use `lobu validate` after config changes.\n5. Discover the live SDK and connector surface with `search_sdk`; never guess a method, connector key, feed key, connection id, or operation key.\n6. When prompt or Automation changes, run evals via promptfoo (see `examples/personal-finance/evals/promptfooconfig.yaml`). The in-house `lobu eval` command has been removed.\n\n## Common Commands\n\n```bash\nnpx @lobu/cli@latest init my-agent\nnpx @lobu/cli@latest run\nnpx @lobu/cli@latest validate\nnpx @lobu/cli@latest login\n```\n\n## Authentication\n\n- Interactive (human at a terminal): `lobu login` runs the device-code flow with a browser approval.\n- CI / your own automation: `LOBU_API_TOKEN`, or `lobu login --token <pat>`.\n- Local `lobu run`: the CLI mints credentials automatically over loopback — no prompt.\n- Headless, on a *user's* behalf: `lobu login --email <address>`. The server emails the user a one-click approval link and the CLI polls until they approve, then stores the scoped credential — no TTY, no pre-minted token. This is the auth.md \"user_claimed\" flow.\n\nAn external agent not using this CLI can drive the same flow over HTTP: read `<origin>/auth.md` (linked from the `agent_auth` block in `<origin>/.well-known/oauth-authorization-server`) for the endpoints. Today only the email user_claimed flow exists (no zero-touch ID-JAG). Never fabricate a token.\n\n## Organization Deletion\n\nTreat organization deletion as permanent and restricted to organization owners. The supported path is the **Organization settings** page, opened from that workspace's settings button in the organization switcher. ClientSDK and Lobu CLI intentionally expose no organization-delete method. When asked to delete organizations, identify each exact target and its data impact read-only, surface one production organization at a time for explicit confirmation, then direct an owner to that page or use their logged-in browser only when explicitly authorized. Never invent a hosted URL, call the raw Better Auth route, bypass a failed authorization check, delete organization rows directly, or batch confirmations.\n\nCloud CLI OAuth/PAT credentials are not a Better Auth browser session. A `401` or `403` is a stop signal: report the authorization boundary and leave the organization intact.\n\n<!-- lobu-memory-guidance:start -->\n## Memory Defaults\n\nYour long-term memory is powered by Lobu. Do NOT use local files (memory/, MEMORY.md) for memory.\n- Lobu automatically recalls relevant memories when you receive a message.\n- To save something, call save_memory with the content and an appropriate semantic_type.\n- To search, call search_memory. Results include view_url links to the web interface.\n- NEVER construct Lobu URLs yourself. When the user asks for a link, call search_memory to get the correct view_url.\n- When the user says \"remember this\", save it to Lobu immediately.\n- When a message changes a fact you already stored (an updated preference, status, count, location, or plan), first search_memory for the prior memory to get its id, then save_memory the new value with supersedes_event_id set to that id. This replaces the stale value so future recalls return the current one; the old value stays in history but is hidden from normal search.\n<!-- lobu-memory-guidance:end -->\n\n## Lobu Memory\n\nConfigure project-scoped memory in `lobu.config.ts` by setting the org on `defineConfig` and declaring the schema with the `define*` helpers:\n\n```ts\nimport { defineConfig, defineEntityType } from \"@lobu/cli/config\";\n\nconst ticket = defineEntityType({\n key: \"ticket\",\n name: \"Ticket\",\n properties: {\n subject: {\n type: \"string\",\n \"x-table-label\": \"Subject\",\n \"x-table-column\": true,\n },\n },\n});\n\nexport default defineConfig({\n org: \"my-org\",\n orgName: \"My workspace\",\n agents: [/* ... */],\n entities: [ticket],\n});\n```\n\nSeed data records still live as YAML under `./data`. Then seed or operate the memory workspace with:\n\n```bash\nlobu login\nlobu memory org set <org-slug>\nlobu memory health --org <org-slug>\nlobu memory seed --org <org-slug>\nlobu memory run search_memory '{\"query\":\"Acme\"}' --org <org-slug>\n```\n\nUse `search_memory` first when the user asks about a specific entity or workspace memory. Use `save_memory` to persist durable memory. To update existing knowledge, search first, then save with `supersedes_event_id` so the old row is tombstoned rather than deleted.\n\n## MCP Client Setup\n\nUse the actual MCP URL for the user's runtime. Never hardcode a hosted URL unless the user explicitly asks for that instance.\n\nCommon setup commands:\n\n```bash\n# Claude Code\nlobu connect claude-code --url <mcp-url>\n\n# Codex\nlobu connect codex --url <mcp-url>\n\n# Antigravity\nlobu connect antigravity --url <mcp-url>\n\n# OpenCode\nlobu connect opencode --url <mcp-url>\n```\n\nRun `lobu connect --url <mcp-url>` without a client id to choose interactively. For ChatGPT, Claude Desktop, Cursor, and other browser-managed clients, the same command applies the safe local configuration it can and prints the exact remaining client handoff. Complete OAuth in the client, not through a separate Lobu CLI login.\n\n## Browser-Authenticated Connectors\n\nFor connectors that need a signed-in browser, pair the Owletto Chrome extension\nand sign in on the source site in that browser. Browser operations run through\nthat paired device; external remote-debugging endpoints and CLI browser-auth\ncapture are no longer supported.\n\nTo test a configured feed without writing ingested data, discover the current\nfeed methods with `search_sdk`, then use `client.feeds.trigger({ feed_id, dry_run: true })`\nthrough `run_sdk` or `lobu memory exec`. Inspect `client.feeds.get({ feed_id })`\nfor the completed run's preview. The dry run uses normal device routing and\nauthorization checks and may access the upstream provider, so obtain consent first.\n\n## Agent-Facing Tool Surface\n\nThe normal MCP surface is intentionally small. Flat administrative tools are not advertised to agents; compose through these tools instead:\n\n- `search_memory` and `save_memory` for direct knowledge recall and persistence.\n- `search_sdk` to discover current ClientSDK methods, signatures, connector feed keys, operations, access requirements, and examples. Pass `mode: \"read\"` when you only need methods safe for `query_sdk`.\n- `query_sdk` for read-only TypeScript and `query_sql` for governed, paginated SQL reads.\n- `run_sdk` for mutations and external operations. Use `lobu memory exec` from the CLI for the same ClientSDK scripting workflow.\n\nSearch before create to avoid duplicates. Prefer a read or dry run before mutations, never fabricate returned URLs or identifiers, and never delete from `events`; supersede or tombstone instead.\n\n## Connectors, Feeds, and Operations\n\nConnectors are the primary integration path for third-party services. The\nend-to-end model (entities vs events, the run lifecycle) is in\n`docs/CONCEPTS.md`; authoring a new connector when none matches is in\n`docs/connector-authoring.md`. Do not freeze a connector lifecycle in project\ninstructions because it can drift from the deployed SDK:\n\n1. Call `search_sdk` with the service name immediately before acting. It returns installed and installable connectors, declared feed keys, readiness, and the caller-aware live lifecycle. Then, before requesting app credentials, call `client.connections.setupOptions({ connector_key })` against the selected runtime: it discovers verified cloud-managed OAuth and hosted chat alongside local setup, so follow the URLs and instructions it returns. `cloud_status: \"unavailable\"` is a discovery outage, not evidence that managed auth is absent. Options are offers, not connected accounts.\n2. Always follow the methods it returns in order instead of relying on a remembered connect/feed/operation sequence. Repeat discovery after authorization or state changes so the next step reflects the live connector and current caller.\n3. Treat `access: operate` as `mcp:write` and `access: administer` as workspace owner/admin plus `mcp:admin`. If discovery asks for MCP reauthorization or an owner/admin handoff, follow that instruction; never attempt methods it withheld as unavailable.\n\nSource-backed feeds query the provider only through an explicit `client.feeds.readMany({ reads: [...] })` call; `search_memory` stays local and reports unqueried source feeds in `coverage`, while `client.feeds.get` returns metadata without source access. Feeds with `sync` may persist events for search and relational queries. For connector actions, use the live discovery result's operation target and readiness. If readiness is disconnected, follow the returned next action instead of guessing a connection. Surface approval-gated `pending_approval` as a waiting state, not a failure.\n\n## Data Ingestion\n\n- Use `lobu memory seed` for small declarative YAML datasets under `./data`; it processes records sequentially and is not a bulk-backfill path.\n- Use `client.knowledge.save` for schema-less semantic history such as messages, notes, observations, and content. Pass `supersedes_event_id` when replacing an existing fact.\n- Use `client.entities.create` / `client.entities.update` only for strict structured records that match declared entity schemas.\n- For large backfills, send bounded chunks through `run_sdk` / `lobu memory exec` and use `Promise.allSettled` so conflicts and partial failures remain visible.\n\n```ts\nexport default async (_ctx, client) => {\n const records = [\n { content: \"...\", semantic_type: \"note\" },\n { content: \"...\", semantic_type: \"observation\" },\n ];\n return Promise.allSettled(records.map((record) => client.knowledge.save(record)));\n};\n```",
11
+ "instructions": "# Lobu\n\nUse this skill when setting up a brand-new Lobu agent from scratch (follow \"Onboarding a New Project\" below) or when running, validating, evaluating, or connecting an existing Lobu project, or operating Lobu memory from a coding agent.\n\nThe `AGENTS.md` generated into a new project is the source of truth for the config API (the `define*` helpers, connectors, auth, Automations, memory) — this skill does not duplicate it. For an existing project, jump to \"Core Model\" + the relevant reference section below.\n\n## Onboarding a New Project\n\nUse this playbook when a new user asks you to build them a Lobu agent from scratch. Set it up end to end: ground yourself in what the user already has, interview, discover, scaffold, prove the complete local path, then offer the deployment choice. Do not call the setup complete until every path the user selected has actually passed end to end. If an external provider, authorization, deployment, or rate limit blocks the proof, name the exact blocker and leave the setup as blocked rather than claiming success.\n\n### 1. Ground yourself in what the user already has\n\nBefore interviewing, look at what already exists so your questions and suggestions are personal rather than a blank slate. This is discovery, not a design decision — do not let it skip the interview.\n\n- Local: run `lobu context list` to see existing contexts; check the current directory and home for existing Lobu projects (`lobu.config.ts`), configured MCP servers, and CLI auth state. Note what the user already set up.\n- Cloud: if the user has an active session (do not create one just to look), call `client.organizations.list()`, `client.agents.list()` for each org, `client.catalog.listInstalled({ kinds: [\"connectors\"] })`, and `search_memory` for prior knowledge. This reveals existing agents, connectors, and memory you can build on.\n- Tell the user what you are looking at so they can correct you, and let what you find shape the options you offer. Never treat this discovery as an identity signal: orgs, emails, or domains never prove a company or product, and never mention a competitor or third party unless it actually appears in what you found.\n\nDo NOT ask for a login email during the interview. Email is only needed when a managed connector actually requires a session (step 3) or when the user chooses cloud deployment (step 6); ask for it at that point. Treat identity only as identity; never infer a company from an email address or domain.\n\n### 2. Interview with concrete, personalized options\n\nInterview the user one question at a time; wait for each answer, do not guess, and do not batch the questions. Anchor each question in what you found in step 1. Instead of asking \"what agent do you want?\" as a blank slate, summarize what you see and offer two or three concrete alternatives to choose from:\n\n- \"You already have org X with connectors A and B installed and N existing agents. Do you want to (a) add a new agent on top of those, (b) extend one of the existing agents, or (c) start something standalone?\"\n- \"For what it should do, the common shapes are (a) a triage agent that reads incoming chat and files a ticket, (b) a scheduled report that summarizes new activity each morning, (c) a research agent that answers questions from your connected tools. Which fits, or what would you change?\"\n\nOffer a default so the user can answer \"the first one\" — decisive users and undecided users both move faster with a concrete menu.\n\n- What company or product is this for?\n- What does it do, and who does it serve?\n- What is its public domain? (optional for a personal project)\n- Do I have permission to research the public website and other public sources?\n- What is the agent for?\n- What should we call it?\n- Who uses it: just me, my team, or each of my customers?\n- How should it behave, and what may it do unattended versus only with approval?\n- What should it remember? Model this as one to three entity types.\n- Where does its data come from? Pick one connector or custom source to start.\n- Where should people talk to it? Offer Web UI, API or SDK, MCP, Slack, Teams, WhatsApp, Discord, Google Chat, and Telegram without forcing a chat platform. If Slack is chosen, ask whether to join Lobu's hosted workspace for a quick start, install Lobu into an existing workspace, or use a custom Slack app; then ask whether to test the DM with Lobu, a named channel, or both, and whether people knowledge means conversation participants, bound-channel members, or the full workspace directory.\n- Should anything run on a schedule?\n- Which supported LLM provider credential does the user have?\n\nIf the user gave permission to research and has a public domain, research the company before proposing the design. Summarize its product, customers, workflows, and useful signals, and cite the public sources you used. Then propose one to three entity types, their relationships, the first data source, one or two useful Automations, and suitable interaction channels. Play back a short numbered plan and wait for confirmation before scaffolding anything.\n\n### 3. Discover the surface before choosing how to scaffold\n\nCheck Node is 22-24 or 26+ (only Node 25 is unsupported), then run `lobu context list` and identify the named Lobu Cloud context; do not assume the active context still points to cloud after a local run. If a managed or cloud connector was chosen and there is no session, ask for the login email at that point, explain that Lobu will email an approval link, and run `lobu login --email <confirmed-address> --context <cloud-name>`. The person approving must sign in with that same email; knowing an address never grants access. After a successful login, an empty organization membership list is a tenancy/discovery result, not an authentication failure: call `client.organizations.list()` and explain the result. Never revoke or repeat login with `--force` unless the user separately approves that re-authentication.\n\nUse ClientSDK through Lobu MCP or `lobu memory exec` with the explicit cloud context. Call `client.organizations.list()` to find public organizations offering managed connections. Call `client.catalog.listInstalled({ kinds: [\"connectors\"] })`; if the connector is not installed, call `client.catalog.listCatalog({ kinds: [\"connectors\"] })`. Inspect the selected entry's `detail.auth_schema`, `detail.options_schema`, `detail.feeds_schema`, and `detail.automation_events` instead of guessing field names. On account-scoped `/mcp`, select an authorized home workspace first with `const home = await client.org(homeSlug)` and call `home.connections.connectManaged`; put the public provider org in `managed_by_org`, rather than selecting that provider org with `client.org`. This call runs against cloud, not the embedded runtime. If a matching live managed offer exists, explain it and call `client.connections.connectManaged` only after consent. Complete the returned user authorization, then run `lobu context use <cloud-name>` immediately before executing its `local_bootstrap_command` from the parent directory where the new project should be created; use `--here` only after entering an empty directory, and do not create a blank Lobu scaffold first. Ask for bring-your-own OAuth credentials only if no managed offer exists or the user prefers their own app.\n\n**If no connector in the catalog matches the data source, do not report \"no integration exists\"** — author a custom connector: write `connectors/<name>.connector.ts` in the project, register it with `connectorFromFile(\"./connectors/<name>.connector.ts\")`, and model it on the [npm downloads example](https://github.com/lobu-ai/lobu/blob/main/examples/lobu-crm/npm-downloads.connector.ts). See [Connector authoring](https://github.com/lobu-ai/lobu/blob/main/docs/connector-authoring.md) for the full contract; the end-to-end entity/event/Automation model is in [Lobu concepts](https://github.com/lobu-ai/lobu/blob/main/docs/CONCEPTS.md).\n\n### 4. Scaffold and build from the confirmed plan\n\nIf managed auth supplied a `local_bootstrap_command`, use the project it generated. Otherwise run `npx @lobu/cli@latest init` with the confirmed name and provider. Postgres is built in, so `lobu run` starts an embedded database; ask for `DATABASE_URL` only if the user chooses external Postgres. Read the generated `AGENTS.md` completely before editing `lobu.config.ts`. Use the canonical reference at `https://github.com/lobu-ai/lobu/blob/main/examples/lobu-crm/lobu.config.ts` when needed; do not assume that example exists in the new project's filesystem. Briefly explain how the chosen feed may use checkpoints to collect incrementally, emits events, builds shared entity memory, and gives both chat and Automations the same governed context.\n\n`feeds_schema.<feed>.eventKinds` are the default Automation trigger catalog for feed connectors: every declared kind is a subscribable event type (`event_type` = the kind slug) for any feed that emits the kind. A feed's first successful non-dry sync establishes its baseline without activation; later inserts of a matching kind activate subscribers. A kind with `updatedEvent: true` also offers `<kind>.updated` for supersedes whose `occurred_at` strictly advances past the previous head. The original kind stays insert-only; unchanged rows, volatile-only updates and same-time reformats stay quiet. Subscribe to both types for new items and later activity. Feed-scoped filtering is not yet available (events dedupe by connection + origin id, so a `feed_key` match would miss origins first seen by another feed). `automation_events` (now derived from eventKinds when a connector declares none) is the trigger picker's list. If no declared kind matches the use case, use a scheduled Automation with a bounded named SQL source and read event text from `payload_text`. Validate the query against the running local schema before relying on it. If `feeds_schema` is empty, do not invent or trigger a feed; chat integrations such as Slack can deliver incoming messages directly. For Slack or Telegram, prefer `defineConnection` with `credentialMode: \"hosted\"` so no bot token is required; `lobu run` prints the exact hosted-workspace join URL, own-workspace install URL when available, and short-lived link command. This hosted chat path requires a cloud session and the agent applied to that cloud workspace; the link targets the cloud agent. It does not create a local Slack data connection or prove local Slack search. Use those returned values instead of constructing URLs. A printed `/lobu link <code>` is one-time: redeem it in the first selected DM or channel. In an installed workspace whose installer is linked to Lobu, bind each additional surface with `/lobu link <agent-id>`; otherwise generate a fresh code for that surface. Mention Lobu in a channel test and verify the App Home separately. Lobu email login and Slack installation are separate: the email link authorizes Lobu CLI access, while an existing-workspace install requires the user or workspace admin to approve Slack's OAuth screen. Never describe Slack consent as an email approval. Use `credentialMode: \"byo\"` only if the user chooses their own app. Tell the user once which remaining secrets are required and add only `secret(\"ENV_NAME\")` placeholders to config. Never open or request permission to read `.env`; inspect `.env.example` when present and declared secret placeholder names only. Never read, print, invent, or paste a real secret into source or chat.\n\nIf the user wants the agent to know people in Slack, ask whether that means conversation participants, members of bound channels, or the full workspace directory. Installing the app proves none of those by itself. Verify the selected scope by inspecting the people or member entities Lobu actually materialized and by asking the agent a roster question. If human-readable names or non-participants are unavailable, identify that exact product gap; never claim the complete workspace directory was synced.\n\n### 5. Prove the complete local path\n\nChange into the generated project directory and verify `pwd` contains the intended `lobu.config.ts`; never run project commands from its parent. Run `npx @lobu/cli@latest validate`, boot with `npx @lobu/cli@latest run`, and verify health and the local Web UI. With the embedded database default, `lobu run` creates and selects the local context and auto-applies the project; with an external `DATABASE_URL`, it does neither, so authenticate and apply to that runtime explicitly. Send a harmless direct chat message without tools.\n\nBefore consent to access provider data, inspect only catalog, connection, auth-profile, and feed metadata. For browser access, inspect the paired device and connection metadata without invoking browser actions. Durable managed OAuth and env-profile credentials stay at the gateway. Do not run a feed or connector dry-run before consent, because a dry-run may still read provider data. Ask explicitly before accessing real provider data. Only after approval, dry-run the connector or feed server-side and trigger the selected feed manually if that connector actually declares one. A feed dry-run records its run but persists no collected events, entities, attachments, checkpoint changes, or feed sync state. Run each Automation once, poll `client.operations.getRun` with its returned `run_id`, and show each completed run plus any declared result event or entity. For a run-result-only or reaction-only Automation, use the completed run and the Automation `view_url` returned by Lobu. For Slack, treat DM, channel mention, App Home, and requested member discovery as four separate checks. Keep actions in approval mode unless the user explicitly approves execution. If any step fails, fix it and rerun that step; do not silently substitute a different path.\n\n### 6. Offer the deployment choice\n\nAfter the local proof, ask the user whether to keep running locally or deploy to Lobu Cloud. Explain that the embedded local runtime and Lobu Cloud are separate targets, and that keeping it local needs no further setup. Only if the user chooses cloud deployment, ask for the login email to identify the deployer, explain that Lobu will email an approval link, and run `lobu login --email <confirmed-address> --context <cloud-name>`; the person approving must sign in with that same email. Because `lobu apply` has no context flag, use `lobu context list` and then `lobu context use <cloud-name>` to select an explicit cloud context before deployment. Run `lobu apply --dry-run` first, show the target organization and exact plan, and wait for confirmation before applying. After apply, use only authoritative `view_url` values and link commands returned by Lobu; never construct URLs. Present the working access choices: Web UI, direct agent chat, API or SDK, MCP, and any channels the user selected.\n\n## Core Model\n\n- **Lobu** is the agent framework, runtime, deployment layer, and memory surface.\n- Keep framework configuration in `lobu.config.ts` (TypeScript, `defineConfig` from `@lobu/cli/config`).\n- Keep agent identity and instructions in `IDENTITY.md`, `SOUL.md`, and `USER.md`.\n- Keep reusable capability bundles in `skills/<name>/SKILL.md` or `agents/<agent>/skills/<name>/SKILL.md`.\n- Use `lobu login` for CLI authentication. Do not use a separate memory login command.\n- Use `lobu connect` for MCP client and skill setup.\n- Use `lobu memory ...` for memory operations, seeding, and direct tool calls.\n\nReference the canonical docs before guessing how a feature works:\n[Lobu concepts](https://github.com/lobu-ai/lobu/blob/main/docs/CONCEPTS.md)\n(entities vs events, identity, end-to-end lifecycle),\n[Automations](https://github.com/lobu-ai/lobu/blob/main/docs/AUTOMATIONS.md)\n(trigger/source/output contract), and\n[Connector authoring](https://github.com/lobu-ai/lobu/blob/main/docs/connector-authoring.md)\n(custom connectors).\n\n## Project Checklist\n\n1. Read `lobu.config.ts` first.\n2. Read the active agent files under `agents/<id>/`.\n3. Check local skills under `skills/` and `agents/<id>/skills/`.\n4. Use `lobu validate` after config changes.\n5. Discover the live SDK and connector surface with `search_sdk`; never guess a method, connector key, feed key, connection id, or operation key.\n6. When prompt or Automation changes, run evals via promptfoo (see `examples/personal-finance/evals/promptfooconfig.yaml`). The in-house `lobu eval` command has been removed.\n\n## Common Commands\n\n```bash\nnpx @lobu/cli@latest init my-agent\nnpx @lobu/cli@latest run\nnpx @lobu/cli@latest validate\nnpx @lobu/cli@latest login\n```\n\n## Authentication\n\n- Interactive (human at a terminal): `lobu login` runs the device-code flow with a browser approval.\n- CI / your own automation: `LOBU_API_TOKEN`, or `lobu login --token <pat>`.\n- Local `lobu run`: the CLI mints credentials automatically over loopback — no prompt.\n- Headless, on a *user's* behalf: `lobu login --email <address>`. The server emails the user a one-click approval link and the CLI polls until they approve, then stores the scoped credential — no TTY, no pre-minted token. This is the auth.md \"user_claimed\" flow.\n\nAn external agent not using this CLI can drive the same flow over HTTP: read `<origin>/auth.md` (linked from the `agent_auth` block in `<origin>/.well-known/oauth-authorization-server`) for the endpoints. Today only the email user_claimed flow exists (no zero-touch ID-JAG). Never fabricate a token.\n\n## Organization Deletion\n\nTreat organization deletion as permanent and restricted to organization owners. The supported path is the **Organization settings** page, opened from that workspace's settings button in the organization switcher. ClientSDK and Lobu CLI intentionally expose no organization-delete method. When asked to delete organizations, identify each exact target and its data impact read-only, surface one production organization at a time for explicit confirmation, then direct an owner to that page or use their logged-in browser only when explicitly authorized. Never invent a hosted URL, call the raw Better Auth route, bypass a failed authorization check, delete organization rows directly, or batch confirmations.\n\nCloud CLI OAuth/PAT credentials are not a Better Auth browser session. A `401` or `403` is a stop signal: report the authorization boundary and leave the organization intact.\n\n<!-- lobu-memory-guidance:start -->\n## Memory Defaults\n\nYour long-term memory is powered by Lobu. Do NOT use local files (memory/, MEMORY.md) for memory.\n- Lobu automatically recalls relevant memories when you receive a message.\n- To save something, call save_memory with the content and an appropriate semantic_type.\n- To search, call search_memory. Results include view_url links to the web interface.\n- NEVER construct Lobu URLs yourself. When the user asks for a link, call search_memory to get the correct view_url.\n- When the user says \"remember this\", save it to Lobu immediately.\n- When a message changes a fact you already stored (an updated preference, status, count, location, or plan), first search_memory for the prior memory to get its id, then save_memory the new value with supersedes_event_id set to that id. This replaces the stale value so future recalls return the current one; the old value stays in history but is hidden from normal search.\n<!-- lobu-memory-guidance:end -->\n\n## Lobu Memory\n\nConfigure project-scoped memory in `lobu.config.ts` by setting the org on `defineConfig` and declaring the schema with the `define*` helpers:\n\n```ts\nimport { defineConfig, defineEntityType } from \"@lobu/cli/config\";\n\nconst ticket = defineEntityType({\n key: \"ticket\",\n name: \"Ticket\",\n properties: {\n subject: {\n type: \"string\",\n \"x-table-label\": \"Subject\",\n \"x-table-column\": true,\n },\n },\n});\n\nexport default defineConfig({\n org: \"my-org\",\n orgName: \"My workspace\",\n agents: [/* ... */],\n entities: [ticket],\n});\n```\n\nSeed data records still live as YAML under `./data`. Then seed or operate the memory workspace with:\n\n```bash\nlobu login\nlobu memory org set <org-slug>\nlobu memory health --org <org-slug>\nlobu memory seed --org <org-slug>\nlobu memory run search_memory '{\"query\":\"Acme\"}' --org <org-slug>\n```\n\nUse `search_memory` first when the user asks about a specific entity or workspace memory. Use `save_memory` to persist durable memory. To update existing knowledge, search first, then save with `supersedes_event_id` so the old row is tombstoned rather than deleted.\n\n## MCP Client Setup\n\nUse the actual MCP URL for the user's runtime. Never hardcode a hosted URL unless the user explicitly asks for that instance.\n\nCommon setup commands:\n\n```bash\n# Claude Code\nlobu connect claude-code --url <mcp-url>\n\n# Codex\nlobu connect codex --url <mcp-url>\n\n# Antigravity\nlobu connect antigravity --url <mcp-url>\n\n# OpenCode\nlobu connect opencode --url <mcp-url>\n```\n\nRun `lobu connect --url <mcp-url>` without a client id to choose interactively. For ChatGPT, Claude Desktop, Cursor, and other browser-managed clients, the same command applies the safe local configuration it can and prints the exact remaining client handoff. Complete OAuth in the client, not through a separate Lobu CLI login.\n\n## Browser-Authenticated Connectors\n\nFor connectors that need a signed-in browser, pair the Owletto Chrome extension\nand sign in on the source site in that browser. Browser operations run through\nthat paired device; external remote-debugging endpoints and CLI browser-auth\ncapture are no longer supported.\n\nTo test a configured feed without writing ingested data, discover the current\nfeed methods with `search_sdk`, then use `client.feeds.trigger({ feed_id, dry_run: true })`\nthrough `run_sdk` or `lobu memory exec`. Inspect `client.feeds.get({ feed_id })`\nfor the completed run's preview. The dry run uses normal device routing and\nauthorization checks and may access the upstream provider, so obtain consent first.\n\n## Agent-Facing Tool Surface\n\nThe normal MCP surface is intentionally small. Flat administrative tools are not advertised to agents; compose through these tools instead:\n\n- `search_memory` and `save_memory` for direct knowledge recall and persistence.\n- `search_sdk` to discover current ClientSDK methods, signatures, connector feed keys, operations, access requirements, and examples. Pass `mode: \"read\"` when you only need methods safe for `query_sdk`.\n- `query_sdk` for read-only TypeScript and `query_sql` for governed, paginated SQL reads.\n- `run_sdk` for mutations and external operations. Use `lobu memory exec` from the CLI for the same ClientSDK scripting workflow.\n\nSearch before create to avoid duplicates. Prefer a read or dry run before mutations, never fabricate returned URLs or identifiers, and never delete from `events`; supersede or tombstone instead.\n\n## Connectors, Feeds, and Operations\n\nConnectors are the primary integration path for third-party services. The\nend-to-end model (entities vs events, the run lifecycle) is in\n`docs/CONCEPTS.md`; authoring a new connector when none matches is in\n`docs/connector-authoring.md`. Do not freeze a connector lifecycle in project\ninstructions because it can drift from the deployed SDK:\n\n1. Call `search_sdk` with the service name immediately before acting. It returns installed and installable connectors, declared feed keys, readiness, and the caller-aware live lifecycle. Then, before requesting app credentials, call `client.connections.setupOptions({ connector_key })` against the selected runtime: it discovers verified cloud-managed OAuth and hosted chat alongside local setup, so follow the URLs and instructions it returns. `cloud_status: \"unavailable\"` is a discovery outage, not evidence that managed auth is absent. Options are offers, not connected accounts.\n2. Always follow the methods it returns in order instead of relying on a remembered connect/feed/operation sequence. Repeat discovery after authorization or state changes so the next step reflects the live connector and current caller.\n3. Treat `access: operate` as `mcp:write` and `access: administer` as workspace owner/admin plus `mcp:admin`. If discovery asks for MCP reauthorization or an owner/admin handoff, follow that instruction; never attempt methods it withheld as unavailable.\n\nSource-backed feeds query the provider only through an explicit `client.feeds.readMany({ reads: [...] })` call; `search_memory` stays local and reports unqueried source feeds in `coverage`, while `client.feeds.get` returns metadata without source access. Feeds with `sync` may persist events for search and relational queries. For connector actions, use the live discovery result's operation target and readiness. If readiness is disconnected, follow the returned next action instead of guessing a connection. Surface approval-gated `pending_approval` as a waiting state, not a failure.\n\n## Data Ingestion\n\n- Use `lobu memory seed` for small declarative YAML datasets under `./data`; it processes records sequentially and is not a bulk-backfill path.\n- Use `client.knowledge.save` for schema-less semantic history such as messages, notes, observations, and content. Pass `supersedes_event_id` when replacing an existing fact.\n- Use `client.entities.create` / `client.entities.update` only for strict structured records that match declared entity schemas.\n- For large backfills, send bounded chunks through `run_sdk` / `lobu memory exec` and use `Promise.allSettled` so conflicts and partial failures remain visible.\n\n```ts\nexport default async (_ctx, client) => {\n const records = [\n { content: \"...\", semantic_type: \"note\" },\n { content: \"...\", semantic_type: \"observation\" },\n ];\n return Promise.allSettled(records.map((record) => client.knowledge.save(record)));\n};\n```",
12
12
  "hidden": false
13
13
  }
14
14
  },
@@ -4,6 +4,6 @@
4
4
  "server": "dist/server.bundle.mjs",
5
5
  "embeddingsServer": "dist/embeddings-server.mjs"
6
6
  },
7
- "version": "22.0.0",
7
+ "version": "23.0.0",
8
8
  "verify": "dist/verify.mjs"
9
9
  }
@@ -252,7 +252,19 @@ feeds: {
252
252
  }
253
253
  ```
254
254
 
255
- A feed's `eventKinds` are also the **default Automation trigger catalog**. The first successful non-dry sync establishes a baseline without activation; later inserts whose kind matches a declared `eventKinds` key activate subscribers. A non-empty `automationEvents` declaration (camelCase in `ConnectorDefinition`, persisted as `automation_events` in the catalog) replaces that derived catalog in the trigger picker. Keys that differ from the feed's `eventKinds` fire only when the emitted `EventEnvelope` carries matching `automation_signals`.
255
+ A feed's `eventKinds` are also the **default Automation trigger catalog**. The first successful non-dry sync establishes a baseline without activation; later inserts whose kind matches a declared `eventKinds` key activate subscribers. A non-empty `automationEvents` declaration (camelCase in `ConnectorDefinition`, persisted as `automation_events` in the catalog) replaces that derived catalog in the trigger picker. Keys outside the feed kinds and their opted-in updated types fire only when the emitted `EventEnvelope` carries matching `automation_signals`.
256
+
257
+ Set `eventKinds.<kind>.updatedEvent: true` to also expose a distinct `<kind>.updated`
258
+ trigger (for example, Gmail's `thread.updated`). After the baseline, it fires when
259
+ ingestion supersedes the source item with changed durable content and strictly
260
+ newer `occurred_at` than the previous head. Use source activity time, not a scheduled
261
+ start time. Unchanged rows, volatile-only counter updates and same-time reformats
262
+ stay quiet. The original `<kind>` trigger remains insert-only; subscribe to both
263
+ types for new items and later activity. Literal kinds declared by any feed of the
264
+ connector win slug collisions, and composite keys over 100 characters are omitted.
265
+ The optional boolean persists unchanged in `connector_definitions.feeds_schema`;
266
+ existing definitions without it retain their semantics. Explicit `automationEvents`
267
+ still replace the derived picker catalog, so include the updated key there if used.
256
268
 
257
269
  ## Syncing Data
258
270
 
@@ -544,6 +556,7 @@ For source-backed bundled connectors, the worker recompiles a `.ts` file after i
544
556
  |-----------|------|-------|---------|
545
557
  | `github` | app_installation/oauth/env_keys | issues, PRs, comments, discussions, commits, stargazers | create/comment/close/reopen issues; create/merge PRs |
546
558
  | `hackernews` | none | stories, front page, comments | - |
559
+ | `linkedin` | browser/none | notifications, inbox messages, home feed, company updates, jobs; Data Export requires an injected CSV reader | send direct-message replies; like; prepare message/post/comment drafts |
547
560
  | `market.quotes` | none | - | quote (read-only, quotes returned to the caller, never persisted) |
548
561
  | `producthunt` | env_keys | posts & comments | - |
549
562
  | `reddit` | oauth/none | posts, comments, user activity | - |
@@ -246,6 +246,7 @@ export default class GmailConnector extends ConnectorRuntime<GmailCheckpoint, Gm
246
246
  eventKinds: {
247
247
  thread: {
248
248
  description: 'A Gmail email thread',
249
+ updatedEvent: true,
249
250
  metadataSchema: {
250
251
  type: 'object',
251
252
  properties: {
@@ -0,0 +1,313 @@
1
+ /**
2
+ * Shared Jira helpers, connector-owned.
3
+ *
4
+ * The bundled Jira connector (`jira.ts`) and the server's Atlassian Rovo MCP
5
+ * feed adapter (`packages/server/src/operations/atlassian-mcp-feed.ts`) read
6
+ * the same source (Jira Cloud issues via JQL) and must agree on the JQL
7
+ * builder, the stable row shape, and ADF-to-text conversion. This module owns
8
+ * that shared knowledge; transport (REST vs MCP tool call) stays with each
9
+ * consumer. Server imports it as `@lobu/connectors/jira-helpers`.
10
+ */
11
+
12
+ /** Stable column set returned by Jira direct source reads. */
13
+ export const JIRA_ISSUE_COLUMNS = [
14
+ { name: 'id', type: 'string' },
15
+ { name: 'key', type: 'string' },
16
+ { name: 'summary', type: 'string' },
17
+ { name: 'status', type: 'string' },
18
+ { name: 'assignee', type: 'string' },
19
+ { name: 'reporter', type: 'string' },
20
+ { name: 'priority', type: 'string' },
21
+ { name: 'project_key', type: 'string' },
22
+ { name: 'project_name', type: 'string' },
23
+ { name: 'labels', type: 'string' },
24
+ { name: 'created_at', type: 'string' },
25
+ { name: 'updated_at', type: 'string' },
26
+ { name: 'description', type: 'string' },
27
+ { name: 'url', type: 'string' },
28
+ ] as const;
29
+
30
+ /** Issue fields requested from `/rest/api/3/search/jql`. */
31
+ export const JIRA_ISSUE_FIELDS =
32
+ 'summary,description,status,assignee,reporter,priority,project,labels,created,updated';
33
+
34
+ /** Sort columns the live path can honor by rewriting ORDER BY. */
35
+ export const JIRA_SORT_COLUMNS: Record<string, string> = {
36
+ updated: 'updated',
37
+ updated_at: 'updated',
38
+ created: 'created',
39
+ created_at: 'created',
40
+ key: 'key',
41
+ priority: 'priority',
42
+ status: 'status',
43
+ };
44
+
45
+ const ADF_BLOCK_TYPES = new Set([
46
+ 'blockquote',
47
+ 'bulletList',
48
+ 'codeBlock',
49
+ 'heading',
50
+ 'listItem',
51
+ 'orderedList',
52
+ 'paragraph',
53
+ 'rule',
54
+ 'table',
55
+ 'tableCell',
56
+ 'tableHeader',
57
+ 'tableRow',
58
+ ]);
59
+
60
+ export function jiraAsString(value: unknown): string | undefined {
61
+ return typeof value === 'string' && value.trim().length > 0
62
+ ? value.trim()
63
+ : undefined;
64
+ }
65
+
66
+ export function jiraActorName(user: unknown): string | undefined {
67
+ if (!user || typeof user !== 'object') {
68
+ return typeof user === 'string' && user.trim() ? user.trim() : undefined;
69
+ }
70
+ const record = user as Record<string, unknown>;
71
+ return (
72
+ jiraAsString(record.displayName) ??
73
+ jiraAsString(record.emailAddress) ??
74
+ jiraAsString(record.name)
75
+ );
76
+ }
77
+
78
+ export function jiraNamedField(value: unknown): string | undefined {
79
+ if (typeof value === 'string') return jiraAsString(value);
80
+ if (!value || typeof value !== 'object') return undefined;
81
+ return jiraAsString((value as Record<string, unknown>).name);
82
+ }
83
+
84
+ /**
85
+ * Jira v3 descriptions/comment bodies use the Atlassian Document Format (ADF) —
86
+ * a nested JSON node tree. Flatten its text nodes to plain text. Strings (older
87
+ * payloads) pass through unchanged.
88
+ *
89
+ * Block nodes join with `"\n"` so paragraphs do not glue together; inline
90
+ * nodes (and `hardBreak`, which already contributes its own newline) join
91
+ * cleanly.
92
+ */
93
+ export function adfToText(value: unknown): string {
94
+ if (typeof value === 'string') return value;
95
+ if (!value || typeof value !== 'object') return '';
96
+ const node = value as { type?: string; text?: string; content?: unknown[] };
97
+ // Soft line break inside a paragraph (not a block boundary).
98
+ if (node.type === 'hardBreak') return '\n';
99
+ if (typeof node.text === 'string') return node.text;
100
+ if (Array.isArray(node.content)) {
101
+ let out = '';
102
+ for (const child of node.content) {
103
+ const text = adfToText(child);
104
+ if (!text) continue;
105
+ const childType =
106
+ child && typeof child === 'object'
107
+ ? (child as { type?: string }).type
108
+ : undefined;
109
+ // hardBreak already contributes '\n' as its text; don't insert a second.
110
+ if (out && childType && ADF_BLOCK_TYPES.has(childType)) out += '\n';
111
+ out += text;
112
+ }
113
+ return out.trim();
114
+ }
115
+ return '';
116
+ }
117
+
118
+ /**
119
+ * Peel a trailing `ORDER BY …` so caller JQL can be AND-composed without
120
+ * wrapping the sort clause.
121
+ */
122
+ export function splitTrailingOrderBy(jql: string): {
123
+ body: string;
124
+ orderBy: string | null;
125
+ } {
126
+ let quote: '"' | "'" | null = null;
127
+ let escaped = false;
128
+ let depth = 0;
129
+ for (let i = 0; i < jql.length; i += 1) {
130
+ const char = jql[i];
131
+ if (quote) {
132
+ if (escaped) {
133
+ escaped = false;
134
+ } else if (char === '\\') {
135
+ escaped = true;
136
+ } else if (char === quote) {
137
+ quote = null;
138
+ }
139
+ continue;
140
+ }
141
+ if (char === '"' || char === "'") {
142
+ quote = char;
143
+ continue;
144
+ }
145
+ if (char === '(') {
146
+ depth += 1;
147
+ continue;
148
+ }
149
+ if (char === ')') {
150
+ depth = Math.max(0, depth - 1);
151
+ continue;
152
+ }
153
+ if (
154
+ depth === 0 &&
155
+ (i === 0 || /\s/.test(jql[i - 1])) &&
156
+ /^order\s+by\b/i.test(jql.slice(i))
157
+ ) {
158
+ return { body: jql.slice(0, i).trim(), orderBy: jql.slice(i).trim() };
159
+ }
160
+ }
161
+ return { body: jql.trim(), orderBy: null };
162
+ }
163
+
164
+ export function buildJiraJql(args: {
165
+ baseQuery: string;
166
+ query?: string;
167
+ sort?: { column: string; order: 'asc' | 'desc' };
168
+ defaultWhenEmpty?: string;
169
+ window?: { start: string; end: string };
170
+ }): string {
171
+ const trimmed = args.baseQuery.trim();
172
+ // Keep an omitted scope bounded instead of scanning the whole site.
173
+ const jql =
174
+ trimmed.length > 0
175
+ ? trimmed
176
+ : (args.defaultWhenEmpty ?? 'updated >= -90d');
177
+
178
+ // If the base is only ORDER BY, treat the restriction as empty and keep sort.
179
+ let { body, orderBy } = splitTrailingOrderBy(jql);
180
+ if (!body && orderBy) {
181
+ body = args.window
182
+ ? (args.defaultWhenEmpty ?? '')
183
+ : (args.defaultWhenEmpty ?? 'updated >= -90d');
184
+ }
185
+
186
+ const callerQuery = args.query?.trim() ?? '';
187
+ if (callerQuery) {
188
+ const caller = splitTrailingOrderBy(callerQuery);
189
+ if (caller.body) {
190
+ body = body.length > 0 ? `(${body}) AND (${caller.body})` : caller.body;
191
+ }
192
+ if (caller.orderBy) {
193
+ throw new Error(
194
+ 'Jira source read query cannot contain ORDER BY; use the separate sort field',
195
+ );
196
+ }
197
+ }
198
+
199
+ if (args.window) {
200
+ const bounds = `updated >= ${Date.parse(args.window.start)} AND updated < ${Date.parse(args.window.end)}`;
201
+ body = body ? `(${body}) AND (${bounds})` : bounds;
202
+ }
203
+
204
+ if (orderBy) {
205
+ if (args.sort) {
206
+ throw new Error(
207
+ 'Jira source read: cannot apply sort when the base JQL already contains ORDER BY',
208
+ );
209
+ }
210
+ return body.length > 0 ? `${body} ${orderBy}` : orderBy;
211
+ }
212
+
213
+ if (args.sort) {
214
+ const field = JIRA_SORT_COLUMNS[args.sort.column];
215
+ if (!field) {
216
+ throw new Error(
217
+ `Jira source read sort column '${args.sort.column}' is unsupported; ` +
218
+ `use one of: ${Object.keys(JIRA_SORT_COLUMNS).join(', ')}`,
219
+ );
220
+ }
221
+ const dir = args.sort.order === 'asc' ? 'ASC' : 'DESC';
222
+ return body.length > 0
223
+ ? `${body} ORDER BY ${field} ${dir}`
224
+ : `ORDER BY ${field} ${dir}`;
225
+ }
226
+
227
+ return body.length > 0
228
+ ? `${body} ORDER BY updated DESC`
229
+ : `${args.defaultWhenEmpty || 'updated >= -90d'} ORDER BY updated DESC`;
230
+ }
231
+
232
+ function jiraIssueUrl(
233
+ issue: Record<string, unknown>,
234
+ fields: Record<string, unknown>,
235
+ config: Record<string, unknown>,
236
+ ): string | undefined {
237
+ const key = jiraAsString(issue.key);
238
+ const siteUrl = jiraAsString(config.site_url);
239
+ const cloudId = jiraAsString(config.cloud_id);
240
+ const siteCloudId = jiraAsString(config.site_cloud_id);
241
+ // Only rewrite to /browse when site_url was discovered for THIS cloud_id.
242
+ // A feed-level cloud_id override must not inherit another site's host.
243
+ if (siteUrl && key && cloudId && siteCloudId && cloudId === siteCloudId) {
244
+ return `${siteUrl.replace(/\/+$/, '')}/browse/${encodeURIComponent(key)}`;
245
+ }
246
+ return (
247
+ jiraAsString(issue.self) ??
248
+ jiraAsString(fields.url) ??
249
+ jiraAsString(issue.url)
250
+ );
251
+ }
252
+
253
+ /**
254
+ * Map one Jira issue (REST-shaped `{ id, key, fields }` or flattened MCP
255
+ * payload) onto the stable issue row. Returns null when the payload carries
256
+ * no usable issue identity.
257
+ */
258
+ export function mapJiraIssueToRow(
259
+ raw: unknown,
260
+ config: Record<string, unknown> = {},
261
+ ): Record<string, unknown> | null {
262
+ if (!raw || typeof raw !== 'object') return null;
263
+ const issue = raw as Record<string, unknown>;
264
+ const fields =
265
+ issue.fields && typeof issue.fields === 'object'
266
+ ? (issue.fields as Record<string, unknown>)
267
+ : issue;
268
+ const id =
269
+ jiraAsString(issue.id) ??
270
+ jiraAsString(issue.key) ??
271
+ jiraAsString(fields.id);
272
+ if (!id) return null;
273
+ const labelsRaw = fields.labels ?? issue.labels;
274
+ const labels = Array.isArray(labelsRaw)
275
+ ? labelsRaw
276
+ .filter((label): label is string => typeof label === 'string')
277
+ .join(', ') || null
278
+ : (jiraAsString(labelsRaw) ?? null);
279
+ const project =
280
+ fields.project && typeof fields.project === 'object'
281
+ ? (fields.project as Record<string, unknown>)
282
+ : undefined;
283
+ return {
284
+ id,
285
+ key: jiraAsString(issue.key) ?? jiraAsString(fields.key) ?? null,
286
+ summary:
287
+ jiraAsString(fields.summary) ?? jiraAsString(issue.summary) ?? null,
288
+ status:
289
+ jiraNamedField(fields.status) ?? jiraNamedField(issue.status) ?? null,
290
+ assignee:
291
+ jiraActorName(fields.assignee ?? issue.assignee) ?? null,
292
+ reporter:
293
+ jiraActorName(fields.reporter ?? issue.reporter) ?? null,
294
+ priority:
295
+ jiraNamedField(fields.priority) ?? jiraNamedField(issue.priority) ?? null,
296
+ project_key:
297
+ jiraAsString(project?.key) ??
298
+ jiraAsString(fields.projectKey) ??
299
+ jiraAsString(issue.project_key) ??
300
+ null,
301
+ project_name:
302
+ jiraAsString(project?.name) ??
303
+ jiraAsString(fields.projectName) ??
304
+ null,
305
+ labels,
306
+ created_at:
307
+ jiraAsString(fields.created) ?? jiraAsString(issue.created) ?? null,
308
+ updated_at:
309
+ jiraAsString(fields.updated) ?? jiraAsString(issue.updated) ?? null,
310
+ description: adfToText(fields.description ?? issue.description) || null,
311
+ url: jiraIssueUrl(issue, fields, config) ?? null,
312
+ };
313
+ }