@indigoai-us/hq-cli 5.345.244 → 5.345.246

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 (116) hide show
  1. package/CHANGELOG.md +87 -0
  2. package/dist/command-catalog.generated.d.ts +93 -6
  3. package/dist/command-catalog.generated.js +114 -6
  4. package/dist/commands/bot.js +1 -1
  5. package/dist/commands/core-checkpoint-native.d.ts +5 -1
  6. package/dist/commands/core-checkpoint-native.js +13 -5
  7. package/dist/commands/deploy-comments.js +139 -0
  8. package/dist/commands/deploy-list.d.ts +5 -0
  9. package/dist/commands/deploy-list.js +8 -0
  10. package/dist/commands/dm.d.ts +4 -1
  11. package/dist/commands/dm.js +11 -2
  12. package/dist/commands/files.d.ts +11 -2
  13. package/dist/commands/files.js +48 -3
  14. package/dist/commands/lanes-loop.js +4 -1
  15. package/dist/commands/lanes.js +16 -5
  16. package/dist/commands/mesh.d.ts +2 -0
  17. package/dist/commands/mesh.js +26 -6
  18. package/dist/commands/reindex.js +2 -1
  19. package/dist/commands/rescue.d.ts +22 -1
  20. package/dist/commands/rescue.js +56 -9
  21. package/dist/commands/sources.d.ts +1 -1
  22. package/dist/commands/sources.js +1 -1
  23. package/dist/commands/storage.d.ts +15 -2
  24. package/dist/commands/storage.js +74 -7
  25. package/dist/hq-cloud-sync-runner/bin/sync-runner.js +2033 -1829
  26. package/dist/hq-cloud-sync-runner/package.json +1 -1
  27. package/dist/lib/agent-kit/mcp/tools.js +22 -0
  28. package/dist/lib/bot/jobs/hot-signal-sync.js +4 -1
  29. package/dist/lib/daemon/fleet-members-cache.d.ts +55 -0
  30. package/dist/lib/daemon/fleet-members-cache.js +266 -0
  31. package/dist/lib/daemon/handoff.d.ts +4 -0
  32. package/dist/lib/daemon/handoff.js +2 -1
  33. package/dist/lib/daemon/hook-requests.d.ts +2 -1
  34. package/dist/lib/daemon/hook-requests.js +19 -2
  35. package/dist/lib/daemon/install.d.ts +9 -1
  36. package/dist/lib/daemon/install.js +11 -2
  37. package/dist/lib/daemon/ops/policy.d.ts +23 -3
  38. package/dist/lib/daemon/ops/policy.js +62 -15
  39. package/dist/lib/daemon/run.js +12 -0
  40. package/dist/lib/daemon/server.d.ts +5 -0
  41. package/dist/lib/daemon/server.js +1 -1
  42. package/dist/lib/daemon/supervisor.d.ts +6 -0
  43. package/dist/lib/daemon/supervisor.js +31 -2
  44. package/dist/lib/doctor/checks/sync-runtime.js +8 -1
  45. package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
  46. package/dist/lib/flag-registry-worker-source.generated.js +1 -1
  47. package/dist/lib/hook-engine/coverage.d.ts +68 -0
  48. package/dist/lib/hook-engine/coverage.js +163 -0
  49. package/dist/lib/hook-engine/native-precompact-compatibility.json +1 -0
  50. package/dist/lib/hot-channels/signals-pass.d.ts +52 -2
  51. package/dist/lib/hot-channels/signals-pass.js +65 -3
  52. package/dist/lib/install/claude-targets.d.ts +6 -0
  53. package/dist/lib/install/claude-targets.js +9 -1
  54. package/dist/lib/lanes/reconcile-result.d.ts +1 -1
  55. package/dist/lib/lanes/reconcile.js +19 -4
  56. package/dist/lib/lanes/remote-control-lane.d.ts +6 -0
  57. package/dist/lib/lanes/remote-control-lane.js +10 -1
  58. package/dist/lib/lanes/spawn.d.ts +2 -0
  59. package/dist/lib/lanes/spawn.js +19 -3
  60. package/dist/lib/lanes/worker-env-scrub.d.ts +48 -0
  61. package/dist/lib/lanes/worker-env-scrub.js +146 -0
  62. package/dist/lib/lanes/worker-process.js +4 -1
  63. package/dist/lib/mesh/client.js +5 -1
  64. package/dist/lib/mesh/live/daemon/doctor.d.ts +9 -0
  65. package/dist/lib/mesh/live/daemon/doctor.js +51 -6
  66. package/dist/lib/mesh/live/daemon/install.d.ts +39 -0
  67. package/dist/lib/mesh/live/daemon/install.js +70 -0
  68. package/dist/lib/mesh/live/daemon/outbox-company.d.ts +47 -0
  69. package/dist/lib/mesh/live/daemon/outbox-company.js +77 -0
  70. package/dist/lib/mesh/live/daemon/run.d.ts +2 -0
  71. package/dist/lib/mesh/live/daemon/run.js +48 -3
  72. package/dist/lib/mesh/live/daemon/state.d.ts +5 -0
  73. package/dist/lib/mesh/live/daemon/system-unit.d.ts +21 -0
  74. package/dist/lib/mesh/live/daemon/system-unit.js +80 -0
  75. package/dist/lib/mesh/live/daemon/transcript-watch.d.ts +4 -1
  76. package/dist/lib/mesh/live/daemon/transcript-watch.js +42 -38
  77. package/dist/lib/mesh/live/direct-drain.js +3 -1
  78. package/dist/lib/mesh/live/emit.js +4 -2
  79. package/dist/lib/mesh/live/flush.d.ts +61 -0
  80. package/dist/lib/mesh/live/flush.js +434 -114
  81. package/dist/lib/mesh/live/paths.d.ts +10 -0
  82. package/dist/lib/mesh/live/paths.js +14 -0
  83. package/dist/lib/mesh/live/reporting-privacy.d.ts +41 -1
  84. package/dist/lib/mesh/live/reporting-privacy.js +81 -7
  85. package/dist/lib/mesh/live/spool.d.ts +171 -17
  86. package/dist/lib/mesh/live/spool.js +777 -62
  87. package/dist/lib/signals/engine.d.ts +82 -2
  88. package/dist/lib/signals/engine.js +389 -53
  89. package/dist/lib/signals/steps/extract.js +5 -0
  90. package/dist/lib/sync-core/engine-holds.d.ts +17 -1
  91. package/dist/lib/sync-core/engine-holds.js +73 -3
  92. package/dist/lib/sync-core/reconcile.js +10 -2
  93. package/dist/lib/work-context/organize.d.ts +22 -4
  94. package/dist/lib/work-context/organize.js +50 -21
  95. package/dist/lib/work-context/paths.d.ts +6 -0
  96. package/dist/lib/work-context/paths.js +9 -0
  97. package/dist/lib/work-context/reconcile.d.ts +1 -1
  98. package/dist/lib/work-context/reconcile.js +1 -1
  99. package/dist/startup-registration.d.ts +14 -0
  100. package/dist/startup-registration.js +26 -0
  101. package/dist/utils/cli-telemetry.d.ts +6 -0
  102. package/dist/utils/cli-telemetry.js +154 -9
  103. package/dist/utils/github-tag-fallback.d.ts +7 -2
  104. package/dist/utils/github-tag-fallback.js +17 -8
  105. package/dist/utils/hq-core-source.d.ts +31 -0
  106. package/dist/utils/hq-core-source.js +144 -0
  107. package/dist/utils/interactive-caller.d.ts +6 -0
  108. package/dist/utils/interactive-caller.js +8 -0
  109. package/dist/utils/shipped-codex-hooks.d.ts +6 -4
  110. package/dist/utils/shipped-codex-hooks.js +22 -10
  111. package/dist/utils/vault-api.js +1 -0
  112. package/dist/utils/version-report.d.ts +3 -1
  113. package/dist/utils/version-report.js +13 -5
  114. package/docs/anywhere-runtime.md +2 -2
  115. package/package.json +8 -8
  116. package/scripts/check-function-manifest.mjs +99 -18
@@ -2,12 +2,17 @@ export interface GitHubLookupDeps {
2
2
  fetchImpl?: typeof fetch;
3
3
  lsRemote?: (repo: string, refsOnly: boolean) => Promise<string>;
4
4
  warn?: (message: string) => void;
5
+ /** Web/clone base for the repo. Defaults to the HQ_CORE_SOURCE `webBase`. */
6
+ webBase?: string;
5
7
  }
6
8
  export declare class GitHubApiUnavailable extends Error {
7
9
  }
8
10
  export declare function isTransientGitHubStatus(status: number): boolean;
9
- /** No shell: git.exe is resolved from PATH on Windows, just as git is on Unix. */
10
- export declare function readRemoteTags(repo: string, refsOnly: boolean): Promise<string>;
11
+ /**
12
+ * No shell: git.exe is resolved from PATH on Windows, just as git is on Unix.
13
+ * The clone URL is webBase/owner/name.git; webBase defaults to HQ_CORE_SOURCE.
14
+ */
15
+ export declare function readRemoteTags(repo: string, refsOnly: boolean, webBase?: string): Promise<string>;
11
16
  export declare function highestReleaseTag(output: string): string;
12
17
  /** One scope per command; latest and floor lookups must share this callback. */
13
18
  export declare function onceWarning(warn?: (message: string) => void): (message: string) => void;
@@ -1,17 +1,21 @@
1
1
  import { execFile } from 'node:child_process';
2
+ import { resolveHqCoreSource } from './hq-core-source.js';
2
3
  export class GitHubApiUnavailable extends Error {
3
4
  }
4
5
  export function isTransientGitHubStatus(status) {
5
6
  return status === 403 || status === 429 || (status >= 500 && status <= 599);
6
7
  }
7
- /** No shell: git.exe is resolved from PATH on Windows, just as git is on Unix. */
8
- export function readRemoteTags(repo, refsOnly) {
8
+ /**
9
+ * No shell: git.exe is resolved from PATH on Windows, just as git is on Unix.
10
+ * The clone URL is webBase/owner/name.git; webBase defaults to HQ_CORE_SOURCE.
11
+ */
12
+ export function readRemoteTags(repo, refsOnly, webBase = resolveHqCoreSource().webBase) {
9
13
  if (!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(repo)) {
10
14
  return Promise.reject(new Error('expected a GitHub owner/repository'));
11
15
  }
12
16
  return new Promise((resolve, reject) => {
13
17
  execFile('git', ['ls-remote', '--tags', ...(refsOnly ? ['--refs'] : []),
14
- 'https://github.com/' + repo + '.git'], {
18
+ webBase + '/' + repo + '.git'], {
15
19
  env: { ...process.env, GIT_TERMINAL_PROMPT: '0', GCM_INTERACTIVE: 'Never' },
16
20
  timeout: 30_000, maxBuffer: 16 * 1024 * 1024, windowsHide: true,
17
21
  encoding: 'utf8',
@@ -63,10 +67,15 @@ export function onceWarning(warn = console.warn) {
63
67
  }
64
68
  };
65
69
  }
70
+ function lsRemoteFor(deps) {
71
+ return deps.lsRemote ?? ((repo, refsOnly) => readRemoteTags(repo, refsOnly, deps.webBase));
72
+ }
66
73
  async function publishedReleaseTag(repo, deps) {
67
74
  if (!/^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/.test(repo))
68
75
  throw new Error('expected a GitHub owner/repository');
69
- const base = `https://github.com/${repo}`;
76
+ const webBase = deps.webBase ?? resolveHqCoreSource().webBase;
77
+ const base = `${webBase}/${repo}`;
78
+ const baseUrl = new URL(base);
70
79
  const request = (url, method) => (deps.fetchImpl ?? fetch)(url, {
71
80
  method, redirect: 'manual', signal: AbortSignal.timeout(3_000),
72
81
  });
@@ -75,15 +84,15 @@ async function publishedReleaseTag(repo, deps) {
75
84
  const location = response.headers.get('location');
76
85
  if (response.status === 302 && location) {
77
86
  const target = new URL(location, base);
78
- const prefix = `/${repo}/releases/tag/`;
87
+ const prefix = `${baseUrl.pathname}/releases/tag/`;
79
88
  const tag = target.pathname.slice(prefix.length);
80
- if (target.origin === 'https://github.com' && target.pathname.startsWith(prefix)
89
+ if (target.origin === baseUrl.origin && target.pathname.startsWith(prefix)
81
90
  && !target.search && !target.hash && STRICT_RELEASE_TAG.test(tag))
82
91
  return tag;
83
92
  }
84
93
  }
85
94
  catch { /* Try bounded publication checks when the web pointer is unavailable. */ }
86
- const tags = sortedReleaseTags(await (deps.lsRemote ?? readRemoteTags)(repo, true));
95
+ const tags = sortedReleaseTags(await lsRemoteFor(deps)(repo, true));
87
96
  // A tag alone is not evidence of publication: release validation runs after tagging.
88
97
  for (const tag of tags.slice(0, 5)) {
89
98
  try {
@@ -113,7 +122,7 @@ export async function withGitTagFallback(api, repo, tag, select, deps) {
113
122
  try {
114
123
  result = select(tag === undefined
115
124
  ? await publishedReleaseTag(repo, deps)
116
- : await (deps.lsRemote ?? readRemoteTags)(repo, false));
125
+ : await lsRemoteFor(deps)(repo, false));
117
126
  }
118
127
  catch (gitError) {
119
128
  throw new Error(error.message + '; git ls-remote fallback failed: ' +
@@ -0,0 +1,31 @@
1
+ export interface HqCoreSource {
2
+ /** Prod channel `owner/name`. */
3
+ repo: string;
4
+ /** Staging channel `owner/name`. */
5
+ stagingRepo: string;
6
+ /** REST API base, e.g. `https://api.github.com`. */
7
+ apiBase: string;
8
+ /** Tarball base, e.g. `https://codeload.github.com`. */
9
+ codeloadBase: string;
10
+ /** Web/clone base, e.g. `https://github.com`. */
11
+ webBase: string;
12
+ }
13
+ export declare const DEFAULT_HQ_CORE_SOURCE: Readonly<HqCoreSource>;
14
+ export declare const HQ_CORE_SOURCE_ENV = "HQ_CORE_SOURCE";
15
+ export interface ResolveHqCoreSourceOptions {
16
+ env?: NodeJS.ProcessEnv;
17
+ /** Home directory holding `.hq/core-source.json`. Defaults to `os.homedir()`. */
18
+ homeDir?: string;
19
+ warn?: (message: string) => void;
20
+ }
21
+ export declare function hqCoreSourceFile(homeDir?: string): string;
22
+ /** Resolve the hq-core source address. Never throws. */
23
+ export declare function resolveHqCoreSource(options?: ResolveHqCoreSourceOptions): HqCoreSource;
24
+ /** True when `url` targets github.com, api.github.com or codeload.github.com over https. */
25
+ export declare function isGitHubHost(url: string): boolean;
26
+ /**
27
+ * The GitHub token to send to `url`, or undefined. A GitHub token is never
28
+ * forwarded to an overridden non-GitHub host.
29
+ */
30
+ export declare function githubTokenFor(url: string, token: string | undefined): string | undefined;
31
+ //# sourceMappingURL=hq-core-source.d.ts.map
@@ -0,0 +1,144 @@
1
+ /**
2
+ * Where hq-core lives. Every hq-cli call site that reads hq-core releases,
3
+ * tags, contents or clone URLs gets the address from here.
4
+ *
5
+ * Lookup order:
6
+ * 1. `HQ_CORE_SOURCE` env var (a JSON object).
7
+ * 2. `~/.hq/core-source.json` (same JSON shape), only when the env var is unset.
8
+ * 3. Built-in GitHub defaults.
9
+ *
10
+ * Every key is optional; a missing or invalid key keeps its GitHub default.
11
+ * Invalid JSON or an invalid field prints one warning to stderr naming
12
+ * `HQ_CORE_SOURCE` and never throws.
13
+ */
14
+ import * as fs from 'node:fs';
15
+ import * as os from 'node:os';
16
+ import * as path from 'node:path';
17
+ export const DEFAULT_HQ_CORE_SOURCE = Object.freeze({
18
+ repo: 'indigoai-us/hq-core',
19
+ stagingRepo: 'indigoai-us/hq-core-staging',
20
+ apiBase: 'https://api.github.com',
21
+ codeloadBase: 'https://codeload.github.com',
22
+ webBase: 'https://github.com',
23
+ });
24
+ export const HQ_CORE_SOURCE_ENV = 'HQ_CORE_SOURCE';
25
+ const REPO_KEYS = ['repo', 'stagingRepo'];
26
+ const BASE_KEYS = ['apiBase', 'codeloadBase', 'webBase'];
27
+ const REPO_PATTERN = /^[A-Za-z0-9_.-]+\/[A-Za-z0-9_.-]+$/;
28
+ const GITHUB_HOSTS = new Set(['github.com', 'api.github.com', 'codeload.github.com']);
29
+ const LOCAL_HOSTS = new Set(['localhost', '127.0.0.1']);
30
+ export function hqCoreSourceFile(homeDir = os.homedir()) {
31
+ return path.join(homeDir, '.hq', 'core-source.json');
32
+ }
33
+ const warnedMessages = new Set();
34
+ function defaultWarn(message) {
35
+ // One line per distinct problem per process, so a bad value does not repeat
36
+ // on every lookup a single command makes.
37
+ if (warnedMessages.has(message))
38
+ return;
39
+ warnedMessages.add(message);
40
+ process.stderr.write(`${message}\n`);
41
+ }
42
+ function normalizeBase(value) {
43
+ if (typeof value !== 'string')
44
+ return undefined;
45
+ let url;
46
+ try {
47
+ url = new URL(value.trim());
48
+ }
49
+ catch {
50
+ return undefined;
51
+ }
52
+ if (url.username || url.password || url.search || url.hash)
53
+ return undefined;
54
+ const secure = url.protocol === 'https:';
55
+ const local = url.protocol === 'http:' && LOCAL_HOSTS.has(url.hostname);
56
+ if (!secure && !local)
57
+ return undefined;
58
+ return `${url.origin}${url.pathname}`.replace(/\/+$/, '');
59
+ }
60
+ /** Parse one JSON value into a full source, collecting the names of bad fields. */
61
+ function parseSource(raw) {
62
+ const source = { ...DEFAULT_HQ_CORE_SOURCE };
63
+ let parsed;
64
+ try {
65
+ parsed = JSON.parse(raw);
66
+ }
67
+ catch {
68
+ return { source, problems: ['invalid JSON'] };
69
+ }
70
+ if (parsed === null || typeof parsed !== 'object' || Array.isArray(parsed)) {
71
+ return { source, problems: ['not a JSON object'] };
72
+ }
73
+ const obj = parsed;
74
+ const problems = [];
75
+ for (const key of REPO_KEYS) {
76
+ if (obj[key] === undefined)
77
+ continue;
78
+ const value = typeof obj[key] === 'string' ? obj[key].trim() : undefined;
79
+ if (value && REPO_PATTERN.test(value))
80
+ source[key] = value;
81
+ else
82
+ problems.push(`${key} must be owner/name`);
83
+ }
84
+ for (const key of BASE_KEYS) {
85
+ if (obj[key] === undefined)
86
+ continue;
87
+ const value = normalizeBase(obj[key]);
88
+ if (value)
89
+ source[key] = value;
90
+ else
91
+ problems.push(`${key} must be an https:// URL (http:// only for localhost)`);
92
+ }
93
+ return { source, problems };
94
+ }
95
+ /** Resolve the hq-core source address. Never throws. */
96
+ export function resolveHqCoreSource(options = {}) {
97
+ const env = options.env ?? process.env;
98
+ const warn = options.warn ?? defaultWarn;
99
+ const fromEnv = env[HQ_CORE_SOURCE_ENV];
100
+ if (fromEnv !== undefined && fromEnv.trim() !== '') {
101
+ const { source, problems } = parseSource(fromEnv);
102
+ if (problems.length > 0) {
103
+ warn(`${HQ_CORE_SOURCE_ENV}: ${problems.join('; ')}. Using the GitHub default for the bad field(s).`);
104
+ }
105
+ return source;
106
+ }
107
+ let file;
108
+ try {
109
+ file = hqCoreSourceFile(options.homeDir);
110
+ }
111
+ catch {
112
+ return { ...DEFAULT_HQ_CORE_SOURCE };
113
+ }
114
+ let raw;
115
+ try {
116
+ raw = fs.readFileSync(file, 'utf8');
117
+ }
118
+ catch {
119
+ return { ...DEFAULT_HQ_CORE_SOURCE };
120
+ }
121
+ const { source, problems } = parseSource(raw);
122
+ if (problems.length > 0) {
123
+ warn(`${HQ_CORE_SOURCE_ENV} (${file}): ${problems.join('; ')}. Using the GitHub default for the bad field(s).`);
124
+ }
125
+ return source;
126
+ }
127
+ /** True when `url` targets github.com, api.github.com or codeload.github.com over https. */
128
+ export function isGitHubHost(url) {
129
+ try {
130
+ const parsed = new URL(url);
131
+ return parsed.protocol === 'https:' && GITHUB_HOSTS.has(parsed.hostname.toLowerCase());
132
+ }
133
+ catch {
134
+ return false;
135
+ }
136
+ }
137
+ /**
138
+ * The GitHub token to send to `url`, or undefined. A GitHub token is never
139
+ * forwarded to an overridden non-GitHub host.
140
+ */
141
+ export function githubTokenFor(url, token) {
142
+ return token && isGitHubHost(url) ? token : undefined;
143
+ }
144
+ //# sourceMappingURL=hq-core-source.js.map
@@ -2,6 +2,12 @@
2
2
  export declare const HQ_NO_BROWSER_LOGIN_ENV = "HQ_NO_BROWSER_LOGIN";
3
3
  /** Remedy printed when an implicit sign-in is refused. */
4
4
  export declare const NON_INTERACTIVE_LOGIN_MESSAGE: string;
5
+ /**
6
+ * True when `error` is the refusal above: no usable HQ session in a process
7
+ * that may not open a browser sign-in. Background callers treat it as
8
+ * "signed out" (an expected state), not as a failure.
9
+ */
10
+ export declare function isNonInteractiveLoginError(error: unknown): boolean;
5
11
  export type InteractiveCallerInput = {
6
12
  env?: NodeJS.ProcessEnv;
7
13
  argv?: readonly string[];
@@ -15,6 +15,14 @@ export const HQ_NO_BROWSER_LOGIN_ENV = "HQ_NO_BROWSER_LOGIN";
15
15
  /** Remedy printed when an implicit sign-in is refused. */
16
16
  export const NON_INTERACTIVE_LOGIN_MESSAGE = "No valid HQ session and interactive login is disabled. Run `hq login` first. " +
17
17
  "This process is not interactive (no terminal, or a background HQ runtime), so it did not open a browser sign-in.";
18
+ /**
19
+ * True when `error` is the refusal above: no usable HQ session in a process
20
+ * that may not open a browser sign-in. Background callers treat it as
21
+ * "signed out" (an expected state), not as a failure.
22
+ */
23
+ export function isNonInteractiveLoginError(error) {
24
+ return error instanceof Error && error.message.startsWith(NON_INTERACTIVE_LOGIN_MESSAGE);
25
+ }
18
26
  /** launchd job labels the HQ service manager installs (see main.ts runCli). */
19
27
  const HQ_LAUNCHD_LABEL_PREFIXES = ["ai.indigo.", "ai.getindigo."];
20
28
  /** Env markers set for background HQ runtimes. Any non-empty value counts. */
@@ -1,12 +1,14 @@
1
1
  import type { ShippedCodexHookFiles } from './hook-trust.js';
2
- /** The only repos rescue installs core from: the default and `--staging`. */
3
- export declare const PROD_SOURCE = "indigoai-us/hq-core";
4
- export declare const STAGING_SOURCE = "indigoai-us/hq-core-staging";
2
+ /** The hq-core repos and API base the re-trust reads from: the built-in defaults only. */
3
+ export declare const TRUSTED_CORE_SOURCE: Readonly<{
4
+ repos: readonly string[];
5
+ apiBase: string;
6
+ }>;
5
7
  /** Resolve a GitHub token: prefer `gh auth token`, fall back to env. */
6
8
  export declare function resolveGhToken(): string | undefined;
7
9
  /**
8
10
  * The upstream repo and commit the last rescue installed, from `core/core.yaml`.
9
- * Only the HQ core repos are accepted.
11
+ * Only the built-in HQ core repos (prod and staging) are accepted.
10
12
  */
11
13
  export declare function readCoreSyncStamp(hqRoot: string): {
12
14
  source: string;
@@ -6,15 +6,23 @@
6
6
  * The commit comes from the sync stamp rescue writes to `core/core.yaml`
7
7
  * (`replaced_from_source.source` + `last_sync_sha`); the files come from the
8
8
  * GitHub contents API for that repo and commit.
9
+ *
10
+ * Trust source. Which hooks count as core-shipped is a trust decision, so the
11
+ * repos and API base used here are the built-in defaults
12
+ * ({@link TRUSTED_CORE_SOURCE}), never HQ_CORE_SOURCE or
13
+ * ~/.hq/core-source.json. A rescue from an overridden source still installs
14
+ * core; its hooks are just not re-trusted automatically.
9
15
  */
10
16
  import { spawnSync } from 'child_process';
11
17
  import * as fs from 'fs';
12
18
  import * as path from 'path';
13
19
  import * as yaml from 'js-yaml';
14
- /** The only repos rescue installs core from: the default and `--staging`. */
15
- export const PROD_SOURCE = 'indigoai-us/hq-core';
16
- export const STAGING_SOURCE = 'indigoai-us/hq-core-staging';
17
- const CORE_SOURCES = [PROD_SOURCE, STAGING_SOURCE];
20
+ import { DEFAULT_HQ_CORE_SOURCE, githubTokenFor } from './hq-core-source.js';
21
+ /** The hq-core repos and API base the re-trust reads from: the built-in defaults only. */
22
+ export const TRUSTED_CORE_SOURCE = Object.freeze({
23
+ repos: Object.freeze([DEFAULT_HQ_CORE_SOURCE.repo, DEFAULT_HQ_CORE_SOURCE.stagingRepo]),
24
+ apiBase: DEFAULT_HQ_CORE_SOURCE.apiBase,
25
+ });
18
26
  /** Resolve a GitHub token: prefer `gh auth token`, fall back to env. */
19
27
  export function resolveGhToken() {
20
28
  try {
@@ -32,7 +40,7 @@ export function resolveGhToken() {
32
40
  }
33
41
  /**
34
42
  * The upstream repo and commit the last rescue installed, from `core/core.yaml`.
35
- * Only the HQ core repos are accepted.
43
+ * Only the built-in HQ core repos (prod and staging) are accepted.
36
44
  */
37
45
  export function readCoreSyncStamp(hqRoot) {
38
46
  const file = path.join(hqRoot, 'core', 'core.yaml');
@@ -45,6 +53,8 @@ export function readCoreSyncStamp(hqRoot) {
45
53
  }
46
54
  // Anyone who can edit core.yaml could otherwise point the comparison (and
47
55
  // the GitHub token) at a repo of their own and make a foreign hook "shipped".
56
+ // The list is the built-in one, so a user-writable source config cannot add to it.
57
+ const CORE_SOURCES = TRUSTED_CORE_SOURCE.repos;
48
58
  if (!CORE_SOURCES.includes(source)) {
49
59
  throw new Error(`core/core.yaml names ${source}, which is not an HQ core repo (${CORE_SOURCES.join(' or ')})`);
50
60
  }
@@ -56,15 +66,16 @@ export function readCoreSyncStamp(hqRoot) {
56
66
  // Same bound as rescue's own GitHub requests.
57
67
  const GITHUB_REQUEST_TIMEOUT_MS = 30_000;
58
68
  /** One file's raw text at `sha`, or undefined when the commit has no such file. */
59
- async function fetchRawFile(repo, sha, file, token, fetchImpl) {
69
+ async function fetchRawFile(apiBase, repo, sha, file, token, fetchImpl) {
60
70
  const headers = {
61
71
  Accept: 'application/vnd.github.raw',
62
72
  'User-Agent': 'hq-cli-rescue',
63
73
  'X-GitHub-Api-Version': '2022-11-28',
64
74
  };
65
- if (token)
66
- headers.Authorization = `Bearer ${token}`;
67
- const url = `https://api.github.com/repos/${repo}/contents/${file}?ref=${sha}`;
75
+ const url = `${apiBase}/repos/${repo}/contents/${file}?ref=${sha}`;
76
+ const auth = githubTokenFor(url, token);
77
+ if (auth)
78
+ headers.Authorization = 'Bearer ' + auth;
68
79
  const response = await fetchImpl(url, { headers, signal: AbortSignal.timeout(GITHUB_REQUEST_TIMEOUT_MS) });
69
80
  if (response.status === 404)
70
81
  return undefined;
@@ -75,9 +86,10 @@ async function fetchRawFile(repo, sha, file, token, fetchImpl) {
75
86
  /** The shipped `.codex/config.toml` and `.codex/hooks.json` for this HQ root's installed core. */
76
87
  export async function loadShippedCodexHookFiles(hqRoot, token = resolveGhToken(), fetchImpl = fetch) {
77
88
  const { source, sha } = readCoreSyncStamp(hqRoot);
89
+ const { apiBase } = TRUSTED_CORE_SOURCE;
78
90
  const shipped = {};
79
91
  for (const name of ['config.toml', 'hooks.json']) {
80
- const text = await fetchRawFile(source, sha, `.codex/${name}`, token, fetchImpl);
92
+ const text = await fetchRawFile(apiBase, source, sha, `.codex/${name}`, token, fetchImpl);
81
93
  if (text !== undefined)
82
94
  shipped[name] = text;
83
95
  }
@@ -284,6 +284,7 @@ export async function vaultApiFetch(opts) {
284
284
  // skew on EVERY authenticated request, not only health heartbeats.
285
285
  // Fixed build constant, never caller-supplied; attribution only.
286
286
  'x-hq-client-version': CLI_VERSION,
287
+ 'User-Agent': `hq-cli/${CLI_VERSION}`,
287
288
  ...opts.headers,
288
289
  },
289
290
  body: opts.body ? JSON.stringify(opts.body) : undefined,
@@ -1,5 +1,7 @@
1
1
  import { type GitHubLookupDeps } from "./github-tag-fallback.js";
2
- export declare const HQ_CORE_LATEST_URL = "https://api.github.com/repos/indigoai-us/hq-core/releases/latest";
2
+ import { type HqCoreSource } from "./hq-core-source.js";
3
+ /** The latest-release API URL for the HQ_CORE_SOURCE prod repo. */
4
+ export declare function hqCoreLatestUrl(source?: HqCoreSource): string;
3
5
  export declare const LATEST_FETCH_TIMEOUT_MS = 3000;
4
6
  export type LatestLookup = "ok" | "network-error";
5
7
  export interface VersionReport {
@@ -15,13 +15,21 @@ import { findHqRoot } from "./manifest.js";
15
15
  import { readHqVersion } from "./hq-core-yaml.js";
16
16
  import { resolveGhToken } from "./shipped-codex-hooks.js";
17
17
  import { GitHubApiUnavailable, isTransientGitHubStatus, withGitTagFallback } from "./github-tag-fallback.js";
18
- export const HQ_CORE_LATEST_URL = "https://api.github.com/repos/indigoai-us/hq-core/releases/latest";
18
+ import { githubTokenFor, resolveHqCoreSource } from "./hq-core-source.js";
19
+ /** The latest-release API URL for the HQ_CORE_SOURCE prod repo. */
20
+ export function hqCoreLatestUrl(source = resolveHqCoreSource()) {
21
+ return `${source.apiBase}/repos/${source.repo}/releases/latest`;
22
+ }
19
23
  export const LATEST_FETCH_TIMEOUT_MS = 3_000;
20
24
  export function normalizeHqCoreTag(tag) {
21
25
  const version = tag.trim().replace(/^v/i, "");
22
26
  return semver.valid(version) ? version : null;
23
27
  }
24
28
  export async function fetchLatestHqCoreRelease(fetchImpl = fetch, timeoutMs = LATEST_FETCH_TIMEOUT_MS, token = resolveGhToken(), deps = {}) {
29
+ const source = resolveHqCoreSource();
30
+ const latestUrl = hqCoreLatestUrl(source);
31
+ // Never forward a GitHub token to an overridden non-GitHub host.
32
+ token = githubTokenFor(latestUrl, token);
25
33
  try {
26
34
  return await withGitTagFallback(async () => {
27
35
  try {
@@ -32,7 +40,7 @@ export async function fetchLatestHqCoreRelease(fetchImpl = fetch, timeoutMs = LA
32
40
  };
33
41
  if (token)
34
42
  headers.Authorization = `Bearer ${token}`;
35
- let res = await fetchImpl(HQ_CORE_LATEST_URL, {
43
+ let res = await fetchImpl(latestUrl, {
36
44
  headers,
37
45
  signal: AbortSignal.timeout(timeoutMs),
38
46
  });
@@ -40,13 +48,13 @@ export async function fetchLatestHqCoreRelease(fetchImpl = fetch, timeoutMs = LA
40
48
  // lookup that used to work.
41
49
  if (token && (res.status === 401 || res.status === 403)) {
42
50
  const { Authorization: _drop, ...anonHeaders } = headers;
43
- res = await fetchImpl(HQ_CORE_LATEST_URL, {
51
+ res = await fetchImpl(latestUrl, {
44
52
  headers: anonHeaders,
45
53
  signal: AbortSignal.timeout(timeoutMs),
46
54
  });
47
55
  }
48
56
  if (isTransientGitHubStatus(res.status)) {
49
- throw new GitHubApiUnavailable(`GitHub releases/latest for indigoai-us/hq-core: HTTP ${res.status}`);
57
+ throw new GitHubApiUnavailable(`GitHub releases/latest for ${source.repo}: HTTP ${res.status}`);
50
58
  }
51
59
  if (!res.ok)
52
60
  return null;
@@ -60,7 +68,7 @@ export async function fetchLatestHqCoreRelease(fetchImpl = fetch, timeoutMs = LA
60
68
  throw error;
61
69
  throw new GitHubApiUnavailable('GitHub release request failed on the network or timed out', { cause: error });
62
70
  }
63
- }, 'indigoai-us/hq-core', undefined, normalizeHqCoreTag, { ...deps, fetchImpl });
71
+ }, source.repo, undefined, normalizeHqCoreTag, { webBase: source.webBase, ...deps, fetchImpl });
64
72
  }
65
73
  catch {
66
74
  return null;
@@ -11,10 +11,10 @@ archived, or unreadable. An explicit registry false or the local
11
11
  requires the current person to enable the `hq-anywhere` setting in HQ. If that
12
12
  setting cannot be read, runtime access stays off.
13
13
 
14
- Work Mesh reporting of company work is the exception. The person's setting and
14
+ Work Mesh reporting of company work is the exception only when `work-mesh-company-reporting-required` is confirmed on in the bound company's fresh HQ flag snapshot. Otherwise the member's switch wins. While that flag is confirmed on, the person's setting and
15
15
  the local `HQ_FLAG_HQ_ANYWHERE_RUNTIME=false|0` override do not stop Work Mesh
16
16
  events of a session with a verified company binding; only the operator's
17
- registry switch does. See "Company work has no member off switch" in
17
+ registry switch does. See "Company reporting enforcement flag" in
18
18
  [work-context-cli.md](work-context-cli.md).
19
19
 
20
20
  ## Install
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@indigoai-us/hq-cli",
3
- "version": "5.345.244",
3
+ "version": "5.345.246",
4
4
  "description": "HQ by Indigo management CLI — modules and cloud sync",
5
5
  "main": "dist/index.js",
6
6
  "bin": {
@@ -63,7 +63,7 @@
63
63
  "@aws-sdk/client-iot-data-plane": "^3.1096.0",
64
64
  "@aws-sdk/client-s3": "^3.1049.0",
65
65
  "@aws-sdk/dsql-signer": "^3.1146.0",
66
- "@indigoai-us/hq-cloud": "6.18.119",
66
+ "@indigoai-us/hq-cloud": "6.18.121",
67
67
  "@indigoai-us/hq-flags-client": "^0.2.0",
68
68
  "@modelcontextprotocol/sdk": "1.32.2",
69
69
  "@sentry/node": "^10.49.0",
@@ -126,11 +126,11 @@
126
126
  "*.{ts,tsx,mts,cts,js,jsx,mjs,cjs}": "eslint --cache --no-error-on-unmatched-pattern"
127
127
  },
128
128
  "optionalDependencies": {
129
- "@indigoai-us/hq-hook-win32-x64": "5.345.244",
130
- "@indigoai-us/hq-hook-win32-arm64": "5.345.244",
131
- "@indigoai-us/hq-hook-darwin-x64": "5.345.244",
132
- "@indigoai-us/hq-hook-darwin-arm64": "5.345.244",
133
- "@indigoai-us/hq-hook-linux-x64": "5.345.244",
134
- "@indigoai-us/hq-hook-linux-arm64": "5.345.244"
129
+ "@indigoai-us/hq-hook-win32-x64": "5.345.246",
130
+ "@indigoai-us/hq-hook-win32-arm64": "5.345.246",
131
+ "@indigoai-us/hq-hook-darwin-x64": "5.345.246",
132
+ "@indigoai-us/hq-hook-darwin-arm64": "5.345.246",
133
+ "@indigoai-us/hq-hook-linux-x64": "5.345.246",
134
+ "@indigoai-us/hq-hook-linux-arm64": "5.345.246"
135
135
  }
136
136
  }