@dsh-ray/lark-channel 0.0.0-stage → 0.2.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 (344) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +207 -2
  3. package/bin/dsh-lark-setup.js +37 -0
  4. package/bin/dsh-ray-setup.js +34 -0
  5. package/bin/dsh-supervised-growth-setup.js +34 -0
  6. package/cordis.patch.yml +23 -0
  7. package/docs/operations.md +133 -0
  8. package/docs/progress-security.md +125 -0
  9. package/docs/rsi-setup.md +216 -0
  10. package/docs/setup.md +358 -0
  11. package/docs/supervised-growth.md +95 -0
  12. package/lib/adapter.d.ts +185 -0
  13. package/lib/adapter.d.ts.map +1 -0
  14. package/lib/adapter.js +2072 -0
  15. package/lib/adapter.js.map +1 -0
  16. package/lib/answer-card.d.ts +40 -0
  17. package/lib/answer-card.d.ts.map +1 -0
  18. package/lib/answer-card.js +262 -0
  19. package/lib/answer-card.js.map +1 -0
  20. package/lib/approval.d.ts +26 -0
  21. package/lib/approval.d.ts.map +1 -0
  22. package/lib/approval.js +104 -0
  23. package/lib/approval.js.map +1 -0
  24. package/lib/business-cli-install.d.ts +9 -0
  25. package/lib/business-cli-install.d.ts.map +1 -0
  26. package/lib/business-cli-install.js +367 -0
  27. package/lib/business-cli-install.js.map +1 -0
  28. package/lib/business-environment.d.ts +2 -0
  29. package/lib/business-environment.d.ts.map +1 -0
  30. package/lib/business-environment.js +16 -0
  31. package/lib/business-environment.js.map +1 -0
  32. package/lib/business-skill.d.ts +32 -0
  33. package/lib/business-skill.d.ts.map +1 -0
  34. package/lib/business-skill.js +202 -0
  35. package/lib/business-skill.js.map +1 -0
  36. package/lib/command-card.d.ts +3 -0
  37. package/lib/command-card.d.ts.map +1 -0
  38. package/lib/command-card.js +480 -0
  39. package/lib/command-card.js.map +1 -0
  40. package/lib/config.d.ts +32 -0
  41. package/lib/config.d.ts.map +1 -0
  42. package/lib/config.js +115 -0
  43. package/lib/config.js.map +1 -0
  44. package/lib/group-thread.d.ts +20 -0
  45. package/lib/group-thread.d.ts.map +1 -0
  46. package/lib/group-thread.js +36 -0
  47. package/lib/group-thread.js.map +1 -0
  48. package/lib/index.d.ts +34 -0
  49. package/lib/index.d.ts.map +1 -0
  50. package/lib/index.js +53 -0
  51. package/lib/index.js.map +1 -0
  52. package/lib/launchd-control.d.ts +24 -0
  53. package/lib/launchd-control.d.ts.map +1 -0
  54. package/lib/launchd-control.js +68 -0
  55. package/lib/launchd-control.js.map +1 -0
  56. package/lib/launchd-identity.d.ts +34 -0
  57. package/lib/launchd-identity.d.ts.map +1 -0
  58. package/lib/launchd-identity.js +184 -0
  59. package/lib/launchd-identity.js.map +1 -0
  60. package/lib/launchd-target-lock.d.ts +6 -0
  61. package/lib/launchd-target-lock.d.ts.map +1 -0
  62. package/lib/launchd-target-lock.js +48 -0
  63. package/lib/launchd-target-lock.js.map +1 -0
  64. package/lib/launchd.d.ts +62 -0
  65. package/lib/launchd.d.ts.map +1 -0
  66. package/lib/launchd.js +370 -0
  67. package/lib/launchd.js.map +1 -0
  68. package/lib/model-picker.d.ts +24 -0
  69. package/lib/model-picker.d.ts.map +1 -0
  70. package/lib/model-picker.js +95 -0
  71. package/lib/model-picker.js.map +1 -0
  72. package/lib/normalize.d.ts +12 -0
  73. package/lib/normalize.d.ts.map +1 -0
  74. package/lib/normalize.js +85 -0
  75. package/lib/normalize.js.map +1 -0
  76. package/lib/permission-picker.d.ts +29 -0
  77. package/lib/permission-picker.d.ts.map +1 -0
  78. package/lib/permission-picker.js +145 -0
  79. package/lib/permission-picker.js.map +1 -0
  80. package/lib/progress.d.ts +34 -0
  81. package/lib/progress.d.ts.map +1 -0
  82. package/lib/progress.js +354 -0
  83. package/lib/progress.js.map +1 -0
  84. package/lib/resident.d.ts +13 -0
  85. package/lib/resident.d.ts.map +1 -0
  86. package/lib/resident.js +41 -0
  87. package/lib/resident.js.map +1 -0
  88. package/lib/rsi-authority-config.d.ts +29 -0
  89. package/lib/rsi-authority-config.d.ts.map +1 -0
  90. package/lib/rsi-authority-config.js +233 -0
  91. package/lib/rsi-authority-config.js.map +1 -0
  92. package/lib/rsi-authority-resources.d.ts +36 -0
  93. package/lib/rsi-authority-resources.d.ts.map +1 -0
  94. package/lib/rsi-authority-resources.js +139 -0
  95. package/lib/rsi-authority-resources.js.map +1 -0
  96. package/lib/rsi-authority-runtime.d.ts +51 -0
  97. package/lib/rsi-authority-runtime.d.ts.map +1 -0
  98. package/lib/rsi-authority-runtime.js +496 -0
  99. package/lib/rsi-authority-runtime.js.map +1 -0
  100. package/lib/rsi-bootstrap-manifest.d.ts +53 -0
  101. package/lib/rsi-bootstrap-manifest.d.ts.map +1 -0
  102. package/lib/rsi-bootstrap-manifest.js +507 -0
  103. package/lib/rsi-bootstrap-manifest.js.map +1 -0
  104. package/lib/rsi-bootstrap.d.ts +61 -0
  105. package/lib/rsi-bootstrap.d.ts.map +1 -0
  106. package/lib/rsi-bootstrap.js +597 -0
  107. package/lib/rsi-bootstrap.js.map +1 -0
  108. package/lib/rsi-build.d.ts +76 -0
  109. package/lib/rsi-build.d.ts.map +1 -0
  110. package/lib/rsi-build.js +210 -0
  111. package/lib/rsi-build.js.map +1 -0
  112. package/lib/rsi-host-authorities.d.ts +18 -0
  113. package/lib/rsi-host-authorities.d.ts.map +1 -0
  114. package/lib/rsi-host-authorities.js +129 -0
  115. package/lib/rsi-host-authorities.js.map +1 -0
  116. package/lib/rsi-host-update.d.ts +179 -0
  117. package/lib/rsi-host-update.d.ts.map +1 -0
  118. package/lib/rsi-host-update.js +568 -0
  119. package/lib/rsi-host-update.js.map +1 -0
  120. package/lib/rsi-install-inputs.d.ts +45 -0
  121. package/lib/rsi-install-inputs.d.ts.map +1 -0
  122. package/lib/rsi-install-inputs.js +345 -0
  123. package/lib/rsi-install-inputs.js.map +1 -0
  124. package/lib/rsi-install.d.ts +117 -0
  125. package/lib/rsi-install.d.ts.map +1 -0
  126. package/lib/rsi-install.js +791 -0
  127. package/lib/rsi-install.js.map +1 -0
  128. package/lib/rsi-linux-cgroup-roots.d.ts +3 -0
  129. package/lib/rsi-linux-cgroup-roots.d.ts.map +1 -0
  130. package/lib/rsi-linux-cgroup-roots.js +3 -0
  131. package/lib/rsi-linux-cgroup-roots.js.map +1 -0
  132. package/lib/rsi-linux-creation-build.d.ts +36 -0
  133. package/lib/rsi-linux-creation-build.d.ts.map +1 -0
  134. package/lib/rsi-linux-creation-build.js +213 -0
  135. package/lib/rsi-linux-creation-build.js.map +1 -0
  136. package/lib/rsi-linux-native-materialize.d.ts +31 -0
  137. package/lib/rsi-linux-native-materialize.d.ts.map +1 -0
  138. package/lib/rsi-linux-native-materialize.js +162 -0
  139. package/lib/rsi-linux-native-materialize.js.map +1 -0
  140. package/lib/rsi-linux-native-relocation.d.ts +124 -0
  141. package/lib/rsi-linux-native-relocation.d.ts.map +1 -0
  142. package/lib/rsi-linux-native-relocation.js +1571 -0
  143. package/lib/rsi-linux-native-relocation.js.map +1 -0
  144. package/lib/rsi-linux-native-resources.d.ts +97 -0
  145. package/lib/rsi-linux-native-resources.d.ts.map +1 -0
  146. package/lib/rsi-linux-native-resources.js +521 -0
  147. package/lib/rsi-linux-native-resources.js.map +1 -0
  148. package/lib/rsi-linux-repository-bootstrap.d.ts +17 -0
  149. package/lib/rsi-linux-repository-bootstrap.d.ts.map +1 -0
  150. package/lib/rsi-linux-repository-bootstrap.js +317 -0
  151. package/lib/rsi-linux-repository-bootstrap.js.map +1 -0
  152. package/lib/rsi-linux-runner-states.d.ts +20 -0
  153. package/lib/rsi-linux-runner-states.d.ts.map +1 -0
  154. package/lib/rsi-linux-runner-states.js +70 -0
  155. package/lib/rsi-linux-runner-states.js.map +1 -0
  156. package/lib/rsi-linux-runtime-bootstrap.d.ts +10 -0
  157. package/lib/rsi-linux-runtime-bootstrap.d.ts.map +1 -0
  158. package/lib/rsi-linux-runtime-bootstrap.js +38 -0
  159. package/lib/rsi-linux-runtime-bootstrap.js.map +1 -0
  160. package/lib/rsi-linux-source-build.d.ts +28 -0
  161. package/lib/rsi-linux-source-build.d.ts.map +1 -0
  162. package/lib/rsi-linux-source-build.js +43 -0
  163. package/lib/rsi-linux-source-build.js.map +1 -0
  164. package/lib/rsi-local-activation.d.ts +78 -0
  165. package/lib/rsi-local-activation.d.ts.map +1 -0
  166. package/lib/rsi-local-activation.js +486 -0
  167. package/lib/rsi-local-activation.js.map +1 -0
  168. package/lib/rsi-local-cohort.d.ts +70 -0
  169. package/lib/rsi-local-cohort.d.ts.map +1 -0
  170. package/lib/rsi-local-cohort.js +810 -0
  171. package/lib/rsi-local-cohort.js.map +1 -0
  172. package/lib/rsi-local-install.d.ts +70 -0
  173. package/lib/rsi-local-install.d.ts.map +1 -0
  174. package/lib/rsi-local-install.js +363 -0
  175. package/lib/rsi-local-install.js.map +1 -0
  176. package/lib/rsi-local-pair-install.d.ts +53 -0
  177. package/lib/rsi-local-pair-install.d.ts.map +1 -0
  178. package/lib/rsi-local-pair-install.js +215 -0
  179. package/lib/rsi-local-pair-install.js.map +1 -0
  180. package/lib/rsi-local-profile-update.d.ts +25 -0
  181. package/lib/rsi-local-profile-update.d.ts.map +1 -0
  182. package/lib/rsi-local-profile-update.js +226 -0
  183. package/lib/rsi-local-profile-update.js.map +1 -0
  184. package/lib/rsi-local-roots-extension.d.ts +11 -0
  185. package/lib/rsi-local-roots-extension.d.ts.map +1 -0
  186. package/lib/rsi-local-roots-extension.js +31 -0
  187. package/lib/rsi-local-roots-extension.js.map +1 -0
  188. package/lib/rsi-local-update-build.d.ts +37 -0
  189. package/lib/rsi-local-update-build.d.ts.map +1 -0
  190. package/lib/rsi-local-update-build.js +75 -0
  191. package/lib/rsi-local-update-build.js.map +1 -0
  192. package/lib/rsi-local-update.d.ts +39 -0
  193. package/lib/rsi-local-update.d.ts.map +1 -0
  194. package/lib/rsi-local-update.js +205 -0
  195. package/lib/rsi-local-update.js.map +1 -0
  196. package/lib/rsi-memory-learning.d.ts +36 -0
  197. package/lib/rsi-memory-learning.d.ts.map +1 -0
  198. package/lib/rsi-memory-learning.js +111 -0
  199. package/lib/rsi-memory-learning.js.map +1 -0
  200. package/lib/rsi-native-install.d.ts +38 -0
  201. package/lib/rsi-native-install.d.ts.map +1 -0
  202. package/lib/rsi-native-install.js +312 -0
  203. package/lib/rsi-native-install.js.map +1 -0
  204. package/lib/rsi-native-launchd.d.ts +7 -0
  205. package/lib/rsi-native-launchd.d.ts.map +1 -0
  206. package/lib/rsi-native-launchd.js +49 -0
  207. package/lib/rsi-native-launchd.js.map +1 -0
  208. package/lib/rsi-native-profile.d.ts +76 -0
  209. package/lib/rsi-native-profile.d.ts.map +1 -0
  210. package/lib/rsi-native-profile.js +530 -0
  211. package/lib/rsi-native-profile.js.map +1 -0
  212. package/lib/rsi-native-runtime-bootstrap.d.ts +44 -0
  213. package/lib/rsi-native-runtime-bootstrap.d.ts.map +1 -0
  214. package/lib/rsi-native-runtime-bootstrap.js +619 -0
  215. package/lib/rsi-native-runtime-bootstrap.js.map +1 -0
  216. package/lib/rsi-ordinary-use-learning.d.ts +60 -0
  217. package/lib/rsi-ordinary-use-learning.d.ts.map +1 -0
  218. package/lib/rsi-ordinary-use-learning.js +103 -0
  219. package/lib/rsi-ordinary-use-learning.js.map +1 -0
  220. package/lib/rsi-owner-profile.d.ts +37 -0
  221. package/lib/rsi-owner-profile.d.ts.map +1 -0
  222. package/lib/rsi-owner-profile.js +178 -0
  223. package/lib/rsi-owner-profile.js.map +1 -0
  224. package/lib/rsi-plugin-creation.d.ts +46 -0
  225. package/lib/rsi-plugin-creation.d.ts.map +1 -0
  226. package/lib/rsi-plugin-creation.js +227 -0
  227. package/lib/rsi-plugin-creation.js.map +1 -0
  228. package/lib/rsi-plugin-revision.d.ts +38 -0
  229. package/lib/rsi-plugin-revision.d.ts.map +1 -0
  230. package/lib/rsi-plugin-revision.js +221 -0
  231. package/lib/rsi-plugin-revision.js.map +1 -0
  232. package/lib/rsi-profile.d.ts +81 -0
  233. package/lib/rsi-profile.d.ts.map +1 -0
  234. package/lib/rsi-profile.js +551 -0
  235. package/lib/rsi-profile.js.map +1 -0
  236. package/lib/rsi-release-build.d.ts +59 -0
  237. package/lib/rsi-release-build.d.ts.map +1 -0
  238. package/lib/rsi-release-build.js +219 -0
  239. package/lib/rsi-release-build.js.map +1 -0
  240. package/lib/rsi-scanner-retirement-config.d.ts +34 -0
  241. package/lib/rsi-scanner-retirement-config.d.ts.map +1 -0
  242. package/lib/rsi-scanner-retirement-config.js +272 -0
  243. package/lib/rsi-scanner-retirement-config.js.map +1 -0
  244. package/lib/rsi-scanner-retirement-runtime.d.ts +23 -0
  245. package/lib/rsi-scanner-retirement-runtime.d.ts.map +1 -0
  246. package/lib/rsi-scanner-retirement-runtime.js +98 -0
  247. package/lib/rsi-scanner-retirement-runtime.js.map +1 -0
  248. package/lib/rsi-scanner-retirement-stage.d.ts +55 -0
  249. package/lib/rsi-scanner-retirement-stage.d.ts.map +1 -0
  250. package/lib/rsi-scanner-retirement-stage.js +181 -0
  251. package/lib/rsi-scanner-retirement-stage.js.map +1 -0
  252. package/lib/rsi-scanner-retirement-transition.d.ts +57 -0
  253. package/lib/rsi-scanner-retirement-transition.d.ts.map +1 -0
  254. package/lib/rsi-scanner-retirement-transition.js +330 -0
  255. package/lib/rsi-scanner-retirement-transition.js.map +1 -0
  256. package/lib/rsi-service-environment.d.ts +6 -0
  257. package/lib/rsi-service-environment.d.ts.map +1 -0
  258. package/lib/rsi-service-environment.js +113 -0
  259. package/lib/rsi-service-environment.js.map +1 -0
  260. package/lib/rsi-service-setup.d.ts +10 -0
  261. package/lib/rsi-service-setup.d.ts.map +1 -0
  262. package/lib/rsi-service-setup.js +34 -0
  263. package/lib/rsi-service-setup.js.map +1 -0
  264. package/lib/rsi-setup.d.ts +92 -0
  265. package/lib/rsi-setup.d.ts.map +1 -0
  266. package/lib/rsi-setup.js +908 -0
  267. package/lib/rsi-setup.js.map +1 -0
  268. package/lib/rsi-source-maintenance.d.ts +33 -0
  269. package/lib/rsi-source-maintenance.d.ts.map +1 -0
  270. package/lib/rsi-source-maintenance.js +407 -0
  271. package/lib/rsi-source-maintenance.js.map +1 -0
  272. package/lib/rsi-source-update.d.ts +26 -0
  273. package/lib/rsi-source-update.d.ts.map +1 -0
  274. package/lib/rsi-source-update.js +276 -0
  275. package/lib/rsi-source-update.js.map +1 -0
  276. package/lib/rsi-source.d.ts +34 -0
  277. package/lib/rsi-source.d.ts.map +1 -0
  278. package/lib/rsi-source.js +487 -0
  279. package/lib/rsi-source.js.map +1 -0
  280. package/lib/rsi-systemd-bootstrap.d.ts +46 -0
  281. package/lib/rsi-systemd-bootstrap.d.ts.map +1 -0
  282. package/lib/rsi-systemd-bootstrap.js +271 -0
  283. package/lib/rsi-systemd-bootstrap.js.map +1 -0
  284. package/lib/sdk.d.ts +216 -0
  285. package/lib/sdk.d.ts.map +1 -0
  286. package/lib/sdk.js +1990 -0
  287. package/lib/sdk.js.map +1 -0
  288. package/lib/service.d.ts +63 -0
  289. package/lib/service.d.ts.map +1 -0
  290. package/lib/service.js +599 -0
  291. package/lib/service.js.map +1 -0
  292. package/lib/setup-business.d.ts +49 -0
  293. package/lib/setup-business.d.ts.map +1 -0
  294. package/lib/setup-business.js +335 -0
  295. package/lib/setup-business.js.map +1 -0
  296. package/lib/setup-materialization.d.ts +15 -0
  297. package/lib/setup-materialization.d.ts.map +1 -0
  298. package/lib/setup-materialization.js +221 -0
  299. package/lib/setup-materialization.js.map +1 -0
  300. package/lib/setup-profile.d.ts +23 -0
  301. package/lib/setup-profile.d.ts.map +1 -0
  302. package/lib/setup-profile.js +1248 -0
  303. package/lib/setup-profile.js.map +1 -0
  304. package/lib/setup.d.ts +298 -0
  305. package/lib/setup.d.ts.map +1 -0
  306. package/lib/setup.js +3310 -0
  307. package/lib/setup.js.map +1 -0
  308. package/lib/supervised-growth-profile.d.ts +111 -0
  309. package/lib/supervised-growth-profile.d.ts.map +1 -0
  310. package/lib/supervised-growth-profile.js +903 -0
  311. package/lib/supervised-growth-profile.js.map +1 -0
  312. package/lib/supervised-growth-setup.d.ts +201 -0
  313. package/lib/supervised-growth-setup.d.ts.map +1 -0
  314. package/lib/supervised-growth-setup.js +1005 -0
  315. package/lib/supervised-growth-setup.js.map +1 -0
  316. package/lib/systemd.d.ts +70 -0
  317. package/lib/systemd.d.ts.map +1 -0
  318. package/lib/systemd.js +308 -0
  319. package/lib/systemd.js.map +1 -0
  320. package/lib/tool-approval.d.ts +22 -0
  321. package/lib/tool-approval.d.ts.map +1 -0
  322. package/lib/tool-approval.js +107 -0
  323. package/lib/tool-approval.js.map +1 -0
  324. package/lib/types.d.ts +351 -0
  325. package/lib/types.d.ts.map +1 -0
  326. package/lib/types.js +11 -0
  327. package/lib/types.js.map +1 -0
  328. package/lib/user-question.d.ts +31 -0
  329. package/lib/user-question.d.ts.map +1 -0
  330. package/lib/user-question.js +161 -0
  331. package/lib/user-question.js.map +1 -0
  332. package/lib/version.d.ts +2 -0
  333. package/lib/version.d.ts.map +1 -0
  334. package/lib/version.js +2 -0
  335. package/lib/version.js.map +1 -0
  336. package/lib/windows-task.d.ts +42 -0
  337. package/lib/windows-task.d.ts.map +1 -0
  338. package/lib/windows-task.js +143 -0
  339. package/lib/windows-task.js.map +1 -0
  340. package/lib/ws-card-callback.d.ts +7 -0
  341. package/lib/ws-card-callback.d.ts.map +1 -0
  342. package/lib/ws-card-callback.js +51 -0
  343. package/lib/ws-card-callback.js.map +1 -0
  344. package/package.json +169 -3
package/docs/setup.md ADDED
@@ -0,0 +1,358 @@
1
+ # 连接飞书
2
+
3
+ 连接后,可以在飞书私聊机器人处理任务、用 `/model` 选择模型。机器人在本机后台运行,关闭 Web 页面不影响收发消息。
4
+
5
+ ## 首次连接
6
+
7
+ 还没安装时,在本机终端运行:
8
+
9
+ ```sh
10
+ npm install --global @dsh-ray/cli
11
+ dsh-ray install
12
+ ```
13
+
14
+ 已经跟随[首页安装](../../../README.md#开始使用)的用户,继续当前向导即可。默认配置名为 `web`,无需手工安装每个飞书插件、填写 App Secret 或配置公网回调地址。
15
+
16
+ 1. **选择机器人**:打开终端显示的飞书链接,选择已有应用或创建新应用,确认应用权限。企业要求管理员审批时,先完成飞书侧审批。
17
+ 2. **绑定本人**:给机器人发送终端当前显示的完整 `DSH-CONNECT-…` 验证码。只用最新验证码,在向导等待期间发送;终端显示成功即完成绑定,这一步不会收到聊天回复。
18
+ 3. **选择模型**:常驻服务启动后,用同一个飞书账号私聊发送 `/model`,在卡片里选择模型并确认。这条消息也会建立首次聊天会话。
19
+ 4. **确认可用**:发一句普通消息,确认收到回复。如果安装器提示 `exactly one current owner DM is required`,完成第 3 步后用原安装命令继续,无需删除配置或重新配对。
20
+
21
+ 只需要飞书消息助理、不启用完整学习场景时,可在首次安装选择 `dsh-ray install --scenario lark`。Mac 原生运行无需 Docker;平台准备见[安装指南](../../../scripts/install/README.md)。
22
+
23
+ ## 业务权限可以单独处理
24
+
25
+ 文档、日历、邮件、审批等业务工具需要额外的用户授权。默认向导会申请这些权限;消息绑定成功不表示它们已经获准。
26
+
27
+ 暂时不需要业务工具时,可以不批准这一步。若向导因此中断,先确认终端已经显示「消息通道已配置」,再用**原安装命令加 `--lark keep`** 继续,保留已绑定的应用和本人身份。例如默认安装:
28
+
29
+ ```sh
30
+ dsh-ray install --lark keep
31
+ ```
32
+
33
+ 这不会重新申请业务授权。若消息通道尚未配置完成,仍需先完成前面的绑定。独立插件向导的 `--no-business-tools` 只属于 `dsh-lark-setup`,不是 `dsh-ray install` 的参数,详见下方高级参考。
34
+
35
+ ## 没有回复时
36
+
37
+ ```sh
38
+ dsh-ray status
39
+ dsh-ray logs --profile web --lines 100
40
+ ```
41
+
42
+ | 现象 | 处理 |
43
+ | --- | --- |
44
+ | 发了验证码,没有回复 | 正常;看终端绑定结果。验证码只用于绑定,不是聊天。 |
45
+ | 终端一直没收到验证码 | 确认发给当前应用、使用本人私聊和最新码;超时后重跑向导,旧码失效。 |
46
+ | 绑定成功,但普通消息没反应 | 先确认常驻服务运行,再检查模型配置和日志;不要同时手动启动第二个相同 profile。 |
47
+ | `/model` 没有卡片或点了没反应 | 核查应用的消息权限和 `card.action.trigger` 回调;旧应用补权限后还需发布或审批,见下方「手工配置飞书应用」。 |
48
+ | 有模型卡片,但对话失败 | 检查[模型登录、API Key 与接口配置](../../../docs/models.md)。 |
49
+
50
+ 日常重启用 `dsh-ray restart --profile web`;已注册服务停止后用 `dsh-ray start --profile web`。重启不会重新授权飞书。
51
+
52
+ <details>
53
+ <summary>高级参考:独立插件、手工应用配置、凭据与系统服务</summary>
54
+
55
+ 以下保留独立部署和源码开发入口。`dsh-lark-setup` 的直接命令要求插件能解析对应 Host 的依赖,且 PATH 中的 `dsh` 就是目标 Host。通过 `dsh-ray` 安装的私有 Host 会由安装器处理这些依赖;这类安装请优先沿用上面的安装器入口,裸运行 profile 下的 `.bin/dsh-lark-setup` 可能缺少依赖或选错 Host。
56
+
57
+ ## 安装
58
+
59
+ 先安装并配置 `@dsh-ray/assistant-policy` 与 `@dsh-ray/assistant-delivery`,再安装本包:
60
+
61
+ ```sh
62
+ dsh plugin --profile web add @dsh-ray/lark-channel
63
+ dsh --profile web --dump-config
64
+ ```
65
+
66
+ 插件默认 `enabled: false`,因此安装不会立即读取凭据或联网。
67
+
68
+ ## 推荐:setup wizard
69
+
70
+ 安装完成后,让向导配置 Keychain、owner 身份、owner 工具策略、Web profile 和用户级常驻服务:
71
+
72
+ ```sh
73
+ ~/.dsh/profiles/web/node_modules/.bin/dsh-lark-setup \
74
+ --profile web \
75
+ --create-app
76
+ ```
77
+
78
+ 源码工作区可运行:
79
+
80
+ ```sh
81
+ cd /path/to/dsh-ray
82
+ pnpm --filter @dsh-ray/lark-channel build
83
+ pnpm --filter @dsh-ray/lark-channel run onboard --profile web --create-app
84
+ ```
85
+
86
+ 向导依次完成:
87
+
88
+ 1. 调用飞书官方 Node SDK 的 `registerApp`,显示十分钟有效的确认链接和终端二维码;
89
+ 2. 在飞书中选择已有应用或创建新应用,并确认权限增量;
90
+ 3. 把返回的 App Secret 写入 macOS Keychain、Linux Secret Service、无桌面 Linux 的版本化 `0600` protected-file,或当前 Windows 用户的 DPAPI 加密文件;Secret 不经过命令行参数、不写 profile、也不打印;
91
+ 4. 使用真实凭据建立一次临时长连接;
92
+ 5. 显示一次性 `DSH-CONNECT-...` 短语,并等待你私聊机器人原样发送;
93
+ 6. 从单聊取得应用作用域内准确的 `open_id`,只把该身份配置为 owner;
94
+ 7. 更新 `web/cordis.patch.yml`,启用 channel 并添加精确 ingress/reply/credential 规则;首次绑定 owner 默认创建本地 foreground 与精确 Delivery 主体的 capability/工具规则;随后运行 `dsh --profile web --dump-config` 自检;
95
+ 8. 安装并启动该 profile 的用户级常驻服务:macOS 使用 launchd,Linux 使用 systemd,Windows 使用 best-effort Task Scheduler;命令均为 `dsh --profile web --no-open`;
96
+ 9. 将同一应用以 stdin 凭据接入官方 `lark-cli` 的 DSH 专用配置,申请其全部业务域用户授权,核对服务端返回的用户身份与刚绑定的 owner 一致,再生成可动态读取 CLI 技能的原生 DSH 技能。
97
+
98
+ 应用授权与用户业务授权在安装流程中完成。插件仍运行在 DSH Host 内;安装到 `web` profile 时,向导默认让该 profile 在后台常驻,不需要保持浏览器打开,也不需要另行运行 `dsh web`。
99
+
100
+ `DSH-CONNECT-...` 仅用于临时长连接上的 owner 身份绑定,绑定阶段不会自动回复,也不会建立 Delivery 聊天会话。应在当前向导的等待窗口内发送最新短语;向导超时退出后,旧短语不再有效。以终端的绑定成功结果判断,不以聊天中是否回复判断。
101
+
102
+ 全新或完整重装的 Home 在常驻服务启动后,还需要 owner 私聊发送一条普通消息或 `/model`,以建立真实会话;`/model` 可同时验证模型卡片与选择回调。交互式安装器会在配置 owner 学习前提示这一步并自动等待(默认最长 600 秒,`--owner-wait-seconds` 调整,`0` 关闭);等待只读取本地绑定快照,不发送消息,也不改变 owner 授权。也可单独运行 `dsh-ray-setup --wait-owner-dm --profile web --dsh-home <绝对路径> --timeout-seconds 600`,出现唯一 owner 私聊时以 `{"mode":"ready"}` 退出,超时或存在多个绑定时退出码为 3。若后续原生学习配置报告 `exactly one current owner DM is required`,先完成这一步,再通过安装器的 Host-aware 入口续跑 owner 配置。此时已有身份绑定和普通服务会保留,无需重新配对或授予额外业务权限。
103
+
104
+ ### 官方一键授权的范围
105
+
106
+ 一键模式使用 OAuth 2.0 Device Authorization Grant。只传 `--create-app` 时,确认页同时提供“选择已有应用”和“创建新应用”;同时传 `--app-id` 时,只更新该已有应用。两种方式都会先显示权限、事件与回调增量,确认后才生效。
107
+
108
+ 向导不传 `createOnly`,默认使用官方智能体应用权限模板(`addons.preset: true`),并增量补齐下列消息通道权限。传 `--no-business-tools` 则保留仅消息通道的 `preset: false`:
109
+
110
+ - `application:bot.basic_info:read`:连接时取得机器人身份;
111
+ - `im:message.p2p_msg:readonly`、`im:message.group_at_msg:readonly`:接收私聊和群内 @ 消息;
112
+ - `im:message.reactions:write_only`:添加 `Get` / `DONE`;
113
+ - `im:message:send_as_bot`:发送和回复消息;
114
+ - `im:resource`:按消息 ID 与该消息中的 image key 调用[消息资源接口](https://open.feishu.cn/document/server-docs/im-v1/message-resource/get)下载用户图片;
115
+ - `im.message.receive_v1`:消息事件;
116
+ - `card.action.trigger`:审批卡片、模型级联选择和最终确认按钮。
117
+
118
+ 消息通道自身的精确日历触发器仍需 `--create-app --calendar-readonly` 和 `allowedCalendarIds`;这与业务 CLI 在用户实际授权下提供的日历功能是两条独立路径。应用模板和 `auth login --domain all` 都不代表租户已经批准平台上的所有权限;后者申请 CLI 当前已知的业务域用户 scopes,平台限制和 CLI 的批量授权排除项仍然适用。
119
+
120
+ ### 自动业务工具接入
121
+
122
+ 安装器优先复用满足契约的本机 CLI,缺失时下载官方 npm `latest` 对应的精确稳定版本到 `$DSH_HOME/.dsh-ray/tools/lark-cli`。优先下载 GitHub release,失败时尝试官方安装器使用的镜像;两条路径都验证 npm SHA512 与包内记录的 release SHA256,不执行 npm 安装脚本或修改全局 npm。已验证的受管 CLI 可在后续安装中复用。
123
+
124
+ 每个 DSH profile/account 的配置与授权记录保存在 `$DSH_HOME/lark-business`;App Secret 仅通过 stdin 交给 CLI。每次 CLI 调用都固定绝对命令、named profile、配置目录,并清除会抢占身份的外部 Agent/CLI 环境变量。Linux 凭据数据也存入专用目录;macOS/Windows 使用 CLI 的原生系统钥匙环,同一应用/用户的条目可能与其它 CLI 实例共享,不能视为独立凭据隔离。
125
+
126
+ 首次用户授权会展示链接与二维码。授权完成后同时检查 CLI 授权结果、已验证状态,以及只读 `user_info` 的服务端 `open_id`;只接受绑定的 owner。CLI 明确报告登录完成但部分 scope 未获批时,向导保存申请、已授予和缺失清单,展示缺失权限并接入实际已授权的业务工具;非零退出码本身不等于登录失败,也不能单独证明登录成功。若身份读回或技能发布中断,只有已持久化完整授权结果的 pending 记录可在重跑时复查身份并续接,不再次请求扫码。已有有效授权在重装时更新应用凭据并重新核对身份;旧记录缺少权限清单时明确标为未知,不推断全部获批。认证未完成、CLI 返回不明错误或范围证据丢失时不启用新的业务技能,已经提交的消息通道配置会保留。同一 owner/app 的授权更新失败保留原有技能;更换 owner、app 或 account,以及显式关闭业务工具时,会在通道 owner 交接前撤下旧受管技能入口。撤下入口不代表撤销平台 token,原凭据配置仍保留。若后续通道配置事务失败并回滚,旧技能不会自动重新发布;按原绑定重跑向导并核对身份后可恢复入口。
127
+
128
+ 生成的 `$DSH_HOME/skills/lark-business-*/SKILL.md` 由 DSH 原生文件系统技能提供者发现,按需读取当前 CLI 的 `skills list/read` 与 `schema`,无需复制一份易过期的 API 指南。技能明确记录适用的 profile/account/app/owner,不携带凭据,也不新增 Agent 循环。DSH 的用户技能目录对同一 DSH_HOME 的 profile 可见;这属于同一操作系统用户的 Full access 信任范围,不提供跨 profile 的凭据隔离。官方业务能力与权限机制参考 [larksuite/cli](https://github.com/larksuite/cli)。
129
+
130
+ 事件与回调由官方流程预置为 WebSocket 长连接,不需要公网 callback URL。实现依据见飞书的[一键创建智能体应用](https://open.larkoffice.com/document/mcp_open_tools/integrating-agents-with-feishu/overview)和 Node SDK 的 [`registerApp` 文档](https://github.com/larksuite/node-sdk/blob/main/README.zh.md#%E4%B8%80%E9%94%AE%E5%88%9B%E5%BB%BA%E5%BA%94%E7%94%A8)。
131
+
132
+ ### 复用已有应用
133
+
134
+ ```sh
135
+ # 通过官方授权页增量补齐指定应用的权限、事件和回调(推荐)
136
+ ~/.dsh/profiles/web/node_modules/.bin/dsh-lark-setup \
137
+ --profile web \
138
+ --create-app \
139
+ --app-id cli_0123456789abcdef
140
+
141
+ # 只安全录入已有凭据,不修改飞书控制台
142
+ ~/.dsh/profiles/web/node_modules/.bin/dsh-lark-setup \
143
+ --profile web \
144
+ --app-id cli_0123456789abcdef
145
+ ```
146
+
147
+ 单独使用 `--app-id` 时,向导通过当前系统的安全输入读取 App Secret,适合已经自行配置控制台的应用。省略 `--create-app` 和 `--app-id` 时,向导会询问 App ID;直接回车进入一键选择/创建。
148
+
149
+ 重复执行会更新同一 account 的受管配置,不会重复添加规则或 handle。首次绑定 owner 默认开放已安装的 Agent 工具能力;已有应用或 owner 配置保留现状,不会因重装重新开启已关闭的工具:
150
+
151
+ 向导在交接 Lark owner 前检查同一 DSH Home 的其他 profile 是否使用相同 Delivery 数据库。Electron 管理的 `desktop` profile 不允许通过 `dsh --profile desktop --dump-config` 读取;向导遇到这条明确的 CLI 拒绝时,使用当前 `dsh` CLI 安装的配置组合器只读检查 Desktop 的 bundle、profile 和 Home 覆盖层。发现共享 Lark owner 或启用的 Delivery scheduler,以及 Desktop 配置无法完整读取时,都会停止交接并保留原 profile。
152
+
153
+ - 不传参数:首次配置默认开放,已有配置保留现状;
154
+ - `--preserve-agent-tools`:始终保留现有规则,首次配置也不新增通用工具授权;
155
+ - `--allow-agent-tools`:写入本地 foreground 与精确 Delivery 主体的通用 capability 可达性规则,并保留外部主体工具级 allow/deny;
156
+ - `--disable-agent-tools`:删除向导为该 account 管理的这些规则。
157
+
158
+ 本地工具授权不等于取得全部飞书平台权限;当前 channel 的业务接口仍限于其已实现能力,应用和用户授权以飞书平台结果为准。普通重跑不会意外授权或撤权。profile 校验失败时会在进程内恢复原内容,不保留备份文件。
159
+
160
+ ## 只刷新 Agent Policy
161
+
162
+ 更新 capability 规则不需要重走 onboarding;未启用飞书的 Web/direct-only profile 也可刷新本地 foreground:
163
+
164
+ ```sh
165
+ # 写入/刷新本地 foreground;若飞书已启用,同时刷新精确 Delivery 规则
166
+ ~/.dsh/profiles/web/node_modules/.bin/dsh-lark-setup \
167
+ --profile web \
168
+ --refresh-agent-policy \
169
+ --allow-agent-tools
170
+
171
+ # 删除 setup 托管的 foreground;若飞书已启用,同时删除该 account 的 Agent 规则
172
+ ~/.dsh/profiles/web/node_modules/.bin/dsh-lark-setup \
173
+ --profile web \
174
+ --refresh-agent-policy \
175
+ --disable-agent-tools
176
+ ```
177
+
178
+ `--refresh-agent-policy` 必须与 allow/disable 之一搭配;除 `--profile` 外只可选 `--account`。本地 foreground 规则独立于 Lark row,总能在已安装的 personal-assistant profile 中刷新;只有 profile 已启用 Lark 时才重建精确 Delivery 规则,显式 account 也必须完全相同。
179
+
180
+ 该模式不读取 App Secret、不发起设备授权,不修改 App、credential handle、owner、conversation binding 或其他 channel 配置,也不安装或重启常驻服务。它原子写入 profile 后立刻运行 `dsh --dump-config`;失败时原子恢复原 patch。
181
+
182
+ ## 手工配置插件
183
+
184
+ 不使用向导时,可在 profile patch 中填写真实值:
185
+
186
+ ```yaml
187
+ config:
188
+ enabled: true
189
+ account: personal-bot
190
+ tenant: personal
191
+ appId: cli_0123456789abcdef
192
+ credentialHandle: lark-app-secret
193
+ credentialPurpose: connect
194
+ credentialLeaseMs: 86400000
195
+ domain: feishu
196
+ requireMentionInGroups: true
197
+ showProgress: true
198
+ progressDetails: direct
199
+ showBackgroundProgress: false
200
+ statusReactions: true
201
+ imageDownloadTimeoutMs: 30000
202
+ ```
203
+
204
+ credential handle 由 `@dsh-ray/credentials-keychain` 提供,并应只允许 consumer `dsh-ray-lark-channel`、purpose `connect`。兼容部署可不激活 keychain service,改为只设置 `appSecretEnv`,再通过进程环境或操作系统 service manager 注入:
205
+
206
+ ```sh
207
+ LARK_APP_SECRET='...' dsh --profile web
208
+ ```
209
+
210
+ `credentialHandle` 与 `appSecretEnv` 只能选择一个;配置不接受 `appSecret` 等明文字段。handle 模式会让 adapter 的完整连接生命周期处于 credential lease callback 内。自然 TTL 到期时会先清理旧连接,再申请新 lease 并重连;运维撤销或插件卸载会清理连接并停止续租,不能把 revoke 当成 expiry 自动恢复。
211
+
212
+ 若以 `appSecretEnv: LARK_APP_SECRET` 配合 `--install-service`,生成的 user unit 不会继承登录 shell 的变量,也不会替你保存 Secret。应使用自有 supervisor,或为目标 profile 创建仅当前用户可读的 systemd drop-in:
213
+
214
+ ```sh
215
+ install -d -m 700 ~/.config/dsh ~/.config/systemd/user/dsh-profile-web.service.d
216
+ # 用编辑器创建 ~/.config/dsh/lark-web.env,内容为 LARK_APP_SECRET=...,权限设为 0600。
217
+ chmod 600 ~/.config/dsh/lark-web.env
218
+
219
+ # 用编辑器创建 ~/.config/systemd/user/dsh-profile-web.service.d/secret.conf:
220
+ # [Service]
221
+ # EnvironmentFile=%h/.config/dsh/lark-web.env
222
+ systemctl --user daemon-reload
223
+ systemctl --user restart dsh-profile-web.service
224
+ ```
225
+
226
+ 不要把 Secret 放入 profile 或 shell history。
227
+
228
+ ## 常驻服务
229
+
230
+ 已完成飞书配置,只需安装或重启服务时运行:
231
+
232
+ ```sh
233
+ ~/.dsh/profiles/web/node_modules/.bin/dsh-lark-setup \
234
+ --profile web \
235
+ --install-service
236
+ ```
237
+
238
+ 若自行管理进程,在首次向导中加入 `--no-service`,然后用 supervisor 运行 `dsh --profile web --no-open`。不要同时启动前台与系统服务的两个相同 profile,否则 Web 端口和飞书长连接会竞争。
239
+
240
+ 同一个 Delivery 数据库也不能由不同 profile 的消息调度器同时消费。即使另一个 profile 已关闭 Lark,只要其 Delivery 调度器仍启用,就可能抢到消息并按另一套 Policy 拒绝处理。向导会检查其他已配置 profile 的有效 Delivery 路径与调度状态;不能仅凭另一个服务暂时停止判断没有冲突。请在旧 profile 的完整 Delivery 配置中关闭 `schedulerEnabled`,或为独立部署配置不同数据库;保留其余配置字段。向导不会替你关闭其他服务、清空队列或撤销旧任务。
241
+
242
+ ### macOS
243
+
244
+ 向导创建 `~/Library/LaunchAgents/ai.deepseek.dsh.profile.web.plist`,登录后自动启动并在异常退出后拉起。配置只包含 `DSH_HOME` 与不含相对目录的 `PATH`,不会复制当前 shell 的 token、password 或其他环境变量。
245
+
246
+ ```sh
247
+ launchctl print gui/$(id -u)/ai.deepseek.dsh.profile.web
248
+ tail -f ~/.dsh/logs/web-host.error.log
249
+
250
+ # 停止并卸载;再次执行 --install-service 可恢复
251
+ launchctl bootout gui/$(id -u)/ai.deepseek.dsh.profile.web
252
+ ```
253
+
254
+ ### Linux
255
+
256
+ 向导创建私有的 `~/.config/systemd/user/dsh-profile-web.service`,配置 DSH 所需路径及 Secret Service 可能需要的用户 D-Bus/XDG 定位。若已通过 [RSI 配置器](rsi-setup.md)登记发布/Host 配置路径,安装或重装服务会自动加载这些持久绑定;不会复制任意 shell 环境或 Secret。OAuth 前会检查 systemd user manager,并尝试为当前用户启用 linger,以便 SSH 注销后继续运行。若系统需要管理员授权,向导会在修改飞书应用前停止,并显示唯一需要执行的命令:
257
+
258
+ ```sh
259
+ sudo loginctl enable-linger "$(id -u)"
260
+ ```
261
+
262
+ 日常运维:
263
+
264
+ ```sh
265
+ systemctl --user status dsh-profile-web.service
266
+ journalctl --user -u dsh-profile-web.service -f
267
+ systemctl --user restart dsh-profile-web.service
268
+ ```
269
+
270
+ 纯 SSH 和无桌面 Linux 支持一键向导;内建服务仍要求 systemd/logind user manager 并允许 linger。不具备这些组件的容器应使用 `--no-service`,交给 Docker、s6、runit 等外部 supervisor。当前安装器要求可调用的 `systemctl` / `loginctl`;不符合这一约束的 Nix、Guix 或精简容器也应使用外部 supervisor。
271
+
272
+ ### Windows
273
+
274
+ Windows 会把 DPAPI 加密的 PSCredential 保存到 `$DSH_HOME/credentials-keychain`,并创建当前用户的 `DSH profile web` 登录任务。不会保存明文,但 Windows/Node/npm/Git Bash 组合差异较大,因此只提供 best-effort 支持:
275
+
276
+ ```powershell
277
+ schtasks.exe /Query /TN "DSH profile web"
278
+ schtasks.exe /End /TN "DSH profile web"
279
+ schtasks.exe /Run /TN "DSH profile web"
280
+ ```
281
+
282
+ ## Linux 凭据后端
283
+
284
+ 默认 `auto`:若当前登录会话有可写且已解锁的 Secret Service,就使用系统钥匙环;纯 SSH、服务器、容器或 Secret Service 不可用时,自动改用 `$DSH_HOME/credentials-keychain/lark-<profile>-<account>-<32hex>.secret` 版本化私有文件。
285
+
286
+ 向导在飞书 OAuth 之前确认 `credentials-keychain` 支持所选 provider,并对实际 backend 执行随机 canary 的写入、读回和删除;这样不会在应用授权后才发现版本混装或无法保存凭据。安装器会同时安装匹配的两个插件版本。
287
+
288
+ protected-file 的父目录必须为当前 UID 所有、权限 `0700`;文件必须为当前 UID 所有的 regular file、单硬链接、权限 `0600`。创建使用独占、拒绝跟随链接的版本化路径,写入和删除后同步父目录。Secret 不进入 profile、argv、环境变量或日志,Host 重启后由 `credentials-keychain` 读取同一路径。
289
+
290
+ protected-file 没有额外静态加密:同一 UID、root 和能读取该文件的备份系统仍可取得 App Secret。可显式选择:
291
+
292
+ ```sh
293
+ # Secret Service 不可用时直接失败
294
+ dsh-lark-setup --profile web --linux-credential-provider secret-service
295
+
296
+ # 即使桌面钥匙环可用也使用 0600 私有文件
297
+ dsh-lark-setup --profile web --linux-credential-provider protected-file
298
+ ```
299
+
300
+ 手工输入已有 App Secret 时优先使用 `/usr/bin/systemd-ask-password`;若不存在但 stdin/stdout 是真实 TTY,则使用无回显 raw-terminal 后备,并在 Enter、Ctrl-C、SIGINT、SIGHUP 或 SIGTERM 后恢复终端模式。`--no-service` 只跳过 systemd 服务,凭据仍按上述 `auto` 规则选择。
301
+
302
+ ### Secret Service 排障与事务恢复
303
+
304
+ 若旧版在授权后留下 `setup failed and staged credential cleanup also failed`,不要删除 `$DSH_HOME/profiles/<profile>/cordis.patch.yml.lark-setup.journal.json`。新版确认 versioned locator 从未被 profile 激活后,会把清理义务原子转入 `cordis.patch.yml.lark-credential-cleanup.json`,清除阻塞事务并改用 protected-file 完成初始化;以后每次进入向导都会 best-effort 重试 Secret Service 清理。不要手工删除或编辑 cleanup record。
305
+
306
+ 若看到 `profile and owner were committed, but previous credential cleanup is pending`,新 profile、owner 和凭据已经生效,不能回滚。向导保留同一 journal,以便修复 Secret Service 后优先重试删除旧凭据;不要删除 journal,也不要立即开始另一轮凭据旋转。
307
+
308
+ Ubuntu/Debian 图形桌面可用将运行 DSH 的普通登录用户打开终端;不要用 `sudo` 运行向导:
309
+
310
+ ```sh
311
+ sudo apt update
312
+ sudo apt install --yes libsecret-tools gnome-keyring dbus-user-session
313
+ # 完整注销并重新登录后,在新的图形终端做无凭据检查
314
+ test -x /usr/bin/secret-tool
315
+ test -n "${DBUS_SESSION_BUS_ADDRESS:-}" || test -S "${XDG_RUNTIME_DIR:-}/bus"
316
+ ```
317
+
318
+ OAuth 前的 canary 不读取、写入或显示 App Secret。出现钥匙环解锁对话框时先解锁;没有桌面 provider 时默认自动选择 protected-file,无需安装 GNOME Keyring。随后用原来的 profile/account/tenant/agent-tools 参数重跑;已创建应用可复用:
319
+
320
+ ```sh
321
+ ~/.dsh/profiles/web/node_modules/.bin/dsh-lark-setup \
322
+ --profile web --create-app --app-id cli_0123456789abcdef
323
+ ```
324
+
325
+ `secret-tool` 与 GNOME Keyring 只在强制 `secret-service` 或希望使用桌面钥匙环时需要。
326
+
327
+ ## 手工配置飞书应用
328
+
329
+ 这一流程只适用于手工输入 `--app-id` 的路径;官方一键路径会预置机器人、所选应用权限模板、消息事件和卡片回调。选择已有应用时只增量添加配置,不删除现有权限。
330
+
331
+ 1. 在[飞书开放平台](https://open.feishu.cn/app)创建“企业自建应用”,复制 `App ID` 与 `App Secret`;
332
+ 2. 在“添加应用能力”中开启“机器人”;
333
+ 3. 在“权限管理”中开通接收/发送单聊和群聊消息、`im:message.reactions:write_only` 和图片所需 `im:resource`;控制台若为接收事件提示额外权限,也按最小范围开通;
334
+ 如要启用精确 Calendar 变更触发器,额外开通 `calendar:calendar:readonly`,并仅向应用共享操作员指定的 Calendar;
335
+ 4. 在“事件与回调/事件订阅”选择长连接,添加 [`im.message.receive_v1`](https://open.feishu.cn/document/server-docs/im-v1/message/events/receive);使用审批卡或 `/model` 时,还需把回调订阅方式设为长连接并添加 `card.action.trigger`;
336
+ 5. 创建并发布应用版本,把可用范围至少包含自己。未发布或不在范围内时,客户端可能搜索不到机器人或不投递事件。
337
+
338
+ 企业策略需要管理员审批时,仍由管理员在飞书侧完成。运行时不需要公网 callback URL;Node SDK 的[长连接说明](https://github.com/larksuite/node-sdk/blob/main/README.zh.md#%E4%BD%BF%E7%94%A8%E9%95%BF%E9%93%BE%E6%A8%A1%E5%BC%8F%E5%A4%84%E7%90%86%E4%BA%8B%E4%BB%B6)也说明本地环境只需能访问公网。
339
+
340
+ 如果应用是在 reaction、图片桥或模型卡片回调加入前绑定的,应重跑一键向导,确认新增权限和 `card.action.trigger`,然后发布新版本或完成管理员审批。指定 App ID 只增量更新,不创建第二个应用:
341
+
342
+ ```sh
343
+ # macOS:先暂停旧长连接,避免 owner 确认消息被常驻实例竞争消费
344
+ launchctl bootout gui/$(id -u)/ai.deepseek.dsh.profile.web
345
+
346
+ ~/.dsh/profiles/web/node_modules/.bin/dsh-lark-setup \
347
+ --profile web \
348
+ --create-app \
349
+ --app-id cli_0123456789abcdef
350
+ ```
351
+
352
+ 向导结束会重新安装并拉起服务。若在官方确认或 owner 私聊阶段取消,可运行 `dsh-lark-setup --profile web --install-service` 恢复原服务。
353
+
354
+ 长连接至少需要消息事件、发送/回复消息权限和机器人身份读取。若群聊无需 `@机器人` 即触发,必须同时将 `requireMentionInGroups` 设为 `false` 并在飞书侧申请更宽的群消息权限。
355
+
356
+ `account` 与 `tenant` 是 DSH 内部稳定路由名,不是 Secret。个人单应用通常保持 `account: primary`、`tenant: personal`;真实飞书身份由向导发现的应用作用域 `open_id` 决定。陌生外部身份仍由 `assistant-delivery` fail closed;不能把“飞书能收到事件”视为已经授权。
357
+
358
+ </details>
@@ -0,0 +1,95 @@
1
+ # 分级自治成长激活器
2
+
3
+ 这是显式选择的固定 Recovery runbook。普通 `supervised` 安装直接使用[日常使用自迭代配置](rsi-setup.md),不再自动调用本激活器;以下 preview、健康门与回滚合同继续适用于显式激活。
4
+
5
+ `dsh-supervised-growth-setup --profile web` 在完成 Lark owner onboarding 后,把
6
+ `supervised-growth/v2` 作为无模型的 `assistant-recovery` Host runbook 激活。它不把恢复步骤、
7
+ 目标 scope、owner route 或 Policy 参数交给模型选择。另有独立、受限的 adoption analyst;它不参与
8
+ Recovery,只能把一个 Host 选出的候选转为 owner 审批卡。
9
+
10
+ ```sh
11
+ ~/.dsh/profiles/web/node_modules/.bin/dsh-supervised-growth-setup --profile web
12
+
13
+ # 只有在确认其他现存 active automation 可以继续运行时才使用
14
+ ~/.dsh/profiles/web/node_modules/.bin/dsh-supervised-growth-setup \
15
+ --profile web \
16
+ --ack-existing-automations
17
+ ```
18
+
19
+ 激活器先从有效配置读取 Delivery、Automations 和 Recovery 的真实 SQLite 路径,再等待唯一一条
20
+ 与 account、tenant、默认 workspace 和 preset 完全一致的 active owner 私聊 binding。没有匹配、
21
+ 存在多个匹配、binding 在写入或重启前发生变化时均不会继续。
22
+
23
+ ## 两阶段激活与完整回滚
24
+
25
+ 一次激活只生成一个非 bearer `activationNonce`,并动态读取已安装 Recovery 包当前编译的
26
+ `RECOVERY_CATALOG_DIGEST`。随后严格执行两个重启阶段:
27
+
28
+ 1. 写入 `activationState: preview`。此时普通 Automations scheduler 固定为关闭;Recovery 只通过
29
+ exact `runSystemDry` 运行一次完整 preview。升级配置中的旧 `supervised-growth` Heartbeat 会先被
30
+ 标记为 disabled、清空 allowed tools,并通过唯一的 reconcile 权限把 durable
31
+ `heartbeat:supervised-growth` 暂停;新的 `heartbeat:supervised-growth-analyst` 也固定为 paused。
32
+ 2. resident 进程 running 只是第一道门。激活器继续有界轮询 Recovery SQLite,要求本次重启的
33
+ `bootstrapStatus` 为 `succeeded`,并证明 legacy Heartbeat、Recovery preview 与 analyst 都处于
34
+ 预期状态,analyst definition 和私有 scratch 与受管合约逐项一致。
35
+ 3. 只有 preview 通过,才用同一 nonce、catalog digest、owner authority 和完整计划写入
36
+ `activationState: active`,打开 scheduler 并再次重启。
37
+ 4. active 阶段同样要求本次持久 bootstrap 成功,并从 Automations SQLite 证明
38
+ `recovery:supervised-growth` 由 `dsh-ray-assistant-recovery` 持有、处于 active,且完整
39
+ production definition 与当前编译计划逐项一致;analyst 必须由 `assistant-heartbeat` 持有、处于
40
+ active,且仍与同一 exact definition 相等。
41
+
42
+ preview 配置验证、preview bootstrap、active 配置验证、active bootstrap、binding 重验或 resident
43
+ 健康任一失败,激活器都会原样写回进入命令前的 patch,并重启原 profile。不会留下“进程还活着,
44
+ 但 Recovery 已降级/失败”的半激活状态。
45
+
46
+ ## 生成的受管配置
47
+
48
+ - 稳定 Delivery owner route `supervised-growth-owner` 精确固定 conversation、principal、绝对
49
+ workspace、preset、policyRef 和首次启用时的 minimum generation;后续同 lineage `/new` 可以前进,
50
+ 身份或 scope 漂移会失败关闭。
51
+ - Recovery job `supervised-growth` 每天在 Asia/Shanghai 的
52
+ 08:00、10:00、12:00、14:00、16:00、18:00、20:00 运行,使用 `automation-runs` workspace
53
+ budget,每天最多 7 次、每次固定 1。
54
+ - analyst 每天 08:00 最多运行一次,使用独立 `automation-runs` workspace budget。它的 immutable
55
+ allowlist 只有 `evolution_adoption_review` 和 `evolution_adoption_propose`,Policy 还把 inspect/propose
56
+ 限定到 production `heartbeat:supervised-growth-analyst`。定义只带 `approvalBindingId`,不带
57
+ `deliveryBindingId`,所以只有 proposal 卡会发给 owner,普通模型正文不会投递。
58
+ - 固定 runbook 依次做 owner authority/Health admission、Evaluation durable projection、至多一条
59
+ Preference retention、至多一个 evidence-ready T1 激活、至多一条可信回归 Evolution rollback、
60
+ 至多一个 exact circuit production canary,最后再次验证 authority 与 Health。
61
+ - preview 完成相同的读取、规划和验证,但不提交 production mutation、exposure、Delivery 或 circuit。
62
+ - workflow learning 不以 Lark 消息、卡片或 callback 作为写入面。只有 Delivery 通过私有、可撤销的
63
+ trace sink 投影已证明的 content-free revision;自动来源还要求 active owner 对已投递普通 Agent reply
64
+ 的精确 `/feedback achieved` 与静态 catalog selector。候选仍须 owner approval、replay、effect-blocked
65
+ shadow、单次 canary 和 trusted outcome,Lark 只负责呈现 Delivery 已持久的结果。
66
+ - Automation incident 只能由固定 `assistant-automations-incidents` 主体投递:Host run
67
+ 限定到 `message/route:supervised-growth-owner`,analyst Agent run 限定到当前 exact owner
68
+ binding。两条授权都绑定同一 workspace 和 principal,不能互相借用。Evolution proposal
69
+ 审批仍只能投递给当前 exact owner binding。
70
+ - 普通 owner Agent 继续拥有 foreground/external 的 Evolution review/propose/rollback/undo 工具与
71
+ inspect/propose 权限,以及 Preference/Evolution prompt snapshot;这些权限不对 Recovery 或 legacy
72
+ background model heartbeat 开放。analyst 只获得上述两个 adoption 工具和精确 evolution resource。
73
+
74
+ overlay 不授予 Recovery shell、文件系统内容读取、网络、浏览器、凭据、代码修改或 Policy 修改能力。
75
+ T2/T3 与自由文本 guidance 仍需 owner 审批。确定性 T1 激活、可信回归回滚和固定 circuit canary 按
76
+ runbook 执行,不增加逐动作审批。
77
+
78
+ ## Health 与安装场景
79
+
80
+ `supervised` 场景在 core 与 `lark` 集合(含 `preference-learning`)基础上,安装完整受管成长组合:`assistant-evaluation`、`assistant-evolution`、`assistant-growth-experiments`、`assistant-heartbeat`、`assistant-health`、`assistant-skills`、`assistant-verifier`、`assistant-growth-driver`、`assistant-work-items`、`assistant-memory-learning`、`assistant-goals`、`assistant-recovery`、`event-triggers`、`assistant-proactive` 与 `owner-console`(完整安装集合以[安装指南](../../../scripts/install/README.md)为准;其中 `assistant-goals` 是 `assistant-recovery` 的必需 Cordis 注入)。Heartbeat 不接管 Recovery,只承载独立 analyst,因此 `assistantHeartbeat` 始终是 supervised Health required provider;用户已有的其他 Heartbeat 配置保持不变。
81
+
82
+ 必需 Health provider 包含 Policy、Memory、Wiki、Automations、Heartbeat、Evaluation、Preference、Evolution、Growth Experiments(`assistantGrowthExperiments`)、Delivery、Recovery 和 Lark Channel。Recovery bootstrap 的 `failed`、stale run/step、缺 provider、Lark 断联、open incident/circuit 等都不会被 resident running 状态掩盖。
83
+
84
+ TraeX 或其他模型 route 不是 Recovery 依赖。它们只影响普通前台助手;需要时用 `--with traex` 等
85
+ 方式单独安装。Windows Task Scheduler 没有可验证的 resident running gate,因此当前拒绝激活
86
+ supervised growth。
87
+
88
+ ## 已有 Automation 与重复执行
89
+
90
+ 除 exact managed `heartbeat:supervised-growth`、`heartbeat:supervised-growth-analyst` 和
91
+ `recovery:supervised-growth` 外,任何 active
92
+ Automation 默认阻止激活,以免打开 scheduler 时意外运行。确认这些其他任务可继续后,显式传入
93
+ `--ack-existing-automations`。已成功启用的 profile 可以再次运行激活器;它会为新一轮 preview
94
+ 生成新 nonce,先暂停旧 managed definition,再按相同两阶段协议重新证明,而不要求为自身使用
95
+ ack 参数。
@@ -0,0 +1,185 @@
1
+ import type { AdapterSendResult, AdapterInboundImageReadResult, DeliveryAdapter, DeliveryAdapterContext, DeliveryProgressIntent, DeliveryPresentation, DeliveryToolApprovalOutcome, DeliveryToolApprovalRequest, DeliveryUserQuestionOutcome, DeliveryUserQuestionRequest, ModelPickerIntent, ModelPickerState, ModelRouteRef, ModelSelectionResult, ModelSelectionSettlementInput, ModelSelectionTerminalResult, OutboundIntent, InboundImageReadInput } from '@dsh-ray/assistant-delivery';
2
+ import { type LarkChannelHealth, type LarkInboundConfig, type LarkTransport } from './types.js';
3
+ export interface LarkApprovalSettlementInput {
4
+ operationId: string;
5
+ callbackEventId: string;
6
+ callbackChatId: string;
7
+ bindingId: string;
8
+ principal: {
9
+ channel: string;
10
+ account: string;
11
+ tenant: string;
12
+ user: string;
13
+ };
14
+ proposalId: string;
15
+ expectedVersion: number;
16
+ diffHash: string;
17
+ decision: 'approved' | 'rejected';
18
+ reason: string;
19
+ }
20
+ export interface LarkAdapterOptions {
21
+ now?: () => number;
22
+ /** Runtime-only readiness signal emitted after a confirmed WS connection. */
23
+ onConnected?(): void;
24
+ /** Runtime-only liveness edge emitted after a confirmed connection is lost. */
25
+ onDisconnected?(): void;
26
+ showProgress?: boolean;
27
+ progressDetails?: 'off' | 'direct';
28
+ /** WP19 stage 2c: opt in to rendering non-terminal background progress. Default false. */
29
+ showBackgroundProgress?: boolean;
30
+ /** SHA-256 of the exact app identity and secret, never the secret itself. */
31
+ progressCredentialFingerprint?: string;
32
+ statusReactions?: boolean;
33
+ userQuestionTtlMs?: number;
34
+ approvalSecret?: string;
35
+ settleApproval?(input: LarkApprovalSettlementInput): unknown | Promise<unknown>;
36
+ recoverApprovalSettlement?(input: LarkApprovalSettlementInput): unknown | undefined | Promise<unknown | undefined>;
37
+ settleModelSelection?(input: ModelSelectionSettlementInput): ModelSelectionResult | Promise<ModelSelectionResult>;
38
+ awaitModelSelection?(input: ModelSelectionSettlementInput, signal: AbortSignal): ModelSelectionTerminalResult | undefined | Promise<ModelSelectionTerminalResult | undefined>;
39
+ settlePermissionSelection?(input: {
40
+ operationId: string;
41
+ callbackEventId: string;
42
+ callbackChatId: string;
43
+ cardMessageId: string;
44
+ bindingId: string;
45
+ bindingVersion: number;
46
+ sessionId: string;
47
+ principal: {
48
+ channel: string;
49
+ account: string;
50
+ tenant: string;
51
+ user: string;
52
+ };
53
+ issuedAt: number;
54
+ expiresAt: number;
55
+ expectedStateHash: string;
56
+ emergencyStopVersion: number;
57
+ targetLevel: 'ask' | 'auto' | 'full';
58
+ }): unknown | Promise<unknown>;
59
+ loadModelPicker?(input: {
60
+ operationId: string;
61
+ callbackChatId: string;
62
+ cardMessageId: string;
63
+ bindingId: string;
64
+ principal: {
65
+ channel: string;
66
+ account: string;
67
+ tenant: string;
68
+ user: string;
69
+ };
70
+ }): ModelPickerIntent | undefined | Promise<ModelPickerIntent | undefined>;
71
+ advanceModelPicker?(input: {
72
+ operationId: string;
73
+ callbackChatId: string;
74
+ cardMessageId: string;
75
+ bindingId: string;
76
+ principal: {
77
+ channel: string;
78
+ account: string;
79
+ tenant: string;
80
+ user: string;
81
+ };
82
+ expected: ModelPickerState;
83
+ next: ModelRouteRef;
84
+ }): {
85
+ applied: boolean;
86
+ state: ModelPickerState;
87
+ } | Promise<{
88
+ applied: boolean;
89
+ state: ModelPickerState;
90
+ }>;
91
+ }
92
+ export declare class LarkDeliveryAdapter implements DeliveryAdapter {
93
+ private readonly config;
94
+ private readonly transport;
95
+ readonly channel = "lark";
96
+ readonly account: string;
97
+ readonly capabilities: DeliveryAdapter['capabilities'];
98
+ private readonly now;
99
+ private readonly onConnected;
100
+ private readonly onDisconnected;
101
+ private readonly approvalSecret;
102
+ private readonly settleApproval;
103
+ private readonly recoverApprovalSettlement;
104
+ private readonly settleModelSelection;
105
+ private readonly awaitModelSelection;
106
+ private readonly settlePermissionSelection;
107
+ private readonly loadModelPicker;
108
+ private readonly advanceModelPicker;
109
+ private readonly statusReactions;
110
+ private readonly userQuestionTtlMs;
111
+ private readonly progressPresenter;
112
+ private readonly progressCredentialFingerprint;
113
+ private readonly pendingToolApprovals;
114
+ private readonly pendingUserQuestions;
115
+ private readonly userQuestionAnswerEvents;
116
+ private readonly toolApprovalTombstones;
117
+ private readonly toolApprovalUpdates;
118
+ private closing;
119
+ private deliveryContext;
120
+ private presentationGeneration;
121
+ private readonly modelSelectionUpdates;
122
+ private readonly pendingAttachmentSends;
123
+ private state;
124
+ private gapGeneration;
125
+ private lastErrorCode;
126
+ constructor(config: LarkInboundConfig, transport: LarkTransport, options?: LarkAdapterOptions);
127
+ start(context: DeliveryAdapterContext): Promise<() => Promise<void>>;
128
+ /**
129
+ * WP20 intake: hand Delivery an observation (ids, booleans, a sha256 digest
130
+ * and the transient normalized text the digest covers). Optional on older
131
+ * Delivery cores and never allowed to affect acceptance.
132
+ */
133
+ /**
134
+ * Best-effort read acknowledgement for bot-authored DM messages.
135
+ *
136
+ * Delivery owns the monotonic receipt state; an unknown provider id (for
137
+ * example a message the bot sent before this process) is expected and must
138
+ * not escape the WebSocket handler. Duplicate ids in one event are collapsed.
139
+ */
140
+ private forwardReadReceipt;
141
+ private observeIntake;
142
+ health(): LarkChannelHealth;
143
+ private leaveConnected;
144
+ progress(intent: Readonly<DeliveryProgressIntent>): Promise<void>;
145
+ requestToolApproval(input: Readonly<DeliveryToolApprovalRequest>, signal: AbortSignal): Promise<DeliveryToolApprovalOutcome>;
146
+ requestUserQuestion(input: Readonly<DeliveryUserQuestionRequest>, signal: AbortSignal): Promise<DeliveryUserQuestionOutcome>;
147
+ readInboundImage(input: Readonly<InboundImageReadInput>, signal: AbortSignal): Promise<AdapterInboundImageReadResult>;
148
+ send(intent: Readonly<OutboundIntent>, signal: AbortSignal): Promise<AdapterSendResult>;
149
+ private rememberAttachmentFileMessage;
150
+ private markSentReaction;
151
+ private sendWithAttachment;
152
+ updatePresentation(providerMessageId: string, presentation: Readonly<DeliveryPresentation>, signal: AbortSignal): Promise<void>;
153
+ private matchesTarget;
154
+ private userQuestionCard;
155
+ private userQuestionAnswerSummary;
156
+ private userQuestionSendOptions;
157
+ private refreshUserQuestionCard;
158
+ private userQuestionResult;
159
+ private updateUserQuestionResult;
160
+ private settleUserQuestion;
161
+ private armUserQuestionExpiry;
162
+ private cancelPendingUserQuestions;
163
+ private recordUserQuestionAnswer;
164
+ private rememberUserQuestionAnswerEvent;
165
+ private clearUserQuestionAnswerEvents;
166
+ private tryAnswerUserQuestion;
167
+ private tryAnswerToolApproval;
168
+ private armToolApprovalTombstone;
169
+ private deleteToolApprovalTombstone;
170
+ private toolApprovalResult;
171
+ private updateToolApprovalResult;
172
+ private drainToolApprovalUpdates;
173
+ private settleToolApproval;
174
+ private cancelPendingToolApprovals;
175
+ private addReaction;
176
+ private recordPresentationFailure;
177
+ private cancelModelSelectionUpdates;
178
+ private startModelSelectionFinalUpdate;
179
+ private handleCardAction;
180
+ private handlePermissionPickerAction;
181
+ private handleToolApprovalAction;
182
+ private handleUserQuestionAction;
183
+ private handleModelPickerAction;
184
+ }
185
+ //# sourceMappingURL=adapter.d.ts.map