@indigoai-us/hq-cli 5.345.264 → 5.345.268

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.
Files changed (68) hide show
  1. package/CHANGELOG.md +77 -0
  2. package/assets/scaffold/core/scripts/hq-delegate-grant.sh +4 -48
  3. package/assets/scaffold/core/scripts/hq-delegate-secrets.sh +16 -10
  4. package/assets/scaffold/core/scripts/hq-delegate-send.sh +17 -1
  5. package/contracts/host-canary-release.json +7 -7
  6. package/dist/command-catalog.generated.d.ts +30 -1
  7. package/dist/command-catalog.generated.js +37 -1
  8. package/dist/commands/core-delegate-w1b.js +21 -40
  9. package/dist/commands/core-delegate.js +11 -8
  10. package/dist/commands/core-job-notify-native.d.ts +6 -0
  11. package/dist/commands/core-job-notify-native.js +64 -4
  12. package/dist/commands/core-jobs-native.js +3 -16
  13. package/dist/commands/files-browse.d.ts +83 -4
  14. package/dist/commands/files-browse.js +404 -54
  15. package/dist/commands/groups.js +2 -2
  16. package/dist/commands/install-global.js +54 -17
  17. package/dist/commands/skill.js +15 -0
  18. package/dist/lib/agent-kit/mcp/tools.js +2 -2
  19. package/dist/lib/agent-kit/skills.js +12 -6
  20. package/dist/lib/daemon/machine-check-owner.js +1 -1
  21. package/dist/lib/daemon/machine-checks.d.ts +3 -11
  22. package/dist/lib/daemon/machine-checks.js +4 -15
  23. package/dist/lib/daemon/merge-sections.d.ts +44 -9
  24. package/dist/lib/daemon/merge-sections.js +234 -37
  25. package/dist/lib/daemon/run.js +1 -0
  26. package/dist/lib/doctor/checks/antigravity-wiring.js +20 -4
  27. package/dist/lib/doctor/checks/codex-wiring.d.ts +4 -2
  28. package/dist/lib/doctor/checks/codex-wiring.js +70 -13
  29. package/dist/lib/doctor/checks/fleet-hook-core.d.ts +4 -4
  30. package/dist/lib/doctor/checks/fleet-hook-core.js +5 -10
  31. package/dist/lib/doctor/checks/grok-wiring.js +38 -0
  32. package/dist/lib/doctor/checks/hook-engine.js +0 -2
  33. package/dist/lib/doctor/checks/host-core.d.ts +1 -1
  34. package/dist/lib/doctor/checks/host-core.js +17 -42
  35. package/dist/lib/doctor/fix/process-identity.d.ts +2 -0
  36. package/dist/lib/doctor/fix/process-identity.js +5 -2
  37. package/dist/lib/hook-engine/coverage.d.ts +10 -1
  38. package/dist/lib/hook-engine/coverage.js +76 -9
  39. package/dist/lib/hook-engine/fleet-registration.js +7 -4
  40. package/dist/lib/hook-engine/native-precompact-compatibility.json +8 -1
  41. package/dist/lib/hook-engine/native-stop-compatibility.json +30 -11
  42. package/dist/lib/hook-engine/reconcile.d.ts +10 -1
  43. package/dist/lib/hook-engine/reconcile.js +351 -44
  44. package/dist/lib/hook-engine/stable-gate.d.ts +43 -0
  45. package/dist/lib/hook-engine/stable-gate.js +276 -0
  46. package/dist/lib/hot-channels/fleet-complete.js +2 -2
  47. package/dist/lib/install/antigravity-targets.js +2 -1
  48. package/dist/lib/install/claude-targets.d.ts +6 -6
  49. package/dist/lib/install/claude-targets.js +13 -9
  50. package/dist/lib/install/codex-targets.d.ts +4 -4
  51. package/dist/lib/install/codex-targets.js +26 -16
  52. package/dist/lib/install/hook-target.d.ts +23 -2
  53. package/dist/lib/install/hook-target.js +89 -16
  54. package/dist/lib/outpost-identity-env.d.ts +18 -0
  55. package/dist/lib/outpost-identity-env.js +29 -0
  56. package/dist/lib/signals/reply.js +25 -5
  57. package/dist/lib/signals/steps/extract.d.ts +28 -4
  58. package/dist/lib/signals/steps/extract.js +158 -10
  59. package/dist/lib/sync-core/release.d.ts +1 -1
  60. package/dist/lib/sync-core/release.js +2 -2
  61. package/dist/utils/core-next-kill.d.ts +2 -15
  62. package/dist/utils/core-next-kill.js +5 -36
  63. package/dist/utils/hook-engine-rollup.js +0 -1
  64. package/dist/utils/hook-trust.d.ts +2 -0
  65. package/dist/utils/hook-trust.js +156 -13
  66. package/dist/utils/host-registration.d.ts +158 -4
  67. package/dist/utils/host-registration.js +500 -17
  68. package/package.json +7 -7
@@ -7,6 +7,7 @@ import { spawnSync } from "node:child_process";
7
7
  import { load } from "js-yaml";
8
8
  import { serializeJqJson } from "../lib/core-utils/jq-json-serializer.js";
9
9
  import { registerCoreJobLeaf } from "./core-job-native-utils.js";
10
+ import { OUTPOST_IDENTITY_ENV_FILE, parseOutpostIdentityAssignments } from "../lib/outpost-identity-env.js";
10
11
  const USAGE = [
11
12
  "hq-job-notify.sh — dm-only remediation alerts for Outpost scheduled jobs (US-006).",
12
13
  "",
@@ -210,7 +211,7 @@ const COGNITO_SUB = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{1
210
211
  function cachedWhoami(deps, json) {
211
212
  return (deps.daemonWhoami ?? ((asJson) => daemonWhoamiOutput(asJson, deps.env)))(json);
212
213
  }
213
- function resolveCognitoOwner(owner, deps) {
214
+ function whoamiOwnerEmail(owner, deps) {
214
215
  if (!deps.commandExists("hq"))
215
216
  return "";
216
217
  let parsed;
@@ -235,6 +236,63 @@ function resolveCognitoOwner(owner, deps) {
235
236
  }
236
237
  return "";
237
238
  }
239
+ function identityValue(value) {
240
+ const trimmed = (value ?? "").trim();
241
+ return trimmed === "null" ? "" : trimmed;
242
+ }
243
+ function identityFileSource(deps) {
244
+ const empty = { userId: "", emails: [] };
245
+ if (deps.env.HQ_JOB_SKIP_SYSTEM_IDENTITY === "1")
246
+ return empty;
247
+ let contents;
248
+ try {
249
+ contents = deps.readFile(deps.identityFile ?? OUTPOST_IDENTITY_ENV_FILE);
250
+ }
251
+ catch {
252
+ return empty;
253
+ }
254
+ const last = {};
255
+ // Later assignments win, as when the file is sourced by a shell.
256
+ for (const { key, value } of parseOutpostIdentityAssignments(contents))
257
+ last[key] = value;
258
+ return {
259
+ userId: identityValue(last.OUTPOST_USER_ID),
260
+ emails: [identityValue(last.OUTPOST_OWNER_EMAIL), identityValue(last.OWNER_EMAIL)],
261
+ };
262
+ }
263
+ /**
264
+ * The box's own owner email when `owner` is this Outpost's user id
265
+ * (OUTPOST_USER_ID), from the process env or the Outpost identity env file.
266
+ * Company Outposts and machine sessions whose cached token carries no
267
+ * delegated owner resolve here. An email is used only from a source whose own
268
+ * OUTPOST_USER_ID equals the owner, and nothing resolves when the env and the
269
+ * file name different user ids.
270
+ */
271
+ function outpostIdentityOwnerEmail(owner, deps) {
272
+ const target = owner.toLowerCase();
273
+ const envSource = {
274
+ userId: identityValue(deps.env.OUTPOST_USER_ID),
275
+ emails: [identityValue(deps.env.OUTPOST_OWNER_EMAIL), identityValue(deps.env.OWNER_EMAIL)],
276
+ };
277
+ const named = [envSource, identityFileSource(deps)].filter((source) => source.userId);
278
+ if (named.length === 0 || named.some((source) => source.userId.toLowerCase() !== target))
279
+ return "";
280
+ for (const source of named) {
281
+ const email = source.emails.find((candidate) => EMAIL_RECIPIENT.test(candidate));
282
+ if (email)
283
+ return email;
284
+ }
285
+ return "";
286
+ }
287
+ function resolveCognitoOwner(owner, deps) {
288
+ const fromWhoami = whoamiOwnerEmail(owner, deps);
289
+ if (fromWhoami)
290
+ return { recipient: fromWhoami, via: "hq whoami" };
291
+ const fromIdentity = outpostIdentityOwnerEmail(owner, deps);
292
+ if (fromIdentity)
293
+ return { recipient: fromIdentity, via: "the Outpost identity env" };
294
+ return { recipient: "", via: "" };
295
+ }
238
296
  function normalizedEpoch(value) {
239
297
  if (!/^-?\d+$/.test(value))
240
298
  throw new Error(`invalid HQ_JOB_NOTIFY_NOW_EPOCH: ${value}`);
@@ -303,11 +361,12 @@ export function runJobNotify(argv, options = {}) {
303
361
  let recipient = owner;
304
362
  const cognitoOwner = Boolean(owner) && COGNITO_SUB.test(owner);
305
363
  if (cognitoOwner) {
306
- recipient = resolveCognitoOwner(owner, deps);
364
+ const resolved = resolveCognitoOwner(owner, deps);
365
+ recipient = resolved.recipient;
307
366
  if (recipient)
308
- log(`owner ${owner} is a Cognito user id — delivering to ${recipient}`);
367
+ log(`owner ${owner} is a Cognito user id — delivering to ${recipient} (from ${resolved.via})`);
309
368
  else {
310
- log(`owner ${owner} is a Cognito user id that hq dm cannot address and hq whoami does not report it — set the job owner to an email or prs_ uid (logged only); never fails the job`);
369
+ log(`owner ${owner} is a Cognito user id that hq dm cannot address, and neither hq whoami nor the Outpost identity env maps it to an email — set the job owner to an email or prs_ uid (logged only); never fails the job`);
311
370
  deps.appendFile(deliveryLog, '{"delivered":false,"reason":"unresolved_owner_id"}\n');
312
371
  }
313
372
  }
@@ -400,6 +459,7 @@ export function runJobNotify(argv, options = {}) {
400
459
  kind,
401
460
  owner,
402
461
  ...(cognitoOwner ? { recipient: recipient || null } : {}),
462
+ ...(cognitoOwner && !recipient ? { reason: "unresolved_owner_id" } : {}),
403
463
  channel_unimplemented: channelUnimplemented === 1,
404
464
  deliver_rc: deliverRc,
405
465
  }, "compact"));
@@ -9,6 +9,7 @@ import { serializeJqJson } from "../lib/core-utils/jq-json-serializer.js";
9
9
  import { resolveLiveRoot } from "../utils/hq-roots.js";
10
10
  import { describeCoreCommand } from "./core-command-catalog.js";
11
11
  import { runScheduleParse } from "./core-jobs-schedule.js";
12
+ import { OUTPOST_IDENTITY_ENV_FILE, parseOutpostIdentityAssignments } from "../lib/outpost-identity-env.js";
12
13
  export { detectHostTimezone, runScheduleParse } from "./core-jobs-schedule.js";
13
14
  const VALIDATE_USAGE = "usage: jobs-validate.sh <file-or-dir> [file-or-dir...]\n";
14
15
  function isValidCronField(value, minimum, maximum) {
@@ -451,26 +452,12 @@ function shellText(value) {
451
452
  return String(value);
452
453
  }
453
454
  function parseIdentityAssignments(contents) {
454
- const values = [];
455
- for (const line of contents.split(/\r?\n/)) {
456
- const assignment = /^\s*(?:export\s+)?(OUTPOST_USER_ID|OUTPOST_OWNER_EMAIL|OWNER_EMAIL)\s*=\s*(.*?)\s*$/.exec(line);
457
- if (!assignment)
458
- continue;
459
- let value = assignment[2] ?? "";
460
- if ((value.startsWith("'") && value.endsWith("'")) || (value.startsWith('"') && value.endsWith('"'))) {
461
- value = value.slice(1, -1);
462
- }
463
- else {
464
- value = value.replace(/\s+#.*$/, "");
465
- }
466
- values.push(value);
467
- }
468
- return values;
455
+ return parseOutpostIdentityAssignments(contents).map((assignment) => assignment.value);
469
456
  }
470
457
  function identityFileTokens(options) {
471
458
  if (process.env.HQ_JOB_SKIP_SYSTEM_IDENTITY === "1")
472
459
  return [];
473
- const filename = "/etc/outpost/codex-identity.env";
460
+ const filename = OUTPOST_IDENTITY_ENV_FILE;
474
461
  try {
475
462
  const contents = options.identityFileReader
476
463
  ? options.identityFileReader(filename)
@@ -193,6 +193,9 @@ export declare function assertOutPathOutsideCompanies(outPath: string, hqRoot: s
193
193
  * stylistically consistent.
194
194
  */
195
195
  export declare function formatBrowseTable(rows: BrowseRow[]): string;
196
+ export declare function formatSearchTable(rows: SearchRow[], acl: boolean): string;
197
+ export declare function formatSearchResults(rows: SearchRow[], query: string, acl?: boolean): string;
198
+ export declare function formatLocalSearchResults(found: LocalSearchResult, query: string): string;
196
199
  export interface RunBrowseInput {
197
200
  /**
198
201
  * Vault path prefix.
@@ -344,6 +347,18 @@ export declare function runSharedWithMe(input: RunSharedWithMeInput): Promise<Sh
344
347
  * Render `shared-with-me` rows as a padded table. Mirrors `formatBrowseTable`.
345
348
  */
346
349
  export declare function formatSharedWithMeTable(rows: SharedWithMeRow[]): string;
350
+ export interface SearchRow {
351
+ key: string;
352
+ size: number;
353
+ lastModified: Date | undefined;
354
+ aclSource?: AclSource;
355
+ }
356
+ export interface SearchProgress {
357
+ pages: number;
358
+ objects: number;
359
+ matches: number;
360
+ elapsedMs: number;
361
+ }
347
362
  export interface RunSearchInput {
348
363
  /** Case-insensitive substring matched against each object's full key. */
349
364
  query: string;
@@ -357,16 +372,80 @@ export interface RunSearchInput {
357
372
  /** COMPANY mode (HQ-59): presign/list client factory. */
358
373
  companyClient?: CompanyBrowseClientFactory;
359
374
  region: string;
375
+ prefix?: string;
376
+ includeAcl?: boolean;
377
+ onPage?: (progress: SearchProgress) => void;
378
+ now?: () => number;
360
379
  }
380
+ export declare function createSearchMatcher(query: string): (lowerKey: string) => boolean;
361
381
  /**
362
382
  * `hq files search <query>` orchestrator. Lists the company (or personal)
363
- * vault under its root via `runBrowse`, then filters to keys containing the
383
+ * vault under its root, then filters to keys containing the
364
384
  * query (case-insensitive). v1 is a name/path search over the listing — no
365
- * content search. Rows carry the same ACL-source classification as browse.
385
+ * content search.
366
386
  *
367
- * Pure-ish: no console output. The caller renders with `formatBrowseTable`.
387
+ * Pure-ish: no console output. The caller renders with `formatSearchResults`.
368
388
  */
369
- export declare function runSearch(input: RunSearchInput): Promise<BrowseRow[]>;
389
+ export declare function runSearch(input: RunSearchInput): Promise<SearchRow[]>;
390
+ export declare function assertSafeCompanySlug(slug: string): void;
391
+ export declare function resolveSearchPrefix(raw: string | undefined, companySlug: string): string;
392
+ export interface LocalSearchResult {
393
+ root: string;
394
+ available: boolean;
395
+ rows: SearchRow[];
396
+ warning?: string;
397
+ }
398
+ export declare function searchLocalCompanyFiles(input: {
399
+ hqRoot: string;
400
+ companySlug: string;
401
+ prefix: string;
402
+ query: string;
403
+ shouldSync?: (absPath: string, isDir?: boolean) => boolean;
404
+ }): LocalSearchResult;
405
+ export interface SearchProgressStream {
406
+ write(chunk: string): unknown;
407
+ isTTY?: boolean;
408
+ }
409
+ export interface SearchProgressReporter {
410
+ start(scope: string): void;
411
+ page(progress: SearchProgress): void;
412
+ done(): void;
413
+ }
414
+ export declare function createSearchProgressReporter(input: {
415
+ stream: SearchProgressStream;
416
+ force?: boolean;
417
+ quiet?: boolean;
418
+ }): SearchProgressReporter;
419
+ export declare function personLocalSearchAllowed(input: {
420
+ credentialKind: "api-key" | "cognito";
421
+ vars?: NodeJS.ProcessEnv;
422
+ describeIdentity?: (vars: NodeJS.ProcessEnv) => {
423
+ tokenSource: string;
424
+ actorKind: string;
425
+ };
426
+ }): boolean;
427
+ export interface RunCompanySearchCommandInput {
428
+ query: string;
429
+ companySlug: string;
430
+ hqRoot: string;
431
+ prefix?: string;
432
+ local?: boolean;
433
+ localOnly?: boolean;
434
+ acl?: boolean;
435
+ progress?: boolean;
436
+ quiet?: boolean;
437
+ region: string;
438
+ connect: () => Promise<{
439
+ vaultClient: FilesBrowseVaultClient;
440
+ companyClient: CompanyBrowseClientFactory;
441
+ localAllowed: boolean;
442
+ }>;
443
+ stdout: (text: string) => void;
444
+ stderr: SearchProgressStream;
445
+ now?: () => number;
446
+ shouldSync?: (absPath: string, isDir?: boolean) => boolean;
447
+ }
448
+ export declare function runCompanySearchCommand(input: RunCompanySearchCommandInput): Promise<void>;
370
449
  interface PinFile {
371
450
  version: number;
372
451
  /** companySlug → sorted list of company-relative pinned prefixes. */