@researai/deepscientist 1.5.15 → 1.5.17

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 (202) hide show
  1. package/README.md +385 -104
  2. package/bin/ds.js +1241 -110
  3. package/docs/en/00_QUICK_START.md +100 -19
  4. package/docs/en/01_SETTINGS_REFERENCE.md +34 -1
  5. package/docs/en/02_START_RESEARCH_GUIDE.md +7 -0
  6. package/docs/en/05_TUI_GUIDE.md +6 -0
  7. package/docs/en/06_RUNTIME_AND_CANVAS.md +4 -3
  8. package/docs/en/09_DOCTOR.md +25 -8
  9. package/docs/en/14_PROMPT_SKILLS_AND_MCP_GUIDE.md +63 -13
  10. package/docs/en/15_CODEX_PROVIDER_SETUP.md +37 -11
  11. package/docs/en/19_EXTERNAL_CONTROLLER_GUIDE.md +226 -0
  12. package/docs/en/19_LOCAL_BROWSER_AUTH.md +70 -0
  13. package/docs/en/20_WORKSPACE_MODES_GUIDE.md +250 -0
  14. package/docs/en/21_LOCAL_MODEL_BACKENDS_GUIDE.md +283 -0
  15. package/docs/en/91_DEVELOPMENT.md +237 -0
  16. package/docs/en/README.md +24 -2
  17. package/docs/zh/00_QUICK_START.md +89 -19
  18. package/docs/zh/01_SETTINGS_REFERENCE.md +34 -1
  19. package/docs/zh/02_START_RESEARCH_GUIDE.md +7 -0
  20. package/docs/zh/05_TUI_GUIDE.md +6 -0
  21. package/docs/zh/09_DOCTOR.md +26 -9
  22. package/docs/zh/14_PROMPT_SKILLS_AND_MCP_GUIDE.md +63 -13
  23. package/docs/zh/15_CODEX_PROVIDER_SETUP.md +37 -11
  24. package/docs/zh/19_EXTERNAL_CONTROLLER_GUIDE.md +226 -0
  25. package/docs/zh/19_LOCAL_BROWSER_AUTH.md +68 -0
  26. package/docs/zh/20_WORKSPACE_MODES_GUIDE.md +251 -0
  27. package/docs/zh/21_LOCAL_MODEL_BACKENDS_GUIDE.md +281 -0
  28. package/docs/zh/README.md +24 -2
  29. package/install.sh +46 -4
  30. package/package.json +2 -1
  31. package/pyproject.toml +1 -1
  32. package/src/deepscientist/__init__.py +1 -1
  33. package/src/deepscientist/acp/envelope.py +6 -0
  34. package/src/deepscientist/artifact/service.py +647 -22
  35. package/src/deepscientist/bash_exec/service.py +234 -9
  36. package/src/deepscientist/bridges/connectors.py +8 -2
  37. package/src/deepscientist/cli.py +115 -19
  38. package/src/deepscientist/codex_cli_compat.py +367 -22
  39. package/src/deepscientist/config/models.py +2 -1
  40. package/src/deepscientist/config/service.py +183 -13
  41. package/src/deepscientist/daemon/api/handlers.py +255 -31
  42. package/src/deepscientist/daemon/api/router.py +9 -0
  43. package/src/deepscientist/daemon/app.py +1146 -105
  44. package/src/deepscientist/diagnostics/__init__.py +6 -0
  45. package/src/deepscientist/diagnostics/runner_failures.py +130 -0
  46. package/src/deepscientist/doctor.py +207 -3
  47. package/src/deepscientist/gitops/__init__.py +10 -1
  48. package/src/deepscientist/gitops/diff.py +129 -0
  49. package/src/deepscientist/gitops/service.py +4 -1
  50. package/src/deepscientist/mcp/server.py +39 -0
  51. package/src/deepscientist/prompts/builder.py +275 -34
  52. package/src/deepscientist/quest/layout.py +15 -2
  53. package/src/deepscientist/quest/service.py +707 -55
  54. package/src/deepscientist/quest/stage_views.py +6 -1
  55. package/src/deepscientist/runners/codex.py +143 -43
  56. package/src/deepscientist/shared.py +19 -0
  57. package/src/deepscientist/skills/__init__.py +2 -2
  58. package/src/deepscientist/skills/installer.py +196 -5
  59. package/src/deepscientist/skills/registry.py +66 -0
  60. package/src/prompts/connectors/qq.md +18 -8
  61. package/src/prompts/connectors/weixin.md +16 -6
  62. package/src/prompts/contracts/shared_interaction.md +14 -2
  63. package/src/prompts/system.md +23 -5
  64. package/src/prompts/system_copilot.md +56 -0
  65. package/src/skills/analysis-campaign/SKILL.md +1 -0
  66. package/src/skills/baseline/SKILL.md +8 -0
  67. package/src/skills/decision/SKILL.md +8 -0
  68. package/src/skills/experiment/SKILL.md +8 -0
  69. package/src/skills/figure-polish/SKILL.md +1 -0
  70. package/src/skills/finalize/SKILL.md +1 -0
  71. package/src/skills/idea/SKILL.md +1 -0
  72. package/src/skills/intake-audit/SKILL.md +8 -0
  73. package/src/skills/mentor/SKILL.md +217 -0
  74. package/src/skills/mentor/references/correction-rules.md +210 -0
  75. package/src/skills/mentor/references/knowledge-profile.md +91 -0
  76. package/src/skills/mentor/references/persona-profile.md +138 -0
  77. package/src/skills/mentor/references/taste-profile.md +128 -0
  78. package/src/skills/mentor/references/thought-style-profile.md +138 -0
  79. package/src/skills/mentor/references/work-profile.md +289 -0
  80. package/src/skills/mentor/references/workflow-profile.md +240 -0
  81. package/src/skills/optimize/SKILL.md +1 -0
  82. package/src/skills/rebuttal/SKILL.md +1 -0
  83. package/src/skills/review/SKILL.md +1 -0
  84. package/src/skills/scout/SKILL.md +8 -0
  85. package/src/skills/write/SKILL.md +1 -0
  86. package/src/tui/dist/app/AppContainer.js +19 -11
  87. package/src/tui/dist/index.js +4 -1
  88. package/src/tui/dist/lib/api.js +33 -3
  89. package/src/tui/package.json +1 -1
  90. package/src/ui/dist/assets/AiManusChatView-Bv-Z8YpU.js +204 -0
  91. package/src/ui/dist/assets/AnalysisPlugin-BCKAfjba.js +1 -0
  92. package/src/ui/dist/assets/CliPlugin-BCKcpc35.js +109 -0
  93. package/src/ui/dist/assets/CodeEditorPlugin-DbOfSJ8K.js +2 -0
  94. package/src/ui/dist/assets/CodeViewerPlugin-CbaFRrUU.js +270 -0
  95. package/src/ui/dist/assets/DocViewerPlugin-DAjLVeQD.js +7 -0
  96. package/src/ui/dist/assets/GitCommitViewerPlugin-CIUqbUDO.js +1 -0
  97. package/src/ui/dist/assets/GitDiffViewerPlugin-CQACjoAA.js +6 -0
  98. package/src/ui/dist/assets/GitSnapshotViewer-0r4nLPke.js +30 -0
  99. package/src/ui/dist/assets/ImageViewerPlugin-nBOmI2v_.js +26 -0
  100. package/src/ui/dist/assets/LabCopilotPanel-BHxOxF4z.js +14 -0
  101. package/src/ui/dist/assets/LabPlugin-BKoZGs95.js +22 -0
  102. package/src/ui/dist/assets/LatexPlugin-ZwtV8pIp.js +25 -0
  103. package/src/ui/dist/assets/MarkdownViewerPlugin-DKqVfKyW.js +128 -0
  104. package/src/ui/dist/assets/MarketplacePlugin-BwxStZ9D.js +13 -0
  105. package/src/ui/dist/assets/NotebookEditor-BEQhaQbt.js +81 -0
  106. package/src/ui/dist/assets/{NotebookEditor-CccQYZjX.css → NotebookEditor-BHH8rdGj.css} +1 -1
  107. package/src/ui/dist/assets/NotebookEditor-BOr3x3Ej.css +1 -0
  108. package/src/ui/dist/assets/NotebookEditor-DB9N_T9q.js +361 -0
  109. package/src/ui/dist/assets/PdfLoader-Cy5jtWrr.css +1 -0
  110. package/src/ui/dist/assets/PdfLoader-eWBONbQP.js +16 -0
  111. package/src/ui/dist/assets/PdfMarkdownPlugin-D22YOZL3.js +1 -0
  112. package/src/ui/dist/assets/PdfViewerPlugin-c-RK9DLM.js +17 -0
  113. package/src/ui/dist/assets/PdfViewerPlugin-nwwE-fjJ.css +1 -0
  114. package/src/ui/dist/assets/SearchPlugin-CxF9ytAx.js +16 -0
  115. package/src/ui/dist/assets/SearchPlugin-DA4en4hK.css +1 -0
  116. package/src/ui/dist/assets/TextViewerPlugin-C5xqeeUH.js +54 -0
  117. package/src/ui/dist/assets/VNCViewer-BoLGLnHz.js +11 -0
  118. package/src/ui/dist/assets/bot-DREQOxzP.js +6 -0
  119. package/src/ui/dist/assets/browser-CTB2jwNe.js +8 -0
  120. package/src/ui/dist/assets/chevron-up-C9Qpx4DE.js +6 -0
  121. package/src/ui/dist/assets/code-WlFHE7z_.js +6 -0
  122. package/src/ui/dist/assets/file-content-BZMz3RYp.js +1 -0
  123. package/src/ui/dist/assets/file-diff-panel-CQhw0jS2.js +1 -0
  124. package/src/ui/dist/assets/file-jump-queue-DA-SdG__.js +1 -0
  125. package/src/ui/dist/assets/file-socket-CfQPKQKj.js +1 -0
  126. package/src/ui/dist/assets/git-commit-horizontal-DxZ8DCZh.js +6 -0
  127. package/src/ui/dist/assets/image-Bgl4VIyx.js +6 -0
  128. package/src/ui/dist/assets/index-BpV6lusQ.css +33 -0
  129. package/src/ui/dist/assets/index-CBNVuWcP.js +2496 -0
  130. package/src/ui/dist/assets/index-CwNu1aH4.js +11 -0
  131. package/src/ui/dist/assets/index-DrUnlf6K.js +1 -0
  132. package/src/ui/dist/assets/index-NW-h8VzN.js +1 -0
  133. package/src/ui/dist/assets/monaco-CiHMMNH_.js +1 -0
  134. package/src/ui/dist/assets/pdf-effect-queue-J8OnM0jE.js +6 -0
  135. package/src/ui/dist/assets/plugin-monaco-C8UgLomw.js +19 -0
  136. package/src/ui/dist/assets/plugin-notebook-HbW2K-1c.js +169 -0
  137. package/src/ui/dist/assets/plugin-pdf-CR8hgQBV.js +357 -0
  138. package/src/ui/dist/assets/plugin-terminal-MXFIPun8.js +227 -0
  139. package/src/ui/dist/assets/popover-CLc0pPP8.js +1 -0
  140. package/src/ui/dist/assets/project-sync-C9IdzdZW.js +1 -0
  141. package/src/ui/dist/assets/select-Cs2PmzwL.js +11 -0
  142. package/src/ui/dist/assets/sigma-ClKcHAXm.js +6 -0
  143. package/src/ui/dist/assets/trash-DwpbFr3w.js +11 -0
  144. package/src/ui/dist/assets/useCliAccess-NQ8m0Let.js +1 -0
  145. package/src/ui/dist/assets/useFileDiffOverlay-FuhcnKiw.js +1 -0
  146. package/src/ui/dist/assets/wrap-text-BC-Hltpd.js +11 -0
  147. package/src/ui/dist/assets/zoom-out-E_gaeAxL.js +11 -0
  148. package/src/ui/dist/index.html +5 -2
  149. package/src/ui/dist/assets/AiManusChatView-DDjbFnbt.js +0 -26597
  150. package/src/ui/dist/assets/AnalysisPlugin-Yb5IdmaU.js +0 -123
  151. package/src/ui/dist/assets/CliPlugin-e64sreyu.js +0 -31037
  152. package/src/ui/dist/assets/CodeEditorPlugin-C4D2TIkU.js +0 -427
  153. package/src/ui/dist/assets/CodeViewerPlugin-BVoNZIvC.js +0 -905
  154. package/src/ui/dist/assets/DocViewerPlugin-CLChbllo.js +0 -278
  155. package/src/ui/dist/assets/GitDiffViewerPlugin-C4xeFyFQ.js +0 -2661
  156. package/src/ui/dist/assets/ImageViewerPlugin-OiMUAcLi.js +0 -500
  157. package/src/ui/dist/assets/LabCopilotPanel-BjD2ThQF.js +0 -4104
  158. package/src/ui/dist/assets/LabPlugin-DQPg-NrB.js +0 -2677
  159. package/src/ui/dist/assets/LatexPlugin-CI05XAV9.js +0 -1792
  160. package/src/ui/dist/assets/MarkdownViewerPlugin-DpeBLYZf.js +0 -308
  161. package/src/ui/dist/assets/MarketplacePlugin-DolE58Q2.js +0 -413
  162. package/src/ui/dist/assets/NotebookEditor-7Qm2rSWD.js +0 -4214
  163. package/src/ui/dist/assets/NotebookEditor-C1kWaxKi.js +0 -84873
  164. package/src/ui/dist/assets/NotebookEditor-C3VQ7ylN.css +0 -1405
  165. package/src/ui/dist/assets/PdfLoader-BfOHw8Zw.js +0 -25468
  166. package/src/ui/dist/assets/PdfLoader-C-Y707R3.css +0 -49
  167. package/src/ui/dist/assets/PdfMarkdownPlugin-BulDREv1.js +0 -409
  168. package/src/ui/dist/assets/PdfViewerPlugin-C-daaOaL.js +0 -3095
  169. package/src/ui/dist/assets/PdfViewerPlugin-DQ11QcSf.css +0 -3627
  170. package/src/ui/dist/assets/SearchPlugin-CjpaiJ3A.js +0 -741
  171. package/src/ui/dist/assets/SearchPlugin-DDMrGDkh.css +0 -379
  172. package/src/ui/dist/assets/TextViewerPlugin-BxIyqPQC.js +0 -472
  173. package/src/ui/dist/assets/VNCViewer-HAg9mF7M.js +0 -18821
  174. package/src/ui/dist/assets/awareness-C0NPR2Dj.js +0 -292
  175. package/src/ui/dist/assets/bot-0DYntytV.js +0 -21
  176. package/src/ui/dist/assets/browser-BAcuE0Xj.js +0 -2895
  177. package/src/ui/dist/assets/code-B20Slj_w.js +0 -17
  178. package/src/ui/dist/assets/file-content-DT24KFma.js +0 -377
  179. package/src/ui/dist/assets/file-diff-panel-DK13YPql.js +0 -92
  180. package/src/ui/dist/assets/file-jump-queue-r5XKgJEV.js +0 -16
  181. package/src/ui/dist/assets/file-socket-B4T2o4nR.js +0 -58
  182. package/src/ui/dist/assets/function-B5QZkkHC.js +0 -1895
  183. package/src/ui/dist/assets/image-DSeR_sDS.js +0 -18
  184. package/src/ui/dist/assets/index-BrFje2Uk.js +0 -120
  185. package/src/ui/dist/assets/index-BwRJaoTl.js +0 -25
  186. package/src/ui/dist/assets/index-D_E4281X.js +0 -221322
  187. package/src/ui/dist/assets/index-DnYB3xb1.js +0 -159
  188. package/src/ui/dist/assets/index-G7AcWcMu.css +0 -12594
  189. package/src/ui/dist/assets/monaco-LExaAN3Y.js +0 -623
  190. package/src/ui/dist/assets/pdf-effect-queue-BJk5okWJ.js +0 -47
  191. package/src/ui/dist/assets/pdf_viewer-e0g1is2C.js +0 -8206
  192. package/src/ui/dist/assets/popover-D3Gg_FoV.js +0 -476
  193. package/src/ui/dist/assets/project-sync-C_ygLlVU.js +0 -297
  194. package/src/ui/dist/assets/select-CpAK6uWm.js +0 -1690
  195. package/src/ui/dist/assets/sigma-DEccaSgk.js +0 -22
  196. package/src/ui/dist/assets/square-check-big-uUfyVsbD.js +0 -17
  197. package/src/ui/dist/assets/trash-CXvwwSe8.js +0 -32
  198. package/src/ui/dist/assets/useCliAccess-Bnop4mgR.js +0 -957
  199. package/src/ui/dist/assets/useFileDiffOverlay-B8eUAX0I.js +0 -53
  200. package/src/ui/dist/assets/wrap-text-9vbOBpkW.js +0 -35
  201. package/src/ui/dist/assets/yjs-DncrqiZ8.js +0 -11243
  202. package/src/ui/dist/assets/zoom-out-BgVMmOW4.js +0 -34
@@ -1,297 +0,0 @@
1
- import { G as acquireSocket, H as uint8ArrayToBase64, J as base64ToUint8Array } from './index-D_E4281X.js';
2
-
3
- function getErrorMessage(err) {
4
- if (err instanceof Error) return err.message;
5
- if (typeof err === "string") return err;
6
- try {
7
- return JSON.stringify(err);
8
- } catch {
9
- return String(err);
10
- }
11
- }
12
- class ProjectSyncClient {
13
- spaceType = "workspace";
14
- projectId;
15
- authMode;
16
- docKind;
17
- socket;
18
- releaseSocket;
19
- joined = false;
20
- joinedDocs = /* @__PURE__ */ new Set();
21
- constructor(projectId, options = {}) {
22
- this.projectId = projectId;
23
- this.authMode = options.authMode ?? "user";
24
- this.docKind = options.docKind;
25
- const { socket, release } = acquireSocket({ authMode: this.authMode });
26
- this.socket = socket;
27
- this.releaseSocket = release;
28
- }
29
- async waitForConnected(timeoutMs) {
30
- if (this.socket.connected) return;
31
- await new Promise((resolve, reject) => {
32
- const timer = window.setTimeout(() => {
33
- cleanup();
34
- reject(new Error("WebSocket connection timeout"));
35
- }, timeoutMs);
36
- const onConnect = () => {
37
- cleanup();
38
- resolve();
39
- };
40
- const onConnectError = (err) => {
41
- cleanup();
42
- reject(new Error(getErrorMessage(err) || "WebSocket connection error"));
43
- };
44
- const cleanup = () => {
45
- window.clearTimeout(timer);
46
- this.socket.off("connect", onConnect);
47
- this.socket.off("connect_error", onConnectError);
48
- this.socket.off?.("error", onConnectError);
49
- };
50
- const attachOnce = (eventName, handler) => {
51
- const socketAny = this.socket;
52
- if (typeof socketAny.once === "function") {
53
- socketAny.once(eventName, handler);
54
- return;
55
- }
56
- const wrapped = (...args) => {
57
- if (typeof socketAny.off === "function") {
58
- socketAny.off(eventName, wrapped);
59
- }
60
- handler(...args);
61
- };
62
- socketAny.on?.(eventName, wrapped);
63
- };
64
- attachOnce("connect", onConnect);
65
- attachOnce("connect_error", onConnectError);
66
- attachOnce("error", onConnectError);
67
- });
68
- }
69
- async emitWithAck(event, data, timeoutMs = 1e4) {
70
- await this.waitForConnected(timeoutMs);
71
- try {
72
- const socketAny = this.socket;
73
- if (typeof socketAny.timeout === "function" && typeof socketAny.emitWithAck === "function") {
74
- return await socketAny.timeout(timeoutMs).emitWithAck(event, data);
75
- }
76
- return await new Promise((resolve) => {
77
- const timer = window.setTimeout(() => {
78
- resolve({
79
- error: { name: "SOCKET_TIMEOUT", message: `Ack timeout for ${event}` }
80
- });
81
- }, timeoutMs);
82
- this.socket.emit(event, data, (payload) => {
83
- window.clearTimeout(timer);
84
- resolve(payload);
85
- });
86
- });
87
- } catch (err) {
88
- return {
89
- error: { name: "SOCKET_ERROR", message: getErrorMessage(err) }
90
- };
91
- }
92
- }
93
- async connect() {
94
- if (this.joined) return;
95
- const res = await this.emitWithAck(
96
- "space:join",
97
- {
98
- spaceType: this.spaceType,
99
- spaceId: this.projectId,
100
- clientVersion: "1.0.0"
101
- },
102
- 12e3
103
- );
104
- if ("error" in res) {
105
- throw new Error(res.error.message);
106
- }
107
- if (!res.data.success) {
108
- throw new Error("Failed to join space");
109
- }
110
- this.joined = true;
111
- }
112
- async joinDoc(docId) {
113
- if (!docId) return;
114
- if (!this.joined) {
115
- await this.connect();
116
- }
117
- if (this.joinedDocs.has(docId)) return;
118
- const res = await this.emitWithAck(
119
- "space:join-doc",
120
- {
121
- spaceType: this.spaceType,
122
- spaceId: this.projectId,
123
- docId,
124
- docKind: this.docKind
125
- },
126
- 12e3
127
- );
128
- if ("error" in res) {
129
- throw new Error(res.error.message);
130
- }
131
- if (!res.data.success) {
132
- throw new Error("Failed to join doc");
133
- }
134
- this.joinedDocs.add(docId);
135
- }
136
- leaveDoc(docId) {
137
- if (!docId) return;
138
- if (!this.joinedDocs.has(docId)) return;
139
- this.socket.emit("space:leave-doc", {
140
- spaceType: this.spaceType,
141
- spaceId: this.projectId,
142
- docId,
143
- docKind: this.docKind
144
- });
145
- this.joinedDocs.delete(docId);
146
- }
147
- disconnect() {
148
- try {
149
- if (this.joined) {
150
- for (const docId of Array.from(this.joinedDocs)) {
151
- this.leaveDoc(docId);
152
- }
153
- this.socket.emit("space:leave", {
154
- spaceType: this.spaceType,
155
- spaceId: this.projectId
156
- });
157
- }
158
- } finally {
159
- this.joined = false;
160
- this.releaseSocket();
161
- }
162
- }
163
- onDocUpdate(handler) {
164
- const wrapped = (msg) => {
165
- if (msg?.spaceId !== this.projectId) return;
166
- handler({
167
- docId: String(msg.docId),
168
- update: base64ToUint8Array(String(msg.update)),
169
- timestamp: Number(msg.timestamp),
170
- editor: msg.editor ? String(msg.editor) : void 0
171
- });
172
- };
173
- this.socket.on("space:broadcast-doc-update", wrapped);
174
- return () => this.socket.off("space:broadcast-doc-update", wrapped);
175
- }
176
- onDocReset(handler) {
177
- const wrapped = (msg) => {
178
- if (msg?.spaceId !== this.projectId) return;
179
- handler({
180
- docId: String(msg.docId),
181
- timestamp: Number(msg.timestamp),
182
- reason: msg?.reason ? String(msg.reason) : void 0,
183
- actorUserId: msg?.actorUserId != null ? String(msg.actorUserId) : null
184
- });
185
- };
186
- this.socket.on("space:doc-reset", wrapped);
187
- return () => this.socket.off("space:doc-reset", wrapped);
188
- }
189
- async loadDoc(notebookId, stateVector) {
190
- await this.joinDoc(notebookId);
191
- const res = await this.emitWithAck(
192
- "space:load-doc",
193
- {
194
- spaceType: this.spaceType,
195
- spaceId: this.projectId,
196
- docId: notebookId,
197
- docKind: this.docKind,
198
- stateVector: stateVector ? await uint8ArrayToBase64(stateVector) : void 0
199
- },
200
- 15e3
201
- );
202
- if ("error" in res) {
203
- if (res.error.name === "DOC_NOT_FOUND" || res.error.name === "NOT_FOUND") {
204
- return null;
205
- }
206
- throw new Error(res.error.message);
207
- }
208
- return {
209
- missing: base64ToUint8Array(res.data.missing),
210
- state: base64ToUint8Array(res.data.state),
211
- timestamp: Number(res.data.timestamp)
212
- };
213
- }
214
- async pushDocUpdate(notebookId, update) {
215
- await this.joinDoc(notebookId);
216
- const res = await this.emitWithAck(
217
- "space:push-doc-update",
218
- {
219
- spaceType: this.spaceType,
220
- spaceId: this.projectId,
221
- docId: notebookId,
222
- docKind: this.docKind,
223
- update: await uint8ArrayToBase64(update)
224
- },
225
- 15e3
226
- );
227
- if ("error" in res) {
228
- throw new Error(res.error.message);
229
- }
230
- return Number(res.data.timestamp);
231
- }
232
- // -------------------- Awareness --------------------
233
- async joinAwareness(notebookId) {
234
- const res = await this.emitWithAck(
235
- "space:join-awareness",
236
- {
237
- spaceType: this.spaceType,
238
- spaceId: this.projectId,
239
- docId: notebookId,
240
- docKind: this.docKind,
241
- clientVersion: "1.0.0"
242
- },
243
- 12e3
244
- );
245
- if ("error" in res) {
246
- throw new Error(res.error.message);
247
- }
248
- if (!res.data.success) {
249
- throw new Error("Failed to join awareness");
250
- }
251
- }
252
- leaveAwareness(notebookId) {
253
- this.socket.emit("space:leave-awareness", {
254
- spaceType: this.spaceType,
255
- spaceId: this.projectId,
256
- docId: notebookId,
257
- docKind: this.docKind
258
- });
259
- }
260
- onAwarenessCollect(notebookId, handler) {
261
- const wrapped = (msg) => {
262
- if (msg?.spaceId !== this.projectId) return;
263
- if (String(msg?.docId) !== notebookId) return;
264
- handler();
265
- };
266
- this.socket.on("space:collect-awareness", wrapped);
267
- return () => this.socket.off("space:collect-awareness", wrapped);
268
- }
269
- onAwarenessUpdate(notebookId, handler) {
270
- const wrapped = (msg) => {
271
- if (msg?.spaceId !== this.projectId) return;
272
- if (String(msg?.docId) !== notebookId) return;
273
- handler(base64ToUint8Array(String(msg.awarenessUpdate)));
274
- };
275
- this.socket.on("space:broadcast-awareness-update", wrapped);
276
- return () => this.socket.off("space:broadcast-awareness-update", wrapped);
277
- }
278
- async broadcastAwareness(notebookId, update) {
279
- this.socket.emit("space:update-awareness", {
280
- spaceType: this.spaceType,
281
- spaceId: this.projectId,
282
- docId: notebookId,
283
- docKind: this.docKind,
284
- awarenessUpdate: await uint8ArrayToBase64(update)
285
- });
286
- }
287
- requestAwarenesses(notebookId) {
288
- this.socket.emit("space:load-awarenesses", {
289
- spaceType: this.spaceType,
290
- spaceId: this.projectId,
291
- docId: notebookId,
292
- docKind: this.docKind
293
- });
294
- }
295
- }
296
-
297
- export { ProjectSyncClient as P };