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.
- package/CONTRIBUTING.md +1 -1
- package/README.md +5 -1
- package/client/dist/assets/{PhosphorBackdrop-CkVIGkeX.js → PhosphorBackdrop-CNumba2X.js} +1 -1
- package/client/dist/assets/{ThemedBackgroundShaderImpl-DHF7CnpE.js → ThemedBackgroundShaderImpl-DX5KyCt3.js} +1 -1
- package/client/dist/assets/{XtermView-SY0UcZUS.js → XtermView-DhS5g8Rt.js} +1 -1
- package/client/dist/assets/{galleryEditor-Ca4F8HiM.js → galleryEditor-fPb76Cjv.js} +1 -1
- package/client/dist/assets/index-CjkHb-_n.js +592 -0
- package/client/dist/assets/index-DIbh3ae5.css +1 -0
- package/client/dist/index.html +2 -2
- package/client/src/App.tsx +2 -0
- package/client/src/alerts/desktopAlerts.ts +13 -1
- package/client/src/brief/briefFacts.ts +22 -0
- package/client/src/brief/briefFromStore.ts +7 -2
- package/client/src/components/ArtifactMoveDialog.tsx +64 -0
- package/client/src/components/BriefControl.tsx +38 -47
- package/client/src/components/CatchMeUp.tsx +25 -25
- package/client/src/components/CheckpointActions.tsx +7 -4
- package/client/src/components/ClusterComposerButtons.tsx +6 -3
- package/client/src/components/ClusterPlanTab.tsx +15 -1
- package/client/src/components/ClusterRightPanel/AutoPickupControl.tsx +6 -2
- package/client/src/components/ClusterTab.tsx +33 -3
- package/client/src/components/ClusterTaskBoardTab.tsx +62 -8
- package/client/src/components/DialogShell.tsx +115 -0
- package/client/src/components/DocsUpdateDialog.tsx +16 -42
- package/client/src/components/ForwardMessages.tsx +28 -32
- package/client/src/components/GitDialog.tsx +52 -52
- package/client/src/components/GitOtherWork.tsx +4 -2
- package/client/src/components/HandoffDialog.tsx +19 -45
- package/client/src/components/Home/HomeView.tsx +36 -8
- package/client/src/components/Home/home.css +7 -0
- package/client/src/components/KeepButton.tsx +23 -0
- package/client/src/components/MdTuneupDialog.tsx +52 -51
- package/client/src/components/MemberCard.tsx +4 -1
- package/client/src/components/MemberPane.tsx +1 -1
- package/client/src/components/NotificationCenter.tsx +4 -3
- package/client/src/components/NotificationChannelsSettings.tsx +25 -7
- package/client/src/components/PlanCandidateBanner.tsx +111 -57
- package/client/src/components/PlanComposerDialog.tsx +55 -87
- package/client/src/components/ProjectStateNotice.tsx +60 -0
- package/client/src/components/PublicProjectBox.tsx +25 -0
- package/client/src/components/ResearchDialog.tsx +15 -24
- package/client/src/components/ReviewDialog.tsx +32 -57
- package/client/src/components/RightPanel/OutputsPanel.tsx +4 -0
- package/client/src/components/RightPanel/PlanTab.tsx +24 -2
- package/client/src/components/RightPanel/UsageTab.tsx +77 -1
- package/client/src/components/SkillEditorDialog.tsx +38 -73
- package/client/src/components/SpawnDialog.tsx +19 -41
- package/client/src/components/StorageWarnings.tsx +21 -0
- package/client/src/components/SystemHeader.tsx +2 -2
- package/client/src/components/TerminalInput.tsx +6 -2
- package/client/src/components/TidyComposer.tsx +24 -41
- package/client/src/components/TranscriptSendDialog.tsx +151 -202
- package/client/src/components/UtilityAgentPicker.tsx +4 -2
- package/client/src/components/WorkflowCreator/index.tsx +2 -0
- package/client/src/components/WorkflowView.tsx +4 -1
- package/client/src/components/clusterNeedsYou.ts +35 -3
- package/client/src/components/compare/CompareDialog.tsx +26 -2
- package/client/src/components/terminalInput/planDraft.ts +33 -4
- package/client/src/components/utilityResult.ts +5 -1
- package/client/src/explorer/ExplorerApp.tsx +5 -2
- package/client/src/explorer/PlansLens.tsx +60 -19
- package/client/src/explorer/StorageLens.tsx +275 -0
- package/client/src/explorer/launch.ts +3 -3
- package/client/src/explorer/plansGrouping.ts +15 -0
- package/client/src/help/content/cluster.tsx +42 -7
- package/client/src/help/content/composer.tsx +26 -6
- package/client/src/help/content/header.tsx +16 -14
- package/client/src/help/content/misc.tsx +141 -6
- package/client/src/help/content/rightPanel.tsx +16 -0
- package/client/src/help/content/settings.tsx +4 -4
- package/client/src/help/manualSections/actions.tsx +19 -4
- package/client/src/help/manualSections/clusters.tsx +29 -16
- package/client/src/help/manualSections/configuration.tsx +6 -4
- package/client/src/help/manualSections/maintenance.tsx +27 -5
- package/client/src/help/manualSections/plans.tsx +96 -2
- package/client/src/help/manualSections/powerFeatures.tsx +2 -2
- package/client/src/help/manualSections/reference.tsx +6 -0
- package/client/src/help/manualSections/workspace.tsx +9 -5
- package/client/src/stores/appStore.ts +10 -1
- package/client/src/stores/appStore.types.ts +2 -0
- package/client/src/stores/mdTuneupStore.ts +5 -4
- package/client/src/stores/memoryTrim.ts +18 -2
- package/client/src/stores/storageWarningStore.ts +18 -0
- package/client/src/utils/gitDialogMemory.ts +26 -0
- package/client/src/utils/historyEvents.ts +1 -0
- package/client/src/utils/homeModel.ts +19 -0
- package/client/src/utils/publicProject.ts +56 -0
- package/client/src/ws/handleServerMessage.ts +7 -2
- package/docs/ARCHITECTURE.md +1 -1
- package/docs/CHECKPOINTS.md +2 -0
- package/docs/CLIENT.md +29 -11
- package/docs/FEATURES.md +14 -11
- package/docs/GETTING_STARTED.md +7 -7
- package/docs/GLOSSARY.md +3 -3
- package/docs/GOTCHAS.md +3 -2
- package/docs/HTTP_API.md +31 -1
- package/docs/NOTIFICATIONS.md +13 -14
- package/docs/OPERATIONS.md +27 -1
- package/docs/OPERATOR_ACTIONS.md +1 -1
- package/docs/OUTPUTS.md +9 -0
- package/docs/PERSISTENCE.md +34 -4
- package/docs/PLAN_OR_BOARD.md +7 -0
- package/docs/PRIMITIVES.md +3 -3
- package/docs/PROTOCOL.md +14 -4
- package/docs/PROTOCOL_CLUSTER.md +3 -2
- package/docs/SERVICE_MODE.md +5 -1
- package/docs/SETTINGS.md +8 -6
- package/docs/STORAGE_PLAN.md +324 -0
- package/docs/TASK_LEDGER.md +5 -4
- package/native/linux-arm64/manifest.json +1 -1
- package/node_modules/@arco/shared/dist/index.d.ts +2 -0
- package/node_modules/@arco/shared/dist/index.js +2 -0
- package/node_modules/@arco/shared/dist/protocol/autoPickup.d.ts +1 -1
- package/node_modules/@arco/shared/dist/protocol/autoPickup.js +1 -1
- package/node_modules/@arco/shared/dist/protocol/checkpoints.d.ts +1 -0
- package/node_modules/@arco/shared/dist/protocol/clusters.d.ts +2 -1
- package/node_modules/@arco/shared/dist/protocol/index.d.ts +1 -0
- package/node_modules/@arco/shared/dist/protocol/index.js +1 -0
- package/node_modules/@arco/shared/dist/protocol/mdTuneup.d.ts +6 -0
- package/node_modules/@arco/shared/dist/protocol/notifications.d.ts +2 -1
- package/node_modules/@arco/shared/dist/protocol/notifications.js +3 -2
- package/node_modules/@arco/shared/dist/protocol/plans.d.ts +2 -0
- package/node_modules/@arco/shared/dist/protocol/serverMessages.d.ts +2 -1
- package/node_modules/@arco/shared/dist/protocol/storage.d.ts +21 -0
- package/node_modules/@arco/shared/dist/protocol/storage.js +3 -0
- package/node_modules/@arco/shared/dist/protocol/tasks.d.ts +3 -0
- package/node_modules/@arco/shared/dist/protocol/utilityAgent.d.ts +2 -2
- package/node_modules/@arco/shared/dist/protocol/utilityAgent.js +2 -2
- package/node_modules/@arco/shared/dist/publicGuardrails.d.ts +7 -0
- package/node_modules/@arco/shared/dist/publicGuardrails.js +47 -0
- package/node_modules/@arco/shared/dist/publicSafetyRules.d.ts +1 -0
- package/node_modules/@arco/shared/dist/publicSafetyRules.js +6 -0
- package/node_modules/@arco/shared/package.json +1 -1
- package/package.json +3 -2
- package/scripts/packaging/arco.mjs +17 -1
- package/scripts/packaging/services.mjs +35 -5
- package/scripts/packaging/storage.mjs +125 -0
- package/scripts/packaging/update.mjs +3 -3
- package/server/dist/artifactCopy.d.ts +26 -0
- package/server/dist/artifactCopy.js +398 -0
- package/server/dist/atomicFile.d.ts +1 -0
- package/server/dist/atomicFile.js +1 -1
- package/server/dist/attention.d.ts +1 -1
- package/server/dist/attention.js +10 -13
- package/server/dist/catchUp.d.ts +2 -0
- package/server/dist/catchUp.js +46 -23
- package/server/dist/clusterPeerOps.d.ts +2 -0
- package/server/dist/clusterPeerOps.js +2 -0
- package/server/dist/clusterSnapshots.js +22 -12
- package/server/dist/eventLog.d.ts +55 -0
- package/server/dist/eventLog.js +792 -0
- package/server/dist/explorerLaunch.d.ts +4 -1
- package/server/dist/explorerLaunch.js +3 -2
- package/server/dist/explorerPlans.d.ts +4 -0
- package/server/dist/explorerPlans.js +27 -2
- package/server/dist/http/clusterRoutes.js +2 -0
- package/server/dist/http/explorerRoutes.js +2 -1
- package/server/dist/http/publicProjectRoutes.d.ts +2 -0
- package/server/dist/http/publicProjectRoutes.js +68 -0
- package/server/dist/http/router.js +6 -0
- package/server/dist/http/storageRoutes.d.ts +2 -0
- package/server/dist/http/storageRoutes.js +254 -0
- package/server/dist/http/usageStatsRoutes.js +3 -12
- package/server/dist/index.js +4 -0
- package/server/dist/keepStore.d.ts +16 -0
- package/server/dist/keepStore.js +119 -0
- package/server/dist/management/clusterActivity.js +6 -20
- package/server/dist/management/initHubLink.js +10 -43
- package/server/dist/mcp/clusterMcpTools.js +8 -1
- package/server/dist/notifications.d.ts +3 -1
- package/server/dist/notifications.js +5 -4
- package/server/dist/outputStore.d.ts +1 -0
- package/server/dist/outputStore.js +1 -1
- package/server/dist/outputs.js +39 -8
- package/server/dist/planHistory.d.ts +3 -0
- package/server/dist/planHistory.js +60 -0
- package/server/dist/primitives/runMdTuneup.d.ts +5 -1
- package/server/dist/primitives/runMdTuneup.js +43 -2
- package/server/dist/project/taskLedger.d.ts +4 -0
- package/server/dist/project/taskLedger.js +19 -0
- package/server/dist/providers/claude-native/peerTools.js +4 -0
- package/server/dist/providers/claude-native/resumeSummary.js +30 -19
- package/server/dist/providers/index.js +8 -13
- package/server/dist/providers/localProviderQueue.d.ts +2 -0
- package/server/dist/providers/localProviderQueue.js +11 -0
- package/server/dist/publicProject.d.ts +54 -0
- package/server/dist/publicProject.js +135 -0
- package/server/dist/recall/index.js +22 -23
- package/server/dist/server/broadcast.d.ts +2 -1
- package/server/dist/server/broadcast.js +56 -1
- package/server/dist/smartPickupAdapters.d.ts +7 -0
- package/server/dist/smartPickupAdapters.js +172 -8
- package/server/dist/storageActions.d.ts +50 -0
- package/server/dist/storageActions.js +326 -0
- package/server/dist/storageArchive.d.ts +24 -0
- package/server/dist/storageArchive.js +358 -0
- package/server/dist/storageOverview.d.ts +47 -0
- package/server/dist/storageOverview.js +197 -0
- package/server/dist/storageReport.d.ts +48 -0
- package/server/dist/storageReport.js +185 -0
- package/server/dist/storageWarnings.d.ts +4 -0
- package/server/dist/storageWarnings.js +96 -0
- package/server/dist/workers/limits.js +4 -1
- package/server/dist/workflowStore.d.ts +2 -0
- package/server/dist/workflowStore.js +88 -72
- package/server/dist/workflows/purgeWorkflow.d.ts +1 -0
- package/server/dist/workflows/purgeWorkflow.js +15 -2
- package/server/dist/workflows/sessionDiscovery.js +5 -17
- package/server/dist/workflows/sessionIndex.js +22 -17
- package/server/dist/ws/taskLedgerHandlers.js +8 -3
- package/server/dist/ws/workflowHandlers.js +5 -4
- package/server/package.json +1 -1
- package/server/src/artifactCopy.ts +254 -0
- package/server/src/atomicFile.ts +1 -1
- package/server/src/attention.ts +9 -10
- package/server/src/catchUp.ts +37 -15
- package/server/src/clusterPeerOps.ts +5 -0
- package/server/src/clusterSnapshots.ts +20 -13
- package/server/src/eventLog.ts +571 -0
- package/server/src/explorerLaunch.ts +3 -2
- package/server/src/explorerPlans.ts +22 -2
- package/server/src/http/clusterRoutes.ts +4 -1
- package/server/src/http/explorerRoutes.ts +2 -1
- package/server/src/http/publicProjectRoutes.ts +54 -0
- package/server/src/http/router.ts +4 -0
- package/server/src/http/storageRoutes.ts +187 -0
- package/server/src/http/usageStatsRoutes.ts +3 -11
- package/server/src/index.ts +4 -0
- package/server/src/keepStore.ts +102 -0
- package/server/src/management/clusterActivity.ts +6 -16
- package/server/src/management/initHubLink.ts +10 -39
- package/server/src/mcp/clusterMcpTools.ts +8 -2
- package/server/src/notifications.ts +4 -3
- package/server/src/outputStore.ts +5 -2
- package/server/src/outputs.ts +30 -6
- package/server/src/planHistory.ts +48 -0
- package/server/src/primitives/runMdTuneup.ts +32 -2
- package/server/src/project/taskLedger.ts +20 -0
- package/server/src/providers/claude-native/peerTools.ts +4 -0
- package/server/src/providers/claude-native/resumeSummary.ts +32 -18
- package/server/src/providers/index.ts +2 -16
- package/server/src/providers/localProviderQueue.ts +13 -0
- package/server/src/publicProject.ts +142 -0
- package/server/src/recall/index.ts +4 -9
- package/server/src/server/broadcast.ts +53 -1
- package/server/src/smartPickupAdapters.ts +128 -5
- package/server/src/storageActions.ts +216 -0
- package/server/src/storageArchive.ts +277 -0
- package/server/src/storageOverview.ts +184 -0
- package/server/src/storageReport.ts +210 -0
- package/server/src/storageWarnings.ts +84 -0
- package/server/src/workers/limits.ts +4 -1
- package/server/src/workflowStore.ts +78 -61
- package/server/src/workflows/purgeWorkflow.ts +12 -3
- package/server/src/workflows/sessionDiscovery.ts +5 -13
- package/server/src/workflows/sessionIndex.ts +5 -9
- package/server/src/ws/taskLedgerHandlers.ts +8 -3
- package/server/src/ws/workflowHandlers.ts +5 -4
- package/shared/dist/index.d.ts +2 -0
- package/shared/dist/index.js +2 -0
- package/shared/dist/protocol/autoPickup.d.ts +1 -1
- package/shared/dist/protocol/autoPickup.js +1 -1
- package/shared/dist/protocol/checkpoints.d.ts +1 -0
- package/shared/dist/protocol/clusters.d.ts +2 -1
- package/shared/dist/protocol/index.d.ts +1 -0
- package/shared/dist/protocol/index.js +1 -0
- package/shared/dist/protocol/mdTuneup.d.ts +6 -0
- package/shared/dist/protocol/notifications.d.ts +2 -1
- package/shared/dist/protocol/notifications.js +3 -2
- package/shared/dist/protocol/plans.d.ts +2 -0
- package/shared/dist/protocol/serverMessages.d.ts +2 -1
- package/shared/dist/protocol/storage.d.ts +21 -0
- package/shared/dist/protocol/storage.js +3 -0
- package/shared/dist/protocol/tasks.d.ts +3 -0
- package/shared/dist/protocol/utilityAgent.d.ts +2 -2
- package/shared/dist/protocol/utilityAgent.js +2 -2
- package/shared/dist/publicGuardrails.d.ts +7 -0
- package/shared/dist/publicGuardrails.js +47 -0
- package/shared/dist/publicSafetyRules.d.ts +1 -0
- package/shared/dist/publicSafetyRules.js +6 -0
- package/shared/src/index.ts +3 -0
- package/shared/src/protocol/autoPickup.ts +1 -1
- package/shared/src/protocol/checkpoints.ts +4 -0
- package/shared/src/protocol/clusters.ts +6 -1
- package/shared/src/protocol/index.ts +1 -0
- package/shared/src/protocol/mdTuneup.ts +5 -0
- package/shared/src/protocol/notifications.ts +6 -2
- package/shared/src/protocol/plans.ts +2 -0
- package/shared/src/protocol/serverMessages.ts +2 -0
- package/shared/src/protocol/storage.ts +35 -0
- package/shared/src/protocol/tasks.ts +6 -0
- package/shared/src/protocol/utilityAgent.ts +2 -2
- package/shared/src/publicGuardrails.ts +50 -0
- package/shared/src/publicSafetyRules.ts +5 -0
- package/client/dist/assets/index-CcNtMA2y.js +0 -546
- 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
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
443
|
-
|
|
444
|
-
|
|
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
|
-
|
|
503
|
-
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
251
|
-
const
|
|
252
|
-
if (
|
|
253
|
-
const
|
|
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
|
-
|
|
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
|
-
|
|
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,
|
|
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
|
|
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(
|
package/shared/dist/index.d.ts
CHANGED
package/shared/dist/index.js
CHANGED
|
@@ -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')
|
|
@@ -442,7 +442,8 @@ export interface ClusterMemberReplacedMessage {
|
|
|
442
442
|
export interface ClusterPlanChangedMessage {
|
|
443
443
|
type: 'cluster_plan_changed';
|
|
444
444
|
clusterId: string;
|
|
445
|
-
body
|
|
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
|
}
|