@indigoai-us/hq-cli 5.60.0 → 5.61.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.
- package/dist/commands/pack-install.d.ts +7 -1
- package/dist/commands/pack-install.js +86 -15
- package/dist/commands/packs.d.ts +2 -1
- package/dist/commands/packs.js +13 -8
- package/dist/commands/secrets.d.ts +5 -0
- package/dist/commands/secrets.js +129 -5
- package/dist/index.d.ts +5 -3
- package/dist/index.js +14 -240
- package/dist/main.d.ts +7 -0
- package/dist/main.js +247 -0
- package/dist/utils/sandbox-runner-client.d.ts +13 -0
- package/dist/utils/sandbox-runner-client.js +82 -5
- package/dist/utils/version-check.d.ts +6 -0
- package/dist/utils/version-check.js +78 -2
- package/package.json +1 -1
- package/src/commands/pack-install.ts +115 -18
- package/src/commands/pack-update-cache.test.ts +149 -0
- package/src/commands/packs.ts +28 -7
- package/src/commands/secrets.test.ts +318 -0
- package/src/commands/secrets.ts +198 -4
- package/src/index.test.ts +32 -0
- package/src/index.ts +11 -274
- package/src/main.ts +283 -0
- package/src/utils/sandbox-runner-client.test.ts +128 -0
- package/src/utils/sandbox-runner-client.ts +99 -3
- package/src/utils/version-check.test.ts +30 -0
- package/src/utils/version-check.ts +72 -0
package/dist/index.js
CHANGED
|
@@ -1,247 +1,21 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
/**
|
|
3
|
-
* HQ CLI - Module management, package management, and cloud sync for HQ
|
|
4
|
-
*/
|
|
5
2
|
// MUST be first: guard the Node version before any dependency that needs a
|
|
6
3
|
// Node 20+ API (e.g. util.styleText) or a newer native ABI is evaluated.
|
|
7
4
|
|
|
8
|
-
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="
|
|
5
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="8fdfd788-4c00-50bc-9ed0-579ed9d5f903")}catch(e){}}();
|
|
9
6
|
import "./node-preflight.js";
|
|
10
|
-
import { Command } from "commander";
|
|
11
|
-
import { initSentry, Sentry } from "./sentry.js";
|
|
12
|
-
import { registerAddCommand } from "./commands/add.js";
|
|
13
|
-
import { registerSyncCommand } from "./commands/sync.js";
|
|
14
|
-
import { registerListCommand } from "./commands/list.js";
|
|
15
|
-
import { registerUpdateCommand } from "./commands/update.js";
|
|
16
|
-
import { registerCloudCommands } from "./commands/cloud.js";
|
|
17
|
-
import { registerSyncModeCommand } from "./commands/sync-mode.js";
|
|
18
|
-
import { registerSyncNarrowCommand } from "./commands/sync-narrow.js";
|
|
19
|
-
import { registerCloudProvisionCommands } from "./commands/cloud-provision.js";
|
|
20
|
-
import { registerCloudDemoteCommands } from "./commands/cloud-demote.js";
|
|
21
|
-
import { registerLoginCommand } from "./commands/login.js";
|
|
22
|
-
import { registerLogoutCommand } from "./commands/logout.js";
|
|
23
|
-
import { registerWhoamiCommand } from "./commands/whoami.js";
|
|
24
|
-
import { registerOnboardCommand } from "./commands/onboard.js";
|
|
25
|
-
import { registerPackageInstallCommand } from "./commands/pkg-install.js";
|
|
26
|
-
import { registerPackageRemoveCommand } from "./commands/pkg-remove.js";
|
|
27
|
-
import { registerPackageUpdateCommand } from "./commands/pkg-update.js";
|
|
28
|
-
import { registerPackageListCommand } from "./commands/pkg-list.js";
|
|
29
|
-
import { registerPacksCommand } from "./commands/packs.js";
|
|
30
|
-
import { registerPublishCommand } from "./commands/publish.js";
|
|
31
|
-
import { registerCreatorsCommand } from "./commands/creators.js";
|
|
32
|
-
import { registerTeamSyncCommand } from "./commands/team-sync.js";
|
|
33
|
-
import { registerAuthCommands } from "./commands/auth.js";
|
|
34
|
-
import { registerApiKeysCommand } from "./commands/api-keys.js";
|
|
35
|
-
import { registerSecretsCommand } from "./commands/secrets.js";
|
|
36
|
-
import { registerRunCommand } from "./commands/run.js";
|
|
37
|
-
import { registerGroupsCommand } from "./commands/groups.js";
|
|
38
|
-
import { registerGroupGrantsCommand } from "./commands/group-grants.js";
|
|
39
|
-
import { registerFilesCommand } from "./commands/files.js";
|
|
40
|
-
import { registerFilesBrowseCommands } from "./commands/files-browse.js";
|
|
41
|
-
import { registerMembersCommand } from "./commands/members.js";
|
|
42
|
-
import { registerPeopleCommand } from "./commands/people.js";
|
|
43
|
-
import { registerDmCommand } from "./commands/dm.js";
|
|
44
|
-
import { registerChannelsCommand } from "./commands/channels.js";
|
|
45
|
-
import { registerFeedbackCommand } from "./commands/feedback.js";
|
|
46
|
-
import { registerMeetingsCommand } from "./commands/meetings.js";
|
|
47
|
-
import { registerSourcesCommand } from "./commands/sources.js";
|
|
48
|
-
import { registerSignalsCommand } from "./commands/signals.js";
|
|
49
|
-
import { registerReindexCommand } from "./commands/reindex.js";
|
|
50
|
-
import { registerRescueCommand } from "./commands/rescue.js";
|
|
51
|
-
import { registerMcpCommand } from "./commands/mcp-status.js";
|
|
52
|
-
import { registerCrmCommand } from "./commands/crm.js";
|
|
53
|
-
import { registerCompanyCommand } from "./commands/company.js";
|
|
54
|
-
import { sanitizeArgv } from "./utils/feedback-diagnostics.js";
|
|
55
|
-
import { environmentalFsErrorMessage } from "./utils/environmental-error.js";
|
|
56
|
-
import { isEpipe } from "./utils/epipe.js";
|
|
57
|
-
import { isInterceptedProcessExit } from "./utils/intercepted-process-exit.js";
|
|
58
|
-
import { maybeWarnNewVersion, refreshVersionCache, } from "./utils/version-check.js";
|
|
59
|
-
import { enforceVersionGate, shouldSkipGate, } from "./utils/version-gate.js";
|
|
60
7
|
import { CLI_VERSION } from "./cli-version.js";
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
process.stderr.on("error", onPipeError);
|
|
74
|
-
initSentry();
|
|
75
|
-
maybeWarnNewVersion();
|
|
76
|
-
const program = new Command();
|
|
77
|
-
program
|
|
78
|
-
.name("hq")
|
|
79
|
-
.description("HQ management CLI — modules, packages, and cloud sync")
|
|
80
|
-
.version(CLI_VERSION);
|
|
81
|
-
// Module management subcommand group
|
|
82
|
-
const modulesCmd = program
|
|
83
|
-
.command("modules")
|
|
84
|
-
.description("Module management commands");
|
|
85
|
-
registerAddCommand(modulesCmd);
|
|
86
|
-
registerSyncCommand(modulesCmd);
|
|
87
|
-
registerListCommand(modulesCmd);
|
|
88
|
-
registerUpdateCommand(modulesCmd);
|
|
89
|
-
// Package management subcommand group
|
|
90
|
-
const packagesCmd = program
|
|
91
|
-
.command("packages")
|
|
92
|
-
.description("Package management commands");
|
|
93
|
-
registerPackageInstallCommand(packagesCmd);
|
|
94
|
-
registerPackageRemoveCommand(packagesCmd);
|
|
95
|
-
registerPackageUpdateCommand(packagesCmd);
|
|
96
|
-
registerPackageListCommand(packagesCmd);
|
|
97
|
-
// Content-pack lifecycle (core/packages/hq-pack-*). Distinct from the registry
|
|
98
|
-
// `packages` system above. Available as both `hq packages packs …` (grouped)
|
|
99
|
-
// and `hq packs …` (top-level convenience).
|
|
100
|
-
registerPacksCommand(packagesCmd);
|
|
101
|
-
registerPacksCommand(program);
|
|
102
|
-
// Top-level shortcuts for package commands
|
|
103
|
-
// "hq install <slug>" = "hq packages install <slug>"
|
|
104
|
-
// "hq remove <slug>" = "hq packages remove <slug>"
|
|
105
|
-
registerPackageInstallCommand(program);
|
|
106
|
-
registerPackageRemoveCommand(program);
|
|
107
|
-
// Marketplace publish (top-level — packer + authenticated upload, US-004)
|
|
108
|
-
// "hq publish <skill-or-worker-path>" packages and submits a pack to the
|
|
109
|
-
// marketplace via POST /v1/listings.
|
|
110
|
-
registerPublishCommand(program);
|
|
111
|
-
// `hq creators apply` — request verified-creator access (required to publish).
|
|
112
|
-
registerCreatorsCommand(program);
|
|
113
|
-
// Cloud sync subcommand group
|
|
114
|
-
const syncCmd = program
|
|
115
|
-
.command("sync")
|
|
116
|
-
.description("Cloud sync commands — sync HQ to S3 for mobile access");
|
|
117
|
-
registerCloudCommands(syncCmd);
|
|
118
|
-
registerSyncModeCommand(syncCmd);
|
|
119
|
-
registerSyncNarrowCommand(syncCmd);
|
|
120
|
-
// Cloud provisioning subcommand group (entity + bucket + initial sync)
|
|
121
|
-
// Distinct from `hq sync` which assumes provisioning has already happened.
|
|
122
|
-
const cloudCmd = program
|
|
123
|
-
.command("cloud")
|
|
124
|
-
.description("Cloud commands — provision entities and manage cloud-backed companies");
|
|
125
|
-
registerCloudProvisionCommands(cloudCmd);
|
|
126
|
-
registerCloudDemoteCommands(cloudCmd);
|
|
127
|
-
// Team commands (top-level)
|
|
128
|
-
registerTeamSyncCommand(program);
|
|
129
|
-
// Auth commands (top-level — Cognito OAuth)
|
|
130
|
-
registerLoginCommand(program);
|
|
131
|
-
registerLogoutCommand(program);
|
|
132
|
-
registerWhoamiCommand(program);
|
|
133
|
-
registerAuthCommands(program);
|
|
134
|
-
// Secrets management (subcommand group — hq secrets set|get|list|delete|exec|generate-link|cache)
|
|
135
|
-
registerSecretsCommand(program);
|
|
136
|
-
// API key management (subcommand group — hq api-keys create|list|revoke)
|
|
137
|
-
registerApiKeysCommand(program);
|
|
138
|
-
// Schema-driven dev runner — hq run [options] -- <cmd>
|
|
139
|
-
registerRunCommand(program);
|
|
140
|
-
// Groups management (subcommand group — hq groups create|delete|add|remove|list|members)
|
|
141
|
-
registerGroupsCommand(program);
|
|
142
|
-
// Cross-company group grants (subcommand group —
|
|
143
|
-
// hq group-grants grant|revoke|outbound|inbound)
|
|
144
|
-
registerGroupGrantsCommand(program);
|
|
145
|
-
// Files ACL management (subcommand group — hq files share|unshare|acl)
|
|
146
|
-
// `registerFilesCommand` returns the `files` group so we can attach the
|
|
147
|
-
// browse-vs-sync subcommands (`hq files browse`/`cat`) onto the same group.
|
|
148
|
-
const filesCmd = registerFilesCommand(program);
|
|
149
|
-
registerFilesBrowseCommands(filesCmd);
|
|
150
|
-
// Membership management (subcommand group — hq members invite|list|revoke)
|
|
151
|
-
registerMembersCommand(program);
|
|
152
|
-
// People directory (subcommand group — hq people list|search|resolve), reading
|
|
153
|
-
// the local companies/<co>/people store scoped to one company.
|
|
154
|
-
registerPeopleCommand(program);
|
|
155
|
-
registerDmCommand(program);
|
|
156
|
-
registerChannelsCommand(program);
|
|
157
|
-
// Onboarding (top-level — Cognito + vault-service provisioning)
|
|
158
|
-
registerOnboardCommand(program);
|
|
159
|
-
// Feedback (subcommand group — hq feedback bug|feature)
|
|
160
|
-
registerFeedbackCommand(program);
|
|
161
|
-
// Meetings (subcommand group — hq meetings list|get|search|transcript|notes)
|
|
162
|
-
registerMeetingsCommand(program);
|
|
163
|
-
// Sources read surface (subcommand group — hq sources list|get|channels|entities)
|
|
164
|
-
registerSourcesCommand(program);
|
|
165
|
-
// Signals read surface (subcommand group — hq signals list|get|types|entities)
|
|
166
|
-
registerSignalsCommand(program);
|
|
167
|
-
// Skill/personal-overlay mirroring + workers-registry regen. Invoked by the
|
|
168
|
-
// hq-core reindex hook shim (Stop / PostToolUse) and by sync()/rescue() after
|
|
169
|
-
// they change on-disk sources. Keeps a `master-sync` alias for one release.
|
|
170
|
-
// Implementation lives in @indigoai-us/hq-cloud.
|
|
171
|
-
registerReindexCommand(program);
|
|
172
|
-
// Drift-preserving HQ-core re-sync (top-level — `hq rescue`). CLI sibling of
|
|
173
|
-
// the HQ Sync app's "Update / Restore" pill; drives the same replace-rescue.sh
|
|
174
|
-
// shipped from @indigoai-us/hq-cloud.
|
|
175
|
-
registerRescueCommand(program);
|
|
176
|
-
// MCP pack observability (subcommand group — `hq mcp status`). Read-only
|
|
177
|
-
// provenance-based status across BOTH Claude + Codex runtimes (reads `_hqPack`
|
|
178
|
-
// off the configs, NOT linkStatus), with secret-redacted output + `--json`.
|
|
179
|
-
registerMcpCommand(program);
|
|
180
|
-
// Native CRM entity upsert (subcommand group — `hq crm entity upsert`). Wraps
|
|
181
|
-
// POST /crm/entities (the ontology write gate) so an authenticated company
|
|
182
|
-
// member can create/update canonical CRM entities in the company vault.
|
|
183
|
-
registerCrmCommand(program);
|
|
184
|
-
// Company settings (subcommand group — `hq company settings set`). Owner-only
|
|
185
|
-
// toggles for crmEnabled / ontologyEnabled via PUT /company-settings.
|
|
186
|
-
registerCompanyCommand(program);
|
|
187
|
-
(async () => {
|
|
188
|
-
try {
|
|
189
|
-
Sentry.addBreadcrumb({
|
|
190
|
-
category: "command",
|
|
191
|
-
message: sanitizeArgv(process.argv.slice(2)).join(" "),
|
|
192
|
-
level: "info",
|
|
193
|
-
});
|
|
194
|
-
// Hard version gate: ask hq-pro whether this CLI is below the floor and
|
|
195
|
-
// auto-update if so (exits the process on update). Skipped for inspection
|
|
196
|
-
// flags (`--version`, `--help`) so users debugging a broken install can
|
|
197
|
-
// still introspect what they have. Silent on any failure — never blocks
|
|
198
|
-
// the CLI on a flaky network or hq-pro hiccup. See `utils/version-gate.ts`.
|
|
199
|
-
if (!shouldSkipGate(process.argv)) {
|
|
200
|
-
await enforceVersionGate();
|
|
201
|
-
}
|
|
202
|
-
await program.parseAsync();
|
|
203
|
-
}
|
|
204
|
-
catch (err) {
|
|
205
|
-
// A broken pipe (EPIPE) means the reader of `hq`'s output closed it early
|
|
206
|
-
// (`hq … | head`, `source <(hq …)`, a parent that exited). That is normal
|
|
207
|
-
// Unix behavior with no user-facing degradation — exit cleanly (0) and
|
|
208
|
-
// skip Sentry capture instead of shipping a fatal (HQ-6B). A synchronous
|
|
209
|
-
// `write EPIPE` thrown out of console.log lands here rather than on the
|
|
210
|
-
// stream 'error' listener above.
|
|
211
|
-
if (isEpipe(err)) {
|
|
212
|
-
process.exitCode = 0;
|
|
213
|
-
}
|
|
214
|
-
else if (isInterceptedProcessExit(err)) {
|
|
215
|
-
// A security/audit FUZZ harness replaced `process.exit` with a throw so it
|
|
216
|
-
// can keep exercising the binary. Commander calling `process.exit` for
|
|
217
|
-
// normal CLI control flow (e.g. an unknown command → exit 1) then surfaces
|
|
218
|
-
// here as that synthetic marker. It is a test-harness artifact, NOT an
|
|
219
|
-
// hq-cli defect — a real user's `process.exit` just exits, so nothing is
|
|
220
|
-
// thrown or captured. Skip Sentry capture (no signal, no user-facing
|
|
221
|
-
// degradation) and preserve the intended non-zero exit (HQ-CLI-3).
|
|
222
|
-
process.exitCode = 1;
|
|
223
|
-
}
|
|
224
|
-
else {
|
|
225
|
-
// A full disk / exhausted quota / read-only filesystem is the user's
|
|
226
|
-
// machine, not an HQ code defect. Surface a clear, actionable message and
|
|
227
|
-
// skip Sentry capture so one full disk doesn't flood the tracker with
|
|
228
|
-
// identical, unfixable crash reports (HQ-CLI-2). Genuine errors still go
|
|
229
|
-
// to Sentry and still exit 1.
|
|
230
|
-
const envMsg = environmentalFsErrorMessage(err);
|
|
231
|
-
if (envMsg) {
|
|
232
|
-
process.stderr.write(`hq: ${envMsg}\n`);
|
|
233
|
-
}
|
|
234
|
-
else {
|
|
235
|
-
Sentry.captureException(err);
|
|
236
|
-
}
|
|
237
|
-
process.exitCode = 1;
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
finally {
|
|
241
|
-
// Release health: finalize the per-run session before the flush.
|
|
242
|
-
Sentry.endSession();
|
|
243
|
-
await Promise.allSettled([refreshVersionCache(), Sentry.flush(2000)]);
|
|
244
|
-
}
|
|
245
|
-
})();
|
|
8
|
+
function isVersionRequest(argv) {
|
|
9
|
+
const args = argv.slice(2);
|
|
10
|
+
return args.length === 1 && (args[0] === "--version" || args[0] === "-V" || args[0] === "-v");
|
|
11
|
+
}
|
|
12
|
+
if (isVersionRequest(process.argv)) {
|
|
13
|
+
process.stdout.write(`${CLI_VERSION}\n`);
|
|
14
|
+
}
|
|
15
|
+
else {
|
|
16
|
+
const { runCli } = await import("./main.js");
|
|
17
|
+
await runCli();
|
|
18
|
+
}
|
|
19
|
+
export const __test__ = { isVersionRequest };
|
|
246
20
|
//# sourceMappingURL=index.js.map
|
|
247
|
-
//# debugId=
|
|
21
|
+
//# debugId=8fdfd788-4c00-50bc-9ed0-579ed9d5f903
|
package/dist/main.d.ts
ADDED
package/dist/main.js
ADDED
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* HQ CLI - Module management, package management, and cloud sync for HQ
|
|
4
|
+
*/
|
|
5
|
+
// MUST be first: guard the Node version before any dependency that needs a
|
|
6
|
+
// Node 20+ API (e.g. util.styleText) or a newer native ABI is evaluated.
|
|
7
|
+
|
|
8
|
+
!function(){try{var e="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:{},n=(new e.Error).stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="a2c1badb-d418-557d-a0f4-0e3defd13913")}catch(e){}}();
|
|
9
|
+
import "./node-preflight.js";
|
|
10
|
+
import { Command } from "commander";
|
|
11
|
+
import { initSentry, Sentry } from "./sentry.js";
|
|
12
|
+
import { registerAddCommand } from "./commands/add.js";
|
|
13
|
+
import { registerSyncCommand } from "./commands/sync.js";
|
|
14
|
+
import { registerListCommand } from "./commands/list.js";
|
|
15
|
+
import { registerUpdateCommand } from "./commands/update.js";
|
|
16
|
+
import { registerCloudCommands } from "./commands/cloud.js";
|
|
17
|
+
import { registerSyncModeCommand } from "./commands/sync-mode.js";
|
|
18
|
+
import { registerSyncNarrowCommand } from "./commands/sync-narrow.js";
|
|
19
|
+
import { registerCloudProvisionCommands } from "./commands/cloud-provision.js";
|
|
20
|
+
import { registerCloudDemoteCommands } from "./commands/cloud-demote.js";
|
|
21
|
+
import { registerLoginCommand } from "./commands/login.js";
|
|
22
|
+
import { registerLogoutCommand } from "./commands/logout.js";
|
|
23
|
+
import { registerWhoamiCommand } from "./commands/whoami.js";
|
|
24
|
+
import { registerOnboardCommand } from "./commands/onboard.js";
|
|
25
|
+
import { registerPackageInstallCommand } from "./commands/pkg-install.js";
|
|
26
|
+
import { registerPackageRemoveCommand } from "./commands/pkg-remove.js";
|
|
27
|
+
import { registerPackageUpdateCommand } from "./commands/pkg-update.js";
|
|
28
|
+
import { registerPackageListCommand } from "./commands/pkg-list.js";
|
|
29
|
+
import { registerPacksCommand } from "./commands/packs.js";
|
|
30
|
+
import { registerPublishCommand } from "./commands/publish.js";
|
|
31
|
+
import { registerCreatorsCommand } from "./commands/creators.js";
|
|
32
|
+
import { registerTeamSyncCommand } from "./commands/team-sync.js";
|
|
33
|
+
import { registerAuthCommands } from "./commands/auth.js";
|
|
34
|
+
import { registerApiKeysCommand } from "./commands/api-keys.js";
|
|
35
|
+
import { registerSecretsCommand } from "./commands/secrets.js";
|
|
36
|
+
import { registerRunCommand } from "./commands/run.js";
|
|
37
|
+
import { registerGroupsCommand } from "./commands/groups.js";
|
|
38
|
+
import { registerGroupGrantsCommand } from "./commands/group-grants.js";
|
|
39
|
+
import { registerFilesCommand } from "./commands/files.js";
|
|
40
|
+
import { registerFilesBrowseCommands } from "./commands/files-browse.js";
|
|
41
|
+
import { registerMembersCommand } from "./commands/members.js";
|
|
42
|
+
import { registerPeopleCommand } from "./commands/people.js";
|
|
43
|
+
import { registerDmCommand } from "./commands/dm.js";
|
|
44
|
+
import { registerChannelsCommand } from "./commands/channels.js";
|
|
45
|
+
import { registerFeedbackCommand } from "./commands/feedback.js";
|
|
46
|
+
import { registerMeetingsCommand } from "./commands/meetings.js";
|
|
47
|
+
import { registerSourcesCommand } from "./commands/sources.js";
|
|
48
|
+
import { registerSignalsCommand } from "./commands/signals.js";
|
|
49
|
+
import { registerReindexCommand } from "./commands/reindex.js";
|
|
50
|
+
import { registerRescueCommand } from "./commands/rescue.js";
|
|
51
|
+
import { registerMcpCommand } from "./commands/mcp-status.js";
|
|
52
|
+
import { registerCrmCommand } from "./commands/crm.js";
|
|
53
|
+
import { registerCompanyCommand } from "./commands/company.js";
|
|
54
|
+
import { sanitizeArgv } from "./utils/feedback-diagnostics.js";
|
|
55
|
+
import { environmentalFsErrorMessage } from "./utils/environmental-error.js";
|
|
56
|
+
import { isEpipe } from "./utils/epipe.js";
|
|
57
|
+
import { isInterceptedProcessExit } from "./utils/intercepted-process-exit.js";
|
|
58
|
+
import { maybeWarnNewVersion, refreshVersionCache, } from "./utils/version-check.js";
|
|
59
|
+
import { enforceVersionGate, shouldSkipGate, } from "./utils/version-gate.js";
|
|
60
|
+
import { CLI_VERSION } from "./cli-version.js";
|
|
61
|
+
// Swallow EPIPE when a downstream reader (e.g. `source <(…)`, `| head`) closes
|
|
62
|
+
// the pipe early. This covers the ASYNC path — an 'error' event emitted on the
|
|
63
|
+
// stream. The SYNCHRONOUS path (a `write EPIPE` thrown straight out of
|
|
64
|
+
// console.log inside a command) is handled in the top-level catch below; both
|
|
65
|
+
// share `isEpipe` (HQ-6B).
|
|
66
|
+
const onPipeError = (err) => {
|
|
67
|
+
if (isEpipe(err)) {
|
|
68
|
+
process.exit(0);
|
|
69
|
+
}
|
|
70
|
+
throw err;
|
|
71
|
+
};
|
|
72
|
+
process.stdout.on("error", onPipeError);
|
|
73
|
+
process.stderr.on("error", onPipeError);
|
|
74
|
+
initSentry();
|
|
75
|
+
maybeWarnNewVersion();
|
|
76
|
+
const program = new Command();
|
|
77
|
+
program
|
|
78
|
+
.name("hq")
|
|
79
|
+
.description("HQ management CLI — modules, packages, and cloud sync")
|
|
80
|
+
.version(CLI_VERSION);
|
|
81
|
+
// Module management subcommand group
|
|
82
|
+
const modulesCmd = program
|
|
83
|
+
.command("modules")
|
|
84
|
+
.description("Module management commands");
|
|
85
|
+
registerAddCommand(modulesCmd);
|
|
86
|
+
registerSyncCommand(modulesCmd);
|
|
87
|
+
registerListCommand(modulesCmd);
|
|
88
|
+
registerUpdateCommand(modulesCmd);
|
|
89
|
+
// Package management subcommand group
|
|
90
|
+
const packagesCmd = program
|
|
91
|
+
.command("packages")
|
|
92
|
+
.description("Package management commands");
|
|
93
|
+
registerPackageInstallCommand(packagesCmd);
|
|
94
|
+
registerPackageRemoveCommand(packagesCmd);
|
|
95
|
+
registerPackageUpdateCommand(packagesCmd);
|
|
96
|
+
registerPackageListCommand(packagesCmd);
|
|
97
|
+
// Content-pack lifecycle (core/packages/hq-pack-*). Distinct from the registry
|
|
98
|
+
// `packages` system above. Available as both `hq packages packs …` (grouped)
|
|
99
|
+
// and `hq packs …` (top-level convenience).
|
|
100
|
+
registerPacksCommand(packagesCmd);
|
|
101
|
+
registerPacksCommand(program);
|
|
102
|
+
// Top-level shortcuts for package commands
|
|
103
|
+
// "hq install <slug>" = "hq packages install <slug>"
|
|
104
|
+
// "hq remove <slug>" = "hq packages remove <slug>"
|
|
105
|
+
registerPackageInstallCommand(program);
|
|
106
|
+
registerPackageRemoveCommand(program);
|
|
107
|
+
// Marketplace publish (top-level — packer + authenticated upload, US-004)
|
|
108
|
+
// "hq publish <skill-or-worker-path>" packages and submits a pack to the
|
|
109
|
+
// marketplace via POST /v1/listings.
|
|
110
|
+
registerPublishCommand(program);
|
|
111
|
+
// `hq creators apply` — request verified-creator access (required to publish).
|
|
112
|
+
registerCreatorsCommand(program);
|
|
113
|
+
// Cloud sync subcommand group
|
|
114
|
+
const syncCmd = program
|
|
115
|
+
.command("sync")
|
|
116
|
+
.description("Cloud sync commands — sync HQ to S3 for mobile access");
|
|
117
|
+
registerCloudCommands(syncCmd);
|
|
118
|
+
registerSyncModeCommand(syncCmd);
|
|
119
|
+
registerSyncNarrowCommand(syncCmd);
|
|
120
|
+
// Cloud provisioning subcommand group (entity + bucket + initial sync)
|
|
121
|
+
// Distinct from `hq sync` which assumes provisioning has already happened.
|
|
122
|
+
const cloudCmd = program
|
|
123
|
+
.command("cloud")
|
|
124
|
+
.description("Cloud commands — provision entities and manage cloud-backed companies");
|
|
125
|
+
registerCloudProvisionCommands(cloudCmd);
|
|
126
|
+
registerCloudDemoteCommands(cloudCmd);
|
|
127
|
+
// Team commands (top-level)
|
|
128
|
+
registerTeamSyncCommand(program);
|
|
129
|
+
// Auth commands (top-level — Cognito OAuth)
|
|
130
|
+
registerLoginCommand(program);
|
|
131
|
+
registerLogoutCommand(program);
|
|
132
|
+
registerWhoamiCommand(program);
|
|
133
|
+
registerAuthCommands(program);
|
|
134
|
+
// Secrets management (subcommand group — hq secrets set|get|list|delete|exec|generate-link|cache)
|
|
135
|
+
registerSecretsCommand(program);
|
|
136
|
+
// API key management (subcommand group — hq api-keys create|list|revoke)
|
|
137
|
+
registerApiKeysCommand(program);
|
|
138
|
+
// Schema-driven dev runner — hq run [options] -- <cmd>
|
|
139
|
+
registerRunCommand(program);
|
|
140
|
+
// Groups management (subcommand group — hq groups create|delete|add|remove|list|members)
|
|
141
|
+
registerGroupsCommand(program);
|
|
142
|
+
// Cross-company group grants (subcommand group —
|
|
143
|
+
// hq group-grants grant|revoke|outbound|inbound)
|
|
144
|
+
registerGroupGrantsCommand(program);
|
|
145
|
+
// Files ACL management (subcommand group — hq files share|unshare|acl)
|
|
146
|
+
// `registerFilesCommand` returns the `files` group so we can attach the
|
|
147
|
+
// browse-vs-sync subcommands (`hq files browse`/`cat`) onto the same group.
|
|
148
|
+
const filesCmd = registerFilesCommand(program);
|
|
149
|
+
registerFilesBrowseCommands(filesCmd);
|
|
150
|
+
// Membership management (subcommand group — hq members invite|list|revoke)
|
|
151
|
+
registerMembersCommand(program);
|
|
152
|
+
// People directory (subcommand group — hq people list|search|resolve), reading
|
|
153
|
+
// the local companies/<co>/people store scoped to one company.
|
|
154
|
+
registerPeopleCommand(program);
|
|
155
|
+
registerDmCommand(program);
|
|
156
|
+
registerChannelsCommand(program);
|
|
157
|
+
// Onboarding (top-level — Cognito + vault-service provisioning)
|
|
158
|
+
registerOnboardCommand(program);
|
|
159
|
+
// Feedback (subcommand group — hq feedback bug|feature)
|
|
160
|
+
registerFeedbackCommand(program);
|
|
161
|
+
// Meetings (subcommand group — hq meetings list|get|search|transcript|notes)
|
|
162
|
+
registerMeetingsCommand(program);
|
|
163
|
+
// Sources read surface (subcommand group — hq sources list|get|channels|entities)
|
|
164
|
+
registerSourcesCommand(program);
|
|
165
|
+
// Signals read surface (subcommand group — hq signals list|get|types|entities)
|
|
166
|
+
registerSignalsCommand(program);
|
|
167
|
+
// Skill/personal-overlay mirroring + workers-registry regen. Invoked by the
|
|
168
|
+
// hq-core reindex hook shim (Stop / PostToolUse) and by sync()/rescue() after
|
|
169
|
+
// they change on-disk sources. Keeps a `master-sync` alias for one release.
|
|
170
|
+
// Implementation lives in @indigoai-us/hq-cloud.
|
|
171
|
+
registerReindexCommand(program);
|
|
172
|
+
// Drift-preserving HQ-core re-sync (top-level — `hq rescue`). CLI sibling of
|
|
173
|
+
// the HQ Sync app's "Update / Restore" pill; drives the same replace-rescue.sh
|
|
174
|
+
// shipped from @indigoai-us/hq-cloud.
|
|
175
|
+
registerRescueCommand(program);
|
|
176
|
+
// MCP pack observability (subcommand group — `hq mcp status`). Read-only
|
|
177
|
+
// provenance-based status across BOTH Claude + Codex runtimes (reads `_hqPack`
|
|
178
|
+
// off the configs, NOT linkStatus), with secret-redacted output + `--json`.
|
|
179
|
+
registerMcpCommand(program);
|
|
180
|
+
// Native CRM entity upsert (subcommand group — `hq crm entity upsert`). Wraps
|
|
181
|
+
// POST /crm/entities (the ontology write gate) so an authenticated company
|
|
182
|
+
// member can create/update canonical CRM entities in the company vault.
|
|
183
|
+
registerCrmCommand(program);
|
|
184
|
+
// Company settings (subcommand group — `hq company settings set`). Owner-only
|
|
185
|
+
// toggles for crmEnabled / ontologyEnabled via PUT /company-settings.
|
|
186
|
+
registerCompanyCommand(program);
|
|
187
|
+
export async function runCli() {
|
|
188
|
+
try {
|
|
189
|
+
Sentry.addBreadcrumb({
|
|
190
|
+
category: "command",
|
|
191
|
+
message: sanitizeArgv(process.argv.slice(2)).join(" "),
|
|
192
|
+
level: "info",
|
|
193
|
+
});
|
|
194
|
+
// Hard version gate: ask hq-pro whether this CLI is below the floor and
|
|
195
|
+
// auto-update if so (exits the process on update). Skipped for inspection
|
|
196
|
+
// flags (`--version`, `--help`) so users debugging a broken install can
|
|
197
|
+
// still introspect what they have. Silent on any failure — never blocks
|
|
198
|
+
// the CLI on a flaky network or hq-pro hiccup. See `utils/version-gate.ts`.
|
|
199
|
+
if (!shouldSkipGate(process.argv)) {
|
|
200
|
+
await enforceVersionGate();
|
|
201
|
+
}
|
|
202
|
+
await program.parseAsync();
|
|
203
|
+
}
|
|
204
|
+
catch (err) {
|
|
205
|
+
// A broken pipe (EPIPE) means the reader of `hq`'s output closed it early
|
|
206
|
+
// (`hq … | head`, `source <(hq …)`, a parent that exited). That is normal
|
|
207
|
+
// Unix behavior with no user-facing degradation — exit cleanly (0) and
|
|
208
|
+
// skip Sentry capture instead of shipping a fatal (HQ-6B). A synchronous
|
|
209
|
+
// `write EPIPE` thrown out of console.log lands here rather than on the
|
|
210
|
+
// stream 'error' listener above.
|
|
211
|
+
if (isEpipe(err)) {
|
|
212
|
+
process.exitCode = 0;
|
|
213
|
+
}
|
|
214
|
+
else if (isInterceptedProcessExit(err)) {
|
|
215
|
+
// A security/audit FUZZ harness replaced `process.exit` with a throw so it
|
|
216
|
+
// can keep exercising the binary. Commander calling `process.exit` for
|
|
217
|
+
// normal CLI control flow (e.g. an unknown command → exit 1) then surfaces
|
|
218
|
+
// here as that synthetic marker. It is a test-harness artifact, NOT an
|
|
219
|
+
// hq-cli defect — a real user's `process.exit` just exits, so nothing is
|
|
220
|
+
// thrown or captured. Skip Sentry capture (no signal, no user-facing
|
|
221
|
+
// degradation) and preserve the intended non-zero exit (HQ-CLI-3).
|
|
222
|
+
process.exitCode = 1;
|
|
223
|
+
}
|
|
224
|
+
else {
|
|
225
|
+
// A full disk / exhausted quota / read-only filesystem is the user's
|
|
226
|
+
// machine, not an HQ code defect. Surface a clear, actionable message and
|
|
227
|
+
// skip Sentry capture so one full disk doesn't flood the tracker with
|
|
228
|
+
// identical, unfixable crash reports (HQ-CLI-2). Genuine errors still go
|
|
229
|
+
// to Sentry and still exit 1.
|
|
230
|
+
const envMsg = environmentalFsErrorMessage(err);
|
|
231
|
+
if (envMsg) {
|
|
232
|
+
process.stderr.write(`hq: ${envMsg}\n`);
|
|
233
|
+
}
|
|
234
|
+
else {
|
|
235
|
+
Sentry.captureException(err);
|
|
236
|
+
}
|
|
237
|
+
process.exitCode = 1;
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
finally {
|
|
241
|
+
// Release health: finalize the per-run session before the flush.
|
|
242
|
+
Sentry.endSession();
|
|
243
|
+
await Promise.allSettled([refreshVersionCache(), Sentry.flush(2000)]);
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
//# sourceMappingURL=main.js.map
|
|
247
|
+
//# debugId=a2c1badb-d418-557d-a0f4-0e3defd13913
|
|
@@ -18,15 +18,28 @@ export interface SandboxRunnerJob {
|
|
|
18
18
|
export interface SandboxRunnerClientOptions {
|
|
19
19
|
baseUrl?: string;
|
|
20
20
|
fetchImpl?: typeof fetch;
|
|
21
|
+
retry?: SandboxRunnerRetryOptions;
|
|
22
|
+
sleep?: (ms: number) => Promise<void>;
|
|
21
23
|
}
|
|
22
24
|
export interface SandboxRunnerPollOptions {
|
|
23
25
|
intervalMs?: number;
|
|
24
26
|
maxPolls?: number;
|
|
25
27
|
}
|
|
28
|
+
export interface SandboxRunnerRetryOptions {
|
|
29
|
+
maxAttempts?: number;
|
|
30
|
+
maxElapsedMs?: number;
|
|
31
|
+
baseDelayMs?: number;
|
|
32
|
+
maxDelayMs?: number;
|
|
33
|
+
}
|
|
26
34
|
export declare class SandboxRunnerClient {
|
|
27
35
|
private readonly baseUrl;
|
|
28
36
|
private readonly fetchImpl;
|
|
37
|
+
private readonly retry;
|
|
38
|
+
private readonly sleep;
|
|
29
39
|
constructor(options?: SandboxRunnerClientOptions);
|
|
40
|
+
private fetchWithRetry;
|
|
41
|
+
private shouldRetry;
|
|
42
|
+
private nextDelayMs;
|
|
30
43
|
startJob(token: string, request: SandboxRunnerStartRequest): Promise<SandboxRunnerStartResponse>;
|
|
31
44
|
getJob(token: string, jobId: string): Promise<SandboxRunnerJob>;
|
|
32
45
|
pollJob(token: string, jobId: string, options?: SandboxRunnerPollOptions): Promise<SandboxRunnerJob>;
|