arco-workbench 0.1.7 → 0.1.9
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 +63 -12
- package/README.md +21 -17
- package/client/dist/assets/{PhosphorBackdrop-DVQdBrTw.js → PhosphorBackdrop-DRu16-Is.js} +1 -1
- package/client/dist/assets/{ThemedBackgroundShaderImpl-BfSs2tB4.js → ThemedBackgroundShaderImpl-BLdwwQ4D.js} +1 -1
- package/client/dist/assets/{XtermView-DaMjC8Ny.js → XtermView-Xk7_9JaH.js} +1 -1
- package/client/dist/assets/{galleryEditor-BCQnXj7R.js → galleryEditor-CI8ClzBa.js} +1 -1
- package/client/dist/assets/{index-DD9kFGsF.css → index-BEFgrUJJ.css} +1 -1
- package/client/dist/assets/{index-COfbHCYv.js → index-C7WzZfsr.js} +257 -255
- package/client/dist/index.html +2 -2
- package/client/src/App.tsx +2 -0
- package/client/src/components/ChatMessage.tsx +33 -8
- package/client/src/components/ChatModeView.tsx +2 -0
- package/client/src/components/ClusterRightPanel/ReplaceMemberDialog.tsx +65 -15
- package/client/src/components/ClusterRightPanel/SkillsControl.tsx +124 -0
- package/client/src/components/ClusterRightPanel/index.tsx +4 -0
- package/client/src/components/ClusterTaskBoardTab.tsx +9 -22
- package/client/src/components/CodexLateCommand.tsx +34 -0
- package/client/src/components/DialogShell.tsx +2 -0
- package/client/src/components/MemberCard.tsx +4 -1
- package/client/src/components/MemberPane.tsx +3 -1
- package/client/src/components/NeedsYouBadge.tsx +3 -3
- package/client/src/components/PhoneUpload.tsx +288 -0
- package/client/src/components/PrimaryStatus.tsx +14 -6
- package/client/src/components/ProviderReleasesModal.tsx +8 -4
- package/client/src/components/ProvidersPopover.tsx +28 -23
- package/client/src/components/RuntimeStateBanner.tsx +5 -0
- package/client/src/components/SettingsPanel.tsx +2 -2
- package/client/src/components/SkillEditorDialog.tsx +2 -2
- package/client/src/components/SkillsSettings.tsx +21 -4
- package/client/src/components/TabBar.tsx +91 -9
- package/client/src/components/TerminalInput.tsx +15 -11
- package/client/src/components/TranscriptSendDialog.tsx +12 -8
- package/client/src/components/TranscriptWorkerDialog.tsx +119 -0
- package/client/src/components/WorkflowView.tsx +2 -0
- package/client/src/components/clusterNeedsYou.ts +11 -18
- package/client/src/explorer/ArtifactsLens.tsx +37 -28
- package/client/src/explorer/ExplorerApp.tsx +5 -4
- package/client/src/explorer/types.ts +8 -3
- package/client/src/help/content/cluster.tsx +48 -17
- package/client/src/help/content/composer.tsx +40 -1
- package/client/src/help/content/header.tsx +18 -1
- package/client/src/help/content/misc.tsx +9 -1
- package/client/src/help/content/settings.tsx +18 -4
- 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 +44 -20
- package/client/src/help/manualSections/configuration.tsx +20 -0
- package/client/src/help/manualSections/gettingStarted.tsx +4 -4
- package/client/src/help/manualSections/maintenance.tsx +25 -6
- package/client/src/help/manualSections/powerFeatures.tsx +3 -2
- 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 +12 -0
- package/client/src/help/manualSections/workspace.tsx +36 -0
- package/client/src/stores/appStore.ts +7 -0
- package/client/src/stores/appStore.types.ts +4 -0
- package/client/src/styles/global.css +109 -0
- package/client/src/utils/phoneTheme.ts +38 -0
- package/client/src/utils/phoneUploadApi.ts +10 -0
- package/client/src/utils/transcriptWorkerRequest.ts +24 -0
- package/client/src/ws/handleServerMessage.ts +31 -8
- package/docs/ARCHITECTURE.md +1 -1
- package/docs/CLIENT.md +16 -9
- package/docs/FEATURES.md +13 -7
- package/docs/GETTING_STARTED.md +12 -6
- package/docs/GOTCHAS.md +2 -1
- package/docs/INDEX.md +1 -1
- package/docs/OPERATIONS.md +213 -52
- package/docs/PERSISTENCE.md +7 -2
- package/docs/PRIMITIVES.md +42 -0
- package/docs/PROTOCOL_CLUSTER.md +51 -4
- package/docs/PROTOCOL_PRIMITIVES.md +39 -0
- package/docs/PROVIDERS.md +84 -13
- package/docs/SETTINGS.md +29 -3
- package/docs/TASK_LEDGER.md +7 -15
- package/native/linux-x64/manifest.json +1 -1
- package/native/win32-x64/manifest.json +1 -1
- 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/chat.d.ts +1 -0
- package/node_modules/@arco/shared/dist/protocol/clientMessages.d.ts +3 -2
- package/node_modules/@arco/shared/dist/protocol/clusters.d.ts +15 -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 +13 -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/protocol/workflows.d.ts +1 -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 +32 -4
- 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/clusterDirector.js +2 -1
- package/server/dist/clusterPeerOps.js +14 -8
- package/server/dist/clusterProgress.js +1 -1
- package/server/dist/clusterRehydrate.js +2 -0
- 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 +7 -2
- package/server/dist/clusterStore.js +42 -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/explorerDocs.d.ts +10 -6
- package/server/dist/explorerDocs.js +75 -34
- package/server/dist/historyLimits.d.ts +1 -0
- package/server/dist/historyLimits.js +3 -0
- package/server/dist/http/attachmentUpload.d.ts +13 -0
- package/server/dist/http/attachmentUpload.js +38 -0
- package/server/dist/http/browserWorktrees.d.ts +23 -0
- package/server/dist/http/browserWorktrees.js +120 -0
- package/server/dist/http/phoneUploadDrafts.d.ts +13 -0
- package/server/dist/http/phoneUploadDrafts.js +125 -0
- package/server/dist/http/phoneUploadListener.d.ts +17 -0
- package/server/dist/http/phoneUploadListener.js +81 -0
- package/server/dist/http/phoneUploadNetwork.d.ts +9 -0
- package/server/dist/http/phoneUploadNetwork.js +106 -0
- package/server/dist/http/phoneUploadPage.d.ts +2 -0
- package/server/dist/http/phoneUploadPage.js +136 -0
- package/server/dist/http/phoneUploadRouteHistory.d.ts +4 -0
- package/server/dist/http/phoneUploadRouteHistory.js +72 -0
- package/server/dist/http/phoneUploadRoutes.d.ts +4 -0
- package/server/dist/http/phoneUploadRoutes.js +419 -0
- package/server/dist/http/phoneUploadTheme.d.ts +17 -0
- package/server/dist/http/phoneUploadTheme.js +96 -0
- package/server/dist/http/projectBinding.d.ts +1 -0
- package/server/dist/http/projectBinding.js +3 -2
- package/server/dist/http/readConfinement.js +5 -1
- package/server/dist/http/router.js +14 -25
- package/server/dist/http/writeConfinement.js +19 -2
- 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/primitives/seedWorker.d.ts +1 -0
- package/server/dist/primitives/seedWorker.js +2 -1
- 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-appserver/heldCommands.d.ts +14 -0
- package/server/dist/providers/codex-appserver/heldCommands.js +54 -0
- package/server/dist/providers/codex-appserver/index.d.ts +52 -2
- package/server/dist/providers/codex-appserver/index.js +239 -21
- package/server/dist/providers/codex-appserver/lateCommands.d.ts +62 -0
- package/server/dist/providers/codex-appserver/lateCommands.js +195 -0
- package/server/dist/providers/codex-appserver/worker.d.ts +23 -1
- package/server/dist/providers/codex-appserver/worker.js +89 -20
- package/server/dist/providers/codex.js +2 -1
- package/server/dist/providers/codexCodeMode.d.ts +2 -1
- package/server/dist/providers/codexCodeMode.js +8 -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/smartPickupAdapters.js +15 -2
- package/server/dist/transcriptWorker.d.ts +34 -0
- package/server/dist/transcriptWorker.js +201 -0
- package/server/dist/workers/WorkerManager.d.ts +1 -0
- package/server/dist/workers/WorkerManager.js +1 -0
- package/server/dist/workers/processKill.d.ts +9 -1
- package/server/dist/workers/processKill.js +26 -10
- package/server/dist/workflowStore.d.ts +1 -0
- package/server/dist/workflowStore.js +31 -0
- package/server/dist/ws/clusterHandlers.d.ts +1 -0
- package/server/dist/ws/clusterHandlers.js +62 -26
- package/server/dist/ws/handoffHandlers.js +7 -2
- package/server/dist/ws/transcriptWorkerHandlers.d.ts +25 -0
- package/server/dist/ws/transcriptWorkerHandlers.js +139 -0
- package/server/dist/ws/turnEngine.js +40 -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/clusterDirector.ts +2 -1
- package/server/src/clusterPeerOps.ts +15 -9
- package/server/src/clusterProgress.ts +1 -1
- package/server/src/clusterRehydrate.ts +2 -0
- package/server/src/clusterSkills.ts +79 -0
- package/server/src/clusterSnapshots.ts +1 -0
- package/server/src/clusterStore.ts +38 -0
- package/server/src/diagnostics/codeSkew.ts +1 -0
- package/server/src/eventLog.ts +73 -13
- package/server/src/explorerDocs.ts +75 -34
- package/server/src/historyLimits.ts +2 -0
- package/server/src/http/attachmentUpload.ts +49 -0
- package/server/src/http/browserWorktrees.ts +124 -0
- package/server/src/http/phoneUploadDrafts.ts +118 -0
- package/server/src/http/phoneUploadListener.ts +96 -0
- package/server/src/http/phoneUploadNetwork.ts +117 -0
- package/server/src/http/phoneUploadPage.ts +137 -0
- package/server/src/http/phoneUploadRouteHistory.ts +73 -0
- package/server/src/http/phoneUploadRoutes.ts +398 -0
- package/server/src/http/phoneUploadTheme.ts +97 -0
- package/server/src/http/projectBinding.ts +3 -2
- package/server/src/http/readConfinement.ts +5 -1
- package/server/src/http/router.ts +12 -26
- package/server/src/http/writeConfinement.ts +13 -2
- 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/primitives/seedWorker.ts +3 -1
- 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-appserver/heldCommands.ts +58 -0
- package/server/src/providers/codex-appserver/index.ts +222 -20
- package/server/src/providers/codex-appserver/lateCommands.ts +225 -0
- package/server/src/providers/codex-appserver/worker.ts +85 -21
- package/server/src/providers/codex.ts +2 -1
- package/server/src/providers/codexCodeMode.ts +9 -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/smartPickupAdapters.ts +17 -3
- package/server/src/transcriptWorker.ts +182 -0
- package/server/src/workers/WorkerManager.ts +2 -0
- package/server/src/workers/processKill.ts +35 -7
- package/server/src/workflowStore.ts +21 -0
- package/server/src/ws/clusterHandlers.ts +43 -25
- package/server/src/ws/handoffHandlers.ts +7 -1
- package/server/src/ws/transcriptWorkerHandlers.ts +126 -0
- package/server/src/ws/turnEngine.ts +35 -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/chat.d.ts +1 -0
- package/shared/dist/protocol/clientMessages.d.ts +3 -2
- package/shared/dist/protocol/clusters.d.ts +15 -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 +13 -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/protocol/workflows.d.ts +1 -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/chat.ts +1 -0
- package/shared/src/protocol/clientMessages.ts +5 -0
- package/shared/src/protocol/clusters.ts +20 -6
- package/shared/src/protocol/index.ts +1 -0
- package/shared/src/protocol/models.ts +31 -5
- package/shared/src/protocol/serverMessages.ts +13 -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/protocol/workflows.ts +4 -0
- package/shared/src/runtimeVersions.ts +14 -0
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.'),
|
|
@@ -225,6 +225,7 @@ export function runPrimaryTurn(
|
|
|
225
225
|
// ignore it; the post-turn drain still picks up anything not consumed.
|
|
226
226
|
drainSteer?: () => SteerItem[];
|
|
227
227
|
peekSteer?: () => readonly SteerItem[];
|
|
228
|
+
pendingInput?: WorkerConfig['pendingInput'];
|
|
228
229
|
// Phase 6b — paired with drainSteer for the Codex app-server worker.
|
|
229
230
|
// Symmetrical contract — same scoping (primary-turn only), same
|
|
230
231
|
// in-process callback shape. Called when a `turn/steer` round-trip
|
|
@@ -359,7 +360,7 @@ export function runPrimaryTurn(
|
|
|
359
360
|
webSearchMaxUses?: number;
|
|
360
361
|
},
|
|
361
362
|
): TurnHandle {
|
|
362
|
-
const { primary, prompt, resumeSessionId, attachments, disableRssGuard, appendSystemPrompt, systemPrompt, interactionMode, disableProviderHooks, chatWebAccess, voiceOperator, incognito, drainSteer, peekSteer, requeueSteer, onSteerDelivered, codexTransport, codexContextPolicy, providerAccountRef, codexHome, claudeTransport, ultracode, claudeNativeTaskDisabled, claudeNativeSubagent, claudeNativeCompact, claudeNativeInTurnCompactPercent, claudeNativeForceInterleavedThinkingBeta, claudeNativeThinkingDisplay, nativeSubagents, claudeNativePlanModeArmed, turnNotice, efficiencyToolFilter, efficiencyFactForce, efficiencyConfigProtection, efficiencySandbox, reviewSafeMode, outputStyle, goal, toolPosture, clusterId, clusterAccessMode, executionCwd, persistenceCwd, clusterTaskBoardAttached, clusterPlan, clusterRole, clusterEfficiencyDoctrine, clusterProgressDoctrine, clusterMcpConfigPath, codebaseMemoryAttached, codebaseMemoryIndexPath, mcpRegistryServers, mcpDisallowedTools, ollamaParams, webSearchMaxUses } = args;
|
|
363
|
+
const { primary, prompt, resumeSessionId, attachments, disableRssGuard, appendSystemPrompt, systemPrompt, interactionMode, disableProviderHooks, chatWebAccess, voiceOperator, incognito, drainSteer, peekSteer, pendingInput, requeueSteer, onSteerDelivered, codexTransport, codexContextPolicy, providerAccountRef, codexHome, claudeTransport, ultracode, claudeNativeTaskDisabled, claudeNativeSubagent, claudeNativeCompact, claudeNativeInTurnCompactPercent, claudeNativeForceInterleavedThinkingBeta, claudeNativeThinkingDisplay, nativeSubagents, claudeNativePlanModeArmed, turnNotice, efficiencyToolFilter, efficiencyFactForce, efficiencyConfigProtection, efficiencySandbox, reviewSafeMode, outputStyle, goal, toolPosture, clusterId, clusterAccessMode, executionCwd, persistenceCwd, clusterTaskBoardAttached, clusterPlan, clusterRole, clusterEfficiencyDoctrine, clusterProgressDoctrine, clusterMcpConfigPath, codebaseMemoryAttached, codebaseMemoryIndexPath, mcpRegistryServers, mcpDisallowedTools, ollamaParams, webSearchMaxUses } = args;
|
|
363
364
|
|
|
364
365
|
const workerId = `primary-${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 6)}`;
|
|
365
366
|
|
|
@@ -403,6 +404,7 @@ export function runPrimaryTurn(
|
|
|
403
404
|
disableRssGuard,
|
|
404
405
|
drainSteer,
|
|
405
406
|
peekSteer,
|
|
407
|
+
pendingInput,
|
|
406
408
|
requeueSteer,
|
|
407
409
|
onSteerDelivered,
|
|
408
410
|
codexTransport,
|
|
@@ -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; });
|
|
@@ -6,9 +6,11 @@ import { promises as fs } from 'node:fs';
|
|
|
6
6
|
import { join } from 'node:path';
|
|
7
7
|
import { randomUUID } from 'node:crypto';
|
|
8
8
|
import { atomicWriteFile } from '../../atomicFile.js';
|
|
9
|
-
import {
|
|
9
|
+
import { openLogByteSource, readLogLines, type LogByteSource } from '../../eventLog.js';
|
|
10
|
+
import { jsonlLines } from '../../jsonlLines.js';
|
|
10
11
|
import { serverFoldSeed, type ServerCompactionBlock } from './serverFold.js';
|
|
11
12
|
import { isShellToolName } from '@arco/shared';
|
|
13
|
+
import { RECENT_HISTORY_MAX_BYTES } from '../../historyLimits.js';
|
|
12
14
|
|
|
13
15
|
const isFileRead = (name: string | undefined): boolean => !!name && /^(?:Read|(?:.*__)?(?:read_file|fetch_file))$/i.test(name);
|
|
14
16
|
|
|
@@ -17,6 +19,19 @@ const SUMMARY_CACHE_KIND = 'claude-native-resume-summary';
|
|
|
17
19
|
const DEFAULT_REPLAY_BYTES = 1 * 1024 * 1024;
|
|
18
20
|
const TAIL_LINE_BACKTRACK_BYTES = 1 * 1024 * 1024;
|
|
19
21
|
|
|
22
|
+
// The retained event arrays still amplify source bytes during reconstruction.
|
|
23
|
+
// Refuse an uncached parse beyond the measured default-heap margin; a valid
|
|
24
|
+
// summary cache needs only its small tail and does not parse the old prefix.
|
|
25
|
+
export const NATIVE_RECONSTRUCTION_MAX_BYTES = 1024 * 1024 * 1024;
|
|
26
|
+
export class NativeReconstructionLimitError extends Error {
|
|
27
|
+
readonly code = 'NATIVE_RECONSTRUCTION_LIMIT';
|
|
28
|
+
readonly limitBytes = NATIVE_RECONSTRUCTION_MAX_BYTES;
|
|
29
|
+
constructor(readonly rangeBytes: number) {
|
|
30
|
+
super(`Claude Native reconstruction requires ${rangeBytes} bytes, above the ${NATIVE_RECONSTRUCTION_MAX_BYTES}-byte limit.`);
|
|
31
|
+
this.name = 'NativeReconstructionLimitError';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
20
35
|
function readPositiveIntEnv(name: string, fallback: number): number {
|
|
21
36
|
const raw = process.env[name];
|
|
22
37
|
if (!raw) return fallback;
|
|
@@ -118,6 +133,7 @@ export type ResumeReplayResult = {
|
|
|
118
133
|
summaryThroughSeq?: number;
|
|
119
134
|
summaryBytes?: number;
|
|
120
135
|
tailEvents?: number;
|
|
136
|
+
summaryNotice?: string;
|
|
121
137
|
// docs/PERSISTENCE.md - true when a branch-aware (leafSeq)
|
|
122
138
|
// replay walked into ancestry that had rotated off the size-capped log, so
|
|
123
139
|
// the branch was reconstructed from what survived rather than replayed in
|
|
@@ -134,12 +150,14 @@ type SummaryCache = {
|
|
|
134
150
|
throughSeq: number | null;
|
|
135
151
|
lastHandoffSeq: number | null;
|
|
136
152
|
summary: string;
|
|
153
|
+
summaryNotice?: string;
|
|
137
154
|
inputHistory: ReplayEvent[];
|
|
138
155
|
updatedAt: string;
|
|
139
156
|
};
|
|
140
157
|
|
|
141
158
|
type SummaryBuild = {
|
|
142
159
|
summary: string;
|
|
160
|
+
summaryNotice?: string;
|
|
143
161
|
throughSeq: number | null;
|
|
144
162
|
lastHandoffSeq: number | null;
|
|
145
163
|
};
|
|
@@ -148,43 +166,28 @@ function workflowDir(cwd: string, workflowId: string): string {
|
|
|
148
166
|
return join(cwd, '.arco', 'workflows', workflowId);
|
|
149
167
|
}
|
|
150
168
|
|
|
151
|
-
function eventsPath(cwd: string, workflowId: string): string {
|
|
152
|
-
return join(workflowDir(cwd, workflowId), 'events.jsonl');
|
|
153
|
-
}
|
|
154
|
-
|
|
155
169
|
function summaryCachePath(cwd: string, workflowId: string): string {
|
|
156
170
|
return join(workflowDir(cwd, workflowId), 'resume-summary.json');
|
|
157
171
|
}
|
|
158
172
|
|
|
159
|
-
//
|
|
160
|
-
//
|
|
161
|
-
|
|
162
|
-
interface LogSource { size: number; read(start: number, length: number): Promise<string> }
|
|
173
|
+
// Only the byte source changes here. Replay projection, summary boundaries,
|
|
174
|
+
// branch ancestry and cache keys continue to use their existing rules.
|
|
175
|
+
type LogSource = LogByteSource;
|
|
163
176
|
async function openLogSource(cwd: string, workflowId: string): Promise<LogSource | null> {
|
|
164
|
-
|
|
165
|
-
if ((await listSegments(dir)).length > 0) {
|
|
166
|
-
const text = Buffer.from(await readLogText(dir), 'utf8');
|
|
167
|
-
return { size: text.length, read: async (start, length) => text.subarray(start, start + length).toString('utf8') };
|
|
168
|
-
}
|
|
169
|
-
const path = eventsPath(cwd, workflowId);
|
|
170
|
-
try {
|
|
171
|
-
const size = (await fs.stat(path)).size;
|
|
172
|
-
return { size, read: (start, length) => readByteRange(path, start, length) };
|
|
173
|
-
} catch (err) {
|
|
174
|
-
if ((err as NodeJS.ErrnoException).code === 'ENOENT') return null;
|
|
175
|
-
throw err;
|
|
176
|
-
}
|
|
177
|
+
return openLogByteSource(workflowDir(cwd, workflowId));
|
|
177
178
|
}
|
|
178
179
|
|
|
179
|
-
async function
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
180
|
+
async function readSourceEvents(source: LogSource, length: number, dropLastPartial = false): Promise<ReplayEvent[]> {
|
|
181
|
+
if (length > NATIVE_RECONSTRUCTION_MAX_BYTES) throw new NativeReconstructionLimitError(length);
|
|
182
|
+
const events: ReplayEvent[] = [];
|
|
183
|
+
for await (const line of jsonlLines(source.chunks(0, length), 'conversation replay', {
|
|
184
|
+
finalLine: !dropLastPartial, carriageReturns: false,
|
|
185
|
+
})) {
|
|
186
|
+
if (!line) continue;
|
|
187
|
+
try { events.push(JSON.parse(line) as ReplayEvent); }
|
|
188
|
+
catch { /* Match parseJsonl: corrupt or partial records remain untouched. */ }
|
|
187
189
|
}
|
|
190
|
+
return events;
|
|
188
191
|
}
|
|
189
192
|
|
|
190
193
|
async function findTailReplayStart(source: LogSource, desiredStart: number): Promise<{ start: number; completeLine: boolean }> {
|
|
@@ -560,20 +563,25 @@ export function summarizeClaudeNativePriorTurns(events: ReplayEvent[], laterEven
|
|
|
560
563
|
|
|
561
564
|
if (turns.length === 0 && !compactSummary) return { summary: '', throughSeq, lastHandoffSeq };
|
|
562
565
|
|
|
563
|
-
const
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
lines.push(compactSummary.trim());
|
|
568
|
-
if (compactTail) {
|
|
566
|
+
const renderPrefix = (summary = compactSummary, tail = compactTail): string => {
|
|
567
|
+
const lines: string[] = [];
|
|
568
|
+
if (compactSummary) {
|
|
569
|
+
lines.push('## Earlier context (operator-compacted)');
|
|
569
570
|
lines.push('');
|
|
570
|
-
lines.push(
|
|
571
|
-
|
|
571
|
+
lines.push(summary?.trim() ?? '');
|
|
572
|
+
if (tail) {
|
|
573
|
+
lines.push('');
|
|
574
|
+
lines.push('### Recent verbatim turns kept at that compaction');
|
|
575
|
+
lines.push(tail);
|
|
576
|
+
}
|
|
577
|
+
if (turns.length > 0) lines.push('');
|
|
572
578
|
}
|
|
573
|
-
if (turns.length > 0) lines.push('');
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
579
|
+
if (turns.length > 0) lines.push('## Prior turns in this workflow (auto-summary)');
|
|
580
|
+
return lines.join('\n');
|
|
581
|
+
};
|
|
582
|
+
let prefix = renderPrefix();
|
|
583
|
+
const notes = turns.map((t, i) => {
|
|
584
|
+
const lines: string[] = [];
|
|
577
585
|
const head = t.userText.length > 120 ? t.userText.slice(0, 120) + '...' : t.userText;
|
|
578
586
|
lines.push('');
|
|
579
587
|
lines.push(`### Turn ${i + 1}: ${head}`);
|
|
@@ -600,8 +608,43 @@ export function summarizeClaudeNativePriorTurns(events: ReplayEvent[], laterEven
|
|
|
600
608
|
const reply = t.finalReply.trim().replace(/\s+/g, ' ').slice(0, 240);
|
|
601
609
|
lines.push(`- Assistant reply: "${reply}${t.finalReply.length > 240 ? '...' : ''}"`);
|
|
602
610
|
}
|
|
611
|
+
return lines.join('\n');
|
|
603
612
|
});
|
|
604
|
-
|
|
613
|
+
const noteBytes = notes.map(note => Buffer.byteLength(note, 'utf8') + 1);
|
|
614
|
+
let retainedBytes = noteBytes.reduce((sum, bytes) => sum + bytes, 0);
|
|
615
|
+
if (Buffer.byteLength(prefix, 'utf8') + retainedBytes <= RECENT_HISTORY_MAX_BYTES) {
|
|
616
|
+
return { summary: [prefix, ...notes].join('\n'), throughSeq, lastHandoffSeq };
|
|
617
|
+
}
|
|
618
|
+
|
|
619
|
+
let omitted = 0;
|
|
620
|
+
let shortened = false;
|
|
621
|
+
const notice = () => `Earlier context: ${omitted} oldest turn note${omitted === 1 ? '' : 's'} ${omitted === 1 ? 'was' : 'were'} left out${shortened ? ' and compacted context was shortened' : ''} to stay within 128 KiB.`;
|
|
622
|
+
const prefixBytes = Buffer.byteLength(prefix, 'utf8');
|
|
623
|
+
while (omitted < notes.length && prefixBytes + 1 + Buffer.byteLength(notice(), 'utf8') + retainedBytes > RECENT_HISTORY_MAX_BYTES) {
|
|
624
|
+
retainedBytes -= noteBytes[omitted++];
|
|
625
|
+
}
|
|
626
|
+
if (prefixBytes + 1 + Buffer.byteLength(notice(), 'utf8') > RECENT_HISTORY_MAX_BYTES) {
|
|
627
|
+
// The compacted context itself can be larger than the budget. Preserve its
|
|
628
|
+
// kept-tail digest first, then as much summary text as fits, without cutting
|
|
629
|
+
// a UTF-8 character. The same notice discloses this exceptional shortening.
|
|
630
|
+
shortened = true;
|
|
631
|
+
const budget = RECENT_HISTORY_MAX_BYTES - Buffer.byteLength(notice(), 'utf8') - 1;
|
|
632
|
+
const clip = (text: string, bytes: number): string => {
|
|
633
|
+
const encoded = Buffer.from(text, 'utf8');
|
|
634
|
+
let end = Math.min(encoded.length, Math.max(0, bytes));
|
|
635
|
+
while (end > 0 && (encoded[end] & 0xc0) === 0x80) end--;
|
|
636
|
+
return encoded.subarray(0, end).toString('utf8');
|
|
637
|
+
};
|
|
638
|
+
const tailPrefix = renderPrefix('', compactTail);
|
|
639
|
+
if (Buffer.byteLength(tailPrefix, 'utf8') <= budget) {
|
|
640
|
+
prefix = renderPrefix(clip(compactSummary?.trim() ?? '', budget - Buffer.byteLength(tailPrefix, 'utf8')), compactTail);
|
|
641
|
+
} else {
|
|
642
|
+
const overhead = Buffer.byteLength(renderPrefix('', 'x'), 'utf8') - 1;
|
|
643
|
+
prefix = renderPrefix('', clip(compactTail ?? '', budget - overhead));
|
|
644
|
+
}
|
|
645
|
+
}
|
|
646
|
+
const summaryNotice = notice();
|
|
647
|
+
return { summary: [prefix, summaryNotice, ...notes.slice(omitted)].join('\n'), summaryNotice, throughSeq, lastHandoffSeq };
|
|
605
648
|
}
|
|
606
649
|
|
|
607
650
|
async function readSummaryCache(path: string, workflowId: string, sourceSize: number, tailStartByte: number): Promise<SummaryCache | null> {
|
|
@@ -614,7 +657,8 @@ async function readSummaryCache(path: string, workflowId: string, sourceSize: nu
|
|
|
614
657
|
parsed.workflowId === workflowId &&
|
|
615
658
|
parsed.sourceSize === sourceSize &&
|
|
616
659
|
parsed.tailStartByte === tailStartByte &&
|
|
617
|
-
typeof parsed.summary === 'string' && Array.isArray(parsed.inputHistory)
|
|
660
|
+
typeof parsed.summary === 'string' && Buffer.byteLength(parsed.summary, 'utf8') <= RECENT_HISTORY_MAX_BYTES && Array.isArray(parsed.inputHistory)
|
|
661
|
+
&& (parsed.summaryNotice === undefined || typeof parsed.summaryNotice === 'string')
|
|
618
662
|
&& parsed.inputHistory.every(event => (event?.type === 'user_message_echo' && typeof event.content === 'string') || (event?.type === 'queued_messages_drained' && typeof event.deliveryId === 'string'))
|
|
619
663
|
) {
|
|
620
664
|
return parsed as SummaryCache;
|
|
@@ -645,6 +689,11 @@ export async function replayMessagesWithResumePolicy(
|
|
|
645
689
|
): Promise<ResumeReplayResult> {
|
|
646
690
|
const source = await openLogSource(cwd, workflowId);
|
|
647
691
|
if (!source) return { messages: [], mode: 'empty', eventBytes: 0 };
|
|
692
|
+
try { return await replayFromSource(cwd, workflowId, source, maxSeq, opts); }
|
|
693
|
+
finally { await source.close(); }
|
|
694
|
+
}
|
|
695
|
+
|
|
696
|
+
async function replayFromSource(cwd: string, workflowId: string, source: LogSource, maxSeq: number | undefined, opts: ReplayOptions): Promise<ResumeReplayResult> {
|
|
648
697
|
const stat = { size: source.size };
|
|
649
698
|
|
|
650
699
|
const exactReplayBytes = opts.exactReplayBytes ?? RESUME_EXACT_REPLAY_BYTES;
|
|
@@ -664,8 +713,7 @@ export async function replayMessagesWithResumePolicy(
|
|
|
664
713
|
// This is what lets post-rewind turns be included WITHOUT advancing leafSeq
|
|
665
714
|
// on every turn.
|
|
666
715
|
if (typeof opts.leafSeq === 'number') {
|
|
667
|
-
const
|
|
668
|
-
const events = parseJsonl(raw);
|
|
716
|
+
const events = await readSourceEvents(source, stat.size);
|
|
669
717
|
let tailSeq: number | undefined;
|
|
670
718
|
for (const e of events) {
|
|
671
719
|
if (typeof e.seq === 'number' && (tailSeq === undefined || e.seq > tailSeq)) tailSeq = e.seq;
|
|
@@ -681,8 +729,7 @@ export async function replayMessagesWithResumePolicy(
|
|
|
681
729
|
}
|
|
682
730
|
|
|
683
731
|
if (stat.size <= exactReplayBytes) {
|
|
684
|
-
const
|
|
685
|
-
const events = parseJsonl(raw);
|
|
732
|
+
const events = await readSourceEvents(source, stat.size);
|
|
686
733
|
return {
|
|
687
734
|
messages: buildMessagesFromReplayEvents(events, [], maxSeq, undefined, [], opts.attachmentMarkers),
|
|
688
735
|
mode: 'exact',
|
|
@@ -717,8 +764,7 @@ export async function replayMessagesWithResumePolicy(
|
|
|
717
764
|
const cachePath = summaryCachePath(cwd, workflowId);
|
|
718
765
|
let cache = opts.attachmentMarkers ? null : await readSummaryCache(cachePath, workflowId, stat.size, tailStartByte);
|
|
719
766
|
if (!cache) {
|
|
720
|
-
const
|
|
721
|
-
const olderEvents = parseJsonl(olderRaw, { dropLastPartial: !tailStart.completeLine });
|
|
767
|
+
const olderEvents = await readSourceEvents(source, tailStartByte, !tailStart.completeLine);
|
|
722
768
|
const built = summarizeClaudeNativePriorTurns(olderEvents, tailEvents, !!opts.attachmentMarkers);
|
|
723
769
|
if (opts.attachmentMarkers) {
|
|
724
770
|
const lastOlderSeq = olderEvents.reduce((max, event) => Math.max(max, event.seq ?? 0), 0);
|
|
@@ -739,6 +785,7 @@ export async function replayMessagesWithResumePolicy(
|
|
|
739
785
|
throughSeq: built.throughSeq,
|
|
740
786
|
lastHandoffSeq: built.lastHandoffSeq,
|
|
741
787
|
summary: built.summary,
|
|
788
|
+
summaryNotice: built.summaryNotice,
|
|
742
789
|
inputHistory: referencedInputRecords(tailEvents, olderEvents),
|
|
743
790
|
updatedAt: new Date().toISOString(),
|
|
744
791
|
};
|
|
@@ -753,5 +800,6 @@ export async function replayMessagesWithResumePolicy(
|
|
|
753
800
|
summaryThroughSeq: cache.throughSeq ?? undefined,
|
|
754
801
|
summaryBytes: cache.summary.length,
|
|
755
802
|
tailEvents: tailEvents.length,
|
|
803
|
+
...(cache.summaryNotice ? { summaryNotice: cache.summaryNotice } : {}),
|
|
756
804
|
};
|
|
757
805
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { setMaxListeners } from 'node:events';
|
|
2
2
|
import { assertNativeTaskAllowed } from './taskAdmission.js';
|
|
3
3
|
import { readSettings } from '../../settings.js';
|
|
4
|
-
import { resolveNativeSubagents, type NativeSubagentPolicy } from '@arco/shared';
|
|
4
|
+
import { buildTurnWaitInstructions, resolveNativeSubagents, type NativeSubagentPolicy } from '@arco/shared';
|
|
5
5
|
import { availableHandoffSources, executeHandoffHistory, HANDOFF_HISTORY_TOOL, HANDOFF_HISTORY_CONTEXT } from '../../handoffHistoryTool.js';
|
|
6
6
|
import { mediaRetirementNotice } from './mediaRetirementNotice.js';
|
|
7
7
|
import { nativeMediaLimits } from './mediaLimits.js';
|
|
@@ -15,6 +15,7 @@ import { nativeOAuthBaseUrl } from './apiEndpoint.js';
|
|
|
15
15
|
import { createHash } from 'node:crypto';
|
|
16
16
|
import { ensureProjectStateIgnore } from '../../projectStateIgnore.js';
|
|
17
17
|
import { replayEventsWithTs } from '../../workflowStore.js';
|
|
18
|
+
import { reportHistoryLoadFailure } from '../../providerConversation.js';
|
|
18
19
|
import { computerToolDefinitions, executeComputerTool } from '../../voice/toolDefinitions.js';
|
|
19
20
|
// Phase 7a — long-lived per-workflow Claude Native worker.
|
|
20
21
|
//
|
|
@@ -58,7 +59,7 @@ import { getPeerToolDefinitions, isPeerTool, executePeerTool } from './peerTools
|
|
|
58
59
|
import { registryToolDefs, parseRegistryToolName, isRegistryToolAllowed, isRegistryToolReadOnly } from './registryTools.js';
|
|
59
60
|
import { connectServer, type McpSession } from '../../mcp/client.js';
|
|
60
61
|
import { getSandboxToolDefinitions, isSandboxTool, executeSandboxTool } from './sandboxTools.js';
|
|
61
|
-
import { buildMessagesFromReplayEvents, replayMessagesWithResumePolicy, compactSummarySeed, type ClaudeResumeMessage } from './resumeSummary.js';
|
|
62
|
+
import { buildMessagesFromReplayEvents, replayMessagesWithResumePolicy, compactSummarySeed, NativeReconstructionLimitError, type ClaudeResumeMessage } from './resumeSummary.js';
|
|
62
63
|
import { readMeta, setResolvedModelId } from '../../workflowMeta.js';
|
|
63
64
|
import { lspManager } from '../../lsp/client.js';
|
|
64
65
|
import { isClaudeServerToolDef, isServerToolResultType, pendingServerTools, pruneServerToolEvidenceAfterTurn, stripDanglingServerToolResults } from './retainedContext.js';
|
|
@@ -1468,10 +1469,11 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
1468
1469
|
.filter((e) => meta?.computerContext?.lastResetSeq !== undefined
|
|
1469
1470
|
? (('seq' in e.message && typeof e.message.seq === 'number') ? e.message.seq : 0) > meta.computerContext.lastResetSeq
|
|
1470
1471
|
: e.ts > (meta?.computerContext?.lastResetAt ?? 0)).map((e) => e.message) as unknown as Parameters<typeof buildMessagesFromReplayEvents>[0]),
|
|
1471
|
-
mode: 'exact', reconstructed: false, summaryThroughSeq: undefined, tailEvents: undefined }
|
|
1472
|
+
mode: 'exact', reconstructed: false, summaryThroughSeq: undefined, tailEvents: undefined, summaryNotice: undefined }
|
|
1472
1473
|
: await replayMessagesWithResumePolicy(cwd, this.workflowId, undefined, { leafSeq: meta?.leafSeq, attachmentMarkers });
|
|
1473
1474
|
this.messages = attachmentMarkers ? await restoreChatAttachments(replay.messages as MessageParam[], attachmentMarkers) : replay.messages as MessageParam[];
|
|
1474
1475
|
this.resetPrefixFreeze('replay');
|
|
1476
|
+
if (replay.summaryNotice) this.emit('system_notice', replay.summaryNotice);
|
|
1475
1477
|
if (replay.reconstructed) {
|
|
1476
1478
|
// docs/PERSISTENCE.md - the rewound branch's ancestry
|
|
1477
1479
|
// had rotated off the size-capped log, so this is a RECONSTRUCTED
|
|
@@ -1488,6 +1490,8 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
1488
1490
|
}
|
|
1489
1491
|
} catch (err) {
|
|
1490
1492
|
console.warn(`[claude-native:${this.workflowId.slice(0, 8)}] replay failed:`, err);
|
|
1493
|
+
reportHistoryLoadFailure(this.workflowId, this, 'native', content => this.emit('system_notice', content),
|
|
1494
|
+
err instanceof NativeReconstructionLimitError ? err.limitBytes : undefined);
|
|
1491
1495
|
}
|
|
1492
1496
|
}
|
|
1493
1497
|
this.replayed = true;
|
|
@@ -2068,7 +2072,7 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
2068
2072
|
'Continue working until the request is complete or you are genuinely blocked on operator input. ' +
|
|
2069
2073
|
"Never end your turn with a status update, a plan, or a promise of future work ('Continuing now', 'I'll do X next') — " +
|
|
2070
2074
|
'if your final paragraph describes work you have not done, do that work now instead of ending the turn. ' +
|
|
2071
|
-
|
|
2075
|
+
buildTurnWaitInstructions(this.config.clusterRole) + ' ' +
|
|
2072
2076
|
'If a delegated Task child fails or returns an error or nonsense (e.g. a login error), say so explicitly in your reply and adapt openly — never silently work around a failed delegation. ' +
|
|
2073
2077
|
// Fable 5.1 / 5.2 can rewrite whole files where a targeted edit would do
|
|
2074
2078
|
// (docs/PROVIDERS.md); Anthropic's documented one-liner.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { buildTurnWaitInstructions } from '@arco/shared';
|
|
1
2
|
import { prepareProviderHistory } from './handoffHistoryBinding.js';
|
|
2
3
|
import { prepareLocalFileContext, combineChatAttachments } from './localFileMedia.js';
|
|
3
4
|
import { cliFileReadGuidance, prepareProviderAttachments, type PreparedAttachments } from './providerFileContent.js';
|
|
@@ -46,7 +47,7 @@ const APPEND_SP_TMPDIR = joinPath(tmpdir(), 'arco-prompts');
|
|
|
46
47
|
// last (the order Claude Native uses). Each part is stable for the tab, so the
|
|
47
48
|
// appended system prompt stays byte-identical from turn to turn.
|
|
48
49
|
function effectiveAppendSystemPrompt(config: WorkerConfig): string | undefined {
|
|
49
|
-
const parts = [goalBlock(config.goal), config.appendSystemPrompt, cliFileReadGuidance(config), outputStyleAddendum(config.outputStyle)]
|
|
50
|
+
const parts = [buildTurnWaitInstructions(config.clusterRole), goalBlock(config.goal), config.appendSystemPrompt, cliFileReadGuidance(config), outputStyleAddendum(config.outputStyle)]
|
|
50
51
|
.filter((s): s is string => typeof s === 'string' && s.length > 0);
|
|
51
52
|
return parts.length > 0 ? parts.join('\n\n') : undefined;
|
|
52
53
|
}
|
|
@@ -31,7 +31,7 @@ export const CLUSTER_TASK_TOOL_DEFINITIONS: ClusterTaskToolDefinition[] = [
|
|
|
31
31
|
{
|
|
32
32
|
name: 'cluster_task_create',
|
|
33
33
|
description:
|
|
34
|
-
'Create a non-terminal task on the shared cluster board. New tasks start as todo;
|
|
34
|
+
'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.',
|
|
35
35
|
input_schema: {
|
|
36
36
|
type: 'object',
|
|
37
37
|
properties: {
|
|
@@ -76,7 +76,7 @@ export const CLUSTER_TASK_TOOL_DEFINITIONS: ClusterTaskToolDefinition[] = [
|
|
|
76
76
|
{
|
|
77
77
|
name: 'cluster_task_update',
|
|
78
78
|
description:
|
|
79
|
-
"Update a task on the shared cluster board.
|
|
79
|
+
"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.",
|
|
80
80
|
input_schema: {
|
|
81
81
|
type: 'object',
|
|
82
82
|
properties: {
|
|
@@ -86,7 +86,7 @@ export const CLUSTER_TASK_TOOL_DEFINITIONS: ClusterTaskToolDefinition[] = [
|
|
|
86
86
|
release: { type: 'string', description: 'Release label such as 0.1.4; an empty string clears it.' },
|
|
87
87
|
signoff: {
|
|
88
88
|
type: 'object',
|
|
89
|
-
description: '
|
|
89
|
+
description: 'Director verdict: met closes the task unless Board auto-done is off.',
|
|
90
90
|
properties: {
|
|
91
91
|
state: { type: 'string', enum: ['met', 'not_met', 'partial'], description: 'Your verdict: met / not_met / partial.' },
|
|
92
92
|
summary: { type: 'string', description: 'One-line reason shown on the board card.' },
|
|
@@ -165,7 +165,7 @@ export const CLUSTER_TASK_TOOL_DEFINITIONS: ClusterTaskToolDefinition[] = [
|
|
|
165
165
|
{
|
|
166
166
|
name: 'cluster_task_complete',
|
|
167
167
|
description:
|
|
168
|
-
"Submit a completion report for a task YOU OWN. Moves the task to review and appends a durable COMPLETION REPORT comment. You can only complete a task currently assigned to you - completing an unknown id is rejected (not_found) and completing another member's or an unassigned task is rejected (not_owner); claim it first (cluster_task_claim) or coordinate via peer_send. It does
|
|
168
|
+
"Submit a completion report for a task YOU OWN. Moves the task to review and appends a durable COMPLETION REPORT comment. You can only complete a task currently assigned to you - completing an unknown id is rejected (not_found) and completing another member's or an unassigned task is rejected (not_owner); claim it first (cluster_task_claim) or coordinate via peer_send. It does not mark done; the director reviews the report.",
|
|
169
169
|
input_schema: {
|
|
170
170
|
type: 'object',
|
|
171
171
|
properties: {
|