@indigoai-us/hq-cli 5.345.225 → 5.345.226
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 +32 -0
- package/dist/command-catalog.generated.d.ts +78 -0
- package/dist/command-catalog.generated.js +97 -0
- package/dist/commands/daemon.js +1 -1
- package/dist/commands/deploy-domains.js +38 -2
- package/dist/commands/lanes-accounts.d.ts +14 -0
- package/dist/commands/lanes-accounts.js +119 -0
- package/dist/commands/lanes-move.js +10 -0
- package/dist/commands/lanes-shared.js +9 -0
- package/dist/commands/lanes.js +137 -12
- package/dist/commands/sync-held.d.ts +22 -0
- package/dist/commands/sync-held.js +167 -18
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +4845 -2524
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/lib/capacity/accounts.d.ts +4 -0
- package/dist/lib/capacity/accounts.js +4 -0
- package/dist/lib/capacity/route.js +14 -0
- package/dist/lib/capacity/sign-in.d.ts +18 -0
- package/dist/lib/capacity/sign-in.js +34 -1
- package/dist/lib/daemon/catalog.d.ts +1 -0
- package/dist/lib/daemon/catalog.js +1 -1
- package/dist/lib/daemon/hook-requests.d.ts +76 -0
- package/dist/lib/daemon/hook-requests.js +481 -0
- package/dist/lib/daemon/lanes-reconcile-status.d.ts +35 -0
- package/dist/lib/daemon/lanes-reconcile-status.js +86 -0
- package/dist/lib/daemon/ops/policy.d.ts +1 -1
- package/dist/lib/daemon/ops/policy.js +43 -4
- package/dist/lib/daemon/run.js +37 -4
- package/dist/lib/daemon/server.js +6 -1
- package/dist/lib/daemon/supervisor.d.ts +2 -0
- package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
- package/dist/lib/flag-registry-worker-source.generated.js +1 -1
- package/dist/lib/lanes/account-company.d.ts +7 -1
- package/dist/lib/lanes/account-company.js +22 -4
- package/dist/lib/lanes/account-ownership.d.ts +65 -0
- package/dist/lib/lanes/account-ownership.js +134 -0
- package/dist/lib/lanes/accounts.js +9 -2
- package/dist/lib/lanes/claude-balance.js +9 -3
- package/dist/lib/lanes/config.js +17 -0
- package/dist/lib/lanes/host-capacity.d.ts +19 -0
- package/dist/lib/lanes/host-capacity.js +37 -0
- package/dist/lib/lanes/reconcile.js +44 -3
- package/dist/lib/lanes/spawn.d.ts +0 -10
- package/dist/lib/lanes/spawn.js +51 -1
- package/dist/lib/lanes/types.d.ts +12 -0
- package/package.json +8 -8
|
@@ -1 +1 @@
|
|
|
1
|
-
{"name":"hq-cli-daemon-sync-runner","type":"module","version":"6.18.
|
|
1
|
+
{"name":"hq-cli-daemon-sync-runner","type":"module","version":"6.18.110","bundleSha256":"f07bdb64deac33e3fd132bfae7452fb8fb207e0b465b0da77b0fcc323a280bf5","formatVersion":1}
|
|
@@ -14,6 +14,10 @@ export interface CapacityAccount {
|
|
|
14
14
|
source: CapacityAccountSource;
|
|
15
15
|
/** False for a capacity-only account: read for usage, never used by lanes. */
|
|
16
16
|
lanes?: boolean;
|
|
17
|
+
/** PS-006: owning business (slug, personal or unknown). Absent on default-home rows. */
|
|
18
|
+
owning_company?: string;
|
|
19
|
+
/** PS-006: owner, another named person, or unknown. Absent on default-home rows. */
|
|
20
|
+
holder?: string;
|
|
17
21
|
}
|
|
18
22
|
/**
|
|
19
23
|
* `disabled_reason` that marks a registry account as capacity-only. Signing in
|
|
@@ -9,6 +9,7 @@ import * as fs from "node:fs";
|
|
|
9
9
|
import * as os from "node:os";
|
|
10
10
|
import * as path from "node:path";
|
|
11
11
|
import { effectiveAccountHome } from "../lanes/account-home.js";
|
|
12
|
+
import { accountOwnership } from "../lanes/account-ownership.js";
|
|
12
13
|
import { lanesConfigPath, loadLanesConfig } from "../lanes/config.js";
|
|
13
14
|
import { resolveLanesHqRoot } from "../lanes/hq-root.js";
|
|
14
15
|
import { LANE_PROVIDERS } from "../lanes/types.js";
|
|
@@ -47,12 +48,15 @@ export function listCapacityAccounts(options = {}) {
|
|
|
47
48
|
if (!account.enabled && !capacityOnly)
|
|
48
49
|
continue;
|
|
49
50
|
const effective = effectiveAccountHome(account, hostname);
|
|
51
|
+
const ownership = accountOwnership(account);
|
|
50
52
|
accounts.push({
|
|
51
53
|
provider,
|
|
52
54
|
label,
|
|
53
55
|
home: effective.home,
|
|
54
56
|
source: effective.source === "host" ? "host" : "registry",
|
|
55
57
|
lanes: account.enabled,
|
|
58
|
+
owning_company: ownership.owning_company,
|
|
59
|
+
holder: ownership.holder,
|
|
56
60
|
});
|
|
57
61
|
}
|
|
58
62
|
}
|
|
@@ -14,6 +14,7 @@ import { codexSnapshotStale, hasCodexCreditRoom } from "./codex-availability.js"
|
|
|
14
14
|
* { ok, at, request, pick, ranked, skipped, moves, next_reset, capacity,
|
|
15
15
|
* lanes_error }
|
|
16
16
|
*/
|
|
17
|
+
import { accountHeldByOther } from "../lanes/account-ownership.js";
|
|
17
18
|
import { canonicalizeHome } from "../lanes/config.js";
|
|
18
19
|
import { LANE_PROVIDERS } from "../lanes/types.js";
|
|
19
20
|
import { capacityLoginCommand } from "./ledger.js";
|
|
@@ -365,6 +366,19 @@ export function pickAccount(input) {
|
|
|
365
366
|
});
|
|
366
367
|
continue;
|
|
367
368
|
}
|
|
369
|
+
// PS-006: another person's login is never a pick, so --account auto
|
|
370
|
+
// moves on to the next account instead of failing at lane create.
|
|
371
|
+
const heldConfig = input.lanesConfig.providers?.[providerId]?.accounts?.[laneMatch.id];
|
|
372
|
+
if (accountHeldByOther(heldConfig)) {
|
|
373
|
+
skipped.push({
|
|
374
|
+
...base,
|
|
375
|
+
reason: "held by another person, not used for lanes",
|
|
376
|
+
fix: "This login is held by " + (heldConfig?.holder ?? "another person") +
|
|
377
|
+
". Use one of your own logins. Change the holder to owner only if this is really your own login: hq lanes accounts set-owner " +
|
|
378
|
+
providerId + " " + laneMatch.id + " --holder owner",
|
|
379
|
+
});
|
|
380
|
+
continue;
|
|
381
|
+
}
|
|
368
382
|
const authState = account.authState ?? "unknown";
|
|
369
383
|
// authState "unknown" means the ledger has no usage reading for the
|
|
370
384
|
// account, not that its sign-in failed. Do not send the user to log in
|
|
@@ -22,6 +22,10 @@ export interface RosterRow {
|
|
|
22
22
|
usageOnly?: boolean;
|
|
23
23
|
/** The default home with no HQ account registered on it. Only the vendor login fixes it. */
|
|
24
24
|
unregisteredDefault?: boolean;
|
|
25
|
+
/** PS-006: owning business of the login (slug, personal or unknown). */
|
|
26
|
+
owningCompany?: string;
|
|
27
|
+
/** PS-006: owner, another named person, or unknown. */
|
|
28
|
+
holder?: string;
|
|
25
29
|
}
|
|
26
30
|
/** Sentence printed for an expired Claude credential. Other commands pass through. */
|
|
27
31
|
export declare function formatRefreshLine(provider: string, command: string): string;
|
|
@@ -63,6 +67,20 @@ export declare function repairSelection(rows: readonly RosterRow[], provider?: s
|
|
|
63
67
|
expired: RosterRow[];
|
|
64
68
|
};
|
|
65
69
|
export declare function loginJson(rows: readonly RosterRow[], nowMs: number, provider?: string): unknown;
|
|
70
|
+
/**
|
|
71
|
+
* PS-006: the same readings grouped by the business that owns each login,
|
|
72
|
+
* sorted by slug with `unknown` last, so usage can be reported per business.
|
|
73
|
+
*/
|
|
74
|
+
export declare function groupByOwningCompany(rows: readonly RosterRow[], nowMs: number): Array<{
|
|
75
|
+
owningCompany: string;
|
|
76
|
+
accounts: Array<{
|
|
77
|
+
provider: string;
|
|
78
|
+
label: string;
|
|
79
|
+
holder: string;
|
|
80
|
+
state: SignInState;
|
|
81
|
+
lastReadingAge: string;
|
|
82
|
+
}>;
|
|
83
|
+
}>;
|
|
66
84
|
export interface CapacityLoginRequest {
|
|
67
85
|
provider?: string;
|
|
68
86
|
account?: string;
|
|
@@ -133,10 +133,15 @@ export function rosterFrom(accounts, view, userHome) {
|
|
|
133
133
|
defaultHome.set(account.provider, path.resolve(account.home));
|
|
134
134
|
}
|
|
135
135
|
const registeredDefault = new Set();
|
|
136
|
+
// The registry account folded into each provider's default row, for its labels.
|
|
137
|
+
const foldedAccount = new Map();
|
|
136
138
|
for (const account of accounts) {
|
|
137
139
|
const home = defaultHome.get(account.provider);
|
|
138
|
-
if (account.label !== "default" && home && path.resolve(account.home) === home)
|
|
140
|
+
if (account.label !== "default" && home && path.resolve(account.home) === home) {
|
|
139
141
|
registeredDefault.add(account.provider);
|
|
142
|
+
if (!foldedAccount.has(account.provider))
|
|
143
|
+
foldedAccount.set(account.provider, account);
|
|
144
|
+
}
|
|
140
145
|
}
|
|
141
146
|
const rows = [];
|
|
142
147
|
for (const account of accounts) {
|
|
@@ -149,6 +154,7 @@ export function rosterFrom(accounts, view, userHome) {
|
|
|
149
154
|
const presented = match
|
|
150
155
|
? presentAccount({ ...match, homes: [account.home], labels: [account.label] }, account.provider, userHome)
|
|
151
156
|
: { state: "unknown", reason: null, command: null };
|
|
157
|
+
const owned = account.label === "default" ? foldedAccount.get(account.provider) : account;
|
|
152
158
|
rows.push({
|
|
153
159
|
provider: account.provider,
|
|
154
160
|
label: account.label,
|
|
@@ -164,6 +170,8 @@ export function rosterFrom(accounts, view, userHome) {
|
|
|
164
170
|
home: account.home,
|
|
165
171
|
usageOnly: account.lanes === false,
|
|
166
172
|
...(unregisteredDefault ? { unregisteredDefault: true } : {}),
|
|
173
|
+
owningCompany: owned?.owning_company ?? "unknown",
|
|
174
|
+
holder: owned?.holder ?? "unknown",
|
|
167
175
|
});
|
|
168
176
|
}
|
|
169
177
|
return rows;
|
|
@@ -261,10 +269,35 @@ export function loginJson(rows, nowMs, provider) {
|
|
|
261
269
|
usageOnly: row.usageOnly === true,
|
|
262
270
|
laneCommand: row.usageOnly ? laneEnableCommand(row.provider, row.label) : null,
|
|
263
271
|
lastReadingAge: readingAge(row.observedAt, nowMs),
|
|
272
|
+
owningCompany: row.owningCompany ?? "unknown",
|
|
273
|
+
holder: row.holder ?? "unknown",
|
|
264
274
|
})),
|
|
275
|
+
byOwningCompany: groupByOwningCompany(rows, nowMs),
|
|
265
276
|
addAccountCommands: addAccountCommands(provider),
|
|
266
277
|
};
|
|
267
278
|
}
|
|
279
|
+
/**
|
|
280
|
+
* PS-006: the same readings grouped by the business that owns each login,
|
|
281
|
+
* sorted by slug with `unknown` last, so usage can be reported per business.
|
|
282
|
+
*/
|
|
283
|
+
export function groupByOwningCompany(rows, nowMs) {
|
|
284
|
+
const groups = new Map();
|
|
285
|
+
for (const row of rows) {
|
|
286
|
+
const key = row.owningCompany ?? "unknown";
|
|
287
|
+
const list = groups.get(key) ?? [];
|
|
288
|
+
list.push({
|
|
289
|
+
provider: row.provider,
|
|
290
|
+
label: row.label,
|
|
291
|
+
holder: row.holder ?? "unknown",
|
|
292
|
+
state: row.state,
|
|
293
|
+
lastReadingAge: readingAge(row.observedAt, nowMs),
|
|
294
|
+
});
|
|
295
|
+
groups.set(key, list);
|
|
296
|
+
}
|
|
297
|
+
return [...groups.entries()]
|
|
298
|
+
.sort(([a], [b]) => (a === "unknown" ? 1 : 0) - (b === "unknown" ? 1 : 0) || a.localeCompare(b))
|
|
299
|
+
.map(([owningCompany, accounts]) => ({ owningCompany, accounts }));
|
|
300
|
+
}
|
|
268
301
|
function readingAge(observedAt, nowMs) {
|
|
269
302
|
if (!observedAt)
|
|
270
303
|
return "—";
|
|
@@ -232,6 +232,7 @@ export declare function hqCloudUnits(machineType: MachineType, enabled: readonly
|
|
|
232
232
|
export declare const CODEX_RUNNER_SCRIPT = "/usr/local/bin/outpost-codex-runner.sh";
|
|
233
233
|
/** The outpost's Claude runner script, read for the session name it uses. */
|
|
234
234
|
export declare const CLAUDE_RUNNER_SCRIPT = "/usr/local/bin/outpost-runner.sh";
|
|
235
|
+
export declare const NOT_SIGNED_IN = "not signed in (run `hq login`)";
|
|
235
236
|
export declare function daemonAloneRunsLegacySync(ctx: PlanContext): boolean;
|
|
236
237
|
/** Turn enabled services into concrete units for this host. */
|
|
237
238
|
export declare function planUnits(services: readonly ServiceName[], ctx: PlanContext): UnitPlan[];
|
|
@@ -143,7 +143,7 @@ export const CODEX_RUNNER_SCRIPT = "/usr/local/bin/outpost-codex-runner.sh";
|
|
|
143
143
|
/** The outpost's Claude runner script, read for the session name it uses. */
|
|
144
144
|
export const CLAUDE_RUNNER_SCRIPT = "/usr/local/bin/outpost-runner.sh";
|
|
145
145
|
const NO_HQ_ROOT = "no HQ folder configured (run `hq daemon install --hq-root <path>`)";
|
|
146
|
-
const NOT_SIGNED_IN = "not signed in (run `hq login`)";
|
|
146
|
+
export const NOT_SIGNED_IN = "not signed in (run `hq login`)";
|
|
147
147
|
const KIT_NOT_SET_UP = "the agent kit is not set up on this machine (run `hq agent kit install`)";
|
|
148
148
|
function syncOwnerBlock(ctx) {
|
|
149
149
|
if (ctx.machineType === "desktop" && ctx.syncOwner === "desktop-app" && ctx.desktopAppManagesSync) {
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
/** What the daemon is asked to do. A closed list, the same as `Kind` in daemon_req.rs. */
|
|
2
|
+
export type HookOperation = {
|
|
3
|
+
kind: "reindex";
|
|
4
|
+
};
|
|
5
|
+
export interface HookRequest {
|
|
6
|
+
/** The note's file name without `.json`. */
|
|
7
|
+
stem: string;
|
|
8
|
+
id: string;
|
|
9
|
+
/** When the hook left the note (ms since the epoch). */
|
|
10
|
+
at: number;
|
|
11
|
+
/** The HQ root the note names. */
|
|
12
|
+
root: string;
|
|
13
|
+
session: string;
|
|
14
|
+
operation: HookOperation;
|
|
15
|
+
}
|
|
16
|
+
/** The longest note the Rust writer leaves (`NOTE_MAX_BYTES`). */
|
|
17
|
+
export declare const HOOK_REQUEST_MAX_BYTES = 4096;
|
|
18
|
+
/** A note older than this is deleted and never run. */
|
|
19
|
+
export declare const HOOK_REQUEST_MAX_AGE_MS: number;
|
|
20
|
+
/** Tries per note, and the waits before the second and third. */
|
|
21
|
+
export declare const HOOK_REQUEST_MAX_ATTEMPTS = 3;
|
|
22
|
+
export declare const HOOK_REQUEST_RETRY_DELAYS_MS: readonly number[];
|
|
23
|
+
/** The longest a request's program runs before it is killed. */
|
|
24
|
+
export declare const HOOK_REQUEST_KILL_MS = 60000;
|
|
25
|
+
/** Notes handled per pass; the drainer schedules another pass at once when reached. */
|
|
26
|
+
export declare const HOOK_REQUEST_PASS_LIMIT = 64;
|
|
27
|
+
/** The folder name for an HQ root: 32 hex characters of SHA-256 over its real path (`root_key` in daemon_req.rs). */
|
|
28
|
+
export declare function hookRequestRootKey(root: string): string;
|
|
29
|
+
/** The request folder of `root` under `home`. */
|
|
30
|
+
export declare function hookRequestDir(home: string, root: string): string;
|
|
31
|
+
/** Read one note. `stem` is its file name without `.json`. Undefined for anything the writer does not produce. */
|
|
32
|
+
export declare function parseHookRequest(text: string, stem: string): HookRequest | undefined;
|
|
33
|
+
/** The CLI arguments for a validated request. Nothing from the note is passed through as an argument except its checked root. */
|
|
34
|
+
export declare function hookRequestArguments(request: HookRequest): string[];
|
|
35
|
+
export interface HookRequestDrainOptions {
|
|
36
|
+
home: string;
|
|
37
|
+
/** The HQ root this daemon serves, read on every pass. */
|
|
38
|
+
root: () => string | undefined;
|
|
39
|
+
/** Must prove ownership of the canonical per-user daemon lease. */
|
|
40
|
+
ownsQueue: () => boolean;
|
|
41
|
+
/** Runs a validated request. No shell evaluation. */
|
|
42
|
+
execute: (request: HookRequest) => Promise<{
|
|
43
|
+
code: number;
|
|
44
|
+
}>;
|
|
45
|
+
log: (message: string) => void;
|
|
46
|
+
/** Clock (tests). */
|
|
47
|
+
now?: () => number;
|
|
48
|
+
/** Waits before the second and third try (tests). */
|
|
49
|
+
retryDelaysMs?: readonly number[];
|
|
50
|
+
/** The wait between fallback scans (tests). */
|
|
51
|
+
scanIntervalMs?: number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* One pass over the request folder of this daemon's HQ root. Returns the
|
|
55
|
+
* number of notes settled or tried. Notes of another HQ root are in another
|
|
56
|
+
* folder and are not touched.
|
|
57
|
+
*/
|
|
58
|
+
export declare function drainHookRequests(options: HookRequestDrainOptions): Promise<number>;
|
|
59
|
+
/** Startup scan plus folder notifications, with a 5 s fallback scan when a
|
|
60
|
+
* watcher is unavailable or an event was missed. Close waits for the request
|
|
61
|
+
* in progress. */
|
|
62
|
+
export declare function startHookRequestDrainer(options: HookRequestDrainOptions): {
|
|
63
|
+
close(): Promise<void>;
|
|
64
|
+
};
|
|
65
|
+
/** Run a validated request through the daemon's own CLI entry point. */
|
|
66
|
+
export declare function executeHookRequest(request: HookRequest, options: {
|
|
67
|
+
nodeBinary: string;
|
|
68
|
+
hqBinary: string;
|
|
69
|
+
allowedRoot: string | undefined;
|
|
70
|
+
env?: NodeJS.ProcessEnv;
|
|
71
|
+
signal?: AbortSignal;
|
|
72
|
+
timeoutMs?: number;
|
|
73
|
+
}): Promise<{
|
|
74
|
+
code: number;
|
|
75
|
+
}>;
|
|
76
|
+
//# sourceMappingURL=hook-requests.d.ts.map
|