arco-workbench 0.1.6 → 0.1.8
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 +52 -12
- package/README.md +20 -13
- package/client/dist/assets/{PhosphorBackdrop-BR-TgB5x.js → PhosphorBackdrop-D7jdAV_G.js} +1 -1
- package/client/dist/assets/{ThemedBackgroundShaderImpl-DgcFj6JN.js → ThemedBackgroundShaderImpl-DrDm60h8.js} +1 -1
- package/client/dist/assets/{XtermView-CflVBQgC.js → XtermView-BGFujb1e.js} +1 -1
- package/client/dist/assets/{galleryEditor-BB-emfmi.js → galleryEditor-D951A2sE.js} +1 -1
- package/client/dist/assets/{index-B_EqHDz3.js → index-CsVy3eZm.js} +248 -248
- package/client/dist/index.html +1 -1
- package/client/src/buildCheck.ts +3 -1
- package/client/src/components/AppUpdateNotice.tsx +2 -1
- package/client/src/components/ClusterRightPanel/AutoPickupControl.tsx +24 -12
- package/client/src/components/ClusterRightPanel/ReplaceMemberDialog.tsx +65 -15
- package/client/src/components/ClusterRightPanel/SkillsControl.tsx +107 -0
- package/client/src/components/ClusterRightPanel/index.tsx +6 -1
- package/client/src/components/ClusterTaskBoardTab.tsx +9 -22
- package/client/src/components/HeaderVersionBox.tsx +7 -4
- package/client/src/components/NeedsYouBadge.tsx +3 -3
- package/client/src/components/ProviderReleasesModal.tsx +8 -4
- package/client/src/components/ProvidersPopover.tsx +28 -23
- package/client/src/components/SettingsPanel.tsx +2 -2
- package/client/src/components/SkillsSettings.tsx +5 -0
- package/client/src/components/TabBar.tsx +91 -9
- package/client/src/components/TerminalInput.tsx +12 -10
- package/client/src/components/TranscriptSendDialog.tsx +12 -8
- package/client/src/components/TranscriptWorkerDialog.tsx +119 -0
- package/client/src/components/UpdateAction.tsx +18 -4
- package/client/src/components/UpdateResultNotice.tsx +3 -1
- package/client/src/components/clusterNeedsYou.ts +11 -18
- package/client/src/help/content/cluster.tsx +54 -22
- package/client/src/help/content/composer.tsx +22 -0
- package/client/src/help/content/header.tsx +19 -1
- package/client/src/help/content/misc.tsx +8 -0
- package/client/src/help/content/rightPanel.tsx +1 -1
- package/client/src/help/content/settings.tsx +19 -5
- package/client/src/help/content/tabbar.tsx +5 -0
- package/client/src/help/manualSections/actions.tsx +31 -0
- package/client/src/help/manualSections/clusters.tsx +58 -21
- package/client/src/help/manualSections/configuration.tsx +38 -4
- package/client/src/help/manualSections/maintenance.tsx +30 -0
- package/client/src/help/manualSections/plans.tsx +5 -1
- package/client/src/help/manualSections/providers.tsx +32 -8
- package/client/src/help/manualSections/troubleshooting.tsx +2 -1
- package/client/src/help/manualSections/workflows.tsx +19 -0
- package/client/src/help/manualSections/workspace.tsx +6 -0
- package/client/src/stores/appUpdateStore.ts +29 -8
- package/client/src/utils/transcriptWorkerRequest.ts +24 -0
- package/client/src/utils/wsSession.ts +2 -1
- package/client/src/ws/handleServerMessage.ts +8 -2
- package/docs/ARCHITECTURE.md +1 -1
- package/docs/CLIENT.md +9 -8
- package/docs/FEATURES.md +8 -5
- package/docs/GETTING_STARTED.md +9 -4
- package/docs/GOTCHAS.md +2 -1
- package/docs/OPERATIONS.md +37 -4
- package/docs/PERSISTENCE.md +25 -3
- package/docs/PRIMITIVES.md +42 -0
- package/docs/PROTOCOL_CLUSTER.md +51 -5
- package/docs/PROTOCOL_PRIMITIVES.md +39 -0
- package/docs/PROVIDERS.md +50 -13
- package/docs/SETTINGS.md +27 -3
- package/docs/TASK_LEDGER.md +7 -15
- package/node_modules/@arco/shared/dist/clusterCoordination.d.ts +2 -0
- package/node_modules/@arco/shared/dist/clusterCoordination.js +5 -1
- package/node_modules/@arco/shared/dist/protocol/autoPickup.d.ts +3 -0
- package/node_modules/@arco/shared/dist/protocol/clientMessages.d.ts +3 -2
- package/node_modules/@arco/shared/dist/protocol/clusters.d.ts +13 -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/models.d.ts +4 -3
- package/node_modules/@arco/shared/dist/protocol/models.js +26 -2
- package/node_modules/@arco/shared/dist/protocol/serverMessages.d.ts +2 -1
- package/node_modules/@arco/shared/dist/protocol/tasks.d.ts +4 -0
- package/node_modules/@arco/shared/dist/protocol/transcriptWorker.d.ts +47 -0
- package/node_modules/@arco/shared/dist/protocol/transcriptWorker.js +2 -0
- package/node_modules/@arco/shared/dist/runtimeVersions.d.ts +1 -0
- package/node_modules/@arco/shared/dist/runtimeVersions.js +14 -0
- package/node_modules/@arco/shared/package.json +1 -1
- package/package.json +2 -2
- package/scripts/packaging/arco.mjs +1 -1
- package/scripts/packaging/native-repair.mjs +78 -12
- package/scripts/packaging/update.mjs +5 -1
- package/server/dist/atomicFile.js +1 -2
- package/server/dist/capabilities.d.ts +5 -2
- package/server/dist/capabilities.js +59 -9
- package/server/dist/cliUpdateDecision.d.ts +1 -1
- package/server/dist/cliUpdateDecision.js +5 -3
- package/server/dist/clusterAutoTurn.d.ts +4 -0
- package/server/dist/clusterAutoTurn.js +29 -25
- package/server/dist/clusterBusyReminder.js +1 -1
- package/server/dist/clusterDirector.js +1 -1
- package/server/dist/clusterPeerOps.js +10 -7
- package/server/dist/clusterProgress.js +1 -1
- package/server/dist/clusterSkills.d.ts +13 -0
- package/server/dist/clusterSkills.js +81 -0
- package/server/dist/clusterSnapshots.js +2 -0
- package/server/dist/clusterStore.d.ts +10 -2
- package/server/dist/clusterStore.js +64 -1
- package/server/dist/diagnostics/codeSkew.js +1 -0
- package/server/dist/eventLog.d.ts +7 -0
- package/server/dist/eventLog.js +70 -13
- package/server/dist/historyLimits.d.ts +1 -0
- package/server/dist/historyLimits.js +3 -0
- package/server/dist/http/router.js +1 -1
- package/server/dist/index.js +24 -1
- package/server/dist/jsonlLines.d.ts +4 -0
- package/server/dist/jsonlLines.js +53 -0
- package/server/dist/management/identity.js +1 -0
- package/server/dist/mcp/clusterMcpTools.js +4 -4
- package/server/dist/project/taskLedger.d.ts +4 -0
- package/server/dist/project/taskLedger.js +7 -4
- package/server/dist/providerConversation.d.ts +1 -0
- package/server/dist/providerConversation.js +17 -0
- package/server/dist/providers/claude-native/resumeSummary.d.ts +9 -0
- package/server/dist/providers/claude-native/resumeSummary.js +102 -49
- package/server/dist/providers/claude-native/worker.js +8 -4
- package/server/dist/providers/claude.js +2 -1
- package/server/dist/providers/clusterTaskToolDefinitions.js +4 -4
- package/server/dist/providers/codex-appserver/catalog.js +16 -1
- package/server/dist/providers/codex.js +2 -1
- package/server/dist/providers/codexCodeMode.d.ts +1 -1
- package/server/dist/providers/codexCodeMode.js +4 -3
- package/server/dist/providers/cursor/print.js +2 -1
- package/server/dist/providers/cursor/worker.js +2 -1
- package/server/dist/providers/llamacpp.js +17 -8
- package/server/dist/providers/ollamaRecovery.js +6 -6
- package/server/dist/providers/ollamaResilience.js +3 -3
- package/server/dist/providers/ollamaTokens.js +1 -1
- package/server/dist/quota.d.ts +0 -18
- package/server/dist/quota.js +0 -44
- package/server/dist/replacementHistory.d.ts +19 -0
- package/server/dist/replacementHistory.js +49 -0
- package/server/dist/server/broadcast.d.ts +2 -1
- package/server/dist/server/broadcast.js +1 -0
- package/server/dist/server/prompts.d.ts +1 -0
- package/server/dist/server/prompts.js +6 -1
- package/server/dist/sessionJsonl.d.ts +1 -1
- package/server/dist/sessionJsonl.js +115 -40
- package/server/dist/smartPickup.d.ts +2 -1
- package/server/dist/smartPickup.js +28 -1
- package/server/dist/smartPickupAdapters.js +15 -2
- package/server/dist/smartPickupLedger.js +6 -4
- package/server/dist/smartPickupObserver.d.ts +1 -0
- package/server/dist/smartPickupObserver.js +24 -15
- package/server/dist/transcriptWorker.d.ts +34 -0
- package/server/dist/transcriptWorker.js +201 -0
- package/server/dist/workflowStore.d.ts +1 -0
- package/server/dist/workflowStore.js +31 -0
- package/server/dist/ws/clusterHandlers.d.ts +2 -0
- package/server/dist/ws/clusterHandlers.js +64 -27
- package/server/dist/ws/handoffHandlers.js +5 -2
- package/server/dist/ws/transcriptWorkerHandlers.d.ts +25 -0
- package/server/dist/ws/transcriptWorkerHandlers.js +139 -0
- package/server/dist/ws/turnEngine.js +23 -9
- package/server/dist/ws/updatePrimaryConfig.js +27 -8
- package/server/dist/ws/workflowHandlers.d.ts +4 -1
- package/server/dist/ws/workflowHandlers.js +3 -1
- package/server/package.json +1 -1
- package/server/src/atomicFile.ts +1 -2
- package/server/src/capabilities.ts +58 -17
- package/server/src/cliUpdateDecision.ts +5 -4
- package/server/src/clusterAutoTurn.ts +26 -21
- package/server/src/clusterBusyReminder.ts +1 -1
- package/server/src/clusterDirector.ts +1 -1
- package/server/src/clusterPeerOps.ts +11 -8
- package/server/src/clusterProgress.ts +1 -1
- package/server/src/clusterSkills.ts +79 -0
- package/server/src/clusterSnapshots.ts +1 -0
- package/server/src/clusterStore.ts +64 -1
- package/server/src/diagnostics/codeSkew.ts +1 -0
- package/server/src/eventLog.ts +73 -13
- package/server/src/historyLimits.ts +2 -0
- package/server/src/http/router.ts +1 -1
- package/server/src/index.ts +23 -0
- package/server/src/jsonlLines.ts +52 -0
- package/server/src/management/identity.ts +1 -0
- package/server/src/mcp/clusterMcpTools.ts +4 -4
- package/server/src/project/taskLedger.ts +7 -5
- package/server/src/providerConversation.ts +15 -0
- package/server/src/providers/claude-native/resumeSummary.ts +98 -50
- package/server/src/providers/claude-native/worker.ts +8 -4
- package/server/src/providers/claude.ts +2 -1
- package/server/src/providers/clusterTaskToolDefinitions.ts +4 -4
- package/server/src/providers/codex-appserver/catalog.ts +14 -1
- package/server/src/providers/codex.ts +2 -1
- package/server/src/providers/codexCodeMode.ts +4 -4
- package/server/src/providers/cursor/print.ts +2 -1
- package/server/src/providers/cursor/worker.ts +2 -1
- package/server/src/providers/llamacpp.ts +18 -7
- package/server/src/providers/llamacppRecovery.ts +2 -0
- package/server/src/providers/ollamaRecovery.ts +6 -6
- package/server/src/providers/ollamaResilience.ts +3 -3
- package/server/src/providers/ollamaTokens.ts +1 -1
- package/server/src/providers/ollamaToolSubset.ts +3 -3
- package/server/src/quota.ts +0 -50
- package/server/src/replacementHistory.ts +44 -0
- package/server/src/server/broadcast.ts +2 -0
- package/server/src/server/prompts.ts +8 -1
- package/server/src/sessionJsonl.ts +92 -32
- package/server/src/smartPickup.ts +27 -3
- package/server/src/smartPickupAdapters.ts +17 -3
- package/server/src/smartPickupLedger.ts +6 -4
- package/server/src/smartPickupObserver.ts +20 -11
- package/server/src/transcriptWorker.ts +182 -0
- package/server/src/workflowStore.ts +21 -0
- package/server/src/ws/clusterHandlers.ts +46 -27
- package/server/src/ws/handoffHandlers.ts +5 -1
- package/server/src/ws/transcriptWorkerHandlers.ts +126 -0
- package/server/src/ws/turnEngine.ts +20 -8
- package/server/src/ws/updatePrimaryConfig.ts +25 -6
- package/server/src/ws/workflowHandlers.ts +3 -1
- package/shared/dist/clusterCoordination.d.ts +2 -0
- package/shared/dist/clusterCoordination.js +5 -1
- package/shared/dist/protocol/autoPickup.d.ts +3 -0
- package/shared/dist/protocol/clientMessages.d.ts +3 -2
- package/shared/dist/protocol/clusters.d.ts +13 -1
- package/shared/dist/protocol/index.d.ts +1 -0
- package/shared/dist/protocol/index.js +1 -0
- package/shared/dist/protocol/models.d.ts +4 -3
- package/shared/dist/protocol/models.js +26 -2
- package/shared/dist/protocol/serverMessages.d.ts +2 -1
- package/shared/dist/protocol/tasks.d.ts +4 -0
- package/shared/dist/protocol/transcriptWorker.d.ts +47 -0
- package/shared/dist/protocol/transcriptWorker.js +2 -0
- package/shared/dist/runtimeVersions.d.ts +1 -0
- package/shared/dist/runtimeVersions.js +14 -0
- package/shared/src/clusterCoordination.ts +7 -1
- package/shared/src/protocol/autoPickup.ts +5 -0
- package/shared/src/protocol/clientMessages.ts +5 -0
- package/shared/src/protocol/clusters.ts +16 -1
- package/shared/src/protocol/index.ts +1 -0
- package/shared/src/protocol/models.ts +31 -5
- package/shared/src/protocol/serverMessages.ts +2 -0
- package/shared/src/protocol/settings.ts +2 -3
- package/shared/src/protocol/tasks.ts +4 -7
- package/shared/src/protocol/transcriptWorker.ts +49 -0
- package/shared/src/runtimeVersions.ts +14 -0
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { normalizeClusterRoleText, type ArcoSkillRef, type ClusterSkillPin } from '@arco/shared';
|
|
2
|
+
import { ClusterValidationError, MEMBER_ROLE_MAX, getClusterIdForWorkflow, readCluster, type ClusterState } from './clusterStore.js';
|
|
3
|
+
import { MAX_PINNED_SKILLS, isValidSlug, resolvePinnedSkills } from './skills.js';
|
|
4
|
+
import { workflows } from './server/state.js';
|
|
5
|
+
import { readMeta } from './workflowMeta.js';
|
|
6
|
+
|
|
7
|
+
const key = (ref: ArcoSkillRef) => `${ref.scope}:${ref.slug}`;
|
|
8
|
+
const pinKey = (pin: ClusterSkillPin) => JSON.stringify([pin.scope, pin.slug, pin.role ?? null]);
|
|
9
|
+
export function uniqueSkillRefs(refs: ArcoSkillRef[]): ArcoSkillRef[] {
|
|
10
|
+
return [...new Map(refs.map(ref => [key(ref), { scope: ref.scope, slug: ref.slug }])).values()];
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function parseClusterSkillPins(value: unknown): ClusterSkillPin[] {
|
|
14
|
+
if (!Array.isArray(value)) throw new ClusterValidationError('skill_pins', 'Skills must be a list.');
|
|
15
|
+
const pins: ClusterSkillPin[] = value.map(pin => {
|
|
16
|
+
if (!pin || (pin.scope !== 'project' && pin.scope !== 'global') || !isValidSlug(pin.slug)
|
|
17
|
+
|| (pin.role !== undefined && (typeof pin.role !== 'string' || !pin.role.trim() || pin.role.trim().length > MEMBER_ROLE_MAX))) {
|
|
18
|
+
throw new ClusterValidationError('skill_pins', 'Choose an installed project/global skill and a saved role of at most 120 characters.');
|
|
19
|
+
}
|
|
20
|
+
return { scope: pin.scope, slug: pin.slug, ...(pin.role !== undefined ? { role: pin.role.trim() } : {}) };
|
|
21
|
+
});
|
|
22
|
+
return [...new Map(pins.map(pin => [pinKey(pin), pin])).values()];
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function skillRefsForRole(state: Pick<ClusterState, 'skillPins'>, role: string | undefined, own: ArcoSkillRef[] = []): ArcoSkillRef[] {
|
|
26
|
+
const savedRole = role ? normalizeClusterRoleText(role) : undefined;
|
|
27
|
+
return uniqueSkillRefs([
|
|
28
|
+
...(state.skillPins ?? []).filter(pin => pin.role === undefined),
|
|
29
|
+
...(state.skillPins ?? []).filter(pin => pin.role !== undefined && pin.role === savedRole),
|
|
30
|
+
...own,
|
|
31
|
+
]);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export async function assertSkillUnion(state: Pick<ClusterState, 'skillPins' | 'cwd'>, role: string | undefined, own: ArcoSkillRef[], label: string): Promise<void> {
|
|
35
|
+
const refs = skillRefsForRole(state, role, own);
|
|
36
|
+
if (refs.length > MAX_PINNED_SKILLS) throw new ClusterValidationError('skill_limit', `${label}: tab, cluster and role pins together exceed 12 unique skills.`);
|
|
37
|
+
const resolved = await resolvePinnedSkills(refs, state.cwd);
|
|
38
|
+
if (resolved.truncated.length) throw new ClusterValidationError('skill_limit', `${label}: tab, cluster and role pins together exceed 64 KiB of skill text.`);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export async function assertClusterSkillLimits(state: ClusterState): Promise<void> {
|
|
42
|
+
// Check role targets even when no current member has that role. New workers
|
|
43
|
+
// must inherit a usable set rather than discovering an over-limit role later.
|
|
44
|
+
const roles = new Set([undefined, ...(state.skillPins ?? []).map(pin => pin.role)]);
|
|
45
|
+
for (const role of roles) await assertSkillUnion(state, role, [], role ? `Role ${role}` : 'All members');
|
|
46
|
+
for (const id of state.members) {
|
|
47
|
+
const wf = workflows.get(id);
|
|
48
|
+
const own = wf?.config.pinnedSkills ?? (await readMeta(state.cwd, id).catch(() => null))?.pinnedSkills ?? [];
|
|
49
|
+
await assertSkillUnion(state, state.memberRoles?.[id], own, wf?.config.name ?? `Member ${id.slice(0, 8)}`);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export async function validateNewClusterPins(state: ClusterState, pins: ClusterSkillPin[]): Promise<void> {
|
|
54
|
+
const previous = new Set((state.skillPins ?? []).map(pinKey));
|
|
55
|
+
// Removing a pin must stay possible after an edited skill grows over budget.
|
|
56
|
+
if (pins.every(pin => previous.has(pinKey(pin)))) return;
|
|
57
|
+
for (const pin of pins) {
|
|
58
|
+
if (previous.has(pinKey(pin))) continue;
|
|
59
|
+
const resolved = await resolvePinnedSkills([pin], state.cwd);
|
|
60
|
+
if (resolved.missing.length) throw new ClusterValidationError('skill_pins', `Skill ${pin.slug} is missing, off or unreadable. Choose an available skill.`);
|
|
61
|
+
if (resolved.truncated.length) throw new ClusterValidationError('skill_limit', `Skill ${pin.slug} exceeds 64 KiB of text.`);
|
|
62
|
+
}
|
|
63
|
+
await assertClusterSkillLimits({ ...state, skillPins: pins });
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export async function resolveWorkflowSkillPins(workflowId: string, cwd: string, own: ArcoSkillRef[]) {
|
|
67
|
+
const clusterId = getClusterIdForWorkflow(workflowId);
|
|
68
|
+
const cluster = clusterId ? await readCluster(clusterId) : null;
|
|
69
|
+
const refs = cluster ? skillRefsForRole(cluster, cluster.memberRoles?.[workflowId], own) : uniqueSkillRefs(own);
|
|
70
|
+
return { refs, resolved: await resolvePinnedSkills(refs, cluster?.cwd ?? cwd) };
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export async function assertWorkflowSkillPins(workflowId: string, cwd: string, refs: ArcoSkillRef[]): Promise<void> {
|
|
74
|
+
const previous = new Set((workflows.get(workflowId)?.config.pinnedSkills ?? []).map(key));
|
|
75
|
+
if (refs.every(ref => previous.has(key(ref)))) return;
|
|
76
|
+
const clusterId = getClusterIdForWorkflow(workflowId);
|
|
77
|
+
const cluster = clusterId ? await readCluster(clusterId) : null;
|
|
78
|
+
await assertSkillUnion(cluster ?? { cwd }, cluster?.memberRoles?.[workflowId], refs, 'This tab');
|
|
79
|
+
}
|
|
@@ -875,6 +875,7 @@ export async function restoreSnapshot(snapshotId: string, targetCwdInput?: strin
|
|
|
875
875
|
// Passive cluster configuration is portable. Runtime arming is not:
|
|
876
876
|
// idle-nudger, auto-turn, dispatcher enabled, REMOTE, and remote gates stay
|
|
877
877
|
// OFF on every restore so importing a cluster cannot start work or expose it.
|
|
878
|
+
if (src.skillPins?.length) await clusterStore.setSkillPins(cluster.clusterId, src.skillPins, { restoringSnapshot: true });
|
|
878
879
|
if (src.autoCompaction) await clusterStore.setAutoCompaction(cluster.clusterId, src.autoCompaction);
|
|
879
880
|
await clusterStore.setEfficiency(
|
|
880
881
|
cluster.clusterId,
|
|
@@ -36,6 +36,7 @@ import {
|
|
|
36
36
|
resolveClusterMessageGuard,
|
|
37
37
|
type ClusterMessageGuard,
|
|
38
38
|
type ClusterCreationSettings,
|
|
39
|
+
type ClusterSkillPin,
|
|
39
40
|
type ClusterDispatcherSettingsPatch,
|
|
40
41
|
type ClusterDispatcherState,
|
|
41
42
|
type ClusterEfficiencyLevel,
|
|
@@ -64,6 +65,7 @@ const ARCO_HOME = arcoHome();
|
|
|
64
65
|
const CLUSTERS_DIR = join(ARCO_HOME, 'clusters');
|
|
65
66
|
|
|
66
67
|
export interface ClusterState {
|
|
68
|
+
skillPins?: ClusterSkillPin[];
|
|
67
69
|
autoCompaction?: AutoCompactionPolicy;
|
|
68
70
|
clusterId: string;
|
|
69
71
|
cwd: string;
|
|
@@ -112,6 +114,9 @@ export interface ClusterState {
|
|
|
112
114
|
// Rule-based), so clusters saved before the modes existed keep their
|
|
113
115
|
// behavior. autoTurnOnMailboxEnabled is kept equal to "mode is rule".
|
|
114
116
|
autoPickupMode?: AutoPickupMode;
|
|
117
|
+
// Operator pause timestamp, independent of the Rule-based wake-budget stop.
|
|
118
|
+
// The timestamp freezes Smart's remaining session time across restart.
|
|
119
|
+
autoPickupPausedAt?: number;
|
|
115
120
|
remindBusy?: boolean;
|
|
116
121
|
rulePickupLimits?: Partial<RulePickupLimits>;
|
|
117
122
|
// Smart pickup choices kept across disarm: the active evaluator, the last
|
|
@@ -272,6 +277,29 @@ function withClusterMetaLock<T>(clusterId: string, fn: () => Promise<T>): Promis
|
|
|
272
277
|
return withFileLock(clusterMetaPath(clusterId), fn);
|
|
273
278
|
}
|
|
274
279
|
|
|
280
|
+
// Direct tab-pin edits share the cluster lock with role and cluster-pin edits,
|
|
281
|
+
// so concurrent edits cannot each pass against an outdated effective union.
|
|
282
|
+
export function withClusterSkillLock<T>(workflowId: string, fn: () => Promise<T>): Promise<T> {
|
|
283
|
+
const clusterId = getClusterIdForWorkflow(workflowId);
|
|
284
|
+
return clusterId ? withClusterMetaLock(clusterId, fn) : fn();
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
export async function setSkillPins(clusterId: string, value: unknown, options: { restoringSnapshot?: boolean } = {}): Promise<ClusterState | null> {
|
|
288
|
+
return withClusterMetaLock(clusterId, async () => {
|
|
289
|
+
const state = await readCluster(clusterId);
|
|
290
|
+
if (!state) return null;
|
|
291
|
+
const { parseClusterSkillPins, validateNewClusterPins } = await import('./clusterSkills.js');
|
|
292
|
+
const pins = parseClusterSkillPins(value);
|
|
293
|
+
// A saved snapshot has the same missing/off/grown-file behavior as restart.
|
|
294
|
+
// Current turn resolution still enforces the standing prompt limits.
|
|
295
|
+
if (!options.restoringSnapshot) await validateNewClusterPins(state, pins);
|
|
296
|
+
const next = { ...state, skillPins: pins.length ? pins : undefined };
|
|
297
|
+
await writeMetaAtomic(next);
|
|
298
|
+
rebuildIndexFor(next);
|
|
299
|
+
return next;
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
|
|
275
303
|
async function writeMetaAtomic(state: ClusterState): Promise<void> {
|
|
276
304
|
const path = clusterMetaPath(state.clusterId);
|
|
277
305
|
// proper-lockfile needs the file to exist before lock(); seed an empty
|
|
@@ -443,6 +471,7 @@ export async function addMember(
|
|
|
443
471
|
);
|
|
444
472
|
}
|
|
445
473
|
const next: ClusterState = { ...state, members: [...state.members, workflowId] };
|
|
474
|
+
if (next.skillPins?.length) await (await import('./clusterSkills.js')).assertClusterSkillLimits(next);
|
|
446
475
|
await writeMetaAtomic(next);
|
|
447
476
|
rebuildIndexFor(next);
|
|
448
477
|
memberJoined?.(clusterId, workflowId);
|
|
@@ -535,6 +564,7 @@ export async function replaceMember(
|
|
|
535
564
|
oldWorkflowId: string,
|
|
536
565
|
newWorkflowId: string,
|
|
537
566
|
accessMode?: ClusterMemberAccessMode,
|
|
567
|
+
role?: string,
|
|
538
568
|
): Promise<ClusterState | null> {
|
|
539
569
|
return withClusterMetaLock(clusterId, async () => {
|
|
540
570
|
const state = await readCluster(clusterId);
|
|
@@ -563,6 +593,16 @@ export async function replaceMember(
|
|
|
563
593
|
memberFocuses: remapSparse(state.memberFocuses, oldWorkflowId, newWorkflowId),
|
|
564
594
|
memberAccessModes: Object.keys(nextModes).length > 0 ? nextModes : undefined,
|
|
565
595
|
};
|
|
596
|
+
if (role !== undefined) {
|
|
597
|
+
const roles = { ...next.memberRoles };
|
|
598
|
+
const savedRole = normalizeClusterRoleText(role).slice(0, MEMBER_ROLE_MAX);
|
|
599
|
+
if (savedRole) roles[newWorkflowId] = savedRole;
|
|
600
|
+
else delete roles[newWorkflowId];
|
|
601
|
+
const problem = clusterDirectorProblem(next.members.map(id => roles[id]));
|
|
602
|
+
if (problem) throw new ClusterValidationError('multiple_directors', problem);
|
|
603
|
+
next.memberRoles = Object.keys(roles).length ? roles : undefined;
|
|
604
|
+
}
|
|
605
|
+
if (next.skillPins?.length) await (await import('./clusterSkills.js')).assertClusterSkillLimits(next);
|
|
566
606
|
if (nextMode === 'isolated') {
|
|
567
607
|
await fs.mkdir(isolatedWorkspaceFor(clusterId, newWorkflowId), { recursive: true, mode: 0o700 });
|
|
568
608
|
}
|
|
@@ -683,6 +723,7 @@ export async function setMemberRole(
|
|
|
683
723
|
const next: ClusterState = Object.keys(nextRoles).length === 0
|
|
684
724
|
? { ...state, memberRoles: undefined }
|
|
685
725
|
: { ...state, memberRoles: nextRoles };
|
|
726
|
+
if (!options.restoringSnapshot && next.skillPins?.length) await (await import('./clusterSkills.js')).assertClusterSkillLimits(next);
|
|
686
727
|
await writeMetaAtomic(next);
|
|
687
728
|
rebuildIndexFor(next);
|
|
688
729
|
return next;
|
|
@@ -1001,13 +1042,28 @@ export async function setAutoTurnOnMailbox(
|
|
|
1001
1042
|
// its own id and expiry; any other mode clears the session, which makes any
|
|
1002
1043
|
// outstanding Smart work stale. The evaluator, last explicit choice and
|
|
1003
1044
|
// limits persist across disarm so re-arming can offer them again.
|
|
1045
|
+
// Pause-only updates preserve session identity and remaining running time;
|
|
1046
|
+
// resume moves its expiry forward by the saved pause duration.
|
|
1004
1047
|
export async function setAutoPickup(
|
|
1005
1048
|
clusterId: string,
|
|
1006
|
-
opts: { mode: AutoPickupMode; evaluator?: SmartPickupEvaluator; limits?: Partial<SmartPickupLimits>; ruleLimits?: Partial<RulePickupLimits>; remindBusy?: boolean; now?: number },
|
|
1049
|
+
opts: { mode: AutoPickupMode; paused?: boolean; evaluator?: SmartPickupEvaluator; limits?: Partial<SmartPickupLimits>; ruleLimits?: Partial<RulePickupLimits>; remindBusy?: boolean; now?: number },
|
|
1007
1050
|
): Promise<ClusterState | null> {
|
|
1008
1051
|
return withClusterMetaLock(clusterId, async () => {
|
|
1009
1052
|
const state = await readCluster(clusterId);
|
|
1010
1053
|
if (!state) return null;
|
|
1054
|
+
if (typeof opts.paused === 'boolean') {
|
|
1055
|
+
if (opts.mode === 'off' || opts.mode !== autoPickupModeOf(state)) return null;
|
|
1056
|
+
const now = opts.now ?? Date.now();
|
|
1057
|
+
const pausedAt = state.autoPickupPausedAt;
|
|
1058
|
+
const session = state.smartPickup?.session;
|
|
1059
|
+
const smartPickup = !opts.paused && pausedAt !== undefined && session && isSmartPickupMode(opts.mode)
|
|
1060
|
+
? { ...state.smartPickup, session: { ...session, expiresAt: session.expiresAt + Math.max(0, now - pausedAt) } }
|
|
1061
|
+
: state.smartPickup;
|
|
1062
|
+
const next = { ...state, autoPickupPausedAt: opts.paused ? pausedAt ?? now : undefined, smartPickup };
|
|
1063
|
+
await writeMetaAtomic(next);
|
|
1064
|
+
rebuildIndexFor(next);
|
|
1065
|
+
return next;
|
|
1066
|
+
}
|
|
1011
1067
|
const now = opts.now ?? Date.now();
|
|
1012
1068
|
const prior = state.smartPickup ?? {};
|
|
1013
1069
|
const limits = opts.limits ? sanitizeSmartPickupLimits({ ...sanitizeSmartPickupLimits(prior.limits), ...opts.limits }) : prior.limits;
|
|
@@ -1033,6 +1089,9 @@ export async function setAutoPickup(
|
|
|
1033
1089
|
rulePickupLimits: opts.ruleLimits ? sanitizeRulePickupLimits({ ...sanitizeRulePickupLimits(state.rulePickupLimits), ...opts.ruleLimits }) : state.rulePickupLimits,
|
|
1034
1090
|
remindBusy: typeof opts.remindBusy === 'boolean' ? opts.remindBusy : state.remindBusy,
|
|
1035
1091
|
autoPickupMode: opts.mode === 'off' ? undefined : opts.mode,
|
|
1092
|
+
autoPickupPausedAt: opts.mode !== 'off' && opts.mode === autoPickupModeOf(state) && state.autoPickupPausedAt !== undefined
|
|
1093
|
+
? isSmartPickupMode(opts.mode) ? now : state.autoPickupPausedAt
|
|
1094
|
+
: undefined,
|
|
1036
1095
|
autoTurnOnMailboxEnabled: opts.mode === 'rule' ? true : undefined,
|
|
1037
1096
|
smartPickup: hasSmart ? smartPickup : undefined,
|
|
1038
1097
|
};
|
|
@@ -1047,6 +1106,10 @@ export function getAutoPickupMode(clusterId: string): AutoPickupMode {
|
|
|
1047
1106
|
return resolveAutoPickupMode(state?.autoPickupMode, state?.autoTurnOnMailboxEnabled);
|
|
1048
1107
|
}
|
|
1049
1108
|
|
|
1109
|
+
export function isAutoPickupPaused(clusterId: string): boolean {
|
|
1110
|
+
return cache.get(clusterId)?.autoPickupPausedAt !== undefined;
|
|
1111
|
+
}
|
|
1112
|
+
|
|
1050
1113
|
export function autoPickupModeOf(state: Pick<ClusterState, 'autoPickupMode' | 'autoTurnOnMailboxEnabled'>): AutoPickupMode {
|
|
1051
1114
|
return resolveAutoPickupMode(state.autoPickupMode, state.autoTurnOnMailboxEnabled);
|
|
1052
1115
|
}
|
package/server/src/eventLog.ts
CHANGED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
// a segment, or that a checked segment holds.
|
|
21
21
|
|
|
22
22
|
import { promises as fs, createReadStream, closeSync, fstatSync, openSync, readFileSync, readSync, readdirSync, statSync, constants as fsConstants } from 'node:fs';
|
|
23
|
-
import {
|
|
23
|
+
import { jsonlLines } from './jsonlLines.js';
|
|
24
24
|
import { brotliCompress, brotliDecompress, brotliDecompressSync, createBrotliDecompress, constants as zc } from 'node:zlib';
|
|
25
25
|
import { promisify } from 'node:util';
|
|
26
26
|
import { randomUUID } from 'node:crypto';
|
|
@@ -225,7 +225,7 @@ async function firstLiveSeq(file: string): Promise<number | null> {
|
|
|
225
225
|
const fh = await openLive(file);
|
|
226
226
|
if (!fh) return null;
|
|
227
227
|
try {
|
|
228
|
-
for await (const line of handleLines(fh)) { const seq = lineSeq(line); if (seq !== null) return seq; }
|
|
228
|
+
for await (const line of handleLines(fh, file)) { const seq = lineSeq(line); if (seq !== null) return seq; }
|
|
229
229
|
return null;
|
|
230
230
|
} finally { await fh.close(); }
|
|
231
231
|
}
|
|
@@ -241,18 +241,17 @@ function reportUnreadable(err: unknown): void {
|
|
|
241
241
|
}
|
|
242
242
|
|
|
243
243
|
async function* segmentLines(seg: Segment): AsyncGenerator<string> {
|
|
244
|
-
const input = createReadStream(seg.file);
|
|
244
|
+
const input = createReadStream(seg.file, { highWaterMark: 64 * 1024 });
|
|
245
245
|
const decompressed = createBrotliDecompress();
|
|
246
246
|
// An error opening or reading the file (a segment removed or replaced since
|
|
247
247
|
// it was listed) reaches the reader below instead of going unhandled.
|
|
248
248
|
input.on('error', (err) => decompressed.destroy(err));
|
|
249
|
-
const rl = createInterface({ input: input.pipe(decompressed), crlfDelay: Infinity });
|
|
250
249
|
try {
|
|
251
|
-
for await (const line of
|
|
250
|
+
for await (const line of jsonlLines(input.pipe(decompressed), seg.file)) if (line) yield line;
|
|
252
251
|
} catch (err) {
|
|
253
252
|
throw new SegmentReadError(seg.file, err);
|
|
254
253
|
} finally {
|
|
255
|
-
|
|
254
|
+
input.destroy(); decompressed.destroy();
|
|
256
255
|
}
|
|
257
256
|
}
|
|
258
257
|
|
|
@@ -261,17 +260,16 @@ async function openLive(file: string): Promise<FileHandle | null> {
|
|
|
261
260
|
catch (err) { if ((err as NodeJS.ErrnoException).code === 'ENOENT') return null; throw err; }
|
|
262
261
|
}
|
|
263
262
|
|
|
264
|
-
async function* handleLines(fh: FileHandle): AsyncGenerator<string> {
|
|
265
|
-
const input = fh.createReadStream({ autoClose: false });
|
|
266
|
-
const
|
|
267
|
-
|
|
268
|
-
finally { rl.close(); input.destroy(); }
|
|
263
|
+
async function* handleLines(fh: FileHandle, source: string): AsyncGenerator<string> {
|
|
264
|
+
const input = fh.createReadStream({ autoClose: false, highWaterMark: 64 * 1024 });
|
|
265
|
+
try { for await (const line of jsonlLines(input, source)) if (line) yield line; }
|
|
266
|
+
finally { input.destroy(); }
|
|
269
267
|
}
|
|
270
268
|
|
|
271
269
|
async function* liveLines(file: string): AsyncGenerator<string> {
|
|
272
270
|
const fh = await openLive(file);
|
|
273
271
|
if (!fh) return;
|
|
274
|
-
try { yield* handleLines(fh); } finally { await fh.close(); }
|
|
272
|
+
try { yield* handleLines(fh, file); } finally { await fh.close(); }
|
|
275
273
|
}
|
|
276
274
|
|
|
277
275
|
// Every record line in sequence order: sealed segments, then the live file.
|
|
@@ -319,7 +317,7 @@ export async function* readLogLines(dir: string, opts: { fromSeq?: number } = {}
|
|
|
319
317
|
try {
|
|
320
318
|
yield* drainSegments();
|
|
321
319
|
if (!fh) return;
|
|
322
|
-
for await (const line of handleLines(fh)) if (!copies.drop(line)) yield line;
|
|
320
|
+
for await (const line of handleLines(fh, path.join(dir, LIVE_LOG))) if (!copies.drop(line)) yield line;
|
|
323
321
|
} finally { await fh?.close(); }
|
|
324
322
|
}
|
|
325
323
|
|
|
@@ -331,6 +329,68 @@ export async function readLogText(dir: string): Promise<string> {
|
|
|
331
329
|
return parts.length ? parts.join('\n') + '\n' : '';
|
|
332
330
|
}
|
|
333
331
|
|
|
332
|
+
// Byte offsets retain the old resume reader's accounting: raw file bytes for
|
|
333
|
+
// a plain log, or the newline-normalized, overlap-filtered readLogText bytes
|
|
334
|
+
// when segments exist. Ranges stream without concatenating the whole log.
|
|
335
|
+
export interface LogByteSource {
|
|
336
|
+
size: number;
|
|
337
|
+
chunks(start: number, length: number): AsyncGenerator<Buffer>;
|
|
338
|
+
read(start: number, length: number): Promise<string>;
|
|
339
|
+
close(): Promise<void>;
|
|
340
|
+
}
|
|
341
|
+
export async function openLogByteSource(dir: string): Promise<LogByteSource | null> {
|
|
342
|
+
let size = 0;
|
|
343
|
+
let chunks: LogByteSource['chunks'];
|
|
344
|
+
let close: LogByteSource['close'] = async () => {};
|
|
345
|
+
if ((await listSegments(dir)).length) {
|
|
346
|
+
for await (const line of readLogLines(dir)) size += Buffer.byteLength(line, 'utf8') + 1;
|
|
347
|
+
chunks = async function* (start, length) {
|
|
348
|
+
const end = Math.min(size, start + length);
|
|
349
|
+
let position = 0;
|
|
350
|
+
for await (const line of readLogLines(dir)) {
|
|
351
|
+
const next = position + Buffer.byteLength(line, 'utf8') + 1;
|
|
352
|
+
if (next > start && position < end) {
|
|
353
|
+
const buffer = Buffer.from(line + '\n', 'utf8');
|
|
354
|
+
const from = Math.max(0, start - position), through = Math.min(buffer.length, end - position);
|
|
355
|
+
for (let offset = from; offset < through; offset += 64 * 1024) {
|
|
356
|
+
yield buffer.subarray(offset, Math.min(through, offset + 64 * 1024));
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
position = next;
|
|
360
|
+
if (position >= end) break;
|
|
361
|
+
}
|
|
362
|
+
};
|
|
363
|
+
} else {
|
|
364
|
+
const file = path.join(dir, LIVE_LOG);
|
|
365
|
+
const fh = await openLive(file);
|
|
366
|
+
if (!fh) return null;
|
|
367
|
+
try {
|
|
368
|
+
const stat = await fh.stat();
|
|
369
|
+
if (!stat.isFile()) throw new Error(`Expected a history file at ${file}`);
|
|
370
|
+
size = stat.size;
|
|
371
|
+
} catch (err) {
|
|
372
|
+
await fh.close();
|
|
373
|
+
throw err;
|
|
374
|
+
}
|
|
375
|
+
close = () => fh.close();
|
|
376
|
+
chunks = async function* (start, length) {
|
|
377
|
+
const end = Math.min(size, start + length);
|
|
378
|
+
for (let position = start; position < end;) {
|
|
379
|
+
const buffer = Buffer.alloc(Math.min(64 * 1024, end - position));
|
|
380
|
+
const { bytesRead } = await fh.read(buffer, 0, buffer.length, position);
|
|
381
|
+
if (!bytesRead) break;
|
|
382
|
+
position += bytesRead;
|
|
383
|
+
yield buffer.subarray(0, bytesRead);
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
}
|
|
387
|
+
return { size, chunks, close, read: async (start, length) => {
|
|
388
|
+
const parts: Buffer[] = [];
|
|
389
|
+
for await (const chunk of chunks(start, length)) parts.push(chunk);
|
|
390
|
+
return Buffer.concat(parts).toString('utf8');
|
|
391
|
+
} };
|
|
392
|
+
}
|
|
393
|
+
|
|
334
394
|
function decompressSegmentSync(seg: Segment): string {
|
|
335
395
|
try { return brotliDecompressSync(readFileSync(seg.file)).toString('utf8'); }
|
|
336
396
|
catch (err) { throw new SegmentReadError(seg.file, err); }
|
|
@@ -1893,7 +1893,7 @@ export async function handleHttpRequest(
|
|
|
1893
1893
|
res.end(JSON.stringify({ error: retired }));
|
|
1894
1894
|
return;
|
|
1895
1895
|
}
|
|
1896
|
-
const provider: CliProvider = providerParam === 'codex'
|
|
1896
|
+
const provider: CliProvider = providerParam === 'codex' || providerParam === 'cursor'
|
|
1897
1897
|
? providerParam
|
|
1898
1898
|
: 'claude';
|
|
1899
1899
|
const result = await runCliUpdate(deps.getCapabilities(), provider);
|
package/server/src/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { releaseProjectSettingsWatcher } from './settings.js';
|
|
2
|
+
import { initTranscriptWorkerHandlers, handleTranscriptWorkerPreview, handleTranscriptWorkerCreate } from './ws/transcriptWorkerHandlers.js';
|
|
2
3
|
import { NativeTaskAdmission, assertNativeTaskAllowed } from './providers/claude-native/taskAdmission.js';
|
|
3
4
|
import { resolveNativeSubagents, CLAUDE_MODELS } from '@arco/shared';
|
|
4
5
|
import { getCatalog as getNativeTaskCatalog } from './providers/claude-native/catalog.js';
|
|
@@ -163,6 +164,7 @@ handleClusterOrchestrationProposalList,
|
|
|
163
164
|
handleClusterOrchestrationProposalReject,
|
|
164
165
|
handleClusterIdleNudgerToggle,
|
|
165
166
|
handleClusterEfficiencySet,
|
|
167
|
+
handleClusterSkillsSet,
|
|
166
168
|
handleClusterAutoCompactionSet,
|
|
167
169
|
handleClusterRemoteSet,
|
|
168
170
|
handleClusterGatesSet,
|
|
@@ -621,6 +623,18 @@ const previewAutoDetect = new PreviewAutoDetect({
|
|
|
621
623
|
|
|
622
624
|
initTurnEngine({ previewAutoDetect, handleCreateWorkflow, handleHandoffRequest, handleCompactWorkflow });
|
|
623
625
|
initWorkflowHandlers({ previewAutoDetect, handleRehydrateWorkflows });
|
|
626
|
+
initTranscriptWorkerHandlers({
|
|
627
|
+
create: async (ws, session, config) => {
|
|
628
|
+
let id: string | undefined;
|
|
629
|
+
await handleCreateWorkflow(ws, session, config, { backgroundCreated: true, onCreated: created => { id = created; } });
|
|
630
|
+
if (!id) throw new Error('The new worker could not be created. Review its settings and try again.');
|
|
631
|
+
return id;
|
|
632
|
+
},
|
|
633
|
+
seed: (ws, session, workflowId, content) => {
|
|
634
|
+
void handleUserMessage(ws, session, workflowId, content, crypto.randomUUID(), undefined, false, undefined, undefined)
|
|
635
|
+
.catch(() => send(ws, { type: 'error', workflowId, message: 'Could not start the new worker. Open its tab to review the request and retry.' }));
|
|
636
|
+
},
|
|
637
|
+
});
|
|
624
638
|
setStrataSwitchActivityCheck(() => [...workflows.values()].some((wf) =>
|
|
625
639
|
(wf.busy && ['ollama', 'llamacpp', 'lmstudio', 'deepseek'].includes(wf.primary.provider)) ||
|
|
626
640
|
Object.values(wf.manager.snapshotWorkers()).some((w) => ['ollama', 'llamacpp', 'lmstudio', 'deepseek'].includes(w.provider ?? '') && (w.status === 'running' || w.status === 'spawning'))));
|
|
@@ -730,6 +744,12 @@ wss.on('connection', (ws: WebSocket) => {
|
|
|
730
744
|
}
|
|
731
745
|
|
|
732
746
|
switch (msg.type) {
|
|
747
|
+
case 'transcript_worker_preview':
|
|
748
|
+
void handleTranscriptWorkerPreview(ws, msg);
|
|
749
|
+
break;
|
|
750
|
+
case 'transcript_worker_create':
|
|
751
|
+
void handleTranscriptWorkerCreate(ws, session, msg);
|
|
752
|
+
break;
|
|
733
753
|
case 'create_workflow':
|
|
734
754
|
(msg.config.incognito ? withoutOperationalLogging : <T>(fn: () => T) => fn())(() =>
|
|
735
755
|
handleCreateWorkflow(ws, session, msg.config).catch((err) => {
|
|
@@ -1313,6 +1333,9 @@ wss.on('connection', (ws: WebSocket) => {
|
|
|
1313
1333
|
console.error('[arco] cluster_efficiency_set handler failed:', err);
|
|
1314
1334
|
});
|
|
1315
1335
|
break;
|
|
1336
|
+
case 'cluster_skills_set':
|
|
1337
|
+
void handleClusterSkillsSet(ws, msg.clusterId, msg.pins);
|
|
1338
|
+
break;
|
|
1316
1339
|
case 'cluster_remote_set':
|
|
1317
1340
|
handleClusterRemoteSet(ws, msg.clusterId, msg.enabled).catch((err) => {
|
|
1318
1341
|
console.error('[arco] cluster_remote_set handler failed:', err);
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { basename } from 'node:path';
|
|
2
|
+
|
|
3
|
+
const LARGE_RECORD_BYTES = 16 * 1024 * 1024;
|
|
4
|
+
const warnedSources = new Set<string>();
|
|
5
|
+
|
|
6
|
+
// Retain only the current record's bytes. Decode once at its boundary so a
|
|
7
|
+
// split UTF-8 character is never replaced and a long record does not build a
|
|
8
|
+
// chain of decoded string fragments. Large records stay readable as before.
|
|
9
|
+
export async function* jsonlLines(
|
|
10
|
+
input: AsyncIterable<Buffer>,
|
|
11
|
+
source: string,
|
|
12
|
+
options: { finalLine?: boolean; carriageReturns?: boolean } = {},
|
|
13
|
+
): AsyncGenerator<string> {
|
|
14
|
+
let parts: Buffer[] = [];
|
|
15
|
+
let bytes = 0;
|
|
16
|
+
let afterCr = false;
|
|
17
|
+
const add = (part: Buffer): void => {
|
|
18
|
+
if (!part.length) return;
|
|
19
|
+
parts.push(part);
|
|
20
|
+
bytes += part.length;
|
|
21
|
+
if (bytes > LARGE_RECORD_BYTES && !warnedSources.has(source)) {
|
|
22
|
+
warnedSources.add(source);
|
|
23
|
+
console.warn(`[arco] A record in ${basename(source)} exceeds 16 MiB; reading it in full.`);
|
|
24
|
+
}
|
|
25
|
+
};
|
|
26
|
+
const take = (): string => {
|
|
27
|
+
const line = parts.length === 1 ? parts[0].toString('utf8') : Buffer.concat(parts, bytes).toString('utf8');
|
|
28
|
+
parts = [];
|
|
29
|
+
bytes = 0;
|
|
30
|
+
return line;
|
|
31
|
+
};
|
|
32
|
+
for await (const chunk of input) {
|
|
33
|
+
let start = 0;
|
|
34
|
+
const hasCr = options.carriageReturns !== false && chunk.includes(0x0d);
|
|
35
|
+
while (start < chunk.length) {
|
|
36
|
+
if (afterCr) {
|
|
37
|
+
afterCr = false;
|
|
38
|
+
if (chunk[start] === 0x0a) { start++; continue; }
|
|
39
|
+
}
|
|
40
|
+
const lf = chunk.indexOf(0x0a, start);
|
|
41
|
+
const cr = hasCr ? chunk.indexOf(0x0d, start) : -1;
|
|
42
|
+
const end = lf < 0 ? cr : cr < 0 ? lf : Math.min(lf, cr);
|
|
43
|
+
if (end < 0) break;
|
|
44
|
+
add(chunk.subarray(start, end));
|
|
45
|
+
yield take();
|
|
46
|
+
afterCr = chunk[end] === 0x0d;
|
|
47
|
+
start = end + 1;
|
|
48
|
+
}
|
|
49
|
+
add(chunk.subarray(start));
|
|
50
|
+
}
|
|
51
|
+
if (bytes && options.finalLine !== false) yield take();
|
|
52
|
+
}
|
|
@@ -465,7 +465,7 @@ export function registerClusterTools(server: McpServer, ctx: ClusterMcpToolCtx):
|
|
|
465
465
|
'cluster_task_create',
|
|
466
466
|
{
|
|
467
467
|
description:
|
|
468
|
-
'Create a non-terminal task on the shared cluster board. New tasks start as todo;
|
|
468
|
+
'Create a non-terminal task on the shared cluster board. New tasks start as todo; terminal statuses cannot be set when creating a task. Use title plus optional body/notes, assignee, priority, parentIds, links, reviewRequired, goalMode, and goalMaxTurns. parentIds must refer to existing tasks. When the task implements a plan item, start the title with that item\'s id or text (e.g. \'P6.9 Live tab drag follow on X11\'): cluster_task_show then resolves the item\'s reference docs (its own ref links, its sub-bullets, its phase intro) for whoever works it. Add any extra ref:slug links the task needs to notes.',
|
|
469
469
|
inputSchema: {
|
|
470
470
|
title: z.string().min(1).describe('Task title. Required and non-empty.'),
|
|
471
471
|
body: z.string().optional().describe('Initial task body. Alias for notes when notes is absent.'),
|
|
@@ -563,7 +563,7 @@ export function registerClusterTools(server: McpServer, ctx: ClusterMcpToolCtx):
|
|
|
563
563
|
'cluster_task_update',
|
|
564
564
|
{
|
|
565
565
|
description:
|
|
566
|
-
"Update a task on the shared cluster board.
|
|
566
|
+
"Update a task on the shared cluster board. Workers move completed work to review. Only the director signs off: set signoff to met, partial, or not_met with a plain one-line summary for the operator, without commit hashes. A director's met sign-off closes the task unless Board auto-done is off in Settings; partial and not_met leave the task status unchanged unless you set a status. Tell the operator in chat what to try. Direct status changes to done or archived remain operator-only.",
|
|
567
567
|
inputSchema: {
|
|
568
568
|
id: z.string().min(1).describe('Task id from cluster_task_list.'),
|
|
569
569
|
status: z.enum(['triage', 'todo', 'ready', 'in_progress', 'blocked', 'review']).optional().describe("New status. 'done' and 'archived' are rejected — operator-only."),
|
|
@@ -572,7 +572,7 @@ export function registerClusterTools(server: McpServer, ctx: ClusterMcpToolCtx):
|
|
|
572
572
|
signoff: z.object({
|
|
573
573
|
state: z.enum(['met', 'not_met', 'partial']).describe('Your verdict: met / not_met / partial.'),
|
|
574
574
|
summary: z.string().optional().describe('One-line reason shown on the board card.'),
|
|
575
|
-
}).optional().describe('
|
|
575
|
+
}).optional().describe('Director verdict: met closes the task unless Board auto-done is off.'),
|
|
576
576
|
},
|
|
577
577
|
},
|
|
578
578
|
async (args) => {
|
|
@@ -699,7 +699,7 @@ export function registerClusterTools(server: McpServer, ctx: ClusterMcpToolCtx):
|
|
|
699
699
|
'cluster_task_complete',
|
|
700
700
|
{
|
|
701
701
|
description:
|
|
702
|
-
"Submit a completion report for a task. Moves the task to review and appends a durable COMPLETION REPORT comment. It does
|
|
702
|
+
"Submit a completion report for a task. Moves the task to review and appends a durable COMPLETION REPORT comment. It does not mark done; the director reviews the report.",
|
|
703
703
|
inputSchema: {
|
|
704
704
|
id: z.string().min(1).describe('Task id from cluster_task_list.'),
|
|
705
705
|
summary: z.string().min(1).describe('What changed, tests run, files touched, and follow-ups.'),
|
|
@@ -14,10 +14,9 @@ import { ensureProjectStateIgnore } from '../projectStateIgnore.js';
|
|
|
14
14
|
// need — is documented in docs/TASK_LEDGER.md, not assumed). The working set is
|
|
15
15
|
// small + single-writer, so query() is load-all + filter-in-JS.
|
|
16
16
|
//
|
|
17
|
-
//
|
|
18
|
-
//
|
|
19
|
-
//
|
|
20
|
-
// recorded operator events; there is no auto-done / no inference anywhere.
|
|
17
|
+
// Direct terminal-status updates are operator-controlled. A director's met
|
|
18
|
+
// sign-off may close a task when Board auto-done is enabled; replay uses the
|
|
19
|
+
// recorded result and never infers a new status.
|
|
21
20
|
|
|
22
21
|
import { promises as fs, existsSync } from 'fs';
|
|
23
22
|
import path from 'path';
|
|
@@ -748,9 +747,10 @@ export function applyUpdate(
|
|
|
748
747
|
// Release label; '' clears it, undefined leaves it untouched.
|
|
749
748
|
release?: string;
|
|
750
749
|
worktree?: TaskWorktree | null;
|
|
751
|
-
//
|
|
750
|
+
// Director verdict. An object sets it (caller stamps
|
|
752
751
|
// byWorkflowId/at); `null` clears it; `undefined` leaves it untouched.
|
|
753
752
|
signoff?: TaskSignoff | null;
|
|
753
|
+
directorClosure?: { byWorkflowId: string; at: number };
|
|
754
754
|
updatedBy?: string;
|
|
755
755
|
},
|
|
756
756
|
): { tasks: LedgerTask[]; updated: LedgerTask } | null {
|
|
@@ -809,6 +809,8 @@ export function applyUpdate(
|
|
|
809
809
|
if (clean) next.signoff = clean;
|
|
810
810
|
else delete next.signoff;
|
|
811
811
|
}
|
|
812
|
+
if (patch.directorClosure) next.directorClosure = patch.directorClosure;
|
|
813
|
+
else if (patch.status && patch.status !== 'done') delete next.directorClosure;
|
|
812
814
|
const out = [...tasks];
|
|
813
815
|
out[i] = next;
|
|
814
816
|
return { tasks: out, updated: next };
|
|
@@ -5,6 +5,21 @@ import { readMeta, persistInitialMeta, reconcileLatestCliSession, workflowMetaSe
|
|
|
5
5
|
import { scanEventsOfTypes } from './workflowStore.js';
|
|
6
6
|
import { broadcastWorkflow, broadcastTransient } from './server/broadcast.js';
|
|
7
7
|
|
|
8
|
+
const historyLoadNotices = new WeakMap<object, Set<string>>();
|
|
9
|
+
export function reportHistoryLoadFailure(workflowId: string, owner: object, provider: 'native' | 'cli', emit?: (content: string) => void, nativeLimitBytes?: number): void {
|
|
10
|
+
const shown = historyLoadNotices.get(owner) ?? new Set<string>();
|
|
11
|
+
if (shown.has(provider)) return;
|
|
12
|
+
shown.add(provider);
|
|
13
|
+
historyLoadNotices.set(owner, shown);
|
|
14
|
+
const content = provider === 'native'
|
|
15
|
+
? nativeLimitBytes !== undefined
|
|
16
|
+
? `Earlier context could not be rebuilt within the ${nativeLimitBytes / (1024 * 1024)} MiB reconstruction limit, so the agent continues without it. Earlier messages remain in this tab.`
|
|
17
|
+
: 'Earlier context could not be rebuilt for this conversation, so the agent continues without it. Earlier messages remain in this tab.'
|
|
18
|
+
: 'Earlier Claude CLI session history could not be loaded in this tab. The saved conversation is intact; new session messages will appear when the file can be read.';
|
|
19
|
+
if (emit) emit(content);
|
|
20
|
+
else broadcastWorkflow(workflowId, { type: 'system_notice', workflowId, content });
|
|
21
|
+
}
|
|
22
|
+
|
|
8
23
|
export async function hasConversationHistory(cwd: string, workflowId: string, afterSeq = 0): Promise<boolean> {
|
|
9
24
|
let found = false;
|
|
10
25
|
await scanEventsOfTypes(cwd, workflowId, ['primary_complete', 'primary_text'], event => { if ((('seq' in event && typeof event.seq === 'number') ? event.seq : 0) > afterSeq) found = true; });
|