arco-workbench 0.1.4 → 0.1.6
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 +49 -8
- package/README.md +42 -21
- package/THIRD_PARTY_NOTICES +789 -0
- package/client/dist/assets/{PhosphorBackdrop-CNumba2X.js → PhosphorBackdrop-BR-TgB5x.js} +1 -1
- package/client/dist/assets/{ThemedBackgroundShaderImpl-DX5KyCt3.js → ThemedBackgroundShaderImpl-DgcFj6JN.js} +1 -1
- package/client/dist/assets/{XtermView-DhS5g8Rt.js → XtermView-CflVBQgC.js} +2 -2
- package/client/dist/assets/galleryEditor-BB-emfmi.js +702 -0
- package/client/dist/assets/index-B_EqHDz3.js +612 -0
- package/client/dist/assets/index-DD9kFGsF.css +1 -0
- package/client/dist/index.html +2 -2
- package/client/src/App.tsx +44 -55
- package/client/src/alerts/desktopAlerts.ts +33 -12
- package/client/src/alerts/desktopTest.ts +68 -0
- package/client/src/alerts/focusNotice.ts +16 -0
- package/client/src/buildCheck.ts +42 -2
- package/client/src/components/ArchitectureReviewDialog.tsx +98 -0
- package/client/src/components/ArtifactModal.tsx +4 -6
- package/client/src/components/ArtifactMoveDialog.tsx +11 -7
- package/client/src/components/AskUserQuestionNotice.tsx +2 -1
- package/client/src/components/AutomaticMessage.tsx +19 -0
- package/client/src/components/BriefControl.tsx +4 -2
- package/client/src/components/BrowserNotice.tsx +35 -0
- package/client/src/components/CatchMeUp.tsx +12 -6
- package/client/src/components/ChatMessage.tsx +15 -4
- package/client/src/components/ChatModeView.tsx +23 -16
- package/client/src/components/ChatPanel.tsx +33 -5
- package/client/src/components/CheckpointActions.tsx +91 -26
- package/client/src/components/ClusterActivityTab.tsx +4 -2
- package/client/src/components/ClusterMemberPicker.tsx +6 -3
- package/client/src/components/ClusterPlanTab.tsx +93 -62
- package/client/src/components/ClusterRightPanel/AddWorkerSection.tsx +16 -5
- package/client/src/components/ClusterRightPanel/AutoPickupControl.tsx +53 -19
- package/client/src/components/ClusterRightPanel/MailboxModal.tsx +7 -3
- package/client/src/components/ClusterRightPanel/MemberRow.tsx +6 -3
- package/client/src/components/ClusterRightPanel/MemberSettingsFields.tsx +104 -0
- package/client/src/components/ClusterRightPanel/MessageGuardControl.tsx +1 -1
- package/client/src/components/ClusterRightPanel/ReplaceMemberDialog.tsx +85 -7
- package/client/src/components/ClusterRightPanel/index.tsx +90 -36
- package/client/src/components/ClusterRightPanel/memberSettings.ts +52 -0
- package/client/src/components/ClusterRightPanel/panels.ts +18 -0
- package/client/src/components/ClusterRightPanel/types.ts +9 -10
- package/client/src/components/ClusterTab.tsx +252 -62
- package/client/src/components/ClusterTaskBoardTab.tsx +76 -601
- package/client/src/components/CommandPalette.tsx +17 -6
- package/client/src/components/ComputerAgentPicker.tsx +1 -1
- package/client/src/components/ComputerPanel.tsx +4 -2
- package/client/src/components/Connections/Connections.tsx +5 -2
- package/client/src/components/Connections/EndpointEditor.tsx +2 -2
- package/client/src/components/Connections/connections.css +1 -1
- package/client/src/components/Connections/model.ts +5 -1
- package/client/src/components/ContextMeter.tsx +22 -4
- package/client/src/components/DeepSeekControls.tsx +7 -6
- package/client/src/components/DiagnosticsTab.tsx +3 -2
- package/client/src/components/DialogShell.tsx +19 -11
- package/client/src/components/FileExplorer.tsx +8 -9
- package/client/src/components/FileViewerModal.tsx +37 -12
- package/client/src/components/FirstRun.tsx +8 -7
- package/client/src/components/GateApprovalNotice.tsx +4 -2
- package/client/src/components/GitDialog.tsx +1 -0
- package/client/src/components/GitHubPanel/CodeView.tsx +35 -23
- package/client/src/components/GitHubPanel/IssueView.tsx +6 -4
- package/client/src/components/GitHubPanel/PullView.tsx +7 -6
- package/client/src/components/GitHubPanel/RunView.tsx +7 -5
- package/client/src/components/GitHubPanel/shared.tsx +23 -8
- package/client/src/components/HandoffSeedPill.tsx +5 -5
- package/client/src/components/HandoffSource.tsx +54 -0
- package/client/src/components/HeaderAuthChip.tsx +22 -1
- package/client/src/components/HeaderDropdown.tsx +5 -0
- package/client/src/components/HeaderVersionBox.tsx +3 -0
- package/client/src/components/HistoryTab.tsx +59 -32
- package/client/src/components/Home/AddProject.tsx +1 -1
- package/client/src/components/Home/HomeView.tsx +29 -20
- package/client/src/components/Home/LocationDialog.tsx +1 -1
- package/client/src/components/Home/ProjectCard.tsx +5 -3
- package/client/src/components/Home/home.css +4 -4
- package/client/src/components/KeepButton.tsx +22 -0
- package/client/src/components/LlamacppCatalogEditor.tsx +12 -3
- package/client/src/components/LocalRuntimeStatus.tsx +54 -0
- package/client/src/components/MdTuneupDialog.tsx +3 -1
- package/client/src/components/MemberCard.tsx +44 -42
- package/client/src/components/MemberPane.tsx +11 -10
- package/client/src/components/ModelHealthPanel.tsx +5 -4
- package/client/src/components/NativeSubagentControls.tsx +64 -0
- package/client/src/components/NeedsYouBadge.tsx +42 -20
- package/client/src/components/NorthStarBar.tsx +5 -3
- package/client/src/components/NotificationCenter.tsx +14 -2
- package/client/src/components/NotificationChannelsSettings.tsx +38 -30
- package/client/src/components/NotificationToasts.tsx +6 -8
- package/client/src/components/OperatorQuestionNotice.tsx +10 -1
- package/client/src/components/PendingQuestionsButton.tsx +4 -1
- package/client/src/components/PlanBodyRenderer.tsx +1 -0
- package/client/src/components/PlanCandidateBanner.tsx +20 -3
- package/client/src/components/PlanReviewPicker.tsx +6 -3
- package/client/src/components/PreviewTab.tsx +62 -25
- package/client/src/components/PrimaryStatus.tsx +20 -74
- package/client/src/components/ProjectsSettings.tsx +28 -2
- package/client/src/components/ProviderReleasesModal.tsx +13 -3
- package/client/src/components/ProvidersPopover.tsx +102 -33
- package/client/src/components/PublicProjectBox.tsx +10 -6
- package/client/src/components/PurgeConversationModal.tsx +7 -2
- package/client/src/components/QueuedMessagesIndicator.tsx +42 -150
- package/client/src/components/Recall/RecallResultRow.tsx +4 -2
- package/client/src/components/Recall/RecallView.tsx +12 -9
- package/client/src/components/ResearchDialog.tsx +1 -1
- package/client/src/components/ReviewDialog.tsx +12 -5
- package/client/src/components/RightPanel/ActivityTab.tsx +32 -16
- package/client/src/components/RightPanel/CodebaseMemorySection.tsx +3 -1
- package/client/src/components/RightPanel/ConfigTab.tsx +129 -140
- package/client/src/components/RightPanel/GenesisTab.tsx +67 -24
- package/client/src/components/RightPanel/HandoffsTab.tsx +4 -0
- package/client/src/components/RightPanel/KnowledgeTab.tsx +1 -1
- package/client/src/components/RightPanel/LedgerTab.tsx +1 -1
- package/client/src/components/RightPanel/McpRegistrySection.tsx +7 -6
- package/client/src/components/RightPanel/MoveTargetModal.tsx +6 -3
- package/client/src/components/RightPanel/OutputsPanel.tsx +40 -17
- package/client/src/components/RightPanel/PlanTab.tsx +109 -111
- package/client/src/components/RightPanel/ReviewTab.tsx +7 -4
- package/client/src/components/RightPanel/UsageTab.tsx +18 -5
- package/client/src/components/RightPanel/format.ts +3 -1
- package/client/src/components/RightPanel/index.tsx +10 -2
- package/client/src/components/RightPanel/types.ts +4 -2
- package/client/src/components/RunAsPicker.tsx +5 -3
- package/client/src/components/RuntimeStateBanner.tsx +13 -3
- package/client/src/components/SavedClustersList.tsx +30 -3
- package/client/src/components/ServicesTab.tsx +17 -34
- package/client/src/components/SettingsPanel.tsx +101 -337
- package/client/src/components/ShortcutCheatSheet.tsx +6 -4
- package/client/src/components/SkillEditorDialog.tsx +2 -1
- package/client/src/components/SkillsSettings.tsx +307 -0
- package/client/src/components/SpawnDialog.tsx +3 -3
- package/client/src/components/SpawnSeedPill.tsx +5 -4
- package/client/src/components/StaleBuildBanner.tsx +3 -1
- package/client/src/components/StorageWarnings.tsx +3 -1
- package/client/src/components/SystemHeader.tsx +17 -10
- package/client/src/components/SystemModal.tsx +6 -5
- package/client/src/components/TabBar.tsx +31 -18
- package/client/src/components/TabContextMenu.tsx +36 -10
- package/client/src/components/TabStatusChip.tsx +8 -7
- package/client/src/components/TaskCard.tsx +16 -11
- package/client/src/components/TasksPanel.tsx +13 -11
- package/client/src/components/Terminal/XtermView.tsx +2 -0
- package/client/src/components/TerminalInput.tsx +248 -447
- package/client/src/components/TerminalSessions.tsx +1 -1
- package/client/src/components/TokenBadge.tsx +20 -17
- package/client/src/components/ToolCallPill.tsx +5 -3
- package/client/src/components/ToolboxMenu.tsx +5 -5
- package/client/src/components/TranscriptSendDialog.tsx +1 -1
- package/client/src/components/TurnTimer.tsx +21 -0
- package/client/src/components/UpdateAction.tsx +4 -1
- package/client/src/components/UsageBar.tsx +32 -126
- package/client/src/components/UserManual/index.tsx +6 -4
- package/client/src/components/VoiceMenu.tsx +5 -1
- package/client/src/components/VoiceSetupSettings.tsx +21 -11
- package/client/src/components/WorkerCard.tsx +7 -1
- package/client/src/components/WorkerDetailModal.tsx +7 -3
- package/client/src/components/WorkflowCreator/ClusterMembersSection.tsx +6 -6
- package/client/src/components/WorkflowCreator/ProjectPicker.tsx +13 -12
- package/client/src/components/WorkflowCreator/index.tsx +237 -78
- package/client/src/components/WorkflowCreator/types.ts +5 -3
- package/client/src/components/WorkflowStatusChip.tsx +93 -13
- package/client/src/components/WorkflowView.tsx +55 -24
- package/client/src/components/WorkspaceRename.tsx +11 -1
- package/client/src/components/activityTime.ts +4 -0
- package/client/src/components/clusterNeedsYou.ts +27 -8
- package/client/src/components/compare/CompareDialog.tsx +6 -3
- package/client/src/components/compare/CompareOverlay.tsx +10 -3
- package/client/src/components/composer/submitComposer.ts +191 -0
- package/client/src/components/diff/ChangesPanel.tsx +4 -2
- package/client/src/components/diff/LiveChangesPanel.tsx +18 -2
- package/client/src/components/editor/CodeEditor.tsx +17 -2
- package/client/src/components/headerPopoverState.ts +15 -0
- package/client/src/components/help/DocViewer.tsx +6 -4
- package/client/src/components/help/HelpCard.tsx +3 -2
- package/client/src/components/help/HelpPopover.tsx +3 -1
- package/client/src/components/media/AudioEditor/AudioOpsPanel.tsx +16 -2
- package/client/src/components/media/DirectoryPicker.tsx +18 -11
- package/client/src/components/media/ImageEditor/ImageEditor.tsx +2 -2
- package/client/src/components/media/MediaModalHost.tsx +7 -15
- package/client/src/components/media/MediaStemsControls.tsx +16 -2
- package/client/src/components/media/VideoEditor/VideoOpsPanel.tsx +16 -2
- package/client/src/components/media/launchers.ts +4 -0
- package/client/src/components/plans/PlanChooser.tsx +135 -0
- package/client/src/components/plans/PlanRefsSection.tsx +47 -28
- package/client/src/components/plans/planBodySave.ts +17 -0
- package/client/src/components/plans/planRefs.ts +21 -11
- package/client/src/components/plans/startPlanGenesis.ts +37 -0
- package/client/src/components/primitives/Panel.tsx +1 -0
- package/client/src/components/providerPanelState.ts +17 -0
- package/client/src/components/settings/AppVersionSection.tsx +5 -5
- package/client/src/components/settings/AppWindowBrowserSection.tsx +88 -0
- package/client/src/components/settings/PreviewPortsSection.tsx +31 -0
- package/client/src/components/settings/SettingsLayout.tsx +1 -1
- package/client/src/components/settings/appWindowBrowserReport.ts +23 -0
- package/client/src/components/settings/navigation.ts +5 -1
- package/client/src/components/settings/settings.css +6 -0
- package/client/src/components/terminalInput/planDraft.ts +5 -5
- package/client/src/components/usageVisibility.ts +3 -2
- package/client/src/components/workSurface/WorkSurfaceControls.tsx +125 -10
- package/client/src/components/workSurface/workSurface.css +10 -2
- package/client/src/explorer/ArtifactsLens.tsx +53 -17
- package/client/src/explorer/ExplorerApp.tsx +8 -6
- package/client/src/explorer/PlansLens.tsx +80 -20
- package/client/src/explorer/RecentsLens.tsx +22 -61
- package/client/src/explorer/StorageLens.tsx +10 -4
- package/client/src/explorer/changedAttribution.ts +23 -0
- package/client/src/explorer/launch.ts +6 -3
- package/client/src/explorer/treeReveal.ts +21 -0
- package/client/src/explorer/types.ts +3 -3
- package/client/src/help/content/chat.tsx +17 -10
- package/client/src/help/content/cluster.tsx +165 -122
- package/client/src/help/content/composer.tsx +132 -44
- package/client/src/help/content/gitOps.tsx +19 -19
- package/client/src/help/content/github.tsx +9 -4
- package/client/src/help/content/header.tsx +90 -62
- package/client/src/help/content/media.tsx +20 -20
- package/client/src/help/content/misc.tsx +355 -163
- package/client/src/help/content/recall.tsx +12 -12
- package/client/src/help/content/rightPanel.tsx +199 -102
- package/client/src/help/content/settings.tsx +117 -44
- package/client/src/help/content/shared.tsx +1 -1
- package/client/src/help/content/tabbar.tsx +3 -2
- package/client/src/help/manualSections/actions.tsx +24 -17
- package/client/src/help/manualSections/chat.tsx +28 -5
- package/client/src/help/manualSections/clusters.tsx +250 -145
- package/client/src/help/manualSections/configuration.tsx +232 -48
- package/client/src/help/manualSections/deepseek.tsx +7 -5
- package/client/src/help/manualSections/gettingStarted.tsx +84 -12
- package/client/src/help/manualSections/maintenance.tsx +96 -19
- package/client/src/help/manualSections/media.tsx +14 -12
- package/client/src/help/manualSections/plans.tsx +108 -25
- package/client/src/help/manualSections/powerFeatures.tsx +145 -50
- package/client/src/help/manualSections/providers.tsx +247 -45
- package/client/src/help/manualSections/reference.tsx +20 -12
- package/client/src/help/manualSections/strata.tsx +6 -6
- package/client/src/help/manualSections/troubleshooting.tsx +14 -8
- package/client/src/help/manualSections/voice.tsx +12 -7
- package/client/src/help/manualSections/workflows.tsx +89 -19
- package/client/src/help/manualSections/workspace.tsx +180 -47
- package/client/src/help/shortcuts.ts +1 -0
- package/client/src/hooks/useWebSocket.ts +49 -25
- package/client/src/layout/SlideOut.tsx +77 -0
- package/client/src/layout/ToolbarOverflow.tsx +97 -0
- package/client/src/layout/keepInWindow.ts +216 -0
- package/client/src/layout/layoutRange.ts +129 -0
- package/client/src/main.tsx +2 -0
- package/client/src/phosphor-demo/Demo.tsx +5 -13
- package/client/src/phosphor-demo/demo.css +1 -1
- package/client/src/questions/waitingQuestion.ts +3 -2
- package/client/src/stores/appStore.ts +66 -15
- package/client/src/stores/appStore.types.ts +36 -16
- package/client/src/stores/docEditStore.ts +13 -21
- package/client/src/stores/draftStore.ts +28 -4
- package/client/src/stores/knowledgeDistillStore.ts +4 -2
- package/client/src/stores/mdTuneupStore.ts +10 -5
- package/client/src/stores/notificationChannelsStore.ts +21 -11
- package/client/src/stores/notificationStore.ts +2 -0
- package/client/src/stores/planGenesisStore.ts +67 -0
- package/client/src/stores/recallStore.ts +6 -0
- package/client/src/stores/terminalStore.ts +1 -1
- package/client/src/styles/global.css +72 -0
- package/client/src/styles/matrix.css +7 -0
- package/client/src/themes/apply.ts +3 -3
- package/client/src/themes/bootstrap.ts +3 -0
- package/client/src/utils/activeProject.ts +6 -0
- package/client/src/utils/activityPresentation.ts +51 -0
- package/client/src/utils/browserFamily.ts +22 -0
- package/client/src/utils/chatFileLinks.ts +3 -2
- package/client/src/utils/chatText.ts +14 -6
- package/client/src/utils/checkedJson.ts +11 -0
- package/client/src/utils/checkpointChanges.ts +18 -0
- package/client/src/utils/clusterCreation.ts +39 -0
- package/client/src/utils/clusterNudge.ts +31 -0
- package/client/src/utils/displayMessages.ts +45 -7
- package/client/src/utils/effortDefaults.ts +4 -3
- package/client/src/utils/format.ts +11 -4
- package/client/src/utils/gateArgs.ts +3 -2
- package/client/src/utils/handoffSeeds.ts +13 -0
- package/client/src/utils/historyEvents.ts +21 -12
- package/client/src/utils/homeModel.ts +19 -3
- package/client/src/utils/memberReviewScope.ts +6 -0
- package/client/src/utils/outputNavigation.ts +16 -0
- package/client/src/utils/outputStyleText.ts +8 -0
- package/client/src/utils/publicProject.ts +102 -28
- package/client/src/utils/queuedMessageEdit.ts +40 -0
- package/client/src/utils/requestGeneration.ts +8 -0
- package/client/src/utils/rewindSupport.ts +17 -0
- package/client/src/utils/settingsRequests.ts +36 -0
- package/client/src/utils/settingsResponse.ts +8 -0
- package/client/src/utils/tabStatus.ts +8 -0
- package/client/src/utils/wsSession.ts +12 -5
- package/client/src/vendor/odysseus-editor/editor/clipboard-and-drop.js +9 -9
- package/client/src/vendor/odysseus-editor/editor/keyboard-shortcuts.js +2 -2
- package/client/src/vendor/odysseus-editor/editor/state.js +8 -0
- package/client/src/vendor/odysseus-editor/editor.css +13 -5
- package/client/src/vendor/odysseus-editor/galleryEditor.d.ts +1 -1
- package/client/src/vendor/odysseus-editor/galleryEditor.js +16 -5
- package/client/src/voice/commands.ts +4 -3
- package/client/src/voice/executor.ts +7 -6
- package/client/src/voice/panels.ts +14 -3
- package/client/src/voice/screen.ts +48 -6
- package/client/src/voice/setupAudio.ts +5 -3
- package/client/src/ws/handleServerMessage.ts +176 -38
- package/client/src/ws/operatorQuestions.ts +4 -2
- package/docs/ARCHITECTURE.md +95 -55
- package/docs/ARCHITECTURE_REVIEW.md +47 -0
- package/docs/BACKUP.md +5 -2
- package/docs/CHAT.md +48 -37
- package/docs/CHECKPOINTS.md +43 -16
- package/docs/CLIENT.md +220 -84
- package/docs/CODEX_GPT56_CLUSTER_INCOMPAT.md +1 -1
- package/docs/DEEPSEEK.md +6 -6
- package/docs/DIAGNOSTICS.md +12 -7
- package/docs/EXTENDING.md +52 -48
- package/docs/FEATURES.md +34 -21
- package/docs/GENESIS.md +42 -6
- package/docs/GETTING_STARTED.md +65 -25
- package/docs/GIT_WORKBENCH.md +15 -9
- package/docs/GLOSSARY.md +47 -41
- package/docs/GOTCHAS.md +86 -61
- package/docs/HTTP_API.md +145 -47
- package/docs/INDEX.md +3 -4
- package/docs/KNOWLEDGE.md +6 -4
- package/docs/LOCAL_SERVICES.md +6 -6
- package/docs/LSP.md +4 -3
- package/docs/MCP_REGISTRY.md +16 -12
- package/docs/MEDIA_STUDIO.md +23 -16
- package/docs/NOTIFICATIONS.md +50 -17
- package/docs/OPERATIONS.md +391 -121
- package/docs/OPERATOR_ACTIONS.md +43 -24
- package/docs/OUTPUTS.md +27 -10
- package/docs/PERSISTENCE.md +92 -34
- package/docs/PHOSPHOR_DEMO.md +4 -4
- package/docs/PLAN_OR_BOARD.md +9 -4
- package/docs/PREVIEW_VERIFY.md +10 -8
- package/docs/PRIMITIVES.md +91 -88
- package/docs/PROTOCOL.md +101 -30
- package/docs/PROTOCOL_CLUSTER.md +86 -19
- package/docs/PROTOCOL_PRIMITIVES.md +9 -9
- package/docs/PROVIDERS.md +481 -87
- package/docs/RECALL.md +17 -12
- package/docs/REMOTE_MANAGEMENT.md +69 -8
- package/docs/REPO_LAYOUT.md +1 -1
- package/docs/RESUME_INDEX.md +16 -17
- package/docs/SERVICE_MODE.md +45 -10
- package/docs/SETTINGS.md +61 -8
- package/docs/STORAGE_PLAN.md +54 -49
- package/docs/STRATA.md +4 -4
- package/docs/TASK_LEDGER.md +39 -12
- package/docs/TERMINAL.md +14 -12
- package/docs/THIRD_PARTY.md +1 -3
- package/docs/VOICE.md +17 -7
- package/native/darwin-arm64/manifest.json +1 -1
- package/native/win32-arm64/manifest.json +1 -1
- package/node_modules/@arco/shared/dist/clusterCoordination.js +15 -7
- package/node_modules/@arco/shared/dist/clusterRolePresets.d.ts +1 -1
- package/node_modules/@arco/shared/dist/clusterRolePresets.js +18 -6
- package/node_modules/@arco/shared/dist/codexChat.d.ts +2 -0
- package/node_modules/@arco/shared/dist/codexChat.js +5 -0
- package/node_modules/@arco/shared/dist/folderName.d.ts +1 -0
- package/node_modules/@arco/shared/dist/folderName.js +18 -0
- package/node_modules/@arco/shared/dist/index.d.ts +6 -0
- package/node_modules/@arco/shared/dist/index.js +6 -0
- package/node_modules/@arco/shared/dist/localRuntimeStatus.d.ts +23 -0
- package/node_modules/@arco/shared/dist/localRuntimeStatus.js +47 -0
- package/node_modules/@arco/shared/dist/notificationTitle.d.ts +9 -0
- package/node_modules/@arco/shared/dist/notificationTitle.js +23 -0
- package/node_modules/@arco/shared/dist/outputStyle.d.ts +10 -0
- package/node_modules/@arco/shared/dist/outputStyle.js +28 -0
- package/node_modules/@arco/shared/dist/outputs.d.ts +1 -0
- package/node_modules/@arco/shared/dist/protocol/autoPickup.d.ts +2 -0
- package/node_modules/@arco/shared/dist/protocol/autoPickup.js +9 -1
- package/node_modules/@arco/shared/dist/protocol/chat.d.ts +4 -0
- package/node_modules/@arco/shared/dist/protocol/checkpoints.d.ts +24 -2
- package/node_modules/@arco/shared/dist/protocol/checkpoints.js +1 -0
- package/node_modules/@arco/shared/dist/protocol/clientMessages.d.ts +11 -16
- package/node_modules/@arco/shared/dist/protocol/clusters.d.ts +21 -4
- package/node_modules/@arco/shared/dist/protocol/clusters.js +3 -3
- package/node_modules/@arco/shared/dist/protocol/connections.d.ts +2 -0
- package/node_modules/@arco/shared/dist/protocol/diagnostics.js +1 -1
- package/node_modules/@arco/shared/dist/protocol/genesis.d.ts +9 -0
- package/node_modules/@arco/shared/dist/protocol/mcp.d.ts +1 -0
- package/node_modules/@arco/shared/dist/protocol/mcp.js +8 -5
- package/node_modules/@arco/shared/dist/protocol/mdTuneup.d.ts +2 -0
- package/node_modules/@arco/shared/dist/protocol/models.d.ts +9 -1
- package/node_modules/@arco/shared/dist/protocol/models.js +19 -8
- package/node_modules/@arco/shared/dist/protocol/notifications.d.ts +6 -1
- package/node_modules/@arco/shared/dist/protocol/notifications.js +15 -3
- package/node_modules/@arco/shared/dist/protocol/operatorQuestions.d.ts +12 -0
- package/node_modules/@arco/shared/dist/protocol/plans.d.ts +2 -1
- package/node_modules/@arco/shared/dist/protocol/remoteManagement.d.ts +6 -0
- package/node_modules/@arco/shared/dist/protocol/serverMessages.d.ts +77 -12
- package/node_modules/@arco/shared/dist/protocol/settings.d.ts +16 -4
- package/node_modules/@arco/shared/dist/protocol/settings.js +17 -1
- package/node_modules/@arco/shared/dist/protocol/tasks.d.ts +1 -0
- package/node_modules/@arco/shared/dist/protocol/usage.d.ts +1 -0
- package/node_modules/@arco/shared/dist/protocol/workers.d.ts +1 -0
- package/node_modules/@arco/shared/dist/protocol/workflows.d.ts +74 -14
- package/node_modules/@arco/shared/dist/protocol/workflows.js +66 -0
- package/node_modules/@arco/shared/dist/publicGuardrails.d.ts +1 -1
- package/node_modules/@arco/shared/dist/publicGuardrails.js +1 -1
- package/node_modules/@arco/shared/dist/runtimeVersions.d.ts +2 -0
- package/node_modules/@arco/shared/dist/runtimeVersions.js +13 -0
- package/node_modules/@arco/shared/dist/shellTool.d.ts +2 -0
- package/node_modules/@arco/shared/dist/shellTool.js +9 -0
- package/node_modules/@arco/shared/package.json +1 -1
- package/node_modules/xlsx/LICENSE +201 -0
- package/node_modules/xlsx/dist/cpexcel.js +1506 -0
- package/node_modules/xlsx/package.json +69 -0
- package/node_modules/xlsx/xlsx.js +28103 -0
- package/node_modules/xlsx/xlsx.mjs +28228 -0
- package/package.json +22 -3
- package/scripts/packaging/arco.mjs +4 -3
- package/scripts/packaging/browsers.mjs +366 -0
- package/scripts/packaging/launch.mjs +34 -20
- package/scripts/packaging/services.mjs +1 -1
- package/scripts/packaging/storage.mjs +39 -3
- package/server/dist/appBrowsers.d.ts +45 -0
- package/server/dist/appBrowsers.js +73 -0
- package/server/dist/architectureReview.d.ts +60 -0
- package/server/dist/architectureReview.js +347 -0
- package/server/dist/architectureSkill.d.ts +8 -0
- package/server/dist/architectureSkill.js +70 -0
- package/server/dist/arcoHome.d.ts +1 -0
- package/server/dist/arcoHome.js +43 -3
- package/server/dist/artifactCopy.d.ts +3 -0
- package/server/dist/artifactCopy.js +113 -36
- package/server/dist/atomicFile.d.ts +1 -1
- package/server/dist/atomicFile.js +6 -1
- package/server/dist/attention.d.ts +6 -2
- package/server/dist/attention.js +33 -20
- package/server/dist/auth.d.ts +1 -0
- package/server/dist/auth.js +19 -6
- package/server/dist/authLoginSession.d.ts +2 -0
- package/server/dist/authLoginSession.js +6 -1
- package/server/dist/boundedRead.d.ts +26 -0
- package/server/dist/boundedRead.js +246 -0
- package/server/dist/capabilities.d.ts +10 -6
- package/server/dist/capabilities.js +81 -95
- package/server/dist/catchUp.d.ts +7 -0
- package/server/dist/catchUp.js +20 -1
- package/server/dist/checkedFile.d.ts +5 -0
- package/server/dist/checkedFile.js +138 -0
- package/server/dist/claudeTransport.d.ts +7 -0
- package/server/dist/claudeTransport.js +14 -0
- package/server/dist/cliUpdateDecision.d.ts +34 -0
- package/server/dist/cliUpdateDecision.js +152 -0
- package/server/dist/clusterAutoTurn.d.ts +7 -0
- package/server/dist/clusterAutoTurn.js +54 -7
- package/server/dist/clusterBusyReminder.d.ts +7 -0
- package/server/dist/clusterBusyReminder.js +45 -0
- package/server/dist/clusterDirector.js +7 -3
- package/server/dist/clusterIdleNudger.d.ts +6 -0
- package/server/dist/clusterIdleNudger.js +5 -0
- package/server/dist/clusterMailbox.d.ts +4 -2
- package/server/dist/clusterMailbox.js +104 -24
- package/server/dist/clusterPeerOps.js +11 -23
- package/server/dist/clusterPlanBridge.d.ts +6 -3
- package/server/dist/clusterPlanBridge.js +48 -45
- package/server/dist/clusterPresets.js +46 -32
- package/server/dist/clusterProgress.js +3 -0
- package/server/dist/clusterSnapshots.d.ts +1 -1
- package/server/dist/clusterSnapshots.js +17 -2
- package/server/dist/clusterStore.d.ts +3 -0
- package/server/dist/clusterStore.js +23 -13
- package/server/dist/clusterTurnTools.d.ts +4 -0
- package/server/dist/clusterTurnTools.js +9 -0
- package/server/dist/commandShell.d.ts +56 -0
- package/server/dist/commandShell.js +278 -0
- package/server/dist/compactionCounter.d.ts +6 -0
- package/server/dist/compactionCounter.js +73 -0
- package/server/dist/compactionReport.d.ts +8 -0
- package/server/dist/compactionReport.js +15 -0
- package/server/dist/contentSearch.js +16 -6
- package/server/dist/contextCalibrator.js +7 -2
- package/server/dist/contextEstimator.d.ts +4 -0
- package/server/dist/contextEstimator.js +76 -17
- package/server/dist/contextRefs.d.ts +1 -0
- package/server/dist/contextRefs.js +44 -9
- package/server/dist/conversationActivity.d.ts +3 -0
- package/server/dist/conversationActivity.js +27 -0
- package/server/dist/cursorUsage.js +15 -4
- package/server/dist/defaults/models.md +1 -1
- package/server/dist/diagnostics/checks.js +4 -12
- package/server/dist/diagnostics/executableLookup.d.ts +2 -0
- package/server/dist/diagnostics/executableLookup.js +28 -0
- package/server/dist/diagnostics/modelHealth.js +3 -12
- package/server/dist/diagnostics/supportBundle.js +5 -13
- package/server/dist/eventLog.d.ts +19 -0
- package/server/dist/eventLog.js +299 -99
- package/server/dist/existingClusterMembers.d.ts +1 -0
- package/server/dist/existingClusterMembers.js +9 -0
- package/server/dist/explorerArtifacts.js +46 -12
- package/server/dist/explorerChanged.d.ts +7 -0
- package/server/dist/explorerChanged.js +116 -80
- package/server/dist/explorerDocs.d.ts +11 -0
- package/server/dist/explorerDocs.js +46 -48
- package/server/dist/explorerLaunch.d.ts +4 -0
- package/server/dist/explorerLaunch.js +9 -1
- package/server/dist/fileAccessPolicy.d.ts +21 -0
- package/server/dist/fileAccessPolicy.js +95 -5
- package/server/dist/fileContent/decodeSlots.d.ts +1 -0
- package/server/dist/fileContent/decodeSlots.js +50 -0
- package/server/dist/fileContent/detect.d.ts +2 -0
- package/server/dist/fileContent/detect.js +55 -0
- package/server/dist/fileContent/externalImage.d.ts +3 -0
- package/server/dist/fileContent/externalImage.js +68 -0
- package/server/dist/fileContent/icons.d.ts +4 -0
- package/server/dist/fileContent/icons.js +58 -0
- package/server/dist/fileContent/images.d.ts +15 -0
- package/server/dist/fileContent/images.js +182 -0
- package/server/dist/fileContent/legacyText.d.ts +3 -0
- package/server/dist/fileContent/legacyText.js +19 -0
- package/server/dist/fileContent/notebook.d.ts +2 -0
- package/server/dist/fileContent/notebook.js +54 -0
- package/server/dist/fileContent/office.d.ts +3 -0
- package/server/dist/fileContent/office.js +349 -0
- package/server/dist/fileContent/pdf.d.ts +2 -0
- package/server/dist/fileContent/pdf.js +76 -0
- package/server/dist/fileContent/pngRows.d.ts +4 -0
- package/server/dist/fileContent/pngRows.js +118 -0
- package/server/dist/fileContent/svg.d.ts +3 -0
- package/server/dist/fileContent/svg.js +60 -0
- package/server/dist/fileContent/types.d.ts +8 -0
- package/server/dist/fileContent/types.js +43 -0
- package/server/dist/fileContent/worker.d.ts +1 -0
- package/server/dist/fileContent/worker.js +68 -0
- package/server/dist/fileContent.d.ts +55 -0
- package/server/dist/fileContent.js +81 -0
- package/server/dist/fileContextReceipts.d.ts +12 -0
- package/server/dist/fileContextReceipts.js +53 -0
- package/server/dist/fileFetch.d.ts +17 -0
- package/server/dist/fileFetch.js +191 -0
- package/server/dist/fileVersion.d.ts +10 -0
- package/server/dist/fileVersion.js +43 -0
- package/server/dist/genesis/creative.js +28 -36
- package/server/dist/genesis/prompts.js +4 -0
- package/server/dist/genesis/savePlan.d.ts +5 -0
- package/server/dist/genesis/savePlan.js +49 -0
- package/server/dist/genesis/stages.js +4 -4
- package/server/dist/gitDiff.js +25 -5
- package/server/dist/gitSnapshots.d.ts +18 -0
- package/server/dist/gitSnapshots.js +280 -149
- package/server/dist/gitWorking.js +15 -13
- package/server/dist/github.js +5 -1
- package/server/dist/goalRun.d.ts +1 -1
- package/server/dist/goalRun.js +7 -5
- package/server/dist/handoffHistory.d.ts +26 -0
- package/server/dist/handoffHistory.js +80 -0
- package/server/dist/handoffHistoryProtocol.d.ts +59 -0
- package/server/dist/handoffHistoryProtocol.js +20 -0
- package/server/dist/handoffHistorySupport.d.ts +2 -0
- package/server/dist/handoffHistorySupport.js +11 -0
- package/server/dist/handoffHistoryTool.d.ts +29 -0
- package/server/dist/handoffHistoryTool.js +235 -0
- package/server/dist/handoffPrompts.js +6 -4
- package/server/dist/handoffReplay.d.ts +9 -0
- package/server/dist/handoffReplay.js +14 -0
- package/server/dist/handoffSeedCache.d.ts +3 -0
- package/server/dist/handoffSeedCache.js +26 -0
- package/server/dist/http/appBrowserRoutes.d.ts +3 -0
- package/server/dist/http/appBrowserRoutes.js +16 -0
- package/server/dist/http/architectureReviewRoutes.d.ts +3 -0
- package/server/dist/http/architectureReviewRoutes.js +117 -0
- package/server/dist/http/clusterRoutes.js +13 -1
- package/server/dist/http/clusterSnapshotRoutes.js +8 -3
- package/server/dist/http/connectionsRoutes.js +3 -1
- package/server/dist/http/diffRoutes.js +37 -3
- package/server/dist/http/explorerRoot.d.ts +3 -0
- package/server/dist/http/explorerRoot.js +22 -0
- package/server/dist/http/explorerRoutes.js +65 -12
- package/server/dist/http/fileRead.js +2 -3
- package/server/dist/http/fileWriteRoutes.js +4 -3
- package/server/dist/http/gitCompareRoutes.js +4 -6
- package/server/dist/http/gitDiffRoutes.js +3 -3
- package/server/dist/http/gitOpRoutes.js +3 -5
- package/server/dist/http/gitWorktreeRoutes.js +3 -3
- package/server/dist/http/handoffHistoryRoutes.d.ts +4 -0
- package/server/dist/http/handoffHistoryRoutes.js +59 -0
- package/server/dist/http/imageWriteRoutes.js +6 -2
- package/server/dist/http/knowledgeRoutes.js +2 -0
- package/server/dist/http/mediaOpsRoutes.js +2 -3
- package/server/dist/http/originGuard.d.ts +1 -1
- package/server/dist/http/originGuard.js +95 -12
- package/server/dist/http/outputRoutes.js +31 -6
- package/server/dist/http/projectBinding.d.ts +3 -0
- package/server/dist/http/projectBinding.js +133 -0
- package/server/dist/http/providerThrottleRoutes.d.ts +8 -0
- package/server/dist/http/providerThrottleRoutes.js +96 -0
- package/server/dist/http/publicProjectRoutes.js +50 -9
- package/server/dist/http/readConfinement.d.ts +2 -1
- package/server/dist/http/readConfinement.js +17 -15
- package/server/dist/http/router.js +224 -62
- package/server/dist/http/searchRoutes.js +4 -4
- package/server/dist/http/sessionTransport.d.ts +2 -0
- package/server/dist/http/sessionTransport.js +32 -0
- package/server/dist/http/skillManagementRoutes.d.ts +5 -0
- package/server/dist/http/skillManagementRoutes.js +166 -0
- package/server/dist/http/storageRoutes.js +20 -6
- package/server/dist/http/utilityAgentRoutes.js +27 -5
- package/server/dist/http/workflowDataRoutes.js +76 -15
- package/server/dist/http/writeConfinement.d.ts +5 -3
- package/server/dist/http/writeConfinement.js +37 -11
- package/server/dist/http/wsAuth.d.ts +3 -2
- package/server/dist/http/wsAuth.js +26 -8
- package/server/dist/imageTokens.d.ts +7 -0
- package/server/dist/imageTokens.js +85 -0
- package/server/dist/index.js +288 -179
- package/server/dist/inputDeliveryHistory.d.ts +21 -0
- package/server/dist/inputDeliveryHistory.js +146 -0
- package/server/dist/keepStore.d.ts +4 -0
- package/server/dist/keepStore.js +48 -0
- package/server/dist/knowledge/store.js +28 -20
- package/server/dist/legacyTarRestore.d.ts +1 -0
- package/server/dist/legacyTarRestore.js +240 -0
- package/server/dist/llamacppCatalog.d.ts +8 -1
- package/server/dist/llamacppCatalog.js +65 -13
- package/server/dist/localRuntimeStatus.d.ts +35 -0
- package/server/dist/localRuntimeStatus.js +136 -0
- package/server/dist/lsp/client.js +28 -9
- package/server/dist/lsp/servers.js +2 -2
- package/server/dist/managedPath.d.ts +2 -0
- package/server/dist/managedPath.js +47 -0
- package/server/dist/management/hubGuard.d.ts +23 -0
- package/server/dist/management/hubGuard.js +118 -0
- package/server/dist/management/hubLink.d.ts +4 -1
- package/server/dist/management/hubLink.js +8 -1
- package/server/dist/management/initHubLink.d.ts +12 -0
- package/server/dist/management/initHubLink.js +44 -22
- package/server/dist/manualCompactCapability.d.ts +2 -0
- package/server/dist/manualCompactCapability.js +7 -0
- package/server/dist/mcp/arcoMcpServer.js +4 -0
- package/server/dist/mcp/client.d.ts +4 -4
- package/server/dist/mcp/client.js +31 -10
- package/server/dist/mcp/clusterMcpLoopback.d.ts +4 -0
- package/server/dist/mcp/clusterMcpLoopback.js +21 -1
- package/server/dist/mcp/clusterMcpTools.js +25 -26
- package/server/dist/mcp/fileContent.d.ts +8 -0
- package/server/dist/mcp/fileContent.js +55 -0
- package/server/dist/mcp/fileMcpServer.d.ts +1 -0
- package/server/dist/mcp/fileMcpServer.js +13 -0
- package/server/dist/mcp/fileMcpTools.d.ts +2 -0
- package/server/dist/mcp/fileMcpTools.js +54 -0
- package/server/dist/mcp/handoffHistoryMcpTools.d.ts +3 -0
- package/server/dist/mcp/handoffHistoryMcpTools.js +27 -0
- package/server/dist/mcp/mcpConfigWriter.d.ts +5 -0
- package/server/dist/mcp/mcpConfigWriter.js +44 -12
- package/server/dist/mcp/planMcpTools.d.ts +6 -14
- package/server/dist/mcp/planMcpTools.js +6 -250
- package/server/dist/mcp/planReadMcpServer.d.ts +1 -0
- package/server/dist/mcp/planReadMcpServer.js +19 -0
- package/server/dist/mcp/registry.js +44 -38
- package/server/dist/mcp/registryWiring.js +4 -5
- package/server/dist/media/demucs.d.ts +5 -0
- package/server/dist/media/demucs.js +16 -4
- package/server/dist/media/ffmpeg.js +24 -16
- package/server/dist/media/scratch.js +24 -9
- package/server/dist/noticeSource.d.ts +2 -0
- package/server/dist/noticeSource.js +11 -0
- package/server/dist/notifications.d.ts +1 -0
- package/server/dist/notifications.js +7 -3
- package/server/dist/npmPlatformResolve.d.ts +9 -3
- package/server/dist/npmPlatformResolve.js +24 -5
- package/server/dist/ntfyTransport.d.ts +2 -1
- package/server/dist/ntfyTransport.js +15 -4
- package/server/dist/outputGrants.d.ts +9 -0
- package/server/dist/outputGrants.js +63 -0
- package/server/dist/outputs.js +78 -13
- package/server/dist/peerRecipientContext.js +22 -5
- package/server/dist/planStore.d.ts +11 -2
- package/server/dist/planStore.js +236 -64
- package/server/dist/planTools.d.ts +41 -0
- package/server/dist/planTools.js +259 -0
- package/server/dist/previewAutoDetect.js +31 -23
- package/server/dist/previewPortConfiguration.d.ts +2 -0
- package/server/dist/previewPortConfiguration.js +32 -0
- package/server/dist/previewPorts.d.ts +1 -0
- package/server/dist/previewPorts.js +3 -0
- package/server/dist/previewProxy.d.ts +30 -9
- package/server/dist/previewProxy.js +226 -183
- package/server/dist/primaryBackgroundTracker.d.ts +15 -2
- package/server/dist/primaryBackgroundTracker.js +172 -63
- package/server/dist/primitives/exportContext.d.ts +3 -0
- package/server/dist/primitives/exportContext.js +77 -15
- package/server/dist/primitives/localFileContext.d.ts +3 -0
- package/server/dist/primitives/localFileContext.js +38 -0
- package/server/dist/primitives/reviewContent.d.ts +2 -0
- package/server/dist/primitives/reviewContent.js +53 -6
- package/server/dist/primitives/runCompare.js +1 -1
- package/server/dist/primitives/runDocEdit.js +1 -1
- package/server/dist/primitives/runMdTuneup.d.ts +2 -1
- package/server/dist/primitives/runMdTuneup.js +20 -34
- package/server/dist/primitives/runResearch.js +1 -1
- package/server/dist/primitives/runReviewer.d.ts +2 -0
- package/server/dist/primitives/runReviewer.js +5 -2
- package/server/dist/primitives/seedWorker.d.ts +12 -2
- package/server/dist/primitives/seedWorker.js +27 -12
- package/server/dist/project/orchestrationProposals.d.ts +1 -0
- package/server/dist/project/orchestrationProposals.js +5 -1
- package/server/dist/project/taskLedger.d.ts +1 -0
- package/server/dist/project/taskLedger.js +17 -11
- package/server/dist/projectGlob.d.ts +1 -0
- package/server/dist/projectGlob.js +9 -0
- package/server/dist/projectIgnore.d.ts +1 -0
- package/server/dist/projectIgnore.js +24 -0
- package/server/dist/projectScan.d.ts +24 -0
- package/server/dist/projectScan.js +101 -0
- package/server/dist/projectStateIgnore.d.ts +13 -0
- package/server/dist/projectStateIgnore.js +36 -1
- package/server/dist/projects.d.ts +11 -3
- package/server/dist/projects.js +141 -40
- package/server/dist/prompts.js +7 -8
- package/server/dist/proportionateTestingSkill.d.ts +7 -0
- package/server/dist/proportionateTestingSkill.js +32 -0
- package/server/dist/providerConversation.d.ts +9 -0
- package/server/dist/providerConversation.js +80 -0
- package/server/dist/providers/attachmentLabels.d.ts +4 -0
- package/server/dist/providers/attachmentLabels.js +9 -0
- package/server/dist/providers/attachments.d.ts +1 -3
- package/server/dist/providers/attachments.js +58 -173
- package/server/dist/providers/claude-native/apiEndpoint.d.ts +2 -0
- package/server/dist/providers/claude-native/apiEndpoint.js +8 -0
- package/server/dist/providers/claude-native/appendOnlyPrefix.js +21 -1
- package/server/dist/providers/claude-native/catalog.js +17 -15
- package/server/dist/providers/claude-native/contentBlocks.d.ts +22 -2
- package/server/dist/providers/claude-native/contentBlocks.js +31 -8
- package/server/dist/providers/claude-native/contextBudget.d.ts +0 -4
- package/server/dist/providers/claude-native/contextBudget.js +0 -2
- package/server/dist/providers/claude-native/editApply.js +6 -1
- package/server/dist/providers/claude-native/fileContent.d.ts +15 -0
- package/server/dist/providers/claude-native/fileContent.js +120 -0
- package/server/dist/providers/claude-native/filterConfigs/bash-cargo-test.js +2 -0
- package/server/dist/providers/claude-native/filterConfigs/bash-jest-vitest.js +2 -0
- package/server/dist/providers/claude-native/filterConfigs/bash-pytest.js +2 -0
- package/server/dist/providers/claude-native/filterConfigs/index.js +2 -1
- package/server/dist/providers/claude-native/foldDigest.js +10 -2
- package/server/dist/providers/claude-native/gateReview.d.ts +1 -1
- package/server/dist/providers/claude-native/gateReview.js +0 -0
- package/server/dist/providers/claude-native/hookIf.d.ts +28 -0
- package/server/dist/providers/claude-native/hookIf.js +590 -0
- package/server/dist/providers/claude-native/hooks.d.ts +77 -7
- package/server/dist/providers/claude-native/hooks.js +344 -52
- package/server/dist/providers/claude-native/imageRead.d.ts +15 -0
- package/server/dist/providers/claude-native/imageRead.js +108 -0
- package/server/dist/providers/claude-native/index.d.ts +4 -1
- package/server/dist/providers/claude-native/index.js +32 -2
- package/server/dist/providers/claude-native/mediaLimits.d.ts +6 -0
- package/server/dist/providers/claude-native/mediaLimits.js +15 -0
- package/server/dist/providers/claude-native/mediaRetention.d.ts +11 -0
- package/server/dist/providers/claude-native/mediaRetention.js +66 -0
- package/server/dist/providers/claude-native/mediaRetirementNotice.d.ts +1 -0
- package/server/dist/providers/claude-native/mediaRetirementNotice.js +12 -0
- package/server/dist/providers/claude-native/modelParams.d.ts +6 -0
- package/server/dist/providers/claude-native/modelParams.js +21 -3
- package/server/dist/providers/claude-native/oauth.js +9 -8
- package/server/dist/providers/claude-native/outputAccumulator.d.ts +2 -0
- package/server/dist/providers/claude-native/outputAccumulator.js +29 -18
- package/server/dist/providers/claude-native/peerTools.js +3 -158
- package/server/dist/providers/claude-native/pretoolGuards.js +92 -9
- package/server/dist/providers/claude-native/registryTools.js +4 -2
- package/server/dist/providers/claude-native/resumeSummary.d.ts +23 -2
- package/server/dist/providers/claude-native/resumeSummary.js +135 -28
- package/server/dist/providers/claude-native/retainedContext.d.ts +4 -0
- package/server/dist/providers/claude-native/retainedContext.js +20 -0
- package/server/dist/providers/claude-native/sandboxExecutor.js +26 -19
- package/server/dist/providers/claude-native/taskAdmission.d.ts +21 -0
- package/server/dist/providers/claude-native/taskAdmission.js +75 -0
- package/server/dist/providers/claude-native/toolChecks.d.ts +38 -0
- package/server/dist/providers/claude-native/toolChecks.js +96 -0
- package/server/dist/providers/claude-native/toolPosture.js +5 -3
- package/server/dist/providers/claude-native/toolResultEviction.d.ts +4 -3
- package/server/dist/providers/claude-native/toolResultEviction.js +18 -29
- package/server/dist/providers/claude-native/tools.d.ts +17 -4
- package/server/dist/providers/claude-native/tools.js +248 -135
- package/server/dist/providers/claude-native/usageContext.d.ts +30 -0
- package/server/dist/providers/claude-native/usageContext.js +70 -0
- package/server/dist/providers/claude-native/wireFingerprint.d.ts +2 -2
- package/server/dist/providers/claude-native/wireFingerprint.js +2 -2
- package/server/dist/providers/claude-native/worker.d.ts +64 -1
- package/server/dist/providers/claude-native/worker.js +1137 -330
- package/server/dist/providers/claude-native/workerHelpers.d.ts +13 -0
- package/server/dist/providers/claude-native/workerHelpers.js +117 -6
- package/server/dist/providers/claude-native/workspaceFacts.js +2 -2
- package/server/dist/providers/claude.d.ts +1 -0
- package/server/dist/providers/claude.js +69 -85
- package/server/dist/providers/clusterTaskToolDefinitions.d.ts +11 -0
- package/server/dist/providers/clusterTaskToolDefinitions.js +161 -0
- package/server/dist/providers/codex-appserver/catalog.js +26 -20
- package/server/dist/providers/codex-appserver/index.js +10 -3
- package/server/dist/providers/codex-appserver/jsonRpc.d.ts +2 -1
- package/server/dist/providers/codex-appserver/jsonRpc.js +11 -3
- package/server/dist/providers/codex-appserver/operatorQuestions.d.ts +5 -0
- package/server/dist/providers/codex-appserver/operatorQuestions.js +30 -0
- package/server/dist/providers/codex-appserver/worker.d.ts +5 -0
- package/server/dist/providers/codex-appserver/worker.js +128 -85
- package/server/dist/providers/codex.js +55 -58
- package/server/dist/providers/codexChatBoundary.d.ts +11 -0
- package/server/dist/providers/codexChatBoundary.js +60 -0
- package/server/dist/providers/codexCodeMode.js +2 -2
- package/server/dist/providers/codexContextWindow.js +2 -2
- package/server/dist/providers/codexHome.d.ts +1 -0
- package/server/dist/providers/codexHome.js +6 -0
- package/server/dist/providers/codexImageTool.d.ts +6 -0
- package/server/dist/providers/codexImageTool.js +21 -0
- package/server/dist/providers/codexVersion.d.ts +1 -0
- package/server/dist/providers/codexVersion.js +14 -0
- package/server/dist/providers/codexWebSearch.d.ts +2 -0
- package/server/dist/providers/codexWebSearch.js +4 -0
- package/server/dist/providers/cursor/acpJsonRpc.d.ts +1 -0
- package/server/dist/providers/cursor/acpJsonRpc.js +3 -1
- package/server/dist/providers/cursor/authState.d.ts +10 -0
- package/server/dist/providers/cursor/authState.js +78 -0
- package/server/dist/providers/cursor/catalog.js +22 -14
- package/server/dist/providers/cursor/chatSandbox.d.ts +11 -0
- package/server/dist/providers/cursor/chatSandbox.js +81 -0
- package/server/dist/providers/cursor/filePlugin.d.ts +4 -0
- package/server/dist/providers/cursor/filePlugin.js +31 -0
- package/server/dist/providers/cursor/index.d.ts +1 -0
- package/server/dist/providers/cursor/index.js +30 -4
- package/server/dist/providers/cursor/modelMap.d.ts +35 -0
- package/server/dist/providers/cursor/modelMap.js +180 -0
- package/server/dist/providers/cursor/print.js +95 -30
- package/server/dist/providers/cursor/worker.d.ts +4 -1
- package/server/dist/providers/cursor/worker.js +169 -89
- package/server/dist/providers/errorClassifier.js +6 -2
- package/server/dist/providers/handoffHistoryBinding.d.ts +11 -0
- package/server/dist/providers/handoffHistoryBinding.js +43 -0
- package/server/dist/providers/index.d.ts +1 -1
- package/server/dist/providers/index.js +10 -5
- package/server/dist/providers/llamacpp.d.ts +1 -0
- package/server/dist/providers/llamacpp.js +102 -192
- package/server/dist/providers/llamacppManager.d.ts +5 -0
- package/server/dist/providers/llamacppManager.js +68 -32
- package/server/dist/providers/llamacppVersion.d.ts +1 -0
- package/server/dist/providers/llamacppVersion.js +5 -0
- package/server/dist/providers/lmstudio.d.ts +3 -3
- package/server/dist/providers/lmstudio.js +133 -207
- package/server/dist/providers/localFileMedia.d.ts +25 -0
- package/server/dist/providers/localFileMedia.js +302 -0
- package/server/dist/providers/localMcp.d.ts +17 -0
- package/server/dist/providers/localMcp.js +85 -0
- package/server/dist/providers/localShellLifecycle.d.ts +7 -0
- package/server/dist/providers/localShellLifecycle.js +33 -0
- package/server/dist/providers/localToolDispatch.d.ts +28 -0
- package/server/dist/providers/localToolDispatch.js +90 -0
- package/server/dist/providers/ollama.d.ts +2 -1
- package/server/dist/providers/ollama.js +182 -184
- package/server/dist/providers/ollamaDurableCompaction.js +5 -4
- package/server/dist/providers/ollamaExecutionHistory.d.ts +1 -1
- package/server/dist/providers/ollamaExecutionHistory.js +55 -14
- package/server/dist/providers/ollamaFencedTools.js +10 -11
- package/server/dist/providers/ollamaResilience.js +9 -13
- package/server/dist/providers/ollamaTokens.js +3 -4
- package/server/dist/providers/ollamaToolSubset.d.ts +2 -0
- package/server/dist/providers/ollamaToolSubset.js +11 -40
- package/server/dist/providers/ollamaTools.d.ts +13 -0
- package/server/dist/providers/ollamaTools.js +225 -219
- package/server/dist/providers/outputStyle.d.ts +2 -1
- package/server/dist/providers/outputStyle.js +70 -76
- package/server/dist/providers/providerFileContent.d.ts +40 -0
- package/server/dist/providers/providerFileContent.js +151 -0
- package/server/dist/providers/renderedTranscript.d.ts +1 -0
- package/server/dist/providers/renderedTranscript.js +3 -0
- package/server/dist/providers/requestDeadline.d.ts +1 -0
- package/server/dist/providers/requestDeadline.js +26 -0
- package/server/dist/providers/sessionScope.d.ts +2 -0
- package/server/dist/providers/sessionScope.js +8 -0
- package/server/dist/providers/types.d.ts +1 -0
- package/server/dist/publicProject.d.ts +10 -2
- package/server/dist/publicProject.js +59 -13
- package/server/dist/publicProjectChoice.d.ts +4 -0
- package/server/dist/publicProjectChoice.js +46 -0
- package/server/dist/quota.d.ts +10 -7
- package/server/dist/quota.js +49 -19
- package/server/dist/recall/search.js +9 -32
- package/server/dist/recall/transcriptSearch.d.ts +4 -0
- package/server/dist/recall/transcriptSearch.js +29 -0
- package/server/dist/recentFilesLedger.js +9 -7
- package/server/dist/recentProjectActivity.d.ts +11 -0
- package/server/dist/recentProjectActivity.js +69 -0
- package/server/dist/scanDeadline.d.ts +4 -0
- package/server/dist/scanDeadline.js +48 -0
- package/server/dist/searchText.d.ts +1 -0
- package/server/dist/searchText.js +22 -0
- package/server/dist/server/broadcast.d.ts +2 -2
- package/server/dist/server/broadcast.js +130 -58
- package/server/dist/sessionJsonl.js +45 -19
- package/server/dist/settings.d.ts +6 -1
- package/server/dist/settings.js +183 -56
- package/server/dist/skillManagement.d.ts +125 -0
- package/server/dist/skillManagement.js +709 -0
- package/server/dist/skillMutation.d.ts +1 -0
- package/server/dist/skillMutation.js +6 -0
- package/server/dist/skills.d.ts +75 -1
- package/server/dist/skills.js +254 -75
- package/server/dist/smartPickup.d.ts +1 -0
- package/server/dist/smartPickup.js +2 -1
- package/server/dist/smartPickupAdapters.d.ts +2 -0
- package/server/dist/smartPickupAdapters.js +49 -13
- package/server/dist/smartPickupObserver.js +45 -8
- package/server/dist/storageActions.d.ts +2 -2
- package/server/dist/storageArchive.js +55 -24
- package/server/dist/storageRoot.d.ts +5 -0
- package/server/dist/storageRoot.js +38 -0
- package/server/dist/storageTurnWatch.d.ts +6 -0
- package/server/dist/storageTurnWatch.js +36 -0
- package/server/dist/taskDispatcher.js +69 -41
- package/server/dist/templates/store.js +75 -59
- package/server/dist/terminal/ptyManager.d.ts +3 -1
- package/server/dist/terminal/ptyManager.js +44 -37
- package/server/dist/terminal/ptyPidRegistry.d.ts +4 -2
- package/server/dist/terminal/ptyPidRegistry.js +9 -63
- package/server/dist/thirdPartySkills.d.ts +4 -0
- package/server/dist/thirdPartySkills.js +80 -0
- package/server/dist/toolPath.d.ts +1 -0
- package/server/dist/toolPath.js +38 -0
- package/server/dist/toolboxWorkflow.js +2 -1
- package/server/dist/uploadImages.d.ts +6 -0
- package/server/dist/uploadImages.js +155 -0
- package/server/dist/voice/computerContext.js +2 -0
- package/server/dist/voice/conditionSchema.d.ts +1 -0
- package/server/dist/voice/conditionSchema.js +3 -1
- package/server/dist/voice/conditions.js +1 -1
- package/server/dist/workers/StreamParser.d.ts +3 -0
- package/server/dist/workers/StreamParser.js +45 -11
- package/server/dist/workers/WorkerManager.d.ts +10 -2
- package/server/dist/workers/WorkerManager.js +19 -18
- package/server/dist/workers/durablePidRegistry.d.ts +53 -0
- package/server/dist/workers/durablePidRegistry.js +289 -0
- package/server/dist/workers/limits.js +7 -3
- package/server/dist/workers/pidRegistry.d.ts +6 -9
- package/server/dist/workers/pidRegistry.js +13 -101
- package/server/dist/workers/processActivity.d.ts +6 -0
- package/server/dist/workers/processActivity.js +13 -0
- package/server/dist/workers/processKill.d.ts +30 -0
- package/server/dist/workers/processKill.js +174 -0
- package/server/dist/workers/processStartTime.d.ts +21 -5
- package/server/dist/workers/processStartTime.js +127 -50
- package/server/dist/workflowMeta.d.ts +26 -13
- package/server/dist/workflowMeta.js +173 -15
- package/server/dist/workflowStore.d.ts +1 -0
- package/server/dist/workflowStore.js +194 -23
- package/server/dist/workflows/modelTitles.js +4 -3
- package/server/dist/workflows/sessionIndex.d.ts +2 -0
- package/server/dist/workflows/sessionIndex.js +24 -2
- package/server/dist/workflows/types.d.ts +16 -5
- package/server/dist/workspace.d.ts +1 -0
- package/server/dist/workspace.js +5 -0
- package/server/dist/ws/afterTurn.d.ts +9 -0
- package/server/dist/ws/afterTurn.js +25 -0
- package/server/dist/ws/clusterHandlers.d.ts +7 -2
- package/server/dist/ws/clusterHandlers.js +361 -407
- package/server/dist/ws/clusterMembers.d.ts +42 -0
- package/server/dist/ws/clusterMembers.js +165 -0
- package/server/dist/ws/compactHandlers.d.ts +1 -1
- package/server/dist/ws/compactHandlers.js +49 -32
- package/server/dist/ws/gateHandlers.js +2 -1
- package/server/dist/ws/genesisHandlers.js +171 -116
- package/server/dist/ws/handoffHandlers.d.ts +3 -1
- package/server/dist/ws/handoffHandlers.js +380 -199
- package/server/dist/ws/operatorQuestionHandlers.d.ts +2 -1
- package/server/dist/ws/operatorQuestionHandlers.js +9 -1
- package/server/dist/ws/previewCaptureHandlers.js +1 -4
- package/server/dist/ws/taskLedgerHandlers.d.ts +6 -1
- package/server/dist/ws/taskLedgerHandlers.js +28 -12
- package/server/dist/ws/taskLifecycle.d.ts +15 -0
- package/server/dist/ws/taskLifecycle.js +39 -0
- package/server/dist/ws/turnEngine.d.ts +29 -12
- package/server/dist/ws/turnEngine.js +1860 -1748
- package/server/dist/ws/turnPrompt.d.ts +17 -0
- package/server/dist/ws/turnPrompt.js +47 -0
- package/server/dist/ws/turnSettings.d.ts +41 -0
- package/server/dist/ws/turnSettings.js +61 -0
- package/server/dist/ws/updatePrimaryConfig.js +63 -40
- package/server/dist/ws/workflowHandlers.d.ts +2 -1
- package/server/dist/ws/workflowHandlers.js +220 -180
- package/server/package.json +1 -1
- package/server/src/appBrowsers.ts +95 -0
- package/server/src/architectureReview.ts +327 -0
- package/server/src/architectureSkill.ts +71 -0
- package/server/src/arcoHome.ts +42 -3
- package/server/src/artifactCopy.ts +90 -24
- package/server/src/atomicFile.ts +6 -1
- package/server/src/attention.ts +29 -21
- package/server/src/auth.ts +20 -6
- package/server/src/authLoginSession.ts +7 -2
- package/server/src/boundedRead.ts +172 -0
- package/server/src/capabilities.ts +81 -105
- package/server/src/catchUp.ts +19 -2
- package/server/src/checkedFile.ts +90 -0
- package/server/src/claudeTransport.ts +14 -0
- package/server/src/cliUpdateDecision.ts +159 -0
- package/server/src/clusterAutoTurn.ts +55 -7
- package/server/src/clusterBusyReminder.ts +45 -0
- package/server/src/clusterDirector.ts +7 -3
- package/server/src/clusterIdleNudger.ts +6 -0
- package/server/src/clusterMailbox.ts +96 -26
- package/server/src/clusterPeerOps.ts +8 -21
- package/server/src/clusterPlanBridge.ts +37 -45
- package/server/src/clusterPresets.ts +44 -31
- package/server/src/clusterProgress.ts +3 -0
- package/server/src/clusterSnapshots.ts +16 -2
- package/server/src/clusterStore.ts +25 -14
- package/server/src/clusterTurnTools.ts +11 -0
- package/server/src/commandShell.ts +287 -0
- package/server/src/compactionCounter.ts +69 -0
- package/server/src/compactionReport.ts +20 -0
- package/server/src/contentSearch.ts +8 -3
- package/server/src/contextCalibrator.ts +6 -1
- package/server/src/contextEstimator.ts +71 -16
- package/server/src/contextRefs.ts +41 -11
- package/server/src/conversationActivity.ts +26 -0
- package/server/src/cursorUsage.ts +13 -3
- package/server/src/defaults/models.md +1 -1
- package/server/src/diagnostics/checks.ts +4 -11
- package/server/src/diagnostics/executableLookup.ts +20 -0
- package/server/src/diagnostics/modelHealth.ts +3 -11
- package/server/src/diagnostics/supportBundle.ts +5 -13
- package/server/src/eventLog.ts +228 -81
- package/server/src/existingClusterMembers.ts +9 -0
- package/server/src/explorerArtifacts.ts +27 -10
- package/server/src/explorerChanged.ts +99 -67
- package/server/src/explorerDocs.ts +37 -31
- package/server/src/explorerLaunch.ts +10 -2
- package/server/src/fileAccessPolicy.ts +88 -5
- package/server/src/fileContent/decodeSlots.ts +31 -0
- package/server/src/fileContent/detect.ts +28 -0
- package/server/src/fileContent/externalImage.ts +49 -0
- package/server/src/fileContent/icons.ts +37 -0
- package/server/src/fileContent/images.ts +140 -0
- package/server/src/fileContent/legacyText.ts +16 -0
- package/server/src/fileContent/notebook.ts +37 -0
- package/server/src/fileContent/office.ts +234 -0
- package/server/src/fileContent/pdf.ts +59 -0
- package/server/src/fileContent/pngRows.ts +54 -0
- package/server/src/fileContent/svg.ts +42 -0
- package/server/src/fileContent/types.ts +39 -0
- package/server/src/fileContent/worker.ts +43 -0
- package/server/src/fileContent.ts +108 -0
- package/server/src/fileContextReceipts.ts +44 -0
- package/server/src/fileFetch.ts +167 -0
- package/server/src/fileVersion.ts +36 -0
- package/server/src/genesis/creative.ts +27 -33
- package/server/src/genesis/prompts.ts +3 -0
- package/server/src/genesis/savePlan.ts +45 -0
- package/server/src/genesis/stages.ts +4 -4
- package/server/src/gitDiff.ts +20 -5
- package/server/src/gitSnapshots.ts +288 -191
- package/server/src/gitWorking.ts +11 -11
- package/server/src/github.ts +3 -1
- package/server/src/goalRun.ts +7 -4
- package/server/src/handoffHistory.ts +89 -0
- package/server/src/handoffHistoryProtocol.ts +20 -0
- package/server/src/handoffHistorySupport.ts +10 -0
- package/server/src/handoffHistoryTool.ts +192 -0
- package/server/src/handoffPrompts.ts +6 -4
- package/server/src/handoffReplay.ts +20 -0
- package/server/src/handoffSeedCache.ts +22 -0
- package/server/src/http/appBrowserRoutes.ts +17 -0
- package/server/src/http/architectureReviewRoutes.ts +86 -0
- package/server/src/http/clusterRoutes.ts +13 -1
- package/server/src/http/clusterSnapshotRoutes.ts +8 -3
- package/server/src/http/connectionsRoutes.ts +5 -1
- package/server/src/http/diffRoutes.ts +36 -3
- package/server/src/http/explorerRoot.ts +20 -0
- package/server/src/http/explorerRoutes.ts +59 -12
- package/server/src/http/fileRead.ts +2 -1
- package/server/src/http/fileWriteRoutes.ts +3 -2
- package/server/src/http/gitCompareRoutes.ts +4 -5
- package/server/src/http/gitDiffRoutes.ts +3 -2
- package/server/src/http/gitOpRoutes.ts +3 -4
- package/server/src/http/gitWorktreeRoutes.ts +3 -2
- package/server/src/http/handoffHistoryRoutes.ts +42 -0
- package/server/src/http/imageWriteRoutes.ts +5 -1
- package/server/src/http/knowledgeRoutes.ts +2 -0
- package/server/src/http/mediaOpsRoutes.ts +2 -1
- package/server/src/http/originGuard.ts +71 -14
- package/server/src/http/outputRoutes.ts +26 -5
- package/server/src/http/projectBinding.ts +108 -0
- package/server/src/http/providerThrottleRoutes.ts +76 -0
- package/server/src/http/publicProjectRoutes.ts +40 -8
- package/server/src/http/readConfinement.ts +16 -9
- package/server/src/http/router.ts +173 -60
- package/server/src/http/searchRoutes.ts +4 -4
- package/server/src/http/sessionTransport.ts +27 -0
- package/server/src/http/skillManagementRoutes.ts +120 -0
- package/server/src/http/storageRoutes.ts +19 -6
- package/server/src/http/utilityAgentRoutes.ts +19 -5
- package/server/src/http/workflowDataRoutes.ts +69 -17
- package/server/src/http/writeConfinement.ts +31 -12
- package/server/src/http/wsAuth.ts +27 -9
- package/server/src/imageTokens.ts +60 -0
- package/server/src/index.ts +270 -179
- package/server/src/inputDeliveryHistory.ts +122 -0
- package/server/src/keepStore.ts +37 -0
- package/server/src/knowledge/store.ts +27 -19
- package/server/src/legacyTarRestore.ts +177 -0
- package/server/src/llamacppCatalog.ts +47 -12
- package/server/src/localRuntimeStatus.ts +121 -0
- package/server/src/lsp/client.ts +19 -11
- package/server/src/lsp/servers.ts +2 -2
- package/server/src/managedPath.ts +38 -0
- package/server/src/management/hubGuard.ts +135 -0
- package/server/src/management/hubLink.ts +8 -2
- package/server/src/management/initHubLink.ts +45 -37
- package/server/src/manualCompactCapability.ts +8 -0
- package/server/src/mcp/arcoMcpServer.ts +4 -0
- package/server/src/mcp/client.ts +28 -11
- package/server/src/mcp/clusterMcpLoopback.ts +27 -1
- package/server/src/mcp/clusterMcpTools.ts +24 -25
- package/server/src/mcp/fileContent.ts +34 -0
- package/server/src/mcp/fileMcpServer.ts +12 -0
- package/server/src/mcp/fileMcpTools.ts +51 -0
- package/server/src/mcp/handoffHistoryMcpTools.ts +21 -0
- package/server/src/mcp/mcpConfigWriter.ts +43 -12
- package/server/src/mcp/planMcpTools.ts +9 -285
- package/server/src/mcp/planReadMcpServer.ts +19 -0
- package/server/src/mcp/registry.ts +41 -35
- package/server/src/mcp/registryWiring.ts +4 -5
- package/server/src/media/demucs.ts +11 -4
- package/server/src/media/ffmpeg.ts +21 -16
- package/server/src/media/scratch.ts +17 -10
- package/server/src/noticeSource.ts +11 -0
- package/server/src/notifications.ts +8 -4
- package/server/src/npmPlatformResolve.ts +25 -8
- package/server/src/ntfyTransport.ts +12 -4
- package/server/src/outputGrants.ts +53 -0
- package/server/src/outputs.ts +54 -11
- package/server/src/peerRecipientContext.ts +16 -5
- package/server/src/planStore.ts +201 -55
- package/server/src/planTools.ts +303 -0
- package/server/src/previewAutoDetect.ts +26 -19
- package/server/src/previewPortConfiguration.ts +28 -0
- package/server/src/previewPorts.ts +2 -0
- package/server/src/previewProxy.ts +156 -189
- package/server/src/primaryBackgroundTracker.ts +151 -61
- package/server/src/primitives/exportContext.ts +67 -16
- package/server/src/primitives/localFileContext.ts +31 -0
- package/server/src/primitives/reviewContent.ts +42 -7
- package/server/src/primitives/runCompare.ts +1 -1
- package/server/src/primitives/runDocEdit.ts +1 -1
- package/server/src/primitives/runMdTuneup.ts +17 -27
- package/server/src/primitives/runResearch.ts +1 -1
- package/server/src/primitives/runReviewer.ts +6 -2
- package/server/src/primitives/seedWorker.ts +38 -17
- package/server/src/project/orchestrationProposals.ts +6 -1
- package/server/src/project/taskLedger.ts +17 -11
- package/server/src/projectGlob.ts +9 -0
- package/server/src/projectIgnore.ts +19 -0
- package/server/src/projectScan.ts +76 -0
- package/server/src/projectStateIgnore.ts +40 -1
- package/server/src/projects.ts +114 -36
- package/server/src/prompts.ts +5 -8
- package/server/src/proportionateTestingSkill.ts +31 -0
- package/server/src/providerConversation.ts +71 -0
- package/server/src/providers/attachmentLabels.ts +8 -0
- package/server/src/providers/attachments.ts +52 -174
- package/server/src/providers/claude-native/apiEndpoint.ts +9 -0
- package/server/src/providers/claude-native/appendOnlyPrefix.ts +17 -1
- package/server/src/providers/claude-native/catalog.ts +16 -14
- package/server/src/providers/claude-native/contentBlocks.ts +39 -8
- package/server/src/providers/claude-native/contextBudget.ts +0 -6
- package/server/src/providers/claude-native/editApply.ts +6 -1
- package/server/src/providers/claude-native/fileContent.ts +98 -0
- package/server/src/providers/claude-native/filterConfigs/bash-cargo-test.ts +1 -0
- package/server/src/providers/claude-native/filterConfigs/bash-jest-vitest.ts +1 -0
- package/server/src/providers/claude-native/filterConfigs/bash-pytest.ts +1 -0
- package/server/src/providers/claude-native/filterConfigs/index.ts +2 -1
- package/server/src/providers/claude-native/foldDigest.ts +9 -2
- package/server/src/providers/claude-native/gateReview.ts +0 -0
- package/server/src/providers/claude-native/hookIf.ts +414 -0
- package/server/src/providers/claude-native/hooks.ts +398 -54
- package/server/src/providers/claude-native/imageRead.ts +92 -0
- package/server/src/providers/claude-native/index.ts +32 -1
- package/server/src/providers/claude-native/mediaLimits.ts +14 -0
- package/server/src/providers/claude-native/mediaRetention.ts +49 -0
- package/server/src/providers/claude-native/mediaRetirementNotice.ts +8 -0
- package/server/src/providers/claude-native/modelParams.ts +23 -2
- package/server/src/providers/claude-native/oauth.ts +9 -8
- package/server/src/providers/claude-native/outputAccumulator.ts +29 -17
- package/server/src/providers/claude-native/peerTools.ts +3 -169
- package/server/src/providers/claude-native/pretoolGuards.ts +76 -9
- package/server/src/providers/claude-native/registryTools.ts +4 -2
- package/server/src/providers/claude-native/resumeSummary.ts +138 -28
- package/server/src/providers/claude-native/retainedContext.ts +22 -0
- package/server/src/providers/claude-native/sandboxExecutor.ts +24 -16
- package/server/src/providers/claude-native/taskAdmission.ts +62 -0
- package/server/src/providers/claude-native/toolChecks.ts +127 -0
- package/server/src/providers/claude-native/toolPosture.ts +5 -3
- package/server/src/providers/claude-native/toolResultEviction.ts +17 -7
- package/server/src/providers/claude-native/tools.ts +228 -130
- package/server/src/providers/claude-native/usageContext.ts +93 -0
- package/server/src/providers/claude-native/wireFingerprint.ts +2 -2
- package/server/src/providers/claude-native/worker.ts +1089 -339
- package/server/src/providers/claude-native/workerHelpers.ts +133 -6
- package/server/src/providers/claude-native/workspaceFacts.ts +2 -2
- package/server/src/providers/claude.ts +65 -93
- package/server/src/providers/clusterTaskToolDefinitions.ts +180 -0
- package/server/src/providers/codex-appserver/catalog.ts +26 -19
- package/server/src/providers/codex-appserver/index.ts +8 -3
- package/server/src/providers/codex-appserver/jsonRpc.ts +9 -2
- package/server/src/providers/codex-appserver/operatorQuestions.ts +24 -0
- package/server/src/providers/codex-appserver/worker.ts +116 -81
- package/server/src/providers/codex.ts +49 -57
- package/server/src/providers/codexChatBoundary.ts +55 -0
- package/server/src/providers/codexCodeMode.ts +2 -2
- package/server/src/providers/codexContextWindow.ts +2 -2
- package/server/src/providers/codexHome.ts +6 -0
- package/server/src/providers/codexImageTool.ts +22 -0
- package/server/src/providers/codexVersion.ts +13 -0
- package/server/src/providers/codexWebSearch.ts +5 -0
- package/server/src/providers/cursor/acpJsonRpc.ts +3 -1
- package/server/src/providers/cursor/authState.ts +72 -0
- package/server/src/providers/cursor/catalog.ts +20 -13
- package/server/src/providers/cursor/chatSandbox.ts +71 -0
- package/server/src/providers/cursor/filePlugin.ts +27 -0
- package/server/src/providers/cursor/index.ts +29 -4
- package/server/src/providers/cursor/modelMap.ts +182 -0
- package/server/src/providers/cursor/print.ts +80 -27
- package/server/src/providers/cursor/worker.ts +156 -84
- package/server/src/providers/errorClassifier.ts +7 -2
- package/server/src/providers/handoffHistoryBinding.ts +40 -0
- package/server/src/providers/index.ts +12 -6
- package/server/src/providers/llamacpp.ts +93 -176
- package/server/src/providers/llamacppManager.ts +62 -33
- package/server/src/providers/llamacppVersion.ts +4 -0
- package/server/src/providers/lmstudio.ts +124 -190
- package/server/src/providers/localFileMedia.ts +229 -0
- package/server/src/providers/localMcp.ts +76 -0
- package/server/src/providers/localShellLifecycle.ts +30 -0
- package/server/src/providers/localToolDispatch.ts +111 -0
- package/server/src/providers/ollama.ts +163 -174
- package/server/src/providers/ollamaCtxFallback.ts +1 -2
- package/server/src/providers/ollamaDurableCompaction.ts +5 -4
- package/server/src/providers/ollamaExecutionHistory.ts +40 -13
- package/server/src/providers/ollamaFencedTools.ts +10 -11
- package/server/src/providers/ollamaResilience.ts +10 -13
- package/server/src/providers/ollamaTokens.ts +4 -7
- package/server/src/providers/ollamaToolSubset.ts +14 -2
- package/server/src/providers/ollamaTools.ts +212 -200
- package/server/src/providers/outputStyle.ts +72 -72
- package/server/src/providers/providerFileContent.ts +133 -0
- package/server/src/providers/renderedTranscript.ts +2 -0
- package/server/src/providers/requestDeadline.ts +27 -0
- package/server/src/providers/sessionScope.ts +9 -0
- package/server/src/providers/types.ts +3 -0
- package/server/src/publicProject.ts +54 -13
- package/server/src/publicProjectChoice.ts +39 -0
- package/server/src/quota.ts +48 -23
- package/server/src/recall/search.ts +9 -32
- package/server/src/recall/transcriptSearch.ts +27 -0
- package/server/src/recentFilesLedger.ts +10 -8
- package/server/src/recentProjectActivity.ts +56 -0
- package/server/src/scanDeadline.ts +26 -0
- package/server/src/searchText.ts +16 -0
- package/server/src/server/broadcast.ts +120 -54
- package/server/src/sessionJsonl.ts +31 -17
- package/server/src/settings.ts +137 -41
- package/server/src/skillManagement.ts +585 -0
- package/server/src/skillMutation.ts +6 -0
- package/server/src/skills.ts +195 -25
- package/server/src/smartPickup.ts +3 -2
- package/server/src/smartPickupAdapters.ts +50 -15
- package/server/src/smartPickupObserver.ts +31 -6
- package/server/src/storageActions.ts +1 -1
- package/server/src/storageArchive.ts +42 -22
- package/server/src/storageRoot.ts +30 -0
- package/server/src/storageTurnWatch.ts +39 -0
- package/server/src/taskDispatcher.ts +22 -2
- package/server/src/templates/store.ts +72 -57
- package/server/src/terminal/ptyManager.ts +37 -27
- package/server/src/terminal/ptyPidRegistry.ts +10 -58
- package/server/src/thirdPartySkills.ts +79 -0
- package/server/src/toolPath.ts +31 -0
- package/server/src/toolboxWorkflow.ts +2 -1
- package/server/src/uploadImages.ts +124 -0
- package/server/src/voice/computerContext.ts +2 -1
- package/server/src/voice/conditionSchema.ts +3 -1
- package/server/src/voice/conditions.ts +1 -1
- package/server/src/workers/StreamParser.ts +42 -11
- package/server/src/workers/WorkerManager.ts +34 -35
- package/server/src/workers/durablePidRegistry.ts +266 -0
- package/server/src/workers/limits.ts +8 -3
- package/server/src/workers/pidRegistry.ts +15 -89
- package/server/src/workers/processActivity.ts +14 -0
- package/server/src/workers/processKill.ts +175 -1
- package/server/src/workers/processStartTime.ts +137 -49
- package/server/src/workflowMeta.ts +197 -23
- package/server/src/workflowStore.ts +177 -22
- package/server/src/workflows/modelTitles.ts +4 -3
- package/server/src/workflows/sessionIndex.ts +24 -3
- package/server/src/workflows/types.ts +21 -10
- package/server/src/workspace.ts +6 -0
- package/server/src/ws/afterTurn.ts +34 -0
- package/server/src/ws/clusterHandlers.ts +198 -276
- package/server/src/ws/clusterMembers.ts +204 -0
- package/server/src/ws/compactHandlers.ts +47 -14
- package/server/src/ws/gateHandlers.ts +2 -1
- package/server/src/ws/genesisHandlers.ts +49 -6
- package/server/src/ws/handoffHandlers.ts +180 -58
- package/server/src/ws/operatorQuestionHandlers.ts +10 -2
- package/server/src/ws/previewCaptureHandlers.ts +1 -4
- package/server/src/ws/taskLedgerHandlers.ts +22 -13
- package/server/src/ws/taskLifecycle.ts +41 -0
- package/server/src/ws/turnEngine.ts +557 -490
- package/server/src/ws/turnPrompt.ts +60 -0
- package/server/src/ws/turnSettings.ts +95 -0
- package/server/src/ws/updatePrimaryConfig.ts +55 -31
- package/server/src/ws/workflowHandlers.ts +187 -158
- package/shared/dist/clusterCoordination.js +15 -7
- package/shared/dist/clusterRolePresets.d.ts +1 -1
- package/shared/dist/clusterRolePresets.js +18 -6
- package/shared/dist/codexChat.d.ts +2 -0
- package/shared/dist/codexChat.js +5 -0
- package/shared/dist/folderName.d.ts +1 -0
- package/shared/dist/folderName.js +18 -0
- package/shared/dist/index.d.ts +6 -0
- package/shared/dist/index.js +6 -0
- package/shared/dist/localRuntimeStatus.d.ts +23 -0
- package/shared/dist/localRuntimeStatus.js +47 -0
- package/shared/dist/notificationTitle.d.ts +9 -0
- package/shared/dist/notificationTitle.js +23 -0
- package/shared/dist/outputStyle.d.ts +10 -0
- package/shared/dist/outputStyle.js +28 -0
- package/shared/dist/outputs.d.ts +1 -0
- package/shared/dist/protocol/autoPickup.d.ts +2 -0
- package/shared/dist/protocol/autoPickup.js +9 -1
- package/shared/dist/protocol/chat.d.ts +4 -0
- package/shared/dist/protocol/checkpoints.d.ts +24 -2
- package/shared/dist/protocol/checkpoints.js +1 -0
- package/shared/dist/protocol/clientMessages.d.ts +11 -16
- package/shared/dist/protocol/clusters.d.ts +21 -4
- package/shared/dist/protocol/clusters.js +3 -3
- package/shared/dist/protocol/connections.d.ts +2 -0
- package/shared/dist/protocol/diagnostics.js +1 -1
- package/shared/dist/protocol/genesis.d.ts +9 -0
- package/shared/dist/protocol/mcp.d.ts +1 -0
- package/shared/dist/protocol/mcp.js +8 -5
- package/shared/dist/protocol/mdTuneup.d.ts +2 -0
- package/shared/dist/protocol/models.d.ts +9 -1
- package/shared/dist/protocol/models.js +19 -8
- package/shared/dist/protocol/notifications.d.ts +6 -1
- package/shared/dist/protocol/notifications.js +15 -3
- package/shared/dist/protocol/operatorQuestions.d.ts +12 -0
- package/shared/dist/protocol/plans.d.ts +2 -1
- package/shared/dist/protocol/remoteManagement.d.ts +6 -0
- package/shared/dist/protocol/serverMessages.d.ts +77 -12
- package/shared/dist/protocol/settings.d.ts +16 -4
- package/shared/dist/protocol/settings.js +17 -1
- package/shared/dist/protocol/tasks.d.ts +1 -0
- package/shared/dist/protocol/usage.d.ts +1 -0
- package/shared/dist/protocol/workers.d.ts +1 -0
- package/shared/dist/protocol/workflows.d.ts +74 -14
- package/shared/dist/protocol/workflows.js +66 -0
- package/shared/dist/publicGuardrails.d.ts +1 -1
- package/shared/dist/publicGuardrails.js +1 -1
- package/shared/dist/runtimeVersions.d.ts +2 -0
- package/shared/dist/runtimeVersions.js +13 -0
- package/shared/dist/shellTool.d.ts +2 -0
- package/shared/dist/shellTool.js +9 -0
- package/shared/src/clusterCoordination.ts +12 -7
- package/shared/src/clusterRolePresets.ts +19 -7
- package/shared/src/codexChat.ts +8 -0
- package/shared/src/folderName.ts +11 -0
- package/shared/src/index.ts +8 -0
- package/shared/src/localRuntimeStatus.ts +53 -0
- package/shared/src/notificationTitle.ts +23 -0
- package/shared/src/outputStyle.ts +35 -0
- package/shared/src/outputs.ts +3 -0
- package/shared/src/protocol/autoPickup.ts +11 -1
- package/shared/src/protocol/chat.ts +5 -0
- package/shared/src/protocol/checkpoints.ts +40 -8
- package/shared/src/protocol/clientMessages.ts +13 -12
- package/shared/src/protocol/clusters.ts +40 -10
- package/shared/src/protocol/connections.ts +6 -0
- package/shared/src/protocol/diagnostics.ts +1 -1
- package/shared/src/protocol/genesis.ts +11 -0
- package/shared/src/protocol/mcp.ts +12 -7
- package/shared/src/protocol/mdTuneup.ts +4 -2
- package/shared/src/protocol/models.ts +27 -10
- package/shared/src/protocol/notifications.ts +21 -3
- package/shared/src/protocol/operatorQuestions.ts +13 -0
- package/shared/src/protocol/plans.ts +5 -7
- package/shared/src/protocol/remoteManagement.ts +10 -3
- package/shared/src/protocol/serverMessages.ts +100 -9
- package/shared/src/protocol/settings.ts +35 -5
- package/shared/src/protocol/tasks.ts +1 -0
- package/shared/src/protocol/usage.ts +3 -3
- package/shared/src/protocol/workers.ts +5 -0
- package/shared/src/protocol/workflows.ts +137 -21
- package/shared/src/publicGuardrails.ts +1 -1
- package/shared/src/runtimeVersions.ts +15 -0
- package/shared/src/shellTool.ts +9 -0
- package/client/dist/assets/galleryEditor-fPb76Cjv.js +0 -702
- package/client/dist/assets/index-CjkHb-_n.js +0 -592
- package/client/dist/assets/index-DIbh3ae5.css +0 -1
- package/client/src/components/ConversationMenu.tsx +0 -467
- package/client/src/stores/sessionIndexStore.ts +0 -92
|
@@ -1,7 +1,14 @@
|
|
|
1
|
+
import { ensureWorkflowMetadata, providerConversationState, saveProviderSession, announceReplacementConversation, markConversationReading } from '../providerConversation.js';
|
|
2
|
+
import { mintHandoffHistoryCapability } from '../http/handoffHistoryRoutes.js';
|
|
3
|
+
import { deliverAfterTurnRevoked } from './taskLifecycle.js';
|
|
4
|
+
import { resolveClaudeTransport } from '../claudeTransport.js';
|
|
5
|
+
import { projectLocalFileReferences } from '../primitives/localFileContext.js';
|
|
6
|
+
import { getEffectivePublicProjectChoice } from '../publicProjectChoice.js';
|
|
1
7
|
import { buildMessageGuardPolicy } from '@arco/shared';
|
|
2
8
|
import * as attention from '../attention.js';
|
|
3
9
|
import { acquireCheckoutWriter, assertCheckoutAvailable, workflowWritePaths, observeCheckoutWriters } from '../checkoutOwnership.js';
|
|
4
10
|
import { randomUUID } from 'node:crypto';
|
|
11
|
+
import path from 'node:path';
|
|
5
12
|
import { projectOllamaHistory, stampOllamaExecution } from '../providers/ollamaExecutionHistory.js';
|
|
6
13
|
import { publishActivity, computerProjectionChanged } from '../voice/activityBus.js';
|
|
7
14
|
import { setComputerBackgroundClaim, clearComputerBackgroundClaim, isComputerBackgroundClaim } from '../voice/operatorTools.js';
|
|
@@ -16,17 +23,19 @@ SteerItem,
|
|
|
16
23
|
WorkflowConfig,
|
|
17
24
|
ClusterEfficiencyLevel
|
|
18
25
|
} from '@arco/shared';
|
|
19
|
-
import {
|
|
26
|
+
import { AUTO_HANDOFF_DEFAULT_COMPACTIONS, autoHandoffAvailability, clampAutoHandoffCompactions, normalizeAutoHandoff, resolveProviderAutoCompaction, type AutoHandoffAvailability, type AutoHandoffConfig, type AutoHandoffMode } from '@arco/shared';
|
|
27
|
+
import { compactionsThisConversation } from '../compactionCounter.js';
|
|
20
28
|
import { WebSocket } from 'ws';
|
|
21
29
|
import { discoverClaudeMdFiles } from '../claudeMdDiscovery.js';
|
|
22
30
|
import { buildKnowledgeBlock } from '../knowledge/store.js';
|
|
23
|
-
import { expandContextRefs } from '../contextRefs.js';
|
|
31
|
+
import { expandContextRefs, type ContextExpansion } from '../contextRefs.js';
|
|
24
32
|
import { refsDoctrine } from '../planRefContext.js';
|
|
25
33
|
import { createCheckpoint } from '../gitSnapshots.js';
|
|
26
34
|
import { summarizeTurnChanges, timelyCheckpoint, shouldCaptureTurn } from '../turnChanges.js';
|
|
27
35
|
import { isManagedBakeoffWorktree } from '../gitBakeoff.js';
|
|
28
36
|
import * as clusterMailbox from '../clusterMailbox.js';
|
|
29
37
|
import * as clusterPlanBridge from '../clusterPlanBridge.js';
|
|
38
|
+
import { clusterToolsPending, CLUSTER_TOOLS_PENDING_NOTICE, CLUSTER_TOOLS_PENDING_AGENT } from '../clusterTurnTools.js';
|
|
30
39
|
import * as clusterStore from '../clusterStore.js';
|
|
31
40
|
import * as clusterEfficiency from '../clusterEfficiency.js';
|
|
32
41
|
import { BLIND_CLUSTER_DOCTRINE } from '../clusterAccessDoctrine.js';
|
|
@@ -79,6 +88,9 @@ withPreviewNudge
|
|
|
79
88
|
} from '../server/prompts.js';
|
|
80
89
|
import { buildGenesisSystemBlock } from '../genesis/prompts.js';
|
|
81
90
|
import { CHAT_PROVIDERS, chatSystemPrompt, chatWebArmed, isChatWorkflow } from '../chatMode.js';
|
|
91
|
+
import { resolveNativeInTurnCompactPercent, resolveTurnSettings } from './turnSettings.js';
|
|
92
|
+
import { composeBasePrompts } from './turnPrompt.js';
|
|
93
|
+
import { runAfterTurn } from './afterTurn.js';
|
|
82
94
|
import {
|
|
83
95
|
sessions,
|
|
84
96
|
workflows
|
|
@@ -94,10 +106,13 @@ buildPinnedSkillsBlock,
|
|
|
94
106
|
resolvePinnedSkills,
|
|
95
107
|
buildSkillsManifest,
|
|
96
108
|
listSkills,
|
|
97
|
-
readSkillBody
|
|
109
|
+
readSkillBody,
|
|
110
|
+
readBuiltinSkill,
|
|
98
111
|
} from '../skills.js';
|
|
112
|
+
import { ARCHITECTURE_REVIEW_SLUG, architectureReviewFacts } from '../architectureReview.js';
|
|
113
|
+
import { artifactsDir } from '../workers/limits.js';
|
|
99
114
|
import {
|
|
100
|
-
|
|
115
|
+
persistInitialMeta,readMeta,updateMeta,workflowDir
|
|
101
116
|
} from '../workflowMeta.js';
|
|
102
117
|
import {
|
|
103
118
|
currentSeq as currentWorkflowSeq,
|
|
@@ -134,11 +149,18 @@ export interface TurnEngineDeps {
|
|
|
134
149
|
captureCheckpoint?: typeof createCheckpoint;
|
|
135
150
|
previewAutoDetect: PreviewAutoDetect;
|
|
136
151
|
handleCreateWorkflow: (ws: WebSocket, session: Session, config: WorkflowConfig) => Promise<void>;
|
|
137
|
-
handleHandoffRequest: (ws: WebSocket, session: Session, msg: import('@arco/shared').HandoffRequestMessage) => Promise<void>;
|
|
138
|
-
handleCompactWorkflow?: (ws: WebSocket, session: Session, msg: import('@arco/shared').CompactWorkflowMessage, guard?: (claim: () => number) => Promise<number | false>, autoDetail?: string) => Promise<void>;
|
|
152
|
+
handleHandoffRequest: (ws: WebSocket, session: Session, msg: import('@arco/shared').HandoffRequestMessage) => Promise<{ artifactName: string } | void>;
|
|
153
|
+
handleCompactWorkflow?: (ws: WebSocket, session: Session, msg: import('@arco/shared').CompactWorkflowMessage, guard?: (claim: () => number) => Promise<number | false>, autoDetail?: string, onSuccess?: () => void) => Promise<void>;
|
|
139
154
|
}
|
|
140
155
|
let deps: TurnEngineDeps;
|
|
141
|
-
export function initTurnEngine(d: TurnEngineDeps): void {
|
|
156
|
+
export function initTurnEngine(d: TurnEngineDeps): void {
|
|
157
|
+
deps = d;
|
|
158
|
+
clusterStore.setMemberJoinedListener((clusterId, workflowId) => {
|
|
159
|
+
if (clusterToolsPending(workflows.get(workflowId), clusterId)) {
|
|
160
|
+
broadcastWorkflow(workflowId, { type: 'system_notice', workflowId, content: CLUSTER_TOOLS_PENDING_NOTICE });
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}
|
|
142
164
|
|
|
143
165
|
|
|
144
166
|
// Extract renderable entries from a raw Claude session JSONL line. A single
|
|
@@ -263,18 +285,7 @@ export function toSessionEntries(raw: SessionJsonlEntry): SessionEntryPayload[]
|
|
|
263
285
|
return out;
|
|
264
286
|
}
|
|
265
287
|
|
|
266
|
-
|
|
267
|
-
// (the harness WorkflowTool lives only in the `claude` binary), else explicit
|
|
268
|
-
// per-tab config wins, else the cwd's TRANSPORT DEFAULTS cascade, else 'cli'.
|
|
269
|
-
// Same precedence as the turn dispatcher — keep the two in sync.
|
|
270
|
-
export async function resolveClaudeTransport(wf: WorkflowState, cwd: string): Promise<'cli' | 'native'> {
|
|
271
|
-
if (wf.primary.provider === 'claude' && wf.config.ultracode === true) return 'cli';
|
|
272
|
-
if (wf.config.claudeTransport === 'native' || wf.config.claudeTransport === 'cli') {
|
|
273
|
-
return wf.config.claudeTransport;
|
|
274
|
-
}
|
|
275
|
-
const cascade = await readSettings(cwd).catch(() => null);
|
|
276
|
-
return cascade?.claude?.transport === 'native' ? 'native' : 'cli';
|
|
277
|
-
}
|
|
288
|
+
export { resolveClaudeTransport } from '../claudeTransport.js';
|
|
278
289
|
|
|
279
290
|
// Start watching Claude's session JSONL for a workflow.
|
|
280
291
|
// `initialWs` receives the historical entries; new entries go to all observers.
|
|
@@ -285,20 +296,25 @@ export async function resolveClaudeTransport(wf: WorkflowState, cwd: string): Pr
|
|
|
285
296
|
// synthetic "No response requested." rows — render as agent replies while
|
|
286
297
|
// ChatPanel's sessionChat-canonical mode hid every real finalized answer
|
|
287
298
|
// otherwise stale session entries could hide finalized answers.
|
|
299
|
+
const sessionWatcherEpochs = new WeakMap<WorkflowState, number>();
|
|
300
|
+
|
|
288
301
|
export function startSessionWatcher(workflowId: string, wf: WorkflowState, cwd: string, initialWs?: WebSocket): void {
|
|
289
|
-
|
|
302
|
+
const epoch = (sessionWatcherEpochs.get(wf) ?? 0) + 1;
|
|
303
|
+
sessionWatcherEpochs.set(wf, epoch);
|
|
290
304
|
const sessionId = wf.primarySessionId;
|
|
291
|
-
if (!sessionId) return;
|
|
292
305
|
if (wf.sessionWatcher) {
|
|
293
306
|
wf.sessionWatcher();
|
|
294
307
|
wf.sessionWatcher = null;
|
|
295
308
|
}
|
|
309
|
+
if (wf.primary.provider !== 'claude' || !sessionId) return;
|
|
310
|
+
const current = () => workflows.get(workflowId) === wf && wf.primarySessionId === sessionId
|
|
311
|
+
&& sessionWatcherEpochs.get(wf) === epoch && wf.primary.provider === 'claude';
|
|
296
312
|
const path = resolveSessionJsonlPath(cwd, sessionId);
|
|
297
313
|
resolveClaudeTransport(wf, cwd).then((transport) => {
|
|
298
|
-
if (transport === 'native') return null;
|
|
314
|
+
if (!current() || transport === 'native') return null;
|
|
299
315
|
return loadSessionJsonl(path);
|
|
300
316
|
}).then((loaded) => {
|
|
301
|
-
if (!loaded) return;
|
|
317
|
+
if (!loaded || !current()) return;
|
|
302
318
|
const { entries, byteLength } = loaded;
|
|
303
319
|
// Tail-first: only the last N raw entries go out immediately. Anything
|
|
304
320
|
// older sits on wf.pendingEarlierEntries until the operator pages back
|
|
@@ -330,6 +346,7 @@ export function startSessionWatcher(workflowId: string, wf: WorkflowState, cwd:
|
|
|
330
346
|
}
|
|
331
347
|
if (!workflows.has(workflowId)) return; // workflow removed while loading
|
|
332
348
|
const dispose = watchSessionJsonl(path, byteLength, (raw) => {
|
|
349
|
+
if (!current()) return;
|
|
333
350
|
// Concurrent-session detection. Live writes with an entrypoint other
|
|
334
351
|
// than 'sdk-cli' mean a native `claude --resume` terminal is writing
|
|
335
352
|
// to this same JSONL. Flag the workflow, and emit a debounced chat
|
|
@@ -359,7 +376,7 @@ export function startSessionWatcher(workflowId: string, wf: WorkflowState, cwd:
|
|
|
359
376
|
}
|
|
360
377
|
});
|
|
361
378
|
const wfNow = workflows.get(workflowId);
|
|
362
|
-
if (wfNow) {
|
|
379
|
+
if (wfNow && current()) {
|
|
363
380
|
wfNow.sessionWatcher = dispose;
|
|
364
381
|
} else {
|
|
365
382
|
dispose(); // workflow gone — clean up immediately
|
|
@@ -382,17 +399,17 @@ export function derivePrimaryConfig(config: WorkflowConfig): PrimaryConfig {
|
|
|
382
399
|
}
|
|
383
400
|
|
|
384
401
|
export function deriveAutoHandoff(config: WorkflowConfig): WorkflowState['autoHandoff'] {
|
|
402
|
+
const saved = normalizeAutoHandoff(config.autoHandoff);
|
|
385
403
|
return {
|
|
386
|
-
enabled:
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
autoFired: false,
|
|
404
|
+
enabled: saved?.enabled ?? false,
|
|
405
|
+
afterCompactions: saved?.afterCompactions ?? AUTO_HANDOFF_DEFAULT_COMPACTIONS,
|
|
406
|
+
compactions: 0,
|
|
407
|
+
fired: false,
|
|
391
408
|
// WP5 — carry through verbatim (no defaulting); resolution happens at
|
|
392
409
|
// fire time so a later change to the global default still affects tabs
|
|
393
410
|
// that never set a per-tab override.
|
|
394
|
-
mode:
|
|
395
|
-
summarizer:
|
|
411
|
+
mode: saved?.mode,
|
|
412
|
+
summarizer: saved?.summarizer,
|
|
396
413
|
};
|
|
397
414
|
}
|
|
398
415
|
|
|
@@ -412,24 +429,28 @@ export function deriveAutoFold(config: WorkflowConfig): WorkflowState['autoFold'
|
|
|
412
429
|
|
|
413
430
|
export function applyAutoHandoffDefault(
|
|
414
431
|
config: WorkflowConfig,
|
|
415
|
-
defaults?:
|
|
432
|
+
defaults?: { enabled?: boolean; afterCompactions?: number; mode?: AutoHandoffMode; summarizer?: AutoHandoffConfig['summarizer'] } | null,
|
|
416
433
|
): boolean {
|
|
434
|
+
// A config from an older client or saved file may carry percent fields.
|
|
435
|
+
if (config.autoHandoff !== undefined) {
|
|
436
|
+
const saved = normalizeAutoHandoff(config.autoHandoff);
|
|
437
|
+
if (saved) config.autoHandoff = saved; else delete config.autoHandoff;
|
|
438
|
+
}
|
|
417
439
|
if (config.autoHandoff) return false;
|
|
418
440
|
if (!defaults) return false;
|
|
419
441
|
if (
|
|
420
442
|
defaults.enabled === undefined
|
|
421
|
-
&& defaults.
|
|
422
|
-
&& defaults.autoAt === undefined
|
|
443
|
+
&& defaults.afterCompactions === undefined
|
|
423
444
|
&& defaults.mode === undefined
|
|
424
445
|
&& defaults.summarizer === undefined
|
|
425
446
|
) return false;
|
|
426
|
-
|
|
447
|
+
// Through normalizeAutoHandoff so the saved form carries the 0.1.4 fields too.
|
|
448
|
+
config.autoHandoff = normalizeAutoHandoff({
|
|
427
449
|
enabled: defaults.enabled ?? false,
|
|
428
|
-
|
|
429
|
-
autoAt: defaults.autoAt ?? 90,
|
|
450
|
+
afterCompactions: clampAutoHandoffCompactions(defaults.afterCompactions),
|
|
430
451
|
...(defaults.mode !== undefined ? { mode: defaults.mode } : {}),
|
|
431
452
|
...(defaults.summarizer !== undefined ? { summarizer: defaults.summarizer } : {}),
|
|
432
|
-
};
|
|
453
|
+
});
|
|
433
454
|
return true;
|
|
434
455
|
}
|
|
435
456
|
|
|
@@ -469,8 +490,6 @@ export function resetCodexContextAfterCompact(
|
|
|
469
490
|
modelContextWindow?: number,
|
|
470
491
|
): void {
|
|
471
492
|
wf.lastContextPercent = 0;
|
|
472
|
-
wf.autoHandoff.warnFired = false;
|
|
473
|
-
wf.autoHandoff.autoFired = false;
|
|
474
493
|
broadcastTransient(workflowId, {
|
|
475
494
|
type: 'codex_token_snapshot',
|
|
476
495
|
workflowId,
|
|
@@ -511,8 +530,36 @@ export function anyObserver(workflowId: string): WebSocket | null {
|
|
|
511
530
|
let busyClaimSeq = 0;
|
|
512
531
|
const busyCheckoutLeases = new WeakMap<WorkflowState, () => void>();
|
|
513
532
|
const busyOwners = new WeakMap<WorkflowState, number>();
|
|
533
|
+
const storageMigrations = new WeakSet<WorkflowState>();
|
|
534
|
+
const incomingMessages = new WeakMap<WorkflowState, number>();
|
|
514
535
|
const lastBusyClaim = new WeakMap<WorkflowState, number>();
|
|
515
536
|
const busyRevocations = new WeakMap<WorkflowState, number>();
|
|
537
|
+
const requeuedSteerDrains = new WeakMap<WorkflowState, { epoch: number; active: boolean }>();
|
|
538
|
+
|
|
539
|
+
function hasRequeuedSteerDrain(wf: WorkflowState): boolean {
|
|
540
|
+
return requeuedSteerDrains.get(wf)?.epoch === (busyRevocations.get(wf) ?? 0);
|
|
541
|
+
}
|
|
542
|
+
|
|
543
|
+
function resumeRequeuedSteer(workflowId: string, wf: WorkflowState): void {
|
|
544
|
+
const pending = requeuedSteerDrains.get(wf);
|
|
545
|
+
if (!pending) return;
|
|
546
|
+
if (workflows.get(workflowId) !== wf || pending.epoch !== (busyRevocations.get(wf) ?? 0)
|
|
547
|
+
|| (wf.queue.steering.length === 0 && wf.queue.followUp.length === 0)) {
|
|
548
|
+
requeuedSteerDrains.delete(wf);
|
|
549
|
+
return;
|
|
550
|
+
}
|
|
551
|
+
// Existing or incoming turns own the next admission. Their finalizer will
|
|
552
|
+
// try again; a later operator send stays queued during this preparation.
|
|
553
|
+
if (pending.active || wf.busy || wf.primaryTurn || wf.computerResetting || incomingMessages.get(wf)) return;
|
|
554
|
+
pending.active = true;
|
|
555
|
+
void drainQueueIfIdle(workflowId).catch((err) => {
|
|
556
|
+
console.error(`[arco] [${workflowId.slice(0, 8)}] re-queued steer drain failed:`, err);
|
|
557
|
+
}).finally(() => {
|
|
558
|
+
pending.active = false;
|
|
559
|
+
if (requeuedSteerDrains.get(wf) === pending && (pending.epoch !== (busyRevocations.get(wf) ?? 0)
|
|
560
|
+
|| (wf.queue.steering.length === 0 && wf.queue.followUp.length === 0))) requeuedSteerDrains.delete(wf);
|
|
561
|
+
});
|
|
562
|
+
}
|
|
516
563
|
|
|
517
564
|
export function publishWorkerActivity(wf: WorkflowState, kind: 'worker_started' | 'worker_finished' | 'worker_failed' | 'worker_interrupted' | 'worker_removed' | 'queue_changed') {
|
|
518
565
|
if (wf.config?.incognito || wf.config?.kind === 'chat' || wf.config?.voiceOperator) return;
|
|
@@ -521,7 +568,8 @@ export function publishWorkerActivity(wf: WorkflowState, kind: 'worker_started'
|
|
|
521
568
|
}
|
|
522
569
|
}
|
|
523
570
|
|
|
524
|
-
export function claimBusy(wf: WorkflowState): number {
|
|
571
|
+
export function claimBusy(wf: WorkflowState, workerActivity = true): number {
|
|
572
|
+
if (storageMigrations.has(wf)) throw new Error('Workflow storage is moving. Wait for the scaffold to finish.');
|
|
525
573
|
// Keep the existing conservative restore reservation, but observe isolated
|
|
526
574
|
// members at their actual scratch cwd for turn-overlap reporting.
|
|
527
575
|
const wfid = [...workflows].find(([, current]) => current === wf)?.[0];
|
|
@@ -536,15 +584,32 @@ export function claimBusy(wf: WorkflowState): number {
|
|
|
536
584
|
lastBusyClaim.set(wf, token);
|
|
537
585
|
watchClaimed(wf, token);
|
|
538
586
|
wf.busy = true;
|
|
587
|
+
wf.turnStartedAt = undefined;
|
|
588
|
+
if (wfid && workerActivity) void notifyClusterStateForWorkflow(wfid);
|
|
539
589
|
if(wf.config?.voiceOperator)wf.computerSettled=false;
|
|
540
|
-
publishWorkerActivity(wf, 'worker_started');
|
|
590
|
+
if (workerActivity) publishWorkerActivity(wf, 'worker_started');
|
|
541
591
|
return token;
|
|
542
592
|
}
|
|
543
593
|
|
|
594
|
+
export function isWorkflowStorageMoving(wf: WorkflowState): boolean { return storageMigrations.has(wf); }
|
|
595
|
+
|
|
596
|
+
export function reserveWorkflowMigration(wf: WorkflowState): () => void {
|
|
597
|
+
if (wf.busy || storageMigrations.has(wf) || incomingMessages.get(wf)) throw new Error('Workflow is busy.');
|
|
598
|
+
const token = claimBusy(wf, false);
|
|
599
|
+
storageMigrations.add(wf);
|
|
600
|
+
return () => { storageMigrations.delete(wf); if (!releaseBusy(wf, token, 'finished', false)) wf.busy = false; };
|
|
601
|
+
}
|
|
602
|
+
|
|
544
603
|
export function ownsBusy(wf: WorkflowState, token: number): boolean {
|
|
545
604
|
return busyOwners.get(wf) === token;
|
|
546
605
|
}
|
|
547
606
|
|
|
607
|
+
// A released claim remains current until another claim or STOP supersedes it.
|
|
608
|
+
// Background completion metadata can use this without retaining busy.
|
|
609
|
+
export function isCurrentBusyClaim(wf: WorkflowState, token: number): boolean {
|
|
610
|
+
return lastBusyClaim.get(wf) === token;
|
|
611
|
+
}
|
|
612
|
+
|
|
548
613
|
// Returns false (and leaves wf.busy alone) when the claim was revoked or
|
|
549
614
|
// superseded — the caller is a stale holder and must not touch busy/queue.
|
|
550
615
|
export function releaseBusy(wf: WorkflowState, token: number, outcome: 'finished' | 'interrupted' | 'failed' = 'interrupted', workerActivity = true): boolean {
|
|
@@ -553,6 +618,7 @@ export function releaseBusy(wf: WorkflowState, token: number, outcome: 'finished
|
|
|
553
618
|
busyOwners.delete(wf);
|
|
554
619
|
busyCheckoutLeases.get(wf)?.(); busyCheckoutLeases.delete(wf);
|
|
555
620
|
wf.busy = false;
|
|
621
|
+
wf.turnStartedAt = undefined;
|
|
556
622
|
clearComputerBackgroundClaim([...workflows].find(([, current]) => current === wf)?.[0] ?? '', token);
|
|
557
623
|
if (wf.config?.voiceOperator) computerProjectionChanged();
|
|
558
624
|
// Compaction publishes its own operation outcome after refresh/queue drain;
|
|
@@ -575,7 +641,8 @@ export function revokeBusy(wf: WorkflowState): void {
|
|
|
575
641
|
watchSettled(wf, busyOwners.get(wf), 'interrupted');
|
|
576
642
|
busyOwners.delete(wf);
|
|
577
643
|
busyCheckoutLeases.get(wf)?.(); busyCheckoutLeases.delete(wf);
|
|
578
|
-
wf.busy =
|
|
644
|
+
wf.busy = storageMigrations.has(wf);
|
|
645
|
+
wf.turnStartedAt = undefined;
|
|
579
646
|
if (token !== undefined) clearComputerBackgroundClaim([...workflows].find(([, current]) => current === wf)?.[0] ?? '', token);
|
|
580
647
|
if (wf.config?.voiceOperator) computerProjectionChanged();
|
|
581
648
|
if(token !== undefined)publishWorkerActivity(wf, 'worker_interrupted');
|
|
@@ -663,8 +730,7 @@ export async function maybeAutoFold(workflowId: string, wf: WorkflowState, cwd:
|
|
|
663
730
|
if ((st.foldIneffectiveCount ?? 0) >= MAX_INEFFECTIVE_FOLDS) return false;
|
|
664
731
|
|
|
665
732
|
// Native transport required (CLI Claude has no in-process history to fold).
|
|
666
|
-
const
|
|
667
|
-
const transport = wf.config.claudeTransport ?? (cascade?.claude?.transport === 'native' ? 'native' : 'cli');
|
|
733
|
+
const transport = await resolveClaudeTransport(wf, cwd);
|
|
668
734
|
if (transport !== 'native') return false;
|
|
669
735
|
// Re-check after the settings await: an operator message can have claimed
|
|
670
736
|
// the tab meanwhile, and folding under a live turn corrupts its history.
|
|
@@ -709,99 +775,105 @@ export async function maybeAutoFold(workflowId: string, wf: WorkflowState, cwd:
|
|
|
709
775
|
return true;
|
|
710
776
|
}
|
|
711
777
|
|
|
712
|
-
//
|
|
713
|
-
// loop exits (wf.busy
|
|
714
|
-
|
|
778
|
+
// Auto-handoff after N compactions (operator decision for 0.1.5). Runs at a
|
|
779
|
+
// turn boundary only: called after the turn loop exits (wf.busy reset), before
|
|
780
|
+
// any automatic fold or compaction of that boundary. Nothing is said before
|
|
781
|
+
// the handoff; once it has run, one chat line names the count and links the
|
|
782
|
+
// handoff document. Returns true when a handoff was started.
|
|
783
|
+
export async function maybeAutoHandoff(workflowId: string, wf: WorkflowState, cwd: string): Promise<boolean> {
|
|
715
784
|
// Chat tabs are projectless: a handoff re-seeds as an Agent worker (tools,
|
|
716
785
|
// project context) and, for incognito, installed a cwdHandoffChain slot for
|
|
717
|
-
// the temp root + broadcast lock snapshots.
|
|
718
|
-
|
|
719
|
-
if (isChatWorkflow(wf.config)) return;
|
|
720
|
-
const percentOfWindow = wf.lastContextPercent;
|
|
721
|
-
if (typeof percentOfWindow !== 'number' || percentOfWindow <= 0) return;
|
|
722
|
-
|
|
786
|
+
// the temp root + broadcast lock snapshots. Never automatically.
|
|
787
|
+
if (isChatWorkflow(wf.config)) return false;
|
|
723
788
|
const ah = wf.autoHandoff;
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
if (
|
|
727
|
-
|
|
728
|
-
|
|
789
|
+
if (!ah?.enabled || ah.fired || wf.busy) return false;
|
|
790
|
+
const count = compactionsThisConversation(wf);
|
|
791
|
+
if (count < ah.afterCompactions) return false;
|
|
792
|
+
const cascade = await readSettings(cwd).catch(() => null);
|
|
793
|
+
if (!(await autoHandoffAvailableFor(workflowId, wf, cwd, cascade)).available) return false;
|
|
794
|
+
if (wf.busy || ah.fired) return false;
|
|
795
|
+
const obs = anyObserver(workflowId);
|
|
796
|
+
if (!obs) {
|
|
797
|
+
console.warn(`[arco] [${workflowId.slice(0, 8)}] auto-handoff: no observer to broadcast on`);
|
|
798
|
+
return false;
|
|
729
799
|
}
|
|
800
|
+
ah.fired = true;
|
|
801
|
+
console.log(`[arco] [${workflowId.slice(0, 8)}] auto-handoff: ${count} compactions this conversation, firing`);
|
|
730
802
|
|
|
731
|
-
//
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
803
|
+
// Re-use the same handoff logic as the manual button by constructing
|
|
804
|
+
// a synthetic message and calling the handler.
|
|
805
|
+
//
|
|
806
|
+
// Per-tab override wins over the global default; quick is the fallback.
|
|
807
|
+
const mode: AutoHandoffMode =
|
|
808
|
+
wf.autoHandoff.mode
|
|
809
|
+
?? cascade?.autoHandoffDefaults?.mode
|
|
810
|
+
?? 'quick';
|
|
811
|
+
// Keep mode resolution in sync with manual handoff: provider-specific
|
|
812
|
+
// resume capability is handled by handoffHandlers, which translates the
|
|
813
|
+
// original-worker choice where a live session cannot be reopened.
|
|
814
|
+
const synthMsg: import('@arco/shared').HandoffRequestMessage = {
|
|
815
|
+
type: 'handoff_request',
|
|
816
|
+
workflowId,
|
|
817
|
+
mode,
|
|
818
|
+
};
|
|
819
|
+
// SUMMARIZER resolution: only matters for fresh-summarizer. Put the
|
|
820
|
+
// per-tab summarizer (if set) onto the synthesized message; the handler's
|
|
821
|
+
// chain is `msg.summarizer ?? settings.handoffSummarizer ?? primary`, so
|
|
822
|
+
// per-tab wins, global is the middle, primary is last. For original-worker
|
|
823
|
+
// we leave summarizer unset.
|
|
824
|
+
if (mode === 'fresh-summarizer' && wf.autoHandoff.summarizer) {
|
|
825
|
+
const s = wf.autoHandoff.summarizer;
|
|
826
|
+
synthMsg.summarizer = {
|
|
827
|
+
provider: s.provider,
|
|
828
|
+
model: s.model ?? wf.primary.model,
|
|
829
|
+
effort: s.effort ?? 'medium',
|
|
830
|
+
};
|
|
831
|
+
}
|
|
832
|
+
try {
|
|
833
|
+
const dummySession: Session = sessions.get(obs) ?? { id: 'auto', workflowIds: new Set([workflowId]), clusterIds: new Set(), clusterObserved: new Map() };
|
|
834
|
+
const done = await deps.handleHandoffRequest(obs, dummySession, synthMsg);
|
|
835
|
+
if (done && typeof done === 'object' && done.artifactName) {
|
|
836
|
+
const doc = path.join(workflowDir(cwd, workflowId), 'handoffs', done.artifactName);
|
|
837
|
+
broadcastWorkflow(workflowId, {
|
|
737
838
|
type: 'system_notice',
|
|
738
839
|
workflowId,
|
|
739
|
-
content: `
|
|
840
|
+
content: `Handed off after ${count} compaction${count === 1 ? '' : 's'}: [handoff document](${doc.split(path.sep).join('/')})`,
|
|
740
841
|
});
|
|
741
842
|
}
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
console.log(`[arco] [${workflowId.slice(0, 8)}] auto-handoff: context at ${percentOfWindow}%, firing`);
|
|
754
|
-
send(obs, {
|
|
755
|
-
type: 'system_notice',
|
|
756
|
-
workflowId,
|
|
757
|
-
content: `[AUTO-HANDOFF] Context at ${percentOfWindow}%. Rotating the session.`,
|
|
758
|
-
});
|
|
759
|
-
|
|
760
|
-
// Re-use the same handoff logic as the manual button by constructing
|
|
761
|
-
// a synthetic message and calling the handler.
|
|
762
|
-
//
|
|
763
|
-
// Per-tab override wins over the global default; quick is the fallback.
|
|
764
|
-
const cascade = await readSettings(cwd).catch(() => null);
|
|
765
|
-
const mode: 'quick' | 'original-worker' | 'fresh-summarizer' =
|
|
766
|
-
wf.autoHandoff.mode
|
|
767
|
-
?? cascade?.autoHandoffDefaults?.mode
|
|
768
|
-
?? 'quick';
|
|
769
|
-
// Keep mode resolution in sync with manual handoff: provider-specific
|
|
770
|
-
// resume capability is handled by handoffHandlers, which translates the
|
|
771
|
-
// original-worker choice where a live session cannot be reopened.
|
|
772
|
-
const synthMsg: import('@arco/shared').HandoffRequestMessage = {
|
|
773
|
-
type: 'handoff_request',
|
|
774
|
-
workflowId,
|
|
775
|
-
mode,
|
|
776
|
-
};
|
|
777
|
-
// SUMMARIZER resolution: only matters for fresh-summarizer. Put the
|
|
778
|
-
// per-tab summarizer (if set) onto the synthesized message; the handler's
|
|
779
|
-
// chain is `msg.summarizer ?? settings.handoffSummarizer ?? primary`, so
|
|
780
|
-
// per-tab wins, global is the middle, primary is last. For original-worker
|
|
781
|
-
// we leave summarizer unset.
|
|
782
|
-
if (mode === 'fresh-summarizer' && wf.autoHandoff.summarizer) {
|
|
783
|
-
const s = wf.autoHandoff.summarizer;
|
|
784
|
-
synthMsg.summarizer = {
|
|
785
|
-
provider: s.provider,
|
|
786
|
-
model: s.model ?? wf.primary.model,
|
|
787
|
-
effort: s.effort ?? 'medium',
|
|
788
|
-
};
|
|
789
|
-
}
|
|
790
|
-
try {
|
|
791
|
-
const dummySession: Session = sessions.get(obs) ?? { id: 'auto', workflowIds: new Set([workflowId]), clusterIds: new Set(), clusterObserved: new Map() };
|
|
792
|
-
await deps.handleHandoffRequest(obs, dummySession, synthMsg);
|
|
793
|
-
} catch (err) {
|
|
794
|
-
console.error(`[arco] [${workflowId.slice(0, 8)}] auto-handoff failed:`, err);
|
|
795
|
-
const obs2 = anyObserver(workflowId);
|
|
796
|
-
if (obs2) {
|
|
797
|
-
send(obs2, {
|
|
798
|
-
type: 'system_notice',
|
|
799
|
-
workflowId,
|
|
800
|
-
content: `[AUTO-HANDOFF FAILED] ${err instanceof Error ? err.message : String(err)}. Click HANDOFF manually.`,
|
|
801
|
-
});
|
|
802
|
-
}
|
|
843
|
+
// Not completed (cancelled, refused, or failed with its own notice): no
|
|
844
|
+
// retry in this conversation; HANDOFF stays available.
|
|
845
|
+
} catch (err) {
|
|
846
|
+
console.error(`[arco] [${workflowId.slice(0, 8)}] auto-handoff failed:`, err);
|
|
847
|
+
const obs2 = anyObserver(workflowId);
|
|
848
|
+
if (obs2) {
|
|
849
|
+
send(obs2, {
|
|
850
|
+
type: 'system_notice',
|
|
851
|
+
workflowId,
|
|
852
|
+
content: `[AUTO-HANDOFF FAILED] ${err instanceof Error ? err.message : String(err)}. Click HANDOFF manually.`,
|
|
853
|
+
});
|
|
803
854
|
}
|
|
804
855
|
}
|
|
856
|
+
return true;
|
|
857
|
+
}
|
|
858
|
+
|
|
859
|
+
// Whether auto-handoff can count compactions for this tab now (provider,
|
|
860
|
+
// transport and the resolved auto-compaction policy, worker over cluster).
|
|
861
|
+
export async function autoHandoffAvailableFor(workflowId: string, wf: WorkflowState, cwd: string, cascade?: Awaited<ReturnType<typeof readSettings>> | null): Promise<AutoHandoffAvailability> {
|
|
862
|
+
const settings = cascade === undefined ? await readSettings(cwd).catch(() => null) : cascade;
|
|
863
|
+
const provider = wf.primary.provider;
|
|
864
|
+
const claudeTransport = provider === 'claude' ? await resolveClaudeTransport(wf, cwd) : undefined;
|
|
865
|
+
const codexTransport = wf.config.codexTransport ?? (settings?.codex?.transport === 'appserver' ? 'appserver' : 'exec');
|
|
866
|
+
const clusterId = clusterStore.getClusterIdForWorkflow(workflowId);
|
|
867
|
+
const ollamaSaved = settings?.ollama?.compaction?.enabled !== undefined || settings?.ollama?.compaction?.threshold !== undefined;
|
|
868
|
+
const compaction = resolveProviderAutoCompaction(wf.config.autoCompaction, clusterId ? clusterStore.getAutoCompaction(clusterId) : undefined, provider, claudeTransport ?? '', wf.config.claudeNativeCompact === true, ollamaSaved);
|
|
869
|
+
return autoHandoffAvailability({
|
|
870
|
+
provider,
|
|
871
|
+
claudeTransport,
|
|
872
|
+
codexTransport,
|
|
873
|
+
chat: isChatWorkflow(wf.config),
|
|
874
|
+
compaction,
|
|
875
|
+
ollamaSavedEnabled: ollamaSaved ? settings?.ollama?.compaction?.enabled !== false : undefined,
|
|
876
|
+
});
|
|
805
877
|
}
|
|
806
878
|
|
|
807
879
|
export function freshAutoCompactionPercent(provider: string, transport: string, outcome: { error?: string; lastPromptTokens?: number; modelContextWindow?: number; freshContextWindow?: number }): number | undefined {
|
|
@@ -814,7 +886,7 @@ export function freshAutoCompactionPercent(provider: string, transport: string,
|
|
|
814
886
|
}
|
|
815
887
|
|
|
816
888
|
type PolicyReading = { percent: number; sessionId: string | undefined; provider: string; transport?: string };
|
|
817
|
-
const policyAttempts = new WeakMap<WorkflowState, { sessionId: string | undefined; provider: string; fired: boolean }>();
|
|
889
|
+
const policyAttempts = new WeakMap<WorkflowState, { sessionId: string | undefined; provider: string; fired: boolean; awaitingReading: boolean; highAfterSuccess: number }>();
|
|
818
890
|
export function resetAutoCompactionCycle(wf: WorkflowState): void { policyAttempts.delete(wf); }
|
|
819
891
|
|
|
820
892
|
export async function maybeAutoCompactPolicy(
|
|
@@ -828,13 +900,25 @@ export async function maybeAutoCompactPolicy(
|
|
|
828
900
|
if (reading.provider === 'codex' && !reading.sessionId) return false;
|
|
829
901
|
let state = policyAttempts.get(wf);
|
|
830
902
|
if (!state || state.sessionId !== reading.sessionId || state.provider !== reading.provider) {
|
|
831
|
-
state = { sessionId: reading.sessionId, provider: reading.provider, fired: false };
|
|
903
|
+
state = { sessionId: reading.sessionId, provider: reading.provider, fired: false, awaitingReading: false, highAfterSuccess: 0 };
|
|
832
904
|
policyAttempts.set(wf, state);
|
|
833
905
|
}
|
|
834
|
-
if (reading.percent < policy.thresholdPercent
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
906
|
+
if (reading.percent < policy.thresholdPercent) {
|
|
907
|
+
state.awaitingReading = false;
|
|
908
|
+
if (reading.percent < policy.thresholdPercent - 5) state.fired = false;
|
|
909
|
+
state.highAfterSuccess = 0;
|
|
910
|
+
return false;
|
|
911
|
+
}
|
|
912
|
+
if (state.awaitingReading) {
|
|
913
|
+
state.awaitingReading = false;
|
|
914
|
+
state.highAfterSuccess++;
|
|
915
|
+
if (state.highAfterSuccess === 3) {
|
|
916
|
+
broadcastWorkflow(workflowId, { type: 'system_notice', workflowId, content: `Automatic compaction has run after each of the last 3 turns and the context is still at or above the ${policy.thresholdPercent}% threshold at turn end. It keeps running. If the turns are simply large this is expected; otherwise raise the threshold or use HANDOFF.` });
|
|
917
|
+
}
|
|
918
|
+
}
|
|
919
|
+
if (state.fired) return false;
|
|
920
|
+
// Prevent retries of an unsuccessful compact until a later valid reading
|
|
921
|
+
// confirms a drop. Mark before awaiting any external work.
|
|
838
922
|
state.fired = true;
|
|
839
923
|
const observedClaim = expectedClaim;
|
|
840
924
|
const obs = ws ?? anyObserver(workflowId);
|
|
@@ -846,7 +930,9 @@ export async function maybeAutoCompactPolicy(
|
|
|
846
930
|
const current = resolveProviderAutoCompaction(wf.config.autoCompaction, clusterId ? clusterStore.getAutoCompaction(clusterId) : undefined, wf.primary.provider, reading.transport ?? (wf.primary.provider === 'claude' ? 'native' : ''), wf.config.claudeNativeCompact === true);
|
|
847
931
|
if (wf.busy || lastBusyClaim.get(wf) !== observedClaim || wf.primarySessionId !== reading.sessionId || wf.primary.provider !== reading.provider || !current?.enabled || current.thresholdPercent !== policy.thresholdPercent) return false;
|
|
848
932
|
return claim();
|
|
849
|
-
}, `context ${reading.percent}% >= ${policy.thresholdPercent}
|
|
933
|
+
}, `context ${reading.percent}% >= ${policy.thresholdPercent}%`, () => {
|
|
934
|
+
if (policyAttempts.get(wf) === state) { state.fired = false; state.awaitingReading = true; }
|
|
935
|
+
});
|
|
850
936
|
return true;
|
|
851
937
|
}
|
|
852
938
|
|
|
@@ -856,8 +942,11 @@ export async function runExplicitContextActions(
|
|
|
856
942
|
busyToken: number, ws?: WebSocket, session?: Session,
|
|
857
943
|
): Promise<'stale' | 'compact-attempted' | 'done'> {
|
|
858
944
|
if (lastBusyClaim.get(wf) !== busyToken) return 'stale';
|
|
859
|
-
//
|
|
860
|
-
//
|
|
945
|
+
// A due auto-handoff starts a fresh session, so this boundary needs no
|
|
946
|
+
// fold or compaction.
|
|
947
|
+
if (await maybeAutoHandoff(workflowId, wf, cwd)) return 'done';
|
|
948
|
+
if (lastBusyClaim.get(wf) !== busyToken) return 'stale';
|
|
949
|
+
// Ollama compacts at the next pre-dispatch boundary.
|
|
861
950
|
if (wf.primary.provider === 'ollama' && policy.enabled) return 'done';
|
|
862
951
|
let foldClaim: number | undefined;
|
|
863
952
|
const folded = await maybeAutoFold(workflowId, wf, cwd, (token) => { foldClaim = token; }, () => lastBusyClaim.get(wf) === busyToken);
|
|
@@ -866,7 +955,6 @@ export async function runExplicitContextActions(
|
|
|
866
955
|
if (folded) { wf.lastContextPercent = 0; wf.lastContextBudgetPct = undefined; }
|
|
867
956
|
if (foldClaim !== undefined) return 'done';
|
|
868
957
|
if (await maybeAutoCompactPolicy(workflowId, wf, cwd, policy, reading, busyToken, ws, session)) return 'compact-attempted';
|
|
869
|
-
await maybeAutoHandoff(workflowId, wf, cwd);
|
|
870
958
|
return 'done';
|
|
871
959
|
}
|
|
872
960
|
|
|
@@ -907,7 +995,15 @@ export async function maybeAutoContinueAfterCompact(
|
|
|
907
995
|
// turn starts while calibration is running, the pty is cancelled via
|
|
908
996
|
// wf.cancelCalibration (set by the primary turn handler in handleUserMessage).
|
|
909
997
|
export async function maybeCalibrate(workflowId: string, wf: WorkflowState, cwd: string): Promise<void> {
|
|
910
|
-
|
|
998
|
+
const sessionId = wf.primarySessionId;
|
|
999
|
+
const model = wf.primary.model;
|
|
1000
|
+
const claim = lastBusyClaim.get(wf);
|
|
1001
|
+
const revocation = busyRevocations.get(wf);
|
|
1002
|
+
const stillIdle = () => workflows.get(workflowId) === wf && !wf.busy
|
|
1003
|
+
&& wf.primary.provider === 'claude' && wf.primarySessionId === sessionId
|
|
1004
|
+
&& wf.primary.model === model && lastBusyClaim.get(wf) === claim
|
|
1005
|
+
&& busyRevocations.get(wf) === revocation;
|
|
1006
|
+
if (!sessionId || !stillIdle() || wf.cancelCalibration) return;
|
|
911
1007
|
// CLI transport only. Native gets exact token counts from the API
|
|
912
1008
|
// (lastPromptTokens) — the byte-ratio estimator this tunes never runs for
|
|
913
1009
|
// it. Worse than useless: the `--print "/context"` probe APPENDS synthetic
|
|
@@ -916,8 +1012,7 @@ export async function maybeCalibrate(workflowId: string, wf: WorkflowState, cwd:
|
|
|
916
1012
|
// CLI session that polluted a file the session watcher was treating as
|
|
917
1013
|
// transcript truth.
|
|
918
1014
|
if (await resolveClaudeTransport(wf, cwd) === 'native') return;
|
|
919
|
-
|
|
920
|
-
if (!sessionId) return;
|
|
1015
|
+
if (!stillIdle()) return;
|
|
921
1016
|
|
|
922
1017
|
const cal: CalibrationState = wf.calibration ?? {
|
|
923
1018
|
ratio: BYTES_PER_TOKEN_DEFAULT,
|
|
@@ -927,15 +1022,15 @@ export async function maybeCalibrate(workflowId: string, wf: WorkflowState, cwd:
|
|
|
927
1022
|
|
|
928
1023
|
// Get current estimate to detect zone crossing
|
|
929
1024
|
const est = await estimateContextFill(cwd, sessionId, wf.primary.model, cal).catch(() => null);
|
|
930
|
-
if (!est) return;
|
|
1025
|
+
if (!est || !stillIdle()) return;
|
|
931
1026
|
|
|
932
1027
|
const currentPercent = est.percentOfWindow;
|
|
933
1028
|
const prevPercent = wf.lastContextPercent;
|
|
934
1029
|
wf.lastContextPercent = currentPercent;
|
|
935
1030
|
|
|
936
|
-
// Don't calibrate
|
|
937
|
-
//
|
|
938
|
-
if (currentPercent >=
|
|
1031
|
+
// Don't calibrate near a full window: not worth the latency when the CLI's
|
|
1032
|
+
// own compaction is imminent.
|
|
1033
|
+
if (currentPercent >= 90) return;
|
|
939
1034
|
|
|
940
1035
|
// Skip when the estimator already has ground truth from the JSONL usage
|
|
941
1036
|
// blocks — calibration only exists to tune the byte-count ratio, and the
|
|
@@ -958,15 +1053,22 @@ export async function maybeCalibrate(workflowId: string, wf: WorkflowState, cwd:
|
|
|
958
1053
|
|
|
959
1054
|
console.log(`[arco] [${workflowId.slice(0, 8)}] calibrating zone ${zone} at ${currentPercent}%`);
|
|
960
1055
|
|
|
1056
|
+
if (!stillIdle() || wf.cancelCalibration) return;
|
|
1057
|
+
let cancelProbe: (() => void) | undefined;
|
|
1058
|
+
let cancelled = false;
|
|
1059
|
+
const cancel = () => { cancelled = true; cancelProbe?.(); };
|
|
1060
|
+
wf.cancelCalibration = cancel;
|
|
961
1061
|
let result: import('../contextCalibrator.js').CalibrationResult | null = null;
|
|
962
1062
|
try {
|
|
963
1063
|
result = await runCalibration(sessionId, wf.primary.model, cwd, est.jsonlBytes, (cancelFn) => {
|
|
964
|
-
|
|
1064
|
+
cancelProbe = cancelFn;
|
|
1065
|
+
if (cancelled || !stillIdle()) cancelFn();
|
|
965
1066
|
});
|
|
966
1067
|
} catch (err) {
|
|
967
1068
|
console.error(`[arco] [${workflowId.slice(0, 8)}] calibration error:`, err);
|
|
968
1069
|
}
|
|
969
|
-
wf.cancelCalibration = undefined;
|
|
1070
|
+
if (wf.cancelCalibration === cancel) wf.cancelCalibration = undefined;
|
|
1071
|
+
if (cancelled || !stillIdle()) return;
|
|
970
1072
|
|
|
971
1073
|
if (!result) {
|
|
972
1074
|
console.warn(`[arco] [${workflowId.slice(0, 8)}] calibration zone ${zone} failed or was cancelled`);
|
|
@@ -1007,7 +1109,7 @@ export async function maybeCalibrate(workflowId: string, wf: WorkflowState, cwd:
|
|
|
1007
1109
|
// Plan-less workflows receive a single-line note describing plan creation and
|
|
1008
1110
|
// attachment. It preserves the parseable phase and checkbox structure and can
|
|
1009
1111
|
// be stripped from session replay without duplicating the user message.
|
|
1010
|
-
function planAuthoringNote(cwd: string, workflowId: string): string {
|
|
1112
|
+
function planAuthoringNote(cwd: string, workflowId: string, publicProject = false): string {
|
|
1011
1113
|
return (
|
|
1012
1114
|
`[No project plan is attached to this Arco workflow. If asked to create/attach one, do NOT just write a ` +
|
|
1013
1115
|
`markdown file — a loose file is invisible to Arco. Prefer the \`plan_create\` tool (MCP server \`arco\`) ` +
|
|
@@ -1024,6 +1126,7 @@ function planAuthoringNote(cwd: string, workflowId: string): string {
|
|
|
1024
1126
|
`docs, which hold the specs/research/design detail. After creating the plan, write each doc with \`plan_ref_write\` ` +
|
|
1025
1127
|
`(or as files at .arco/plans/<planId>.refs/<slug>.md — not loose design files elsewhere in the repo) and link it ` +
|
|
1026
1128
|
`from every task that depends on it as \`[label](ref:slug)\`; whoever works that task reads the linked ref first. ` +
|
|
1129
|
+
(publicProject ? `This project is public. Include a Privacy and public safety section in any new plan, fitted to this project and its risks. ` : '') +
|
|
1027
1130
|
`Don't create a plan unless asked.]\n\n`
|
|
1028
1131
|
);
|
|
1029
1132
|
}
|
|
@@ -1034,7 +1137,10 @@ export async function buildPlanPrefix(
|
|
|
1034
1137
|
workflowId: string,
|
|
1035
1138
|
): Promise<string> {
|
|
1036
1139
|
if (!cwd) return '';
|
|
1037
|
-
if (!wf.planId)
|
|
1140
|
+
if (!wf.planId) {
|
|
1141
|
+
const isPublic = await getEffectivePublicProjectChoice(cwd).catch((error: NodeJS.ErrnoException) => { if (error.code === 'ENOENT') return null; throw error; });
|
|
1142
|
+
return planAuthoringNote(cwd, workflowId, isPublic === true);
|
|
1143
|
+
}
|
|
1038
1144
|
const plan = await readPlan(cwd, wf.planId).catch(() => null);
|
|
1039
1145
|
if (!plan) {
|
|
1040
1146
|
// Plan was deleted out from under us. Detach quietly so future turns
|
|
@@ -1090,9 +1196,10 @@ export async function buildPlanPrefix(
|
|
|
1090
1196
|
return header;
|
|
1091
1197
|
}
|
|
1092
1198
|
|
|
1093
|
-
export function projectQueue(items: QueueItem[]): Array<{ content: string; clientMessageId?: string; interrupt?: boolean }> {
|
|
1199
|
+
export function projectQueue(items: QueueItem[]): Array<{ content: string; clientMessageId?: string; interrupt?: boolean; automaticKind?: import('@arco/shared').AutomaticMessageKind }> {
|
|
1094
1200
|
return items.map((q) => ({
|
|
1095
1201
|
content: q.content,
|
|
1202
|
+
...(q.automaticKind ? { automaticKind: q.automaticKind } : {}),
|
|
1096
1203
|
...(q.interrupt ? { interrupt: true } : {}),
|
|
1097
1204
|
...(q.clientMessageId ? { clientMessageId: q.clientMessageId } : {}),
|
|
1098
1205
|
}));
|
|
@@ -1125,8 +1232,8 @@ export function broadcastQueueUpdate(workflowId: string): void {
|
|
|
1125
1232
|
// shape the post-turn drain uses. The `user_message_echo` was already
|
|
1126
1233
|
// emitted at enqueue time (handleUserMessage) so we don't re-echo here;
|
|
1127
1234
|
// the persisted echo at the original timestamp is the authoritative
|
|
1128
|
-
//
|
|
1129
|
-
//
|
|
1235
|
+
// audit record. Delivery attempt metadata places the input at its confirmed
|
|
1236
|
+
// boundary for provider replay and review, while the live chat keeps the echo.
|
|
1130
1237
|
//
|
|
1131
1238
|
// Retry safety: the drain is destructive (splice) so a same-iteration
|
|
1132
1239
|
// re-call would return []. Provider-side retry loops that call drainSteer
|
|
@@ -1134,37 +1241,48 @@ export function broadcastQueueUpdate(workflowId: string): void {
|
|
|
1134
1241
|
// results and the next streamOneTurn) cannot double-deliver. Recovery
|
|
1135
1242
|
// paths in llamacpp.ts inject their own synthetic user messages and skip
|
|
1136
1243
|
// past the hook — by design.
|
|
1137
|
-
|
|
1244
|
+
const originalSteerItems = new WeakMap<SteerItem, QueueItem>();
|
|
1245
|
+
|
|
1246
|
+
export function drainSteerForWorker(workflowId: string, ws: WebSocket, deliveryProvider?: WorkflowConfig['primaryProvider']): SteerItem[] {
|
|
1138
1247
|
const wf = workflows.get(workflowId);
|
|
1139
1248
|
if (!wf || wf.queue.steering.length === 0 || wf.primaryTurn?.holdSteer || wf.queue.steering.some((q) => q.interrupt)) return [];
|
|
1140
1249
|
const drained = wf.queue.steering.splice(0);
|
|
1250
|
+
const deliveryId = randomUUID();
|
|
1141
1251
|
broadcastQueueUpdate(workflowId);
|
|
1142
1252
|
const drainedClientIds = drained
|
|
1143
1253
|
.map((d) => d.clientMessageId)
|
|
1144
1254
|
.filter((id): id is string => typeof id === 'string' && id.length > 0);
|
|
1145
|
-
if (drainedClientIds.length > 0 && wf.primary.provider !== 'codex') {
|
|
1146
|
-
|
|
1255
|
+
if (drainedClientIds.length > 0 && (deliveryProvider ?? wf.primary.provider) !== 'codex') {
|
|
1256
|
+
broadcastWorkflow(workflowId, { type: 'turn_messages_delivered', workflowId, clientMessageIds: drainedClientIds, deliveryId });
|
|
1147
1257
|
}
|
|
1148
1258
|
if (drainedClientIds.length > 0) {
|
|
1149
1259
|
send(ws, {
|
|
1150
1260
|
type: 'queued_messages_drained',
|
|
1151
1261
|
workflowId,
|
|
1262
|
+
deliveryId,
|
|
1152
1263
|
clientMessageIds: drainedClientIds,
|
|
1153
1264
|
drainedAt: Date.now(),
|
|
1154
1265
|
});
|
|
1155
1266
|
}
|
|
1156
1267
|
console.log(`[arco] [${workflowId.slice(0, 8)}] mid-turn steer drained (${drained.length} item${drained.length === 1 ? '' : 's'}; follow-up bucket untouched)`);
|
|
1157
|
-
return drained.map((d) =>
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1268
|
+
return drained.map((d) => {
|
|
1269
|
+
const pending = clusterToolsPending(wf, clusterStore.getClusterIdForWorkflow(workflowId));
|
|
1270
|
+
const raw = d.expandedContext ? d.content + d.expandedContext : d.content;
|
|
1271
|
+
const item: SteerItem = {
|
|
1272
|
+
deliveryId,
|
|
1273
|
+
// §D1 — mid-turn steer is delivered as a single `content` string through
|
|
1274
|
+
// the provider steer APIs (SteerItem has no separate context block), so a
|
|
1275
|
+
// steer message's expanded `@`-refs ride appended to its content. The echo
|
|
1276
|
+
// already went out compact at enqueue; this only affects what the model
|
|
1277
|
+
// sees mid-turn. Post-turn drain (the loop in handleUserMessage) uses the
|
|
1278
|
+
// separate-block path instead.
|
|
1279
|
+
content: pending ? (d.clusterBusyReminder ? CLUSTER_TOOLS_PENDING_AGENT : `${CLUSTER_TOOLS_PENDING_AGENT}\n\n${raw}`) : raw,
|
|
1280
|
+
...(d.clientMessageId ? { clientMessageId: d.clientMessageId } : {}),
|
|
1281
|
+
...(d.attachments && d.attachments.length > 0 ? { attachments: d.attachments } : {}),
|
|
1282
|
+
};
|
|
1283
|
+
originalSteerItems.set(item, d);
|
|
1284
|
+
return item;
|
|
1285
|
+
});
|
|
1168
1286
|
}
|
|
1169
1287
|
|
|
1170
1288
|
// Phase 6b — re-enqueue support for the Codex app-server worker. The worker
|
|
@@ -1190,7 +1308,7 @@ export function requeueSteerForWorker(
|
|
|
1190
1308
|
if (!wf || items.length === 0) return;
|
|
1191
1309
|
const arr = bucket === 'steer' ? wf.queue.steering : wf.queue.followUp;
|
|
1192
1310
|
for (const item of items) {
|
|
1193
|
-
arr.push({
|
|
1311
|
+
arr.push(originalSteerItems.get(item) ?? {
|
|
1194
1312
|
content: item.content,
|
|
1195
1313
|
...(item.clientMessageId ? { clientMessageId: item.clientMessageId } : {}),
|
|
1196
1314
|
...(item.attachments && item.attachments.length > 0 ? { attachments: item.attachments } : {}),
|
|
@@ -1205,128 +1323,18 @@ export function requeueSteerForWorker(
|
|
|
1205
1323
|
console.log(
|
|
1206
1324
|
`[arco] [${workflowId.slice(0, 8)}] mid-turn steer re-queued (bucket=${bucket}, items=${items.length})`,
|
|
1207
1325
|
);
|
|
1326
|
+
if (!wf.busy) {
|
|
1327
|
+
const epoch = busyRevocations.get(wf) ?? 0;
|
|
1328
|
+
if (!hasRequeuedSteerDrain(wf)) requeuedSteerDrains.set(wf, { epoch, active: false });
|
|
1329
|
+
resumeRequeuedSteer(workflowId, wf);
|
|
1330
|
+
}
|
|
1208
1331
|
// ws is unused today (no per-originator notification); keep the parameter
|
|
1209
1332
|
// for parity with drainSteerForWorker so future per-tab signaling can wire
|
|
1210
1333
|
// through here without re-threading the call sites.
|
|
1211
1334
|
void ws;
|
|
1212
1335
|
}
|
|
1213
1336
|
|
|
1214
|
-
export
|
|
1215
|
-
cwd: string,
|
|
1216
|
-
workflowId: string,
|
|
1217
|
-
config: WorkflowConfig,
|
|
1218
|
-
primary: PrimaryConfig,
|
|
1219
|
-
opts?: { parentWorkflowId?: string },
|
|
1220
|
-
): Promise<void> {
|
|
1221
|
-
// Cheap unlocked probe first (the common resume case); the actual seed goes
|
|
1222
|
-
// through ensureMeta so a check-then-write can't clobber a concurrent
|
|
1223
|
-
// updateMeta landing between the two.
|
|
1224
|
-
const existing = await readMeta(cwd, workflowId);
|
|
1225
|
-
if (existing) return;
|
|
1226
|
-
const now = Date.now();
|
|
1227
|
-
const meta: WorkflowMeta = {
|
|
1228
|
-
workflowId,
|
|
1229
|
-
name: config.name,
|
|
1230
|
-
cwd,
|
|
1231
|
-
...(config.kind === 'chat' ? { kind: 'chat' as const } : {}),
|
|
1232
|
-
...(config.kind === 'chat' && config.voiceOperator === true ? { voiceOperator: true } : {}),
|
|
1233
|
-
createdAt: now,
|
|
1234
|
-
lastActiveAt: now,
|
|
1235
|
-
primaryProvider: primary.provider,
|
|
1236
|
-
primaryModel: primary.model,
|
|
1237
|
-
primaryEffort: primary.effort,
|
|
1238
|
-
...(config.providerAccountRef ? { providerAccountRef: config.providerAccountRef } : {}),
|
|
1239
|
-
cliSessions: [],
|
|
1240
|
-
operator: 'local',
|
|
1241
|
-
lastEventSeq: null,
|
|
1242
|
-
lastTranscriptSeq: null,
|
|
1243
|
-
compactedAt: null,
|
|
1244
|
-
...(config.pinnedSkills?.length
|
|
1245
|
-
? { pinnedSkills: config.pinnedSkills.map((s) => ({ scope: s.scope, slug: s.slug })) }
|
|
1246
|
-
: {}),
|
|
1247
|
-
...(opts?.parentWorkflowId ? { parentWorkflowId: opts.parentWorkflowId } : {}),
|
|
1248
|
-
// docs/PROVIDERS.md / docs/PROVIDERS.md - when the New-tab
|
|
1249
|
-
// picker (or Spawn-from-here parent inheritance) provided a non-default
|
|
1250
|
-
// value, persist it to disk on the very first meta write so a server
|
|
1251
|
-
// restart before the operator's first turn doesn't lose the pick.
|
|
1252
|
-
// Sanitized one more time at write-site against unknown values reaching
|
|
1253
|
-
// disk via a hand-edited cascade default.
|
|
1254
|
-
...(config.efficiencyToolFilter === 'off' || config.efficiencyToolFilter === 'conservative' || config.efficiencyToolFilter === 'aggressive'
|
|
1255
|
-
? { efficiencyToolFilter: config.efficiencyToolFilter }
|
|
1256
|
-
: {}),
|
|
1257
|
-
// docs/PROVIDERS.md - persist the stamped new-tab default or
|
|
1258
|
-
// an explicit operator choice on the first meta write.
|
|
1259
|
-
...(config.efficiencyFactForce === 'on' || config.efficiencyFactForce === 'off'
|
|
1260
|
-
? { efficiencyFactForce: config.efficiencyFactForce }
|
|
1261
|
-
: {}),
|
|
1262
|
-
// Persist an explicit config-protection choice to disk on first meta-write
|
|
1263
|
-
// so an operator opt-out survives a restart. Absent ⇒ gate ON by default.
|
|
1264
|
-
...(config.efficiencyConfigProtection === 'on' || config.efficiencyConfigProtection === 'off'
|
|
1265
|
-
? { efficiencyConfigProtection: config.efficiencyConfigProtection }
|
|
1266
|
-
: {}),
|
|
1267
|
-
...(typeof config.claudeNativeCompact === 'boolean'
|
|
1268
|
-
? {
|
|
1269
|
-
claudeNativeCompact: config.claudeNativeCompact,
|
|
1270
|
-
...(config.claudeNativeCompact === true ? { claudeNativeCompactUserSetAt: now } : {}),
|
|
1271
|
-
}
|
|
1272
|
-
: {}),
|
|
1273
|
-
...(typeof config.claudeNativeForceInterleavedThinkingBeta === 'boolean'
|
|
1274
|
-
? { claudeNativeForceInterleavedThinkingBeta: config.claudeNativeForceInterleavedThinkingBeta }
|
|
1275
|
-
: {}),
|
|
1276
|
-
...(config.claudeNativeThinkingDisplay === 'omitted' || config.claudeNativeThinkingDisplay === 'summarized' || config.claudeNativeThinkingDisplay === 'updates'
|
|
1277
|
-
? { claudeNativeThinkingDisplay: config.claudeNativeThinkingDisplay }
|
|
1278
|
-
: {}),
|
|
1279
|
-
...(config.codexTransport === 'exec' || config.codexTransport === 'appserver'
|
|
1280
|
-
? { codexTransport: config.codexTransport }
|
|
1281
|
-
: {}),
|
|
1282
|
-
...(config.codexContextPolicy === 'max' || config.codexContextPolicy === 'standard'
|
|
1283
|
-
? { codexContextPolicy: config.codexContextPolicy }
|
|
1284
|
-
: {}),
|
|
1285
|
-
...(config.claudeTransport === 'cli' || config.claudeTransport === 'native'
|
|
1286
|
-
? { claudeTransport: config.claudeTransport }
|
|
1287
|
-
: {}),
|
|
1288
|
-
// Persist the seeded auto-handoff default on the first meta-write so a
|
|
1289
|
-
// server restart before the operator's first turn keeps the global
|
|
1290
|
-
// default (handleCreateWorkflow bakes it into config for new tabs). The
|
|
1291
|
-
// savedMeta restore in handleCreateWorkflow reads this back.
|
|
1292
|
-
...(isAutoCompactionPolicy(config.autoCompaction) ? { autoCompaction: { ...config.autoCompaction } } : {}),
|
|
1293
|
-
...(config.autoHandoff ? { autoHandoff: { ...config.autoHandoff } } : {}),
|
|
1294
|
-
// docs/PROVIDERS.md - persist the sandbox toggle on the
|
|
1295
|
-
// first meta-write when the cascade default supplied a non-undefined
|
|
1296
|
-
// value. Default is 'off'; only the explicit on/off pair lands here so
|
|
1297
|
-
// a stale cascade doesn't accidentally turn the sandbox on for tabs
|
|
1298
|
-
// that were never asked.
|
|
1299
|
-
...(config.efficiencySandbox === 'on' || config.efficiencySandbox === 'off'
|
|
1300
|
-
? { efficiencySandbox: config.efficiencySandbox }
|
|
1301
|
-
: {}),
|
|
1302
|
-
// docs/PROVIDERS.md - persist the review-gate toggle on the first meta-write
|
|
1303
|
-
// when the cascade default supplied an explicit value, so an operator opt-in
|
|
1304
|
-
// survives a restart before the first turn. Default 'off'.
|
|
1305
|
-
...(config.reviewSafeMode === 'on' || config.reviewSafeMode === 'off'
|
|
1306
|
-
? { reviewSafeMode: config.reviewSafeMode }
|
|
1307
|
-
: {}),
|
|
1308
|
-
...((config.outputStyle === 'lite' || config.outputStyle === 'terse')
|
|
1309
|
-
? { outputStyle: config.outputStyle }
|
|
1310
|
-
// Legacy `caveman` from a stale client → write `terse` to disk.
|
|
1311
|
-
: (config.outputStyle as string) === 'caveman'
|
|
1312
|
-
? { outputStyle: 'terse' as const }
|
|
1313
|
-
: {}),
|
|
1314
|
-
// docs/GOTCHAS.md - persist a north-star seeded before the first turn
|
|
1315
|
-
// (e.g. a Spawn-from-here that inherited the parent's) so it survives a
|
|
1316
|
-
// restart even if the operator never re-sets it. Blank ⇒ omitted.
|
|
1317
|
-
...(config.goal && config.goal.trim() ? { goal: config.goal } : {}),
|
|
1318
|
-
// docs/PROVIDERS.md - persist sticky ultracode on the first meta-write so a
|
|
1319
|
-
// tab left in ultracode survives a restart (the rehydrate read in
|
|
1320
|
-
// workflowHandlers.ts expects saved.ultracode). Without this the flag lives
|
|
1321
|
-
// only in-memory and the tab silently drops out of ultracode on restart.
|
|
1322
|
-
...(config.ultracode === true ? { ultracode: true } : {}),
|
|
1323
|
-
...(typeof config.webSearchMaxUses === 'number' ? { webSearchMaxUses: config.webSearchMaxUses } : {}),
|
|
1324
|
-
...(config.managedWorktreeSourceCwd
|
|
1325
|
-
? { managedWorktreeSourceCwd: config.managedWorktreeSourceCwd }
|
|
1326
|
-
: {}),
|
|
1327
|
-
};
|
|
1328
|
-
await ensureMeta(cwd, meta);
|
|
1329
|
-
}
|
|
1337
|
+
export { persistInitialMeta } from '../workflowMeta.js';
|
|
1330
1338
|
|
|
1331
1339
|
export async function writeCalibrationToMeta(
|
|
1332
1340
|
cwd: string,
|
|
@@ -1342,6 +1350,18 @@ export async function writeCalibrationToMeta(
|
|
|
1342
1350
|
});
|
|
1343
1351
|
}
|
|
1344
1352
|
|
|
1353
|
+
// Automatic busy reminders use the same steering queue as a manual nudge.
|
|
1354
|
+
// Losing the busy turn during async preparation drops the reminder instead
|
|
1355
|
+
// of creating a new turn or steering a newer generation.
|
|
1356
|
+
export async function enqueueBusyReminder(workflowId: string, content: string, allow?: () => boolean): Promise<boolean> {
|
|
1357
|
+
let accepted = false;
|
|
1358
|
+
const ws = { readyState: WebSocket.CLOSED, send: () => undefined } as unknown as WebSocket;
|
|
1359
|
+
const session = { id: 'busy-reminder', workflowIds: new Set([workflowId]), clusterIds: new Set<string>(), clusterObserved: new Map() } as Session;
|
|
1360
|
+
await handleUserMessage(ws,session,workflowId,content,undefined,undefined,true,'steer',undefined,undefined,
|
|
1361
|
+
{ automaticKind: 'auto-pickup', clusterBusyReminder: true, busyOnly: true, busyOnlyGuard: allow, onBusyQueued: () => { accepted = true; } });
|
|
1362
|
+
return accepted;
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1345
1365
|
export async function handleUserMessage(
|
|
1346
1366
|
ws: WebSocket,
|
|
1347
1367
|
session: Session,
|
|
@@ -1352,10 +1372,10 @@ export async function handleUserMessage(
|
|
|
1352
1372
|
interjection: boolean,
|
|
1353
1373
|
kind: 'steer' | 'follow-up' | 'interrupt' | undefined,
|
|
1354
1374
|
primitive: 'docs' | 'git' | 'plan-review' | undefined,
|
|
1355
|
-
pickedSkills?: Array<{ scope: 'project' | 'global'; slug: string }>,
|
|
1375
|
+
pickedSkills?: Array<{ scope: 'project' | 'global' | 'builtin'; slug: string }>,
|
|
1356
1376
|
// drainQueueIfIdle only: take the prompt from wf.queue at claim time
|
|
1357
1377
|
// instead of `content` (items were echoed + expanded at enqueue).
|
|
1358
|
-
opts?: { fromQueue?: boolean; backgroundEvent?: boolean; onBackgroundSettled?: (error?: string) => void; claimGuard?: (claim: () => boolean) => Promise<boolean> },
|
|
1378
|
+
opts?: { clusterBusyReminder?: boolean; automaticKind?: import('@arco/shared').AutomaticMessageKind; fromQueue?: boolean; busyOnly?: boolean; busyOnlyGuard?: () => boolean; onBusyQueued?: () => void; backgroundEvent?: boolean; onBackgroundSettled?: (error?: string) => void; claimGuard?: (claim: () => boolean) => Promise<boolean> },
|
|
1359
1379
|
): Promise<void> {
|
|
1360
1380
|
const fromQueue = opts?.fromQueue === true;
|
|
1361
1381
|
const wf = workflows.get(workflowId);
|
|
@@ -1363,6 +1383,14 @@ export async function handleUserMessage(
|
|
|
1363
1383
|
send(ws, { type: 'error', message: `Unknown workflow ${workflowId.slice(0, 8)}` });
|
|
1364
1384
|
return;
|
|
1365
1385
|
}
|
|
1386
|
+
if (storageMigrations.has(wf)) {
|
|
1387
|
+
send(ws, { type: 'error', message: 'Message not sent: workflow storage is moving. Wait for the scaffold to finish, then resend.' });
|
|
1388
|
+
return;
|
|
1389
|
+
}
|
|
1390
|
+
incomingMessages.set(wf, (incomingMessages.get(wf) ?? 0) + 1);
|
|
1391
|
+
try {
|
|
1392
|
+
const busyOnlyClaim = lastBusyClaim.get(wf);
|
|
1393
|
+
if (opts?.busyOnly && !wf.busy) return;
|
|
1366
1394
|
const interruptEpoch = busyRevocations.get(wf) ?? 0;
|
|
1367
1395
|
const cwd = wf.config.workingDirectory;
|
|
1368
1396
|
if (!cwd) {
|
|
@@ -1373,7 +1401,7 @@ export async function handleUserMessage(
|
|
|
1373
1401
|
const chatMode = isChatWorkflow(wf.config);
|
|
1374
1402
|
const incognito = chatMode && wf.config.incognito === true;
|
|
1375
1403
|
const trackOllama = wf.primary.provider === 'ollama' && !chatMode;
|
|
1376
|
-
if (
|
|
1404
|
+
if (!clientMessageId) clientMessageId = randomUUID();
|
|
1377
1405
|
// Chat tabs expose no project tools; web_search/web_fetch is the one
|
|
1378
1406
|
// exception the operator can arm (default on for a saved Chat). Computed per
|
|
1379
1407
|
// turn so the header toggle takes effect on the next message, and passed
|
|
@@ -1401,6 +1429,26 @@ export async function handleUserMessage(
|
|
|
1401
1429
|
return;
|
|
1402
1430
|
}
|
|
1403
1431
|
|
|
1432
|
+
// Explicit built-in slash commands are resolved before queueing, so queued
|
|
1433
|
+
// turns retain the same pick. A trusted project or global copy takes priority.
|
|
1434
|
+
if (projectContextEnabled && !fromQueue) {
|
|
1435
|
+
const invocation = /^\/(grill-me|grill-with-docs|wait-what|retro|improve-codebase-architecture)(?:\s|$)/i.exec(content);
|
|
1436
|
+
if (invocation) {
|
|
1437
|
+
const requested = invocation[1].toLowerCase();
|
|
1438
|
+
const slug = requested === 'improve-codebase-architecture' ? 'architecture-review' : requested;
|
|
1439
|
+
const include = await projectTrust.resolveTrustStatus(managedTrustSource ?? cwd).catch(() => 'ask' as const) === 'always';
|
|
1440
|
+
const catalog = await listSkills(cwd, { includeProject: include });
|
|
1441
|
+
const own = [...catalog.project, ...catalog.global].find((s) => s.slug.toLowerCase() === requested || s.name.toLowerCase() === requested);
|
|
1442
|
+
const builtin = catalog.builtin.find((s) => s.slug === slug);
|
|
1443
|
+
if (own?.off || (!own && builtin?.off)) {
|
|
1444
|
+
send(ws, { type: 'error', workflowId, message: `/${requested} is turned off.` });
|
|
1445
|
+
return;
|
|
1446
|
+
}
|
|
1447
|
+
if (own) pickedSkills = [...(pickedSkills ?? []), { scope: own.scope, slug: own.slug }];
|
|
1448
|
+
else if (builtin && !builtin.replaced) pickedSkills = [...(pickedSkills ?? []), { scope: 'builtin', slug }];
|
|
1449
|
+
}
|
|
1450
|
+
}
|
|
1451
|
+
|
|
1404
1452
|
// DD10 — parameterized `/prompt` command expansion. Runs FIRST (before
|
|
1405
1453
|
// context-refs + before any echo/record) so events.jsonl carries the expanded
|
|
1406
1454
|
// turn, and so `@`-refs inside an expanded template still expand below. A
|
|
@@ -1445,7 +1493,7 @@ export async function handleUserMessage(
|
|
|
1445
1493
|
// for queued). A system_notice summarizes the expansion so it's visible +
|
|
1446
1494
|
// reviewable in events.jsonl (the four-question test). Never throws — the
|
|
1447
1495
|
// expander converts every failure to a notice.
|
|
1448
|
-
const contextExpansion = !projectContextEnabled || fromQueue
|
|
1496
|
+
const contextExpansion: ContextExpansion = !projectContextEnabled || fromQueue
|
|
1449
1497
|
? { block: '', notices: [], expandedCount: 0 }
|
|
1450
1498
|
: await expandContextRefs(cwd, content, { windowSize: lookupCtx(wf.primary.model) }).catch((err) => {
|
|
1451
1499
|
console.error(`[arco] [${workflowId.slice(0, 8)}] context-ref expansion failed:`, err);
|
|
@@ -1462,10 +1510,25 @@ export async function handleUserMessage(
|
|
|
1462
1510
|
});
|
|
1463
1511
|
}
|
|
1464
1512
|
let expandedContext = contextExpansion.block || undefined;
|
|
1513
|
+
const contextAttachments = contextExpansion.attachments ?? [];
|
|
1514
|
+
|
|
1515
|
+
const editPickedSkills = Array.isArray(pickedSkills)
|
|
1516
|
+
? pickedSkills.filter(p => p && ['project', 'global', 'builtin'].includes(p.scope) && typeof p.slug === 'string' && p.slug.length > 0)
|
|
1517
|
+
.filter((p, index, all) => all.findIndex(other => other.scope === p.scope && other.slug === p.slug) === index)
|
|
1518
|
+
.map(({ scope, slug }) => ({ scope, slug })) : undefined;
|
|
1519
|
+
pickedSkills = editPickedSkills;
|
|
1520
|
+
|
|
1521
|
+
// A synchronous provider drain cannot load one-shot skills. Resolve them
|
|
1522
|
+
// before admitting a busy send; both drain paths then carry the same block.
|
|
1523
|
+
if (wf.busy && pickedSkills?.length) {
|
|
1524
|
+
const selectedBlock = await resolvePickedSkillsBlock(pickedSkills);
|
|
1525
|
+
if (selectedBlock) expandedContext = `${expandedContext ?? ''}\n\n${selectedBlock}`;
|
|
1526
|
+
pickedSkills = undefined;
|
|
1527
|
+
}
|
|
1465
1528
|
|
|
1466
|
-
// STOP/removal during async ref/trust preparation
|
|
1467
|
-
//
|
|
1468
|
-
if (
|
|
1529
|
+
// STOP/removal during async ref/trust preparation revokes every pending
|
|
1530
|
+
// send, before it can claim a fresh busy token or enter either queue.
|
|
1531
|
+
if (workflows.get(workflowId) !== wf || (busyRevocations.get(wf) ?? 0) !== interruptEpoch) {
|
|
1469
1532
|
if (clientMessageId) send(ws, { type: 'queued_message_cancelled', workflowId, clientMessageId });
|
|
1470
1533
|
return;
|
|
1471
1534
|
}
|
|
@@ -1479,8 +1542,9 @@ export async function handleUserMessage(
|
|
|
1479
1542
|
// the closest fit). Phase 4 ships visible/rebindable; both kinds still
|
|
1480
1543
|
// drain post-turn — Phases 5–7 turn on real mid-turn delivery for steer
|
|
1481
1544
|
// per provider.
|
|
1482
|
-
if (opts?.
|
|
1483
|
-
if (wf.busy || wf.computerResetting)
|
|
1545
|
+
if (opts?.busyOnly && (!wf.busy || wf.computerResetting || lastBusyClaim.get(wf) !== busyOnlyClaim || (opts.busyOnlyGuard && !opts.busyOnlyGuard()))) return;
|
|
1546
|
+
if (opts?.claimGuard && (wf.busy || wf.computerResetting || hasRequeuedSteerDrain(wf))) return;
|
|
1547
|
+
if (wf.busy || wf.computerResetting || (!fromQueue && hasRequeuedSteerDrain(wf))) {
|
|
1484
1548
|
if (primitive === 'plan-review') {
|
|
1485
1549
|
send(ws, { type: 'system_notice', workflowId, content: '[PLAN DRAFT NOT STARTED] Wait for the current turn to finish, then try again.' });
|
|
1486
1550
|
return;
|
|
@@ -1493,6 +1557,11 @@ export async function handleUserMessage(
|
|
|
1493
1557
|
// but we still queue rather than error — drops fewer operator messages.
|
|
1494
1558
|
console.warn(`[arco] [${workflowId.slice(0, 8)}] user_message while busy without interjection flag — queuing anyway`);
|
|
1495
1559
|
}
|
|
1560
|
+
const toolsPending = clusterToolsPending(wf, clusterStore.getClusterIdForWorkflow(workflowId));
|
|
1561
|
+
if (opts?.clusterBusyReminder && toolsPending) return;
|
|
1562
|
+
if (toolsPending && !opts?.clusterBusyReminder && opts?.automaticKind !== 'auto-pickup' && !opts?.backgroundEvent) broadcastWorkflow(workflowId, {
|
|
1563
|
+
type: 'system_notice', workflowId, content: CLUSTER_TOOLS_PENDING_NOTICE,
|
|
1564
|
+
});
|
|
1496
1565
|
const interrupt = kind === 'interrupt' && !wf.config.voiceOperator
|
|
1497
1566
|
&& (wf.primary.provider === 'claude' || wf.primary.provider === 'codex')
|
|
1498
1567
|
&& wf.primaryTurn !== undefined && ownsBusy(wf, wf.primaryTurn.token);
|
|
@@ -1503,16 +1572,20 @@ export async function handleUserMessage(
|
|
|
1503
1572
|
content: '[INTERRUPT & SEND] No interruptible Claude or Codex primary turn is running. Your message is queued as a follow-up.',
|
|
1504
1573
|
});
|
|
1505
1574
|
const arr = bucket === 'steer' ? wf.queue.steering : wf.queue.followUp;
|
|
1506
|
-
const
|
|
1575
|
+
const queuedAttachments = [...new Set([...(attachments ?? []), ...contextAttachments])];
|
|
1576
|
+
const queuedItem = { clusterBusyReminder: opts?.clusterBusyReminder, automaticKind: opts?.automaticKind, content, attachments: isolatedMember || !queuedAttachments.length ? undefined : queuedAttachments, clientMessageId, expandedContext, pickedSkills, editPickedSkills, ollamaInputSeq: undefined as number | undefined, ...(interrupt ? { interrupt: true } : {}) };
|
|
1507
1577
|
arr.push(queuedItem);
|
|
1578
|
+
opts?.onBusyQueued?.();
|
|
1508
1579
|
send(ws, {
|
|
1509
1580
|
type: 'user_message_echo',
|
|
1510
1581
|
workflowId,
|
|
1582
|
+
...(opts?.automaticKind ? { automaticKind: opts.automaticKind } : {}),
|
|
1511
1583
|
content,
|
|
1512
1584
|
attachments,
|
|
1513
1585
|
clientMessageId,
|
|
1514
1586
|
timestamp: Date.now(),
|
|
1515
1587
|
kind: interrupt ? 'interrupt' : bucket,
|
|
1588
|
+
deliveryTracked: true,
|
|
1516
1589
|
...(trackOllama ? { ollamaReplayInput: true } : {}),
|
|
1517
1590
|
});
|
|
1518
1591
|
if (trackOllama) queuedItem.ollamaInputSeq = currentWorkflowSeq(cwd, workflowId);
|
|
@@ -1557,6 +1630,7 @@ export async function handleUserMessage(
|
|
|
1557
1630
|
send(ws, {
|
|
1558
1631
|
type: 'user_message_echo',
|
|
1559
1632
|
workflowId,
|
|
1633
|
+
...(opts?.automaticKind ? { automaticKind: opts.automaticKind } : {}),
|
|
1560
1634
|
content,
|
|
1561
1635
|
attachments,
|
|
1562
1636
|
clientMessageId,
|
|
@@ -1579,6 +1653,7 @@ export async function handleUserMessage(
|
|
|
1579
1653
|
// must leave the queue available for an explicit later attempt.
|
|
1580
1654
|
assertCheckoutAvailable(workflowWritePaths(wf));
|
|
1581
1655
|
let activeOllamaInputSeqs: number[] = [];
|
|
1656
|
+
let activeInputClientIds: string[] = [];
|
|
1582
1657
|
if (fromQueue) {
|
|
1583
1658
|
const drained = takeQueuedTurn(wf.queue);
|
|
1584
1659
|
if (drained.length === 0) return;
|
|
@@ -1590,6 +1665,7 @@ export async function handleUserMessage(
|
|
|
1590
1665
|
if (drainedClientIds.length > 0) {
|
|
1591
1666
|
send(ws, { type: 'queued_messages_drained', workflowId, clientMessageIds: drainedClientIds, drainedAt: Date.now() });
|
|
1592
1667
|
}
|
|
1668
|
+
activeInputClientIds = drained.flatMap(item => item.clientMessageId ? [item.clientMessageId] : []);
|
|
1593
1669
|
activeOllamaInputSeqs = drained.every(d => d.ollamaInputSeq) ? drained.map(d => d.ollamaInputSeq!) : [];
|
|
1594
1670
|
content = drained.map((d) => d.content).join('\n\n');
|
|
1595
1671
|
const mergedAttachments = drained.flatMap((d) => d.attachments ?? []);
|
|
@@ -1608,7 +1684,7 @@ export async function handleUserMessage(
|
|
|
1608
1684
|
await opts.claimGuard(() => {
|
|
1609
1685
|
// Async preflight may have lost to STOP, a real operator turn or removal.
|
|
1610
1686
|
// Conditional nudges must never fall into the ordinary follow-up queue.
|
|
1611
|
-
if (workflows.get(workflowId) !== wf || wf.busy || wf.computerResetting || wf.queue.steering.length || wf.queue.followUp.length
|
|
1687
|
+
if (workflows.get(workflowId) !== wf || (busyRevocations.get(wf) ?? 0) !== interruptEpoch || wf.busy || wf.computerResetting || wf.queue.steering.length || wf.queue.followUp.length
|
|
1612
1688
|
|| (wf.lastForeignWriteAt && Date.now() - wf.lastForeignWriteAt < FOREIGN_WRITE_BLOCK_MS)) return false;
|
|
1613
1689
|
guardedToken = claimBusy(wf); return true;
|
|
1614
1690
|
});
|
|
@@ -1626,7 +1702,8 @@ export async function handleUserMessage(
|
|
|
1626
1702
|
if (opts?.backgroundEvent) setComputerBackgroundClaim(workflowId, busyToken);
|
|
1627
1703
|
let prompt: string = content;
|
|
1628
1704
|
let promptPickedSkills = pickedSkills;
|
|
1629
|
-
|
|
1705
|
+
const initialAttachments = [...new Set([...(attachments ?? []), ...contextAttachments])];
|
|
1706
|
+
let promptAttachments: string[] | undefined = isolatedMember || !initialAttachments.length ? undefined : initialAttachments;
|
|
1630
1707
|
let promptClientMessageId: string | undefined = clientMessageId;
|
|
1631
1708
|
// §D1 — expanded `@`-context-refs for the current iteration's prompt. First
|
|
1632
1709
|
// iteration uses the immediate-send expansion; drain iterations rebuild it
|
|
@@ -1654,6 +1731,7 @@ export async function handleUserMessage(
|
|
|
1654
1731
|
const ids = drained.flatMap((d) => d.clientMessageId ? [d.clientMessageId] : []);
|
|
1655
1732
|
if (ids.length) send(ws, { type: 'queued_messages_drained', workflowId,
|
|
1656
1733
|
clientMessageIds: ids, drainedAt: Date.now() });
|
|
1734
|
+
activeInputClientIds = [...(append ? activeInputClientIds : []), ...drained.flatMap(item => item.clientMessageId ? [item.clientMessageId] : [])];
|
|
1657
1735
|
activeOllamaInputSeqs = drained.every(d => d.ollamaInputSeq) ? [...(append ? activeOllamaInputSeqs : []), ...drained.map(d => d.ollamaInputSeq!)] : [];
|
|
1658
1736
|
prompt = [...(append ? [prompt] : []), ...drained.map((d) => d.content)].join('\n\n');
|
|
1659
1737
|
const files = [...(append ? promptAttachments ?? [] : []), ...drained.flatMap((d) => d.attachments ?? [])];
|
|
@@ -1716,10 +1794,25 @@ export async function handleUserMessage(
|
|
|
1716
1794
|
// unreadable skill is skipped with a notice rather than failing the turn.
|
|
1717
1795
|
async function resolvePickedSkillsBlock(picks: typeof pickedSkills): Promise<string> {
|
|
1718
1796
|
if (!projectContextEnabled || !picks?.length) return '';
|
|
1719
|
-
const resolved: Array<{ name: string; scope: 'project' | 'global'; body: string }> = [];
|
|
1797
|
+
const resolved: Array<{ name: string; scope: 'project' | 'global' | 'builtin'; body: string }> = [];
|
|
1720
1798
|
const missing: string[] = [];
|
|
1721
1799
|
for (const pick of picks) {
|
|
1722
1800
|
try {
|
|
1801
|
+
if (pick.scope === 'builtin') {
|
|
1802
|
+
// Built-in skills ship with Arco. The Architecture review also gets
|
|
1803
|
+
// the facts Arco gathers now and the project's recorded decisions.
|
|
1804
|
+
const builtin = readBuiltinSkill(pick.slug);
|
|
1805
|
+
if (!builtin) { missing.push(`builtin:${pick.slug}`); continue; }
|
|
1806
|
+
const trust = await projectTrust.resolveTrustStatus(managedTrustSource ?? cwd).catch(() => 'ask' as const);
|
|
1807
|
+
const catalog = await listSkills(cwd, { includeProject: trust === 'always' });
|
|
1808
|
+
const summary = catalog.builtin.find((s) => s.slug === builtin.slug);
|
|
1809
|
+
if (!summary || summary.off || summary.replaced) { missing.push(`builtin:${pick.slug}`); continue; }
|
|
1810
|
+
const extra = builtin.slug === ARCHITECTURE_REVIEW_SLUG
|
|
1811
|
+
? `\n\nArtifacts folder for this conversation: ${artifactsDir(cwd, workflowId)}\n\n${await architectureReviewFacts(cwd, wf?.planId ?? clusterStore.getPlanId(clusterStore.getClusterIdForWorkflow(workflowId) ?? ''))}`
|
|
1812
|
+
: `\n\nThe available skill files are listed in the skill manifest.`;
|
|
1813
|
+
resolved.push({ name: builtin.name, scope: 'builtin', body: builtin.body + extra });
|
|
1814
|
+
continue;
|
|
1815
|
+
}
|
|
1723
1816
|
const full = await readSkillBody(pick.scope, pick.slug, cwd);
|
|
1724
1817
|
if (full) resolved.push({ name: full.name, scope: full.scope, body: full.body });
|
|
1725
1818
|
else missing.push(`${pick.scope}:${pick.slug}`);
|
|
@@ -1772,103 +1865,44 @@ export async function handleUserMessage(
|
|
|
1772
1865
|
// update_primary_config so the operator's choice doesn't depend on a
|
|
1773
1866
|
// hand-edited settings.json.
|
|
1774
1867
|
const cascade = await readSettings(cwd, { includeProject }).catch(() => null);
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
//
|
|
1783
|
-
//
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
:
|
|
1791
|
-
|
|
1792
|
-
|
|
1868
|
+
// turnSettings.ts — which value wins for each per-turn setting (tab
|
|
1869
|
+
// choice, settings files, default; Native-only switches off elsewhere).
|
|
1870
|
+
const {
|
|
1871
|
+
codexTransport, ultracode, claudeTransport, claudeNativeCompact, claudeNativeForceInterleavedThinkingBeta,
|
|
1872
|
+
claudeNativeThinkingDisplay, nativeSubagents, efficiencyToolFilter, efficiencyFactForce, efficiencyConfigProtection,
|
|
1873
|
+
efficiencySandbox, reviewSafeMode, outputStyle, goal, ollamaParams,
|
|
1874
|
+
} = resolveTurnSettings({ provider: wf.primary.provider, config: wf.config, cascade, isolatedMember, primitive });
|
|
1875
|
+
// In-turn compaction follows the tab's or cluster's auto-compaction policy
|
|
1876
|
+
// (the plan-review step, a Chat-style request, leaves it off below).
|
|
1877
|
+
const inTurnClusterId = clusterStore.getClusterIdForWorkflow(workflowId);
|
|
1878
|
+
const claudeNativeInTurnCompactPercent = wf.primary.provider === 'claude'
|
|
1879
|
+
? resolveNativeInTurnCompactPercent({
|
|
1880
|
+
native: claudeTransport === 'native',
|
|
1881
|
+
chat: isChatWorkflow(wf.config),
|
|
1882
|
+
claudeNativeCompact,
|
|
1883
|
+
worker: wf.config.autoCompaction ?? undefined,
|
|
1884
|
+
cluster: inTurnClusterId ? clusterStore.getAutoCompaction(inTurnClusterId) : undefined,
|
|
1885
|
+
})
|
|
1886
|
+
: undefined;
|
|
1793
1887
|
const providerAccount = wf.primary.provider === 'codex'
|
|
1794
1888
|
? await resolveProviderAccount('codex', wf.config.providerAccountRef, cwd).catch(() => null)
|
|
1795
1889
|
: null;
|
|
1796
1890
|
if (providerAccount?.profile.id && wf.config.providerAccountRef !== providerAccount.profile.id) {
|
|
1797
1891
|
wf.config.providerAccountRef = providerAccount.profile.id;
|
|
1798
1892
|
}
|
|
1799
|
-
// Anthropic server-side compaction (`compact_20260112`). Defaults OFF for
|
|
1800
|
-
// Native tabs (NATIVE_COMPACTION_PLAN §1) — seeded into config at tab
|
|
1801
|
-
// creation, so by here it's a concrete boolean; an absent value also reads
|
|
1802
|
-
// as off. CLI Claude handles compaction inside the CLI process so the flag
|
|
1803
|
-
// is moot there.
|
|
1804
|
-
const claudeNativeCompact: boolean = claudeTransport === 'native'
|
|
1805
|
-
? wf.config.claudeNativeCompact === true
|
|
1806
|
-
: false;
|
|
1807
|
-
const claudeNativeForceInterleavedThinkingBeta: boolean = claudeTransport === 'native'
|
|
1808
|
-
? wf.config.claudeNativeForceInterleavedThinkingBeta === true
|
|
1809
|
-
: false;
|
|
1810
|
-
// Adaptive-thinking display for the Native worker. Absent ⇒ 'omitted'
|
|
1811
|
-
// (Claude-Code parity — no thinking streamed back); 'summarized' streams
|
|
1812
|
-
// summarized thinking into the Activity tab.
|
|
1813
|
-
const claudeNativeThinkingDisplay: 'omitted' | 'summarized' | 'updates' | undefined = claudeTransport === 'native'
|
|
1814
|
-
? wf.config.claudeNativeThinkingDisplay
|
|
1815
|
-
: undefined;
|
|
1816
|
-
// docs/PROVIDERS.md - Native tool-result filter mode. Only honored
|
|
1817
|
-
// on Native (the filter pipeline runs inside `claude-native/dispatchTool`;
|
|
1818
|
-
// CLI/Codex don't surface raw tool stdout to us). Default off until measured
|
|
1819
|
-
// per the §13.3 / §2.4 doc-discipline rule (no aggressive defaults).
|
|
1820
|
-
const efficiencyToolFilter: 'off' | 'conservative' | 'aggressive' = claudeTransport === 'native'
|
|
1821
|
-
? (wf.config.efficiencyToolFilter ?? 'off')
|
|
1822
|
-
: 'off';
|
|
1823
|
-
// docs/PROVIDERS.md - fact-force first-edit gate mode. It is
|
|
1824
|
-
// opt-in: new tabs and rehydrated tabs without the field stay 'off'. CLI
|
|
1825
|
-
// parity is deferred (master §3.3 F4), so hard-zero non-Native transports.
|
|
1826
|
-
const efficiencyFactForce: 'on' | 'off' = claudeTransport === 'native'
|
|
1827
|
-
? (wf.config.efficiencyFactForce ?? 'off')
|
|
1828
|
-
: 'off';
|
|
1829
|
-
// Config-protection write-gate. Default 'on' (safety gate); the operator
|
|
1830
|
-
// opts out per-tab. Native-only (the gate lives in the Native worker), so
|
|
1831
|
-
// we hard-zero non-Native transports to 'off' to avoid a meaningless flag.
|
|
1832
|
-
const efficiencyConfigProtection: 'on' | 'off' = claudeTransport === 'native'
|
|
1833
|
-
? (wf.config.efficiencyConfigProtection ?? 'on')
|
|
1834
|
-
: 'off';
|
|
1835
|
-
const efficiencySandbox: 'off' | 'on' = claudeTransport === 'native' && !isolatedMember
|
|
1836
|
-
? (wf.config.efficiencySandbox ?? 'off')
|
|
1837
|
-
: 'off';
|
|
1838
|
-
// docs/PROVIDERS.md - operator-armed durable review gate. Native-only (the gate
|
|
1839
|
-
// lives in the in-process worker's dispatchTool). Default 'off' so it stays
|
|
1840
|
-
// operator-opted-in and inert until armed.
|
|
1841
|
-
const reviewSafeMode: 'off' | 'on' = claudeTransport === 'native'
|
|
1842
|
-
? (wf.config.reviewSafeMode ?? 'off')
|
|
1843
|
-
: 'off';
|
|
1844
|
-
// docs/PROVIDERS.md - operator-armed terseness picker. Honored by
|
|
1845
|
-
const outputStyleSupported =
|
|
1846
|
-
(wf.primary.provider === 'claude' && claudeTransport === 'native') ||
|
|
1847
|
-
(wf.primary.provider === 'codex' && codexTransport === 'appserver');
|
|
1848
|
-
const outputStyle: 'normal' | 'lite' | 'terse' = primitive === 'docs' || primitive === 'git'
|
|
1849
|
-
? 'normal'
|
|
1850
|
-
: outputStyleSupported
|
|
1851
|
-
? (wf.config.outputStyle ?? 'normal')
|
|
1852
|
-
: 'normal';
|
|
1853
|
-
// docs/GOTCHAS.md - operator-set persistent north-star. Read straight
|
|
1854
|
-
// from wf.config, inherited on EVERY path including in-tab DOCS / GIT (the one
|
|
1855
|
-
// deliberate divergence from outputStyle's forced 'normal' for those two — a
|
|
1856
|
-
// DOCS/GIT prompt benefits from the goal context). Absent / blank ⇒ no block
|
|
1857
|
-
// on any transport; honored wherever clusterPlan is folded.
|
|
1858
|
-
const goal: string | undefined = isolatedMember ? undefined : wf.config.goal;
|
|
1859
|
-
// docs/PROVIDERS.md - per-tab Ollama param preset blob. Resolved
|
|
1860
|
-
// ONLY for Ollama tabs (the provider's request builder is the sole consumer;
|
|
1861
|
-
// every other provider ignores the field). Read straight from wf.config so
|
|
1862
|
-
// it is byte-stable across this workflow's turns — the prefix-cache
|
|
1863
|
-
// invariant. The operator-edit path (updatePrimaryConfig) is the only place
|
|
1864
|
-
// it changes between turns, and that's logged as a cache-invalidation event.
|
|
1865
|
-
const ollamaParams: Record<string, unknown> | undefined = wf.primary.provider === 'ollama'
|
|
1866
|
-
? wf.config.ollamaParams
|
|
1867
|
-
: undefined;
|
|
1868
1893
|
|
|
1894
|
+
if (!incognito) {
|
|
1895
|
+
await ensureWorkflowMetadata(cwd, workflowId, wf);
|
|
1896
|
+
wf.providerConversation = await providerConversationState(cwd, workflowId, wf);
|
|
1897
|
+
if (wf.providerConversation) broadcastTransient(workflowId, { type: 'provider_conversation_state', workflowId, state: wf.providerConversation });
|
|
1898
|
+
}
|
|
1899
|
+
let sessionSave: Promise<void> = Promise.resolve();
|
|
1900
|
+
let hasFreshContextReading = false;
|
|
1869
1901
|
let activeTurnObservation: ReturnType<typeof observeCheckoutWriters> | undefined;
|
|
1870
1902
|
try {
|
|
1871
1903
|
while (true) {
|
|
1904
|
+
primaryTurn.clusterDispatch = undefined;
|
|
1905
|
+
hasFreshContextReading = false;
|
|
1872
1906
|
const pickedSkillsBlock = await resolvePickedSkillsBlock(promptPickedSkills);
|
|
1873
1907
|
console.log(`[arco] [${workflowId.slice(0, 8)}] user_message received; starting primary turn (${wf.primary.provider}:${wf.primary.model}, resume=${wf.primarySessionId?.slice(0, 8) || 'none'})`);
|
|
1874
1908
|
|
|
@@ -1916,12 +1950,15 @@ export async function handleUserMessage(
|
|
|
1916
1950
|
if (!fromQueue) send(ws, {
|
|
1917
1951
|
type: 'user_message_echo',
|
|
1918
1952
|
workflowId,
|
|
1953
|
+
...(opts?.automaticKind ? { automaticKind: opts.automaticKind } : {}),
|
|
1919
1954
|
content: prompt,
|
|
1920
1955
|
attachments: promptAttachments,
|
|
1921
1956
|
clientMessageId: promptClientMessageId,
|
|
1957
|
+
deliveryTracked: true,
|
|
1922
1958
|
timestamp: Date.now(),
|
|
1923
1959
|
...(trackOllama ? { ollamaReplayInput: true } : {}),
|
|
1924
1960
|
});
|
|
1961
|
+
if (!fromQueue) activeInputClientIds = promptClientMessageId ? [promptClientMessageId] : [];
|
|
1925
1962
|
if (!fromQueue && trackOllama) activeOllamaInputSeqs = [currentWorkflowSeq(cwd, workflowId)];
|
|
1926
1963
|
if (chatMode && !incognito) {
|
|
1927
1964
|
// Keep the global Past Chats list useful without rescanning a growing
|
|
@@ -1981,6 +2018,8 @@ export async function handleUserMessage(
|
|
|
1981
2018
|
// pending). Static text — no timestamps or random ids — so the prefix
|
|
1982
2019
|
// cache hits cleanly across turns.
|
|
1983
2020
|
let ollamaReplay: import('@arco/shared').WorkerConfig['ollamaReplay'];
|
|
2021
|
+
const retainLocalFiles = ['ollama', 'llamacpp', 'lmstudio', 'strata', 'deepseek'].includes(wf.primary.provider);
|
|
2022
|
+
let priorFiles: import('@arco/shared').WorkerConfig['priorFiles'] = retainLocalFiles || chatMode ? [] : undefined;
|
|
1984
2023
|
let primaryAppendSystemPrompt: string | undefined;
|
|
1985
2024
|
let primarySystemPrompt: string | undefined;
|
|
1986
2025
|
// The current user echo was just recorded above. Stateless providers
|
|
@@ -2010,6 +2049,7 @@ export async function handleUserMessage(
|
|
|
2010
2049
|
primarySkillsManifest = buildSkillsManifest({
|
|
2011
2050
|
project: catalog.project.filter((s) => !pinnedKeys.has(`project:${s.slug}`)),
|
|
2012
2051
|
global: catalog.global.filter((s) => !pinnedKeys.has(`global:${s.slug}`)),
|
|
2052
|
+
builtin: catalog.builtin,
|
|
2013
2053
|
});
|
|
2014
2054
|
} catch (err) {
|
|
2015
2055
|
console.error(`[arco] [${workflowId.slice(0, 8)}] skills scan failed:`, err);
|
|
@@ -2042,9 +2082,10 @@ export async function handleUserMessage(
|
|
|
2042
2082
|
const current = resolveProviderAutoCompaction(wf.config.autoCompaction, cluster ? clusterStore.getAutoCompaction(cluster) : undefined, 'ollama', '', false, savedOllamaPolicy);
|
|
2043
2083
|
return workflows.get(workflowId) === wf && ownsBusy(wf, busyToken) && wf.primary.provider === 'ollama' && JSON.stringify(current) === policyKey;
|
|
2044
2084
|
} };
|
|
2045
|
-
replayEvents = projectOllamaHistory(events, workflowId, activeOllamaInputSeqs).events;
|
|
2085
|
+
replayEvents = projectOllamaHistory(events, workflowId, activeOllamaInputSeqs, true).events;
|
|
2046
2086
|
}
|
|
2047
|
-
|
|
2087
|
+
priorFiles = projectLocalFileReferences(events, cwd, chatMode);
|
|
2088
|
+
const rendered = (wf.config.voiceOperator ? renderComputerHistory(replayEvents) : renderTranscript(replayEvents, { preserveThinking: !chatMode, separateFileContext: !chatMode, attachmentOnly: chatMode })).trim();
|
|
2048
2089
|
if (rendered) primaryAppendSystemPrompt = rendered;
|
|
2049
2090
|
} catch (err) {
|
|
2050
2091
|
console.error(`[arco] [${workflowId.slice(0, 8)}] ollama transcript build failed:`, err);
|
|
@@ -2075,8 +2116,9 @@ export async function handleUserMessage(
|
|
|
2075
2116
|
const events = priorIncognitoEvents ?? (wf.config.voiceOperator
|
|
2076
2117
|
? await computerReplayEvents(cwd, workflowId, wf.config.computerContext?.lastResetAt, wf.config.computerContext?.lastResetSeq)
|
|
2077
2118
|
: await replayWorkflowEvents(cwd, workflowId, 0));
|
|
2119
|
+
if (retainLocalFiles || chatMode) priorFiles = projectLocalFileReferences(events, cwd, chatMode);
|
|
2078
2120
|
const summary = chatMode ? '' : summarizePriorTurns(events);
|
|
2079
|
-
const rendered = (wf.config.voiceOperator ? renderComputerHistory(events) : renderTranscript(events, { preserveThinking: false })).trim();
|
|
2121
|
+
const rendered = (wf.config.voiceOperator ? renderComputerHistory(events) : renderTranscript(events, { preserveThinking: false, separateFileContext: !chatMode && (wf.primary.provider === 'llamacpp' || wf.primary.provider === 'lmstudio'), attachmentOnly: chatMode })).trim();
|
|
2080
2122
|
const parts: string[] = [];
|
|
2081
2123
|
if (summary) {
|
|
2082
2124
|
parts.push(`USER: [Workflow context]`);
|
|
@@ -2097,65 +2139,40 @@ export async function handleUserMessage(
|
|
|
2097
2139
|
if (rendered) primaryAppendSystemPrompt = `Conversation so far:\n\n${rendered}`;
|
|
2098
2140
|
}
|
|
2099
2141
|
|
|
2142
|
+
if (chatMode && (incognito || !wf.primarySessionId) && (wf.primary.provider === 'codex' || (wf.primary.provider === 'claude' && claudeTransport !== 'native'))) {
|
|
2143
|
+
try {
|
|
2144
|
+
const events = priorIncognitoEvents ?? await replayWorkflowEvents(cwd, workflowId, 0);
|
|
2145
|
+
priorFiles = projectLocalFileReferences(events, cwd, true);
|
|
2146
|
+
} catch (err) {
|
|
2147
|
+
console.error(`[arco] [${workflowId.slice(0, 8)}] chat attachment replay failed:`, err);
|
|
2148
|
+
}
|
|
2149
|
+
}
|
|
2150
|
+
|
|
2100
2151
|
// Local HTTP transports receive stable tool instructions through the
|
|
2101
2152
|
// provider system-prompt field; Claude and Codex transports fold them
|
|
2102
2153
|
// into their string-form prompt or native request blocks.
|
|
2103
|
-
|
|
2104
|
-
const primarySkillsContext = [pinnedSkillsBlock, primarySkillsManifest].filter(Boolean).join('\n\n');
|
|
2105
|
-
let finalSystemPrompt = usesSystemPromptForSkills && primarySkillsContext
|
|
2106
|
-
? (primarySystemPrompt ? `${primarySkillsContext}\n\n${primarySystemPrompt}` : primarySkillsContext)
|
|
2107
|
-
: primarySystemPrompt;
|
|
2108
|
-
const finalAppendBase = chatMode ? primaryAppendSystemPrompt : withPreviewNudge(primaryAppendSystemPrompt);
|
|
2109
|
-
const baseWithSkills = !usesSystemPromptForSkills && primarySkillsContext
|
|
2110
|
-
? `${primarySkillsContext}\n\n${finalAppendBase}`
|
|
2111
|
-
: finalAppendBase;
|
|
2112
|
-
// Phase 7a — fold discovered CLAUDE.md files into appendSystemPrompt
|
|
2113
|
-
// for Claude tabs (CLI + Native both benefit). Walks up from cwd
|
|
2114
|
-
// collecting CLAUDE.md, plus ~/.claude/CLAUDE.md.
|
|
2115
|
-
let finalAppend = baseWithSkills;
|
|
2116
|
-
// docs/VOICE.md - the Computer voice operator chat has its own
|
|
2117
|
-
// base instructions and real (arco-voice) tools; the generic Chat
|
|
2118
|
-
// preamble ("do not use backend tools… continue in an Agent tab") made
|
|
2119
|
-
// Luna refuse them (2026-10-17 smoke:voice-luna regression).
|
|
2120
|
-
if (chatMode && wf.config.voiceOperator === true) {
|
|
2121
|
-
if (usesSystemPromptForSkills) finalSystemPrompt = VOICE_OPERATOR_PROMPT;
|
|
2122
|
-
else if (wf.primary.provider !== 'codex') finalAppend = [VOICE_OPERATOR_PROMPT, finalAppend].filter(Boolean).join('\n\n');
|
|
2123
|
-
}
|
|
2124
|
-
if (chatMode && wf.config.voiceOperator !== true) {
|
|
2125
|
-
const chatPrompt = chatSystemPrompt(chatWeb);
|
|
2126
|
-
if (usesSystemPromptForSkills) {
|
|
2127
|
-
finalSystemPrompt = chatPrompt;
|
|
2128
|
-
} else {
|
|
2129
|
-
finalAppend = finalAppend ? `${chatPrompt}\n\n${finalAppend}` : chatPrompt;
|
|
2130
|
-
}
|
|
2131
|
-
}
|
|
2154
|
+
let claudeMd: string | null = null;
|
|
2132
2155
|
if (projectContextEnabled && (wf.primary.provider === 'claude') && cwd) {
|
|
2133
2156
|
try {
|
|
2134
|
-
|
|
2135
|
-
if (claudeMd) {
|
|
2136
|
-
finalAppend = baseWithSkills
|
|
2137
|
-
? `${claudeMd}\n\n${baseWithSkills}`
|
|
2138
|
-
: claudeMd;
|
|
2139
|
-
}
|
|
2157
|
+
claudeMd = (await discoverClaudeMdFiles(cwd, { includeProject })) || null;
|
|
2140
2158
|
} catch (err) {
|
|
2141
2159
|
console.warn(`[arco] [${workflowId.slice(0, 8)}] CLAUDE.md discovery failed:`, err);
|
|
2142
2160
|
}
|
|
2143
2161
|
}
|
|
2144
|
-
|
|
2145
|
-
//
|
|
2146
|
-
//
|
|
2147
|
-
//
|
|
2148
|
-
//
|
|
2149
|
-
//
|
|
2150
|
-
//
|
|
2151
|
-
//
|
|
2152
|
-
|
|
2153
|
-
// this READS operator-curated articles; nothing here writes the KB.
|
|
2162
|
+
// docs/ARCHITECTURE.md - the operator-curated knowledge base, as a
|
|
2163
|
+
// BOUNDED block. Provider-agnostic, only the always-include articles.
|
|
2164
|
+
// buildKnowledgeBlock hard-caps the combined body at
|
|
2165
|
+
// KNOWLEDGE_INJECT_BUDGET and appends a truncation notice when the set
|
|
2166
|
+
// overflows — the KB can NEVER silently bloat the turn. Emitted byte
|
|
2167
|
+
// counts land in events.jsonl (system_notice) for the four-question
|
|
2168
|
+
// test's context visibility. FENCE: this READS operator-curated
|
|
2169
|
+
// articles; nothing here writes the KB.
|
|
2170
|
+
let knowledge: string | null = null;
|
|
2154
2171
|
if (projectContextEnabled && cwd) {
|
|
2155
2172
|
try {
|
|
2156
2173
|
const kb = await buildKnowledgeBlock(cwd);
|
|
2157
2174
|
if (kb.text) {
|
|
2158
|
-
|
|
2175
|
+
knowledge = kb.text;
|
|
2159
2176
|
if (firstIteration) {
|
|
2160
2177
|
const truncNote = kb.truncated ? ` (truncated — exceeds injection budget)` : '';
|
|
2161
2178
|
send(ws, {
|
|
@@ -2169,6 +2186,20 @@ export async function handleUserMessage(
|
|
|
2169
2186
|
console.warn(`[arco] [${workflowId.slice(0, 8)}] knowledge-base injection failed:`, err);
|
|
2170
2187
|
}
|
|
2171
2188
|
}
|
|
2189
|
+
// turnPrompt.ts — skills, the Chat or Computer preamble, CLAUDE.md and
|
|
2190
|
+
// the knowledge base, in the order the model sees them.
|
|
2191
|
+
let { systemPrompt: finalSystemPrompt, appendSystemPrompt: finalAppend } = composeBasePrompts({
|
|
2192
|
+
provider: wf.primary.provider,
|
|
2193
|
+
chatMode,
|
|
2194
|
+
computerChat: wf.config.voiceOperator === true,
|
|
2195
|
+
chatWeb,
|
|
2196
|
+
systemPrompt: primarySystemPrompt,
|
|
2197
|
+
appendSystemPrompt: primaryAppendSystemPrompt,
|
|
2198
|
+
pinnedSkills: pinnedSkillsBlock,
|
|
2199
|
+
skillsManifest: primarySkillsManifest,
|
|
2200
|
+
claudeMd,
|
|
2201
|
+
knowledge,
|
|
2202
|
+
});
|
|
2172
2203
|
|
|
2173
2204
|
// Operator-initiated plan-mode entry. Resolved per turn from the
|
|
2174
2205
|
// pending flag the `enter_plan_mode_request` handler set. Only Claude
|
|
@@ -2208,6 +2239,7 @@ export async function handleUserMessage(
|
|
|
2208
2239
|
// the next turn's lookup returns undefined and the tools disappear
|
|
2209
2240
|
// from the worker's tool list.
|
|
2210
2241
|
const turnClusterId = clusterStore.getClusterIdForWorkflow(workflowId);
|
|
2242
|
+
primaryTurn.clusterDispatch = { clusterId: turnClusterId };
|
|
2211
2243
|
|
|
2212
2244
|
// Phase 2.6 — resolve the cluster's shared plan body + this member's
|
|
2213
2245
|
// role hint at turn start. Both ride into WorkerConfig so the Native
|
|
@@ -2267,7 +2299,7 @@ export async function handleUserMessage(
|
|
|
2267
2299
|
);
|
|
2268
2300
|
}
|
|
2269
2301
|
|
|
2270
|
-
if (turnClusterId && (wf.primary.provider === 'ollama' || wf.primary.provider === 'llamacpp')) {
|
|
2302
|
+
if (turnClusterId && (wf.primary.provider === 'ollama' || wf.primary.provider === 'llamacpp' || wf.primary.provider === 'lmstudio' || wf.primary.provider === 'strata' || wf.primary.provider === 'deepseek')) {
|
|
2271
2303
|
if (clusterAccessMode === 'standard') {
|
|
2272
2304
|
finalSystemPrompt = buildLocalClusterSystemPrompt({
|
|
2273
2305
|
base: finalSystemPrompt,
|
|
@@ -2392,7 +2424,7 @@ export async function handleUserMessage(
|
|
|
2392
2424
|
// scratch-dir path. buildGenesisSystemBlock folds in seed.projectContext for
|
|
2393
2425
|
// this case so the model stays anchored to what is really on disk.
|
|
2394
2426
|
const inGenesisCreative = !!genesisSeed && genesisSeed.creative === true;
|
|
2395
|
-
if ((inGenesisScratch || inGenesisCreative) && genesisSeed) {
|
|
2427
|
+
if ((inGenesisScratch || inGenesisCreative || genesisSeed?.planOnly) && genesisSeed) {
|
|
2396
2428
|
if (wf.primary.provider === 'ollama' || wf.primary.provider === 'llamacpp' || wf.primary.provider === 'lmstudio' || (wf.primary.provider === 'strata' || wf.primary.provider === 'deepseek')) {
|
|
2397
2429
|
finalSystemPrompt = buildGenesisSystemBlock(genesisSeed, { base: finalSystemPrompt });
|
|
2398
2430
|
} else {
|
|
@@ -2457,6 +2489,8 @@ export async function handleUserMessage(
|
|
|
2457
2489
|
try {
|
|
2458
2490
|
turnClusterMcpConfigPath = await mcpConfigWriter.writeFor(cwd, workflowId, {
|
|
2459
2491
|
planToolsCwd: cwd,
|
|
2492
|
+
handoffHistoryToken: !wf.primary.tools || wf.primary.tools.includes('handoff_history')
|
|
2493
|
+
? await mintHandoffHistoryCapability(workflowId) : undefined,
|
|
2460
2494
|
clusterId: turnClusterId,
|
|
2461
2495
|
taskBoardAttached: turnClusterTaskBoardAttached,
|
|
2462
2496
|
accessMode: clusterAccessMode,
|
|
@@ -2485,8 +2519,8 @@ export async function handleUserMessage(
|
|
|
2485
2519
|
// the operator's tree. The operator-turn loop in turnEngine.handleUserMessage
|
|
2486
2520
|
// is the only dispatch path that runs an operator-driven, file-mutating
|
|
2487
2521
|
// turn, so the checkpoint belongs at this call site. The ref suffix uses
|
|
2488
|
-
// the workflow's current event seq (the turn it guards)
|
|
2489
|
-
//
|
|
2522
|
+
// the workflow's current event seq (the turn it guards), carried as
|
|
2523
|
+
// `checkpointSeq`; the checkpoint_created event gets its own next seq.
|
|
2490
2524
|
// Upload-time image downscaling runs in the background; a send right
|
|
2491
2525
|
// after a paste can beat it. Wait (bounded) here so the sync providers
|
|
2492
2526
|
// (Claude CLI / Native, Codex exec) read the model copy too — they call
|
|
@@ -2501,12 +2535,18 @@ export async function handleUserMessage(
|
|
|
2501
2535
|
continue;
|
|
2502
2536
|
}
|
|
2503
2537
|
|
|
2538
|
+
let checkpointSkipNoticeSent = false;
|
|
2539
|
+
const onCheckpointSkipped = (content: string) => {
|
|
2540
|
+
if (checkpointSkipNoticeSent || workflows.get(workflowId) !== wf) return;
|
|
2541
|
+
checkpointSkipNoticeSent = true;
|
|
2542
|
+
broadcastWorkflow(workflowId, { type: 'system_notice', workflowId, content });
|
|
2543
|
+
};
|
|
2504
2544
|
let checkpoint: Awaited<ReturnType<typeof createCheckpoint>> = null;
|
|
2505
2545
|
let checkpointGuardSeq: number | undefined;
|
|
2506
2546
|
if (!(firstIteration && primitive === 'plan-review') && shouldCaptureTurn({ chatMode, planMode: armPlanMode, isolated: isolatedMember, provider: wf.primary.provider, tools: wf.primary.tools })) {
|
|
2507
2547
|
checkpointGuardSeq = currentWorkflowSeq(cwd, workflowId);
|
|
2508
2548
|
activeTurnObservation = observeCheckoutWriters(workflowWritePaths(wf), wf.manager);
|
|
2509
|
-
checkpoint = await timelyCheckpoint((deps.captureCheckpoint ?? createCheckpoint)({ cwd, workflowId, seq: checkpointGuardSeq }));
|
|
2549
|
+
checkpoint = await timelyCheckpoint((deps.captureCheckpoint ?? createCheckpoint)({ cwd, workflowId, seq: checkpointGuardSeq, onSkipped: onCheckpointSkipped }));
|
|
2510
2550
|
if (!checkpoint || !ownsBusy(wf, busyToken)) {
|
|
2511
2551
|
activeTurnObservation.stop(); activeTurnObservation = undefined;
|
|
2512
2552
|
checkpoint = null;
|
|
@@ -2522,24 +2562,36 @@ export async function handleUserMessage(
|
|
|
2522
2562
|
}
|
|
2523
2563
|
if (checkpoint && checkpointGuardSeq !== undefined) {
|
|
2524
2564
|
broadcastWorkflow(workflowId, {
|
|
2525
|
-
type: 'checkpoint_created', workflowId,
|
|
2565
|
+
type: 'checkpoint_created', workflowId, checkpointSeq: checkpointGuardSeq,
|
|
2526
2566
|
ref: checkpoint.ref, label: checkpoint.label, ts: checkpoint.ts, fileCount: checkpoint.fileCount,
|
|
2527
2567
|
...(checkpoint.skippedLargeFiles ? { skippedLargeFiles: checkpoint.skippedLargeFiles } : {}),
|
|
2568
|
+
...(checkpoint.limitation ? { limitation: checkpoint.limitation } : {}),
|
|
2528
2569
|
});
|
|
2529
2570
|
}
|
|
2530
2571
|
|
|
2531
2572
|
const policyTurnProvider = wf.primary.provider;
|
|
2532
2573
|
const ollamaExecutionId = trackOllama ? randomUUID() : undefined;
|
|
2533
2574
|
const executionInputSeqs = [...activeOllamaInputSeqs];
|
|
2575
|
+
const executionInputClientIds = [...activeInputClientIds];
|
|
2576
|
+
let dispatchedWorkerId: string | undefined;
|
|
2577
|
+
const dispatchCurrent = () => workflows.get(workflowId) === wf && ownsBusy(wf, busyToken) && (dispatchedWorkerId === undefined || primaryTurn.workerId === dispatchedWorkerId);
|
|
2534
2578
|
const turn = runPrimaryTurn(
|
|
2535
2579
|
{
|
|
2536
2580
|
workflowId,
|
|
2537
2581
|
cwd,
|
|
2538
2582
|
manager: wf.manager,
|
|
2539
|
-
broadcast: (msg) =>
|
|
2583
|
+
broadcast: (msg) => {
|
|
2584
|
+
// A Task child's final status still belongs to the card after STOP.
|
|
2585
|
+
if (!dispatchCurrent() && !deliverAfterTurnRevoked(msg)) return;
|
|
2586
|
+
if (msg.type === 'primary_complete' && msg.tokens
|
|
2587
|
+
&& msg.tokens.input + (msg.tokens.cacheRead ?? 0) + (msg.tokens.cacheCreate ?? 0) > 0) hasFreshContextReading = true;
|
|
2588
|
+
const delivery = msg.type === 'primary_turn_started' && executionInputClientIds.length
|
|
2589
|
+
? { ...msg, inputClientMessageIds: executionInputClientIds } : msg;
|
|
2590
|
+
send(ws, ollamaExecutionId ? stampOllamaExecution(delivery, ollamaExecutionId, executionInputSeqs) : delivery);
|
|
2591
|
+
},
|
|
2540
2592
|
bgTracker: chatMode ? undefined : wf.bgTracker,
|
|
2541
|
-
notePotentialDevServerStart: chatMode ? undefined : (cmd, toolUseId) => deps.previewAutoDetect.notePotentialDevServerStart(workflowId, cmd, toolUseId),
|
|
2542
|
-
noteAgentText: chatMode ? undefined : (text) => deps.previewAutoDetect.noteAgentText(workflowId, text),
|
|
2593
|
+
notePotentialDevServerStart: chatMode ? undefined : (cmd, toolUseId) => { if (dispatchCurrent()) deps.previewAutoDetect.notePotentialDevServerStart(workflowId, cmd, toolUseId); },
|
|
2594
|
+
noteAgentText: chatMode ? undefined : (text) => { if (dispatchCurrent()) deps.previewAutoDetect.noteAgentText(workflowId, text); },
|
|
2543
2595
|
},
|
|
2544
2596
|
{
|
|
2545
2597
|
primary: wf.primary,
|
|
@@ -2554,11 +2606,20 @@ export async function handleUserMessage(
|
|
|
2554
2606
|
chatWebAccess: firstIteration && primitive === 'plan-review' ? false : chatWeb,
|
|
2555
2607
|
voiceOperator: chatMode && wf.config.voiceOperator === true,
|
|
2556
2608
|
incognito,
|
|
2557
|
-
drainSteer: () =>
|
|
2558
|
-
|
|
2609
|
+
drainSteer: () => {
|
|
2610
|
+
if (!dispatchCurrent()) return [];
|
|
2611
|
+
return drainSteerForWorker(workflowId, ws, policyTurnProvider);
|
|
2612
|
+
},
|
|
2613
|
+
peekSteer: () => {
|
|
2614
|
+
if (!dispatchCurrent() || wf.primaryTurn?.holdSteer || wf.queue.steering.some((item) => item.interrupt)) return [];
|
|
2615
|
+
return wf.queue.steering;
|
|
2616
|
+
},
|
|
2617
|
+
requeueSteer: (items, bucket) => {
|
|
2618
|
+
if (workflows.get(workflowId) === wf && (busyRevocations.get(wf) ?? 0) === interruptEpoch) requeueSteerForWorker(workflowId, ws, items, bucket);
|
|
2619
|
+
},
|
|
2559
2620
|
onSteerDelivered: (items) => {
|
|
2560
2621
|
const clientMessageIds = items.flatMap((item) => item.clientMessageId ? [item.clientMessageId] : []);
|
|
2561
|
-
if (clientMessageIds.length)
|
|
2622
|
+
if (clientMessageIds.length && policyTurnProvider === 'codex') broadcastWorkflow(workflowId, { type: 'turn_messages_delivered', workflowId, clientMessageIds, ...(items[0]?.deliveryId ? { deliveryId: items[0].deliveryId } : {}) });
|
|
2562
2623
|
},
|
|
2563
2624
|
codexTransport,
|
|
2564
2625
|
codexContextPolicy: wf.config.codexContextPolicy,
|
|
@@ -2567,8 +2628,10 @@ export async function handleUserMessage(
|
|
|
2567
2628
|
claudeTransport,
|
|
2568
2629
|
ultracode,
|
|
2569
2630
|
claudeNativeCompact,
|
|
2631
|
+
claudeNativeTaskDisabled: wf.config.claudeNativeTaskDisabled,
|
|
2632
|
+
...(claudeNativeInTurnCompactPercent !== undefined && !(firstIteration && primitive === 'plan-review') ? { claudeNativeInTurnCompactPercent } : {}),
|
|
2570
2633
|
claudeNativeForceInterleavedThinkingBeta,
|
|
2571
|
-
claudeNativeThinkingDisplay,
|
|
2634
|
+
claudeNativeThinkingDisplay, nativeSubagents,
|
|
2572
2635
|
claudeNativePlanModeArmed: armPlanMode,
|
|
2573
2636
|
turnNotice: turnNoticeParts.length > 0 ? turnNoticeParts.join('\n\n') : undefined,
|
|
2574
2637
|
efficiencyToolFilter,
|
|
@@ -2605,12 +2668,16 @@ export async function handleUserMessage(
|
|
|
2605
2668
|
mcpDisallowedTools: turnMcpDisallowedTools,
|
|
2606
2669
|
ollamaParams,
|
|
2607
2670
|
ollamaReplay,
|
|
2671
|
+
priorFiles,
|
|
2672
|
+
fileContextCwd: retainLocalFiles ? cwd : undefined,
|
|
2673
|
+
fileContextInputIds: retainLocalFiles ? [...activeInputClientIds] : undefined,
|
|
2608
2674
|
// Per-tab Claude Native web budget (Anthropic server-tool max_uses).
|
|
2609
2675
|
// Native-only; the worker falls back to the server default when unset.
|
|
2610
2676
|
webSearchMaxUses: wf.config.webSearchMaxUses,
|
|
2611
2677
|
},
|
|
2612
2678
|
);
|
|
2613
2679
|
|
|
2680
|
+
dispatchedWorkerId = turn.workerId;
|
|
2614
2681
|
activeTurnObservation?.setPrimaryWorker(turn.workerId);
|
|
2615
2682
|
primaryTurn.workerId = turn.workerId;
|
|
2616
2683
|
|
|
@@ -2625,19 +2692,16 @@ export async function handleUserMessage(
|
|
|
2625
2692
|
if (!incognito && firstIteration && !wf.primarySessionId && turn.initialSessionId
|
|
2626
2693
|
&& wf.primary.provider === 'claude' && claudeTransport !== 'native') {
|
|
2627
2694
|
wf.primarySessionId = turn.initialSessionId;
|
|
2628
|
-
|
|
2629
|
-
console.error(`[arco] [${workflowId.slice(0, 8)}] meta reconcile (claude mint) failed:`, err);
|
|
2630
|
-
});
|
|
2695
|
+
sessionSave = saveProviderSession(cwd, workflowId, wf, 'claude', turn.initialSessionId);
|
|
2631
2696
|
}
|
|
2632
2697
|
|
|
2633
2698
|
// Codex emits thread_id at init. Capture on first fire, persist to meta.
|
|
2634
2699
|
turn.onSessionDiscovered((sid) => {
|
|
2635
|
-
if (incognito) return;
|
|
2700
|
+
if (incognito || !dispatchCurrent() || wf.primary.provider !== policyTurnProvider) return;
|
|
2636
2701
|
if (!wf.primarySessionId) wf.primarySessionId = sid;
|
|
2637
2702
|
|
|
2638
|
-
|
|
2639
|
-
|
|
2640
|
-
});
|
|
2703
|
+
announceReplacementConversation(workflowId, wf);
|
|
2704
|
+
sessionSave = sessionSave.then(() => saveProviderSession(cwd, workflowId, wf, policyTurnProvider, sid, providerAccount?.profile.id));
|
|
2641
2705
|
});
|
|
2642
2706
|
|
|
2643
2707
|
// docs/PROVIDERS.md - surface the background fleet. Under ultracode the
|
|
@@ -2661,6 +2725,8 @@ export async function handleUserMessage(
|
|
|
2661
2725
|
let carryInterruptedPrompt = false;
|
|
2662
2726
|
try {
|
|
2663
2727
|
outcome = await turn.settled;
|
|
2728
|
+
await sessionSave;
|
|
2729
|
+
if (hasFreshContextReading && dispatchCurrent()) await markConversationReading(cwd, workflowId, wf);
|
|
2664
2730
|
// A second correction may cancel Native during auth/hooks, before
|
|
2665
2731
|
// its first correction entered history. Carry that unsent input.
|
|
2666
2732
|
carryInterruptedPrompt = await primaryTurn.interruption === false && primaryTurn.holdSteer;
|
|
@@ -2681,7 +2747,7 @@ export async function handleUserMessage(
|
|
|
2681
2747
|
// otherwise a queued follow-up could alter the tree before the range ends.
|
|
2682
2748
|
const endSeq = currentWorkflowSeq(cwd, workflowId);
|
|
2683
2749
|
if (endSeq > checkpointGuardSeq) {
|
|
2684
|
-
const end = await (deps.captureCheckpoint ?? createCheckpoint)({ cwd, workflowId, seq: endSeq });
|
|
2750
|
+
const end = await (deps.captureCheckpoint ?? createCheckpoint)({ cwd, workflowId, seq: endSeq, onSkipped: onCheckpointSkipped });
|
|
2685
2751
|
if (end && ownsBusy(wf, busyToken)) {
|
|
2686
2752
|
const otherWriters = activeTurnObservation.hasOverlap();
|
|
2687
2753
|
activeTurnObservation.stop(); activeTurnObservation = undefined;
|
|
@@ -2727,9 +2793,8 @@ export async function handleUserMessage(
|
|
|
2727
2793
|
...est,
|
|
2728
2794
|
claudeSessionId: sid,
|
|
2729
2795
|
});
|
|
2730
|
-
// Keep the shared
|
|
2731
|
-
//
|
|
2732
|
-
// absorbs the one-turn lag).
|
|
2796
|
+
// Keep the shared context signal fresh (fire-and-forget, so it may
|
|
2797
|
+
// settle one turn late; nothing here acts on a single reading).
|
|
2733
2798
|
wf.lastContextPercent = est.percentOfWindow;
|
|
2734
2799
|
}).catch(() => { /* best-effort */ });
|
|
2735
2800
|
} else if (wf.primary.provider === 'claude' && claudeTransport === 'native' && typeof outcome.lastPromptTokens === 'number') {
|
|
@@ -2761,8 +2826,6 @@ export async function handleUserMessage(
|
|
|
2761
2826
|
const budget = computeContextBudget(outcome.lastPromptTokens, win, reserved);
|
|
2762
2827
|
wf.lastContextBudgetPct = budget.pct;
|
|
2763
2828
|
const thresholds = {
|
|
2764
|
-
warnAt: wf.autoHandoff.warnAt,
|
|
2765
|
-
autoAt: wf.autoHandoff.autoAt,
|
|
2766
2829
|
...(typeof wf.autoFold?.foldAt === 'number' ? { foldAt: wf.autoFold.foldAt } : {}),
|
|
2767
2830
|
};
|
|
2768
2831
|
broadcastTransient(workflowId, {
|
|
@@ -2895,40 +2958,44 @@ export async function handleUserMessage(
|
|
|
2895
2958
|
|
|
2896
2959
|
if (preserveQueue) return;
|
|
2897
2960
|
|
|
2898
|
-
//
|
|
2899
|
-
await
|
|
2900
|
-
|
|
2901
|
-
|
|
2902
|
-
|
|
2903
|
-
|
|
2904
|
-
|
|
2905
|
-
|
|
2906
|
-
|
|
2907
|
-
|
|
2908
|
-
|
|
2909
|
-
|
|
2910
|
-
|
|
2911
|
-
|
|
2912
|
-
|
|
2913
|
-
|
|
2914
|
-
|
|
2915
|
-
|
|
2916
|
-
|
|
2917
|
-
|
|
2918
|
-
|
|
2919
|
-
|
|
2920
|
-
|
|
2961
|
+
// afterTurn.ts — the post-settle steps in their fixed order.
|
|
2962
|
+
await runAfterTurn({
|
|
2963
|
+
// Computer rotates only after the complete tool/queue turn has settled.
|
|
2964
|
+
computer: async () => {
|
|
2965
|
+
await maybeFreshComputerContext(workflowId, !lastTurnErrored);
|
|
2966
|
+
await announceComputerSettled(workflowId);
|
|
2967
|
+
},
|
|
2968
|
+
// Phase 2 calibration: per-session ratio/overhead from ground-truth /context output.
|
|
2969
|
+
calibrate: () => maybeCalibrate(workflowId, wf, cwd),
|
|
2970
|
+
// A due auto-handoff (N compactions this conversation) runs first and
|
|
2971
|
+
// replaces any fold or compaction of this boundary; otherwise the cheap
|
|
2972
|
+
// deterministic Fold, then the auto-compaction policy.
|
|
2973
|
+
context: async () => {
|
|
2974
|
+
const clusterIdForPolicy = clusterStore.getClusterIdForWorkflow(workflowId);
|
|
2975
|
+
const explicitPolicy = resolveProviderAutoCompaction(wf.config.autoCompaction, clusterIdForPolicy ? clusterStore.getAutoCompaction(clusterIdForPolicy) : undefined, wf.primary.provider, claudeTransport, wf.config.claudeNativeCompact === true, cascade?.ollama?.compaction?.enabled !== undefined || cascade?.ollama?.compaction?.threshold !== undefined);
|
|
2976
|
+
if (explicitPolicy) {
|
|
2977
|
+
const action = await runExplicitContextActions(workflowId, wf, cwd, explicitPolicy, policyReading, busyToken, ws, session);
|
|
2978
|
+
if (action === 'stale') return 'stop';
|
|
2979
|
+
if (action === 'compact-attempted') { await drainQueueIfIdle(workflowId); return 'stop'; }
|
|
2980
|
+
} else {
|
|
2981
|
+
// Work without an explicit policy: a due auto-handoff first, else
|
|
2982
|
+
// the cheap fold. Provider-owned compaction remains with the provider.
|
|
2983
|
+
if (!(await maybeAutoHandoff(workflowId, wf, cwd))) await maybeAutoFold(workflowId, wf, cwd);
|
|
2984
|
+
}
|
|
2985
|
+
return 'continue';
|
|
2986
|
+
},
|
|
2987
|
+
// Messages typed while auto-fold / auto-handoff held the tab are still
|
|
2988
|
+
// queued; that turn runs its own post-settle chain (goal run included).
|
|
2989
|
+
drainQueue: () => drainQueueIfIdle(workflowId),
|
|
2990
|
+
// docs/GOTCHAS.md - north-star auto-continue, last on purpose: fold,
|
|
2991
|
+
// handoff and compaction all reshape the context this tick would run against.
|
|
2992
|
+
goalRun: () => maybeGoalRun(workflowId, wf, ws, session, lastTurnErrored),
|
|
2993
|
+
});
|
|
2994
|
+
} finally {
|
|
2995
|
+
const remaining = (incomingMessages.get(wf) ?? 1) - 1;
|
|
2996
|
+
if (remaining) incomingMessages.set(wf, remaining); else incomingMessages.delete(wf);
|
|
2997
|
+
resumeRequeuedSteer(workflowId, wf);
|
|
2921
2998
|
}
|
|
2922
|
-
|
|
2923
|
-
// Messages typed while auto-fold / auto-handoff held the tab are still
|
|
2924
|
-
// queued. Flush them first; that turn runs its own post-settle chain (goal
|
|
2925
|
-
// run included), so this settle is done.
|
|
2926
|
-
if (await drainQueueIfIdle(workflowId)) return;
|
|
2927
|
-
|
|
2928
|
-
// docs/GOTCHAS.md - north-star auto-continue. Last of the post-settle armed
|
|
2929
|
-
// actions on purpose: fold / handoff / compaction all reshape the context
|
|
2930
|
-
// this tick would run against, so they get to act first.
|
|
2931
|
-
await maybeGoalRun(workflowId, wf, ws, session, lastTurnErrored);
|
|
2932
2999
|
}
|
|
2933
3000
|
|
|
2934
3001
|
// docs/GOTCHAS.md - one tick of an armed goal run. Every branch either
|