@indigoai-us/hq-cli 5.323.0 → 5.324.0

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 (72) hide show
  1. package/CHANGELOG.md +8 -1
  2. package/dist/bin/hq-auth-refresh.d.ts +5 -1
  3. package/dist/bin/hq-auth-refresh.js +33 -1
  4. package/dist/command-catalog.generated.d.ts +125 -6
  5. package/dist/command-catalog.generated.js +162 -6
  6. package/dist/command-registration-plan.d.ts +24 -0
  7. package/dist/command-registration-plan.js +4 -0
  8. package/dist/commands/anywhere-runtime-flag.d.ts +9 -0
  9. package/dist/commands/anywhere-runtime-flag.js +22 -0
  10. package/dist/commands/daemon.js +39 -2
  11. package/dist/commands/db-provision.js +6 -1
  12. package/dist/commands/doctor.js +8 -4
  13. package/dist/commands/feedback.d.ts +2 -0
  14. package/dist/commands/feedback.js +10 -0
  15. package/dist/commands/install-global.d.ts +46 -0
  16. package/dist/commands/install-global.js +674 -0
  17. package/dist/commands/link.d.ts +30 -0
  18. package/dist/commands/link.js +184 -0
  19. package/dist/commands/mcp-status.d.ts +6 -0
  20. package/dist/commands/mcp-status.js +21 -4
  21. package/dist/commands/pkg-install.js +20 -1
  22. package/dist/commands/update.d.ts +19 -0
  23. package/dist/commands/update.js +52 -6
  24. package/dist/fast-core.d.ts +2 -1
  25. package/dist/fast-core.js +12 -8
  26. package/dist/index.js +9 -7
  27. package/dist/lib/core-utils/timeout-guard-native-flags.d.ts +6 -0
  28. package/dist/lib/core-utils/timeout-guard-native-flags.js +30 -0
  29. package/dist/lib/core-utils/timeout-guard-native.d.ts +0 -3
  30. package/dist/lib/core-utils/timeout-guard-native.js +4 -30
  31. package/dist/lib/core-utils/timeout-guard.d.ts +2 -0
  32. package/dist/lib/core-utils/timeout-guard.js +2 -1
  33. package/dist/lib/daemon/convergence.d.ts +42 -0
  34. package/dist/lib/daemon/convergence.js +66 -0
  35. package/dist/lib/daemon/heartbeat.d.ts +43 -0
  36. package/dist/lib/daemon/heartbeat.js +70 -0
  37. package/dist/lib/daemon/ops/journal.d.ts +29 -0
  38. package/dist/lib/daemon/ops/journal.js +141 -0
  39. package/dist/lib/daemon/ops/memory.d.ts +20 -0
  40. package/dist/lib/daemon/ops/memory.js +65 -0
  41. package/dist/lib/daemon/ops/mesh.d.ts +38 -0
  42. package/dist/lib/daemon/ops/mesh.js +70 -0
  43. package/dist/lib/daemon/ops/policy.d.ts +78 -0
  44. package/dist/lib/daemon/ops/policy.js +283 -0
  45. package/dist/lib/daemon/protocol.d.ts +68 -0
  46. package/dist/lib/daemon/protocol.js +154 -0
  47. package/dist/lib/daemon/run.d.ts +10 -0
  48. package/dist/lib/daemon/run.js +85 -3
  49. package/dist/lib/daemon/server.d.ts +36 -0
  50. package/dist/lib/daemon/server.js +306 -0
  51. package/dist/lib/daemon/session-registry.d.ts +30 -0
  52. package/dist/lib/daemon/session-registry.js +42 -0
  53. package/dist/lib/doctor/checks/anywhere.d.ts +38 -0
  54. package/dist/lib/doctor/checks/anywhere.js +182 -0
  55. package/dist/lib/doctor/registry.js +6 -0
  56. package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
  57. package/dist/lib/flag-registry-worker-source.generated.js +1 -1
  58. package/dist/lib/install/claude-targets.d.ts +47 -0
  59. package/dist/lib/install/claude-targets.js +203 -0
  60. package/dist/lib/install/codex-targets.d.ts +57 -0
  61. package/dist/lib/install/codex-targets.js +187 -0
  62. package/dist/lib/mesh/live/session-seq.js +62 -9
  63. package/dist/lib/registry/normalize-remote.d.ts +21 -0
  64. package/dist/lib/registry/normalize-remote.js +68 -0
  65. package/dist/lib/registry/registry.d.ts +75 -0
  66. package/dist/lib/registry/registry.js +261 -0
  67. package/dist/utils/cognito-session.d.ts +5 -1
  68. package/dist/utils/cognito-session.js +8 -12
  69. package/dist/utils/feedback-diagnostics.d.ts +2 -0
  70. package/dist/utils/version-check.d.ts +2 -0
  71. package/dist/utils/version-check.js +7 -0
  72. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -2,8 +2,15 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
- ## [5.323.0] — 2026-10-02
5
+ ## [5.324.0] — 2026-10-02
6
+ - Keep the bundled shell runner out of native fast-route startup and defer timeout-guard flag snapshot imports until a timeout would block.
7
+ - Reuse the parsed fast-route entry when dispatching the selected command.
6
8
  - Add native `hq core derive-trigger-facts` on the fast route behind the default-off `core-native-hook-helpers` flag.
9
+ - Feedback reports can include the current cached hq-cli release when the default-off `feedback.latest-version` flag is enabled.
10
+ - Added flag-gated global Anywhere installation, company linking, and hqd daemon commands.
11
+ - Added flag-gated Anywhere daemon operations, doctor checks, and update convergence.
12
+ - `hq-auth-refresh` accepts `--min-validity-seconds` or `HQ_AUTH_MIN_VALIDITY_SECONDS`; values above 1800 seconds use the resolver's 1800-second cache margin.
13
+ - `hq db provision` now says remote databases are not available yet, instead of printing the server adapter error.
7
14
 
8
15
  ## [5.322.0] — 2026-10-02
9
16
  - Add an opt-in, default-off CLI prompt for solo companies to invite a teammate after a work-bearing sync.
@@ -14,6 +14,10 @@ import "../node-preflight.js";
14
14
  import { acquireCurrentPackageUseLease } from "../utils/package-use-lease.js";
15
15
  import "../node-network-compat.js";
16
16
  import type { refreshCachedSession } from "../utils/cognito-session.js";
17
- export declare function runAuthRefresh(refreshSession?: typeof refreshCachedSession): Promise<number>;
17
+ type RefreshSession = (options?: {
18
+ minValiditySeconds?: number;
19
+ }) => ReturnType<typeof refreshCachedSession>;
20
+ export declare function runAuthRefresh(refreshSession?: RefreshSession): Promise<number>;
18
21
  export declare function startAuthRefresh(acquireLease?: typeof acquireCurrentPackageUseLease): Promise<number>;
22
+ export {};
19
23
  //# sourceMappingURL=hq-auth-refresh.d.ts.map
@@ -17,12 +17,44 @@ import { acquireCurrentPackageUseLease } from "../utils/package-use-lease.js";
17
17
  import "../node-network-compat.js";
18
18
  import { fileURLToPath } from "node:url";
19
19
  import path from "node:path";
20
+ const MIN_VALIDITY_FLAG = "--min-validity-seconds";
21
+ function parseMinimumValiditySeconds(argv, env) {
22
+ let raw;
23
+ let fromFlag = false;
24
+ for (let index = 0; index < argv.length; index += 1) {
25
+ const arg = argv[index];
26
+ if (arg === MIN_VALIDITY_FLAG) {
27
+ raw = argv[index + 1];
28
+ fromFlag = true;
29
+ if (!raw || raw.startsWith("--")) {
30
+ throw new Error(`${MIN_VALIDITY_FLAG} requires a non-negative integer`);
31
+ }
32
+ break;
33
+ }
34
+ if (arg.startsWith(`${MIN_VALIDITY_FLAG}=`)) {
35
+ raw = arg.slice(MIN_VALIDITY_FLAG.length + 1);
36
+ fromFlag = true;
37
+ break;
38
+ }
39
+ }
40
+ if (!fromFlag)
41
+ raw = env.HQ_AUTH_MIN_VALIDITY_SECONDS || undefined;
42
+ if (raw === undefined)
43
+ return undefined;
44
+ const value = /^\d+$/.test(raw) ? Number(raw) : Number.NaN;
45
+ if (!Number.isSafeInteger(value)) {
46
+ throw new Error("minimum token validity must be a non-negative integer");
47
+ }
48
+ // Values above the provider's cache margin are clamped by cognito-session.
49
+ return value;
50
+ }
20
51
  export async function runAuthRefresh(refreshSession) {
21
52
  const { finishSentrySession, Sentry } = await import("../sentry.js");
22
53
  const { refreshCachedSession: refresh } = await import("../utils/cognito-session.js");
23
54
  let exitCode = 1;
24
55
  try {
25
- const result = await (refreshSession ?? refresh)();
56
+ const minValiditySeconds = parseMinimumValiditySeconds(process.argv.slice(2), process.env);
57
+ const result = await (refreshSession ?? refresh)(minValiditySeconds === undefined ? {} : { minValiditySeconds });
26
58
  if (result.refreshed) {
27
59
  exitCode = 0;
28
60
  }
@@ -96,10 +96,10 @@ export declare const COMMAND_CATALOG: readonly [{
96
96
  readonly description: "Install a package. Sources: bare slug (registry, Cognito-gated), @scope/name[@ver] (npm pack), git URL[#ref], or local path.";
97
97
  readonly aliases: readonly [];
98
98
  readonly hidden: false;
99
- readonly usage: "[options] <source>";
99
+ readonly usage: "[options] [source]";
100
100
  readonly arguments: readonly [{
101
101
  readonly name: "source";
102
- readonly required: true;
102
+ readonly required: false;
103
103
  readonly variadic: false;
104
104
  }];
105
105
  readonly options: readonly [{
@@ -114,6 +114,18 @@ export declare const COMMAND_CATALOG: readonly [{
114
114
  }, {
115
115
  readonly flags: "--branch";
116
116
  readonly description: "Follow a ref instead of SHA-pinning (git content-pack flow)";
117
+ }, {
118
+ readonly flags: "--global";
119
+ readonly description: "Install HQ into an agent runtime at user scope (requires the hq-anywhere-runtime flag)";
120
+ }, {
121
+ readonly flags: "--runtime <runtime>";
122
+ readonly description: "Runtime for --global (claude | codex)";
123
+ }, {
124
+ readonly flags: "--dry-run";
125
+ readonly description: "With --global: print every file and config diff without writing";
126
+ }, {
127
+ readonly flags: "--hq-root <dir>";
128
+ readonly description: "With --global: HQ checkout to install from (default: walk up from cwd)";
117
129
  }];
118
130
  readonly subcommands: readonly [];
119
131
  }, {
@@ -368,10 +380,10 @@ export declare const COMMAND_CATALOG: readonly [{
368
380
  readonly description: "Install a package. Sources: bare slug (registry, Cognito-gated), @scope/name[@ver] (npm pack), git URL[#ref], or local path.";
369
381
  readonly aliases: readonly [];
370
382
  readonly hidden: false;
371
- readonly usage: "[options] <source>";
383
+ readonly usage: "[options] [source]";
372
384
  readonly arguments: readonly [{
373
385
  readonly name: "source";
374
- readonly required: true;
386
+ readonly required: false;
375
387
  readonly variadic: false;
376
388
  }];
377
389
  readonly options: readonly [{
@@ -386,6 +398,18 @@ export declare const COMMAND_CATALOG: readonly [{
386
398
  }, {
387
399
  readonly flags: "--branch";
388
400
  readonly description: "Follow a ref instead of SHA-pinning (git content-pack flow)";
401
+ }, {
402
+ readonly flags: "--global";
403
+ readonly description: "Install HQ into an agent runtime at user scope (requires the hq-anywhere-runtime flag)";
404
+ }, {
405
+ readonly flags: "--runtime <runtime>";
406
+ readonly description: "Runtime for --global (claude | codex)";
407
+ }, {
408
+ readonly flags: "--dry-run";
409
+ readonly description: "With --global: print every file and config diff without writing";
410
+ }, {
411
+ readonly flags: "--hq-root <dir>";
412
+ readonly description: "With --global: HQ checkout to install from (default: walk up from cwd)";
389
413
  }];
390
414
  readonly subcommands: readonly [];
391
415
  }, {
@@ -839,6 +863,79 @@ export declare const COMMAND_CATALOG: readonly [{
839
863
  readonly description: "Also report this company's workspace plan state (Starter nag)";
840
864
  }];
841
865
  readonly subcommands: readonly [];
866
+ }, {
867
+ readonly name: "link";
868
+ readonly description: "Link this folder (or its git remote) to an HQ company";
869
+ readonly aliases: readonly [];
870
+ readonly hidden: false;
871
+ readonly usage: "[options] [company]";
872
+ readonly arguments: readonly [{
873
+ readonly name: "company";
874
+ readonly required: false;
875
+ readonly variadic: false;
876
+ }];
877
+ readonly options: readonly [{
878
+ readonly flags: "--path <dir>";
879
+ readonly description: "Folder to link (default: current directory)";
880
+ }, {
881
+ readonly flags: "--list";
882
+ readonly description: "Print every linked folder";
883
+ }, {
884
+ readonly flags: "--json";
885
+ readonly description: "Print JSON output";
886
+ }, {
887
+ readonly flags: "--seed-manifest <hqRoot>";
888
+ readonly description: "Seed entries from an HQ companies/manifest.yaml";
889
+ }];
890
+ readonly subcommands: readonly [];
891
+ }, {
892
+ readonly name: "unlink";
893
+ readonly description: "Remove the HQ company link for this folder";
894
+ readonly aliases: readonly [];
895
+ readonly hidden: false;
896
+ readonly usage: "[options]";
897
+ readonly arguments: readonly [];
898
+ readonly options: readonly [{
899
+ readonly flags: "--path <dir>";
900
+ readonly description: "Folder to unlink (default: current directory)";
901
+ }];
902
+ readonly subcommands: readonly [];
903
+ }, {
904
+ readonly name: "uninstall";
905
+ readonly description: "Remove the HQ global install from an agent runtime (use with --global)";
906
+ readonly aliases: readonly [];
907
+ readonly hidden: false;
908
+ readonly usage: "[options]";
909
+ readonly arguments: readonly [];
910
+ readonly options: readonly [{
911
+ readonly flags: "--global";
912
+ readonly description: "Reverse `hq install --global`";
913
+ }, {
914
+ readonly flags: "--runtime <runtime>";
915
+ readonly description: "Runtime to uninstall from (claude | codex)";
916
+ }, {
917
+ readonly flags: "--dry-run";
918
+ readonly description: "Print what would change without writing";
919
+ }, {
920
+ readonly flags: "--hq-root <dir>";
921
+ readonly description: "HQ checkout (only needed when install state is missing)";
922
+ }];
923
+ readonly subcommands: readonly [];
924
+ }, {
925
+ readonly name: "resolve-company";
926
+ readonly description: "Print the HQ company linked to this folder (never guesses)";
927
+ readonly aliases: readonly [];
928
+ readonly hidden: false;
929
+ readonly usage: "[options]";
930
+ readonly arguments: readonly [];
931
+ readonly options: readonly [{
932
+ readonly flags: "--path <dir>";
933
+ readonly description: "Folder to resolve (default: current directory)";
934
+ }, {
935
+ readonly flags: "--json";
936
+ readonly description: "Print JSON output";
937
+ }];
938
+ readonly subcommands: readonly [];
842
939
  }, {
843
940
  readonly name: "version";
844
941
  readonly description: "Show HQ, CLI, and latest hq-core versions";
@@ -9828,6 +9925,25 @@ export declare const COMMAND_CATALOG: readonly [{
9828
9925
  readonly description: "Run as a child of this app (only \"desktop\"), which has handed sync over to the daemon";
9829
9926
  }];
9830
9927
  readonly subcommands: readonly [];
9928
+ }, {
9929
+ readonly name: "call";
9930
+ readonly description: "Send one request to hqd (policy.check, journal.append, memory.get, memory.put, mesh.presence, …) and print the result as JSON";
9931
+ readonly aliases: readonly [];
9932
+ readonly hidden: false;
9933
+ readonly usage: "[options] <op>";
9934
+ readonly arguments: readonly [{
9935
+ readonly name: "op";
9936
+ readonly required: true;
9937
+ readonly variadic: false;
9938
+ }];
9939
+ readonly options: readonly [{
9940
+ readonly flags: "--json <args>";
9941
+ readonly description: "Request args as a JSON object";
9942
+ }, {
9943
+ readonly flags: "--timeout <ms>";
9944
+ readonly description: "Give up after this many milliseconds";
9945
+ }];
9946
+ readonly subcommands: readonly [];
9831
9947
  }, {
9832
9948
  readonly name: "status";
9833
9949
  readonly description: "Show the machine type and each service's state";
@@ -10000,7 +10116,7 @@ export declare const COMMAND_CATALOG: readonly [{
10000
10116
  readonly subcommands: readonly [];
10001
10117
  }, {
10002
10118
  readonly name: "restart";
10003
- readonly description: "Restart one service, or every running service";
10119
+ readonly description: "Restart one service, every service, or the daemon process";
10004
10120
  readonly aliases: readonly [];
10005
10121
  readonly hidden: false;
10006
10122
  readonly usage: "[options] [unit]";
@@ -10009,7 +10125,10 @@ export declare const COMMAND_CATALOG: readonly [{
10009
10125
  readonly required: false;
10010
10126
  readonly variadic: false;
10011
10127
  }];
10012
- readonly options: readonly [];
10128
+ readonly options: readonly [{
10129
+ readonly flags: "--daemon";
10130
+ readonly description: "Restart the supervisor process itself";
10131
+ }];
10013
10132
  readonly subcommands: readonly [];
10014
10133
  }, {
10015
10134
  readonly name: "trigger";
@@ -101,11 +101,11 @@ export const COMMAND_CATALOG = [
101
101
  "description": "Install a package. Sources: bare slug (registry, Cognito-gated), @scope/name[@ver] (npm pack), git URL[#ref], or local path.",
102
102
  "aliases": [],
103
103
  "hidden": false,
104
- "usage": "[options] <source>",
104
+ "usage": "[options] [source]",
105
105
  "arguments": [
106
106
  {
107
107
  "name": "source",
108
- "required": true,
108
+ "required": false,
109
109
  "variadic": false
110
110
  }
111
111
  ],
@@ -125,6 +125,22 @@ export const COMMAND_CATALOG = [
125
125
  {
126
126
  "flags": "--branch",
127
127
  "description": "Follow a ref instead of SHA-pinning (git content-pack flow)"
128
+ },
129
+ {
130
+ "flags": "--global",
131
+ "description": "Install HQ into an agent runtime at user scope (requires the hq-anywhere-runtime flag)"
132
+ },
133
+ {
134
+ "flags": "--runtime <runtime>",
135
+ "description": "Runtime for --global (claude | codex)"
136
+ },
137
+ {
138
+ "flags": "--dry-run",
139
+ "description": "With --global: print every file and config diff without writing"
140
+ },
141
+ {
142
+ "flags": "--hq-root <dir>",
143
+ "description": "With --global: HQ checkout to install from (default: walk up from cwd)"
128
144
  }
129
145
  ],
130
146
  "subcommands": []
@@ -465,11 +481,11 @@ export const COMMAND_CATALOG = [
465
481
  "description": "Install a package. Sources: bare slug (registry, Cognito-gated), @scope/name[@ver] (npm pack), git URL[#ref], or local path.",
466
482
  "aliases": [],
467
483
  "hidden": false,
468
- "usage": "[options] <source>",
484
+ "usage": "[options] [source]",
469
485
  "arguments": [
470
486
  {
471
487
  "name": "source",
472
- "required": true,
488
+ "required": false,
473
489
  "variadic": false
474
490
  }
475
491
  ],
@@ -489,6 +505,22 @@ export const COMMAND_CATALOG = [
489
505
  {
490
506
  "flags": "--branch",
491
507
  "description": "Follow a ref instead of SHA-pinning (git content-pack flow)"
508
+ },
509
+ {
510
+ "flags": "--global",
511
+ "description": "Install HQ into an agent runtime at user scope (requires the hq-anywhere-runtime flag)"
512
+ },
513
+ {
514
+ "flags": "--runtime <runtime>",
515
+ "description": "Runtime for --global (claude | codex)"
516
+ },
517
+ {
518
+ "flags": "--dry-run",
519
+ "description": "With --global: print every file and config diff without writing"
520
+ },
521
+ {
522
+ "flags": "--hq-root <dir>",
523
+ "description": "With --global: HQ checkout to install from (default: walk up from cwd)"
492
524
  }
493
525
  ],
494
526
  "subcommands": []
@@ -1073,6 +1105,100 @@ export const COMMAND_CATALOG = [
1073
1105
  ],
1074
1106
  "subcommands": []
1075
1107
  },
1108
+ {
1109
+ "name": "link",
1110
+ "description": "Link this folder (or its git remote) to an HQ company",
1111
+ "aliases": [],
1112
+ "hidden": false,
1113
+ "usage": "[options] [company]",
1114
+ "arguments": [
1115
+ {
1116
+ "name": "company",
1117
+ "required": false,
1118
+ "variadic": false
1119
+ }
1120
+ ],
1121
+ "options": [
1122
+ {
1123
+ "flags": "--path <dir>",
1124
+ "description": "Folder to link (default: current directory)"
1125
+ },
1126
+ {
1127
+ "flags": "--list",
1128
+ "description": "Print every linked folder"
1129
+ },
1130
+ {
1131
+ "flags": "--json",
1132
+ "description": "Print JSON output"
1133
+ },
1134
+ {
1135
+ "flags": "--seed-manifest <hqRoot>",
1136
+ "description": "Seed entries from an HQ companies/manifest.yaml"
1137
+ }
1138
+ ],
1139
+ "subcommands": []
1140
+ },
1141
+ {
1142
+ "name": "unlink",
1143
+ "description": "Remove the HQ company link for this folder",
1144
+ "aliases": [],
1145
+ "hidden": false,
1146
+ "usage": "[options]",
1147
+ "arguments": [],
1148
+ "options": [
1149
+ {
1150
+ "flags": "--path <dir>",
1151
+ "description": "Folder to unlink (default: current directory)"
1152
+ }
1153
+ ],
1154
+ "subcommands": []
1155
+ },
1156
+ {
1157
+ "name": "uninstall",
1158
+ "description": "Remove the HQ global install from an agent runtime (use with --global)",
1159
+ "aliases": [],
1160
+ "hidden": false,
1161
+ "usage": "[options]",
1162
+ "arguments": [],
1163
+ "options": [
1164
+ {
1165
+ "flags": "--global",
1166
+ "description": "Reverse `hq install --global`"
1167
+ },
1168
+ {
1169
+ "flags": "--runtime <runtime>",
1170
+ "description": "Runtime to uninstall from (claude | codex)"
1171
+ },
1172
+ {
1173
+ "flags": "--dry-run",
1174
+ "description": "Print what would change without writing"
1175
+ },
1176
+ {
1177
+ "flags": "--hq-root <dir>",
1178
+ "description": "HQ checkout (only needed when install state is missing)"
1179
+ }
1180
+ ],
1181
+ "subcommands": []
1182
+ },
1183
+ {
1184
+ "name": "resolve-company",
1185
+ "description": "Print the HQ company linked to this folder (never guesses)",
1186
+ "aliases": [],
1187
+ "hidden": false,
1188
+ "usage": "[options]",
1189
+ "arguments": [],
1190
+ "options": [
1191
+ {
1192
+ "flags": "--path <dir>",
1193
+ "description": "Folder to resolve (default: current directory)"
1194
+ },
1195
+ {
1196
+ "flags": "--json",
1197
+ "description": "Print JSON output"
1198
+ }
1199
+ ],
1200
+ "subcommands": []
1201
+ },
1076
1202
  {
1077
1203
  "name": "version",
1078
1204
  "description": "Show HQ, CLI, and latest hq-core versions",
@@ -12661,6 +12787,31 @@ export const COMMAND_CATALOG = [
12661
12787
  ],
12662
12788
  "subcommands": []
12663
12789
  },
12790
+ {
12791
+ "name": "call",
12792
+ "description": "Send one request to hqd (policy.check, journal.append, memory.get, memory.put, mesh.presence, …) and print the result as JSON",
12793
+ "aliases": [],
12794
+ "hidden": false,
12795
+ "usage": "[options] <op>",
12796
+ "arguments": [
12797
+ {
12798
+ "name": "op",
12799
+ "required": true,
12800
+ "variadic": false
12801
+ }
12802
+ ],
12803
+ "options": [
12804
+ {
12805
+ "flags": "--json <args>",
12806
+ "description": "Request args as a JSON object"
12807
+ },
12808
+ {
12809
+ "flags": "--timeout <ms>",
12810
+ "description": "Give up after this many milliseconds"
12811
+ }
12812
+ ],
12813
+ "subcommands": []
12814
+ },
12664
12815
  {
12665
12816
  "name": "status",
12666
12817
  "description": "Show the machine type and each service's state",
@@ -12879,7 +13030,7 @@ export const COMMAND_CATALOG = [
12879
13030
  },
12880
13031
  {
12881
13032
  "name": "restart",
12882
- "description": "Restart one service, or every running service",
13033
+ "description": "Restart one service, every service, or the daemon process",
12883
13034
  "aliases": [],
12884
13035
  "hidden": false,
12885
13036
  "usage": "[options] [unit]",
@@ -12890,7 +13041,12 @@ export const COMMAND_CATALOG = [
12890
13041
  "variadic": false
12891
13042
  }
12892
13043
  ],
12893
- "options": [],
13044
+ "options": [
13045
+ {
13046
+ "flags": "--daemon",
13047
+ "description": "Restart the supervisor process itself"
13048
+ }
13049
+ ],
12894
13050
  "subcommands": []
12895
13051
  },
12896
13052
  {
@@ -177,6 +177,30 @@ export declare const REGISTRATION_PLAN: readonly [{
177
177
  readonly parent: "program";
178
178
  readonly module: "./commands/whoami.js";
179
179
  readonly exportName: "registerWhoamiCommand";
180
+ }, {
181
+ readonly type: "registrar";
182
+ readonly root: "link";
183
+ readonly parent: "program";
184
+ readonly module: "./commands/link.js";
185
+ readonly exportName: "registerLinkCommand";
186
+ }, {
187
+ readonly type: "registrar";
188
+ readonly root: "unlink";
189
+ readonly parent: "program";
190
+ readonly module: "./commands/link.js";
191
+ readonly exportName: "registerUnlinkCommand";
192
+ }, {
193
+ readonly type: "registrar";
194
+ readonly root: "uninstall";
195
+ readonly parent: "program";
196
+ readonly module: "./commands/install-global.js";
197
+ readonly exportName: "registerUninstallCommand";
198
+ }, {
199
+ readonly type: "registrar";
200
+ readonly root: "resolve-company";
201
+ readonly parent: "program";
202
+ readonly module: "./commands/link.js";
203
+ readonly exportName: "registerResolveCompanyCommand";
180
204
  }, {
181
205
  readonly type: "registrar";
182
206
  readonly root: "version";
@@ -32,6 +32,10 @@ export const REGISTRATION_PLAN = [
32
32
  { type: "registrar", root: "login", parent: "program", module: "./commands/login.js", exportName: "registerLoginCommand" },
33
33
  { type: "registrar", root: "logout", parent: "program", module: "./commands/logout.js", exportName: "registerLogoutCommand" },
34
34
  { type: "registrar", root: "whoami", parent: "program", module: "./commands/whoami.js", exportName: "registerWhoamiCommand" },
35
+ { type: "registrar", root: "link", parent: "program", module: "./commands/link.js", exportName: "registerLinkCommand" },
36
+ { type: "registrar", root: "unlink", parent: "program", module: "./commands/link.js", exportName: "registerUnlinkCommand" },
37
+ { type: "registrar", root: "uninstall", parent: "program", module: "./commands/install-global.js", exportName: "registerUninstallCommand" },
38
+ { type: "registrar", root: "resolve-company", parent: "program", module: "./commands/link.js", exportName: "registerResolveCompanyCommand" },
35
39
  { type: "registrar", root: "version", parent: "program", module: "./commands/version.js", exportName: "registerVersionCommand" },
36
40
  { type: "registrar", root: "auth", parent: "program", module: "./commands/auth.js", exportName: "registerAuthCommands" },
37
41
  { type: "registrar", root: "secrets", parent: "program", module: "./commands/secrets.js", exportName: "registerSecretsCommand" },
@@ -0,0 +1,9 @@
1
+ /** hq-flags key for the staged HQ Anywhere runtime. The registry default is off. */
2
+ export declare const HQ_ANYWHERE_RUNTIME_FLAG = "hq-anywhere-runtime";
3
+ export declare class AnywhereRuntimeDisabledError extends Error {
4
+ readonly expected: true;
5
+ constructor();
6
+ }
7
+ export declare function anywhereRuntimeEnabled(env?: NodeJS.ProcessEnv): boolean;
8
+ export declare function requireAnywhereRuntime(): void;
9
+ //# sourceMappingURL=anywhere-runtime-flag.d.ts.map
@@ -0,0 +1,22 @@
1
+ import { resolveFlagGate, resolveProcessFlagGate } from "../lib/flag-registry.js";
2
+ /** hq-flags key for the staged HQ Anywhere runtime. The registry default is off. */
3
+ export const HQ_ANYWHERE_RUNTIME_FLAG = "hq-anywhere-runtime";
4
+ export class AnywhereRuntimeDisabledError extends Error {
5
+ expected = true;
6
+ constructor() {
7
+ super("HQ Anywhere is not enabled. Enable the hq-anywhere-runtime flag to use this command.");
8
+ this.name = "AnywhereRuntimeDisabledError";
9
+ }
10
+ }
11
+ export function anywhereRuntimeEnabled(env = process.env) {
12
+ const fallback = () => false;
13
+ const lookup = { fallback: false };
14
+ return env === process.env
15
+ ? resolveProcessFlagGate(HQ_ANYWHERE_RUNTIME_FLAG, lookup, fallback)
16
+ : resolveFlagGate(undefined, HQ_ANYWHERE_RUNTIME_FLAG, lookup, fallback, env);
17
+ }
18
+ export function requireAnywhereRuntime() {
19
+ if (!anywhereRuntimeEnabled())
20
+ throw new AnywhereRuntimeDisabledError();
21
+ }
22
+ //# sourceMappingURL=anywhere-runtime-flag.js.map
@@ -31,6 +31,7 @@ import { processCommandLine } from "../lib/daemon/lock.js";
31
31
  import { writeControlRequest } from "../lib/daemon/requests.js";
32
32
  import { isSyncRunnerCommandLine, readWatchRunnerOwnerStatus, watchRunnerOwnerStatusPath } from "../lib/daemon/sync-runner.js";
33
33
  import { getSyncModeForCompany, setSyncMode } from "./sync-mode.js";
34
+ import { requireAnywhereRuntime } from "./anywhere-runtime-flag.js";
34
35
  import { resolveDefaultHqRoot } from "../utils/cognito-session.js";
35
36
  class DaemonCommandError extends Error {
36
37
  }
@@ -766,6 +767,37 @@ export function registerDaemonCommand(program, over = {}) {
766
767
  hqBinary: d.hqBinary,
767
768
  });
768
769
  }));
770
+ daemon
771
+ .command("call <op>")
772
+ .description("Send one request to hqd (policy.check, journal.append, memory.get, memory.put, mesh.presence, …) and print the result as JSON")
773
+ .option("--json <args>", "Request args as a JSON object", "{}")
774
+ .option("--timeout <ms>", "Give up after this many milliseconds")
775
+ .action(wrap(async (d, op, opts) => {
776
+ requireAnywhereRuntime();
777
+ let args;
778
+ try {
779
+ args = JSON.parse(opts.json);
780
+ }
781
+ catch {
782
+ throw new Error("--json must be valid JSON");
783
+ }
784
+ if (!args || typeof args !== "object" || Array.isArray(args))
785
+ throw new Error("--json must be a JSON object");
786
+ const timeoutMs = Number(opts.timeout ?? (op === "policy.check" ? "40000" : "20000"));
787
+ if (!Number.isFinite(timeoutMs) || timeoutMs <= 0)
788
+ throw new Error("--timeout must be a positive number of milliseconds");
789
+ const { hqdRequest, hqdSocketPath, HqdClientError } = await import("../lib/daemon/protocol.js");
790
+ try {
791
+ const result = await hqdRequest(op, args, { socketPath: hqdSocketPath(d.home, d.env), timeoutMs });
792
+ d.out(JSON.stringify(result, null, 2));
793
+ }
794
+ catch (err) {
795
+ if (!(err instanceof HqdClientError))
796
+ throw err;
797
+ d.out(JSON.stringify({ error: { code: err.code, message: err.message } }, null, 2));
798
+ process.exitCode = 1;
799
+ }
800
+ }));
769
801
  daemon
770
802
  .command("status")
771
803
  .description("Show the machine type and each service's state")
@@ -828,8 +860,13 @@ export function registerDaemonCommand(program, over = {}) {
828
860
  .action(wrap((d, unit, opts) => runLogs(d, unit, opts)));
829
861
  daemon
830
862
  .command("restart [unit]")
831
- .description("Restart one service, or every running service")
832
- .action(wrap(async (d, unit) => queueRequest(d, unit ? { action: "restart", unit } : { action: "restart" }, unit ? `restart ${unit}` : "restart all services")));
863
+ .description("Restart one service, every service, or the daemon process")
864
+ .option("--daemon", "Restart the supervisor process itself")
865
+ .action(wrap(async (d, unit, opts) => {
866
+ if (opts.daemon && unit)
867
+ throw new DaemonCommandError("--daemon cannot be combined with a service name");
868
+ return queueRequest(d, opts.daemon ? { action: "restart-daemon" } : unit ? { action: "restart", unit } : { action: "restart" }, opts.daemon ? "restart daemon" : unit ? `restart ${unit}` : "restart all services");
869
+ }));
833
870
  daemon
834
871
  .command("trigger <unit>")
835
872
  .description("Run a scheduled service now (for example search-index)")
@@ -65,7 +65,12 @@ export function registerDbProvisionCommand(db, depsFactory = defaultDeps) {
65
65
  throw error;
66
66
  const msg = error instanceof Error ? error.message : "Unknown error";
67
67
  const status = error.status;
68
- if (status === 402 || /PLAN_REQUIRED|Team plan|Workforce|\$500/i.test(msg)) {
68
+ const code = error.code;
69
+ if (code === "REMOTE_DB_NOT_AVAILABLE" || status === 501) {
70
+ console.error(chalk.red("Error:"), "Remote databases are not available yet.");
71
+ console.error(chalk.dim("Local hq db status|sql|migrate still work offline."));
72
+ }
73
+ else if (status === 402 || /PLAN_REQUIRED|Team plan|Workforce|\$500/i.test(msg)) {
69
74
  console.error(chalk.red("Error:"), "Remote vault DB requires the HQ Workforce plan ($500/mo).");
70
75
  console.error(chalk.dim("Local databases still work: hq db status|sql|migrate — no HQ Workforce plan required."));
71
76
  }