@indigoai-us/hq-cli 5.60.0 → 5.62.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/agents.d.ts +109 -0
- package/dist/commands/agents.js +385 -0
- package/dist/commands/db-migrate.d.ts +6 -0
- package/dist/commands/db-migrate.js +42 -0
- package/dist/commands/db-provision.d.ts +15 -0
- package/dist/commands/db-provision.js +78 -0
- package/dist/commands/db-sql.d.ts +9 -0
- package/dist/commands/db-sql.js +81 -0
- package/dist/commands/db-status.d.ts +7 -0
- package/dist/commands/db-status.js +70 -0
- package/dist/commands/db.d.ts +9 -0
- package/dist/commands/db.js +23 -0
- package/dist/commands/integrations.d.ts +78 -0
- package/dist/commands/integrations.js +309 -0
- package/dist/commands/members.js +4 -4
- package/dist/commands/outposts.d.ts +60 -0
- package/dist/commands/outposts.js +255 -0
- 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 +13 -0
- package/dist/commands/secrets.js +149 -10
- package/dist/commands/skill.d.ts +153 -0
- package/dist/commands/skill.js +593 -0
- package/dist/commands/workers.d.ts +48 -0
- package/dist/commands/workers.js +229 -0
- package/dist/index.d.ts +5 -3
- package/dist/index.js +14 -240
- package/dist/lib/db/control-plane.d.ts +45 -0
- package/dist/lib/db/control-plane.js +81 -0
- package/dist/lib/db/local.d.ts +49 -0
- package/dist/lib/db/local.js +106 -0
- package/dist/lib/db/migrate.d.ts +41 -0
- package/dist/lib/db/migrate.js +104 -0
- package/dist/lib/db/paths.d.ts +56 -0
- package/dist/lib/db/paths.js +103 -0
- package/dist/lib/db/remote-engine.d.ts +58 -0
- package/dist/lib/db/remote-engine.js +90 -0
- package/dist/lib/db/remote-sql.d.ts +22 -0
- package/dist/lib/db/remote-sql.js +39 -0
- package/dist/lib/db/sql.d.ts +49 -0
- package/dist/lib/db/sql.js +132 -0
- package/dist/main.d.ts +7 -0
- package/dist/main.js +272 -0
- package/dist/utils/cognito-session.js +3 -3
- package/dist/utils/sandbox-runner-client.d.ts +13 -0
- package/dist/utils/sandbox-runner-client.js +83 -6
- package/dist/utils/version-check.d.ts +6 -0
- package/dist/utils/version-check.js +78 -2
- package/package.json +9 -1
- package/pnpm-workspace.yaml +2 -0
- package/src/commands/agents.test.ts +297 -0
- package/src/commands/agents.ts +561 -0
- package/src/commands/db-migrate.ts +55 -0
- package/src/commands/db-provision.ts +102 -0
- package/src/commands/db-sql.ts +124 -0
- package/src/commands/db-status.ts +100 -0
- package/src/commands/db.ts +26 -0
- package/src/commands/integrations.test.ts +284 -0
- package/src/commands/integrations.ts +438 -0
- package/src/commands/members.ts +2 -2
- package/src/commands/outposts.test.ts +177 -0
- package/src/commands/outposts.ts +338 -0
- 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.parse-destination.test.ts +38 -0
- package/src/commands/secrets.test.ts +342 -0
- package/src/commands/secrets.ts +227 -13
- package/src/commands/skill.test.ts +770 -0
- package/src/commands/skill.ts +796 -0
- package/src/commands/workers.test.ts +158 -0
- package/src/commands/workers.ts +298 -0
- package/src/index.test.ts +32 -0
- package/src/index.ts +11 -274
- package/src/lib/db/control-plane.test.ts +59 -0
- package/src/lib/db/control-plane.ts +113 -0
- package/src/lib/db/local.test.ts +81 -0
- package/src/lib/db/local.ts +148 -0
- package/src/lib/db/migrate.test.ts +133 -0
- package/src/lib/db/migrate.ts +137 -0
- package/src/lib/db/paths.test.ts +112 -0
- package/src/lib/db/paths.ts +128 -0
- package/src/lib/db/remote-engine.test.ts +44 -0
- package/src/lib/db/remote-engine.ts +148 -0
- package/src/lib/db/remote-sql.test.ts +32 -0
- package/src/lib/db/remote-sql.ts +62 -0
- package/src/lib/db/sql.test.ts +106 -0
- package/src/lib/db/sql.ts +192 -0
- package/src/main.ts +314 -0
- package/src/utils/cognito-session.ts +1 -1
- package/src/utils/sandbox-runner-client.test.ts +128 -0
- package/src/utils/sandbox-runner-client.ts +100 -4
- package/src/utils/version-check.test.ts +30 -0
- package/src/utils/version-check.ts +72 -0
- package/test/commands/db-tenant-isolation.test.ts +94 -0
- package/test/commands/db.test.ts +85 -0
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local SQL execution helpers (vault-databases US-004).
|
|
3
|
+
*
|
|
4
|
+
* Company scope is path-bound via resolveLocalDbPath — callers must pass the
|
|
5
|
+
* resolved company slug from HQ session/flags. Path overrides that open
|
|
6
|
+
* another company's DB are denied unless an explicit dangerous flag is set.
|
|
7
|
+
*/
|
|
8
|
+
import { type LocalDbPathEnv } from "./paths.js";
|
|
9
|
+
export interface SqlRunOptions extends LocalDbPathEnv {
|
|
10
|
+
company: string;
|
|
11
|
+
sql: string;
|
|
12
|
+
/** Allow INSERT/UPDATE/DELETE/DDL. Default false (read-only). */
|
|
13
|
+
write?: boolean;
|
|
14
|
+
/**
|
|
15
|
+
* Dangerous: open an absolute DB path instead of the company canonical path.
|
|
16
|
+
* Denied unless allowCrossCompanyPath is true.
|
|
17
|
+
*/
|
|
18
|
+
dbPathOverride?: string;
|
|
19
|
+
/** Explicit dangerous flag to open a non-canonical local DB path. Default false. */
|
|
20
|
+
allowCrossCompanyPath?: boolean;
|
|
21
|
+
/** Output format */
|
|
22
|
+
format?: "jsonl" | "table";
|
|
23
|
+
}
|
|
24
|
+
export interface SqlRunResult {
|
|
25
|
+
columns: string[];
|
|
26
|
+
rows: Record<string, unknown>[];
|
|
27
|
+
changes: number;
|
|
28
|
+
readonly: boolean;
|
|
29
|
+
}
|
|
30
|
+
export declare function stripSqlNoise(sql: string): string;
|
|
31
|
+
export declare function isWriteSql(sql: string): boolean;
|
|
32
|
+
/**
|
|
33
|
+
* Statements that must never run via `hq db sql`, even with --write.
|
|
34
|
+
* ATTACH/DETACH would let a company-scoped session open another company's
|
|
35
|
+
* vault.db by absolute path (category-1 isolation).
|
|
36
|
+
*/
|
|
37
|
+
export declare function assertSqlAllowed(sql: string): void;
|
|
38
|
+
/**
|
|
39
|
+
* Resolve which file path to open, enforcing company isolation by default.
|
|
40
|
+
*/
|
|
41
|
+
export declare function resolveSqlDbPath(opts: SqlRunOptions): string;
|
|
42
|
+
/**
|
|
43
|
+
* Execute SQL against the company local vault DB.
|
|
44
|
+
*/
|
|
45
|
+
export declare function runLocalSql(opts: SqlRunOptions): SqlRunResult;
|
|
46
|
+
export declare function formatSqlResult(result: SqlRunResult, format?: "jsonl" | "table"): string;
|
|
47
|
+
/** Test helper: company dir for isolation assertions. */
|
|
48
|
+
export declare function companyLocalDbDir(company: string, env?: LocalDbPathEnv): string;
|
|
49
|
+
//# sourceMappingURL=sql.d.ts.map
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Local SQL execution helpers (vault-databases US-004).
|
|
3
|
+
*
|
|
4
|
+
* Company scope is path-bound via resolveLocalDbPath — callers must pass the
|
|
5
|
+
* resolved company slug from HQ session/flags. Path overrides that open
|
|
6
|
+
* another company's DB are denied unless an explicit dangerous flag is set.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
!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]="f9dc08da-ad30-5af4-94fb-b167d4299692")}catch(e){}}();
|
|
10
|
+
import Database from "better-sqlite3";
|
|
11
|
+
import { openLocalDb } from "./local.js";
|
|
12
|
+
import { normalizeCompanySlugForLocalDb, resolveLocalDbDir, resolveLocalDbPath, } from "./paths.js";
|
|
13
|
+
const WRITE_PATTERN = /^\s*(INSERT|UPDATE|DELETE|REPLACE|CREATE|DROP|ALTER|TRUNCATE|REINDEX|VACUUM|BEGIN|COMMIT|ROLLBACK)\b/i;
|
|
14
|
+
/** Always forbidden — opens other files/DBs and breaks company path isolation. */
|
|
15
|
+
const FORBIDDEN_SQL_PATTERN = /\b(ATTACH|DETACH|LOAD_EXTENSION)\b/i;
|
|
16
|
+
export function stripSqlNoise(sql) {
|
|
17
|
+
return sql
|
|
18
|
+
.replace(/^\s*--[^\n]*\n/gm, "")
|
|
19
|
+
.replace(/^\s*\/\*[\s\S]*?\*\//gm, "")
|
|
20
|
+
.trim();
|
|
21
|
+
}
|
|
22
|
+
export function isWriteSql(sql) {
|
|
23
|
+
return WRITE_PATTERN.test(stripSqlNoise(sql));
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Statements that must never run via `hq db sql`, even with --write.
|
|
27
|
+
* ATTACH/DETACH would let a company-scoped session open another company's
|
|
28
|
+
* vault.db by absolute path (category-1 isolation).
|
|
29
|
+
*/
|
|
30
|
+
export function assertSqlAllowed(sql) {
|
|
31
|
+
const stripped = stripSqlNoise(sql);
|
|
32
|
+
if (FORBIDDEN_SQL_PATTERN.test(stripped)) {
|
|
33
|
+
throw new Error("ATTACH/DETACH/LOAD_EXTENSION are not allowed via hq db sql (tenant isolation); use the company-canonical local path only");
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Resolve which file path to open, enforcing company isolation by default.
|
|
38
|
+
*/
|
|
39
|
+
export function resolveSqlDbPath(opts) {
|
|
40
|
+
const company = normalizeCompanySlugForLocalDb(opts.company);
|
|
41
|
+
const canonical = resolveLocalDbPath(company, opts);
|
|
42
|
+
if (!opts.dbPathOverride) {
|
|
43
|
+
return canonical;
|
|
44
|
+
}
|
|
45
|
+
if (opts.dbPathOverride === canonical) {
|
|
46
|
+
return canonical;
|
|
47
|
+
}
|
|
48
|
+
if (!opts.allowCrossCompanyPath) {
|
|
49
|
+
throw new Error("cross-company or path override denied: refusing to open a non-canonical local DB path without --allow-cross-company-path (dangerous)");
|
|
50
|
+
}
|
|
51
|
+
return opts.dbPathOverride;
|
|
52
|
+
}
|
|
53
|
+
function openByPath(dbPath) {
|
|
54
|
+
const db = new Database(dbPath);
|
|
55
|
+
db.pragma("journal_mode = WAL");
|
|
56
|
+
db.pragma("foreign_keys = ON");
|
|
57
|
+
return db;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Execute SQL against the company local vault DB.
|
|
61
|
+
*/
|
|
62
|
+
export function runLocalSql(opts) {
|
|
63
|
+
const sql = opts.sql?.trim();
|
|
64
|
+
if (!sql) {
|
|
65
|
+
throw new Error("SQL statement is required");
|
|
66
|
+
}
|
|
67
|
+
assertSqlAllowed(sql);
|
|
68
|
+
const writeRequested = !!opts.write;
|
|
69
|
+
if (isWriteSql(sql) && !writeRequested) {
|
|
70
|
+
throw new Error("write/DDL statement blocked in read-only mode; pass --write to allow (prefer hq db migrate for schema changes)");
|
|
71
|
+
}
|
|
72
|
+
const dbPath = resolveSqlDbPath(opts);
|
|
73
|
+
const usingCanonical = !opts.dbPathOverride || opts.dbPathOverride === resolveLocalDbPath(opts.company, opts);
|
|
74
|
+
const db = usingCanonical
|
|
75
|
+
? openLocalDb(opts.company, opts)
|
|
76
|
+
: openByPath(dbPath);
|
|
77
|
+
try {
|
|
78
|
+
if (!writeRequested) {
|
|
79
|
+
db.pragma("query_only = ON");
|
|
80
|
+
}
|
|
81
|
+
const stmt = db.prepare(sql);
|
|
82
|
+
if (stmt.reader) {
|
|
83
|
+
const rows = stmt.all();
|
|
84
|
+
const columns = rows.length > 0
|
|
85
|
+
? Object.keys(rows[0])
|
|
86
|
+
: stmt.columns().map((c) => c.name);
|
|
87
|
+
return {
|
|
88
|
+
columns,
|
|
89
|
+
rows,
|
|
90
|
+
changes: 0,
|
|
91
|
+
readonly: !writeRequested,
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
const info = stmt.run();
|
|
95
|
+
return {
|
|
96
|
+
columns: ["changes", "lastInsertRowid"],
|
|
97
|
+
rows: [
|
|
98
|
+
{
|
|
99
|
+
changes: info.changes,
|
|
100
|
+
lastInsertRowid: Number(info.lastInsertRowid),
|
|
101
|
+
},
|
|
102
|
+
],
|
|
103
|
+
changes: info.changes,
|
|
104
|
+
readonly: !writeRequested,
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
finally {
|
|
108
|
+
db.close();
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
export function formatSqlResult(result, format = "jsonl") {
|
|
112
|
+
if (format === "jsonl") {
|
|
113
|
+
if (result.rows.length === 0) {
|
|
114
|
+
return JSON.stringify({ columns: result.columns, rows: 0 });
|
|
115
|
+
}
|
|
116
|
+
return result.rows.map((r) => JSON.stringify(r)).join("\n");
|
|
117
|
+
}
|
|
118
|
+
const cols = result.columns;
|
|
119
|
+
if (cols.length === 0)
|
|
120
|
+
return "(no columns)";
|
|
121
|
+
const header = cols.join("\t");
|
|
122
|
+
const body = result.rows
|
|
123
|
+
.map((r) => cols.map((c) => String(r[c] ?? "")).join("\t"))
|
|
124
|
+
.join("\n");
|
|
125
|
+
return body ? `${header}\n${body}` : header;
|
|
126
|
+
}
|
|
127
|
+
/** Test helper: company dir for isolation assertions. */
|
|
128
|
+
export function companyLocalDbDir(company, env) {
|
|
129
|
+
return resolveLocalDbDir(company, env);
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=sql.js.map
|
|
132
|
+
//# debugId=f9dc08da-ad30-5af4-94fb-b167d4299692
|
package/dist/main.d.ts
ADDED
package/dist/main.js
ADDED
|
@@ -0,0 +1,272 @@
|
|
|
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]="d089113e-52b9-5313-a256-63f054d8e72a")}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 { registerWorkersCommand } from "./commands/workers.js";
|
|
39
|
+
import { registerGroupGrantsCommand } from "./commands/group-grants.js";
|
|
40
|
+
import { registerFilesCommand } from "./commands/files.js";
|
|
41
|
+
import { registerFilesBrowseCommands } from "./commands/files-browse.js";
|
|
42
|
+
import { registerSkillCommand } from "./commands/skill.js";
|
|
43
|
+
import { registerMembersCommand } from "./commands/members.js";
|
|
44
|
+
import { registerPeopleCommand } from "./commands/people.js";
|
|
45
|
+
import { registerDmCommand } from "./commands/dm.js";
|
|
46
|
+
import { registerChannelsCommand } from "./commands/channels.js";
|
|
47
|
+
import { registerFeedbackCommand } from "./commands/feedback.js";
|
|
48
|
+
import { registerMeetingsCommand } from "./commands/meetings.js";
|
|
49
|
+
import { registerSourcesCommand } from "./commands/sources.js";
|
|
50
|
+
import { registerSignalsCommand } from "./commands/signals.js";
|
|
51
|
+
import { registerIntegrationsCommand } from "./commands/integrations.js";
|
|
52
|
+
import { registerReindexCommand } from "./commands/reindex.js";
|
|
53
|
+
import { registerRescueCommand } from "./commands/rescue.js";
|
|
54
|
+
import { registerMcpCommand } from "./commands/mcp-status.js";
|
|
55
|
+
import { registerCrmCommand } from "./commands/crm.js";
|
|
56
|
+
import { registerCompanyCommand } from "./commands/company.js";
|
|
57
|
+
import { registerAgentsCommand } from "./commands/agents.js";
|
|
58
|
+
import { registerOutpostsCommand } from "./commands/outposts.js";
|
|
59
|
+
import { registerDbCommand } from "./commands/db.js";
|
|
60
|
+
import { sanitizeArgv } from "./utils/feedback-diagnostics.js";
|
|
61
|
+
import { environmentalFsErrorMessage } from "./utils/environmental-error.js";
|
|
62
|
+
import { isEpipe } from "./utils/epipe.js";
|
|
63
|
+
import { isInterceptedProcessExit } from "./utils/intercepted-process-exit.js";
|
|
64
|
+
import { maybeWarnNewVersion, refreshVersionCache, } from "./utils/version-check.js";
|
|
65
|
+
import { enforceVersionGate, shouldSkipGate, } from "./utils/version-gate.js";
|
|
66
|
+
import { CLI_VERSION } from "./cli-version.js";
|
|
67
|
+
// Swallow EPIPE when a downstream reader (e.g. `source <(…)`, `| head`) closes
|
|
68
|
+
// the pipe early. This covers the ASYNC path — an 'error' event emitted on the
|
|
69
|
+
// stream. The SYNCHRONOUS path (a `write EPIPE` thrown straight out of
|
|
70
|
+
// console.log inside a command) is handled in the top-level catch below; both
|
|
71
|
+
// share `isEpipe` (HQ-6B).
|
|
72
|
+
const onPipeError = (err) => {
|
|
73
|
+
if (isEpipe(err)) {
|
|
74
|
+
process.exit(0);
|
|
75
|
+
}
|
|
76
|
+
throw err;
|
|
77
|
+
};
|
|
78
|
+
process.stdout.on("error", onPipeError);
|
|
79
|
+
process.stderr.on("error", onPipeError);
|
|
80
|
+
initSentry();
|
|
81
|
+
maybeWarnNewVersion();
|
|
82
|
+
const program = new Command();
|
|
83
|
+
program
|
|
84
|
+
.name("hq")
|
|
85
|
+
.description("HQ management CLI — modules, packages, and cloud sync")
|
|
86
|
+
.version(CLI_VERSION);
|
|
87
|
+
// Module management subcommand group
|
|
88
|
+
const modulesCmd = program
|
|
89
|
+
.command("modules")
|
|
90
|
+
.description("Module management commands");
|
|
91
|
+
registerAddCommand(modulesCmd);
|
|
92
|
+
registerSyncCommand(modulesCmd);
|
|
93
|
+
registerListCommand(modulesCmd);
|
|
94
|
+
registerUpdateCommand(modulesCmd);
|
|
95
|
+
// Package management subcommand group
|
|
96
|
+
const packagesCmd = program
|
|
97
|
+
.command("packages")
|
|
98
|
+
.description("Package management commands");
|
|
99
|
+
registerPackageInstallCommand(packagesCmd);
|
|
100
|
+
registerPackageRemoveCommand(packagesCmd);
|
|
101
|
+
registerPackageUpdateCommand(packagesCmd);
|
|
102
|
+
registerPackageListCommand(packagesCmd);
|
|
103
|
+
// Content-pack lifecycle (core/packages/hq-pack-*). Distinct from the registry
|
|
104
|
+
// `packages` system above. Available as both `hq packages packs …` (grouped)
|
|
105
|
+
// and `hq packs …` (top-level convenience).
|
|
106
|
+
registerPacksCommand(packagesCmd);
|
|
107
|
+
registerPacksCommand(program);
|
|
108
|
+
// Top-level shortcuts for package commands
|
|
109
|
+
// "hq install <slug>" = "hq packages install <slug>"
|
|
110
|
+
// "hq remove <slug>" = "hq packages remove <slug>"
|
|
111
|
+
registerPackageInstallCommand(program);
|
|
112
|
+
registerPackageRemoveCommand(program);
|
|
113
|
+
// Marketplace publish (top-level — packer + authenticated upload, US-004)
|
|
114
|
+
// "hq publish <skill-or-worker-path>" packages and submits a pack to the
|
|
115
|
+
// marketplace via POST /v1/listings.
|
|
116
|
+
registerPublishCommand(program);
|
|
117
|
+
// `hq creators apply` — request verified-creator access (required to publish).
|
|
118
|
+
registerCreatorsCommand(program);
|
|
119
|
+
// Cloud sync subcommand group
|
|
120
|
+
const syncCmd = program
|
|
121
|
+
.command("sync")
|
|
122
|
+
.description("Cloud sync commands — sync HQ to S3 for mobile access");
|
|
123
|
+
registerCloudCommands(syncCmd);
|
|
124
|
+
registerSyncModeCommand(syncCmd);
|
|
125
|
+
registerSyncNarrowCommand(syncCmd);
|
|
126
|
+
// Cloud provisioning subcommand group (entity + bucket + initial sync)
|
|
127
|
+
// Distinct from `hq sync` which assumes provisioning has already happened.
|
|
128
|
+
const cloudCmd = program
|
|
129
|
+
.command("cloud")
|
|
130
|
+
.description("Cloud commands — provision entities and manage cloud-backed companies");
|
|
131
|
+
registerCloudProvisionCommands(cloudCmd);
|
|
132
|
+
registerCloudDemoteCommands(cloudCmd);
|
|
133
|
+
// Team commands (top-level)
|
|
134
|
+
registerTeamSyncCommand(program);
|
|
135
|
+
// Auth commands (top-level — Cognito OAuth)
|
|
136
|
+
registerLoginCommand(program);
|
|
137
|
+
registerLogoutCommand(program);
|
|
138
|
+
registerWhoamiCommand(program);
|
|
139
|
+
registerAuthCommands(program);
|
|
140
|
+
// Secrets management (subcommand group — hq secrets set|get|list|delete|exec|generate-link|cache)
|
|
141
|
+
registerSecretsCommand(program);
|
|
142
|
+
// Vault databases (subcommand group — hq db status|sql|migrate|provision)
|
|
143
|
+
registerDbCommand(program);
|
|
144
|
+
// API key management (subcommand group — hq api-keys create|list|revoke)
|
|
145
|
+
registerApiKeysCommand(program);
|
|
146
|
+
// Schema-driven dev runner — hq run [options] -- <cmd>
|
|
147
|
+
registerRunCommand(program);
|
|
148
|
+
// Groups management (subcommand group — hq groups create|delete|add|remove|list|members)
|
|
149
|
+
registerGroupsCommand(program);
|
|
150
|
+
// Worker discovery + sharing (subcommand group — hq workers list|share)
|
|
151
|
+
registerWorkersCommand(program);
|
|
152
|
+
// Cross-company group grants (subcommand group —
|
|
153
|
+
// hq group-grants grant|revoke|outbound|inbound)
|
|
154
|
+
registerGroupGrantsCommand(program);
|
|
155
|
+
// Files ACL management (subcommand group — hq files share|unshare|acl)
|
|
156
|
+
// `registerFilesCommand` returns the `files` group so we can attach the
|
|
157
|
+
// browse-vs-sync subcommands (`hq files browse`/`cat`) onto the same group.
|
|
158
|
+
const filesCmd = registerFilesCommand(program);
|
|
159
|
+
registerFilesBrowseCommands(filesCmd);
|
|
160
|
+
// Skill collaboration loop (subcommand group — hq skill suggest|list-suggestions|review).
|
|
161
|
+
// A thin terminal front-end over the SAME wired hq-pro skill suggestion + merge
|
|
162
|
+
// routes the MCP (US-007) and console merge (US-009) surfaces use — no forked logic.
|
|
163
|
+
registerSkillCommand(program);
|
|
164
|
+
// Membership management (subcommand group — hq members invite|list|revoke)
|
|
165
|
+
registerMembersCommand(program);
|
|
166
|
+
// People directory (subcommand group — hq people list|search|resolve), reading
|
|
167
|
+
// the local companies/<co>/people store scoped to one company.
|
|
168
|
+
registerPeopleCommand(program);
|
|
169
|
+
registerDmCommand(program);
|
|
170
|
+
registerChannelsCommand(program);
|
|
171
|
+
// Onboarding (top-level — Cognito + vault-service provisioning)
|
|
172
|
+
registerOnboardCommand(program);
|
|
173
|
+
// Feedback (subcommand group — hq feedback bug|feature)
|
|
174
|
+
registerFeedbackCommand(program);
|
|
175
|
+
// Meetings (subcommand group — hq meetings list|get|search|transcript|notes)
|
|
176
|
+
registerMeetingsCommand(program);
|
|
177
|
+
// Sources read surface (subcommand group — hq sources list|get|channels|entities)
|
|
178
|
+
registerSourcesCommand(program);
|
|
179
|
+
// Signals read surface (subcommand group — hq signals list|get|types|entities)
|
|
180
|
+
registerSignalsCommand(program);
|
|
181
|
+
// Company-connected apps via the governed integration gateway
|
|
182
|
+
// (subcommand group — hq integrations list|tools|call|approve|reject)
|
|
183
|
+
registerIntegrationsCommand(program);
|
|
184
|
+
// Skill/personal-overlay mirroring + workers-registry regen. Invoked by the
|
|
185
|
+
// hq-core reindex hook shim (Stop / PostToolUse) and by sync()/rescue() after
|
|
186
|
+
// they change on-disk sources. Keeps a `master-sync` alias for one release.
|
|
187
|
+
// Implementation lives in @indigoai-us/hq-cloud.
|
|
188
|
+
registerReindexCommand(program);
|
|
189
|
+
// Drift-preserving HQ-core re-sync (top-level — `hq rescue`). CLI sibling of
|
|
190
|
+
// the HQ Sync app's "Update / Restore" pill; drives the same replace-rescue.sh
|
|
191
|
+
// shipped from @indigoai-us/hq-cloud.
|
|
192
|
+
registerRescueCommand(program);
|
|
193
|
+
// MCP pack observability (subcommand group — `hq mcp status`). Read-only
|
|
194
|
+
// provenance-based status across BOTH Claude + Codex runtimes (reads `_hqPack`
|
|
195
|
+
// off the configs, NOT linkStatus), with secret-redacted output + `--json`.
|
|
196
|
+
registerMcpCommand(program);
|
|
197
|
+
// Native CRM entity upsert (subcommand group — `hq crm entity upsert`). Wraps
|
|
198
|
+
// POST /crm/entities (the ontology write gate) so an authenticated company
|
|
199
|
+
// member can create/update canonical CRM entities in the company vault.
|
|
200
|
+
registerCrmCommand(program);
|
|
201
|
+
// Company settings (subcommand group — `hq company settings set`). Owner-only
|
|
202
|
+
// toggles for crmEnabled / ontologyEnabled via PUT /company-settings.
|
|
203
|
+
registerCompanyCommand(program);
|
|
204
|
+
// Cloud agent management (subcommand group — `hq agents …`). Rename, reconfigure,
|
|
205
|
+
// start/stop, and tear down a company's fleet agents via the hq-pro /v1/agents
|
|
206
|
+
// control plane — the same routes the web console's agents panel calls.
|
|
207
|
+
registerAgentsCommand(program);
|
|
208
|
+
// Personal Outpost management (subcommand group — `hq outposts …`). List, inspect,
|
|
209
|
+
// enable Codex on, refresh login for, and destroy your EC2 boxes via the hq-pro
|
|
210
|
+
// /outpost/* control plane.
|
|
211
|
+
registerOutpostsCommand(program);
|
|
212
|
+
export async function runCli() {
|
|
213
|
+
try {
|
|
214
|
+
Sentry.addBreadcrumb({
|
|
215
|
+
category: "command",
|
|
216
|
+
message: sanitizeArgv(process.argv.slice(2)).join(" "),
|
|
217
|
+
level: "info",
|
|
218
|
+
});
|
|
219
|
+
// Hard version gate: ask hq-pro whether this CLI is below the floor and
|
|
220
|
+
// auto-update if so (exits the process on update). Skipped for inspection
|
|
221
|
+
// flags (`--version`, `--help`) so users debugging a broken install can
|
|
222
|
+
// still introspect what they have. Silent on any failure — never blocks
|
|
223
|
+
// the CLI on a flaky network or hq-pro hiccup. See `utils/version-gate.ts`.
|
|
224
|
+
if (!shouldSkipGate(process.argv)) {
|
|
225
|
+
await enforceVersionGate();
|
|
226
|
+
}
|
|
227
|
+
await program.parseAsync();
|
|
228
|
+
}
|
|
229
|
+
catch (err) {
|
|
230
|
+
// A broken pipe (EPIPE) means the reader of `hq`'s output closed it early
|
|
231
|
+
// (`hq … | head`, `source <(hq …)`, a parent that exited). That is normal
|
|
232
|
+
// Unix behavior with no user-facing degradation — exit cleanly (0) and
|
|
233
|
+
// skip Sentry capture instead of shipping a fatal (HQ-6B). A synchronous
|
|
234
|
+
// `write EPIPE` thrown out of console.log lands here rather than on the
|
|
235
|
+
// stream 'error' listener above.
|
|
236
|
+
if (isEpipe(err)) {
|
|
237
|
+
process.exitCode = 0;
|
|
238
|
+
}
|
|
239
|
+
else if (isInterceptedProcessExit(err)) {
|
|
240
|
+
// A security/audit FUZZ harness replaced `process.exit` with a throw so it
|
|
241
|
+
// can keep exercising the binary. Commander calling `process.exit` for
|
|
242
|
+
// normal CLI control flow (e.g. an unknown command → exit 1) then surfaces
|
|
243
|
+
// here as that synthetic marker. It is a test-harness artifact, NOT an
|
|
244
|
+
// hq-cli defect — a real user's `process.exit` just exits, so nothing is
|
|
245
|
+
// thrown or captured. Skip Sentry capture (no signal, no user-facing
|
|
246
|
+
// degradation) and preserve the intended non-zero exit (HQ-CLI-3).
|
|
247
|
+
process.exitCode = 1;
|
|
248
|
+
}
|
|
249
|
+
else {
|
|
250
|
+
// A full disk / exhausted quota / read-only filesystem is the user's
|
|
251
|
+
// machine, not an HQ code defect. Surface a clear, actionable message and
|
|
252
|
+
// skip Sentry capture so one full disk doesn't flood the tracker with
|
|
253
|
+
// identical, unfixable crash reports (HQ-CLI-2). Genuine errors still go
|
|
254
|
+
// to Sentry and still exit 1.
|
|
255
|
+
const envMsg = environmentalFsErrorMessage(err);
|
|
256
|
+
if (envMsg) {
|
|
257
|
+
process.stderr.write(`hq: ${envMsg}\n`);
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
Sentry.captureException(err);
|
|
261
|
+
}
|
|
262
|
+
process.exitCode = 1;
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
finally {
|
|
266
|
+
// Release health: finalize the per-run session before the flush.
|
|
267
|
+
Sentry.endSession();
|
|
268
|
+
await Promise.allSettled([refreshVersionCache(), Sentry.flush(2000)]);
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
//# sourceMappingURL=main.js.map
|
|
272
|
+
//# debugId=d089113e-52b9-5313-a256-63f054d8e72a
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
* HQ_VAULT_API_URL — vault-service API Gateway URL
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
!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]="
|
|
22
|
+
!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]="f5342b2c-413d-5142-a44a-92788f273678")}catch(e){}}();
|
|
23
23
|
import * as fs from "fs";
|
|
24
24
|
import * as os from "os";
|
|
25
25
|
import * as path from "path";
|
|
@@ -43,7 +43,7 @@ export const DEFAULT_COGNITO = {
|
|
|
43
43
|
? process.env.HQ_COGNITO_IDENTITY_PROVIDER || undefined
|
|
44
44
|
: "Google",
|
|
45
45
|
};
|
|
46
|
-
export const DEFAULT_VAULT_API_URL = process.env.HQ_VAULT_API_URL ?? "https://hqapi.
|
|
46
|
+
export const DEFAULT_VAULT_API_URL = process.env.HQ_VAULT_API_URL ?? "https://hqapi.hq.computer";
|
|
47
47
|
/**
|
|
48
48
|
* Resolve the HQ tree root for cloud-aware subcommands (`hq sync`, `hq onboard`,
|
|
49
49
|
* `hq cloud …`, etc.).
|
|
@@ -375,4 +375,4 @@ export async function refreshCachedSession() {
|
|
|
375
375
|
}
|
|
376
376
|
}
|
|
377
377
|
//# sourceMappingURL=cognito-session.js.map
|
|
378
|
-
//# debugId=
|
|
378
|
+
//# debugId=f5342b2c-413d-5142-a44a-92788f273678
|
|
@@ -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>;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
|
|
2
|
-
!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]="
|
|
3
|
-
const DEFAULT_SANDBOX_RUNNER_URL = "https://hqapi.
|
|
2
|
+
!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]="590fc03f-67ee-5f1c-820f-d0bb5e256d78")}catch(e){}}();
|
|
3
|
+
const DEFAULT_SANDBOX_RUNNER_URL = "https://hqapi.hq.computer/sandbox";
|
|
4
|
+
const RETRYABLE_STATUS_CODES = new Set([408, 425, 429, 500, 502, 503, 504]);
|
|
5
|
+
const DEFAULT_RETRY_OPTIONS = {
|
|
6
|
+
maxAttempts: 8,
|
|
7
|
+
maxElapsedMs: 90_000,
|
|
8
|
+
baseDelayMs: 500,
|
|
9
|
+
maxDelayMs: 5_000,
|
|
10
|
+
};
|
|
4
11
|
function normalizeBaseUrl(baseUrl) {
|
|
5
12
|
return baseUrl.replace(/\/+$/, "");
|
|
6
13
|
}
|
|
@@ -40,15 +47,85 @@ function delay(ms) {
|
|
|
40
47
|
return Promise.resolve();
|
|
41
48
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
42
49
|
}
|
|
50
|
+
function getErrorMessage(error) {
|
|
51
|
+
if (error instanceof Error) {
|
|
52
|
+
return error.message;
|
|
53
|
+
}
|
|
54
|
+
if (typeof error === "string") {
|
|
55
|
+
return error;
|
|
56
|
+
}
|
|
57
|
+
return String(error);
|
|
58
|
+
}
|
|
59
|
+
function parseRetryAfterMs(value) {
|
|
60
|
+
if (!value)
|
|
61
|
+
return undefined;
|
|
62
|
+
const seconds = Number(value);
|
|
63
|
+
if (Number.isFinite(seconds) && seconds >= 0) {
|
|
64
|
+
return seconds * 1000;
|
|
65
|
+
}
|
|
66
|
+
const dateMs = Date.parse(value);
|
|
67
|
+
if (!Number.isNaN(dateMs)) {
|
|
68
|
+
return Math.max(0, dateMs - Date.now());
|
|
69
|
+
}
|
|
70
|
+
return undefined;
|
|
71
|
+
}
|
|
43
72
|
export class SandboxRunnerClient {
|
|
44
73
|
baseUrl;
|
|
45
74
|
fetchImpl;
|
|
75
|
+
retry;
|
|
76
|
+
sleep;
|
|
46
77
|
constructor(options = {}) {
|
|
47
78
|
this.baseUrl = normalizeBaseUrl(options.baseUrl ?? getSandboxRunnerBaseUrl());
|
|
48
79
|
this.fetchImpl = options.fetchImpl ?? fetch;
|
|
80
|
+
this.retry = { ...DEFAULT_RETRY_OPTIONS, ...options.retry };
|
|
81
|
+
this.sleep = options.sleep ?? delay;
|
|
82
|
+
}
|
|
83
|
+
async fetchWithRetry(url, init) {
|
|
84
|
+
const startedAt = Date.now();
|
|
85
|
+
let lastError = "unknown error";
|
|
86
|
+
let attempts = 0;
|
|
87
|
+
for (let attempt = 1; attempt <= this.retry.maxAttempts; attempt += 1) {
|
|
88
|
+
attempts = attempt;
|
|
89
|
+
try {
|
|
90
|
+
const res = await this.fetchImpl(url, init);
|
|
91
|
+
if (!RETRYABLE_STATUS_CODES.has(res.status)) {
|
|
92
|
+
return res;
|
|
93
|
+
}
|
|
94
|
+
lastError = `HTTP ${res.status} ${res.statusText}`.trim();
|
|
95
|
+
if (!this.shouldRetry(attempt, startedAt)) {
|
|
96
|
+
break;
|
|
97
|
+
}
|
|
98
|
+
await this.sleep(this.nextDelayMs(attempt, res));
|
|
99
|
+
}
|
|
100
|
+
catch (error) {
|
|
101
|
+
lastError = getErrorMessage(error);
|
|
102
|
+
if (!this.shouldRetry(attempt, startedAt)) {
|
|
103
|
+
break;
|
|
104
|
+
}
|
|
105
|
+
await this.sleep(this.nextDelayMs(attempt));
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
throw new Error(`Sandbox Runner did not respond after ${attempts} attempts ` +
|
|
109
|
+
`(cold start or transient network); last error: ${lastError}`);
|
|
110
|
+
}
|
|
111
|
+
shouldRetry(attempt, startedAt) {
|
|
112
|
+
if (attempt >= this.retry.maxAttempts) {
|
|
113
|
+
return false;
|
|
114
|
+
}
|
|
115
|
+
return Date.now() - startedAt < this.retry.maxElapsedMs;
|
|
116
|
+
}
|
|
117
|
+
nextDelayMs(attempt, res) {
|
|
118
|
+
const retryAfterMs = parseRetryAfterMs(res?.headers.get("Retry-After") ?? null);
|
|
119
|
+
if (retryAfterMs !== undefined) {
|
|
120
|
+
return Math.min(retryAfterMs, this.retry.maxDelayMs);
|
|
121
|
+
}
|
|
122
|
+
const exponential = this.retry.baseDelayMs * 2 ** (attempt - 1);
|
|
123
|
+
const capped = Math.min(exponential, this.retry.maxDelayMs);
|
|
124
|
+
const jitter = Math.floor(Math.random() * Math.max(1, capped * 0.25));
|
|
125
|
+
return Math.min(capped + jitter, this.retry.maxDelayMs);
|
|
49
126
|
}
|
|
50
127
|
async startJob(token, request) {
|
|
51
|
-
const res = await this.
|
|
128
|
+
const res = await this.fetchWithRetry(`${this.baseUrl}/jobs`, {
|
|
52
129
|
method: "POST",
|
|
53
130
|
headers: {
|
|
54
131
|
Authorization: `Bearer ${token}`,
|
|
@@ -75,7 +152,7 @@ export class SandboxRunnerClient {
|
|
|
75
152
|
};
|
|
76
153
|
}
|
|
77
154
|
async getJob(token, jobId) {
|
|
78
|
-
const res = await this.
|
|
155
|
+
const res = await this.fetchWithRetry(`${this.baseUrl}/jobs/${encodeURIComponent(jobId)}`, {
|
|
79
156
|
headers: { Authorization: `Bearer ${token}` },
|
|
80
157
|
});
|
|
81
158
|
const body = await parseJsonResponse(res);
|
|
@@ -97,10 +174,10 @@ export class SandboxRunnerClient {
|
|
|
97
174
|
if (job.status === "succeeded" || job.status === "failed") {
|
|
98
175
|
return job;
|
|
99
176
|
}
|
|
100
|
-
await
|
|
177
|
+
await this.sleep(intervalMs);
|
|
101
178
|
}
|
|
102
179
|
throw new Error(`Sandbox Runner job '${jobId}' did not finish before the poll limit.`);
|
|
103
180
|
}
|
|
104
181
|
}
|
|
105
182
|
//# sourceMappingURL=sandbox-runner-client.js.map
|
|
106
|
-
//# debugId=
|
|
183
|
+
//# debugId=590fc03f-67ee-5f1c-820f-d0bb5e256d78
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
+
declare function isKnownNoninteractiveStatusProbe(argv?: readonly string[]): boolean;
|
|
1
2
|
export declare function maybeWarnNewVersion(): void;
|
|
2
3
|
export declare function refreshVersionCache(): Promise<void>;
|
|
4
|
+
export declare const __test__: {
|
|
5
|
+
CACHE_TTL_MS: number;
|
|
6
|
+
isKnownNoninteractiveStatusProbe: typeof isKnownNoninteractiveStatusProbe;
|
|
7
|
+
};
|
|
8
|
+
export {};
|
|
3
9
|
//# sourceMappingURL=version-check.d.ts.map
|