arco-workbench 0.2.6 → 0.2.7
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/client/dist/assets/{PhosphorBackdrop-YsHTmZJh.js → PhosphorBackdrop-Df7xl7fv.js} +1 -1
- package/client/dist/assets/{ThemedBackgroundShaderImpl-BEjpgoBW.js → ThemedBackgroundShaderImpl-HQHu9fmC.js} +1 -1
- package/client/dist/assets/{XtermView-wh7jNKvk.js → XtermView-BlQ7QADf.js} +1 -1
- package/client/dist/assets/{galleryEditor-CaOS2mmM.js → galleryEditor-Db_t1HrV.js} +1 -1
- package/client/dist/assets/{index-j68SfA-l.js → index-BPeBsjq5.js} +109 -109
- package/client/dist/index.html +1 -1
- package/client/src/components/UpdateAction.tsx +13 -9
- package/client/src/help/content/cluster.tsx +1 -1
- package/client/src/help/content/header.tsx +7 -7
- package/client/src/help/content/settings.tsx +2 -2
- package/client/src/help/manualSections/clusters.tsx +2 -1
- package/client/src/help/manualSections/maintenance.tsx +8 -12
- package/docs/DOCKER.md +4 -3
- package/docs/GLOSSARY.md +1 -1
- package/docs/OPERATIONS.md +31 -20
- package/docs/PROTOCOL_CLUSTER.md +1 -1
- package/docs/SETTINGS.md +8 -7
- package/node_modules/@arco/shared/dist/clusterCoordination.js +1 -1
- package/node_modules/@arco/shared/package.json +1 -1
- package/package.json +3 -2
- package/scripts/packaging/arco.mjs +17 -3
- package/scripts/packaging/update-process.mjs +160 -0
- package/scripts/packaging/update.mjs +50 -11
- package/server/dist/clusterDirector.js +1 -2
- package/server/dist/providers/claude-native/worker.js +6 -5
- package/server/dist/updateManager.d.ts +6 -1
- package/server/dist/updateManager.js +87 -20
- package/server/package.json +1 -1
- package/server/src/clusterDirector.ts +1 -2
- package/server/src/providers/claude-native/worker.ts +6 -5
- package/server/src/updateManager.ts +62 -18
- package/shared/dist/clusterCoordination.js +1 -1
- package/shared/src/clusterCoordination.ts +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// Package updates snapshot the installed tree before replacing files.
|
|
2
2
|
import { spawnSync } from 'node:child_process';
|
|
3
|
-
import { closeSync, cpSync, existsSync, lstatSync, mkdtempSync, mkdirSync, openSync, readFileSync, renameSync, rmSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
3
|
+
import { closeSync, cpSync, existsSync, lstatSync, mkdtempSync, mkdirSync, openSync, readFileSync, realpathSync, renameSync, rmSync, unlinkSync, writeFileSync } from 'node:fs';
|
|
4
4
|
import { basename, dirname, join, resolve } from 'node:path';
|
|
5
5
|
import { npmCliPath } from './native-repair.mjs';
|
|
6
6
|
import { linuxServiceState, readWindowsServicePid, runWindowsProbe, serviceAction, servicePaths } from './services.mjs';
|
|
@@ -29,8 +29,27 @@ export function globalPrefix(root, platform = process.platform) {
|
|
|
29
29
|
? dirname(parent)
|
|
30
30
|
: null;
|
|
31
31
|
if (!modules) throw new Error('This is not a global npm installation.');
|
|
32
|
+
if (platform !== 'win32' && basename(dirname(modules)) !== 'lib') throw new Error('This is not a global npm installation.');
|
|
32
33
|
return platform === 'win32' ? dirname(modules) : dirname(dirname(modules));
|
|
33
34
|
}
|
|
35
|
+
|
|
36
|
+
// A global-looking folder alone also matches linked checkouts and some
|
|
37
|
+
// project-owned npm layouts. Resolve the launcher belonging to this prefix.
|
|
38
|
+
export function verifiedPackagePrefix(root, platform = process.platform) {
|
|
39
|
+
const prefix = globalPrefix(root, platform);
|
|
40
|
+
const path = realpathSync.native(root);
|
|
41
|
+
const norm = (value) => platform === 'win32' ? value.toLowerCase() : value;
|
|
42
|
+
const modules = platform === 'win32' ? join(prefix, 'node_modules') : join(prefix, 'lib', 'node_modules');
|
|
43
|
+
const expected = join(realpathSync.native(modules), 'arco-workbench');
|
|
44
|
+
if (norm(path) !== norm(expected) || lstatSync(root).isSymbolicLink()) throw new Error('The running package is not an owned global npm installation.');
|
|
45
|
+
const entry = join(path, 'scripts', 'packaging', 'arco.mjs');
|
|
46
|
+
const launcher = platform === 'win32' ? join(prefix, 'arco.cmd') : join(prefix, 'bin', 'arco');
|
|
47
|
+
const valid = platform === 'win32'
|
|
48
|
+
? lstatSync(launcher).isFile() && readFileSync(launcher, 'utf8').includes('%dp0%\\node_modules\\arco-workbench\\scripts\\packaging\\arco.mjs')
|
|
49
|
+
: realpathSync.native(launcher) === entry;
|
|
50
|
+
if (!valid) throw new Error('The global launcher does not match the running package.');
|
|
51
|
+
return prefix;
|
|
52
|
+
}
|
|
34
53
|
export function writeUpdateResult(resultFile, attemptId, result, now = Date.now) {
|
|
35
54
|
const attempt = JSON.parse(readFileSync(resultFile, 'utf8'));
|
|
36
55
|
if (attempt.attemptId !== attemptId || attempt.outcome !== 'running') return false;
|
|
@@ -125,6 +144,7 @@ export async function updatePackage(manifest, packageRoot, deps = {}) {
|
|
|
125
144
|
if (order === 0) return { outcome: 'unchanged', message: 'Already on the newest release.' };
|
|
126
145
|
}
|
|
127
146
|
const archive = deps.target ?? stagePackage(call, manifest.name, version, scratch);
|
|
147
|
+
if (deps.prepare) await deps.prepare(archive, scratch, call, version);
|
|
128
148
|
// Dependencies are not all bundled in the tarball. A full local snapshot
|
|
129
149
|
// permits rollback even when the registry or the network is unavailable.
|
|
130
150
|
cpSync(root, backup, { recursive: true, dereference: false, verbatimSymlinks: true, errorOnExist: true, force: false });
|
|
@@ -136,32 +156,46 @@ export async function updatePackage(manifest, packageRoot, deps = {}) {
|
|
|
136
156
|
// canceled by another start or restart of the service while it waits.
|
|
137
157
|
const linuxState = platform === 'linux' && managed ? deps.serviceState ?? (deps.service ? null : () => linuxServiceState()) : null;
|
|
138
158
|
const before = linuxState ? await linuxState() : null;
|
|
139
|
-
if (
|
|
159
|
+
if (deps.lifecycle) {
|
|
160
|
+
await deps.lifecycle.stop();
|
|
161
|
+
stopped = true;
|
|
162
|
+
} else if (managed) {
|
|
140
163
|
try { await service('stop'); }
|
|
141
164
|
catch (error) { if (linuxState) throw await afterFailedStop(error, before, linuxState, service, deps); throw error; }
|
|
142
165
|
stopped = true;
|
|
143
166
|
}
|
|
144
|
-
if (platform === 'win32') {
|
|
167
|
+
if (platform === 'win32' && !deps.lifecycle?.ownsProcess) {
|
|
145
168
|
const running = servicePid ? await waitForRecordedPid(servicePid, deps) : await windowsRunning();
|
|
146
169
|
if (running) throw new Error(servicePid ? `The Arco service process ${servicePid} is still running. Stop it before updating on Windows.` : 'Stop all Arco processes before updating on Windows.');
|
|
147
170
|
}
|
|
148
171
|
installAttempted = true;
|
|
149
|
-
call('Package installation failed', ['install', '--global', '--ignore-scripts', '--no-audit', '--no-fund', '--prefix', prefix, archive]
|
|
172
|
+
call('Package installation failed', ['install', '--global', '--ignore-scripts', '--no-audit', '--no-fund', '--prefix', prefix, archive],
|
|
173
|
+
deps.lifecycle ? { timeout: 120_000 } : {});
|
|
150
174
|
// The new package may define the service differently. A fresh process loads
|
|
151
175
|
// the new code to
|
|
152
176
|
// rewrite an unmodified Arco-owned definition; a failure keeps the old one.
|
|
153
177
|
let refreshNote = '';
|
|
154
178
|
if (managed && (platform === 'win32' || platform === 'linux')) {
|
|
155
179
|
const refresh = deps.refresh ?? (() => run(process.execPath, [join(root, 'scripts/packaging/arco.mjs'), 'service', 'refresh'], { windowsHide: true }));
|
|
156
|
-
|
|
157
|
-
|
|
180
|
+
const refreshFailure = deps.lifecycle ? ' The service definition could not be refreshed.' : ' The service definition was not refreshed; run arco service refresh.';
|
|
181
|
+
try { const r = await refresh(); if (r?.error || (r?.status ?? 0) !== 0) refreshNote = refreshFailure; }
|
|
182
|
+
catch { refreshNote = refreshFailure; }
|
|
183
|
+
}
|
|
184
|
+
if (stopped) {
|
|
185
|
+
if (deps.lifecycle) await deps.lifecycle.start(version);
|
|
186
|
+
else await service('start');
|
|
187
|
+
stopped = false;
|
|
158
188
|
}
|
|
159
|
-
|
|
160
|
-
return { outcome: 'updated', message: `Updated${version ? ` to v${version}` : ` ${manifest.name}`}; ${
|
|
189
|
+
const restartNote = deps.lifecycle ? 'Arco restarted' : managed ? 'service restarted' : 'restart Arco to use the update';
|
|
190
|
+
return { outcome: 'updated', message: `Updated${version ? ` to v${version}` : ` ${manifest.name}`}; ${restartNote}.${refreshNote}` };
|
|
161
191
|
} catch (error) {
|
|
162
192
|
const detail = String(error.message).replace(/[.\s]+$/, '');
|
|
163
193
|
let damaged;
|
|
164
194
|
if (installAttempted) {
|
|
195
|
+
if (deps.lifecycle?.canRestore?.() === false) {
|
|
196
|
+
preserve = true;
|
|
197
|
+
throw new Error(`Update failed: ${detail}. Arco could not confirm that the replacement stopped. Previous package snapshot: ${backup}`);
|
|
198
|
+
}
|
|
165
199
|
// Keep both copies until a complete restoration is available. If the
|
|
166
200
|
// copy fails, retain the snapshot and report its location for recovery.
|
|
167
201
|
damaged = `${root}.arco-update-failed-${process.pid}`;
|
|
@@ -177,16 +211,21 @@ export async function updatePackage(manifest, packageRoot, deps = {}) {
|
|
|
177
211
|
}
|
|
178
212
|
}
|
|
179
213
|
if (stopped) {
|
|
180
|
-
try {
|
|
214
|
+
try {
|
|
215
|
+
if (deps.lifecycle) await deps.lifecycle.start(manifest.version);
|
|
216
|
+
else await service('start');
|
|
217
|
+
}
|
|
181
218
|
catch {
|
|
182
219
|
preserve = true;
|
|
183
220
|
const recovery = installAttempted
|
|
184
221
|
? `The previous package was restored. Previous package snapshot: ${backup}`
|
|
185
222
|
: 'The installed package was left unchanged.';
|
|
186
|
-
throw new Error(
|
|
223
|
+
throw new Error(deps.lifecycle
|
|
224
|
+
? `Update failed: ${detail}. Arco could not restart even on the previous release. ${recovery}`
|
|
225
|
+
: `Update failed: ${detail}. The service could not restart. Check the service and run arco service start after resolving the error. ${recovery}`);
|
|
187
226
|
}
|
|
188
227
|
}
|
|
189
|
-
const recovery = installAttempted ? ' The previous package was restored.' + (stopped ? ' The service was restarted.' : '') : '';
|
|
228
|
+
const recovery = installAttempted ? ' The previous package was restored.' + (stopped ? (deps.lifecycle ? ' Arco restarted on the previous release.' : ' The service was restarted.') : '') : '';
|
|
190
229
|
let cleanupNote = '';
|
|
191
230
|
if (damaged) {
|
|
192
231
|
try { rmSync(damaged, { recursive: true, force: true }); }
|
|
@@ -18,14 +18,13 @@ export function buildClusterDirectorDoctrine(role) {
|
|
|
18
18
|
'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.',
|
|
19
19
|
'An assignment never asks for something the project\'s own rules forbid (how commits land, changelog, documentation, testing); state the delivery those rules require. When the work truly needs an exception, ask the operator first.',
|
|
20
20
|
'When you assign work, ask for one report at the end, or one at an agreed milestone, plus blockers, and ask for step notes as comments on the board task. Never ask members to coordinate with each other by message for routine things, such as taking turns on a shared resource, status or acknowledgements, when a lock, a file or the board can do it.',
|
|
21
|
-
'
|
|
21
|
+
'For long checks, stay responsive and follow operator and project instructions. Wait for the result, hand off the check, or continue other approved work as the workflow requires. Follow the same instructions on when to end the turn.',
|
|
22
22
|
'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.',
|
|
23
23
|
'When a task is met, sign it off with a plain operator-facing summary without commit hashes. If the whole linked plan item is also complete, pass completePlan with the attached plan ID, reviewed revision and unique numbered item ID; otherwise leave the plan unchanged. If the tool reports a pending plan completion, read the original plan ID, item ID and reviewed revision with cluster_task_show, then retry; if the plan changed, resolve the pending sign-off and review again. A met sign-off closes it unless Board auto-done is off in Settings. Tell the operator in chat what to try.',
|
|
24
24
|
'Before a failure holds work up, say what a user would lose if it were real; note cosmetic or momentary faults and carry on.',
|
|
25
25
|
'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.',
|
|
26
26
|
'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.',
|
|
27
27
|
'The plan holds standing rules and tasks only. You may add, split, reword, or restructure tasks and tick them with cluster_plan_tick; change standing rules only when the operator asks. Put progress, evidence, commit hashes, CI ids, test counts, and dates on board tasks, never in the plan body.',
|
|
28
|
-
'When runnable work remains, delegate it via peer_send and end your turn; do not do a peer\'s work to keep the turn going.',
|
|
29
28
|
'If two instructions conflict or required authority is genuinely missing, identify the exact conflict immediately and ask the operator; do not silently stall.',
|
|
30
29
|
].join('\n');
|
|
31
30
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { setMaxListeners } from 'node:events';
|
|
2
2
|
import { assertNativeTaskAllowed, nativeTaskBatchApprovalReasons } from './taskAdmission.js';
|
|
3
3
|
import { readSettings } from '../../settings.js';
|
|
4
|
-
import { buildTurnWaitInstructions, resolveNativeSubagents, CLAUDE_MODELS, isIsolatedAccessMode } from '@arco/shared';
|
|
4
|
+
import { buildTurnWaitInstructions, isClusterDirector, resolveNativeSubagents, CLAUDE_MODELS, isIsolatedAccessMode } from '@arco/shared';
|
|
5
5
|
import { RESEARCHER_DOCTRINE, researchDirectorDoctrine } from '../../research/researchDoctrine.js';
|
|
6
6
|
import { availableHandoffSources, executeHandoffHistory, HANDOFF_HISTORY_TOOL, HANDOFF_HISTORY_CONTEXT } from '../../handoffHistoryTool.js';
|
|
7
7
|
import { mediaRetirementNotice } from './mediaRetirementNotice.js';
|
|
@@ -1910,10 +1910,11 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
1910
1910
|
// retain precedence if there is a conflict.
|
|
1911
1911
|
blocks.push({
|
|
1912
1912
|
type: 'text',
|
|
1913
|
-
text:
|
|
1914
|
-
'
|
|
1915
|
-
|
|
1916
|
-
|
|
1913
|
+
text: (isClusterDirector(this.config.clusterRole) ? '' :
|
|
1914
|
+
'Turn discipline: the operator is not watching in real time and cannot answer mid-turn. ' +
|
|
1915
|
+
'Continue working until the request is complete or you are genuinely blocked on operator input. ' +
|
|
1916
|
+
"Never end your turn with a status update, a plan, or a promise of future work ('Continuing now', 'I'll do X next') — " +
|
|
1917
|
+
'if your final paragraph describes work you have not done, do that work now instead of ending the turn. ') +
|
|
1917
1918
|
buildTurnWaitInstructions(this.config.clusterRole) + ' ' +
|
|
1918
1919
|
'If a delegated Task child fails or returns an error or nonsense (e.g. a login error), say so explicitly in your reply and adapt openly — never silently work around a failed delegation. ' +
|
|
1919
1920
|
// Fable 5.1 / 5.2 can rewrite whole files where a targeted edit would do
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { UpdateCheckStatus } from '@arco/shared';
|
|
2
2
|
export type UpdateMode = 'service' | 'foreground' | 'docker';
|
|
3
|
-
export declare function updateMode(platform?: NodeJS.Platform, env?: NodeJS.ProcessEnv): UpdateMode;
|
|
3
|
+
export declare function updateMode(platform?: NodeJS.Platform, env?: NodeJS.ProcessEnv, launcher?: 'start' | 'service-run'): UpdateMode;
|
|
4
4
|
type Status = {
|
|
5
5
|
outcome: string;
|
|
6
6
|
message?: string;
|
|
@@ -23,10 +23,14 @@ export declare function createUpdateManager(deps?: {
|
|
|
23
23
|
error?: Error;
|
|
24
24
|
stderr?: string | null;
|
|
25
25
|
};
|
|
26
|
+
launchForeground?: (args: string[]) => Promise<void>;
|
|
27
|
+
packageInstallation?: () => boolean;
|
|
28
|
+
argv?: string[];
|
|
26
29
|
now?: () => number;
|
|
27
30
|
version?: string;
|
|
28
31
|
}): {
|
|
29
32
|
status: () => {
|
|
33
|
+
canUpdate: boolean;
|
|
30
34
|
mode: UpdateMode;
|
|
31
35
|
platform: NodeJS.Platform;
|
|
32
36
|
packaged: boolean;
|
|
@@ -57,6 +61,7 @@ export declare function createUpdateManager(deps?: {
|
|
|
57
61
|
};
|
|
58
62
|
export declare const updateManager: {
|
|
59
63
|
status: () => {
|
|
64
|
+
canUpdate: boolean;
|
|
60
65
|
mode: UpdateMode;
|
|
61
66
|
platform: NodeJS.Platform;
|
|
62
67
|
packaged: boolean;
|
|
@@ -1,21 +1,27 @@
|
|
|
1
|
-
import { spawnSync } from 'node:child_process';
|
|
2
|
-
import {
|
|
1
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
2
|
+
import { once } from 'node:events';
|
|
3
|
+
import { mkdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
4
|
import { dirname, join, resolve } from 'node:path';
|
|
4
5
|
import { fileURLToPath } from 'node:url';
|
|
5
6
|
import { randomUUID } from 'node:crypto';
|
|
7
|
+
import { createRequire } from 'node:module';
|
|
6
8
|
import { arcoHome } from './arcoHome.js';
|
|
7
9
|
import { updateChecker } from './server/updateCheck.js';
|
|
8
10
|
import { APP_VERSION } from './appVersion.js';
|
|
9
|
-
export function updateMode(platform = process.platform, env = process.env) {
|
|
11
|
+
export function updateMode(platform = process.platform, env = process.env, launcher) {
|
|
10
12
|
if (env.ARCO_DEPLOYMENT === 'docker')
|
|
11
13
|
return 'docker';
|
|
12
|
-
if (env.ARCO_PACKAGED === '1'
|
|
13
|
-
|
|
14
|
+
if (env.ARCO_PACKAGED === '1') {
|
|
15
|
+
// A foreground launcher can inherit systemd markers from its parent.
|
|
16
|
+
if (launcher === 'start')
|
|
17
|
+
return 'foreground';
|
|
18
|
+
if (launcher === 'service-run' || env.ARCO_PACKAGE_SERVICE === '1')
|
|
19
|
+
return 'service';
|
|
20
|
+
}
|
|
14
21
|
return platform === 'linux' && !!(env.INVOCATION_ID || env.SYSTEMD_EXEC_PID) ? 'service' : 'foreground';
|
|
15
22
|
}
|
|
16
23
|
const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), '../..');
|
|
17
24
|
export function createUpdateManager(deps = {}) {
|
|
18
|
-
const mode = deps.mode ?? (() => updateMode());
|
|
19
25
|
const home = deps.home ?? arcoHome;
|
|
20
26
|
const env = deps.env ?? process.env;
|
|
21
27
|
const platform = deps.platform ?? process.platform;
|
|
@@ -24,6 +30,57 @@ export function createUpdateManager(deps = {}) {
|
|
|
24
30
|
const launch = deps.launch ?? ((command, args) => spawnSync(command, args, { encoding: 'utf8', timeout: 15_000 }));
|
|
25
31
|
const now = deps.now ?? Date.now;
|
|
26
32
|
const version = deps.version ?? APP_VERSION;
|
|
33
|
+
const repo = deps.root ?? repoRoot;
|
|
34
|
+
const cli = join(repo, 'scripts', 'packaging', 'arco.mjs');
|
|
35
|
+
const argv = deps.argv ?? process.argv;
|
|
36
|
+
const launcher = (() => {
|
|
37
|
+
const command = argv[2];
|
|
38
|
+
if (!packaged || (command !== 'start' && command !== 'service-run') || !argv[1])
|
|
39
|
+
return undefined;
|
|
40
|
+
try {
|
|
41
|
+
return realpathSync.native(argv[1]) === realpathSync.native(cli) ? command : undefined;
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
})();
|
|
47
|
+
const mode = deps.mode ?? (() => updateMode(platform, env, launcher));
|
|
48
|
+
const packageInstallation = deps.packageInstallation ?? (() => {
|
|
49
|
+
try {
|
|
50
|
+
const { verifiedPackagePrefix } = createRequire(import.meta.url)(join(repo, 'scripts', 'packaging', 'update.mjs'));
|
|
51
|
+
verifiedPackagePrefix(repo);
|
|
52
|
+
return true;
|
|
53
|
+
}
|
|
54
|
+
catch {
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
});
|
|
58
|
+
const canUpdate = () => {
|
|
59
|
+
const current = mode();
|
|
60
|
+
if (!packaged)
|
|
61
|
+
return current === 'service' && platform === 'linux';
|
|
62
|
+
if (!['linux', 'darwin', 'win32'].includes(platform))
|
|
63
|
+
return false;
|
|
64
|
+
if (current === 'foreground')
|
|
65
|
+
return launcher === 'start' && packageInstallation();
|
|
66
|
+
return current === 'service' && launcher === 'service-run' && packageInstallation();
|
|
67
|
+
};
|
|
68
|
+
const launchForeground = deps.launchForeground ?? (async (args) => {
|
|
69
|
+
const child = spawn(process.execPath, args, {
|
|
70
|
+
detached: true, stdio: ['ignore', 'ignore', 'ignore', 'ipc'], cwd: home(), env, windowsHide: true,
|
|
71
|
+
});
|
|
72
|
+
child.once('message', (message) => {
|
|
73
|
+
if (message === 'stop-for-update')
|
|
74
|
+
process.emit('SIGTERM', 'SIGTERM');
|
|
75
|
+
});
|
|
76
|
+
try {
|
|
77
|
+
await once(child, 'spawn');
|
|
78
|
+
}
|
|
79
|
+
finally {
|
|
80
|
+
child.unref();
|
|
81
|
+
child.channel?.unref();
|
|
82
|
+
}
|
|
83
|
+
});
|
|
27
84
|
const resultPath = () => join(home(), 'update-result.json');
|
|
28
85
|
function read() { try {
|
|
29
86
|
const x = JSON.parse(readFileSync(resultPath(), 'utf8'));
|
|
@@ -33,6 +90,9 @@ export function createUpdateManager(deps = {}) {
|
|
|
33
90
|
return null;
|
|
34
91
|
} }
|
|
35
92
|
function status() {
|
|
93
|
+
return { ...readStatus(), canUpdate: canUpdate() };
|
|
94
|
+
}
|
|
95
|
+
function readStatus() {
|
|
36
96
|
const result = read();
|
|
37
97
|
if (!result?.attemptId || !Number.isFinite(result.startedAt) || !result.fromVersion || !/^v\d+\.\d+\.\d+$/.test(result.target ?? ''))
|
|
38
98
|
return { mode: mode(), platform, packaged, result: null };
|
|
@@ -60,8 +120,8 @@ export function createUpdateManager(deps = {}) {
|
|
|
60
120
|
}
|
|
61
121
|
let starting = false;
|
|
62
122
|
async function start(body) {
|
|
63
|
-
if (
|
|
64
|
-
return { ok: false, status: 409, error: '
|
|
123
|
+
if (!canUpdate())
|
|
124
|
+
return { ok: false, status: 409, error: 'Arco cannot update this launch from the browser.' };
|
|
65
125
|
if (!body || typeof body !== 'object' || Array.isArray(body) || Object.keys(body).some((key) => key !== 'expectedLatest') || typeof body.expectedLatest !== 'string')
|
|
66
126
|
return { ok: false, status: 400, error: 'Confirm the displayed release; update accepts no target.' };
|
|
67
127
|
if (starting)
|
|
@@ -90,18 +150,26 @@ export function createUpdateManager(deps = {}) {
|
|
|
90
150
|
const resultFile = resultPath();
|
|
91
151
|
mkdirSync(home(), { recursive: true, mode: 0o700 });
|
|
92
152
|
writeFileSync(resultFile, JSON.stringify({ ...attempt, outcome: 'running' }), { mode: 0o600 });
|
|
93
|
-
const
|
|
94
|
-
const
|
|
95
|
-
|
|
96
|
-
const updateArgs = [cli, 'package-update', latest.latest, resultFile, task, attempt.attemptId];
|
|
153
|
+
const task = mode() === 'service' ? `arco-updater-${randomUUID()}` : '';
|
|
154
|
+
const updateArgs = [cli, 'package-update', latest.latest, resultFile, task, attempt.attemptId,
|
|
155
|
+
String(process.pid), version, env.ARCO_PORT || '3001', env.ARCO_HOST || '127.0.0.1'];
|
|
97
156
|
let result;
|
|
98
|
-
if (
|
|
157
|
+
if (!task) {
|
|
158
|
+
try {
|
|
159
|
+
await launchForeground(updateArgs);
|
|
160
|
+
result = { status: 0 };
|
|
161
|
+
}
|
|
162
|
+
catch {
|
|
163
|
+
result = { status: 1 };
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
else if (platform === 'linux') {
|
|
99
167
|
if ([repo, resultFile, home(), process.execPath].some((value) => value.includes('$'))) {
|
|
100
|
-
const message = '
|
|
168
|
+
const message = 'The installation path cannot be passed safely to the service updater.';
|
|
101
169
|
writeFileSync(resultFile, JSON.stringify({ ...attempt, outcome: 'failed', message, finishedAt: now() }), { mode: 0o600 });
|
|
102
170
|
return { ok: false, status: 503, error: message };
|
|
103
171
|
}
|
|
104
|
-
result = launch('systemd-run', ['--user', '--collect', '--no-ask-password', '--service-type=exec', '--quiet', `--unit=${task}`, `--working-directory=${home()}`, `--setenv=ARCO_HOME=${home()}`, ...(env.PATH ? [`--setenv=PATH=${env.PATH}`] : []), process.execPath, ...updateArgs]);
|
|
172
|
+
result = launch('systemd-run', ['--user', '--collect', '--no-ask-password', '--service-type=exec', '--quiet', `--unit=${task}`, `--working-directory=${home()}`, `--setenv=ARCO_HOME=${home()}`, ...(env.PATH ? [`--setenv=PATH=${env.PATH}`] : []), ...(env.XDG_CONFIG_HOME ? [`--setenv=XDG_CONFIG_HOME=${env.XDG_CONFIG_HOME}`] : []), process.execPath, ...updateArgs]);
|
|
105
173
|
}
|
|
106
174
|
else if (platform === 'darwin') {
|
|
107
175
|
result = launch('launchctl', ['submit', '-l', task, '--', process.execPath, ...updateArgs]);
|
|
@@ -109,7 +177,7 @@ export function createUpdateManager(deps = {}) {
|
|
|
109
177
|
else if (platform === 'win32') {
|
|
110
178
|
const user = env.USERDOMAIN && env.USERNAME ? `${env.USERDOMAIN}\\${env.USERNAME}` : env.USERNAME;
|
|
111
179
|
if (!user || [user, repo, resultFile, process.execPath].some((value) => /[\r\n\0]/.test(value))) {
|
|
112
|
-
const message = '
|
|
180
|
+
const message = 'The updater could not identify the Windows account or installation.';
|
|
113
181
|
writeFileSync(resultFile, JSON.stringify({ ...attempt, outcome: 'failed', message, finishedAt: now() }), { mode: 0o600 });
|
|
114
182
|
return { ok: false, status: 503, error: message };
|
|
115
183
|
}
|
|
@@ -132,7 +200,7 @@ export function createUpdateManager(deps = {}) {
|
|
|
132
200
|
else
|
|
133
201
|
result = { status: 1 };
|
|
134
202
|
if (result.error || result.status !== 0) {
|
|
135
|
-
const message = 'Could not start a separate updater.
|
|
203
|
+
const message = 'Could not start a separate updater. Try again.';
|
|
136
204
|
writeFileSync(resultFile, JSON.stringify({ ...attempt, outcome: 'failed', message, finishedAt: now() }), { mode: 0o600 });
|
|
137
205
|
return { ok: false, status: 503, error: message };
|
|
138
206
|
}
|
|
@@ -144,9 +212,8 @@ export function createUpdateManager(deps = {}) {
|
|
|
144
212
|
const resultFile = resultPath();
|
|
145
213
|
mkdirSync(home(), { recursive: true, mode: 0o700 });
|
|
146
214
|
writeFileSync(resultFile, JSON.stringify({ ...attempt, outcome: 'running' }), { mode: 0o600 });
|
|
147
|
-
const repo = deps.root ?? repoRoot;
|
|
148
215
|
if ([repo, resultFile, home(), process.execPath].some((value) => value.includes('$'))) {
|
|
149
|
-
const message = 'The checkout or home path cannot be passed safely to the service
|
|
216
|
+
const message = 'The checkout or home path cannot be passed safely to the service updater.';
|
|
150
217
|
writeFileSync(resultFile, JSON.stringify({ ...attempt, outcome: 'failed', message, finishedAt: now() }), { mode: 0o600 });
|
|
151
218
|
return { ok: false, status: 503, error: message };
|
|
152
219
|
}
|
|
@@ -155,7 +222,7 @@ export function createUpdateManager(deps = {}) {
|
|
|
155
222
|
process.execPath, join(repo, 'scripts', 'arco-update.mjs'), '--yes', '--require-service', '--expected-release', latest.latest, '--result-file', resultFile, '--attempt-id', attempt.attemptId];
|
|
156
223
|
const result = launch('systemd-run', args);
|
|
157
224
|
if (result.error || result.status !== 0) {
|
|
158
|
-
const message = 'Could not start a separate updater.
|
|
225
|
+
const message = 'Could not start a separate updater. Try again.';
|
|
159
226
|
writeFileSync(resultFile, JSON.stringify({ ...attempt, outcome: 'failed', message, finishedAt: now() }), { mode: 0o600 });
|
|
160
227
|
return { ok: false, status: 503, error: message };
|
|
161
228
|
}
|
package/server/package.json
CHANGED
|
@@ -20,14 +20,13 @@ export function buildClusterDirectorDoctrine(role: string | undefined): string |
|
|
|
20
20
|
'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.',
|
|
21
21
|
'An assignment never asks for something the project\'s own rules forbid (how commits land, changelog, documentation, testing); state the delivery those rules require. When the work truly needs an exception, ask the operator first.',
|
|
22
22
|
'When you assign work, ask for one report at the end, or one at an agreed milestone, plus blockers, and ask for step notes as comments on the board task. Never ask members to coordinate with each other by message for routine things, such as taking turns on a shared resource, status or acknowledgements, when a lock, a file or the board can do it.',
|
|
23
|
-
'
|
|
23
|
+
'For long checks, stay responsive and follow operator and project instructions. Wait for the result, hand off the check, or continue other approved work as the workflow requires. Follow the same instructions on when to end the turn.',
|
|
24
24
|
'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.',
|
|
25
25
|
'When a task is met, sign it off with a plain operator-facing summary without commit hashes. If the whole linked plan item is also complete, pass completePlan with the attached plan ID, reviewed revision and unique numbered item ID; otherwise leave the plan unchanged. If the tool reports a pending plan completion, read the original plan ID, item ID and reviewed revision with cluster_task_show, then retry; if the plan changed, resolve the pending sign-off and review again. A met sign-off closes it unless Board auto-done is off in Settings. Tell the operator in chat what to try.',
|
|
26
26
|
'Before a failure holds work up, say what a user would lose if it were real; note cosmetic or momentary faults and carry on.',
|
|
27
27
|
'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.',
|
|
28
28
|
'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
29
|
'The plan holds standing rules and tasks only. You may add, split, reword, or restructure tasks and tick them with cluster_plan_tick; change standing rules only when the operator asks. Put progress, evidence, commit hashes, CI ids, test counts, and dates on board tasks, never in the plan body.',
|
|
30
|
-
'When runnable work remains, delegate it via peer_send and end your turn; do not do a peer\'s work to keep the turn going.',
|
|
31
30
|
'If two instructions conflict or required authority is genuinely missing, identify the exact conflict immediately and ask the operator; do not silently stall.',
|
|
32
31
|
].join('\n');
|
|
33
32
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { setMaxListeners } from 'node:events';
|
|
2
2
|
import { assertNativeTaskAllowed, nativeTaskBatchApprovalReasons } from './taskAdmission.js';
|
|
3
3
|
import { readSettings } from '../../settings.js';
|
|
4
|
-
import { buildTurnWaitInstructions, resolveNativeSubagents, CLAUDE_MODELS, isIsolatedAccessMode, type NativeSubagentPolicy } from '@arco/shared';
|
|
4
|
+
import { buildTurnWaitInstructions, isClusterDirector, resolveNativeSubagents, CLAUDE_MODELS, isIsolatedAccessMode, type NativeSubagentPolicy } from '@arco/shared';
|
|
5
5
|
import { RESEARCHER_DOCTRINE, researchDirectorDoctrine } from '../../research/researchDoctrine.js';
|
|
6
6
|
import { availableHandoffSources, executeHandoffHistory, HANDOFF_HISTORY_TOOL, HANDOFF_HISTORY_CONTEXT } from '../../handoffHistoryTool.js';
|
|
7
7
|
import { mediaRetirementNotice } from './mediaRetirementNotice.js';
|
|
@@ -2121,10 +2121,11 @@ export class ClaudeNativeWorker extends EventEmitter {
|
|
|
2121
2121
|
blocks.push({
|
|
2122
2122
|
type: 'text',
|
|
2123
2123
|
text:
|
|
2124
|
-
|
|
2125
|
-
|
|
2126
|
-
|
|
2127
|
-
|
|
2124
|
+
(isClusterDirector(this.config.clusterRole) ? '' :
|
|
2125
|
+
'Turn discipline: the operator is not watching in real time and cannot answer mid-turn. ' +
|
|
2126
|
+
'Continue working until the request is complete or you are genuinely blocked on operator input. ' +
|
|
2127
|
+
"Never end your turn with a status update, a plan, or a promise of future work ('Continuing now', 'I'll do X next') — " +
|
|
2128
|
+
'if your final paragraph describes work you have not done, do that work now instead of ending the turn. ') +
|
|
2128
2129
|
buildTurnWaitInstructions(this.config.clusterRole) + ' ' +
|
|
2129
2130
|
'If a delegated Task child fails or returns an error or nonsense (e.g. a login error), say so explicitly in your reply and adapt openly — never silently work around a failed delegation. ' +
|
|
2130
2131
|
// Fable 5.1 / 5.2 can rewrite whole files where a targeted edit would do
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import { spawnSync } from 'node:child_process';
|
|
2
|
-
import {
|
|
1
|
+
import { spawn, spawnSync } from 'node:child_process';
|
|
2
|
+
import { once } from 'node:events';
|
|
3
|
+
import { mkdirSync, readFileSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
|
|
3
4
|
import { dirname, join, resolve } from 'node:path';
|
|
4
5
|
import { fileURLToPath } from 'node:url';
|
|
5
6
|
import { randomUUID } from 'node:crypto';
|
|
7
|
+
import { createRequire } from 'node:module';
|
|
6
8
|
import { arcoHome } from './arcoHome.js';
|
|
7
9
|
import { updateChecker } from './server/updateCheck.js';
|
|
8
10
|
import { APP_VERSION } from './appVersion.js';
|
|
9
11
|
import type { UpdateCheckStatus } from '@arco/shared';
|
|
10
12
|
|
|
11
13
|
export type UpdateMode = 'service' | 'foreground' | 'docker';
|
|
12
|
-
export function updateMode(platform = process.platform, env: NodeJS.ProcessEnv = process.env): UpdateMode {
|
|
14
|
+
export function updateMode(platform = process.platform, env: NodeJS.ProcessEnv = process.env, launcher?: 'start' | 'service-run'): UpdateMode {
|
|
13
15
|
if (env.ARCO_DEPLOYMENT === 'docker') return 'docker';
|
|
14
|
-
if (env.ARCO_PACKAGED === '1'
|
|
16
|
+
if (env.ARCO_PACKAGED === '1') {
|
|
17
|
+
// A foreground launcher can inherit systemd markers from its parent.
|
|
18
|
+
if (launcher === 'start') return 'foreground';
|
|
19
|
+
if (launcher === 'service-run' || env.ARCO_PACKAGE_SERVICE === '1') return 'service';
|
|
20
|
+
}
|
|
15
21
|
return platform === 'linux' && !!(env.INVOCATION_ID || env.SYSTEMD_EXEC_PID) ? 'service' : 'foreground';
|
|
16
22
|
}
|
|
17
23
|
const repoRoot = resolve(dirname(fileURLToPath(import.meta.url)), '../..');
|
|
@@ -20,9 +26,11 @@ export function createUpdateManager(deps: {
|
|
|
20
26
|
mode?: () => UpdateMode; home?: () => string; root?: string; env?: NodeJS.ProcessEnv; platform?: NodeJS.Platform;
|
|
21
27
|
check?: () => Promise<Pick<UpdateCheckStatus, 'latest' | 'updateAvailable' | 'checkFailure'>>;
|
|
22
28
|
launch?: (command: string, args: string[]) => { status: number | null; error?: Error; stderr?: string | null };
|
|
29
|
+
launchForeground?: (args: string[]) => Promise<void>;
|
|
30
|
+
packageInstallation?: () => boolean;
|
|
31
|
+
argv?: string[];
|
|
23
32
|
now?: () => number; version?: string;
|
|
24
33
|
} = {}) {
|
|
25
|
-
const mode = deps.mode ?? (() => updateMode());
|
|
26
34
|
const home = deps.home ?? arcoHome;
|
|
27
35
|
const env = deps.env ?? process.env;
|
|
28
36
|
const platform = deps.platform ?? process.platform;
|
|
@@ -31,9 +39,44 @@ export function createUpdateManager(deps: {
|
|
|
31
39
|
const launch = deps.launch ?? ((command, args) => spawnSync(command, args, { encoding: 'utf8', timeout: 15_000 }));
|
|
32
40
|
const now = deps.now ?? Date.now;
|
|
33
41
|
const version = deps.version ?? APP_VERSION;
|
|
42
|
+
const repo = deps.root ?? repoRoot;
|
|
43
|
+
const cli = join(repo, 'scripts', 'packaging', 'arco.mjs');
|
|
44
|
+
const argv = deps.argv ?? process.argv;
|
|
45
|
+
const launcher = (() => {
|
|
46
|
+
const command = argv[2];
|
|
47
|
+
if (!packaged || (command !== 'start' && command !== 'service-run') || !argv[1]) return undefined;
|
|
48
|
+
try { return realpathSync.native(argv[1]) === realpathSync.native(cli) ? command : undefined; } catch { return undefined; }
|
|
49
|
+
})();
|
|
50
|
+
const mode = deps.mode ?? (() => updateMode(platform, env, launcher));
|
|
51
|
+
const packageInstallation = deps.packageInstallation ?? (() => {
|
|
52
|
+
try {
|
|
53
|
+
const { verifiedPackagePrefix } = createRequire(import.meta.url)(join(repo, 'scripts', 'packaging', 'update.mjs'));
|
|
54
|
+
verifiedPackagePrefix(repo);
|
|
55
|
+
return true;
|
|
56
|
+
} catch { return false; }
|
|
57
|
+
});
|
|
58
|
+
const canUpdate = () => {
|
|
59
|
+
const current = mode();
|
|
60
|
+
if (!packaged) return current === 'service' && platform === 'linux';
|
|
61
|
+
if (!['linux', 'darwin', 'win32'].includes(platform)) return false;
|
|
62
|
+
if (current === 'foreground') return launcher === 'start' && packageInstallation();
|
|
63
|
+
return current === 'service' && launcher === 'service-run' && packageInstallation();
|
|
64
|
+
};
|
|
65
|
+
const launchForeground = deps.launchForeground ?? (async (args: string[]) => {
|
|
66
|
+
const child = spawn(process.execPath, args, {
|
|
67
|
+
detached: true, stdio: ['ignore', 'ignore', 'ignore', 'ipc'], cwd: home(), env, windowsHide: true,
|
|
68
|
+
});
|
|
69
|
+
child.once('message', (message) => {
|
|
70
|
+
if (message === 'stop-for-update') process.emit('SIGTERM', 'SIGTERM');
|
|
71
|
+
});
|
|
72
|
+
try { await once(child, 'spawn'); } finally { child.unref(); child.channel?.unref(); }
|
|
73
|
+
});
|
|
34
74
|
const resultPath = () => join(home(), 'update-result.json');
|
|
35
75
|
function read(): Status | null { try { const x = JSON.parse(readFileSync(resultPath(), 'utf8')); return x && typeof x.outcome === 'string' ? x : null; } catch { return null; } }
|
|
36
76
|
function status() {
|
|
77
|
+
return { ...readStatus(), canUpdate: canUpdate() };
|
|
78
|
+
}
|
|
79
|
+
function readStatus() {
|
|
37
80
|
const result = read();
|
|
38
81
|
if (!result?.attemptId || !Number.isFinite(result.startedAt) || !result.fromVersion || !/^v\d+\.\d+\.\d+$/.test(result.target ?? '')) return { mode: mode(), platform, packaged, result: null };
|
|
39
82
|
if (result.outcome === 'running') return { mode: mode(), platform, packaged, result: now() - result.startedAt! < 30 * 60_000 && now() >= result.startedAt! ? result : null };
|
|
@@ -52,7 +95,7 @@ export function createUpdateManager(deps: {
|
|
|
52
95
|
}
|
|
53
96
|
let starting = false;
|
|
54
97
|
async function start(body: unknown) {
|
|
55
|
-
if (
|
|
98
|
+
if (!canUpdate()) return { ok: false, status: 409, error: 'Arco cannot update this launch from the browser.' };
|
|
56
99
|
if (!body || typeof body !== 'object' || Array.isArray(body) || Object.keys(body).some((key) => key !== 'expectedLatest') || typeof (body as { expectedLatest?: unknown }).expectedLatest !== 'string') return { ok: false, status: 400, error: 'Confirm the displayed release; update accepts no target.' };
|
|
57
100
|
if (starting) return { ok: false, status: 409, error: 'An update is already starting.' };
|
|
58
101
|
starting = true;
|
|
@@ -69,24 +112,26 @@ export function createUpdateManager(deps: {
|
|
|
69
112
|
if (packaged) {
|
|
70
113
|
const resultFile = resultPath(); mkdirSync(home(), { recursive: true, mode: 0o700 });
|
|
71
114
|
writeFileSync(resultFile, JSON.stringify({ ...attempt, outcome: 'running' }), { mode: 0o600 });
|
|
72
|
-
const
|
|
73
|
-
const
|
|
74
|
-
|
|
75
|
-
const updateArgs = [cli, 'package-update', latest.latest, resultFile, task, attempt.attemptId];
|
|
115
|
+
const task = mode() === 'service' ? `arco-updater-${randomUUID()}` : '';
|
|
116
|
+
const updateArgs = [cli, 'package-update', latest.latest, resultFile, task, attempt.attemptId,
|
|
117
|
+
String(process.pid), version, env.ARCO_PORT || '3001', env.ARCO_HOST || '127.0.0.1'];
|
|
76
118
|
let result: { status: number | null; error?: Error; stderr?: string | null };
|
|
77
|
-
if (
|
|
119
|
+
if (!task) {
|
|
120
|
+
try { await launchForeground(updateArgs); result = { status: 0 }; }
|
|
121
|
+
catch { result = { status: 1 }; }
|
|
122
|
+
} else if (platform === 'linux') {
|
|
78
123
|
if ([repo, resultFile, home(), process.execPath].some((value) => value.includes('$'))) {
|
|
79
|
-
const message = '
|
|
124
|
+
const message = 'The installation path cannot be passed safely to the service updater.';
|
|
80
125
|
writeFileSync(resultFile, JSON.stringify({ ...attempt, outcome: 'failed', message, finishedAt: now() }), { mode: 0o600 });
|
|
81
126
|
return { ok: false, status: 503, error: message };
|
|
82
127
|
}
|
|
83
|
-
result = launch('systemd-run', ['--user', '--collect', '--no-ask-password', '--service-type=exec', '--quiet', `--unit=${task}`, `--working-directory=${home()}`, `--setenv=ARCO_HOME=${home()}`, ...(env.PATH ? [`--setenv=PATH=${env.PATH}`] : []), process.execPath, ...updateArgs]);
|
|
128
|
+
result = launch('systemd-run', ['--user', '--collect', '--no-ask-password', '--service-type=exec', '--quiet', `--unit=${task}`, `--working-directory=${home()}`, `--setenv=ARCO_HOME=${home()}`, ...(env.PATH ? [`--setenv=PATH=${env.PATH}`] : []), ...(env.XDG_CONFIG_HOME ? [`--setenv=XDG_CONFIG_HOME=${env.XDG_CONFIG_HOME}`] : []), process.execPath, ...updateArgs]);
|
|
84
129
|
} else if (platform === 'darwin') {
|
|
85
130
|
result = launch('launchctl', ['submit', '-l', task, '--', process.execPath, ...updateArgs]);
|
|
86
131
|
} else if (platform === 'win32') {
|
|
87
132
|
const user = env.USERDOMAIN && env.USERNAME ? `${env.USERDOMAIN}\\${env.USERNAME}` : env.USERNAME;
|
|
88
133
|
if (!user || [user, repo, resultFile, process.execPath].some((value) => /[\r\n\0]/.test(value))) {
|
|
89
|
-
const message = '
|
|
134
|
+
const message = 'The updater could not identify the Windows account or installation.';
|
|
90
135
|
writeFileSync(resultFile, JSON.stringify({ ...attempt, outcome: 'failed', message, finishedAt: now() }), { mode: 0o600 });
|
|
91
136
|
return { ok: false, status: 503, error: message };
|
|
92
137
|
}
|
|
@@ -102,7 +147,7 @@ export function createUpdateManager(deps: {
|
|
|
102
147
|
} else rmSync(xmlPath, { force: true });
|
|
103
148
|
} else result = { status: 1 };
|
|
104
149
|
if (result.error || result.status !== 0) {
|
|
105
|
-
const message = 'Could not start a separate updater.
|
|
150
|
+
const message = 'Could not start a separate updater. Try again.';
|
|
106
151
|
writeFileSync(resultFile, JSON.stringify({ ...attempt, outcome: 'failed', message, finishedAt: now() }), { mode: 0o600 });
|
|
107
152
|
return { ok: false, status: 503, error: message };
|
|
108
153
|
}
|
|
@@ -112,9 +157,8 @@ export function createUpdateManager(deps: {
|
|
|
112
157
|
if (!/^[a-zA-Z0-9][a-zA-Z0-9_.@-]*\.service$/.test(unit)) return { ok: false, status: 409, error: 'The service unit name is invalid.' };
|
|
113
158
|
const resultFile = resultPath(); mkdirSync(home(), { recursive: true, mode: 0o700 });
|
|
114
159
|
writeFileSync(resultFile, JSON.stringify({ ...attempt, outcome: 'running' }), { mode: 0o600 });
|
|
115
|
-
const repo = deps.root ?? repoRoot;
|
|
116
160
|
if ([repo, resultFile, home(), process.execPath].some((value) => value.includes('$'))) {
|
|
117
|
-
const message = 'The checkout or home path cannot be passed safely to the service
|
|
161
|
+
const message = 'The checkout or home path cannot be passed safely to the service updater.';
|
|
118
162
|
writeFileSync(resultFile, JSON.stringify({ ...attempt, outcome: 'failed', message, finishedAt: now() }), { mode: 0o600 });
|
|
119
163
|
return { ok: false, status: 503, error: message };
|
|
120
164
|
}
|
|
@@ -123,7 +167,7 @@ export function createUpdateManager(deps: {
|
|
|
123
167
|
process.execPath, join(repo, 'scripts', 'arco-update.mjs'), '--yes', '--require-service', '--expected-release', latest.latest, '--result-file', resultFile, '--attempt-id', attempt.attemptId];
|
|
124
168
|
const result = launch('systemd-run', args);
|
|
125
169
|
if (result.error || result.status !== 0) {
|
|
126
|
-
const message = 'Could not start a separate updater.
|
|
170
|
+
const message = 'Could not start a separate updater. Try again.';
|
|
127
171
|
writeFileSync(resultFile, JSON.stringify({ ...attempt, outcome: 'failed', message, finishedAt: now() }), { mode: 0o600 });
|
|
128
172
|
return { ok: false, status: 503, error: message };
|
|
129
173
|
}
|