@walkhi/code-relax 0.1.0-beta.30 → 0.1.0-beta.32

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 (187) hide show
  1. package/README.md +95 -89
  2. package/dist/bin/cleanup-accounts.mjs +63 -63
  3. package/dist/bin/codex-remote.mjs +374 -367
  4. package/dist/bin/manage-relay-admin.mjs +20 -20
  5. package/dist/bin/migrate-relay-db.mjs +109 -109
  6. package/dist/bin/publish-android-release.mjs +63 -58
  7. package/dist/bin/publish-harmony-release.mjs +46 -0
  8. package/dist/bin/release-upload-server.mjs +174 -0
  9. package/dist/bin/self-relay-admin.mjs +8 -8
  10. package/dist/bin/self-relay-demo.mjs +33 -33
  11. package/dist/bin/self-relay-server.mjs +66 -66
  12. package/dist/build-platform.json +1 -1
  13. package/dist/get-lan-networks.ps1 +40 -40
  14. package/dist/get-shared-service-url.ps1 +6 -6
  15. package/dist/shared/app-server-events.cjs +422 -412
  16. package/dist/shared/code-browser.cjs +159 -159
  17. package/dist/shared/file-changes.cjs +31 -31
  18. package/dist/shared/file-citations.cjs +117 -117
  19. package/dist/shared/file-mentions.cjs +92 -92
  20. package/dist/shared/message-delivery.cjs +54 -54
  21. package/dist/shared/p2p-data-channel.cjs +72 -72
  22. package/dist/shared/p2p-diagnostics.cjs +28 -28
  23. package/dist/shared/p2p-file-channel.cjs +78 -74
  24. package/dist/shared/plan-pricing.cjs +32 -32
  25. package/dist/shared/question-attention.cjs +69 -0
  26. package/dist/shared/server-requests.cjs +219 -219
  27. package/dist/shared/timeline-sync.cjs +173 -173
  28. package/dist/skills/code-relax/SKILL.md +22 -22
  29. package/dist/src/archived-threads.mjs +22 -0
  30. package/dist/src/background-process.mjs +18 -18
  31. package/dist/src/bounded-process-log.mjs +63 -63
  32. package/dist/src/celsius-client.mjs +107 -107
  33. package/dist/src/code-browser.mjs +100 -100
  34. package/dist/src/desktop-launcher.mjs +46 -46
  35. package/dist/src/dots-approval-timeline.mjs +99 -99
  36. package/dist/src/dots-avatar.mjs +42 -42
  37. package/dist/src/dots-chat-projection.mjs +50 -50
  38. package/dist/src/dots-chat-server.mjs +461 -461
  39. package/dist/src/dots-message-images.mjs +319 -319
  40. package/dist/src/dots-profile.mjs +77 -77
  41. package/dist/src/dots-room-activity.mjs +94 -94
  42. package/dist/src/dots-room-client.mjs +135 -135
  43. package/dist/src/dots-room-projection.mjs +94 -94
  44. package/dist/src/dots-schedules.mjs +66 -66
  45. package/dist/src/dots-summary-tasks.mjs +32 -32
  46. package/dist/src/dots-task-catalog.mjs +430 -430
  47. package/dist/src/dots-task-files.mjs +52 -52
  48. package/dist/src/execution-health.mjs +26 -26
  49. package/dist/src/file-transfer-range.mjs +22 -22
  50. package/dist/src/file-upload-session.mjs +130 -130
  51. package/dist/src/hosted-history-app-server.mjs +103 -103
  52. package/dist/src/hosted-history-cache.mjs +113 -113
  53. package/dist/src/lan-socket-server.mjs +265 -263
  54. package/dist/src/managed-app-server.mjs +244 -244
  55. package/dist/src/message-images.mjs +9 -9
  56. package/dist/src/message-upload-files.mjs +74 -74
  57. package/dist/src/onboarding.mjs +12 -12
  58. package/dist/src/plan-pricing.mjs +47 -47
  59. package/dist/src/platform/README.md +12 -12
  60. package/dist/src/platform/codex-protocol.mjs +46 -46
  61. package/dist/src/platform/codex-runtime.mjs +3 -3
  62. package/dist/src/platform/credential-store.mjs +3 -3
  63. package/dist/src/platform/desktop-host.mjs +3 -3
  64. package/dist/src/platform/desktop-project-registration.mjs +3 -3
  65. package/dist/src/platform/desktop-project-store.mjs +208 -149
  66. package/dist/src/platform/file-opener.mjs +9 -0
  67. package/dist/src/platform/linux/README.md +3 -3
  68. package/dist/src/platform/linux/codex-runtime.mjs +56 -0
  69. package/dist/src/platform/linux/credential-store.mjs +28 -0
  70. package/dist/src/platform/linux/desktop-host.mjs +83 -0
  71. package/dist/src/platform/linux/desktop-installation.mjs +36 -0
  72. package/dist/src/platform/linux/desktop-project-registration.mjs +11 -0
  73. package/dist/src/platform/linux/network-info.mjs +11 -0
  74. package/dist/src/platform/linux/process.mjs +42 -0
  75. package/dist/src/platform/linux/project-locations.mjs +17 -0
  76. package/dist/src/platform/linux/resident-startup.mjs +52 -0
  77. package/dist/src/platform/linux/retained-runtime.mjs +76 -0
  78. package/dist/src/platform/linux/service-host.mjs +18 -0
  79. package/dist/src/platform/linux/system.mjs +49 -0
  80. package/dist/src/platform/linux/user-environment.mjs +7 -0
  81. package/dist/src/platform/macos/README.md +3 -3
  82. package/dist/src/platform/macos/codex-runtime.mjs +125 -125
  83. package/dist/src/platform/macos/credential-store.mjs +10 -10
  84. package/dist/src/platform/macos/desktop-host.mjs +82 -82
  85. package/dist/src/platform/macos/desktop-project-registration.mjs +11 -10
  86. package/dist/src/platform/macos/network-info.mjs +8 -28
  87. package/dist/src/platform/macos/project-locations.mjs +8 -8
  88. package/dist/src/platform/macos/resident-startup.mjs +84 -84
  89. package/dist/src/platform/macos/retained-runtime.mjs +127 -127
  90. package/dist/src/platform/macos/service-host.mjs +18 -18
  91. package/dist/src/platform/macos/system.mjs +29 -29
  92. package/dist/src/platform/macos/user-environment.mjs +7 -7
  93. package/dist/src/platform/native-package.mjs +58 -46
  94. package/dist/src/platform/network-info.mjs +3 -3
  95. package/dist/src/platform/path-identity.mjs +5 -5
  96. package/dist/src/platform/posix/network-candidates.mjs +23 -0
  97. package/dist/src/platform/posix/runtime-paths.mjs +25 -25
  98. package/dist/src/platform/project-locations.mjs +3 -3
  99. package/dist/src/platform/runtime-paths.mjs +8 -8
  100. package/dist/src/platform/select.mjs +5 -5
  101. package/dist/src/platform/service-host.mjs +3 -3
  102. package/dist/src/platform/user-environment.mjs +3 -3
  103. package/dist/src/platform/windows/IsolatedProcess.cs +79 -79
  104. package/dist/src/platform/windows/activate-desktop.ps1 +48 -48
  105. package/dist/src/platform/windows/background-process.mjs +30 -30
  106. package/dist/src/platform/windows/codex-runtime.mjs +215 -215
  107. package/dist/src/platform/windows/credential-store.mjs +27 -27
  108. package/dist/src/platform/windows/credential-store.ps1 +49 -49
  109. package/dist/src/platform/windows/desktop-helper.mjs +179 -179
  110. package/dist/src/platform/windows/desktop-host.mjs +58 -58
  111. package/dist/src/platform/windows/desktop-info.ps1 +14 -14
  112. package/dist/src/platform/windows/desktop-project-registration.mjs +4 -4
  113. package/dist/src/platform/windows/desktop-runtime.ps1 +10 -10
  114. package/dist/src/platform/windows/desktop-shortcuts.ps1 +21 -21
  115. package/dist/src/platform/windows/dots-profile.mjs +49 -49
  116. package/dist/src/platform/windows/launch-worker.mjs +41 -41
  117. package/dist/src/platform/windows/network-info.mjs +34 -34
  118. package/dist/src/platform/windows/project-locations.mjs +16 -16
  119. package/dist/src/platform/windows/resident-start.js +20 -20
  120. package/dist/src/platform/windows/resident-start.ps1 +7 -7
  121. package/dist/src/platform/windows/resident-startup.ps1 +83 -83
  122. package/dist/src/platform/windows/resolve-state-root.ps1 +14 -14
  123. package/dist/src/platform/windows/runtime-paths.mjs +20 -20
  124. package/dist/src/platform/windows/rustdesk-video-probe.mjs +167 -167
  125. package/dist/src/platform/windows/service-host.mjs +31 -31
  126. package/dist/src/platform/windows/start-hidden-console.ps1 +49 -49
  127. package/dist/src/platform/windows/stop-desktop.ps1 +22 -22
  128. package/dist/src/platform/windows/user-environment.mjs +50 -50
  129. package/dist/src/platform/windows/user-environment.ps1 +41 -41
  130. package/dist/src/project-archive.mjs +30 -0
  131. package/dist/src/project-create.mjs +121 -119
  132. package/dist/src/project-management.mjs +59 -69
  133. package/dist/src/project-remove.mjs +55 -0
  134. package/dist/src/project-update.mjs +56 -0
  135. package/dist/src/runtime-discovery.mjs +47 -47
  136. package/dist/src/self-relay/account-cleanup.mjs +30 -30
  137. package/dist/src/self-relay/account-connections.mjs +52 -52
  138. package/dist/src/self-relay/admin-cloud.mjs +101 -101
  139. package/dist/src/self-relay/admin-page.mjs +80 -80
  140. package/dist/src/self-relay/admin-server.mjs +74 -74
  141. package/dist/src/self-relay/admin-state.mjs +127 -127
  142. package/dist/src/self-relay/admin-style.mjs +14 -14
  143. package/dist/src/self-relay/android-releases.mjs +61 -61
  144. package/dist/src/self-relay/client.mjs +61 -61
  145. package/dist/src/self-relay/connector.mjs +439 -438
  146. package/dist/src/self-relay/debug-allowlist.mjs +33 -33
  147. package/dist/src/self-relay/demo.mjs +37 -37
  148. package/dist/src/self-relay/device-info.mjs +27 -0
  149. package/dist/src/self-relay/device-store.mjs +92 -84
  150. package/dist/src/self-relay/diagnostics.mjs +54 -54
  151. package/dist/src/self-relay/email-accounts.mjs +183 -183
  152. package/dist/src/self-relay/file-wire.mjs +13 -13
  153. package/dist/src/self-relay/lan-authorizations.mjs +71 -42
  154. package/dist/src/self-relay/lifecycle.mjs +264 -250
  155. package/dist/src/self-relay/long-pairing.mjs +40 -40
  156. package/dist/src/self-relay/mysql-state.mjs +118 -105
  157. package/dist/src/self-relay/p2p-probe.mjs +159 -159
  158. package/dist/src/self-relay/privacy-page.mjs +26 -26
  159. package/dist/src/self-relay/public-releases.mjs +52 -0
  160. package/dist/src/self-relay/rtc-file-bridge.mjs +41 -41
  161. package/dist/src/self-relay/server.mjs +1006 -932
  162. package/dist/src/self-relay/usage-daily.mjs +55 -55
  163. package/dist/src/self-relay/usage-meter.mjs +141 -141
  164. package/dist/src/self-relay/windows-route-helper.mjs +75 -75
  165. package/dist/src/self-relay/wire.mjs +36 -36
  166. package/dist/src/server.mjs +1861 -1778
  167. package/dist/src/service-control.mjs +82 -82
  168. package/dist/src/service-doctor.mjs +110 -110
  169. package/dist/src/service-health.mjs +33 -33
  170. package/dist/src/service-install.mjs +91 -91
  171. package/dist/src/service-lifecycle.mjs +138 -138
  172. package/dist/src/service-restart.mjs +81 -81
  173. package/dist/src/shared-app-server.mjs +615 -611
  174. package/dist/src/shared-catalog.mjs +132 -132
  175. package/dist/src/shared-recovery.mjs +146 -146
  176. package/dist/src/shared-thread-stream.mjs +164 -164
  177. package/dist/src/skill-install.mjs +51 -51
  178. package/dist/src/thread-title-generation.mjs +150 -150
  179. package/dist/src/turn-model-history.mjs +47 -47
  180. package/dist/src/usage-reset.mjs +17 -17
  181. package/dist/src/workstation-downloads.mjs +120 -120
  182. package/dist/tools/rtc-route-helper.ps1 +99 -99
  183. package/dist/tools/start-rtc-route-helper.ps1 +15 -15
  184. package/dist/web/vendor/markdown-it.LICENSE.txt +22 -22
  185. package/dist/web/vendor/markdown-it.umd.min.js +13 -13
  186. package/package.json +7 -6
  187. package/tools/postinstall.mjs +127 -127
@@ -1,94 +1,94 @@
1
- // Desktop 26.1002.7124.0 hides appshot context before the visible request.
2
- // Presentation recognizes the format, never an application's routing contract.
3
- function appshotMessageBody(text) {
4
- if (typeof text !== 'string' || !text.trimStart().startsWith('# Applications mentioned by the user:')) return text;
5
- const request = /\r?\n## My request(?: for Codex)?:\r?\n/.exec(text);
6
- if (!request) return text;
7
- const context = text.slice(0, request.index);
8
- for (const [, attributes, content] of context.matchAll(/<appshot\b([^>]*)>([\s\S]*?)<\/appshot>/g)) {
9
- const attrs = new Map([...attributes.matchAll(/([A-Za-z][A-Za-z0-9-]*)="([^"]*)"/g)].map(([, key, value]) => [key, value]));
10
- if (attrs.get('app')?.trim() && attrs.get('bundle-identifier')?.trim()
11
- && (content.trim() || attrs.get('image')?.trim())) return text.slice(request.index + request[0].length);
12
- }
13
- return text;
14
- }
15
-
16
- // Desktop 26.1007.2314.0 X8o/Z8o: suggestions are a native widget, not text.
17
- // Use its supplied web setup entry on mobile; never invent an OAuth URL.
18
- function pluginSetupLinks(attachments) {
19
- const links = new Map();
20
- for (const attachment of attachments) {
21
- if (attachment.type !== 'widget' || attachment.product_sku !== 'aeon'
22
- || attachment.messages?.length !== 2) continue;
23
- const [call, reply] = attachment.messages;
24
- if (call.author?.role !== 'assistant' || reply.author?.role !== 'tool'
25
- || call.id !== attachment.original_message_id || reply.metadata?.is_visually_hidden_from_conversation === true
26
- || reply.metadata?.is_error === true) continue;
27
- const first = call.metadata?.chatgpt_sdk, second = reply.metadata?.chatgpt_sdk;
28
- const connector = first?.resource_name === 'plugin_management.suggest_plugins' ? 'connector_openai_plugin_management'
29
- : first?.resource_name === 'openai_settings.suggest_plugins' ? 'connector_openai_openai_settings' : null;
30
- if (!connector || [first, second].some(sdk => !sdk || sdk.resource_name !== first.resource_name
31
- || sdk.html_asset_pointer !== 'internal://plugin-management-suggestions' || sdk.distribution_channel !== 'openai'
32
- || sdk.attribution_id !== connector || sdk.resolved_pineapple_uri !== `connectors://${connector}`
33
- || sdk.is_error === true || sdk.is_widget_closed === true)) continue;
34
- const result = second.tool_response_metadata?.call_tool_result, data = result?.structuredContent;
35
- if (result?.isError === true || data?.kind !== 'plugin_suggestions' || data.version !== 1
36
- || typeof data.setup_url !== 'string' || !Array.isArray(data.suggestions) || !data.suggestions.length
37
- || data.suggestions.some(plugin => typeof plugin?.plugin_id !== 'string' || !plugin.plugin_id
38
- || typeof plugin.display_name !== 'string' || !plugin.display_name.trim())) continue;
39
- let url;
40
- try { url = new URL(data.setup_url); } catch { continue; }
41
- if (url.origin !== 'https://chatgpt.com' || url.pathname !== '/plugin-suggestions'
42
- || url.username || url.password || url.hash || url.searchParams.getAll('bundle').length !== 1
43
- || !url.searchParams.get('bundle')) continue;
44
- const names = [...new Map(data.suggestions.map(plugin => [plugin.plugin_id, plugin.display_name])).values()];
45
- const label = names.join('、').replace(/[\r\n]+/g, ' ').replace(/[\\`*_[\]<>]/g, '\\$&');
46
- links.set(data.setup_url, `[设置 ${label} 连接](<${url.href.replace(/</g, '%3C').replace(/>/g, '%3E')}>)`);
47
- }
48
- return [...links.values()];
49
- }
50
-
51
- // Message role alone is insufficient: Dot is also a user-shaped room member.
52
- export function dotsRoomTurns(room, messages) {
53
- return messages.map(message => {
54
- const member = room.members.find(value => value.account_user_id === message.account_user_id);
55
- const assistant = Array.isArray(message.raw_messages) || Boolean(member?.aeon_id);
56
- const time = Date.parse(message.created_at);
57
- const common = { id: message.id, startedAtMs: Number.isFinite(time) ? time : undefined,
58
- completedAtMs: Number.isFinite(time) ? time : undefined };
59
- const rawText = Array.isArray(message.raw_messages) ? message.raw_messages
60
- .filter(raw => raw.author?.role === 'assistant' && raw.channel !== 'analysis'
61
- && !raw.metadata?.is_hidden && !raw.metadata?.hidden && ['text', 'multimodal_text'].includes(raw.content?.content_type))
62
- .flatMap(raw => (raw.content.parts || []).filter(part => typeof part === 'string')).join('\n\n')
63
- : message.content?.text || '';
64
- const sourceAttachments = message.content?.attachments || message.attachments || [];
65
- const text = assistant ? [rawText, ...pluginSetupLinks(sourceAttachments)].filter(Boolean).join('\n\n')
66
- : member ? appshotMessageBody(rawText) : rawText;
67
- const attachments = sourceAttachments.flatMap(attachment => {
68
- if (attachment.type !== 'file' || typeof attachment.file_id !== 'string') return [];
69
- const file = attachment.file || {};
70
- return [{ type: /^image\//.test(file.mime_type || '') ? 'image' : 'file',
71
- roomId: room.id, fileId: attachment.file_id, name: file.name || file.file_name || '附件',
72
- mimeType: file.mime_type || '', size: file.size_bytes }];
73
- });
74
- let item;
75
- if (!message.deleted_at && message.content?.type !== 'message_error') {
76
- if (assistant) item = { ...common, type: 'agentMessage', text, attachments, phase: 'final', delivery: 'async',
77
- ...(message.generation?.status === 'in_progress' ? { dotsStreaming: true, completedAtMs: null } : {}) };
78
- else if (member) item = { ...common, type: 'userMessage', clientId: message.request_id?.replace(/-/g, ''),
79
- content: [...(text ? [{ type: 'text', text }] : []), ...attachments] };
80
- }
81
- const request = message.content?.elicitation;
82
- const approval = !message.deleted_at && request && typeof request.request_id === 'string' && request.request_id
83
- && typeof request.thread_id === 'string' && request.thread_id && request.params?.threadId === request.thread_id
84
- && ['pending', 'resolved', 'expired'].includes(request.status)
85
- ? { type: 'approval', id: `approval:string:${request.request_id}`, requestId: request.request_id,
86
- method: 'mcpServer/elicitation/request', params: request.params, status: request.status, result: null,
87
- sourceThreadId: request.thread_id, turnId: request.turn_id ?? null, receivedAtMs: time,
88
- completedAtMs: null, roomMessageId: message.id } : null;
89
- return { id: message.id, status: item?.dotsStreaming ? 'inProgress' : 'completed',
90
- roomMessage: true, deleted: Boolean(message.deleted_at), createdAt: message.created_at,
91
- updatedAt: message.deleted_at || message.updated_at || message.created_at,
92
- items: [...(item && (text || attachments.length) ? [item] : []), ...(approval ? [approval] : [])] };
93
- });
94
- }
1
+ // Desktop 26.1002.7124.0 hides appshot context before the visible request.
2
+ // Presentation recognizes the format, never an application's routing contract.
3
+ function appshotMessageBody(text) {
4
+ if (typeof text !== 'string' || !text.trimStart().startsWith('# Applications mentioned by the user:')) return text;
5
+ const request = /\r?\n## My request(?: for Codex)?:\r?\n/.exec(text);
6
+ if (!request) return text;
7
+ const context = text.slice(0, request.index);
8
+ for (const [, attributes, content] of context.matchAll(/<appshot\b([^>]*)>([\s\S]*?)<\/appshot>/g)) {
9
+ const attrs = new Map([...attributes.matchAll(/([A-Za-z][A-Za-z0-9-]*)="([^"]*)"/g)].map(([, key, value]) => [key, value]));
10
+ if (attrs.get('app')?.trim() && attrs.get('bundle-identifier')?.trim()
11
+ && (content.trim() || attrs.get('image')?.trim())) return text.slice(request.index + request[0].length);
12
+ }
13
+ return text;
14
+ }
15
+
16
+ // Desktop 26.1007.2314.0 X8o/Z8o: suggestions are a native widget, not text.
17
+ // Use its supplied web setup entry on mobile; never invent an OAuth URL.
18
+ function pluginSetupLinks(attachments) {
19
+ const links = new Map();
20
+ for (const attachment of attachments) {
21
+ if (attachment.type !== 'widget' || attachment.product_sku !== 'aeon'
22
+ || attachment.messages?.length !== 2) continue;
23
+ const [call, reply] = attachment.messages;
24
+ if (call.author?.role !== 'assistant' || reply.author?.role !== 'tool'
25
+ || call.id !== attachment.original_message_id || reply.metadata?.is_visually_hidden_from_conversation === true
26
+ || reply.metadata?.is_error === true) continue;
27
+ const first = call.metadata?.chatgpt_sdk, second = reply.metadata?.chatgpt_sdk;
28
+ const connector = first?.resource_name === 'plugin_management.suggest_plugins' ? 'connector_openai_plugin_management'
29
+ : first?.resource_name === 'openai_settings.suggest_plugins' ? 'connector_openai_openai_settings' : null;
30
+ if (!connector || [first, second].some(sdk => !sdk || sdk.resource_name !== first.resource_name
31
+ || sdk.html_asset_pointer !== 'internal://plugin-management-suggestions' || sdk.distribution_channel !== 'openai'
32
+ || sdk.attribution_id !== connector || sdk.resolved_pineapple_uri !== `connectors://${connector}`
33
+ || sdk.is_error === true || sdk.is_widget_closed === true)) continue;
34
+ const result = second.tool_response_metadata?.call_tool_result, data = result?.structuredContent;
35
+ if (result?.isError === true || data?.kind !== 'plugin_suggestions' || data.version !== 1
36
+ || typeof data.setup_url !== 'string' || !Array.isArray(data.suggestions) || !data.suggestions.length
37
+ || data.suggestions.some(plugin => typeof plugin?.plugin_id !== 'string' || !plugin.plugin_id
38
+ || typeof plugin.display_name !== 'string' || !plugin.display_name.trim())) continue;
39
+ let url;
40
+ try { url = new URL(data.setup_url); } catch { continue; }
41
+ if (url.origin !== 'https://chatgpt.com' || url.pathname !== '/plugin-suggestions'
42
+ || url.username || url.password || url.hash || url.searchParams.getAll('bundle').length !== 1
43
+ || !url.searchParams.get('bundle')) continue;
44
+ const names = [...new Map(data.suggestions.map(plugin => [plugin.plugin_id, plugin.display_name])).values()];
45
+ const label = names.join('、').replace(/[\r\n]+/g, ' ').replace(/[\\`*_[\]<>]/g, '\\$&');
46
+ links.set(data.setup_url, `[设置 ${label} 连接](<${url.href.replace(/</g, '%3C').replace(/>/g, '%3E')}>)`);
47
+ }
48
+ return [...links.values()];
49
+ }
50
+
51
+ // Message role alone is insufficient: Dot is also a user-shaped room member.
52
+ export function dotsRoomTurns(room, messages) {
53
+ return messages.map(message => {
54
+ const member = room.members.find(value => value.account_user_id === message.account_user_id);
55
+ const assistant = Array.isArray(message.raw_messages) || Boolean(member?.aeon_id);
56
+ const time = Date.parse(message.created_at);
57
+ const common = { id: message.id, startedAtMs: Number.isFinite(time) ? time : undefined,
58
+ completedAtMs: Number.isFinite(time) ? time : undefined };
59
+ const rawText = Array.isArray(message.raw_messages) ? message.raw_messages
60
+ .filter(raw => raw.author?.role === 'assistant' && raw.channel !== 'analysis'
61
+ && !raw.metadata?.is_hidden && !raw.metadata?.hidden && ['text', 'multimodal_text'].includes(raw.content?.content_type))
62
+ .flatMap(raw => (raw.content.parts || []).filter(part => typeof part === 'string')).join('\n\n')
63
+ : message.content?.text || '';
64
+ const sourceAttachments = message.content?.attachments || message.attachments || [];
65
+ const text = assistant ? [rawText, ...pluginSetupLinks(sourceAttachments)].filter(Boolean).join('\n\n')
66
+ : member ? appshotMessageBody(rawText) : rawText;
67
+ const attachments = sourceAttachments.flatMap(attachment => {
68
+ if (attachment.type !== 'file' || typeof attachment.file_id !== 'string') return [];
69
+ const file = attachment.file || {};
70
+ return [{ type: /^image\//.test(file.mime_type || '') ? 'image' : 'file',
71
+ roomId: room.id, fileId: attachment.file_id, name: file.name || file.file_name || '附件',
72
+ mimeType: file.mime_type || '', size: file.size_bytes }];
73
+ });
74
+ let item;
75
+ if (!message.deleted_at && message.content?.type !== 'message_error') {
76
+ if (assistant) item = { ...common, type: 'agentMessage', text, attachments, phase: 'final', delivery: 'async',
77
+ ...(message.generation?.status === 'in_progress' ? { dotsStreaming: true, completedAtMs: null } : {}) };
78
+ else if (member) item = { ...common, type: 'userMessage', clientId: message.request_id?.replace(/-/g, ''),
79
+ content: [...(text ? [{ type: 'text', text }] : []), ...attachments] };
80
+ }
81
+ const request = message.content?.elicitation;
82
+ const approval = !message.deleted_at && request && typeof request.request_id === 'string' && request.request_id
83
+ && typeof request.thread_id === 'string' && request.thread_id && request.params?.threadId === request.thread_id
84
+ && ['pending', 'resolved', 'expired'].includes(request.status)
85
+ ? { type: 'approval', id: `approval:string:${request.request_id}`, requestId: request.request_id,
86
+ method: 'mcpServer/elicitation/request', params: request.params, status: request.status, result: null,
87
+ sourceThreadId: request.thread_id, turnId: request.turn_id ?? null, receivedAtMs: time,
88
+ completedAtMs: null, roomMessageId: message.id } : null;
89
+ return { id: message.id, status: item?.dotsStreaming ? 'inProgress' : 'completed',
90
+ roomMessage: true, deleted: Boolean(message.deleted_at), createdAt: message.created_at,
91
+ updatedAt: message.deleted_at || message.updated_at || message.created_at,
92
+ items: [...(item && (text || attachments.length) ? [item] : []), ...(approval ? [approval] : [])] };
93
+ });
94
+ }
@@ -1,66 +1,66 @@
1
- import http2 from 'node:http2';
2
-
3
- // Desktop 26.930.3748.0: state-42dba351d73f lists this Dot's automations,
4
- // and F8 excludes finished schedules while retaining condition watches.
5
- export async function readDotsSchedules(dotsServer, threadId) {
6
- await dotsServer.connect();
7
- await dotsServer.source(threadId, 'aeon');
8
- const identity = dotsServer.profileIdentity;
9
- const auth = await dotsServer.localServer.request('getAuthStatus', { includeToken: true, refreshToken: false });
10
- const principal = JSON.parse(Buffer.from(auth.authToken.split('.')[1], 'base64url').toString('utf8'))['https://api.openai.com/auth'];
11
- if (!identity || identity.accountId !== principal?.chatgpt_account_id || identity.userId !== principal?.chatgpt_user_id) {
12
- throw new Error('点点账号已变化,请重新连接。');
13
- }
14
- const session = http2.connect('https://chatgpt.com');
15
- // Stream errors carry failures to the caller; consume the corresponding
16
- // session event so a failed connection does not crash the workstation.
17
- session.on('error', () => {});
18
- const get = path => new Promise((resolve, reject) => {
19
- const request = session.request({ ':method': 'GET', ':path': '/backend-api' + path,
20
- authorization: `Bearer ${auth.authToken}`, 'chatgpt-account-id': identity.accountId,
21
- 'user-agent': 'Code-Relax/0.1.0', accept: 'application/json' });
22
- let status, contentType, body = '', size = 0;
23
- const timeout = setTimeout(() => request.destroy(new Error('读取点点定时任务超时。')), 60000);
24
- request.setEncoding('utf8');
25
- request.on('response', headers => { status = headers[':status']; contentType = headers['content-type']; });
26
- request.on('data', chunk => {
27
- size += Buffer.byteLength(chunk);
28
- if (size > 8 * 1024 * 1024) request.destroy(new Error('点点定时任务响应过大。'));
29
- else body += chunk;
30
- });
31
- request.on('error', reject);
32
- request.on('close', () => clearTimeout(timeout));
33
- request.on('end', () => {
34
- try {
35
- if (status !== 200) throw new Error(`读取点点定时任务失败(HTTP ${status})。`);
36
- if (!contentType?.includes('application/json')) throw new Error('点点定时任务返回了非 JSON 响应。');
37
- resolve(JSON.parse(body));
38
- } catch (error) { reject(error); }
39
- });
40
- request.end();
41
- });
42
- try {
43
- const profile = await get(`/tbo/by-thread/${encodeURIComponent(threadId)}`);
44
- if (typeof profile.id !== 'string' || !profile.id) throw new Error('点点资料缺少身份。');
45
- const schedules = [];
46
- let cursor;
47
- do {
48
- const query = new URLSearchParams({ limit: '100', ...(cursor ? { cursor } : {}) });
49
- const page = await get(`/tbo/${encodeURIComponent(profile.id)}/automations?${query}`);
50
- if (!Array.isArray(page.items) || page.cursor != null && typeof page.cursor !== 'string') throw new Error('点点定时任务列表格式无效。');
51
- for (const item of page.items) {
52
- if (typeof item.id !== 'string' || typeof item.title !== 'string' || typeof item.is_enabled !== 'boolean'
53
- || !Array.isArray(item.next_run_times)) throw new Error('点点定时任务信息不完整。');
54
- const watching = item.timing_mode === 'condition_watch';
55
- if (item.executor !== 'local' && !watching && item.next_run_times.length === 0) continue;
56
- schedules.push({ id: item.id, title: item.display_title?.trim() || item.title.trim(),
57
- status: !item.is_enabled ? 'paused' : watching ? 'monitoring' : 'scheduled',
58
- schedule: watching ? '' : item.display_schedule || '',
59
- nextRunAt: item.is_enabled && !watching ? item.next_run_times[0] || null : null });
60
- }
61
- cursor = page.cursor;
62
- } while (cursor);
63
- if (dotsServer.profileIdentity !== identity) throw new Error('点点连接已变化,请重新读取。');
64
- return { threadId, schedules };
65
- } finally { session.destroy(); }
66
- }
1
+ import http2 from 'node:http2';
2
+
3
+ // Desktop 26.930.3748.0: state-42dba351d73f lists this Dot's automations,
4
+ // and F8 excludes finished schedules while retaining condition watches.
5
+ export async function readDotsSchedules(dotsServer, threadId) {
6
+ await dotsServer.connect();
7
+ await dotsServer.source(threadId, 'aeon');
8
+ const identity = dotsServer.profileIdentity;
9
+ const auth = await dotsServer.localServer.request('getAuthStatus', { includeToken: true, refreshToken: false });
10
+ const principal = JSON.parse(Buffer.from(auth.authToken.split('.')[1], 'base64url').toString('utf8'))['https://api.openai.com/auth'];
11
+ if (!identity || identity.accountId !== principal?.chatgpt_account_id || identity.userId !== principal?.chatgpt_user_id) {
12
+ throw new Error('点点账号已变化,请重新连接。');
13
+ }
14
+ const session = http2.connect('https://chatgpt.com');
15
+ // Stream errors carry failures to the caller; consume the corresponding
16
+ // session event so a failed connection does not crash the workstation.
17
+ session.on('error', () => {});
18
+ const get = path => new Promise((resolve, reject) => {
19
+ const request = session.request({ ':method': 'GET', ':path': '/backend-api' + path,
20
+ authorization: `Bearer ${auth.authToken}`, 'chatgpt-account-id': identity.accountId,
21
+ 'user-agent': 'Code-Relax/0.1.0', accept: 'application/json' });
22
+ let status, contentType, body = '', size = 0;
23
+ const timeout = setTimeout(() => request.destroy(new Error('读取点点定时任务超时。')), 60000);
24
+ request.setEncoding('utf8');
25
+ request.on('response', headers => { status = headers[':status']; contentType = headers['content-type']; });
26
+ request.on('data', chunk => {
27
+ size += Buffer.byteLength(chunk);
28
+ if (size > 8 * 1024 * 1024) request.destroy(new Error('点点定时任务响应过大。'));
29
+ else body += chunk;
30
+ });
31
+ request.on('error', reject);
32
+ request.on('close', () => clearTimeout(timeout));
33
+ request.on('end', () => {
34
+ try {
35
+ if (status !== 200) throw new Error(`读取点点定时任务失败(HTTP ${status})。`);
36
+ if (!contentType?.includes('application/json')) throw new Error('点点定时任务返回了非 JSON 响应。');
37
+ resolve(JSON.parse(body));
38
+ } catch (error) { reject(error); }
39
+ });
40
+ request.end();
41
+ });
42
+ try {
43
+ const profile = await get(`/tbo/by-thread/${encodeURIComponent(threadId)}`);
44
+ if (typeof profile.id !== 'string' || !profile.id) throw new Error('点点资料缺少身份。');
45
+ const schedules = [];
46
+ let cursor;
47
+ do {
48
+ const query = new URLSearchParams({ limit: '100', ...(cursor ? { cursor } : {}) });
49
+ const page = await get(`/tbo/${encodeURIComponent(profile.id)}/automations?${query}`);
50
+ if (!Array.isArray(page.items) || page.cursor != null && typeof page.cursor !== 'string') throw new Error('点点定时任务列表格式无效。');
51
+ for (const item of page.items) {
52
+ if (typeof item.id !== 'string' || typeof item.title !== 'string' || typeof item.is_enabled !== 'boolean'
53
+ || !Array.isArray(item.next_run_times)) throw new Error('点点定时任务信息不完整。');
54
+ const watching = item.timing_mode === 'condition_watch';
55
+ if (item.executor !== 'local' && !watching && item.next_run_times.length === 0) continue;
56
+ schedules.push({ id: item.id, title: item.display_title?.trim() || item.title.trim(),
57
+ status: !item.is_enabled ? 'paused' : watching ? 'monitoring' : 'scheduled',
58
+ schedule: watching ? '' : item.display_schedule || '',
59
+ nextRunAt: item.is_enabled && !watching ? item.next_run_times[0] || null : null });
60
+ }
61
+ cursor = page.cursor;
62
+ } while (cursor);
63
+ if (dotsServer.profileIdentity !== identity) throw new Error('点点连接已变化,请重新读取。');
64
+ return { threadId, schedules };
65
+ } finally { session.destroy(); }
66
+ }
@@ -1,32 +1,32 @@
1
- import events from '../shared/app-server-events.cjs';
2
-
3
- export async function readDotsSummaryTasks(dotsServer, threadId) {
4
- await dotsServer.source(threadId, 'aeon');
5
- const catalog = await dotsServer.taskCatalog(false);
6
- // Use the existing account-scoped local profile map, without a remote profile
7
- // request. A Dot keeps its identity when its active root thread changes.
8
- await dotsServer.refreshProfiles();
9
- const identity = dotsServer.profileIdentity;
10
- const profileId = dotsServer.profileNames.get(threadId)?.profileId;
11
- const tasks = await Promise.all(catalog.filter(thread => thread.threadSource === 'aeon_child').map(async thread => {
12
- const page = await dotsServer.nativeRequest('thread/items/list', {
13
- threadId: thread.id, limit: 1, sortDirection: 'asc',
14
- });
15
- if (!Array.isArray(page.data)) throw new Error('点点任务未返回委派来源。');
16
- const item = page.data[0]?.item;
17
- if (item?.type !== 'userMessage' || !Array.isArray(item.content)
18
- || !item.content.some(part => {
19
- const sourceId = part.type === 'text' && events.parseCodexDelegation(part.text)?.sourceThreadId;
20
- return sourceId && (sourceId === threadId || profileId
21
- && dotsServer.profileNames.get(sourceId)?.profileId === profileId);
22
- })) return null;
23
-
24
- return {
25
- id: thread.id, hostId: 'durable', threadSource: 'aeon_child',
26
- title: thread.name?.trim() || '未命名任务', cwd: thread.cwd,
27
- recencyAt: thread.recencyAt ?? thread.updatedAt,
28
- };
29
- }));
30
- if (identity !== dotsServer.profileIdentity) throw new Error('点点账号已变化,请重新读取任务。');
31
- return { threadId, tasks: tasks.filter(task => task !== null) };
32
- }
1
+ import events from '../shared/app-server-events.cjs';
2
+
3
+ export async function readDotsSummaryTasks(dotsServer, threadId) {
4
+ await dotsServer.source(threadId, 'aeon');
5
+ const catalog = await dotsServer.taskCatalog(false);
6
+ // Use the existing account-scoped local profile map, without a remote profile
7
+ // request. A Dot keeps its identity when its active root thread changes.
8
+ await dotsServer.refreshProfiles();
9
+ const identity = dotsServer.profileIdentity;
10
+ const profileId = dotsServer.profileNames.get(threadId)?.profileId;
11
+ const tasks = await Promise.all(catalog.filter(thread => thread.threadSource === 'aeon_child').map(async thread => {
12
+ const page = await dotsServer.nativeRequest('thread/items/list', {
13
+ threadId: thread.id, limit: 1, sortDirection: 'asc',
14
+ });
15
+ if (!Array.isArray(page.data)) throw new Error('点点任务未返回委派来源。');
16
+ const item = page.data[0]?.item;
17
+ if (item?.type !== 'userMessage' || !Array.isArray(item.content)
18
+ || !item.content.some(part => {
19
+ const sourceId = part.type === 'text' && events.parseCodexDelegation(part.text)?.sourceThreadId;
20
+ return sourceId && (sourceId === threadId || profileId
21
+ && dotsServer.profileNames.get(sourceId)?.profileId === profileId);
22
+ })) return null;
23
+
24
+ return {
25
+ id: thread.id, hostId: 'durable', threadSource: 'aeon_child',
26
+ title: thread.name?.trim() || '未命名任务', cwd: thread.cwd,
27
+ recencyAt: thread.recencyAt ?? thread.updatedAt,
28
+ };
29
+ }));
30
+ if (identity !== dotsServer.profileIdentity) throw new Error('点点账号已变化,请重新读取任务。');
31
+ return { threadId, tasks: tasks.filter(task => task !== null) };
32
+ }