@indigoai-us/hq-cli 5.345.228 → 5.345.230
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 +14 -0
- package/dist/command-catalog.generated.d.ts +239 -11
- package/dist/command-catalog.generated.js +287 -11
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +1473 -1043
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/lib/daemon/hook-requests-conduct-link.d.ts +20 -0
- package/dist/lib/daemon/hook-requests-conduct-link.js +105 -0
- package/dist/lib/daemon/hook-requests.d.ts +6 -1
- package/dist/lib/daemon/hook-requests.js +18 -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/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.112","bundleSha256":"8c9e1034d6fc5a89949c510ab5283c7e965e3c645e4c7e00695b10e299cb6837","formatVersion":1}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { type HookRequest, type HookRequestResult } from "./hook-requests.js";
|
|
2
|
+
export type ConductLinkKind = "conduct-lanes-link-deliver" | "conduct-link-inherit";
|
|
3
|
+
export type ConductLinkOperation = {
|
|
4
|
+
kind: ConductLinkKind;
|
|
5
|
+
sessionId: string;
|
|
6
|
+
};
|
|
7
|
+
/** The root's hook script each kind runs, with the event the adapter gave it. */
|
|
8
|
+
export declare const CONDUCT_LINK_SCRIPTS: Readonly<Record<ConductLinkKind, string>>;
|
|
9
|
+
/** The adapter ran both through its PostToolUse dispatch (`dispatch_settings_hooks "PostToolUse" "Agent"`). */
|
|
10
|
+
export declare const CONDUCT_LINK_EVENT = "PostToolUse";
|
|
11
|
+
export declare function isConductLinkKind(kind: unknown): kind is ConductLinkKind;
|
|
12
|
+
/** The operation in a conduct note's `args`, or undefined for anything the hook does not write. */
|
|
13
|
+
export declare function parseConductLink(kind: ConductLinkKind, args: Record<string, unknown>, session: unknown): ConductLinkOperation | undefined;
|
|
14
|
+
/** Run the root's hook script for one conduct note (see the file comment). */
|
|
15
|
+
export declare function runConductLink(request: HookRequest, operation: ConductLinkOperation, base: NodeJS.ProcessEnv, options: {
|
|
16
|
+
signal?: AbortSignal;
|
|
17
|
+
timeoutMs: number;
|
|
18
|
+
killGraceMs: number;
|
|
19
|
+
}): Promise<HookRequestResult>;
|
|
20
|
+
//# sourceMappingURL=hook-requests-conduct-link.d.ts.map
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The two programs the Codex adapter started at SubagentStop for conduct
|
|
3
|
+
* links, run by the daemon instead (standing rule b; `conduct_lanes_link_deliver`
|
|
4
|
+
* and `conduct_link_inherit_settle` in crates/hq-hook/src/daemon_req.rs).
|
|
5
|
+
*
|
|
6
|
+
* The hq-core v16.0.47 Codex adapter (`hq-codex-hook-adapter.sh`, its
|
|
7
|
+
* `SubagentStop)` arm) fed the completed lifecycle payload through the root's
|
|
8
|
+
* Agent-matched PostToolUse hooks. Two of them start programs:
|
|
9
|
+
*
|
|
10
|
+
* - `conduct-lanes-link-deliver`: `.claude/hooks/conduct-lanes-link-deliver.sh
|
|
11
|
+
* PostToolUse`, which for a root session with a
|
|
12
|
+
* `workspace/lanes-links/by-session/<sid>` pointer runs
|
|
13
|
+
* `hq lanes link _deliver --event PostToolUse` with the payload on stdin.
|
|
14
|
+
* - `conduct-link-inherit`: `.claude/hooks/conduct-link-inherit.sh PostToolUse`,
|
|
15
|
+
* which runs `node core/scripts/lib/conduct-link-inherit.mjs PostToolUse
|
|
16
|
+
* <root>`; its `settle` joins a pending claim of the session to its conduct
|
|
17
|
+
* link once the session's companies are bound, and sweeps stale claims.
|
|
18
|
+
*
|
|
19
|
+
* Each reads only `session_id` from a root payload, so that is all the note
|
|
20
|
+
* carries (`args.session_id`, also the note's session). The daemon runs the
|
|
21
|
+
* root's own hook script, `bash <root>/.claude/hooks/<script> PostToolUse`,
|
|
22
|
+
* with `{"session_id": <sid>}` on stdin:
|
|
23
|
+
*
|
|
24
|
+
* - The program and its arguments are an argv array, no shell; the session id
|
|
25
|
+
* reaches the script only inside the JSON on stdin.
|
|
26
|
+
* - A root without the script: done, nothing is started (the adapter's
|
|
27
|
+
* launcher found no file and went on).
|
|
28
|
+
* - `HQ_ROOT` and `CLAUDE_PROJECT_DIR` are the note's root, as the adapter's
|
|
29
|
+
* launcher set them. The daemon's own `HQ_HOOK_AGENT_ID` is not the
|
|
30
|
+
* session's and is removed: the writer decided the event was a root's before
|
|
31
|
+
* it left the note.
|
|
32
|
+
* - Output is not read: the adapter's `emit_context` has no SubagentStop
|
|
33
|
+
* shape, so what the hooks printed was dropped there too.
|
|
34
|
+
* - Exit status ignored when the script ended by itself (both scripts exit 0
|
|
35
|
+
* on every path); a run stopped at the limit or by a daemon stop is a failed
|
|
36
|
+
* try.
|
|
37
|
+
*/
|
|
38
|
+
import * as fs from "node:fs";
|
|
39
|
+
import * as path from "node:path";
|
|
40
|
+
// A cycle with hook-requests.ts, which dispatches to this module: each side uses the other only inside functions.
|
|
41
|
+
import { spawnRequestProgram } from "./hook-requests.js";
|
|
42
|
+
/** The root's hook script each kind runs, with the event the adapter gave it. */
|
|
43
|
+
export const CONDUCT_LINK_SCRIPTS = {
|
|
44
|
+
"conduct-lanes-link-deliver": ".claude/hooks/conduct-lanes-link-deliver.sh",
|
|
45
|
+
"conduct-link-inherit": ".claude/hooks/conduct-link-inherit.sh",
|
|
46
|
+
};
|
|
47
|
+
/** The adapter ran both through its PostToolUse dispatch (`dispatch_settings_hooks "PostToolUse" "Agent"`). */
|
|
48
|
+
export const CONDUCT_LINK_EVENT = "PostToolUse";
|
|
49
|
+
/**
|
|
50
|
+
* A session id a conduct note carries (`conduct_session` in daemon_req.rs): the
|
|
51
|
+
* scripts' own `^[A-Za-z0-9._-]+$`, not `.` or `..`, at most 512 characters.
|
|
52
|
+
*/
|
|
53
|
+
const CONDUCT_SESSION = /^[A-Za-z0-9._-]{1,512}$/;
|
|
54
|
+
export function isConductLinkKind(kind) {
|
|
55
|
+
return kind === "conduct-lanes-link-deliver" || kind === "conduct-link-inherit";
|
|
56
|
+
}
|
|
57
|
+
/** The operation in a conduct note's `args`, or undefined for anything the hook does not write. */
|
|
58
|
+
export function parseConductLink(kind, args, session) {
|
|
59
|
+
const keys = Object.keys(args);
|
|
60
|
+
if (keys.length !== 1 || keys[0] !== "session_id")
|
|
61
|
+
return undefined;
|
|
62
|
+
const sessionId = args.session_id;
|
|
63
|
+
if (typeof sessionId !== "string" || !CONDUCT_SESSION.test(sessionId) || sessionId === "." || sessionId === ".."
|
|
64
|
+
|| sessionId !== session)
|
|
65
|
+
return undefined;
|
|
66
|
+
return { kind, sessionId };
|
|
67
|
+
}
|
|
68
|
+
/** Run the root's hook script for one conduct note (see the file comment). */
|
|
69
|
+
export async function runConductLink(request, operation, base, options) {
|
|
70
|
+
const script = path.join(request.root, CONDUCT_LINK_SCRIPTS[operation.kind]);
|
|
71
|
+
try {
|
|
72
|
+
if (!fs.statSync(script).isFile())
|
|
73
|
+
return { code: 0 };
|
|
74
|
+
}
|
|
75
|
+
catch {
|
|
76
|
+
return { code: 0 };
|
|
77
|
+
}
|
|
78
|
+
const env = { ...base };
|
|
79
|
+
delete env.HQ_HOOK_AGENT_ID;
|
|
80
|
+
Object.assign(env, { HQ_ROOT: request.root, CLAUDE_PROJECT_DIR: request.root, HQ_HOOK_REQUEST_ID: request.id });
|
|
81
|
+
const input = JSON.stringify({ session_id: operation.sessionId });
|
|
82
|
+
return new Promise(resolve => {
|
|
83
|
+
if (options.signal?.aborted) {
|
|
84
|
+
resolve({ code: 1 });
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
const { child, settle } = spawnRequestProgram("bash", [script, CONDUCT_LINK_EVENT], {
|
|
88
|
+
cwd: request.root, env, windowsHide: true, stdio: ["pipe", "ignore", "ignore"],
|
|
89
|
+
}, { timeoutMs: options.timeoutMs, killGraceMs: options.killGraceMs, ...(options.signal ? { signal: options.signal } : {}) });
|
|
90
|
+
// A script that exits before it reads leaves a closed pipe; its exit status is the result.
|
|
91
|
+
child.stdin?.on("error", () => undefined);
|
|
92
|
+
child.stdin?.end(input);
|
|
93
|
+
let settled = false;
|
|
94
|
+
const done = (exited) => {
|
|
95
|
+
if (settled)
|
|
96
|
+
return;
|
|
97
|
+
settled = true;
|
|
98
|
+
const ended = settle();
|
|
99
|
+
resolve({ code: !ended && exited ? 0 : 1 });
|
|
100
|
+
};
|
|
101
|
+
child.once("error", () => done(false));
|
|
102
|
+
child.once("close", (code, signal) => done(code !== null && signal === null));
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=hook-requests-conduct-link.js.map
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* (decision 36), `fleet-local-settings` (US-050 c2, conductor ruling on #3042), and the mesh kinds
|
|
7
7
|
* `mesh-reconcile` and `mesh-register-retry` (hook-requests-mesh.ts).
|
|
8
8
|
* Also `fleet-session-start`, US-050 c2 (hook-requests-fleet-session-start.ts).
|
|
9
|
+
* Also `conduct-lanes-link-deliver` and `conduct-link-inherit`, the Codex adapter's
|
|
10
|
+
* SubagentStop conduct-link runs (hook-requests-conduct-link.ts).
|
|
9
11
|
*
|
|
10
12
|
* A hook that used to re-index, commit, copy a plan or edit a pull request
|
|
11
13
|
* now only decides that the work is due and leaves one small file in
|
|
@@ -52,6 +54,7 @@ import { type MeshOperation } from "./hook-requests-mesh.js";
|
|
|
52
54
|
import { type MachineCheckResult, type RunMachineChecksOptions } from "./machine-checks.js";
|
|
53
55
|
import { type MeshToolWritesOperation } from "./hook-requests-mesh-tool-writes.js";
|
|
54
56
|
import { type FleetSessionStartOperation } from "./hook-requests-fleet-session-start.js";
|
|
57
|
+
import { type ConductLinkOperation } from "./hook-requests-conduct-link.js";
|
|
55
58
|
/** What the daemon is asked to do. A closed list, the same as `Kind` in daemon_req.rs. */
|
|
56
59
|
export type HookOperation = {
|
|
57
60
|
kind: "reindex";
|
|
@@ -104,7 +107,9 @@ export type HookOperation = {
|
|
|
104
107
|
disabled?: MeshSessionBindSwitch;
|
|
105
108
|
}
|
|
106
109
|
/** One machine check run by the daemon for a SessionStart where the hooks own the checks (the machine-check notes at the end of this file). */
|
|
107
|
-
| MachineCheckOperation | MeshOperation | MeshToolWritesOperation | FleetSessionStartOperation
|
|
110
|
+
| MachineCheckOperation | MeshOperation | MeshToolWritesOperation | FleetSessionStartOperation
|
|
111
|
+
/** The Codex adapter's SubagentStop runs of the root's conduct-link hooks (hook-requests-conduct-link.ts). */
|
|
112
|
+
| ConductLinkOperation;
|
|
108
113
|
/**
|
|
109
114
|
* One command of a `fleet-local-settings` note, a record of the adapter's `hqad_iter_settings`. Typed fields only: the
|
|
110
115
|
* daemon builds the program and its arguments (`fleetLocalSettingsProgram`).
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
* (decision 36), `fleet-local-settings` (US-050 c2, conductor ruling on #3042), and the mesh kinds
|
|
7
7
|
* `mesh-reconcile` and `mesh-register-retry` (hook-requests-mesh.ts).
|
|
8
8
|
* Also `fleet-session-start`, US-050 c2 (hook-requests-fleet-session-start.ts).
|
|
9
|
+
* Also `conduct-lanes-link-deliver` and `conduct-link-inherit`, the Codex adapter's
|
|
10
|
+
* SubagentStop conduct-link runs (hook-requests-conduct-link.ts).
|
|
9
11
|
*
|
|
10
12
|
* A hook that used to re-index, commit, copy a plan or edit a pull request
|
|
11
13
|
* now only decides that the work is due and leaves one small file in
|
|
@@ -57,6 +59,7 @@ import { parseMeshOperation, runMeshReconcile, runMeshRegisterRetry } from "./ho
|
|
|
57
59
|
import { MACHINE_CHECKS, machineCheckCollectOnlySupported, runMachineChecks } from "./machine-checks.js";
|
|
58
60
|
import { parseMeshToolWrites, runMeshToolWrites } from "./hook-requests-mesh-tool-writes.js";
|
|
59
61
|
import { parseFleetSessionStart, runFleetSessionStart } from "./hook-requests-fleet-session-start.js";
|
|
62
|
+
import { isConductLinkKind, parseConductLink, runConductLink } from "./hook-requests-conduct-link.js";
|
|
60
63
|
/** The longest note the Rust writer leaves (`NOTE_MAX_BYTES`). */
|
|
61
64
|
export const HOOK_REQUEST_MAX_BYTES = 4096;
|
|
62
65
|
/** The longest `.body` file the Rust writer leaves (`BODY_MAX_BYTES`). */
|
|
@@ -298,6 +301,12 @@ export function parseHookRequest(text, stem) {
|
|
|
298
301
|
return undefined;
|
|
299
302
|
operation = fleet;
|
|
300
303
|
}
|
|
304
|
+
else if (isConductLinkKind(value.kind)) {
|
|
305
|
+
const conduct = parseConductLink(value.kind, args, value.session);
|
|
306
|
+
if (!conduct)
|
|
307
|
+
return undefined;
|
|
308
|
+
operation = conduct;
|
|
309
|
+
}
|
|
301
310
|
else if (isMachineCheckRequestKind(value.kind)) {
|
|
302
311
|
const check = parseMachineCheckOperation(value.kind, args);
|
|
303
312
|
if (!check)
|
|
@@ -399,6 +408,9 @@ export function hookRequestArguments(request) {
|
|
|
399
408
|
case "session-close": return undefined;
|
|
400
409
|
// Run by hook-requests-fleet-session-start.ts with the pinned engine.
|
|
401
410
|
case "fleet-session-start": return [];
|
|
411
|
+
// Not a CLI request: the root's own conduct-link hook script is run (`runConductLink`).
|
|
412
|
+
case "conduct-lanes-link-deliver":
|
|
413
|
+
case "conduct-link-inherit": return [];
|
|
402
414
|
}
|
|
403
415
|
}
|
|
404
416
|
/**
|
|
@@ -1595,6 +1607,12 @@ export function executeHookRequest(request, options) {
|
|
|
1595
1607
|
timeoutMs: options.timeoutMs ?? HOOK_REQUEST_KILL_MS, ...(options.log ? { log: options.log } : {}),
|
|
1596
1608
|
}).catch(() => ({ code: 1 }));
|
|
1597
1609
|
}
|
|
1610
|
+
if (request.operation.kind === "conduct-lanes-link-deliver" || request.operation.kind === "conduct-link-inherit") {
|
|
1611
|
+
return runConductLink(request, request.operation, base, {
|
|
1612
|
+
...(options.signal ? { signal: options.signal } : {}), killGraceMs,
|
|
1613
|
+
timeoutMs: options.timeoutMs ?? HOOK_REQUEST_KILL_MS,
|
|
1614
|
+
}).catch(() => ({ code: 1 }));
|
|
1615
|
+
}
|
|
1598
1616
|
if (request.operation.kind === "startwork-prefetch") {
|
|
1599
1617
|
return runStartworkPrefetch(request, request.operation, base, {
|
|
1600
1618
|
...(options.signal ? { signal: options.signal } : {}), killGraceMs,
|