pacework 1.7.0 → 1.7.2
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/bin/pacework-runner-ctl.mjs +61 -12
- package/bin/pacework-runner.mjs +20 -0
- package/lib/capabilities.mjs +58 -0
- package/lib/run-limits.mjs +43 -5
- package/lib/service.mjs +46 -0
- package/lib/version.mjs +13 -0
- package/package.json +1 -1
|
@@ -41,9 +41,12 @@ import {
|
|
|
41
41
|
installService,
|
|
42
42
|
installStableCopy,
|
|
43
43
|
installCommandLauncher,
|
|
44
|
+
installedServiceVersion,
|
|
44
45
|
isServiceInstalled,
|
|
45
46
|
isServiceRunning,
|
|
47
|
+
moveServiceTo,
|
|
46
48
|
privacyProtectedFolder,
|
|
49
|
+
serviceNeedsUpdate,
|
|
47
50
|
serviceKind,
|
|
48
51
|
startService,
|
|
49
52
|
stopService,
|
|
@@ -72,6 +75,57 @@ async function checkForUpdate() {
|
|
|
72
75
|
} catch {}
|
|
73
76
|
}
|
|
74
77
|
|
|
78
|
+
/**
|
|
79
|
+
* Move the login service to this copy of the runner when it runs an older one.
|
|
80
|
+
* The service runs the stable copy `up` saved, so installing a new version or
|
|
81
|
+
* restarting used to leave it on the old runner (PWK-307). Returns true when it
|
|
82
|
+
* moved.
|
|
83
|
+
*/
|
|
84
|
+
function moveServiceToThisVersion() {
|
|
85
|
+
if (!isServiceInstalled() || !LOCAL_VERSION) return false
|
|
86
|
+
const running = installedServiceVersion()
|
|
87
|
+
if (!serviceNeedsUpdate(running, LOCAL_VERSION)) return false
|
|
88
|
+
console.log(` Moving the runner service from ${running ?? "an older copy"} to \x1b[1m${LOCAL_VERSION}\x1b[0m…`)
|
|
89
|
+
try {
|
|
90
|
+
moveServiceTo(path.resolve(__dirname, ".."), LOCAL_VERSION)
|
|
91
|
+
return true
|
|
92
|
+
} catch (err) {
|
|
93
|
+
console.error(` Could not move the runner service to ${LOCAL_VERSION}: ${err.message}`)
|
|
94
|
+
return false
|
|
95
|
+
}
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/**
|
|
99
|
+
* `pacework update`: install the newest published version and restart the
|
|
100
|
+
* runner on it. With nothing newer on npm, still move a service that runs an
|
|
101
|
+
* older copy than this one.
|
|
102
|
+
*/
|
|
103
|
+
async function updateRunner() {
|
|
104
|
+
console.log("Checking for updates…")
|
|
105
|
+
const latest = await latestPublishedVersion().catch(() => null)
|
|
106
|
+
if (!latest) {
|
|
107
|
+
console.log("\x1b[31mCould not reach npm registry.\x1b[0m")
|
|
108
|
+
return 1
|
|
109
|
+
}
|
|
110
|
+
if (!isNewerVersion(latest, LOCAL_VERSION)) {
|
|
111
|
+
console.log(`\x1b[32m✓\x1b[0m Already on latest (\x1b[1m${LOCAL_VERSION}\x1b[0m)`)
|
|
112
|
+
if (moveServiceToThisVersion()) console.log(`\x1b[32m✓\x1b[0m Runner service now runs ${LOCAL_VERSION}`)
|
|
113
|
+
return 0
|
|
114
|
+
}
|
|
115
|
+
console.log(`Updating ${LOCAL_VERSION} → \x1b[1m${latest}\x1b[0m…`)
|
|
116
|
+
const install = spawn("npm", ["install", "-g", `${NPM_PACKAGE}@${latest}`], { stdio: "inherit" })
|
|
117
|
+
const installed = await new Promise((resolve) => install.on("exit", (code) => resolve(code === 0)))
|
|
118
|
+
if (!installed) {
|
|
119
|
+
console.log("\x1b[31mnpm install failed; the runner keeps running the current version.\x1b[0m")
|
|
120
|
+
return 1
|
|
121
|
+
}
|
|
122
|
+
// This process is still the old version: restart through the new one, whose
|
|
123
|
+
// `start` moves the service to it.
|
|
124
|
+
console.log(`Restarting the runner on ${latest}…`)
|
|
125
|
+
const restart = spawn("npx", ["-y", `${NPM_PACKAGE}@${latest}`, "start"], { stdio: "inherit", env: process.env })
|
|
126
|
+
return await new Promise((resolve) => restart.on("exit", (code) => resolve(code ?? 1)))
|
|
127
|
+
}
|
|
128
|
+
|
|
75
129
|
// ── ascii banner ──────────────────────────────────────────────────────────────
|
|
76
130
|
|
|
77
131
|
const BANNER = `\x1b[38;5;39m${BANNER_LINES.map((line) => ` ${line}`).join("\n")}\x1b[0m`
|
|
@@ -279,6 +333,7 @@ ${row("pacework doctor", "Check this machine's setup")}
|
|
|
279
333
|
${row("pacework triage [--once]", "Only triage, in the foreground")}
|
|
280
334
|
${row("pacework up --token CODE", "One-step setup from the command in pacework's Runners page; asks for the runner's name and model")}
|
|
281
335
|
${row("pacework down", "Remove the background service")}
|
|
336
|
+
${row("pacework update", "Install the newest version and restart the runner on it")}
|
|
282
337
|
|
|
283
338
|
\x1b[1mRunner flags\x1b[0m ${d("for start, connect and up")}
|
|
284
339
|
--repo-root PATH --executor TOOL --name NAME --model ID --max-parallel-runs N --sandbox --no-triage
|
|
@@ -930,6 +985,7 @@ else if (command === "start") {
|
|
|
930
985
|
|
|
931
986
|
if (isServiceInstalled()) {
|
|
932
987
|
const logOffset = (() => { try { return fs.statSync(LOG_FILE).size } catch { return 0 } })()
|
|
988
|
+
moveServiceToThisVersion()
|
|
933
989
|
if (!isServiceRunning()) {
|
|
934
990
|
try { startService() } catch (err) { console.error(`Could not start the runner service: ${err.message}`); process.exit(1) }
|
|
935
991
|
}
|
|
@@ -1044,6 +1100,10 @@ run()
|
|
|
1044
1100
|
|
|
1045
1101
|
// ── stop ─────────────────────────────────────────────────────────────────────
|
|
1046
1102
|
|
|
1103
|
+
else if (command === "update") {
|
|
1104
|
+
process.exit(await updateRunner())
|
|
1105
|
+
}
|
|
1106
|
+
|
|
1047
1107
|
else if (command === "stop") {
|
|
1048
1108
|
// With a login service, stop it first; otherwise it restarts the runner the
|
|
1049
1109
|
// moment the process below is killed.
|
|
@@ -2547,18 +2607,7 @@ else if (command === "shell" || command === "sh") {
|
|
|
2547
2607
|
break
|
|
2548
2608
|
}
|
|
2549
2609
|
case "update": {
|
|
2550
|
-
|
|
2551
|
-
try {
|
|
2552
|
-
const latest = await latestPublishedVersion()
|
|
2553
|
-
if (!latest) throw new Error("no version")
|
|
2554
|
-
if (!isNewerVersion(latest, LOCAL_VERSION)) {
|
|
2555
|
-
console.log(`\x1b[32m✓\x1b[0m Already on latest (\x1b[1m${LOCAL_VERSION}\x1b[0m)`)
|
|
2556
|
-
} else {
|
|
2557
|
-
console.log(`Updating ${LOCAL_VERSION} → \x1b[1m${latest}\x1b[0m…`)
|
|
2558
|
-
const child = spawn("npm", ["install", "-g", `${NPM_PACKAGE}@${latest}`], { stdio: "inherit" })
|
|
2559
|
-
await new Promise(r => child.on("exit", r))
|
|
2560
|
-
}
|
|
2561
|
-
} catch { console.log("\x1b[31mCould not reach npm registry.\x1b[0m") }
|
|
2610
|
+
await updateRunner()
|
|
2562
2611
|
break
|
|
2563
2612
|
}
|
|
2564
2613
|
case "login": {
|
package/bin/pacework-runner.mjs
CHANGED
|
@@ -9,6 +9,7 @@ import process from "node:process"
|
|
|
9
9
|
import { spawn, execFileSync } from "node:child_process"
|
|
10
10
|
import { AsyncLocalStorage } from "node:async_hooks"
|
|
11
11
|
import { createLogger } from "../lib/logger.mjs"
|
|
12
|
+
import { detectCapabilities, detectPower } from "../lib/capabilities.mjs"
|
|
12
13
|
import { detectRunUsageLimit, USAGE_LIMIT_MARKER } from "../lib/usage-limit.mjs"
|
|
13
14
|
import {
|
|
14
15
|
buildImpactReport,
|
|
@@ -32,6 +33,7 @@ import { AVAILABILITY_MODES, describeRegistration, isRevokedError, registrationC
|
|
|
32
33
|
import { describeTriageJob, runTriageLoop, TRIAGE_EXECUTORS } from "../lib/triage-worker.mjs"
|
|
33
34
|
import { automationDenyRules, automationLimits } from "../lib/automation-limits.mjs"
|
|
34
35
|
import { truncateSummary } from "../lib/summary-text.mjs"
|
|
36
|
+
import { RUNNER_VERSION } from "../lib/version.mjs"
|
|
35
37
|
|
|
36
38
|
function parseArgs(argv) {
|
|
37
39
|
const args = {}
|
|
@@ -965,8 +967,10 @@ async function registerRunner() {
|
|
|
965
967
|
local_executor: defaultExecutor,
|
|
966
968
|
labels,
|
|
967
969
|
max_parallel_runs: maxParallelRuns,
|
|
970
|
+
...(RUNNER_VERSION ? { version: RUNNER_VERSION } : {}),
|
|
968
971
|
...(homeTeam ? { home_team: homeTeam } : {}),
|
|
969
972
|
...(availabilityMode ? { availability_mode: availabilityMode } : {}),
|
|
973
|
+
capabilities: runnerCapabilities(),
|
|
970
974
|
}),
|
|
971
975
|
})
|
|
972
976
|
|
|
@@ -1015,6 +1019,18 @@ async function ensureRegisteredRunner() {
|
|
|
1015
1019
|
return registerRunner()
|
|
1016
1020
|
}
|
|
1017
1021
|
|
|
1022
|
+
// Which repositories and tools this machine has (PWK-297). Re-checked every few
|
|
1023
|
+
// minutes, so a newly added remote or a started Docker shows up without a restart.
|
|
1024
|
+
let capabilitiesCache = null
|
|
1025
|
+
function runnerCapabilities() {
|
|
1026
|
+
if (!capabilitiesCache || Date.now() - capabilitiesCache.at > 5 * 60_000) {
|
|
1027
|
+
capabilitiesCache = { at: Date.now(), value: detectCapabilities({ repoRoot, executors: installedExecutors }) }
|
|
1028
|
+
}
|
|
1029
|
+
// Power changes often (unplugging a laptop); it's cheap to read every heartbeat.
|
|
1030
|
+
const power = detectPower()
|
|
1031
|
+
return power ? { ...capabilitiesCache.value, power } : capabilitiesCache.value
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1018
1034
|
async function heartbeat(state, status = "online") {
|
|
1019
1035
|
return requestJson(`${appUrl}/api/agent-runners/heartbeat`, {
|
|
1020
1036
|
method: "POST",
|
|
@@ -1027,6 +1043,10 @@ async function heartbeat(state, status = "online") {
|
|
|
1027
1043
|
runner_id: state.runner_id,
|
|
1028
1044
|
status,
|
|
1029
1045
|
local_executors: installedExecutors,
|
|
1046
|
+
// Sent on every heartbeat, so the runner list shows the version a
|
|
1047
|
+
// runner is on now, not the one it registered with.
|
|
1048
|
+
...(RUNNER_VERSION ? { version: RUNNER_VERSION } : {}),
|
|
1049
|
+
capabilities: runnerCapabilities(),
|
|
1030
1050
|
}),
|
|
1031
1051
|
})
|
|
1032
1052
|
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { execFileSync } from "node:child_process"
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* What this machine can work on (PWK-297), reported when the runner registers and
|
|
5
|
+
* on every heartbeat. The server only gives it issues for repositories it has.
|
|
6
|
+
* Anything not detected is left out, which the server reads as "unknown, eligible".
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
/** "owner/name" (lower case) from a GitHub remote URL, or null for anything else. */
|
|
10
|
+
export function repoFromRemoteUrl(url) {
|
|
11
|
+
const match = String(url ?? "").trim().match(/github\.com[:/]+([^/\s]+)\/([^/\s]+?)(?:\.git)?\/?$/i)
|
|
12
|
+
return match ? `${match[1]}/${match[2]}`.toLowerCase() : null
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function run(command, args, options = {}) {
|
|
16
|
+
try {
|
|
17
|
+
return execFileSync(command, args, { encoding: "utf8", stdio: ["ignore", "pipe", "ignore"], timeout: 4000, ...options }).trim()
|
|
18
|
+
} catch {
|
|
19
|
+
return null
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** "ac" or "battery" on macOS (pmset); null where it can't tell. For "help only on power" (PWK-300). */
|
|
24
|
+
export function detectPower(exec = run) {
|
|
25
|
+
const out = exec("pmset", ["-g", "batt"])
|
|
26
|
+
if (!out) return null
|
|
27
|
+
if (/AC Power/i.test(out)) return "ac"
|
|
28
|
+
if (/Battery Power/i.test(out)) return "battery"
|
|
29
|
+
return null
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Whether this machine can run an agent inside its AI tool's own OS sandbox
|
|
34
|
+
* (Seatbelt on macOS, bubblewrap on Linux; Claude Code and Codex). Teams that
|
|
35
|
+
* require sandboxed helpers only get such runners (PWK-295). No Docker needed,
|
|
36
|
+
* and the tool keeps using the machine's own login.
|
|
37
|
+
*/
|
|
38
|
+
export function canSandbox({ platform = process.platform, executors = [], exec = run } = {}) {
|
|
39
|
+
if (!executors.some((executor) => executor === "claude_code" || executor === "codex")) return false
|
|
40
|
+
if (platform === "darwin") return true
|
|
41
|
+
if (platform === "linux") return Boolean(exec("bwrap", ["--version"]))
|
|
42
|
+
return false
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function detectCapabilities({ repoRoot, executors = [], exec = run, platform = process.platform } = {}) {
|
|
46
|
+
const capabilities = {}
|
|
47
|
+
const remotes = (exec("git", ["-C", repoRoot, "remote", "-v"]) ?? "")
|
|
48
|
+
.split("\n")
|
|
49
|
+
.map((line) => repoFromRemoteUrl(line.split(/\s+/)[1]))
|
|
50
|
+
.filter(Boolean)
|
|
51
|
+
// Only when a GitHub repo was found: an empty list would mean "can't do any repo".
|
|
52
|
+
if (remotes.length) capabilities.repos = [...new Set(remotes)]
|
|
53
|
+
const tools = []
|
|
54
|
+
if (exec("docker", ["version", "--format", "{{.Server.Version}}"])) tools.push("docker")
|
|
55
|
+
if (canSandbox({ platform, executors, exec })) tools.push("sandbox")
|
|
56
|
+
capabilities.tools = tools
|
|
57
|
+
return capabilities
|
|
58
|
+
}
|
package/lib/run-limits.mjs
CHANGED
|
@@ -142,6 +142,44 @@ export function tripwireHeadline(stop) {
|
|
|
142
142
|
return `${TRIPWIRE_MARKER}: the run was stopped at its ${what} limit because ${stop.reason}.`
|
|
143
143
|
}
|
|
144
144
|
|
|
145
|
+
/**
|
|
146
|
+
* Folders that hold installed dependencies, package stores and build caches.
|
|
147
|
+
* An install inside the checkout (a pnpm store when the home folder is on
|
|
148
|
+
* another volume, a Python virtualenv, a node_modules a repo forgot to ignore)
|
|
149
|
+
* writes tens of thousands of files that are not the agent's work. They do not
|
|
150
|
+
* count toward the file limit and are never committed as a stopped run's work.
|
|
151
|
+
*/
|
|
152
|
+
export const DEPENDENCY_DIRS = Object.freeze([
|
|
153
|
+
"node_modules",
|
|
154
|
+
".pnpm-store",
|
|
155
|
+
".npm",
|
|
156
|
+
".bun",
|
|
157
|
+
".venv",
|
|
158
|
+
"venv",
|
|
159
|
+
"__pycache__",
|
|
160
|
+
".gradle",
|
|
161
|
+
".m2",
|
|
162
|
+
".cargo",
|
|
163
|
+
".turbo",
|
|
164
|
+
".next",
|
|
165
|
+
".cache",
|
|
166
|
+
])
|
|
167
|
+
|
|
168
|
+
const DEPENDENCY_DIR_SET = new Set(DEPENDENCY_DIRS)
|
|
169
|
+
|
|
170
|
+
/** Whether a repo-relative path lies inside one of DEPENDENCY_DIRS. */
|
|
171
|
+
export function isDependencyPath(file) {
|
|
172
|
+
const parts = String(file || "").split("/")
|
|
173
|
+
// The last part is the file itself; only its folders matter.
|
|
174
|
+
return parts.slice(0, -1).some((part) => DEPENDENCY_DIR_SET.has(part))
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
/** Pathspecs that keep git from listing or adding anything in DEPENDENCY_DIRS. */
|
|
178
|
+
export const DEPENDENCY_PATHSPEC_EXCLUDES = Object.freeze([
|
|
179
|
+
".",
|
|
180
|
+
...DEPENDENCY_DIRS.map((dir) => `:(exclude,glob)**/${dir}/**`),
|
|
181
|
+
])
|
|
182
|
+
|
|
145
183
|
/**
|
|
146
184
|
* The files a run has changed, from `git status --porcelain --untracked-files=all`
|
|
147
185
|
* and `git diff --name-only` against where the run started. Counting from the
|
|
@@ -160,7 +198,7 @@ export function parseChangedFiles(porcelain, diffNames = "") {
|
|
|
160
198
|
if (line.trim()) files.add(line.trim())
|
|
161
199
|
}
|
|
162
200
|
files.delete("")
|
|
163
|
-
return [...files].sort()
|
|
201
|
+
return [...files].filter((file) => !isDependencyPath(file)).sort()
|
|
164
202
|
}
|
|
165
203
|
|
|
166
204
|
const REPORT_FILE_LIST_MAX = 30
|
|
@@ -259,8 +297,8 @@ function git(cwd, args, onError) {
|
|
|
259
297
|
|
|
260
298
|
/** The files a run changed since `startSha`, committed or not, untracked included. */
|
|
261
299
|
export async function listRunChangedFiles(worktreePath, startSha) {
|
|
262
|
-
const status = await git(worktreePath, ["status", "--porcelain", "--untracked-files=all"])
|
|
263
|
-
const diff = startSha ? await git(worktreePath, ["diff", "--name-only", startSha]) : null
|
|
300
|
+
const status = await git(worktreePath, ["status", "--porcelain", "--untracked-files=all", "--", ...DEPENDENCY_PATHSPEC_EXCLUDES])
|
|
301
|
+
const diff = startSha ? await git(worktreePath, ["diff", "--name-only", startSha, "--", ...DEPENDENCY_PATHSPEC_EXCLUDES]) : null
|
|
264
302
|
return parseChangedFiles(status, diff)
|
|
265
303
|
}
|
|
266
304
|
|
|
@@ -272,11 +310,11 @@ export async function listRunChangedFiles(worktreePath, startSha) {
|
|
|
272
310
|
* `committed` is false with no error when there was nothing to commit.
|
|
273
311
|
*/
|
|
274
312
|
export async function commitStoppedWork(worktreePath, { subject, body }) {
|
|
275
|
-
const dirty = (await git(worktreePath, ["status", "--porcelain"]))?.trim()
|
|
313
|
+
const dirty = (await git(worktreePath, ["status", "--porcelain", "--", ...DEPENDENCY_PATHSPEC_EXCLUDES]))?.trim()
|
|
276
314
|
if (!dirty) return { committed: false, sha: null, error: null }
|
|
277
315
|
let error = null
|
|
278
316
|
const onError = (message) => { error = message.replace(/\s+/g, " ").slice(0, 200) }
|
|
279
|
-
const added = await git(worktreePath, ["add", "-A"], onError)
|
|
317
|
+
const added = await git(worktreePath, ["add", "-A", "--", ...DEPENDENCY_PATHSPEC_EXCLUDES], onError)
|
|
280
318
|
const done = added !== null
|
|
281
319
|
&& await git(worktreePath, ["commit", "--no-verify", "-m", subject, "-m", body, "-m", STOPPED_BY_TRIPWIRE_TRAILER], onError) !== null
|
|
282
320
|
if (!done) return { committed: false, sha: null, error: error || "git commit failed" }
|
package/lib/service.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import path from "node:path"
|
|
|
4
4
|
import process from "node:process"
|
|
5
5
|
import { execFileSync } from "node:child_process"
|
|
6
6
|
import { PACEWORK_DIR, LOG_FILE, USES_LEGACY_DIR } from "./control-state.mjs"
|
|
7
|
+
import { isNewerVersion } from "./version.mjs"
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Run the runner as an OS-managed login service, so it starts at login, restarts
|
|
@@ -230,6 +231,51 @@ WantedBy=default.target
|
|
|
230
231
|
return { kind, file }
|
|
231
232
|
}
|
|
232
233
|
|
|
234
|
+
/**
|
|
235
|
+
* The runner version a service file starts: the `<version>` in the stable copy's
|
|
236
|
+
* path, `.../runner-app/<version>/bin/pacework-runner-ctl.mjs`. Null when the
|
|
237
|
+
* file points somewhere else (an install from before stable copies).
|
|
238
|
+
*/
|
|
239
|
+
export function serviceVersionFromFile(text) {
|
|
240
|
+
const match = String(text || "").match(/runner-app[\\/]+([^\\/<"'\s]+)[\\/]+bin[\\/]+pacework-runner-ctl\.mjs/)
|
|
241
|
+
return match ? match[1] : null
|
|
242
|
+
}
|
|
243
|
+
|
|
244
|
+
/** The runner version the installed login service runs, or null when unknown or not installed. */
|
|
245
|
+
export function installedServiceVersion() {
|
|
246
|
+
const file = serviceFilePath()
|
|
247
|
+
if (!file) return null
|
|
248
|
+
try {
|
|
249
|
+
return serviceVersionFromFile(fs.readFileSync(file, "utf8"))
|
|
250
|
+
} catch {
|
|
251
|
+
return null
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
/**
|
|
256
|
+
* Whether the service should move to `version`. It keeps running the copy `up`
|
|
257
|
+
* saved, so updating the package or restarting left it on the old runner
|
|
258
|
+
* (PWK-307). Never moves it back to an older version: an old copy in npx's
|
|
259
|
+
* cache must not downgrade a newer service.
|
|
260
|
+
*/
|
|
261
|
+
export function serviceNeedsUpdate(installedVersion, version) {
|
|
262
|
+
if (!version) return false
|
|
263
|
+
if (!installedVersion) return true
|
|
264
|
+
return isNewerVersion(version, installedVersion)
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
/**
|
|
268
|
+
* Point the login service at a stable copy of the package in `sourceRoot` and
|
|
269
|
+
* restart it from there. Returns the new control script's path.
|
|
270
|
+
*/
|
|
271
|
+
export function moveServiceTo(sourceRoot, version) {
|
|
272
|
+
stopService()
|
|
273
|
+
const ctlPath = installStableCopy(sourceRoot, version)
|
|
274
|
+
try { installCommandLauncher(ctlPath) } catch {}
|
|
275
|
+
installService({ ctlPath })
|
|
276
|
+
return ctlPath
|
|
277
|
+
}
|
|
278
|
+
|
|
233
279
|
/** Start an installed service that was stopped. */
|
|
234
280
|
export function startService() {
|
|
235
281
|
const kind = serviceKind()
|
package/lib/version.mjs
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import fs from "node:fs"
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* The CLI's own npm package. The update check and `pacework update` both use
|
|
3
5
|
* this name: they used to ask for "pacework-runner", a name nobody owns, so no
|
|
@@ -25,3 +27,14 @@ export async function latestPublishedVersion(fetchImpl = fetch) {
|
|
|
25
27
|
const { version } = await res.json()
|
|
26
28
|
return typeof version === "string" ? version : null
|
|
27
29
|
}
|
|
30
|
+
|
|
31
|
+
/** This package's own version, from its package.json; null when it cannot be read. */
|
|
32
|
+
export const RUNNER_VERSION = (() => {
|
|
33
|
+
try {
|
|
34
|
+
const raw = fs.readFileSync(new URL("../package.json", import.meta.url), "utf8")
|
|
35
|
+
const version = JSON.parse(raw).version
|
|
36
|
+
return typeof version === "string" ? version : null
|
|
37
|
+
} catch {
|
|
38
|
+
return null
|
|
39
|
+
}
|
|
40
|
+
})()
|