@indigoai-us/hq-cli 5.345.233 → 5.345.235
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 +67 -0
- package/dist/command-catalog.generated.d.ts +240 -7
- package/dist/command-catalog.generated.js +296 -7
- package/dist/command-registration-plan.d.ts +24 -0
- package/dist/command-registration-plan.js +4 -0
- package/dist/commands/bot-companies.d.ts +4 -1
- package/dist/commands/bot-companies.js +5 -1
- package/dist/commands/bot.d.ts +10 -0
- package/dist/commands/bot.js +165 -36
- package/dist/commands/capacity.js +1 -1
- package/dist/commands/core-handoff.js +2 -2
- package/dist/commands/core-ontology-native.js +5 -4
- package/dist/commands/core-pipeline-workflow-runner-native.js +4 -9
- package/dist/commands/deploy-app-db.d.ts +3 -0
- package/dist/commands/deploy-app-db.js +79 -0
- package/dist/commands/deploy-app-upload.d.ts +3 -0
- package/dist/commands/deploy-app-upload.js +120 -0
- package/dist/commands/deploy-comments.js +46 -1
- package/dist/commands/deploy-mutations.js +71 -5
- package/dist/commands/deploy-ssr.d.ts +3 -0
- package/dist/commands/deploy-ssr.js +74 -0
- package/dist/commands/dm.d.ts +7 -1
- package/dist/commands/dm.js +39 -9
- package/dist/commands/doctor.d.ts +1 -0
- package/dist/commands/doctor.js +26 -10
- package/dist/commands/fingerprint.js +4 -9
- package/dist/commands/install-global.js +10 -0
- package/dist/commands/lanes-accounts.js +5 -5
- package/dist/commands/lanes-hold.js +1 -1
- package/dist/commands/lanes-message.js +3 -3
- package/dist/commands/lanes-move.js +1 -1
- package/dist/commands/lanes-resume.js +6 -6
- package/dist/commands/lanes-watch.js +2 -2
- package/dist/commands/lanes.js +21 -21
- package/dist/commands/work-env.d.ts +90 -0
- package/dist/commands/work-env.js +304 -0
- package/dist/lazy-commands.js +2 -10
- package/dist/lib/bot/api.d.ts +27 -0
- package/dist/lib/bot/api.js +28 -2
- package/dist/lib/bot/cloud-create.d.ts +46 -0
- package/dist/lib/bot/cloud-create.js +128 -0
- package/dist/lib/bot/fleet-daemon.js +4 -1
- package/dist/lib/bot/fleet-local.d.ts +7 -0
- package/dist/lib/bot/fleet-local.js +39 -3
- package/dist/lib/bot/fleet-owner-companies.js +2 -2
- package/dist/lib/bot/promote.d.ts +81 -2
- package/dist/lib/bot/promote.js +425 -51
- package/dist/lib/bot/promotion-hold.d.ts +9 -0
- package/dist/lib/bot/promotion-hold.js +29 -0
- package/dist/lib/bot/promotion-receipt.d.ts +10 -0
- package/dist/lib/bot/promotion-receipt.js +41 -1
- package/dist/lib/bot/promotion-upload.d.ts +6 -1
- package/dist/lib/bot/promotion-upload.js +3 -1
- package/dist/lib/bot/readiness.d.ts +9 -0
- package/dist/lib/bot/readiness.js +16 -0
- package/dist/lib/capacity/route.js +4 -4
- package/dist/lib/capacity/sign-in.js +1 -1
- package/dist/lib/checkpoint-ontology/entity-file.js +15 -17
- package/dist/lib/daemon/catalog.d.ts +2 -0
- package/dist/lib/daemon/catalog.js +2 -0
- package/dist/lib/daemon/hook-requests.js +23 -3
- package/dist/lib/daemon/run.d.ts +14 -0
- package/dist/lib/daemon/run.js +24 -14
- package/dist/lib/deploy-api.d.ts +2 -0
- package/dist/lib/deploy-api.js +9 -0
- package/dist/lib/environment/work-requirements.js +1 -1
- package/dist/lib/hook-engine/coverage.js +50 -0
- package/dist/lib/hot-channels/signals-pass.d.ts +0 -76
- package/dist/lib/hot-channels/signals-pass.js +81 -4
- package/dist/lib/lanes/account-company.js +1 -1
- package/dist/lib/lanes/account-ownership.js +1 -1
- package/dist/lib/lanes/accounts.js +1 -1
- package/dist/lib/lanes/delivery.js +7 -7
- package/dist/lib/lanes/dropbox.js +1 -1
- package/dist/lib/lanes/grants.js +3 -3
- package/dist/lib/lanes/hq-root.js +1 -1
- package/dist/lib/lanes/keep-alive-audit.js +2 -2
- package/dist/lib/lanes/links.js +4 -4
- package/dist/lib/lanes/monitor.js +3 -3
- package/dist/lib/lanes/quota-notice.js +1 -1
- package/dist/lib/lanes/reconcile.js +22 -12
- package/dist/lib/lanes/signal-brief-template.js +1 -1
- package/dist/lib/lanes/worker-continuity.js +1 -1
- package/dist/lib/mesh/live/direct-drain.d.ts +1 -0
- package/dist/lib/mesh/live/direct-drain.js +12 -1
- package/dist/lib/mesh/live/emit.d.ts +1 -1
- package/dist/lib/mesh/live/emit.js +10 -5
- package/dist/lib/mesh/live/flush.js +19 -4
- package/dist/lib/mesh/live/reporting-privacy.d.ts +9 -3
- package/dist/lib/mesh/live/reporting-privacy.js +27 -7
- package/dist/lib/mesh/live/spool.d.ts +2 -0
- package/dist/lib/mesh/live/spool.js +41 -0
- package/dist/lib/signals/sanitize.js +5 -4
- package/dist/lib/signals/steps/garden.js +5 -4
- package/dist/lib/windows/jq.d.ts +17 -0
- package/dist/lib/windows/jq.js +72 -0
- package/dist/utils/frontmatter.d.ts +8 -0
- package/dist/utils/frontmatter.js +11 -2
- package/dist/utils/hq-roots-core.d.ts +5 -0
- package/dist/utils/hq-roots-core.js +18 -9
- package/dist/utils/owner-session.d.ts +13 -0
- package/dist/utils/owner-session.js +28 -0
- package/package.json +7 -7
- package/scripts/install-hook-engine.mjs +8 -15
|
@@ -62,8 +62,10 @@ export async function uploadLocalBotPromotion(input) {
|
|
|
62
62
|
const credential = Buffer.from(JSON.stringify({ kind: "hq-bot-machine-credential-v1", agentUid: bundle.agentUid,
|
|
63
63
|
ownerUid: bundle.ownerUid, digest: bundle.digest, operationId, username: machine.username, secret: machine.secret }));
|
|
64
64
|
try {
|
|
65
|
-
|
|
65
|
+
input.onPreparing?.();
|
|
66
|
+
let state = await api.preparePromotion(bundle.agentUid, { companyUid, operationId, snapshotSha256: bundle.digest, brain: input.brain });
|
|
66
67
|
assertState(state, bundle, companyUid, operationId);
|
|
68
|
+
input.onPrepared?.();
|
|
67
69
|
for (const [kind, bytes] of [["snapshot", snapshot], ["machine-credential", credential]]) {
|
|
68
70
|
const signed = await api.promotionUpload(bundle.agentUid, { companyUid, operationId, kind, bytes: bytes.length, sha256: sha(bytes) });
|
|
69
71
|
assertState(signed.promotion, bundle, companyUid, operationId);
|
|
@@ -73,4 +73,13 @@ export interface SetupStepReporter {
|
|
|
73
73
|
steps(): SetupStepRecord[];
|
|
74
74
|
}
|
|
75
75
|
export declare function createSetupStepReporter(mode: "text" | "json" | "silent", write?: (line: string) => void): SetupStepReporter;
|
|
76
|
+
export type BotOnlineLabel = "cloud" | "moving to cloud" | "creating" | "installing" | "starting" | "unreachable" | "online" | "offline" | "unknown";
|
|
77
|
+
/** The online column of `hq bot list`. A promoted or held bot is never shown as starting here. */
|
|
78
|
+
export declare function botOnlineLabel(row: {
|
|
79
|
+
hosting: "local" | "cloud";
|
|
80
|
+
promotionHold?: unknown;
|
|
81
|
+
readiness: BotReadiness;
|
|
82
|
+
lastHeartbeatOk: boolean | null;
|
|
83
|
+
online: boolean | null;
|
|
84
|
+
}): BotOnlineLabel;
|
|
76
85
|
//# sourceMappingURL=readiness.d.ts.map
|
|
@@ -156,4 +156,20 @@ export function createSetupStepReporter(mode, write = (line) => { process.stdout
|
|
|
156
156
|
steps: () => records.map((entry) => ({ ...entry })),
|
|
157
157
|
};
|
|
158
158
|
}
|
|
159
|
+
/** The online column of `hq bot list`. A promoted or held bot is never shown as starting here. */
|
|
160
|
+
export function botOnlineLabel(row) {
|
|
161
|
+
if (row.hosting === "cloud")
|
|
162
|
+
return "cloud";
|
|
163
|
+
if (row.promotionHold)
|
|
164
|
+
return "moving to cloud";
|
|
165
|
+
if (row.readiness === "creating" || row.readiness === "installing" || row.readiness === "starting")
|
|
166
|
+
return row.readiness;
|
|
167
|
+
if (row.lastHeartbeatOk === false)
|
|
168
|
+
return "unreachable";
|
|
169
|
+
if (row.online === true)
|
|
170
|
+
return "online";
|
|
171
|
+
if (row.online === false)
|
|
172
|
+
return "offline";
|
|
173
|
+
return "unknown";
|
|
174
|
+
}
|
|
159
175
|
//# sourceMappingURL=readiness.js.map
|
|
@@ -374,7 +374,7 @@ export function pickAccount(input) {
|
|
|
374
374
|
...base,
|
|
375
375
|
reason: "held by another person, not used for lanes",
|
|
376
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
|
|
377
|
+
". Use one of your own logins. Change the holder to owner only if this is really your own login: hq runners accounts set-owner " +
|
|
378
378
|
providerId + " " + laneMatch.id + " --holder owner",
|
|
379
379
|
});
|
|
380
380
|
continue;
|
|
@@ -389,7 +389,7 @@ export function pickAccount(input) {
|
|
|
389
389
|
skipped.push({
|
|
390
390
|
...base,
|
|
391
391
|
reason: "usage-only, lanes cannot run on it",
|
|
392
|
-
fix: `hq
|
|
392
|
+
fix: `hq runners accounts enable ${providerId} ${laneMatch.id}`,
|
|
393
393
|
});
|
|
394
394
|
continue;
|
|
395
395
|
}
|
|
@@ -420,7 +420,7 @@ export function pickAccount(input) {
|
|
|
420
420
|
skipped.push({
|
|
421
421
|
...base,
|
|
422
422
|
reason: "usage-only, lanes cannot run on it",
|
|
423
|
-
fix: `hq
|
|
423
|
+
fix: `hq runners accounts enable ${providerId} ${laneMatch.id}`,
|
|
424
424
|
});
|
|
425
425
|
continue;
|
|
426
426
|
}
|
|
@@ -671,7 +671,7 @@ export function pickAccount(input) {
|
|
|
671
671
|
reason: bad.get(key),
|
|
672
672
|
to: to?.account ?? null,
|
|
673
673
|
command: to
|
|
674
|
-
? `hq
|
|
674
|
+
? `hq runners message ${lane.lane_id} --account ${to.account} --text "Continue on account ${to.account}; ${lane.account} is out of room."`
|
|
675
675
|
: null,
|
|
676
676
|
});
|
|
677
677
|
}
|
|
@@ -22,7 +22,7 @@ export function formatRefreshLine(provider, command) {
|
|
|
22
22
|
return command;
|
|
23
23
|
}
|
|
24
24
|
export function laneEnableCommand(provider, label) {
|
|
25
|
-
return `hq
|
|
25
|
+
return `hq runners accounts enable ${provider} ${label}`;
|
|
26
26
|
}
|
|
27
27
|
export class SignInUsageError extends Error {
|
|
28
28
|
constructor(message) {
|
|
@@ -13,28 +13,26 @@
|
|
|
13
13
|
*/
|
|
14
14
|
import { isDeepStrictEqual } from "node:util";
|
|
15
15
|
import yaml from "js-yaml";
|
|
16
|
-
import { splitFrontmatterBlock } from "../../utils/frontmatter.js";
|
|
16
|
+
import { splitFrontmatterBlock, splitFrontmatterBody } from "../../utils/frontmatter.js";
|
|
17
17
|
import { entityId } from "./identity.js";
|
|
18
|
-
// Same delimiters as hq-pro `parser.ts`.
|
|
19
|
-
const FRONTMATTER_RE = /^---\r?\n([\s\S]*?)\r?\n---\r?\n?([\s\S]*)$/;
|
|
20
18
|
/**
|
|
21
19
|
* Parse with the YAML 1.2 core schema, as the cloud's `yaml` package does.
|
|
22
20
|
* js-yaml's default schema would turn unquoted timestamps into Date objects.
|
|
23
21
|
*/
|
|
24
22
|
export function parseEntityFile(content) {
|
|
25
|
-
const
|
|
26
|
-
if (!
|
|
23
|
+
const block = splitFrontmatterBody(content);
|
|
24
|
+
if (!block)
|
|
27
25
|
return null;
|
|
28
26
|
let raw;
|
|
29
27
|
try {
|
|
30
|
-
raw = yaml.load(
|
|
28
|
+
raw = yaml.load(block.yaml, { schema: yaml.CORE_SCHEMA });
|
|
31
29
|
}
|
|
32
30
|
catch {
|
|
33
31
|
return null;
|
|
34
32
|
}
|
|
35
33
|
if (!raw || typeof raw !== "object" || Array.isArray(raw))
|
|
36
34
|
return null;
|
|
37
|
-
return { frontmatter: raw, body:
|
|
35
|
+
return { frontmatter: raw, body: block.body };
|
|
38
36
|
}
|
|
39
37
|
function isStringArray(value) {
|
|
40
38
|
return Array.isArray(value) && value.every((item) => typeof item === "string");
|
|
@@ -151,9 +149,9 @@ function appendAliases(lines, all, added) {
|
|
|
151
149
|
* unchanged so a rerun writes nothing.
|
|
152
150
|
*/
|
|
153
151
|
export function patchEntityFile(content, patch) {
|
|
154
|
-
const
|
|
152
|
+
const block = splitFrontmatterBody(content);
|
|
155
153
|
const parsed = parseEntityFile(content);
|
|
156
|
-
if (!
|
|
154
|
+
if (!block || !parsed)
|
|
157
155
|
return { ok: false, reason: "unparseable" };
|
|
158
156
|
const before = validateEntityFrontmatter(parsed.frontmatter);
|
|
159
157
|
if (typeof before === "string")
|
|
@@ -172,7 +170,7 @@ export function patchEntityFile(content, patch) {
|
|
|
172
170
|
if (!aliasesChanged && !countChanged && !patch.bodyChanged)
|
|
173
171
|
return { ok: true, content, changed: false };
|
|
174
172
|
const newline = content.includes("\r\n") ? "\r\n" : "\n";
|
|
175
|
-
let lines =
|
|
173
|
+
let lines = block.yaml.split(/\r?\n/);
|
|
176
174
|
if (removed)
|
|
177
175
|
lines = replaceTopLevelKey(lines, "aliases", renderAliases(aliases));
|
|
178
176
|
else if (aliasesChanged)
|
|
@@ -183,8 +181,8 @@ export function patchEntityFile(content, patch) {
|
|
|
183
181
|
lines = replaceTopLevelKey(lines, "last_updated", `last_updated: ${patch.lastUpdated}`);
|
|
184
182
|
if (!lines)
|
|
185
183
|
return { ok: false, reason: "missing_owned_key" };
|
|
186
|
-
const head = content.slice(0, content.indexOf(
|
|
187
|
-
const tail = content.slice(content.indexOf(
|
|
184
|
+
const head = content.slice(0, content.indexOf(block.yaml));
|
|
185
|
+
const tail = content.slice(content.indexOf(block.yaml) + block.yaml.length);
|
|
188
186
|
const next = `${head}${lines.join(newline)}${tail}`;
|
|
189
187
|
const check = checkPatched(parsed.frontmatter, next, aliases, signalCount, patch.lastUpdated);
|
|
190
188
|
if (check)
|
|
@@ -243,9 +241,9 @@ function renderWebDomains(domains) {
|
|
|
243
241
|
* `last_updated`. When neither key changes the file is returned unchanged.
|
|
244
242
|
*/
|
|
245
243
|
export function setIdentityKeys(content, patch) {
|
|
246
|
-
const
|
|
244
|
+
const block = splitFrontmatterBody(content);
|
|
247
245
|
const parsed = parseEntityFile(content);
|
|
248
|
-
if (!
|
|
246
|
+
if (!block || !parsed)
|
|
249
247
|
return { ok: false, reason: "unparseable" };
|
|
250
248
|
const before = validateEntityFrontmatter(parsed.frontmatter);
|
|
251
249
|
if (typeof before === "string")
|
|
@@ -263,7 +261,7 @@ export function setIdentityKeys(content, patch) {
|
|
|
263
261
|
if (!idsChanged && !domainsChanged && !refsChanged)
|
|
264
262
|
return { ok: true, content, changed: false };
|
|
265
263
|
const newline = content.includes("\r\n") ? "\r\n" : "\n";
|
|
266
|
-
let lines =
|
|
264
|
+
let lines = block.yaml.split(/\r?\n/);
|
|
267
265
|
if (idsChanged) {
|
|
268
266
|
const rendered = renderExternalIds(patch.externalIds);
|
|
269
267
|
lines = replaceTopLevelKey(lines, "external_ids", rendered) ?? [...lines, ...rendered.split("\n")];
|
|
@@ -280,8 +278,8 @@ export function setIdentityKeys(content, patch) {
|
|
|
280
278
|
if (!stamped)
|
|
281
279
|
return { ok: false, reason: "missing_owned_key" };
|
|
282
280
|
lines = stamped;
|
|
283
|
-
const head = content.slice(0, content.indexOf(
|
|
284
|
-
const tail = content.slice(content.indexOf(
|
|
281
|
+
const head = content.slice(0, content.indexOf(block.yaml));
|
|
282
|
+
const tail = content.slice(content.indexOf(block.yaml) + block.yaml.length);
|
|
285
283
|
const next = `${head}${lines.join(newline)}${tail}`;
|
|
286
284
|
const reparsed = parseEntityFile(next);
|
|
287
285
|
if (!reparsed)
|
|
@@ -122,6 +122,8 @@ export interface FleetBotPlan {
|
|
|
122
122
|
authPending: boolean;
|
|
123
123
|
/** `hq bot start <name>` has not run yet. */
|
|
124
124
|
installPending: boolean;
|
|
125
|
+
/** The bot runs in the cloud, or is held for a move there; it must not run on this machine. */
|
|
126
|
+
promotion?: "cloud" | "moving";
|
|
125
127
|
/** The runtime's own LaunchAgent still exists (it could not be retired), by label. */
|
|
126
128
|
legacyAgent?: string;
|
|
127
129
|
/** A gateway for this bot started outside the daemon is still running; it has been asked to exit. */
|
|
@@ -404,6 +404,8 @@ function planService(service, ctx) {
|
|
|
404
404
|
// The gateway finishes the reply it is sending before it exits; its own LaunchAgent gave it 25 s.
|
|
405
405
|
stopGraceMs: FLEET_BOT_STOP_GRACE_MS,
|
|
406
406
|
blocked: firstBlock([
|
|
407
|
+
[bot.promotion === "cloud", "moved to the cloud; it no longer runs on this computer"],
|
|
408
|
+
[bot.promotion === "moving", `held for its move to the cloud (finish with \`hq bot promote ${bot.name} --company <uid>\`, or add --cancel)`],
|
|
407
409
|
[bot.authPending, `not signed in (run \`hq bot auth ${bot.name}\`)`],
|
|
408
410
|
[bot.installPending, `waiting for \`hq bot start ${bot.name}\``],
|
|
409
411
|
[bot.gateway === null, `the HQ Fleet runtime is not installed for ${bot.name} (run \`hq bot start ${bot.name}\`)`],
|
|
@@ -54,6 +54,10 @@ import * as fs from "node:fs";
|
|
|
54
54
|
import * as os from "node:os";
|
|
55
55
|
import * as path from "node:path";
|
|
56
56
|
import { openStoreDir } from "../safe-store.js";
|
|
57
|
+
import { hasWorkMeshCompanyBinding, workMeshSwitchDisabled } from "../mesh/live/reporting-privacy.js";
|
|
58
|
+
import { readMetaCompanySlug } from "../work-context/company.js";
|
|
59
|
+
import { workContextRoot } from "../work-context/paths.js";
|
|
60
|
+
import { readSessionState } from "../work-context/state.js";
|
|
57
61
|
import { executeAclSuggestion, parseShareCandidates } from "./hook-requests-acl-suggest.js";
|
|
58
62
|
import { parseMeshOperation, runMeshReconcile, runMeshRegisterRetry } from "./hook-requests-mesh.js";
|
|
59
63
|
import { MACHINE_CHECKS, machineCheckCollectOnlySupported, runMachineChecks } from "./machine-checks.js";
|
|
@@ -1430,9 +1434,20 @@ async function runFleetLocalSettings(request, operation, base, options) {
|
|
|
1430
1434
|
* (the shell's redirection failed and the hook did not run).
|
|
1431
1435
|
*/
|
|
1432
1436
|
async function runMeshSessionBind(request, operation, base, options) {
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1437
|
+
const switchOn = operation.disabled !== undefined || workMeshSwitchDisabled(base);
|
|
1438
|
+
if (switchOn) {
|
|
1439
|
+
const contextRoot = workContextRoot(base.HOME, base);
|
|
1440
|
+
const state = readSessionState(operation.sessionId, contextRoot);
|
|
1441
|
+
const metaCompany = readMetaCompanySlug(operation.sessionId, request.root);
|
|
1442
|
+
const bound = hasWorkMeshCompanyBinding(state) &&
|
|
1443
|
+
(metaCompany === undefined || metaCompany === state.companySlug) &&
|
|
1444
|
+
(operation.kind === "mesh-session-register" || operation.company === state.companySlug);
|
|
1445
|
+
if (!bound) {
|
|
1446
|
+
if (operation.disabled !== undefined) {
|
|
1447
|
+
options.log?.(`${operation.kind}: ${operation.disabled} switched the Work Mesh hook off in session ${operation.sessionId}; not bound`);
|
|
1448
|
+
}
|
|
1449
|
+
return { code: 0 };
|
|
1450
|
+
}
|
|
1436
1451
|
}
|
|
1437
1452
|
const hook = path.join(request.root, MESH_SESSION_BIND_HOOK);
|
|
1438
1453
|
try {
|
|
@@ -1449,6 +1464,11 @@ async function runMeshSessionBind(request, operation, base, options) {
|
|
|
1449
1464
|
const env = { ...base };
|
|
1450
1465
|
for (const name of MESH_SESSION_BIND_UNSET)
|
|
1451
1466
|
delete env[name];
|
|
1467
|
+
if (switchOn) {
|
|
1468
|
+
delete env.HQ_WORK_MESH_DISABLED;
|
|
1469
|
+
env.HQ_DISABLED_HOOKS = env.HQ_DISABLED_HOOKS?.split(",")
|
|
1470
|
+
.filter(value => !["*", "work-mesh", "work-mesh-live"].includes(value.trim())).join(",");
|
|
1471
|
+
}
|
|
1452
1472
|
Object.assign(env, { HQ_ROOT: request.root, CLAUDE_CODE_SESSION_ID: operation.sessionId, HQ_HOOK_REQUEST_ID: request.id });
|
|
1453
1473
|
let cwd = request.root;
|
|
1454
1474
|
try {
|
package/dist/lib/daemon/run.d.ts
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
import { acquirePackageUseLease } from "../../utils/package-use-lease.js";
|
|
9
9
|
import { type LegacySyncHolder, type PlanContext, type ServiceName, type UnitPlan } from "./catalog.js";
|
|
10
10
|
import { type SyncCoreVaultPlan } from "../sync-core/engine-home.js";
|
|
11
|
+
import { type DaemonFlagRegistryRead, type DaemonFlagSnapshotSource } from "./flag.js";
|
|
11
12
|
import { type LegacyUnit, type WindowsTaskOwner } from "./legacy.js";
|
|
12
13
|
import { type DaemonLockResult } from "./lock.js";
|
|
13
14
|
import { removeMeshUnitFromOtherHome, type LaunchctlRunner } from "../mesh/live/daemon/unit-home.js";
|
|
@@ -46,6 +47,19 @@ export declare function shouldStartHqd(anywhereEnabled: boolean): boolean;
|
|
|
46
47
|
* revocation stays in place.
|
|
47
48
|
*/
|
|
48
49
|
export declare function refreshHqdRuntimeDecision(readDecision: () => Promise<boolean>, home: string, env: NodeJS.ProcessEnv, onMarkerError?: (error: unknown) => void, syncEnabledMarker?: (enabled: boolean) => void): Promise<boolean>;
|
|
50
|
+
/**
|
|
51
|
+
* The daemon's one flag poller (US-036): the source every timed flag read
|
|
52
|
+
* shares. Each shared registry request also writes the on-disk flag snapshot
|
|
53
|
+
* (shared-flag-reads.ts), then tells the observers in order, so the state file
|
|
54
|
+
* and the hqd runtime events cost no request of their own.
|
|
55
|
+
*/
|
|
56
|
+
export declare function createDaemonRunFlagReads(observers: ReadonlyArray<(read: DaemonFlagRegistryRead, env: NodeJS.ProcessEnv) => void>): DaemonFlagSnapshotSource;
|
|
57
|
+
/**
|
|
58
|
+
* The hqd listener's runtime decision (US-036): the HQ Anywhere flag as the
|
|
59
|
+
* shared read last wrote it to the on-disk snapshot, then the person setting.
|
|
60
|
+
* It makes no registry request of its own.
|
|
61
|
+
*/
|
|
62
|
+
export declare function hqdListenerRuntimeAllowed(env: NodeJS.ProcessEnv, readSetting: () => Promise<boolean | null>): Promise<boolean>;
|
|
49
63
|
/** Route an updater request through the daemon's existing graceful handoff. */
|
|
50
64
|
export declare function handoffForPackageUpdateRequest(requested: boolean, restartDaemon: () => void): void;
|
|
51
65
|
export interface RunDaemonOptions {
|
package/dist/lib/daemon/run.js
CHANGED
|
@@ -38,7 +38,8 @@ import { daemonLanesReconcileHandler } from "../lanes/daemon-reconcile.js";
|
|
|
38
38
|
import { computeLanesMonitorSection } from "./lanes-monitor-state.js";
|
|
39
39
|
import { ensureDaemonLanesReconcileHandler, runDaemonLanesReconcileInProcess } from "./lanes-reconcile-loader.js";
|
|
40
40
|
import { startWhoamiCacheWriter } from "./whoami-cache.js";
|
|
41
|
-
import { SUPERVISOR_HANDOFF_FLAG,
|
|
41
|
+
import { SUPERVISOR_HANDOFF_FLAG, readDaemonFlag } from "./flag.js";
|
|
42
|
+
import { createDaemonSharedFlagReads, hqdListenerFlagGate } from "./shared-flag-reads.js";
|
|
42
43
|
import { createDaemonKillSwitchMonitors } from "./timed-flag-monitors.js";
|
|
43
44
|
import { MACHINE_CHECKS_RESULT_FILE, readMachineCheckResults, startMachineCheckSchedule } from "./machine-checks.js";
|
|
44
45
|
import { createLanesReconcileWatcher } from "./lanes-reconcile-watcher.js";
|
|
@@ -288,6 +289,23 @@ export async function refreshHqdRuntimeDecision(readDecision, home, env, onMarke
|
|
|
288
289
|
}
|
|
289
290
|
return enabled;
|
|
290
291
|
}
|
|
292
|
+
/**
|
|
293
|
+
* The daemon's one flag poller (US-036): the source every timed flag read
|
|
294
|
+
* shares. Each shared registry request also writes the on-disk flag snapshot
|
|
295
|
+
* (shared-flag-reads.ts), then tells the observers in order, so the state file
|
|
296
|
+
* and the hqd runtime events cost no request of their own.
|
|
297
|
+
*/
|
|
298
|
+
export function createDaemonRunFlagReads(observers) {
|
|
299
|
+
return createDaemonSharedFlagReads({ observers });
|
|
300
|
+
}
|
|
301
|
+
/**
|
|
302
|
+
* The hqd listener's runtime decision (US-036): the HQ Anywhere flag as the
|
|
303
|
+
* shared read last wrote it to the on-disk snapshot, then the person setting.
|
|
304
|
+
* It makes no registry request of its own.
|
|
305
|
+
*/
|
|
306
|
+
export function hqdListenerRuntimeAllowed(env, readSetting) {
|
|
307
|
+
return anywhereRuntimeAllowed(env, { ...hqdListenerFlagGate(), readSetting });
|
|
308
|
+
}
|
|
291
309
|
/** Route an updater request through the daemon's existing graceful handoff. */
|
|
292
310
|
export function handoffForPackageUpdateRequest(requested, restartDaemon) {
|
|
293
311
|
if (requested)
|
|
@@ -1131,12 +1149,10 @@ export async function runDaemon(opts) {
|
|
|
1131
1149
|
// its own beyond a rare fallback (anywhere-listener.ts).
|
|
1132
1150
|
const hqdRuntimeEvents = createHqdRuntimeEvents();
|
|
1133
1151
|
const observeHqdRuntime = observeHqdRuntimeFlag(() => hqdRuntimeEvents.emit());
|
|
1134
|
-
const flagSnapshots =
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
},
|
|
1139
|
-
});
|
|
1152
|
+
const flagSnapshots = createDaemonRunFlagReads([
|
|
1153
|
+
observeHqdRuntime,
|
|
1154
|
+
(read, readEnv) => stateWriter.onRegistryRead(read, readEnv),
|
|
1155
|
+
]);
|
|
1140
1156
|
const killSwitches = createDaemonKillSwitchMonitors({ env, log, snapshots: flagSnapshots });
|
|
1141
1157
|
const childBootstrapHandoffWatchFlag = killSwitches.childBootstrapHandoffWatch;
|
|
1142
1158
|
const lanesReconcileFileWatchFlag = killSwitches.lanesReconcileFileWatch;
|
|
@@ -1856,13 +1872,7 @@ export async function runDaemon(opts) {
|
|
|
1856
1872
|
exit: (code) => tccEpermExit(code),
|
|
1857
1873
|
});
|
|
1858
1874
|
const hqdListener = await startHqdRuntimeListener({
|
|
1859
|
-
isEnabled: async () => refreshHqdRuntimeDecision(async () => shouldStartHqd(await
|
|
1860
|
-
refreshFlag: async () => {
|
|
1861
|
-
const { refreshFlagRegistrySnapshot } = await import("../flag-registry.js");
|
|
1862
|
-
await refreshFlagRegistrySnapshot(5_000);
|
|
1863
|
-
},
|
|
1864
|
-
readSetting: readPersonSetting,
|
|
1865
|
-
})), home, env, (error) => log("warn", `hqd runtime marker update failed: ${error.message ?? String(error)}`), (enabled) => syncHqdEnabledMarker(hqdSocketPath(home, env), enabled)),
|
|
1875
|
+
isEnabled: async () => refreshHqdRuntimeDecision(async () => shouldStartHqd(await hqdListenerRuntimeAllowed(env, readPersonSetting)), home, env, (error) => log("warn", `hqd runtime marker update failed: ${error.message ?? String(error)}`), (enabled) => syncHqdEnabledMarker(hqdSocketPath(home, env), enabled)),
|
|
1866
1876
|
startServer: async () => {
|
|
1867
1877
|
const startConfig = readDaemonConfig(paths.configPath);
|
|
1868
1878
|
const hqRoot = startConfig.hqRoot ?? (env.HQ_ROOT?.trim() || undefined);
|
package/dist/lib/deploy-api.d.ts
CHANGED
|
@@ -2,4 +2,6 @@
|
|
|
2
2
|
export declare const DEPLOY_API_URL: string;
|
|
3
3
|
export declare function deployHeaders(token: string, json?: boolean, extra?: Record<string, string>): Record<string, string>;
|
|
4
4
|
export declare function deployApiRequest(token: string, route: string, method: string, body?: unknown, extraHeaders?: Record<string, string>): Promise<Response>;
|
|
5
|
+
/** Submit an app archive on the authenticated multipart route. Fetch owns the boundary. */
|
|
6
|
+
export declare function deployApiFormRequest(token: string, route: string, body: FormData, extraHeaders: Record<string, string>): Promise<Response>;
|
|
5
7
|
//# sourceMappingURL=deploy-api.d.ts.map
|
package/dist/lib/deploy-api.js
CHANGED
|
@@ -20,4 +20,13 @@ export async function deployApiRequest(token, route, method, body, extraHeaders
|
|
|
20
20
|
signal: AbortSignal.timeout(DEPLOY_API_REQUEST_TIMEOUT_MS),
|
|
21
21
|
});
|
|
22
22
|
}
|
|
23
|
+
/** Submit an app archive on the authenticated multipart route. Fetch owns the boundary. */
|
|
24
|
+
export function deployApiFormRequest(token, route, body, extraHeaders) {
|
|
25
|
+
return fetch(deployApiUrl(route), {
|
|
26
|
+
method: "POST",
|
|
27
|
+
headers: deployHeaders(token, false, extraHeaders),
|
|
28
|
+
body,
|
|
29
|
+
redirect: "error",
|
|
30
|
+
});
|
|
31
|
+
}
|
|
23
32
|
//# sourceMappingURL=deploy-api.js.map
|
|
@@ -382,7 +382,7 @@ export function withRepairedCompany(document, company) {
|
|
|
382
382
|
return {
|
|
383
383
|
...document,
|
|
384
384
|
company,
|
|
385
|
-
origin: { ...document.origin, derived_from: ["company: the work's own company (set by hq
|
|
385
|
+
origin: { ...document.origin, derived_from: ["company: the work's own company (set by hq runners repair-company)", ...derivedFrom] },
|
|
386
386
|
assumptions: (document.assumptions ?? []).filter((entry) => !entry.startsWith("No company on the work")),
|
|
387
387
|
};
|
|
388
388
|
}
|
|
@@ -1682,8 +1682,58 @@ export function uncoveredHooks(root, host, event, covers, env = process.env) {
|
|
|
1682
1682
|
if (hold)
|
|
1683
1683
|
missing.push(`(native PreCompact compatibility: ${hold})`);
|
|
1684
1684
|
}
|
|
1685
|
+
if (host === 'grok' && GROK_STOP_OBSERVE.has(event) && covered.includes(`master-hook:${event}`)) {
|
|
1686
|
+
for (const hook of grokStopObserveUncovered(root, event, covers))
|
|
1687
|
+
if (!missing.includes(hook))
|
|
1688
|
+
missing.push(hook);
|
|
1689
|
+
}
|
|
1685
1690
|
return missing;
|
|
1686
1691
|
}
|
|
1692
|
+
/** Grok events the adapter dispatched as its settings.json `Stop` entries (lifecycle_master.rs `dispatched`). */
|
|
1693
|
+
const GROK_STOP_OBSERVE = new Set(['StopCancelled', 'StopFailure']);
|
|
1694
|
+
/**
|
|
1695
|
+
* The Stop hooks the old path ran on a Grok StopCancelled or StopFailure that
|
|
1696
|
+
* the claim does not cover, as lifecycle_master.rs `stop_observe_uncovered`
|
|
1697
|
+
* lists them for its guard: with master-hook among the settings.json Stop
|
|
1698
|
+
* entries, every Stop hook (registry rows, folders, other settings commands);
|
|
1699
|
+
* without it, only the other settings.json Stop commands. Covered are the
|
|
1700
|
+
* event's own claims, master-hook:Stop and grok-adapter:Stop, and the Stop
|
|
1701
|
+
* host-set claims for grok. Without this, reindex switches the event and the
|
|
1702
|
+
* native guard refuses every one (US-050 c7, O2 R1).
|
|
1703
|
+
*/
|
|
1704
|
+
function grokStopObserveUncovered(root, event, covers) {
|
|
1705
|
+
const stop = shellHooks(root, 'grok', 'Stop');
|
|
1706
|
+
if (!stop)
|
|
1707
|
+
return [UNREADABLE];
|
|
1708
|
+
let master = 0;
|
|
1709
|
+
try {
|
|
1710
|
+
const settings = JSON.parse(fs.readFileSync(path.join(root, '.claude', 'settings.json'), 'utf8'));
|
|
1711
|
+
const groups = settings?.hooks?.Stop;
|
|
1712
|
+
for (const group of Array.isArray(groups) ? groups : []) {
|
|
1713
|
+
for (const entry of Array.isArray(group?.hooks) ? group.hooks : []) {
|
|
1714
|
+
const command = entry?.command;
|
|
1715
|
+
if (typeof command !== 'string' || !command.includes('master-hook.sh'))
|
|
1716
|
+
continue;
|
|
1717
|
+
master += 1;
|
|
1718
|
+
if (entry.args != null)
|
|
1719
|
+
master += 1;
|
|
1720
|
+
}
|
|
1721
|
+
}
|
|
1722
|
+
}
|
|
1723
|
+
catch {
|
|
1724
|
+
return [UNREADABLE];
|
|
1725
|
+
}
|
|
1726
|
+
// Two master-hook entries, or the exec form: the native guard refuses.
|
|
1727
|
+
if (master > 1)
|
|
1728
|
+
return [`(native Grok ${event}: master-hook Stop entry not modelled)`];
|
|
1729
|
+
const listed = master === 1 ? stop : stop.filter((hook) => hook.startsWith('settings:'));
|
|
1730
|
+
const onHost = {};
|
|
1731
|
+
for (const [key, ids] of Object.entries(covers ?? {}))
|
|
1732
|
+
if (key.includes('@'))
|
|
1733
|
+
onHost[key] = ids;
|
|
1734
|
+
const covered = [...coveredOn(covers, event, 'grok'), 'master-hook:Stop', 'grok-adapter:Stop', ...coveredOn(onHost, 'Stop', 'grok')];
|
|
1735
|
+
return listed.filter((hook) => !covered.some((claim) => claimCovers(claim, hook)));
|
|
1736
|
+
}
|
|
1687
1737
|
/**
|
|
1688
1738
|
* `target` narrowed to the events it covers in full on `host` in this HQ
|
|
1689
1739
|
* root; null when none is covered (every event stays on the old dispatcher),
|
|
@@ -1,79 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The local signals pass (US-011). After each hot-channel adapter run, the
|
|
3
|
-
* pass takes the adapter's channel through the ontology worklist, asks
|
|
4
|
-
* `claude -p` for signals one document at a time, and writes those signals to
|
|
5
|
-
* `companies/{co}/signals/`. It returns the count for the run ledger.
|
|
6
|
-
*
|
|
7
|
-
* Work comes from the worklist, not only from this run's landings: when the
|
|
8
|
-
* worklist script exits 0, the pass takes the channel's unprocessed items in
|
|
9
|
-
* the worklist's order (newest first) up to the run's document cap. Items the
|
|
10
|
-
* cap leaves over stay unmarked, and a later run picks them up, including a
|
|
11
|
-
* run that landed nothing (a bounded backlog drain: at most
|
|
12
|
-
* DEFAULT_MAX_SIGNAL_DOCS claude calls per run, and no claude call at all when
|
|
13
|
-
* the backlog is empty). A channel with no source.yaml (worklist exit 2, the
|
|
14
|
-
* usual case for a hot channel such as `meeting-events`) has no worklist, so
|
|
15
|
-
* the pass keeps its own backlog: landed documents it has not processed yet
|
|
16
|
-
* are listed in `sources/_signals-pending/{channel}.json` and drained, newest
|
|
17
|
-
* first by `when` (else `created_at`), on later runs under the same cap. A
|
|
18
|
-
* cloud-run source (exit 4) is skipped.
|
|
19
|
-
*
|
|
20
|
-
* A landed document with both `payload_ref` and `raw_ref` is a pointer (the
|
|
21
|
-
* meetings, Slack and Attio adapters land these). For it, claude gets the
|
|
22
|
-
* pointer followed by the document `payload_ref` names, capped at
|
|
23
|
-
* MAX_PAYLOAD_BYTES. A payload outside `sources/`, missing or unreadable falls
|
|
24
|
-
* back to the pointer alone, and the reason is warned and kept on the signal.
|
|
25
|
-
*
|
|
26
|
-
* Runtime: Claude Code (`claude -p`) by default, exactly as before. When the
|
|
27
|
-
* Executive bot (the bot whose runtime the pass already reads for its
|
|
28
|
-
* signed-out wording) is a Codex bot with `signalsRuntime: "bot"` in bot.json
|
|
29
|
-
* (`hq bot set <name> --signals-runtime bot`), the pass runs on Codex
|
|
30
|
-
* instead, through `runRuntimeTurn`, the turn runner a Daily Brief job uses.
|
|
31
|
-
* The argv and environment differ from a DM turn on purpose, because the
|
|
32
|
-
* documents are untrusted (see codexSignalsArgs and codexSignalsEnv). The
|
|
33
|
-
* opt-in defaults off so the first Codex runs can be compared with Claude's.
|
|
34
|
-
* When it is on, a failed Codex run is a Codex failure (`codex-*` codes); it
|
|
35
|
-
* never falls back to Claude.
|
|
36
|
-
*
|
|
37
|
-
* Billing: policy hq-no-headless-print-subscription-billing forbids headless
|
|
38
|
-
* `claude -p` / `codex exec` in general.
|
|
39
|
-
* - Claude: this is its allowed case, per the owner decision of 2026-10-21:
|
|
40
|
-
* the owner's own `claude` login, on their own machine, in a bounded
|
|
41
|
-
* single-turn call.
|
|
42
|
-
* - Codex: narrow exception hq-signals-pass-codex-exec-narrow-exception (owner
|
|
43
|
-
* decision 2026-11-15). It holds only while the Codex call is
|
|
44
|
-
* 1. a single bounded turn (one `codex exec`, a per-document timeout),
|
|
45
|
-
* 2. with every Codex tool and feature off (codexLockdownFlags in
|
|
46
|
-
* signals/codex-lockdown.ts: shell, apps, plugins, hooks, multi-agent,
|
|
47
|
-
* web search, browser and computer use, bundled skills),
|
|
48
|
-
* 3. with no network (`permissions.*.network.enabled=false`),
|
|
49
|
-
* 4. with read access limited to the empty temp dir plus the codex install
|
|
50
|
-
* dir, never $HOME, ~/.hq, or a parent of either
|
|
51
|
-
* (resolveCodexLockdownTarget),
|
|
52
|
-
* 5. under an environment allowlist (CODEX_SIGNALS_ENV_ALLOWLIST).
|
|
53
|
-
* The login is the bot's own Codex login dir (never the owner's ~/.codex,
|
|
54
|
-
* and not available for an HQ Fleet Runtime bot), used in place so Codex's
|
|
55
|
-
* own refresh lock applies; the pass never copies or writes it.
|
|
56
|
-
* A change that loosens any of these is outside the exception;
|
|
57
|
-
* signals-pass.codex.test.ts pins all five.
|
|
58
|
-
* Cloud Claude is not the bot brain, and no model is called from the poller
|
|
59
|
-
* itself. Do not reuse this pass for a shared, fleet or hosted identity.
|
|
60
|
-
*
|
|
61
|
-
* Failures: a pass that fails keeps the real class as its ledger code (see
|
|
62
|
-
* SignalsPassErrorCode), and writes the provider's own reason, redacted and
|
|
63
|
-
* cut, to `warn`. The reason stays out of the ledger because the ledger syncs
|
|
64
|
-
* with the company vault. A failed document is never marked done, so a later
|
|
65
|
-
* run picks it up. No account is picked and no other provider is called here.
|
|
66
|
-
*
|
|
67
|
-
* Unusable replies: a document whose reply is `claude-bad-output` is sent
|
|
68
|
-
* again, up to BAD_OUTPUT_ATTEMPTS calls in all. If every reply is unusable the
|
|
69
|
-
* pass leaves that document for a later run, goes on to the next one, and
|
|
70
|
-
* fails with `claude-bad-output` at the end. Every other failure class stops
|
|
71
|
-
* the pass at once, because it would fail the next document the same way. A
|
|
72
|
-
* reply with no stdout is not sent again, and BAD_OUTPUT_STOP_AFTER documents
|
|
73
|
-
* in a row with unusable replies stop the pass, for the same reason. So a run
|
|
74
|
-
* makes at most the document cap (`maxDocs`) × BAD_OUTPUT_ATTEMPTS calls, and
|
|
75
|
-
* BAD_OUTPUT_STOP_AFTER × BAD_OUTPUT_ATTEMPTS when every reply is unusable.
|
|
76
|
-
*/
|
|
77
1
|
import type { BotRuntimeId } from "../bot/config.js";
|
|
78
2
|
import { type SpawnLike } from "../bot/runtime/index.js";
|
|
79
3
|
import type { HotChannelRunResult, WriteGuard } from "./loop.js";
|
|
@@ -1,4 +1,81 @@
|
|
|
1
1
|
import { prepareSignalPublication, flushSignalPublications } from "../bot/jobs/signal-to-lane.js";
|
|
2
|
+
/**
|
|
3
|
+
* The local signals pass (US-011). After each hot-channel adapter run, the
|
|
4
|
+
* pass takes the adapter's channel through the ontology worklist, asks
|
|
5
|
+
* `claude -p` for signals one document at a time, and writes those signals to
|
|
6
|
+
* `companies/{co}/signals/`. It returns the count for the run ledger.
|
|
7
|
+
*
|
|
8
|
+
* Work comes from the worklist, not only from this run's landings: when the
|
|
9
|
+
* worklist script exits 0, the pass takes the channel's unprocessed items in
|
|
10
|
+
* the worklist's order (newest first) up to the run's document cap. Items the
|
|
11
|
+
* cap leaves over stay unmarked, and a later run picks them up, including a
|
|
12
|
+
* run that landed nothing (a bounded backlog drain: at most
|
|
13
|
+
* DEFAULT_MAX_SIGNAL_DOCS claude calls per run, and no claude call at all when
|
|
14
|
+
* the backlog is empty). A channel with no source.yaml (worklist exit 2, the
|
|
15
|
+
* usual case for a hot channel such as `meeting-events`) has no worklist, so
|
|
16
|
+
* the pass keeps its own backlog: landed documents it has not processed yet
|
|
17
|
+
* are listed in `sources/_signals-pending/{channel}.json` and drained, newest
|
|
18
|
+
* first by `when` (else `created_at`), on later runs under the same cap. A
|
|
19
|
+
* cloud-run source (exit 4) is skipped.
|
|
20
|
+
*
|
|
21
|
+
* A landed document with both `payload_ref` and `raw_ref` is a pointer (the
|
|
22
|
+
* meetings, Slack and Attio adapters land these). For it, claude gets the
|
|
23
|
+
* pointer followed by the document `payload_ref` names, capped at
|
|
24
|
+
* MAX_PAYLOAD_BYTES. A payload outside `sources/`, missing or unreadable falls
|
|
25
|
+
* back to the pointer alone, and the reason is warned and kept on the signal.
|
|
26
|
+
*
|
|
27
|
+
* Runtime: Claude Code (`claude -p`) by default, exactly as before. When the
|
|
28
|
+
* Executive bot (the bot whose runtime the pass already reads for its
|
|
29
|
+
* signed-out wording) is a Codex bot with `signalsRuntime: "bot"` in bot.json
|
|
30
|
+
* (`hq bot set <name> --signals-runtime bot`), the pass runs on Codex
|
|
31
|
+
* instead, through `runRuntimeTurn`, the turn runner a Daily Brief job uses.
|
|
32
|
+
* The argv and environment differ from a DM turn on purpose, because the
|
|
33
|
+
* documents are untrusted (see codexSignalsArgs and codexSignalsEnv). The
|
|
34
|
+
* opt-in defaults off so the first Codex runs can be compared with Claude's.
|
|
35
|
+
* When it is on, a failed Codex run is a Codex failure (`codex-*` codes); it
|
|
36
|
+
* never falls back to Claude.
|
|
37
|
+
*
|
|
38
|
+
* Billing: policy hq-no-headless-print-subscription-billing forbids headless
|
|
39
|
+
* `claude -p` / `codex exec` in general.
|
|
40
|
+
* - Claude: this is its allowed case, per the owner decision of 2026-10-21:
|
|
41
|
+
* the owner's own `claude` login, on their own machine, in a bounded
|
|
42
|
+
* single-turn call.
|
|
43
|
+
* - Codex: narrow exception hq-signals-pass-codex-exec-narrow-exception (owner
|
|
44
|
+
* decision 2026-11-15). It holds only while the Codex call is
|
|
45
|
+
* 1. a single bounded turn (one `codex exec`, a per-document timeout),
|
|
46
|
+
* 2. with every Codex tool and feature off (codexLockdownFlags in
|
|
47
|
+
* signals/codex-lockdown.ts: shell, apps, plugins, hooks, multi-agent,
|
|
48
|
+
* web search, browser and computer use, bundled skills),
|
|
49
|
+
* 3. with no network (`permissions.*.network.enabled=false`),
|
|
50
|
+
* 4. with read access limited to the empty temp dir plus the codex install
|
|
51
|
+
* dir, never $HOME, ~/.hq, or a parent of either
|
|
52
|
+
* (resolveCodexLockdownTarget),
|
|
53
|
+
* 5. under an environment allowlist (CODEX_SIGNALS_ENV_ALLOWLIST).
|
|
54
|
+
* The login is the bot's own Codex login dir (never the owner's ~/.codex,
|
|
55
|
+
* and not available for an HQ Fleet Runtime bot), used in place so Codex's
|
|
56
|
+
* own refresh lock applies; the pass never copies or writes it.
|
|
57
|
+
* A change that loosens any of these is outside the exception;
|
|
58
|
+
* signals-pass.codex.test.ts pins all five.
|
|
59
|
+
* Cloud Claude is not the bot brain, and no model is called from the poller
|
|
60
|
+
* itself. Do not reuse this pass for a shared, fleet or hosted identity.
|
|
61
|
+
*
|
|
62
|
+
* Failures: a pass that fails keeps the real class as its ledger code (see
|
|
63
|
+
* SignalsPassErrorCode), and writes the provider's own reason, redacted and
|
|
64
|
+
* cut, to `warn`. The reason stays out of the ledger because the ledger syncs
|
|
65
|
+
* with the company vault. A failed document is never marked done, so a later
|
|
66
|
+
* run picks it up. No account is picked and no other provider is called here.
|
|
67
|
+
*
|
|
68
|
+
* Unusable replies: a document whose reply is `claude-bad-output` is sent
|
|
69
|
+
* again, up to BAD_OUTPUT_ATTEMPTS calls in all. If every reply is unusable the
|
|
70
|
+
* pass leaves that document for a later run, goes on to the next one, and
|
|
71
|
+
* fails with `claude-bad-output` at the end. Every other failure class stops
|
|
72
|
+
* the pass at once, because it would fail the next document the same way. A
|
|
73
|
+
* reply with no stdout is not sent again, and BAD_OUTPUT_STOP_AFTER documents
|
|
74
|
+
* in a row with unusable replies stop the pass, for the same reason. So a run
|
|
75
|
+
* makes at most the document cap (`maxDocs`) × BAD_OUTPUT_ATTEMPTS calls, and
|
|
76
|
+
* BAD_OUTPUT_STOP_AFTER × BAD_OUTPUT_ATTEMPTS when every reply is unusable.
|
|
77
|
+
*/
|
|
78
|
+
import { splitFrontmatterBody } from "../../utils/frontmatter.js";
|
|
2
79
|
import { isRuntimeUsageLimit } from "../bot/runtime-failure.js";
|
|
3
80
|
import { createCodexRuntime, defaultSpawn, runRuntimeTurn, RuntimeError } from "../bot/runtime/index.js";
|
|
4
81
|
import { CODEX_LOCKDOWN_DISABLED_FEATURES, CODEX_LOCKDOWN_ENV_ALLOWLIST, codexLockdownEnv, codexLockdownFilesystem, codexLockdownFlags, lockdownHomes, resolveCodexLockdownTarget, } from "../signals/codex-lockdown.js";
|
|
@@ -296,13 +373,13 @@ function isSafeChannel(channel) {
|
|
|
296
373
|
}
|
|
297
374
|
}
|
|
298
375
|
export function splitFrontmatter(text) {
|
|
299
|
-
const
|
|
300
|
-
if (!
|
|
376
|
+
const block = splitFrontmatterBody(text, "lf");
|
|
377
|
+
if (!block)
|
|
301
378
|
return { frontmatter: {}, body: text };
|
|
302
|
-
const parsed = yaml.load(
|
|
379
|
+
const parsed = yaml.load(block.yaml);
|
|
303
380
|
return {
|
|
304
381
|
frontmatter: parsed && typeof parsed === "object" ? parsed : {},
|
|
305
|
-
body:
|
|
382
|
+
body: block.body,
|
|
306
383
|
};
|
|
307
384
|
}
|
|
308
385
|
function isMissing(err) {
|
|
@@ -50,7 +50,7 @@ export function companyMismatchError(input) {
|
|
|
50
50
|
return new LanesError("account_held_by_other", `Every enabled ${input.provider} account is held by another person and is not used for lanes: ` +
|
|
51
51
|
`${held.map((row) => `${row.account} (${row.holder})`).join(", ")}. ` +
|
|
52
52
|
"Sign in with one of your own logins. Change a holder to owner only if that login is really yours: " +
|
|
53
|
-
`hq
|
|
53
|
+
`hq runners accounts set-owner ${input.provider} <id> --holder owner`, { provider: input.provider, held_accounts: held, config_key: `providers.${input.provider}.accounts.<id>.holder`, config_file: "personal/lanes/config.json" });
|
|
54
54
|
}
|
|
55
55
|
if (!companyEnforcementActive(input.providerAccounts))
|
|
56
56
|
return undefined;
|