@indigoai-us/hq-cli 5.345.215 → 5.345.218

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 (161) hide show
  1. package/CHANGELOG.md +168 -0
  2. package/README.md +46 -1
  3. package/assets/bot-workers/setup/skills/add-a-pack.md +3 -3
  4. package/assets/scaffold/core/scripts/hq-session.sh +4 -0
  5. package/assets/scaffold/core/scripts/lib/epochrealtime.sh +30 -0
  6. package/assets/scaffold/core/scripts/lib/work-mesh-enqueue.sh +12 -5
  7. package/dist/command-catalog.generated.d.ts +59 -4
  8. package/dist/command-catalog.generated.js +74 -4
  9. package/dist/command-help.js +3 -1
  10. package/dist/command-registration-plan.d.ts +6 -0
  11. package/dist/command-registration-plan.js +1 -0
  12. package/dist/commands/auth.d.ts +1 -1
  13. package/dist/commands/auth.js +11 -52
  14. package/dist/commands/bot.js +11 -4
  15. package/dist/commands/cloud-demote.d.ts +19 -4
  16. package/dist/commands/cloud-demote.js +85 -12
  17. package/dist/commands/cloud-provision.d.ts +5 -1
  18. package/dist/commands/cloud-provision.js +6 -2
  19. package/dist/commands/cloud.d.ts +37 -1
  20. package/dist/commands/cloud.js +110 -27
  21. package/dist/commands/core-hq-session-native.js +3 -0
  22. package/dist/commands/core.js +1 -0
  23. package/dist/commands/daemon.js +4 -1
  24. package/dist/commands/dm.js +7 -0
  25. package/dist/commands/doctor-usage.d.ts +8 -0
  26. package/dist/commands/doctor-usage.js +20 -0
  27. package/dist/commands/doctor.js +7 -1
  28. package/dist/commands/env.d.ts +18 -0
  29. package/dist/commands/env.js +82 -0
  30. package/dist/commands/install-global.js +3 -3
  31. package/dist/commands/lanes.js +100 -24
  32. package/dist/commands/logout.d.ts +7 -0
  33. package/dist/commands/logout.js +41 -34
  34. package/dist/commands/members.js +1 -1
  35. package/dist/commands/pack-start-bot.d.ts +1 -1
  36. package/dist/commands/pack-start-bot.js +2 -2
  37. package/dist/commands/pkg-update.js +1 -1
  38. package/dist/commands/sources.d.ts +8 -2
  39. package/dist/commands/sources.js +65 -9
  40. package/dist/commands/sync-narrow.js +1 -1
  41. package/dist/commands/team-sync.js +1 -1
  42. package/dist/commands/whoami.js +26 -1
  43. package/dist/data/command-states.json +22 -0
  44. package/dist/index.js +52 -4
  45. package/dist/lazy-commands.js +2 -1
  46. package/dist/lib/anywhere-person-setting.d.ts +2 -0
  47. package/dist/lib/anywhere-person-setting.js +6 -3
  48. package/dist/lib/billing/usage-card.d.ts +25 -4
  49. package/dist/lib/billing/usage-card.js +76 -9
  50. package/dist/lib/billing/usage-cost.d.ts +3 -3
  51. package/dist/lib/billing/usage-cost.js +40 -15
  52. package/dist/lib/billing/usage-only.js +4 -2
  53. package/dist/lib/billing/usage-rate-card.d.ts +2 -2
  54. package/dist/lib/billing/usage-rate-card.js +3 -0
  55. package/dist/lib/bot/fleet-cron.js +93 -6
  56. package/dist/lib/bot/inflight.d.ts +9 -0
  57. package/dist/lib/bot/inflight.js +10 -0
  58. package/dist/lib/bot/jobs/hot-signal-sync.js +12 -1
  59. package/dist/lib/bot/pack-link.d.ts +2 -2
  60. package/dist/lib/bot/pack-link.js +2 -2
  61. package/dist/lib/bot/runtime/grok-acp.d.ts +1 -0
  62. package/dist/lib/bot/runtime/grok-acp.js +26 -11
  63. package/dist/lib/bot/runtime/grok.js +1 -1
  64. package/dist/lib/daemon/flag-monitor.d.ts +8 -0
  65. package/dist/lib/daemon/flag-monitor.js +17 -6
  66. package/dist/lib/daemon/flag.d.ts +65 -1
  67. package/dist/lib/daemon/flag.js +190 -40
  68. package/dist/lib/daemon/hook-env.d.ts +32 -0
  69. package/dist/lib/daemon/hook-env.js +51 -0
  70. package/dist/lib/daemon/ops/policy.js +67 -8
  71. package/dist/lib/daemon/paths.d.ts +72 -2
  72. package/dist/lib/daemon/paths.js +154 -3
  73. package/dist/lib/daemon/run.js +32 -21
  74. package/dist/lib/daemon/selfcheck.d.ts +22 -0
  75. package/dist/lib/daemon/selfcheck.js +40 -1
  76. package/dist/lib/daemon/server.d.ts +3 -1
  77. package/dist/lib/daemon/server.js +7 -22
  78. package/dist/lib/daemon/state-file-switch.d.ts +57 -0
  79. package/dist/lib/daemon/state-file-switch.js +88 -0
  80. package/dist/lib/daemon/state-file.d.ts +198 -0
  81. package/dist/lib/daemon/state-file.js +419 -0
  82. package/dist/lib/daemon/timed-flag-monitors.d.ts +47 -0
  83. package/dist/lib/daemon/timed-flag-monitors.js +75 -0
  84. package/dist/lib/doctor/checks/host-core.d.ts +52 -0
  85. package/dist/lib/doctor/checks/host-core.js +337 -0
  86. package/dist/lib/doctor/checks/replay-recorder.d.ts +39 -0
  87. package/dist/lib/doctor/checks/replay-recorder.js +261 -0
  88. package/dist/lib/doctor/checks/sync-runtime.js +3 -3
  89. package/dist/lib/doctor/registry.js +4 -0
  90. package/dist/lib/environment/credential-shapes.d.ts +61 -0
  91. package/dist/lib/environment/credential-shapes.js +333 -0
  92. package/dist/lib/environment/profile.d.ts +239 -0
  93. package/dist/lib/environment/profile.js +239 -0
  94. package/dist/lib/hook-engine/coverage.d.ts +13 -0
  95. package/dist/lib/hook-engine/coverage.js +124 -0
  96. package/dist/lib/hook-engine/reconcile.js +300 -94
  97. package/dist/lib/hook-engine/registration.d.ts +17 -1
  98. package/dist/lib/hook-engine/registration.js +62 -7
  99. package/dist/lib/hot-channels/adapters/slack.d.ts +21 -5
  100. package/dist/lib/hot-channels/adapters/slack.js +64 -21
  101. package/dist/lib/hot-channels/alert.d.ts +2 -0
  102. package/dist/lib/hot-channels/alert.js +8 -1
  103. package/dist/lib/hot-channels/contract.d.ts +12 -0
  104. package/dist/lib/hot-channels/contract.js +7 -0
  105. package/dist/lib/hot-channels/loop.js +1 -0
  106. package/dist/lib/hot-channels/run.d.ts +6 -0
  107. package/dist/lib/hot-channels/run.js +4 -0
  108. package/dist/lib/hot-channels/signals-pass.d.ts +64 -1
  109. package/dist/lib/hot-channels/signals-pass.js +21 -49
  110. package/dist/lib/install/claude-targets.d.ts +12 -1
  111. package/dist/lib/install/claude-targets.js +70 -5
  112. package/dist/lib/install/codex-pack-contributions.js +1 -1
  113. package/dist/lib/install/codex-targets.d.ts +2 -2
  114. package/dist/lib/install/codex-targets.js +48 -5
  115. package/dist/lib/install/hook-target.d.ts +4 -1
  116. package/dist/lib/install/hook-target.js +14 -1
  117. package/dist/lib/lanes/canonical-host.d.ts +35 -0
  118. package/dist/lib/lanes/canonical-host.js +65 -0
  119. package/dist/lib/lanes/host-capacity.d.ts +30 -0
  120. package/dist/lib/lanes/host-capacity.js +29 -3
  121. package/dist/lib/mesh/live/daemon/run.d.ts +2 -0
  122. package/dist/lib/mesh/live/daemon/run.js +5 -2
  123. package/dist/lib/mesh/live/flush.d.ts +5 -1
  124. package/dist/lib/mesh/live/flush.js +12 -6
  125. package/dist/lib/mesh/live/reporting-privacy.d.ts +32 -0
  126. package/dist/lib/mesh/live/reporting-privacy.js +56 -1
  127. package/dist/lib/mesh/live/spool.d.ts +7 -0
  128. package/dist/lib/mesh/live/spool.js +25 -0
  129. package/dist/lib/packages/setup-block.d.ts +2 -2
  130. package/dist/lib/packages/setup-block.js +2 -2
  131. package/dist/lib/packages/start-bot.d.ts +1 -1
  132. package/dist/lib/packages/start-bot.js +1 -1
  133. package/dist/lib/person-setting-cache.d.ts +38 -0
  134. package/dist/lib/person-setting-cache.js +98 -0
  135. package/dist/lib/safe-store.d.ts +245 -0
  136. package/dist/lib/safe-store.js +777 -0
  137. package/dist/lib/signals/engine.d.ts +29 -2
  138. package/dist/lib/signals/engine.js +103 -4
  139. package/dist/lib/signals/reply.js +73 -18
  140. package/dist/lib/signals/steps/adapters.js +7 -2
  141. package/dist/lib/signals/steps/extract.d.ts +13 -0
  142. package/dist/lib/signals/steps/extract.js +84 -4
  143. package/dist/main.js +47 -4
  144. package/dist/schemas/hq-environment-profile.v1.schema.json +438 -0
  145. package/dist/types.d.ts +1 -1
  146. package/dist/utils/auth-expiry.d.ts +8 -0
  147. package/dist/utils/auth-expiry.js +53 -0
  148. package/dist/utils/callback-port-busy.d.ts +1 -1
  149. package/dist/utils/callback-port-busy.js +4 -4
  150. package/dist/utils/cli-telemetry.d.ts +21 -0
  151. package/dist/utils/cli-telemetry.js +34 -0
  152. package/dist/utils/command-usage.d.ts +275 -0
  153. package/dist/utils/command-usage.js +797 -0
  154. package/dist/utils/hook-trust.d.ts +7 -0
  155. package/dist/utils/hook-trust.js +34 -4
  156. package/dist/utils/host-registration.d.ts +179 -0
  157. package/dist/utils/host-registration.js +505 -0
  158. package/dist/utils/resident-package-preload.js +2 -0
  159. package/package.json +10 -8
  160. package/scripts/bench-core.mjs +1096 -0
  161. package/scripts/check-function-manifest.mjs +702 -0
@@ -0,0 +1,438 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "urn:hq:schema:hq-environment-profile:v1",
4
+ "title": "hq-environment-profile.v1",
5
+ "description": "One profile per place that can do work (Mac, Outpost, MicroVM, bot, fleet box), published as a company-scoped view. The declared part changes rarely and is written by the environment's owner or image. The readings part is written by the environment about itself; each reading carries observed_at and ttl_seconds. Every login in accounts records its owning business and its holder; a login the owner holds is listed there whichever of the owner's businesses owns it, and a login held by another person appears only in foreign_accounts. Work is paired only with an account whose usable is true, which requires holder owner. The schema is closed: every object rejects unknown fields and every enum is fixed, so any added field or enum value needs a new schema_version. No secret values, tokens, credential paths or sign-in sessions may appear anywhere in a profile.",
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "required": ["schema_version", "view", "declared", "readings"],
9
+ "properties": {
10
+ "schema_version": { "const": "hq-environment-profile.v1" },
11
+ "view": {
12
+ "description": "Which company this view of the environment is published for. Logins the owner holds are listed in readings.accounts whichever business owns them. Logins held by other people are listed only in readings.foreign_accounts.",
13
+ "type": "object",
14
+ "additionalProperties": false,
15
+ "required": ["company", "generated_at", "generated_by"],
16
+ "properties": {
17
+ "company": { "$ref": "#/$defs/company_slug", "description": "Must be one of declared.companies. The loader checks this; JSON Schema cannot compare the two fields." },
18
+ "generated_at": { "$ref": "#/$defs/timestamp" },
19
+ "generated_by": { "type": "string", "minLength": 1, "description": "Writer, for example 'hand capture 2026-11-13 from hq runners capacity --json'." }
20
+ }
21
+ },
22
+ "declared": { "$ref": "#/$defs/declared" },
23
+ "readings": { "$ref": "#/$defs/readings" },
24
+ "notes": { "type": "array", "items": { "type": "string" } }
25
+ },
26
+ "allOf": [
27
+ {
28
+ "description": "A template does not exist yet, so it has no live readings: no compute, slots, accounts, foreign accounts, access probes or base readiness.",
29
+ "if": { "properties": { "declared": { "properties": { "state": { "const": "template" } } } } },
30
+ "then": {
31
+ "properties": {
32
+ "readings": {
33
+ "properties": {
34
+ "compute": false,
35
+ "slots": false,
36
+ "accounts": { "maxItems": 0 },
37
+ "foreign_accounts": { "maxItems": 0 },
38
+ "access": { "maxItems": 0 },
39
+ "base_readiness": false
40
+ }
41
+ }
42
+ }
43
+ }
44
+ }
45
+ ],
46
+ "$defs": {
47
+ "company_slug": { "type": "string", "pattern": "^[a-z0-9][a-z0-9-]*$" },
48
+ "timestamp": {
49
+ "type": "string",
50
+ "format": "date-time",
51
+ "pattern": "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(\\.[0-9]+)?(Z|[+-][0-9]{2}:[0-9]{2})$",
52
+ "description": "RFC 3339 date-time. The pattern enforces the shape where a validator does not check formats."
53
+ },
54
+ "timestamp_or_null": { "oneOf": [{ "type": "null" }, { "$ref": "#/$defs/timestamp" }] },
55
+ "provenance": {
56
+ "type": "object",
57
+ "additionalProperties": false,
58
+ "required": ["source", "verified"],
59
+ "properties": {
60
+ "source": { "type": "string", "minLength": 1, "description": "Command, file:line or document the value came from." },
61
+ "verified": { "type": "boolean", "description": "true only when read from the live system at observed time; false for estimates, prose notes and unconfirmed vendor figures." }
62
+ }
63
+ },
64
+ "label": {
65
+ "type": "string",
66
+ "description": "key:value. Keys in use: os, arch, tool, engine, net, role, power, data, image.",
67
+ "pattern": "^[a-z][a-z0-9-]*:[A-Za-z0-9._/@*-]+$"
68
+ },
69
+ "taint": {
70
+ "type": "object",
71
+ "additionalProperties": false,
72
+ "required": ["key", "effect", "reason"],
73
+ "properties": {
74
+ "key": { "$ref": "#/$defs/label", "description": "key:value; work tolerates it by listing the same string." },
75
+ "effect": {
76
+ "enum": ["no-place", "prefer-not"],
77
+ "description": "no-place: pass 1 rejects work that does not tolerate it. prefer-not: pass 2 penalty unless tolerated."
78
+ },
79
+ "reason": { "type": "string" }
80
+ }
81
+ },
82
+ "declared": {
83
+ "type": "object",
84
+ "additionalProperties": false,
85
+ "required": ["kind", "id", "companies", "state", "lifecycle", "limits", "labels", "dispatch", "cost", "taints"],
86
+ "properties": {
87
+ "kind": { "enum": ["local", "outpost", "microvm", "bot", "fleet-box"] },
88
+ "id": {
89
+ "type": "string",
90
+ "pattern": "^(local|outpost|microvm|bot|fleet-box):[A-Za-z0-9._@:-]+$",
91
+ "description": "kind:native-id. The prefix must equal kind. The native id is the one hq-lanes-host-capacity.v1 uses where one exists."
92
+ },
93
+ "aliases": {
94
+ "type": "array",
95
+ "description": "Other ids the same environment appears under in today's records (lane host ids, instance names, hostnames).",
96
+ "items": { "type": "string" },
97
+ "uniqueItems": true
98
+ },
99
+ "companies": {
100
+ "type": "array",
101
+ "minItems": 1,
102
+ "uniqueItems": true,
103
+ "items": { "$ref": "#/$defs/company_slug" },
104
+ "description": "Companies this environment may do work for. Hard filter."
105
+ },
106
+ "state": { "enum": ["running", "template", "stopped"] },
107
+ "lifecycle": {
108
+ "type": "object",
109
+ "additionalProperties": false,
110
+ "required": ["type", "start_seconds_estimate"],
111
+ "properties": {
112
+ "type": { "enum": ["persistent", "ephemeral"] },
113
+ "start_seconds_estimate": {
114
+ "type": ["number", "null"],
115
+ "minimum": 0,
116
+ "description": "0 for a running environment; null when unknown."
117
+ },
118
+ "provenance": { "$ref": "#/$defs/provenance" }
119
+ }
120
+ },
121
+ "limits": {
122
+ "type": "object",
123
+ "additionalProperties": false,
124
+ "required": ["max_run_seconds", "workspace_survives"],
125
+ "properties": {
126
+ "vcpu": { "type": ["integer", "null"], "minimum": 1 },
127
+ "memory_mb": { "type": ["integer", "null"], "minimum": 1 },
128
+ "disk_gb": { "type": ["number", "null"], "minimum": 0 },
129
+ "max_concurrent": { "type": ["integer", "null"], "minimum": 1 },
130
+ "max_run_seconds": {
131
+ "type": ["integer", "null"],
132
+ "minimum": 1,
133
+ "description": "Hard ceiling on one run. null means no ceiling."
134
+ },
135
+ "workspace_survives": {
136
+ "type": "boolean",
137
+ "description": "Whether the working directory survives the end of a run and a restart."
138
+ },
139
+ "provenance": { "$ref": "#/$defs/provenance" }
140
+ }
141
+ },
142
+ "labels": { "type": "array", "uniqueItems": true, "items": { "$ref": "#/$defs/label" } },
143
+ "image": {
144
+ "type": ["object", "null"],
145
+ "additionalProperties": false,
146
+ "required": ["name", "version", "ref"],
147
+ "properties": {
148
+ "name": { "type": "string" },
149
+ "version": { "type": "string" },
150
+ "ref": { "type": ["string", "null"], "description": "Registry or snapshot reference; null when the image is not built yet." },
151
+ "contents": { "type": "array", "items": { "type": "string" } }
152
+ }
153
+ },
154
+ "dispatch": {
155
+ "type": "object",
156
+ "additionalProperties": false,
157
+ "required": ["method", "exists_today"],
158
+ "properties": {
159
+ "method": { "enum": ["lane-local", "lane-ssm", "lane-endpoint", "dm", "fleet-task"] },
160
+ "target": { "type": "string", "description": "What the dispatcher addresses, for example '--placement outpost:primary'." },
161
+ "exists_today": { "type": "boolean", "description": "false when the method is proposed and not built." }
162
+ }
163
+ },
164
+ "cost": {
165
+ "type": "object",
166
+ "additionalProperties": false,
167
+ "required": ["model", "marginal_usd_per_hour", "provenance"],
168
+ "properties": {
169
+ "model": {
170
+ "enum": ["owned", "fixed", "metered"],
171
+ "description": "owned: already paid hardware. fixed: a standing charge whether or not work runs. metered: charged while running."
172
+ },
173
+ "marginal_usd_per_hour": { "type": ["number", "null"], "minimum": 0, "description": "Extra cost of one more hour of work here. 0 for owned and fixed." },
174
+ "fixed_usd_per_month": { "type": ["number", "null"], "minimum": 0 },
175
+ "suspend_usd_per_hour": { "type": ["number", "null"], "minimum": 0 },
176
+ "basis": { "type": "string" },
177
+ "provenance": { "$ref": "#/$defs/provenance" }
178
+ }
179
+ },
180
+ "taints": { "type": "array", "items": { "$ref": "#/$defs/taint" } }
181
+ },
182
+ "allOf": [
183
+ {
184
+ "if": { "properties": { "lifecycle": { "properties": { "type": { "const": "ephemeral" } } } } },
185
+ "then": {
186
+ "properties": {
187
+ "limits": {
188
+ "required": ["max_run_seconds", "workspace_survives"],
189
+ "properties": {
190
+ "workspace_survives": { "const": false },
191
+ "max_run_seconds": { "type": "integer" }
192
+ }
193
+ }
194
+ }
195
+ }
196
+ },
197
+ {
198
+ "if": { "properties": { "kind": { "const": "local" } } },
199
+ "then": { "properties": { "dispatch": { "properties": { "method": { "const": "lane-local" } } } } }
200
+ },
201
+ {
202
+ "description": "The id prefix is the kind.",
203
+ "if": { "properties": { "kind": { "const": "local" } }, "required": ["kind"] },
204
+ "then": { "properties": { "id": { "pattern": "^local:" } } }
205
+ },
206
+ {
207
+ "if": { "properties": { "kind": { "const": "outpost" } }, "required": ["kind"] },
208
+ "then": { "properties": { "id": { "pattern": "^outpost:" } } }
209
+ },
210
+ {
211
+ "if": { "properties": { "kind": { "const": "microvm" } }, "required": ["kind"] },
212
+ "then": { "properties": { "id": { "pattern": "^microvm:" } } }
213
+ },
214
+ {
215
+ "if": { "properties": { "kind": { "const": "bot" } }, "required": ["kind"] },
216
+ "then": { "properties": { "id": { "pattern": "^bot:" } } }
217
+ },
218
+ {
219
+ "if": { "properties": { "kind": { "const": "fleet-box" } }, "required": ["kind"] },
220
+ "then": { "properties": { "id": { "pattern": "^fleet-box:" } } }
221
+ },
222
+ {
223
+ "if": { "properties": { "kind": { "const": "bot" } } },
224
+ "then": { "properties": { "dispatch": { "properties": { "method": { "const": "dm" } } } } }
225
+ },
226
+ {
227
+ "if": { "properties": { "kind": { "const": "microvm" } } },
228
+ "then": { "properties": { "lifecycle": { "properties": { "type": { "const": "ephemeral" } } } } }
229
+ },
230
+ {
231
+ "if": { "properties": { "state": { "const": "template" } } },
232
+ "then": { "properties": { "image": { "type": "object" } }, "required": ["image"] }
233
+ }
234
+ ]
235
+ },
236
+ "reading_meta": {
237
+ "type": "object",
238
+ "required": ["observed_at", "ttl_seconds", "source"],
239
+ "properties": {
240
+ "observed_at": { "$ref": "#/$defs/timestamp" },
241
+ "ttl_seconds": { "type": "integer", "minimum": 0 },
242
+ "source": { "type": "string", "minLength": 1 }
243
+ }
244
+ },
245
+ "compute": {
246
+ "allOf": [{ "$ref": "#/$defs/reading_meta" }],
247
+ "type": "object",
248
+ "unevaluatedProperties": false,
249
+ "properties": {
250
+ "observed_at": true,
251
+ "ttl_seconds": true,
252
+ "source": true,
253
+ "vcpu_online": { "type": "integer", "minimum": 1 },
254
+ "load_1m": { "type": ["number", "null"], "minimum": 0 },
255
+ "load_per_vcpu": { "type": ["number", "null"], "minimum": 0 },
256
+ "mem_total_mb": { "type": "integer", "minimum": 0 },
257
+ "mem_available_mb": { "type": "integer", "minimum": 0 },
258
+ "disk_total_gb": { "type": "number", "minimum": 0 },
259
+ "disk_free_gb": { "type": "number", "minimum": 0 }
260
+ },
261
+ "required": ["vcpu_online", "mem_available_mb", "disk_free_gb"]
262
+ },
263
+ "slots": {
264
+ "allOf": [{ "$ref": "#/$defs/reading_meta" }],
265
+ "type": "object",
266
+ "unevaluatedProperties": false,
267
+ "description": "Content of hq-lanes-host-capacity.v1, provider totals. Per-account slot counts sit on each account.",
268
+ "properties": {
269
+ "observed_at": true,
270
+ "ttl_seconds": true,
271
+ "source": true,
272
+ "host_ref": {
273
+ "type": "object",
274
+ "additionalProperties": false,
275
+ "required": ["kind", "id"],
276
+ "properties": { "kind": { "type": "string" }, "id": { "type": "string" } }
277
+ },
278
+ "providers": {
279
+ "type": "array",
280
+ "items": {
281
+ "type": "object",
282
+ "additionalProperties": false,
283
+ "required": ["engine", "max_running", "running", "queued"],
284
+ "properties": {
285
+ "engine": { "$ref": "#/$defs/engine" },
286
+ "max_running": { "type": "integer", "minimum": 0 },
287
+ "max_queued": { "type": "integer", "minimum": 0 },
288
+ "running": { "type": "integer", "minimum": 0 },
289
+ "queued": { "type": "integer", "minimum": 0 }
290
+ }
291
+ }
292
+ },
293
+ "queued_lanes": { "type": "integer", "minimum": 0 }
294
+ },
295
+ "required": ["host_ref", "providers"]
296
+ },
297
+ "engine": { "enum": ["claude", "codex", "grok"] },
298
+ "account": {
299
+ "allOf": [
300
+ { "$ref": "#/$defs/reading_meta" },
301
+ {
302
+ "if": { "properties": { "usable": { "const": true } }, "required": ["usable"] },
303
+ "then": {
304
+ "properties": {
305
+ "holder": { "const": "owner" },
306
+ "enabled": { "const": true },
307
+ "signed_in": { "const": true }
308
+ }
309
+ }
310
+ }
311
+ ],
312
+ "type": "object",
313
+ "unevaluatedProperties": false,
314
+ "properties": {
315
+ "observed_at": true,
316
+ "ttl_seconds": true,
317
+ "source": true,
318
+ "engine": { "$ref": "#/$defs/engine" },
319
+ "account_id": { "type": "string", "minLength": 1, "description": "Lane-config account label (the id lanes use)." },
320
+ "provider_account_id": { "type": ["string", "null"], "description": "Provider account id from hq-available-ai.v1, when it can be joined." },
321
+ "provider_account_join_verified": { "type": "boolean" },
322
+ "owning_company": {
323
+ "type": "string",
324
+ "description": "Company slug, 'personal' or 'unknown'.",
325
+ "pattern": "^([a-z0-9][a-z0-9-]*|personal|unknown)$"
326
+ },
327
+ "owning_company_source": { "type": "string" },
328
+ "holder": {
329
+ "enum": ["owner", "unknown"],
330
+ "description": "Who holds this login. owner: the HQ owner, who may use it for any of the owner's businesses, so owning_company is a reporting and ranking input and not a filter. unknown: not recorded yet. A login held by another person is never listed here; it goes in foreign_accounts."
331
+ },
332
+ "holder_source": { "type": "string" },
333
+ "usable": {
334
+ "type": "boolean",
335
+ "description": "Whether work may be paired with this login. true is allowed only when holder is owner, enabled is true and signed_in is true. A login whose holder is unknown is recorded with usable false, whatever its sign-in state, until its holder is recorded."
336
+ },
337
+ "usable_for_companies": {
338
+ "type": "array",
339
+ "uniqueItems": true,
340
+ "items": { "$ref": "#/$defs/company_slug" },
341
+ "description": "Companies the owner has explicitly designated this account for. A record for reporting; an owner-held login is not limited to this list."
342
+ },
343
+ "enabled": { "type": "boolean" },
344
+ "signed_in": { "type": ["boolean", "null"], "description": "null when sources disagree or no reading exists." },
345
+ "sign_in_evidence": { "type": "array", "items": { "type": "string" } },
346
+ "slots": {
347
+ "type": "object",
348
+ "additionalProperties": false,
349
+ "properties": {
350
+ "max_running": { "type": "integer", "minimum": 0 },
351
+ "running": { "type": "integer", "minimum": 0 },
352
+ "queued": { "type": "integer", "minimum": 0 },
353
+ "quota_held": { "type": "boolean" }
354
+ }
355
+ },
356
+ "room": {
357
+ "type": "object",
358
+ "additionalProperties": false,
359
+ "required": ["left_percent", "availability", "observed_at", "ttl_seconds"],
360
+ "description": "From hq-available-ai.v1. left_percent and availability are null when there is no reading.",
361
+ "properties": {
362
+ "left_percent": { "type": ["number", "null"], "minimum": 0, "maximum": 100 },
363
+ "availability": {
364
+ "enum": ["ready", "likely_ready", "low", "used_up", "needs_sign_in", "not_installed", null],
365
+ "description": "Exactly the availability words hq-available-ai.v1 emits, copied unchanged from the option this account was joined to. null when no option was joined, so there is no reading."
366
+ },
367
+ "back_at": { "$ref": "#/$defs/timestamp_or_null" },
368
+ "tranche": { "type": "string" },
369
+ "usage_ref": { "type": ["string", "null"], "description": "optionId in available.json." },
370
+ "observed_at": { "$ref": "#/$defs/timestamp_or_null" },
371
+ "ttl_seconds": { "type": "integer", "minimum": 0 }
372
+ }
373
+ }
374
+ },
375
+ "required": ["engine", "account_id", "owning_company", "holder", "usable", "enabled", "signed_in", "room"]
376
+ },
377
+ "foreign_account": {
378
+ "type": "object",
379
+ "additionalProperties": false,
380
+ "required": ["engine", "holder", "observed_at", "ttl_seconds", "source"],
381
+ "description": "A login on this environment that is held by a person other than the owner. Only its existence, engine and holder are recorded, with observed_at, ttl_seconds and source like every other reading; it has no account id, no room and no sign-in state, and it is never paired with work.",
382
+ "properties": {
383
+ "engine": { "$ref": "#/$defs/engine" },
384
+ "holder": {
385
+ "type": "string",
386
+ "pattern": "^other(:[a-z0-9][a-z0-9._-]*)?$",
387
+ "description": "other, or other:<person-slug> when the person is known. Never owner: an owner-held login belongs in accounts."
388
+ },
389
+ "observed_at": { "$ref": "#/$defs/timestamp" },
390
+ "ttl_seconds": { "type": "integer", "minimum": 0 },
391
+ "source": { "type": "string", "minLength": 1 }
392
+ }
393
+ },
394
+ "probe": {
395
+ "allOf": [{ "$ref": "#/$defs/reading_meta" }],
396
+ "type": "object",
397
+ "unevaluatedProperties": false,
398
+ "properties": {
399
+ "observed_at": true,
400
+ "ttl_seconds": true,
401
+ "source": true,
402
+ "name": {
403
+ "type": "string",
404
+ "pattern": "^(secret|repo|integration|vault|data|identity|tool):[A-Za-z0-9._/-]+$",
405
+ "description": "secret:<NAME> holds a secret name only, never a value."
406
+ },
407
+ "result": { "enum": ["pass", "fail", "unknown"] },
408
+ "checks": { "type": "string", "description": "What the probe actually proves, for example 'name exists in vault (HEAD)' versus 'resolvable under this identity'." }
409
+ },
410
+ "required": ["name", "result", "checks"]
411
+ },
412
+ "readings": {
413
+ "type": "object",
414
+ "additionalProperties": false,
415
+ "required": ["accounts", "foreign_accounts", "access"],
416
+ "properties": {
417
+ "compute": { "$ref": "#/$defs/compute" },
418
+ "slots": { "$ref": "#/$defs/slots" },
419
+ "accounts": { "type": "array", "items": { "$ref": "#/$defs/account" } },
420
+ "foreign_accounts": { "type": "array", "items": { "$ref": "#/$defs/foreign_account" } },
421
+ "access": { "type": "array", "items": { "$ref": "#/$defs/probe" } },
422
+ "base_readiness": {
423
+ "allOf": [{ "$ref": "#/$defs/reading_meta" }],
424
+ "type": "object",
425
+ "unevaluatedProperties": false,
426
+ "properties": {
427
+ "observed_at": true,
428
+ "ttl_seconds": true,
429
+ "source": true,
430
+ "result": { "enum": ["ready", "degraded", "not-ready", "unknown"] },
431
+ "document_ref": { "type": ["string", "null"] }
432
+ },
433
+ "required": ["result"]
434
+ }
435
+ }
436
+ }
437
+ }
438
+ }
package/dist/types.d.ts CHANGED
@@ -130,7 +130,7 @@ export interface PackManifest {
130
130
  /**
131
131
  * Guided in-app setup. Optional — absent on
132
132
  * legacy packs, which install unchanged. Validated by
133
- * `lib/packages/setup-block.ts`; `hq packages install --start-bot` creates the
133
+ * `lib/packages/setup-block.ts`; `hq install --start-bot` creates the
134
134
  * bot it names and the bot's system prompt renders the questions and the run
135
135
  * command from it.
136
136
  */
@@ -0,0 +1,8 @@
1
+ /** The expiry as an ISO time, or null when it cannot be read as a time. */
2
+ export declare function authExpiryIso(expiresAt: number | string): string | null;
3
+ /**
4
+ * Expiry of a cached HQ session as text: the ISO time and how far away it is.
5
+ * Shared by `hq whoami` and `hq auth status`. Takes only the expiry, never a token.
6
+ */
7
+ export declare function formatAuthExpiry(expiresAt: number | string, now?: number): string;
8
+ //# sourceMappingURL=auth-expiry.d.ts.map
@@ -0,0 +1,53 @@
1
+ /** The expiry as an ISO time, or null when it cannot be read as a time. */
2
+ export function authExpiryIso(expiresAt) {
3
+ const expiresAtMs = typeof expiresAt === "number" ? expiresAt : Date.parse(expiresAt);
4
+ // A finite number can still be outside the Date range (a damaged cache
5
+ // holding 1e20, say); toISOString would throw a RangeError on it.
6
+ const expiresAtDate = new Date(expiresAtMs);
7
+ return Number.isFinite(expiresAtMs) && !Number.isNaN(expiresAtDate.getTime())
8
+ ? expiresAtDate.toISOString()
9
+ : null;
10
+ }
11
+ /**
12
+ * Expiry of a cached HQ session as text: the ISO time and how far away it is.
13
+ * Shared by `hq whoami` and `hq auth status`. Takes only the expiry, never a token.
14
+ */
15
+ export function formatAuthExpiry(expiresAt, now = Date.now()) {
16
+ const expiresAtMs = typeof expiresAt === "number" ? expiresAt : Date.parse(expiresAt);
17
+ const expiresAtDate = new Date(expiresAtMs);
18
+ if (!Number.isFinite(expiresAtMs) || Number.isNaN(expiresAtDate.getTime())) {
19
+ return String(expiresAt);
20
+ }
21
+ const remainingMs = expiresAtMs - now;
22
+ const absoluteMs = Math.abs(remainingMs);
23
+ let unit;
24
+ let unitMs;
25
+ if (absoluteMs >= 365 * 24 * 60 * 60 * 1_000) {
26
+ unit = "year";
27
+ unitMs = 365 * 24 * 60 * 60 * 1_000;
28
+ }
29
+ else if (absoluteMs >= 30 * 24 * 60 * 60 * 1_000) {
30
+ unit = "month";
31
+ unitMs = 30 * 24 * 60 * 60 * 1_000;
32
+ }
33
+ else if (absoluteMs >= 24 * 60 * 60 * 1_000) {
34
+ unit = "day";
35
+ unitMs = 24 * 60 * 60 * 1_000;
36
+ }
37
+ else if (absoluteMs >= 60 * 60 * 1_000) {
38
+ unit = "hour";
39
+ unitMs = 60 * 60 * 1_000;
40
+ }
41
+ else if (absoluteMs >= 60 * 1_000) {
42
+ unit = "minute";
43
+ unitMs = 60 * 1_000;
44
+ }
45
+ else {
46
+ unit = "second";
47
+ unitMs = 1_000;
48
+ }
49
+ const relative = new Intl.RelativeTimeFormat("en", { numeric: "always" })
50
+ .format(Math.round(remainingMs / unitMs), unit);
51
+ return expiresAtDate.toISOString() + " (" + relative + ")";
52
+ }
53
+ //# sourceMappingURL=auth-expiry.js.map
@@ -8,7 +8,7 @@ export declare const DEFAULT_CALLBACK_PORT = 8765;
8
8
  export declare function callbackPortBusyGuidance(port: number): string;
9
9
  /**
10
10
  * The LOOSE predicate for a caller that just invoked browserLogin and is
11
- * catching its own error (`hq auth login`/`hq login`): an EADDRINUSE by errno
11
+ * catching its own error (`hq login`): an EADDRINUSE by errno
12
12
  * code OR message is the callback-port collision, because the callback server is
13
13
  * the only listener that call could have opened. NOT for the shared boundary —
14
14
  * use {@link callbackPortBusyMessage} there.
@@ -21,14 +21,14 @@
21
21
  // address already in use 127.0.0.1:8765`. That Node error carries no `expected`
22
22
  // flag and is not an AuthError/CognitoAuthError/…, so every predicate in
23
23
  // handleTopLevelError returned false and the collision was captured as a
24
- // high-priority, unfixable "crash". `hq auth login` already classified the
24
+ // high-priority, unfixable "crash". `hq login` already classified the
25
25
  // identical condition in a file-private helper; this module lifts that
26
26
  // classification to the shared boundary so every implicit call site is covered
27
27
  // from one source of truth.
28
28
  //
29
29
  // Two predicates, differing ONLY by how much context the caller already has:
30
30
  // - isCallbackPortBusy(err): the LOOSE form for a call site that KNOWS it just
31
- // invoked browserLogin (`hq auth login`/`hq login`). There the only listener
31
+ // invoked browserLogin (`hq login`). There the only listener
32
32
  // in play is the callback server, so an EADDRINUSE — by code or message — is
33
33
  // unambiguously the callback port.
34
34
  // - callbackPortBusyMessage(err, port): the STRUCTURAL form for the shared
@@ -47,12 +47,12 @@ const EADDRINUSE = "EADDRINUSE";
47
47
  */
48
48
  export function callbackPortBusyGuidance(port) {
49
49
  return (`The browser-login callback port (127.0.0.1:${port}) is already in use. ` +
50
- "Another `hq auth login` may still be waiting for browser sign-in. Finish that login, " +
50
+ "Another `hq login` may still be waiting for browser sign-in. Finish that login, " +
51
51
  "or stop its terminal/process, then retry.");
52
52
  }
53
53
  /**
54
54
  * The LOOSE predicate for a caller that just invoked browserLogin and is
55
- * catching its own error (`hq auth login`/`hq login`): an EADDRINUSE by errno
55
+ * catching its own error (`hq login`): an EADDRINUSE by errno
56
56
  * code OR message is the callback-port collision, because the callback server is
57
57
  * the only listener that call could have opened. NOT for the shared boundary —
58
58
  * use {@link callbackPortBusyMessage} there.
@@ -14,6 +14,13 @@ export declare const FIRST_SYNC_TELEMETRY_DISCLOSURE_LINE = "HQ sends a usage ev
14
14
  export declare const CLI_INVITE_NUDGE_TELEMETRY_DISCLOSURE_LINE = "HQ sends a usage event when it shows the teammate invite prompt (your company UID and whether you saw, clicked, or dismissed the prompt; no invitee details, command names, file contents, or secrets). Set HQ_TELEMETRY=0 to turn this off.";
15
15
  export declare const CLI_FEATURE_USED_TELEMETRY_FLAG = "cli.feature-used-telemetry-v1";
16
16
  export declare const CLI_FEATURE_USED_TELEMETRY_DISCLOSURE_LINE = "HQ sends a feature-use event when you run a supported CLI feature (feature kind and outcome, plus your company UID when available; never command names, file contents, or secrets). The hq-flags key cli.feature-used-telemetry-v1 controls these events. Set HQ_TELEMETRY=0 to turn this off.";
17
+ /**
18
+ * What HQ stores on this computer and never sends: the local command count
19
+ * (utils/command-usage.ts). Printed once on stderr on the first interactive
20
+ * run that is not `--json`, signed in or not. It is separate from the notices
21
+ * above because nothing is sent, so `HQ_TELEMETRY=0` does not turn it off.
22
+ */
23
+ export declare const LOCAL_COMMAND_USAGE_DISCLOSURE_LINE = "HQ keeps a count of the commands you run in ~/.hq/command-usage on this computer (the command name and the date of each run, never arguments, file contents, or secrets). It is never sent anywhere, so HQ_TELEMETRY=0 does not turn it off. Run `hq doctor usage` to see it; delete that folder to clear it.";
17
24
  export type CliInviteNudgeOutcome = "shown" | "clicked" | "dismissed";
18
25
  export interface CliInviteNudgeEvent {
19
26
  companyUid: string;
@@ -68,6 +75,8 @@ export declare function withCliFeatureUsed<T>(kind: CliFeatureKind, action: () =
68
75
  /**
69
76
  * `HQ_TELEMETRY=0` (also `false` and `off`, case-insensitive) disables every
70
77
  * CLI POST to `/v1/telemetry/events`. `HQ_TELEMETRY_TIMEOUT_MS` is unchanged.
78
+ * It does not turn off the local command count (utils/command-usage.ts): that
79
+ * count is a file on this computer and sends nothing.
71
80
  */
72
81
  export declare function isCliTelemetryDisabled(env?: NodeJS.ProcessEnv): boolean;
73
82
  /** Feature-use collection stays off until the HQ flag is explicitly enabled. */
@@ -83,6 +92,18 @@ export declare function maybeDiscloseCliTelemetry(stderr?: {
83
92
  }, stdout?: {
84
93
  isTTY?: boolean;
85
94
  }, argv?: readonly string[]): boolean;
95
+ export declare function localCommandUsageDisclosureMarkerPath(): string;
96
+ /**
97
+ * Print the local command count notice at most once per machine. It does not
98
+ * depend on sign-in or on `HQ_TELEMETRY`, because the count does not either.
99
+ * Nothing is printed while `~/.hq` does not exist: no count is kept then, and
100
+ * the marker could not be recorded.
101
+ */
102
+ export declare function maybeDiscloseLocalCommandUsage(stderr?: {
103
+ write: (chunk: string) => unknown;
104
+ }, stdout?: {
105
+ isTTY?: boolean;
106
+ }, argv?: readonly string[]): boolean;
86
107
  /**
87
108
  * Emit the authenticated CLI session signal using an already-cached token.
88
109
  * This deliberately never refreshes a session or opens a browser.