arco-workbench 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CONTRIBUTING.md +52 -12
- package/README.md +14 -12
- package/client/dist/assets/{PhosphorBackdrop-DVQdBrTw.js → PhosphorBackdrop-D7jdAV_G.js} +1 -1
- package/client/dist/assets/{ThemedBackgroundShaderImpl-BfSs2tB4.js → ThemedBackgroundShaderImpl-DrDm60h8.js} +1 -1
- package/client/dist/assets/{XtermView-DaMjC8Ny.js → XtermView-BGFujb1e.js} +1 -1
- package/client/dist/assets/{galleryEditor-BCQnXj7R.js → galleryEditor-D951A2sE.js} +1 -1
- package/client/dist/assets/{index-COfbHCYv.js → index-CsVy3eZm.js} +246 -246
- package/client/dist/index.html +1 -1
- package/client/src/components/ClusterRightPanel/ReplaceMemberDialog.tsx +65 -15
- package/client/src/components/ClusterRightPanel/SkillsControl.tsx +107 -0
- package/client/src/components/ClusterRightPanel/index.tsx +4 -0
- package/client/src/components/ClusterTaskBoardTab.tsx +9 -22
- package/client/src/components/NeedsYouBadge.tsx +3 -3
- package/client/src/components/ProviderReleasesModal.tsx +8 -4
- package/client/src/components/ProvidersPopover.tsx +28 -23
- package/client/src/components/SettingsPanel.tsx +2 -2
- package/client/src/components/SkillsSettings.tsx +5 -0
- package/client/src/components/TabBar.tsx +91 -9
- package/client/src/components/TerminalInput.tsx +12 -10
- package/client/src/components/TranscriptSendDialog.tsx +12 -8
- package/client/src/components/TranscriptWorkerDialog.tsx +119 -0
- package/client/src/components/clusterNeedsYou.ts +11 -18
- package/client/src/help/content/cluster.tsx +38 -17
- package/client/src/help/content/composer.tsx +22 -0
- package/client/src/help/content/header.tsx +16 -0
- package/client/src/help/content/misc.tsx +8 -0
- 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 +41 -20
- package/client/src/help/manualSections/configuration.tsx +18 -0
- package/client/src/help/manualSections/maintenance.tsx +18 -0
- 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 +6 -0
- package/client/src/utils/transcriptWorkerRequest.ts +24 -0
- package/client/src/ws/handleServerMessage.ts +8 -2
- package/docs/ARCHITECTURE.md +1 -1
- package/docs/CLIENT.md +9 -8
- package/docs/FEATURES.md +8 -5
- package/docs/GETTING_STARTED.md +4 -3
- package/docs/GOTCHAS.md +2 -1
- package/docs/OPERATIONS.md +14 -4
- package/docs/PERSISTENCE.md +7 -2
- package/docs/PRIMITIVES.md +42 -0
- package/docs/PROTOCOL_CLUSTER.md +42 -3
- package/docs/PROTOCOL_PRIMITIVES.md +39 -0
- package/docs/PROVIDERS.md +50 -13
- package/docs/SETTINGS.md +27 -3
- package/docs/TASK_LEDGER.md +7 -15
- package/native/darwin-arm64/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/clientMessages.d.ts +3 -2
- package/node_modules/@arco/shared/dist/protocol/clusters.d.ts +13 -1
- package/node_modules/@arco/shared/dist/protocol/index.d.ts +1 -0
- package/node_modules/@arco/shared/dist/protocol/index.js +1 -0
- package/node_modules/@arco/shared/dist/protocol/models.d.ts +4 -3
- package/node_modules/@arco/shared/dist/protocol/models.js +26 -2
- package/node_modules/@arco/shared/dist/protocol/serverMessages.d.ts +2 -1
- package/node_modules/@arco/shared/dist/protocol/tasks.d.ts +4 -0
- package/node_modules/@arco/shared/dist/protocol/transcriptWorker.d.ts +47 -0
- package/node_modules/@arco/shared/dist/protocol/transcriptWorker.js +2 -0
- package/node_modules/@arco/shared/dist/runtimeVersions.d.ts +1 -0
- package/node_modules/@arco/shared/dist/runtimeVersions.js +14 -0
- package/node_modules/@arco/shared/package.json +1 -1
- package/package.json +2 -2
- package/scripts/packaging/arco.mjs +1 -1
- package/scripts/packaging/native-repair.mjs +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 +1 -1
- package/server/dist/clusterPeerOps.js +10 -7
- package/server/dist/clusterProgress.js +1 -1
- package/server/dist/clusterSkills.d.ts +13 -0
- package/server/dist/clusterSkills.js +81 -0
- package/server/dist/clusterSnapshots.js +2 -0
- package/server/dist/clusterStore.d.ts +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/historyLimits.d.ts +1 -0
- package/server/dist/historyLimits.js +3 -0
- package/server/dist/http/router.js +1 -1
- package/server/dist/index.js +24 -1
- package/server/dist/jsonlLines.d.ts +4 -0
- package/server/dist/jsonlLines.js +53 -0
- package/server/dist/management/identity.js +1 -0
- package/server/dist/mcp/clusterMcpTools.js +4 -4
- package/server/dist/project/taskLedger.d.ts +4 -0
- package/server/dist/project/taskLedger.js +7 -4
- package/server/dist/providerConversation.d.ts +1 -0
- package/server/dist/providerConversation.js +17 -0
- package/server/dist/providers/claude-native/resumeSummary.d.ts +9 -0
- package/server/dist/providers/claude-native/resumeSummary.js +102 -49
- package/server/dist/providers/claude-native/worker.js +8 -4
- package/server/dist/providers/claude.js +2 -1
- package/server/dist/providers/clusterTaskToolDefinitions.js +4 -4
- package/server/dist/providers/codex-appserver/catalog.js +16 -1
- package/server/dist/providers/codex.js +2 -1
- package/server/dist/providers/codexCodeMode.d.ts +1 -1
- package/server/dist/providers/codexCodeMode.js +4 -3
- package/server/dist/providers/cursor/print.js +2 -1
- package/server/dist/providers/cursor/worker.js +2 -1
- package/server/dist/providers/llamacpp.js +17 -8
- package/server/dist/providers/ollamaRecovery.js +6 -6
- package/server/dist/providers/ollamaResilience.js +3 -3
- package/server/dist/providers/ollamaTokens.js +1 -1
- package/server/dist/quota.d.ts +0 -18
- package/server/dist/quota.js +0 -44
- package/server/dist/replacementHistory.d.ts +19 -0
- package/server/dist/replacementHistory.js +49 -0
- package/server/dist/server/broadcast.d.ts +2 -1
- package/server/dist/server/broadcast.js +1 -0
- package/server/dist/server/prompts.d.ts +1 -0
- package/server/dist/server/prompts.js +6 -1
- package/server/dist/sessionJsonl.d.ts +1 -1
- package/server/dist/sessionJsonl.js +115 -40
- package/server/dist/smartPickupAdapters.js +15 -2
- package/server/dist/transcriptWorker.d.ts +34 -0
- package/server/dist/transcriptWorker.js +201 -0
- package/server/dist/workflowStore.d.ts +1 -0
- package/server/dist/workflowStore.js +31 -0
- package/server/dist/ws/clusterHandlers.d.ts +1 -0
- package/server/dist/ws/clusterHandlers.js +62 -26
- package/server/dist/ws/handoffHandlers.js +5 -2
- package/server/dist/ws/transcriptWorkerHandlers.d.ts +25 -0
- package/server/dist/ws/transcriptWorkerHandlers.js +139 -0
- package/server/dist/ws/turnEngine.js +23 -9
- package/server/dist/ws/updatePrimaryConfig.js +27 -8
- package/server/dist/ws/workflowHandlers.d.ts +4 -1
- package/server/dist/ws/workflowHandlers.js +3 -1
- package/server/package.json +1 -1
- package/server/src/atomicFile.ts +1 -2
- package/server/src/capabilities.ts +58 -17
- package/server/src/cliUpdateDecision.ts +5 -4
- package/server/src/clusterDirector.ts +1 -1
- package/server/src/clusterPeerOps.ts +11 -8
- package/server/src/clusterProgress.ts +1 -1
- package/server/src/clusterSkills.ts +79 -0
- package/server/src/clusterSnapshots.ts +1 -0
- package/server/src/clusterStore.ts +38 -0
- package/server/src/diagnostics/codeSkew.ts +1 -0
- package/server/src/eventLog.ts +73 -13
- package/server/src/historyLimits.ts +2 -0
- package/server/src/http/router.ts +1 -1
- package/server/src/index.ts +23 -0
- package/server/src/jsonlLines.ts +52 -0
- package/server/src/management/identity.ts +1 -0
- package/server/src/mcp/clusterMcpTools.ts +4 -4
- package/server/src/project/taskLedger.ts +7 -5
- package/server/src/providerConversation.ts +15 -0
- package/server/src/providers/claude-native/resumeSummary.ts +98 -50
- package/server/src/providers/claude-native/worker.ts +8 -4
- package/server/src/providers/claude.ts +2 -1
- package/server/src/providers/clusterTaskToolDefinitions.ts +4 -4
- package/server/src/providers/codex-appserver/catalog.ts +14 -1
- package/server/src/providers/codex.ts +2 -1
- package/server/src/providers/codexCodeMode.ts +4 -4
- package/server/src/providers/cursor/print.ts +2 -1
- package/server/src/providers/cursor/worker.ts +2 -1
- package/server/src/providers/llamacpp.ts +18 -7
- package/server/src/providers/llamacppRecovery.ts +2 -0
- package/server/src/providers/ollamaRecovery.ts +6 -6
- package/server/src/providers/ollamaResilience.ts +3 -3
- package/server/src/providers/ollamaTokens.ts +1 -1
- package/server/src/providers/ollamaToolSubset.ts +3 -3
- package/server/src/quota.ts +0 -50
- package/server/src/replacementHistory.ts +44 -0
- package/server/src/server/broadcast.ts +2 -0
- package/server/src/server/prompts.ts +8 -1
- package/server/src/sessionJsonl.ts +92 -32
- package/server/src/smartPickupAdapters.ts +17 -3
- package/server/src/transcriptWorker.ts +182 -0
- package/server/src/workflowStore.ts +21 -0
- package/server/src/ws/clusterHandlers.ts +43 -25
- package/server/src/ws/handoffHandlers.ts +5 -1
- package/server/src/ws/transcriptWorkerHandlers.ts +126 -0
- package/server/src/ws/turnEngine.ts +20 -8
- package/server/src/ws/updatePrimaryConfig.ts +25 -6
- package/server/src/ws/workflowHandlers.ts +3 -1
- package/shared/dist/clusterCoordination.d.ts +2 -0
- package/shared/dist/clusterCoordination.js +5 -1
- package/shared/dist/protocol/clientMessages.d.ts +3 -2
- package/shared/dist/protocol/clusters.d.ts +13 -1
- package/shared/dist/protocol/index.d.ts +1 -0
- package/shared/dist/protocol/index.js +1 -0
- package/shared/dist/protocol/models.d.ts +4 -3
- package/shared/dist/protocol/models.js +26 -2
- package/shared/dist/protocol/serverMessages.d.ts +2 -1
- package/shared/dist/protocol/tasks.d.ts +4 -0
- package/shared/dist/protocol/transcriptWorker.d.ts +47 -0
- package/shared/dist/protocol/transcriptWorker.js +2 -0
- package/shared/dist/runtimeVersions.d.ts +1 -0
- package/shared/dist/runtimeVersions.js +14 -0
- package/shared/src/clusterCoordination.ts +7 -1
- package/shared/src/protocol/clientMessages.ts +5 -0
- package/shared/src/protocol/clusters.ts +16 -1
- package/shared/src/protocol/index.ts +1 -0
- package/shared/src/protocol/models.ts +31 -5
- package/shared/src/protocol/serverMessages.ts +2 -0
- package/shared/src/protocol/settings.ts +2 -3
- package/shared/src/protocol/tasks.ts +4 -7
- package/shared/src/protocol/transcriptWorker.ts +49 -0
- package/shared/src/runtimeVersions.ts +14 -0
|
@@ -39,4 +39,18 @@ export function compareLlamacppBuild(a, b) {
|
|
|
39
39
|
const aa = llamacppBuild(a), bb = llamacppBuild(b);
|
|
40
40
|
return aa === undefined || bb === undefined ? undefined : aa < bb ? -1 : aa > bb ? 1 : 0;
|
|
41
41
|
}
|
|
42
|
+
// Cursor uses a date plus a build hash, not semver. A different hash on the
|
|
43
|
+
// same date has no reliable ordering; leave that comparison unknown.
|
|
44
|
+
export function compareCursorVersions(a, b) {
|
|
45
|
+
const date = (value) => {
|
|
46
|
+
const stamp = /^(\d{4}\.\d{2}\.\d{2})-[a-f0-9]{6,40}$/i.exec(value)?.[1];
|
|
47
|
+
if (!stamp)
|
|
48
|
+
return undefined;
|
|
49
|
+
const iso = stamp.replaceAll('.', '-');
|
|
50
|
+
const parsed = new Date(`${iso}T00:00:00Z`);
|
|
51
|
+
return Number.isFinite(parsed.getTime()) && parsed.toISOString().startsWith(iso) ? stamp : undefined;
|
|
52
|
+
};
|
|
53
|
+
const aa = date(a), bb = date(b);
|
|
54
|
+
return !aa || !bb ? undefined : aa < bb ? -1 : aa > bb ? 1 : a === b ? 0 : undefined;
|
|
55
|
+
}
|
|
42
56
|
//# sourceMappingURL=runtimeVersions.js.map
|
package/package.json
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
"node-pty": "1.1.0"
|
|
5
5
|
},
|
|
6
6
|
"name": "arco-workbench",
|
|
7
|
-
"version": "0.1.
|
|
7
|
+
"version": "0.1.8",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
10
|
"url": "git+https://github.com/ghreprimand/arco.git"
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"word-extractor": "1.0.4",
|
|
67
67
|
"ws": "8.22.0",
|
|
68
68
|
"xlsx": "0.20.3",
|
|
69
|
-
"@arco/shared": "0.1.
|
|
69
|
+
"@arco/shared": "0.1.8"
|
|
70
70
|
},
|
|
71
71
|
"bundleDependencies": [
|
|
72
72
|
"@arco/shared",
|
|
@@ -71,7 +71,7 @@ async function main() {
|
|
|
71
71
|
console.log(`Arco v${manifest.version}`);
|
|
72
72
|
requireSupportedNode();
|
|
73
73
|
if (args.length && (args.length !== 1 || args[0] !== '--repair-native')) throw new Error('Unknown setup option.');
|
|
74
|
-
if (args.includes('--repair-native')) { repairNative(manifest); console.log('Native modules repaired. Restart Arco.'); return; }
|
|
74
|
+
if (args.includes('--repair-native')) { await repairNative(manifest); console.log('Native modules repaired. Restart Arco.'); return; }
|
|
75
75
|
if (!process.stdin.isTTY) throw new Error('Run arco setup in an interactive terminal.');
|
|
76
76
|
const prompt = createInterface({ input: process.stdin, output: process.stdout });
|
|
77
77
|
let answer;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { spawn } from 'node:child_process';
|
|
2
2
|
import { chmodSync, cpSync, existsSync, mkdirSync, mkdtempSync, readFileSync, realpathSync, renameSync, rmSync, statSync, writeFileSync } from 'node:fs';
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import { basename, delimiter, dirname, isAbsolute, join, resolve } from 'node:path';
|
|
@@ -90,7 +90,36 @@ export function activateRepairedTerminal(env = process.env) {
|
|
|
90
90
|
return { dir: pty, module: require(file) };
|
|
91
91
|
};
|
|
92
92
|
}
|
|
93
|
-
|
|
93
|
+
function buildFailure(output, error, code, signal) {
|
|
94
|
+
const lines = output.replace(/\x1b\[[0-9;]*m/g, '').split(/\r?\n/)
|
|
95
|
+
.map((line) => line.replace(/^npm (?:error|ERR!)\s*/i, '').trim()).filter(Boolean);
|
|
96
|
+
// Prefer the compiler/linker diagnosis over npm and node-gyp's exit summary.
|
|
97
|
+
const decisive = [...lines].reverse().find((line) =>
|
|
98
|
+
!/^(?:gyp ERR!|make:|ninja:|collect2:)|linker command failed/i.test(line)
|
|
99
|
+
&& /\b(?:ld(?:\.lld)?|lld-link|link\.exe):|\berror LNK\d+|\bfatal error\b|\berror:|unknown architecture|undefined symbols/i.test(line));
|
|
100
|
+
const detail = decisive || error?.message || lines.at(-1) || (signal ? `build command stopped by ${signal}` : `build command exited with status ${code}`);
|
|
101
|
+
const step = /\b(?:ld(?:\.lld)?|lld-link|link\.exe):|\berror LNK\d+|unknown architecture|undefined symbols/i.test(decisive || '') ? 'link'
|
|
102
|
+
: /\bfatal error\b|\berror:/i.test(decisive || '') ? 'compile' : 'build';
|
|
103
|
+
return `Native ${step} failed: ${detail.replace(/[.\s]+$/, '')}. The platform build tools may be missing, out of date or broken. Installed native parts were left unchanged and keep working. Repair is only needed when Arco reports that a native part will not load.`;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
async function buildNative(command, args, options) {
|
|
107
|
+
await new Promise((resolve, reject) => {
|
|
108
|
+
const child = spawn(command, args, { ...options, stdio: ['inherit', 'pipe', 'pipe'] });
|
|
109
|
+
let tail = '';
|
|
110
|
+
// Forward progress while retaining only a bounded tail for the closing line.
|
|
111
|
+
const forward = (stream) => (chunk) => {
|
|
112
|
+
tail = (tail + chunk.toString()).slice(-64 * 1024);
|
|
113
|
+
stream.write(chunk);
|
|
114
|
+
};
|
|
115
|
+
child.stdout.on('data', forward(process.stdout));
|
|
116
|
+
child.stderr.on('data', forward(process.stderr));
|
|
117
|
+
child.once('error', (error) => reject(new Error(buildFailure(tail, error))));
|
|
118
|
+
child.once('close', (code, signal) => code === 0 ? resolve() : reject(new Error(buildFailure(tail, undefined, code, signal))));
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export async function repairNative(manifest, env = process.env) {
|
|
94
123
|
const versions = manifest.arcoNativeDependencies;
|
|
95
124
|
if (!versions || !['node-pty', 'better-sqlite3'].every((name) => /^\d+\.\d+\.\d+$/.test(versions[name] || ''))) throw new Error('Native dependency versions are missing from this package.');
|
|
96
125
|
const target = repairedNativeDir(env), parent = dirname(target);
|
|
@@ -100,8 +129,7 @@ export function repairNative(manifest, env = process.env) {
|
|
|
100
129
|
const dependencies = Object.fromEntries(Object.entries(versions));
|
|
101
130
|
const allowScripts = Object.fromEntries(Object.entries(versions).map(([name, version]) => [`${name}@${version}`, true]));
|
|
102
131
|
writeFileSync(join(scratch, 'package.json'), JSON.stringify({ name: 'arco-native-repair', version: '1.0.0', private: true, dependencies, allowScripts }, null, 2));
|
|
103
|
-
|
|
104
|
-
if (result.error || result.status !== 0) throw new Error('Native build failed. Install the platform build tools, then run arco setup --repair-native.');
|
|
132
|
+
await buildNative(process.execPath, [npmCliPath(env), 'install', '--no-audit', '--no-fund'], { cwd: scratch, env: { ...env, npm_config_build_from_source: 'true', npm_config_cache: env.npm_config_cache || join(parent, '..', 'cache', 'npm'), npm_config_devdir: env.npm_config_devdir || join(parent, '..', 'cache', 'node-gyp') } });
|
|
105
133
|
const modules = join(scratch, 'node_modules');
|
|
106
134
|
const require = createRequire(join(scratch, 'package.json'));
|
|
107
135
|
const sqliteRoot = join(modules, 'better-sqlite3');
|
|
@@ -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
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Capabilities, CliUpdateOutcome } from '@arco/shared';
|
|
2
2
|
import { type CliUpdateDecision, type UpdateCommandResult } from './cliUpdateDecision.js';
|
|
3
|
-
export type CliProvider = 'claude' | 'codex';
|
|
3
|
+
export type CliProvider = 'claude' | 'codex' | 'cursor';
|
|
4
4
|
export declare function probeVersion(bin: string, flags?: string[], timeoutMs?: number): Promise<string>;
|
|
5
5
|
export declare function probeCapabilities(): Promise<Capabilities>;
|
|
6
6
|
export declare function refreshRuntimeVersions(previous: Capabilities): Promise<Capabilities>;
|
|
@@ -20,11 +20,13 @@ export interface UpdateResult {
|
|
|
20
20
|
/**
|
|
21
21
|
* Run the updater for the installation Arco actually launches. Claude uses its
|
|
22
22
|
* built-in updater; Codex shares one installation decision with its version flag.
|
|
23
|
+
* Cursor also uses its own updater, with no installer or npm fallback.
|
|
23
24
|
* Re-probe afterwards: a successful command alone does not prove a working CLI.
|
|
24
25
|
*/
|
|
25
26
|
export declare function runCliUpdate(previous: Capabilities, provider?: CliProvider, runCommand?: (cmd: string, args: string[]) => Promise<UpdateCommandResult>): Promise<UpdateResult>;
|
|
27
|
+
type HelpProvider = Exclude<CliProvider, 'cursor'>;
|
|
26
28
|
export interface CliChange {
|
|
27
|
-
provider:
|
|
29
|
+
provider: HelpProvider;
|
|
28
30
|
fromVersion: string;
|
|
29
31
|
toVersion: string;
|
|
30
32
|
newFlags: string[];
|
|
@@ -40,3 +42,4 @@ export interface CliChange {
|
|
|
40
42
|
*/
|
|
41
43
|
export declare function detectCliChanges(caps: Capabilities): Promise<CliChange[]>;
|
|
42
44
|
export declare function cliSnapshotDir(): string;
|
|
45
|
+
export {};
|
|
@@ -3,7 +3,7 @@ import { promisify } from 'util';
|
|
|
3
3
|
import { promises as fs } from 'fs';
|
|
4
4
|
import { join } from 'path';
|
|
5
5
|
import { createHash } from 'crypto';
|
|
6
|
-
import { CLAUDE_MODELS } from '@arco/shared';
|
|
6
|
+
import { CLAUDE_MODELS, compareCursorVersions } from '@arco/shared';
|
|
7
7
|
import { getStrataBase } from './providers/strata.js';
|
|
8
8
|
import { getDeepSeekBase } from './providers/deepseek.js';
|
|
9
9
|
import { probeStrataVersion, installedXolotlRevision, strataEngineReleaseVersion } from './providers/runtimeVersions.js';
|
|
@@ -20,6 +20,7 @@ const CLI_PROBE_OPTIONS = {
|
|
|
20
20
|
};
|
|
21
21
|
const FALLBACK_EFFORTS = ['low', 'medium', 'high', 'xhigh', 'max'];
|
|
22
22
|
const MODELS = [...CLAUDE_MODELS];
|
|
23
|
+
const cliBinary = (provider) => provider === 'cursor' ? 'cursor-agent' : provider;
|
|
23
24
|
// 'unknown' = the CLI isn't installed (the PROVIDERS popover hides those rows).
|
|
24
25
|
// 'broken' = it IS installed but the version probe failed. Keeping them distinct
|
|
25
26
|
// is load-bearing: 2026-09-03 `npm install -g @openai/codex@latest` (the popover's
|
|
@@ -85,7 +86,8 @@ export async function probeCapabilities() {
|
|
|
85
86
|
//
|
|
86
87
|
// Source of truth for "is the operator running the latest CLI?" Claude reads
|
|
87
88
|
// npm; Codex uses its installation decision and npm publication metadata;
|
|
88
|
-
// Ollama
|
|
89
|
+
// Ollama and llama.cpp query GitHub Releases since they are not npm-installed.
|
|
90
|
+
// Cursor reads the version embedded in its public installer as text. All are best-effort: any
|
|
89
91
|
// failure (offline, rate-limited, schema drift) leaves that key undefined
|
|
90
92
|
// and the UI falls back to displaying the installed version with no
|
|
91
93
|
// outdated indicator. Caller decides cadence — boot + the existing 4h
|
|
@@ -118,6 +120,51 @@ async function ollamaLatestRelease() {
|
|
|
118
120
|
return tag.replace(/^v/, '');
|
|
119
121
|
return undefined;
|
|
120
122
|
}
|
|
123
|
+
async function llamacppLatestRelease() {
|
|
124
|
+
// /releases/latest can be a semantic milestone older than the daily builds.
|
|
125
|
+
// Only numeric build tags can be compared to the installed binary's build.
|
|
126
|
+
const data = await fetchJson('https://api.github.com/repos/ggml-org/llama.cpp/releases?per_page=20');
|
|
127
|
+
if (!Array.isArray(data))
|
|
128
|
+
return undefined;
|
|
129
|
+
const builds = data.filter((release) => release && !release.draft)
|
|
130
|
+
.map((release) => typeof release.tag_name === 'string' && /^b[1-9]\d*$/.test(release.tag_name) ? Number(release.tag_name.slice(1)) : NaN)
|
|
131
|
+
.filter(Number.isSafeInteger);
|
|
132
|
+
return builds.length ? `b${Math.max(...builds)}` : undefined;
|
|
133
|
+
}
|
|
134
|
+
async function cursorLatestRelease() {
|
|
135
|
+
try {
|
|
136
|
+
// Read the installer as bounded metadata only; never run fetched shell text.
|
|
137
|
+
const response = await fetch('https://cursor.com/install', { signal: AbortSignal.timeout(REGISTRY_TIMEOUT_MS) });
|
|
138
|
+
if (!response.ok || !response.body)
|
|
139
|
+
return undefined;
|
|
140
|
+
const reader = response.body.getReader();
|
|
141
|
+
const chunks = [];
|
|
142
|
+
let size = 0;
|
|
143
|
+
try {
|
|
144
|
+
while (true) {
|
|
145
|
+
const { done, value } = await reader.read();
|
|
146
|
+
if (done)
|
|
147
|
+
break;
|
|
148
|
+
size += value.byteLength;
|
|
149
|
+
if (size > 64 * 1024) {
|
|
150
|
+
await reader.cancel();
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
chunks.push(value);
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
finally {
|
|
157
|
+
reader.releaseLock();
|
|
158
|
+
}
|
|
159
|
+
const script = Buffer.concat(chunks).toString('utf8');
|
|
160
|
+
const versions = new Set([...script.matchAll(/https:\/\/downloads\.cursor\.com\/(?:lab|stable)\/(\d{4}\.\d{2}\.\d{2}-[a-f0-9]{6,40})\//gi)].map(match => match[1]));
|
|
161
|
+
const version = versions.size === 1 ? [...versions][0] : undefined;
|
|
162
|
+
return version && compareCursorVersions(version, version) === 0 ? version : undefined;
|
|
163
|
+
}
|
|
164
|
+
catch {
|
|
165
|
+
return undefined;
|
|
166
|
+
}
|
|
167
|
+
}
|
|
121
168
|
export async function refreshRuntimeVersions(previous) {
|
|
122
169
|
// Installed runtimes can change outside Arco. Refresh on demand without
|
|
123
170
|
// probing every CLI/upstream registry or starting an inference service.
|
|
@@ -135,7 +182,7 @@ async function strataLatestRelease() {
|
|
|
135
182
|
return strataEngineReleaseVersion(feed, release);
|
|
136
183
|
}
|
|
137
184
|
export async function probeLatestVersions(codexDecision = npmLatest('@openai/codex').then(probeCodexUpdate)) {
|
|
138
|
-
const [claude, codex, ollama, strata, xolotl] = await Promise.all([
|
|
185
|
+
const [claude, codex, ollama, strata, xolotl, llamacpp, cursor] = await Promise.all([
|
|
139
186
|
npmLatest('@anthropic-ai/claude-code'),
|
|
140
187
|
codexDecision.then((decision) => decision.targetVersion),
|
|
141
188
|
ollamaLatestRelease(),
|
|
@@ -144,19 +191,22 @@ export async function probeLatestVersions(codexDecision = npmLatest('@openai/cod
|
|
|
144
191
|
const sha = data?.sha;
|
|
145
192
|
return typeof sha === 'string' && /^[a-f0-9]{40}$/.test(sha) ? sha : undefined;
|
|
146
193
|
}),
|
|
194
|
+
llamacppLatestRelease(),
|
|
195
|
+
cursorLatestRelease(),
|
|
147
196
|
]);
|
|
148
|
-
return { claude, codex, ollama, strata, xolotl };
|
|
197
|
+
return { claude, codex, ollama, strata, xolotl, llamacpp, cursor };
|
|
149
198
|
}
|
|
150
199
|
function versionForProvider(caps, provider) {
|
|
151
|
-
return provider === 'claude' ? caps.cliVersion : caps.codexVersion ?? 'unknown';
|
|
200
|
+
return provider === 'claude' ? caps.cliVersion : provider === 'cursor' ? caps.cursorVersion ?? 'unknown' : caps.codexVersion ?? 'unknown';
|
|
152
201
|
}
|
|
153
202
|
/**
|
|
154
203
|
* Run the updater for the installation Arco actually launches. Claude uses its
|
|
155
204
|
* built-in updater; Codex shares one installation decision with its version flag.
|
|
205
|
+
* Cursor also uses its own updater, with no installer or npm fallback.
|
|
156
206
|
* Re-probe afterwards: a successful command alone does not prove a working CLI.
|
|
157
207
|
*/
|
|
158
208
|
export async function runCliUpdate(previous, provider = 'claude', runCommand = (cmd, args) => runUpdateCommand(cmd, args, provider)) {
|
|
159
|
-
const previousVersion = provider === '
|
|
209
|
+
const previousVersion = provider === 'claude' ? versionForProvider(previous, provider) : await probeVersion(cliBinary(provider));
|
|
160
210
|
// Pre-flight: for npm-installed CLIs, work out which version can actually run
|
|
161
211
|
// on this machine before installing anything. `@latest` is not automatically
|
|
162
212
|
// installable — a package whose binary ships as a platform-specific
|
|
@@ -165,7 +215,7 @@ export async function runCliUpdate(previous, provider = 'claude', runCommand = (
|
|
|
165
215
|
// and npm reports that as success. See npmPlatformResolve.ts.
|
|
166
216
|
const decision = provider === 'codex'
|
|
167
217
|
? await probeCodexUpdate(await npmLatest('@openai/codex'))
|
|
168
|
-
: { kind: 'unknown', command: { cmd:
|
|
218
|
+
: { kind: 'unknown', command: { cmd: cliBinary(provider), args: ['update'] }, targetVersion: previous.latestVersions?.[provider] };
|
|
169
219
|
const notice = decision.notice;
|
|
170
220
|
const capabilities = provider === 'codex'
|
|
171
221
|
? { ...previous, codexVersion: previousVersion, latestVersions: { ...previous.latestVersions, codex: decision.targetVersion }, codexUpdate: { kind: decision.kind, updateAvailable: !!decision.targetVersion && (compareVersions(previousVersion, decision.targetVersion) ?? 0) < 0, instruction: decision.message ?? decision.notice } }
|
|
@@ -205,7 +255,7 @@ export async function runCliUpdate(previous, provider = 'claude', runCommand = (
|
|
|
205
255
|
// the previous executable still runs and reports the same version.
|
|
206
256
|
const report = describeCliUpdate(provider, previousVersion, currentVersion, next.latestVersions?.[provider], commandResult, notice);
|
|
207
257
|
if (report.outcome === 'failed' && commandResult.exitCode === 0) {
|
|
208
|
-
const reason = await probeFailureReason(provider);
|
|
258
|
+
const reason = await probeFailureReason(cliBinary(provider));
|
|
209
259
|
if (reason) {
|
|
210
260
|
report.error = reason;
|
|
211
261
|
report.message = reason;
|
|
@@ -246,7 +296,7 @@ const HELP_PROBES = {
|
|
|
246
296
|
};
|
|
247
297
|
async function runHelpProbe(bin, args) {
|
|
248
298
|
try {
|
|
249
|
-
const { stdout } = await execFileAsync(...commandArgs(bin, args), CLI_PROBE_OPTIONS);
|
|
299
|
+
const { stdout } = await execFileAsync(...commandArgs(cliBinary(bin), args), CLI_PROBE_OPTIONS);
|
|
250
300
|
return stdout;
|
|
251
301
|
}
|
|
252
302
|
catch {
|
|
@@ -3,6 +3,7 @@ import { promises as fs, constants, statSync } from 'node:fs';
|
|
|
3
3
|
import { homedir } from 'node:os';
|
|
4
4
|
import path from 'node:path';
|
|
5
5
|
import { promisify } from 'node:util';
|
|
6
|
+
import { compareCursorVersions } from '@arco/shared';
|
|
6
7
|
import { commandArgs, findWindowsCommand, npmShimTarget } from './windowsCommand.js';
|
|
7
8
|
import { resolveInstallableVersion } from './npmPlatformResolve.js';
|
|
8
9
|
import { compareVersions } from './updateCheck.js';
|
|
@@ -128,7 +129,8 @@ export async function probeCodexUpdate(published) {
|
|
|
128
129
|
return decideCodexUpdate(installation, published, resolved);
|
|
129
130
|
}
|
|
130
131
|
export function describeCliUpdate(provider, previous, current, target, command, notice) {
|
|
131
|
-
const name = provider === 'codex' ? 'Codex' : 'Claude CLI';
|
|
132
|
+
const name = provider === 'codex' ? 'Codex' : provider === 'cursor' ? 'Cursor' : 'Claude CLI';
|
|
133
|
+
const compare = provider === 'cursor' ? (a, b) => compareCursorVersions(a, b) ?? null : compareVersions;
|
|
132
134
|
if (command.exitCode !== 0) {
|
|
133
135
|
const error = `${name} update failed: ${command.output.trim().slice(0, 2000) || `exit code ${command.exitCode}`}`;
|
|
134
136
|
return { outcome: 'failed', message: error, updated: false, error };
|
|
@@ -137,12 +139,12 @@ export function describeCliUpdate(provider, previous, current, target, command,
|
|
|
137
139
|
const error = `${name} did not run after the update.`;
|
|
138
140
|
return { outcome: 'failed', message: error, updated: false, error };
|
|
139
141
|
}
|
|
140
|
-
if (previous !== current && (
|
|
142
|
+
if (previous !== current && (compare(current, previous) ?? 1) > 0) {
|
|
141
143
|
return { outcome: 'updated', message: `Updated ${name} from v${previous} to v${current}.${notice ? ` ${notice}` : ''}`, updated: true };
|
|
142
144
|
}
|
|
143
145
|
if (notice)
|
|
144
146
|
return { outcome: 'deferred', message: notice, updated: false };
|
|
145
|
-
const comparison = target ?
|
|
147
|
+
const comparison = target ? compare(current, target) : null;
|
|
146
148
|
if (comparison !== null && comparison >= 0)
|
|
147
149
|
return { outcome: 'current', message: `${name} v${current} is up to date for this installation.`, updated: false };
|
|
148
150
|
return { outcome: 'unchanged', updated: false, message: comparison !== null
|
|
@@ -15,8 +15,8 @@ export function buildClusterDirectorDoctrine(role) {
|
|
|
15
15
|
'When this cluster has an Advisor, consult it before a design decision or when the evidence is thin; the decision remains yours.',
|
|
16
16
|
'Delegate implementation, builds, and test runs only through peer_send and track them on the board. Do not write or edit product code or tests yourself.',
|
|
17
17
|
'Stay available to the operator. Hand long-running work to peers: the project\'s checks to the tester (or a builder when there is no tester), CI watching to the change\'s author. Use their reports of what was done, run and not covered; do not run builds, test suites or CI waits yourself.',
|
|
18
|
-
'Never wait inside a turn: no sleep or polling longer than 60 seconds at a time. When the next step depends on a peer or on CI, say what is pending and end the turn; reports arrive as mail.',
|
|
19
18
|
'Landing is yours: read the complete accepted diff, check that what the project requires was run, then commit and push per project rules. Ask the peer for missing or stale results rather than regenerating them yourself. Do not invent a gate where the project has none. Do not turn a one-off incident into a standing rule or permanent test without the operator.',
|
|
19
|
+
'When a task is met, sign it off with a plain operator-facing summary without commit hashes. A met sign-off closes it unless Board auto-done is off in Settings. Tell the operator in chat what to try.',
|
|
20
20
|
'Before a failure holds work up, say what a user would lose if it were real; note cosmetic or momentary faults and carry on.',
|
|
21
21
|
'A red check must mean something. Sort each failure first: a fault in the product, or a fault in a test, a housekeeping rule or the CI service. Fix product faults. When the test or rule is at fault, fix it, skip it on that system with a stated reason, or delete it, so the check goes green and can be trusted; do not release over a red check and do not leave one red. Rerun alone a job the CI service dropped. Keep CI to checks whose failure tells the operator something about the product, and small enough to pass in one run; housekeeping findings warn, they do not fail a run.',
|
|
22
22
|
'When reading a diff, also check its shape: a second implementation of existing logic, a wrapper that only passes calls through, tests that miss the module\'s interface, or one change spread over many places. These findings are advisory unless they meet the blocking rules; record them as tasks.',
|
|
@@ -29,6 +29,7 @@
|
|
|
29
29
|
// recipient. The REST path does the same — both reach the in-process
|
|
30
30
|
// `broadcastWorkflow` so persistAndStampSeq stamps every event into the
|
|
31
31
|
// recipient's events.jsonl.
|
|
32
|
+
import { readSettings } from './settings.js';
|
|
32
33
|
import { recipientContext } from './peerRecipientContext.js';
|
|
33
34
|
import { createHash } from 'node:crypto';
|
|
34
35
|
import { promises as fs } from 'node:fs';
|
|
@@ -757,11 +758,8 @@ function taskDependsOn(tasks, fromId, targetId, seen = new Set()) {
|
|
|
757
758
|
return true;
|
|
758
759
|
return task.parentIds.some((parentId) => taskDependsOn(tasks, parentId, targetId, seen));
|
|
759
760
|
}
|
|
760
|
-
//
|
|
761
|
-
//
|
|
762
|
-
// operator-confirmed-done invariant (§D1) is re-enforced at the peer layer:
|
|
763
|
-
// only the operator's WS task_ledger_update may reach applyUpdate with those
|
|
764
|
-
// terminal statuses.
|
|
761
|
+
// Workers may set non-terminal statuses. Direct done / archived requests are
|
|
762
|
+
// rejected; a director met sign-off may close the task when auto-done is on.
|
|
765
763
|
const SIGNOFF_STATES = new Set(['met', 'not_met', 'partial']);
|
|
766
764
|
export async function peerTaskUpdate(ctx, args, broadcastCluster) {
|
|
767
765
|
if (mailboxOnly(ctx))
|
|
@@ -773,7 +771,7 @@ export async function peerTaskUpdate(ctx, args, broadcastCluster) {
|
|
|
773
771
|
message: 'done/archived can only be set by the operator from the LEDGER tab. Move the task to review, set blocked, or report completion via peer_send to the director.',
|
|
774
772
|
};
|
|
775
773
|
}
|
|
776
|
-
//
|
|
774
|
+
// Stamp the sign-off at the peer boundary so its author cannot be spoofed.
|
|
777
775
|
let signoffPatch;
|
|
778
776
|
if (args.signoff === null) {
|
|
779
777
|
signoffPatch = null;
|
|
@@ -807,10 +805,15 @@ export async function peerTaskUpdate(ctx, args, broadcastCluster) {
|
|
|
807
805
|
if (!board) {
|
|
808
806
|
return { ok: false, code: 'board_detached', message: 'no task board is enabled for this cluster.' };
|
|
809
807
|
}
|
|
808
|
+
const director = isClusterDirector(clusterStore.getMemberRole(ctx.clusterId, ctx.workflowId));
|
|
809
|
+
const autoMarkDone = director && signoffPatch?.state === 'met' && (await readSettings()).autoMarkDoneOnMetSignoff !== false;
|
|
810
810
|
let rejection = null;
|
|
811
811
|
const result = await persistLedgerMutation(ctx.workflowId, board.cwd, 'update', (tasks) => {
|
|
812
|
+
const previous = tasks.find((task) => task.id === args.id);
|
|
813
|
+
const close = director && autoMarkDone && signoffPatch?.state === 'met' && previous?.status !== 'done' && previous?.status !== 'archived';
|
|
812
814
|
const applied = taskLedger.applyUpdate(tasks, args.id, {
|
|
813
|
-
...(
|
|
815
|
+
...(close ? { directorClosure: { byWorkflowId: ctx.workflowId, at: signoffPatch.at } } : {}),
|
|
816
|
+
...(close ? { status: 'done' } : args.status ? { status: args.status } : {}),
|
|
814
817
|
...(typeof args.notes === 'string' ? { notes: args.notes } : {}),
|
|
815
818
|
...(typeof args.release === 'string' ? { release: args.release } : {}),
|
|
816
819
|
...(signoffPatch !== undefined ? { signoff: signoffPatch } : {}),
|
|
@@ -33,7 +33,7 @@ const PLAN_CLAUSE = [
|
|
|
33
33
|
].join(' ');
|
|
34
34
|
const BOARD_CLAUSE = [
|
|
35
35
|
'Keep the task board current.',
|
|
36
|
-
'Move each task through its statuses (todo → in_progress → review) as the work actually progresses, and report completion
|
|
36
|
+
'Move each task through its statuses (todo → in_progress → review) as the work actually progresses, and report completion for director review; a met sign-off closes the task unless Board auto-done is off in Settings. Direct done/archived status changes stay operator-only.',
|
|
37
37
|
'Do not leave finished work sitting in an earlier status.',
|
|
38
38
|
].join(' ');
|
|
39
39
|
const RECONCILE_CLAUSE = 'The plan and the board track the same work at different granularities — keep BOTH reflecting reality. ' +
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { type ArcoSkillRef, type ClusterSkillPin } from '@arco/shared';
|
|
2
|
+
import { type ClusterState } from './clusterStore.js';
|
|
3
|
+
export declare function uniqueSkillRefs(refs: ArcoSkillRef[]): ArcoSkillRef[];
|
|
4
|
+
export declare function parseClusterSkillPins(value: unknown): ClusterSkillPin[];
|
|
5
|
+
export declare function skillRefsForRole(state: Pick<ClusterState, 'skillPins'>, role: string | undefined, own?: ArcoSkillRef[]): ArcoSkillRef[];
|
|
6
|
+
export declare function assertSkillUnion(state: Pick<ClusterState, 'skillPins' | 'cwd'>, role: string | undefined, own: ArcoSkillRef[], label: string): Promise<void>;
|
|
7
|
+
export declare function assertClusterSkillLimits(state: ClusterState): Promise<void>;
|
|
8
|
+
export declare function validateNewClusterPins(state: ClusterState, pins: ClusterSkillPin[]): Promise<void>;
|
|
9
|
+
export declare function resolveWorkflowSkillPins(workflowId: string, cwd: string, own: ArcoSkillRef[]): Promise<{
|
|
10
|
+
refs: ArcoSkillRef[];
|
|
11
|
+
resolved: import("./skills.js").ResolvedPinnedSkills;
|
|
12
|
+
}>;
|
|
13
|
+
export declare function assertWorkflowSkillPins(workflowId: string, cwd: string, refs: ArcoSkillRef[]): Promise<void>;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { normalizeClusterRoleText } from '@arco/shared';
|
|
2
|
+
import { ClusterValidationError, MEMBER_ROLE_MAX, getClusterIdForWorkflow, readCluster } from './clusterStore.js';
|
|
3
|
+
import { MAX_PINNED_SKILLS, isValidSlug, resolvePinnedSkills } from './skills.js';
|
|
4
|
+
import { workflows } from './server/state.js';
|
|
5
|
+
import { readMeta } from './workflowMeta.js';
|
|
6
|
+
const key = (ref) => `${ref.scope}:${ref.slug}`;
|
|
7
|
+
const pinKey = (pin) => JSON.stringify([pin.scope, pin.slug, pin.role ?? null]);
|
|
8
|
+
export function uniqueSkillRefs(refs) {
|
|
9
|
+
return [...new Map(refs.map(ref => [key(ref), { scope: ref.scope, slug: ref.slug }])).values()];
|
|
10
|
+
}
|
|
11
|
+
export function parseClusterSkillPins(value) {
|
|
12
|
+
if (!Array.isArray(value))
|
|
13
|
+
throw new ClusterValidationError('skill_pins', 'Skills must be a list.');
|
|
14
|
+
const pins = value.map(pin => {
|
|
15
|
+
if (!pin || (pin.scope !== 'project' && pin.scope !== 'global') || !isValidSlug(pin.slug)
|
|
16
|
+
|| (pin.role !== undefined && (typeof pin.role !== 'string' || !pin.role.trim() || pin.role.trim().length > MEMBER_ROLE_MAX))) {
|
|
17
|
+
throw new ClusterValidationError('skill_pins', 'Choose an installed project/global skill and a saved role of at most 120 characters.');
|
|
18
|
+
}
|
|
19
|
+
return { scope: pin.scope, slug: pin.slug, ...(pin.role !== undefined ? { role: pin.role.trim() } : {}) };
|
|
20
|
+
});
|
|
21
|
+
return [...new Map(pins.map(pin => [pinKey(pin), pin])).values()];
|
|
22
|
+
}
|
|
23
|
+
export function skillRefsForRole(state, role, own = []) {
|
|
24
|
+
const savedRole = role ? normalizeClusterRoleText(role) : undefined;
|
|
25
|
+
return uniqueSkillRefs([
|
|
26
|
+
...(state.skillPins ?? []).filter(pin => pin.role === undefined),
|
|
27
|
+
...(state.skillPins ?? []).filter(pin => pin.role !== undefined && pin.role === savedRole),
|
|
28
|
+
...own,
|
|
29
|
+
]);
|
|
30
|
+
}
|
|
31
|
+
export async function assertSkillUnion(state, role, own, label) {
|
|
32
|
+
const refs = skillRefsForRole(state, role, own);
|
|
33
|
+
if (refs.length > MAX_PINNED_SKILLS)
|
|
34
|
+
throw new ClusterValidationError('skill_limit', `${label}: tab, cluster and role pins together exceed 12 unique skills.`);
|
|
35
|
+
const resolved = await resolvePinnedSkills(refs, state.cwd);
|
|
36
|
+
if (resolved.truncated.length)
|
|
37
|
+
throw new ClusterValidationError('skill_limit', `${label}: tab, cluster and role pins together exceed 64 KiB of skill text.`);
|
|
38
|
+
}
|
|
39
|
+
export async function assertClusterSkillLimits(state) {
|
|
40
|
+
// Check role targets even when no current member has that role. New workers
|
|
41
|
+
// must inherit a usable set rather than discovering an over-limit role later.
|
|
42
|
+
const roles = new Set([undefined, ...(state.skillPins ?? []).map(pin => pin.role)]);
|
|
43
|
+
for (const role of roles)
|
|
44
|
+
await assertSkillUnion(state, role, [], role ? `Role ${role}` : 'All members');
|
|
45
|
+
for (const id of state.members) {
|
|
46
|
+
const wf = workflows.get(id);
|
|
47
|
+
const own = wf?.config.pinnedSkills ?? (await readMeta(state.cwd, id).catch(() => null))?.pinnedSkills ?? [];
|
|
48
|
+
await assertSkillUnion(state, state.memberRoles?.[id], own, wf?.config.name ?? `Member ${id.slice(0, 8)}`);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
export async function validateNewClusterPins(state, pins) {
|
|
52
|
+
const previous = new Set((state.skillPins ?? []).map(pinKey));
|
|
53
|
+
// Removing a pin must stay possible after an edited skill grows over budget.
|
|
54
|
+
if (pins.every(pin => previous.has(pinKey(pin))))
|
|
55
|
+
return;
|
|
56
|
+
for (const pin of pins) {
|
|
57
|
+
if (previous.has(pinKey(pin)))
|
|
58
|
+
continue;
|
|
59
|
+
const resolved = await resolvePinnedSkills([pin], state.cwd);
|
|
60
|
+
if (resolved.missing.length)
|
|
61
|
+
throw new ClusterValidationError('skill_pins', `Skill ${pin.slug} is missing, off or unreadable. Choose an available skill.`);
|
|
62
|
+
if (resolved.truncated.length)
|
|
63
|
+
throw new ClusterValidationError('skill_limit', `Skill ${pin.slug} exceeds 64 KiB of text.`);
|
|
64
|
+
}
|
|
65
|
+
await assertClusterSkillLimits({ ...state, skillPins: pins });
|
|
66
|
+
}
|
|
67
|
+
export async function resolveWorkflowSkillPins(workflowId, cwd, own) {
|
|
68
|
+
const clusterId = getClusterIdForWorkflow(workflowId);
|
|
69
|
+
const cluster = clusterId ? await readCluster(clusterId) : null;
|
|
70
|
+
const refs = cluster ? skillRefsForRole(cluster, cluster.memberRoles?.[workflowId], own) : uniqueSkillRefs(own);
|
|
71
|
+
return { refs, resolved: await resolvePinnedSkills(refs, cluster?.cwd ?? cwd) };
|
|
72
|
+
}
|
|
73
|
+
export async function assertWorkflowSkillPins(workflowId, cwd, refs) {
|
|
74
|
+
const previous = new Set((workflows.get(workflowId)?.config.pinnedSkills ?? []).map(key));
|
|
75
|
+
if (refs.every(ref => previous.has(key(ref))))
|
|
76
|
+
return;
|
|
77
|
+
const clusterId = getClusterIdForWorkflow(workflowId);
|
|
78
|
+
const cluster = clusterId ? await readCluster(clusterId) : null;
|
|
79
|
+
await assertSkillUnion(cluster ?? { cwd }, cluster?.memberRoles?.[workflowId], refs, 'This tab');
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=clusterSkills.js.map
|
|
@@ -793,6 +793,8 @@ export async function restoreSnapshot(snapshotId, targetCwdInput, turnsPerMember
|
|
|
793
793
|
// Passive cluster configuration is portable. Runtime arming is not:
|
|
794
794
|
// idle-nudger, auto-turn, dispatcher enabled, REMOTE, and remote gates stay
|
|
795
795
|
// OFF on every restore so importing a cluster cannot start work or expose it.
|
|
796
|
+
if (src.skillPins?.length)
|
|
797
|
+
await clusterStore.setSkillPins(cluster.clusterId, src.skillPins, { restoringSnapshot: true });
|
|
796
798
|
if (src.autoCompaction)
|
|
797
799
|
await clusterStore.setAutoCompaction(cluster.clusterId, src.autoCompaction);
|
|
798
800
|
await clusterStore.setEfficiency(cluster.clusterId, src.efficiencyLevel ?? 'thorough', src.efficiencyAddendum ?? '', resolveClusterMessageGuard(src)).catch(() => { });
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { type AutoCompactionPolicy, MEMBER_TIERS, type ClusterMessageGuard, type ClusterCreationSettings, type ClusterDispatcherSettingsPatch, type ClusterDispatcherState, type ClusterEfficiencyLevel, type ClusterMemberAccessMode, type ClusterProgressMode, type ClusterTaskBoardMode, type MemberTier, isMemberTier, type RulePickupLimits, type AutoPickupMode, type SmartPickupEvaluator, type SmartPickupLimits, type SmartPickupSession } from '@arco/shared';
|
|
1
|
+
import { type AutoCompactionPolicy, MEMBER_TIERS, type ClusterMessageGuard, type ClusterCreationSettings, type ClusterSkillPin, type ClusterDispatcherSettingsPatch, type ClusterDispatcherState, type ClusterEfficiencyLevel, type ClusterMemberAccessMode, type ClusterProgressMode, type ClusterTaskBoardMode, type MemberTier, isMemberTier, type RulePickupLimits, type AutoPickupMode, type SmartPickupEvaluator, type SmartPickupLimits, type SmartPickupSession } from '@arco/shared';
|
|
2
2
|
export interface ClusterState {
|
|
3
|
+
skillPins?: ClusterSkillPin[];
|
|
3
4
|
autoCompaction?: AutoCompactionPolicy;
|
|
4
5
|
clusterId: string;
|
|
5
6
|
cwd: string;
|
|
@@ -48,6 +49,10 @@ export declare function createCluster(opts: {
|
|
|
48
49
|
cwd: string;
|
|
49
50
|
memberWorkflowIds: string[];
|
|
50
51
|
} & ClusterCreationSettings): Promise<ClusterState>;
|
|
52
|
+
export declare function withClusterSkillLock<T>(workflowId: string, fn: () => Promise<T>): Promise<T>;
|
|
53
|
+
export declare function setSkillPins(clusterId: string, value: unknown, options?: {
|
|
54
|
+
restoringSnapshot?: boolean;
|
|
55
|
+
}): Promise<ClusterState | null>;
|
|
51
56
|
export declare function readCluster(clusterId: string): Promise<ClusterState | null>;
|
|
52
57
|
export declare function loadAllClustersFromDisk(): Promise<ClusterState[]>;
|
|
53
58
|
export declare function deleteCluster(clusterId: string): Promise<void>;
|
|
@@ -60,7 +65,7 @@ export declare function removeMember(clusterId: string, workflowId: string): Pro
|
|
|
60
65
|
export declare function addMember(clusterId: string, workflowId: string): Promise<ClusterState | null>;
|
|
61
66
|
export declare function getMemberAccessMode(clusterId: string, workflowId: string): ClusterMemberAccessMode;
|
|
62
67
|
export declare function setMemberAccessMode(clusterId: string, workflowId: string, mode: ClusterMemberAccessMode): Promise<ClusterState | null>;
|
|
63
|
-
export declare function replaceMember(clusterId: string, oldWorkflowId: string, newWorkflowId: string, accessMode?: ClusterMemberAccessMode): Promise<ClusterState | null>;
|
|
68
|
+
export declare function replaceMember(clusterId: string, oldWorkflowId: string, newWorkflowId: string, accessMode?: ClusterMemberAccessMode, role?: string): Promise<ClusterState | null>;
|
|
64
69
|
export declare function getMembers(clusterId: string): string[] | undefined;
|
|
65
70
|
export declare function getPlanId(clusterId: string): string | undefined;
|
|
66
71
|
export declare function setPlanId(clusterId: string, planId: string): Promise<ClusterState | null>;
|
|
@@ -117,6 +117,29 @@ export async function createCluster(opts) {
|
|
|
117
117
|
function withClusterMetaLock(clusterId, fn) {
|
|
118
118
|
return withFileLock(clusterMetaPath(clusterId), fn);
|
|
119
119
|
}
|
|
120
|
+
// Direct tab-pin edits share the cluster lock with role and cluster-pin edits,
|
|
121
|
+
// so concurrent edits cannot each pass against an outdated effective union.
|
|
122
|
+
export function withClusterSkillLock(workflowId, fn) {
|
|
123
|
+
const clusterId = getClusterIdForWorkflow(workflowId);
|
|
124
|
+
return clusterId ? withClusterMetaLock(clusterId, fn) : fn();
|
|
125
|
+
}
|
|
126
|
+
export async function setSkillPins(clusterId, value, options = {}) {
|
|
127
|
+
return withClusterMetaLock(clusterId, async () => {
|
|
128
|
+
const state = await readCluster(clusterId);
|
|
129
|
+
if (!state)
|
|
130
|
+
return null;
|
|
131
|
+
const { parseClusterSkillPins, validateNewClusterPins } = await import('./clusterSkills.js');
|
|
132
|
+
const pins = parseClusterSkillPins(value);
|
|
133
|
+
// A saved snapshot has the same missing/off/grown-file behavior as restart.
|
|
134
|
+
// Current turn resolution still enforces the standing prompt limits.
|
|
135
|
+
if (!options.restoringSnapshot)
|
|
136
|
+
await validateNewClusterPins(state, pins);
|
|
137
|
+
const next = { ...state, skillPins: pins.length ? pins : undefined };
|
|
138
|
+
await writeMetaAtomic(next);
|
|
139
|
+
rebuildIndexFor(next);
|
|
140
|
+
return next;
|
|
141
|
+
});
|
|
142
|
+
}
|
|
120
143
|
async function writeMetaAtomic(state) {
|
|
121
144
|
const path = clusterMetaPath(state.clusterId);
|
|
122
145
|
// proper-lockfile needs the file to exist before lock(); seed an empty
|
|
@@ -290,6 +313,8 @@ export async function addMember(clusterId, workflowId) {
|
|
|
290
313
|
throw new ClusterValidationError('member_already_in_cluster', `workflow ${workflowId} is already a member of cluster ${existing}; cross-cluster membership is rejected`);
|
|
291
314
|
}
|
|
292
315
|
const next = { ...state, members: [...state.members, workflowId] };
|
|
316
|
+
if (next.skillPins?.length)
|
|
317
|
+
await (await import('./clusterSkills.js')).assertClusterSkillLimits(next);
|
|
293
318
|
await writeMetaAtomic(next);
|
|
294
319
|
rebuildIndexFor(next);
|
|
295
320
|
memberJoined?.(clusterId, workflowId);
|
|
@@ -367,7 +392,7 @@ async function reassignPendingMailbox(clusterId, oldWorkflowId, newWorkflowId) {
|
|
|
367
392
|
// validates its config first; the meta write preserves member order and remaps
|
|
368
393
|
// every member-scoped setting without ever collapsing a 2-member cluster.
|
|
369
394
|
// Pending inbound mail follows the slot to the replacement workflow.
|
|
370
|
-
export async function replaceMember(clusterId, oldWorkflowId, newWorkflowId, accessMode) {
|
|
395
|
+
export async function replaceMember(clusterId, oldWorkflowId, newWorkflowId, accessMode, role) {
|
|
371
396
|
return withClusterMetaLock(clusterId, async () => {
|
|
372
397
|
const state = await readCluster(clusterId);
|
|
373
398
|
if (!state || !state.members.includes(oldWorkflowId))
|
|
@@ -398,6 +423,20 @@ export async function replaceMember(clusterId, oldWorkflowId, newWorkflowId, acc
|
|
|
398
423
|
memberFocuses: remapSparse(state.memberFocuses, oldWorkflowId, newWorkflowId),
|
|
399
424
|
memberAccessModes: Object.keys(nextModes).length > 0 ? nextModes : undefined,
|
|
400
425
|
};
|
|
426
|
+
if (role !== undefined) {
|
|
427
|
+
const roles = { ...next.memberRoles };
|
|
428
|
+
const savedRole = normalizeClusterRoleText(role).slice(0, MEMBER_ROLE_MAX);
|
|
429
|
+
if (savedRole)
|
|
430
|
+
roles[newWorkflowId] = savedRole;
|
|
431
|
+
else
|
|
432
|
+
delete roles[newWorkflowId];
|
|
433
|
+
const problem = clusterDirectorProblem(next.members.map(id => roles[id]));
|
|
434
|
+
if (problem)
|
|
435
|
+
throw new ClusterValidationError('multiple_directors', problem);
|
|
436
|
+
next.memberRoles = Object.keys(roles).length ? roles : undefined;
|
|
437
|
+
}
|
|
438
|
+
if (next.skillPins?.length)
|
|
439
|
+
await (await import('./clusterSkills.js')).assertClusterSkillLimits(next);
|
|
401
440
|
if (nextMode === 'isolated') {
|
|
402
441
|
await fs.mkdir(isolatedWorkspaceFor(clusterId, newWorkflowId), { recursive: true, mode: 0o700 });
|
|
403
442
|
}
|
|
@@ -517,6 +556,8 @@ export async function setMemberRole(clusterId, workflowId, role, options = {}) {
|
|
|
517
556
|
const next = Object.keys(nextRoles).length === 0
|
|
518
557
|
? { ...state, memberRoles: undefined }
|
|
519
558
|
: { ...state, memberRoles: nextRoles };
|
|
559
|
+
if (!options.restoringSnapshot && next.skillPins?.length)
|
|
560
|
+
await (await import('./clusterSkills.js')).assertClusterSkillLimits(next);
|
|
520
561
|
await writeMetaAtomic(next);
|
|
521
562
|
rebuildIndexFor(next);
|
|
522
563
|
return next;
|