dscord 0.2.0-alpha.1 → 0.4.0-alpha.3

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 (231) hide show
  1. package/LICENSE +201 -0
  2. package/NOTICE +27 -0
  3. package/README.md +77 -49
  4. package/bin/dscord.mjs +5 -4
  5. package/central/README.md +144 -0
  6. package/central/avatars.md +74 -0
  7. package/central/avatars.mjs +105 -0
  8. package/central/directory.mjs +224 -0
  9. package/central/rules.mjs +51 -0
  10. package/central/service.mjs +362 -0
  11. package/central/store.mjs +400 -0
  12. package/central/tokens.mjs +63 -0
  13. package/cordis.patch.yml +3 -0
  14. package/deploy/synapse/dscord_guard.py +212 -0
  15. package/dist/admin/assets/index-B6oXrmH-.js +10 -0
  16. package/dist/admin/assets/index-C7fyavkW.css +1 -0
  17. package/dist/admin/assets/mark-128-C4ed4p0U.png +0 -0
  18. package/dist/admin/index.html +13 -0
  19. package/dist/admin/licenses/bundled-dependencies.txt +421 -0
  20. package/dist/admin/licenses/lucide.txt +43 -0
  21. package/dist/admin/licenses/ui-foundation.txt +336 -0
  22. package/dist/admin/theme.js +66 -0
  23. package/dist/central-admin/assets/index-C-slX89W.css +1 -0
  24. package/dist/central-admin/assets/index-C06XyvSK.js +9 -0
  25. package/dist/central-admin/assets/mark-128-C4ed4p0U.png +0 -0
  26. package/dist/central-admin/index.html +13 -0
  27. package/dist/central-admin/licenses/bundled-dependencies.txt +421 -0
  28. package/dist/central-admin/licenses/lucide.txt +43 -0
  29. package/dist/central-admin/licenses/ui-foundation.txt +336 -0
  30. package/dist/central-admin/theme.js +66 -0
  31. package/dist/web/assets/apple-touch-icon-C_qAgjR1.png +0 -0
  32. package/dist/web/assets/common-DGlCXKV6.js +5 -0
  33. package/dist/web/assets/favicon-32-CEKpvmlx.png +0 -0
  34. package/dist/web/assets/favicon-6aWeKmcy.ico +0 -0
  35. package/dist/web/assets/index-C5Owa1w-.js +55 -0
  36. package/dist/web/assets/index-Cr0sYP4g.css +1 -0
  37. package/dist/web/assets/{manifest-eq_1S_IC.webmanifest → manifest-Ca-bIZpP.webmanifest} +2 -8
  38. package/dist/web/assets/mark-128-C4ed4p0U.png +0 -0
  39. package/dist/web/assets/rolldown-runtime-XKyaHtl9.js +1 -0
  40. package/dist/web/client-config.json +3 -0
  41. package/dist/web/icons/apple-touch-icon.png +0 -0
  42. package/dist/web/icons/favicon-32.png +0 -0
  43. package/dist/web/icons/favicon.ico +0 -0
  44. package/dist/web/icons/icon-192.png +0 -0
  45. package/dist/web/icons/icon-512.png +0 -0
  46. package/dist/web/icons/mark-128.png +0 -0
  47. package/dist/web/index.html +9 -7
  48. package/dist/web/licenses/bundled-dependencies.txt +2452 -0
  49. package/dist/web/licenses/ui-foundation.txt +336 -0
  50. package/dist/web/manifest.webmanifest +2 -8
  51. package/dist/web/sw.js +233 -79
  52. package/dist/web/theme.js +27 -5
  53. package/dsh-connect/KERNEL.md +90 -0
  54. package/dsh-connect/client.js +29858 -0
  55. package/dsh-connect/controller.mjs +525 -0
  56. package/dsh-connect/decision-settings.mjs +111 -0
  57. package/dsh-connect/index.mjs +44 -0
  58. package/dsh-connect/kernel-runtime.mjs +120 -0
  59. package/dsh-connect/kernel-updates.mjs +243 -0
  60. package/dsh-connect/native-bots.mjs +93 -0
  61. package/dsh-connect/native-bridge.mjs +466 -0
  62. package/dsh-connect/native-connections.mjs +201 -0
  63. package/dsh-connect/native-team.mjs +63 -0
  64. package/dsh-connect/work-core.mjs +656 -0
  65. package/dsh-plugin/README.md +32 -31
  66. package/dsh-plugin/index.mjs +18 -11
  67. package/dsh-plugin/model-profile.mjs +73 -0
  68. package/dsh-plugin/runtime-dependencies-lock.json +696 -6
  69. package/dsh-plugin/runtime-dependencies-pnpm-lock.yaml +489 -0
  70. package/dsh-plugin/runtime-dependencies.json +7 -2
  71. package/dsh-plugin/runtime-rules.mjs +10 -2
  72. package/dsh-plugin/runtime.mjs +330 -45
  73. package/dsh-plugin/scoped-work.mjs +73 -0
  74. package/dsh-plugin/work-files.mjs +24 -5
  75. package/icon.png +0 -0
  76. package/memory/contacts.mjs +36 -0
  77. package/memory/ingress.mjs +57 -0
  78. package/memory/model-options.mjs +9 -0
  79. package/memory/native.mjs +374 -0
  80. package/memory/observation-policy.mjs +67 -0
  81. package/memory/ombre.mjs +165 -0
  82. package/memory/panel.mjs +88 -0
  83. package/memory/review.mjs +90 -0
  84. package/memory/service.mjs +443 -0
  85. package/memory/snapshot-context.mjs +95 -0
  86. package/memory/source-query.mjs +87 -0
  87. package/memory/store.mjs +351 -0
  88. package/memory/views.mjs +305 -0
  89. package/memory//345/244/215/347/224/250/344/270/216/350/277/220/350/241/214.md +47 -0
  90. package/memory//345/275/223/345/211/215/344/270/212/344/270/213/346/226/207/344/270/216/345/233/236/351/241/276.md +73 -0
  91. package/package.json +59 -7
  92. package/scripts/admin.mjs +41 -0
  93. package/scripts/dsh-node.mjs +92 -54
  94. package/scripts/memory-setup.mjs +21 -0
  95. package/scripts/runtime-config.mjs +55 -23
  96. package/scripts/runtime-dependencies.mjs +79 -0
  97. package/scripts/server-admin.mjs +25 -3
  98. package/scripts/server-bootstrap.mjs +55 -9
  99. package/scripts/server-init.mjs +92 -11
  100. package/scripts/service.mjs +39 -14
  101. package/service/ombre/LICENSE +21 -0
  102. package/service/ombre/SOURCE.json +15 -0
  103. package/service/ombre/controlled_store.py +295 -0
  104. package/service/ombre/harrier_profile.py +320 -0
  105. package/service/ombre/protocol.py +67 -0
  106. package/service/ombre/requirements.lock.txt +1100 -0
  107. package/service/ombre/semantic.py +449 -0
  108. package/service/ombre/service.py +204 -0
  109. package/src/accounts.mjs +292 -0
  110. package/src/admin-auth.mjs +246 -0
  111. package/src/admin-directory.mjs +69 -0
  112. package/src/admin.mjs +326 -0
  113. package/src/attachment-access.mjs +57 -0
  114. package/src/attention.mjs +140 -0
  115. package/src/bot-node.mjs +888 -75
  116. package/src/bot-work-policy.mjs +77 -0
  117. package/src/bot-work.mjs +276 -0
  118. package/src/budget.mjs +22 -7
  119. package/src/central-trust.mjs +53 -0
  120. package/src/collaboration.mjs +178 -0
  121. package/src/contact-book.mjs +301 -0
  122. package/src/core/attachment-routes.mjs +43 -0
  123. package/src/core/bot-routes.mjs +25 -0
  124. package/src/core/node-routes.mjs +66 -0
  125. package/src/core/room-routes.mjs +285 -0
  126. package/src/core/router.mjs +31 -0
  127. package/src/core/server-page.mjs +23 -0
  128. package/src/core/session-routes.mjs +69 -0
  129. package/src/core.mjs +157 -360
  130. package/src/decision-presets.mjs +47 -0
  131. package/src/decision-provider.mjs +185 -0
  132. package/src/file-formats.mjs +1 -1
  133. package/src/governance.mjs +424 -0
  134. package/src/http-json.mjs +19 -0
  135. package/src/identity.mjs +89 -0
  136. package/src/invites.mjs +71 -0
  137. package/src/kernel-control.mjs +419 -0
  138. package/src/kernel-node-client.mjs +164 -0
  139. package/src/matrix-client.mjs +70 -13
  140. package/src/media.mjs +50 -28
  141. package/src/mentions.mjs +28 -8
  142. package/src/message-context.mjs +115 -0
  143. package/src/model-config.mjs +51 -0
  144. package/src/model-failure.mjs +5 -0
  145. package/src/native-bindings.mjs +37 -0
  146. package/src/native-request.mjs +42 -0
  147. package/src/node-auth.mjs +60 -0
  148. package/src/node-delivery.mjs +3 -3
  149. package/src/node-files.mjs +29 -7
  150. package/src/node-protocol.mjs +99 -0
  151. package/src/node-store.mjs +606 -13
  152. package/src/node-work.mjs +43 -0
  153. package/src/participant-labels.mjs +9 -0
  154. package/src/profile-sync.mjs +89 -0
  155. package/src/push.mjs +23 -3
  156. package/src/room-media.mjs +122 -0
  157. package/src/synapse-control.mjs +409 -0
  158. package/src/tasks.mjs +19 -5
  159. package/src/verified-media.mjs +283 -0
  160. package/src/web-mode.mjs +9 -0
  161. package/vendor/ds-bot/NOTICE +86 -0
  162. package/vendor/ds-bot/UPSTREAM.json +83 -5
  163. package/vendor/ds-bot/client.js +15079 -9868
  164. package/vendor/ds-bot/index.js +6 -2
  165. package/vendor/ds-bot/package.json +9 -4
  166. package/vendor/ds-bot/src/host/approvals.js +54 -7
  167. package/vendor/ds-bot/src/host/browser/script-child.js +136 -0
  168. package/vendor/ds-bot/src/host/browser/script-runner.js +77 -0
  169. package/vendor/ds-bot/src/host/browser/script.js +1 -0
  170. package/vendor/ds-bot/src/host/browser/session.js +19 -29
  171. package/vendor/ds-bot/src/host/capabilities.js +6 -3
  172. package/vendor/ds-bot/src/host/channel.js +214 -54
  173. package/vendor/ds-bot/src/host/computer/catalog.js +91 -0
  174. package/vendor/ds-bot/src/host/computer/index.js +1213 -0
  175. package/vendor/ds-bot/src/host/computer/leases.js +71 -0
  176. package/vendor/ds-bot/src/host/connectors/catalog.js +96 -0
  177. package/vendor/ds-bot/src/host/connectors/gateway.js +264 -0
  178. package/vendor/ds-bot/src/host/connectors/index.js +863 -0
  179. package/vendor/ds-bot/src/host/connectors/mail/index.js +613 -0
  180. package/vendor/ds-bot/src/host/connectors/mail/presets.js +23 -0
  181. package/vendor/ds-bot/src/host/connectors/mail/transport.js +306 -0
  182. package/vendor/ds-bot/src/host/connectors/oauth.js +191 -0
  183. package/vendor/ds-bot/src/host/constants.js +1 -1
  184. package/vendor/ds-bot/src/host/context-failure.js +11 -0
  185. package/vendor/ds-bot/src/host/delivery.js +6 -3
  186. package/vendor/ds-bot/src/host/feed.js +10 -3
  187. package/vendor/ds-bot/src/host/groups.js +58 -16
  188. package/vendor/ds-bot/src/host/home-lock.js +103 -35
  189. package/vendor/ds-bot/src/host/im/format.js +190 -0
  190. package/vendor/ds-bot/src/host/im/index.js +943 -0
  191. package/vendor/ds-bot/src/host/im/platforms/dingtalk.js +207 -0
  192. package/vendor/ds-bot/src/host/im/platforms/discord.js +234 -0
  193. package/vendor/ds-bot/src/host/im/platforms/feishu.js +352 -0
  194. package/vendor/ds-bot/src/host/im/platforms/index.js +12 -0
  195. package/vendor/ds-bot/src/host/im/platforms/qq.js +216 -0
  196. package/vendor/ds-bot/src/host/im/platforms/slack.js +210 -0
  197. package/vendor/ds-bot/src/host/im/platforms/telegram.js +249 -0
  198. package/vendor/ds-bot/src/host/im/platforms/wecom.js +217 -0
  199. package/vendor/ds-bot/src/host/im/platforms/weixin.js +256 -0
  200. package/vendor/ds-bot/src/host/images.js +22 -7
  201. package/vendor/ds-bot/src/host/learning.js +27 -7
  202. package/vendor/ds-bot/src/host/legacy.mjs +4 -0
  203. package/vendor/ds-bot/src/host/local-agents/acp.js +232 -0
  204. package/vendor/ds-bot/src/host/local-agents/adapter.js +540 -0
  205. package/vendor/ds-bot/src/host/local-agents/claude.js +179 -0
  206. package/vendor/ds-bot/src/host/local-agents/codex.js +175 -0
  207. package/vendor/ds-bot/src/host/local-agents/discover.js +99 -0
  208. package/vendor/ds-bot/src/host/local-agents/engines.js +65 -0
  209. package/vendor/ds-bot/src/host/local-agents/index.js +235 -0
  210. package/vendor/ds-bot/src/host/local-agents/jsonrpc.js +111 -0
  211. package/vendor/ds-bot/src/host/local-agents/mcp.js +141 -0
  212. package/vendor/ds-bot/src/host/memory.js +14 -1
  213. package/vendor/ds-bot/src/host/message-source.js +56 -0
  214. package/vendor/ds-bot/src/host/parts.js +259 -48
  215. package/vendor/ds-bot/src/host/providers.js +142 -17
  216. package/vendor/ds-bot/src/host/resume.js +54 -4
  217. package/vendor/ds-bot/src/host/roster.js +25 -3
  218. package/vendor/ds-bot/src/host/schedules.js +101 -7
  219. package/vendor/ds-bot/src/host/steward.js +2 -1
  220. package/vendor/ds-bot/src/host/store.js +52 -5
  221. package/vendor/ds-bot/src/host/tools.js +102 -15
  222. package/vendor/ds-bot/src/host/turns.js +28 -5
  223. package/vendor/ds-bot/src/host/update.js +3 -0
  224. package/vendor/ds-bot/src/shared/im-platforms.js +86 -0
  225. package//346/250/241/345/236/213/351/205/215/347/275/256/344/270/216/350/277/201/347/247/273.md +99 -0
  226. package/dist/web/assets/apple-touch-icon-BVvy03qx.png +0 -0
  227. package/dist/web/assets/icon-C8lhqe5n.svg +0 -6
  228. package/dist/web/assets/index-D2MsIF_C.js +0 -20
  229. package/dist/web/assets/index-DpwihgYi.css +0 -1
  230. package/dist/web/icons/icon.svg +0 -6
  231. package/vendor/ds-bot/README.md +0 -258
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/NOTICE ADDED
@@ -0,0 +1,27 @@
1
+ DSCord
2
+ Copyright 2026 DSCord contributors
3
+
4
+ DSCord-specific source code and documentation in this package are licensed
5
+ under the Apache License, Version 2.0. See LICENSE.
6
+
7
+ Third-party components retain their own licenses and notices.
8
+
9
+ DS-Bot
10
+ The vendored kernel is based on DS-Bot 0.3.1 by Fei2411 and the DS Bot
11
+ contributors, under Apache-2.0. See vendor/ds-bot/LICENSE,
12
+ vendor/ds-bot/NOTICE and vendor/ds-bot/UPSTREAM.json for provenance,
13
+ additional third-party notices and the DSCord modifications.
14
+
15
+ Ombre
16
+ The optional memory service is distributed under its MIT license.
17
+ See service/ombre/LICENSE and service/ombre/SOURCE.json.
18
+
19
+ Web interfaces
20
+ Bundled UI and icon notices are in web/licenses/ and the corresponding
21
+ licenses/ directory in each prebuilt interface. Other installed dependencies
22
+ retain the licenses provided by their respective packages.
23
+
24
+ Avatar image processing
25
+ The installed sharp 0.35.5 dependency is licensed under Apache-2.0. Its
26
+ platform packages include libvips and their own third-party license notices;
27
+ retain those notices with the installed dependencies.
package/README.md CHANGED
@@ -1,87 +1,115 @@
1
- # DSCord
1
+ # DSCord 0.4.0-alpha.3 安装与连接
2
2
 
3
- 人类与独立 Bot 共同参与的聊天协作框架,原项目名为 DS-Group。npm 包包含 Node 服务端、预构建 React PWA、Matrix 接入器、DSH 桥接和固定 DS-Bot 0.2.7。
3
+ > [!WARNING]
4
+ > **实验性项目。** DSCord 目前是实验性质的项目,接口、数据格式和行为随时可能变化,不保证兼容旧版本。项目不考虑安全问题,因此将别人加入到你的服务器当中的时候,请确认你有线下找他喝茶的能力。
4
5
 
5
- 当前为 `0.2.0-alpha.1`,使用 `alpha` 标签发布。服务器发行目标为 Linux amd64/arm64,要求 Node 24.19.0 及以上的 24.x。Bot 节点另外需要 DSH 0.2.1-rc.5 和 `opencode-go/deepseek-v4.1-flash` 模型配置。
6
+ DSCord 的 npm 包包含 Core、预构建网页/PWA、Matrix 适配器和 DSCord Bot 内核。完整服务器源码发行包另含 Compose 部署文件;同一部署的 Core、客户端和节点使用同一发行版本。
7
+
8
+ 本指南对应预发布版本 0.4.0-alpha.3,npm registry 和该版本的 GitHub Release 均提供安装包。Node 支持范围由 [package.json](package.json) 声明为 `>=24.19.0 <25`。Bot 宿主固定使用 DSH `0.2.2-rc.1` 的 SDK 契约,见[内核说明](dsh-connect/KERNEL.md)。Docker 服务器无需在宿主另装 Node。
6
9
 
7
10
  ## 安装
8
11
 
12
+ 从发行页下载 `dscord-0.4.0-alpha.3.tgz` 后,可在 DSH 的 `Plugins → Add plugin` 中安装并启用 `dscord`,再登录服务器连接 Bot。发行页同时提供 `SHA256SUMS` 校验文件。[下载发行包](https://github.com/MixGeekers/dscord/releases/tag/ds-group-v0.4.0-alpha.3)
13
+
14
+ 全局安装 CLI 用于服务器与独立节点管理。从 npm registry 安装当前版本,安装后核对 `dscord --version`。
15
+
9
16
  ```sh
10
- npm install --global dscord@alpha
17
+ npm install --global dscord@0.4.0-alpha.3
11
18
  dscord --help
12
19
  dscord --version
13
20
  ```
14
21
 
15
- 服务端与网页已经随包提供。运行时通过 `DS_GROUP_DATA_DIR` 指定数据目录,默认使用执行命令时所在目录下的 `.dscord`。在多个终端管理同一实例时,设置相同的绝对数据路径。`DS_GROUP_*` 是当前配置接口。
22
+ Core、CLI 和 DSH 插件使用同一发行版本。已有全局安装可用上述命令升级。当前预发布版本使用 `alpha` 标签,也可执行 `npm install --global dscord@alpha` 升级到最新 Alpha。[npm 包页面](https://www.npmjs.com/package/dscord/v/0.4.0-alpha.3)
16
23
 
17
- ## 启动本机服务器
18
-
19
- 以下步骤使用 Docker 运行独立 Synapse,核心通过 Node 启动。先安装 Docker Engine 并启动 Docker 服务。
24
+ 从源码构建 npm 包,在 `apps/ds-group/` 中执行:
20
25
 
21
26
  ```sh
22
- export DS_GROUP_DATA_DIR="$HOME/.local/share/dscord"
23
- export DS_GROUP_SERVER_NAME=localhost
24
- export DS_GROUP_MATRIX_URL=http://127.0.0.1:18008
25
- export DS_GROUP_MATRIX_PUBLIC_URL=http://localhost:18008
26
- export DS_GROUP_PUBLIC_URL=http://localhost:18100
27
- dscord init
28
-
29
- docker run --detach --name dscord-synapse \
30
- --user "$(id -u):$(id -g)" \
31
- --publish 127.0.0.1:18008:8008 \
32
- --mount "type=bind,source=$DS_GROUP_DATA_DIR/synapse,target=/data" \
33
- ghcr.io/element-hq/synapse@sha256:f0df87cff259872637b4b5e5174b9977e5e3046dd421505407803b5e45c5f842
27
+ npm ci --ignore-scripts
28
+ npm run npm:pack
34
29
  ```
35
30
 
36
- 等待 Synapse 的 `http://127.0.0.1:18008/_matrix/client/versions` 返回成功,再执行。
31
+ 该版本默认生成 `.local/npm-release/dscord-0.4.0-alpha.3.tgz`,仍应核对命令实际输出的版本、路径与校验值。构建需要开发依赖,运行已提供的预构建包不需要重新构建界面。
32
+
33
+ ## 部署服务器
34
+
35
+ 完整服务器采用[Compose 部署指南](https://github.com/MixGeekers/dscord/blob/ds-group-v0.4.0-alpha.3/apps/ds-group/deploy/README.md),先配置自己的 Matrix 身份域、公开地址和持久存储。npm CLI 不代替 Synapse 或反向代理。需要 `dscord server`、初始化及节点导入等命令时,在各终端保持同一个绝对数据路径:
37
36
 
38
37
  ```sh
39
- dscord bootstrap
40
- dscord admin credentials alice
41
- dscord server
38
+ export DS_GROUP_DATA_DIR="$HOME/.local/share/dscord-server"
39
+ dscord --version
42
40
  ```
43
41
 
44
- 浏览器访问 `http://localhost:18100`,使用上一步在管理员终端显示的 Alice 登录信息。初始化会创建 Alice、Bob、财务和人事四个独立成员。Bot 在各自节点接入后上线。服务端通过 `Ctrl+C` 停止,Synapse 可通过 `docker stop dscord-synapse` 停止,并通过 `docker start dscord-synapse` 再次启动。
42
+ 上面的路径可自行替换。npm CLI 未设置数据目录时使用当前工作目录下的 `.dscord/`,在不同目录执行管理命令可能选中不同实例。
43
+
44
+ ## 在 DSH 中连接
45
+
46
+ 1. 准备固定基线的官方 CLI,或提供相同 SDK 服务的 DSH 宿主。CLI 可执行 `npm install --global @deepseek-ai/dsh@0.2.2-rc.1`。在 DSH 中配置自己的业务模型和凭据。
47
+ 2. 安装同版本 `dscord` 插件并启用。
48
+ 3. 在 DSCord 网页点“添加 Bot”,填名字(职责和模型可选),点“创建 Bot”。中央为它建 Bot 账号并保存设置。
49
+ 4. 对话框给出连接密钥时点“复制连接密钥”(也可以在“设置 → 账号 → 连接 DSH”里生成),打开 DSH 左侧的 **DSCord** 粘贴,粘贴后自动连接。DSH 会从密钥里的服务器发现它接入的中央并登录,随后按中央的设置创建本机 Bot、完成设备码授权并让它上线,网页上的状态变成“在线”。
50
+ 5. 之后的设置都在网页“我的 Bot”里:改名字、职责、模型和运行设备,让 Bot 加入或退出当前服务器。要让 Bot 也进其他聊天服务器,打开那台服务器的网页(它必须接入同一个中央),在“我的 Bot”里点“加入这台服务器”。
51
+ 6. 在网页打开私聊或邀请 Bot 进入需要参与的群聊。参与方式、来源记忆和当前工作在 Bot 的状态主页中查看。
52
+
53
+ 地址、账号、模型和路径都来自部署者自己的配置。业务模型没有指定服务商;自然参与的单独判断服务是可选功能,见[模型与参与设置](模型配置与迁移.md)。
54
+
55
+ Core 提供的 Matrix 公开地址必须能从节点访问。一个连接页使用一个归属账号,可管理多个本机 Bot。连接数据默认位于实际 DSH home 的 `dscord/<profile>/`,Bot 数据保留在该 home 的 `bot/`。断开服务器、退出连接页或关闭网页不删除本机 Bot;DSH 停止后,Bot 也无法继续工作。
45
56
 
46
- HTTPS、Docker Compose、备份恢复与 systemd 的完整部署流程见源码仓库中的部署指南。手机 PWA 安装和通知需要可信 HTTPS。[服务器部署指南](https://github.com/MixGeekers/ds_group/blob/main/apps/ds-group/deploy/README.md)
57
+ 决策服务在 DSH 的 DSCord 页面配置,提供 OpenAI Decisions、TypeSafe Jev、Cloudflare Clef / Clef Flash 预设。不同服务分别保存凭据;Cloudflare 默认地址还需要 Account ID。保存时使用合成输入检查参与判断和接话协议,连接检查不代表真实聊天判断质量。[决策服务配置](模型配置与迁移.md#决策模型)
47
58
 
48
- ## 连接 Bot 节点
59
+ ## 自定义头像
49
60
 
50
- 先按服务器部署指南配置 HTTPS 反向代理,使核心 API 和 Matrix API 可从 Bot 机器访问。然后将 `DS_GROUP_PUBLIC_URL` 和 `DS_GROUP_MATRIX_PUBLIC_URL` 配置为对应的外部地址,再执行 `dscord init` 和 `dscord bootstrap` 更新地址。使用目标 Bot 的名称导出节点配置。
61
+ 在个人设置中更换自己的头像,或在所属 Bot 的设置中更换 Bot 头像;支持裁剪、预览和恢复默认,Bot 离线时也可修改。头像保存在中央数据目录的 `avatars/` 中,Core 自动同步到各聊天服务器。备份中央时同时保留数据库、签名密钥和头像目录。[头像配置与备份](central/avatars.md)
62
+
63
+ ## 升级和已有 Bot
64
+
65
+ 先备份服务器数据和各 DSH Bot home,再停止当前工作并升级到同一发行版本。已有 `ds-bot` 插件必须先停用,DSCord 才能在同一目录接管;同时启动两个内核会报冲突。接管会保存迁移快照,保留 Bot 与 Session 身份。[生命周期与迁移](https://github.com/MixGeekers/dscord/blob/ds-group-v0.4.0-alpha.3/apps/ds-group/deploy/kernel-runtime.md)
66
+
67
+ 旧服务器 Bot 可在连接页绑定已有本机 Bot,保留 Matrix 身份;两套独立 Session 或记忆不会自动合并。已有原生绑定的 Bot 应从所属 DSH 连接,导出其配置不能在另一台机器创建身份副本。
68
+
69
+ ## 独立 CLI 节点
70
+
71
+ CLI 适用于没有已有原生绑定的独立 Bot。已绑定本机 Bot 的成员必须使用所属 DSH 的连接页,启动器会拒绝复制其身份。
72
+
73
+ 在服务器端导出目标 Bot,参数使用完整 Matrix ID 中 `@` 与 `:` 之间的账号部分,不是显示名称:
51
74
 
52
75
  ```sh
76
+ BOT_ACCOUNT='your-bot-account'
53
77
  umask 077
54
- dscord admin export-node finance > finance-node.json
78
+ dscord admin export-node "$BOT_ACCOUNT" > bot-node.json
55
79
  ```
56
80
 
57
- 将配置文件传到 Bot 机器,在该机器安装 `dscord@alpha` 和 DSH,再执行。
81
+ 将私有导出文件传到节点,安装同版本程序和兼容 DSH。以下数据目录、空闲端口、来源 profile 和 `provider/model-id` 均须替换为自己的配置:
58
82
 
59
83
  ```sh
60
- npm install --global @deepseek-ai/dsh@0.2.1-rc.5
61
- export DS_GROUP_DATA_DIR="$HOME/.local/share/dscord-finance"
62
- dscord admin import-node finance-node.json "$DS_GROUP_DATA_DIR"
63
- read -r -s OPENCODE_API_KEY
64
- export OPENCODE_API_KEY
65
- dscord service up finance
84
+ BOT_ACCOUNT='your-bot-account'
85
+ export DS_GROUP_DATA_DIR="$HOME/.local/share/dscord-nodes/$BOT_ACCOUNT"
86
+ export DS_GROUP_BRIDGE_PORT=23100
87
+ dscord admin import-node bot-node.json "$DS_GROUP_DATA_DIR"
88
+ export DS_GROUP_DSH_SOURCE_HOME='/absolute/path/to/your/dsh-home'
89
+ export DS_GROUP_DSH_SOURCE_PROFILE='your-profile'
90
+ export DS_GROUP_MODEL='provider/model-id'
91
+ dscord service up "$BOT_ACCOUNT"
66
92
  ```
67
93
 
68
- `OPENCODE_API_KEY` 在本地终端输入。人事节点使用 `hr` 及独立数据目录。使用以下命令停止财务节点及其 DSH。
94
+ 若 DSH 不在 PATH,用 `DS_GROUP_DSH_CLI` 指定可执行文件、`DS_GROUP_DSH_RUNTIME` 指定实际 SDK 包根或安装前缀。启动器按锁准备自己的运行依赖,不需要手工复制库目录。独立节点会复制所选模型配置所需的凭据到私有数据目录,行为与直接复用宿主的图形节点不同。[模型与凭据](模型配置与迁移.md)
95
+
96
+ 在同一组环境变量下停止:
69
97
 
70
98
  ```sh
71
- dscord service down finance
72
- dscord dsh stop finance
99
+ dscord service down "$BOT_ACCOUNT"
100
+ dscord dsh stop "$BOT_ACCOUNT"
73
101
  ```
74
102
 
75
- 当前 npm 入口提供 CLI 部署。DSH 桌面“添加插件”中的直接安装与自动接入仍待实现。
103
+ 每个 Bot 同时运行一个节点,每个独立节点使用自己的数据目录和桥接端口。Linux 常驻服务见 [systemd](https://github.com/MixGeekers/dscord/blob/ds-group-v0.4.0-alpha.3/apps/ds-group/deploy/systemd/README.md)。
104
+
105
+ ## 存储与组件
106
+
107
+ 附件默认使用 Synapse 本地媒体目录,可选 S3-compatible 后端。[存储配置](https://github.com/MixGeekers/dscord/blob/ds-group-v0.4.0-alpha.3/apps/ds-group/deploy/storage/README.md)说明远端对象、缓存和备份关系;已有云盘扫描与历史迁移不是自动功能。
108
+
109
+ `dscord server` 运行 Core/PWA,`init` 和 `bootstrap` 初始化服务器,`admin` 管理导出与导入,`node` 运行 Matrix 适配器,`dsh` 管理独立宿主,`service` 管理本机进程,`path` 显示安装目录。
76
110
 
77
- ## 包内组件
111
+ DS-Bot 的 Apache-2.0 LICENSE 与 NOTICE 位于 `vendor/ds-bot/`,界面图标许可随 `dist/web/licenses/` 提供。
78
112
 
79
- - `dscord server` 启动核心 API 和预构建 PWA。
80
- - `dscord init` 与 `dscord bootstrap` 管理服务器初始化和 Matrix 成员。
81
- - `dscord admin` 读取账号、导出和导入节点配置。
82
- - `dscord node` 运行 Matrix 适配进程。
83
- - `dscord dsh` 管理独立 DSH 运行时。
84
- - `dscord service` 管理本机核心和 Bot 进程。
85
- - `dscord path` 显示安装目录。
113
+ ## 许可证
86
114
 
87
- 上游 DS-Bot 的 Apache-2.0 LICENSE 与 NOTICE 位于 `vendor/ds-bot/`。Lucide 的 ISC 与 Feather MIT 许可位于 `dist/web/licenses/lucide.txt`。
115
+ DSCord 自有代码和文档采用 Apache-2.0。安装包包含本体许可及第三方声明,预构建界面的依赖许可位于各自的 `licenses/` 目录。[LICENSE](LICENSE) · [NOTICE](NOTICE)
package/bin/dscord.mjs CHANGED
@@ -17,8 +17,8 @@ const entries = new Map([
17
17
  ]);
18
18
  const help = `Usage: dscord <command> [arguments]
19
19
 
20
- server Run the core server and PWA
21
- init Prepare server and Synapse configuration
20
+ server Run the core server in its configured web mode
21
+ init [--web-mode MODE] Prepare configuration (MODE: bundled or api-only)
22
22
  bootstrap Register initial members on the configured Synapse
23
23
  admin <arguments> Manage server credentials and node exports
24
24
  node <arguments> Run a Matrix Bot adapter
@@ -29,6 +29,7 @@ const help = `Usage: dscord <command> [arguments]
29
29
  help Show this help
30
30
 
31
31
  DS_GROUP_DATA_DIR defaults to .dscord in the current directory.
32
+ DS_GROUP_WEB_MODE overrides web hosting; init persists it in core-config.json.
32
33
  `;
33
34
 
34
35
  async function run() {
@@ -48,10 +49,10 @@ async function run() {
48
49
  const entry = entries.get(command);
49
50
  if (!entry) throw new Error(`Unknown command "${command}". Run dscord help.`);
50
51
  if (command === 'service' && ['up', 'down', 'restart'].includes(args[0]) && !args[1]) {
51
- throw new Error('Choose a service component explicitly: all, core, finance, or hr.');
52
+ throw new Error('Choose a service component explicitly: all, core, or a local Bot account name.');
52
53
  }
53
54
  if (command === 'dsh' && args.length < 2) {
54
- throw new Error('Use dscord dsh <start|run|stop|status|prepare> <finance|hr>.');
55
+ throw new Error('Use dscord dsh <start|run|stop|status|prepare> <bot-account>.');
55
56
  }
56
57
 
57
58
  const env = { ...process.env };
@@ -0,0 +1,144 @@
1
+ # DSCord Central(中央服务器)
2
+
3
+ 中央服务器管四件事:账号、签发身份、服务器索引,以及每个人名下 Bot 的设置和运行它们的设备。它保存账号头像等身份资料,不存聊天消息和任务附件,不转发聊天,也不持有任何 Matrix token。聊天服务器(Core + Synapse)接入一台中央,人和 Bot 都用中央账号登录聊天服务器。整体方案见项目文档《DSCord 中央身份与聊天服务器方案》。
4
+
5
+ 已经完成:账号、账号规则、身份令牌、Bot 节点授权(第一期),聊天服务器只认中央账号(第二期,见下文“聊天服务器怎样接入”),服务器索引和中央管理面板(第四期,见下文“服务器索引”和“管理面板”)。
6
+
7
+ ## 运行
8
+
9
+ ```sh
10
+ npm run central
11
+ ```
12
+
13
+ 数据目录默认是 `.local/central/`,可用 `DSCORD_CENTRAL_DATA_DIR` 指定;监听地址用 `DSCORD_CENTRAL_HOST`(默认 `127.0.0.1`)和 `DSCORD_CENTRAL_PORT`(默认 `18200`)。配置文件是数据目录下的 `central-config.json`,或由 `DSCORD_CENTRAL_CONFIG_PATH` 指定:
14
+
15
+ ```json
16
+ {
17
+ "issuer": "https://id.example.org",
18
+ "registration": "open",
19
+ "listing": "review",
20
+ "admins": ["alice"],
21
+ "usernameRule": { "minLength": 3, "maxLength": 32, "reserved": ["admin", "root", "system", "dscord", "central"] },
22
+ "clientOrigins": ["https://client.example.org"]
23
+ }
24
+ ```
25
+
26
+ - `issuer`:中央的公开地址,必须是 HTTPS 的裸 origin(本机调试可用 `http://localhost`)。
27
+ - `domain`:全局身份 ID 里 `@` 后面的部分,默认取 `issuer` 的主机名。
28
+ - `registration`:`open` 允许自助注册,`closed` 关闭。
29
+ - `listing`:新登记的聊天服务器怎么处理。`review`(默认)等管理员审核后才上架,`open` 读到页面就直接上架。
30
+ - `admins`:中央管理员的用户名列表。管理员用自己的中央账号登录 `/admin` 管理面板。
31
+ - `registration` 和 `listing` 只是初始值:管理员在面板里改过之后,以面板里保存的为准(存在 `central.sqlite`)。
32
+ - `usernameRule`:账号规则,见下。
33
+ - `clientOrigins`:允许跨域调用中央接口的网页客户端 origin。
34
+ - `serverFetchUrls`:可选,`{ "聊天服务器 origin": "中央实际访问的地址" }`。中央所在网络访问不到某台聊天服务器的公开地址时(例如同一个 Compose 里),索引改从这里读它的公开页面。
35
+
36
+ 配置文件不存在时,可以用环境变量 `DSCORD_CENTRAL_ISSUER`、`DSCORD_CENTRAL_REGISTRATION`、`DSCORD_CENTRAL_LISTING`、`DSCORD_CENTRAL_ADMINS`(逗号分隔的用户名)、`DSCORD_CENTRAL_CLIENT_ORIGINS`(逗号分隔)、`DSCORD_CENTRAL_SERVER_FETCH_URLS`(逗号分隔的 `origin=地址`)在第一次启动时生成它;之后以文件为准,改环境变量不再生效。Compose 自带的 `central` 服务就是这样启动的。
37
+
38
+ 数据目录里的 `signing-key.json` 是签名私钥(权限 `0600`),`central.sqlite` 是账号库。备份时两者都要保留;换掉私钥后,聊天服务器要重新读取公钥。
39
+
40
+ ## 自定义头像
41
+
42
+ 用户可修改自己和名下 Bot 的头像,跨服务器同步,Bot 离线时也可设置。默认复用中央数据卷;入口、配置、备份和接口见[自定义头像](avatars.md)。
43
+
44
+ ## 账号格式
45
+
46
+ 账号规则由中央在配置里指定,并公开在 `GET /.well-known/dscord/central` 的 `usernameRule` 里。聊天服务器和客户端只读这份规则。
47
+
48
+ - 全局身份 ID 是 `用户名@domain`,例如 `alice@id.example.org`;在某台聊天服务器上的地址是 `@用户名:聊天服务器域名`。
49
+ - 用户名会直接当 Matrix 本地名用,所以中央的规则总是和 Matrix 本地名字符集(小写 a-z、0-9 和 `. _ = - /`)取交集:`pattern` 写得再宽,也收不进 Matrix 不接受的字符。`maxLength` 最多 64。
50
+ - 默认规则:3 到 32 个字符,小写字母开头,只含 a-z、0-9 和 `. _ -`。输入不分大小写,一律存小写。
51
+ - 用户名注册后不能改;账号注销后用户名也不回收。显示名可以改。
52
+ - 人和 Bot 共用同一个命名空间,是否 Bot 看账号类型。
53
+
54
+ ## 接口
55
+
56
+ 除注明外,接口用 `Authorization: Bearer <中央会话令牌>`。错误返回 `{ error, code }`。
57
+
58
+ | 接口 | 谁用 | 作用 |
59
+ | --- | --- | --- |
60
+ | `GET /.well-known/dscord/central` | 任何人 | 中央地址、账号规则、公钥地址、令牌有效期 |
61
+ | `GET /.well-known/jwks.json` | 聊天服务器 | 验证身份令牌的公钥 |
62
+ | `POST /api/register` | 人 | `{username, password, displayName?}` 注册并登录(`registration: open` 时) |
63
+ | `POST /api/login` / `POST /api/logout` | 人 | 密码登录 / 退出当前会话 |
64
+ | `GET /api/me` / `DELETE /api/me` | 人、Bot 节点 / 人 | 查看自己 / 注销(名下还有 Bot 时要先注销 Bot) |
65
+ | `POST /api/identity-tokens` | 人、Bot 节点 | `{audience, allowNew?}` 为某台聊天服务器(HTTPS origin)签发 5 分钟有效的身份令牌;第一次去某台服务器时要带 `allowNew: true`,否则返回 `GRANT_REQUIRED` |
66
+ | `GET /api/grants` / `DELETE /api/grants/:audience` | 人、Bot 节点 | 查看 / 撤销自己授权过的聊天服务器 |
67
+ | `POST /api/connect-codes` | 人 | 生成 DSH 连接用的一次性代码(10 分钟有效)。聊天服务器网页把它和服务器地址一起编码成连接密钥 |
68
+ | `POST /api/connect-codes/redeem` | DSH 插件(不用令牌) | `{code, label?}` 用代码换取这个人的中央会话;只能换一次,过期返回 `CONNECT_CODE_EXPIRED`,未知或已用返回 `CONNECT_CODE_UNKNOWN` |
69
+ | `POST /api/bots` / `GET /api/bots` / `DELETE /api/bots/:id` | 人 | 创建 / 列出 / 注销自己名下的 Bot。创建时给 `{displayName, username?, role?, model?, effort?, deviceId?, servers?}`,不给 `username` 时由名字生成;返回的每个 Bot 带 `settings`(`role`、`model`、`effort`、`deviceId`、`servers`、`revision`)和 `runtime`(运行它的设备是否在线,以及设备最近报告的 `revision`、`model`、`error`、各服务器的连接状态;还没有设备时是 `null`) |
70
+ | `PATCH /api/bots/:id` | 人 | 修改名字和上面的设置,只改给出的字段,`revision` 加一。`model` 为空表示跟随设备默认,`servers` 是 Bot 要加入的聊天服务器(HTTPS origin,最多 32 个),`deviceId` 必须是自己的设备 |
71
+ | `GET /api/devices` | 人 | 自己连接过的 DSH:`id`、`label`、是否在线(30 秒内报告过)、它能用的模型目录和插件版本 |
72
+ | `POST /api/devices/:id/sync` | DSH 插件(用连接密钥换来的会话) | `{label, report}` 报告这台设备的模型目录、插件版本和各 Bot 的状态,返回分给它的 Bot 和设置。还没有设备的 Bot 归第一台报告的设备;同一台 DSH 换了人登录时,前一个人的 Bot 回到等待 |
73
+ | `DELETE /api/devices/:id` | 人、DSH 插件 | 移除设备:它名下的 Bot 等下一台设备接手,设备报告用的会话同时结束 |
74
+ | `GET /api/bots/:id/grants`、`DELETE /api/bots/:id/grants/:audience` | Bot 的所属人 | 查看 / 撤销 Bot 的服务器授权 |
75
+ | `GET /api/bots/:id/nodes`、`DELETE /api/bots/:id/nodes/:nodeId` | Bot 的所属人 | 查看 / 撤销 Bot 的节点 |
76
+ | `POST /api/device` | Bot 节点 | `{label?}` 开始设备码授权,返回 `deviceCode`、`userCode`(10 分钟有效) |
77
+ | `POST /api/device/approve` | Bot 的所属人 | `{userCode, botId}` 把这个节点授权给自己的 Bot |
78
+ | `POST /api/device/token` | Bot 节点 | `{deviceCode}` 换取 Bot 的节点会话;所属人批准前返回 `AUTHORIZATION_PENDING`,只能换一次 |
79
+ | `GET /api/servers?q=&tag=&limit=` | 任何人(不用令牌,允许任意网页跨域) | 搜索服务器索引;`q` 是 8 位数字时按服务器号精确查找 |
80
+ | `POST /api/servers` | 任何人(不用令牌) | `{origin}` 把一台聊天服务器报给索引。中央去读它的公开页面,返回 `{server: {origin, number, status, note, discovery}}`;再报一次会重新读取页面、返回当前状态 |
81
+ | `GET /api/admin/overview` | 中央管理员 | 待审、已上架等数量,账号数量,当前设置 |
82
+ | `POST /api/admin/settings` | 中央管理员 | `{registration?, listing?}` 修改注册和登记审核设置 |
83
+ | `GET /api/admin/servers?status=` | 中央管理员 | 索引里的全部服务器(含待审、驳回、封禁),可按状态筛选 |
84
+ | `POST /api/admin/servers/:origin/decision` | 中央管理员 | `{status: listed\|rejected\|banned, note?}` 上架、驳回或封禁,留言会随下次登记带回给该服务器 |
85
+ | `POST /api/admin/servers/:origin/refresh` / `DELETE /api/admin/servers/:origin` | 中央管理员 | 立即重新读取 / 从索引里移除(收回服务器号) |
86
+ | `GET /api/admin/accounts?q=&kind=&status=` | 中央管理员 | 按用户名或显示名查账号 |
87
+ | `POST /api/admin/accounts/:id/disable` / `enable` | 中央管理员 | 停用(立即结束它的所有会话,不能再登录或拿身份令牌)/ 恢复账号;不能停用自己 |
88
+
89
+ ## 服务器索引
90
+
91
+ 索引只记每台聊天服务器自己公开的介绍,不存它的成员、房间和消息。
92
+
93
+ - 登记:聊天服务器把自己的 origin 报给中央(管理后台“服务器目录”里点一次“登记到中央”),不需要任何中央账号。中央从这个 origin 读 `GET /.well-known/dscord/server`,页面写明信任的中央就是自己、`origin` 也对得上,就收下这台服务器。
94
+ - 为什么不需要账号:页面是从这个 origin 读到的,又点名信任这台中央,本身就说明控制这个域名的人愿意被登记。聊天服务器在中央不持有任何凭据,也没有“所属人”;要改介绍就改自己的策略,中央下次读取时更新;不想被找到就把发现方式改成 `hidden`。
95
+ - 审核:新服务器默认是“待审核”,中央管理员在管理面板里上架、驳回或封禁,可以附一句留言。`listing: open` 时读到页面就直接上架。被驳回的服务器再登记一次会回到待审核;被封禁的再登记会被拒绝(`SERVER_BANNED`),直到管理员解除封禁。只有已上架的服务器能被搜到。
96
+ - 服务器号:第一次登记时,中央随机分配一个 8 位数字作为服务器号(像 QQ 群号),之后一直不变;管理员把它从索引里移除后再登记会拿到新号码。
97
+ - 发现方式由聊天服务器自己决定(页面里的 `discovery`):`public` 能被关键词搜到,也能凭号码找到;`number` 关键词搜不到,只能输入完整号码找到;`hidden` 搜不到也查不到号码,中央管理员仍能在面板里看到。
98
+ - 加入方式也由聊天服务器决定(`join`):`open` 任何中央账号都能直接加入,`invite` 只接受凭邀请码加入。中央只把它显示在搜索结果里,真正的检查在聊天服务器上。
99
+ - 刷新:中央每小时重新读一遍待审和已上架的服务器(读取不跟随跳转,页面上限 64 KB)。页面读不到或改信任别的中央时,保留上次的介绍并记下错误;连续三天没读到成功的页面,就从搜索结果里消失,读到后自动恢复。发现方式的改动在下次读取后生效。
100
+ - 搜索:只列已上架、三天内读到过的服务器。`q` 是 8 位数字时先按号码精确查找(`public` 和 `number` 的服务器);否则只搜 `public` 的服务器,`q` 里的每个词都要出现在名称、简介或标签里(不分大小写),按人数排序;`tag` 按标签精确筛选;`limit` 默认 20,最多 50。结果含服务器号和加入方式。
101
+
102
+ 公开页面的格式(`schemaVersion: 1`):
103
+
104
+ ```json
105
+ {
106
+ "schemaVersion": 1,
107
+ "central": "https://id.example.org",
108
+ "origin": "https://chat.example.org",
109
+ "discovery": "public",
110
+ "name": "机器人社",
111
+ "description": "机械臂和小车",
112
+ "tags": ["robots"],
113
+ "join": "invite",
114
+ "members": { "people": 12, "bots": 3 }
115
+ }
116
+ ```
117
+
118
+ `origin` 必须和登记的 origin 一致;`name` 最多 80 字,`description` 最多 500 字,`tags` 最多 10 个、每个最多 32 字。
119
+
120
+ ## 管理面板
121
+
122
+ 中央自己在 `/admin` 提供管理面板(构建产物在 `dist/central-admin`,可用 `DSCORD_CENTRAL_ADMIN_WEB_DIR` 指定别的目录)。用配置里 `admins` 列出的中央账号登录,其他账号会被拒绝。面板有四页:
123
+
124
+ - 概览:待审核和已上架的服务器数、人和 Bot 的账号数、当前设置。
125
+ - 服务器:按状态(待审核、已上架、已驳回、已封禁)查看所有登记过的服务器,看它的介绍、发现方式、加入方式、人数和最近一次读取结果;可以上架、驳回、封禁、解除封禁、立即重新读取或移除,并给该服务器的管理员留言。
126
+ - 账号:按用户名或显示名、类型、状态查账号,停用或恢复。
127
+ - 设置:新服务器要不要先审核,账号注册是否开放。
128
+
129
+ 管理员名单只能在配置文件里改,面板里不能增删。
130
+
131
+ ## 身份令牌
132
+
133
+ 身份令牌是 Ed25519 签名的 JWT(`alg: EdDSA`),声明包括 `iss`、`sub`(账号编号)、`aud`(聊天服务器 origin)、`iat`、`exp`、`jti`、`username`、`gid`(全局身份 ID)、`kind`(`human` 或 `bot`)、`name`(显示名),Bot 另有 `owner`(所属人的全局身份 ID)。聊天服务器用 `central/tokens.mjs` 的 `verifyIdentityToken` 按中央公钥、`issuer` 和自己的 origin 校验。一张令牌只对写明的那台聊天服务器有效。
134
+
135
+ 撤销授权后,中央不再为那台服务器签发令牌;聊天服务器的本地会话是短期的,续期时要重新拿令牌,因此撤销会在一个会话周期内生效。
136
+
137
+ ## 聊天服务器怎样接入
138
+
139
+ 聊天服务器(Core)在 `core-config.json` 的 `identity.central` 写中央地址(初始化时取 `DS_GROUP_CENTRAL_URL`),并把自己的 `publicUrl` 当作令牌的 `aud`。Core 从中央读 `/.well-known/dscord/central` 和公钥,遇到新的签名密钥时重新读一次。容器网络里 Core 访问中央的地址和中央的公开地址不同时,用 `DS_GROUP_CENTRAL_FETCH_URL` 指定前者;令牌里的 `iss` 仍是公开地址。
140
+
141
+ - 登录:客户端在中央拿到身份令牌,交给 Core 的 `POST /api/session {identityToken}`,换回这台服务器的会话。Core 没有注册、密码登录和演示登录接口。
142
+ - 账号对应:中央用户名就是 Matrix 本地名。账号第一次登录时 Core 在 Synapse 建同名用户;已有的同名初始化成员由这个中央账号认领,之后只认它。
143
+ - Bot:Bot 的身份令牌带 `owner`,Core 据此把 Bot 记在所属人名下。Bot 节点用自己的会话调 `POST /api/bots/:id/connect` 拿节点配置,并报告它在哪个 DSH 宿主上(`native`)。
144
+ - 发现:`GET /.well-known/dscord/client` 的 `central.issuer` 告诉客户端去哪台中央登录,`auth.audience` 是申请身份令牌时要写的 `audience`。没有配置中央的 Core 返回 `central: null`,登录接口返回 503。