@indigoai-us/hq-cli 5.345.109 → 5.345.111
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/CHANGELOG.md +30 -0
- package/dist/command-catalog.generated.d.ts +17 -5
- package/dist/command-catalog.generated.js +20 -5
- package/dist/commands/capacity.d.ts +26 -0
- package/dist/commands/capacity.js +64 -2
- package/dist/commands/core-policy.d.ts +4 -1
- package/dist/commands/core-policy.js +21 -43
- package/dist/commands/core.js +2 -7
- package/dist/commands/db-provision.js +31 -10
- package/dist/commands/db-remote-deps.js +12 -0
- package/dist/commands/db-sql.js +42 -9
- package/dist/commands/db-status.d.ts +2 -1
- package/dist/commands/db-status.js +33 -7
- package/dist/fast-scaffold.js +0 -12
- package/dist/hq-cloud-sync-runner/bin/sync-runner.js +1414 -923
- package/dist/hq-cloud-sync-runner/package.json +1 -1
- package/dist/lib/bot/brief-job.d.ts +22 -0
- package/dist/lib/bot/brief-job.js +38 -0
- package/dist/lib/bot/run.d.ts +10 -0
- package/dist/lib/bot/run.js +54 -9
- package/dist/lib/capacity/collectors/claude-oauth.d.ts +225 -2
- package/dist/lib/capacity/collectors/claude-oauth.js +1053 -43
- package/dist/lib/capacity/ledger.d.ts +10 -1
- package/dist/lib/capacity/ledger.js +8 -1
- package/dist/lib/capacity/project.js +3 -0
- package/dist/lib/db/control-plane.d.ts +22 -0
- package/dist/lib/db/control-plane.js +50 -0
- package/dist/lib/db/remote-engine.d.ts +9 -1
- package/dist/lib/db/remote-engine.js +32 -4
- package/dist/lib/flag-registry-worker-source.generated.d.ts +1 -1
- package/dist/lib/flag-registry-worker-source.generated.js +1 -1
- package/package.json +2 -2
- package/assets/scaffold/core/scripts/policy-age-report.sh +0 -199
- package/assets/scaffold/core/scripts/policy-retire.sh +0 -199
- package/assets/scaffold/core/scripts/read-policy-frontmatter.sh +0 -39
package/dist/commands/db-sql.js
CHANGED
|
@@ -8,10 +8,10 @@ import { Option } from "commander";
|
|
|
8
8
|
import chalk from "chalk";
|
|
9
9
|
import fs from "node:fs";
|
|
10
10
|
import { safeErrorMessage } from "../lib/db/redact.js";
|
|
11
|
-
import { formatRemoteResults, openRemoteAppConnection, runRemoteSql, } from "../lib/db/remote-engine.js";
|
|
11
|
+
import { formatRemoteResults, openRemoteAppConnection, openRemoteSessionConnection, runRemoteSql, } from "../lib/db/remote-engine.js";
|
|
12
12
|
import { formatSqlResult, runLocalSql } from "../lib/db/sql.js";
|
|
13
13
|
import { isPlanGateError } from "../utils/plan-gate-error.js";
|
|
14
|
-
import { defaultRemoteDeps, describeRemoteError, remoteEngineDeps, resolveAppId, } from "./db-remote-deps.js";
|
|
14
|
+
import { defaultRemoteDeps, controlPlaneClient, describeRemoteError, remoteEngineDeps, resolveAppId, } from "./db-remote-deps.js";
|
|
15
15
|
import { describeSessionGap } from "./db-dump.js";
|
|
16
16
|
function readSqlArg(sqlArgs, stdinFlag) {
|
|
17
17
|
if (stdinFlag || sqlArgs.length === 0) {
|
|
@@ -24,8 +24,9 @@ function readSqlArg(sqlArgs, stdinFlag) {
|
|
|
24
24
|
}
|
|
25
25
|
export function registerDbSqlCommand(db, remoteDepsFactory = defaultRemoteDeps) {
|
|
26
26
|
db.command("sql")
|
|
27
|
-
.description("Run SQL against
|
|
28
|
-
.
|
|
27
|
+
.description("Run read-only SQL against a company or personal database; use --write for changes")
|
|
28
|
+
.option("--company <slug>", "Company slug (tenant scope)")
|
|
29
|
+
.option("--personal", "Run against your personal remote database")
|
|
29
30
|
.option("--app <app>", "Run against this app's remote database (app id, name or subdomain)")
|
|
30
31
|
.option("--write", "Allow write/DDL statements (discouraged for ad-hoc DDL)", false)
|
|
31
32
|
.addOption(new Option("--remote", "Remote SQL is not available in this CLI build yet; local queries work without --remote").hideHelp())
|
|
@@ -38,8 +39,26 @@ export function registerDbSqlCommand(db, remoteDepsFactory = defaultRemoteDeps)
|
|
|
38
39
|
.action(async (sqlParts, opts) => {
|
|
39
40
|
try {
|
|
40
41
|
const company = String(opts.company ?? "").trim();
|
|
41
|
-
if (
|
|
42
|
-
console.error(chalk.red("Error: --
|
|
42
|
+
if (opts.personal && opts.company !== undefined) {
|
|
43
|
+
console.error(chalk.red("Error: --personal cannot be used with --company"));
|
|
44
|
+
process.exitCode = 1;
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
if (opts.personal) {
|
|
48
|
+
const conflicts = [
|
|
49
|
+
opts.app !== undefined && "--app",
|
|
50
|
+
!!opts.remote && "--remote",
|
|
51
|
+
opts.dbPath !== undefined && "--db-path",
|
|
52
|
+
!!opts.allowCrossCompanyPath && "--allow-cross-company-path",
|
|
53
|
+
].filter(Boolean);
|
|
54
|
+
if (conflicts.length > 0) {
|
|
55
|
+
console.error(chalk.red(`Error: --personal cannot be used with ${conflicts.join(", ")}`));
|
|
56
|
+
process.exitCode = 1;
|
|
57
|
+
return;
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (!opts.personal && !company) {
|
|
61
|
+
console.error(chalk.red("error: required option '--company <slug>' not specified"));
|
|
43
62
|
process.exitCode = 1;
|
|
44
63
|
return;
|
|
45
64
|
}
|
|
@@ -50,8 +69,12 @@ export function registerDbSqlCommand(db, remoteDepsFactory = defaultRemoteDeps)
|
|
|
50
69
|
}
|
|
51
70
|
const sql = readSqlArg(sqlParts, !!opts.stdin).trim();
|
|
52
71
|
const format = opts.format === "table" ? "table" : "jsonl";
|
|
72
|
+
if (opts.personal) {
|
|
73
|
+
await runPersonalRemote(remoteDepsFactory(), sql, !!opts.write, format);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
53
76
|
if (opts.app) {
|
|
54
|
-
await runRemote(remoteDepsFactory(), company, opts.app, sql, !!opts.write);
|
|
77
|
+
await runRemote(remoteDepsFactory(), company, opts.app, sql, !!opts.write, format);
|
|
55
78
|
return;
|
|
56
79
|
}
|
|
57
80
|
const result = runLocalSql({
|
|
@@ -73,7 +96,17 @@ export function registerDbSqlCommand(db, remoteDepsFactory = defaultRemoteDeps)
|
|
|
73
96
|
}
|
|
74
97
|
});
|
|
75
98
|
}
|
|
76
|
-
async function
|
|
99
|
+
async function runPersonalRemote(deps, sql, write, format) {
|
|
100
|
+
const session = await controlPlaneClient(deps).personalSession();
|
|
101
|
+
const conn = await openRemoteSessionConnection(remoteEngineDeps(deps), session, (schema) => schema === "personal");
|
|
102
|
+
try {
|
|
103
|
+
console.log(formatRemoteResults(await runRemoteSql(conn, sql, write), format));
|
|
104
|
+
}
|
|
105
|
+
finally {
|
|
106
|
+
await conn.close();
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
async function runRemote(deps, company, app, sql, write, format) {
|
|
77
110
|
const resolved = await deps.resolveCompany(company);
|
|
78
111
|
const appId = await resolveAppId(deps, resolved.companySlug, app);
|
|
79
112
|
const conn = await openRemoteAppConnection(remoteEngineDeps(deps), {
|
|
@@ -81,7 +114,7 @@ async function runRemote(deps, company, app, sql, write) {
|
|
|
81
114
|
appId,
|
|
82
115
|
});
|
|
83
116
|
try {
|
|
84
|
-
console.log(formatRemoteResults(await runRemoteSql(conn, sql, write)));
|
|
117
|
+
console.log(formatRemoteResults(await runRemoteSql(conn, sql, write), format));
|
|
85
118
|
}
|
|
86
119
|
finally {
|
|
87
120
|
await conn.close();
|
|
@@ -3,5 +3,6 @@
|
|
|
3
3
|
* Optionally reports remote tier when control plane returns a binding (US-009).
|
|
4
4
|
*/
|
|
5
5
|
import { Command } from "commander";
|
|
6
|
-
|
|
6
|
+
import { type DbRemoteCommandDeps } from "./db-remote-deps.js";
|
|
7
|
+
export declare function registerDbStatusCommand(db: Command, depsFactory?: () => DbRemoteCommandDeps): void;
|
|
7
8
|
//# sourceMappingURL=db-status.d.ts.map
|
|
@@ -5,21 +5,47 @@
|
|
|
5
5
|
import chalk from "chalk";
|
|
6
6
|
import { ControlPlaneDbClient } from "../lib/db/control-plane.js";
|
|
7
7
|
import { ensureAndStatusLocalDb, formatLocalDbStatus, } from "../lib/db/local.js";
|
|
8
|
-
|
|
8
|
+
import { safeErrorMessage } from "../lib/db/redact.js";
|
|
9
|
+
import { controlPlaneClient, defaultRemoteDeps, describeRemoteError, } from "./db-remote-deps.js";
|
|
10
|
+
export function registerDbStatusCommand(db, depsFactory = defaultRemoteDeps) {
|
|
9
11
|
db.command("status")
|
|
10
|
-
.description("Show local
|
|
11
|
-
.
|
|
12
|
+
.description("Show company local/remote status or your personal database status")
|
|
13
|
+
.option("--company <slug>", "Company slug (tenant scope)")
|
|
14
|
+
.option("--personal", "Show your personal database status")
|
|
12
15
|
.option("--home <path>", "Override home directory for local DB root (tests / advanced only)")
|
|
13
16
|
.option("--remote", "Also query control plane for remote tier status (requires auth)", false)
|
|
14
17
|
.option("--company-uid <uid>", "Company uid for remote status (with --remote)")
|
|
15
18
|
.action(async (opts) => {
|
|
16
19
|
try {
|
|
17
20
|
const company = String(opts.company ?? "").trim();
|
|
18
|
-
if (
|
|
19
|
-
console.error(chalk.red("Error: --
|
|
21
|
+
if (opts.personal && opts.company !== undefined) {
|
|
22
|
+
console.error(chalk.red("Error: --personal cannot be used with --company"));
|
|
20
23
|
process.exitCode = 1;
|
|
21
24
|
return;
|
|
22
25
|
}
|
|
26
|
+
if (opts.personal && (opts.remote || opts.companyUid !== undefined)) {
|
|
27
|
+
console.error(chalk.red("Error: --personal cannot be used with --remote or --company-uid"));
|
|
28
|
+
process.exitCode = 1;
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
if (!opts.personal && !company) {
|
|
32
|
+
console.error(chalk.red("error: required option '--company <slug>' not specified"));
|
|
33
|
+
process.exitCode = 1;
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
if (opts.personal) {
|
|
37
|
+
const remote = await controlPlaneClient(depsFactory()).personalStatus();
|
|
38
|
+
if (!remote.remote) {
|
|
39
|
+
console.log("remote: (none)");
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
console.log(`remote: ${remote.remote.status}`);
|
|
43
|
+
console.log(`remoteEngine: ${remote.remote.engineId}`);
|
|
44
|
+
console.log(`remoteRegion: ${remote.remote.region}`);
|
|
45
|
+
console.log(`remoteResourceArn: ${remote.remote.resourceArn}`);
|
|
46
|
+
}
|
|
47
|
+
return;
|
|
48
|
+
}
|
|
23
49
|
const status = ensureAndStatusLocalDb(company, opts.home ? { home: opts.home } : undefined);
|
|
24
50
|
// Never print remote connection material.
|
|
25
51
|
console.log(formatLocalDbStatus(status));
|
|
@@ -54,7 +80,7 @@ export function registerDbStatusCommand(db) {
|
|
|
54
80
|
}
|
|
55
81
|
}
|
|
56
82
|
catch (e) {
|
|
57
|
-
const msg = e
|
|
83
|
+
const msg = describeRemoteError(e) ?? safeErrorMessage(e);
|
|
58
84
|
console.log(`remote: error (${msg})`);
|
|
59
85
|
}
|
|
60
86
|
}
|
|
@@ -63,7 +89,7 @@ export function registerDbStatusCommand(db) {
|
|
|
63
89
|
}
|
|
64
90
|
}
|
|
65
91
|
catch (error) {
|
|
66
|
-
console.error(chalk.red("Error:"), error
|
|
92
|
+
console.error(chalk.red("Error:"), describeRemoteError(error) ?? safeErrorMessage(error));
|
|
67
93
|
process.exitCode = 1;
|
|
68
94
|
}
|
|
69
95
|
});
|
package/dist/fast-scaffold.js
CHANGED
|
@@ -372,11 +372,7 @@ export const FAST_SCAFFOLD_SCRIPTS = [
|
|
|
372
372
|
modulePath: "./commands/core-policy.js",
|
|
373
373
|
exportName: "runPolicyFast",
|
|
374
374
|
flagKey: "hq-core-native-fast-route",
|
|
375
|
-
familyFlagKey: "core-native-policy",
|
|
376
|
-
asset: "core/scripts/read-policy-frontmatter.sh",
|
|
377
375
|
root: "cwd",
|
|
378
|
-
shellCwd: "caller",
|
|
379
|
-
shellHqRoot: "none",
|
|
380
376
|
},
|
|
381
377
|
{
|
|
382
378
|
name: "policy age-report",
|
|
@@ -384,11 +380,7 @@ export const FAST_SCAFFOLD_SCRIPTS = [
|
|
|
384
380
|
modulePath: "./commands/core-policy.js",
|
|
385
381
|
exportName: "runPolicyFast",
|
|
386
382
|
flagKey: "hq-core-native-fast-route",
|
|
387
|
-
familyFlagKey: "core-native-policy",
|
|
388
|
-
asset: "core/scripts/policy-age-report.sh",
|
|
389
383
|
root: "live",
|
|
390
|
-
shellCwd: "caller",
|
|
391
|
-
shellHqRoot: "live",
|
|
392
384
|
},
|
|
393
385
|
{
|
|
394
386
|
name: "policy retire",
|
|
@@ -396,11 +388,7 @@ export const FAST_SCAFFOLD_SCRIPTS = [
|
|
|
396
388
|
modulePath: "./commands/core-policy.js",
|
|
397
389
|
exportName: "runPolicyFast",
|
|
398
390
|
flagKey: "hq-core-native-fast-route",
|
|
399
|
-
familyFlagKey: "core-native-policy",
|
|
400
|
-
asset: "core/scripts/policy-retire.sh",
|
|
401
391
|
root: "live",
|
|
402
|
-
shellCwd: "caller",
|
|
403
|
-
shellHqRoot: "live",
|
|
404
392
|
},
|
|
405
393
|
{
|
|
406
394
|
name: "knowledge-prefs",
|