@indigoai-us/hq-cli 5.345.207 → 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 +105 -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/commands/storage-offload.d.ts +3 -2
- package/dist/commands/storage-offload.js +30 -16
- package/dist/commands/storage.js +2 -1
- 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
package/dist/lib/bot/index.d.ts
CHANGED
|
@@ -26,6 +26,7 @@ export * from "./lock.js";
|
|
|
26
26
|
export * from "./display-name.js";
|
|
27
27
|
export * from "./decisions.js";
|
|
28
28
|
export * from "./fleet-local.js";
|
|
29
|
+
export * from "./fleet-daemon.js";
|
|
29
30
|
export * from "./fleet-owner-companies.js";
|
|
30
31
|
export * from "./fleet-python.js";
|
|
31
32
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/lib/bot/index.js
CHANGED
|
@@ -26,6 +26,7 @@ export * from "./lock.js";
|
|
|
26
26
|
export * from "./display-name.js";
|
|
27
27
|
export * from "./decisions.js";
|
|
28
28
|
export * from "./fleet-local.js";
|
|
29
|
+
export * from "./fleet-daemon.js";
|
|
29
30
|
export * from "./fleet-owner-companies.js";
|
|
30
31
|
export * from "./fleet-python.js";
|
|
31
32
|
//# sourceMappingURL=index.js.map
|
|
@@ -82,6 +82,10 @@ export declare function currentHotSignalSyncCompany(config: Pick<BotConfig, "com
|
|
|
82
82
|
* The local bot folder, other than `dir`, that already has the hot-signal-sync
|
|
83
83
|
* job for `company` (or registered it once, even if its owner removed it
|
|
84
84
|
* since). Null = none. Unreadable folders are skipped.
|
|
85
|
+
*
|
|
86
|
+
* Only a live bot can hold a company: a folder with no readable bot.json (the
|
|
87
|
+
* bot was removed, or only leftovers remain) or a bot turned off
|
|
88
|
+
* (`enabled: false`) does not count, so its companies go to a bot that runs.
|
|
85
89
|
*/
|
|
86
90
|
export declare function otherBotWithHotSignalSync(dir: string, company: string, botDirs: readonly string[]): string | null;
|
|
87
91
|
/**
|
|
@@ -40,7 +40,7 @@ import { signalsAlertKey } from "../../hot-channels/alert.js";
|
|
|
40
40
|
import { JOB_RUN_OPTIONS_CONTEXT_KEY } from "../job-run.js";
|
|
41
41
|
import { localDate, runRecordRel } from "../../signals/engine.js";
|
|
42
42
|
import { formatJobErrorReply, formatLockedReply, formatRunReply, timeInWords } from "../../signals/reply.js";
|
|
43
|
-
import { effectiveBotCompanies, effectiveBotKind } from "../config.js";
|
|
43
|
+
import { effectiveBotCompanies, effectiveBotKind, readBotConfig } from "../config.js";
|
|
44
44
|
import { ensureLocalJob, readLocalJobs, removeLocalJobsWhere, withJobsLock } from "../local-jobs.js";
|
|
45
45
|
export const HOT_SIGNAL_SYNC_JOB_KIND = "hot-signal-sync";
|
|
46
46
|
/**
|
|
@@ -186,12 +186,19 @@ export function currentHotSignalSyncCompany(config, activeCompany) {
|
|
|
186
186
|
* The local bot folder, other than `dir`, that already has the hot-signal-sync
|
|
187
187
|
* job for `company` (or registered it once, even if its owner removed it
|
|
188
188
|
* since). Null = none. Unreadable folders are skipped.
|
|
189
|
+
*
|
|
190
|
+
* Only a live bot can hold a company: a folder with no readable bot.json (the
|
|
191
|
+
* bot was removed, or only leftovers remain) or a bot turned off
|
|
192
|
+
* (`enabled: false`) does not count, so its companies go to a bot that runs.
|
|
189
193
|
*/
|
|
190
194
|
export function otherBotWithHotSignalSync(dir, company, botDirs) {
|
|
191
195
|
const self = path.resolve(dir);
|
|
192
196
|
for (const other of botDirs) {
|
|
193
197
|
if (path.resolve(other) === self)
|
|
194
198
|
continue;
|
|
199
|
+
const otherConfig = readBotConfig(other);
|
|
200
|
+
if (!otherConfig || otherConfig.enabled === false)
|
|
201
|
+
continue;
|
|
195
202
|
const registered = readMarker(other).registered;
|
|
196
203
|
if (registered[markerKey(company)] || registered[fleetMarkerKey(company)])
|
|
197
204
|
return other;
|
package/dist/lib/bot/log.js
CHANGED
|
@@ -45,8 +45,10 @@ export function botLogLine(level, message, now = () => new Date()) {
|
|
|
45
45
|
}
|
|
46
46
|
export function appendBotLog(dir, line) {
|
|
47
47
|
rotateBotLogIfNeeded(dir);
|
|
48
|
-
const logPath = ensureBotLog(dir);
|
|
49
48
|
try {
|
|
49
|
+
// Creating the log can fail too (a full disk): a log line is never worth
|
|
50
|
+
// an exception in the bot loop that wrote it.
|
|
51
|
+
const logPath = ensureBotLog(dir);
|
|
50
52
|
fs.appendFileSync(logPath, line.endsWith("\n") ? line : `${line}\n`);
|
|
51
53
|
}
|
|
52
54
|
catch {
|
package/dist/lib/bot/probe.js
CHANGED
|
@@ -37,6 +37,8 @@ export function probeFailureText(cls, runtime, usageLimit) {
|
|
|
37
37
|
return `${tool} on this computer is out of date for this model. Update ${tool}, then check again.`;
|
|
38
38
|
case "model-unsupported":
|
|
39
39
|
return `This model isn't available in ${tool} here. Choose a different model, then check again.`;
|
|
40
|
+
case "billing":
|
|
41
|
+
return `${tool} account is out of credits. Top up its billing, then check again.`;
|
|
40
42
|
case "transient":
|
|
41
43
|
return `${tool} is busy or out of reach right now. Check again in a few minutes.`;
|
|
42
44
|
case "not-installed":
|
package/dist/lib/bot/run.js
CHANGED
|
@@ -101,7 +101,7 @@ import { classifyRuntimeError, classifyRuntimeFailure, isRuntimeUsageLimit, usag
|
|
|
101
101
|
import { HQ_BOT_AGENT_UID_ENV } from "../../commands/onboard-bot-membership.js";
|
|
102
102
|
import { captureHeartbeatIdentityMismatch, identityMismatchMessage, isHeartbeatIdentityMismatch, } from "../heartbeat-identity.js";
|
|
103
103
|
import { clearBotSession, ensureBotCompanyScope, readBotSession, writeBotSession } from "./session.js";
|
|
104
|
-
import {
|
|
104
|
+
import { createBotStatusWriter, defaultBotStatus, readBotStatus } from "./status.js";
|
|
105
105
|
import { CLI_VERSION } from "../../cli-version.js";
|
|
106
106
|
import { CLI_UPDATE_RESTART_EXIT_CODE, describeCliUpdate } from "./cli-update.js";
|
|
107
107
|
import { createInboxMqttWakeFlagReader, createInboxPollBackoffFlagReader, safeErrorClass } from "./inbox-poll-backoff-flag.js";
|
|
@@ -469,7 +469,18 @@ export async function runBot(deps) {
|
|
|
469
469
|
const heartbeatIntervalMs = deps.heartbeatIntervalMs ?? HEARTBEAT_INTERVAL_MS;
|
|
470
470
|
const exit = deps.exit ?? ((code) => process.exit(code));
|
|
471
471
|
const fallback = () => defaultBotStatus(pid, config.runtime, now);
|
|
472
|
-
|
|
472
|
+
// status.json is a report: a failed write (a full disk) is logged once and
|
|
473
|
+
// retried with the next update, never thrown into the loop that made it.
|
|
474
|
+
const setStatus = createBotStatusWriter(dir, fallback, {
|
|
475
|
+
now,
|
|
476
|
+
onWriteError: (err, first) => {
|
|
477
|
+
if (!first)
|
|
478
|
+
return;
|
|
479
|
+
const code = err?.code;
|
|
480
|
+
log("warn", `could not write status.json (${typeof code === "string" ? code : "error"}); the bot keeps running and retries with its next update`);
|
|
481
|
+
},
|
|
482
|
+
onRecovered: () => log("info", "status.json writes work again"),
|
|
483
|
+
});
|
|
473
484
|
let state = "starting";
|
|
474
485
|
let stopping = false;
|
|
475
486
|
/** Aborts the model turns in progress (owner stop). */
|
|
@@ -1008,6 +1019,17 @@ export async function runBot(deps) {
|
|
|
1008
1019
|
log("warn", `could not say that ${runtime.id} needs a sign-in: ${err instanceof Error ? err.message : String(err)}`);
|
|
1009
1020
|
}
|
|
1010
1021
|
};
|
|
1022
|
+
// A loop that throws must not leave the bot half alive: an inbox loop that
|
|
1023
|
+
// died while the heartbeat went on looked online and read nothing until a
|
|
1024
|
+
// person restarted it (feedback b3320cb6). End the bot as failed with a
|
|
1025
|
+
// non-zero code instead, so it reads offline and its supervisor (launchd
|
|
1026
|
+
// KeepAlive / systemd on-failure) starts a fresh process that polls again.
|
|
1027
|
+
const loopFailed = (which) => (err) => {
|
|
1028
|
+
if (stopping || state !== "running")
|
|
1029
|
+
return;
|
|
1030
|
+
const message = err instanceof Error ? err.message : String(err);
|
|
1031
|
+
void finish("failed", 1, `${which} loop stopped: ${message}`);
|
|
1032
|
+
};
|
|
1011
1033
|
const heartbeatLoop = (async () => {
|
|
1012
1034
|
let heartbeatFails = 0;
|
|
1013
1035
|
while (!stopping && state === "running") {
|
|
@@ -1056,6 +1078,7 @@ export async function runBot(deps) {
|
|
|
1056
1078
|
}
|
|
1057
1079
|
}
|
|
1058
1080
|
})();
|
|
1081
|
+
void heartbeatLoop.catch(loopFailed("heartbeat"));
|
|
1059
1082
|
// ── Inbox loop ─────────────────────────────────────────────────────────────
|
|
1060
1083
|
const attempts = new Map();
|
|
1061
1084
|
const inboxBackoffSteps = [inboxIntervalMs, 10_000, 20_000, 30_000];
|
|
@@ -3208,8 +3231,10 @@ export async function runBot(deps) {
|
|
|
3208
3231
|
await finish("stopped", 0, mode === "drain" ? "drain completed (running turns finished)" : "stop requested");
|
|
3209
3232
|
};
|
|
3210
3233
|
onStopRequest = (mode) => { void stop(mode); };
|
|
3234
|
+
// See loopFailed: an inbox loop that throws ends the bot, never just itself.
|
|
3235
|
+
void inboxLoop.catch(loopFailed("inbox"));
|
|
3211
3236
|
void inboxLoop.then(() => { if (hasPromotionHold(dir))
|
|
3212
|
-
void stop("drain"); });
|
|
3237
|
+
void stop("drain"); }, () => undefined);
|
|
3213
3238
|
setStatus({ canDrainForPromotion: true });
|
|
3214
3239
|
void Promise.allSettled([heartbeatLoop, inboxLoop]).then(() => {
|
|
3215
3240
|
if (state !== "running")
|
|
@@ -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
|
*
|
|
@@ -23,6 +23,8 @@ export type RuntimeFailureClass =
|
|
|
23
23
|
| "cli-outdated"
|
|
24
24
|
/** The model id is unknown, retired, or not available to this account. */
|
|
25
25
|
| "model-unsupported"
|
|
26
|
+
/** The provider account needs billing attention or more credits. */
|
|
27
|
+
| "billing"
|
|
26
28
|
/** Network trouble, a rate or usage limit, an overloaded service, or a timeout. */
|
|
27
29
|
| "transient"
|
|
28
30
|
/** The tool is not installed (or not on PATH) on this computer. */
|
|
@@ -32,7 +34,7 @@ export type RuntimeFailureClass =
|
|
|
32
34
|
/** Anything else. Neutral copy; never blames the sign-in. */
|
|
33
35
|
| "unknown";
|
|
34
36
|
/** The classes that get a repair card in the DM. */
|
|
35
|
-
export type RuntimeRepairClass = Extract<RuntimeFailureClass, "signed-out" | "cli-outdated" | "model-unsupported" | "transient" | "runtime-crashed">;
|
|
37
|
+
export type RuntimeRepairClass = Extract<RuntimeFailureClass, "signed-out" | "cli-outdated" | "model-unsupported" | "transient" | "runtime-crashed" | "billing">;
|
|
36
38
|
/** The one thing the person can do about it. The desktop maps each to a button. */
|
|
37
39
|
export type RuntimeRepairAction = "signIn" | "update" | "switchModel" | "tryAgain" | "restart";
|
|
38
40
|
export declare const RUNTIME_REPAIR_ACTIONS: Record<RuntimeRepairClass, RuntimeRepairAction>;
|
|
@@ -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
|