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
|
@@ -191,29 +191,31 @@ async function sweep() {
|
|
|
191
191
|
if (!membersByCluster)
|
|
192
192
|
return;
|
|
193
193
|
for (const clusterId of clusterStore.listKnownClusterIds()) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
194
|
+
await pickupWaitingMail(clusterId, membersByCluster.get(clusterId));
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
// Resume uses the same scan as the periodic sweep, including every normal
|
|
198
|
+
// guard and budget. Never reset the Rule-based ledger to resume an operator pause.
|
|
199
|
+
export async function pickupWaitingMail(clusterId, liveMembers = resolveMembersFn?.()?.get(clusterId)) {
|
|
200
|
+
if (!isBusyFn || !clusterStore.isAutoPickupWaking(clusterId) || clusterStore.isAutoPickupPaused(clusterId) || !liveMembers)
|
|
201
|
+
return;
|
|
202
|
+
for (const m of liveMembers) {
|
|
203
|
+
if (m.busy) {
|
|
204
|
+
if (dispatchBusyReminderFn)
|
|
205
|
+
await remindBusyMember(clusterId, m.workflowId, { isBusy: isBusyFn, hasClusterTools: hasClusterToolsFn, dispatch: dispatchBusyReminderFn });
|
|
198
206
|
continue;
|
|
199
|
-
for (const m of liveMembers) {
|
|
200
|
-
if (m.busy) {
|
|
201
|
-
if (dispatchBusyReminderFn)
|
|
202
|
-
await remindBusyMember(clusterId, m.workflowId, { isBusy: isBusyFn, hasClusterTools: hasClusterToolsFn, dispatch: dispatchBusyReminderFn });
|
|
203
|
-
continue;
|
|
204
|
-
}
|
|
205
|
-
if (!clusterStore.isAutoTurnOnMailboxEnabled(clusterId))
|
|
206
|
-
continue;
|
|
207
|
-
const pending = await clusterMailbox.peek(m.workflowId).catch(() => []);
|
|
208
|
-
if (pending.length === 0)
|
|
209
|
-
continue;
|
|
210
|
-
onPeerMessageSent({
|
|
211
|
-
clusterId,
|
|
212
|
-
senderWfid: pending[0].fromWorkflowId,
|
|
213
|
-
recipientWfid: m.workflowId,
|
|
214
|
-
incomingChainDepth: heldMailDepth(m.workflowId, pending),
|
|
215
|
-
});
|
|
216
207
|
}
|
|
208
|
+
if (!clusterStore.isAutoTurnOnMailboxEnabled(clusterId))
|
|
209
|
+
continue;
|
|
210
|
+
const pending = await clusterMailbox.peek(m.workflowId).catch(() => []);
|
|
211
|
+
if (pending.length === 0)
|
|
212
|
+
continue;
|
|
213
|
+
onPeerMessageSent({
|
|
214
|
+
clusterId,
|
|
215
|
+
senderWfid: pending[0].fromWorkflowId,
|
|
216
|
+
recipientWfid: m.workflowId,
|
|
217
|
+
incomingChainDepth: heldMailDepth(m.workflowId, pending),
|
|
218
|
+
});
|
|
217
219
|
}
|
|
218
220
|
}
|
|
219
221
|
function getClusterState(clusterId) {
|
|
@@ -327,6 +329,8 @@ export function onPeerMessageSent(opts) {
|
|
|
327
329
|
return;
|
|
328
330
|
if (opts.incomingChainDepth > pendingChainDepth(opts.recipientWfid))
|
|
329
331
|
pendingDepth.set(opts.recipientWfid, opts.incomingChainDepth);
|
|
332
|
+
if (clusterStore.isAutoPickupPaused(opts.clusterId))
|
|
333
|
+
return;
|
|
330
334
|
try {
|
|
331
335
|
ruleGuard.mail(opts.clusterId, opts.senderWfid, opts.recipientWfid);
|
|
332
336
|
}
|
|
@@ -356,7 +360,7 @@ function fireRulePickup(opts) {
|
|
|
356
360
|
const now = Date.now();
|
|
357
361
|
// Guard 0: cluster toggle armed. Most clusters won't have this on; the
|
|
358
362
|
// gate is the first check so the hot path is one map lookup when off.
|
|
359
|
-
if (!clusterStore.isAutoTurnOnMailboxEnabled(clusterId))
|
|
363
|
+
if (!clusterStore.isAutoTurnOnMailboxEnabled(clusterId) || clusterStore.isAutoPickupPaused(clusterId))
|
|
360
364
|
return;
|
|
361
365
|
// Guard 1: depth cap. An incoming chainDepth of (cap - 1) is the last one
|
|
362
366
|
// we'll auto-turn on; the auto-turn it produces will land at cap, so the
|
|
@@ -389,13 +393,13 @@ function fireRulePickup(opts) {
|
|
|
389
393
|
const wasBudgetPaused = ruleGuard.snapshot(clusterId).budgetPaused;
|
|
390
394
|
const problem = ruleGuard.admit(clusterId, senderWfid, recipientWfid, limits, now);
|
|
391
395
|
if (problem) {
|
|
392
|
-
const notice = problem === 'budget_paused' && !wasBudgetPaused ? 'Wake budget reached.
|
|
396
|
+
const notice = problem === 'budget_paused' && !wasBudgetPaused ? 'Wake budget reached. Select RESET BUDGET beside AUTO-PICKUP.' : undefined;
|
|
393
397
|
emitSkip(clusterId, recipientWfid, senderWfid, incomingChainDepth, problem, now, notice);
|
|
394
398
|
return;
|
|
395
399
|
}
|
|
396
400
|
const pauses = ruleGuard.stamp(clusterId, senderWfid, recipientWfid, limits, now);
|
|
397
401
|
const notices = [
|
|
398
|
-
...(pauses.budgetPaused ? ['Wake budget reached.
|
|
402
|
+
...(pauses.budgetPaused ? ['Wake budget reached. Select RESET BUDGET beside AUTO-PICKUP.'] : []),
|
|
399
403
|
...(pauses.pairPaused ? [`Alternating wakes paused between ${clusterStore.displayNameFor(senderWfid)} and ${clusterStore.displayNameFor(recipientWfid)}.`] : []),
|
|
400
404
|
];
|
|
401
405
|
// All guards pass — fire. Mark the new depth BEFORE dispatch so the
|
|
@@ -434,7 +438,7 @@ function fireRulePickup(opts) {
|
|
|
434
438
|
const dispatch = dispatchAutoTurnFn;
|
|
435
439
|
setImmediate(() => {
|
|
436
440
|
try {
|
|
437
|
-
if (!clusterStore.isAutoTurnOnMailboxEnabled(clusterId) || isBusyFn?.(recipientWfid))
|
|
441
|
+
if (!clusterStore.isAutoTurnOnMailboxEnabled(clusterId) || clusterStore.isAutoPickupPaused(clusterId) || isBusyFn?.(recipientWfid))
|
|
438
442
|
return;
|
|
439
443
|
dispatch(recipientWfid, prompt);
|
|
440
444
|
}
|
|
@@ -6,7 +6,7 @@ const states = new Map();
|
|
|
6
6
|
const pending = new Set();
|
|
7
7
|
function enabled(clusterId, workflowId, now) {
|
|
8
8
|
const state = store.getClusterCached(clusterId);
|
|
9
|
-
if (state?.remindBusy !== true || !state.members.includes(workflowId))
|
|
9
|
+
if (state?.remindBusy !== true || state.autoPickupPausedAt !== undefined || !state.members.includes(workflowId))
|
|
10
10
|
return false;
|
|
11
11
|
const mode = store.autoPickupModeOf(state);
|
|
12
12
|
return mode === 'rule' || (mode === 'smart-auto' && (state.smartPickup?.session?.expiresAt ?? 0) > now);
|
|
@@ -15,8 +15,8 @@ export function buildClusterDirectorDoctrine(role) {
|
|
|
15
15
|
'When this cluster has an Advisor, consult it before a design decision or when the evidence is thin; the decision remains yours.',
|
|
16
16
|
'Delegate implementation, builds, and test runs only through peer_send and track them on the board. Do not write or edit product code or tests yourself.',
|
|
17
17
|
'Stay available to the operator. Hand long-running work to peers: the project\'s checks to the tester (or a builder when there is no tester), CI watching to the change\'s author. Use their reports of what was done, run and not covered; do not run builds, test suites or CI waits yourself.',
|
|
18
|
-
'Never wait inside a turn: no sleep or polling longer than 60 seconds at a time. When the next step depends on a peer or on CI, say what is pending and end the turn; reports arrive as mail.',
|
|
19
18
|
'Landing is yours: read the complete accepted diff, check that what the project requires was run, then commit and push per project rules. Ask the peer for missing or stale results rather than regenerating them yourself. Do not invent a gate where the project has none. Do not turn a one-off incident into a standing rule or permanent test without the operator.',
|
|
19
|
+
'When a task is met, sign it off with a plain operator-facing summary without commit hashes. A met sign-off closes it unless Board auto-done is off in Settings. Tell the operator in chat what to try.',
|
|
20
20
|
'Before a failure holds work up, say what a user would lose if it were real; note cosmetic or momentary faults and carry on.',
|
|
21
21
|
'A red check must mean something. Sort each failure first: a fault in the product, or a fault in a test, a housekeeping rule or the CI service. Fix product faults. When the test or rule is at fault, fix it, skip it on that system with a stated reason, or delete it, so the check goes green and can be trusted; do not release over a red check and do not leave one red. Rerun alone a job the CI service dropped. Keep CI to checks whose failure tells the operator something about the product, and small enough to pass in one run; housekeeping findings warn, they do not fail a run.',
|
|
22
22
|
'When reading a diff, also check its shape: a second implementation of existing logic, a wrapper that only passes calls through, tests that miss the module\'s interface, or one change spread over many places. These findings are advisory unless they meet the blocking rules; record them as tasks.',
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
// recipient. The REST path does the same — both reach the in-process
|
|
30
30
|
// `broadcastWorkflow` so persistAndStampSeq stamps every event into the
|
|
31
31
|
// recipient's events.jsonl.
|
|
32
|
+
import { readSettings } from './settings.js';
|
|
32
33
|
import { recipientContext } from './peerRecipientContext.js';
|
|
33
34
|
import { createHash } from 'node:crypto';
|
|
34
35
|
import { promises as fs } from 'node:fs';
|
|
@@ -757,11 +758,8 @@ function taskDependsOn(tasks, fromId, targetId, seen = new Set()) {
|
|
|
757
758
|
return true;
|
|
758
759
|
return task.parentIds.some((parentId) => taskDependsOn(tasks, parentId, targetId, seen));
|
|
759
760
|
}
|
|
760
|
-
//
|
|
761
|
-
//
|
|
762
|
-
// operator-confirmed-done invariant (§D1) is re-enforced at the peer layer:
|
|
763
|
-
// only the operator's WS task_ledger_update may reach applyUpdate with those
|
|
764
|
-
// terminal statuses.
|
|
761
|
+
// Workers may set non-terminal statuses. Direct done / archived requests are
|
|
762
|
+
// rejected; a director met sign-off may close the task when auto-done is on.
|
|
765
763
|
const SIGNOFF_STATES = new Set(['met', 'not_met', 'partial']);
|
|
766
764
|
export async function peerTaskUpdate(ctx, args, broadcastCluster) {
|
|
767
765
|
if (mailboxOnly(ctx))
|
|
@@ -773,7 +771,7 @@ export async function peerTaskUpdate(ctx, args, broadcastCluster) {
|
|
|
773
771
|
message: 'done/archived can only be set by the operator from the LEDGER tab. Move the task to review, set blocked, or report completion via peer_send to the director.',
|
|
774
772
|
};
|
|
775
773
|
}
|
|
776
|
-
//
|
|
774
|
+
// Stamp the sign-off at the peer boundary so its author cannot be spoofed.
|
|
777
775
|
let signoffPatch;
|
|
778
776
|
if (args.signoff === null) {
|
|
779
777
|
signoffPatch = null;
|
|
@@ -807,10 +805,15 @@ export async function peerTaskUpdate(ctx, args, broadcastCluster) {
|
|
|
807
805
|
if (!board) {
|
|
808
806
|
return { ok: false, code: 'board_detached', message: 'no task board is enabled for this cluster.' };
|
|
809
807
|
}
|
|
808
|
+
const director = isClusterDirector(clusterStore.getMemberRole(ctx.clusterId, ctx.workflowId));
|
|
809
|
+
const autoMarkDone = director && signoffPatch?.state === 'met' && (await readSettings()).autoMarkDoneOnMetSignoff !== false;
|
|
810
810
|
let rejection = null;
|
|
811
811
|
const result = await persistLedgerMutation(ctx.workflowId, board.cwd, 'update', (tasks) => {
|
|
812
|
+
const previous = tasks.find((task) => task.id === args.id);
|
|
813
|
+
const close = director && autoMarkDone && signoffPatch?.state === 'met' && previous?.status !== 'done' && previous?.status !== 'archived';
|
|
812
814
|
const applied = taskLedger.applyUpdate(tasks, args.id, {
|
|
813
|
-
...(
|
|
815
|
+
...(close ? { directorClosure: { byWorkflowId: ctx.workflowId, at: signoffPatch.at } } : {}),
|
|
816
|
+
...(close ? { status: 'done' } : args.status ? { status: args.status } : {}),
|
|
814
817
|
...(typeof args.notes === 'string' ? { notes: args.notes } : {}),
|
|
815
818
|
...(typeof args.release === 'string' ? { release: args.release } : {}),
|
|
816
819
|
...(signoffPatch !== undefined ? { signoff: signoffPatch } : {}),
|
|
@@ -33,7 +33,7 @@ const PLAN_CLAUSE = [
|
|
|
33
33
|
].join(' ');
|
|
34
34
|
const BOARD_CLAUSE = [
|
|
35
35
|
'Keep the task board current.',
|
|
36
|
-
'Move each task through its statuses (todo → in_progress → review) as the work actually progresses, and report completion
|
|
36
|
+
'Move each task through its statuses (todo → in_progress → review) as the work actually progresses, and report completion for director review; a met sign-off closes the task unless Board auto-done is off in Settings. Direct done/archived status changes stay operator-only.',
|
|
37
37
|
'Do not leave finished work sitting in an earlier status.',
|
|
38
38
|
].join(' ');
|
|
39
39
|
const RECONCILE_CLAUSE = 'The plan and the board track the same work at different granularities — keep BOTH reflecting reality. ' +
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ArcoSkillRef, type ClusterSkillPin } from '@arco/shared';
|
|
2
|
+
import { type ClusterState } from './clusterStore.js';
|
|
3
|
+
export declare function uniqueSkillRefs(refs: ArcoSkillRef[]): ArcoSkillRef[];
|
|
4
|
+
export declare function parseClusterSkillPins(value: unknown): ClusterSkillPin[];
|
|
5
|
+
export declare function skillRefsForRole(state: Pick<ClusterState, 'skillPins'>, role: string | undefined, own?: ArcoSkillRef[]): ArcoSkillRef[];
|
|
6
|
+
export declare function assertSkillUnion(state: Pick<ClusterState, 'skillPins' | 'cwd'>, role: string | undefined, own: ArcoSkillRef[], label: string): Promise<void>;
|
|
7
|
+
export declare function assertClusterSkillLimits(state: ClusterState): Promise<void>;
|
|
8
|
+
export declare function validateNewClusterPins(state: ClusterState, pins: ClusterSkillPin[]): Promise<void>;
|
|
9
|
+
export declare function resolveWorkflowSkillPins(workflowId: string, cwd: string, own: ArcoSkillRef[]): Promise<{
|
|
10
|
+
refs: ArcoSkillRef[];
|
|
11
|
+
resolved: import("./skills.js").ResolvedPinnedSkills;
|
|
12
|
+
}>;
|
|
13
|
+
export declare function assertWorkflowSkillPins(workflowId: string, cwd: string, refs: ArcoSkillRef[]): Promise<void>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { normalizeClusterRoleText } from '@arco/shared';
|
|
2
|
+
import { ClusterValidationError, MEMBER_ROLE_MAX, getClusterIdForWorkflow, readCluster } 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
|
+
const key = (ref) => `${ref.scope}:${ref.slug}`;
|
|
7
|
+
const pinKey = (pin) => JSON.stringify([pin.scope, pin.slug, pin.role ?? null]);
|
|
8
|
+
export function uniqueSkillRefs(refs) {
|
|
9
|
+
return [...new Map(refs.map(ref => [key(ref), { scope: ref.scope, slug: ref.slug }])).values()];
|
|
10
|
+
}
|
|
11
|
+
export function parseClusterSkillPins(value) {
|
|
12
|
+
if (!Array.isArray(value))
|
|
13
|
+
throw new ClusterValidationError('skill_pins', 'Skills must be a list.');
|
|
14
|
+
const pins = value.map(pin => {
|
|
15
|
+
if (!pin || (pin.scope !== 'project' && pin.scope !== 'global') || !isValidSlug(pin.slug)
|
|
16
|
+
|| (pin.role !== undefined && (typeof pin.role !== 'string' || !pin.role.trim() || pin.role.trim().length > MEMBER_ROLE_MAX))) {
|
|
17
|
+
throw new ClusterValidationError('skill_pins', 'Choose an installed project/global skill and a saved role of at most 120 characters.');
|
|
18
|
+
}
|
|
19
|
+
return { scope: pin.scope, slug: pin.slug, ...(pin.role !== undefined ? { role: pin.role.trim() } : {}) };
|
|
20
|
+
});
|
|
21
|
+
return [...new Map(pins.map(pin => [pinKey(pin), pin])).values()];
|
|
22
|
+
}
|
|
23
|
+
export function skillRefsForRole(state, role, own = []) {
|
|
24
|
+
const savedRole = role ? normalizeClusterRoleText(role) : undefined;
|
|
25
|
+
return uniqueSkillRefs([
|
|
26
|
+
...(state.skillPins ?? []).filter(pin => pin.role === undefined),
|
|
27
|
+
...(state.skillPins ?? []).filter(pin => pin.role !== undefined && pin.role === savedRole),
|
|
28
|
+
...own,
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
31
|
+
export async function assertSkillUnion(state, role, own, label) {
|
|
32
|
+
const refs = skillRefsForRole(state, role, own);
|
|
33
|
+
if (refs.length > MAX_PINNED_SKILLS)
|
|
34
|
+
throw new ClusterValidationError('skill_limit', `${label}: tab, cluster and role pins together exceed 12 unique skills.`);
|
|
35
|
+
const resolved = await resolvePinnedSkills(refs, state.cwd);
|
|
36
|
+
if (resolved.truncated.length)
|
|
37
|
+
throw new ClusterValidationError('skill_limit', `${label}: tab, cluster and role pins together exceed 64 KiB of skill text.`);
|
|
38
|
+
}
|
|
39
|
+
export async function assertClusterSkillLimits(state) {
|
|
40
|
+
// Check role targets even when no current member has that role. New workers
|
|
41
|
+
// must inherit a usable set rather than discovering an over-limit role later.
|
|
42
|
+
const roles = new Set([undefined, ...(state.skillPins ?? []).map(pin => pin.role)]);
|
|
43
|
+
for (const role of roles)
|
|
44
|
+
await assertSkillUnion(state, role, [], role ? `Role ${role}` : 'All members');
|
|
45
|
+
for (const id of state.members) {
|
|
46
|
+
const wf = workflows.get(id);
|
|
47
|
+
const own = wf?.config.pinnedSkills ?? (await readMeta(state.cwd, id).catch(() => null))?.pinnedSkills ?? [];
|
|
48
|
+
await assertSkillUnion(state, state.memberRoles?.[id], own, wf?.config.name ?? `Member ${id.slice(0, 8)}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export async function validateNewClusterPins(state, pins) {
|
|
52
|
+
const previous = new Set((state.skillPins ?? []).map(pinKey));
|
|
53
|
+
// Removing a pin must stay possible after an edited skill grows over budget.
|
|
54
|
+
if (pins.every(pin => previous.has(pinKey(pin))))
|
|
55
|
+
return;
|
|
56
|
+
for (const pin of pins) {
|
|
57
|
+
if (previous.has(pinKey(pin)))
|
|
58
|
+
continue;
|
|
59
|
+
const resolved = await resolvePinnedSkills([pin], state.cwd);
|
|
60
|
+
if (resolved.missing.length)
|
|
61
|
+
throw new ClusterValidationError('skill_pins', `Skill ${pin.slug} is missing, off or unreadable. Choose an available skill.`);
|
|
62
|
+
if (resolved.truncated.length)
|
|
63
|
+
throw new ClusterValidationError('skill_limit', `Skill ${pin.slug} exceeds 64 KiB of text.`);
|
|
64
|
+
}
|
|
65
|
+
await assertClusterSkillLimits({ ...state, skillPins: pins });
|
|
66
|
+
}
|
|
67
|
+
export async function resolveWorkflowSkillPins(workflowId, cwd, own) {
|
|
68
|
+
const clusterId = getClusterIdForWorkflow(workflowId);
|
|
69
|
+
const cluster = clusterId ? await readCluster(clusterId) : null;
|
|
70
|
+
const refs = cluster ? skillRefsForRole(cluster, cluster.memberRoles?.[workflowId], own) : uniqueSkillRefs(own);
|
|
71
|
+
return { refs, resolved: await resolvePinnedSkills(refs, cluster?.cwd ?? cwd) };
|
|
72
|
+
}
|
|
73
|
+
export async function assertWorkflowSkillPins(workflowId, cwd, refs) {
|
|
74
|
+
const previous = new Set((workflows.get(workflowId)?.config.pinnedSkills ?? []).map(key));
|
|
75
|
+
if (refs.every(ref => previous.has(key(ref))))
|
|
76
|
+
return;
|
|
77
|
+
const clusterId = getClusterIdForWorkflow(workflowId);
|
|
78
|
+
const cluster = clusterId ? await readCluster(clusterId) : null;
|
|
79
|
+
await assertSkillUnion(cluster ?? { cwd }, cluster?.memberRoles?.[workflowId], refs, 'This tab');
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=clusterSkills.js.map
|
|
@@ -793,6 +793,8 @@ export async function restoreSnapshot(snapshotId, targetCwdInput, turnsPerMember
|
|
|
793
793
|
// Passive cluster configuration is portable. Runtime arming is not:
|
|
794
794
|
// idle-nudger, auto-turn, dispatcher enabled, REMOTE, and remote gates stay
|
|
795
795
|
// OFF on every restore so importing a cluster cannot start work or expose it.
|
|
796
|
+
if (src.skillPins?.length)
|
|
797
|
+
await clusterStore.setSkillPins(cluster.clusterId, src.skillPins, { restoringSnapshot: true });
|
|
796
798
|
if (src.autoCompaction)
|
|
797
799
|
await clusterStore.setAutoCompaction(cluster.clusterId, src.autoCompaction);
|
|
798
800
|
await clusterStore.setEfficiency(cluster.clusterId, src.efficiencyLevel ?? 'thorough', src.efficiencyAddendum ?? '', resolveClusterMessageGuard(src)).catch(() => { });
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type AutoCompactionPolicy, MEMBER_TIERS, type ClusterMessageGuard, type ClusterCreationSettings, type ClusterDispatcherSettingsPatch, type ClusterDispatcherState, type ClusterEfficiencyLevel, type ClusterMemberAccessMode, type ClusterProgressMode, type ClusterTaskBoardMode, type MemberTier, isMemberTier, type RulePickupLimits, type AutoPickupMode, type SmartPickupEvaluator, type SmartPickupLimits, type SmartPickupSession } from '@arco/shared';
|
|
1
|
+
import { type AutoCompactionPolicy, MEMBER_TIERS, type ClusterMessageGuard, type ClusterCreationSettings, type ClusterSkillPin, type ClusterDispatcherSettingsPatch, type ClusterDispatcherState, type ClusterEfficiencyLevel, type ClusterMemberAccessMode, type ClusterProgressMode, type ClusterTaskBoardMode, type MemberTier, isMemberTier, type RulePickupLimits, type AutoPickupMode, type SmartPickupEvaluator, type SmartPickupLimits, type SmartPickupSession } from '@arco/shared';
|
|
2
2
|
export interface ClusterState {
|
|
3
|
+
skillPins?: ClusterSkillPin[];
|
|
3
4
|
autoCompaction?: AutoCompactionPolicy;
|
|
4
5
|
clusterId: string;
|
|
5
6
|
cwd: string;
|
|
@@ -14,6 +15,7 @@ export interface ClusterState {
|
|
|
14
15
|
idleNudgerEnabled?: boolean;
|
|
15
16
|
autoTurnOnMailboxEnabled?: boolean;
|
|
16
17
|
autoPickupMode?: AutoPickupMode;
|
|
18
|
+
autoPickupPausedAt?: number;
|
|
17
19
|
remindBusy?: boolean;
|
|
18
20
|
rulePickupLimits?: Partial<RulePickupLimits>;
|
|
19
21
|
smartPickup?: {
|
|
@@ -47,6 +49,10 @@ export declare function createCluster(opts: {
|
|
|
47
49
|
cwd: string;
|
|
48
50
|
memberWorkflowIds: string[];
|
|
49
51
|
} & ClusterCreationSettings): Promise<ClusterState>;
|
|
52
|
+
export declare function withClusterSkillLock<T>(workflowId: string, fn: () => Promise<T>): Promise<T>;
|
|
53
|
+
export declare function setSkillPins(clusterId: string, value: unknown, options?: {
|
|
54
|
+
restoringSnapshot?: boolean;
|
|
55
|
+
}): Promise<ClusterState | null>;
|
|
50
56
|
export declare function readCluster(clusterId: string): Promise<ClusterState | null>;
|
|
51
57
|
export declare function loadAllClustersFromDisk(): Promise<ClusterState[]>;
|
|
52
58
|
export declare function deleteCluster(clusterId: string): Promise<void>;
|
|
@@ -59,7 +65,7 @@ export declare function removeMember(clusterId: string, workflowId: string): Pro
|
|
|
59
65
|
export declare function addMember(clusterId: string, workflowId: string): Promise<ClusterState | null>;
|
|
60
66
|
export declare function getMemberAccessMode(clusterId: string, workflowId: string): ClusterMemberAccessMode;
|
|
61
67
|
export declare function setMemberAccessMode(clusterId: string, workflowId: string, mode: ClusterMemberAccessMode): Promise<ClusterState | null>;
|
|
62
|
-
export declare function replaceMember(clusterId: string, oldWorkflowId: string, newWorkflowId: string, accessMode?: ClusterMemberAccessMode): Promise<ClusterState | null>;
|
|
68
|
+
export declare function replaceMember(clusterId: string, oldWorkflowId: string, newWorkflowId: string, accessMode?: ClusterMemberAccessMode, role?: string): Promise<ClusterState | null>;
|
|
63
69
|
export declare function getMembers(clusterId: string): string[] | undefined;
|
|
64
70
|
export declare function getPlanId(clusterId: string): string | undefined;
|
|
65
71
|
export declare function setPlanId(clusterId: string, planId: string): Promise<ClusterState | null>;
|
|
@@ -102,6 +108,7 @@ export declare function setProgressTracking(clusterId: string, mode: ClusterProg
|
|
|
102
108
|
export declare function setAutoTurnOnMailbox(clusterId: string, enabled: boolean): Promise<ClusterState | null>;
|
|
103
109
|
export declare function setAutoPickup(clusterId: string, opts: {
|
|
104
110
|
mode: AutoPickupMode;
|
|
111
|
+
paused?: boolean;
|
|
105
112
|
evaluator?: SmartPickupEvaluator;
|
|
106
113
|
limits?: Partial<SmartPickupLimits>;
|
|
107
114
|
ruleLimits?: Partial<RulePickupLimits>;
|
|
@@ -109,6 +116,7 @@ export declare function setAutoPickup(clusterId: string, opts: {
|
|
|
109
116
|
now?: number;
|
|
110
117
|
}): Promise<ClusterState | null>;
|
|
111
118
|
export declare function getAutoPickupMode(clusterId: string): AutoPickupMode;
|
|
119
|
+
export declare function isAutoPickupPaused(clusterId: string): boolean;
|
|
112
120
|
export declare function autoPickupModeOf(state: Pick<ClusterState, 'autoPickupMode' | 'autoTurnOnMailboxEnabled'>): AutoPickupMode;
|
|
113
121
|
export declare function isAutoTurnOnMailboxEnabled(clusterId: string): boolean;
|
|
114
122
|
export declare function isAutoPickupWaking(clusterId: string): boolean;
|
|
@@ -117,6 +117,29 @@ export async function createCluster(opts) {
|
|
|
117
117
|
function withClusterMetaLock(clusterId, fn) {
|
|
118
118
|
return withFileLock(clusterMetaPath(clusterId), fn);
|
|
119
119
|
}
|
|
120
|
+
// Direct tab-pin edits share the cluster lock with role and cluster-pin edits,
|
|
121
|
+
// so concurrent edits cannot each pass against an outdated effective union.
|
|
122
|
+
export function withClusterSkillLock(workflowId, fn) {
|
|
123
|
+
const clusterId = getClusterIdForWorkflow(workflowId);
|
|
124
|
+
return clusterId ? withClusterMetaLock(clusterId, fn) : fn();
|
|
125
|
+
}
|
|
126
|
+
export async function setSkillPins(clusterId, value, options = {}) {
|
|
127
|
+
return withClusterMetaLock(clusterId, async () => {
|
|
128
|
+
const state = await readCluster(clusterId);
|
|
129
|
+
if (!state)
|
|
130
|
+
return null;
|
|
131
|
+
const { parseClusterSkillPins, validateNewClusterPins } = await import('./clusterSkills.js');
|
|
132
|
+
const pins = parseClusterSkillPins(value);
|
|
133
|
+
// A saved snapshot has the same missing/off/grown-file behavior as restart.
|
|
134
|
+
// Current turn resolution still enforces the standing prompt limits.
|
|
135
|
+
if (!options.restoringSnapshot)
|
|
136
|
+
await validateNewClusterPins(state, pins);
|
|
137
|
+
const next = { ...state, skillPins: pins.length ? pins : undefined };
|
|
138
|
+
await writeMetaAtomic(next);
|
|
139
|
+
rebuildIndexFor(next);
|
|
140
|
+
return next;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
120
143
|
async function writeMetaAtomic(state) {
|
|
121
144
|
const path = clusterMetaPath(state.clusterId);
|
|
122
145
|
// proper-lockfile needs the file to exist before lock(); seed an empty
|
|
@@ -290,6 +313,8 @@ export async function addMember(clusterId, workflowId) {
|
|
|
290
313
|
throw new ClusterValidationError('member_already_in_cluster', `workflow ${workflowId} is already a member of cluster ${existing}; cross-cluster membership is rejected`);
|
|
291
314
|
}
|
|
292
315
|
const next = { ...state, members: [...state.members, workflowId] };
|
|
316
|
+
if (next.skillPins?.length)
|
|
317
|
+
await (await import('./clusterSkills.js')).assertClusterSkillLimits(next);
|
|
293
318
|
await writeMetaAtomic(next);
|
|
294
319
|
rebuildIndexFor(next);
|
|
295
320
|
memberJoined?.(clusterId, workflowId);
|
|
@@ -367,7 +392,7 @@ async function reassignPendingMailbox(clusterId, oldWorkflowId, newWorkflowId) {
|
|
|
367
392
|
// validates its config first; the meta write preserves member order and remaps
|
|
368
393
|
// every member-scoped setting without ever collapsing a 2-member cluster.
|
|
369
394
|
// Pending inbound mail follows the slot to the replacement workflow.
|
|
370
|
-
export async function replaceMember(clusterId, oldWorkflowId, newWorkflowId, accessMode) {
|
|
395
|
+
export async function replaceMember(clusterId, oldWorkflowId, newWorkflowId, accessMode, role) {
|
|
371
396
|
return withClusterMetaLock(clusterId, async () => {
|
|
372
397
|
const state = await readCluster(clusterId);
|
|
373
398
|
if (!state || !state.members.includes(oldWorkflowId))
|
|
@@ -398,6 +423,20 @@ export async function replaceMember(clusterId, oldWorkflowId, newWorkflowId, acc
|
|
|
398
423
|
memberFocuses: remapSparse(state.memberFocuses, oldWorkflowId, newWorkflowId),
|
|
399
424
|
memberAccessModes: Object.keys(nextModes).length > 0 ? nextModes : undefined,
|
|
400
425
|
};
|
|
426
|
+
if (role !== undefined) {
|
|
427
|
+
const roles = { ...next.memberRoles };
|
|
428
|
+
const savedRole = normalizeClusterRoleText(role).slice(0, MEMBER_ROLE_MAX);
|
|
429
|
+
if (savedRole)
|
|
430
|
+
roles[newWorkflowId] = savedRole;
|
|
431
|
+
else
|
|
432
|
+
delete roles[newWorkflowId];
|
|
433
|
+
const problem = clusterDirectorProblem(next.members.map(id => roles[id]));
|
|
434
|
+
if (problem)
|
|
435
|
+
throw new ClusterValidationError('multiple_directors', problem);
|
|
436
|
+
next.memberRoles = Object.keys(roles).length ? roles : undefined;
|
|
437
|
+
}
|
|
438
|
+
if (next.skillPins?.length)
|
|
439
|
+
await (await import('./clusterSkills.js')).assertClusterSkillLimits(next);
|
|
401
440
|
if (nextMode === 'isolated') {
|
|
402
441
|
await fs.mkdir(isolatedWorkspaceFor(clusterId, newWorkflowId), { recursive: true, mode: 0o700 });
|
|
403
442
|
}
|
|
@@ -517,6 +556,8 @@ export async function setMemberRole(clusterId, workflowId, role, options = {}) {
|
|
|
517
556
|
const next = Object.keys(nextRoles).length === 0
|
|
518
557
|
? { ...state, memberRoles: undefined }
|
|
519
558
|
: { ...state, memberRoles: nextRoles };
|
|
559
|
+
if (!options.restoringSnapshot && next.skillPins?.length)
|
|
560
|
+
await (await import('./clusterSkills.js')).assertClusterSkillLimits(next);
|
|
520
561
|
await writeMetaAtomic(next);
|
|
521
562
|
rebuildIndexFor(next);
|
|
522
563
|
return next;
|
|
@@ -798,11 +839,27 @@ export async function setAutoTurnOnMailbox(clusterId, enabled) {
|
|
|
798
839
|
// its own id and expiry; any other mode clears the session, which makes any
|
|
799
840
|
// outstanding Smart work stale. The evaluator, last explicit choice and
|
|
800
841
|
// limits persist across disarm so re-arming can offer them again.
|
|
842
|
+
// Pause-only updates preserve session identity and remaining running time;
|
|
843
|
+
// resume moves its expiry forward by the saved pause duration.
|
|
801
844
|
export async function setAutoPickup(clusterId, opts) {
|
|
802
845
|
return withClusterMetaLock(clusterId, async () => {
|
|
803
846
|
const state = await readCluster(clusterId);
|
|
804
847
|
if (!state)
|
|
805
848
|
return null;
|
|
849
|
+
if (typeof opts.paused === 'boolean') {
|
|
850
|
+
if (opts.mode === 'off' || opts.mode !== autoPickupModeOf(state))
|
|
851
|
+
return null;
|
|
852
|
+
const now = opts.now ?? Date.now();
|
|
853
|
+
const pausedAt = state.autoPickupPausedAt;
|
|
854
|
+
const session = state.smartPickup?.session;
|
|
855
|
+
const smartPickup = !opts.paused && pausedAt !== undefined && session && isSmartPickupMode(opts.mode)
|
|
856
|
+
? { ...state.smartPickup, session: { ...session, expiresAt: session.expiresAt + Math.max(0, now - pausedAt) } }
|
|
857
|
+
: state.smartPickup;
|
|
858
|
+
const next = { ...state, autoPickupPausedAt: opts.paused ? pausedAt ?? now : undefined, smartPickup };
|
|
859
|
+
await writeMetaAtomic(next);
|
|
860
|
+
rebuildIndexFor(next);
|
|
861
|
+
return next;
|
|
862
|
+
}
|
|
806
863
|
const now = opts.now ?? Date.now();
|
|
807
864
|
const prior = state.smartPickup ?? {};
|
|
808
865
|
const limits = opts.limits ? sanitizeSmartPickupLimits({ ...sanitizeSmartPickupLimits(prior.limits), ...opts.limits }) : prior.limits;
|
|
@@ -830,6 +887,9 @@ export async function setAutoPickup(clusterId, opts) {
|
|
|
830
887
|
rulePickupLimits: opts.ruleLimits ? sanitizeRulePickupLimits({ ...sanitizeRulePickupLimits(state.rulePickupLimits), ...opts.ruleLimits }) : state.rulePickupLimits,
|
|
831
888
|
remindBusy: typeof opts.remindBusy === 'boolean' ? opts.remindBusy : state.remindBusy,
|
|
832
889
|
autoPickupMode: opts.mode === 'off' ? undefined : opts.mode,
|
|
890
|
+
autoPickupPausedAt: opts.mode !== 'off' && opts.mode === autoPickupModeOf(state) && state.autoPickupPausedAt !== undefined
|
|
891
|
+
? isSmartPickupMode(opts.mode) ? now : state.autoPickupPausedAt
|
|
892
|
+
: undefined,
|
|
833
893
|
autoTurnOnMailboxEnabled: opts.mode === 'rule' ? true : undefined,
|
|
834
894
|
smartPickup: hasSmart ? smartPickup : undefined,
|
|
835
895
|
};
|
|
@@ -842,6 +902,9 @@ export function getAutoPickupMode(clusterId) {
|
|
|
842
902
|
const state = cache.get(clusterId);
|
|
843
903
|
return resolveAutoPickupMode(state?.autoPickupMode, state?.autoTurnOnMailboxEnabled);
|
|
844
904
|
}
|
|
905
|
+
export function isAutoPickupPaused(clusterId) {
|
|
906
|
+
return cache.get(clusterId)?.autoPickupPausedAt !== undefined;
|
|
907
|
+
}
|
|
845
908
|
export function autoPickupModeOf(state) {
|
|
846
909
|
return resolveAutoPickupMode(state.autoPickupMode, state.autoTurnOnMailboxEnabled);
|
|
847
910
|
}
|
|
@@ -43,6 +43,13 @@ export declare function readLogLines(dir: string, opts?: {
|
|
|
43
43
|
fromSeq?: number;
|
|
44
44
|
}): AsyncGenerator<string>;
|
|
45
45
|
export declare function readLogText(dir: string): Promise<string>;
|
|
46
|
+
export interface LogByteSource {
|
|
47
|
+
size: number;
|
|
48
|
+
chunks(start: number, length: number): AsyncGenerator<Buffer>;
|
|
49
|
+
read(start: number, length: number): Promise<string>;
|
|
50
|
+
close(): Promise<void>;
|
|
51
|
+
}
|
|
52
|
+
export declare function openLogByteSource(dir: string): Promise<LogByteSource | null>;
|
|
46
53
|
export declare function readLogTextSync(dir: string): string;
|
|
47
54
|
export declare function readLogTail(dir: string, maxBytes: number): Promise<{
|
|
48
55
|
text: string;
|
package/server/dist/eventLog.js
CHANGED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
// live records only up to the newest sequence number they actually read from
|
|
20
20
|
// a segment, or that a checked segment holds.
|
|
21
21
|
import { promises as fs, createReadStream, closeSync, fstatSync, openSync, readFileSync, readSync, readdirSync, statSync, constants as fsConstants } from 'node:fs';
|
|
22
|
-
import {
|
|
22
|
+
import { jsonlLines } from './jsonlLines.js';
|
|
23
23
|
import { brotliCompress, brotliDecompress, brotliDecompressSync, createBrotliDecompress, constants as zc } from 'node:zlib';
|
|
24
24
|
import { promisify } from 'node:util';
|
|
25
25
|
import { randomUUID } from 'node:crypto';
|
|
@@ -287,7 +287,7 @@ async function firstLiveSeq(file) {
|
|
|
287
287
|
if (!fh)
|
|
288
288
|
return null;
|
|
289
289
|
try {
|
|
290
|
-
for await (const line of handleLines(fh)) {
|
|
290
|
+
for await (const line of handleLines(fh, file)) {
|
|
291
291
|
const seq = lineSeq(line);
|
|
292
292
|
if (seq !== null)
|
|
293
293
|
return seq;
|
|
@@ -310,14 +310,13 @@ function reportUnreadable(err) {
|
|
|
310
310
|
console.error(`[arco] ${err instanceof Error ? err.message : String(err)}; skipping it, the rest of the history stays readable`);
|
|
311
311
|
}
|
|
312
312
|
async function* segmentLines(seg) {
|
|
313
|
-
const input = createReadStream(seg.file);
|
|
313
|
+
const input = createReadStream(seg.file, { highWaterMark: 64 * 1024 });
|
|
314
314
|
const decompressed = createBrotliDecompress();
|
|
315
315
|
// An error opening or reading the file (a segment removed or replaced since
|
|
316
316
|
// it was listed) reaches the reader below instead of going unhandled.
|
|
317
317
|
input.on('error', (err) => decompressed.destroy(err));
|
|
318
|
-
const rl = createInterface({ input: input.pipe(decompressed), crlfDelay: Infinity });
|
|
319
318
|
try {
|
|
320
|
-
for await (const line of
|
|
319
|
+
for await (const line of jsonlLines(input.pipe(decompressed), seg.file))
|
|
321
320
|
if (line)
|
|
322
321
|
yield line;
|
|
323
322
|
}
|
|
@@ -325,8 +324,8 @@ async function* segmentLines(seg) {
|
|
|
325
324
|
throw new SegmentReadError(seg.file, err);
|
|
326
325
|
}
|
|
327
326
|
finally {
|
|
328
|
-
rl.close();
|
|
329
327
|
input.destroy();
|
|
328
|
+
decompressed.destroy();
|
|
330
329
|
}
|
|
331
330
|
}
|
|
332
331
|
async function openLive(file) {
|
|
@@ -339,16 +338,14 @@ async function openLive(file) {
|
|
|
339
338
|
throw err;
|
|
340
339
|
}
|
|
341
340
|
}
|
|
342
|
-
async function* handleLines(fh) {
|
|
343
|
-
const input = fh.createReadStream({ autoClose: false });
|
|
344
|
-
const rl = createInterface({ input, crlfDelay: Infinity });
|
|
341
|
+
async function* handleLines(fh, source) {
|
|
342
|
+
const input = fh.createReadStream({ autoClose: false, highWaterMark: 64 * 1024 });
|
|
345
343
|
try {
|
|
346
|
-
for await (const line of
|
|
344
|
+
for await (const line of jsonlLines(input, source))
|
|
347
345
|
if (line)
|
|
348
346
|
yield line;
|
|
349
347
|
}
|
|
350
348
|
finally {
|
|
351
|
-
rl.close();
|
|
352
349
|
input.destroy();
|
|
353
350
|
}
|
|
354
351
|
}
|
|
@@ -357,7 +354,7 @@ async function* liveLines(file) {
|
|
|
357
354
|
if (!fh)
|
|
358
355
|
return;
|
|
359
356
|
try {
|
|
360
|
-
yield* handleLines(fh);
|
|
357
|
+
yield* handleLines(fh, file);
|
|
361
358
|
}
|
|
362
359
|
finally {
|
|
363
360
|
await fh.close();
|
|
@@ -416,7 +413,7 @@ export async function* readLogLines(dir, opts = {}) {
|
|
|
416
413
|
yield* drainSegments();
|
|
417
414
|
if (!fh)
|
|
418
415
|
return;
|
|
419
|
-
for await (const line of handleLines(fh))
|
|
416
|
+
for await (const line of handleLines(fh, path.join(dir, LIVE_LOG)))
|
|
420
417
|
if (!copies.drop(line))
|
|
421
418
|
yield line;
|
|
422
419
|
}
|
|
@@ -432,6 +429,66 @@ export async function readLogText(dir) {
|
|
|
432
429
|
parts.push(line);
|
|
433
430
|
return parts.length ? parts.join('\n') + '\n' : '';
|
|
434
431
|
}
|
|
432
|
+
export async function openLogByteSource(dir) {
|
|
433
|
+
let size = 0;
|
|
434
|
+
let chunks;
|
|
435
|
+
let close = async () => { };
|
|
436
|
+
if ((await listSegments(dir)).length) {
|
|
437
|
+
for await (const line of readLogLines(dir))
|
|
438
|
+
size += Buffer.byteLength(line, 'utf8') + 1;
|
|
439
|
+
chunks = async function* (start, length) {
|
|
440
|
+
const end = Math.min(size, start + length);
|
|
441
|
+
let position = 0;
|
|
442
|
+
for await (const line of readLogLines(dir)) {
|
|
443
|
+
const next = position + Buffer.byteLength(line, 'utf8') + 1;
|
|
444
|
+
if (next > start && position < end) {
|
|
445
|
+
const buffer = Buffer.from(line + '\n', 'utf8');
|
|
446
|
+
const from = Math.max(0, start - position), through = Math.min(buffer.length, end - position);
|
|
447
|
+
for (let offset = from; offset < through; offset += 64 * 1024) {
|
|
448
|
+
yield buffer.subarray(offset, Math.min(through, offset + 64 * 1024));
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
position = next;
|
|
452
|
+
if (position >= end)
|
|
453
|
+
break;
|
|
454
|
+
}
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
else {
|
|
458
|
+
const file = path.join(dir, LIVE_LOG);
|
|
459
|
+
const fh = await openLive(file);
|
|
460
|
+
if (!fh)
|
|
461
|
+
return null;
|
|
462
|
+
try {
|
|
463
|
+
const stat = await fh.stat();
|
|
464
|
+
if (!stat.isFile())
|
|
465
|
+
throw new Error(`Expected a history file at ${file}`);
|
|
466
|
+
size = stat.size;
|
|
467
|
+
}
|
|
468
|
+
catch (err) {
|
|
469
|
+
await fh.close();
|
|
470
|
+
throw err;
|
|
471
|
+
}
|
|
472
|
+
close = () => fh.close();
|
|
473
|
+
chunks = async function* (start, length) {
|
|
474
|
+
const end = Math.min(size, start + length);
|
|
475
|
+
for (let position = start; position < end;) {
|
|
476
|
+
const buffer = Buffer.alloc(Math.min(64 * 1024, end - position));
|
|
477
|
+
const { bytesRead } = await fh.read(buffer, 0, buffer.length, position);
|
|
478
|
+
if (!bytesRead)
|
|
479
|
+
break;
|
|
480
|
+
position += bytesRead;
|
|
481
|
+
yield buffer.subarray(0, bytesRead);
|
|
482
|
+
}
|
|
483
|
+
};
|
|
484
|
+
}
|
|
485
|
+
return { size, chunks, close, read: async (start, length) => {
|
|
486
|
+
const parts = [];
|
|
487
|
+
for await (const chunk of chunks(start, length))
|
|
488
|
+
parts.push(chunk);
|
|
489
|
+
return Buffer.concat(parts).toString('utf8');
|
|
490
|
+
} };
|
|
491
|
+
}
|
|
435
492
|
function decompressSegmentSync(seg) {
|
|
436
493
|
try {
|
|
437
494
|
return brotliDecompressSync(readFileSync(seg.file)).toString('utf8');
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const RECENT_HISTORY_MAX_BYTES: number;
|