arco-workbench 0.1.3 → 0.1.4

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 (296) hide show
  1. package/CONTRIBUTING.md +1 -1
  2. package/README.md +5 -1
  3. package/client/dist/assets/{PhosphorBackdrop-CkVIGkeX.js → PhosphorBackdrop-CNumba2X.js} +1 -1
  4. package/client/dist/assets/{ThemedBackgroundShaderImpl-DHF7CnpE.js → ThemedBackgroundShaderImpl-DX5KyCt3.js} +1 -1
  5. package/client/dist/assets/{XtermView-SY0UcZUS.js → XtermView-DhS5g8Rt.js} +1 -1
  6. package/client/dist/assets/{galleryEditor-Ca4F8HiM.js → galleryEditor-fPb76Cjv.js} +1 -1
  7. package/client/dist/assets/index-CjkHb-_n.js +592 -0
  8. package/client/dist/assets/index-DIbh3ae5.css +1 -0
  9. package/client/dist/index.html +2 -2
  10. package/client/src/App.tsx +2 -0
  11. package/client/src/alerts/desktopAlerts.ts +13 -1
  12. package/client/src/brief/briefFacts.ts +22 -0
  13. package/client/src/brief/briefFromStore.ts +7 -2
  14. package/client/src/components/ArtifactMoveDialog.tsx +64 -0
  15. package/client/src/components/BriefControl.tsx +38 -47
  16. package/client/src/components/CatchMeUp.tsx +25 -25
  17. package/client/src/components/CheckpointActions.tsx +7 -4
  18. package/client/src/components/ClusterComposerButtons.tsx +6 -3
  19. package/client/src/components/ClusterPlanTab.tsx +15 -1
  20. package/client/src/components/ClusterRightPanel/AutoPickupControl.tsx +6 -2
  21. package/client/src/components/ClusterTab.tsx +33 -3
  22. package/client/src/components/ClusterTaskBoardTab.tsx +62 -8
  23. package/client/src/components/DialogShell.tsx +115 -0
  24. package/client/src/components/DocsUpdateDialog.tsx +16 -42
  25. package/client/src/components/ForwardMessages.tsx +28 -32
  26. package/client/src/components/GitDialog.tsx +52 -52
  27. package/client/src/components/GitOtherWork.tsx +4 -2
  28. package/client/src/components/HandoffDialog.tsx +19 -45
  29. package/client/src/components/Home/HomeView.tsx +36 -8
  30. package/client/src/components/Home/home.css +7 -0
  31. package/client/src/components/KeepButton.tsx +23 -0
  32. package/client/src/components/MdTuneupDialog.tsx +52 -51
  33. package/client/src/components/MemberCard.tsx +4 -1
  34. package/client/src/components/MemberPane.tsx +1 -1
  35. package/client/src/components/NotificationCenter.tsx +4 -3
  36. package/client/src/components/NotificationChannelsSettings.tsx +25 -7
  37. package/client/src/components/PlanCandidateBanner.tsx +111 -57
  38. package/client/src/components/PlanComposerDialog.tsx +55 -87
  39. package/client/src/components/ProjectStateNotice.tsx +60 -0
  40. package/client/src/components/PublicProjectBox.tsx +25 -0
  41. package/client/src/components/ResearchDialog.tsx +15 -24
  42. package/client/src/components/ReviewDialog.tsx +32 -57
  43. package/client/src/components/RightPanel/OutputsPanel.tsx +4 -0
  44. package/client/src/components/RightPanel/PlanTab.tsx +24 -2
  45. package/client/src/components/RightPanel/UsageTab.tsx +77 -1
  46. package/client/src/components/SkillEditorDialog.tsx +38 -73
  47. package/client/src/components/SpawnDialog.tsx +19 -41
  48. package/client/src/components/StorageWarnings.tsx +21 -0
  49. package/client/src/components/SystemHeader.tsx +2 -2
  50. package/client/src/components/TerminalInput.tsx +6 -2
  51. package/client/src/components/TidyComposer.tsx +24 -41
  52. package/client/src/components/TranscriptSendDialog.tsx +151 -202
  53. package/client/src/components/UtilityAgentPicker.tsx +4 -2
  54. package/client/src/components/WorkflowCreator/index.tsx +2 -0
  55. package/client/src/components/WorkflowView.tsx +4 -1
  56. package/client/src/components/clusterNeedsYou.ts +35 -3
  57. package/client/src/components/compare/CompareDialog.tsx +26 -2
  58. package/client/src/components/terminalInput/planDraft.ts +33 -4
  59. package/client/src/components/utilityResult.ts +5 -1
  60. package/client/src/explorer/ExplorerApp.tsx +5 -2
  61. package/client/src/explorer/PlansLens.tsx +60 -19
  62. package/client/src/explorer/StorageLens.tsx +275 -0
  63. package/client/src/explorer/launch.ts +3 -3
  64. package/client/src/explorer/plansGrouping.ts +15 -0
  65. package/client/src/help/content/cluster.tsx +42 -7
  66. package/client/src/help/content/composer.tsx +26 -6
  67. package/client/src/help/content/header.tsx +16 -14
  68. package/client/src/help/content/misc.tsx +141 -6
  69. package/client/src/help/content/rightPanel.tsx +16 -0
  70. package/client/src/help/content/settings.tsx +4 -4
  71. package/client/src/help/manualSections/actions.tsx +19 -4
  72. package/client/src/help/manualSections/clusters.tsx +29 -16
  73. package/client/src/help/manualSections/configuration.tsx +6 -4
  74. package/client/src/help/manualSections/maintenance.tsx +27 -5
  75. package/client/src/help/manualSections/plans.tsx +96 -2
  76. package/client/src/help/manualSections/powerFeatures.tsx +2 -2
  77. package/client/src/help/manualSections/reference.tsx +6 -0
  78. package/client/src/help/manualSections/workspace.tsx +9 -5
  79. package/client/src/stores/appStore.ts +10 -1
  80. package/client/src/stores/appStore.types.ts +2 -0
  81. package/client/src/stores/mdTuneupStore.ts +5 -4
  82. package/client/src/stores/memoryTrim.ts +18 -2
  83. package/client/src/stores/storageWarningStore.ts +18 -0
  84. package/client/src/utils/gitDialogMemory.ts +26 -0
  85. package/client/src/utils/historyEvents.ts +1 -0
  86. package/client/src/utils/homeModel.ts +19 -0
  87. package/client/src/utils/publicProject.ts +56 -0
  88. package/client/src/ws/handleServerMessage.ts +7 -2
  89. package/docs/ARCHITECTURE.md +1 -1
  90. package/docs/CHECKPOINTS.md +2 -0
  91. package/docs/CLIENT.md +29 -11
  92. package/docs/FEATURES.md +14 -11
  93. package/docs/GETTING_STARTED.md +7 -7
  94. package/docs/GLOSSARY.md +3 -3
  95. package/docs/GOTCHAS.md +3 -2
  96. package/docs/HTTP_API.md +31 -1
  97. package/docs/NOTIFICATIONS.md +13 -14
  98. package/docs/OPERATIONS.md +27 -1
  99. package/docs/OPERATOR_ACTIONS.md +1 -1
  100. package/docs/OUTPUTS.md +9 -0
  101. package/docs/PERSISTENCE.md +34 -4
  102. package/docs/PLAN_OR_BOARD.md +7 -0
  103. package/docs/PRIMITIVES.md +3 -3
  104. package/docs/PROTOCOL.md +14 -4
  105. package/docs/PROTOCOL_CLUSTER.md +3 -2
  106. package/docs/SERVICE_MODE.md +5 -1
  107. package/docs/SETTINGS.md +8 -6
  108. package/docs/STORAGE_PLAN.md +324 -0
  109. package/docs/TASK_LEDGER.md +5 -4
  110. package/native/linux-arm64/manifest.json +1 -1
  111. package/node_modules/@arco/shared/dist/index.d.ts +2 -0
  112. package/node_modules/@arco/shared/dist/index.js +2 -0
  113. package/node_modules/@arco/shared/dist/protocol/autoPickup.d.ts +1 -1
  114. package/node_modules/@arco/shared/dist/protocol/autoPickup.js +1 -1
  115. package/node_modules/@arco/shared/dist/protocol/checkpoints.d.ts +1 -0
  116. package/node_modules/@arco/shared/dist/protocol/clusters.d.ts +2 -1
  117. package/node_modules/@arco/shared/dist/protocol/index.d.ts +1 -0
  118. package/node_modules/@arco/shared/dist/protocol/index.js +1 -0
  119. package/node_modules/@arco/shared/dist/protocol/mdTuneup.d.ts +6 -0
  120. package/node_modules/@arco/shared/dist/protocol/notifications.d.ts +2 -1
  121. package/node_modules/@arco/shared/dist/protocol/notifications.js +3 -2
  122. package/node_modules/@arco/shared/dist/protocol/plans.d.ts +2 -0
  123. package/node_modules/@arco/shared/dist/protocol/serverMessages.d.ts +2 -1
  124. package/node_modules/@arco/shared/dist/protocol/storage.d.ts +21 -0
  125. package/node_modules/@arco/shared/dist/protocol/storage.js +3 -0
  126. package/node_modules/@arco/shared/dist/protocol/tasks.d.ts +3 -0
  127. package/node_modules/@arco/shared/dist/protocol/utilityAgent.d.ts +2 -2
  128. package/node_modules/@arco/shared/dist/protocol/utilityAgent.js +2 -2
  129. package/node_modules/@arco/shared/dist/publicGuardrails.d.ts +7 -0
  130. package/node_modules/@arco/shared/dist/publicGuardrails.js +47 -0
  131. package/node_modules/@arco/shared/dist/publicSafetyRules.d.ts +1 -0
  132. package/node_modules/@arco/shared/dist/publicSafetyRules.js +6 -0
  133. package/node_modules/@arco/shared/package.json +1 -1
  134. package/package.json +3 -2
  135. package/scripts/packaging/arco.mjs +17 -1
  136. package/scripts/packaging/services.mjs +35 -5
  137. package/scripts/packaging/storage.mjs +125 -0
  138. package/scripts/packaging/update.mjs +3 -3
  139. package/server/dist/artifactCopy.d.ts +26 -0
  140. package/server/dist/artifactCopy.js +398 -0
  141. package/server/dist/atomicFile.d.ts +1 -0
  142. package/server/dist/atomicFile.js +1 -1
  143. package/server/dist/attention.d.ts +1 -1
  144. package/server/dist/attention.js +10 -13
  145. package/server/dist/catchUp.d.ts +2 -0
  146. package/server/dist/catchUp.js +46 -23
  147. package/server/dist/clusterPeerOps.d.ts +2 -0
  148. package/server/dist/clusterPeerOps.js +2 -0
  149. package/server/dist/clusterSnapshots.js +22 -12
  150. package/server/dist/eventLog.d.ts +55 -0
  151. package/server/dist/eventLog.js +792 -0
  152. package/server/dist/explorerLaunch.d.ts +4 -1
  153. package/server/dist/explorerLaunch.js +3 -2
  154. package/server/dist/explorerPlans.d.ts +4 -0
  155. package/server/dist/explorerPlans.js +27 -2
  156. package/server/dist/http/clusterRoutes.js +2 -0
  157. package/server/dist/http/explorerRoutes.js +2 -1
  158. package/server/dist/http/publicProjectRoutes.d.ts +2 -0
  159. package/server/dist/http/publicProjectRoutes.js +68 -0
  160. package/server/dist/http/router.js +6 -0
  161. package/server/dist/http/storageRoutes.d.ts +2 -0
  162. package/server/dist/http/storageRoutes.js +254 -0
  163. package/server/dist/http/usageStatsRoutes.js +3 -12
  164. package/server/dist/index.js +4 -0
  165. package/server/dist/keepStore.d.ts +16 -0
  166. package/server/dist/keepStore.js +119 -0
  167. package/server/dist/management/clusterActivity.js +6 -20
  168. package/server/dist/management/initHubLink.js +10 -43
  169. package/server/dist/mcp/clusterMcpTools.js +8 -1
  170. package/server/dist/notifications.d.ts +3 -1
  171. package/server/dist/notifications.js +5 -4
  172. package/server/dist/outputStore.d.ts +1 -0
  173. package/server/dist/outputStore.js +1 -1
  174. package/server/dist/outputs.js +39 -8
  175. package/server/dist/planHistory.d.ts +3 -0
  176. package/server/dist/planHistory.js +60 -0
  177. package/server/dist/primitives/runMdTuneup.d.ts +5 -1
  178. package/server/dist/primitives/runMdTuneup.js +43 -2
  179. package/server/dist/project/taskLedger.d.ts +4 -0
  180. package/server/dist/project/taskLedger.js +19 -0
  181. package/server/dist/providers/claude-native/peerTools.js +4 -0
  182. package/server/dist/providers/claude-native/resumeSummary.js +30 -19
  183. package/server/dist/providers/index.js +8 -13
  184. package/server/dist/providers/localProviderQueue.d.ts +2 -0
  185. package/server/dist/providers/localProviderQueue.js +11 -0
  186. package/server/dist/publicProject.d.ts +54 -0
  187. package/server/dist/publicProject.js +135 -0
  188. package/server/dist/recall/index.js +22 -23
  189. package/server/dist/server/broadcast.d.ts +2 -1
  190. package/server/dist/server/broadcast.js +56 -1
  191. package/server/dist/smartPickupAdapters.d.ts +7 -0
  192. package/server/dist/smartPickupAdapters.js +172 -8
  193. package/server/dist/storageActions.d.ts +50 -0
  194. package/server/dist/storageActions.js +326 -0
  195. package/server/dist/storageArchive.d.ts +24 -0
  196. package/server/dist/storageArchive.js +358 -0
  197. package/server/dist/storageOverview.d.ts +47 -0
  198. package/server/dist/storageOverview.js +197 -0
  199. package/server/dist/storageReport.d.ts +48 -0
  200. package/server/dist/storageReport.js +185 -0
  201. package/server/dist/storageWarnings.d.ts +4 -0
  202. package/server/dist/storageWarnings.js +96 -0
  203. package/server/dist/workers/limits.js +4 -1
  204. package/server/dist/workflowStore.d.ts +2 -0
  205. package/server/dist/workflowStore.js +88 -72
  206. package/server/dist/workflows/purgeWorkflow.d.ts +1 -0
  207. package/server/dist/workflows/purgeWorkflow.js +15 -2
  208. package/server/dist/workflows/sessionDiscovery.js +5 -17
  209. package/server/dist/workflows/sessionIndex.js +22 -17
  210. package/server/dist/ws/taskLedgerHandlers.js +8 -3
  211. package/server/dist/ws/workflowHandlers.js +5 -4
  212. package/server/package.json +1 -1
  213. package/server/src/artifactCopy.ts +254 -0
  214. package/server/src/atomicFile.ts +1 -1
  215. package/server/src/attention.ts +9 -10
  216. package/server/src/catchUp.ts +37 -15
  217. package/server/src/clusterPeerOps.ts +5 -0
  218. package/server/src/clusterSnapshots.ts +20 -13
  219. package/server/src/eventLog.ts +571 -0
  220. package/server/src/explorerLaunch.ts +3 -2
  221. package/server/src/explorerPlans.ts +22 -2
  222. package/server/src/http/clusterRoutes.ts +4 -1
  223. package/server/src/http/explorerRoutes.ts +2 -1
  224. package/server/src/http/publicProjectRoutes.ts +54 -0
  225. package/server/src/http/router.ts +4 -0
  226. package/server/src/http/storageRoutes.ts +187 -0
  227. package/server/src/http/usageStatsRoutes.ts +3 -11
  228. package/server/src/index.ts +4 -0
  229. package/server/src/keepStore.ts +102 -0
  230. package/server/src/management/clusterActivity.ts +6 -16
  231. package/server/src/management/initHubLink.ts +10 -39
  232. package/server/src/mcp/clusterMcpTools.ts +8 -2
  233. package/server/src/notifications.ts +4 -3
  234. package/server/src/outputStore.ts +5 -2
  235. package/server/src/outputs.ts +30 -6
  236. package/server/src/planHistory.ts +48 -0
  237. package/server/src/primitives/runMdTuneup.ts +32 -2
  238. package/server/src/project/taskLedger.ts +20 -0
  239. package/server/src/providers/claude-native/peerTools.ts +4 -0
  240. package/server/src/providers/claude-native/resumeSummary.ts +32 -18
  241. package/server/src/providers/index.ts +2 -16
  242. package/server/src/providers/localProviderQueue.ts +13 -0
  243. package/server/src/publicProject.ts +142 -0
  244. package/server/src/recall/index.ts +4 -9
  245. package/server/src/server/broadcast.ts +53 -1
  246. package/server/src/smartPickupAdapters.ts +128 -5
  247. package/server/src/storageActions.ts +216 -0
  248. package/server/src/storageArchive.ts +277 -0
  249. package/server/src/storageOverview.ts +184 -0
  250. package/server/src/storageReport.ts +210 -0
  251. package/server/src/storageWarnings.ts +84 -0
  252. package/server/src/workers/limits.ts +4 -1
  253. package/server/src/workflowStore.ts +78 -61
  254. package/server/src/workflows/purgeWorkflow.ts +12 -3
  255. package/server/src/workflows/sessionDiscovery.ts +5 -13
  256. package/server/src/workflows/sessionIndex.ts +5 -9
  257. package/server/src/ws/taskLedgerHandlers.ts +8 -3
  258. package/server/src/ws/workflowHandlers.ts +5 -4
  259. package/shared/dist/index.d.ts +2 -0
  260. package/shared/dist/index.js +2 -0
  261. package/shared/dist/protocol/autoPickup.d.ts +1 -1
  262. package/shared/dist/protocol/autoPickup.js +1 -1
  263. package/shared/dist/protocol/checkpoints.d.ts +1 -0
  264. package/shared/dist/protocol/clusters.d.ts +2 -1
  265. package/shared/dist/protocol/index.d.ts +1 -0
  266. package/shared/dist/protocol/index.js +1 -0
  267. package/shared/dist/protocol/mdTuneup.d.ts +6 -0
  268. package/shared/dist/protocol/notifications.d.ts +2 -1
  269. package/shared/dist/protocol/notifications.js +3 -2
  270. package/shared/dist/protocol/plans.d.ts +2 -0
  271. package/shared/dist/protocol/serverMessages.d.ts +2 -1
  272. package/shared/dist/protocol/storage.d.ts +21 -0
  273. package/shared/dist/protocol/storage.js +3 -0
  274. package/shared/dist/protocol/tasks.d.ts +3 -0
  275. package/shared/dist/protocol/utilityAgent.d.ts +2 -2
  276. package/shared/dist/protocol/utilityAgent.js +2 -2
  277. package/shared/dist/publicGuardrails.d.ts +7 -0
  278. package/shared/dist/publicGuardrails.js +47 -0
  279. package/shared/dist/publicSafetyRules.d.ts +1 -0
  280. package/shared/dist/publicSafetyRules.js +6 -0
  281. package/shared/src/index.ts +3 -0
  282. package/shared/src/protocol/autoPickup.ts +1 -1
  283. package/shared/src/protocol/checkpoints.ts +4 -0
  284. package/shared/src/protocol/clusters.ts +6 -1
  285. package/shared/src/protocol/index.ts +1 -0
  286. package/shared/src/protocol/mdTuneup.ts +5 -0
  287. package/shared/src/protocol/notifications.ts +6 -2
  288. package/shared/src/protocol/plans.ts +2 -0
  289. package/shared/src/protocol/serverMessages.ts +2 -0
  290. package/shared/src/protocol/storage.ts +35 -0
  291. package/shared/src/protocol/tasks.ts +6 -0
  292. package/shared/src/protocol/utilityAgent.ts +2 -2
  293. package/shared/src/publicGuardrails.ts +50 -0
  294. package/shared/src/publicSafetyRules.ts +5 -0
  295. package/client/dist/assets/index-CcNtMA2y.js +0 -546
  296. package/client/dist/assets/index-Dl8tYsSp.css +0 -1
@@ -0,0 +1,84 @@
1
+ import { promises as fs } from 'node:fs';
2
+ import path from 'node:path';
3
+ import type { StorageWarningItem } from '@arco/shared';
4
+ import { atomicWriteFile, withFileLock } from './atomicFile.js';
5
+ import { isKept, readKeep } from './keepStore.js';
6
+
7
+ // Artifact size warnings (P7.4, docs/STORAGE_PLAN.md). Checked when a turn
8
+ // ends: an artifact file at or above the file threshold, or a conversation's
9
+ // artifacts at or above the conversation threshold, warns once. Thresholds are
10
+ // high on purpose (in the measured state 7 files and 2 conversations out of
11
+ // 1,895 would have warned). Kept items never warn.
12
+ const GiB = 1024 * 1024 * 1024;
13
+ function envBytes(name: string, fallback: number): number {
14
+ const n = Number(process.env[name]);
15
+ return Number.isFinite(n) && n > 0 ? Math.floor(n) : fallback;
16
+ }
17
+ export function fileWarnBytes(): number { return envBytes('ARCO_ARTIFACT_WARN_FILE_BYTES', GiB); }
18
+ export function conversationWarnBytes(): number { return envBytes('ARCO_ARTIFACT_WARN_CONVERSATION_BYTES', 5 * GiB); }
19
+
20
+ const STATE_FILE = 'storage-warnings.json';
21
+ const MAX_ENTRIES = 50_000;
22
+ interface WarnState { version: 1; files: Record<string, number>; conversationBytes: number }
23
+
24
+ async function readState(dir: string): Promise<WarnState> {
25
+ try {
26
+ const v = JSON.parse(await fs.readFile(path.join(dir, STATE_FILE), 'utf8')) as Partial<WarnState>;
27
+ if (v.version === 1 && v.files && typeof v.files === 'object' && typeof v.conversationBytes === 'number') return v as WarnState;
28
+ } catch { /* missing or unreadable: start fresh */ }
29
+ return { version: 1, files: {}, conversationBytes: 0 };
30
+ }
31
+
32
+ // Sizes under artifacts/, links never followed, bounded.
33
+ async function artifactSizes(dir: string): Promise<{ total: number; large: Array<{ rel: string; bytes: number }> }> {
34
+ const root = path.join(dir, 'artifacts');
35
+ const limit = fileWarnBytes();
36
+ let total = 0, seen = 0;
37
+ const large: Array<{ rel: string; bytes: number }> = [];
38
+ const stack = [root];
39
+ while (stack.length && seen < MAX_ENTRIES) {
40
+ const folder = stack.pop()!;
41
+ let entries;
42
+ try { entries = await fs.readdir(folder, { withFileTypes: true }); } catch { continue; }
43
+ for (const entry of entries) {
44
+ if (++seen > MAX_ENTRIES) break;
45
+ const p = path.join(folder, entry.name);
46
+ if (entry.isDirectory()) { stack.push(p); continue; }
47
+ if (!entry.isFile()) continue;
48
+ try {
49
+ const st = await fs.lstat(p);
50
+ if (!st.isFile()) continue;
51
+ total += st.size;
52
+ if (st.size >= limit) large.push({ rel: path.relative(dir, p).split(path.sep).join('/'), bytes: st.size });
53
+ } catch { /* vanished */ }
54
+ }
55
+ }
56
+ return { total, large };
57
+ }
58
+
59
+ // Returns the items that newly cross a threshold and records them, so each
60
+ // warns once. A conversation total warns again only after it grows by
61
+ // another conversation threshold.
62
+ export async function checkArtifactSizes(conversationDir: string): Promise<StorageWarningItem[]> {
63
+ return withFileLock(path.join(conversationDir, STATE_FILE), async () => {
64
+ const { total, large } = await artifactSizes(conversationDir);
65
+ const convLimit = conversationWarnBytes();
66
+ if (!large.length && total < convLimit) return [];
67
+ const keep = await readKeep(conversationDir);
68
+ const kept = keep.ok ? keep.items : [];
69
+ const state = await readState(conversationDir);
70
+ const items: StorageWarningItem[] = [];
71
+ for (const file of large) {
72
+ if (isKept(kept, file.rel) || state.files[file.rel] !== undefined) continue;
73
+ state.files[file.rel] = file.bytes;
74
+ items.push({ path: file.rel, bytes: file.bytes, kind: 'file' });
75
+ }
76
+ const next = state.conversationBytes ? state.conversationBytes + convLimit : convLimit;
77
+ if (total >= next && !isKept(kept, 'artifacts')) {
78
+ state.conversationBytes = total;
79
+ items.push({ path: 'artifacts', bytes: total, kind: 'conversation' });
80
+ }
81
+ if (items.length) await atomicWriteFile(path.join(conversationDir, STATE_FILE), JSON.stringify(state) + '\n');
82
+ return items;
83
+ });
84
+ }
@@ -68,6 +68,9 @@ export function buildWorkerSafetyFooter(cwd?: string, wfid?: string): string {
68
68
  ? `- For report-shaped outputs (deep dives, inventories, audits, multi-section findings), write a markdown file into \`${dir}/\` (this directory already exists) and return a brief summary that names the file in backticks (for example \`audit-spawns.md\`) so it is clickable in chat. Do NOT write report files at the project root — Arco tracks artifacts per-workflow and surfaces them inline in chat. For ordinary prose responses — even detailed ones — return the full text inline; the operator reads it in chat.`
69
69
  : `- For report-shaped outputs (deep dives, inventories, audits, multi-section findings), write a markdown file in the cwd and return a brief summary + absolute path. For ordinary prose responses — even detailed ones — return the full text inline; the operator reads it in chat.`;
70
70
 
71
+ const scratchLine = dir
72
+ ? `\n- Put large intermediate files (builds, disk images, downloads, datasets) in \`${path.join(path.dirname(dir), 'scratch')}/\` (create it if missing), not in artifacts. Keep only finished deliverables in artifacts. The operator empties scratch with EMPTY SCRATCH; nothing there is deleted automatically.`
73
+ : '';
71
74
  return `
72
75
 
73
76
  ---
@@ -76,7 +79,7 @@ export function buildWorkerSafetyFooter(cwd?: string, wfid?: string): string {
76
79
  - No \`find /\` / \`du -sh /\` without \`-maxdepth\` and exclusions for \`/proc /sys /dev /run\`. Skip \`~/.cache\`, \`node_modules\`, \`.git/objects\`, \`/var/cache\`, \`/snap\`.
77
80
  - No reads of \`/proc/kcore\`, \`/proc/*/mem\`, \`/dev/{kmem,mem,zero,urandom}\` past first KB. No unbounded \`journalctl\` or \`while true\` loops.
78
81
  - No \`cat\` of files >10MB; use \`head -c 100K\` instead. \`xargs\` always with explicit limits.
79
- ${bigOutputLine}
82
+ ${bigOutputLine}${scratchLine}
80
83
  - Arco will hard-kill your process tree at 32GB RSS or ${formatCapMb(MAX_WORKER_OUTPUT_BYTES)} returned output. These are the floor, not the budget.
81
84
  `;
82
85
  }
@@ -20,9 +20,12 @@ import { ensureProjectStateIgnore } from './projectStateIgnore.js';
20
20
  // don't get stranded.
21
21
  // - wfid must match a UUID-ish shape (path-scope defense).
22
22
 
23
- import { promises as fs, createReadStream } from 'fs';
24
- import { createInterface } from 'readline';
23
+ import { promises as fs } from 'fs';
25
24
  import path from 'path';
25
+ import {
26
+ LOG_FORMAT, firstSealedSeq, readLogFormat, readLogLines, readLogTail, sealLiveLog,
27
+ sealThresholdBytes, highestNamedSeq, type SealResult,
28
+ } from './eventLog.js';
26
29
  import type { ServerMessage } from '@arco/shared';
27
30
 
28
31
  const FLUSH_DEBOUNCE_MS = 100;
@@ -49,6 +52,14 @@ interface WorkflowBuffer {
49
52
  // check, the second's readLatestSeq landing AFTER the first had stamped
50
53
  // events — rolling buf.seq back and writing duplicate seqs to events.jsonl.
51
54
  initPromise: Promise<void> | null;
55
+ // Bytes in the live events.jsonl (P7.3). Sealing runs after an append that
56
+ // takes it past the seal threshold; a failed seal waits for another
57
+ // threshold's worth of growth before it is tried again.
58
+ liveBytes: number;
59
+ sealRetryAt: number;
60
+ // A log written by a newer release (format above LOG_FORMAT): events are
61
+ // still delivered live but not written, so the newer history is not damaged.
62
+ readOnly: boolean;
52
63
  }
53
64
 
54
65
  const buffers = new Map<string, WorkflowBuffer>();
@@ -122,6 +133,9 @@ export async function initWorkflowStore(cwd: string, wfid: string): Promise<void
122
133
  flushTimer: null,
123
134
  flushInFlight: null,
124
135
  initPromise: null,
136
+ liveBytes: 0,
137
+ sealRetryAt: 0,
138
+ readOnly: false,
125
139
  };
126
140
  buffers.set(key, buf);
127
141
  }
@@ -132,11 +146,19 @@ export async function initWorkflowStore(cwd: string, wfid: string): Promise<void
132
146
  async function primeBuffer(buf: WorkflowBuffer): Promise<void> {
133
147
  const { cwd, wfid } = buf;
134
148
  try {
135
- buf.seq = await readLatestSeq(eventsPath(cwd, wfid));
149
+ // A live file that holds no record (all of it sealed) falls back to the
150
+ // highest sequence number any segment name has claimed, damaged ones moved
151
+ // aside included, so no number is ever reused.
152
+ buf.seq = Math.max(await readLatestSeq(eventsPath(cwd, wfid)), await highestNamedSeq(workflowDir(cwd, wfid)));
136
153
  } catch (err) {
137
154
  console.error(`[arco] workflowStore init failed for ${wfid.slice(0, 8)}:`, err);
138
155
  buf.seq = 0;
139
156
  }
157
+ try { buf.liveBytes = (await fs.stat(eventsPath(cwd, wfid))).size; } catch { buf.liveBytes = 0; }
158
+ if (await readLogFormat(workflowDir(cwd, wfid)) > LOG_FORMAT) {
159
+ buf.readOnly = true;
160
+ console.error(`[arco] workflow ${wfid.slice(0, 8)}: its log was written by a newer Arco release; new events are shown but not saved. Update Arco to continue saving this conversation.`);
161
+ }
140
162
  // Protect all project state before creating the first workflow directory.
141
163
  ensureProjectStateIgnore(cwd);
142
164
  await fs.mkdir(path.join(workflowDir(cwd, wfid), 'artifacts'), { recursive: true });
@@ -164,7 +186,7 @@ export function persistAndStampSeq(
164
186
  ): ServerMessage {
165
187
  if (!cwd) return message;
166
188
  const buf = buffers.get(bufferKey(cwd, wfid));
167
- if (!buf || !buf.initialized) return message;
189
+ if (!buf || !buf.initialized || buf.readOnly) return message;
168
190
  // Phase 0 — link each event back to its predecessor for HISTORY (Phase 8)
169
191
  // and forks (Phase 9). Linear workflows: parent = previous seq. The very
170
192
  // first event has no parent (left undefined; readers treat absent as
@@ -233,6 +255,23 @@ async function flushBuffer(buf: WorkflowBuffer): Promise<void> {
233
255
  // sees on next reconnect triggers the snapshot-only fallback.
234
256
  return;
235
257
  }
258
+ buf.liveBytes += Buffer.byteLength(chunk);
259
+ // P7.3: seal the live file into compressed segments once it is large.
260
+ // Runs inside this flush chain, so nothing appends meanwhile; new events
261
+ // wait in `pending` and land in the fresh live file.
262
+ const threshold = sealThresholdBytes();
263
+ if (buf.liveBytes >= Math.max(threshold, buf.sealRetryAt)) {
264
+ try {
265
+ const sealed = await sealLiveLog(path.dirname(filePath), threshold);
266
+ if (sealed) buf.liveBytes = sealed.liveBytes;
267
+ // A live file that could not be replaced yet (held open on Windows)
268
+ // is tried again after a little more growth, not on every flush.
269
+ buf.sealRetryAt = sealed && !sealed.liveReplaced ? buf.liveBytes + Math.max(1024, Math.floor(threshold / 4)) : 0;
270
+ } catch (err) {
271
+ console.error(`[arco] sealing the log of ${buf.wfid.slice(0, 8)} failed; it stays a plain file:`, err);
272
+ buf.sealRetryAt = buf.liveBytes + threshold;
273
+ }
274
+ }
236
275
  }
237
276
  })();
238
277
  try {
@@ -242,6 +281,30 @@ async function flushBuffer(buf: WorkflowBuffer): Promise<void> {
242
281
  }
243
282
  }
244
283
 
284
+ // COMPRESS OLD LOGS (P7.3/P7.5): seal a conversation's live log now, inside
285
+ // its flush chain so no append can land between reading and replacing the
286
+ // live file. Pending events are written first; events arriving meanwhile
287
+ // wait and land in the new live file. Returns null when nothing was sealed.
288
+ export async function sealWorkflowLogNow(cwd: string, wfid: string): Promise<SealResult | null> {
289
+ validateWfid(wfid);
290
+ await initWorkflowStore(cwd, wfid);
291
+ const buf = buffers.get(bufferKey(cwd, wfid));
292
+ if (!buf) return null;
293
+ if (buf.readOnly) throw new Error('This conversation log uses a newer storage format.');
294
+ if (buf.flushTimer) { clearTimeout(buf.flushTimer); buf.flushTimer = null; }
295
+ await flushBuffer(buf);
296
+ while (buf.flushInFlight) await buf.flushInFlight;
297
+ let result: SealResult | null = null;
298
+ const run = (async () => {
299
+ result = await sealLiveLog(workflowDir(cwd, wfid), sealThresholdBytes());
300
+ if (result) buf.liveBytes = result.liveBytes;
301
+ })();
302
+ buf.flushInFlight = run;
303
+ try { await run; } finally { if (buf.flushInFlight === run) buf.flushInFlight = null; }
304
+ if (buf.pending.length) await flushBuffer(buf);
305
+ return result;
306
+ }
307
+
245
308
  // Flush a single workflow's pending events to disk now (clearing its debounce
246
309
  // timer). Used by the Genesis rebind (M2) before moving a workflow's on-disk
247
310
  // store from the scratch ideation dir to the real project dir — every queued
@@ -304,6 +367,8 @@ export async function getHeadSeq(cwd: string, wfid: string): Promise<number> {
304
367
  export async function readFirstSeq(cwd: string, wfid: string): Promise<number | null> {
305
368
  if (!cwd) return null;
306
369
  validateWfid(wfid);
370
+ const sealedFirst = await firstSealedSeq(workflowDir(cwd, wfid)).catch(() => null);
371
+ if (sealedFirst !== null) return sealedFirst;
307
372
  const filePath = eventsPath(cwd, wfid);
308
373
  let fh;
309
374
  try {
@@ -350,16 +415,8 @@ export async function replayEventsWithTs(
350
415
  }
351
416
  await flushBuffer(buf);
352
417
  }
353
- const filePath = eventsPath(cwd, wfid);
354
- let text: string;
355
- try {
356
- text = await fs.readFile(filePath, 'utf8');
357
- } catch (err) {
358
- if ((err as NodeJS.ErrnoException).code === 'ENOENT') return [];
359
- throw err;
360
- }
361
418
  const out: Array<{ ts: number; message: ServerMessage }> = [];
362
- for (const line of text.split('\n')) {
419
+ for await (const line of readLogLines(workflowDir(cwd, wfid), { fromSeq })) {
363
420
  if (!line.trim()) continue;
364
421
  let entry: { seq?: number; ts?: number; [k: string]: unknown };
365
422
  try {
@@ -394,16 +451,8 @@ export async function replayEvents(
394
451
  }
395
452
  await flushBuffer(buf);
396
453
  }
397
- const filePath = eventsPath(cwd, wfid);
398
- let text: string;
399
- try {
400
- text = await fs.readFile(filePath, 'utf8');
401
- } catch (err) {
402
- if ((err as NodeJS.ErrnoException).code === 'ENOENT') return [];
403
- throw err;
404
- }
405
454
  const out: ServerMessage[] = [];
406
- for (const line of text.split('\n')) {
455
+ for await (const line of readLogLines(workflowDir(cwd, wfid), { fromSeq })) {
407
456
  if (!line.trim()) continue;
408
457
  let entry: { seq?: number; ts?: number; [k: string]: unknown };
409
458
  try {
@@ -439,27 +488,12 @@ export async function replayTailEvents(
439
488
  }
440
489
  await flushBuffer(buf);
441
490
  }
442
- const filePath = eventsPath(cwd, wfid);
443
- let size: number;
444
- try {
445
- size = (await fs.stat(filePath)).size;
446
- } catch (err) {
447
- if ((err as NodeJS.ErrnoException).code === 'ENOENT') return { events: [], truncated: false };
448
- throw err;
449
- }
450
- if (size <= maxBytes) return { events: await replayEvents(cwd, wfid, 0), truncated: false };
451
- const fh = await fs.open(filePath, 'r');
452
- let text: string;
453
- try {
454
- const chunk = Buffer.alloc(maxBytes);
455
- const { bytesRead } = await fh.read(chunk, 0, maxBytes, size - maxBytes);
456
- text = chunk.subarray(0, bytesRead).toString('utf8');
457
- } finally {
458
- await fh.close();
459
- }
491
+ // Live tail, plus the newest sealed segments when the live file is short.
492
+ const tail = await readLogTail(workflowDir(cwd, wfid), maxBytes);
493
+ if (!tail.truncated) return { events: await replayEvents(cwd, wfid, 0), truncated: false };
460
494
  // The first line is almost certainly cut mid-record (and may start mid
461
495
  // UTF-8 sequence) — drop it.
462
- const lines = text.split('\n').slice(1);
496
+ const lines = tail.text.split('\n').slice(1);
463
497
  const parsed: Array<{ type?: string; [k: string]: unknown }> = [];
464
498
  for (const line of lines) {
465
499
  if (!line.trim()) continue;
@@ -499,10 +533,8 @@ export async function scanEventsOfTypes(
499
533
  }
500
534
  const needles = types.map((t) => `"${t}"`);
501
535
  const out: ServerMessage[] = [];
502
- const stream = createReadStream(eventsPath(cwd, wfid), { encoding: 'utf8' });
503
- try {
504
- const rl = createInterface({ input: stream, crlfDelay: Infinity });
505
- for await (const line of rl) {
536
+ {
537
+ for await (const line of readLogLines(workflowDir(cwd, wfid))) {
506
538
  if (!needles.some((n) => line.includes(n))) continue;
507
539
  let entry: { seq?: number; ts?: number; type?: string; [k: string]: unknown };
508
540
  try {
@@ -517,11 +549,6 @@ export async function scanEventsOfTypes(
517
549
  if (visit) visit(event);
518
550
  else out.push(event);
519
551
  }
520
- } catch (err) {
521
- if ((err as NodeJS.ErrnoException).code === 'ENOENT') return [];
522
- throw err;
523
- } finally {
524
- stream.destroy();
525
552
  }
526
553
  return out;
527
554
  }
@@ -542,18 +569,8 @@ export async function readEventsPageBefore(
542
569
  }
543
570
  await flushBuffer(buf);
544
571
  }
545
- const filePath = eventsPath(cwd, wfid);
546
- let text: string;
547
- try {
548
- text = await fs.readFile(filePath, 'utf8');
549
- } catch (err) {
550
- if ((err as NodeJS.ErrnoException).code === 'ENOENT') {
551
- return { events: [], hasEarlier: false, total: 0 };
552
- }
553
- throw err;
554
- }
555
572
  const parsed: ServerMessage[] = [];
556
- for (const line of text.split('\n')) {
573
+ for await (const line of readLogLines(workflowDir(cwd, wfid))) {
557
574
  if (!line.trim()) continue;
558
575
  let entry: { seq?: number; ts?: number; [k: string]: unknown };
559
576
  try {
@@ -14,7 +14,7 @@
14
14
  // caller logs what was removed. There is no undo; the type-to-confirm gate on the
15
15
  // nuclear tier is the only guard (enforced at the route).
16
16
 
17
- import { rm, readdir, unlink, readFile } from 'node:fs/promises';
17
+ import { lstat, rm, readdir, unlink, readFile } from 'node:fs/promises';
18
18
  import { homedir } from 'node:os';
19
19
  import { join } from 'node:path';
20
20
  import { execFile } from 'node:child_process';
@@ -104,9 +104,16 @@ async function deleteProviderSessions(
104
104
  export async function purgeWorkflow(
105
105
  cwd: string,
106
106
  wfid: string,
107
- opts: { nuclear: boolean },
107
+ opts: { nuclear: boolean; removeDir?: (dir: string) => Promise<void> },
108
108
  ): Promise<PurgeResult> {
109
109
  const removed: string[] = [];
110
+ // A link in the way (the project's .arco, .arco/workflows or the workflow
111
+ // folder) is never followed: refuse before anything is torn down.
112
+ for (const rel of ['.arco', join('.arco', 'workflows'), join('.arco', 'workflows', wfid)]) {
113
+ try {
114
+ if ((await lstat(join(cwd, rel))).isSymbolicLink()) return { ok: false, removed, error: `${rel.split('\\').join('/')} is a link, so nothing was deleted` };
115
+ } catch { /* missing: nothing to follow */ }
116
+ }
110
117
  try {
111
118
  // For nuclear, capture the provider sessions BEFORE the dir (holding
112
119
  // meta.json) is deleted.
@@ -141,7 +148,9 @@ export async function purgeWorkflow(
141
148
 
142
149
  // 2. The workflow directory tree (events.jsonl, meta.json, artifacts,
143
150
  // handoffs, sandbox.db, mcp-config, attachments, …).
144
- await rm(workflowDir(cwd, wfid), { recursive: true, force: true });
151
+ // The storage DELETE action passes `removeDir` to leave KEEP items in place.
152
+ if (opts.removeDir) await opts.removeDir(workflowDir(cwd, wfid));
153
+ else await rm(workflowDir(cwd, wfid), { recursive: true, force: true });
145
154
  removed.push('workflow dir');
146
155
 
147
156
  // 3. Checkpoints (git refs + tar files).
@@ -1,5 +1,4 @@
1
1
  import { open, readdir, stat } from 'fs/promises';
2
- import { openSync, fstatSync, readSync, closeSync } from 'node:fs';
3
2
  import { join, resolve } from 'path';
4
3
  import { homedir } from 'os';
5
4
  import type { SessionInfo } from '@arco/shared';
@@ -10,6 +9,7 @@ import { backfillSessionIndex } from './sessionIndex.js';
10
9
  import { getRecallIndex } from '../recall/index.js';
11
10
  import { encodeProjectDir } from '../http/fileRead.js';
12
11
  import { extractUserText } from './transcripts.js';
12
+ import { readLogHeadSync } from '../eventLog.js';
13
13
 
14
14
  export async function extractSessionName(
15
15
  path: string,
@@ -245,15 +245,11 @@ export async function extractCodexSessionInfo(path: string, wantCwd: string): Pr
245
245
  // Arco-internal sessions that have no provider .jsonl and may not yet be in
246
246
  // the recall index. Bounded head read, best-effort, never throws.
247
247
  function readFirstUserText(cwd: string, wfid: string): string | undefined {
248
- let fd: number | undefined;
249
248
  try {
250
- fd = openSync(join(cwd, '.arco', 'workflows', wfid, 'events.jsonl'), 'r');
251
- const size = fstatSync(fd).size;
252
- if (size === 0) return undefined;
253
- const len = Math.min(size, 256 * 1024);
254
- const buf = Buffer.allocUnsafe(len);
255
- readSync(fd, buf, 0, len, 0);
256
- for (const line of buf.toString('utf8').split('\n')) {
249
+ // The oldest records, from the first sealed segment when there is one (P7.3).
250
+ const head = readLogHeadSync(join(cwd, '.arco', 'workflows', wfid), 256 * 1024);
251
+ if (!head) return undefined;
252
+ for (const line of head.split('\n')) {
257
253
  if (!line || !line.includes('"user_message_echo"')) continue;
258
254
  try {
259
255
  const ev = JSON.parse(line) as { type?: string; content?: string };
@@ -268,10 +264,6 @@ function readFirstUserText(cwd: string, wfid: string): string | undefined {
268
264
  return undefined;
269
265
  } catch {
270
266
  return undefined;
271
- } finally {
272
- if (fd !== undefined) {
273
- try { closeSync(fd); } catch { /* ignore */ }
274
- }
275
267
  }
276
268
  }
277
269
 
@@ -36,6 +36,7 @@ import path from 'path';
36
36
  import type { ProviderName, SessionIndex, SessionIndexEntry, SessionTitleEvent } from '@arco/shared';
37
37
  import type { WorkflowMeta } from '../workflowMeta.js';
38
38
  import { atomicWriteFile, withFileLock } from '../atomicFile.js';
39
+ import { readLogLines } from '../eventLog.js';
39
40
 
40
41
  const WFID_PATTERN = /^[a-zA-Z0-9-]{1,64}$/;
41
42
  const CURRENT_INDEX_VERSION = 1;
@@ -138,21 +139,16 @@ function newestCliSession(meta: WorkflowMeta): WorkflowMeta['cliSessions'][numbe
138
139
  // + "where this left off" subtitle.
139
140
  export async function scanOperatorMessages(cwd: string, wfid: string): Promise<string[]> {
140
141
  if (!WFID_PATTERN.test(wfid)) return [];
141
- const eventsPath = path.join(cwd, '.arco', 'workflows', wfid, 'events.jsonl');
142
- let raw: string;
143
- try {
144
- raw = await fs.readFile(eventsPath, 'utf8');
145
- } catch {
146
- return [];
147
- }
148
142
  const out: string[] = [];
149
- for (const line of raw.split('\n')) {
143
+ let lines: AsyncGenerator<string>;
144
+ try { lines = readLogLines(path.join(cwd, '.arco', 'workflows', wfid)); } catch { return []; }
145
+ try { for await (const line of lines) {
150
146
  if (!line || !line.includes('"user_message_echo"')) continue;
151
147
  let entry: any;
152
148
  try { entry = JSON.parse(line); } catch { continue; }
153
149
  if (entry.type !== 'user_message_echo') continue;
154
150
  if (typeof entry.content === 'string' && entry.content.trim()) out.push(entry.content.trim());
155
- }
151
+ } } catch { return out; }
156
152
  return out;
157
153
  }
158
154
 
@@ -28,7 +28,7 @@ import type {
28
28
  import * as clusterStore from '../clusterStore.js';
29
29
  import * as taskLedger from '../project/taskLedger.js';
30
30
  import { workflows, workflowCwds } from '../server/state.js';
31
- import { broadcastWorkflow, send } from '../server/broadcast.js';
31
+ import { broadcastWorkflow, send, sendWorkflowLive } from '../server/broadcast.js';
32
32
 
33
33
  // Per-cwd mutation serialization. Each cwd gets a tail promise; a new mutation
34
34
  // chains off it so the load-mutate-save sequence never interleaves.
@@ -131,9 +131,12 @@ export async function appendLedgerComment(
131
131
 
132
132
  // Re-snapshot the cwd to every observer of the originating workflow. We
133
133
  // broadcast on the originating workflow so the snapshot fans out to the tab(s)
134
- // looking at this cwd; the client keys it by `cwd`.
134
+ // looking at this cwd; the client keys it by `cwd`. Live only (P7.2): a full
135
+ // board copy is not written to events.jsonl. The ledger store holds the board,
136
+ // emitEvent below persists each change, and a reconnecting tab gets a fresh
137
+ // copy from sendTaskLedgerSnapshot.
135
138
  export function broadcastSnapshot(workflowId: string, cwd: string, tasks: LedgerTask[], boardKey?: TaskBoardKey): void {
136
- broadcastWorkflow(workflowId, {
139
+ sendWorkflowLive(workflowId, {
137
140
  type: 'task_ledger_snapshot',
138
141
  workflowId,
139
142
  cwd,
@@ -193,6 +196,7 @@ export async function handleTaskLedgerCreate(
193
196
  goalMode: msg.goalMode,
194
197
  goalMaxTurns: msg.goalMaxTurns,
195
198
  worktreeRequired: msg.worktreeRequired,
199
+ release: msg.release,
196
200
  createdBy: msg.workflowId,
197
201
  });
198
202
  const next = [...tasks, task];
@@ -227,6 +231,7 @@ export async function handleTaskLedgerUpdate(
227
231
  goalMode: msg.goalMode,
228
232
  goalMaxTurns: msg.goalMaxTurns,
229
233
  worktreeRequired: msg.worktreeRequired,
234
+ release: msg.release,
230
235
  assignee: msg.assignee,
231
236
  updatedBy: msg.workflowId,
232
237
  });
@@ -39,7 +39,7 @@ import { buildClusterPlanReviewContent, buildPlanReviewContent, buildPreviewCapt
39
39
  import { runReviewer } from '../primitives/runReviewer.js';
40
40
  import { runResearch } from '../primitives/runResearch.js';
41
41
  import { runDocEdit } from '../primitives/runDocEdit.js';
42
- import { runMdTuneup, backupAndWriteInstructionFile, discoverInstructionFiles } from '../primitives/runMdTuneup.js';
42
+ import { runMdTuneup, backupAndWriteInstructionFile, discoverInstructionFilesWithLinks } from '../primitives/runMdTuneup.js';
43
43
  import { rememberTuneupUndo, undoTuneup } from '../primitives/mdTuneupUndo.js';
44
44
  import { resolveWithinCwd } from '../providers/ollamaTools.js';
45
45
  import { RESEARCH_MAX_ROUNDS_CEILING } from '@arco/shared';
@@ -1400,6 +1400,7 @@ async function restoreAdmittedCheckpoint(
1400
1400
  type: 'checkpoint_reverted',
1401
1401
  workflowId: msg.workflowId,
1402
1402
  seq: msg.seq,
1403
+ restoredSeq: msg.seq,
1403
1404
  fileCount: result.fileCount,
1404
1405
  safetySnapshotRef: safety.ref,
1405
1406
  safetySnapshotSeq: safetyGuardSeq,
@@ -2012,10 +2013,10 @@ export async function handleMdTuneupCandidatesRequest(
2012
2013
  send(ws, { type: 'md_tuneup_candidates', workflowId: msg.workflowId, candidates: [] });
2013
2014
  return;
2014
2015
  }
2015
- const candidates = await discoverInstructionFiles(cwd).catch(() => []);
2016
+ const { candidates, skippedLinks } = await discoverInstructionFilesWithLinks(cwd).catch(() => ({ candidates: [], skippedLinks: [] }));
2016
2017
  const providerDefault = tuneupBaseNameForProvider(wf.primary.provider);
2017
- const defaultPath = candidates.find((c) => c.path === providerDefault)?.path;
2018
- send(ws, { type: 'md_tuneup_candidates', workflowId: msg.workflowId, candidates, defaultPath });
2018
+ const defaultPath = candidates.find((c) => c.path === providerDefault || c.alsoReadAs?.includes(providerDefault))?.path;
2019
+ send(ws, { type: 'md_tuneup_candidates', workflowId: msg.workflowId, candidates, skippedLinks, defaultPath });
2019
2020
  }
2020
2021
 
2021
2022
  export async function handleMdTuneupRequest(
@@ -6,3 +6,5 @@ export * from './outputs.js';
6
6
  export * from './clusterCoordination.js';
7
7
  export * from './localCapacity.js';
8
8
  export * from './autoPickupAck.js';
9
+ export * from './publicGuardrails.js';
10
+ export * from './publicSafetyRules.js';
@@ -6,4 +6,6 @@ export * from './outputs.js';
6
6
  export * from './clusterCoordination.js';
7
7
  export * from './localCapacity.js';
8
8
  export * from './autoPickupAck.js';
9
+ export * from './publicGuardrails.js';
10
+ export * from './publicSafetyRules.js';
9
11
  //# sourceMappingURL=index.js.map
@@ -8,7 +8,7 @@ export declare function isAutoPickupMode(value: unknown): value is AutoPickupMod
8
8
  export declare function isSmartPickupMode(mode: AutoPickupMode | undefined): mode is 'smart-observe' | 'smart-auto';
9
9
  export declare function autoPickupWakes(mode: AutoPickupMode | undefined): boolean;
10
10
  export declare function resolveAutoPickupMode(mode: unknown, legacyEnabled: unknown): AutoPickupMode;
11
- export declare const SMART_PICKUP_EVALUATOR_PROVIDERS: readonly ["claude", "codex", "cursor", "ollama"];
11
+ export declare const SMART_PICKUP_EVALUATOR_PROVIDERS: readonly ["claude", "codex", "cursor", "ollama", "lmstudio", "llamacpp", "strata", "deepseek"];
12
12
  export type SmartPickupEvaluatorProvider = typeof SMART_PICKUP_EVALUATOR_PROVIDERS[number];
13
13
  export interface SmartPickupEvaluator {
14
14
  provider: SmartPickupEvaluatorProvider;
@@ -28,7 +28,7 @@ export function resolveAutoPickupMode(mode, legacyEnabled) {
28
28
  return mode;
29
29
  return legacyEnabled === true ? 'rule' : 'off';
30
30
  }
31
- export const SMART_PICKUP_EVALUATOR_PROVIDERS = ['claude', 'codex', 'cursor', 'ollama'];
31
+ export const SMART_PICKUP_EVALUATOR_PROVIDERS = ['claude', 'codex', 'cursor', 'ollama', 'lmstudio', 'llamacpp', 'strata', 'deepseek'];
32
32
  export const SMART_PICKUP_MODEL_MAX = 200;
33
33
  export function sanitizeSmartPickupEvaluator(raw) {
34
34
  if (!raw || typeof raw !== 'object')
@@ -69,6 +69,7 @@ export interface CheckpointRevertedMessage {
69
69
  type: 'checkpoint_reverted';
70
70
  workflowId: string;
71
71
  seq: number;
72
+ restoredSeq?: number;
72
73
  fileCount: number;
73
74
  safetySnapshotRef: string;
74
75
  safetySnapshotSeq: number;
@@ -442,7 +442,8 @@ export interface ClusterMemberReplacedMessage {
442
442
  export interface ClusterPlanChangedMessage {
443
443
  type: 'cluster_plan_changed';
444
444
  clusterId: string;
445
- body: string;
445
+ body?: string;
446
+ bodySha256?: string;
446
447
  updatedAt: number;
447
448
  bodyLength: number;
448
449
  }
@@ -20,6 +20,7 @@ export * from './mdTuneup.js';
20
20
  export * from './handoffs.js';
21
21
  export * from './checkpoints.js';
22
22
  export * from './liveChanges.js';
23
+ export * from './storage.js';
23
24
  export * from './gitOps.js';
24
25
  export * from './bakeoffs.js';
25
26
  export * from './terminal.js';
@@ -24,6 +24,7 @@ export * from './mdTuneup.js';
24
24
  export * from './handoffs.js';
25
25
  export * from './checkpoints.js';
26
26
  export * from './liveChanges.js';
27
+ export * from './storage.js';
27
28
  export * from './gitOps.js';
28
29
  export * from './bakeoffs.js';
29
30
  export * from './terminal.js';
@@ -8,6 +8,11 @@ export interface MdTuneupCandidate {
8
8
  lines?: number;
9
9
  approximateTokens?: number;
10
10
  hints?: string[];
11
+ alsoReadAs?: string[];
12
+ }
13
+ export interface MdTuneupSkippedLink {
14
+ path: string;
15
+ reason: string;
11
16
  }
12
17
  export interface MdTuneupCandidatesRequestMessage {
13
18
  type: 'md_tuneup_candidates_request';
@@ -17,6 +22,7 @@ export interface MdTuneupCandidatesMessage {
17
22
  type: 'md_tuneup_candidates';
18
23
  workflowId: string;
19
24
  candidates: MdTuneupCandidate[];
25
+ skippedLinks?: MdTuneupSkippedLink[];
20
26
  defaultPath?: string;
21
27
  }
22
28
  export interface MdTuneupRequestMessage {
@@ -1,5 +1,5 @@
1
1
  import type { ProviderName } from './providers.js';
2
- export type WorkbenchNoticeCategory = 'port-change' | 'computer-watch' | 'turn-finished' | 'quota-recovered' | 'auth-expired' | 'cluster-nudge' | 'terminal-exited' | 'preview-failed' | 'pr-status' | 'backup';
2
+ export type WorkbenchNoticeCategory = 'attention' | 'port-change' | 'computer-watch' | 'turn-finished' | 'quota-recovered' | 'auth-expired' | 'cluster-nudge' | 'terminal-exited' | 'preview-failed' | 'pr-status' | 'backup';
3
3
  export declare const WORKBENCH_NOTICE_CATEGORIES: readonly WorkbenchNoticeCategory[];
4
4
  export type WorkbenchNoticeSeverity = 'info' | 'success' | 'warning' | 'error';
5
5
  export interface WorkbenchNotice {
@@ -57,4 +57,5 @@ export interface AttentionEventMessage {
57
57
  kind: AttentionKind;
58
58
  workflowId: string;
59
59
  workflowName: string;
60
+ desktopEligible?: boolean;
60
61
  }