@indigoai-us/hq-cli 5.345.215-beta.0 → 5.345.215
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 +65 -1
- package/assets/scaffold/core/scripts/hq-delegate-verify.sh +5 -2
- package/dist/command-catalog.generated.d.ts +46 -6
- package/dist/command-catalog.generated.js +53 -6
- package/dist/commands/bot.js +64 -6
- package/dist/commands/capacity.d.ts +4 -1
- package/dist/commands/capacity.js +46 -10
- package/dist/commands/cloud.js +1 -1
- package/dist/commands/core-delegate-w1b.js +15 -1
- package/dist/commands/core-policy.js +67 -8
- package/dist/commands/daemon.js +5 -0
- package/dist/commands/files-browse.d.ts +11 -4
- package/dist/commands/files-browse.js +21 -4
- package/dist/commands/files.d.ts +1 -1
- package/dist/commands/files.js +25 -11
- package/dist/commands/integrations-auth-rules.d.ts +27 -0
- package/dist/commands/integrations-auth-rules.js +79 -0
- package/dist/commands/integrations-import.js +124 -12
- package/dist/commands/lanes.js +2 -2
- package/dist/commands/mesh.d.ts +2 -0
- package/dist/commands/mesh.js +60 -35
- package/dist/commands/sync-held.js +5 -2
- package/dist/lazy-commands.js +3 -5
- package/dist/lib/bot/fleet-cron.d.ts +8 -0
- package/dist/lib/bot/fleet-cron.js +35 -3
- package/dist/lib/bot/fleet-daemon.d.ts +46 -0
- package/dist/lib/bot/fleet-daemon.js +99 -1
- package/dist/lib/bot/probe.js +7 -1
- package/dist/lib/bot/run.js +20 -1
- package/dist/lib/bot/runtime/codex.js +1 -1
- package/dist/lib/bot/runtime/grok-acp.d.ts +5 -1
- package/dist/lib/bot/runtime/grok-acp.js +6 -3
- package/dist/lib/bot/runtime/index.js +19 -9
- package/dist/lib/bot/runtime/messages-stream.js +2 -2
- package/dist/lib/bot/runtime/types.d.ts +15 -0
- package/dist/lib/bot/runtime/types.js +9 -0
- package/dist/lib/bot/runtime-failure.d.ts +23 -0
- package/dist/lib/bot/runtime-failure.js +43 -1
- package/dist/lib/capacity/accounts.d.ts +8 -0
- package/dist/lib/capacity/accounts.js +19 -0
- package/dist/lib/capacity/available.d.ts +154 -0
- package/dist/lib/capacity/available.js +905 -0
- package/dist/lib/capacity/codex-availability.d.ts +14 -1
- package/dist/lib/capacity/codex-availability.js +26 -1
- package/dist/lib/capacity/collectors/claude-oauth.d.ts +29 -2
- package/dist/lib/capacity/collectors/claude-oauth.js +104 -7
- package/dist/lib/capacity/collectors/codex.js +10 -7
- package/dist/lib/capacity/ledger.d.ts +37 -1
- package/dist/lib/capacity/ledger.js +207 -30
- package/dist/lib/capacity/project.d.ts +26 -0
- package/dist/lib/capacity/project.js +137 -8
- package/dist/lib/capacity/refusal-rows.d.ts +31 -0
- package/dist/lib/capacity/refusal-rows.js +61 -0
- package/dist/lib/capacity/refusal.d.ts +53 -2
- package/dist/lib/capacity/refusal.js +284 -65
- package/dist/lib/capacity/route.js +46 -11
- package/dist/lib/capacity/widget.d.ts +12 -1
- package/dist/lib/capacity/widget.js +91 -3
- package/dist/lib/daemon/resolver.d.ts +2 -0
- package/dist/lib/daemon/resolver.js +3 -0
- package/dist/lib/daemon/run.d.ts +9 -0
- package/dist/lib/daemon/run.js +54 -1
- package/dist/lib/daemon/server.d.ts +2 -0
- package/dist/lib/daemon/server.js +10 -1
- package/dist/lib/daemon/tcc-eperm.d.ts +153 -0
- package/dist/lib/daemon/tcc-eperm.js +310 -0
- package/dist/lib/delivery/admission.d.ts +86 -0
- package/dist/lib/delivery/admission.js +148 -0
- package/dist/lib/delivery/artifacts.d.ts +7 -1
- package/dist/lib/delivery/artifacts.js +29 -10
- package/dist/lib/delivery/attempt-id.d.ts +13 -0
- package/dist/lib/delivery/attempt-id.js +16 -0
- package/dist/lib/delivery/disposable-target.d.ts +42 -0
- package/dist/lib/delivery/disposable-target.js +111 -0
- package/dist/lib/delivery/effects.d.ts +136 -0
- package/dist/lib/delivery/effects.js +541 -0
- package/dist/lib/delivery/enrollment.d.ts +21 -17
- package/dist/lib/delivery/enrollment.js +83 -5
- package/dist/lib/delivery/escalations.d.ts +51 -0
- package/dist/lib/delivery/escalations.js +60 -0
- package/dist/lib/delivery/lease.d.ts +80 -0
- package/dist/lib/delivery/lease.js +134 -0
- package/dist/lib/delivery/migrations.d.ts +120 -4
- package/dist/lib/delivery/migrations.js +215 -15
- package/dist/lib/delivery/mqtt.d.ts +2 -0
- package/dist/lib/delivery/mqtt.js +7 -0
- package/dist/lib/delivery/reconciler.d.ts +65 -1
- package/dist/lib/delivery/reconciler.js +224 -13
- package/dist/lib/delivery/rpc/client.d.ts +22 -0
- package/dist/lib/delivery/rpc/client.js +159 -0
- package/dist/lib/delivery/rpc/port.d.ts +40 -0
- package/dist/lib/delivery/rpc/port.js +16 -0
- package/dist/lib/delivery/rpc/server.d.ts +30 -0
- package/dist/lib/delivery/rpc/server.js +205 -0
- package/dist/lib/delivery/rpc/wire.d.ts +85 -0
- package/dist/lib/delivery/rpc/wire.js +143 -0
- package/dist/lib/delivery/store.d.ts +2 -0
- package/dist/lib/delivery/store.js +4 -0
- package/dist/lib/delivery/windows-service-install.d.ts +262 -0
- package/dist/lib/delivery/windows-service-install.js +892 -0
- package/dist/lib/delivery/workers/macos.d.ts +16 -1
- package/dist/lib/delivery/workers/macos.js +54 -12
- package/dist/lib/delivery/workers/windows-service-live.d.ts +121 -0
- package/dist/lib/delivery/workers/windows-service-live.js +711 -0
- package/dist/lib/delivery/workers/windows-service-runner.d.ts +33 -0
- package/dist/lib/delivery/workers/windows-service-runner.js +82 -0
- package/dist/lib/delivery/workers/windows-service.d.ts +140 -0
- package/dist/lib/delivery/workers/windows-service.js +584 -0
- package/dist/lib/delivery/workers/windows.d.ts +32 -22
- package/dist/lib/delivery/workers/windows.js +50 -64
- package/dist/lib/hot-channels/adapters/meetings.d.ts +15 -0
- package/dist/lib/hot-channels/adapters/meetings.js +36 -3
- package/dist/lib/hot-channels/signals-pass.d.ts +10 -0
- package/dist/lib/hot-channels/signals-pass.js +71 -2
- package/dist/lib/hot-channels/signals-redo.js +10 -2
- package/dist/lib/lanes/watcher.js +35 -0
- package/dist/lib/signals/steps/extract.js +40 -4
- package/dist/schemas/hq-available-ai.v1.schema.json +76 -0
- package/dist/utils/catalog-runtime-paths.d.ts +34 -0
- package/dist/utils/catalog-runtime-paths.js +53 -0
- package/dist/utils/files-browse-acl.js +1 -1
- package/package.json +7 -7
- package/dist/lib/delivery/workers/windows-boundary.d.ts +0 -453
- package/dist/lib/delivery/workers/windows-boundary.js +0 -693
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
export declare const MANIFEST_VERSION = "hq-delivery.windows-service-manifest.v1";
|
|
2
|
+
export interface ServiceManifest {
|
|
3
|
+
schemaVersion: string;
|
|
4
|
+
service: string;
|
|
5
|
+
root: string;
|
|
6
|
+
/** Path relative to root -> sha256. */
|
|
7
|
+
files: Record<string, string>;
|
|
8
|
+
/** The service wrapper as verified at install. acceptedUnsigned names the owner decision when signed is false. */
|
|
9
|
+
wrapper?: {
|
|
10
|
+
sha256: string;
|
|
11
|
+
signed: boolean;
|
|
12
|
+
signer: string;
|
|
13
|
+
acceptedUnsigned?: string;
|
|
14
|
+
};
|
|
15
|
+
/** The installed runtime\\node.exe as it reported itself at install. No version is pinned in the repo. */
|
|
16
|
+
node?: {
|
|
17
|
+
version: string;
|
|
18
|
+
sha256: string;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export declare function readManifest(root: string): ServiceManifest;
|
|
22
|
+
/** The SID from "whoami /user /fo csv /nh" output, or "". */
|
|
23
|
+
export declare function parseWhoamiUser(text: string): string;
|
|
24
|
+
export interface RunnerDeps {
|
|
25
|
+
platform?: NodeJS.Platform;
|
|
26
|
+
/** The SID this process runs as. Defaults to asking whoami.exe. */
|
|
27
|
+
currentSid?: () => string;
|
|
28
|
+
err?: (line: string) => void;
|
|
29
|
+
signal?: AbortSignal;
|
|
30
|
+
readManifest?: (root: string) => ServiceManifest;
|
|
31
|
+
}
|
|
32
|
+
export declare function runnerMain(argv: string[], deps?: RunnerDeps): Promise<number>;
|
|
33
|
+
//# sourceMappingURL=windows-service-runner.d.ts.map
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Entry point of the US-006 pilot runner inside the Windows service
|
|
3
|
+
* (proposal 040). The service wrapper starts
|
|
4
|
+
* runtime\node.exe bin\runner.mjs --root <pilot root>
|
|
5
|
+
* as the service's virtual account. The runner reads the protected manifest,
|
|
6
|
+
* pins the job helper to its recorded sha256 and runs the spool until the
|
|
7
|
+
* wrapper stops it (Ctrl+C, SIGINT or SIGTERM), cancelling running jobs first.
|
|
8
|
+
*/
|
|
9
|
+
import { execFileSync } from "node:child_process";
|
|
10
|
+
import { readFileSync } from "node:fs";
|
|
11
|
+
import { join } from "node:path";
|
|
12
|
+
import { jobHelperLauncher, manifestDigest, runSpoolService, serviceSidFor } from "./windows-service.js";
|
|
13
|
+
export const MANIFEST_VERSION = "hq-delivery.windows-service-manifest.v1";
|
|
14
|
+
export function readManifest(root) {
|
|
15
|
+
const m = JSON.parse(readFileSync(join(root, "config", "manifest.json"), "utf8"));
|
|
16
|
+
if (m.schemaVersion !== MANIFEST_VERSION || typeof m.service !== "string" || typeof m.files?.["bin/hqjob.exe"] !== "string") {
|
|
17
|
+
throw new Error("config/manifest.json is not a service manifest");
|
|
18
|
+
}
|
|
19
|
+
return m;
|
|
20
|
+
}
|
|
21
|
+
/** The SID from "whoami /user /fo csv /nh" output, or "". */
|
|
22
|
+
export function parseWhoamiUser(text) {
|
|
23
|
+
return /^"[^"]*","(S-[0-9-]+)"\s*$/m.exec(text)?.[1] ?? "";
|
|
24
|
+
}
|
|
25
|
+
function currentSidFromWhoami() {
|
|
26
|
+
const systemRoot = process.env.SystemRoot ?? process.env.SYSTEMROOT ?? "C:\\Windows";
|
|
27
|
+
return parseWhoamiUser(execFileSync(join(systemRoot, "System32", "whoami.exe"), ["/user", "/fo", "csv", "/nh"], { encoding: "utf8", windowsHide: true, timeout: 30_000 }));
|
|
28
|
+
}
|
|
29
|
+
const INSTALLED_ROOT = /^[A-Za-z]:\\ProgramData\\HQNativeDelivery-/i;
|
|
30
|
+
/**
|
|
31
|
+
* Why this process may not be the runner, or null. The runner serves jobs only
|
|
32
|
+
* as the service's own virtual account: started as LocalSystem, an
|
|
33
|
+
* administrator or anyone else, it stops before it touches the spool.
|
|
34
|
+
* --skip-identity-check exists for tests that run the bundle against a
|
|
35
|
+
* scratch root as the test user; it is ignored for an installed pilot root.
|
|
36
|
+
*/
|
|
37
|
+
function identityProblem(argv, root, service, deps) {
|
|
38
|
+
if (argv.includes("--skip-identity-check") && !INSTALLED_ROOT.test(root))
|
|
39
|
+
return null;
|
|
40
|
+
const expected = serviceSidFor(service);
|
|
41
|
+
const must = `the runner must run as NT SERVICE\\${service} (${expected})`;
|
|
42
|
+
if ((deps.platform ?? process.platform) !== "win32")
|
|
43
|
+
return `${must}; this host is not Windows`;
|
|
44
|
+
let sid;
|
|
45
|
+
try {
|
|
46
|
+
sid = (deps.currentSid ?? currentSidFromWhoami)();
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
return `${must}; its identity could not be read: ${err instanceof Error ? err.message.split("\n")[0] : String(err)}`;
|
|
50
|
+
}
|
|
51
|
+
return sid === expected ? null : `${must}; it is running as ${sid || "an unreadable identity"}`;
|
|
52
|
+
}
|
|
53
|
+
export async function runnerMain(argv, deps = {}) {
|
|
54
|
+
const err = deps.err ?? ((line) => process.stderr.write(line + "\n"));
|
|
55
|
+
const i = argv.indexOf("--root");
|
|
56
|
+
const root = i >= 0 ? argv[i + 1] : undefined;
|
|
57
|
+
if (!root) {
|
|
58
|
+
err("usage: runner.mjs --root <pilot root>");
|
|
59
|
+
return 2;
|
|
60
|
+
}
|
|
61
|
+
const manifest = (deps.readManifest ?? readManifest)(root);
|
|
62
|
+
const problem = identityProblem(argv, root, manifest.service, deps);
|
|
63
|
+
if (problem) {
|
|
64
|
+
err(`refused: ${problem}`);
|
|
65
|
+
return 3;
|
|
66
|
+
}
|
|
67
|
+
const ac = new AbortController();
|
|
68
|
+
if (deps.signal?.aborted)
|
|
69
|
+
ac.abort();
|
|
70
|
+
deps.signal?.addEventListener("abort", () => ac.abort(), { once: true });
|
|
71
|
+
for (const sig of ["SIGINT", "SIGTERM", "SIGBREAK"])
|
|
72
|
+
process.on(sig, () => ac.abort());
|
|
73
|
+
await runSpoolService({
|
|
74
|
+
root,
|
|
75
|
+
service: manifest.service,
|
|
76
|
+
manifestDigest: manifestDigest(join(root, "config", "manifest.json")),
|
|
77
|
+
launcher: jobHelperLauncher({ helperExe: join(root, "bin", "hqjob.exe"), sha256: manifest.files["bin/hqjob.exe"] }),
|
|
78
|
+
signal: ac.signal,
|
|
79
|
+
});
|
|
80
|
+
return 0;
|
|
81
|
+
}
|
|
82
|
+
//# sourceMappingURL=windows-service-runner.js.map
|
|
@@ -0,0 +1,140 @@
|
|
|
1
|
+
import { type ContainedLauncher, type ContainedProcess, type LaunchOutcome, type LaunchRequest, type LaunchRun, type ServiceTransport } from "./windows.js";
|
|
2
|
+
export declare const SPOOL_VERSION = "hq-delivery.windows-spool.v1";
|
|
3
|
+
/** The proposal 040 pilot names. */
|
|
4
|
+
export declare const PILOT040: {
|
|
5
|
+
readonly service: "HQNDUS006040";
|
|
6
|
+
readonly account: "NT SERVICE\\HQNDUS006040";
|
|
7
|
+
readonly root: "C:\\ProgramData\\HQNativeDelivery-US006-040";
|
|
8
|
+
};
|
|
9
|
+
export declare const SPOOL_DIRS: readonly ["queue", "control", "state", "logs", "runs"];
|
|
10
|
+
/**
|
|
11
|
+
* The virtual account SID Windows derives for a service name:
|
|
12
|
+
* S-1-5-80- followed by the SHA-1 of the upper-cased UTF-16LE name, read as
|
|
13
|
+
* five little-endian 32-bit values.
|
|
14
|
+
*/
|
|
15
|
+
export declare function serviceSidFor(name: string): string;
|
|
16
|
+
export interface JobHelperLauncherOptions {
|
|
17
|
+
/** Absolute path of the installed hqjob.exe. */
|
|
18
|
+
helperExe: string;
|
|
19
|
+
/** Its sha256 from the approved manifest. */
|
|
20
|
+
sha256: string;
|
|
21
|
+
/** Defaults to process.platform. */
|
|
22
|
+
platform?: NodeJS.Platform;
|
|
23
|
+
/** SystemRoot for the helper's own environment. Defaults to the running process's. */
|
|
24
|
+
systemRoot?: string;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Runs each job in its own Job Object through the installed helper; see
|
|
28
|
+
* the helper source for the limits and the line protocol. prepare checks
|
|
29
|
+
* the platform, the helper's digest and its self test, and refuses with
|
|
30
|
+
* CONTAINMENT_UNAVAILABLE on any failure. Nothing is compiled or written.
|
|
31
|
+
*/
|
|
32
|
+
export declare function jobHelperLauncher(opts: JobHelperLauncherOptions): ContainedLauncher;
|
|
33
|
+
export interface SpoolRequest {
|
|
34
|
+
schemaVersion: string;
|
|
35
|
+
id: string;
|
|
36
|
+
run: LaunchRun;
|
|
37
|
+
/** req.env is always empty in the queue file; the values are in envRef.path. */
|
|
38
|
+
req: LaunchRequest;
|
|
39
|
+
envRef?: {
|
|
40
|
+
path: string;
|
|
41
|
+
sha256: string;
|
|
42
|
+
keys: string[];
|
|
43
|
+
};
|
|
44
|
+
submittedAt: string;
|
|
45
|
+
}
|
|
46
|
+
export interface Heartbeat {
|
|
47
|
+
schemaVersion: string;
|
|
48
|
+
service: string;
|
|
49
|
+
pid: number;
|
|
50
|
+
startedAt: string;
|
|
51
|
+
at: string;
|
|
52
|
+
manifestDigest: string;
|
|
53
|
+
stopping?: boolean;
|
|
54
|
+
}
|
|
55
|
+
export type SpoolEvent = {
|
|
56
|
+
e: "accepted";
|
|
57
|
+
at: string;
|
|
58
|
+
} | {
|
|
59
|
+
e: "started";
|
|
60
|
+
pid: number;
|
|
61
|
+
supervisorPid: number | null;
|
|
62
|
+
at: string;
|
|
63
|
+
} | {
|
|
64
|
+
e: "process";
|
|
65
|
+
pid: number;
|
|
66
|
+
} | {
|
|
67
|
+
e: "done";
|
|
68
|
+
outcome: LaunchOutcome;
|
|
69
|
+
at: string;
|
|
70
|
+
};
|
|
71
|
+
export declare function spoolPaths(root: string): {
|
|
72
|
+
queue: string;
|
|
73
|
+
control: string;
|
|
74
|
+
state: string;
|
|
75
|
+
heartbeat: string;
|
|
76
|
+
request: (id: string) => string;
|
|
77
|
+
cancel: (id: string) => string;
|
|
78
|
+
events: (id: string) => string;
|
|
79
|
+
};
|
|
80
|
+
/** sha256 of the manifest file bytes, the identity the CLI and runner agree on. */
|
|
81
|
+
export declare function manifestDigest(manifestPath: string): string;
|
|
82
|
+
/**
|
|
83
|
+
* Replace `path` with `text` through a temp file and a rename. A final failure
|
|
84
|
+
* throws as before; the temp file is removed first, on every OS, so a failed
|
|
85
|
+
* write leaves nothing in the spool. Exported for its tests.
|
|
86
|
+
*/
|
|
87
|
+
export declare function writeAtomic(path: string, text: string, platform?: NodeJS.Platform): void;
|
|
88
|
+
export interface SpoolServiceOptions {
|
|
89
|
+
root: string;
|
|
90
|
+
service: string;
|
|
91
|
+
manifestDigest: string;
|
|
92
|
+
/** Contains each job. In the installed service this is jobHelperLauncher. */
|
|
93
|
+
launcher: ContainedLauncher;
|
|
94
|
+
pollMs?: number;
|
|
95
|
+
signal?: AbortSignal;
|
|
96
|
+
now?: () => Date;
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Run the spool until the signal aborts. Each queued request runs once: a
|
|
100
|
+
* request that already has an events file is never started again. A request
|
|
101
|
+
* that was accepted by an earlier runner but has no done event is closed as
|
|
102
|
+
* supervisor_lost, because that runner's helper and Job Object are gone.
|
|
103
|
+
* On abort every running job is cancelled and awaited before the promise
|
|
104
|
+
* resolves.
|
|
105
|
+
*/
|
|
106
|
+
export declare function runSpoolService(opts: SpoolServiceOptions): Promise<void>;
|
|
107
|
+
export interface SpoolTransportOptions {
|
|
108
|
+
root: string;
|
|
109
|
+
service: string;
|
|
110
|
+
/** The digest the CLI computed from the protected manifest. */
|
|
111
|
+
manifestDigest: string;
|
|
112
|
+
/** A heartbeat older than this is a dead runner. Default 10 s. */
|
|
113
|
+
maxHeartbeatAgeMs?: number;
|
|
114
|
+
pollMs?: number;
|
|
115
|
+
now?: () => Date;
|
|
116
|
+
}
|
|
117
|
+
export declare class SpoolTransport implements ServiceTransport {
|
|
118
|
+
private readonly opts;
|
|
119
|
+
private readonly p;
|
|
120
|
+
private readonly now;
|
|
121
|
+
private readonly maxAge;
|
|
122
|
+
private readonly pollMs;
|
|
123
|
+
constructor(opts: SpoolTransportOptions);
|
|
124
|
+
/** The current heartbeat when it is live and for this installation; throws a WorkerRefusal otherwise. */
|
|
125
|
+
check(): Heartbeat;
|
|
126
|
+
submit(req: LaunchRequest, run: LaunchRun): ContainedProcess;
|
|
127
|
+
}
|
|
128
|
+
export interface ServiceWindowsLauncherOptions {
|
|
129
|
+
transport: ServiceTransport;
|
|
130
|
+
/** Defaults to process.platform. */
|
|
131
|
+
platform?: NodeJS.Platform;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* The CLI launcher for the service pilot. prepare refuses with
|
|
135
|
+
* CONTAINMENT_UNAVAILABLE before the claim unless the host is Windows and the
|
|
136
|
+
* runner is live, named and on the expected manifest. There is no other path
|
|
137
|
+
* to a process.
|
|
138
|
+
*/
|
|
139
|
+
export declare function serviceWindowsLauncher(opts: ServiceWindowsLauncherOptions): ContainedLauncher;
|
|
140
|
+
//# sourceMappingURL=windows-service.d.ts.map
|