arco-workbench 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +63 -12
- package/README.md +21 -17
- package/client/dist/assets/{PhosphorBackdrop-DVQdBrTw.js → PhosphorBackdrop-DRu16-Is.js} +1 -1
- package/client/dist/assets/{ThemedBackgroundShaderImpl-BfSs2tB4.js → ThemedBackgroundShaderImpl-BLdwwQ4D.js} +1 -1
- package/client/dist/assets/{XtermView-DaMjC8Ny.js → XtermView-Xk7_9JaH.js} +1 -1
- package/client/dist/assets/{galleryEditor-BCQnXj7R.js → galleryEditor-CI8ClzBa.js} +1 -1
- package/client/dist/assets/{index-DD9kFGsF.css → index-BEFgrUJJ.css} +1 -1
- package/client/dist/assets/{index-COfbHCYv.js → index-C7WzZfsr.js} +257 -255
- package/client/dist/index.html +2 -2
- package/client/src/App.tsx +2 -0
- package/client/src/components/ChatMessage.tsx +33 -8
- package/client/src/components/ChatModeView.tsx +2 -0
- package/client/src/components/ClusterRightPanel/ReplaceMemberDialog.tsx +65 -15
- package/client/src/components/ClusterRightPanel/SkillsControl.tsx +124 -0
- package/client/src/components/ClusterRightPanel/index.tsx +4 -0
- package/client/src/components/ClusterTaskBoardTab.tsx +9 -22
- package/client/src/components/CodexLateCommand.tsx +34 -0
- package/client/src/components/DialogShell.tsx +2 -0
- package/client/src/components/MemberCard.tsx +4 -1
- package/client/src/components/MemberPane.tsx +3 -1
- package/client/src/components/NeedsYouBadge.tsx +3 -3
- package/client/src/components/PhoneUpload.tsx +288 -0
- package/client/src/components/PrimaryStatus.tsx +14 -6
- package/client/src/components/ProviderReleasesModal.tsx +8 -4
- package/client/src/components/ProvidersPopover.tsx +28 -23
- package/client/src/components/RuntimeStateBanner.tsx +5 -0
- package/client/src/components/SettingsPanel.tsx +2 -2
- package/client/src/components/SkillEditorDialog.tsx +2 -2
- package/client/src/components/SkillsSettings.tsx +21 -4
- package/client/src/components/TabBar.tsx +91 -9
- package/client/src/components/TerminalInput.tsx +15 -11
- package/client/src/components/TranscriptSendDialog.tsx +12 -8
- package/client/src/components/TranscriptWorkerDialog.tsx +119 -0
- package/client/src/components/WorkflowView.tsx +2 -0
- package/client/src/components/clusterNeedsYou.ts +11 -18
- package/client/src/explorer/ArtifactsLens.tsx +37 -28
- package/client/src/explorer/ExplorerApp.tsx +5 -4
- package/client/src/explorer/types.ts +8 -3
- package/client/src/help/content/cluster.tsx +48 -17
- package/client/src/help/content/composer.tsx +40 -1
- package/client/src/help/content/header.tsx +18 -1
- package/client/src/help/content/misc.tsx +9 -1
- package/client/src/help/content/settings.tsx +18 -4
- package/client/src/help/content/tabbar.tsx +5 -0
- package/client/src/help/manualSections/actions.tsx +31 -0
- package/client/src/help/manualSections/clusters.tsx +44 -20
- package/client/src/help/manualSections/configuration.tsx +20 -0
- package/client/src/help/manualSections/gettingStarted.tsx +4 -4
- package/client/src/help/manualSections/maintenance.tsx +25 -6
- package/client/src/help/manualSections/powerFeatures.tsx +3 -2
- package/client/src/help/manualSections/providers.tsx +32 -8
- package/client/src/help/manualSections/troubleshooting.tsx +2 -1
- package/client/src/help/manualSections/workflows.tsx +12 -0
- package/client/src/help/manualSections/workspace.tsx +36 -0
- package/client/src/stores/appStore.ts +7 -0
- package/client/src/stores/appStore.types.ts +4 -0
- package/client/src/styles/global.css +109 -0
- package/client/src/utils/phoneTheme.ts +38 -0
- package/client/src/utils/phoneUploadApi.ts +10 -0
- package/client/src/utils/transcriptWorkerRequest.ts +24 -0
- package/client/src/ws/handleServerMessage.ts +31 -8
- package/docs/ARCHITECTURE.md +1 -1
- package/docs/CLIENT.md +16 -9
- package/docs/FEATURES.md +13 -7
- package/docs/GETTING_STARTED.md +12 -6
- package/docs/GOTCHAS.md +2 -1
- package/docs/INDEX.md +1 -1
- package/docs/OPERATIONS.md +213 -52
- package/docs/PERSISTENCE.md +7 -2
- package/docs/PRIMITIVES.md +42 -0
- package/docs/PROTOCOL_CLUSTER.md +51 -4
- package/docs/PROTOCOL_PRIMITIVES.md +39 -0
- package/docs/PROVIDERS.md +84 -13
- package/docs/SETTINGS.md +29 -3
- package/docs/TASK_LEDGER.md +7 -15
- package/native/linux-x64/manifest.json +1 -1
- package/native/win32-x64/manifest.json +1 -1
- package/node_modules/@arco/shared/dist/clusterCoordination.d.ts +2 -0
- package/node_modules/@arco/shared/dist/clusterCoordination.js +5 -1
- package/node_modules/@arco/shared/dist/protocol/chat.d.ts +1 -0
- package/node_modules/@arco/shared/dist/protocol/clientMessages.d.ts +3 -2
- package/node_modules/@arco/shared/dist/protocol/clusters.d.ts +15 -1
- package/node_modules/@arco/shared/dist/protocol/index.d.ts +1 -0
- package/node_modules/@arco/shared/dist/protocol/index.js +1 -0
- package/node_modules/@arco/shared/dist/protocol/models.d.ts +4 -3
- package/node_modules/@arco/shared/dist/protocol/models.js +26 -2
- package/node_modules/@arco/shared/dist/protocol/serverMessages.d.ts +13 -1
- package/node_modules/@arco/shared/dist/protocol/tasks.d.ts +4 -0
- package/node_modules/@arco/shared/dist/protocol/transcriptWorker.d.ts +47 -0
- package/node_modules/@arco/shared/dist/protocol/transcriptWorker.js +2 -0
- package/node_modules/@arco/shared/dist/protocol/workflows.d.ts +1 -0
- package/node_modules/@arco/shared/dist/runtimeVersions.d.ts +1 -0
- package/node_modules/@arco/shared/dist/runtimeVersions.js +14 -0
- package/node_modules/@arco/shared/package.json +1 -1
- package/package.json +2 -2
- package/scripts/packaging/arco.mjs +1 -1
- package/scripts/packaging/native-repair.mjs +32 -4
- package/server/dist/atomicFile.js +1 -2
- package/server/dist/capabilities.d.ts +5 -2
- package/server/dist/capabilities.js +59 -9
- package/server/dist/cliUpdateDecision.d.ts +1 -1
- package/server/dist/cliUpdateDecision.js +5 -3
- package/server/dist/clusterDirector.js +2 -1
- package/server/dist/clusterPeerOps.js +14 -8
- package/server/dist/clusterProgress.js +1 -1
- package/server/dist/clusterRehydrate.js +2 -0
- package/server/dist/clusterSkills.d.ts +13 -0
- package/server/dist/clusterSkills.js +81 -0
- package/server/dist/clusterSnapshots.js +2 -0
- package/server/dist/clusterStore.d.ts +7 -2
- package/server/dist/clusterStore.js +42 -1
- package/server/dist/diagnostics/codeSkew.js +1 -0
- package/server/dist/eventLog.d.ts +7 -0
- package/server/dist/eventLog.js +70 -13
- package/server/dist/explorerDocs.d.ts +10 -6
- package/server/dist/explorerDocs.js +75 -34
- package/server/dist/historyLimits.d.ts +1 -0
- package/server/dist/historyLimits.js +3 -0
- package/server/dist/http/attachmentUpload.d.ts +13 -0
- package/server/dist/http/attachmentUpload.js +38 -0
- package/server/dist/http/browserWorktrees.d.ts +23 -0
- package/server/dist/http/browserWorktrees.js +120 -0
- package/server/dist/http/phoneUploadDrafts.d.ts +13 -0
- package/server/dist/http/phoneUploadDrafts.js +125 -0
- package/server/dist/http/phoneUploadListener.d.ts +17 -0
- package/server/dist/http/phoneUploadListener.js +81 -0
- package/server/dist/http/phoneUploadNetwork.d.ts +9 -0
- package/server/dist/http/phoneUploadNetwork.js +106 -0
- package/server/dist/http/phoneUploadPage.d.ts +2 -0
- package/server/dist/http/phoneUploadPage.js +136 -0
- package/server/dist/http/phoneUploadRouteHistory.d.ts +4 -0
- package/server/dist/http/phoneUploadRouteHistory.js +72 -0
- package/server/dist/http/phoneUploadRoutes.d.ts +4 -0
- package/server/dist/http/phoneUploadRoutes.js +419 -0
- package/server/dist/http/phoneUploadTheme.d.ts +17 -0
- package/server/dist/http/phoneUploadTheme.js +96 -0
- package/server/dist/http/projectBinding.d.ts +1 -0
- package/server/dist/http/projectBinding.js +3 -2
- package/server/dist/http/readConfinement.js +5 -1
- package/server/dist/http/router.js +14 -25
- package/server/dist/http/writeConfinement.js +19 -2
- package/server/dist/index.js +24 -1
- package/server/dist/jsonlLines.d.ts +4 -0
- package/server/dist/jsonlLines.js +53 -0
- package/server/dist/management/identity.js +1 -0
- package/server/dist/mcp/clusterMcpTools.js +4 -4
- package/server/dist/primitives/seedWorker.d.ts +1 -0
- package/server/dist/primitives/seedWorker.js +2 -1
- package/server/dist/project/taskLedger.d.ts +4 -0
- package/server/dist/project/taskLedger.js +7 -4
- package/server/dist/providerConversation.d.ts +1 -0
- package/server/dist/providerConversation.js +17 -0
- package/server/dist/providers/claude-native/resumeSummary.d.ts +9 -0
- package/server/dist/providers/claude-native/resumeSummary.js +102 -49
- package/server/dist/providers/claude-native/worker.js +8 -4
- package/server/dist/providers/claude.js +2 -1
- package/server/dist/providers/clusterTaskToolDefinitions.js +4 -4
- package/server/dist/providers/codex-appserver/catalog.js +16 -1
- package/server/dist/providers/codex-appserver/heldCommands.d.ts +14 -0
- package/server/dist/providers/codex-appserver/heldCommands.js +54 -0
- package/server/dist/providers/codex-appserver/index.d.ts +52 -2
- package/server/dist/providers/codex-appserver/index.js +239 -21
- package/server/dist/providers/codex-appserver/lateCommands.d.ts +62 -0
- package/server/dist/providers/codex-appserver/lateCommands.js +195 -0
- package/server/dist/providers/codex-appserver/worker.d.ts +23 -1
- package/server/dist/providers/codex-appserver/worker.js +89 -20
- package/server/dist/providers/codex.js +2 -1
- package/server/dist/providers/codexCodeMode.d.ts +2 -1
- package/server/dist/providers/codexCodeMode.js +8 -3
- package/server/dist/providers/cursor/print.js +2 -1
- package/server/dist/providers/cursor/worker.js +2 -1
- package/server/dist/providers/llamacpp.js +17 -8
- package/server/dist/providers/ollamaRecovery.js +6 -6
- package/server/dist/providers/ollamaResilience.js +3 -3
- package/server/dist/providers/ollamaTokens.js +1 -1
- package/server/dist/quota.d.ts +0 -18
- package/server/dist/quota.js +0 -44
- package/server/dist/replacementHistory.d.ts +19 -0
- package/server/dist/replacementHistory.js +49 -0
- package/server/dist/server/broadcast.d.ts +2 -1
- package/server/dist/server/broadcast.js +1 -0
- package/server/dist/server/prompts.d.ts +1 -0
- package/server/dist/server/prompts.js +6 -1
- package/server/dist/sessionJsonl.d.ts +1 -1
- package/server/dist/sessionJsonl.js +115 -40
- package/server/dist/smartPickupAdapters.js +15 -2
- package/server/dist/transcriptWorker.d.ts +34 -0
- package/server/dist/transcriptWorker.js +201 -0
- package/server/dist/workers/WorkerManager.d.ts +1 -0
- package/server/dist/workers/WorkerManager.js +1 -0
- package/server/dist/workers/processKill.d.ts +9 -1
- package/server/dist/workers/processKill.js +26 -10
- package/server/dist/workflowStore.d.ts +1 -0
- package/server/dist/workflowStore.js +31 -0
- package/server/dist/ws/clusterHandlers.d.ts +1 -0
- package/server/dist/ws/clusterHandlers.js +62 -26
- package/server/dist/ws/handoffHandlers.js +7 -2
- package/server/dist/ws/transcriptWorkerHandlers.d.ts +25 -0
- package/server/dist/ws/transcriptWorkerHandlers.js +139 -0
- package/server/dist/ws/turnEngine.js +40 -9
- package/server/dist/ws/updatePrimaryConfig.js +27 -8
- package/server/dist/ws/workflowHandlers.d.ts +4 -1
- package/server/dist/ws/workflowHandlers.js +3 -1
- package/server/package.json +1 -1
- package/server/src/atomicFile.ts +1 -2
- package/server/src/capabilities.ts +58 -17
- package/server/src/cliUpdateDecision.ts +5 -4
- package/server/src/clusterDirector.ts +2 -1
- package/server/src/clusterPeerOps.ts +15 -9
- package/server/src/clusterProgress.ts +1 -1
- package/server/src/clusterRehydrate.ts +2 -0
- package/server/src/clusterSkills.ts +79 -0
- package/server/src/clusterSnapshots.ts +1 -0
- package/server/src/clusterStore.ts +38 -0
- package/server/src/diagnostics/codeSkew.ts +1 -0
- package/server/src/eventLog.ts +73 -13
- package/server/src/explorerDocs.ts +75 -34
- package/server/src/historyLimits.ts +2 -0
- package/server/src/http/attachmentUpload.ts +49 -0
- package/server/src/http/browserWorktrees.ts +124 -0
- package/server/src/http/phoneUploadDrafts.ts +118 -0
- package/server/src/http/phoneUploadListener.ts +96 -0
- package/server/src/http/phoneUploadNetwork.ts +117 -0
- package/server/src/http/phoneUploadPage.ts +137 -0
- package/server/src/http/phoneUploadRouteHistory.ts +73 -0
- package/server/src/http/phoneUploadRoutes.ts +398 -0
- package/server/src/http/phoneUploadTheme.ts +97 -0
- package/server/src/http/projectBinding.ts +3 -2
- package/server/src/http/readConfinement.ts +5 -1
- package/server/src/http/router.ts +12 -26
- package/server/src/http/writeConfinement.ts +13 -2
- package/server/src/index.ts +23 -0
- package/server/src/jsonlLines.ts +52 -0
- package/server/src/management/identity.ts +1 -0
- package/server/src/mcp/clusterMcpTools.ts +4 -4
- package/server/src/primitives/seedWorker.ts +3 -1
- package/server/src/project/taskLedger.ts +7 -5
- package/server/src/providerConversation.ts +15 -0
- package/server/src/providers/claude-native/resumeSummary.ts +98 -50
- package/server/src/providers/claude-native/worker.ts +8 -4
- package/server/src/providers/claude.ts +2 -1
- package/server/src/providers/clusterTaskToolDefinitions.ts +4 -4
- package/server/src/providers/codex-appserver/catalog.ts +14 -1
- package/server/src/providers/codex-appserver/heldCommands.ts +58 -0
- package/server/src/providers/codex-appserver/index.ts +222 -20
- package/server/src/providers/codex-appserver/lateCommands.ts +225 -0
- package/server/src/providers/codex-appserver/worker.ts +85 -21
- package/server/src/providers/codex.ts +2 -1
- package/server/src/providers/codexCodeMode.ts +9 -4
- package/server/src/providers/cursor/print.ts +2 -1
- package/server/src/providers/cursor/worker.ts +2 -1
- package/server/src/providers/llamacpp.ts +18 -7
- package/server/src/providers/llamacppRecovery.ts +2 -0
- package/server/src/providers/ollamaRecovery.ts +6 -6
- package/server/src/providers/ollamaResilience.ts +3 -3
- package/server/src/providers/ollamaTokens.ts +1 -1
- package/server/src/providers/ollamaToolSubset.ts +3 -3
- package/server/src/quota.ts +0 -50
- package/server/src/replacementHistory.ts +44 -0
- package/server/src/server/broadcast.ts +2 -0
- package/server/src/server/prompts.ts +8 -1
- package/server/src/sessionJsonl.ts +92 -32
- package/server/src/smartPickupAdapters.ts +17 -3
- package/server/src/transcriptWorker.ts +182 -0
- package/server/src/workers/WorkerManager.ts +2 -0
- package/server/src/workers/processKill.ts +35 -7
- package/server/src/workflowStore.ts +21 -0
- package/server/src/ws/clusterHandlers.ts +43 -25
- package/server/src/ws/handoffHandlers.ts +7 -1
- package/server/src/ws/transcriptWorkerHandlers.ts +126 -0
- package/server/src/ws/turnEngine.ts +35 -8
- package/server/src/ws/updatePrimaryConfig.ts +25 -6
- package/server/src/ws/workflowHandlers.ts +3 -1
- package/shared/dist/clusterCoordination.d.ts +2 -0
- package/shared/dist/clusterCoordination.js +5 -1
- package/shared/dist/protocol/chat.d.ts +1 -0
- package/shared/dist/protocol/clientMessages.d.ts +3 -2
- package/shared/dist/protocol/clusters.d.ts +15 -1
- package/shared/dist/protocol/index.d.ts +1 -0
- package/shared/dist/protocol/index.js +1 -0
- package/shared/dist/protocol/models.d.ts +4 -3
- package/shared/dist/protocol/models.js +26 -2
- package/shared/dist/protocol/serverMessages.d.ts +13 -1
- package/shared/dist/protocol/tasks.d.ts +4 -0
- package/shared/dist/protocol/transcriptWorker.d.ts +47 -0
- package/shared/dist/protocol/transcriptWorker.js +2 -0
- package/shared/dist/protocol/workflows.d.ts +1 -0
- package/shared/dist/runtimeVersions.d.ts +1 -0
- package/shared/dist/runtimeVersions.js +14 -0
- package/shared/src/clusterCoordination.ts +7 -1
- package/shared/src/protocol/chat.ts +1 -0
- package/shared/src/protocol/clientMessages.ts +5 -0
- package/shared/src/protocol/clusters.ts +20 -6
- package/shared/src/protocol/index.ts +1 -0
- package/shared/src/protocol/models.ts +31 -5
- package/shared/src/protocol/serverMessages.ts +13 -0
- package/shared/src/protocol/settings.ts +2 -3
- package/shared/src/protocol/tasks.ts +4 -7
- package/shared/src/protocol/transcriptWorker.ts +49 -0
- package/shared/src/protocol/workflows.ts +4 -0
- package/shared/src/runtimeVersions.ts +14 -0
|
@@ -60,6 +60,7 @@ export declare function handleClusterMemberFocusSet(ws: WebSocket, clusterId: st
|
|
|
60
60
|
export declare function handleClusterIdleNudgerToggle(ws: WebSocket, clusterId: string, enabled: boolean): Promise<void>;
|
|
61
61
|
export declare function handleClusterAutoCompactionSet(ws: WebSocket, clusterId: string, policy: import('@arco/shared').AutoCompactionPolicy | null): Promise<void>;
|
|
62
62
|
export declare function handleClusterEfficiencySet(ws: WebSocket, clusterId: string, level: ClusterEfficiencyLevel, addendum?: string, messageGuard?: import('@arco/shared').ClusterMessageGuard): Promise<void>;
|
|
63
|
+
export declare function handleClusterSkillsSet(ws: WebSocket, clusterId: string, pins: unknown): Promise<void>;
|
|
63
64
|
export declare function handleClusterRemoteSet(ws: WebSocket, clusterId: string, enabled: boolean): Promise<void>;
|
|
64
65
|
export declare function handleClusterGatesSet(ws: WebSocket, clusterId: string, enabled: boolean): Promise<void>;
|
|
65
66
|
export declare function handleClusterMemberReorder(ws: WebSocket, clusterId: string, memberIds: string[]): Promise<void>;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { buildReplacementHistory, replacementHistoryNotice } from '../replacementHistory.js';
|
|
2
|
+
import { takeReplacementHistoryPreview } from './transcriptWorkerHandlers.js';
|
|
1
3
|
import { existingClusterMemberRefusal } from '../existingClusterMembers.js';
|
|
2
4
|
import { isClusterCreationSettings, isClusterMessageGuard, clusterDirectorProblem, isClusterDirector, normalizeClusterRoleText, presetForText } from '@arco/shared';
|
|
3
5
|
import { disabledClusterProvider, localCapacityRefusal, memberProvider } from '../localCapacity.js';
|
|
@@ -7,6 +9,7 @@ import { disabledClusterProvider, localCapacityRefusal, memberProvider } from '.
|
|
|
7
9
|
// createBlankNativeWorkflow / assertAllMembersClaudeOrCodex) are injected once at
|
|
8
10
|
// startup via initClusterHandlers to avoid a cycle with the entry point.
|
|
9
11
|
import { isClusterOpen, workspaceAdoptFormerMembers, workspaceCloseCluster, workspaceOpenCluster } from '../workspace.js';
|
|
12
|
+
import { assertSkillUnion } from '../clusterSkills.js';
|
|
10
13
|
import { isClusterMemberProvider, isClusterMemberAccessMode, isClusterEfficiencyLevel, isClusterTaskBoardMode, isClusterProgressMode, } from '@arco/shared';
|
|
11
14
|
import { WebSocket } from 'ws';
|
|
12
15
|
import * as clusterAutoTurn from '../clusterAutoTurn.js';
|
|
@@ -18,7 +21,6 @@ import * as clusterRehydrate from '../clusterRehydrate.js';
|
|
|
18
21
|
import * as clusterStore from '../clusterStore.js';
|
|
19
22
|
import { refreshHubReporting } from '../management/initHubLink.js';
|
|
20
23
|
import { replayEvents } from '../workflowStore.js';
|
|
21
|
-
import { renderTranscript, summarizePriorTurns } from '../primitives/exportContext.js';
|
|
22
24
|
import * as taskDispatcher from '../taskDispatcher.js';
|
|
23
25
|
import * as taskLedger from '../project/taskLedger.js';
|
|
24
26
|
import * as orchestrationProposals from '../project/orchestrationProposals.js';
|
|
@@ -1813,6 +1815,13 @@ export async function handleClusterAddFreshWorkers(ws, session, msg) {
|
|
|
1813
1815
|
model: msg.model, effort: msg.effort, accountRef: msg.providerAccountRef, isolated: accessMode === 'isolated', resolveCodexAccount,
|
|
1814
1816
|
tuning: msg,
|
|
1815
1817
|
});
|
|
1818
|
+
try {
|
|
1819
|
+
await assertSkillUnion(cluster, newRole || undefined, childConfig.pinnedSkills ?? [], childName);
|
|
1820
|
+
}
|
|
1821
|
+
catch (err) {
|
|
1822
|
+
send(ws, { type: 'error', message: `cluster_add_fresh_workers rejected: ${err instanceof Error ? err.message : String(err)}` });
|
|
1823
|
+
return;
|
|
1824
|
+
}
|
|
1816
1825
|
try {
|
|
1817
1826
|
const id = await deps.createBlankNativeWorkflow(ws, session, childConfig, MEMBER_PENDING);
|
|
1818
1827
|
newIds.push(id);
|
|
@@ -1864,7 +1873,6 @@ export async function handleClusterAddFreshWorkers(ws, session, msg) {
|
|
|
1864
1873
|
}
|
|
1865
1874
|
console.log(`[arco] cluster ${msg.clusterId.slice(0, 8)} grew by ${newIds.length} fresh workers`);
|
|
1866
1875
|
}
|
|
1867
|
-
const REPLACEMENT_HISTORY_MAX_BYTES = 512 * 1024;
|
|
1868
1876
|
// The name and role a REPLACE request carries, as a refusal code or null.
|
|
1869
1877
|
function replaceIdentityRefusal(cluster, msg) {
|
|
1870
1878
|
if (msg.name !== undefined && (typeof msg.name !== 'string' || msg.name.trim().length > 64))
|
|
@@ -1898,7 +1906,12 @@ export async function handleClusterMemberReplace(ws, session, msg) {
|
|
|
1898
1906
|
send(ws, { type: 'error', message: 'cluster_member_replace rejected: invalid_access_mode' });
|
|
1899
1907
|
return;
|
|
1900
1908
|
}
|
|
1901
|
-
|
|
1909
|
+
const historyMode = msg.historyMode ?? (msg.includeHistory ? 'full' : 'none');
|
|
1910
|
+
if (!['none', 'recent', 'full'].includes(historyMode)) {
|
|
1911
|
+
send(ws, { type: 'error', message: 'cluster_member_replace rejected: invalid_history_mode' });
|
|
1912
|
+
return;
|
|
1913
|
+
}
|
|
1914
|
+
if (accessMode === 'isolated' && (historyMode !== 'none' || msg.transferActiveTasks)) {
|
|
1902
1915
|
send(ws, { type: 'error', message: 'cluster_member_replace rejected: isolated_requires_fresh_context_and_no_tasks' });
|
|
1903
1916
|
return;
|
|
1904
1917
|
}
|
|
@@ -1938,22 +1951,24 @@ export async function handleClusterMemberReplace(ws, session, msg) {
|
|
|
1938
1951
|
return;
|
|
1939
1952
|
}
|
|
1940
1953
|
}
|
|
1941
|
-
let historySeed = '';
|
|
1942
|
-
if (
|
|
1943
|
-
const
|
|
1944
|
-
|
|
1945
|
-
|
|
1946
|
-
|
|
1947
|
-
|
|
1948
|
-
|
|
1949
|
-
|
|
1950
|
-
|
|
1951
|
-
|
|
1952
|
-
|
|
1953
|
-
|
|
1954
|
-
|
|
1955
|
-
|
|
1956
|
-
|
|
1954
|
+
let historySeed = '', historyNotice;
|
|
1955
|
+
if (historyMode !== 'none') {
|
|
1956
|
+
const turns = msg.historyTurns ?? 10;
|
|
1957
|
+
try {
|
|
1958
|
+
if (!Number.isInteger(turns) || turns < 1 || turns > 50)
|
|
1959
|
+
throw new Error('Choose from 1 to 50 recent turns.');
|
|
1960
|
+
const preview = msg.historyToken
|
|
1961
|
+
? await takeReplacementHistoryPreview(ws, msg.clusterId, msg.workflowId, historyMode, turns, msg.historyToken)
|
|
1962
|
+
: msg.historyMode !== undefined
|
|
1963
|
+
? (() => { throw new Error('Preview the history before replacing this member.'); })()
|
|
1964
|
+
: await buildReplacementHistory(cluster.cwd, msg.workflowId, 'full', { turns, includePartial: false, preface: '', wasBusy: false });
|
|
1965
|
+
historySeed = preview.seed;
|
|
1966
|
+
historyNotice = replacementHistoryNotice(preview);
|
|
1967
|
+
if (source.busy)
|
|
1968
|
+
throw new Error('The member started working. Wait for it to finish and refresh the preview.');
|
|
1969
|
+
}
|
|
1970
|
+
catch (err) {
|
|
1971
|
+
send(ws, { type: 'error', message: `cluster_member_replace rejected: ${err instanceof Error ? err.message : String(err)}` });
|
|
1957
1972
|
return;
|
|
1958
1973
|
}
|
|
1959
1974
|
}
|
|
@@ -1962,16 +1977,22 @@ export async function handleClusterMemberReplace(ws, session, msg) {
|
|
|
1962
1977
|
model: msg.model, effort: msg.effort, accountRef: msg.providerAccountRef, isolated: accessMode === 'isolated', resolveCodexAccount,
|
|
1963
1978
|
tuning: msg,
|
|
1964
1979
|
});
|
|
1980
|
+
try {
|
|
1981
|
+
await assertSkillUnion(cluster, msg.role ?? clusterStore.getMemberRole(msg.clusterId, msg.workflowId), childConfig.pinnedSkills ?? [], childConfig.name ?? 'Replacement');
|
|
1982
|
+
}
|
|
1983
|
+
catch (err) {
|
|
1984
|
+
send(ws, { type: 'error', message: `cluster_member_replace rejected: ${err instanceof Error ? err.message : String(err)}` });
|
|
1985
|
+
return;
|
|
1986
|
+
}
|
|
1965
1987
|
let newWorkflowId;
|
|
1966
1988
|
try {
|
|
1967
1989
|
newWorkflowId = await deps.createBlankNativeWorkflow(ws, session, childConfig, MEMBER_PENDING);
|
|
1968
|
-
const replaced = await clusterStore.replaceMember(msg.clusterId, msg.workflowId, newWorkflowId, accessMode);
|
|
1990
|
+
const replaced = await clusterStore.replaceMember(msg.clusterId, msg.workflowId, newWorkflowId, accessMode, msg.role);
|
|
1969
1991
|
if (!replaced)
|
|
1970
1992
|
throw new Error('atomic_replace_failed');
|
|
1971
1993
|
// The slot's role, tier and focus moved with the replacement; the
|
|
1972
|
-
// request's own values win.
|
|
1973
|
-
|
|
1974
|
-
await clusterStore.setMemberRole(msg.clusterId, newWorkflowId, msg.role);
|
|
1994
|
+
// request's own values win. Role and skill limits were applied atomically
|
|
1995
|
+
// with replacement; the tier/focus values were checked above.
|
|
1975
1996
|
if (msg.tier !== undefined)
|
|
1976
1997
|
await clusterStore.setMemberTier(msg.clusterId, newWorkflowId, msg.tier);
|
|
1977
1998
|
if (msg.focus !== undefined)
|
|
@@ -2024,7 +2045,7 @@ export async function handleClusterMemberReplace(ws, session, msg) {
|
|
|
2024
2045
|
oldWorkflowId: msg.workflowId,
|
|
2025
2046
|
newWorkflowId,
|
|
2026
2047
|
accessMode,
|
|
2027
|
-
historyIncluded: !!
|
|
2048
|
+
historyIncluded: !!historySeed,
|
|
2028
2049
|
transferredTaskCount,
|
|
2029
2050
|
member: {
|
|
2030
2051
|
workflowId: newWorkflowId,
|
|
@@ -2045,6 +2066,8 @@ export async function handleClusterMemberReplace(ws, session, msg) {
|
|
|
2045
2066
|
const payload = await buildClusterStatePayload(msg.clusterId);
|
|
2046
2067
|
if (payload)
|
|
2047
2068
|
broadcastCluster(msg.clusterId, { type: 'cluster_state', clusterId: msg.clusterId, state: payload });
|
|
2069
|
+
if (historyNotice)
|
|
2070
|
+
broadcastWorkflow(newWorkflowId, { type: 'system_notice', workflowId: newWorkflowId, content: historyNotice });
|
|
2048
2071
|
if (historySeed) {
|
|
2049
2072
|
await deps.handleUserMessage(ws, session, newWorkflowId, historySeed, undefined, undefined, false, undefined, undefined);
|
|
2050
2073
|
}
|
|
@@ -2174,8 +2197,8 @@ export async function handleClusterMemberRoleSet(ws, clusterId, workflowId, role
|
|
|
2174
2197
|
updated = await clusterStore.setMemberRole(clusterId, workflowId, role);
|
|
2175
2198
|
}
|
|
2176
2199
|
catch (err) {
|
|
2177
|
-
if (err instanceof clusterStore.ClusterValidationError
|
|
2178
|
-
send(ws, { type: 'error', message: `cluster_member_role_set rejected:
|
|
2200
|
+
if (err instanceof clusterStore.ClusterValidationError) {
|
|
2201
|
+
send(ws, { type: 'error', message: `cluster_member_role_set rejected: ${err.code}: ${err.message}` });
|
|
2179
2202
|
return;
|
|
2180
2203
|
}
|
|
2181
2204
|
throw err;
|
|
@@ -2292,6 +2315,19 @@ export async function handleClusterEfficiencySet(ws, clusterId, level, addendum,
|
|
|
2292
2315
|
}
|
|
2293
2316
|
console.log(`[arco] cluster ${clusterId.slice(0, 8)} efficiency → ${level}${addendum !== undefined ? ' (addendum updated)' : ''}`);
|
|
2294
2317
|
}
|
|
2318
|
+
export async function handleClusterSkillsSet(ws, clusterId, pins) {
|
|
2319
|
+
try {
|
|
2320
|
+
const updated = await clusterStore.setSkillPins(clusterId, pins);
|
|
2321
|
+
if (!updated)
|
|
2322
|
+
throw new Error('Unknown cluster.');
|
|
2323
|
+
const payload = await buildClusterStatePayload(clusterId);
|
|
2324
|
+
if (payload)
|
|
2325
|
+
broadcastCluster(clusterId, { type: 'cluster_state', clusterId, state: payload });
|
|
2326
|
+
}
|
|
2327
|
+
catch (err) {
|
|
2328
|
+
send(ws, { type: 'error', message: `Cluster skills: ${err instanceof Error ? err.message : String(err)}` });
|
|
2329
|
+
}
|
|
2330
|
+
}
|
|
2295
2331
|
// R3 (docs/REMOTE_MANAGEMENT.md) - operator flipped the cluster-level
|
|
2296
2332
|
// ◉ REMOTE chip. Persist, rebroadcast cluster_state, and re-push the hub
|
|
2297
2333
|
// snapshot immediately so the phone console reflects the flip without waiting
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { runningCodexLateCommands } from '../providers/codex-appserver/index.js';
|
|
1
2
|
import { ensureWorkflowMetadata, providerConversationState, saveProviderSession } from '../providerConversation.js';
|
|
2
3
|
import { isClaudeNativeTaskActive } from '../providers/claude-native/index.js';
|
|
3
4
|
import { appendHandoffNotice } from '../handoffHistoryTool.js';
|
|
@@ -33,7 +34,7 @@ import { disposeProviderResources } from '../providers/index.js';
|
|
|
33
34
|
import { INCOGNITO_CHAT_PROVIDERS, incognitoChatCwd, isChatWorkflow } from '../chatMode.js';
|
|
34
35
|
import { registerPrivateLogToken } from '../server/logger.js';
|
|
35
36
|
import { acquirePlansWatcher, broadcastCluster, broadcastHandoffLockSnapshot, broadcastTransient, broadcastWorkflow, recordContextUsage, buildClusterStatePayload, send, } from '../server/broadcast.js';
|
|
36
|
-
import { buildLocalClusterSystemPrompt, LLAMACPP_PRIMARY_SYSTEM_PROMPT, OLLAMA_PRIMARY_SYSTEM_PROMPT, withPreviewNudge, } from '../server/prompts.js';
|
|
37
|
+
import { buildLocalClusterSystemPrompt, withLocalTurnWaitInstructions, LLAMACPP_PRIMARY_SYSTEM_PROMPT, OLLAMA_PRIMARY_SYSTEM_PROMPT, withPreviewNudge, } from '../server/prompts.js';
|
|
37
38
|
import { cwdHandoffChain, workflowCwds, workflows, } from '../server/state.js';
|
|
38
39
|
import { acquireProjectSettingsWatcher, readSettings, } from '../settings.js';
|
|
39
40
|
import { appendHistoryEntry, readMeta, workflowConfigFromMeta, writeMeta, } from '../workflowMeta.js';
|
|
@@ -517,11 +518,14 @@ export async function handleHandoffRequest(ws, session, msg) {
|
|
|
517
518
|
prewarmClusterProgressDoctrine = joinClusterDoctrines(buildClusterDirectorDoctrine(prewarmClusterRole), buildProgressDoctrine(clusterStore.getProgressTracking(prewarmClusterId), !!prewarmClusterPlan?.trim(), prewarmClusterTaskBoardAttached));
|
|
518
519
|
}
|
|
519
520
|
const prewarmIsLocal = wf.primary.provider === 'ollama' || wf.primary.provider === 'llamacpp' || wf.primary.provider === 'lmstudio' || (wf.primary.provider === 'strata' || wf.primary.provider === 'deepseek');
|
|
520
|
-
const
|
|
521
|
+
const prewarmLocalBaseline = wf.primary.provider === 'ollama'
|
|
521
522
|
? OLLAMA_PRIMARY_SYSTEM_PROMPT
|
|
522
523
|
: (wf.primary.provider === 'llamacpp' || wf.primary.provider === 'lmstudio' || (wf.primary.provider === 'strata' || wf.primary.provider === 'deepseek'))
|
|
523
524
|
? LLAMACPP_PRIMARY_SYSTEM_PROMPT
|
|
524
525
|
: undefined;
|
|
526
|
+
const prewarmLocalBase = prewarmIsLocal
|
|
527
|
+
? withLocalTurnWaitInstructions(prewarmLocalBaseline, prewarmClusterRole)
|
|
528
|
+
: undefined;
|
|
525
529
|
const prewarmSystemPrompt = prewarmIsLocal && prewarmClusterId
|
|
526
530
|
? buildLocalClusterSystemPrompt({
|
|
527
531
|
base: prewarmLocalBase,
|
|
@@ -1831,6 +1835,7 @@ export async function rehydrateOneWorkflow(ws, workflowId, wf, clientLastSeq, op
|
|
|
1831
1835
|
const msg = {
|
|
1832
1836
|
type: 'workflow_state_snapshot',
|
|
1833
1837
|
workflowId,
|
|
1838
|
+
...(wf.primary.provider === 'codex' ? { codexLateCommands: runningCodexLateCommands(workflowId) } : {}),
|
|
1834
1839
|
...(conversationState ? { providerConversation: conversationState } : {}),
|
|
1835
1840
|
workers: {},
|
|
1836
1841
|
busy: wf.busy,
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type WebSocket from 'ws';
|
|
2
|
+
import type { TranscriptWorkerCreateMessage, TranscriptWorkerPreviewMessage, WorkflowConfig } from '@arco/shared';
|
|
3
|
+
import type { Session } from '../workflows/types.js';
|
|
4
|
+
interface Dependencies {
|
|
5
|
+
create(ws: WebSocket, session: Session, config: WorkflowConfig): Promise<string>;
|
|
6
|
+
seed(ws: WebSocket, session: Session, workflowId: string, content: string): void;
|
|
7
|
+
}
|
|
8
|
+
export declare function initTranscriptWorkerHandlers(value: Dependencies): void;
|
|
9
|
+
export declare function handleTranscriptWorkerPreview(ws: WebSocket, message: TranscriptWorkerPreviewMessage): Promise<void>;
|
|
10
|
+
export declare function handleTranscriptWorkerCreate(ws: WebSocket, session: Session, message: TranscriptWorkerCreateMessage): Promise<void>;
|
|
11
|
+
export declare function takeReplacementHistoryPreview(ws: WebSocket, clusterId: string, workflowId: string, mode: 'recent' | 'full', turns: number, token: string): Promise<{
|
|
12
|
+
seed: string;
|
|
13
|
+
bytes: number;
|
|
14
|
+
selectedTurns: number;
|
|
15
|
+
digest: string;
|
|
16
|
+
historyMode: import("../replacementHistory.js").ReplacementHistoryMode;
|
|
17
|
+
requestedTurns: number;
|
|
18
|
+
truncated: boolean;
|
|
19
|
+
historyFallback: boolean;
|
|
20
|
+
availableTurns: number;
|
|
21
|
+
partialIncluded: boolean;
|
|
22
|
+
cutoffSeq: number;
|
|
23
|
+
branchKey: string;
|
|
24
|
+
}>;
|
|
25
|
+
export {};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import * as clusterStore from '../clusterStore.js';
|
|
2
|
+
import { buildReplacementHistory } from '../replacementHistory.js';
|
|
3
|
+
import { randomUUID } from 'node:crypto';
|
|
4
|
+
import { isAbsolute } from 'node:path';
|
|
5
|
+
import { send } from '../server/broadcast.js';
|
|
6
|
+
import { workflows } from '../server/state.js';
|
|
7
|
+
import { safeDirectory } from '../fileAccessPolicy.js';
|
|
8
|
+
import { readSettings } from '../settings.js';
|
|
9
|
+
import { isKnownProvider } from '../providers/index.js';
|
|
10
|
+
import { configuredAccounts } from '../providerAccounts.js';
|
|
11
|
+
import { buildTranscriptWorkerSlice } from '../transcriptWorker.js';
|
|
12
|
+
import { TERMINAL_CODEX_ACCOUNT } from '@arco/shared';
|
|
13
|
+
let deps;
|
|
14
|
+
export function initTranscriptWorkerHandlers(value) { deps = value; }
|
|
15
|
+
const snapshots = new Map();
|
|
16
|
+
function prune() {
|
|
17
|
+
for (const [token, entry] of snapshots)
|
|
18
|
+
if (entry.expires < Date.now() && !entry.creating)
|
|
19
|
+
snapshots.delete(token);
|
|
20
|
+
while (snapshots.size >= 32) {
|
|
21
|
+
const oldest = [...snapshots].find(([, entry]) => !entry.creating);
|
|
22
|
+
if (!oldest)
|
|
23
|
+
throw new Error('Transcript previews are busy. Try again when a request finishes.');
|
|
24
|
+
snapshots.delete(oldest[0]);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
function sourceFor(workflowId) {
|
|
28
|
+
const source = workflows.get(workflowId);
|
|
29
|
+
if (!source || source.config.kind === 'chat' || source.config.kind === 'cluster' || source.config.incognito || !source.config.workingDirectory)
|
|
30
|
+
throw new Error('Choose an available Agent conversation as the source.');
|
|
31
|
+
return source;
|
|
32
|
+
}
|
|
33
|
+
export async function handleTranscriptWorkerPreview(ws, message) {
|
|
34
|
+
try {
|
|
35
|
+
prune();
|
|
36
|
+
const source = sourceFor(message.workflowId);
|
|
37
|
+
const options = { turns: message.turns, includePartial: message.includePartial, preface: message.preface, wasBusy: source.busy };
|
|
38
|
+
let cwd = source.config.workingDirectory;
|
|
39
|
+
if (message.replacement) {
|
|
40
|
+
const cluster = await clusterStore.readCluster(message.replacement.clusterId);
|
|
41
|
+
if (!cluster?.members.includes(message.workflowId))
|
|
42
|
+
throw new Error('Choose an available cluster member.');
|
|
43
|
+
if (source.busy)
|
|
44
|
+
throw new Error('Wait for the member to finish before replacing it.');
|
|
45
|
+
if (!['recent', 'full'].includes(message.replacement.mode))
|
|
46
|
+
throw new Error('Choose a valid history mode.');
|
|
47
|
+
cwd = cluster.cwd;
|
|
48
|
+
options.includePartial = false;
|
|
49
|
+
options.preface = '';
|
|
50
|
+
options.wasBusy = false;
|
|
51
|
+
}
|
|
52
|
+
const slice = message.replacement
|
|
53
|
+
? await buildReplacementHistory(cwd, message.workflowId, message.replacement.mode, options)
|
|
54
|
+
: await buildTranscriptWorkerSlice(cwd, message.workflowId, options);
|
|
55
|
+
const token = randomUUID();
|
|
56
|
+
snapshots.set(token, { replacement: message.replacement, owner: ws, source: message.workflowId, cwd, options: { ...options, cutoffSeq: slice.cutoffSeq }, slice, expires: Date.now() + 10 * 60_000 });
|
|
57
|
+
const { digest: _digest, branchKey: _branch, ...preview } = slice;
|
|
58
|
+
send(ws, { type: 'transcript_worker_result', requestId: message.requestId, preview: { ...preview, token } });
|
|
59
|
+
}
|
|
60
|
+
catch (error) {
|
|
61
|
+
send(ws, { type: 'transcript_worker_result', requestId: message.requestId, error: error instanceof Error ? error.message : String(error) });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
async function destinationConfig(message) {
|
|
65
|
+
const target = message.destination;
|
|
66
|
+
if (!target || typeof target.workingDirectory !== 'string' || !isAbsolute(target.workingDirectory))
|
|
67
|
+
throw new Error('Choose an existing absolute working directory for the new worker.');
|
|
68
|
+
let workingDirectory;
|
|
69
|
+
try {
|
|
70
|
+
workingDirectory = safeDirectory(target.workingDirectory);
|
|
71
|
+
}
|
|
72
|
+
catch {
|
|
73
|
+
throw new Error('The destination folder is unavailable or protected. Choose another existing folder.');
|
|
74
|
+
}
|
|
75
|
+
if (!isKnownProvider(target.provider) || typeof target.model !== 'string' || !target.model.trim())
|
|
76
|
+
throw new Error('Choose a supported provider and model.');
|
|
77
|
+
if (!['none', 'low', 'medium', 'high', 'xhigh', 'max', 'ultra'].includes(target.effort))
|
|
78
|
+
throw new Error('Choose a valid effort.');
|
|
79
|
+
if (target.skipPermissions !== undefined && typeof target.skipPermissions !== 'boolean')
|
|
80
|
+
throw new Error('Choose the new worker permission setting.');
|
|
81
|
+
const settings = await readSettings(workingDirectory);
|
|
82
|
+
if (settings.enabledProviders?.[target.provider] === false)
|
|
83
|
+
throw new Error('That provider is turned off. Enable it or choose another provider.');
|
|
84
|
+
if (target.providerAccountRef && !(target.provider === 'codex' && target.providerAccountRef === TERMINAL_CODEX_ACCOUNT)) {
|
|
85
|
+
if (target.provider !== 'codex' || !(await configuredAccounts('codex', workingDirectory)).some(account => account.id === target.providerAccountRef))
|
|
86
|
+
throw new Error('Choose an available account for the new worker.');
|
|
87
|
+
}
|
|
88
|
+
return { kind: 'workflow', name: typeof target.name === 'string' && target.name.trim() ? target.name.trim().slice(0, 120) : 'Transcript worker', workingDirectory,
|
|
89
|
+
primaryProvider: target.provider, primaryModel: target.model.trim(), primaryEffort: target.effort,
|
|
90
|
+
...(target.provider === 'codex' && target.providerAccountRef ? { providerAccountRef: target.providerAccountRef } : {}), skipPermissions: target.skipPermissions === true };
|
|
91
|
+
}
|
|
92
|
+
export async function handleTranscriptWorkerCreate(ws, session, message) {
|
|
93
|
+
try {
|
|
94
|
+
const entry = snapshots.get(message.token);
|
|
95
|
+
if (!entry || entry.owner !== ws || entry.replacement || entry.expires < Date.now())
|
|
96
|
+
throw new Error('The preview expired or disconnected. Refresh the preview before sending.');
|
|
97
|
+
if (!entry.created && !entry.creating) {
|
|
98
|
+
entry.creating = (async () => {
|
|
99
|
+
const source = sourceFor(entry.source);
|
|
100
|
+
if (source.config.workingDirectory !== entry.cwd)
|
|
101
|
+
throw new Error('The source folder changed. Refresh the preview.');
|
|
102
|
+
const current = await buildTranscriptWorkerSlice(entry.cwd, entry.source, entry.options);
|
|
103
|
+
if (current.digest !== entry.slice.digest)
|
|
104
|
+
throw new Error('The source history changed or was rewound. Refresh the preview.');
|
|
105
|
+
const config = await destinationConfig(message);
|
|
106
|
+
const id = await deps.create(ws, session, config);
|
|
107
|
+
entry.created = id;
|
|
108
|
+
deps.seed(ws, session, id, entry.slice.seed);
|
|
109
|
+
return id;
|
|
110
|
+
})();
|
|
111
|
+
}
|
|
112
|
+
const id = entry.created ?? await entry.creating;
|
|
113
|
+
entry.creating = undefined;
|
|
114
|
+
send(ws, { type: 'transcript_worker_result', requestId: message.requestId, newWorkflowId: id });
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
const entry = snapshots.get(message.token);
|
|
118
|
+
if (entry && !entry.created)
|
|
119
|
+
entry.creating = undefined;
|
|
120
|
+
send(ws, { type: 'transcript_worker_result', requestId: message.requestId, error: error instanceof Error ? error.message : String(error) });
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
// REPLACE consumes the same socket-bound, fixed-cutoff preview as NEW WORKER.
|
|
124
|
+
// Claim after checking again so a repeated submit cannot allocate two members.
|
|
125
|
+
export async function takeReplacementHistoryPreview(ws, clusterId, workflowId, mode, turns, token) {
|
|
126
|
+
const entry = snapshots.get(token);
|
|
127
|
+
if (!entry || entry.owner !== ws || entry.expires < Date.now() || entry.source !== workflowId
|
|
128
|
+
|| entry.replacement?.clusterId !== clusterId || entry.replacement.mode !== mode || entry.options.turns !== turns) {
|
|
129
|
+
throw new Error('The history preview expired or changed. Refresh it before replacing.');
|
|
130
|
+
}
|
|
131
|
+
const current = await buildReplacementHistory(entry.cwd, workflowId, mode, entry.options);
|
|
132
|
+
if (current.digest !== entry.slice.digest)
|
|
133
|
+
throw new Error('The source history changed or was rewound. Refresh the preview.');
|
|
134
|
+
if (entry.claimed)
|
|
135
|
+
throw new Error('This history preview was already used. Refresh it before replacing again.');
|
|
136
|
+
entry.claimed = true;
|
|
137
|
+
return current;
|
|
138
|
+
}
|
|
139
|
+
//# sourceMappingURL=transcriptWorkerHandlers.js.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveWorkflowSkillPins } from '../clusterSkills.js';
|
|
2
|
+
import { ensureWorkflowMetadata, providerConversationState, saveProviderSession, announceReplacementConversation, markConversationReading, reportHistoryLoadFailure } from '../providerConversation.js';
|
|
2
3
|
import { mintHandoffHistoryCapability } from '../http/handoffHistoryRoutes.js';
|
|
3
4
|
import { deliverAfterTurnRevoked } from './taskLifecycle.js';
|
|
4
5
|
import { resolveClaudeTransport } from '../claudeTransport.js';
|
|
@@ -55,7 +56,7 @@ import { isAvailable } from '../quota.js';
|
|
|
55
56
|
import { resolveProviderAccount } from '../providerAccounts.js';
|
|
56
57
|
import { broadcastTransient, broadcastWorkflow, notifyClusterStateForWorkflow, send } from '../server/broadcast.js';
|
|
57
58
|
import { FOREIGN_WARN_DEBOUNCE_MS, FOREIGN_WRITE_BLOCK_MS, PORT, SESSION_HISTORY_PAGE_SIZE } from '../server/constants.js';
|
|
58
|
-
import { buildLocalClusterSystemPrompt, LLAMACPP_PRIMARY_SYSTEM_PROMPT, OLLAMA_PRIMARY_SYSTEM_PROMPT } from '../server/prompts.js';
|
|
59
|
+
import { buildLocalClusterSystemPrompt, withLocalTurnWaitInstructions, LLAMACPP_PRIMARY_SYSTEM_PROMPT, OLLAMA_PRIMARY_SYSTEM_PROMPT } from '../server/prompts.js';
|
|
59
60
|
import { buildGenesisSystemBlock } from '../genesis/prompts.js';
|
|
60
61
|
import { CHAT_PROVIDERS, chatSystemPrompt, chatWebArmed, isChatWorkflow } from '../chatMode.js';
|
|
61
62
|
import { resolveNativeInTurnCompactPercent, resolveTurnSettings } from './turnSettings.js';
|
|
@@ -65,7 +66,7 @@ import { sessions, workflows } from '../server/state.js';
|
|
|
65
66
|
import { loadSessionJsonl, resolveSessionJsonlPath, watchSessionJsonl } from '../sessionJsonl.js';
|
|
66
67
|
import { startUltracodeFleetWatcher } from '../ultracodeFleetWatcher.js';
|
|
67
68
|
import { readSettings } from '../settings.js';
|
|
68
|
-
import { buildPickedSkillsBlock, buildPinnedSkillsBlock,
|
|
69
|
+
import { buildPickedSkillsBlock, buildPinnedSkillsBlock, buildSkillsManifest, listSkills, readSkillBody, readBuiltinSkill, } from '../skills.js';
|
|
69
70
|
import { ARCHITECTURE_REVIEW_SLUG, architectureReviewFacts } from '../architectureReview.js';
|
|
70
71
|
import { artifactsDir } from '../workers/limits.js';
|
|
71
72
|
import { readMeta, updateMeta, workflowDir } from '../workflowMeta.js';
|
|
@@ -75,6 +76,7 @@ import { foldClaudeNativeWorker } from '../providers/claude-native/index.js';
|
|
|
75
76
|
import { maybeFreshComputerContext } from '../voice/computerContext.js';
|
|
76
77
|
import { takeQueuedTurn } from './messageQueue.js';
|
|
77
78
|
import { awaitModelImages } from '../providers/attachments.js';
|
|
79
|
+
import { adoptPhoneDrafts } from '../http/phoneUploadDrafts.js';
|
|
78
80
|
const PUBLIC_REPO_SAFETY_SYSTEM_BLOCK = [
|
|
79
81
|
'Genesis public repository safety:',
|
|
80
82
|
'This workflow is attached to a Genesis project configured for a public GitHub repository.',
|
|
@@ -239,10 +241,19 @@ export function startSessionWatcher(workflowId, wf, cwd, initialWs) {
|
|
|
239
241
|
const current = () => workflows.get(workflowId) === wf && wf.primarySessionId === sessionId
|
|
240
242
|
&& sessionWatcherEpochs.get(wf) === epoch && wf.primary.provider === 'claude';
|
|
241
243
|
const path = resolveSessionJsonlPath(cwd, sessionId);
|
|
242
|
-
resolveClaudeTransport(wf, cwd).then((transport) => {
|
|
244
|
+
resolveClaudeTransport(wf, cwd).then(async (transport) => {
|
|
243
245
|
if (!current() || transport === 'native')
|
|
244
246
|
return null;
|
|
245
|
-
|
|
247
|
+
try {
|
|
248
|
+
return await loadSessionJsonl(path);
|
|
249
|
+
}
|
|
250
|
+
catch (err) {
|
|
251
|
+
console.error(`[arco] [${workflowId.slice(0, 8)}] session history load failed:`, err);
|
|
252
|
+
if (!current())
|
|
253
|
+
return null;
|
|
254
|
+
reportHistoryLoadFailure(workflowId, wf, 'cli');
|
|
255
|
+
return { entries: [], byteLength: null };
|
|
256
|
+
}
|
|
246
257
|
}).then((loaded) => {
|
|
247
258
|
if (!loaded || !current())
|
|
248
259
|
return;
|
|
@@ -314,7 +325,7 @@ export function startSessionWatcher(workflowId, wf, cwd, initialWs) {
|
|
|
314
325
|
else {
|
|
315
326
|
dispose(); // workflow gone — clean up immediately
|
|
316
327
|
}
|
|
317
|
-
console.log(`[arco] [${workflowId.slice(0, 8)}] session watcher started (${tail.length} emitted / ${earlier.length} deferred / ${entries.length} total, ${byteLength}B)`);
|
|
328
|
+
console.log(`[arco] [${workflowId.slice(0, 8)}] session watcher started (${tail.length} emitted / ${earlier.length} deferred / ${entries.length} total, ${byteLength === null ? 'offset pending' : `${byteLength}B`})`);
|
|
318
329
|
}).catch((err) => {
|
|
319
330
|
console.error(`[arco] [${workflowId.slice(0, 8)}] session watcher init failed:`, err);
|
|
320
331
|
});
|
|
@@ -1489,6 +1500,10 @@ opts) {
|
|
|
1489
1500
|
type: 'system_notice', workflowId,
|
|
1490
1501
|
content: '[INTERRUPT & SEND] No interruptible Claude or Codex primary turn is running. Your message is queued as a follow-up.',
|
|
1491
1502
|
});
|
|
1503
|
+
if (!isolatedMember && !adoptPhoneDrafts(workflowId, attachments)) {
|
|
1504
|
+
send(ws, { type: 'error', workflowId, message: 'A phone attachment expired or belongs to another conversation.' });
|
|
1505
|
+
return;
|
|
1506
|
+
}
|
|
1492
1507
|
const arr = bucket === 'steer' ? wf.queue.steering : wf.queue.followUp;
|
|
1493
1508
|
const queuedAttachments = [...new Set([...(attachments ?? []), ...contextAttachments])];
|
|
1494
1509
|
const queuedItem = { clusterBusyReminder: opts?.clusterBusyReminder, automaticKind: opts?.automaticKind, content, attachments: isolatedMember || !queuedAttachments.length ? undefined : queuedAttachments, clientMessageId, expandedContext, pickedSkills, editPickedSkills, ollamaInputSeq: undefined, ...(interrupt ? { interrupt: true } : {}) };
|
|
@@ -1566,6 +1581,10 @@ opts) {
|
|
|
1566
1581
|
// Refuse before taking queued input: a restore admitted during preflight
|
|
1567
1582
|
// must leave the queue available for an explicit later attempt.
|
|
1568
1583
|
assertCheckoutAvailable(workflowWritePaths(wf));
|
|
1584
|
+
if (!fromQueue && !isolatedMember && !adoptPhoneDrafts(workflowId, attachments)) {
|
|
1585
|
+
send(ws, { type: 'error', workflowId, message: 'A phone attachment expired or belongs to another conversation.' });
|
|
1586
|
+
return;
|
|
1587
|
+
}
|
|
1569
1588
|
let activeOllamaInputSeqs = [];
|
|
1570
1589
|
let activeInputClientIds = [];
|
|
1571
1590
|
if (fromQueue) {
|
|
@@ -1762,8 +1781,9 @@ opts) {
|
|
|
1762
1781
|
// pick, a project pin is an explicit operator vouch and bypasses discovery's
|
|
1763
1782
|
// project-trust suppression. Missing files fail safe and stay visible.
|
|
1764
1783
|
let pinnedSkillsBlock = '';
|
|
1765
|
-
|
|
1766
|
-
|
|
1784
|
+
const effectivePins = projectContextEnabled ? await resolveWorkflowSkillPins(workflowId, cwd, wf.config.pinnedSkills ?? []) : undefined;
|
|
1785
|
+
if (effectivePins?.refs.length) {
|
|
1786
|
+
const { resolved } = effectivePins;
|
|
1767
1787
|
const built = buildPinnedSkillsBlock(resolved.skills);
|
|
1768
1788
|
pinnedSkillsBlock = built.text;
|
|
1769
1789
|
const skipped = [...resolved.missing, ...resolved.truncated];
|
|
@@ -1963,7 +1983,7 @@ opts) {
|
|
|
1963
1983
|
const catalog = await listSkills(cwd, { includeProject });
|
|
1964
1984
|
// A pinned body is already present in full; omit its progressive-
|
|
1965
1985
|
// disclosure metadata to avoid duplicate/conflicting instructions.
|
|
1966
|
-
const pinnedKeys = new Set((
|
|
1986
|
+
const pinnedKeys = new Set((effectivePins?.refs ?? []).map((s) => `${s.scope}:${s.slug}`));
|
|
1967
1987
|
primarySkillsManifest = buildSkillsManifest({
|
|
1968
1988
|
project: catalog.project.filter((s) => !pinnedKeys.has(`project:${s.slug}`)),
|
|
1969
1989
|
global: catalog.global.filter((s) => !pinnedKeys.has(`global:${s.slug}`)),
|
|
@@ -2213,6 +2233,9 @@ opts) {
|
|
|
2213
2233
|
turnClusterEfficiencyDoctrine = clusterEfficiency.buildDoctrine(turnClusterEfficiencyLevel, clusterStore.getEfficiencyAddendum(turnClusterId), turnClusterRole, clusterStore.getMessageGuard(turnClusterId));
|
|
2214
2234
|
turnClusterProgressDoctrine = joinClusterDoctrines(buildClusterDirectorDoctrine(turnClusterRole), buildProgressDoctrine(clusterStore.getProgressTracking(turnClusterId), !!turnClusterPlan && turnClusterPlan.trim().length > 0, turnClusterTaskBoardAttached));
|
|
2215
2235
|
}
|
|
2236
|
+
if (!chatMode && (wf.primary.provider === 'ollama' || wf.primary.provider === 'llamacpp' || wf.primary.provider === 'lmstudio' || wf.primary.provider === 'strata' || wf.primary.provider === 'deepseek')) {
|
|
2237
|
+
finalSystemPrompt = withLocalTurnWaitInstructions(finalSystemPrompt, turnClusterRole);
|
|
2238
|
+
}
|
|
2216
2239
|
if (turnClusterId && (wf.primary.provider === 'ollama' || wf.primary.provider === 'llamacpp' || wf.primary.provider === 'lmstudio' || wf.primary.provider === 'strata' || wf.primary.provider === 'deepseek')) {
|
|
2217
2240
|
if (clusterAccessMode === 'standard') {
|
|
2218
2241
|
finalSystemPrompt = buildLocalClusterSystemPrompt({
|
|
@@ -2525,6 +2548,14 @@ opts) {
|
|
|
2525
2548
|
return [];
|
|
2526
2549
|
return wf.queue.steering;
|
|
2527
2550
|
},
|
|
2551
|
+
pendingInput: () => {
|
|
2552
|
+
if (!dispatchCurrent() || wf.queue.steering.some((item) => item.interrupt))
|
|
2553
|
+
return undefined;
|
|
2554
|
+
const direct = (item) => item.automaticKind !== 'auto-pickup';
|
|
2555
|
+
if (!wf.primaryTurn?.holdSteer && wf.queue.steering.some(direct))
|
|
2556
|
+
return 'steer';
|
|
2557
|
+
return wf.queue.followUp.some(direct) ? 'follow-up' : undefined;
|
|
2558
|
+
},
|
|
2528
2559
|
requeueSteer: (items, bucket) => {
|
|
2529
2560
|
if (workflows.get(workflowId) === wf && (busyRevocations.get(wf) ?? 0) === interruptEpoch)
|
|
2530
2561
|
requeueSteerForWorker(workflowId, ws, items, bucket);
|
|
@@ -9,13 +9,21 @@ import { updateMeta } from '../workflowMeta.js';
|
|
|
9
9
|
import { withFileLock } from '../atomicFile.js';
|
|
10
10
|
import { disposeProviderResources } from '../providers/index.js';
|
|
11
11
|
import { refreshHubReporting } from '../management/initHubLink.js';
|
|
12
|
-
import { buildPinnedSkillsBlock, resolvePinnedSkills } from '../skills.js';
|
|
12
|
+
import { buildPinnedSkillsBlock, resolvePinnedSkills, isValidSlug } from '../skills.js';
|
|
13
|
+
import { withClusterSkillLock } from '../clusterStore.js';
|
|
14
|
+
import { assertWorkflowSkillPins, uniqueSkillRefs } from '../clusterSkills.js';
|
|
13
15
|
export async function handleUpdatePrimaryConfig(ws, session, msg) {
|
|
14
16
|
const wf = workflows.get(msg.workflowId);
|
|
15
17
|
if (!wf) {
|
|
16
18
|
send(ws, { type: 'error', message: `Unknown workflow ${msg.workflowId.slice(0, 8)}` });
|
|
17
19
|
return;
|
|
18
20
|
}
|
|
21
|
+
if (wf.primary.provider === 'claude' && msg.effort !== undefined
|
|
22
|
+
&& !['low', 'medium', 'high', 'xhigh', 'max'].includes(msg.effort)) {
|
|
23
|
+
send(ws, { type: 'error', workflowId: msg.workflowId,
|
|
24
|
+
message: 'Claude effort must be low, medium, high, xhigh or max; no settings were changed.' });
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
19
27
|
const proposedGoal = msg.goal === undefined ? wf.config.goal : capGoal(msg.goal);
|
|
20
28
|
const proposedGoalRun = msg.goalRun === undefined ? undefined : normalizeGoalRunArm(msg.goalRun, !!proposedGoal?.trim());
|
|
21
29
|
if (typeof proposedGoalRun === 'string') {
|
|
@@ -270,13 +278,24 @@ export async function handleUpdatePrimaryConfig(ws, session, msg) {
|
|
|
270
278
|
// re-read at every turn; this snapshot is only the pin acknowledgement.
|
|
271
279
|
let pinnedSkillsBroadcast;
|
|
272
280
|
if (msg.pinnedSkills !== undefined) {
|
|
273
|
-
const requested = Array.isArray(msg.pinnedSkills) ? msg.pinnedSkills : [];
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
281
|
+
const requested = uniqueSkillRefs((Array.isArray(msg.pinnedSkills) ? msg.pinnedSkills : []).filter(ref => ref && (ref.scope === 'project' || ref.scope === 'global') && isValidSlug(ref.slug)));
|
|
282
|
+
let resolved;
|
|
283
|
+
try {
|
|
284
|
+
resolved = await withClusterSkillLock(msg.workflowId, async () => {
|
|
285
|
+
await assertWorkflowSkillPins(msg.workflowId, wf.config.workingDirectory, requested);
|
|
286
|
+
const result = await resolvePinnedSkills(requested, wf.config.workingDirectory);
|
|
287
|
+
const refs = result.skills.map(s => ({ scope: s.scope, slug: s.slug }));
|
|
288
|
+
if (refs.length)
|
|
289
|
+
wf.config.pinnedSkills = refs;
|
|
290
|
+
else
|
|
291
|
+
delete wf.config.pinnedSkills;
|
|
292
|
+
return result;
|
|
293
|
+
});
|
|
294
|
+
}
|
|
295
|
+
catch (err) {
|
|
296
|
+
send(ws, { type: 'error', workflowId: msg.workflowId, message: err instanceof Error ? err.message : String(err) });
|
|
297
|
+
return;
|
|
298
|
+
}
|
|
280
299
|
const block = buildPinnedSkillsBlock(resolved.skills);
|
|
281
300
|
pinnedSkillsBroadcast = {
|
|
282
301
|
skills: resolved.skills.map((s) => ({ scope: s.scope, slug: s.slug, name: s.name })),
|
|
@@ -12,7 +12,10 @@ export interface WorkflowHandlerDeps {
|
|
|
12
12
|
}>) => Promise<void>;
|
|
13
13
|
}
|
|
14
14
|
export declare function initWorkflowHandlers(d: WorkflowHandlerDeps): void;
|
|
15
|
-
export declare function handleCreateWorkflow(ws: WebSocket, session: Session, config: WorkflowConfig
|
|
15
|
+
export declare function handleCreateWorkflow(ws: WebSocket, session: Session, config: WorkflowConfig, options?: {
|
|
16
|
+
onCreated?: (workflowId: string) => void;
|
|
17
|
+
backgroundCreated?: boolean;
|
|
18
|
+
}): Promise<void>;
|
|
16
19
|
export declare function appendPreviewHistory(arr: PreviewHistoryEntry[], entry: PreviewHistoryEntry): PreviewHistoryEntry[];
|
|
17
20
|
export declare function handleSetPreviewPort(workflowId: string, port: number, framework: string | undefined, manual: boolean): Promise<void>;
|
|
18
21
|
export declare function handleClearPreviewPort(workflowId: string): Promise<void>;
|
|
@@ -62,7 +62,7 @@ import { applyAutoHandoffDefault, applyClaudeNativeCompactDefault, broadcastQueu
|
|
|
62
62
|
import { restoreCompactions } from '../compactionCounter.js';
|
|
63
63
|
let deps;
|
|
64
64
|
export function initWorkflowHandlers(d) { deps = d; }
|
|
65
|
-
export async function handleCreateWorkflow(ws, session, config) {
|
|
65
|
+
export async function handleCreateWorkflow(ws, session, config, options) {
|
|
66
66
|
let workflowId;
|
|
67
67
|
let resumed = false;
|
|
68
68
|
let resumeWorkflowMeta = null;
|
|
@@ -590,10 +590,12 @@ export async function handleCreateWorkflow(ws, session, config) {
|
|
|
590
590
|
workflowId,
|
|
591
591
|
config,
|
|
592
592
|
...hints,
|
|
593
|
+
...(options?.backgroundCreated ? { backgroundCreated: true } : {}),
|
|
593
594
|
...(wfNowForCreate?.primary.provider === 'claude' && wfNowForCreate.primarySessionId
|
|
594
595
|
? { claudeSessionId: wfNowForCreate.primarySessionId }
|
|
595
596
|
: {}),
|
|
596
597
|
});
|
|
598
|
+
options?.onCreated?.(workflowId);
|
|
597
599
|
// Genesis creation starts with the seed on config, but the right-panel UI
|
|
598
600
|
// reads the normalized seed/readiness fields populated by genesis_seed_updated.
|
|
599
601
|
// Echo it immediately so a fresh Genesis tab does not look like an ordinary
|
package/server/package.json
CHANGED
package/server/src/atomicFile.ts
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
//
|
|
3
3
|
// Before this module, ~20 call sites hand-rolled `write tmp -> rename`, 11 of
|
|
4
4
|
// them via byte-identical private `atomicWrite` helpers. They shared three
|
|
5
|
-
// defects (
|
|
6
|
-
// writes):
|
|
5
|
+
// defects (see docs/PERSISTENCE.md, Atomic writes):
|
|
7
6
|
//
|
|
8
7
|
// 1. NO fsync. `rename` is atomic for the directory entry, but the bytes may
|
|
9
8
|
// still be in the page cache. A crash between write and flush can leave a
|