@indigoai-us/hq-cli 5.115.6 → 5.116.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 (55) hide show
  1. package/CHANGELOG.md +72 -11
  2. package/dist/command-catalog.generated.d.ts +162 -2
  3. package/dist/command-catalog.generated.js +205 -2
  4. package/dist/command-registration-plan.d.ts +6 -0
  5. package/dist/command-registration-plan.js +1 -0
  6. package/dist/commands/agent-enroll.d.ts +105 -0
  7. package/dist/commands/agent-enroll.js +273 -0
  8. package/dist/commands/agent-kit.d.ts +53 -0
  9. package/dist/commands/agent-kit.js +260 -0
  10. package/dist/commands/agent-mcp.d.ts +22 -0
  11. package/dist/commands/agent-mcp.js +104 -0
  12. package/dist/commands/agent-probe.d.ts +71 -0
  13. package/dist/commands/agent-probe.js +294 -0
  14. package/dist/commands/agent.d.ts +12 -0
  15. package/dist/commands/agent.js +23 -0
  16. package/dist/commands/agents.d.ts +27 -0
  17. package/dist/commands/agents.js +280 -6
  18. package/dist/commands/secrets.js +17 -5
  19. package/dist/lib/agent-kit/creds.d.ts +60 -0
  20. package/dist/lib/agent-kit/creds.js +123 -0
  21. package/dist/lib/agent-kit/kit-config.d.ts +29 -0
  22. package/dist/lib/agent-kit/kit-config.js +54 -0
  23. package/dist/lib/agent-kit/log.d.ts +17 -0
  24. package/dist/lib/agent-kit/log.js +46 -0
  25. package/dist/lib/agent-kit/mcp/jsonrpc.d.ts +84 -0
  26. package/dist/lib/agent-kit/mcp/jsonrpc.js +164 -0
  27. package/dist/lib/agent-kit/mcp/tools.d.ts +45 -0
  28. package/dist/lib/agent-kit/mcp/tools.js +280 -0
  29. package/dist/lib/agent-kit/paths.d.ts +42 -0
  30. package/dist/lib/agent-kit/paths.js +56 -0
  31. package/dist/lib/agent-kit/run/heartbeat.d.ts +52 -0
  32. package/dist/lib/agent-kit/run/heartbeat.js +97 -0
  33. package/dist/lib/agent-kit/run/inbox.d.ts +59 -0
  34. package/dist/lib/agent-kit/run/inbox.js +152 -0
  35. package/dist/lib/agent-kit/run/mesh-listener.d.ts +58 -0
  36. package/dist/lib/agent-kit/run/mesh-listener.js +193 -0
  37. package/dist/lib/agent-kit/run/sync.d.ts +33 -0
  38. package/dist/lib/agent-kit/run/sync.js +58 -0
  39. package/dist/lib/agent-kit/services.d.ts +21 -0
  40. package/dist/lib/agent-kit/services.js +46 -0
  41. package/dist/lib/agent-kit/skills.d.ts +18 -0
  42. package/dist/lib/agent-kit/skills.js +149 -0
  43. package/dist/lib/service-manager/index.d.ts +43 -0
  44. package/dist/lib/service-manager/index.js +114 -0
  45. package/dist/lib/service-manager/launchd.d.ts +23 -0
  46. package/dist/lib/service-manager/launchd.js +81 -0
  47. package/dist/lib/service-manager/systemd.d.ts +19 -0
  48. package/dist/lib/service-manager/systemd.js +72 -0
  49. package/dist/lib/service-manager/types.d.ts +32 -0
  50. package/dist/lib/service-manager/types.js +26 -0
  51. package/dist/utils/self-update.js +2 -30
  52. package/dist/utils/update-command-supervisor.cjs +194 -0
  53. package/dist/utils/version-gate.d.ts +18 -0
  54. package/dist/utils/version-gate.js +126 -7
  55. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -2,20 +2,66 @@
2
2
 
3
3
  ## [Unreleased]
4
4
 
5
- ## [5.115.6] — 2026-09-16
5
+ ## [5.116.0] — 2026-09-16
6
+
7
+ ### Added
8
+
9
+ - External bots as team members (host side). `hq agent enroll <code>`
10
+ redeems a one-time enrollment code from the console: it generates an
11
+ Ed25519 host key at `~/.hq-agent/host-key` (0600), POSTs the public half to
12
+ `POST /v1/agents/enroll`, and writes `~/.hq-agent/machine-creds.json` (0600)
13
+ with `runtime: "external"`. It refuses to run on a host that already holds a
14
+ human session file or another machine identity unless `--replace`, and
15
+ never reads `~/.hq/cognito-tokens.json`. Every contract error (expired,
16
+ already redeemed, invalid, revoked, plan-gated, throttled, unreachable) maps
17
+ to a message that names the fix.
18
+ - `hq agent kit install|status|uninstall|run <service>`: user-level services
19
+ (LaunchAgent on macOS, systemd `--user` on Linux) for the company-vault sync
20
+ loop, a work-mesh doorbell listener (ids-only MQTT → REST refetch into
21
+ `~/.hq/work-mesh/cache`), an inbox poller that mirrors new items to
22
+ `~/.hq-agent/inbox/` (server ack opt-in via `--inbox-ack`), and a 60 s
23
+ heartbeat posting `{ components: { sync, mesh, inbox } }`. Each unit just
24
+ runs `hq agent kit run <service>`; logs land in `~/.hq-agent/logs/`. The
25
+ install also ships `~/.hq-agent/skills/{dm,search,files,secrets-exec,work-mesh-status}/SKILL.md`
26
+ (agentskills.io format). `docker/hq-agent-kit/` runs the same four
27
+ processes from a mounted creds volume.
28
+ - `hq agent probe`: whoami → vault sync → mesh presence → DM round trip to
29
+ self → secrets list, one PASS/FAIL line each, non-zero exit on any failure,
30
+ a final `heartbeat <age>` line (the recipe format), and the result POSTed to
31
+ `POST /v1/agents/{uid}/probe-result` so the console flips to Enrolled.
32
+ - `hq agent mcp`: a stdio MCP server (no SDK dependency; initialize / ping /
33
+ tools/list / tools/call) backed by the enrolled machine identity, exposing
34
+ `hq_whoami`, `hq_search`, `hq_files_list`, `hq_files_read`,
35
+ `hq_secrets_list`, `hq_secrets_exec` (exit code + output only, never
36
+ values), `hq_dm_send`, `hq_inbox_read`, `hq_work_mesh_status`. Console
37
+ recipes register it as `command: hq, args: [agent, mcp]`.
38
+ - `hq agents rotate <uid>` (fresh enrollment code, shown once) and
39
+ `hq agents revoke <uid> [--remove] --yes` for external agents. Both fail
40
+ closed under `HQ_API_KEY` (JWT-only routes).
41
+
42
+ ### Changed
43
+
44
+ - `@indigoai-us/hq-cloud` pinned to `~6.16.48`, whose machine mint signs the
45
+ server's nonce with the host key when creds carry `runtime: "external"`.
6
46
 
7
47
  ### Fixed
8
48
 
9
- - `hq doctor --fix` can now refresh a company sync journal that is stale or
10
- has never synced, when that company still has a folder under `companies/`.
11
- It pulls that company only, keeps your local copy if there is a conflict,
12
- and does not push. Company journals left over from memberships you do not
13
- keep locally are reported as unused rather than broken, so a session-start
14
- health check no longer files "could not repair" reports for folders that
15
- were never on this machine. Personal journals are unchanged: they still
16
- warn when stale, and `--fix` will not pull your personal vault on its own.
17
- The repair pass also skips the integrations inventory, which it cannot
18
- repair, so a slow connection check cannot stall the fix.
49
+ - When a new agent needs an owner action, `hq agents provision` prints the
50
+ current Codex sign-in code or a link to finish setting up the Slack app. `hq agents status
51
+ <slug>` gets the current action again. The `--json` output adds a
52
+ `pendingActions` array, plus `slackInstallPending` and `slackInstallUrl` for
53
+ Slack installs.
54
+
55
+ - `hq secrets` now fails promptly instead of waiting for a browser sign-in
56
+ that cannot be completed when stdin or stderr is not a terminal, or in CI.
57
+ Run `hq login` from an interactive shell first if no valid session exists.
58
+
59
+ - hq gives both visible and quiet version-gated updates 30 minutes to finish.
60
+ When that limit expires, it tries to terminate the updater's process group
61
+ on POSIX or process tree on Windows. If the operating system denies that
62
+ request, hq reports it instead of waiting forever. Set `HQ_UPDATE_TIMEOUT_MS`
63
+ to another whole number of milliseconds up to 2,147,483,647. hq ignores an
64
+ invalid value and tells you it is using the 30-minute limit.
19
65
 
20
66
  - HQ's housekeeping pass now clears out add-on shortcuts that lead nowhere,
21
67
  instead of warning about them forever. A pack that stops shipping one of its
@@ -37,6 +83,21 @@
37
83
  that leads to real content. Repairing a tree this way fixed a batch of
38
84
  long-broken pack shortcuts in one pass.
39
85
 
86
+ ## [5.115.6] — 2026-09-16
87
+
88
+ ### Fixed
89
+
90
+ - `hq doctor --fix` can now refresh a company sync journal that is stale or
91
+ has never synced, when that company still has a folder under `companies/`.
92
+ It pulls that company only, keeps your local copy if there is a conflict,
93
+ and does not push. Company journals left over from memberships you do not
94
+ keep locally are reported as unused rather than broken, so a session-start
95
+ health check no longer files "could not repair" reports for folders that
96
+ were never on this machine. Personal journals are unchanged: they still
97
+ warn when stale, and `--fix` will not pull your personal vault on its own.
98
+ The repair pass also skips the integrations inventory, which it cannot
99
+ repair, so a slow connection check cannot stall the fix.
100
+
40
101
  ## [5.115.5] — 2026-09-15
41
102
 
42
103
  ### Fixed
@@ -3853,9 +3853,9 @@ export declare const COMMAND_CATALOG: readonly [{
3853
3853
  readonly description: "Show an agent's setup state and runtime detail";
3854
3854
  readonly aliases: readonly [];
3855
3855
  readonly hidden: false;
3856
- readonly usage: "[options] <agentUid>";
3856
+ readonly usage: "[options] <agent>";
3857
3857
  readonly arguments: readonly [{
3858
- readonly name: "agentUid";
3858
+ readonly name: "agent";
3859
3859
  readonly required: true;
3860
3860
  readonly variadic: false;
3861
3861
  }];
@@ -4022,6 +4022,47 @@ export declare const COMMAND_CATALOG: readonly [{
4022
4022
  readonly description: "Confirm the irreversible teardown (required)";
4023
4023
  }];
4024
4024
  readonly subcommands: readonly [];
4025
+ }, {
4026
+ readonly name: "rotate";
4027
+ readonly description: "Issue a fresh enrollment code for an external agent (old secret + host key stop minting)";
4028
+ readonly aliases: readonly [];
4029
+ readonly hidden: false;
4030
+ readonly usage: "[options] <agentUid>";
4031
+ readonly arguments: readonly [{
4032
+ readonly name: "agentUid";
4033
+ readonly required: true;
4034
+ readonly variadic: false;
4035
+ }];
4036
+ readonly options: readonly [{
4037
+ readonly flags: "--company <slug>";
4038
+ readonly description: "Company slug (resolves to companyUid)";
4039
+ }, {
4040
+ readonly flags: "--json";
4041
+ readonly description: "Emit raw JSON (code included — pipe carefully)";
4042
+ }];
4043
+ readonly subcommands: readonly [];
4044
+ }, {
4045
+ readonly name: "revoke";
4046
+ readonly description: "Revoke an external agent: disable its login and drop it from the team";
4047
+ readonly aliases: readonly [];
4048
+ readonly hidden: false;
4049
+ readonly usage: "[options] <agentUid>";
4050
+ readonly arguments: readonly [{
4051
+ readonly name: "agentUid";
4052
+ readonly required: true;
4053
+ readonly variadic: false;
4054
+ }];
4055
+ readonly options: readonly [{
4056
+ readonly flags: "--company <slug>";
4057
+ readonly description: "Company slug (resolves to companyUid)";
4058
+ }, {
4059
+ readonly flags: "--remove";
4060
+ readonly description: "Also delete the agent entity (it disappears from the roster)";
4061
+ }, {
4062
+ readonly flags: "--yes";
4063
+ readonly description: "Confirm the revoke (required)";
4064
+ }];
4065
+ readonly subcommands: readonly [];
4025
4066
  }, {
4026
4067
  readonly name: "jobs";
4027
4068
  readonly description: "List, pause, or cancel an agent's scheduled jobs";
@@ -4091,6 +4132,125 @@ export declare const COMMAND_CATALOG: readonly [{
4091
4132
  readonly subcommands: readonly [];
4092
4133
  }];
4093
4134
  }];
4135
+ }, {
4136
+ readonly name: "agent";
4137
+ readonly description: "Enroll and run this host as an external HQ agent";
4138
+ readonly aliases: readonly [];
4139
+ readonly hidden: false;
4140
+ readonly usage: "[options] [command]";
4141
+ readonly arguments: readonly [];
4142
+ readonly options: readonly [];
4143
+ readonly subcommands: readonly [{
4144
+ readonly name: "enroll";
4145
+ readonly description: "Enroll this host as an external HQ agent using a one-time code";
4146
+ readonly aliases: readonly [];
4147
+ readonly hidden: false;
4148
+ readonly usage: "[options] <code>";
4149
+ readonly arguments: readonly [{
4150
+ readonly name: "code";
4151
+ readonly required: true;
4152
+ readonly variadic: false;
4153
+ }];
4154
+ readonly options: readonly [{
4155
+ readonly flags: "--company <slug>";
4156
+ readonly description: "Expected company slug (warns when the code belongs elsewhere)";
4157
+ }, {
4158
+ readonly flags: "--replace";
4159
+ readonly description: "Overwrite an existing machine identity on this host";
4160
+ }, {
4161
+ readonly flags: "--api-base-url <url>";
4162
+ readonly description: "hq-pro control plane (default: HQ_VAULT_API_URL or production)";
4163
+ }];
4164
+ readonly subcommands: readonly [];
4165
+ }, {
4166
+ readonly name: "kit";
4167
+ readonly description: "Install, inspect, or run the external-agent background services";
4168
+ readonly aliases: readonly [];
4169
+ readonly hidden: false;
4170
+ readonly usage: "[options] [command]";
4171
+ readonly arguments: readonly [];
4172
+ readonly options: readonly [];
4173
+ readonly subcommands: readonly [{
4174
+ readonly name: "install";
4175
+ readonly description: "Install sync, work-mesh, inbox and heartbeat services plus the skills directory";
4176
+ readonly aliases: readonly [];
4177
+ readonly hidden: false;
4178
+ readonly usage: "[options]";
4179
+ readonly arguments: readonly [];
4180
+ readonly options: readonly [{
4181
+ readonly flags: "--hq-root <path>";
4182
+ readonly description: "Local HQ tree to sync the company vault into (default: ~/.hq-agent/hq)";
4183
+ }, {
4184
+ readonly flags: "--inbox-ack";
4185
+ readonly description: "Ack mirrored inbox items on the server (default: leave acking to the bot)";
4186
+ }, {
4187
+ readonly flags: "--no-activate";
4188
+ readonly description: "Write unit files but do not load them";
4189
+ }, {
4190
+ readonly flags: "--json";
4191
+ readonly description: "Print machine-readable JSON";
4192
+ }];
4193
+ readonly subcommands: readonly [];
4194
+ }, {
4195
+ readonly name: "status";
4196
+ readonly description: "Show whether each kit service is installed and running";
4197
+ readonly aliases: readonly [];
4198
+ readonly hidden: false;
4199
+ readonly usage: "[options]";
4200
+ readonly arguments: readonly [];
4201
+ readonly options: readonly [{
4202
+ readonly flags: "--json";
4203
+ readonly description: "Print machine-readable JSON";
4204
+ }];
4205
+ readonly subcommands: readonly [];
4206
+ }, {
4207
+ readonly name: "uninstall";
4208
+ readonly description: "Stop and remove the kit services (credentials and skills are kept)";
4209
+ readonly aliases: readonly [];
4210
+ readonly hidden: false;
4211
+ readonly usage: "[options]";
4212
+ readonly arguments: readonly [];
4213
+ readonly options: readonly [{
4214
+ readonly flags: "--json";
4215
+ readonly description: "Print machine-readable JSON";
4216
+ }];
4217
+ readonly subcommands: readonly [];
4218
+ }, {
4219
+ readonly name: "run";
4220
+ readonly description: "Run one kit service in the foreground (sync|mesh|inbox|heartbeat)";
4221
+ readonly aliases: readonly [];
4222
+ readonly hidden: false;
4223
+ readonly usage: "[options] <service>";
4224
+ readonly arguments: readonly [{
4225
+ readonly name: "service";
4226
+ readonly required: true;
4227
+ readonly variadic: false;
4228
+ }];
4229
+ readonly options: readonly [];
4230
+ readonly subcommands: readonly [];
4231
+ }];
4232
+ }, {
4233
+ readonly name: "probe";
4234
+ readonly description: "Verify identity, vault sync, work-mesh presence, DMs and secrets; report to the console";
4235
+ readonly aliases: readonly [];
4236
+ readonly hidden: false;
4237
+ readonly usage: "[options]";
4238
+ readonly arguments: readonly [];
4239
+ readonly options: readonly [{
4240
+ readonly flags: "--json";
4241
+ readonly description: "Print machine-readable JSON";
4242
+ }];
4243
+ readonly subcommands: readonly [];
4244
+ }, {
4245
+ readonly name: "mcp";
4246
+ readonly description: "Serve HQ as a stdio MCP server for the bot framework (whoami, search, files, secrets-exec, dm, inbox, work-mesh)";
4247
+ readonly aliases: readonly [];
4248
+ readonly hidden: false;
4249
+ readonly usage: "[options]";
4250
+ readonly arguments: readonly [];
4251
+ readonly options: readonly [];
4252
+ readonly subcommands: readonly [];
4253
+ }];
4094
4254
  }, {
4095
4255
  readonly name: "outposts";
4096
4256
  readonly description: "Manage your personal HQ Outposts (EC2 boxes)";
@@ -4979,10 +4979,10 @@ export const COMMAND_CATALOG = [
4979
4979
  "description": "Show an agent's setup state and runtime detail",
4980
4980
  "aliases": [],
4981
4981
  "hidden": false,
4982
- "usage": "[options] <agentUid>",
4982
+ "usage": "[options] <agent>",
4983
4983
  "arguments": [
4984
4984
  {
4985
- "name": "agentUid",
4985
+ "name": "agent",
4986
4986
  "required": true,
4987
4987
  "variadic": false
4988
4988
  }
@@ -5205,6 +5205,60 @@ export const COMMAND_CATALOG = [
5205
5205
  ],
5206
5206
  "subcommands": []
5207
5207
  },
5208
+ {
5209
+ "name": "rotate",
5210
+ "description": "Issue a fresh enrollment code for an external agent (old secret + host key stop minting)",
5211
+ "aliases": [],
5212
+ "hidden": false,
5213
+ "usage": "[options] <agentUid>",
5214
+ "arguments": [
5215
+ {
5216
+ "name": "agentUid",
5217
+ "required": true,
5218
+ "variadic": false
5219
+ }
5220
+ ],
5221
+ "options": [
5222
+ {
5223
+ "flags": "--company <slug>",
5224
+ "description": "Company slug (resolves to companyUid)"
5225
+ },
5226
+ {
5227
+ "flags": "--json",
5228
+ "description": "Emit raw JSON (code included — pipe carefully)"
5229
+ }
5230
+ ],
5231
+ "subcommands": []
5232
+ },
5233
+ {
5234
+ "name": "revoke",
5235
+ "description": "Revoke an external agent: disable its login and drop it from the team",
5236
+ "aliases": [],
5237
+ "hidden": false,
5238
+ "usage": "[options] <agentUid>",
5239
+ "arguments": [
5240
+ {
5241
+ "name": "agentUid",
5242
+ "required": true,
5243
+ "variadic": false
5244
+ }
5245
+ ],
5246
+ "options": [
5247
+ {
5248
+ "flags": "--company <slug>",
5249
+ "description": "Company slug (resolves to companyUid)"
5250
+ },
5251
+ {
5252
+ "flags": "--remove",
5253
+ "description": "Also delete the agent entity (it disappears from the roster)"
5254
+ },
5255
+ {
5256
+ "flags": "--yes",
5257
+ "description": "Confirm the revoke (required)"
5258
+ }
5259
+ ],
5260
+ "subcommands": []
5261
+ },
5208
5262
  {
5209
5263
  "name": "jobs",
5210
5264
  "description": "List, pause, or cancel an agent's scheduled jobs",
@@ -5295,6 +5349,155 @@ export const COMMAND_CATALOG = [
5295
5349
  }
5296
5350
  ]
5297
5351
  },
5352
+ {
5353
+ "name": "agent",
5354
+ "description": "Enroll and run this host as an external HQ agent",
5355
+ "aliases": [],
5356
+ "hidden": false,
5357
+ "usage": "[options] [command]",
5358
+ "arguments": [],
5359
+ "options": [],
5360
+ "subcommands": [
5361
+ {
5362
+ "name": "enroll",
5363
+ "description": "Enroll this host as an external HQ agent using a one-time code",
5364
+ "aliases": [],
5365
+ "hidden": false,
5366
+ "usage": "[options] <code>",
5367
+ "arguments": [
5368
+ {
5369
+ "name": "code",
5370
+ "required": true,
5371
+ "variadic": false
5372
+ }
5373
+ ],
5374
+ "options": [
5375
+ {
5376
+ "flags": "--company <slug>",
5377
+ "description": "Expected company slug (warns when the code belongs elsewhere)"
5378
+ },
5379
+ {
5380
+ "flags": "--replace",
5381
+ "description": "Overwrite an existing machine identity on this host"
5382
+ },
5383
+ {
5384
+ "flags": "--api-base-url <url>",
5385
+ "description": "hq-pro control plane (default: HQ_VAULT_API_URL or production)"
5386
+ }
5387
+ ],
5388
+ "subcommands": []
5389
+ },
5390
+ {
5391
+ "name": "kit",
5392
+ "description": "Install, inspect, or run the external-agent background services",
5393
+ "aliases": [],
5394
+ "hidden": false,
5395
+ "usage": "[options] [command]",
5396
+ "arguments": [],
5397
+ "options": [],
5398
+ "subcommands": [
5399
+ {
5400
+ "name": "install",
5401
+ "description": "Install sync, work-mesh, inbox and heartbeat services plus the skills directory",
5402
+ "aliases": [],
5403
+ "hidden": false,
5404
+ "usage": "[options]",
5405
+ "arguments": [],
5406
+ "options": [
5407
+ {
5408
+ "flags": "--hq-root <path>",
5409
+ "description": "Local HQ tree to sync the company vault into (default: ~/.hq-agent/hq)"
5410
+ },
5411
+ {
5412
+ "flags": "--inbox-ack",
5413
+ "description": "Ack mirrored inbox items on the server (default: leave acking to the bot)"
5414
+ },
5415
+ {
5416
+ "flags": "--no-activate",
5417
+ "description": "Write unit files but do not load them"
5418
+ },
5419
+ {
5420
+ "flags": "--json",
5421
+ "description": "Print machine-readable JSON"
5422
+ }
5423
+ ],
5424
+ "subcommands": []
5425
+ },
5426
+ {
5427
+ "name": "status",
5428
+ "description": "Show whether each kit service is installed and running",
5429
+ "aliases": [],
5430
+ "hidden": false,
5431
+ "usage": "[options]",
5432
+ "arguments": [],
5433
+ "options": [
5434
+ {
5435
+ "flags": "--json",
5436
+ "description": "Print machine-readable JSON"
5437
+ }
5438
+ ],
5439
+ "subcommands": []
5440
+ },
5441
+ {
5442
+ "name": "uninstall",
5443
+ "description": "Stop and remove the kit services (credentials and skills are kept)",
5444
+ "aliases": [],
5445
+ "hidden": false,
5446
+ "usage": "[options]",
5447
+ "arguments": [],
5448
+ "options": [
5449
+ {
5450
+ "flags": "--json",
5451
+ "description": "Print machine-readable JSON"
5452
+ }
5453
+ ],
5454
+ "subcommands": []
5455
+ },
5456
+ {
5457
+ "name": "run",
5458
+ "description": "Run one kit service in the foreground (sync|mesh|inbox|heartbeat)",
5459
+ "aliases": [],
5460
+ "hidden": false,
5461
+ "usage": "[options] <service>",
5462
+ "arguments": [
5463
+ {
5464
+ "name": "service",
5465
+ "required": true,
5466
+ "variadic": false
5467
+ }
5468
+ ],
5469
+ "options": [],
5470
+ "subcommands": []
5471
+ }
5472
+ ]
5473
+ },
5474
+ {
5475
+ "name": "probe",
5476
+ "description": "Verify identity, vault sync, work-mesh presence, DMs and secrets; report to the console",
5477
+ "aliases": [],
5478
+ "hidden": false,
5479
+ "usage": "[options]",
5480
+ "arguments": [],
5481
+ "options": [
5482
+ {
5483
+ "flags": "--json",
5484
+ "description": "Print machine-readable JSON"
5485
+ }
5486
+ ],
5487
+ "subcommands": []
5488
+ },
5489
+ {
5490
+ "name": "mcp",
5491
+ "description": "Serve HQ as a stdio MCP server for the bot framework (whoami, search, files, secrets-exec, dm, inbox, work-mesh)",
5492
+ "aliases": [],
5493
+ "hidden": false,
5494
+ "usage": "[options]",
5495
+ "arguments": [],
5496
+ "options": [],
5497
+ "subcommands": []
5498
+ }
5499
+ ]
5500
+ },
5298
5501
  {
5299
5502
  "name": "outposts",
5300
5503
  "description": "Manage your personal HQ Outposts (EC2 boxes)",
@@ -340,6 +340,12 @@ export declare const REGISTRATION_PLAN: readonly [{
340
340
  readonly parent: "program";
341
341
  readonly module: "./commands/agents.js";
342
342
  readonly exportName: "registerAgentsCommand";
343
+ }, {
344
+ readonly type: "registrar";
345
+ readonly root: "agent";
346
+ readonly parent: "program";
347
+ readonly module: "./commands/agent.js";
348
+ readonly exportName: "registerAgentCommand";
343
349
  }, {
344
350
  readonly type: "registrar";
345
351
  readonly root: "outposts";
@@ -59,6 +59,7 @@ export const REGISTRATION_PLAN = [
59
59
  { type: "registrar", root: "crm", parent: "program", module: "./commands/crm.js", exportName: "registerCrmCommand" },
60
60
  { type: "registrar", root: "company", parent: "program", module: "./commands/company.js", exportName: "registerCompanyCommand" },
61
61
  { type: "registrar", root: "agents", parent: "program", module: "./commands/agents.js", exportName: "registerAgentsCommand" },
62
+ { type: "registrar", root: "agent", parent: "program", module: "./commands/agent.js", exportName: "registerAgentCommand" },
62
63
  { type: "registrar", root: "outposts", parent: "program", module: "./commands/outposts.js", exportName: "registerOutpostsCommand" },
63
64
  { type: "registrar", root: "billing", parent: "program", module: "./commands/billing.js", exportName: "registerBillingCommand" },
64
65
  { type: "registrar", root: "core", parent: "program", module: "./commands/core.js", exportName: "registerCoreCommands" },
@@ -0,0 +1,105 @@
1
+ /**
2
+ * `hq agent enroll <code>` — turn this host into an external HQ agent.
3
+ *
4
+ * Flow (api-contract v1, POST /v1/agents/enroll):
5
+ * 1. refuse if this host already carries an identity (human session file or
6
+ * a machine-creds file) unless --replace
7
+ * 2. generate an Ed25519 key pair at ~/.hq-agent/host-key{,.pub} (0600)
8
+ * 3. POST { code, hostPublicKey, hostInfo } — unauthenticated, one-shot
9
+ * 4. write ~/.hq-agent/machine-creds.json (0600) with runtime "external",
10
+ * hostKeyPath, companySlug and apiBaseUrl
11
+ *
12
+ * The code is single-use and expires 15 minutes after an admin creates it,
13
+ * so every failure names the fix. The human session file is only checked
14
+ * for EXISTENCE — its contents are never read (policy
15
+ * never-extract-stored-session-tokens-to-forge-privileged-calls).
16
+ */
17
+ import { Command } from "commander";
18
+ import { generateHostKeyPair } from "../lib/agent-kit/creds.js";
19
+ import { type AgentKitPaths } from "../lib/agent-kit/paths.js";
20
+ export declare const ENROLL_PATH = "/v1/agents/enroll";
21
+ /** Canonical code: un-grouped, uppercase (server hashes exactly this). */
22
+ export declare function normalizeEnrollmentCode(raw: string): string;
23
+ /** 24 chars of Crockford base32 (no I, L, O, U). */
24
+ export declare function isWellFormedEnrollmentCode(code: string): boolean;
25
+ export interface HostInfo {
26
+ os: string;
27
+ arch: string;
28
+ hostname: string;
29
+ cliVersion: string;
30
+ }
31
+ export declare function collectHostInfo(): HostInfo;
32
+ export type ExistingIdentity = {
33
+ kind: "none";
34
+ } | {
35
+ kind: "human";
36
+ file: string;
37
+ } | {
38
+ kind: "machine";
39
+ file: string;
40
+ agentUid?: string;
41
+ };
42
+ /**
43
+ * What identity already lives on this host. Existence checks only: the
44
+ * human token file is never opened.
45
+ */
46
+ export declare function detectExistingIdentity(paths: Pick<AgentKitPaths, "machineCredsPath" | "home">, env?: NodeJS.ProcessEnv): ExistingIdentity;
47
+ export declare function refusalMessage(existing: ExistingIdentity): string | null;
48
+ export declare class EnrollError extends Error {
49
+ readonly status?: number | undefined;
50
+ readonly code?: string | undefined;
51
+ constructor(message: string, status?: number | undefined, code?: string | undefined);
52
+ }
53
+ /** Map a non-2xx enroll response to an actionable message (contract codes). */
54
+ export declare function mapEnrollFailure(status: number, body: {
55
+ code?: unknown;
56
+ error?: unknown;
57
+ message?: unknown;
58
+ attemptsRemaining?: unknown;
59
+ }, headers?: {
60
+ retryAfter?: string | null;
61
+ }): EnrollError;
62
+ export declare function mapEnrollTransportError(err: unknown, apiBaseUrl: string): EnrollError;
63
+ export interface EnrollResponse {
64
+ agentUid: string;
65
+ companyUid: string;
66
+ companySlug: string;
67
+ credentials: {
68
+ username: string;
69
+ secret: string;
70
+ userPoolId?: string;
71
+ clientId: string;
72
+ region: string;
73
+ entityType: "agent";
74
+ entityUid: string;
75
+ runtime: "external";
76
+ };
77
+ hostFingerprint: string;
78
+ }
79
+ export interface EnrollDeps {
80
+ fetch?: typeof fetch;
81
+ paths?: AgentKitPaths;
82
+ env?: NodeJS.ProcessEnv;
83
+ hostInfo?: HostInfo;
84
+ generateKeyPair?: typeof generateHostKeyPair;
85
+ }
86
+ export interface EnrollOptions {
87
+ code: string;
88
+ company?: string;
89
+ replace?: boolean;
90
+ apiBaseUrl?: string;
91
+ }
92
+ export interface EnrollResult {
93
+ agentUid: string;
94
+ companySlug: string;
95
+ companyUid: string;
96
+ hostFingerprint: string;
97
+ credsPath: string;
98
+ hostKeyPath: string;
99
+ /** Set when --company disagreed with the server's company. */
100
+ companyMismatch?: string;
101
+ }
102
+ /** Pure-ish orchestration so tests can drive it without a TTY or network. */
103
+ export declare function enrollHost(opts: EnrollOptions, deps?: EnrollDeps): Promise<EnrollResult>;
104
+ export declare function registerAgentEnrollCommand(agent: Command): void;
105
+ //# sourceMappingURL=agent-enroll.d.ts.map