@indigoai-us/hq-cli 5.345.208 → 5.345.210
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/CHANGELOG.md +98 -0
- package/assets/scaffold/core/scripts/derive-trigger-facts.sh +22 -3
- package/dist/command-catalog.generated.d.ts +33 -8
- package/dist/command-catalog.generated.js +40 -8
- package/dist/command-registration-plan.d.ts +2 -2
- package/dist/command-registration-plan.js +1 -1
- package/dist/commands/access.js +11 -5
- package/dist/commands/agents.d.ts +8 -0
- package/dist/commands/agents.js +5 -0
- package/dist/commands/bot.d.ts +8 -0
- package/dist/commands/bot.js +67 -7
- package/dist/commands/channels.js +4 -0
- package/dist/commands/cloud.d.ts +83 -2
- package/dist/commands/cloud.js +161 -31
- package/dist/commands/company.d.ts +9 -0
- package/dist/commands/company.js +44 -14
- package/dist/commands/core-checkpoint-native.js +21 -0
- package/dist/commands/core-derive-trigger-facts-native.js +14 -3
- package/dist/commands/core-generate-workers-registry-fast.d.ts +1 -1
- package/dist/commands/core-generate-workers-registry-fast.js +7 -1
- package/dist/commands/core-job-run-native.d.ts +8 -0
- package/dist/commands/core-job-run-native.js +11 -3
- package/dist/commands/core-jobs-native.js +1 -1
- package/dist/commands/core-register-project-native.js +31 -1
- package/dist/commands/core-scan-packages-fast.d.ts +1 -1
- package/dist/commands/core-scan-packages-fast.js +8 -1
- package/dist/commands/core.js +12 -3
- package/dist/commands/dm-attach.d.ts +10 -0
- package/dist/commands/dm-attach.js +33 -5
- package/dist/commands/integrations-connect.js +47 -2
- package/dist/commands/lanes-session-start.d.ts +17 -0
- package/dist/commands/lanes-session-start.js +281 -13
- package/dist/commands/lanes-watch.js +11 -3
- package/dist/commands/lanes.d.ts +4 -0
- package/dist/commands/lanes.js +95 -22
- package/dist/commands/library.d.ts +10 -0
- package/dist/commands/library.js +30 -3
- package/dist/commands/meetings.d.ts +42 -0
- package/dist/commands/meetings.js +157 -12
- package/dist/commands/mesh.js +3 -0
- package/dist/commands/monitor.d.ts +6 -0
- package/dist/commands/monitor.js +29 -19
- package/dist/commands/onboard.js +8 -1
- package/dist/commands/sources.js +7 -3
- package/dist/index.js +9 -0
- package/dist/lanes-monitor-check-argv.d.ts +1 -1
- package/dist/lanes-monitor-check-argv.js +2 -2
- package/dist/lanes-session-start-argv.d.ts +4 -1
- package/dist/lanes-session-start-argv.js +5 -2
- package/dist/lib/bot/fleet-daemon.d.ts +101 -0
- package/dist/lib/bot/fleet-daemon.js +227 -0
- package/dist/lib/bot/fleet-local.d.ts +26 -0
- package/dist/lib/bot/fleet-local.js +51 -2
- package/dist/lib/bot/index.d.ts +1 -0
- package/dist/lib/bot/index.js +1 -0
- package/dist/lib/bot/jobs/hot-signal-sync.d.ts +4 -0
- package/dist/lib/bot/jobs/hot-signal-sync.js +8 -1
- package/dist/lib/bot/log.js +3 -1
- package/dist/lib/bot/probe.js +2 -0
- package/dist/lib/bot/run.js +28 -3
- package/dist/lib/bot/runtime-failure.d.ts +4 -2
- package/dist/lib/bot/runtime-failure.js +9 -1
- package/dist/lib/bot/status.d.ts +17 -0
- package/dist/lib/bot/status.js +53 -2
- package/dist/lib/capacity/collectors/claude-oauth.d.ts +5 -5
- package/dist/lib/capacity/collectors/claude-oauth.js +6 -6
- package/dist/lib/core-utils/native-scaffold-help.d.ts +16 -0
- package/dist/lib/core-utils/native-scaffold-help.js +26 -0
- package/dist/lib/core-utils/session-company.d.ts +25 -8
- package/dist/lib/core-utils/session-company.js +59 -17
- package/dist/lib/daemon/catalog.d.ts +25 -1
- package/dist/lib/daemon/catalog.js +29 -2
- package/dist/lib/daemon/run.d.ts +0 -1
- package/dist/lib/daemon/run.js +3 -11
- package/dist/lib/daemon/server.js +26 -7
- package/dist/lib/daemon/supervisor.js +1 -1
- package/dist/lib/daemon/tools.js +17 -1
- package/dist/lib/db/sqlite-binding.js +2 -1
- package/dist/lib/doctor/checks/bots.d.ts +2 -0
- package/dist/lib/doctor/checks/bots.js +11 -0
- package/dist/lib/doctor/checks/runtime-health.js +3 -2
- package/dist/lib/doctor/checks/work-context.js +5 -2
- package/dist/lib/hook-engine/resolve.d.ts +1 -1
- package/dist/lib/hook-engine/resolve.js +4 -1
- package/dist/lib/hot-channels/adapters/meeting-providers.d.ts +2 -0
- package/dist/lib/hot-channels/adapters/meeting-providers.js +13 -2
- package/dist/lib/lanes/index.d.ts +1 -1
- package/dist/lib/lanes/index.js +1 -1
- package/dist/lib/lanes/monitor.d.ts +14 -0
- package/dist/lib/lanes/monitor.js +51 -10
- package/dist/lib/lanes/outpost-dispatch.d.ts +3 -0
- package/dist/lib/lanes/outpost-dispatch.js +1 -0
- package/dist/lib/lanes/store.d.ts +1 -1
- package/dist/lib/lanes/store.js +2 -1
- package/dist/lib/mesh/client.js +7 -1
- package/dist/lib/mesh/live/backfill-held.d.ts +3 -0
- package/dist/lib/mesh/live/backfill-held.js +167 -7
- package/dist/lib/mesh/live/flush.d.ts +7 -0
- package/dist/lib/mesh/live/flush.js +10 -1
- package/dist/lib/monitor.d.ts +9 -0
- package/dist/lib/monitor.js +33 -7
- package/dist/lib/onboarding/orchestrator.js +269 -132
- package/dist/lib/onboarding/types.d.ts +2 -0
- package/dist/lib/scaffold-cli-floor.js +2 -1
- package/dist/lib/signals/failure-alert.js +3 -1
- package/dist/lib/work-context/organize.d.ts +6 -0
- package/dist/lib/work-context/organize.js +28 -0
- package/dist/lib/work-context/paths.d.ts +9 -0
- package/dist/lib/work-context/paths.js +15 -0
- package/dist/lib/work-context/prd-sync.js +2 -1
- package/dist/runners-alias.d.ts +54 -0
- package/dist/runners-alias.js +86 -0
- package/dist/utils/install-tree-torn.js +5 -3
- package/dist/utils/npm-install-flags.d.ts +27 -0
- package/dist/utils/npm-install-flags.js +68 -0
- package/dist/utils/package-use-lease.js +1 -1
- package/dist/utils/qmd-native-binding-error.js +2 -1
- package/dist/utils/self-update.js +2 -1
- package/dist/utils/staged-install.js +2 -1
- package/dist/utils/staged-npm-install.js +2 -1
- package/dist/utils/upload-author.d.ts +2 -1
- package/dist/utils/upload-author.js +9 -5
- package/dist/utils/version-check.js +2 -1
- package/dist/utils/version-gate.js +7 -6
- package/package.json +7 -7
- package/scripts/install-hook-engine.mjs +7 -3
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* fallback copy told the person to check the sign-in even when the cause was
|
|
9
9
|
* something else. Now every failure is classified here, the person gets one
|
|
10
10
|
* plain sentence plus one next step, and the raw text goes only to the bot
|
|
11
|
-
* log. For
|
|
11
|
+
* log. For repairable classes the DM also carries a machine-readable
|
|
12
12
|
* `runtime-repair` block in its `richContent` so the desktop can render a
|
|
13
13
|
* repair card; the plain body stays the fallback.
|
|
14
14
|
*
|
|
@@ -21,6 +21,7 @@ export const RUNTIME_REPAIR_ACTIONS = {
|
|
|
21
21
|
"cli-outdated": "update",
|
|
22
22
|
"model-unsupported": "switchModel",
|
|
23
23
|
transient: "tryAgain",
|
|
24
|
+
billing: "tryAgain",
|
|
24
25
|
"runtime-crashed": "restart",
|
|
25
26
|
};
|
|
26
27
|
export function isRuntimeRepairClass(cls) {
|
|
@@ -62,6 +63,7 @@ const USAGE_LIMIT = /\byou(?:['’]?ve| have) (?:hit|reached) your (?:[\w'’-]+
|
|
|
62
63
|
const NOT_PLAN_USAGE = /\brate[\s_-]?limit|\b(?:conversation|context|token|output|request|message)(?:[\s_-]+(?:length|window|size))?[\s_-]+limit\b/i;
|
|
63
64
|
/** "9pm (Asia/Dhaka)" from "... · resets 9pm (Asia/Dhaka)". */
|
|
64
65
|
const USAGE_LIMIT_RESET = /\bresets?(?: at| on)? ([^\n|·]{1,60}?)\s*(?:$|[\n|·])/im;
|
|
66
|
+
const BILLING = /\bcredit balance is too low\b|\binsufficient (?:credits|funds|balance|quota)\b|\bpayment required\b|\bbilling\b/i;
|
|
65
67
|
const TRANSIENT = /\brate[_ ]limit|\busage[_ ]limit|\btoo many requests\b|\b429\b|\boverloaded\b|\b(?:502|503|504|529)\b|\bservice unavailable\b|\bbad gateway\b|\bgateway time-?out\b|\binternal server error\b|\bECONNRESET\b|\bECONNREFUSED\b|\bETIMEDOUT\b|\bENOTFOUND\b|\bEAI_AGAIN\b|\bENETUNREACH\b|\bsocket hang up\b|\bnetwork (?:error|is unreachable)\b|\bstream (?:disconnected|error)\b|\bconnection (?:reset|refused|closed|error)\b|\btimed out\b|\bexceeded \d+ms \(HQ_BOT_TURN_TIMEOUT_MS\)/i;
|
|
66
68
|
/** Sort a runtime's failure text into one class. Order matters: most specific first. */
|
|
67
69
|
export function classifyRuntimeFailure(text) {
|
|
@@ -76,6 +78,8 @@ export function classifyRuntimeFailure(text) {
|
|
|
76
78
|
return "signed-out";
|
|
77
79
|
if (MODEL_UNSUPPORTED.test(t))
|
|
78
80
|
return "model-unsupported";
|
|
81
|
+
if (BILLING.test(t))
|
|
82
|
+
return "billing";
|
|
79
83
|
if (TRANSIENT.test(t) || USAGE_LIMIT.test(t))
|
|
80
84
|
return "transient";
|
|
81
85
|
return "unknown";
|
|
@@ -179,6 +183,8 @@ export function runtimeFailureReason(cls, runtime) {
|
|
|
179
183
|
return `my ${tool} app is out of date`;
|
|
180
184
|
case "model-unsupported":
|
|
181
185
|
return `the model I'm set to use isn't available in ${tool} here`;
|
|
186
|
+
case "billing":
|
|
187
|
+
return `${tool} account needs billing attention`;
|
|
182
188
|
case "transient":
|
|
183
189
|
return `${tool} is busy or out of reach right now`;
|
|
184
190
|
case "not-installed":
|
|
@@ -201,6 +207,8 @@ export function runtimeFailureNextStep(cls, runtime, context = "message", botNam
|
|
|
201
207
|
return `Update ${tool}, then send me any message.`;
|
|
202
208
|
case "model-unsupported":
|
|
203
209
|
return `Choose a different model in my settings, then send me any message.`;
|
|
210
|
+
case "billing":
|
|
211
|
+
return `Top up its billing, then send me any message.`;
|
|
204
212
|
case "transient":
|
|
205
213
|
return context === "kickoff"
|
|
206
214
|
? `Send me any message in a few minutes and I'll get started.`
|
package/dist/lib/bot/status.d.ts
CHANGED
|
@@ -132,6 +132,23 @@ export declare function defaultBotStatus(pid: number, runtime: BotRuntimeId, now
|
|
|
132
132
|
export declare function readBotStatus(dir: string): BotStatusFile | null;
|
|
133
133
|
export declare function writeBotStatus(dir: string, status: BotStatusFile): void;
|
|
134
134
|
export declare function patchBotStatus(dir: string, patch: Partial<BotStatusFile>, fallback: () => BotStatusFile, now?: () => Date): BotStatusFile;
|
|
135
|
+
export interface BotStatusWriterOptions {
|
|
136
|
+
now?: () => Date;
|
|
137
|
+
/** A write failed. `first` is true for the first failure of a run of them. */
|
|
138
|
+
onWriteError?: (err: unknown, first: boolean) => void;
|
|
139
|
+
/** A write worked again after one or more failures. */
|
|
140
|
+
onRecovered?: () => void;
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* The running bot's status.json writer. It never throws: status.json is a
|
|
144
|
+
* report, and a failed write (a full disk: ENOSPC) used to throw out of the
|
|
145
|
+
* inbox loop, which ended it while the heartbeat went on, so the bot looked
|
|
146
|
+
* online and read no messages until someone restarted it (feedback
|
|
147
|
+
* b3320cb6). A patch that could not be written is kept and merged into the
|
|
148
|
+
* next write, so status.json catches up on its own once the disk has room.
|
|
149
|
+
* Returns what status.json holds now, or would hold if the write had worked.
|
|
150
|
+
*/
|
|
151
|
+
export declare function createBotStatusWriter(dir: string, fallback: () => BotStatusFile, opts?: BotStatusWriterOptions): (patch: Partial<BotStatusFile>) => BotStatusFile;
|
|
135
152
|
/** A coding-tool crash the bot has not recovered from yet (see `runtimeCrashSinceStart`). */
|
|
136
153
|
export interface RuntimeCrash {
|
|
137
154
|
at: string;
|
package/dist/lib/bot/status.js
CHANGED
|
@@ -37,8 +37,20 @@ export function writeBotStatus(dir, status) {
|
|
|
37
37
|
fs.mkdirSync(dir, { recursive: true, mode: 0o700 });
|
|
38
38
|
const dest = botStatusPath(dir);
|
|
39
39
|
const tmp = path.join(dir, `.status.tmp.${process.pid}.${Date.now()}`);
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
try {
|
|
41
|
+
fs.writeFileSync(tmp, `${JSON.stringify(status, null, 2)}\n`, { mode: 0o600 });
|
|
42
|
+
fs.renameSync(tmp, dest);
|
|
43
|
+
}
|
|
44
|
+
catch (err) {
|
|
45
|
+
// A full disk can leave an empty temp file behind; never let it pile up.
|
|
46
|
+
try {
|
|
47
|
+
fs.unlinkSync(tmp);
|
|
48
|
+
}
|
|
49
|
+
catch {
|
|
50
|
+
/* it was never created */
|
|
51
|
+
}
|
|
52
|
+
throw err;
|
|
53
|
+
}
|
|
42
54
|
}
|
|
43
55
|
export function patchBotStatus(dir, patch, fallback, now = () => new Date()) {
|
|
44
56
|
const current = readBotStatus(dir) ?? fallback();
|
|
@@ -51,6 +63,45 @@ export function patchBotStatus(dir, patch, fallback, now = () => new Date()) {
|
|
|
51
63
|
writeBotStatus(dir, next);
|
|
52
64
|
return next;
|
|
53
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* The running bot's status.json writer. It never throws: status.json is a
|
|
68
|
+
* report, and a failed write (a full disk: ENOSPC) used to throw out of the
|
|
69
|
+
* inbox loop, which ended it while the heartbeat went on, so the bot looked
|
|
70
|
+
* online and read no messages until someone restarted it (feedback
|
|
71
|
+
* b3320cb6). A patch that could not be written is kept and merged into the
|
|
72
|
+
* next write, so status.json catches up on its own once the disk has room.
|
|
73
|
+
* Returns what status.json holds now, or would hold if the write had worked.
|
|
74
|
+
*/
|
|
75
|
+
export function createBotStatusWriter(dir, fallback, opts = {}) {
|
|
76
|
+
const now = opts.now ?? (() => new Date());
|
|
77
|
+
let held = null;
|
|
78
|
+
// The last status this writer wrote: the base when the file cannot be read.
|
|
79
|
+
let last = null;
|
|
80
|
+
const base = () => last ?? fallback();
|
|
81
|
+
return (patch) => {
|
|
82
|
+
const merged = held ? { ...held, ...patch } : patch;
|
|
83
|
+
try {
|
|
84
|
+
const next = patchBotStatus(dir, merged, base, now);
|
|
85
|
+
last = next;
|
|
86
|
+
if (held) {
|
|
87
|
+
held = null;
|
|
88
|
+
opts.onRecovered?.();
|
|
89
|
+
}
|
|
90
|
+
return next;
|
|
91
|
+
}
|
|
92
|
+
catch (err) {
|
|
93
|
+
const first = held === null;
|
|
94
|
+
held = merged;
|
|
95
|
+
try {
|
|
96
|
+
opts.onWriteError?.(err, first);
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
/* reporting must not throw either */
|
|
100
|
+
}
|
|
101
|
+
return { ...(readBotStatus(dir) ?? base()), ...merged, v: 1, updatedAt: now().toISOString() };
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
}
|
|
54
105
|
/**
|
|
55
106
|
* The coding tool crashed before its turn started, in this bot process, and
|
|
56
107
|
* no turn has worked since. Null when there is no such crash: none recorded,
|
|
@@ -219,7 +219,7 @@ export interface CollectClaudeOAuthOptions {
|
|
|
219
219
|
* preserving all sibling fields (including `mcpOAuth`).
|
|
220
220
|
*/
|
|
221
221
|
writeCredentials?: WriteClaudeCredentials;
|
|
222
|
-
/** Returns homes that live lanes are using. Default implementation reads `hq
|
|
222
|
+
/** Returns homes that live lanes are using. Default implementation reads `hq runners list --json`. */
|
|
223
223
|
listLiveLanes?: ListLiveLanes;
|
|
224
224
|
/** Returns processes whose `CLAUDE_CONFIG_DIR` identifies a home. Default reads `ps -ewwo pid,command`. */
|
|
225
225
|
listProcesses?: ListProcesses;
|
|
@@ -319,7 +319,7 @@ export declare function isRefreshTokenRevoked(root: string, refreshToken: string
|
|
|
319
319
|
*/
|
|
320
320
|
export declare function revokedMarkerForCurrentCredential(root: string, accountId: string, refreshToken: string | null | undefined): "match" | "stale" | "none";
|
|
321
321
|
/**
|
|
322
|
-
* Shape of a single lane row emitted by `hq
|
|
322
|
+
* Shape of a single lane row emitted by `hq runners list --json`.
|
|
323
323
|
* See src/commands/lanes.ts (withoutProviderHome strips `provider_home_at_spawn`
|
|
324
324
|
* from CLI output; we must consult the accounts registry to map
|
|
325
325
|
* account id -> effective_home).
|
|
@@ -367,12 +367,12 @@ export declare function execHqJson(args: readonly string[], invocation?: {
|
|
|
367
367
|
args: string[];
|
|
368
368
|
}, env?: NodeJS.ProcessEnv): Promise<unknown>;
|
|
369
369
|
/**
|
|
370
|
-
* Parse `hq
|
|
370
|
+
* Parse `hq runners list --json` payload into typed rows.
|
|
371
371
|
* Exported for tests; fail-closed semantics live in defaultListLiveLanes.
|
|
372
372
|
*/
|
|
373
373
|
export declare function parseLanesListPayload(payload: unknown): readonly RawLaneRow[];
|
|
374
374
|
/**
|
|
375
|
-
* Parse `hq
|
|
375
|
+
* Parse `hq runners accounts list --json` payload into typed rows.
|
|
376
376
|
* Exported for tests; fail-closed semantics live in defaultListLiveLanes.
|
|
377
377
|
*/
|
|
378
378
|
export declare function parseAccountsListPayload(payload: unknown): readonly RawAccountRow[];
|
|
@@ -383,7 +383,7 @@ export declare function parseAccountsListPayload(payload: unknown): readonly Raw
|
|
|
383
383
|
export declare function buildLiveLanesFromPayloads(lanes: readonly RawLaneRow[], accounts: readonly RawAccountRow[]): readonly LiveLane[];
|
|
384
384
|
/**
|
|
385
385
|
* Share one lane read across every home in a collect. Without this each expired home ran its
|
|
386
|
-
* own pair of `hq
|
|
386
|
+
* own pair of `hq runners ... --json` reads, so one slow machine turned into N timeouts per
|
|
387
387
|
* collect. A failure is shared too: the next home fails closed without waiting again.
|
|
388
388
|
* Exported for tests.
|
|
389
389
|
*/
|
|
@@ -1788,7 +1788,7 @@ export function execHqJson(args, invocation = resolveHqInvocation(), env = proce
|
|
|
1788
1788
|
// load (load average ~95 on 18 cores) the same read took 16-18 s, so 15 s still failed the
|
|
1789
1789
|
// gate closed on every collect and every Claude home stayed expired.
|
|
1790
1790
|
timeout: HQ_JSON_TIMEOUT_MS,
|
|
1791
|
-
// `hq
|
|
1791
|
+
// `hq runners list --json` grows with lane history (6.8 MB on a busy machine). The 1 MiB
|
|
1792
1792
|
// default made the live-lane gate fail closed on every collect.
|
|
1793
1793
|
maxBuffer: HQ_JSON_MAX_BUFFER_BYTES,
|
|
1794
1794
|
// SIGTERM can be trapped, and execFile waits for the child to exit before calling back.
|
|
@@ -1829,7 +1829,7 @@ export function execHqJson(args, invocation = resolveHqInvocation(), env = proce
|
|
|
1829
1829
|
});
|
|
1830
1830
|
}
|
|
1831
1831
|
/**
|
|
1832
|
-
* Parse `hq
|
|
1832
|
+
* Parse `hq runners list --json` payload into typed rows.
|
|
1833
1833
|
* Exported for tests; fail-closed semantics live in defaultListLiveLanes.
|
|
1834
1834
|
*/
|
|
1835
1835
|
export function parseLanesListPayload(payload) {
|
|
@@ -1849,7 +1849,7 @@ export function parseLanesListPayload(payload) {
|
|
|
1849
1849
|
return out;
|
|
1850
1850
|
}
|
|
1851
1851
|
/**
|
|
1852
|
-
* Parse `hq
|
|
1852
|
+
* Parse `hq runners accounts list --json` payload into typed rows.
|
|
1853
1853
|
* Exported for tests; fail-closed semantics live in defaultListLiveLanes.
|
|
1854
1854
|
*/
|
|
1855
1855
|
export function parseAccountsListPayload(payload) {
|
|
@@ -1918,8 +1918,8 @@ const defaultListLiveLanes = async () => {
|
|
|
1918
1918
|
const env = { ...process.env, [REMOTE_LANE_READ_ENV]: "1" };
|
|
1919
1919
|
const invocation = resolveHqInvocation();
|
|
1920
1920
|
const [lanesPayload, accountsPayload] = await Promise.all([
|
|
1921
|
-
execHqJson(["
|
|
1922
|
-
execHqJson(["
|
|
1921
|
+
execHqJson(["runners", "list", "--json"], invocation, env),
|
|
1922
|
+
execHqJson(["runners", "accounts", "list", "--json"], invocation, env),
|
|
1923
1923
|
]);
|
|
1924
1924
|
const lanes = parseLanesListPayload(lanesPayload);
|
|
1925
1925
|
const accounts = parseAccountsListPayload(accountsPayload);
|
|
@@ -1927,7 +1927,7 @@ const defaultListLiveLanes = async () => {
|
|
|
1927
1927
|
};
|
|
1928
1928
|
/**
|
|
1929
1929
|
* Share one lane read across every home in a collect. Without this each expired home ran its
|
|
1930
|
-
* own pair of `hq
|
|
1930
|
+
* own pair of `hq runners ... --json` reads, so one slow machine turned into N timeouts per
|
|
1931
1931
|
* collect. A failure is shared too: the next home fails closed without waiting again.
|
|
1932
1932
|
* Exported for tests.
|
|
1933
1933
|
*/
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared `--help` handling for the native scaffold commands
|
|
3
|
+
* (`hq core scan-packages`, `hq core generate-workers-registry`).
|
|
4
|
+
*
|
|
5
|
+
* Both the native fast routes (src/commands/core-*-fast.ts) and the commander
|
|
6
|
+
* route (src/commands/core.ts) print the same usage text from here. It lives in
|
|
7
|
+
* src/lib so the fast routes can import it without loading another command
|
|
8
|
+
* module, which the fast-path import guard forbids (feedback_83ae2e72).
|
|
9
|
+
*/
|
|
10
|
+
export declare const SCAN_PACKAGES_SUMMARY = "Wire installed content-pack contributions";
|
|
11
|
+
export declare const GENERATE_WORKERS_REGISTRY_SUMMARY = "Regenerate the derived workers registry";
|
|
12
|
+
/** True when the caller asked for help (`--help` / `-h`) before any `--`. */
|
|
13
|
+
export declare function isNativeScaffoldHelpRequest(args: readonly string[]): boolean;
|
|
14
|
+
/** Usage text for a native scaffold command; printing it changes nothing on disk. */
|
|
15
|
+
export declare function nativeScaffoldUsage(name: string, summary: string): string;
|
|
16
|
+
//# sourceMappingURL=native-scaffold-help.d.ts.map
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared `--help` handling for the native scaffold commands
|
|
3
|
+
* (`hq core scan-packages`, `hq core generate-workers-registry`).
|
|
4
|
+
*
|
|
5
|
+
* Both the native fast routes (src/commands/core-*-fast.ts) and the commander
|
|
6
|
+
* route (src/commands/core.ts) print the same usage text from here. It lives in
|
|
7
|
+
* src/lib so the fast routes can import it without loading another command
|
|
8
|
+
* module, which the fast-path import guard forbids (feedback_83ae2e72).
|
|
9
|
+
*/
|
|
10
|
+
export const SCAN_PACKAGES_SUMMARY = "Wire installed content-pack contributions";
|
|
11
|
+
export const GENERATE_WORKERS_REGISTRY_SUMMARY = "Regenerate the derived workers registry";
|
|
12
|
+
/** True when the caller asked for help (`--help` / `-h`) before any `--`. */
|
|
13
|
+
export function isNativeScaffoldHelpRequest(args) {
|
|
14
|
+
for (const arg of args) {
|
|
15
|
+
if (arg === "--")
|
|
16
|
+
return false;
|
|
17
|
+
if (arg === "--help" || arg === "-h")
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
/** Usage text for a native scaffold command; printing it changes nothing on disk. */
|
|
23
|
+
export function nativeScaffoldUsage(name, summary) {
|
|
24
|
+
return `Usage: hq core ${name}\n\n${summary}\n\nOptions:\n -h, --help Show this help and exit without running\n`;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=native-scaffold-help.js.map
|
|
@@ -1,14 +1,31 @@
|
|
|
1
1
|
/** Reads the active session's company lock without importing the full hq-session command. */
|
|
2
2
|
export declare function sessionCompanySlugs(root: string, env?: NodeJS.ProcessEnv, multiCompanyLockEnabled?: boolean): string[];
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
4
|
+
* Whether the multi-company session lock is on for a session whose primary
|
|
5
|
+
* company is `primary`, as hq-session.sh last recorded it. hq-session.sh
|
|
6
|
+
* (session_scope_multi_company_enabled) evaluates hooks.multi-company-session-lock
|
|
7
|
+
* scoped to the primary company and caches the answer in
|
|
8
|
+
* ~/.hq/hook-flag.multi-company-session-lock.<primary> as "<true|false> <epoch>".
|
|
9
|
+
* The flag is a kill switch: hq-session.sh treats a missing or unreadable
|
|
10
|
+
* record as on, so only a well-formed "false" record turns the lock off here.
|
|
11
|
+
*/
|
|
12
|
+
export declare function multiCompanySessionLockRecordedOn(primary: string, env?: NodeJS.ProcessEnv): boolean;
|
|
13
|
+
/**
|
|
14
|
+
* The companies a session bound itself to, from
|
|
15
|
+
* workspace/sessions/<sessionId>/meta.yaml: `company_slug` first, then any
|
|
16
|
+
* other company its `company_slugs` lock lists (`hq-session.sh add company`).
|
|
17
|
+
* This is the bind a company bot's runner and `hq-session.sh` write, and that
|
|
18
|
+
* the HQ hooks read. `company_slugs` counts only while the multi-company
|
|
19
|
+
* session lock is on for the session's primary company, as hq-session.sh
|
|
20
|
+
* recorded it; with the lock off only `company_slug` counts, the same as
|
|
21
|
+
* `hq-session.sh get company_slugs`.
|
|
8
22
|
*
|
|
9
|
-
* Returns
|
|
10
|
-
*
|
|
11
|
-
*
|
|
23
|
+
* Returns [] unless `company_slug` names a real (non-symlink) directory under
|
|
24
|
+
* companies/. Listed companies that are not real directories are dropped.
|
|
25
|
+
* hqd's own synthetic `hqd-*` check sessions are ignored, so a caller cannot
|
|
26
|
+
* borrow the binding hqd wrote for a different check. The session folder and
|
|
27
|
+
* its meta.yaml must both be real entries, not symlinks: a symlinked session
|
|
28
|
+
* folder could point at any meta.yaml on disk (feedback_76cb8dc3).
|
|
12
29
|
*/
|
|
13
|
-
export declare function
|
|
30
|
+
export declare function sessionMetaCompanies(root: string, sessionId: string, env?: NodeJS.ProcessEnv): string[];
|
|
14
31
|
//# sourceMappingURL=session-company.d.ts.map
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import * as fs from "node:fs";
|
|
2
|
+
import * as os from "node:os";
|
|
2
3
|
import * as path from "node:path";
|
|
3
4
|
import { resolveSessionId } from "./session-id.js";
|
|
4
5
|
function metaValue(contents, key) {
|
|
@@ -75,38 +76,79 @@ export function sessionCompanySlugs(root, env = process.env, multiCompanyLockEna
|
|
|
75
76
|
}
|
|
76
77
|
return listedCompanySlugs(contents).filter((slug) => slug === "personal" || isExactCompanyDirectory(root, slug));
|
|
77
78
|
}
|
|
79
|
+
/**
|
|
80
|
+
* Whether the multi-company session lock is on for a session whose primary
|
|
81
|
+
* company is `primary`, as hq-session.sh last recorded it. hq-session.sh
|
|
82
|
+
* (session_scope_multi_company_enabled) evaluates hooks.multi-company-session-lock
|
|
83
|
+
* scoped to the primary company and caches the answer in
|
|
84
|
+
* ~/.hq/hook-flag.multi-company-session-lock.<primary> as "<true|false> <epoch>".
|
|
85
|
+
* The flag is a kill switch: hq-session.sh treats a missing or unreadable
|
|
86
|
+
* record as on, so only a well-formed "false" record turns the lock off here.
|
|
87
|
+
*/
|
|
88
|
+
export function multiCompanySessionLockRecordedOn(primary, env = process.env) {
|
|
89
|
+
if (!/^[A-Za-z0-9_-]+$/.test(primary))
|
|
90
|
+
return true;
|
|
91
|
+
const home = env.HOME || os.homedir();
|
|
92
|
+
if (!home)
|
|
93
|
+
return true;
|
|
94
|
+
let record;
|
|
95
|
+
try {
|
|
96
|
+
record = fs.readFileSync(path.join(home, ".hq", `hook-flag.multi-company-session-lock.${primary}`), "utf8");
|
|
97
|
+
}
|
|
98
|
+
catch {
|
|
99
|
+
return true;
|
|
100
|
+
}
|
|
101
|
+
return !/^false [0-9]+\r?\n?$/.test(record);
|
|
102
|
+
}
|
|
78
103
|
/** A caller session id that is safe to use as one path segment. */
|
|
79
104
|
const SESSION_DIR_RE = /^[A-Za-z0-9][A-Za-z0-9._-]{0,199}$/;
|
|
80
105
|
/**
|
|
81
|
-
* The
|
|
82
|
-
* workspace/sessions/<sessionId>/meta.yaml `company_slug
|
|
83
|
-
* company
|
|
84
|
-
*
|
|
106
|
+
* The companies a session bound itself to, from
|
|
107
|
+
* workspace/sessions/<sessionId>/meta.yaml: `company_slug` first, then any
|
|
108
|
+
* other company its `company_slugs` lock lists (`hq-session.sh add company`).
|
|
109
|
+
* This is the bind a company bot's runner and `hq-session.sh` write, and that
|
|
110
|
+
* the HQ hooks read. `company_slugs` counts only while the multi-company
|
|
111
|
+
* session lock is on for the session's primary company, as hq-session.sh
|
|
112
|
+
* recorded it; with the lock off only `company_slug` counts, the same as
|
|
113
|
+
* `hq-session.sh get company_slugs`.
|
|
85
114
|
*
|
|
86
|
-
* Returns
|
|
87
|
-
*
|
|
88
|
-
*
|
|
115
|
+
* Returns [] unless `company_slug` names a real (non-symlink) directory under
|
|
116
|
+
* companies/. Listed companies that are not real directories are dropped.
|
|
117
|
+
* hqd's own synthetic `hqd-*` check sessions are ignored, so a caller cannot
|
|
118
|
+
* borrow the binding hqd wrote for a different check. The session folder and
|
|
119
|
+
* its meta.yaml must both be real entries, not symlinks: a symlinked session
|
|
120
|
+
* folder could point at any meta.yaml on disk (feedback_76cb8dc3).
|
|
89
121
|
*/
|
|
90
|
-
export function
|
|
122
|
+
export function sessionMetaCompanies(root, sessionId, env = process.env) {
|
|
91
123
|
if (!SESSION_DIR_RE.test(sessionId) || sessionId.includes("..") || sessionId.startsWith("hqd-"))
|
|
92
|
-
return
|
|
93
|
-
const
|
|
124
|
+
return [];
|
|
125
|
+
const sessionDir = path.join(root, "workspace", "sessions", sessionId);
|
|
126
|
+
const metaPath = path.join(sessionDir, "meta.yaml");
|
|
94
127
|
let contents;
|
|
95
128
|
try {
|
|
129
|
+
const dirStat = fs.lstatSync(sessionDir);
|
|
130
|
+
if (dirStat.isSymbolicLink() || !dirStat.isDirectory())
|
|
131
|
+
return [];
|
|
96
132
|
const stat = fs.lstatSync(metaPath);
|
|
97
133
|
if (!stat.isFile())
|
|
98
|
-
return
|
|
99
|
-
contents = fs.readFileSync(metaPath, "utf8");
|
|
134
|
+
return [];
|
|
135
|
+
contents = fs.readFileSync(metaPath, "utf8").replace(/\r$/gm, "");
|
|
100
136
|
}
|
|
101
137
|
catch (error) {
|
|
102
138
|
const code = error.code;
|
|
103
139
|
if (code === "ENOENT" || code === "ENOTDIR" || code === "EACCES" || code === "ELOOP")
|
|
104
|
-
return
|
|
140
|
+
return [];
|
|
105
141
|
throw error;
|
|
106
142
|
}
|
|
107
|
-
const
|
|
108
|
-
if (!
|
|
109
|
-
return
|
|
110
|
-
|
|
143
|
+
const primary = metaValue(contents, "company_slug");
|
|
144
|
+
if (!primary || primary === "personal" || !/^[A-Za-z0-9_-]+$/.test(primary))
|
|
145
|
+
return [];
|
|
146
|
+
if (!isExactCompanyDirectory(root, primary))
|
|
147
|
+
return [];
|
|
148
|
+
if (!multiCompanySessionLockRecordedOn(primary, env))
|
|
149
|
+
return [primary];
|
|
150
|
+
const others = listedCompanySlugs(contents)
|
|
151
|
+
.filter((slug) => slug !== primary && slug !== "personal" && isExactCompanyDirectory(root, slug));
|
|
152
|
+
return [primary, ...others];
|
|
111
153
|
}
|
|
112
154
|
//# sourceMappingURL=session-company.js.map
|
|
@@ -77,6 +77,10 @@ export interface UnitPlan {
|
|
|
77
77
|
drainSignal?: "SIGUSR2";
|
|
78
78
|
/** A new CLI version alone does not restart this unit; it restarts itself when idle. */
|
|
79
79
|
keepAcrossCliUpdates?: true;
|
|
80
|
+
/** Working directory for the process; the HQ folder, else the home folder, when absent. */
|
|
81
|
+
cwd?: string;
|
|
82
|
+
/** How long after SIGTERM the unit may keep running before SIGKILL; the supervisor's default when absent. */
|
|
83
|
+
stopGraceMs?: number;
|
|
80
84
|
/**
|
|
81
85
|
* Scheduled units only: before each timed run the supervisor asks
|
|
82
86
|
* `SupervisorDeps.runGuard` whether there is work. `spawn` runs as usual,
|
|
@@ -92,6 +96,26 @@ export interface SyncCoreRunning {
|
|
|
92
96
|
personal: boolean;
|
|
93
97
|
companies: ReadonlySet<string>;
|
|
94
98
|
}
|
|
99
|
+
/** An HQ Fleet bot on this machine, as the daemon sees it (see bot/fleet-daemon.ts). */
|
|
100
|
+
export interface FleetBotPlan {
|
|
101
|
+
name: string;
|
|
102
|
+
/** The gateway process, or null while the bot's HQ Fleet runtime is not fully installed. */
|
|
103
|
+
gateway: {
|
|
104
|
+
file: string;
|
|
105
|
+
args: string[];
|
|
106
|
+
env: Record<string, string>;
|
|
107
|
+
cwd: string;
|
|
108
|
+
} | null;
|
|
109
|
+
/** `hq bot auth <name>` has not run yet. */
|
|
110
|
+
authPending: boolean;
|
|
111
|
+
/** `hq bot start <name>` has not run yet. */
|
|
112
|
+
installPending: boolean;
|
|
113
|
+
/** The runtime's own LaunchAgent still exists (it could not be retired), by label. */
|
|
114
|
+
legacyAgent?: string;
|
|
115
|
+
/** A gateway for this bot started outside the daemon is still running; it has been asked to exit. */
|
|
116
|
+
outsideGateway?: number;
|
|
117
|
+
}
|
|
118
|
+
export declare const FLEET_BOT_STOP_GRACE_MS = 30000;
|
|
95
119
|
export declare const FLEET_BOTS_UPDATE_UNIT = "fleet-bots-update";
|
|
96
120
|
export declare const FLEET_BOTS_UPDATE_INTERVAL_SEC: number;
|
|
97
121
|
export declare const FLEET_BOTS_UPDATE_INITIAL_DELAY_SEC = 120;
|
|
@@ -154,7 +178,7 @@ export interface PlanContext {
|
|
|
154
178
|
/** ~/.hq-agent/kit.json exists. */
|
|
155
179
|
kitConfigured: boolean;
|
|
156
180
|
bots: readonly string[];
|
|
157
|
-
fleetBots?: readonly
|
|
181
|
+
fleetBots?: readonly FleetBotPlan[];
|
|
158
182
|
/** Name of a pre-daemon unit that still runs this unit id, or null. */
|
|
159
183
|
legacyOwner: (unitId: string) => string | null;
|
|
160
184
|
/** This CLI is a global install the updater can replace (not a project dependency). */
|
|
@@ -92,6 +92,7 @@ export function enabledServices(machineType, overrides) {
|
|
|
92
92
|
};
|
|
93
93
|
return SERVICE_NAMES.filter((s) => wanted(s) || implied(s));
|
|
94
94
|
}
|
|
95
|
+
export const FLEET_BOT_STOP_GRACE_MS = 30_000;
|
|
95
96
|
export const FLEET_BOTS_UPDATE_UNIT = "fleet-bots-update";
|
|
96
97
|
export const FLEET_BOTS_UPDATE_INTERVAL_SEC = 30 * 60;
|
|
97
98
|
export const FLEET_BOTS_UPDATE_INITIAL_DELAY_SEC = 120;
|
|
@@ -203,6 +204,9 @@ function planService(service, ctx) {
|
|
|
203
204
|
...ctx.legacySyncEnv,
|
|
204
205
|
...(vaultSync ? vaultSkipEnv(vaultSync) : {}),
|
|
205
206
|
HQ_SYNC_PASS_REQUEST_DIR: ctx.syncPassRequestsDir,
|
|
207
|
+
// feedback_65ee9e51: nobody watches an Outpost or agent machine's
|
|
208
|
+
// sync, so hq-cloud holds deletes of files other members created.
|
|
209
|
+
...(ctx.machineType === "outpost" || agentMachine ? { HQ_SYNC_UNATTENDED: "1" } : {}),
|
|
206
210
|
},
|
|
207
211
|
heartbeatTimeoutMs: ctx.syncHeartbeatTimeoutMs,
|
|
208
212
|
blocked: commonBlock,
|
|
@@ -352,7 +356,29 @@ function planService(service, ctx) {
|
|
|
352
356
|
}),
|
|
353
357
|
]
|
|
354
358
|
: [];
|
|
355
|
-
|
|
359
|
+
// On macOS the daemon runs each HQ Fleet gateway itself, so no bot needs
|
|
360
|
+
// its own login item (macOS reports each as "python" from an unknown
|
|
361
|
+
// developer). Elsewhere the runtime's own service manager keeps them.
|
|
362
|
+
const fleetUnits = ctx.platform === "darwin"
|
|
363
|
+
? (ctx.fleetBots ?? []).map((bot) => base(service, {
|
|
364
|
+
id: `fleet-bots:${bot.name}`,
|
|
365
|
+
description: `runs the HQ Fleet bot ${bot.name}`,
|
|
366
|
+
restart: "always",
|
|
367
|
+
command: bot.gateway ? { type: "exec", file: bot.gateway.file, args: bot.gateway.args } : null,
|
|
368
|
+
env: bot.gateway?.env ?? {},
|
|
369
|
+
...(bot.gateway ? { cwd: bot.gateway.cwd } : {}),
|
|
370
|
+
// The gateway finishes the reply it is sending before it exits; its own LaunchAgent gave it 25 s.
|
|
371
|
+
stopGraceMs: FLEET_BOT_STOP_GRACE_MS,
|
|
372
|
+
blocked: firstBlock([
|
|
373
|
+
[bot.authPending, `not signed in (run \`hq bot auth ${bot.name}\`)`],
|
|
374
|
+
[bot.installPending, `waiting for \`hq bot start ${bot.name}\``],
|
|
375
|
+
[bot.gateway === null, `the HQ Fleet runtime is not installed for ${bot.name} (run \`hq bot start ${bot.name}\`)`],
|
|
376
|
+
[bot.legacyAgent !== undefined, `still started by its own login item ${bot.legacyAgent} (run \`hq bot start ${bot.name}\`)`],
|
|
377
|
+
[bot.outsideGateway !== undefined, `waiting for its gateway started outside hq daemon (pid ${bot.outsideGateway}) to exit`],
|
|
378
|
+
]),
|
|
379
|
+
}))
|
|
380
|
+
: [];
|
|
381
|
+
if (ctx.bots.length === 0 && fleetUnits.length === 0) {
|
|
356
382
|
return fleetWatch.length > 0 ? fleetWatch : [base(service, { blocked: { state: "waiting", reason: "no local bots" } })];
|
|
357
383
|
}
|
|
358
384
|
return [
|
|
@@ -364,6 +390,7 @@ function planService(service, ctx) {
|
|
|
364
390
|
// A bot drains on SIGUSR2: running turns finish, then it exits.
|
|
365
391
|
drainSignal: "SIGUSR2",
|
|
366
392
|
})),
|
|
393
|
+
...fleetUnits,
|
|
367
394
|
...fleetWatch,
|
|
368
395
|
];
|
|
369
396
|
}
|
|
@@ -390,7 +417,7 @@ function planService(service, ctx) {
|
|
|
390
417
|
// timer for due keep-alive work, avoiding a fresh CLI process per poll.
|
|
391
418
|
intervalSec: 15,
|
|
392
419
|
initialDelaySec: 30,
|
|
393
|
-
command: { type: "hq", args: ["
|
|
420
|
+
command: { type: "hq", args: ["runners", "reconcile"] },
|
|
394
421
|
env: ctx.hqRoot ? { HQ_ROOT: ctx.hqRoot } : {},
|
|
395
422
|
...(ctx.machineType === "desktop"
|
|
396
423
|
? { runGuard: { name: "lanes-reconcile", idleIntervalSec: 60 } }
|
package/dist/lib/daemon/run.d.ts
CHANGED
|
@@ -101,7 +101,6 @@ export declare function daemonInstantSyncEnabled(env: NodeJS.ProcessEnv, configu
|
|
|
101
101
|
* background service, so it is not one of them.
|
|
102
102
|
*/
|
|
103
103
|
export declare function listLocalBots(root?: string): string[];
|
|
104
|
-
export declare function listFleetRuntimeBots(root?: string): string[];
|
|
105
104
|
/** Whose task `taskName` is: only the current user's own task may be taken over. */
|
|
106
105
|
export declare function windowsTaskOwner(taskName: string): WindowsTaskOwner;
|
|
107
106
|
export declare function probeLegacyUnits(platform: NodeJS.Platform, home: string): LegacyUnit[];
|
package/dist/lib/daemon/run.js
CHANGED
|
@@ -19,6 +19,7 @@ import { currentPackageUseLeaseInstall, currentPackageUseUpdateRequested } from
|
|
|
19
19
|
import { isLocalDependencyInstall, resolveRunningInstall } from "../../utils/version-gate.js";
|
|
20
20
|
import { agentKitPaths } from "../agent-kit/paths.js";
|
|
21
21
|
import { HQ_FLEET_RUNTIME_ENGINE_ID, readBotConfig } from "../bot/config.js";
|
|
22
|
+
import { planFleetBots } from "../bot/fleet-daemon.js";
|
|
22
23
|
import { botsRoot } from "../bot/paths.js";
|
|
23
24
|
import { CLAUDE_RUNNER_SCRIPT, CODEX_RUNNER_SCRIPT, enabledServices, planUnits } from "./catalog.js";
|
|
24
25
|
import { effectiveSyncOwner, readDaemonConfig } from "./config.js";
|
|
@@ -359,15 +360,6 @@ export function listLocalBots(root = botsRoot()) {
|
|
|
359
360
|
.map((d) => d.name)
|
|
360
361
|
.sort();
|
|
361
362
|
}
|
|
362
|
-
export function listFleetRuntimeBots(root = botsRoot()) {
|
|
363
|
-
if (!fs.existsSync(root))
|
|
364
|
-
return [];
|
|
365
|
-
return fs
|
|
366
|
-
.readdirSync(root, { withFileTypes: true })
|
|
367
|
-
.filter((d) => d.isDirectory() && readBotConfig(path.join(root, d.name))?.engine?.id === HQ_FLEET_RUNTIME_ENGINE_ID)
|
|
368
|
-
.map((d) => d.name)
|
|
369
|
-
.sort();
|
|
370
|
-
}
|
|
371
363
|
/** Whose task `taskName` is: only the current user's own task may be taken over. */
|
|
372
364
|
export function windowsTaskOwner(taskName) {
|
|
373
365
|
const run = (cmd, args) => {
|
|
@@ -1153,7 +1145,7 @@ export async function runDaemon(opts) {
|
|
|
1153
1145
|
!appManagesSync && Boolean(hqRoot && isSignedIn && runners.syncRunner),
|
|
1154
1146
|
syncHeartbeatTimeoutMs: syncHeartbeatTimeoutMs(env),
|
|
1155
1147
|
bots: listLocalBots(),
|
|
1156
|
-
fleetBots:
|
|
1148
|
+
fleetBots: planFleetBots({ platform, home, env, log: (message) => log("info", message) }),
|
|
1157
1149
|
legacyOwner: legacyOwnerLookup(legacy),
|
|
1158
1150
|
cliSelfUpdatable: updatable,
|
|
1159
1151
|
claudePath: findUserBinary("claude", env, home),
|
|
@@ -1197,7 +1189,7 @@ export async function runDaemon(opts) {
|
|
|
1197
1189
|
: [command.file, command.args];
|
|
1198
1190
|
[file, args] = backgroundQosCommand([file, args], unit.backgroundQos === true);
|
|
1199
1191
|
const logPath = paths.unitLogPath(unit.id);
|
|
1200
|
-
const cwd = unit.env.HQ_ROOT && fs.existsSync(unit.env.HQ_ROOT) ? unit.env.HQ_ROOT : home;
|
|
1192
|
+
const cwd = unit.cwd && fs.existsSync(unit.cwd) ? unit.cwd : unit.env.HQ_ROOT && fs.existsSync(unit.env.HQ_ROOT) ? unit.env.HQ_ROOT : home;
|
|
1201
1193
|
const childEnv = daemonChildOwnershipEnv(env, unit, succession ? succession.handoffPath : null);
|
|
1202
1194
|
const trackOwner = command.type === "hq";
|
|
1203
1195
|
if (unit.heartbeatTimeoutMs && succession) {
|